Previous 15994 Revisions Next

r11509 Wednesday 11th May, 2011 at 08:19:49 UTC by Miodrag Milanović
Sync with MAME (r12501) (no whatsnew)
[src/emu]crsshair.c devcpu.h devintrf.c devintrf.h devlegcy.h driver.h emu.h emutempl.h info.c inptport.c inptport.h machine.c machine.h memory.c tokenize.h ui.c uimenu.c validity.c
[src/emu/machine]generic.c
[src/mame]mame.lst
[src/mame/audio]cchasm.c gorf.c gottlieb.c jedi.c wow.c
[src/mame/drivers]8080bw.c acefruit.c alg.c arcadia.c arkanoid.c artmagic.c asteroid.c astinvad.c astrocde.c astrocdh.c astrof.c battlex.c bfm_sc2.c brkthru.c btime.c btoads.c bwidow.c bwing.c bzone.c calomega.c cave.c ccastles.c cd32.c cdi.c champbas.c cheekyms.c cidelsa.c cinemat.c cloud9.c cntsteer.c cop01.c copsnrob.c cosmic.c crbaloon.c crshrace.c dacholer.c dcheese.c ddayjlc.c ddenlovr.c ddragon.c dlair.c dorachan.c dreamwld.c dynax.c enigma2.c equites.c esripsys.c exerion.c exidy.c exidy440.c exprraid.c fantland.c fcombat.c fgoal.c firefox.c firetrk.c flstory.c fromanc2.c gaelco3d.c galaga.c galastrm.c galaxi.c galaxian.c galaxold.c galdrvr.c galpanic.c gottlieb.c gradius3.c groundfx.c gstream.c guab.c gunbustr.c gundealr.c halleys.c hexion.c homerun.c igs009.c igs011.c igspoker.c inufuku.c itech32.c itech8.c jack.c jackie.c jpmsys5.c kopunch.c ksys573.c ladybug.c lasso.c lethalj.c limenko.c m10.c m14.c m92.c madalien.c mainsnk.c maxaflex.c meadows.c merit.c metro.c mhavoc.c midyunit.c midzeus.c missile.c model2.c mpu4.c ms32.c msx.c multfish.c multigam.c mw8080bw.c mystston.c namcos22.c naughtyb.c neogeo.c ng_aes.c niyanpai.c nova2001.c pastelg.c peplus.c pirates.c polepos.c policetr.c progolf.c psikyo.c psikyo4.c punchout.c pzletime.c qdrmfgp.c r2dtank.c redclash.c renegade.c rgum.c rpunch.c scobra.c scramble.c segag80r.c segag80v.c seibuspi.c sfbonus.c sg1000.c shootout.c skyfox.c snes.c snk.c snk6502.c spoker.c sprint4.c ssingles.c ssozumo.c stactics.c starshp1.c statriv2.c superwng.c suprnova.c suprridr.c system1.c taito_f3.c taitosj.c tankbatt.c tempest.c tetrisp2.c thayers.c toaplan1.c toaplan2.c tryout.c ultratnk.c ultrsprt.c undrfire.c vicdual.c welltris.c wolfpack.c wwfsstar.c wwfwfest.c xain.c xmen.c xxmissio.c yiear.c zaccaria.c zaxxon.c zn.c
[src/mame/machine]amiga.c amigakbd.c arkanoid.c balsente.c cdislave.c gaelco2.c galaxold.c jvs13551.c jvs13551.h mhavoc.c micro3d.c playch10.c scramble.c segasms.c starwars.c williams.c
[src/mame/video]konicdev.c phoenix.c stactics.c
[src/mess/drivers]abc80.c amstrad.c apple2.c aquarius.c atom.c beta.c c80.c cosmicos.c crvision.c elf.c ex800.c exp85.c fidelz80.c geneve.c gizmondo.c hp49gp.c junior.c kim1.c lc80.c mpf1.c nakajies.c ngp.c palm.c pc.c pc8001.c pc8801.c pc9801.c pecom.c pockstat.c poly880.c psion.c px4.c qx10.c rex6000.c ssem.c studio2.c ti89.c ti99_4x.c tmc1800.c trs80m2.c v1050.c vidbrain.c vip.c x07.c x1.c
[src/mess/includes]genpc.h
[src/mess/machine]abc77.c abc77.h abc99.c abc99.h cbmipt.c coco.c comx35.c comxpl80.c comxpl80.h genpc.c lux10828.c lux10828.h lux21046.c lux21046.h z80ne.c

src/mame/mame.lst
r11508r11509
19241924arkatour      // ??? (c) 1987 Taito America Corporation + Romstar license (US)
19251925tetrsark      // ??? (c) D.R.Korea
19261926hexa         // D. R. Korea
1927brixian         // (c) 1993 Cheil Computer System
19271928sqix         // B03 1987
19281929sqixr1         // B03 1987
19291930sqixu         // B03 1987
r11508r11509
86288629spk116it      // (c) 199? IGS
86298630jackie         // (c) 1993 IGS
86308631pktet346      // (c) 199? IGS
8632cpokerx         // (c) 1993 IGS
86318633chleague      // (c) 199? IGS
86328634chleagul      // (c) 199? IGS
86338635number10      // (c) IGS (Board labeled Playmark Srl)
r11508r11509
95049506pipeline      // (c) 1990 Daehyun Electronics
95059507ttchamp
95069508ttchampa
9509baryon         // (c) 1997 SemiCom
95079510dreamwld      // (c) 2000 SemiCom
95089511cybertnk      // (c) 1990 Coreland
95099512cubeqst         // (c) 1983 Simutrek Inc.
r11508r11509
1072010723m_gmball
1072110724m_grtecp      // 199?
1072210725m_blsbys      // BwB
10723//m_frkstn
10726m_frkstn
1072410727
1072510728// MPU5
1072610729m_honmon
src/mame/audio/gorf.c
r11508r11509
177177
178178CUSTOM_INPUT( gorf_speech_status_r )
179179{
180   device_t *samples = field->port->machine().device("samples");
180   device_t *samples = field->machine().device("samples");
181181   return !sample_playing(samples, 0);
182182}
src/mame/audio/gottlieb.c
r11508r11509
466466
467467static CUSTOM_INPUT( speech_drq_custom_r )
468468{
469   return sp0250_drq_r(field->port->machine().device("spsnd"));
469   return sp0250_drq_r(field->machine().device("spsnd"));
470470}
471471
472472
src/mame/audio/jedi.c
r11508r11509
103103
104104CUSTOM_INPUT( jedi_audio_comm_stat_r )
105105{
106   jedi_state *state = field->port->machine().driver_data<jedi_state>();
106   jedi_state *state = field->machine().driver_data<jedi_state>();
107107   return *state->m_audio_comm_stat >> 6;
108108}
109109
src/mame/audio/cchasm.c
r11508r11509
2424
2525INPUT_CHANGED( cchasm_set_coin_flag )
2626{
27   cchasm_state *state = field->port->machine().driver_data<cchasm_state>();
27   cchasm_state *state = field->machine().driver_data<cchasm_state>();
2828   if (!newval && !state->m_coin_flag)
2929   {
3030      state->m_coin_flag = 1;
src/mame/audio/wow.c
r11508r11509
171171
172172CUSTOM_INPUT( wow_speech_status_r )
173173{
174   device_t *samples = field->port->machine().device("samples");
174   device_t *samples = field->machine().device("samples");
175175   return !sample_playing(samples, 0);
176176}
src/mame/machine/mhavoc.c
r11508r11509
213213
214214CUSTOM_INPUT( tms5220_r )
215215{
216   return tms5220_readyq_r(field->port->machine().device("tms")) ? 1 : 0;
216   return tms5220_readyq_r(field->machine().device("tms")) ? 1 : 0;
217217}
218218
219219CUSTOM_INPUT( mhavoc_bit67_r )
220220{
221   mhavoc_state *state = field->port->machine().driver_data<mhavoc_state>();
221   mhavoc_state *state = field->machine().driver_data<mhavoc_state>();
222222   const char *tag1 = (const char *)param;
223223   const char *tag2 = tag1 + strlen(tag1) + 1;
224   return input_port_read(field->port->machine(), state->m_player_1 ? tag2 : tag1) & 0x03;
224   return input_port_read(field->machine(), state->m_player_1 ? tag2 : tag1) & 0x03;
225225}
226226
227227CUSTOM_INPUT( gamma_rcvd_r )
228228{
229   mhavoc_state *state = field->port->machine().driver_data<mhavoc_state>();
229   mhavoc_state *state = field->machine().driver_data<mhavoc_state>();
230230   /* Gamma rcvd flag */
231231   return state->m_gamma_rcvd;
232232}
233233
234234CUSTOM_INPUT( gamma_xmtd_r )
235235{
236   mhavoc_state *state = field->port->machine().driver_data<mhavoc_state>();
236   mhavoc_state *state = field->machine().driver_data<mhavoc_state>();
237237   /* Gamma xmtd flag */
238238   return state->m_gamma_xmtd;
239239}
240240
241241CUSTOM_INPUT( alpha_rcvd_r )
242242{
243   mhavoc_state *state = field->port->machine().driver_data<mhavoc_state>();
243   mhavoc_state *state = field->machine().driver_data<mhavoc_state>();
244244   /* Alpha rcvd flag */
245245   return (state->m_has_gamma_cpu && state->m_alpha_rcvd);
246246}
247247
248248CUSTOM_INPUT( alpha_xmtd_r )
249249{
250   mhavoc_state *state = field->port->machine().driver_data<mhavoc_state>();
250   mhavoc_state *state = field->machine().driver_data<mhavoc_state>();
251251   /* Alpha xmtd flag */
252252   return (state->m_has_gamma_cpu && state->m_alpha_xmtd);
253253}
src/mame/machine/balsente.c
r11508r11509
11101110
11111111CUSTOM_INPUT( nstocker_bits_r )
11121112{
1113   balsente_state *state = field->port->machine().driver_data<balsente_state>();
1113   balsente_state *state = field->machine().driver_data<balsente_state>();
11141114   return state->m_nstocker_bits;
11151115}
11161116
src/mame/machine/amiga.c
r11508r11509
413413
414414CUSTOM_INPUT( amiga_joystick_convert )
415415{
416   UINT8 bits = input_port_read(field->port->machine(), (const char *)param);
416   UINT8 bits = input_port_read(field->machine(), (const char *)param);
417417   int up = (bits >> 0) & 1;
418418   int down = (bits >> 1) & 1;
419419   int left = (bits >> 2) & 1;
src/mame/machine/cdislave.c
r11508r11509
119119
120120INPUT_CHANGED( cdislave_device::mouse_update )
121121{
122    cdislave_device *slave = static_cast<cdislave_device *>(field->port->machine().device("slave"));
122    cdislave_device *slave = static_cast<cdislave_device *>(field->machine().device("slave"));
123123    slave->perform_mouse_update();
124124}
125125
src/mame/machine/amigakbd.c
r11508r11509
6868   /* Special case Page UP, which we will use as Action Replay button */
6969   if ( (index == 3) && ( delta & 0x80000000 ) && ( newvalue & 0x80000000 ) )
7070   {
71      const amiga_machine_interface *amiga_intf = amiga_get_interface(field->port->machine());
71      const amiga_machine_interface *amiga_intf = amiga_get_interface(field->machine());
7272
7373      if ( amiga_intf != NULL && amiga_intf->nmi_callback )
7474      {
75         (*amiga_intf->nmi_callback)(field->port->machine());
75         (*amiga_intf->nmi_callback)(field->machine());
7676      }
7777   }
7878   else
r11508r11509
9696      /* if the buffer was empty and we have new data, start a timer to send the keystrokes */
9797      if ( key_buf_was_empty && ( kbd.buf_pos != kbd.cur_pos ) )
9898      {
99         kbd.timer->adjust(field->port->machine().primary_screen->frame_period() / 4);
99         kbd.timer->adjust(field->machine().primary_screen->frame_period() / 4);
100100      }
101101   }
102102}
src/mame/machine/micro3d.c
r11508r11509
545545
546546CUSTOM_INPUT( botssa_hwchk_r )
547547{
548   micro3d_state *state = field->port->machine().driver_data<micro3d_state>();
548   micro3d_state *state = field->machine().driver_data<micro3d_state>();
549549
550550   return state->m_botssa_latch;
551551}
src/mame/machine/playch10.c
r11508r11509
9393
9494CUSTOM_INPUT( pc10_int_detect_r )
9595{
96   playch10_state *state = field->port->machine().driver_data<playch10_state>();
96   playch10_state *state = field->machine().driver_data<playch10_state>();
9797   return ~state->m_pc10_int_detect & 1;
9898}
9999
src/mame/machine/scramble.c
r11508r11509
4343                       0x2b, 0x2a, 0x28, 0x29, 0x09, 0x08, 0x0a, 0x0b,
4444                       0x0f, 0x0e, 0x0c, 0x0d, 0x2d, 0x2c, 0x2e, 0x2f,
4545                       0x27, 0x26, 0x24, 0x25, 0x05, 0x04, 0x06, 0x07 };
46   UINT8 val = input_port_read(field->port->machine(), (const char *)param);
46   UINT8 val = input_port_read(field->machine(), (const char *)param);
4747
4848   return remap[val >> 2];
4949}
src/mame/machine/segasms.c
r11508r11509
319319
320320INPUT_CHANGED( lgun1_changed )
321321{
322   sms_state *state = field->port->machine().driver_data<sms_state>();
322   sms_state *state = field->machine().driver_data<sms_state>();
323323   if (!state->m_lphaser_1_timer ||
324      (input_port_read_safe(field->port->machine(), "CTRLSEL", 0x00) & 0x0f) != 0x01)
324      (input_port_read_safe(field->machine(), "CTRLSEL", 0x00) & 0x0f) != 0x01)
325325      return;
326326
327327   if (newval != oldval)
328      lphaser1_sensor_check(field->port->machine());
328      lphaser1_sensor_check(field->machine());
329329}
330330
331331INPUT_CHANGED( lgun2_changed )
332332{
333   sms_state *state = field->port->machine().driver_data<sms_state>();
333   sms_state *state = field->machine().driver_data<sms_state>();
334334   if (!state->m_lphaser_2_timer ||
335      (input_port_read_safe(field->port->machine(), "CTRLSEL", 0x00) & 0xf0) != 0x10)
335      (input_port_read_safe(field->machine(), "CTRLSEL", 0x00) & 0xf0) != 0x10)
336336      return;
337337
338338   if (newval != oldval)
339      lphaser2_sensor_check(field->port->machine());
339      lphaser2_sensor_check(field->machine());
340340}
341341
342342
src/mame/machine/gaelco2.c
r11508r11509
223223
224224CUSTOM_INPUT( wrally2_analog_bit_r )
225225{
226   gaelco2_state *state = field->port->machine().driver_data<gaelco2_state>();
226   gaelco2_state *state = field->machine().driver_data<gaelco2_state>();
227227   int which = (FPTR)param;
228228   return (state->m_analog_ports[which] >> 7) & 0x01;
229229}
src/mame/machine/arkanoid.c
r11508r11509
106106
107107CUSTOM_INPUT( arkanoid_68705_input_r )
108108{
109   arkanoid_state *state = field->port->machine().driver_data<arkanoid_state>();
109   arkanoid_state *state = field->machine().driver_data<arkanoid_state>();
110110   int res = 0;
111111
112112   /* bit 0x40 of comes from the sticky bit */
r11508r11509
122122
123123CUSTOM_INPUT( arkanoid_input_mux )
124124{
125   arkanoid_state *state = field->port->machine().driver_data<arkanoid_state>();
125   arkanoid_state *state = field->machine().driver_data<arkanoid_state>();
126126   const char *tag1 = (const char *)param;
127127   const char *tag2 = tag1 + strlen(tag1) + 1;
128   return input_port_read(field->port->machine(), (state->m_paddle_select == 0) ? tag1 : tag2);
128   return input_port_read(field->machine(), (state->m_paddle_select == 0) ? tag1 : tag2);
129129}
130130
131131/*
src/mame/machine/galaxold.c
r11508r11509
257257
258258CUSTOM_INPUT( _4in1_fake_port_r )
259259{
260   galaxold_state *state = field->port->machine().driver_data<galaxold_state>();
260   galaxold_state *state = field->machine().driver_data<galaxold_state>();
261261   static const char *const portnames[] = { "FAKE1", "FAKE2", "FAKE3", "FAKE4" };
262262   int bit_mask = (FPTR)param;
263263
264   return (input_port_read(field->port->machine(), portnames[state->m__4in1_bank]) & bit_mask) ? 0x01 : 0x00;
264   return (input_port_read(field->machine(), portnames[state->m__4in1_bank]) & bit_mask) ? 0x01 : 0x00;
265265}
266266
267267#ifdef UNUSED_FUNCTION
src/mame/machine/jvs13551.c
r11508r11509
22
33const device_type SEGA_837_13551 = &device_creator<sega_837_13551>;
44
5static WRITE_LINE_DEVICE_HANDLER(coin_1_w)
5WRITE_LINE_DEVICE_HANDLER(jvs13551_coin_1_w)
66{
77   if(state)
88      downcast<sega_837_13551 *>(device)->inc_coin(0);
99}
1010
11static WRITE_LINE_DEVICE_HANDLER(coin_2_w)
11WRITE_LINE_DEVICE_HANDLER(jvs13551_coin_2_w)
1212{
1313   if(state)
1414      downcast<sega_837_13551 *>(device)->inc_coin(1);
r11508r11509
1616
1717static INPUT_PORTS_START(sega_837_13551_coins)
1818   PORT_START("COINS")
19   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_COIN1) PORT_WRITE_LINE_DEVICE(DEVICE_SELF, coin_1_w)
20   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_COIN2) PORT_WRITE_LINE_DEVICE(DEVICE_SELF, coin_2_w)
19   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_COIN1) PORT_WRITE_LINE_DEVICE(DEVICE_SELF, jvs13551_coin_1_w)
20   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_COIN2) PORT_WRITE_LINE_DEVICE(DEVICE_SELF, jvs13551_coin_2_w)
2121INPUT_PORTS_END
2222
2323void sega_837_13551::static_set_port_tag(device_t &device, int port, const char *tag)
r11508r11509
2626   ctrl.port_tag[port] = tag;
2727}
2828
29const input_port_token *sega_837_13551::device_input_ports() const
29ioport_constructor sega_837_13551::device_input_ports() const
3030{
3131   return INPUT_PORTS_NAME(sega_837_13551_coins);
3232}
src/mame/machine/jvs13551.h
r11508r11509
2626public:
2727   sega_837_13551(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
2828   static void static_set_port_tag(device_t &device, int port, const char *tag);
29   const input_port_token *device_input_ports() const;
29   ioport_constructor device_input_ports() const;
3030
3131   void inc_coin(int coin);
3232
src/mame/machine/williams.c
r11508r11509
577577
578578CUSTOM_INPUT( williams_mux_r )
579579{
580   williams_state *state = field->port->machine().driver_data<williams_state>();
580   williams_state *state = field->machine().driver_data<williams_state>();
581581   const char *tag = (const char *)param;
582582
583583   if (state->m_port_select != 0)
584584      tag += strlen(tag) + 1;
585585
586   return input_port_read(field->port->machine(), tag);
586   return input_port_read(field->machine(), tag);
587587}
588588
589589/*
src/mame/machine/starwars.c
r11508r11509
110110
111111CUSTOM_INPUT( matrix_flag_r )
112112{
113   starwars_state *state = field->port->machine().driver_data<starwars_state>();
113   starwars_state *state = field->machine().driver_data<starwars_state>();
114114   /* set the matrix processor flag */
115115   return state->m_math_run ? 1 : 0;
116116}
src/mame/video/stactics.c
r11508r11509
114114
115115CUSTOM_INPUT( stactics_get_frame_count_d3 )
116116{
117   stactics_state *state = field->port->machine().driver_data<stactics_state>();
117   stactics_state *state = field->machine().driver_data<stactics_state>();
118118
119119   return (state->m_frame_count >> 3) & 0x01;
120120}
r11508r11509
172172
173173CUSTOM_INPUT( stactics_get_shot_standby )
174174{
175   stactics_state *state = field->port->machine().driver_data<stactics_state>();
175   stactics_state *state = field->machine().driver_data<stactics_state>();
176176
177177   return state->m_shot_standby;
178178}
r11508r11509
180180
181181CUSTOM_INPUT( stactics_get_not_shot_arrive )
182182{
183   stactics_state *state = field->port->machine().driver_data<stactics_state>();
183   stactics_state *state = field->machine().driver_data<stactics_state>();
184184
185185   return !state->m_shot_arrive;
186186}
src/mame/video/phoenix.c
r11508r11509
310310
311311CUSTOM_INPUT( player_input_r )
312312{
313   phoenix_state *state = field->port->machine().driver_data<phoenix_state>();
313   phoenix_state *state = field->machine().driver_data<phoenix_state>();
314314   if (state->m_cocktail_mode)
315      return (input_port_read(field->port->machine(), "CTRL") & 0xf0) >> 4;
315      return (input_port_read(field->machine(), "CTRL") & 0xf0) >> 4;
316316   else
317      return (input_port_read(field->port->machine(), "CTRL") & 0x0f) >> 0;
317      return (input_port_read(field->machine(), "CTRL") & 0x0f) >> 0;
318318}
319319
320320CUSTOM_INPUT( pleiads_protection_r )
321321{
322   phoenix_state *state = field->port->machine().driver_data<phoenix_state>();
322   phoenix_state *state = field->machine().driver_data<phoenix_state>();
323323   /* handle Pleiads protection */
324324   switch (state->m_pleiads_protection_question)
325325   {
r11508r11509
332332      /* Bit 3 is 1 */
333333      return 1;
334334   default:
335      logerror("%s:Unknown protection question %02X\n", field->port->machine().describe_context(), state->m_pleiads_protection_question);
335      logerror("%s:Unknown protection question %02X\n", field->machine().describe_context(), state->m_pleiads_protection_question);
336336      return 0;
337337   }
338338}
src/mame/video/konicdev.c
r11508r11509
89878987/*                                                                         */
89888988/***************************************************************************/
89898989
8990/*
8991
8992left res = current in game, right res = computed
8993
8994hexion:    02 FF 00 4D 00 73 00 00 01 1F 05 0E B7 7C 00 00 512x256 ~ 512x256 <- writes to e and f regs, in an irq ack fashion
8995overdriv:  01 7F 00 22 00 0D 00 03 01 07 10 0F 73 00 00 00 304x256 ~ 305x224
8996esckids:   01 7F 00 12 00 0D 00 01 01 07 08 07 73 00 00 00 304x224 ~ 321x240
8997rollerg:   01 7F 00 23 00 1D 02 00 01 07 10 0F 73 00 02 00 288x224 ~ 288x224 <- writes to 6 and e regs, in an irq ack fashion
8998gaiapols:  01 FB 00 19 00 37 00 00 01 06 10 0E 75 00 D1 00 376x224 ~ 380x224
8999mmaulers:  01 7F 00 19 00 27 00 00 01 07 10 0F 73 00 00 00 288x224 ~ 288x224
9000mystwarr:  01 7F 00 12 00 2E 00 00 01 07 11 0E 73 00 00 00 288x224 ~ 288x224
9001metamrph:  01 7F 00 11 00 27 01 00 01 07 10 0F 74 00 00 00 288x224 ~ 288x224
9002viostorm:  01 FF 00 16 00 39 00 00 01 07 11 0E 75 00 00 00 384x224 ~ 385x224
9003mtlchamp:  01 FF 00 21 00 37 00 00 01 07 11 0E 74 00 00 00 384x224 ~ 384x224
9004dbz:       01 FF 00 21 00 37 00 00 01 20 0C 0E 54 00 00 00 384x256 ~ 384x256
9005dbz2:      01 FF 00 21 00 37 00 00 01 20 0C 0E 54 00 00 00 384x256 ~ 384x256
9006xexex:     01 FF 00 21 00 37 01 00 01 20 0C 0E 54 00 00 00 384x256 ~ 384x256 (*)
9007(all konamigx, cowboys of moo mesa, run & gun, dj main)
9008
9009(*) hblank duration 512 (0x200), hdisp 384 (0x180), vblank duration 288 (0x120), vdisp 256 (0x100)
9010
9011    Definitions from GX, look similar, all values big-endian, write-only:
9012
9013   0-1: bits 9-0: HC        - Total hblank duration (-1)     Hres ~ (HC+1) - HFP - HBP - 8*(HSW+1)
9014   2-3: bits 8-0: HFP       - HBlank front porch
9015   4-5: bits 8-0: HBP       - HBlank back porch
9016   8-9: bits 8-0: VC        - Total vblank duration
9017   a  : bits 7-0: VFP       - VBlank front porch             Vres ~ VC - VFP - VBP - (VSW+1)
9018   b  : bits 7-0: VBP       - VBlank back porch
9019   c  : bits 7-4: VSW
9020   c  : bits 3-0: HSW
9021   d  : bits 7-0: INT-TIME
9022   e  : bits 7-0: INT1ACK
9023   f  : bits 7-0: INT2ACK
9024
9025    Read-only:
9026   e-f: vits 8-0: VCT
9027*/
9028
89909029typedef struct _k053252_state k053252_state;
89919030struct _k053252_state
89929031{
src/mame/drivers/skyfox.c
r11508r11509
8484
8585static INPUT_CHANGED( coin_inserted )
8686{
87   skyfox_state *state = field->port->machine().driver_data<skyfox_state>();
87   skyfox_state *state = field->machine().driver_data<skyfox_state>();
8888   device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
8989}
9090
src/mame/drivers/fgoal.c
r11508r11509
106106
107107static CUSTOM_INPUT( fgoal_80_r )
108108{
109   UINT8 ret = (field->port->machine().primary_screen->vpos() & 0x80) ? 1 : 0;
109   UINT8 ret = (field->machine().primary_screen->vpos() & 0x80) ? 1 : 0;
110110
111111   return ret;
112112}
src/mame/drivers/mystston.c
r11508r11509
5959static INPUT_CHANGED( coin_inserted )
6060{
6161   /* coin insertion causes an NMI */
62   cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
62   cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
6363}
6464
6565
src/mame/drivers/mainsnk.c
r11508r11509
136136
137137static CUSTOM_INPUT( mainsnk_sound_r )
138138{
139   mainsnk_state *state = field->port->machine().driver_data<mainsnk_state>();
139   mainsnk_state *state = field->machine().driver_data<mainsnk_state>();
140140
141141   return (state->m_sound_cpu_busy) ? 0x01 : 0x00;
142142}
src/mame/drivers/yiear.c
r11508r11509
159159   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
160160   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
161161   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
162   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_CODE("NONE")
162   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) /*WTF? PORT_CODE("NONE")*/
163163   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
164164
165165   PORT_START("P2")
r11508r11509
169169   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL
170170   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
171171   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL
172   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_COCKTAIL PORT_CODE("NONE")
172   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_COCKTAIL /*WTF? PORT_CODE("NONE")*/
173173   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
174174
175175   PORT_START("DSW1")
src/mame/drivers/copsnrob.c
r11508r11509
134134 *
135135 *************************************/
136136
137static const int gun_table[] = {0x3f, 0x5f, 0x6f, 0x77, 0x7b, 0x7d, 0x7e};
137static const input_port_value gun_table[] = {0x3f, 0x5f, 0x6f, 0x77, 0x7b, 0x7d, 0x7e};
138138
139139static INPUT_PORTS_START( copsnrob )
140140   PORT_START("IN0")
src/mame/drivers/cntsteer.c
r11508r11509
672672
673673static INPUT_CHANGED( coin_inserted )
674674{
675   cntsteer_state *state = field->port->machine().driver_data<cntsteer_state>();
675   cntsteer_state *state = field->machine().driver_data<cntsteer_state>();
676676   device_set_input_line(state->m_subcpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
677677}
678678
src/mame/drivers/ccastles.c
r11508r11509
173173
174174static CUSTOM_INPUT( get_vblank )
175175{
176   ccastles_state *state = field->port->machine().driver_data<ccastles_state>();
177   int scanline = field->port->machine().primary_screen->vpos();
176   ccastles_state *state = field->machine().driver_data<ccastles_state>();
177   int scanline = field->machine().primary_screen->vpos();
178178   return state->m_syncprom[scanline & 0xff] & 1;
179179}
180180
src/mame/drivers/policetr.c
r11508r11509
183183
184184static CUSTOM_INPUT( bsmt_status_r )
185185{
186   return field->port->machine().device<bsmt2000_device>("bsmt")->read_status();
186   return field->machine().device<bsmt2000_device>("bsmt")->read_status();
187187}
188188
189189
src/mame/drivers/zn.c
r11508r11509
20662066
20672067static CUSTOM_INPUT( jdredd_gun_mux_read )
20682068{
2069   zn_state *state = field->port->machine().driver_data<zn_state>();
2069   zn_state *state = field->machine().driver_data<zn_state>();
20702070
20712071   return state->m_jdredd_gun_mux;
20722072}
src/mame/drivers/midzeus.c
r11508r11509
432432   static const UINT8 translate49[7] = { 0x8, 0xc, 0xe, 0xf, 0x3, 0x1, 0x0 };
433433   const char *namex = (const char *)param;
434434   const char *namey = namex + strlen(namex) + 1;
435   return (translate49[input_port_read(field->port->machine(), namey) >> 4] << 4) | translate49[input_port_read(field->port->machine(), namex) >> 4];
435   return (translate49[input_port_read(field->machine(), namey) >> 4] << 4) | translate49[input_port_read(field->machine(), namex) >> 4];
436436}
437437
438438
r11508r11509
445445
446446static CUSTOM_INPUT( keypad_r )
447447{
448   UINT32 bits = input_port_read(field->port->machine(), (const char *)param);
448   UINT32 bits = input_port_read(field->machine(), (const char *)param);
449449   UINT8 select = keypad_select;
450450   while ((select & 1) != 0)
451451   {
src/mame/drivers/zaxxon.c
r11508r11509
293293{
294294   /* pressing the service switch sends an NMI */
295295   if (newval)
296      cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE);
296      cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE);
297297}
298298
299299
r11508r11509
355355
356356static CUSTOM_INPUT( razmataz_dial_r )
357357{
358   zaxxon_state *state = field->port->machine().driver_data<zaxxon_state>();
358   zaxxon_state *state = field->machine().driver_data<zaxxon_state>();
359359   static const char *const dialname[2] = { "DIAL0", "DIAL1" };
360360   int num = (FPTR)param;
361361   int delta, res;
362362
363   delta = input_port_read(field->port->machine(), dialname[num]);
363   delta = input_port_read(field->machine(), dialname[num]);
364364
365365   if (delta < 0x80)
366366   {
r11508r11509
408408{
409409   if (newval)
410410   {
411      zaxxon_state *state = field->port->machine().driver_data<zaxxon_state>();
411      zaxxon_state *state = field->machine().driver_data<zaxxon_state>();
412412
413413      state->m_coin_status[(int)(FPTR)param] = state->m_coin_enable[(int)(FPTR)param];
414414   }
r11508r11509
417417
418418static CUSTOM_INPUT( zaxxon_coin_r )
419419{
420   zaxxon_state *state = field->port->machine().driver_data<zaxxon_state>();
420   zaxxon_state *state = field->machine().driver_data<zaxxon_state>();
421421
422422   return state->m_coin_status[(int)(FPTR)param];
423423}
src/mame/drivers/punchout.c
r11508r11509
122122static CUSTOM_INPUT( punchout_vlm5030_busy_r )
123123{
124124   /* bit 4 of DSW1 is busy pin level */
125   return (vlm5030_bsy(field->port->machine().device("vlm"))) ? 0x00 : 0x01;
125   return (vlm5030_bsy(field->machine().device("vlm"))) ? 0x00 : 0x01;
126126}
127127
128128static WRITE8_DEVICE_HANDLER( punchout_speech_reset_w )
src/mame/drivers/maxaflex.c
r11508r11509
256256static INPUT_CHANGED( coin_inserted )
257257{
258258   if (!newval)
259      cputag_set_input_line(field->port->machine(), "mcu", M6805_IRQ_LINE, HOLD_LINE );
259      cputag_set_input_line(field->machine(), "mcu", M6805_IRQ_LINE, HOLD_LINE );
260260}
261261
262262int atari_input_disabled(running_machine &machine)
src/mame/drivers/kopunch.c
r11508r11509
7070
7171static INPUT_CHANGED( left_coin_inserted )
7272{
73   kopunch_state *state = field->port->machine().driver_data<kopunch_state>();
73   kopunch_state *state = field->machine().driver_data<kopunch_state>();
7474
7575   /* left coin insertion causes a rst6.5 (vector 0x34) */
7676   if (newval)
r11508r11509
7979
8080static INPUT_CHANGED( right_coin_inserted )
8181{
82   kopunch_state *state = field->port->machine().driver_data<kopunch_state>();
82   kopunch_state *state = field->machine().driver_data<kopunch_state>();
8383
8484   /* right coin insertion causes a rst5.5 (vector 0x2c) */
8585   if (newval)
src/mame/drivers/ng_aes.c
r11508r11509
315315         { "IN0-0", "IN0-1" }, { "IN1-0", "IN1-1" }
316316      };
317317
318   return input_port_read_safe(field->port->machine(), cntrl[port][controller_select & 0x01], 0x00);
318   return input_port_read_safe(field->machine(), cntrl[port][controller_select & 0x01], 0x00);
319319}
320320
321321
r11508r11509
334334   {
335335   default:
336336   case 0x00: ret = 0x0000; break; /* nothing? */
337   case 0x09: ret = input_port_read(field->port->machine(), "MAHJONG1"); break;
338   case 0x12: ret = input_port_read(field->port->machine(), "MAHJONG2"); break;
339   case 0x1b: ret = input_port_read(field->port->machine(), "MAHJONG3"); break; /* player 1 normal inputs? */
340   case 0x24: ret = input_port_read(field->port->machine(), "MAHJONG4"); break;
337   case 0x09: ret = input_port_read(field->machine(), "MAHJONG1"); break;
338   case 0x12: ret = input_port_read(field->machine(), "MAHJONG2"); break;
339   case 0x1b: ret = input_port_read(field->machine(), "MAHJONG3"); break; /* player 1 normal inputs? */
340   case 0x24: ret = input_port_read(field->machine(), "MAHJONG4"); break;
341341   }
342342
343343   return ret;
r11508r11509
430430
431431static CUSTOM_INPUT( get_calendar_status )
432432{
433   neogeo_state *state = field->port->machine().driver_data<neogeo_state>();
433   neogeo_state *state = field->machine().driver_data<neogeo_state>();
434434   return (upd4990a_databit_r(state->m_upd4990a, 0) << 1) | upd4990a_testbit_r(state->m_upd4990a, 0);
435435}
436436
r11508r11509
487487{
488488   /* D0 and D1 are memcard presence indicators, D2 indicates memcard
489489       write protect status (we are always write enabled) */
490   if(strcmp((char*)field->port->machine().system().name,"aes") != 0)
490   if(strcmp((char*)field->machine().system().name,"aes") != 0)
491491      return 0x00;  // On the Neo Geo CD, the memory card is internal and therefore always present.
492492   else
493      return (memcard_present(field->port->machine()) == -1) ? 0x07 : 0x00;
493      return (memcard_present(field->machine()) == -1) ? 0x07 : 0x00;
494494}
495495
496496static READ16_HANDLER( memcard_r )
r11508r11509
604604
605605static CUSTOM_INPUT( get_audio_result )
606606{
607   neogeo_state *state = field->port->machine().driver_data<neogeo_state>();
607   neogeo_state *state = field->machine().driver_data<neogeo_state>();
608608   UINT32 ret = state->m_audio_result;
609609
610//  if (LOG_CPU_COMM) logerror("MAIN CPU PC %06x: audio_result_r %02x\n", cpu_get_pc(field->port->machine().device("maincpu")), ret);
610//  if (LOG_CPU_COMM) logerror("MAIN CPU PC %06x: audio_result_r %02x\n", cpu_get_pc(field->machine().device("maincpu")), ret);
611611
612612   return ret;
613613}
src/mame/drivers/ddenlovr.c
r11508r11509
14091409
14101410static CUSTOM_INPUT( ddenlovr_special_r )
14111411{
1412   dynax_state *state = field->port->machine().driver_data<dynax_state>();
1412   dynax_state *state = field->machine().driver_data<dynax_state>();
14131413   return state->m_ddenlovr_blitter_irq_flag;
14141414}
14151415
r11508r11509
17811781
17821782static CUSTOM_INPUT( ddenlovj_blitter_r )
17831783{
1784   dynax_state *state = field->port->machine().driver_data<dynax_state>();
1784   dynax_state *state = field->machine().driver_data<dynax_state>();
17851785   return state->m_ddenlovr_blitter_irq_flag ? 0x03 : 0x00;      // bit 4 = 1 -> blitter busy
17861786}
17871787
r11508r11509
19211921
19221922static CUSTOM_INPUT( nettoqc_special_r )
19231923{
1924   dynax_state *state = field->port->machine().driver_data<dynax_state>();
1924   dynax_state *state = field->machine().driver_data<dynax_state>();
19251925   return state->m_ddenlovr_blitter_irq_flag ? 0x03 : 0x00;
19261926}
19271927
r11508r11509
34463446
34473447static CUSTOM_INPUT( mjflove_blitter_r )
34483448{
3449   dynax_state *state = field->port->machine().driver_data<dynax_state>();
3449   dynax_state *state = field->machine().driver_data<dynax_state>();
34503450
34513451   // bit 7 = 1 -> blitter busy
34523452   // bit 6 = 0 -> VBLANK?
src/mame/drivers/ms32.c
r11508r11509
176176
177177static CUSTOM_INPUT( mahjong_ctrl_r )
178178{
179   ms32_state *state = field->port->machine().driver_data<ms32_state>();
179   ms32_state *state = field->machine().driver_data<ms32_state>();
180180   UINT32 mj_input;
181181
182182   switch (state->m_mahjong_input_select[0])
183183   {
184184      case 0x01:
185         mj_input = input_port_read(field->port->machine(), "MJ0");
185         mj_input = input_port_read(field->machine(), "MJ0");
186186         break;
187187      case 0x02:
188         mj_input = input_port_read(field->port->machine(), "MJ1");
188         mj_input = input_port_read(field->machine(), "MJ1");
189189         break;
190190      case 0x04:
191         mj_input = input_port_read(field->port->machine(), "MJ2");
191         mj_input = input_port_read(field->machine(), "MJ2");
192192         break;
193193      case 0x08:
194         mj_input = input_port_read(field->port->machine(), "MJ3");
194         mj_input = input_port_read(field->machine(), "MJ3");
195195         break;
196196      case 0x10:
197         mj_input = input_port_read(field->port->machine(), "MJ4");
197         mj_input = input_port_read(field->machine(), "MJ4");
198198         break;
199199      default:
200200         mj_input = 0;
src/mame/drivers/mpu4.c
r11508r11509
26592659   state->m_led_lamp=1;
26602660}
26612661
2662//static DRIVER_INIT (m_frkstn)
2663//{
2664//  mpu4_state *state = machine.driver_data<mpu4_state>();
2665//  state->m_reel_mux=STANDARD_REEL;
2666//  state->m_reels = 4;
2667//
2668//  // setup 4 default 96 half step reels with the mux board
2669//  mpu4_config_common_reels(machine,4);
2670//
2671//  //This is a Crystal ROM, needs UPD chip and Project Amber's ROM swizzle.
2672//}
2662static DRIVER_INIT (m_frkstn)
2663{
2664  mpu4_state *state = machine.driver_data<mpu4_state>();
2665  state->m_reel_mux=STANDARD_REEL;
2666  state->m_reels = 4;
26732667
2668  // setup 4 default 96 half step reels with the mux board
2669  mpu4_config_common_reels(machine,4);
2670
2671  //This is a Crystal ROM, needs UPD chip and Project Amber's ROM swizzle.
2672}
2673
26742674/* generate a 50 Hz signal (based on an RC time) */
26752675static TIMER_DEVICE_CALLBACK( gen_50hz )
26762676{
r11508r11509
27792779   AM_RANGE(0x1000, 0xffff) AM_ROMBANK("bank1")   // 64k  paged ROM (4 pages)
27802780ADDRESS_MAP_END
27812781
2782//static ADDRESS_MAP_START( mpu4_crystal_map, AS_PROGRAM, 8 )
2783//  AM_RANGE(0x0000, 0x07ff) AM_RAM AM_SHARE("nvram")
2784//
2785//  AM_RANGE(0x0850, 0x0850) AM_WRITE(bankswitch_w) // write bank (rom page select)
2786//
2787//  AM_RANGE(0x0858, 0x0858) AM_WRITE(bankswitch_w) // write bank (rom page select)
2788//  AM_RANGE(0x0878, 0x0878) AM_WRITE(bankset_w)    // write bank (rom page select)
2789//
2790////  AM_RANGE(0x08e0, 0x08e7) AM_READWRITE(68681_duart_r,68681_duart_w) //Runs hoppers
2791//
2792//  AM_RANGE(0x0900, 0x0907) AM_DEVREADWRITE_MODERN("ptm_ic2", ptm6840_device, read, write)/* PTM6840 IC2 */
2793//
2794//  AM_RANGE(0x0a00, 0x0a03) AM_DEVREADWRITE_MODERN("pia_ic3", pia6821_device, read, write)     /* PIA6821 IC3 */
2795//  AM_RANGE(0x0b00, 0x0b03) AM_DEVREADWRITE_MODERN("pia_ic4", pia6821_device, read, write)     /* PIA6821 IC4 */
2796//  AM_RANGE(0x0c00, 0x0c03) AM_DEVREADWRITE_MODERN("pia_ic5", pia6821_device, read, write)     /* PIA6821 IC5 */
2797//  AM_RANGE(0x0d00, 0x0d03) AM_DEVREADWRITE_MODERN("pia_ic6", pia6821_device, read, write)     /* PIA6821 IC6 */
2798//  AM_RANGE(0x0e00, 0x0e03) AM_DEVREADWRITE_MODERN("pia_ic7", pia6821_device, read, write)     /* PIA6821 IC7 */
2799//  AM_RANGE(0x0f00, 0x0f03) AM_DEVREADWRITE_MODERN("pia_ic8", pia6821_device, read, write)     /* PIA6821 IC8 */
2800//
2801//  AM_RANGE(0x1000, 0xffff) AM_ROMBANK("bank1")    // 64k  paged ROM (4 pages)
2802//ADDRESS_MAP_END */
2782static ADDRESS_MAP_START( mpu4_crystal_map, AS_PROGRAM, 8 )
2783   AM_RANGE(0x0000, 0x07ff) AM_RAM AM_SHARE("nvram")
2784   AM_RANGE(0x0850, 0x0850) AM_WRITE(bankswitch_w) // write bank (rom page select)
2785   AM_RANGE(0x0858, 0x0858) AM_WRITE(bankswitch_w) // write bank (rom page select)
2786   AM_RANGE(0x0878, 0x0878) AM_WRITE(bankset_w)    // write bank (rom page select)
2787//   AM_RANGE(0x08e0, 0x08e7) AM_READWRITE(68681_duart_r,68681_duart_w) //Runs hoppers
2788   AM_RANGE(0x0900, 0x0907) AM_DEVREADWRITE_MODERN("ptm_ic2", ptm6840_device, read, write)/* PTM6840 IC2 */
2789   AM_RANGE(0x0a00, 0x0a03) AM_DEVREADWRITE_MODERN("pia_ic3", pia6821_device, read, write)     /* PIA6821 IC3 */
2790   AM_RANGE(0x0b00, 0x0b03) AM_DEVREADWRITE_MODERN("pia_ic4", pia6821_device, read, write)     /* PIA6821 IC4 */
2791   AM_RANGE(0x0c00, 0x0c03) AM_DEVREADWRITE_MODERN("pia_ic5", pia6821_device, read, write)     /* PIA6821 IC5 */
2792   AM_RANGE(0x0d00, 0x0d03) AM_DEVREADWRITE_MODERN("pia_ic6", pia6821_device, read, write)     /* PIA6821 IC6 */
2793   AM_RANGE(0x0e00, 0x0e03) AM_DEVREADWRITE_MODERN("pia_ic7", pia6821_device, read, write)     /* PIA6821 IC7 */
2794   AM_RANGE(0x0f00, 0x0f03) AM_DEVREADWRITE_MODERN("pia_ic8", pia6821_device, read, write)     /* PIA6821 IC8 */
2795   AM_RANGE(0x1000, 0xffff) AM_ROMBANK("bank1")    // 64k  paged ROM (4 pages)
2796ADDRESS_MAP_END
28032797
28042798
28052799static ADDRESS_MAP_START( dutch_memmap, AS_PROGRAM, 8 )
r11508r11509
29042898   MCFG_CPU_PROGRAM_MAP(mpu4_bwb_map)            // setup read and write memorymap
29052899MACHINE_CONFIG_END
29062900
2907//static MACHINE_CONFIG_DERIVED(mpu4crys, mpu4mod2 )
2908//  MCFG_CPU_MODIFY("maincpu")
2909//  MCFG_CPU_PROGRAM_MAP(mpu4_crystal_map)              // setup read and write memorymap
2910//
2911//  MCFG_SOUND_ADD("upd", UPD7759, UPD7759_STANDARD_CLOCK)
2912//  MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
2913//MACHINE_CONFIG_END
2901static MACHINE_CONFIG_DERIVED(mpu4crys, mpu4mod2 )
2902  MCFG_CPU_MODIFY("maincpu")
2903  MCFG_CPU_PROGRAM_MAP(mpu4_crystal_map)              // setup read and write memorymap
29142904
2905  MCFG_SOUND_ADD("upd", UPD7759, UPD7759_STANDARD_CLOCK)
2906  MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
2907MACHINE_CONFIG_END
29152908
29162909
2910
29172911ROM_START( m_oldtmr )
29182912   ROM_REGION( 0x10000, "maincpu", 0 )
29192913   ROM_LOAD( "dot11.bin",  0x00000, 0x10000,  CRC(da095666) SHA1(bc7654dc9da1f830a43f925db8079f27e18bb61e))
r11508r11509
29872981GAMEL(198?,  m_gmball,0,      mod4yam,  gamball,  m_gmball, ROT0, "Barcrest",       "Gamball",                     GAME_REQUIRES_ARTWORK|GAME_MECHANICAL,layout_gamball )//Mechanical ball launcher
29882982GAMEL(198?,  m_grtecp,0,      mod4oki,  mpu4,     m_grtecp, ROT0,   "Barcrest",       "Andy's Great Escape",            GAME_NOT_WORKING|GAME_REQUIRES_ARTWORK,layout_mpu4ext )//5 reel meter mux
29892983GAME(199?,   m_blsbys,0,     bwboki,   mpu4,     m_blsbys, ROT0,   "Barcrest",       "Blues Boys (Version 6)",         GAME_NOT_WORKING|GAME_REQUIRES_ARTWORK )
2990//GAME(199?,   m_frkstn,0,    mpu4crys, mpu4,     m_frkstn, ROT0,   "Crystal Gaming","Frank 'n' Stein (unencrypted)",   GAME_NOT_WORKING|GAME_REQUIRES_ARTWORK|GAME_NO_SOUND )//hardware not connected
2984GAME(199?,   m_frkstn,0,    mpu4crys, mpu4,     m_frkstn, ROT0,   "Crystal Gaming","Frank 'n' Stein (unencrypted)",   GAME_NOT_WORKING|GAME_REQUIRES_ARTWORK|GAME_NO_SOUND )//hardware not connected
29912985
29922986//SWP
29932987GAMEL(1989?,connect4,        0, mpu4mod2,   connect4,   connect4,   ROT0, "Dolbeck Systems","Connect 4",GAME_IMPERFECT_GRAPHICS|GAME_REQUIRES_ARTWORK,layout_connect4 )
src/mame/drivers/wwfsstar.c
r11508r11509
274274
275275static CUSTOM_INPUT( wwfsstar_vblank_r )
276276{
277   wwfsstar_state *state = field->port->machine().driver_data<wwfsstar_state>();
277   wwfsstar_state *state = field->machine().driver_data<wwfsstar_state>();
278278
279279   return state->m_vblank;
280280}
src/mame/drivers/mw8080bw.c
r11508r11509
319319
320320static CUSTOM_INPUT( seawolf_erase_input_r )
321321{
322   return input_port_read(field->port->machine(), SEAWOLF_ERASE_SW_PORT_TAG) &
323         input_port_read(field->port->machine(), SEAWOLF_ERASE_DIP_PORT_TAG);
322   return input_port_read(field->machine(), SEAWOLF_ERASE_SW_PORT_TAG) &
323         input_port_read(field->machine(), SEAWOLF_ERASE_DIP_PORT_TAG);
324324}
325325
326326
r11508r11509
559559
560560static CUSTOM_INPUT( tornbase_hit_left_input_r )
561561{
562   return input_port_read(field->port->machine(), TORNBASE_L_HIT_PORT_TAG);
562   return input_port_read(field->machine(), TORNBASE_L_HIT_PORT_TAG);
563563}
564564
565565
r11508r11509
567567{
568568   UINT32 ret;
569569
570   switch (tornbase_get_cabinet_type(field->port->machine()))
570   switch (tornbase_get_cabinet_type(field->machine()))
571571   {
572572   case TORNBASE_CAB_TYPE_UPRIGHT_OLD:
573      ret = input_port_read(field->port->machine(), TORNBASE_L_HIT_PORT_TAG);
573      ret = input_port_read(field->machine(), TORNBASE_L_HIT_PORT_TAG);
574574      break;
575575
576576   case TORNBASE_CAB_TYPE_UPRIGHT_NEW:
577577   case TORNBASE_CAB_TYPE_COCKTAIL:
578578   default:
579      ret = input_port_read(field->port->machine(), TORNBASE_R_HIT_PORT_TAG);
579      ret = input_port_read(field->machine(), TORNBASE_R_HIT_PORT_TAG);
580580      break;
581581   }
582582
r11508r11509
588588{
589589   UINT32 ret;
590590
591   switch (tornbase_get_cabinet_type(field->port->machine()))
591   switch (tornbase_get_cabinet_type(field->machine()))
592592   {
593593   case TORNBASE_CAB_TYPE_UPRIGHT_OLD:
594594   case TORNBASE_CAB_TYPE_UPRIGHT_NEW:
595      ret = input_port_read(field->port->machine(), TORNBASE_L_PITCH_PORT_TAG);
595      ret = input_port_read(field->machine(), TORNBASE_L_PITCH_PORT_TAG);
596596      break;
597597
598598   case TORNBASE_CAB_TYPE_COCKTAIL:
599599   default:
600      ret = input_port_read(field->port->machine(), TORNBASE_R_PITCH_PORT_TAG);
600      ret = input_port_read(field->machine(), TORNBASE_R_PITCH_PORT_TAG);
601601      break;
602602   }
603603
r11508r11509
607607
608608static CUSTOM_INPUT( tornbase_pitch_right_input_r )
609609{
610   return input_port_read(field->port->machine(), TORNBASE_L_PITCH_PORT_TAG);
610   return input_port_read(field->machine(), TORNBASE_L_PITCH_PORT_TAG);
611611}
612612
613613
614614static CUSTOM_INPUT( tornbase_score_input_r )
615615{
616   return input_port_read(field->port->machine(), TORNBASE_SCORE_SW_PORT_TAG) &
617         input_port_read(field->port->machine(), TORNBASE_SCORE_DIP_PORT_TAG);
616   return input_port_read(field->machine(), TORNBASE_SCORE_SW_PORT_TAG) &
617         input_port_read(field->machine(), TORNBASE_SCORE_DIP_PORT_TAG);
618618}
619619
620620
r11508r11509
11941194
11951195static CUSTOM_INPUT( desertgu_gun_input_r )
11961196{
1197   mw8080bw_state *state = field->port->machine().driver_data<mw8080bw_state>();
1197   mw8080bw_state *state = field->machine().driver_data<mw8080bw_state>();
11981198   UINT32 ret;
11991199
12001200   if (state->m_desertgun_controller_select)
1201      ret = input_port_read(field->port->machine(), DESERTGU_GUN_X_PORT_TAG);
1201      ret = input_port_read(field->machine(), DESERTGU_GUN_X_PORT_TAG);
12021202   else
1203      ret = input_port_read(field->port->machine(), DESERTGU_GUN_Y_PORT_TAG);
1203      ret = input_port_read(field->machine(), DESERTGU_GUN_Y_PORT_TAG);
12041204
12051205   return ret;
12061206}
r11508r11509
12081208
12091209static CUSTOM_INPUT( desertgu_dip_sw_0_1_r )
12101210{
1211   mw8080bw_state *state = field->port->machine().driver_data<mw8080bw_state>();
1211   mw8080bw_state *state = field->machine().driver_data<mw8080bw_state>();
12121212   UINT32 ret;
12131213
12141214   if (state->m_desertgun_controller_select)
1215      ret = input_port_read(field->port->machine(), DESERTGU_DIP_SW_0_1_SET_2_TAG);
1215      ret = input_port_read(field->machine(), DESERTGU_DIP_SW_0_1_SET_2_TAG);
12161216   else
1217      ret = input_port_read(field->port->machine(), DESERTGU_DIP_SW_0_1_SET_1_TAG);
1217      ret = input_port_read(field->machine(), DESERTGU_DIP_SW_0_1_SET_1_TAG);
12181218
12191219   return ret;
12201220}
r11508r11509
13271327{
13281328   UINT32 ret;
13291329
1330   if (input_port_read(field->port->machine(), DPLAY_CAB_TYPE_PORT_TAG) == DPLAY_CAB_TYPE_UPRIGHT)
1331      ret = input_port_read(field->port->machine(), DPLAY_L_PITCH_PORT_TAG);
1330   if (input_port_read(field->machine(), DPLAY_CAB_TYPE_PORT_TAG) == DPLAY_CAB_TYPE_UPRIGHT)
1331      ret = input_port_read(field->machine(), DPLAY_L_PITCH_PORT_TAG);
13321332   else
1333      ret = input_port_read(field->port->machine(), DPLAY_R_PITCH_PORT_TAG);
1333      ret = input_port_read(field->machine(), DPLAY_R_PITCH_PORT_TAG);
13341334
13351335   return ret;
13361336}
r11508r11509
13381338
13391339static CUSTOM_INPUT( dplay_pitch_right_input_r )
13401340{
1341   return input_port_read(field->port->machine(), DPLAY_L_PITCH_PORT_TAG);
1341   return input_port_read(field->machine(), DPLAY_L_PITCH_PORT_TAG);
13421342}
13431343
13441344
r11508r11509
17161716
17171717static CUSTOM_INPUT( clowns_controller_r )
17181718{
1719   mw8080bw_state *state = field->port->machine().driver_data<mw8080bw_state>();
1719   mw8080bw_state *state = field->machine().driver_data<mw8080bw_state>();
17201720   UINT32 ret;
17211721
17221722   if (state->m_clowns_controller_select)
17231723   {
1724      ret = input_port_read(field->port->machine(), CLOWNS_CONTROLLER_P2_TAG);
1724      ret = input_port_read(field->machine(), CLOWNS_CONTROLLER_P2_TAG);
17251725   }
17261726   else
17271727   {
1728      ret = input_port_read(field->port->machine(), CLOWNS_CONTROLLER_P1_TAG);
1728      ret = input_port_read(field->machine(), CLOWNS_CONTROLLER_P1_TAG);
17291729   }
17301730
17311731   return ret;
r11508r11509
25482548
25492549static CUSTOM_INPUT( invaders_coin_input_r )
25502550{
2551   UINT32 ret = input_port_read(field->port->machine(), INVADERS_COIN_INPUT_PORT_TAG);
2551   UINT32 ret = input_port_read(field->machine(), INVADERS_COIN_INPUT_PORT_TAG);
25522552
2553   coin_counter_w(field->port->machine(), 0, !ret);
2553   coin_counter_w(field->machine(), 0, !ret);
25542554
25552555   return ret;
25562556}
r11508r11509
25632563   /* upright PCB : switches visible
25642564       cocktail PCB: HI */
25652565
2566   if (invaders_is_cabinet_cocktail(field->port->machine()))
2566   if (invaders_is_cabinet_cocktail(field->machine()))
25672567      ret = 0x03;
25682568   else
2569      ret = input_port_read(field->port->machine(), INVADERS_SW6_SW7_PORT_TAG);
2569      ret = input_port_read(field->machine(), INVADERS_SW6_SW7_PORT_TAG);
25702570
25712571   return ret;
25722572}
r11508r11509
25792579   /* upright PCB : switch visible
25802580       cocktail PCB: HI */
25812581
2582   if (invaders_is_cabinet_cocktail(field->port->machine()))
2582   if (invaders_is_cabinet_cocktail(field->machine()))
25832583      ret = 0x01;
25842584   else
2585      ret = input_port_read(field->port->machine(), INVADERS_SW5_PORT_TAG);
2585      ret = input_port_read(field->machine(), INVADERS_SW5_PORT_TAG);
25862586
25872587   return ret;
25882588}
r11508r11509
25952595   /* upright PCB : P1 controls
25962596       cocktail PCB: HI */
25972597
2598   if (invaders_is_cabinet_cocktail(field->port->machine()))
2598   if (invaders_is_cabinet_cocktail(field->machine()))
25992599      ret = 0x07;
26002600   else
2601      ret = input_port_read(field->port->machine(), INVADERS_P1_CONTROL_PORT_TAG);
2601      ret = input_port_read(field->machine(), INVADERS_P1_CONTROL_PORT_TAG);
26022602
26032603   return ret;
26042604}
r11508r11509
26062606
26072607CUSTOM_INPUT( invaders_in1_control_r )
26082608{
2609   return input_port_read(field->port->machine(), INVADERS_P1_CONTROL_PORT_TAG);
2609   return input_port_read(field->machine(), INVADERS_P1_CONTROL_PORT_TAG);
26102610}
26112611
26122612
r11508r11509
26172617   /* upright PCB : P1 controls
26182618       cocktail PCB: P2 controls */
26192619
2620   if (invaders_is_cabinet_cocktail(field->port->machine()))
2621      ret = input_port_read(field->port->machine(), INVADERS_P2_CONTROL_PORT_TAG);
2620   if (invaders_is_cabinet_cocktail(field->machine()))
2621      ret = input_port_read(field->machine(), INVADERS_P2_CONTROL_PORT_TAG);
26222622   else
2623      ret = input_port_read(field->port->machine(), INVADERS_P1_CONTROL_PORT_TAG);
2623      ret = input_port_read(field->machine(), INVADERS_P1_CONTROL_PORT_TAG);
26242624
26252625   return ret;
26262626}
r11508r11509
27552755
27562756static CUSTOM_INPUT( blueshrk_coin_input_r )
27572757{
2758   UINT32 ret = input_port_read(field->port->machine(), BLUESHRK_COIN_INPUT_PORT_TAG);
2758   UINT32 ret = input_port_read(field->machine(), BLUESHRK_COIN_INPUT_PORT_TAG);
27592759
2760   coin_counter_w(field->port->machine(), 0, !ret);
2760   coin_counter_w(field->machine(), 0, !ret);
27612761
27622762   return ret;
27632763}
src/mame/drivers/btime.c
r11508r11509
525525
526526static INPUT_CHANGED( coin_inserted_irq_hi )
527527{
528   btime_state *state = field->port->machine().driver_data<btime_state>();
528   btime_state *state = field->machine().driver_data<btime_state>();
529529
530530   if (newval)
531531      device_set_input_line(state->m_maincpu, 0, HOLD_LINE);
r11508r11509
533533
534534static INPUT_CHANGED( coin_inserted_irq_lo )
535535{
536   btime_state *state = field->port->machine().driver_data<btime_state>();
536   btime_state *state = field->machine().driver_data<btime_state>();
537537
538538   if (!newval)
539539      device_set_input_line(state->m_maincpu, 0, HOLD_LINE);
r11508r11509
541541
542542static INPUT_CHANGED( coin_inserted_nmi_lo )
543543{
544   btime_state *state = field->port->machine().driver_data<btime_state>();
544   btime_state *state = field->machine().driver_data<btime_state>();
545545   device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
546546}
547547
src/mame/drivers/m14.c
r11508r11509
222222
223223static INPUT_CHANGED( left_coin_inserted )
224224{
225   m14_state *state = field->port->machine().driver_data<m14_state>();
225   m14_state *state = field->machine().driver_data<m14_state>();
226226   /* left coin insertion causes a rst6.5 (vector 0x34) */
227227   if (newval)
228228      device_set_input_line(state->m_maincpu, I8085_RST65_LINE, HOLD_LINE);
r11508r11509
230230
231231static INPUT_CHANGED( right_coin_inserted )
232232{
233   m14_state *state = field->port->machine().driver_data<m14_state>();
233   m14_state *state = field->machine().driver_data<m14_state>();
234234   /* right coin insertion causes a rst5.5 (vector 0x2c) */
235235   if (newval)
236236      device_set_input_line(state->m_maincpu, I8085_RST55_LINE, HOLD_LINE);
src/mame/drivers/nova2001.c
r11508r11509
134134
135135static CUSTOM_INPUT( ninjakun_io_A002_ctrl_r )
136136{
137   nova2001_state *state = field->port->machine().driver_data<nova2001_state>();
137   nova2001_state *state = field->machine().driver_data<nova2001_state>();
138138   return state->m_ninjakun_io_a002_ctrl;
139139}
140140
src/mame/drivers/gaelco3d.c
r11508r11509
409409
410410static CUSTOM_INPUT( analog_bit_r )
411411{
412   gaelco3d_state *state = field->port->machine().driver_data<gaelco3d_state>();
412   gaelco3d_state *state = field->machine().driver_data<gaelco3d_state>();
413413   int which = (FPTR)param;
414414   return (state->m_analog_ports[which] >> 7) & 0x01;
415415}
src/mame/drivers/snk.c
r11508r11509
333333
334334static CUSTOM_INPUT( marvins_sound_busy )
335335{
336   snk_state *state = field->port->machine().driver_data<snk_state>();
336   snk_state *state = field->machine().driver_data<snk_state>();
337337
338338   return state->m_marvins_sound_busy_flag;
339339}
r11508r11509
500500
501501static CUSTOM_INPUT( snk_sound_busy )
502502{
503   snk_state *state = field->port->machine().driver_data<snk_state>();
503   snk_state *state = field->machine().driver_data<snk_state>();
504504
505505   return (state->m_sound_status & 4) ? 1 : 0;
506506}
r11508r11509
752752
753753static CUSTOM_INPUT( gwar_rotary )
754754{
755   snk_state *state = field->port->machine().driver_data<snk_state>();
755   snk_state *state = field->machine().driver_data<snk_state>();
756756   static const char *const ports[] = { "P1ROT", "P2ROT" };
757757   int which = (int)(FPTR)param;
758   int value = input_port_read(field->port->machine(), ports[which]);
758   int value = input_port_read(field->machine(), ports[which]);
759759
760760   if ((state->m_last_value[which] == 0x5 && value == 0x6) || (state->m_last_value[which] == 0x6 && value == 0x5))
761761   {
r11508r11509
770770
771771static CUSTOM_INPUT( gwarb_rotary )
772772{
773   if (input_port_read(field->port->machine(), "JOYSTICK_MODE") == 1)
773   if (input_port_read(field->machine(), "JOYSTICK_MODE") == 1)
774774   {
775      return gwar_rotary(field, param);
775      return gwar_rotary(device, field, param);
776776   }
777777   else
778778   {
r11508r11509
819819
820820static CUSTOM_INPUT( countryc_trackball_x )
821821{
822   snk_state *state = field->port->machine().driver_data<snk_state>();
822   snk_state *state = field->machine().driver_data<snk_state>();
823823
824   return input_port_read(field->port->machine(), state->m_countryc_trackball ? "TRACKBALLX2" : "TRACKBALLX1");
824   return input_port_read(field->machine(), state->m_countryc_trackball ? "TRACKBALLX2" : "TRACKBALLX1");
825825}
826826
827827static CUSTOM_INPUT( countryc_trackball_y )
828828{
829   snk_state *state = field->port->machine().driver_data<snk_state>();
829   snk_state *state = field->machine().driver_data<snk_state>();
830830
831   return input_port_read(field->port->machine(), state->m_countryc_trackball ? "TRACKBALLY2" : "TRACKBALLY1");
831   return input_port_read(field->machine(), state->m_countryc_trackball ? "TRACKBALLY2" : "TRACKBALLY1");
832832}
833833
834834
r11508r11509
841841   switch (bit_mask)
842842   {
843843      case 0x01:  /* older games : "Occurence" Dip Switch (DSW2:1) */
844         return ((input_port_read(field->port->machine(), "BONUS") & bit_mask) >> 0);
844         return ((input_port_read(field->machine(), "BONUS") & bit_mask) >> 0);
845845      case 0xc0:  /* older games : "Bonus Life" Dip Switches (DSW1:7,8) */
846         return ((input_port_read(field->port->machine(), "BONUS") & bit_mask) >> 6);
846         return ((input_port_read(field->machine(), "BONUS") & bit_mask) >> 6);
847847
848848      case 0x04:  /* later games : "Occurence" Dip Switch (DSW1:3) */
849         return ((input_port_read(field->port->machine(), "BONUS") & bit_mask) >> 2);
849         return ((input_port_read(field->machine(), "BONUS") & bit_mask) >> 2);
850850      case 0x30:  /* later games : "Bonus Life" Dip Switches (DSW2:5,6) */
851         return ((input_port_read(field->port->machine(), "BONUS") & bit_mask) >> 4);
851         return ((input_port_read(field->machine(), "BONUS") & bit_mask) >> 4);
852852
853853      default:
854854         logerror("snk_bonus_r : invalid %02X bit_mask\n",bit_mask);
src/mame/drivers/cosmic.c
r11508r11509
414414
415415static INPUT_CHANGED( panic_coin_inserted )
416416{
417   panic_sound_output_w(field->port->machine().device("maincpu")->memory().space(AS_PROGRAM), 17, newval == 0);
417   panic_sound_output_w(field->machine().device("maincpu")->memory().space(AS_PROGRAM), 17, newval == 0);
418418}
419419
420420static INPUT_PORTS_START( panic )
r11508r11509
475475
476476static INPUT_CHANGED( cosmica_coin_inserted )
477477{
478   cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
478   cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
479479}
480480
481481static INPUT_PORTS_START( cosmica )
r11508r11509
530530
531531static INPUT_CHANGED( cosmicg_coin_inserted )
532532{
533   cputag_set_input_line_and_vector(field->port->machine(), "maincpu", 0, newval ? ASSERT_LINE : CLEAR_LINE, 6);
533   cputag_set_input_line_and_vector(field->machine(), "maincpu", 0, newval ? ASSERT_LINE : CLEAR_LINE, 6);
534534}
535535
536536static INPUT_PORTS_START( cosmicg )
r11508r11509
577577
578578static INPUT_CHANGED( coin_inserted_irq0 )
579579{
580   cputag_set_input_line(field->port->machine(), "maincpu", 0, newval ? HOLD_LINE : CLEAR_LINE);
580   cputag_set_input_line(field->machine(), "maincpu", 0, newval ? HOLD_LINE : CLEAR_LINE);
581581}
582582
583583static INPUT_CHANGED( coin_inserted_nmi )
584584{
585   cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
585   cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
586586}
587587
588588static INPUT_PORTS_START( magspot )
src/mame/drivers/model2.c
r11508r11509
460460
461461static CUSTOM_INPUT( _1c00000_r )
462462{
463   model2_state *state = field->port->machine().driver_data<model2_state>();
464   UINT32 ret = input_port_read(field->port->machine(), "IN0");
463   model2_state *state = field->machine().driver_data<model2_state>();
464   UINT32 ret = input_port_read(field->machine(), "IN0");
465465
466466   if(state->m_ctrlmode == 0)
467467   {
r11508r11509
470470   else
471471   {
472472      ret &= ~0x0030;
473      return ret | 0x00d0 | (eeprom_read_bit(field->port->machine().device("eeprom")) << 5);
473      return ret | 0x00d0 | (eeprom_read_bit(field->machine().device("eeprom")) << 5);
474474   }
475475}
476476
477477static CUSTOM_INPUT( _1c0001c_r )
478478{
479   model2_state *state = field->port->machine().driver_data<model2_state>();
479   model2_state *state = field->machine().driver_data<model2_state>();
480480   UINT32 iptval = 0x00ff;
481481   if(state->m_analog_channel < 4)
482482   {
483483      static const char *const ports[] = { "ANA0", "ANA1", "ANA2", "ANA3" };
484      iptval = input_port_read_safe(field->port->machine(), ports[state->m_analog_channel], 0);
484      iptval = input_port_read_safe(field->machine(), ports[state->m_analog_channel], 0);
485485      ++state->m_analog_channel;
486486   }
487487   return iptval;
src/mame/drivers/gstream.c
r11508r11509
168168   int result;
169169
170170   /* PORT_SERVICE_NO_TOGGLE */
171   result = (input_port_read(field->port->machine(), "IN0") & 0x8000) >> 15;
171   result = (input_port_read(field->machine(), "IN0") & 0x8000) >> 15;
172172
173173   return ~result;
174174}
r11508r11509
178178   int result;
179179
180180   /* IPT_COIN1 */
181   result  = ((input_port_read(field->port->machine(), "IN0") & 0x200) >>  9) << 0;
181   result  = ((input_port_read(field->machine(), "IN0") & 0x200) >>  9) << 0;
182182   /* IPT_COIN2 */
183   result |= ((input_port_read(field->port->machine(), "IN1") & 0x200) >>  9) << 1;
183   result |= ((input_port_read(field->machine(), "IN1") & 0x200) >>  9) << 1;
184184   /* IPT_START1 */
185   result |= ((input_port_read(field->port->machine(), "IN0") & 0x400) >> 10) << 2;
185   result |= ((input_port_read(field->machine(), "IN0") & 0x400) >> 10) << 2;
186186   /* IPT_START2 */
187   result |= ((input_port_read(field->port->machine(), "IN1") & 0x400) >> 10) << 3;
187   result |= ((input_port_read(field->machine(), "IN1") & 0x400) >> 10) << 3;
188188   /* PORT_SERVICE_NO_TOGGLE */
189   result |= ((input_port_read(field->port->machine(), "IN0") & 0x8000) >> 15) << 6;
189   result |= ((input_port_read(field->machine(), "IN0") & 0x8000) >> 15) << 6;
190190
191191   return ~result;
192192}
src/mame/drivers/scramble.c
r11508r11509
475475static CUSTOM_INPUT( ckongs_coinage_r )
476476{
477477   int bit_mask = (FPTR)param;
478   return (input_port_read(field->port->machine(), "FAKE") & bit_mask) ? 0x01 : 0x00;
478   return (input_port_read(field->machine(), "FAKE") & bit_mask) ? 0x01 : 0x00;
479479}
480480
481481
src/mame/drivers/ssingles.c
r11508r11509
288288static CUSTOM_INPUT(controls_r)
289289{
290290   int data = 7;
291   switch(input_port_read(field->port->machine(), "EXTRA"))      //multiplexed
291   switch(input_port_read(field->machine(), "EXTRA"))      //multiplexed
292292   {
293293      case 0x01: data = 1; break;
294294      case 0x02: data = 2; break;
src/mame/drivers/battlex.c
r11508r11509
5757
5858static CUSTOM_INPUT( battlex_in0_b4_r )
5959{
60   battlex_state *state = field->port->machine().driver_data<battlex_state>();
60   battlex_state *state = field->machine().driver_data<battlex_state>();
6161   UINT32 ret = state->m_in0_b4;
6262   if (state->m_in0_b4)
6363   {
64      cputag_set_input_line(field->port->machine(), "maincpu", 0, CLEAR_LINE);
64      cputag_set_input_line(field->machine(), "maincpu", 0, CLEAR_LINE);
6565      state->m_in0_b4 = 0;
6666   }
6767
src/mame/drivers/snes.c
r11508r11509
113113
114114static CUSTOM_INPUT( snes_mouse_speed_input )
115115{
116   snes_state *state = field->port->machine().driver_data<snes_state>();
116   snes_state *state = field->machine().driver_data<snes_state>();
117117   int port = (FPTR)param;
118118
119119   if (snes_ram[OLDJOY1] & 0x1)
r11508r11509
128128
129129static CUSTOM_INPUT( snes_superscope_offscreen_input )
130130{
131   snes_state *state = field->port->machine().driver_data<snes_state>();
131   snes_state *state = field->machine().driver_data<snes_state>();
132132   int port = (FPTR)param;
133133   static const char *const portnames[2][3] =
134134         {
r11508r11509
136136            { "SUPERSCOPE2", "SUPERSCOPE2_X", "SUPERSCOPE2_Y" },
137137         };
138138
139   INT16 x = input_port_read(field->port->machine(), portnames[port][1]);
140   INT16 y = input_port_read(field->port->machine(), portnames[port][2]);
139   INT16 x = input_port_read(field->machine(), portnames[port][1]);
140   INT16 y = input_port_read(field->machine(), portnames[port][2]);
141141
142142   /* these are the theoretical boundaries, but we currently are always onscreen... */
143143   if (x < 0 || x >= SNES_SCR_WIDTH || y < 0 || y >= snes_ppu.beam.last_visible_line)
src/mame/drivers/toaplan2.c
r11508r11509
713713
714714static CUSTOM_INPUT( c2map_r )
715715{
716   toaplan2_state *state = field->port->machine().driver_data<toaplan2_state>();
716   toaplan2_state *state = field->machine().driver_data<toaplan2_state>();
717717
718718   // For Teki Paki hardware
719719   // bit 4 high signifies secondary CPU is ready
src/mame/drivers/cinemat.c
r11508r11509
9999
100100static INPUT_CHANGED( coin_inserted )
101101{
102   cinemat_state *state = field->port->machine().driver_data<cinemat_state>();
102   cinemat_state *state = field->machine().driver_data<cinemat_state>();
103103   /* on the falling edge of a new coin, set the coin_detected flag */
104104   if (newval == 0)
105105      state->m_coin_detected = 1;
src/mame/drivers/crbaloon.c
r11508r11509
7070
7171static CUSTOM_INPUT( pc3092_r )
7272{
73   crbaloon_state *state = field->port->machine().driver_data<crbaloon_state>();
73   crbaloon_state *state = field->machine().driver_data<crbaloon_state>();
7474   UINT32 ret;
7575
7676   /* enable coin & start input? Wild guess!!! */
7777   if (state->m_pc3092_data[1] & 0x02)
78      ret = input_port_read(field->port->machine(), "PC3092");
78      ret = input_port_read(field->machine(), "PC3092");
7979   else
8080      ret = 0x00;
8181
82   if (LOG_PC3092) logerror("%s:  read  PC3092 = 0x%02x\n", field->port->machine().describe_context(), ret);
82   if (LOG_PC3092) logerror("%s:  read  PC3092 = 0x%02x\n", field->machine().describe_context(), ret);
8383
8484   return ret;
8585}
src/mame/drivers/btoads.c
r11508r11509
7272
7373CUSTOM_INPUT( btoads_state::static_main_to_sound_r )
7474{
75   return field->port->machine().driver_data<btoads_state>()->m_main_to_sound_ready;
75   return field->machine().driver_data<btoads_state>()->m_main_to_sound_ready;
7676}
7777
7878
7979CUSTOM_INPUT( btoads_state::static_sound_to_main_r )
8080{
81   return field->port->machine().driver_data<btoads_state>()->m_sound_to_main_ready;
81   return field->machine().driver_data<btoads_state>()->m_sound_to_main_ready;
8282}
8383
8484
src/mame/drivers/redclash.c
r11508r11509
7878*/
7979static INPUT_CHANGED( left_coin_inserted )
8080{
81   ladybug_state *state = field->port->machine().driver_data<ladybug_state>();
81   ladybug_state *state = field->machine().driver_data<ladybug_state>();
8282
8383   if(newval)
8484      device_set_input_line(state->m_maincpu, 0, ASSERT_LINE);
r11508r11509
8686
8787static INPUT_CHANGED( right_coin_inserted )
8888{
89   ladybug_state *state = field->port->machine().driver_data<ladybug_state>();
89   ladybug_state *state = field->machine().driver_data<ladybug_state>();
9090
9191   if(newval)
9292      device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, PULSE_LINE);
src/mame/drivers/vicdual.c
r11508r11509
8383
8484static CUSTOM_INPUT( vicdual_read_coin_status )
8585{
86   vicdual_state *state = field->port->machine().driver_data<vicdual_state>();
86   vicdual_state *state = field->machine().driver_data<vicdual_state>();
8787   return state->m_coin_status;
8888}
8989
r11508r11509
9393   if (newval && !oldval)
9494   {
9595      /* increment the coin counter */
96      coin_counter_w(field->port->machine(), 0, 1);
97      coin_counter_w(field->port->machine(), 0, 0);
96      coin_counter_w(field->machine(), 0, 1);
97      coin_counter_w(field->machine(), 0, 0);
9898
99      cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_RESET, PULSE_LINE);
99      cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_RESET, PULSE_LINE);
100100
101101      /* simulate the coin switch being closed for a while */
102      field->port->machine().scheduler().timer_set(4 * field->port->machine().primary_screen->frame_period(), FUNC(clear_coin_status));
102      field->machine().scheduler().timer_set(4 * field->machine().primary_screen->frame_period(), FUNC(clear_coin_status));
103103   }
104104}
105105
r11508r11509
137137
138138static CUSTOM_INPUT( vicdual_get_64v )
139139{
140   return (get_vcounter(field->port->machine()) >> 6) & 0x01;
140   return (get_vcounter(field->machine()) >> 6) & 0x01;
141141}
142142
143143
144144static CUSTOM_INPUT( vicdual_get_vblank_comp )
145145{
146   return (get_vcounter(field->port->machine()) < VICDUAL_VBSTART);
146   return (get_vcounter(field->machine()) < VICDUAL_VBSTART);
147147}
148148
149149
150150static CUSTOM_INPUT( vicdual_get_composite_blank_comp )
151151{
152   return (vicdual_get_vblank_comp(field, 0) && !field->port->machine().primary_screen->hblank());
152   return (vicdual_get_vblank_comp(device, field, 0) && !field->machine().primary_screen->hblank());
153153}
154154
155155
156156static CUSTOM_INPUT( vicdual_get_timer_value )
157157{
158158   /* return the state of the timer (old code claims "4MHz square wave", but it was toggled once every 2msec, or 500Hz) */
159   return field->port->machine().time().as_ticks(500) & 1;
159   return field->machine().time().as_ticks(500) & 1;
160160}
161161
162162
r11508r11509
16321632static CUSTOM_INPUT( brdrline_lives )
16331633{
16341634   int bit_mask = (FPTR)param;
1635   return (input_port_read(field->port->machine(), "FAKE_LIVES") & bit_mask) ? 0x00 : 0x01;
1635   return (input_port_read(field->machine(), "FAKE_LIVES") & bit_mask) ? 0x00 : 0x01;
16361636}
16371637
16381638static INPUT_PORTS_START( brdrline )
r11508r11509
20532053
20542054static CUSTOM_INPUT( samurai_protection_r )
20552055{
2056   vicdual_state *state = field->port->machine().driver_data<vicdual_state>();
2056   vicdual_state *state = field->machine().driver_data<vicdual_state>();
20572057   int offset = (FPTR)param;
20582058   UINT32 answer = 0;
20592059
src/mame/drivers/welltris.c
r11508r11509
342342
343343static CUSTOM_INPUT( pending_sound_r )
344344{
345   welltris_state *state = field->port->machine().driver_data<welltris_state>();
345   welltris_state *state = field->machine().driver_data<welltris_state>();
346346   return state->m_pending_command ? 1 : 0;
347347}
348348
src/mame/drivers/metro.c
r11508r11509
379379
380380static CUSTOM_INPUT( custom_soundstatus_r )
381381{
382   metro_state *state = field->port->machine().driver_data<metro_state>();
382   metro_state *state = field->machine().driver_data<metro_state>();
383383   return (state->m_busy_sndcpu ? 0x01 : 0x00);
384384}
385385
src/mame/drivers/rgum.c
r11508r11509
8181
8282static CUSTOM_INPUT( rgum_heartbeat_r )
8383{
84   rgum_state *state = field->port->machine().driver_data<rgum_state>();
84   rgum_state *state = field->machine().driver_data<rgum_state>();
8585
8686   state->m_hbeat ^= 1;
8787
src/mame/drivers/zaccaria.c
r11508r11509
342342
343343static CUSTOM_INPUT( acs_r )
344344{
345   zaccaria_state *state = field->port->machine().driver_data<zaccaria_state>();
345   zaccaria_state *state = field->machine().driver_data<zaccaria_state>();
346346   return (state->m_acs & 0x08) ? 1 : 0;
347347}
348348
src/mame/drivers/cheekyms.c
r11508r11509
1414
1515static INPUT_CHANGED( coin_inserted )
1616{
17   cheekyms_state *state = field->port->machine().driver_data<cheekyms_state>();
17   cheekyms_state *state = field->machine().driver_data<cheekyms_state>();
1818
1919   /* this starts a 556 one-shot timer (and triggers a sound effect) */
2020   if (newval)
src/mame/drivers/asteroid.c
r11508r11509
308308
309309static CUSTOM_INPUT( clock_r )
310310{
311   return (field->port->machine().device<cpu_device>("maincpu")->total_cycles() & 0x100) ? 1 : 0;
311   return (field->machine().device<cpu_device>("maincpu")->total_cycles() & 0x100) ? 1 : 0;
312312}
313313
314314static INPUT_PORTS_START( asteroid )
src/mame/drivers/fromanc2.c
r11508r11509
7575
7676static CUSTOM_INPUT( subcpu_int_r )
7777{
78   fromanc2_state *state = field->port->machine().driver_data<fromanc2_state>();
78   fromanc2_state *state = field->machine().driver_data<fromanc2_state>();
7979   return state->m_subcpu_int_flag & 0x01;
8080}
8181
8282static CUSTOM_INPUT( sndcpu_nmi_r )
8383{
84   fromanc2_state *state = field->port->machine().driver_data<fromanc2_state>();
84   fromanc2_state *state = field->machine().driver_data<fromanc2_state>();
8585   return state->m_sndcpu_nmi_flag & 0x01;
8686}
8787
8888static CUSTOM_INPUT( subcpu_nmi_r )
8989{
90   fromanc2_state *state = field->port->machine().driver_data<fromanc2_state>();
90   fromanc2_state *state = field->machine().driver_data<fromanc2_state>();
9191   return state->m_subcpu_nmi_flag & 0x01;
9292}
9393
r11508r11509
416416   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eeprom_set_cs_line)
417417INPUT_PORTS_END
418418
419#ifdef UNREFERENCED_CODE
419420static INPUT_PORTS_START( fromancr )
420421   PORT_INCLUDE( fromanc2 )
421422
r11508r11509
424425   PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eeprom_set_clock_line)
425426   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eeprom_set_cs_line)
426427INPUT_PORTS_END
428#endif
427429
428430static INPUT_PORTS_START( fromanc4 )
429431   PORT_INCLUDE( fromanc2 )
src/mame/drivers/arcadia.c
r11508r11509
157157static CUSTOM_INPUT( coin_counter_r )
158158{
159159   int coin = (FPTR)param;
160   UINT8 *coin_counter = field->port->machine().driver_data<arcadia_state>()->coin_counter;
160   UINT8 *coin_counter = field->machine().driver_data<arcadia_state>()->coin_counter;
161161
162162   /* return coin counter values */
163163   return coin_counter[coin] & 3;
r11508r11509
167167static INPUT_CHANGED( coin_changed_callback )
168168{
169169   int coin = (FPTR)param;
170   UINT8 *coin_counter = field->port->machine().driver_data<arcadia_state>()->coin_counter;
170   UINT8 *coin_counter = field->machine().driver_data<arcadia_state>()->coin_counter;
171171
172172   /* check for a 0 -> 1 transition */
173173   if (!oldval && newval && coin_counter[coin] < 3)
src/mame/drivers/xain.c
r11508r11509
276276
277277static CUSTOM_INPUT( xain_vblank_r )
278278{
279   xain_state *state = field->port->machine().driver_data<xain_state>();
279   xain_state *state = field->machine().driver_data<xain_state>();
280280   return state->m_vblank;
281281}
282282
r11508r11509
368368
369369static CUSTOM_INPUT( mcu_status_r )
370370{
371   xain_state *state = field->port->machine().driver_data<xain_state>();
371   xain_state *state = field->machine().driver_data<xain_state>();
372372   UINT8 res = 0;
373373
374   if (field->port->machine().device("mcu") != NULL)
374   if (field->machine().device("mcu") != NULL)
375375   {
376376      if (state->m_mcu_ready == 1)
377377         res |= 0x01;
src/mame/drivers/galdrvr.c
r11508r11509
23542354
23552355static CUSTOM_INPUT( moonwar_dial_r )
23562356{
2357   galaxian_state *state = field->port->machine().driver_data<galaxian_state>();
2357   galaxian_state *state = field->machine().driver_data<galaxian_state>();
23582358   static const char *const dialname[2] = { "P1_DIAL", "P2_DIAL" };
23592359   int p = (~state->m_moonwar_port_select >> 4) & 1;
23602360
23612361   // see http://www.cityofberwyn.com/schematics/stern/MoonWar_opto.tiff for schematic
23622362   // I.e. a 74ls161 counts from 0 to 15 which is the absolute number of bars passed on the quadrature
23632363
2364   signed char dialread = input_port_read(field->port->machine(), dialname[p]);
2364   signed char dialread = input_port_read(field->machine(), dialname[p]);
23652365
23662366   UINT8 ret;
23672367
src/mame/drivers/gundealr.c
r11508r11509
4848
4949#include "emu.h"
5050#include "cpu/z80/z80.h"
51#include "deprecat.h"
5251#include "sound/2203intf.h"
5352#include "includes/gundealr.h"
5453
55
56static INTERRUPT_GEN( yamyam_interrupt )
57{
58   gundealr_state *state = device->machine().driver_data<gundealr_state>();
59
60   if (cpu_getiloops(device) == 0)
61   {
62      if (state->m_input_ports_hack)
63      {
64         state->m_rambase[0x004] = input_port_read(device->machine(), "IN2");
65         state->m_rambase[0x005] = input_port_read(device->machine(), "IN1");
66         state->m_rambase[0x006] = input_port_read(device->machine(), "IN0");
67      }
68      device_set_input_line_and_vector(device, 0, HOLD_LINE, 0xd7);   /* RST 10h vblank */
69   }
70   else if ((cpu_getiloops(device) & 1) == 1)
71      device_set_input_line_and_vector(device, 0, HOLD_LINE, 0xcf);   /* RST 08h sound (hand tuned) */
72}
73
7454static WRITE8_HANDLER( yamyam_bankswitch_w )
7555{
7656   memory_set_bank(space->machine(), "bank1", data & 0x07);
7757}
7858
79static WRITE8_HANDLER( yamyam_protection_w )
80{
81   gundealr_state *state = space->machine().driver_data<gundealr_state>();
82   logerror("e000 = %02x\n", state->m_rambase[0x000]);
83   state->m_rambase[0x000] = data;
84   if (data == 0x03) state->m_rambase[0x001] = 0x03;
85   if (data == 0x04) state->m_rambase[0x001] = 0x04;
86   if (data == 0x05) state->m_rambase[0x001] = 0x05;
87   if (data == 0x0a) state->m_rambase[0x001] = 0x08;
88   if (data == 0x0d) state->m_rambase[0x001] = 0x07;
8959
90   if (data == 0x03)
91   {
92      /*
93        read dip switches
94        3a 00 c0  ld   a,($c000)
95        47        ld   b,a
96        3a 01 c0  ld   a,($c001)
97        c9        ret
98        */
99      state->m_rambase[0x010] = 0x3a;
100      state->m_rambase[0x011] = 0x00;
101      state->m_rambase[0x012] = 0xc0;
102      state->m_rambase[0x013] = 0x47;
103      state->m_rambase[0x014] = 0x3a;
104      state->m_rambase[0x015] = 0x01;
105      state->m_rambase[0x016] = 0xc0;
106      state->m_rambase[0x017] = 0xc9;
107   }
10860
109   if (data == 0x05)
110   {
111      /*
112        add a to hl
113        c5        push    bc
114        010000    ld      bc,#0000
115        4f        ld      c,a
116        09        add     hl,bc
117        c1        pop     bc
118        c9        ret
119        */
120      state->m_rambase[0x020] = 0xc5;
121      state->m_rambase[0x021] = 0x01;
122      state->m_rambase[0x022] = 0x00;
123      state->m_rambase[0x023] = 0x00;
124      state->m_rambase[0x024] = 0x4f;
125      state->m_rambase[0x025] = 0x09;
126      state->m_rambase[0x026] = 0xc1;
127      state->m_rambase[0x027] = 0xc9;
128      /*
129        lookup data in table
130        cd20e0    call    #e020
131        7e        ld      a,(hl)
132        c9        ret
133        */
134      state->m_rambase[0x010] = 0xcd;
135      state->m_rambase[0x011] = 0x20;
136      state->m_rambase[0x012] = 0xe0;
137      state->m_rambase[0x013] = 0x7e;
138      state->m_rambase[0x014] = 0xc9;
139   }
140}
141
142
143
14461static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8 )
14562   AM_RANGE(0x0000, 0x7fff) AM_ROM
14663   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
r11508r11509
466383   state->m_scroll[3] = 0;
467384}
468385
386static TIMER_DEVICE_CALLBACK( gundealr_scanline )
387{
388   int scanline = param;
389
390   if(scanline == 240) // vblank-out irq
391      cputag_set_input_line_and_vector(timer.machine(), "maincpu", 0, HOLD_LINE,0xd7); /* RST 10h */
392   else if((scanline == 0) || (scanline == 120) ) //timer irq
393      cputag_set_input_line_and_vector(timer.machine(), "maincpu", 0, HOLD_LINE,0xcf); /* RST 10h */
394}
395
396static const ym2203_interface ym2203_config =
397{
398   {
399      AY8910_LEGACY_OUTPUT,
400      AY8910_DEFAULT_LOADS,
401      DEVCB_NULL,
402      DEVCB_NULL,
403      DEVCB_NULL,
404      DEVCB_NULL
405   },
406   NULL
407};
408
469409static MACHINE_CONFIG_START( gundealr, gundealr_state )
470410
471411   /* basic machine hardware */
472412   MCFG_CPU_ADD("maincpu", Z80, 8000000)   /* 8 MHz ??? */
473413   MCFG_CPU_PROGRAM_MAP(main_map)
474414   MCFG_CPU_IO_MAP(main_portmap)
475   MCFG_CPU_VBLANK_INT_HACK(yamyam_interrupt,4)   /* ? */
415   MCFG_TIMER_ADD_SCANLINE("scantimer", gundealr_scanline, "screen", 0, 1)
476416
477417   MCFG_MACHINE_START(gundealr)
478418   MCFG_MACHINE_RESET(gundealr)
r11508r11509
495435   MCFG_SPEAKER_STANDARD_MONO("mono")
496436
497437   MCFG_SOUND_ADD("ymsnd", YM2203, 1500000)
438   MCFG_SOUND_CONFIG(ym2203_config)
498439   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
499440MACHINE_CONFIG_END
500441
442static TIMER_DEVICE_CALLBACK( yamyam_mcu_sim )
443{
444   gundealr_state *state = timer.machine().driver_data<gundealr_state>();
445   static const UINT8 snipped_cmd03[8] = { 0x3a, 0x00, 0xc0, 0x47, 0x3a, 0x01, 0xc0, 0xc9 };
446   static const UINT8 snipped_cmd05_1[5] = { 0xcd, 0x20, 0xe0, 0x7e, 0xc9 };
447   static const UINT8 snipped_cmd05_2[8] = { 0xc5, 0x01, 0x00, 0x00, 0x4f, 0x09, 0xc1, 0xc9 };
501448
449   int i;
502450
451   //logerror("e000 = %02x\n", state->m_rambase[0x000]);
452   switch(state->m_rambase[0x000])
453   {
454      case 0x03:
455         state->m_rambase[0x001] = 0x03;
456         /*
457                 read dip switches
458                 3a 00 c0  ld   a,($c000)
459              47        ld   b,a
460              3a 01 c0  ld   a,($c001)
461              c9        ret
462           */
463           for(i=0;i<8;i++)
464              state->m_rambase[0x010+i] = snipped_cmd03[i];
465
466         break;
467      case 0x04:
468         state->m_rambase[0x001] = 0x04;
469         break;
470      case 0x05:
471         state->m_rambase[0x001] = 0x05;
472         /*
473                 add a to hl
474              c5          push    bc
475              01 00 00    ld      bc,#0000
476              4f          ld      c,a
477              09          add     hl,bc
478              c1          pop     bc
479              c9          ret
480           */
481           for(i=0;i<8;i++)
482            state->m_rambase[0x020+i] = snipped_cmd05_2[i];
483
484         /*
485              lookup data in table
486              cd 20 e0    call    #e020
487              7e          ld      a,(hl)
488              c9          ret
489           */
490           for(i=0;i<5;i++)
491            state->m_rambase[0x010+i] = snipped_cmd05_1[i];
492
493         break;
494      case 0x0a:
495         state->m_rambase[0x001] = 0x08;
496         break;
497      case 0x0d:
498         state->m_rambase[0x001] = 0x07;
499         break;
500   }
501
502   state->m_rambase[0x004] = input_port_read(timer.machine(), "IN2");
503   state->m_rambase[0x005] = input_port_read(timer.machine(), "IN1");
504   state->m_rambase[0x006] = input_port_read(timer.machine(), "IN0");
505}
506
507static MACHINE_CONFIG_DERIVED( yamyam, gundealr )
508
509   MCFG_TIMER_ADD_PERIODIC("mcusim", yamyam_mcu_sim, attotime::from_hz(8000000/60)) // not real, but for simulating the MCU
510MACHINE_CONFIG_END
511
512
503513/***************************************************************************
504514
505515  Game driver(s)
r11508r11509
547557   ROM_LOAD( "b3.f10",       0x00000, 0x20000, CRC(96ae9088) SHA1(a605882dcdcf1e8cf8b0112f614e696d59acfd97) )
548558   ROM_RELOAD(               0x10000, 0x20000 )   /* banked at 0x8000-0xbfff */
549559
560   ROM_REGION( 0x10000, "mcu", 0 ) //unknown type, there must be one
561   ROM_LOAD( "mcu", 0x0000, 0x10000, NO_DUMP)
562
550563   ROM_REGION( 0x10000, "gfx1", 0 )
551564   ROM_LOAD( "b2.d16",       0x00000, 0x10000, CRC(cb4f84ee) SHA1(54319ecbd74b763757eb6d17c8f7be0705ab0714) )
552565
r11508r11509
560573   ROM_LOAD( "b3.f10",       0x00000, 0x20000, CRC(96ae9088) SHA1(a605882dcdcf1e8cf8b0112f614e696d59acfd97) )
561574   ROM_RELOAD(               0x10000, 0x20000 )   /* banked at 0x8000-0xbfff */
562575
576   ROM_REGION( 0x10000, "mcu", 0 ) //unknown type, there must be one
577   ROM_LOAD( "mcu", 0x0000, 0x10000, NO_DUMP)
578
563579   ROM_REGION( 0x10000, "gfx1", 0 )
564580   ROM_LOAD( "wguyb2.bin",   0x00000, 0x10000, CRC(1c684c46) SHA1(041bc500e31b02a8bf3ce4683a67de998f938ccc) )
565581
r11508r11509
569585
570586
571587
572static DRIVER_INIT( gundealr )
573{
574   gundealr_state *state = machine.driver_data<gundealr_state>();
575   state->m_input_ports_hack = 0;
576}
577588
578static DRIVER_INIT( yamyam )
579{
580   gundealr_state *state = machine.driver_data<gundealr_state>();
581   state->m_input_ports_hack = 1;
582   machine.device("maincpu")->memory().space(AS_PROGRAM)->install_legacy_write_handler(0xe000, 0xe000, FUNC(yamyam_protection_w));
583}
584589
585590
586
587GAME( 1990, gundealr,  0,        gundealr, gundealr, gundealr, ROT270, "Dooyong", "Gun Dealer",                GAME_SUPPORTS_SAVE )
588GAME( 19??, gundealra, gundealr, gundealr, gundealr, gundealr, ROT270, "Dooyong", "Gun Dealer (alt card set)", GAME_SUPPORTS_SAVE )
589GAME( 1990, gundealrt, gundealr, gundealr, gundealt, gundealr, ROT270, "Dooyong (Tecmo license)", "Gun Dealer (Korea)", GAME_SUPPORTS_SAVE )
590GAME( 1990, yamyam,    0,        gundealr, yamyam,   yamyam,   ROT0,   "Dooyong", "Yam! Yam!?",                GAME_SUPPORTS_SAVE )
591GAME( 1990, wiseguy,   yamyam,   gundealr, yamyam,   yamyam,   ROT0,   "Dooyong", "Wise Guy",                  GAME_SUPPORTS_SAVE )
591GAME( 1990, gundealr,  0,        gundealr, gundealr, 0, ROT270, "Dooyong", "Gun Dealer",                GAME_SUPPORTS_SAVE )
592GAME( 19??, gundealra, gundealr, gundealr, gundealr, 0, ROT270, "Dooyong", "Gun Dealer (alt card set)", GAME_SUPPORTS_SAVE )
593GAME( 1990, gundealrt, gundealr, gundealr, gundealt, 0, ROT270, "Dooyong (Tecmo license)", "Gun Dealer (Korea)", GAME_SUPPORTS_SAVE )
594GAME( 1990, yamyam,    0,        yamyam,   yamyam,   0, ROT0,   "Dooyong", "Yam! Yam!?",                GAME_SUPPORTS_SAVE )
595GAME( 1990, wiseguy,   yamyam,   yamyam,   yamyam,   0, ROT0,   "Dooyong", "Wise Guy",                  GAME_SUPPORTS_SAVE )
src/mame/drivers/firefox.c
r11508r11509
265265
266266static CUSTOM_INPUT( mainflag_r )
267267{
268   firefox_state *state = field->port->machine().driver_data<firefox_state>();
268   firefox_state *state = field->machine().driver_data<firefox_state>();
269269   return state->m_main_to_sound_flag;
270270}
271271
272272static CUSTOM_INPUT( soundflag_r )
273273{
274   firefox_state *state = field->port->machine().driver_data<firefox_state>();
274   firefox_state *state = field->machine().driver_data<firefox_state>();
275275   return state->m_sound_to_main_flag;
276276}
277277
src/mame/drivers/renegade.c
r11508r11509
608608
609609static CUSTOM_INPUT( mcu_status_r )
610610{
611   renegade_state *state = field->port->machine().driver_data<renegade_state>();
611   renegade_state *state = field->machine().driver_data<renegade_state>();
612612   UINT8 res = 0;
613613
614614   if (state->m_mcu_sim == TRUE)
src/mame/drivers/missile.c
r11508r11509
450450
451451static CUSTOM_INPUT( get_vblank )
452452{
453   missile_state *state = field->port->machine().driver_data<missile_state>();
454   int v = scanline_to_v(state, field->port->machine().primary_screen->vpos());
453   missile_state *state = field->machine().driver_data<missile_state>();
454   int v = scanline_to_v(state, field->machine().primary_screen->vpos());
455455   return v < 24;
456456}
457457
src/mame/drivers/jack.c
r11508r11509
8383
8484static CUSTOM_INPUT( sound_check_r )
8585{
86   jack_state *state = field->port->machine().driver_data<jack_state>();
86   jack_state *state = field->machine().driver_data<jack_state>();
8787   UINT8 ret = 0;
8888
89   if ((input_port_read(field->port->machine(), "IN2") & 0x80) && !state->m_joinem_snd_bit)
89   if ((input_port_read(field->machine(), "IN2") & 0x80) && !state->m_joinem_snd_bit)
9090      ret = 1;
9191
9292   return ret;
src/mame/drivers/taitosj.c
r11508r11509
193193
194194static CUSTOM_INPUT( input_port_4_f0_r )
195195{
196   taitosj_state *state = field->port->machine().driver_data<taitosj_state>();
196   taitosj_state *state = field->machine().driver_data<taitosj_state>();
197197   return state->m_input_port_4_f0;
198198}
199199
r11508r11509
282282
283283static CUSTOM_INPUT( kikstart_gear_r )
284284{
285   taitosj_state *state = field->port->machine().driver_data<taitosj_state>();
285   taitosj_state *state = field->machine().driver_data<taitosj_state>();
286286   const char *port_tag;
287287
288288   int player = (int)(FPTR)param;
r11508r11509
293293      port_tag = "GEARP2";
294294
295295   /* gear MUST be 1, 2 or 3 */
296   if (input_port_read(field->port->machine(), port_tag) & 0x01) state->m_kikstart_gears[player] = 0x02;
297   if (input_port_read(field->port->machine(), port_tag) & 0x02) state->m_kikstart_gears[player] = 0x03;
298   if (input_port_read(field->port->machine(), port_tag) & 0x04) state->m_kikstart_gears[player] = 0x01;
296   if (input_port_read(field->machine(), port_tag) & 0x01) state->m_kikstart_gears[player] = 0x02;
297   if (input_port_read(field->machine(), port_tag) & 0x02) state->m_kikstart_gears[player] = 0x03;
298   if (input_port_read(field->machine(), port_tag) & 0x04) state->m_kikstart_gears[player] = 0x01;
299299
300300   return state->m_kikstart_gears[player];
301301}
src/mame/drivers/snk6502.c
r11508r11509
306306
307307static CUSTOM_INPUT( snk6502_music0_r )
308308{
309   return (snk6502_music0_playing(field->port->machine()) ? 0x01 : 0x00);
309   return (snk6502_music0_playing(field->machine()) ? 0x01 : 0x00);
310310}
311311
312312static CUSTOM_INPUT( sasuke_count_r )
313313{
314   snk6502_state *state = field->port->machine().driver_data<snk6502_state>();
314   snk6502_state *state = field->machine().driver_data<snk6502_state>();
315315
316316   return (state->m_sasuke_counter >> 4);
317317}
src/mame/drivers/exidy440.c
r11508r11509
256256{
257257   /* if we got a coin, set the IRQ on the main CPU */
258258   if (newval == 0)
259      cputag_set_input_line(field->port->machine(), "maincpu", 0, ASSERT_LINE);
259      cputag_set_input_line(field->machine(), "maincpu", 0, ASSERT_LINE);
260260}
261261
262262
r11508r11509
269269
270270static CUSTOM_INPUT( firq_beam_r )
271271{
272   exidy440_state *state = field->port->machine().driver_data<exidy440_state>();
272   exidy440_state *state = field->machine().driver_data<exidy440_state>();
273273   return state->m_firq_beam;
274274}
275275
276276
277277static CUSTOM_INPUT( firq_vblank_r )
278278{
279   exidy440_state *state = field->port->machine().driver_data<exidy440_state>();
279   exidy440_state *state = field->machine().driver_data<exidy440_state>();
280280   return state->m_firq_vblank;
281281}
282282
r11508r11509
284284static CUSTOM_INPUT( hitnmiss_button1_r )
285285{
286286   /* button 1 shows up in two bits */
287   UINT32 button1 = input_port_read(field->port->machine(), "HITNMISS_BUTTON1");
287   UINT32 button1 = input_port_read(field->machine(), "HITNMISS_BUTTON1");
288288   return (button1 << 1) | button1;
289289}
290290
src/mame/drivers/r2dtank.c
r11508r11509
228228
229229static CUSTOM_INPUT( get_ttl74123_output )
230230{
231   r2dtank_state *state = field->port->machine().driver_data<r2dtank_state>();
231   r2dtank_state *state = field->machine().driver_data<r2dtank_state>();
232232   return state->m_ttl74123_output;
233233}
234234
src/mame/drivers/fantland.c
r11508r11509
730730static CUSTOM_INPUT( wheelrun_wheel_r )
731731{
732732   int player = (FPTR)param;
733   int delta = input_port_read(field->port->machine(), player ? "WHEEL1" : "WHEEL0");
733   int delta = input_port_read(field->machine(), player ? "WHEEL1" : "WHEEL0");
734734   delta = (delta & 0x7f) - (delta & 0x80) + 4;
735735
736736   if      (delta > 7)   delta = 7;
src/mame/drivers/galaxi.c
r11508r11509
261261
262262static CUSTOM_INPUT( ticket_r )
263263{
264   galaxi_state *state = field->port->machine().driver_data<galaxi_state>();
265   return state->m_ticket && !(field->port->machine().primary_screen->frame_number() % 10);
264   galaxi_state *state = field->machine().driver_data<galaxi_state>();
265   return state->m_ticket && !(field->machine().primary_screen->frame_number() % 10);
266266}
267267
268268static CUSTOM_INPUT( hopper_r )
269269{
270   galaxi_state *state = field->port->machine().driver_data<galaxi_state>();
271   return state->m_hopper && !(field->port->machine().primary_screen->frame_number() % 10);
270   galaxi_state *state = field->machine().driver_data<galaxi_state>();
271   return state->m_hopper && !(field->machine().primary_screen->frame_number() % 10);
272272}
273273
274274
src/mame/drivers/cd32.c
r11508r11509
230230
231231static CUSTOM_INPUT(cubo_input)
232232{
233   cd32_state *state = field->port->machine().driver_data<cd32_state>();
234   return handle_joystick_potgor(field->port->machine(), state->m_potgo_value) >> 10;
233   cd32_state *state = field->machine().driver_data<cd32_state>();
234   return handle_joystick_potgor(field->machine(), state->m_potgo_value) >> 10;
235235}
236236
237237static INPUT_PORTS_START( cd32 )
src/mame/drivers/ultratnk.c
r11508r11509
2020
2121static CUSTOM_INPUT( get_collision )
2222{
23   ultratnk_state *state = field->port->machine().driver_data<ultratnk_state>();
23   ultratnk_state *state = field->machine().driver_data<ultratnk_state>();
2424   return state->m_collision[(FPTR) param];
2525}
2626
2727
2828static CUSTOM_INPUT( get_joystick )
2929{
30   ultratnk_state *state = field->port->machine().driver_data<ultratnk_state>();
31   UINT8 joy = input_port_read(field->port->machine(), (const char *)param) & 3;
30   ultratnk_state *state = field->machine().driver_data<ultratnk_state>();
31   UINT8 joy = input_port_read(field->machine(), (const char *)param) & 3;
3232
3333   if (joy == 1)
3434   {
src/mame/drivers/astrocdh.c
r11508r11509
9090static INPUT_CHANGED( set_write_protect )  // run when RAM expansion write protect switch is changed
9191{
9292   int ram_expansion_installed = 0, write_protect_on = 0, expansion_ram_start = 0, expansion_ram_end = 0, shadow_ram_end = 0;
93   address_space *space = field->port->machine().device("maincpu")->memory().space(AS_PROGRAM);
94   UINT8 *expram = ram_get_ptr(field->port->machine().device("ram_tag"));
93   address_space *space = field->machine().device("maincpu")->memory().space(AS_PROGRAM);
94   UINT8 *expram = ram_get_ptr(field->machine().device("ram_tag"));
9595
9696   get_ram_expansion_settings(space, ram_expansion_installed, write_protect_on, expansion_ram_start, expansion_ram_end, shadow_ram_end);  // passing by reference
9797
src/mame/drivers/astinvad.c
r11508r11509
275275
276276static INPUT_CHANGED( spaceint_coin_inserted )
277277{
278   astinvad_state *state = field->port->machine().driver_data<astinvad_state>();
278   astinvad_state *state = field->machine().driver_data<astinvad_state>();
279279   /* coin insertion causes an NMI */
280280   device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
281281}
src/mame/drivers/halleys.c
r11508r11509
1919      instead of costly bitmaps.
2020    - Ben Bero Beh has collision problems with the falling fireballs and a minor
2121      priority glitch with the "Elevator Action" baddies.
22    - IRQ system needs a complete rewrite
23    - De-achoize the blitter code
2224
2325    * Halley's Comet's undocumented DIP switches only work if the player1 start button
2426      is depressed during boot-up.
r11508r11509
160162#include "emu.h"
161163#include "cpu/z80/z80.h"
162164#include "includes/taitoipt.h"
163#include "deprecat.h"
164165#include "cpu/m6809/m6809.h"
165166#include "sound/ay8910.h"
166167
r11508r11509
15261527//**************************************************************************
15271528// Interrupt and Hardware Handlers
15281529
1529static INTERRUPT_GEN( halleys_interrupt )
1530
1531static TIMER_DEVICE_CALLBACK( halleys_scanline )
15301532{
1531   halleys_state *state = device->machine().driver_data<halleys_state>();
1532   UINT8 latch_data;
1533   halleys_state *state = timer.machine().driver_data<halleys_state>();
1534   int scanline = param;
15331535
1534   switch (cpu_getiloops(device))
1536   /* TODO: fix this */
1537   switch (scanline)
15351538   {
1536      case 0:
1537         /*
1538                How the custom chips handle sound latching is largely unknown.
1539                Halley's Comet dumps sound commands to register ff8a so
1540                rapidly the AY8910 core sometimes fails to reset itself and
1541                the music stops. Masking sound NMI is not enough to ensure
1542                successive writes are processed properly so it is advisable to
1543                queue sound commands or make the main CPU yield for a minimum
1544                of 600 Z80 cycles. Furthermore, soundlatch NMI interval should
1545                not be too much shorter than music IRQ's period(27306667ns),
1546                and must be longer in case of a reset(00).
1547
1548                Current implementation is quite safe although not 100% foul-proof.
1549            */
1550         if (state->m_latch_delay) state->m_latch_delay--; else
1551         if (state->m_ffcount)
1552         {
1553            state->m_ffcount--;
1554            latch_data = state->m_sound_fifo[state->m_fftail];
1555            state->m_fftail = (state->m_fftail + 1) & (MAX_SOUNDS - 1);
1556            state->m_latch_delay = (latch_data) ? 0 : 4;
1557            soundlatch_w( device->memory().space(AS_PROGRAM), 0, latch_data);
1558            cputag_set_input_line(device->machine(), "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
1559         }
1560
1539      case 248:
15611540         // clear collision list of this frame unconditionally
15621541         state->m_collision_count = 0;
1563      break;
1542         break;
15641543
15651544      // In Halley's Comet, NMI is used exclusively to handle coin input
1566      case 1:
1567         device_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
1568      break;
1545      case 56*3:
1546         cputag_set_input_line(timer.machine(),"maincpu", INPUT_LINE_NMI, PULSE_LINE);
1547         break;
15691548
15701549      // FIRQ drives gameplay; we need both types of NMI each frame.
1571      case 2:
1572         state->m_mVectorType = 1; device_set_input_line(device, M6809_FIRQ_LINE, ASSERT_LINE);
1573      break;
1550      case 56*2:
1551         state->m_mVectorType = 1; cputag_set_input_line(timer.machine(),"maincpu", M6809_FIRQ_LINE, ASSERT_LINE);
1552         break;
15741553
1575      case 3:
1576         state->m_mVectorType = 0; device_set_input_line(device, M6809_FIRQ_LINE, ASSERT_LINE);
1577      break;
1554      case 56:
1555         state->m_mVectorType = 0; cputag_set_input_line(timer.machine(),"maincpu", M6809_FIRQ_LINE, ASSERT_LINE);
1556         break;
15781557   }
15791558}
15801559
15811560
1582static INTERRUPT_GEN( benberob_interrupt )
1561static TIMER_DEVICE_CALLBACK( benberob_scanline )
15831562{
1584   halleys_state *state = device->machine().driver_data<halleys_state>();
1585   UINT8 latch_data;
1563   halleys_state *state = timer.machine().driver_data<halleys_state>();
1564   int scanline = param;
15861565
1587   switch (cpu_getiloops(device))
1566   /* TODO: fix this */
1567   switch (scanline)
15881568   {
1589      case 0:
1590         if (state->m_latch_delay) state->m_latch_delay--; else
1591         if (state->m_ffcount)
1592         {
1593            state->m_ffcount--;
1594            latch_data = state->m_sound_fifo[state->m_fftail];
1595            state->m_fftail = (state->m_fftail + 1) & (MAX_SOUNDS - 1);
1596            state->m_latch_delay = (latch_data) ? 0 : 4;
1597            soundlatch_w(device->memory().space(AS_PROGRAM), 0, latch_data);
1598            cputag_set_input_line(device->machine(), "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
1599         }
1600      break;
1569      case 248:
1570         break;
16011571
1602      case 1:
1603         device_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
1604      break;
1572      case 56*3:
1573         cputag_set_input_line(timer.machine(),"maincpu", INPUT_LINE_NMI, PULSE_LINE);
1574         break;
16051575
1606      case 2:
1607      case 3:
1576      case 56*2:
1577      case 56*1:
16081578         // FIRQ must not happen when the blitter is being updated or it'll cause serious screen artifacts
1609         if (!state->m_blitter_busy) device_set_input_line(device, M6809_FIRQ_LINE, ASSERT_LINE); else state->m_firq_level++;
1610      break;
1579         if (!state->m_blitter_busy) cputag_set_input_line(timer.machine(),"maincpu", M6809_FIRQ_LINE, ASSERT_LINE); else state->m_firq_level++;
1580         break;
16111581   }
16121582}
16131583
r11508r11509
16391609static WRITE8_HANDLER( soundcommand_w )
16401610{
16411611   halleys_state *state = space->machine().driver_data<halleys_state>();
1642   if (state->m_ffcount < MAX_SOUNDS)
1643   {
1644      state->m_ffcount++;
1645      state->m_sound_fifo[state->m_ffhead] = state->m_io_ram[0x8a] = data;
1646      state->m_ffhead = (state->m_ffhead + 1) & (MAX_SOUNDS - 1);
1647   }
1612
1613   state->m_io_ram[0x8a] = data;
1614   soundlatch_w(space,offset,data);
1615   cputag_set_input_line(space->machine(), "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
16481616}
16491617
16501618
r11508r11509
17331701   PORT_DIPSETTING(    0x08, "3" )
17341702   PORT_DIPSETTING(    0x10, "4" )
17351703   PORT_DIPSETTING(    0x18, "5" )
1736   PORT_DIPSETTING(    0x00, "Infinite (Cheat)" )
1704   PORT_DIPSETTING(    0x00, DEF_STR( Infinite ) )
17371705   PORT_DIPUNKNOWN( 0x20, IP_ACTIVE_LOW )
17381706   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Flip_Screen ) )      /* TO DO : confirm OFF/ON when screen flipping emulated */
17391707   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
r11508r11509
17961764   PORT_DIPNAME( 0x20, 0x20, "Show Year" )
17971765   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
17981766   PORT_DIPSETTING(    0x20, DEF_STR( Yes ) )
1799   PORT_DIPNAME( 0x40, 0x40, "No Hit (Cheat)" )
1767   PORT_DIPNAME( 0x40, 0x40, "No Hit" )
18001768   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
18011769   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
18021770   PORT_DIPNAME( 0x80, 0x80, "Maximum Credits" )
r11508r11509
18751843       However, they enable debug features if you press START1 during the boot sequence. */
18761844   PORT_START("DSW3")   /* 0xff97 */
18771845   PORT_DIPUNUSED_DIPLOC( 0x01, IP_ACTIVE_LOW, "SW2:1" )
1878   PORT_DIPNAME( 0x02, 0x02, "Free Play (Cheat)" )         PORT_DIPLOCATION("SW2:2")
1846   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Free_Play ) )         PORT_DIPLOCATION("SW2:2")
18791847   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
18801848   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1881   PORT_DIPNAME( 0x1c, 0x1c, "Start Area (Cheat)" )        PORT_DIPLOCATION("SW2:3,4,5")
1849   PORT_DIPNAME( 0x1c, 0x1c, "Start Area" )        PORT_DIPLOCATION("SW2:3,4,5")
18821850   PORT_DIPSETTING( 0x1c, "1 (Earth)" )
18831851   PORT_DIPSETTING( 0x18, "4 (Venus)" )
18841852   PORT_DIPSETTING( 0x14, "7 (Mercury)" )
r11508r11509
18881856   PORT_DIPSETTING( 0x04, "19 (Uranus)" )
18891857   PORT_DIPSETTING( 0x00, "22 (Saturn)" )
18901858   PORT_DIPUNUSED_DIPLOC( 0x20, IP_ACTIVE_LOW, "SW2:6" )
1891   PORT_DIPNAME( 0x40, 0x40, "Invincibility (Cheat)")      PORT_DIPLOCATION("SW2:7")
1859   PORT_DIPNAME( 0x40, 0x40, "Invincibility")      PORT_DIPLOCATION("SW2:7")
18921860   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
18931861   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1894   PORT_DIPNAME( 0x80, 0x80, "Infinite Lives (Cheat)" )    PORT_DIPLOCATION("SW2:8")
1862   PORT_DIPNAME( 0x80, 0x80, "Infinite Lives" )    PORT_DIPLOCATION("SW2:8")
18951863   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
18961864   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
18971865
r11508r11509
19831951static MACHINE_CONFIG_START( halleys, halleys_state )
19841952   MCFG_CPU_ADD("maincpu", M6809, XTAL_19_968MHz/12) /* verified on pcb */
19851953   MCFG_CPU_PROGRAM_MAP(halleys_map)
1986   MCFG_CPU_VBLANK_INT_HACK(halleys_interrupt, 4)
1954   MCFG_TIMER_ADD_SCANLINE("scantimer", halleys_scanline, "screen", 0, 1)
19871955
19881956   MCFG_CPU_ADD("audiocpu", Z80, XTAL_6MHz/2) /* verified on pcb */
19891957   MCFG_CPU_PROGRAM_MAP(sound_map)
r11508r11509
20271995static MACHINE_CONFIG_DERIVED( benberob, halleys )
20281996   MCFG_CPU_MODIFY("maincpu")
20291997   MCFG_CPU_CLOCK(XTAL_19_968MHz/12) /* not verified but pcb identical to halley's comet */
2030   MCFG_CPU_VBLANK_INT_HACK(benberob_interrupt, 4)
1998   MCFG_TIMER_MODIFY("scantimer")
1999   MCFG_TIMER_CALLBACK(benberob_scanline)
20312000
20322001   MCFG_SCREEN_MODIFY("screen")
20332002   MCFG_SCREEN_UPDATE(benberob)
src/mame/drivers/msx.c
r11508r11509
659659   PORT_INCLUDE( msx_dips )
660660INPUT_PORTS_END
661661
662#ifdef UNREFERENCED_CODE
662663static INPUT_PORTS_START( msxuk )
663664   PORT_START("KEY0")
664665   KEYB_ROW0
r11508r11509
692693
693694   PORT_INCLUDE( msx_dips )
694695INPUT_PORTS_END
696#endif
695697
696698#define KEYB_JAP_ROW0   \
697699   PORT_BIT (0x0001, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0')               \
src/mame/drivers/neogeo.c
r11508r11509
428428
429429static CUSTOM_INPUT( multiplexed_controller_r )
430430{
431   neogeo_state *state = field->port->machine().driver_data<neogeo_state>();
431   neogeo_state *state = field->machine().driver_data<neogeo_state>();
432432   int port = (FPTR)param;
433433
434434   static const char *const cntrl[2][2] =
r11508r11509
436436         { "IN0-0", "IN0-1" }, { "IN1-0", "IN1-1" }
437437      };
438438
439   return input_port_read_safe(field->port->machine(), cntrl[port][state->m_controller_select & 0x01], 0x00);
439   return input_port_read_safe(field->machine(), cntrl[port][state->m_controller_select & 0x01], 0x00);
440440}
441441
442442
443443static CUSTOM_INPUT( mahjong_controller_r )
444444{
445   neogeo_state *state = field->port->machine().driver_data<neogeo_state>();
445   neogeo_state *state = field->machine().driver_data<neogeo_state>();
446446   UINT32 ret;
447447
448448/*
r11508r11509
456456   {
457457   default:
458458   case 0x00: ret = 0x0000; break; /* nothing? */
459   case 0x09: ret = input_port_read(field->port->machine(), "MAHJONG1"); break;
460   case 0x12: ret = input_port_read(field->port->machine(), "MAHJONG2"); break;
461   case 0x1b: ret = input_port_read(field->port->machine(), "MAHJONG3"); break; /* player 1 normal inputs? */
462   case 0x24: ret = input_port_read(field->port->machine(), "MAHJONG4"); break;
459   case 0x09: ret = input_port_read(field->machine(), "MAHJONG1"); break;
460   case 0x12: ret = input_port_read(field->machine(), "MAHJONG2"); break;
461   case 0x1b: ret = input_port_read(field->machine(), "MAHJONG3"); break; /* player 1 normal inputs? */
462   case 0x24: ret = input_port_read(field->machine(), "MAHJONG4"); break;
463463   }
464464
465465   return ret;
r11508r11509
525525
526526static CUSTOM_INPUT( get_calendar_status )
527527{
528   neogeo_state *state = field->port->machine().driver_data<neogeo_state>();
528   neogeo_state *state = field->machine().driver_data<neogeo_state>();
529529   return (upd4990a_databit_r(state->m_upd4990a, 0) << 1) | upd4990a_testbit_r(state->m_upd4990a, 0);
530530}
531531
r11508r11509
567567{
568568   /* D0 and D1 are memcard presence indicators, D2 indicates memcard
569569       write protect status (we are always write enabled) */
570   return (memcard_present(field->port->machine()) == -1) ? 0x07 : 0x00;
570   return (memcard_present(field->machine()) == -1) ? 0x07 : 0x00;
571571}
572572
573573
r11508r11509
663663
664664static CUSTOM_INPUT( get_audio_result )
665665{
666   neogeo_state *state = field->port->machine().driver_data<neogeo_state>();
666   neogeo_state *state = field->machine().driver_data<neogeo_state>();
667667   UINT32 ret = state->m_audio_result;
668668
669//  if (LOG_CPU_COMM) logerror("MAIN CPU PC %06x: audio_result_r %02x\n", cpu_get_pc(field->port->machine().device("maincpu")), ret);
669//  if (LOG_CPU_COMM) logerror("MAIN CPU PC %06x: audio_result_r %02x\n", cpu_get_pc(field->machine().device("maincpu")), ret);
670670
671671   return ret;
672672}
src/mame/drivers/statriv2.c
r11508r11509
244244
245245static CUSTOM_INPUT( latched_coin_r )
246246{
247   statriv2_state *state = field->port->machine().driver_data<statriv2_state>();
247   statriv2_state *state = field->machine().driver_data<statriv2_state>();
248248   return state->m_latched_coin;
249249}
250250
src/mame/drivers/ladybug.c
r11508r11509
189189
190190static INPUT_CHANGED( coin1_inserted )
191191{
192   ladybug_state *state = field->port->machine().driver_data<ladybug_state>();
192   ladybug_state *state = field->machine().driver_data<ladybug_state>();
193193
194194   /* left coin insertion causes an NMI */
195195   device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
r11508r11509
197197
198198static INPUT_CHANGED( coin2_inserted )
199199{
200   ladybug_state *state = field->port->machine().driver_data<ladybug_state>();
200   ladybug_state *state = field->machine().driver_data<ladybug_state>();
201201
202202   /* right coin insertion causes an IRQ */
203203   if (newval)
r11508r11509
210210
211211static CUSTOM_INPUT( ladybug_p1_control_r )
212212{
213   return input_port_read(field->port->machine(), LADYBUG_P1_CONTROL_PORT_TAG);
213   return input_port_read(field->machine(), LADYBUG_P1_CONTROL_PORT_TAG);
214214}
215215
216216static CUSTOM_INPUT( ladybug_p2_control_r )
r11508r11509
218218   UINT32 ret;
219219
220220   /* upright cabinet only uses a single set of controls */
221   if (input_port_read(field->port->machine(), "DSW0") & 0x20)
222      ret = input_port_read(field->port->machine(), LADYBUG_P2_CONTROL_PORT_TAG);
221   if (input_port_read(field->machine(), "DSW0") & 0x20)
222      ret = input_port_read(field->machine(), LADYBUG_P2_CONTROL_PORT_TAG);
223223   else
224      ret = input_port_read(field->port->machine(), LADYBUG_P1_CONTROL_PORT_TAG);
224      ret = input_port_read(field->machine(), LADYBUG_P1_CONTROL_PORT_TAG);
225225
226226   return ret;
227227}
src/mame/drivers/starshp1.c
r11508r11509
6767
6868static CUSTOM_INPUT( starshp1_analog_r )
6969{
70   starshp1_state *state = field->port->machine().driver_data<starshp1_state>();
70   starshp1_state *state = field->machine().driver_data<starshp1_state>();
7171   int val = 0;
7272
7373   switch (state->m_analog_in_select)
7474   {
7575   case 0:
76      val = input_port_read(field->port->machine(), "STICKY");
76      val = input_port_read(field->machine(), "STICKY");
7777      break;
7878   case 1:
79      val = input_port_read(field->port->machine(), "STICKX");
79      val = input_port_read(field->machine(), "STICKX");
8080      break;
8181   case 2:
8282      val = 0x20; /* DAC feedback, not used */
8383      break;
8484   case 3:
85      val = input_port_read(field->port->machine(), "PLAYTIME");
85      val = input_port_read(field->machine(), "PLAYTIME");
8686      break;
8787   }
8888
r11508r11509
9292
9393static CUSTOM_INPUT( collision_latch_r )
9494{
95   starshp1_state *state = field->port->machine().driver_data<starshp1_state>();
95   starshp1_state *state = field->machine().driver_data<starshp1_state>();
9696   return state->m_collision_latch & 0x0f;
9797}
9898
src/mame/drivers/gottlieb.c
r11508r11509
295295
296296static CUSTOM_INPUT( analog_delta_r )
297297{
298   gottlieb_state *state = field->port->machine().driver_data<gottlieb_state>();
298   gottlieb_state *state = field->machine().driver_data<gottlieb_state>();
299299   const char *string = (const char *)param;
300300   int which = string[0] - '0';
301301
302   return input_port_read(field->port->machine(), &string[1]) - state->m_track[which];
302   return input_port_read(field->machine(), &string[1]) - state->m_track[which];
303303}
304304
305305
r11508r11509
314314
315315static CUSTOM_INPUT( stooges_joystick_r )
316316{
317   gottlieb_state *state = field->port->machine().driver_data<gottlieb_state>();
317   gottlieb_state *state = field->machine().driver_data<gottlieb_state>();
318318   static const char *const joyport[] = { "P2JOY", "P3JOY", "P1JOY", NULL };
319   return (joyport[state->m_joystick_select & 3] != NULL) ? input_port_read(field->port->machine(), joyport[state->m_joystick_select & 3]) : 0xff;
319   return (joyport[state->m_joystick_select & 3] != NULL) ? input_port_read(field->machine(), joyport[state->m_joystick_select & 3]) : 0xff;
320320}
321321
322322
src/mame/drivers/ddragon.c
r11508r11509
357357
358358static CUSTOM_INPUT( sub_cpu_busy )
359359{
360   ddragon_state *state = field->port->machine().driver_data<ddragon_state>();
360   ddragon_state *state = field->machine().driver_data<ddragon_state>();
361361   return state->m_dd_sub_cpu_busy;
362362}
363363
src/mame/drivers/xxmissio.c
r11508r11509
2121
2222static CUSTOM_INPUT( xxmissio_status_r )
2323{
24   xxmissio_state *state = field->port->machine().driver_data<xxmissio_state>();
24   xxmissio_state *state = field->machine().driver_data<xxmissio_state>();
2525   int bit_mask = (FPTR)param;
2626   return (state->m_status & bit_mask) ? 1 : 0;
2727}
src/mame/drivers/groundfx.c
r11508r11509
126126
127127static CUSTOM_INPUT( frame_counter_r )
128128{
129   groundfx_state *state = field->port->machine().driver_data<groundfx_state>();
129   groundfx_state *state = field->machine().driver_data<groundfx_state>();
130130   return state->m_frame_counter;
131131}
132132
133133static CUSTOM_INPUT( coin_word_r )
134134{
135   groundfx_state *state = field->port->machine().driver_data<groundfx_state>();
135   groundfx_state *state = field->machine().driver_data<groundfx_state>();
136136   return state->m_coin_word;
137137}
138138
src/mame/drivers/m92.c
r11508r11509
289289
290290static CUSTOM_INPUT( m92_sprite_busy_r )
291291{
292   m92_state *state = field->port->machine().driver_data<m92_state>();
292   m92_state *state = field->machine().driver_data<m92_state>();
293293   return state->m_sprite_buffer_busy;
294294}
295295
src/mame/drivers/fcombat.c
r11508r11509
3636
3737static INPUT_CHANGED( coin_inserted )
3838{
39   fcombat_state *state = field->port->machine().driver_data<fcombat_state>();
39   fcombat_state *state = field->machine().driver_data<fcombat_state>();
4040
4141   /* coin insertion causes an NMI */
4242   device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
src/mame/drivers/wwfwfest.c
r11508r11509
181181static CUSTOM_INPUT( dsw_3f_r )
182182{
183183   const char *tag = (const char *)param;
184   return input_port_read(field->port->machine(), tag) & 0x3f;
184   return input_port_read(field->machine(), tag) & 0x3f;
185185}
186186
187187static CUSTOM_INPUT( dsw_c0_r )
188188{
189189   const char *tag = (const char *)param;
190   return (input_port_read(field->port->machine(), tag) & 0xc0) >> 6;
190   return (input_port_read(field->machine(), tag) & 0xc0) >> 6;
191191}
192192
193193
src/mame/drivers/multigam.c
r11508r11509
262262
263263static CUSTOM_INPUT( multigam_inputs_r )
264264{
265   multigam_state *state = field->port->machine().driver_data<multigam_state>();
265   multigam_state *state = field->machine().driver_data<multigam_state>();
266266   /* bit 0: serial input (dsw)
267267       bit 1: coin */
268268   return (state->m_in_dsw >> state->m_in_dsw_shift++) & 0x01;
src/mame/drivers/superwng.c
r11508r11509
326326   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
327327   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
328328   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 )
329   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
329   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
330330   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
331331
332332   PORT_START("P2")
src/mame/drivers/guab.c
r11508r11509
594594   if (newval == 0)
595595   {
596596      UINT32 credit;
597      address_space *space = field->port->machine().device("maincpu")->memory().space(AS_PROGRAM);
597      address_space *space = field->machine().device("maincpu")->memory().space(AS_PROGRAM);
598598
599599      /* Get the current credit value and add the new coin value */
600600      credit = space->read_dword(0x8002c) + (UINT32)(FPTR)param;
src/mame/drivers/dcheese.c
r11508r11509
119119
120120static CUSTOM_INPUT( sound_latch_state_r )
121121{
122   dcheese_state *state = field->port->machine().driver_data<dcheese_state>();
122   dcheese_state *state = field->machine().driver_data<dcheese_state>();
123123   return state->m_soundlatch_full;
124124}
125125
src/mame/drivers/brkthru.c
r11508r11509
9292
9393static INPUT_CHANGED( coin_inserted )
9494{
95   brkthru_state *state = field->port->machine().driver_data<brkthru_state>();
95   brkthru_state *state = field->machine().driver_data<brkthru_state>();
9696   /* coin insertion causes an IRQ */
9797   device_set_input_line(state->m_maincpu, 0, newval ? CLEAR_LINE : ASSERT_LINE);
9898}
src/mame/drivers/cloud9.c
r11508r11509
142142
143143static CUSTOM_INPUT( get_vblank )
144144{
145   cloud9_state *state = field->port->machine().driver_data<cloud9_state>();
146   int scanline = field->port->machine().primary_screen->vpos();
145   cloud9_state *state = field->machine().driver_data<cloud9_state>();
146   int scanline = field->machine().primary_screen->vpos();
147147   return (~state->m_syncprom[scanline & 0xff] >> 1) & 1;
148148}
149149
src/mame/drivers/rpunch.c
r11508r11509
146146
147147static CUSTOM_INPUT( hi_bits_r )
148148{
149   return input_port_read(field->port->machine(), "SERVICE");
149   return input_port_read(field->machine(), "SERVICE");
150150}
151151
152152
src/mame/drivers/exerion.c
r11508r11509
133133static CUSTOM_INPUT( exerion_controls_r )
134134{
135135   static const char *const inname[2] = { "P1", "P2" };
136   exerion_state *state = field->port->machine().driver_data<exerion_state>();
137   return input_port_read(field->port->machine(), inname[state->m_cocktail_flip]) & 0x3f;
136   exerion_state *state = field->machine().driver_data<exerion_state>();
137   return input_port_read(field->machine(), inname[state->m_cocktail_flip]) & 0x3f;
138138}
139139
140140
141141static INPUT_CHANGED( coin_inserted )
142142{
143   exerion_state *state = field->port->machine().driver_data<exerion_state>();
143   exerion_state *state = field->machine().driver_data<exerion_state>();
144144   /* coin insertion causes an NMI */
145145   device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
146146}
src/mame/drivers/tryout.c
r11508r11509
8484static INPUT_CHANGED( coin_inserted )
8585{
8686   if(newval != oldval)
87      cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, ASSERT_LINE);
87      cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, ASSERT_LINE);
8888}
8989
9090static INPUT_PORTS_START( tryout )
src/mame/drivers/sfbonus.c
r11508r11509
927927   int globalyscroll = (state->m_vregs[2] | state->m_vregs[3]<<8);
928928   int globalxscroll = (state->m_vregs[0] | state->m_vregs[1]<<8);
929929   UINT8* front_rowscroll = &state->m_videoram[0x200];
930   const input_port_token *ipt;
930   ioport_constructor ipt;
931931   int i;
932932
933933   // align to 0
src/mame/drivers/tempest.c
r11508r11509
332332
333333static CUSTOM_INPUT( tempest_knob_r )
334334{
335   tempest_state *state = field->port->machine().driver_data<tempest_state>();
336   return input_port_read(field->port->machine(), (state->m_player_select == 0) ?
335   tempest_state *state = field->machine().driver_data<tempest_state>();
336   return input_port_read(field->machine(), (state->m_player_select == 0) ?
337337                              TEMPEST_KNOB_P1_TAG : TEMPEST_KNOB_P2_TAG);
338338}
339339
340340static CUSTOM_INPUT( tempest_buttons_r )
341341{
342   tempest_state *state = field->port->machine().driver_data<tempest_state>();
343   return input_port_read(field->port->machine(), (state->m_player_select == 0) ?
342   tempest_state *state = field->machine().driver_data<tempest_state>();
343   return input_port_read(field->machine(), (state->m_player_select == 0) ?
344344                              TEMPEST_BUTTONS_P1_TAG : TEMPEST_BUTTONS_P2_TAG);
345345}
346346
r11508r11509
348348static CUSTOM_INPUT( clock_r )
349349{
350350   /* Emulate the 3kHz source on bit 7 (divide 1.5MHz by 512) */
351   return (field->port->machine().device<cpu_device>("maincpu")->total_cycles() & 0x100) ? 1 : 0;
351   return (field->machine().device<cpu_device>("maincpu")->total_cycles() & 0x100) ? 1 : 0;
352352}
353353
354354
src/mame/drivers/ultrsprt.c
r11508r11509
8383static CUSTOM_INPUT( analog_ctrl_r )
8484{
8585   const char *tag = (const char *)param;
86   return input_port_read(field->port->machine(), tag) & 0xfff;
86   return input_port_read(field->machine(), tag) & 0xfff;
8787}
8888
8989static WRITE32_HANDLER( int_ack_w )
src/mame/drivers/midyunit.c
r11508r11509
152152
153153static CUSTOM_INPUT( narc_talkback_strobe_r )
154154{
155   return (williams_narc_talkback_r(field->port->machine()) >> 8) & 1;
155   return (williams_narc_talkback_r(field->machine()) >> 8) & 1;
156156}
157157
158158
159159static CUSTOM_INPUT( narc_talkback_data_r )
160160{
161   return williams_narc_talkback_r(field->port->machine()) & 0xff;
161   return williams_narc_talkback_r(field->machine()) & 0xff;
162162}
163163
164164
165165static CUSTOM_INPUT( adpcm_irq_state_r )
166166{
167   return williams_adpcm_sound_irq_r(field->port->machine()) & 1;
167   return williams_adpcm_sound_irq_r(field->machine()) & 1;
168168}
169169
170170
src/mame/drivers/bzone.c
r11508r11509
258258
259259static CUSTOM_INPUT( clock_r )
260260{
261   return (field->port->machine().device<cpu_device>("maincpu")->total_cycles() & 0x100) ? 1 : 0;
261   return (field->machine().device<cpu_device>("maincpu")->total_cycles() & 0x100) ? 1 : 0;
262262}
263263
264264
src/mame/drivers/mhavoc.c
r11508r11509
320320static CUSTOM_INPUT( clock_r )
321321{
322322   /* 2.4kHz (divide 2.5MHz by 1024) */
323   return (field->port->machine().device<cpu_device>("alpha")->total_cycles() & 0x400) ? 0 : 1;
323   return (field->machine().device<cpu_device>("alpha")->total_cycles() & 0x400) ? 0 : 1;
324324}
325325
326326
src/mame/drivers/artmagic.c
r11508r11509
387387
388388static CUSTOM_INPUT( prot_r )
389389{
390   artmagic_state *state = field->port->machine().driver_data<artmagic_state>();
390   artmagic_state *state = field->machine().driver_data<artmagic_state>();
391391   return state->m_prot_output_bit;
392392}
393393
src/mame/drivers/hexion.c
r11508r11509
8080
8181#include "emu.h"
8282#include "cpu/z80/z80.h"
83#include "deprecat.h"
8483#include "sound/okim6295.h"
8584#include "sound/k051649.h"
8685#include "includes/konamipt.h"
r11508r11509
102101if ((data & 0xdc) != 0x10) popmessage("coincntr %02x",data);
103102}
104103
104/* probably not? */
105static WRITE8_HANDLER( hexion_irq_ack_w )
106{
107   cputag_set_input_line(space->machine(), "maincpu", 0, CLEAR_LINE);
108}
105109
110static WRITE8_HANDLER( hexion_nmi_ack_w )
111{
112   cputag_set_input_line(space->machine(), "maincpu", INPUT_LINE_NMI, CLEAR_LINE);
113}
106114
107115static ADDRESS_MAP_START( hexion_map, AS_PROGRAM, 8 )
108116   AM_RANGE(0x0000, 0x7fff) AM_ROM
r11508r11509
114122   AM_RANGE(0xe880, 0xe889) AM_DEVWRITE("konami", k051649_frequency_w)
115123   AM_RANGE(0xe88a, 0xe88e) AM_DEVWRITE("konami", k051649_volume_w)
116124   AM_RANGE(0xe88f, 0xe88f) AM_DEVWRITE("konami", k051649_keyonoff_w)
117   AM_RANGE(0xf000, 0xf00f) AM_WRITENOP   /* 053252? f00e = IRQ ack, f00f = NMI ack */
125   AM_RANGE(0xf000, 0xf00d) AM_RAM   /* 053252? f00e = IRQ ack, f00f = NMI ack */
126   AM_RANGE(0xf00e, 0xf00e) AM_WRITE(hexion_irq_ack_w)
127   AM_RANGE(0xf00f, 0xf00f) AM_WRITE(hexion_nmi_ack_w)
118128   AM_RANGE(0xf200, 0xf200) AM_DEVWRITE_MODERN("oki", okim6295_device, write)
119129   AM_RANGE(0xf400, 0xf400) AM_READ_PORT("DSW1")
120130   AM_RANGE(0xf401, 0xf401) AM_READ_PORT("DSW2")
r11508r11509
207217   GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 16 )
208218GFXDECODE_END
209219
220static TIMER_DEVICE_CALLBACK( hexion_scanline )
221{
222   //hexion_state *state = timer.machine().driver_data<hexion_state>();
223   int scanline = param;
210224
211
212static INTERRUPT_GEN( hexion_interrupt )
213{
214   /* NMI handles start and coin inputs, origin unknown */
215   if (cpu_getiloops(device))
216      device_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
217   else
218      device_set_input_line(device, 0, HOLD_LINE);
225   if(scanline == 256)
226      cputag_set_input_line(timer.machine(), "maincpu", 0, ASSERT_LINE);
227   else if ((scanline == 85) || (scanline == 170))
228      cputag_set_input_line(timer.machine(), "maincpu", INPUT_LINE_NMI, ASSERT_LINE);
219229}
220230
221231static MACHINE_CONFIG_START( hexion, hexion_state )
r11508r11509
223233   /* basic machine hardware */
224234   MCFG_CPU_ADD("maincpu", Z80,24000000/4)   /* Z80B 6 MHz */
225235   MCFG_CPU_PROGRAM_MAP(hexion_map)
226   MCFG_CPU_VBLANK_INT_HACK(hexion_interrupt,3)   /* both IRQ and NMI are used */
236   MCFG_TIMER_ADD_SCANLINE("scantimer", hexion_scanline, "screen", 0, 1)
227237
228238   /* video hardware */
229239   MCFG_SCREEN_ADD("screen", RASTER)
230240   MCFG_SCREEN_REFRESH_RATE(60)
231241   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
232242   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
233   MCFG_SCREEN_SIZE(64*8, 32*8)
243   MCFG_SCREEN_SIZE(64*8, 36*8)
234244   MCFG_SCREEN_VISIBLE_AREA(0*8, 64*8-1, 0*8, 32*8-1)
235245   MCFG_SCREEN_UPDATE(hexion)
236246
r11508r11509
244254   MCFG_SPEAKER_STANDARD_MONO("mono")
245255
246256   MCFG_OKIM6295_ADD("oki", 1056000, OKIM6295_PIN7_HIGH) // clock frequency & pin 7 not verified
247   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
257   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5)
248258
249259   MCFG_SOUND_ADD("konami", K051649, 24000000/16)
250   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
260   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5)
251261MACHINE_CONFIG_END
252262
253263
r11508r11509
277287ROM_END
278288
279289
280GAME( 1992, hexion, 0, hexion, hexion, 0, ROT0, "Konami", "Hexion (Japan)", 0 )
290GAME( 1992, hexion, 0, hexion, hexion, 0, ROT0, "Konami", "Hexion (Japan ver JAB)", 0 )
src/mame/drivers/multfish.c
r11508r11509
378378
379379static CUSTOM_INPUT( multfish_hopper_r )
380380{
381   multfish_state *state = field->port->machine().driver_data<multfish_state>();
381   multfish_state *state = field->machine().driver_data<multfish_state>();
382382
383383   if ( state->m_hopper_motor != 0 )
384384   {
src/mame/drivers/seibuspi.c
r11508r11509
936936
937937static CUSTOM_INPUT( ejsakura_keyboard_r )
938938{
939   seibuspi_state *state = field->port->machine().driver_data<seibuspi_state>();
939   seibuspi_state *state = field->machine().driver_data<seibuspi_state>();
940940   switch(state->m_ejsakura_input_port)
941941   {
942942      case 0x01:
943         return input_port_read(field->port->machine(), "INPUT01");
943         return input_port_read(field->machine(), "INPUT01");
944944      case 0x02:
945         return input_port_read(field->port->machine(), "INPUT02");
945         return input_port_read(field->machine(), "INPUT02");
946946      case 0x04:
947         return input_port_read(field->port->machine(), "INPUT04");
947         return input_port_read(field->machine(), "INPUT04");
948948      case 0x08:
949         return input_port_read(field->port->machine(), "INPUT08");
949         return input_port_read(field->machine(), "INPUT08");
950950      case 0x10:
951         return input_port_read(field->port->machine(), "INPUT10");
951         return input_port_read(field->machine(), "INPUT10");
952952      default:
953         return input_port_read(field->port->machine(), "SYSTEM");
953         return input_port_read(field->machine(), "SYSTEM");
954954   }
955955   return 0xffffffff;
956956}
r11508r11509
12951295static CUSTOM_INPUT( ejanhs_encode )
12961296{
12971297   static const UINT8 encoding[] = { 0x02, 0x10, 0x03, 0x18, 0x04, 0x20, 0x05, 0x28, 0x06, 0x30, 0x07 };
1298   input_port_value state = input_port_read(field->port->machine(), (const char *)param);
1298   input_port_value state = input_port_read(field->machine(), (const char *)param);
12991299   int bit;
13001300
13011301   for (bit = 0; bit < ARRAY_LENGTH(encoding); bit++)
src/mame/drivers/system1.c
r11508r11509
428428
429429static CUSTOM_INPUT( dakkochn_mux_data_r )
430430{
431   system1_state *state = field->port->machine().driver_data<system1_state>();
431   system1_state *state = field->machine().driver_data<system1_state>();
432432   static const char *const ports[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6" };
433   return input_port_read(field->port->machine(), ports[state->m_dakkochn_mux_data]);
433   return input_port_read(field->machine(), ports[state->m_dakkochn_mux_data]);
434434}
435435
436436
437437static CUSTOM_INPUT( dakkochn_mux_status_r )
438438{
439   system1_state *state = field->port->machine().driver_data<system1_state>();
439   system1_state *state = field->machine().driver_data<system1_state>();
440440   /* reads from here indicate which mux port is selected */
441441   return 1 << (state->m_dakkochn_mux_data);
442442}
src/mame/drivers/niyanpai.c
r11508r11509
337337
338338static CUSTOM_INPUT( musobana_outcoin_flag_r )
339339{
340   niyanpai_state *state = field->port->machine().driver_data<niyanpai_state>();
341   address_space *space = field->port->machine().device("maincpu")->memory().space(AS_PROGRAM);
340   niyanpai_state *state = field->machine().driver_data<niyanpai_state>();
341   address_space *space = field->machine().device("maincpu")->memory().space(AS_PROGRAM);
342342   // tmp68301_parallel_interface[0x05]
343343   //  bit 0   coin counter
344344   //  bit 2   motor on
src/mame/drivers/bfm_sc2.c
r11508r11509
28642864   AM_RANGE(0x8000, 0xFFFF) AM_ROM
28652865ADDRESS_MAP_END
28662866
2867
2867#ifdef UNREFERENCED_CODE
28682868static INPUT_PORTS_START( scorpion2 )
28692869   PORT_START("COINS")
28702870   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(3)
r11508r11509
30083008   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
30093009   PORT_DIPSETTING(    0x10, DEF_STR( On  ) )
30103010INPUT_PORTS_END
3011#endif
30113012
30123013static INPUT_PORTS_START( bbrkfst )
30133014   PORT_START("COINS")
src/mame/drivers/suprnova.c
r11508r11509
438438static CUSTOM_INPUT( paddle_r )
439439{
440440   const char *tag = (const char *)param;
441   return input_port_read(field->port->machine(), tag);
441   return input_port_read(field->machine(), tag);
442442}
443443
444444static INPUT_PORTS_START( skns )      /* 3 buttons, 2 players */
src/mame/drivers/dynax.c
r11508r11509
20472047   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_SMALL ) PORT_PLAYER(2)      // "s"
20482048INPUT_PORTS_END
20492049
2050#ifdef UNREFERENCED_CODE
20502051static INPUT_PORTS_START( HANAFUDA_KEYS_BET_ALT )
20512052   PORT_START("KEY0")
20522053   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_HANAFUDA_A ) PORT_PLAYER(1)
r11508r11509
21322133   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
21332134   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
21342135INPUT_PORTS_END
2136#endif
21352137
2136
21372138static INPUT_PORTS_START( hanamai )
21382139   PORT_START("DSW0")
21392140   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
src/mame/drivers/shootout.c
r11508r11509
107107
108108static INPUT_CHANGED( coin_inserted )
109109{
110   cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
110   cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
111111}
112112
113113static INPUT_PORTS_START( shootout )
src/mame/drivers/itech32.c
r11508r11509
466466
467467static CUSTOM_INPUT( special_port_r )
468468{
469   itech32_state *state = field->port->machine().driver_data<itech32_state>();
469   itech32_state *state = field->machine().driver_data<itech32_state>();
470470   if (state->m_sound_int_state)
471471      state->m_special_result ^= 1;
472472
src/mame/drivers/undrfire.c
r11508r11509
253253
254254static CUSTOM_INPUT(frame_counter_r)
255255{
256   undrfire_state *state = field->port->machine().driver_data<undrfire_state>();
256   undrfire_state *state = field->machine().driver_data<undrfire_state>();
257257   return state->m_frame_counter;
258258}
259259
src/mame/drivers/astrof.c
r11508r11509
104104
105105static INPUT_CHANGED( coin_inserted )
106106{
107   astrof_state *state = field->port->machine().driver_data<astrof_state>();
107   astrof_state *state = field->machine().driver_data<astrof_state>();
108108
109109   /* coin insertion causes an NMI */
110110   device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
111   coin_counter_w(field->port->machine(), 0, newval);
111   coin_counter_w(field->machine(), 0, newval);
112112}
113113
114114
115115static INPUT_CHANGED( service_coin_inserted )
116116{
117   astrof_state *state = field->port->machine().driver_data<astrof_state>();
117   astrof_state *state = field->machine().driver_data<astrof_state>();
118118
119119   /* service coin insertion causes an NMI */
120120   device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
r11508r11509
123123
124124static CUSTOM_INPUT( astrof_p1_controls_r )
125125{
126   return input_port_read(field->port->machine(), "P1");
126   return input_port_read(field->machine(), "P1");
127127}
128128
129129
r11508r11509
134134   /* on an upright cabinet, a single set of controls
135135       is connected to both sets of pins on the edge
136136       connector */
137   if (input_port_read(field->port->machine(), "CAB"))
138      ret = input_port_read(field->port->machine(), "P2");
137   if (input_port_read(field->machine(), "CAB"))
138      ret = input_port_read(field->machine(), "P2");
139139   else
140      ret = input_port_read(field->port->machine(), "P1");
140      ret = input_port_read(field->machine(), "P1");
141141
142142   return ret;
143143}
r11508r11509
146146static CUSTOM_INPUT( tomahawk_controls_r )
147147{
148148   UINT32 ret;
149   astrof_state *state = field->port->machine().driver_data<astrof_state>();
149   astrof_state *state = field->machine().driver_data<astrof_state>();
150150
151151   /* on a cocktail cabinet, two sets of controls are
152152       multiplexed on a single set of inputs
153153         (not verified on pcb) */
154154
155155   if (state->m_flipscreen)
156      ret = input_port_read(field->port->machine(), "P2");
156      ret = input_port_read(field->machine(), "P2");
157157   else
158      ret = input_port_read(field->port->machine(), "P1");
158      ret = input_port_read(field->machine(), "P1");
159159
160160   return ret;
161161}
src/mame/drivers/galpanic.c
r11508r11509
119119
120120#include "emu.h"
121121#include "cpu/m68000/m68000.h"
122#include "deprecat.h"
123122#include "includes/kaneko16.h"
124123#include "sound/okim6295.h"
125124#include "video/kan_pand.h"
r11508r11509
131130   pandora_eof(pandora);
132131}
133132
134static INTERRUPT_GEN( galpanic_interrupt )
133static TIMER_DEVICE_CALLBACK( galpanic_scanline )
135134{
136   /* IRQ 3 drives the game, IRQ 5 updates the palette */
137   if (cpu_getiloops(device) != 0)
138      device_set_input_line(device, 5, HOLD_LINE);
139   else
140      device_set_input_line(device, 3, HOLD_LINE);
135   int scanline = param;
136
137   if(scanline == 224) // vblank-out irq
138      cputag_set_input_line(timer.machine(), "maincpu", 3, HOLD_LINE);
139
140   /* Pandora "sprite end dma" irq? */
141   if(scanline == 32)
142      cputag_set_input_line(timer.machine(), "maincpu", 5, HOLD_LINE);
141143}
142144
143static INTERRUPT_GEN( galhustl_interrupt )
145
146static TIMER_DEVICE_CALLBACK( galhustl_scanline )
144147{
145   switch ( cpu_getiloops(device) )
146   {
147      case 2:  device_set_input_line(device, 5, HOLD_LINE); break;
148      case 1:  device_set_input_line(device, 4, HOLD_LINE); break;
149      case 0:  device_set_input_line(device, 3, HOLD_LINE); break;
150   }
148   int scanline = param;
149
150   if(scanline == 224) // vblank-out irq
151      cputag_set_input_line(timer.machine(), "maincpu", 3, HOLD_LINE);
152
153   /* Pandora "sprite end dma" irq? */
154   if(scanline == 32)
155      cputag_set_input_line(timer.machine(), "maincpu", 4, HOLD_LINE);
156
157   if(scanline == 0) // timer irq?
158      cputag_set_input_line(timer.machine(), "maincpu", 5, HOLD_LINE);
151159}
152160
153161
r11508r11509
231239   AM_RANGE(0xe00000, 0xe00015) AM_READWRITE(galpanib_calc_r,galpanib_calc_w) /* CALC1 MCU interaction (simulated) */
232240ADDRESS_MAP_END
233241
234static READ16_HANDLER( kludge )
242static READ16_HANDLER( comad_timer_r )
235243{
236   return space->machine().rand() & 0x0700;
244   return (space->machine().primary_screen->vpos() & 0x07) << 8;
237245}
238246
239247/* a kludge! */
240248static READ8_DEVICE_HANDLER( comad_okim6295_r )
241249{
242250   UINT16 retvalue;
251//   okim6295_device *oki = downcast<okim6295_device *>(device);
243252
244//  retvalue = okim6295_r(offset,mem_mask) << 8; // doesn't work, causes lockups when girls change..
253//  retvalue = oki->read_status(); // doesn't work, causes lockups when girls change..
245254   retvalue = device->machine().rand();
246255
247256   return retvalue;
r11508r11509
257266   AM_RANGE(0x800002, 0x800003) AM_READ_PORT("DSW2_P2")
258267   AM_RANGE(0x800004, 0x800005) AM_READ_PORT("SYSTEM")
259268//  AM_RANGE(0x800006, 0x800007)    ??
260   AM_RANGE(0x80000a, 0x80000b) AM_READ(kludge)   /* bits 8-a = timer? palette update code waits for them to be 111 */
261   AM_RANGE(0x80000c, 0x80000d) AM_READ(kludge)   /* missw96 bits 8-a = timer? palette update code waits for them to be 111 */
269   AM_RANGE(0x80000a, 0x80000b) AM_READ(comad_timer_r)   /* bits 8-a = timer? palette update code waits for them to be 111 */
270   AM_RANGE(0x80000c, 0x80000d) AM_READ(comad_timer_r)   /* missw96 bits 8-a = timer? palette update code waits for them to be 111 */
262271   AM_RANGE(0x900000, 0x900001) AM_WRITE(galpanica_6295_bankswitch_w)   /* not sure */
263272   AM_RANGE(0xc00000, 0xc0ffff) AM_RAM            /* missw96 */
264273   AM_RANGE(0xc80000, 0xc8ffff) AM_RAM            /* fantasia, newfant */
r11508r11509
276285   AM_RANGE(0x800002, 0x800003) AM_READ_PORT("DSW2_P2")
277286   AM_RANGE(0x800004, 0x800005) AM_READ_PORT("SYSTEM")
278287//  AM_RANGE(0x800006, 0x800007)    ??
279   AM_RANGE(0x800008, 0x800009) AM_READ(kludge)   /* bits 8-a = timer? palette update code waits for them to be 111 */
288   AM_RANGE(0x800008, 0x800009) AM_READ(comad_timer_r)   /* bits 8-a = timer? palette update code waits for them to be 111 */
280289   AM_RANGE(0x900000, 0x900001) AM_WRITE(galpanica_6295_bankswitch_w)   /* not sure */
281290   AM_RANGE(0xa00000, 0xa00001) AM_WRITENOP   /* coin counters, + ? */
282291   AM_RANGE(0xc80000, 0xc80001) AM_DEVREAD8("oki", comad_okim6295_r, 0xff00) AM_DEVWRITE8_MODERN("oki", okim6295_device, write, 0xff00)
r11508r11509
343352   AM_RANGE(0x800000, 0x800001) AM_READ_PORT("DSW1_P1")
344353   AM_RANGE(0x800002, 0x800003) AM_READ_PORT("DSW2_P2")
345354   AM_RANGE(0x800004, 0x800005) AM_READ_PORT("SYSTEM")
346   AM_RANGE(0x800006, 0x800007) AM_READ(kludge)
347   AM_RANGE(0x800008, 0x800009) AM_READ(kludge)
355   AM_RANGE(0x800006, 0x800007) AM_READ(comad_timer_r)
356   AM_RANGE(0x800008, 0x800009) AM_READ(comad_timer_r)
348357   AM_RANGE(0x900000, 0x900001) AM_WRITE(galpanica_6295_bankswitch_w)   /* not sure */
349358   AM_RANGE(0xa00000, 0xa00001) AM_WRITENOP
350359   AM_RANGE(0xc80000, 0xc8ffff) AM_RAM
r11508r11509
876885   /* basic machine hardware */
877886   MCFG_CPU_ADD("maincpu", M68000, XTAL_12MHz) /* verified on pcb */
878887   MCFG_CPU_PROGRAM_MAP(galpanic_map)
879   MCFG_CPU_VBLANK_INT_HACK(galpanic_interrupt,2)
888   MCFG_TIMER_ADD_SCANLINE("scantimer", galpanic_scanline, "screen", 0, 1)
880889
881890   /* video hardware */
882891   MCFG_SCREEN_ADD("screen", RASTER)
r11508r11509
933942   MCFG_CPU_MODIFY("maincpu")
934943   MCFG_CPU_CLOCK(12000000)   /* ? */
935944   MCFG_CPU_PROGRAM_MAP(supmodel_map)
936   MCFG_CPU_VBLANK_INT_HACK(galpanic_interrupt,2)
945//   MCFG_TIMER_ADD_SCANLINE("scantimer", galpanic_scanline, "screen", 0, 1)
937946
938947   /* video hardware */
939948   MCFG_SCREEN_MODIFY("screen")
r11508r11509
965974   MCFG_CPU_MODIFY("maincpu")
966975   MCFG_CPU_CLOCK(12000000)   /* ? */
967976   MCFG_CPU_PROGRAM_MAP(galhustl_map)
968   MCFG_CPU_VBLANK_INT_HACK(galhustl_interrupt,3)
977   MCFG_TIMER_MODIFY("scantimer")
978   MCFG_TIMER_CALLBACK(galhustl_scanline)
969979
970980   /* video hardware */
971981   MCFG_SCREEN_MODIFY("screen")
r11508r11509
983993   MCFG_CPU_MODIFY("maincpu")
984994   MCFG_CPU_CLOCK(12000000)   /* ? */
985995   MCFG_CPU_PROGRAM_MAP(zipzap_map)
986   MCFG_CPU_VBLANK_INT_HACK(galhustl_interrupt,3)
996   MCFG_TIMER_MODIFY("scantimer")
997   MCFG_TIMER_CALLBACK(galhustl_scanline)
987998
988999   /* video hardware */
9891000   MCFG_SCREEN_MODIFY("screen")
src/mame/drivers/enigma2.c
r11508r11509
416416
417417static CUSTOM_INPUT( p1_controls_r )
418418{
419   return input_port_read(field->port->machine(), "P1CONTROLS");
419   return input_port_read(field->machine(), "P1CONTROLS");
420420}
421421
422422
423423static CUSTOM_INPUT( p2_controls_r )
424424{
425   enigma2_state *state = field->port->machine().driver_data<enigma2_state>();
425   enigma2_state *state = field->machine().driver_data<enigma2_state>();
426426   if (state->m_flip_screen)
427      return input_port_read(field->port->machine(), "P2CONTROLS");
427      return input_port_read(field->machine(), "P2CONTROLS");
428428   else
429      return input_port_read(field->port->machine(), "P1CONTROLS");
429      return input_port_read(field->machine(), "P1CONTROLS");
430430}
431431
432432
src/mame/drivers/igspoker.c
r11508r11509
9191};
9292
9393
94
95
96
97
98
9994static MACHINE_RESET( igs )
10095{
10196   igspoker_state *state = machine.driver_data<igspoker_state>();
r11508r11509
126121}
127122
128123
129
130
131124static TILE_GET_INFO( get_bg_tile_info )
132125{
133126   igspoker_state *state = machine.driver_data<igspoker_state>();
r11508r11509
240233    ---- x---  Hold4 lamp.
241234    ---- -x--  Hold5 lamp.
242235    ---- ---x  Start lamp.
236
237    cpokerx set has different layout:
238   
239    - Lbits -
240    7654 3210
241    =========
242    ---- ---x  Start lamp.
243   
244    ---- ---x  Hold1 lamp.
245    ---- --x-  Hold2 lamp.
246    ---- -x--  Hold3 lamp.
247    ---- x---  Hold4 lamp.
248    ---x ----  Hold5 lamp.
249    xx-- ----  one pulse once bet amount allows start.
243250*/
244251   output_set_lamp_value(1, (data >> 1) & 1);      /* Lamp 1 - HOLD 1 */
245252   output_set_lamp_value(2, (data >> 5) & 1);      /* Lamp 2 - HOLD 2  */
r11508r11509
313320
314321static CUSTOM_INPUT( hopper_r )
315322{
316   igspoker_state *state = field->port->machine().driver_data<igspoker_state>();
317   if (state->m_hopper) return !(field->port->machine().primary_screen->frame_number()%10);
318   return input_code_pressed(field->port->machine(), KEYCODE_H);
323   igspoker_state *state = field->machine().driver_data<igspoker_state>();
324   if (state->m_hopper) return !(field->machine().primary_screen->frame_number()%10);
325   return input_code_pressed(field->machine(), KEYCODE_H);
319326}
320327
321328static READ8_HANDLER( exp_rom_r )
r11508r11509
486493   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
487494INPUT_PORTS_END
488495
496static INPUT_PORTS_START( cpokerx )
497   PORT_START("DSW1")
498   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SWA:8")
499   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
500   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
501   PORT_DIPNAME( 0x06, 0x06, "Min Bet to Start" ) PORT_DIPLOCATION("SWA:7,6")
502   PORT_DIPSETTING(    0x06, "1" )
503   PORT_DIPSETTING(    0x04, "3" )
504   PORT_DIPSETTING(    0x02, "5" )
505   PORT_DIPSETTING(    0x00, "10" )
506   PORT_DIPNAME( 0x18, 0x10, "Max Bet" ) PORT_DIPLOCATION("SWA:5,4")
507   PORT_DIPSETTING(    0x18, "3" )
508   PORT_DIPSETTING(    0x10, "5" )
509   PORT_DIPSETTING(    0x08, "20" )
510   PORT_DIPSETTING(    0x00, "40" )
511   PORT_DIPNAME( 0x60, 0x60, "Min Bet to play Fever" ) PORT_DIPLOCATION("SWA:3,2")
512   PORT_DIPSETTING(    0x60, "1" )
513   PORT_DIPSETTING(    0x40, "5" )
514   PORT_DIPSETTING(    0x20, "10" )
515   PORT_DIPSETTING(    0x00, "20" )
516   PORT_DIPNAME( 0x80, 0x00, "Credit Limit" ) PORT_DIPLOCATION("SWA:1")
517   PORT_DIPSETTING(    0x80, "5000" )
518   PORT_DIPSETTING(    0x00, "10000" )
519
520   PORT_START("DSW2")
521   PORT_DIPNAME( 0x07, 0x07, "Coin In Rate" ) PORT_DIPLOCATION("SWB:8,7,6")
522   PORT_DIPSETTING(    0x07, "1" )
523   PORT_DIPSETTING(    0x06, "2" )
524   PORT_DIPSETTING(    0x05, "5" )
525   PORT_DIPSETTING(    0x04, "10" )
526   PORT_DIPSETTING(    0x03, "20" )
527   PORT_DIPSETTING(    0x02, "40" )
528   PORT_DIPSETTING(    0x01, "50" )
529   PORT_DIPSETTING(    0x00, "100" )
530   PORT_DIPNAME( 0x18, 0x18, "Key In Rate" ) PORT_DIPLOCATION("SWB:5,4")
531   PORT_DIPSETTING(    0x18, "10" )
532   PORT_DIPSETTING(    0x10, "20" )
533   PORT_DIPSETTING(    0x08, "50" )
534   PORT_DIPSETTING(    0x00, "100" )
535   PORT_DIPNAME( 0x60, 0x60, "Key Out Rate" ) PORT_DIPLOCATION("SWB:3,2")
536   PORT_DIPSETTING(    0x60, "1:1" )
537   PORT_DIPSETTING(    0x40, "10:1" )
538   PORT_DIPSETTING(    0x20, "100:1" )
539   PORT_DIPSETTING(    0x00, "100:1" )
540   PORT_DIPNAME( 0x80, 0x80, "Payout" ) PORT_DIPLOCATION("SWB:1")
541   PORT_DIPSETTING(    0x80, "Manual" )
542   PORT_DIPSETTING(    0x00, "Auto" )
543
544   PORT_START("DSW3")
545   PORT_DIPNAME( 0x01, 0x01, "W-UP Bonus Target" ) PORT_DIPLOCATION("SWC:8")
546   PORT_DIPSETTING(    0x01, "3000" )
547   PORT_DIPSETTING(    0x00, "5000" )
548   PORT_DIPNAME( 0x02, 0x02, "W-UP Bonus Rate" ) PORT_DIPLOCATION("SWC:7")
549   PORT_DIPSETTING(    0x02, "300" )
550   PORT_DIPSETTING(    0x00, "500" )
551   PORT_DIPNAME( 0x0c, 0x0c, "W-UP Chance" ) PORT_DIPLOCATION("SWC:6,5")
552   PORT_DIPSETTING(    0x0c, "94%" )
553   PORT_DIPSETTING(    0x08, "96%" )
554   PORT_DIPSETTING(    0x04, "98%" )
555   PORT_DIPSETTING(    0x00, "100%" )
556   PORT_DIPNAME( 0x30, 0x20, "W-UP Type" ) PORT_DIPLOCATION("SWC:4,3")
557   PORT_DIPSETTING(    0x30, DEF_STR( None ) )
558   PORT_DIPSETTING(    0x20, "High-Low" )
559   PORT_DIPSETTING(    0x10, "Red-Black" )      /* Bit 4 is equal for ON/OFF */
560   PORT_DIPNAME( 0x40, 0x00, "Strip Girl" ) PORT_DIPLOCATION("SWC:2")
561   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
562   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
563   PORT_DIPNAME( 0x80, 0x00, "Anytime Key-in" ) PORT_DIPLOCATION("SWC:1")
564   PORT_DIPSETTING(    0x80, DEF_STR( No ) )
565   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
566
567   PORT_START("DSW4")
568   PORT_DIPNAME( 0x0f, 0x07, "Main Game Chance" ) PORT_DIPLOCATION("SWD:8,7,6,5")
569   PORT_DIPSETTING(    0x0f, "69%" )
570   PORT_DIPSETTING(    0x0e, "72%" )
571   PORT_DIPSETTING(    0x0d, "75%" )
572   PORT_DIPSETTING(    0x0c, "78%" )
573   PORT_DIPSETTING(    0x0b, "81%" )
574   PORT_DIPSETTING(    0x0a, "83%" )
575   PORT_DIPSETTING(    0x09, "85%" )
576   PORT_DIPSETTING(    0x08, "87%" )
577   PORT_DIPSETTING(    0x07, "89%" )
578   PORT_DIPSETTING(    0x06, "91%" )
579   PORT_DIPSETTING(    0x05, "93%" )
580   PORT_DIPSETTING(    0x04, "95%" )
581   PORT_DIPSETTING(    0x03, "97%" )
582   PORT_DIPSETTING(    0x02, "99%" )
583   PORT_DIPSETTING(    0x01, "101%" )
584   PORT_DIPSETTING(    0x00, "103%" )
585   PORT_DIPNAME( 0x10, 0x00, "Five Jokers" ) PORT_DIPLOCATION("SWD:4")
586   PORT_DIPSETTING(    0x10, DEF_STR( No ) )
587   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
588   PORT_DIPNAME( 0x20, 0x00, "Royal Flush" ) PORT_DIPLOCATION("SWD:3")
589   PORT_DIPSETTING(    0x20, DEF_STR( No ) )
590   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
591   PORT_DIPNAME( 0x40, 0x00, "Auto Hold" ) PORT_DIPLOCATION("SWD:2")
592   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
593   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
594   PORT_DIPNAME( 0x80, 0x00, "Hopper" ) PORT_DIPLOCATION("SWD:1")
595   PORT_DIPSETTING(    0x80, DEF_STR( No ) )
596   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
597
598   PORT_START("DSW5")
599   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
600
601   PORT_START("SERVICE")
602   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
603   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_9) PORT_NAME("Attendent")
604   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL  ) PORT_CUSTOM( hopper_r, (void *)0 ) PORT_NAME("HPSW")   // hopper sensor
605   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
606   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
607   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
608   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_CODE(KEYCODE_0) PORT_NAME("Operator")
609   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
610
611   PORT_START("COINS")
612   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
613   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
614   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2 )
615   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_GAMBLE_KEYIN )
616   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_GAMBLE_KEYOUT )
617   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
618   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
619   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
620
621   PORT_START("BUTTONS1")
622   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_POKER_HOLD1 ) PORT_NAME("Hold 1")
623   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_POKER_HOLD2 ) PORT_NAME("Hold 2 / Low / Black")
624   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_POKER_HOLD3 ) PORT_NAME("Hold 3")
625   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_POKER_HOLD4 ) PORT_NAME("Hold 4 / High / Red")
626   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_POKER_HOLD5 ) PORT_NAME("Hold 5 / Bet")
627   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
628   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
629   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
630
631   PORT_START("BUTTONS2")
632   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
633   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
634   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
635   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_GAMBLE_TAKE )
636   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
637   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
638   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
639   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
640INPUT_PORTS_END
641
489642static INPUT_PORTS_START( csk227 )
490643   PORT_START("DSW1")
491644   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SWA:8")
r11508r11509
18802033ROM_END
18812034
18822035
2036/*
2037  Champion Poker (IGS) V100.
2038 
20391x ZILOG Z0840006PSC-Z80CPU (main)
2040
20411x oscillator 12.000MHz (main)
2042
20431x custom QFP80 label IGS001A
20441x custom QFP80 label IGS002
2045
2046Note
2047
20481x 10x2 edge connector (con1) (looks like a coin payout)
20491x 36x2 edge connector (con2)
20501x switch (sw6)
20515x 8 DIP switches (sw1-5)
20521x trimmer (volume)
2053----------------------
2054IGS PCB NO-0139-3
2055
2056*/
2057
2058ROM_START( cpokerx )
2059   ROM_REGION( 0x20000, "maincpu", 0 )
2060   ROM_LOAD( "champion_v-100.bin", 0x00000, 0x10000, CRC(00fc9fc3) SHA1(ee6d4e156f0bf866a4b93272b92bb460dd7e73e1) )
2061   ROM_LOAD( "champion7.u22",      0x18000, 0x8000,  CRC(123ff157) SHA1(aa1d1dc589a2d1ca38b667ab88706280347088b4) )
2062   ROM_IGNORE(                              0x8000)
2063
2064   ROM_REGION( 0x60000, "gfx1", 0 )
2065   ROM_LOAD( "champion3.u6", 0x00000, 0x20000, CRC(f3e61b24) SHA1(b18998defb6e51daef4ac5a5865674565ffb9029) )
2066   ROM_LOAD( "champion2.u5", 0x20000, 0x20000, CRC(a68b305f) SHA1(f872d2bf7ab194145dffe6b254ae0ad66aa6a497) )
2067   ROM_LOAD( "champion1.u4", 0x40000, 0x20000, CRC(860be7c9) SHA1(41bc58713076276aeefc44c7ea903549692b0224) )
2068
2069   //copy?
2070   ROM_REGION( 0x60000, "gfx2", 0 )
2071   ROM_COPY( "gfx1", 0, 0, 0x60000 )
2072
2073   ROM_REGION( 0x4000, "plds", 0 )
2074   ROM_LOAD( "16v8b.u31",  0x00000, 0x000892, BAD_DUMP CRC(33dec5f5) SHA1(f5c2e45513fa3657160ff38111a745f76cf679e1) )   // all 0's, seems protected
2075   ROM_LOAD( "16v8h.u14",  0x01000, 0x000892, CRC(123d539a) SHA1(cccf0cbae3175b091a998eedf4aa44a55b679400) )
2076   ROM_LOAD( "22v10b.u22", 0x02000, 0x001704, CRC(609a1aaa) SHA1(b123c93929f932e4ee343a7109f8b16717845d8b) )
2077ROM_END
2078
2079
18832080ROM_START( igs_ncs )
18842081   ROM_REGION( 0x20000, "maincpu", 0 )
18852082   ROM_LOAD( "v.bin",   0x00000, 0x10000, CRC(8077724b) SHA1(1f6e01d5838e6ec4f91b07637c281a3f59631a51) )
r11508r11509
22372434
22382435GAMEL( 1993?, cpoker,   0,        igspoker, cpoker,   cpoker,   ROT0, "IGS",           "Champion Poker (v220I)",                     0, layout_igspoker )
22392436GAMEL( 1993?, cpokert,  cpoker,   igspoker, cpoker,   cpokert,  ROT0, "IGS (Tuning license)", "Champion Poker (v200G)",              0, layout_igspoker )
2437GAMEL( 1993, cpokerx,   cpoker,   igspoker, cpokerx,  cpokert,  ROT0, "IGS",           "Champion Poker (v100)",                      0, layout_igspoker )
22402438GAMEL( 2000, chleague,  0,        igspoker, chleague, chleague, ROT0, "IGS",           "Champion League (Poker)",                    0, layout_igspoker )
22412439GAMEL( 2000, chleagul,  chleague, igspoker, chleague, chleague, ROT0, "IGS",           "Champion League (Lattine)",                  0, layout_igspoker )
2242GAMEL( 198?,  csk227it, 0,        csk227it, csk227,   cska,     ROT0, "IGS",           "Champion Skill (with Ability)",              0, layout_igspoker ) /* SU 062 */
2243GAMEL( 198?,  csk234it, csk227it, csk234it, csk234,   cska,     ROT0, "IGS",           "Champion Skill (Ability, Poker & Symbols)",  0, layout_igspoker ) /* SU 062 */
2440GAMEL( 198?, csk227it,  0,        csk227it, csk227,   cska,     ROT0, "IGS",           "Champion Skill (with Ability)",              0, layout_igspoker ) /* SU 062 */
2441GAMEL( 198?, csk234it,  csk227it, csk234it, csk234,   cska,     ROT0, "IGS",           "Champion Skill (Ability, Poker & Symbols)",  0, layout_igspoker ) /* SU 062 */
22442442GAMEL( 2000, number10,  0,        number10, number10, number10, ROT0, "PlayMark SRL",  "Number Dieci (Poker)",                       0, layout_igspoker )
22452443GAMEL( 2000, numbr10l,  number10, number10, number10, number10, ROT0, "PlayMark SRL",  "Number Dieci (Lattine)",                     0, layout_igspoker )
2246GAMEL( 198?, igs_ncs,  0,        igs_ncs,  igs_ncs,  igs_ncs,  ROT0, "IGS",           "New Champion Skill (v100n)",                 0, layout_igspoker ) /* SU 062 */
2444GAMEL( 198?, igs_ncs,   0,        igs_ncs,  igs_ncs,  igs_ncs,  ROT0, "IGS",           "New Champion Skill (v100n)",                 0, layout_igspoker ) /* SU 062 */
22472445GAMEL( 199?, cpokerpk,  0,        cpokerpk, cpokerpk, cpokerpk, ROT0, "bootleg (SGS)", "Champion Italian PK (bootleg, blue board)",  0, layout_igspoker )
22482446GAMEL( 199?, cpokerpkg, cpokerpk, cpokerpk, cpokerpk, cpokerpk, ROT0, "bootleg (SGS)", "Champion Italian PK (bootleg, green board)", 0, layout_igspoker )
22492447GAMEL( 199?, citalcup,  cpokerpk, cpokerpk, cpokerpk, cpokerpk, ROT0, "bootleg (SGS)", "Champion Italian Cup (bootleg V220IT)",      0, layout_igspoker )
src/mame/drivers/cdi.c
r11508r11509
8181
8282static INPUT_CHANGED( mcu_input )
8383{
84    cdi_state *state = field->port->machine().driver_data<cdi_state>();
84    cdi_state *state = field->machine().driver_data<cdi_state>();
8585    scc68070_regs_t *scc68070 = &state->m_scc68070_regs;
8686   bool send = false;
8787
8888   switch((FPTR)param)
8989   {
9090      case 0x39:
91         if(input_port_read(field->port->machine(), "INPUT1") & 0x01) send = true;
91         if(input_port_read(field->machine(), "INPUT1") & 0x01) send = true;
9292         break;
9393      case 0x37:
94         if(input_port_read(field->port->machine(), "INPUT1") & 0x02) send = true;
94         if(input_port_read(field->machine(), "INPUT1") & 0x02) send = true;
9595         break;
9696      case 0x31:
97         if(input_port_read(field->port->machine(), "INPUT1") & 0x04) send = true;
97         if(input_port_read(field->machine(), "INPUT1") & 0x04) send = true;
9898         break;
9999      case 0x32:
100         if(input_port_read(field->port->machine(), "INPUT1") & 0x08) send = true;
100         if(input_port_read(field->machine(), "INPUT1") & 0x08) send = true;
101101         break;
102102      case 0x33:
103         if(input_port_read(field->port->machine(), "INPUT1") & 0x10) send = true;
103         if(input_port_read(field->machine(), "INPUT1") & 0x10) send = true;
104104         break;
105105
106106      case 0x30:
107         if(input_port_read(field->port->machine(), "INPUT2") & 0x01) send = true;
107         if(input_port_read(field->machine(), "INPUT2") & 0x01) send = true;
108108         break;
109109      case 0x38:
110         if(input_port_read(field->port->machine(), "INPUT2") & 0x02) send = true;
110         if(input_port_read(field->machine(), "INPUT2") & 0x02) send = true;
111111         break;
112112      case 0x34:
113         if(input_port_read(field->port->machine(), "INPUT2") & 0x04) send = true;
113         if(input_port_read(field->machine(), "INPUT2") & 0x04) send = true;
114114         break;
115115      case 0x35:
116         if(input_port_read(field->port->machine(), "INPUT2") & 0x08) send = true;
116         if(input_port_read(field->machine(), "INPUT2") & 0x08) send = true;
117117         break;
118118      case 0x36:
119         if(input_port_read(field->port->machine(), "INPUT2") & 0x10) send = true;
119         if(input_port_read(field->machine(), "INPUT2") & 0x10) send = true;
120120         break;
121121   }
122122
123123   if(send)
124124   {
125125      UINT8 data = (UINT8)((FPTR)param & 0x000000ff);
126      scc68070_quizard_rx(field->port->machine(), scc68070, data);
126      scc68070_quizard_rx(field->machine(), scc68070, data);
127127   }
128128}
129129
src/mame/drivers/acefruit.c
r11508r11509
168168   switch (bit_mask)
169169   {
170170      case 0x01:
171         return ((input_port_read(field->port->machine(), "PAYOUT") & bit_mask) >> 0);
171         return ((input_port_read(field->machine(), "PAYOUT") & bit_mask) >> 0);
172172      case 0x02:
173         return ((input_port_read(field->port->machine(), "PAYOUT") & bit_mask) >> 1);
173         return ((input_port_read(field->machine(), "PAYOUT") & bit_mask) >> 1);
174174      default:
175175         logerror("sidewndr_payout_r : invalid %02X bit_mask\n",bit_mask);
176176         return 0;
r11508r11509
184184   switch (bit_mask)
185185   {
186186      case 0x01:
187         return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 0);
187         return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 0);
188188      case 0x02:
189         return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 1);
189         return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 1);
190190      case 0x04:
191         return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 2);
191         return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 2);
192192      case 0x08:
193         return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 3);
193         return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 3);
194194      default:
195195         logerror("starspnr_coinage_r : invalid %02X bit_mask\n",bit_mask);
196196         return 0;
r11508r11509
204204   switch (bit_mask)
205205   {
206206      case 0x01:
207         return ((input_port_read(field->port->machine(), "PAYOUT") & bit_mask) >> 0);
207         return ((input_port_read(field->machine(), "PAYOUT") & bit_mask) >> 0);
208208      case 0x02:
209         return ((input_port_read(field->port->machine(), "PAYOUT") & bit_mask) >> 1);
209         return ((input_port_read(field->machine(), "PAYOUT") & bit_mask) >> 1);
210210      case 0x04:
211         return ((input_port_read(field->port->machine(), "PAYOUT") & bit_mask) >> 2);
211         return ((input_port_read(field->machine(), "PAYOUT") & bit_mask) >> 2);
212212      default:
213213         logerror("starspnr_payout_r : invalid %02X bit_mask\n",bit_mask);
214214         return 0;
src/mame/drivers/sprint4.c
r11508r11509
1919
2020static CUSTOM_INPUT( get_lever )
2121{
22   sprint4_state *state = field->port->machine().driver_data<sprint4_state>();
22   sprint4_state *state = field->machine().driver_data<sprint4_state>();
2323   int n = (FPTR) param;
2424
2525   return 4 * state->m_gear[n] > state->m_da_latch;
r11508r11509
2828
2929static CUSTOM_INPUT( get_wheel )
3030{
31   sprint4_state *state = field->port->machine().driver_data<sprint4_state>();
31   sprint4_state *state = field->machine().driver_data<sprint4_state>();
3232   int n = (FPTR) param;
3333
3434   return 8 * state->m_steer_FF1[n] + 8 * state->m_steer_FF2[n] > state->m_da_latch;
r11508r11509
3737
3838static CUSTOM_INPUT( get_collision )
3939{
40   sprint4_state *state = field->port->machine().driver_data<sprint4_state>();
40   sprint4_state *state = field->machine().driver_data<sprint4_state>();
4141   int n = (FPTR) param;
4242
4343   return state->m_collision[n];
src/mame/drivers/limenko.c
r11508r11509
112112
113113static CUSTOM_INPUT( spriteram_bit_r )
114114{
115   limenko_state *state = field->port->machine().driver_data<limenko_state>();
115   limenko_state *state = field->machine().driver_data<limenko_state>();
116116   return state->m_spriteram_bit;
117117}
118118
src/mame/drivers/polepos.c
r11508r11509
348348}
349349
350350
351static CUSTOM_INPUT( high_port_r ) { return input_port_read(field->port->machine(), (const char *)param) >> 4; }
352static CUSTOM_INPUT( low_port_r ) { return input_port_read(field->port->machine(), (const char *)param) & 0x0f; }
351static CUSTOM_INPUT( high_port_r ) { return input_port_read(field->machine(), (const char *)param) >> 4; }
352static CUSTOM_INPUT( low_port_r ) { return input_port_read(field->machine(), (const char *)param) & 0x0f; }
353353static CUSTOM_INPUT( auto_start_r )
354354{
355   polepos_state *state = field->port->machine().driver_data<polepos_state>();
355   polepos_state *state = field->machine().driver_data<polepos_state>();
356356   return state->m_auto_start_mask;
357357}
358358
src/mame/drivers/qdrmfgp.c
r11508r11509
3737
3838static CUSTOM_INPUT( inputs_r )
3939{
40   qdrmfgp_state *state = field->port->machine().driver_data<qdrmfgp_state>();
40   qdrmfgp_state *state = field->machine().driver_data<qdrmfgp_state>();
4141   const char *tag1 = (const char *)param;
4242   const char *tag2 = tag1 + strlen(tag1) + 1;
43   return input_port_read(field->port->machine(), (state->m_control & 0x0080) ? tag1 : tag2);
43   return input_port_read(field->machine(), (state->m_control & 0x0080) ? tag1 : tag2);
4444}
4545
4646static CUSTOM_INPUT( battery_sensor_r )
src/mame/drivers/scobra.c
r11508r11509
264264static CUSTOM_INPUT( stratgyx_coinage_r )
265265{
266266   int bit_mask = (FPTR)param;
267   return (input_port_read(field->port->machine(), "IN4") & bit_mask) ? 0x01 : 0x00;
267   return (input_port_read(field->machine(), "IN4") & bit_mask) ? 0x01 : 0x00;
268268}
269269
270270
src/mame/drivers/stactics.c
r11508r11509
5555
5656static CUSTOM_INPUT( get_motor_not_ready )
5757{
58   stactics_state *state = field->port->machine().driver_data<stactics_state>();
58   stactics_state *state = field->machine().driver_data<stactics_state>();
5959
6060   /* if the motor is self-centering, but not centered yet */
6161    return ((*state->m_motor_on & 0x01) == 0) &&
r11508r11509
130130static CUSTOM_INPUT( get_rng )
131131{
132132   /* this is a 555 timer, but cannot read one of the resistor values */
133   return field->port->machine().rand() & 0x07;
133   return field->machine().rand() & 0x07;
134134}
135135
136136
src/mame/drivers/lethalj.c
r11508r11509
161161
162162static CUSTOM_INPUT( cclownz_paddle )
163163{
164   int value = input_port_read(field->port->machine(), "PADDLE");
164   int value = input_port_read(field->machine(), "PADDLE");
165165   return ((value << 4) & 0xf00) | (value & 0x00f);
166166}
167167
src/mame/drivers/itech8.c
r11508r11509
728728
729729static CUSTOM_INPUT( special_r )
730730{
731   itech8_state *state = field->port->machine().driver_data<itech8_state>();
731   itech8_state *state = field->machine().driver_data<itech8_state>();
732732   return state->m_pia_portb_data & 0x01;
733733}
734734
r11508r11509
11021102{
11031103   const char *tag1 = (const char *)param;
11041104   const char *tag2 = tag1 + strlen(tag1) + 1;
1105   return input_port_read(field->port->machine(), tag1) & input_port_read(field->port->machine(), tag2);
1105   return input_port_read(field->machine(), tag1) & input_port_read(field->machine(), tag2);
11061106}
11071107
11081108static INPUT_PORTS_START( gtg )
src/mame/drivers/galaxian.c
r11508r11509
728728
729729static CUSTOM_INPUT( scramble_protection_alt_r )
730730{
731   galaxian_state *state = field->port->machine().driver_data<galaxian_state>();
731   galaxian_state *state = field->machine().driver_data<galaxian_state>();
732732   /*
733733        There are two additional bits that are derived from bit 7 of
734734        the protection result. This is just a guess but works well enough
r11508r11509
10081008
10091009static INPUT_CHANGED( gmgalax_game_changed )
10101010{
1011   galaxian_state *state = field->port->machine().driver_data<galaxian_state>();
1012   address_space *space = field->port->machine().device("maincpu")->memory().space(AS_PROGRAM);
1011   galaxian_state *state = field->machine().driver_data<galaxian_state>();
1012   address_space *space = field->machine().device("maincpu")->memory().space(AS_PROGRAM);
10131013
10141014   /* new value is the selected game */
10151015   state->m_gmgalax_selected_game = newval;
10161016
10171017   /* select the bank and graphics bank based on it */
1018   memory_set_bank(field->port->machine(), "bank1", state->m_gmgalax_selected_game);
1018   memory_set_bank(field->machine(), "bank1", state->m_gmgalax_selected_game);
10191019   galaxian_gfxbank_w(space, 0, state->m_gmgalax_selected_game);
10201020
10211021   /* reset the stars */
10221022   galaxian_stars_enable_w(space, 0, 0);
10231023
10241024   /* reset the CPU */
1025   cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_RESET, PULSE_LINE);
1025   cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_RESET, PULSE_LINE);
10261026}
10271027
10281028
10291029static CUSTOM_INPUT( gmgalax_port_r )
10301030{
1031   galaxian_state *state = field->port->machine().driver_data<galaxian_state>();
1031   galaxian_state *state = field->machine().driver_data<galaxian_state>();
10321032   const char *portname = (const char *)param;
10331033   if (state->m_gmgalax_selected_game != 0)
10341034      portname += strlen(portname) + 1;
1035   return input_port_read(field->port->machine(), portname);
1035   return input_port_read(field->machine(), portname);
10361036}
10371037
10381038
r11508r11509
10841084
10851085static CUSTOM_INPUT( azurian_port_r )
10861086{
1087   return (input_port_read(field->port->machine(), "FAKE") >> (FPTR)param) & 1;
1087   return (input_port_read(field->machine(), "FAKE") >> (FPTR)param) & 1;
10881088}
10891089
10901090
r11508r11509
10971097
10981098static CUSTOM_INPUT( kingball_muxbit_r )
10991099{
1100   galaxian_state *state = field->port->machine().driver_data<galaxian_state>();
1100   galaxian_state *state = field->machine().driver_data<galaxian_state>();
11011101   /* multiplex the service mode switch with a speech DIP switch */
1102   return (input_port_read(field->port->machine(), "FAKE") >> state->m_kingball_speech_dip) & 1;
1102   return (input_port_read(field->machine(), "FAKE") >> state->m_kingball_speech_dip) & 1;
11031103}
11041104
11051105
r11508r11509
11081108   /* bit 5 is the NOISE line from the sound circuit.  The code just verifies
11091109       that it's working, doesn't actually use return value, so we can just use
11101110       rand() */
1111   return field->port->machine().rand() & 1;
1111   return field->machine().rand() & 1;
11121112}
11131113
11141114
r11508r11509
26892689   memory_configure_bank(machine, "bank1", 0, 2, machine.region("maincpu")->base() + 0x10000, 0x4000);
26902690
26912691   /* callback when the game select is toggled */
2692   gmgalax_game_changed(machine.m_portlist.first()->fieldlist, NULL, 0, 0);
2692   gmgalax_game_changed(*state, machine.m_portlist.first()->fieldlist().first(), NULL, 0, 0);
26932693   state_save_register_global(machine, state->m_gmgalax_selected_game);
26942694}
26952695
src/mame/drivers/flstory.c
r11508r11509
124124
125125static CUSTOM_INPUT( victnine_mcu_status_bit01_r )
126126{
127   flstory_state *state = field->port->machine().driver_data<flstory_state>();
127   flstory_state *state = field->machine().driver_data<flstory_state>();
128128   address_space *space = state->m_maincpu->memory().space(AS_PROGRAM);
129129
130130   return (victnine_mcu_status_r(space, 0) & 3);
src/mame/drivers/calomega.c
r11508r11509
10241024   PORT_DIPSETTING(    0x00, "50Hz." )
10251025INPUT_PORTS_END
10261026
1027#ifdef UNREFERENCED_CODE
10271028static INPUT_PORTS_START( stand904 )
10281029   PORT_START("IN0-0")
10291030   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("0-1") PORT_CODE(KEYCODE_1)
r11508r11509
11281129   PORT_DIPSETTING(    0x80, "60Hz." )
11291130   PORT_DIPSETTING(    0x00, "50Hz." )
11301131INPUT_PORTS_END
1132#endif
11311133
11321134static INPUT_PORTS_START( stand905 )
11331135   PORT_START("IN0-0")
src/mame/drivers/toaplan1.c
r11508r11509
674674   PORT_BIT( 0xfffe, IP_ACTIVE_HIGH, IPT_UNKNOWN )
675675INPUT_PORTS_END
676676
677#ifdef UNREFERENCED_CODE
677678static INPUT_PORTS_START( toaplan1_3b )
678679   PORT_INCLUDE( toaplan1_2b )
679680
r11508r11509
683684   PORT_MODIFY("P2")
684685   TOAPLAN_JOY_UDLR_3_BUTTONS( 2 )
685686INPUT_PORTS_END
687#endif
686688
687
688689#define  TOAPLAN1_PLAYER_INPUT( player, button3, options )                              \
689690   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(player) options PORT_8WAY      \
690691   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(player) options PORT_8WAY   \
src/mame/drivers/segag80r.c
r11508r11509
149149{
150150   /* pressing the service switch sends an NMI */
151151   if (newval)
152      cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE);
152      cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE);
153153}
154154
155155
src/mame/drivers/suprridr.c
r11508r11509
228228   UINT32 ret;
229229
230230   /* screen flip multiplexes controls */
231   if (suprridr_is_screen_flipped(field->port->machine()))
232      ret = input_port_read(field->port->machine(), SUPRRIDR_P2_CONTROL_PORT_TAG);
231   if (suprridr_is_screen_flipped(field->machine()))
232      ret = input_port_read(field->machine(), SUPRRIDR_P2_CONTROL_PORT_TAG);
233233   else
234      ret = input_port_read(field->port->machine(), SUPRRIDR_P1_CONTROL_PORT_TAG);
234      ret = input_port_read(field->machine(), SUPRRIDR_P1_CONTROL_PORT_TAG);
235235
236236   return ret;
237237}
src/mame/drivers/igs009.c
r11508r11509
342342
343343static CUSTOM_INPUT( hopper_r )
344344{
345   igs009_state *state = field->port->machine().driver_data<igs009_state>();
346   return state->m_hopper && !(field->port->machine().primary_screen->frame_number()%10);
345   igs009_state *state = field->machine().driver_data<igs009_state>();
346   return state->m_hopper && !(field->machine().primary_screen->frame_number()%10);
347347}
348348
349349
src/mame/drivers/psikyo.c
r11508r11509
7979
8080static CUSTOM_INPUT( z80_nmi_r )
8181{
82   psikyo_state *state = field->port->machine().driver_data<psikyo_state>();
82   psikyo_state *state = field->machine().driver_data<psikyo_state>();
8383   int ret = 0x00;
8484
8585   if (state->m_z80_nmi)
r11508r11509
8888
8989      /* main CPU might be waiting for sound CPU to finish NMI,
9090           so set a timer to give sound CPU a chance to run */
91      field->port->machine().scheduler().synchronize();
91      field->machine().scheduler().synchronize();
9292//      logerror("%s - Read coin port during Z80 NMI\n", machine.describe_context());
9393   }
9494
r11508r11509
9797
9898static CUSTOM_INPUT( mcu_status_r )
9999{
100   psikyo_state *state = field->port->machine().driver_data<psikyo_state>();
100   psikyo_state *state = field->machine().driver_data<psikyo_state>();
101101   int ret = 0x00;
102102
103103   /* Don't know exactly what this bit is, but s1945 and tengai
src/mame/drivers/dacholer.c
r11508r11509
142142
143143static CUSTOM_INPUT( snd_ack_r )
144144{
145   dacholer_state *state = field->port->machine().driver_data<dacholer_state>();
145   dacholer_state *state = field->machine().driver_data<dacholer_state>();
146146   return state->m_snd_ack;      //guess ...
147147}
148148
src/mame/drivers/pastelg.c
r11508r11509
217217// stops the game hanging..
218218static CUSTOM_INPUT( nb1413m3_hackbusyflag_r )
219219{
220   return field->port->machine().rand() & 3;
220   return field->machine().rand() & 3;
221221}
222222
223223static INPUT_PORTS_START( threeds )
src/mame/drivers/galastrm.c
r11508r11509
9292
9393static CUSTOM_INPUT( frame_counter_r )
9494{
95   galastrm_state *state = field->port->machine().driver_data<galastrm_state>();
95   galastrm_state *state = field->machine().driver_data<galastrm_state>();
9696   return state->m_frame_counter;
9797}
9898
9999static CUSTOM_INPUT( coin_word_r )
100100{
101   galastrm_state *state = field->port->machine().driver_data<galastrm_state>();
101   galastrm_state *state = field->machine().driver_data<galastrm_state>();
102102   return state->m_coin_word;
103103}
104104
src/mame/drivers/tetrisp2.c
r11508r11509
267267
268268static CUSTOM_INPUT( rocknms_main2sub_status_r )
269269{
270   tetrisp2_state *state = field->port->machine().driver_data<tetrisp2_state>();
270   tetrisp2_state *state = field->machine().driver_data<tetrisp2_state>();
271271   return  state->m_rocknms_sub2main & 0x0003;
272272}
273273
src/mame/drivers/namcos22.c
r11508r11509
52905290
52915291static CUSTOM_INPUT( acedrvr_shift_read )
52925292{
5293   namcos22_state *state = field->port->machine().driver_data<namcos22_state>();
5294   int shift = input_port_read(field->port->machine(), "SHIFT");
5293   namcos22_state *state = field->machine().driver_data<namcos22_state>();
5294   int shift = input_port_read(field->machine(), "SHIFT");
52955295
52965296   if (shift > 0 && shift != state->m_prev_stick_state)
52975297   {
r11508r11509
54715471
54725472static CUSTOM_INPUT( ridger_gear_read )
54735473{
5474   namcos22_state *state = field->port->machine().driver_data<namcos22_state>();
5475   int gear = input_port_read(field->port->machine(), "GEARS");
5474   namcos22_state *state = field->machine().driver_data<namcos22_state>();
5475   int gear = input_port_read(field->machine(), "GEARS");
54765476
54775477   if (gear > 0 && gear != state->m_prev_stick_state)
54785478   {
src/mame/drivers/galaxold.c
r11508r11509
917917   switch (bit_mask)
918918   {
919919      case 0x40:  /* vpool : IN1 (0xa800) bit 6 */
920         return ((input_port_read(field->port->machine(), "LIVES") & bit_mask) >> 6);
920         return ((input_port_read(field->machine(), "LIVES") & bit_mask) >> 6);
921921      case 0x01:  /* vpool : DSW (0xb000) bit 0 */
922         return ((input_port_read(field->port->machine(), "LIVES") & bit_mask) >> 0);
922         return ((input_port_read(field->machine(), "LIVES") & bit_mask) >> 0);
923923
924924      default:
925925         logerror("vpool_lives_r : invalid %02X bit_mask\n",bit_mask);
r11508r11509
10641064   switch (bit_mask)
10651065   {
10661066      case 0x0c:  /* ckongg  : DSW (0xc800) bits 2 and 3 */
1067         return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 2);
1067         return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 2);
10681068      case 0x40:  /* ckongg  : IN1 (0xc400) bit 6 */
1069         return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 6);
1069         return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 6);
10701070
10711071      case 0xc0:  /* ckongmc : IN1 (0xa800) bits 6 and 7 */
1072         return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 6);
1072         return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 6);
10731073      case 0x01:  /* ckongmc : DSW (0xb000) bit 0 */
1074         return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 0);
1074         return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 0);
10751075
10761076      default:
10771077         logerror("ckongg_coinage_r : invalid %02X bit_mask\n",bit_mask);
r11508r11509
14321432   switch (bit_mask)
14331433   {
14341434      case 0xc0:  /* dkongjrm : IN1 (0xa8??) bits 6 and 7 */
1435         return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 6);
1435         return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 6);
14361436      case 0x01:  /* dkongjrm : DSW (0xb0??) bit 0 */
1437         return ((input_port_read(field->port->machine(), "COINAGE") & bit_mask) >> 0);
1437         return ((input_port_read(field->machine(), "COINAGE") & bit_mask) >> 0);
14381438
14391439      default:
14401440         logerror("dkongjrm_coinage_r : invalid %02X bit_mask\n",bit_mask);
src/mame/drivers/cop01.c
r11508r11509
100100static CUSTOM_INPUT( mightguy_area_r )
101101{
102102   int bit_mask = (FPTR)param;
103   return (input_port_read(field->port->machine(), "FAKE") & bit_mask) ? 0x01 : 0x00;
103   return (input_port_read(field->machine(), "FAKE") & bit_mask) ? 0x01 : 0x00;
104104}
105105
106106static WRITE8_HANDLER( cop01_irq_ack_w )
src/mame/drivers/inufuku.c
r11508r11509
115115
116116static CUSTOM_INPUT( soundflag_r )
117117{
118   inufuku_state *state = field->port->machine().driver_data<inufuku_state>();
118   inufuku_state *state = field->machine().driver_data<inufuku_state>();
119119   UINT16 soundflag = state->m_pending_command ? 0 : 1;
120120
121121   return soundflag;
src/mame/drivers/progolf.c
r11508r11509
268268
269269static INPUT_CHANGED( coin_inserted )
270270{
271   cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
271   cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
272272}
273273
274274static INPUT_PORTS_START( progolf )
src/mame/drivers/jackie.c
r11508r11509
391391
392392static CUSTOM_INPUT( hopper_r )
393393{
394   jackie_state *state = field->port->machine().driver_data<jackie_state>();
395   if (state->m_hopper) return !(field->port->machine().primary_screen->frame_number()%10);
396   return input_code_pressed(field->port->machine(), KEYCODE_H);
394   jackie_state *state = field->machine().driver_data<jackie_state>();
395   if (state->m_hopper) return !(field->machine().primary_screen->frame_number()%10);
396   return input_code_pressed(field->machine(), KEYCODE_H);
397397}
398398
399399static INPUT_PORTS_START( jackie )
src/mame/drivers/alg.c
r11508r11509
185185
186186static CUSTOM_INPUT( lightgun_pos_r )
187187{
188   alg_state *state = field->port->machine().driver_data<alg_state>();
188   alg_state *state = field->machine().driver_data<alg_state>();
189189   int x = 0, y = 0;
190190
191191   /* get the position based on the input select */
192   get_lightgun_pos(*field->port->machine().primary_screen, state->m_input_select, &x, &y);
192   get_lightgun_pos(*field->machine().primary_screen, state->m_input_select, &x, &y);
193193   return (y << 8) | (x >> 2);
194194}
195195
196196
197197static CUSTOM_INPUT( lightgun_trigger_r )
198198{
199   alg_state *state = field->port->machine().driver_data<alg_state>();
199   alg_state *state = field->machine().driver_data<alg_state>();
200200
201201   /* read the trigger control based on the input select */
202   return (input_port_read(field->port->machine(), "TRIGGERS") >> state->m_input_select) & 1;
202   return (input_port_read(field->machine(), "TRIGGERS") >> state->m_input_select) & 1;
203203}
204204
205205
206206static CUSTOM_INPUT( lightgun_holster_r )
207207{
208   alg_state *state = field->port->machine().driver_data<alg_state>();
208   alg_state *state = field->machine().driver_data<alg_state>();
209209
210210   /* read the holster control based on the input select */
211   return (input_port_read(field->port->machine(), "TRIGGERS") >> (2 + state->m_input_select)) & 1;
211   return (input_port_read(field->machine(), "TRIGGERS") >> (2 + state->m_input_select)) & 1;
212212}
213213
214214
src/mame/drivers/segag80v.c
r11508r11509
162162{
163163   /* pressing the service switch sends an NMI */
164164   if (newval)
165      cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE);
165      cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, PULSE_LINE);
166166}
167167
168168
r11508r11509
293293
294294static CUSTOM_INPUT( elim4_joint_coin_r )
295295{
296   return (input_port_read(field->port->machine(), "COINS") & 0xf) != 0xf;
296   return (input_port_read(field->machine(), "COINS") & 0xf) != 0xf;
297297}
298298
299299
src/mame/drivers/dreamwld.c
r11508r11509
102102   UINT32 *  m_bg_scroll;
103103   UINT32 *  m_paletteram;
104104   UINT32 *  m_spriteram;
105   UINT32 *  m_workram;
105106
106107   /* video-related */
107108   tilemap_t  *m_bg_tilemap;
r11508r11509
252253
253254static READ32_HANDLER( dreamwld_protdata_r )
254255{
256   //static int count = 0;
255257   dreamwld_state *state = space->machine().driver_data<dreamwld_state>();
256258
259   //printf("protection read %04x\n", count);
260   //count++;
261
257262   UINT8 *protdata = space->machine().region("user1")->base();
258263   size_t protsize = space->machine().region("user1")->bytes();
259264   UINT8 dat = protdata[(state->m_protindex++) % protsize];
r11508r11509
323328
324329   AM_RANGE(0xc00030, 0xc00033) AM_READ(dreamwld_protdata_r) // it reads protection data (irq code) from here and puts it at ffd000
325330
326   AM_RANGE(0xfe0000, 0xffffff) AM_RAM // work ram
331   AM_RANGE(0xfe0000, 0xffffff) AM_RAM AM_BASE_MEMBER(dreamwld_state, m_workram) // work ram
327332ADDRESS_MAP_END
328333
329334
335static ADDRESS_MAP_START( baryon_map, AS_PROGRAM, 32 )
336   AM_RANGE(0x000000, 0x0fffff) AM_ROM  AM_WRITENOP
337
338   AM_RANGE(0x400000, 0x401fff) AM_RAM AM_BASE_MEMBER(dreamwld_state, m_spriteram)
339   AM_RANGE(0x600000, 0x601fff) AM_RAM//_WRITE(dreamwld_palette_w) AM_BASE_MEMBER(dreamwld_state, m_paletteram)  // real palette?
340   AM_RANGE(0x800000, 0x801fff) AM_RAM_WRITE(dreamwld_bg_videoram_w ) AM_BASE_MEMBER(dreamwld_state, m_bg_videoram)
341   AM_RANGE(0x802000, 0x803fff) AM_RAM_WRITE(dreamwld_bg2_videoram_w ) AM_BASE_MEMBER(dreamwld_state, m_bg2_videoram)
342   AM_RANGE(0x804000, 0x805fff) AM_RAM AM_BASE_MEMBER(dreamwld_state, m_bg_scroll)  // scroll regs etc.
343
344   AM_RANGE(0xc00000, 0xc00003) AM_READ_PORT("INPUTS")
345   AM_RANGE(0xc00004, 0xc00007) AM_READ_PORT("c00004")
346
347   AM_RANGE(0xc0000c, 0xc0000f) AM_WRITE(dreamwld_6295_0_bank_w) // sfx
348   AM_RANGE(0xc00018, 0xc0001b) AM_DEVREADWRITE8_MODERN("oki1", okim6295_device, read, write, 0xff000000) // sfx
349
350   AM_RANGE(0xc00030, 0xc00033) AM_READ(dreamwld_protdata_r) // it reads protection data (irq code) from here and puts it at ffd000
351
352   AM_RANGE(0xfe0000, 0xffffff) AM_RAM AM_BASE_MEMBER(dreamwld_state, m_workram) // work ram
353ADDRESS_MAP_END
354
330355static INPUT_PORTS_START( dreamwld )
331356   PORT_START("INPUTS")
332357   PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_COIN1 )
r11508r11509
455480   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50)
456481MACHINE_CONFIG_END
457482
483static INTERRUPT_GEN( baryon_irq_hack )
484{
485   dreamwld_state *state = device->machine().driver_data<dreamwld_state>();
486   state->m_workram[0x3600/4] = 0x00000000;
487   state->m_workram[0x35d8/4] = 0x00000000;
488   // to run attract mode (without palette, scrolling or sprites)
489   // bp a644
490   // do pc = a646
491   // bp a67a
492   // do pc = a67c
458493
494}
459495
496
497static MACHINE_CONFIG_START( baryon, dreamwld_state )
498
499   /* basic machine hardware */
500   MCFG_CPU_ADD("maincpu", M68EC020, MASTER_CLOCK/2)
501   MCFG_CPU_PROGRAM_MAP(baryon_map)
502   MCFG_CPU_VBLANK_INT("screen", baryon_irq_hack /* irq4_line_hold */ ) // 4, 5, or 6, all point to the same place
503
504   MCFG_MACHINE_START(dreamwld)
505   MCFG_MACHINE_RESET(dreamwld)
506
507   /* video hardware */
508   MCFG_SCREEN_ADD("screen", RASTER)
509   MCFG_SCREEN_REFRESH_RATE(58)
510   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
511   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
512   MCFG_SCREEN_SIZE(512,256)
513   MCFG_SCREEN_VISIBLE_AREA(0, 304-1, 0, 224-1)
514   MCFG_SCREEN_UPDATE(dreamwld)
515
516   MCFG_PALETTE_LENGTH(0x1000)
517   MCFG_GFXDECODE(dreamwld)
518
519   MCFG_VIDEO_START(dreamwld)
520
521   MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
522
523   MCFG_OKIM6295_ADD("oki1", MASTER_CLOCK/32, OKIM6295_PIN7_LOW)
524   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50)
525   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50)
526MACHINE_CONFIG_END
527
528
460529ROM_START( dreamwld )
461530   ROM_REGION( 0x200000, "maincpu", 0 )
462531   ROM_LOAD32_BYTE( "1.bin", 0x000002, 0x040000, CRC(35c94ee5) SHA1(3440a65a807622b619c97bc2a88fd7d875c26f66) )
r11508r11509
471540   /* The MCU supplies this data.
472541      The 68k reads it through a port, taking the size and destination write address from the level 1
473542      and level 2 irq positions in the 68k vector table (there is code to check that they haven't been
474      modofied!)  It then decodes the data using the rom checksum previously calculated and puts it in
543      modified!)  It then decodes the data using the rom checksum previously calculated and puts it in
475544      ram.  The interrupt vectors point at the code placed in RAM. */
476545   ROM_LOAD( "protdata.bin", 0x000, 0x6c9 ,  CRC(f284b2fd) SHA1(9e8096c8aa8a288683f002311b38787b120748d1) ) /* extracted */
477546
478547   ROM_REGION( 0x100000, "oki1", 0 ) /* OKI Samples - 1st chip*/
479548   ROM_LOAD( "5.bin", 0x000000, 0x80000, CRC(9689570a) SHA1(4414233da8f46214ca7e9022df70953922a63aa4) )
480   ROM_RELOAD(0x80000,0x80000) // fot the banks
549   ROM_RELOAD(0x80000,0x80000) // for the banks
481550
482551   ROM_REGION( 0x100000, "oki2", 0 ) /* OKI Samples - 2nd chip*/
483552   ROM_LOAD( "6.bin", 0x000000, 0x80000, CRC(c8b91f30) SHA1(706004ca56d0a74bc7a3dfd73a21cdc09eb90f05) )
484   ROM_RELOAD(0x80000,0x80000) // fot the banks
553   ROM_RELOAD(0x80000,0x80000) // for the banks
485554
486555   ROM_REGION( 0x400000, "gfx1", 0 ) /* Sprite Tiles - decoded */
487556   ROM_LOAD( "9.bin", 0x000000, 0x200000, CRC(fa84e3af) SHA1(5978737d348fd382f4ec004d29870656c864d137) )
r11508r11509
498567ROM_END
499568
500569
570ROM_START( baryon )
571   ROM_REGION( 0x200000, "maincpu", 0 )
572   ROM_LOAD32_BYTE( "3.bin", 0x000002, 0x040000, CRC(046d4231) SHA1(05056efe5fec7f43c400f05278de516b01be0fdf) )
573   ROM_LOAD32_BYTE( "4.bin", 0x000000, 0x040000, CRC(59e0df20) SHA1(ff12f4adcf731f6984db7d0fbdd7fcc71ce66aa4) )
574   ROM_LOAD32_BYTE( "5.bin", 0x000003, 0x040000, CRC(63d5e7cb) SHA1(269bf5ffe10f2464f823c4d377921e19cfb8bc46) )
575   ROM_LOAD32_BYTE( "6.bin", 0x000001, 0x040000, CRC(abccbb3d) SHA1(01524f094543d872d775306024f51258a11e9240) )
576
577   ROM_REGION( 0x10000, "cpu1", 0 ) /* 87C52 MCU Code */
578   ROM_LOAD( "87c52.mcu", 0x00000, 0x10000 , NO_DUMP ) /* can't be dumped. */
579
580   ROM_REGION( 0x6c9, "user1", 0 ) /* Protection data  */
581   ROM_FILL( 0x0, 0x6c9, 0x00 )
582   //ROM_LOAD( "protdata.bin", 0x000, 0x6bc ,  CRC(1) SHA1(1) ) /* extracted */
583
584   ROM_REGION( 0x100000, "oki1", 0 ) /* OKI Samples */
585   ROM_LOAD( "1.bin", 0x000000, 0x80000, CRC(e0349074) SHA1(f3d53d96dff586a0ad1632f52e5559cdce5ed0d8) )
586   ROM_RELOAD(0x80000,0x80000) // for the banks
587
588   ROM_REGION( 0x400000, "gfx1", 0 ) /* Sprite Tiles - decoded */
589   ROM_LOAD( "9.bin",  0x000000, 0x200000, CRC(28bf828f) SHA1(271390cc4f4015a3b69976f0d0527947f13c971b) )
590   ROM_LOAD( "11.bin", 0x200000, 0x200000, CRC(d0ff1bc6) SHA1(4aeb795222eedeeba770cf725122e989f97119b2) )
591
592   ROM_REGION( 0x200000, "gfx2", 0 ) /* BG Tiles - decoded */
593   ROM_LOAD( "2.bin",0x000000, 0x200000, CRC(684012e6) SHA1(4cb60907184b67be130b8385e4336320c0f6e4a7) )
594
595   ROM_REGION( 0x040000, "gfx3", 0 ) /* Sprite Code Lookup ... */
596   ROM_LOAD16_BYTE( "8.bin", 0x000000, 0x020000, CRC(fdbb08b0) SHA1(4b3ac56c4c8370b1434fb6a481fce0d9c52313e0) )
597   ROM_LOAD16_BYTE( "10.bin",0x000001, 0x020000, CRC(c9d20480) SHA1(3f6170e8e08fb7508bd13c23f243ec6888a91f5e) )
598
599   ROM_REGION( 0x10000, "gfx4", 0 ) /* ???? - not decoded seems to be in blocks of 0x41 bytes.. */
600   ROM_LOAD( "7.bin", 0x000000, 0x10000, CRC(0da8db45) SHA1(7d5bd71c5b0b28ff74c732edd7c662f46f2ab25b) )
601ROM_END
602
603
604GAME( 1997, baryon,   0, baryon,   dreamwld, 0, ROT270,  "SemiCom", "Baryon - Future Assault", GAME_SUPPORTS_SAVE|GAME_NOT_WORKING )
501605GAME( 2000, dreamwld, 0, dreamwld, dreamwld, 0, ROT0,  "SemiCom", "Dream World", GAME_SUPPORTS_SAVE )
src/mame/drivers/astrocde.c
r11508r11509
259259
260260static CUSTOM_INPUT( ebases_trackball_r )
261261{
262   astrocde_state *state = field->port->machine().driver_data<astrocde_state>();
262   astrocde_state *state = field->machine().driver_data<astrocde_state>();
263263   static const char *const names[] = { "TRACKX2", "TRACKY2", "TRACKX1", "TRACKY1" };
264   return input_port_read(field->port->machine(), names[state->m_input_select]);
264   return input_port_read(field->machine(), names[state->m_input_select]);
265265}
266266
267267
r11508r11509
487487
488488static CUSTOM_INPUT( demndragn_joystick_r )
489489{
490   astrocde_state *state = field->port->machine().driver_data<astrocde_state>();
490   astrocde_state *state = field->machine().driver_data<astrocde_state>();
491491   static const char *const names[] = { "MOVEX", "MOVEY" };
492   return input_port_read(field->port->machine(), names[state->m_input_select]);
492   return input_port_read(field->machine(), names[state->m_input_select]);
493493}
494494
495495
r11508r11509
841841
842842static INPUT_CHANGED( spacezap_monitor )
843843{
844   astrocde_state *state = field->port->machine().driver_data<astrocde_state>();
844   astrocde_state *state = field->machine().driver_data<astrocde_state>();
845845   if (newval)
846846      state->m_video_config &= ~AC_MONITOR_BW;
847847   else
src/mame/drivers/sg1000.c
r11508r11509
242242
243243static INPUT_CHANGED( trigger_nmi )
244244{
245   cputag_set_input_line(field->port->machine(), Z80_TAG, INPUT_LINE_NMI, (input_port_read(field->port->machine(), "NMI") ? CLEAR_LINE : ASSERT_LINE));
245   cputag_set_input_line(field->machine(), Z80_TAG, INPUT_LINE_NMI, (input_port_read(field->machine(), "NMI") ? CLEAR_LINE : ASSERT_LINE));
246246}
247247
248248/*-------------------------------------------------
src/mame/drivers/galaga.c
r11508r11509
779779   }
780780}
781781
782static CUSTOM_INPUT( shifted_port_r ) { return input_port_read(field->port->machine(), (const char *)param) >> 4; }
782static CUSTOM_INPUT( shifted_port_r ) { return input_port_read(field->machine(), (const char *)param) >> 4; }
783783
784784static WRITE8_DEVICE_HANDLER( out_0 )
785785{
src/mame/drivers/lasso.c
r11508r11509
3838
3939static INPUT_CHANGED( coin_inserted )
4040{
41   lasso_state *state = field->port->machine().driver_data<lasso_state>();
41   lasso_state *state = field->machine().driver_data<lasso_state>();
4242
4343   /* coin insertion causes an NMI */
4444   device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
src/mame/drivers/8080bw.c
r11508r11509
11551155
11561156static CUSTOM_INPUT( sflush_80_r )
11571157{
1158   return (field->port->machine().primary_screen->vpos() & 0x80) ? 1 : 0;
1158   return (field->machine().primary_screen->vpos() & 0x80) ? 1 : 0;
11591159}
11601160
11611161static ADDRESS_MAP_START( sflush_map, AS_PROGRAM, 8 )
src/mame/drivers/psikyo4.c
r11508r11509
198198
199199static CUSTOM_INPUT( system_port_r )
200200{
201   return input_port_read(field->port->machine(), "SYSTEM");
201   return input_port_read(field->machine(), "SYSTEM");
202202}
203203
204204static CUSTOM_INPUT( mahjong_ctrl_r ) /* used by hotgmck/hgkairak */
205205{
206   psikyo4_state *state = field->port->machine().driver_data<psikyo4_state>();
206   psikyo4_state *state = field->machine().driver_data<psikyo4_state>();
207207   int player = (FPTR)param;
208208   int sel = (state->m_io_select[0] & 0x0000ff00) >> 8;
209209   int ret = 0xff;
210210
211   if (sel & 1) ret &= input_port_read(field->port->machine(), player ? "KEY4" : "KEY0" );
212   if (sel & 2) ret &= input_port_read(field->port->machine(), player ? "KEY5" : "KEY1" );
213   if (sel & 4) ret &= input_port_read(field->port->machine(), player ? "KEY6" : "KEY2" );
214   if (sel & 8) ret &= input_port_read(field->port->machine(), player ? "KEY7" : "KEY3" );
211   if (sel & 1) ret &= input_port_read(field->machine(), player ? "KEY4" : "KEY0" );
212   if (sel & 2) ret &= input_port_read(field->machine(), player ? "KEY5" : "KEY1" );
213   if (sel & 4) ret &= input_port_read(field->machine(), player ? "KEY6" : "KEY2" );
214   if (sel & 8) ret &= input_port_read(field->machine(), player ? "KEY7" : "KEY3" );
215215
216216   return ret;
217217}
src/mame/drivers/esripsys.c
r11508r11509
414414
415415static INPUT_CHANGED( keypad_interrupt )
416416{
417   esripsys_state *state = field->port->machine().driver_data<esripsys_state>();
417   esripsys_state *state = field->machine().driver_data<esripsys_state>();
418418   if (newval == 0)
419419   {
420420      state->m_io_firq_status |= 2;
421421      state->m_keypad_status |= 0x20;
422      cputag_set_input_line(field->port->machine(), "game_cpu", M6809_FIRQ_LINE, HOLD_LINE);
422      cputag_set_input_line(field->machine(), "game_cpu", M6809_FIRQ_LINE, HOLD_LINE);
423423   }
424424}
425425
426426static INPUT_CHANGED( coin_interrupt )
427427{
428   esripsys_state *state = field->port->machine().driver_data<esripsys_state>();
428   esripsys_state *state = field->machine().driver_data<esripsys_state>();
429429   if (newval == 1)
430430   {
431431      state->m_io_firq_status |= 2;
432      state->m_coin_latch = input_port_read(field->port->machine(), "COINS") << 2;
433      cputag_set_input_line(field->port->machine(), "game_cpu", M6809_FIRQ_LINE, HOLD_LINE);
432      state->m_coin_latch = input_port_read(field->machine(), "COINS") << 2;
433      cputag_set_input_line(field->machine(), "game_cpu", M6809_FIRQ_LINE, HOLD_LINE);
434434   }
435435}
436436
src/mame/drivers/thayers.c
r11508r11509
614614
615615static CUSTOM_INPUT( laserdisc_enter_r )
616616{
617   thayers_state *state = field->port->machine().driver_data<thayers_state>();
617   thayers_state *state = field->machine().driver_data<thayers_state>();
618618   switch (laserdisc_get_type(state->m_laserdisc))
619619   {
620620      case LASERDISC_TYPE_PIONEER_PR7820:
r11508r11509
629629
630630static CUSTOM_INPUT( laserdisc_ready_r )
631631{
632   thayers_state *state = field->port->machine().driver_data<thayers_state>();
632   thayers_state *state = field->machine().driver_data<thayers_state>();
633633   switch (laserdisc_get_type(state->m_laserdisc))
634634   {
635635      case LASERDISC_TYPE_PIONEER_PR7820:
src/mame/drivers/merit.c
r11508r11509
346346
347347static CUSTOM_INPUT(rndbit_r)
348348{
349   return field->port->machine().rand();
349   return field->machine().rand();
350350}
351351
352352static ADDRESS_MAP_START( pitboss_map, AS_PROGRAM, 8 )
src/mame/drivers/meadows.c
r11508r11509
199199
200200static INPUT_CHANGED( coin_inserted )
201201{
202   cputag_set_input_line_and_vector(field->port->machine(), "maincpu", 0, (newval ? ASSERT_LINE : CLEAR_LINE), 0x82);
202   cputag_set_input_line_and_vector(field->machine(), "maincpu", 0, (newval ? ASSERT_LINE : CLEAR_LINE), 0x82);
203203}
204204
205205
src/mame/drivers/spoker.c
r11508r11509
105105
106106static CUSTOM_INPUT( hopper_r )
107107{
108   running_machine &machine = field->port->machine();
108   running_machine &machine = field->machine();
109109   spoker_state *state = machine.driver_data<spoker_state>();
110110
111111   if (state->m_hopper) return !(machine.primary_screen->frame_number()%10);
src/mame/drivers/madalien.c
r11508r11509
1919static INPUT_CHANGED( coin_inserted )
2020{
2121   /* coin insertion causes an NMI */
22   cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
22   cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
2323}
2424
2525
src/mame/drivers/ksys573.c
r11508r11509
16531653
16541654static CUSTOM_INPUT( gn845pwbb_read )
16551655{
1656   ksys573_state *state = field->port->machine().driver_data<ksys573_state>();
1656   ksys573_state *state = field->machine().driver_data<ksys573_state>();
16571657
1658   return input_port_read(field->port->machine(), "STAGE") & state->m_stage_mask;
1658   return input_port_read(field->machine(), "STAGE") & state->m_stage_mask;
16591659}
16601660
16611661static void gn845pwbb_output_callback( running_machine &machine, int offset, int data )
r11508r11509
28812881
28822882static CUSTOM_INPUT( gunmania_tank_shutter_sensor )
28832883{
2884   ksys573_state *state = field->port->machine().driver_data<ksys573_state>();
2884   ksys573_state *state = field->machine().driver_data<ksys573_state>();
28852885
28862886   if( state->m_tank_shutter_position == 0 )
28872887   {
r11508r11509
28932893
28942894static CUSTOM_INPUT( gunmania_cable_holder_sensor )
28952895{
2896   ksys573_state *state = field->port->machine().driver_data<ksys573_state>();
2896   ksys573_state *state = field->machine().driver_data<ksys573_state>();
28972897
28982898   return state->m_cable_holder_release;
28992899}
src/mame/drivers/bwidow.c
r11508r11509
316316
317317static CUSTOM_INPUT( clock_r )
318318{
319   return (field->port->machine().device<cpu_device>("maincpu")->total_cycles() & 0x100) ? 1 : 0;
319   return (field->machine().device<cpu_device>("maincpu")->total_cycles() & 0x100) ? 1 : 0;
320320}
321321
322322
src/mame/drivers/xmen.c
r11508r11509
258258
259259static CUSTOM_INPUT( xmen_frame_r )
260260{
261   xmen_state *state = field->port->machine().driver_data<xmen_state>();
261   xmen_state *state = field->machine().driver_data<xmen_state>();
262262   return state->m_current_frame;
263263}
264264
src/mame/drivers/exprraid.c
r11508r11509
280280
281281static INPUT_CHANGED( coin_inserted_deco16 )
282282{
283   exprraid_state *state = field->port->machine().driver_data<exprraid_state>();
283   exprraid_state *state = field->machine().driver_data<exprraid_state>();
284284   device_set_input_line(state->m_maincpu, DECO16_IRQ_LINE, newval ? CLEAR_LINE : ASSERT_LINE);
285285}
286286
287287static INPUT_CHANGED( coin_inserted_nmi )
288288{
289   exprraid_state *state = field->port->machine().driver_data<exprraid_state>();
289   exprraid_state *state = field->machine().driver_data<exprraid_state>();
290290   device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
291291}
292292
src/mame/drivers/naughtyb.c
r11508r11509
284284
285285static INPUT_CHANGED( coin_inserted )
286286{
287   cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
287   cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
288288}
289289
290290static INPUT_PORTS_START( naughtyb )
src/mame/drivers/gunbustr.c
r11508r11509
8080
8181static CUSTOM_INPUT( coin_word_r )
8282{
83   gunbustr_state *state = field->port->machine().driver_data<gunbustr_state>();
83   gunbustr_state *state = field->machine().driver_data<gunbustr_state>();
8484   return state->m_coin_word;
8585}
8686
src/mame/drivers/pzletime.c
r11508r11509
202202
203203static CUSTOM_INPUT( ticket_status_r )
204204{
205   pzletime_state *state = field->port->machine().driver_data<pzletime_state>();
206   return (state->m_ticket && !(field->port->machine().primary_screen->frame_number() % 128));
205   pzletime_state *state = field->machine().driver_data<pzletime_state>();
206   return (state->m_ticket && !(field->machine().primary_screen->frame_number() % 128));
207207}
208208
209209static ADDRESS_MAP_START( pzletime_map, AS_PROGRAM, 16 )
src/mame/drivers/equites.c
r11508r11509
657657
658658static CUSTOM_INPUT( gekisou_unknown_status )
659659{
660   equites_state *state = field->port->machine().driver_data<equites_state>();
660   equites_state *state = field->machine().driver_data<equites_state>();
661661   return state->m_unknown_bit;
662662}
663663
src/mame/drivers/gradius3.c
r11508r11509
1919***************************************************************************/
2020
2121#include "emu.h"
22#include "deprecat.h"
2322#include "video/konicdev.h"
2423#include "cpu/m68000/m68000.h"
2524#include "cpu/z80/z80.h"
r11508r11509
115114      device_set_input_line(device, 2, HOLD_LINE);
116115}
117116
118static INTERRUPT_GEN( cpuB_interrupt )
117
118static TIMER_DEVICE_CALLBACK( gradius3_sub_scanline )
119119{
120   gradius3_state *state = device->machine().driver_data<gradius3_state>();
120   gradius3_state *state = timer.machine().driver_data<gradius3_state>();
121   int scanline = param;
121122
122   if (cpu_getiloops(device) & 1)   /* ??? */
123   {
124      if (state->m_irqBmask & 2)
125         device_set_input_line(device, 2, HOLD_LINE);
126   }
127   else
128   {
129      if (state->m_irqBmask & 1)
130         device_set_input_line(device, 1, HOLD_LINE);
131   }
123   if(scanline == 240 && state->m_irqBmask & 1) // vblank-out irq
124      cputag_set_input_line(timer.machine(), "sub", 1, HOLD_LINE);
125
126   if(scanline ==  16 && state->m_irqBmask & 2) // sprite end DMA irq
127      cputag_set_input_line(timer.machine(), "sub", 2, HOLD_LINE);
132128}
133129
134130static WRITE16_HANDLER( cpuB_irqtrigger_w )
r11508r11509
336332
337333   MCFG_CPU_ADD("sub", M68000, 10000000)   /* 10 MHz */
338334   MCFG_CPU_PROGRAM_MAP(gradius3_map2)
339   MCFG_CPU_VBLANK_INT_HACK(cpuB_interrupt,2)   /* has three interrupt vectors, 1 2 and 4 */
340                        /* 4 is triggered by cpu A, the others are unknown but */
341                        /* required for the game to run. */
335   MCFG_TIMER_ADD_SCANLINE("scantimer", gradius3_sub_scanline, "screen", 0, 1) /* has three interrupt vectors, 1 2 and 4 */
336                                                            /* 4 is triggered by cpu A, the others are unknown but */
337                                                            /* required for the game to run. */
338
342339   MCFG_CPU_ADD("audiocpu", Z80, 3579545)
343340   MCFG_CPU_PROGRAM_MAP(gradius3_s_map)
344341
src/mame/drivers/dlair.c
r11508r11509
316316
317317static CUSTOM_INPUT( laserdisc_status_r )
318318{
319   dlair_state *state = field->port->machine().driver_data<dlair_state>();
319   dlair_state *state = field->machine().driver_data<dlair_state>();
320320   switch (laserdisc_get_type(state->m_laserdisc))
321321   {
322322      case LASERDISC_TYPE_PIONEER_PR7820:
r11508r11509
334334
335335static CUSTOM_INPUT( laserdisc_command_r )
336336{
337   dlair_state *state = field->port->machine().driver_data<dlair_state>();
337   dlair_state *state = field->machine().driver_data<dlair_state>();
338338   switch (laserdisc_get_type(state->m_laserdisc))
339339   {
340340      case LASERDISC_TYPE_PIONEER_PR7820:
src/mame/drivers/firetrk.c
r11508r11509
2929
3030static INPUT_CHANGED( service_mode_switch_changed )
3131{
32   set_service_mode(field->port->machine(), newval);
32   set_service_mode(field->machine(), newval);
3333}
3434
3535
3636static INPUT_CHANGED( firetrk_horn_changed )
3737{
38   device_t *discrete = field->port->machine().device("discrete");
38   device_t *discrete = field->machine().device("discrete");
3939   discrete_sound_w(discrete, FIRETRUCK_HORN_EN, newval);
4040}
4141
4242
4343static INPUT_CHANGED( gear_changed )
4444{
45   firetrk_state *state = field->port->machine().driver_data<firetrk_state>();
45   firetrk_state *state = field->machine().driver_data<firetrk_state>();
4646   if (newval)
4747      state->m_gear = (FPTR)param;
4848}
r11508r11509
200200
201201static CUSTOM_INPUT( steer_dir_r )
202202{
203   firetrk_state *state = field->port->machine().driver_data<firetrk_state>();
203   firetrk_state *state = field->machine().driver_data<firetrk_state>();
204204   return state->m_steer_dir[(FPTR)param];
205205}
206206
207207
208208static CUSTOM_INPUT( steer_flag_r )
209209{
210   firetrk_state *state = field->port->machine().driver_data<firetrk_state>();
210   firetrk_state *state = field->machine().driver_data<firetrk_state>();
211211   return state->m_steer_flag[(FPTR)param];
212212}
213213
214214
215215static CUSTOM_INPUT( skid_r )
216216{
217   firetrk_state *state = field->port->machine().driver_data<firetrk_state>();
217   firetrk_state *state = field->machine().driver_data<firetrk_state>();
218218   UINT32 ret;
219219   int which = (FPTR)param;
220220
r11508r11509
229229
230230static CUSTOM_INPUT( crash_r )
231231{
232   firetrk_state *state = field->port->machine().driver_data<firetrk_state>();
232   firetrk_state *state = field->machine().driver_data<firetrk_state>();
233233   UINT32 ret;
234234   int which = (FPTR)param;
235235
r11508r11509
244244
245245static CUSTOM_INPUT( gear_r )
246246{
247   firetrk_state *state = field->port->machine().driver_data<firetrk_state>();
247   firetrk_state *state = field->machine().driver_data<firetrk_state>();
248248   return (state->m_gear == (FPTR)param) ? 1 : 0;
249249}
250250
src/mame/drivers/peplus.c
r11508r11509
799799static CUSTOM_INPUT( peplus_input_r )
800800{
801801   UINT8 inp_ret = 0x00;
802   UINT8 inp_read = input_port_read(field->port->machine(), (const char *)param);
802   UINT8 inp_read = input_port_read(field->machine(), (const char *)param);
803803
804804   if (inp_read & 0x01) inp_ret = 0x01;
805805   if (inp_read & 0x02) inp_ret = 0x02;
src/mame/drivers/ddayjlc.c
r11508r11509
130130
131131static CUSTOM_INPUT( prot_r )
132132{
133   ddayjlc_state *state = field->port->machine().driver_data<ddayjlc_state>();
133   ddayjlc_state *state = field->machine().driver_data<ddayjlc_state>();
134134   return prot_data[state->m_prot_addr];
135135}
136136
src/mame/drivers/dorachan.c
r11508r11509
4141
4242static CUSTOM_INPUT( dorachan_protection_r )
4343{
44   dorachan_state *state = field->port->machine().driver_data<dorachan_state>();
44   dorachan_state *state = field->machine().driver_data<dorachan_state>();
4545   UINT8 ret = 0;
4646
4747   switch (cpu_get_previouspc(state->m_main_cpu))
r11508r11509
129129
130130static CUSTOM_INPUT( dorachan_v128_r )
131131{
132   dorachan_state *state = field->port->machine().driver_data<dorachan_state>();
132   dorachan_state *state = field->machine().driver_data<dorachan_state>();
133133
134134   /* to avoid resetting (when player 2 starts) bit 0 need to be inverted when screen is flipped */
135   return ((field->port->machine().primary_screen->vpos() >> 7) & 0x01) ^ state->m_flip_screen;
135   return ((field->machine().primary_screen->vpos() >> 7) & 0x01) ^ state->m_flip_screen;
136136}
137137
138138
src/mame/drivers/exidy.c
r11508r11509
157157
158158static CUSTOM_INPUT( teetert_input_r )
159159{
160   exidy_state *state = field->port->machine().driver_data<exidy_state>();
161   UINT8 dial = input_port_read(field->port->machine(), "DIAL");
160   exidy_state *state = field->machine().driver_data<exidy_state>();
161   UINT8 dial = input_port_read(field->machine(), "DIAL");
162162   int result = 0;
163163
164164   result = (dial != state->m_last_dial) << 4;
src/mame/drivers/cidelsa.c
r11508r11509
272272
273273static CUSTOM_INPUT( cdp1869_pcb_r )
274274{
275   cidelsa_state *state = field->port->machine().driver_data<cidelsa_state>();
275   cidelsa_state *state = field->machine().driver_data<cidelsa_state>();
276276
277277   return state->m_cdp1869_pcb;
278278}
279279
280280static INPUT_CHANGED( ef_w )
281281{
282   cputag_set_input_line(field->port->machine(), CDP1802_TAG, (int)(FPTR)param, newval);
282   cputag_set_input_line(field->machine(), CDP1802_TAG, (int)(FPTR)param, newval);
283283}
284284
285285static INPUT_PORTS_START( destryer )
src/mame/drivers/taito_f3.c
r11508r11509
5151   const char *tag = (const char *)param;
5252   UINT32 ipt = 0;
5353
54   ipt = ((input_port_read(field->port->machine(), tag) & 0xf)<<12) | ((input_port_read(field->port->machine(), tag) & 0xff0)>>4);
54   ipt = ((input_port_read(field->machine(), tag) & 0xf)<<12) | ((input_port_read(field->machine(), tag) & 0xff0)>>4);
5555
5656   return ipt;
5757}
5858
5959static CUSTOM_INPUT( f3_coin_r )
6060{
61   taito_f3_state *state = field->port->machine().driver_data<taito_f3_state>();
61   taito_f3_state *state = field->machine().driver_data<taito_f3_state>();
6262   int num = (FPTR)param;
6363   return state->m_coin_word[num];
6464}
src/mame/drivers/jpmsys5.c
r11508r11509
368368
369369static INPUT_CHANGED( touchscreen_press )
370370{
371   jpmsys5_state *state = field->port->machine().driver_data<jpmsys5_state>();
371   jpmsys5_state *state = field->machine().driver_data<jpmsys5_state>();
372372   if (newval == 0)
373373   {
374374      attotime rx_period = attotime::from_hz(10000) * 16;
375375
376376      /* Each touch screen packet is 3 bytes */
377377      state->m_touch_data[0] = 0x2a;
378      state->m_touch_data[1] = 0x7 - (input_port_read(field->port->machine(), "TOUCH_Y") >> 5) + 0x30;
379      state->m_touch_data[2] = (input_port_read(field->port->machine(), "TOUCH_X") >> 5) + 0x30;
378      state->m_touch_data[1] = 0x7 - (input_port_read(field->machine(), "TOUCH_Y") >> 5) + 0x30;
379      state->m_touch_data[2] = (input_port_read(field->machine(), "TOUCH_X") >> 5) + 0x30;
380380
381381      /* Start sending the data to the 68000 serially */
382382      state->m_touch_data_count = 0;
src/mame/drivers/homerun.c
r11508r11509
6464
6565static CUSTOM_INPUT( homerun_40_r )
6666{
67   UINT8 ret = (field->port->machine().primary_screen->vpos() > 116) ? 1 : 0;
67   UINT8 ret = (field->machine().primary_screen->vpos() > 116) ? 1 : 0;
6868
6969   return ret;
7070}
src/mame/drivers/champbas.c
r11508r11509
119119
120120static CUSTOM_INPUT( champbas_watchdog_bit2 )
121121{
122   champbas_state *state = field->port->machine().driver_data<champbas_state>();
122   champbas_state *state = field->machine().driver_data<champbas_state>();
123123   return BIT(state->m_watchdog_count, 2);
124124}
125125
src/mame/drivers/ssozumo.c
r11508r11509
5151
5252static INPUT_CHANGED( coin_inserted )
5353{
54   cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
54   cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
5555}
5656
5757static INPUT_PORTS_START( ssozumo )
src/mame/drivers/arkanoid.c
r11508r11509
858858   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
859859INPUT_PORTS_END
860860
861static INPUT_PORTS_START( brixian )
862         PORT_START("SYSTEM")
863   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
864   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
865   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
866   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
867   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
868   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
869   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 )
870   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
871
872   PORT_START("BUTTONS")
873   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
874   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY
875   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY
876   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY
877   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY
878   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 )
879   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 )
880   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON3 )
881
882   PORT_START("MUX")
883   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START2 )
884   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY PORT_PLAYER(2)
885   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_PLAYER(2)
886   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_PLAYER(2)
887   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_PLAYER(2)
888   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
889   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
890   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
891
892   PORT_START("DSW")
893   PORT_DIPNAME( 0x0f, 0x01, DEF_STR( Lives ) )      PORT_DIPLOCATION("SW1:1,2,3,4")
894   PORT_DIPSETTING(    0x00, "2" )
895   PORT_DIPSETTING(    0x01, "3" )
896   PORT_DIPSETTING(    0x03, "4" )
897   PORT_DIPSETTING(    0x07, "5" )
898   PORT_DIPSETTING(    0x0f, "6" )
899   PORT_DIPNAME( 0x30, 0x00, "Speed of Elevator" )      PORT_DIPLOCATION("SW1:5,6")
900   PORT_DIPSETTING(    0x00, "Slow" )
901   PORT_DIPSETTING(    0x30, "Fast" )
902   PORT_DIPNAME( 0xc0, 0x40, "Time Left" )         PORT_DIPLOCATION("SW1:7,8")
903   PORT_DIPSETTING(    0x00, "Half" )
904   PORT_DIPSETTING(    0x40, DEF_STR( Normal ) )
905   PORT_DIPSETTING(    0xc0, "Double" )
906
907   PORT_START("UNUSED")
908   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
909INPUT_PORTS_END
910
861911/***************************************************************************/
862912
863913/* Graphics Layouts */
r11508r11509
10381088   MCFG_DEVICE_REMOVE("mcu")
10391089MACHINE_CONFIG_END
10401090
1091// todo
1092static MACHINE_CONFIG_DERIVED( brixian, arkanoid )
10411093
1094   /* basic machine hardware */
1095   MCFG_CPU_MODIFY("maincpu")
1096   MCFG_CPU_PROGRAM_MAP(bootleg_map)
1097   MCFG_CPU_VBLANK_INT("screen", irq0_line_hold)
1098
1099   MCFG_DEVICE_REMOVE("mcu")
1100MACHINE_CONFIG_END
1101
10421102/***************************************************************************/
10431103
10441104/* ROMs */
r11508r11509
14411501   ROM_LOAD( "hexa.002",     0x0200, 0x0100, CRC(ff15366c) SHA1(7feaf1c768bfe76432fb80991585e13d95960b34) )
14421502ROM_END
14431503
1504ROM_START( brixian )
1505   ROM_REGION( 0x18000, "maincpu", 0 )
1506   ROM_LOAD( "b1.bin",      0x00000, 0x8000, CRC(3d167d09) SHA1(1d5bd098b655b8d2f956cfcb718213915bee3e41) )
1507   ROM_LOAD( "e7.bin",      0x08000, 0x2000, CRC(9e3707ab) SHA1(a04fb4824239f8ed1ef1de2f3c0f9d749320b2ba) ) // what is this? where does it map?
14441508
1509   ROM_REGION( 0x18000, "gfx1", 0 )
1510   ROM_LOAD( "b4.bin",      0x00000, 0x8000, CRC(34a7a693) SHA1(793fa6dd065a158bedcd0fdc494cc8fc793ae8be) )
1511   ROM_LOAD( "c4.bin",      0x08000, 0x8000, CRC(d422eda5) SHA1(4874b57ec8a8aa29937f5ccc2a734ffeb7834d8a) )
1512   ROM_LOAD( "e4.bin",      0x10000, 0x8000, CRC(9b2e79d6) SHA1(8a40e0ef2a792efc37ea50eec01cf3fb5a3e3215) )
1513
1514   ROM_REGION( 0x0600, "proms", 0 )
1515   ROM_LOAD( "r",    0x0000, 0x0200, NO_DUMP )
1516   ROM_LOAD( "g",    0x0200, 0x0200, NO_DUMP )
1517   ROM_LOAD( "b",    0x0400, 0x0200, NO_DUMP )
1518
1519   ROM_REGION( 0x0800, "mcu", 0 )
1520   ROM_LOAD( "68705p5", 0x0000, 0x0800, NO_DUMP ) // this appears to be providing ~0x200 bytes of code at c600, like most semicom games.
1521ROM_END
1522
1523
1524
14451525/* Driver Initialization */
14461526
14471527static void arkanoid_bootleg_init( running_machine &machine )
r11508r11509
15871667GAME( 1987, arkatour,   arkanoid, arkanoid, arkanoid, 0,        ROT90, "Taito America Corporation (Romstar license)", "Tournament Arkanoid (US)", GAME_SUPPORTS_SAVE )
15881668GAME( 19??, tetrsark,   0,        bootleg,  tetrsark, tetrsark, ROT0,  "D.R. Korea", "Tetris (D.R. Korea)", GAME_SUPPORTS_SAVE )
15891669GAME( 199?, hexa,       0,        hexa,     hexa,     hexa,     ROT0,  "D.R. Korea", "Hexa", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1670GAME( 1993, brixian,    0,        brixian,  brixian,  0,        ROT0,  "Cheil Computer System", "Brixian", GAME_SUPPORTS_SAVE|GAME_NOT_WORKING )
src/mame/drivers/crshrace.c
r11508r11509
174174
175175static CUSTOM_INPUT( country_sndpending_r )
176176{
177   crshrace_state *state = field->port->machine().driver_data<crshrace_state>();
177   crshrace_state *state = field->machine().driver_data<crshrace_state>();
178178   return state->m_pending_command;
179179}
180180
src/mame/drivers/igs011.c
r11508r11509
466466
467467static CUSTOM_INPUT( igs_hopper_r )
468468{
469   igs011_state *state = field->port->machine().driver_data<igs011_state>();
470   return (state->m_igs_hopper && ((field->port->machine().primary_screen->frame_number()/5)&1)) ? 0x0000 : 0x0001;
469   igs011_state *state = field->machine().driver_data<igs011_state>();
470   return (state->m_igs_hopper && ((field->machine().primary_screen->frame_number()/5)&1)) ? 0x0000 : 0x0001;
471471}
472472
473473static WRITE16_HANDLER( igs_dips_w )
src/mame/drivers/bwing.c
r11508r11509
200200
201201static INPUT_CHANGED( coin_inserted )
202202{
203   cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
203   cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
204204}
205205
206206static INPUT_CHANGED( tilt_pressed )
207207{
208   cputag_set_input_line(field->port->machine(), "maincpu", M6809_FIRQ_LINE, newval ? ASSERT_LINE : CLEAR_LINE);
208   cputag_set_input_line(field->machine(), "maincpu", M6809_FIRQ_LINE, newval ? ASSERT_LINE : CLEAR_LINE);
209209}
210210
211211static INPUT_PORTS_START( bwing )
src/mame/drivers/cave.c
r11508r11509
692692
693693static CUSTOM_INPUT( korokoro_hopper_r )
694694{
695   cave_state *state = field->port->machine().driver_data<cave_state>();
695   cave_state *state = field->machine().driver_data<cave_state>();
696696   return state->m_hopper ? 1 : 0;
697697}
698698
r11508r11509
928928
929929static CUSTOM_INPUT( tjumpman_hopper_r )
930930{
931   cave_state *state = field->port->machine().driver_data<cave_state>();
932   return (state->m_hopper && !(field->port->machine().primary_screen->frame_number() % 10)) ? 0 : 1;
931   cave_state *state = field->machine().driver_data<cave_state>();
932   return (state->m_hopper && !(field->machine().primary_screen->frame_number() % 10)) ? 0 : 1;
933933}
934934
935935static ADDRESS_MAP_START( tjumpman_map, AS_PROGRAM, 16 )
src/mame/drivers/wolfpack.c
r11508r11509
3333static CUSTOM_INPUT( wolfpack_dial_r )
3434{
3535   int bit = (FPTR)param;
36   return ((input_port_read(field->port->machine(), "DIAL") + bit) / 2) & 0x01;
36   return ((input_port_read(field->machine(), "DIAL") + bit) / 2) & 0x01;
3737}
3838
3939
src/mame/drivers/pirates.c
r11508r11509
132132//  offs_t pc;
133133   int bit;
134134
135//  logerror("%s: IN1_r\n",field->port->machine().describe_context());
135//  logerror("%s: IN1_r\n",field->machine().describe_context());
136136
137137#if 0
138138   /* Pirates protection workaround. It more complicated than this... see code at
139139       602e and 62a6 */
140140   /* For Genix, see 6576 for setting values and 67c2,d3b4 and dbc2 for tests. */
141141
142   pc = cpu_get_pc(field->port->machine().device("main"));
142   pc = cpu_get_pc(field->machine().device("main"));
143143   if (pc == 0x6134)
144144   {
145145      bit = prot & 1;
src/mame/drivers/tankbatt.c
r11508r11509
194194
195195static INPUT_CHANGED( coin_inserted )
196196{
197   cputag_set_input_line(field->port->machine(), "maincpu", 0, ASSERT_LINE);
197   cputag_set_input_line(field->machine(), "maincpu", 0, ASSERT_LINE);
198198}
199199
200200static INPUT_PORTS_START( tankbatt )
src/mame/drivers/m10.c
r11508r11509
508508
509509static INPUT_CHANGED( coin_inserted )
510510{
511   m10_state *state = field->port->machine().driver_data<m10_state>();
511   m10_state *state = field->machine().driver_data<m10_state>();
512512   /* coin insertion causes an NMI */
513513   device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE);
514514}
src/emu/tokenize.h
r11508r11509
1/***************************************************************************
2
3    tokenize.h
4
5    Common definitions and macros for tokenizing definitions.
6
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
9
10***************************************************************************/
11
12#pragma once
13
14#ifndef __TOKENIZE_H__
15#define __TOKENIZE_H__
16
17
18/***************************************************************************
19    CONSTANTS
20***************************************************************************/
21
22/* tokens per item */
23#define TOKENS_PER_PTR         (1)
24#define TOKENS_PER_UINT32      (1)
25#define TOKENS_PER_UINT64      (8 / sizeof(FPTR))
26#define TOKENS_PER_ATTOTIME      (TOKENS_PER_UINT32 + TOKENS_PER_UINT64)
27
28
29
30/***************************************************************************
31    TYPE DEFINITIONS
32***************************************************************************/
33
34/* include this at the top of your union to get the standard fields */
35#define TOKEN_COMMON_FIELDS      \
36   FPTR         i;         \
37   const char *   stringptr;   \
38   const void *   voidptr;   \
39   const UINT8 *   ui8ptr;      \
40   const INT8 *   i8ptr;      \
41   const UINT16 *   ui16ptr;   \
42   const INT16 *   i16ptr;      \
43   const UINT32 *   ui32ptr;   \
44   const INT32 *   i32ptr;      \
45   const UINT64 *   ui64ptr;   \
46   const INT64 *   i64ptr;      \
47
48
49/* generic_token can be used when there are no particularly special types */
50typedef struct _generic_token generic_token;
51struct _generic_token
52{
53   TOKEN_COMMON_FIELDS
54};
55
56
57
58/***************************************************************************
59    MACROS
60***************************************************************************/
61
62/* ----- compile-time token generation macros ----- */
63
64/* GCC and C99 compilers can use designated initializers for type safety */
65#if (defined(__GNUC__) && (__GNUC__ >= 3) && !defined(__cplusplus)) || (defined(_STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
66#define TOKEN_VALUE(field,a)   { .field = (a) }
67#else
68#define TOKEN_VALUE(field,a)   { (FPTR)(a) }
69#endif
70
71/* token output primitives */
72/* note that regardless of the endianness, UINT64s are packed LSW first */
73#define TOKEN_PTR(field,p)      TOKEN_VALUE(field, p)
74#define TOKEN_STRING(p)         TOKEN_VALUE(stringptr, p)
75#define TOKEN_UINT32(a)         TOKEN_VALUE(i, a)
76#ifdef PTR64
77#define TOKEN_UINT64(a)         TOKEN_VALUE(i, a)
78#else
79#define TOKEN_UINT64(a)         TOKEN_VALUE(i, (UINT32)(a)), TOKEN_VALUE(i, (UINT32)((a) >> 32))
80#endif
81
82/* mask a value to a fixed number of bits and then shift it */
83#define SHIFT_AND_MASK32(val, bits, shift)      (((UINT32)(val) & ((1 << (bits)) - 1)) << (shift))
84#define SHIFT_AND_MASK64(val, bits, shift)      (((UINT64)(val) & (((UINT64)1 << (bits)) - 1)) << (shift))
85
86/* 32-bit integer packing */
87#define TOKEN_UINT32_PACK1(val1, bits1) \
88   TOKEN_UINT32(SHIFT_AND_MASK32((val1), (bits1), 0))
89
90#define TOKEN_UINT32_PACK2(val1, bits1, val2, bits2) \
91   TOKEN_UINT32(SHIFT_AND_MASK32((val1), (bits1), 0) | \
92             SHIFT_AND_MASK32((val2), (bits2), (bits1)))
93
94#define TOKEN_UINT32_PACK3(val1, bits1, val2, bits2, val3, bits3) \
95   TOKEN_UINT32(SHIFT_AND_MASK32((val1), (bits1), 0) | \
96             SHIFT_AND_MASK32((val2), (bits2), (bits1)) | \
97             SHIFT_AND_MASK32((val3), (bits3), (bits1)+(bits2)))
98
99#define TOKEN_UINT32_PACK4(val1, bits1, val2, bits2, val3, bits3, val4, bits4) \
100   TOKEN_UINT32(SHIFT_AND_MASK32((val1), (bits1), 0) | \
101             SHIFT_AND_MASK32((val2), (bits2), (bits1)) | \
102             SHIFT_AND_MASK32((val3), (bits3), (bits1)+(bits2)) | \
103             SHIFT_AND_MASK32((val4), (bits4), (bits1)+(bits2)+(bits3)))
104
105/* 64-bit integer packing */
106#define TOKEN_UINT64_PACK1(val1, bits1) \
107   TOKEN_UINT64(SHIFT_AND_MASK64((val1), (bits1), 0))
108
109#define TOKEN_UINT64_PACK2(val1, bits1, val2, bits2) \
110   TOKEN_UINT64(SHIFT_AND_MASK64((val1), (bits1), 0) | \
111             SHIFT_AND_MASK64((val2), (bits2), (bits1)))
112
113#define TOKEN_UINT64_PACK3(val1, bits1, val2, bits2, val3, bits3) \
114   TOKEN_UINT64(SHIFT_AND_MASK64((val1), (bits1), 0) | \
115             SHIFT_AND_MASK64((val2), (bits2), (bits1)) | \
116             SHIFT_AND_MASK64((val3), (bits3), (bits1)+(bits2)))
117
118#define TOKEN_UINT64_PACK4(val1, bits1, val2, bits2, val3, bits3, val4, bits4) \
119   TOKEN_UINT64(SHIFT_AND_MASK64((val1), (bits1), 0) | \
120             SHIFT_AND_MASK64((val2), (bits2), (bits1)) | \
121             SHIFT_AND_MASK64((val3), (bits3), (bits1)+(bits2)) | \
122             SHIFT_AND_MASK64((val4), (bits4), (bits1)+(bits2)+(bits3)))
123
124
125
126/* ----- run-time token extraction macros ----- */
127
128/* token fetch and advance primitives */
129#define TOKEN_GET_PTR(tp,field)      (((tp)++)->field)
130#define TOKEN_GET_STRING(tp)      (((tp)++)->stringptr)
131#define TOKEN_GET_UINT32(tp)      (((tp)++)->i)
132#ifdef PTR64
133#define TOKEN_EXTRACT_UINT64(tp,a)   do { (a) = (tp)->i; (tp)++; } while (0)
134#else
135#define TOKEN_EXTRACT_UINT64(tp,a)   do { (a) = (tp)[0].i | ((UINT64)(tp)[1].i << 32); (tp) += 2; } while (0)
136#endif
137
138/* token unfetch primitives */
139#define TOKEN_UNGET_PTR(tp)         ((tp)--)
140#define TOKEN_UNGET_STRING(tp)      ((tp)--)
141#define TOKEN_UNGET_UINT32(tp)      ((tp)--)
142#define TOKEN_UNGET_UINT64(tp)      ((tp) -= 8 / sizeof(FPTR))
143
144/* token skip primitives */
145#define TOKEN_SKIP_PTR(tp)         ((tp)++)
146#define TOKEN_SKIP_STRING(tp)      ((tp)++)
147#define TOKEN_SKIP_UINT32(tp)      ((tp)++)
148#define TOKEN_SKIP_UINT64(tp)      ((tp) += 8 / sizeof(FPTR))
149
150/* extract a value from a fixed number of bits; if bits is negative, treat it as a signed value */
151#define UNSHIFT_AND_MASK32(src, val, bits, shift)   do { \
152   if ((bits) < 0) \
153      (val) = token_sign_extend32((src) >> (shift), (UINT8)-(bits)); \
154   else \
155      (val) = token_zero_extend32((src) >> (shift), (UINT8)(bits)); \
156} while (0)
157
158#define UNSHIFT_AND_MASK64(src, val, bits, shift)   do { \
159   if ((bits) < 0) \
160      (val) = token_sign_extend64((src) >> (shift), (UINT8)-(bits)); \
161   else \
162      (val) = token_zero_extend64((src) >> (shift), (UINT8)(bits)); \
163} while (0)
164
165/* cheesy inline absolute value */
166#define TOKENABS(v)      (((v) < 0) ? -(v) : (v))
167
168/* 32-bit integer unpacking */
169#define TOKEN_GET_UINT32_UNPACK1(tp, val1, bits1) do { \
170   UINT32 token32 = TOKEN_GET_UINT32(tp); \
171   UNSHIFT_AND_MASK32(token32, val1, (bits1), 0); \
172} while (0)
173
174#define TOKEN_GET_UINT32_UNPACK2(tp, val1, bits1, val2, bits2) do { \
175   UINT32 token32 = TOKEN_GET_UINT32(tp); \
176   UINT8 shift = 0; \
177   UNSHIFT_AND_MASK32(token32, val1, (bits1), shift); shift += TOKENABS(bits1); \
178   UNSHIFT_AND_MASK32(token32, val2, (bits2), shift); \
179} while (0)
180
181#define TOKEN_GET_UINT32_UNPACK3(tp, val1, bits1, val2, bits2, val3, bits3) do { \
182   UINT32 token32 = TOKEN_GET_UINT32(tp); \
183   UINT8 shift = 0; \
184   UNSHIFT_AND_MASK32(token32, val1, (bits1), shift); shift += TOKENABS(bits1); \
185   UNSHIFT_AND_MASK32(token32, val2, (bits2), shift); shift += TOKENABS(bits2); \
186   UNSHIFT_AND_MASK32(token32, val3, (bits3), shift); \
187} while (0)
188
189#define TOKEN_GET_UINT32_UNPACK4(tp, val1, bits1, val2, bits2, val3, bits3, val4, bits4) do { \
190   UINT32 token32 = TOKEN_GET_UINT32(tp); \
191   UINT8 shift = 0; \
192   UNSHIFT_AND_MASK32(token32, val1, (bits1), shift); shift += TOKENABS(bits1); \
193   UNSHIFT_AND_MASK32(token32, val2, (bits2), shift); shift += TOKENABS(bits2); \
194   UNSHIFT_AND_MASK32(token32, val3, (bits3), shift); shift += TOKENABS(bits3); \
195   UNSHIFT_AND_MASK32(token32, val4, (bits4), shift); \
196} while (0)
197
198/* 64-bit integer unpacking */
199#define TOKEN_GET_UINT64_UNPACK1(tp, val1, bits1) do { \
200   UINT64 token64; \
201   TOKEN_EXTRACT_UINT64(tp, token64); \
202   UNSHIFT_AND_MASK64(token64, val1, (bits1), 0); \
203} while (0)
204
205#define TOKEN_GET_UINT64_UNPACK2(tp, val1, bits1, val2, bits2) do { \
206   UINT64 token64; \
207   UINT8 shift = 0; \
208   TOKEN_EXTRACT_UINT64(tp, token64); \
209   UNSHIFT_AND_MASK64(token64, val1, (bits1), shift); shift += TOKENABS(bits1); \
210   UNSHIFT_AND_MASK64(token64, val2, (bits2), shift); \
211} while (0)
212
213#define TOKEN_GET_UINT64_UNPACK3(tp, val1, bits1, val2, bits2, val3, bits3) do { \
214   UINT64 token64; \
215   UINT8 shift = 0; \
216   TOKEN_EXTRACT_UINT64(tp, token64); \
217   UNSHIFT_AND_MASK64(token64, val1, (bits1), shift); shift += TOKENABS(bits1); \
218   UNSHIFT_AND_MASK64(token64, val2, (bits2), shift); shift += TOKENABS(bits2); \
219   UNSHIFT_AND_MASK64(token64, val3, (bits3), shift); \
220} while (0)
221
222#define TOKEN_GET_UINT64_UNPACK4(tp, val1, bits1, val2, bits2, val3, bits3, val4, bits4) do { \
223   UINT64 token64; \
224   UINT8 shift = 0; \
225   TOKEN_EXTRACT_UINT64(tp, token64); \
226   UNSHIFT_AND_MASK64(token64, val1, (bits1), shift); shift += TOKENABS(bits1); \
227   UNSHIFT_AND_MASK64(token64, val2, (bits2), shift); shift += TOKENABS(bits2); \
228   UNSHIFT_AND_MASK64(token64, val3, (bits3), shift); shift += TOKENABS(bits3); \
229   UNSHIFT_AND_MASK64(token64, val4, (bits4), shift); \
230} while (0)
231
232
233
234/***************************************************************************
235    INLINE FUNCTIONS
236***************************************************************************/
237
238INLINE UINT32 token_zero_extend32(UINT32 val, UINT8 bits)
239{
240   return val & (((UINT32)1 << bits) - 1);
241}
242
243INLINE INT32 token_sign_extend32(UINT32 val, UINT8 bits)
244{
245   return (INT32)(val << (32 - bits)) >> (32 - bits);
246}
247
248INLINE UINT64 token_zero_extend64(UINT64 val, UINT8 bits)
249{
250   return val & (((UINT64)1 << bits) - 1);
251}
252
253INLINE INT64 token_sign_extend64(UINT64 val, UINT8 bits)
254{
255   return (INT64)(val << (64 - bits)) >> (64 - bits);
256}
257
258#endif
src/emu/uimenu.c
r11508r11509
168168typedef struct _analog_item_data analog_item_data;
169169struct _analog_item_data
170170{
171   const input_field_config *field;
171   input_field_config *field;
172172   int               type;
173173   int               min, max;
174174   int               cur;
r11508r11509
327327    to the default sequence for the given field
328328-------------------------------------------------*/
329329
330INLINE const input_seq *get_field_default_seq(const input_field_config *field, input_seq_type seqtype)
330INLINE const input_seq *get_field_default_seq(input_field_config *field, input_seq_type seqtype)
331331{
332332   if (input_seq_get_1(&field->seq[seqtype]) == SEQCODE_DEFAULT)
333      return input_type_seq(field->port->machine(), field->type, field->player, seqtype);
333      return input_type_seq(field->machine(), field->type, field->player, seqtype);
334334   else
335335      return &field->seq[seqtype];
336336}
r11508r11509
16251625
16261626static void menu_main_populate(running_machine &machine, ui_menu *menu, void *state)
16271627{
1628   const input_field_config *field;
1629   const input_port_config *port;
1628   input_field_config *field;
1629   input_port_config *port;
16301630   int has_categories = FALSE;
16311631   int has_configs = FALSE;
16321632   int has_analog = FALSE;
r11508r11509
16341634
16351635   /* scan the input port array to see what options we need to enable */
16361636   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
1637      for (field = port->fieldlist; field != NULL; field = field->next)
1637      for (field = port->fieldlist().first(); field != NULL; field = field->next())
16381638      {
16391639         if (field->type == IPT_DIPSWITCH)
16401640            has_dips = TRUE;
r11508r11509
18441844static void menu_input_specific_populate(running_machine &machine, ui_menu *menu, input_menu_state *menustate)
18451845{
18461846   input_item_data *itemlist = NULL;
1847   const input_field_config *field;
1848   const input_port_config *port;
1847   input_field_config *field;
1848   input_port_config *port;
18491849   int suborder[SEQ_TYPE_TOTAL];
18501850   astring tempstring;
18511851
r11508r11509
18561856
18571857   /* iterate over the input ports and add menu items */
18581858   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
1859      for (field = port->fieldlist; field != NULL; field = field->next)
1859      for (field = port->fieldlist().first(); field != NULL; field = field->next())
18601860      {
18611861         const char *name = input_field_name(field);
18621862
r11508r11509
19991999      {
20002000         input_field_user_settings settings;
20012001
2002         input_field_get_user_settings((const input_field_config *)seqchangeditem->ref, &settings);
2002         input_field_get_user_settings((input_field_config *)seqchangeditem->ref, &settings);
20032003         settings.seq[seqchangeditem->seqtype] = seqchangeditem->seq;
2004         input_field_set_user_settings((const input_field_config *)seqchangeditem->ref, &settings);
2004         input_field_set_user_settings((input_field_config *)seqchangeditem->ref, &settings);
20052005      }
20062006
20072007      /* invalidate the menu to force an update */
r11508r11509
21562156   /* handle events */
21572157   if (menu_event != NULL && menu_event->itemref != NULL)
21582158   {
2159      const input_field_config *field = (const input_field_config *)menu_event->itemref;
2159      input_field_config *field = (input_field_config *)menu_event->itemref;
21602160      input_field_user_settings settings;
21612161      int changed = FALSE;
21622162
r11508r11509
21972197
21982198static void menu_settings_populate(running_machine &machine, ui_menu *menu, settings_menu_state *menustate, UINT32 type)
21992199{
2200   const input_field_config *field;
2201   const input_port_config *port;
2200   input_field_config *field;
2201   input_port_config *port;
22022202   dip_descriptor **diplist_tailptr;
22032203   int dipcount = 0;
22042204
r11508r11509
22082208
22092209   /* loop over input ports and set up the current values */
22102210   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
2211      for (field = port->fieldlist; field != NULL; field = field->next)
2211      for (field = port->fieldlist().first(); field != NULL; field = field->next())
22122212         if (field->type == type && input_condition_true(machine, &field->condition))
22132213         {
22142214            UINT32 flags = 0;
r11508r11509
22232223            ui_menu_item_append(menu, input_field_name(field), input_field_setting_name(field), flags, (void *)field);
22242224
22252225            /* for DIP switches, build up the model */
2226            if (type == IPT_DIPSWITCH && field->diploclist != NULL)
2226            if (type == IPT_DIPSWITCH && field->diploclist().count() != 0)
22272227            {
22282228               const input_field_diplocation *diploc;
22292229               input_field_user_settings settings;
r11508r11509
22332233               input_field_get_user_settings(field, &settings);
22342234
22352235               /* iterate over each bit in the field */
2236               for (diploc = field->diploclist; diploc != NULL; diploc = diploc->next)
2236               for (diploc = field->diploclist().first(); diploc != NULL; diploc = diploc->next())
22372237               {
22382238                  UINT32 mask = accummask & ~(accummask - 1);
22392239                  dip_descriptor *dip;
r11508r11509
22792279
22802280static void menu_settings_custom_render(running_machine &machine, ui_menu *menu, void *state, void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2)
22812281{
2282   const input_field_config *field = (const input_field_config *)selectedref;
2282   input_field_config *field = (input_field_config *)selectedref;
22832283   settings_menu_state *menustate = (settings_menu_state *)state;
22842284   dip_descriptor *dip;
22852285
r11508r11509
22992299
23002300      /* determine the mask of selected bits */
23012301      if (field != NULL)
2302         for (diploc = field->diploclist; diploc != NULL; diploc = diploc->next)
2302         for (diploc = field->diploclist().first(); diploc != NULL; diploc = diploc->next())
23032303            if (strcmp(dip->name, diploc->swname) == 0)
23042304               selectedmask |= 1 << (diploc->swnum - 1);
23052305
r11508r11509
24552455
24562456static void menu_analog_populate(running_machine &machine, ui_menu *menu)
24572457{
2458   const input_field_config *field;
2459   const input_port_config *port;
2458   input_field_config *field;
2459   input_port_config *port;
24602460   astring subtext;
24612461   astring text;
24622462
24632463   /* loop over input ports and add the items */
24642464   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
2465      for (field = port->fieldlist; field != NULL; field = field->next)
2465      for (field = port->fieldlist().first(); field != NULL; field = field->next())
24662466         if (input_type_is_analog(field->type) && input_condition_true(machine, &field->condition))
24672467         {
24682468            input_field_user_settings settings;
src/emu/inptport.c
r11508r11509
787787static void frame_update_analog_field(running_machine &machine, analog_field_state *analog);
788788static int frame_get_digital_field_state(const input_field_config *field, int mouse_down);
789789
790/* port configuration helpers */
791static void port_config_detokenize(ioport_list &portlist, const input_port_token *ipt, char *errorbuf, int errorbuflen, device_t *owner);
792static input_field_config *field_config_alloc(input_port_config *port, int type, input_port_value defvalue, input_port_value maskbits);
793static void field_config_insert(input_field_config *field, input_port_value *disallowedbits, char *errorbuf, int errorbuflen);
794static void field_config_free(input_field_config **fieldptr);
795static input_setting_config *setting_config_alloc(input_field_config *field, input_port_value value, const char *name);
796static void setting_config_free(input_setting_config **settingptr);
797static const input_field_diplocation *diplocation_list_alloc(const input_field_config *field, const char *location, char *errorbuf, int errorbuflen);
798static void diplocation_free(input_field_diplocation **diplocptr);
799
800790/* tokenization helpers */
801791static int token_to_input_field_type(running_machine &machine, const char *string, int *player);
802792static const char *input_field_type_to_token(running_machine &machine, int type, int player);
r11508r11509
885875
886876INLINE const char *get_port_tag(const input_port_config *port, char *tempbuffer)
887877{
888   const input_port_config *curport;
889   int index = 0;
890
891   if (port->tag != NULL)
892      return port->tag;
893   for (curport = port->machine().m_portlist.first(); curport != NULL; curport = curport->next())
894   {
895      if (curport == port)
896         break;
897      index++;
898   }
899   sprintf(tempbuffer, "(PORT#%d)", index);
900   return tempbuffer;
878   return port->tag();
901879}
902880
903881
904882/*-------------------------------------------------
905    error_buf_append - append text to an error
906    buffer
907-------------------------------------------------*/
908
909INLINE void* ATTR_PRINTF(3,4) error_buf_append(char *errorbuf, int errorbuflen, const char *format, ...)
910{
911   int curlen = (errorbuf != NULL) ? strlen(errorbuf) : 0;
912   int bytesleft = errorbuflen - curlen;
913   va_list va;
914
915   va_start(va, format);
916   if (strlen(format) + 25 < bytesleft)
917      vsprintf(&errorbuf[curlen], format, va);
918   va_end(va);
919
920   return NULL;
921}
922
923
924/*-------------------------------------------------
925883    condition_equal - TRUE if two conditions are
926884    equivalent
927885-------------------------------------------------*/
r11508r11509
934892
935893
936894/***************************************************************************
937    CUSTOM DEVICE I/O
938***************************************************************************/
939
940/*-------------------------------------------------
941    custom_read_line_device - device handler
942    stub to process PORT_CUSTOM behavior
943-------------------------------------------------*/
944
945static READ_LINE_DEVICE_HANDLER( custom_read_line_device )
946{
947   const device_field_info *device_field = (const device_field_info *) device;
948
949   return (*device_field->field->custom)(device_field->field, device_field->field->custom_param);
950}
951
952
953/*-------------------------------------------------
954    changed_write_line_device - device handler
955    stub to process PORT_CHANGED behavior
956-------------------------------------------------*/
957
958static WRITE_LINE_DEVICE_HANDLER( changed_write_line_device )
959{
960   const device_field_info *device_field = (const device_field_info *) device;
961
962   (*device_field->field->changed)(device_field->field, device_field->field->changed_param, device_field->oldval, state);
963}
964
965
966
967/***************************************************************************
968895    CORE SYSTEM MANAGEMENT
969896***************************************************************************/
970897
r11508r11509
973900    system
974901-------------------------------------------------*/
975902
976time_t input_port_init(running_machine &machine, const device_list &devicelist)
903time_t input_port_init(running_machine &machine)
977904{
978905   //input_port_private *portdata;
979   char errorbuf[1024];
980906   time_t basetime;
981907
982908   /* allocate memory for our data structure */
r11508r11509
991917   init_port_types(machine);
992918
993919   /* if we have a token list, proceed */
994   for (device_t *device = devicelist.first(); device != NULL; device = device->next())
995      if (device->input_ports() != NULL)
996      {
997         input_port_list_init(machine.m_portlist, device->input_ports(), errorbuf, sizeof(errorbuf), TRUE, device);
998         if (errorbuf[0] != 0)
999            mame_printf_error("Input port errors:\n%s", errorbuf);
1000      }
920   for (device_t *device = machine.devicelist().first(); device != NULL; device = device->next())
921   {
922      astring errors;
923      input_port_list_init(*device, machine.m_portlist, errors);
924      if (errors)
925         mame_printf_error("Input port errors:\n%s", errors.cstr());
926   }
1001927
1002928   init_port_state(machine);
1003929   /* register callbacks for when we load configurations */
r11508r11509
1035961    according to the given tokens
1036962-------------------------------------------------*/
1037963
1038void input_port_list_init(ioport_list &portlist, const input_port_token *tokens, char *errorbuf, int errorbuflen, int allocmap, device_t *owner)
964void input_port_list_init(device_t &device, ioport_list &portlist, astring &errorbuf)
1039965{
1040   /* no tokens, no list */
1041   if (tokens == NULL)
966   /* no constructor, no list */
967   ioport_constructor constructor = device.input_ports();
968   if (constructor == NULL)
1042969      return;
1043970
1044971   /* reset error buffer */
1045   if (errorbuf != NULL)
1046      *errorbuf = 0;
972   errorbuf.reset();
1047973
1048974   /* detokenize into the list */
1049   port_config_detokenize(portlist, tokens, errorbuf, errorbuflen, owner);
975   (*constructor)(device, portlist, errorbuf);
976
977   // collapse fields and sort the list
978   for (input_port_config *port = portlist.first(); port != NULL; port = port->next())
979      port->collapse_fields(errorbuf);
1050980}
1051981
1052982
r11508r11509
1062992
1063993   /* if we got the port, look for the field */
1064994   if (port != NULL)
1065      for (const input_field_config *field = port->fieldlist; field != NULL; field = field->next)
995      for (const input_field_config *field = port->first_field(); field != NULL; field = field->next())
1066996         if ((field->mask & mask) != 0)
1067997            return field;
1068998
r11508r11509
10891019      return field->name;
10901020
10911021   /* otherwise, return the name associated with the type */
1092   return input_type_name(field->port->machine(), field->type, field->player);
1022   return input_type_name(field->machine(), field->type, field->player);
10931023}
10941024
10951025
r11508r11509
11121042
11131043   /* if the portseq is the special default code, return the expanded default value */
11141044   if (input_seq_get_1(portseq) == SEQCODE_DEFAULT)
1115      return input_type_seq(field->port->machine(), field->type, field->player, seqtype);
1045      return input_type_seq(field->machine(), field->type, field->player, seqtype);
11161046
11171047   /* otherwise, return the sequence as-is */
11181048   return portseq;
r11508r11509
11361066      settings->seq[seqtype] = field->state->seq[seqtype];
11371067
11381068   /* if there's a list of settings or we're an adjuster, copy the current value */
1139   if (field->settinglist != NULL || field->type == IPT_ADJUSTER)
1069   if (field->settinglist().count() != 0 || field->type == IPT_ADJUSTER)
11401070      settings->value = field->state->value;
11411071
11421072   /* if there's analog data, extract the analog settings */
r11508r11509
11631093   /* copy the basics */
11641094   for (seqtype = 0; seqtype < ARRAY_LENGTH(settings->seq); seqtype++)
11651095   {
1166      const input_seq *defseq = input_type_seq(field->port->machine(), field->type, field->player, (input_seq_type)seqtype);
1096      const input_seq *defseq = input_type_seq(field->machine(), field->type, field->player, (input_seq_type)seqtype);
11671097      if (input_seq_cmp(defseq, &settings->seq[seqtype]) == 0)
11681098         field->state->seq[seqtype] = default_seq;
11691099      else
r11508r11509
11711101   }
11721102
11731103   /* if there's a list of settings or we're an adjuster, copy the current value */
1174   if (field->settinglist != NULL || field->type == IPT_ADJUSTER)
1104   if (field->settinglist().count() != 0 || field->type == IPT_ADJUSTER)
11751105      field->state->value = settings->value;
11761106
11771107   /* if there's analog data, extract the analog settings */
r11508r11509
11951125   const input_setting_config *setting;
11961126
11971127   /* only makes sense if we have settings */
1198   assert(field->settinglist != NULL);
1128   assert(field->settinglist().count() != 0);
11991129
12001130   /* scan the list of settings looking for a match on the current value */
1201   for (setting = field->settinglist; setting != NULL; setting = setting->next)
1202      if (input_condition_true(field->port->machine(), &setting->condition))
1131   for (setting = field->settinglist().first(); setting != NULL; setting = setting->next())
1132      if (input_condition_true(field->machine(), &setting->condition))
12031133         if (setting->value == field->state->value)
12041134            return setting->name;
12051135
r11508r11509
12171147   const input_setting_config *setting;
12181148
12191149   /* only makes sense if we have settings */
1220   assert(field->settinglist != NULL);
1150   assert(field->settinglist().count() != 0);
12211151
12221152   /* scan the list of settings looking for a match on the current value */
1223   for (setting = field->settinglist; setting != NULL; setting = setting->next)
1224      if (input_condition_true(field->port->machine(), &setting->condition))
1153   for (setting = field->settinglist().first(); setting != NULL; setting = setting->next())
1154      if (input_condition_true(field->machine(), &setting->condition))
12251155         return (setting->value != field->state->value);
12261156
12271157   return FALSE;
r11508r11509
12401170   int found_match = FALSE;
12411171
12421172   /* only makes sense if we have settings */
1243   assert(field->settinglist != NULL);
1173   assert(field->settinglist().count() != 0);
12441174
12451175   /* scan the list of settings looking for a match on the current value */
12461176   prevsetting = NULL;
1247   for (setting = field->settinglist; setting != NULL; setting = setting->next)
1248      if (input_condition_true(field->port->machine(), &setting->condition))
1177   for (setting = field->settinglist().first(); setting != NULL; setting = setting->next())
1178      if (input_condition_true(field->machine(), &setting->condition))
12491179      {
12501180         if (setting->value == field->state->value)
12511181         {
r11508r11509
12591189   /* if we didn't find a matching value, select the first */
12601190   if (!found_match)
12611191   {
1262      for (prevsetting = field->settinglist; prevsetting != NULL; prevsetting = prevsetting->next)
1263         if (input_condition_true(field->port->machine(), &prevsetting->condition))
1192      for (prevsetting = field->settinglist().first(); prevsetting != NULL; prevsetting = prevsetting->next())
1193         if (input_condition_true(field->machine(), &prevsetting->condition))
12641194            break;
12651195   }
12661196
r11508r11509
12811211   int found = FALSE;
12821212
12831213   /* only makes sense if we have settings */
1284   assert(field->settinglist != NULL);
1214   assert(field->settinglist().count() != 0);
12851215
12861216   /* scan the list of settings looking for a match on the current value */
1287   for (setting = field->settinglist; setting != NULL; setting = setting->next)
1288      if (input_condition_true(field->port->machine(), &setting->condition))
1217   for (setting = field->settinglist().first(); setting != NULL; setting = setting->next())
1218      if (input_condition_true(field->machine(), &setting->condition))
12891219      {
12901220         if (found)
12911221            return TRUE;
r11508r11509
13081238   const input_setting_config *setting, *nextsetting;
13091239
13101240   /* only makes sense if we have settings */
1311   assert(field->settinglist != NULL);
1241   assert(field->settinglist().count() != 0);
13121242
13131243   /* scan the list of settings looking for a match on the current value */
13141244   nextsetting = NULL;
1315   for (setting = field->settinglist; setting != NULL; setting = setting->next)
1316      if (input_condition_true(field->port->machine(), &setting->condition))
1245   for (setting = field->settinglist().first(); setting != NULL; setting = setting->next())
1246      if (input_condition_true(field->machine(), &setting->condition))
13171247         if (setting->value == field->state->value)
13181248            break;
13191249
13201250   /* if we found one, scan forward for the next valid one */
13211251   if (setting != NULL)
1322      for (nextsetting = setting->next; nextsetting != NULL; nextsetting = nextsetting->next)
1323         if (input_condition_true(field->port->machine(), &nextsetting->condition))
1252      for (nextsetting = setting->next(); nextsetting != NULL; nextsetting = nextsetting->next())
1253         if (input_condition_true(field->machine(), &nextsetting->condition))
13241254            break;
13251255
13261256   /* if we hit the end, search from the beginning */
13271257   if (nextsetting == NULL)
1328      for (nextsetting = field->settinglist; nextsetting != NULL; nextsetting = nextsetting->next)
1329         if (input_condition_true(field->port->machine(), &nextsetting->condition))
1258      for (nextsetting = field->settinglist().first(); nextsetting != NULL; nextsetting = nextsetting->next())
1259         if (input_condition_true(field->machine(), &nextsetting->condition))
13301260            break;
13311261
13321262   /* update the value to the previous one */
r11508r11509
15511481   /* start with the digital */
15521482   result = port->state->digital;
15531483
1554   /* update custom values */
1484   /* update read values */
15551485   for (device_field = port->state->readdevicelist; device_field != NULL; device_field = device_field->next)
15561486      if (input_condition_true(port->machine(), &device_field->field->condition))
15571487      {
15581488         /* replace the bits with bits from the device */
1559         input_port_value newval = (*device_field->field->read_line_device)(device_field->device);
1489         input_port_value newval = (*device_field->field->read)(*device_field->device, device_field->field, device_field->field->read_param);
15601490         device_field->oldval = newval;
15611491         result = (result & ~device_field->field->mask) | ((newval << device_field->shift) & device_field->field->mask);
15621492      }
r11508r11509
15701500         result &= ~port->state->vblank;
15711501   }
15721502
1573   /* apply active high/low state to digital, custom, and VBLANK inputs */
1503   /* apply active high/low state to digital, read, and VBLANK inputs */
15741504   result ^= port->state->defvalue;
15751505
15761506   /* merge in analog portions */
r11508r11509
16621592
16631593   /* read all the lightgun values */
16641594   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
1665      for (field = port->fieldlist; field != NULL; field = field->next)
1595      for (field = port->first_field(); field != NULL; field = field->next())
16661596         if (field->player == player && field->crossaxis != CROSSHAIR_AXIS_NONE)
16671597            if (input_condition_true(machine, &field->condition))
16681598            {
r11508r11509
17391669            port->state->defvalue = 0;
17401670
17411671         /* first compute the default value for the entire port */
1742         for (field = port->fieldlist; field != NULL; field = field->next)
1672         for (field = port->first_field(); field != NULL; field = field->next())
17431673            if (input_condition_true(machine, &field->condition))
17441674               port->state->defvalue = (port->state->defvalue & ~field->mask) | (field->state->value & field->mask);
17451675      }
r11508r11509
17891719
17901720void input_port_write_direct(const input_port_config *port, input_port_value data, input_port_value mem_mask)
17911721{
1792   /* call device line changed handlers */
1722   /* call device line write handlers */
17931723   device_field_info *device_field;
17941724
17951725   COMBINE_DATA(&port->state->outputvalue);
r11508r11509
17991729      {
18001730         input_port_value newval = ( (port->state->outputvalue ^ device_field->field->defvalue ) & device_field->field->mask) >> device_field->shift;
18011731
1802         /* if the bits have changed, call the handler */
1732         /* if the bits have write, call the handler */
18031733         if (device_field->oldval != newval)
18041734         {
1805            (*device_field->field->write_line_device)(device_field->device, newval);
1735            (*device_field->field->write)(*device_field->device, device_field->field, device_field->field->write_param, device_field->oldval, newval);
18061736
18071737            device_field->oldval = newval;
18081738         }
r11508r11509
18881818    input_port_token to a default string
18891819-------------------------------------------------*/
18901820
1891const char *input_port_string_from_token(const input_port_token token)
1821const char *input_port_string_from_token(const char *string)
18921822{
18931823   int index;
18941824
18951825   /* 0 is an invalid index */
1896   if (token.i == 0)
1826   if (string == NULL)
18971827      return NULL;
18981828
18991829   /* if the index is greater than the count, assume it to be a pointer */
1900   if (token.i >= INPUT_STRING_COUNT)
1901      return token.stringptr;
1830   if (FPTR(string) >= INPUT_STRING_COUNT)
1831      return string;
19021832
19031833   /* otherwise, scan the list for a matching string and return it */
19041834   for (index = 0; index < ARRAY_LENGTH(input_port_default_strings); index++)
1905      if (input_port_default_strings[index].id == token.i)
1835      if (input_port_default_strings[index].id == FPTR(string))
19061836         return input_port_default_strings[index].string;
19071837   return "(Unknown Default)";
19081838}
r11508r11509
20902020      /* allocate a new input_port_info structure */
20912021      portstate = auto_alloc_clear(machine, input_port_state);
20922022      ((input_port_config *)port)->state = portstate;
2093      ((input_port_config *)port)->set_machine(machine);
20942023
20952024      /* start with tail pointers to all the data */
20962025      analogstatetail = &portstate->analoglist;
r11508r11509
20982027      writedevicetail = &portstate->writedevicelist;
20992028
21002029      /* iterate over fields */
2101      for (field = port->fieldlist; field != NULL; field = field->next)
2030      for (field = port->first_field(); field != NULL; field = field->next())
21022031      {
21032032         input_field_state *fieldstate;
21042033         int seqtype;
r11508r11509
21292058         }
21302059
21312060         /* if this entry has device input, allocate memory for the tracking structure */
2132         if (field->read_line_device != NULL)
2061         if (field->read != NULL)
21332062         {
2134            *readdevicetail = init_field_device_info(field,field->read_device_name);
2063            *readdevicetail = init_field_device_info(field,field->read_device);
21352064            readdevicetail = &(*readdevicetail)->next;
21362065         }
21372066
21382067         /* if this entry has device output, allocate memory for the tracking structure */
2139         if (field->write_line_device != NULL)
2068         if (field->write != NULL)
21402069         {
2141            *writedevicetail = init_field_device_info(field,field->write_device_name);
2070            *writedevicetail = init_field_device_info(field,field->write_device);
21422071            writedevicetail = &(*writedevicetail)->next;
21432072         }
21442073
r11508r11509
21682097   /* look for 4-way joysticks and change the default map if we find any */
21692098   if (joystick_map_default[0] == 0 || strcmp(joystick_map_default, "auto") == 0)
21702099      for (port = machine.m_portlist.first(); port != NULL; port = port->next())
2171         for (field = port->fieldlist; field != NULL; field = field->next)
2100         for (field = port->first_field(); field != NULL; field = field->next())
21722101            if (field->state->joystick != NULL && field->way == 4)
21732102            {
21742103               input_device_set_joystick_map(machine, -1, (field->flags & FIELD_FLAG_ROTATED) ? joystick_map_4way_diagonal : joystick_map_4way_sticky);
r11508r11509
22232152   /* only scan the list if we haven't already enabled this class of control */
22242153   if (portlist.first() != NULL && !input_device_class_enabled(portlist.first()->machine(), autoenable))
22252154      for (port = portlist.first(); port != NULL; port = port->next())
2226         for (field = port->fieldlist; field != NULL; field = field->next)
2155         for (field = port->first_field(); field != NULL; field = field->next())
22272156
22282157            /* if this port type is in use, apply the autoselect criteria */
22292158            if ((type1 != 0 && field->type == type1) ||
r11508r11509
22482177   input_port_value mask;
22492178
22502179   /* allocate memory */
2251   info = auto_alloc_clear(field->port->machine(), device_field_info);
2180   info = auto_alloc_clear(field->machine(), device_field_info);
22522181
22532182   /* fill in the data */
22542183   info->field = field;
r11508r11509
22562185      info->shift++;
22572186
22582187   if (device_name != NULL)
2259      info->device = field->port->machine().device(device_name);
2188      info->device = field->machine().device(device_name);
22602189   else
2261      info->device = (device_t *) info;
2190      info->device = &field->port().owner();
22622191
22632192   info->oldval = field->defvalue >> info->shift;
22642193   return info;
r11508r11509
22762205   input_port_value mask;
22772206
22782207   /* allocate memory */
2279   state = auto_alloc_clear(field->port->machine(), analog_field_state);
2208   state = auto_alloc_clear(field->machine(), analog_field_state);
22802209
22812210   /* compute the shift amount and number of bits */
22822211   for (mask = field->mask; !(mask & 1); mask >>= 1)
r11508r11509
25062435         {
25072436            for (i = 0; i < ARRAY_LENGTH(code->field) && (code->field[i] != NULL); i++)
25082437            {
2509               if (code->field[i]->port == port)
2438               if (&code->field[i]->port() == port)
25102439               {
25112440                  value = code->field[i]->mask;
25122441                  *digital |= value;
r11508r11509
25742503      port->state->vblank = 0;
25752504
25762505      /* now loop back and modify based on the inputs */
2577      for (field = port->fieldlist; field != NULL; field = field->next)
2506      for (field = port->first_field(); field != NULL; field = field->next())
25782507         if (input_condition_true(port->machine(), &field->condition))
25792508         {
25802509            /* accumulate VBLANK bits */
r11508r11509
25972526      playback_port(port);
25982527      record_port(port);
25992528
2600      /* call device line changed handlers */
2529      /* call device line write handlers */
26012530      newvalue = input_port_read_direct(port);
26022531      for (device_field = port->state->writedevicelist; device_field; device_field = device_field->next)
26032532         if (device_field->field->type != IPT_OUTPUT && input_condition_true(port->machine(), &device_field->field->condition))
26042533         {
26052534            input_port_value newval = (newvalue & device_field->field->mask) >> device_field->shift;
26062535
2607            /* if the bits have  changed, call the handler */
2536            /* if the bits have  write, call the handler */
26082537            if (device_field->oldval != newval)
26092538            {
2610               (*device_field->field->write_line_device)(device_field->device, newval);
2539               (*device_field->field->write)(*device_field->device, device_field->field, device_field->field->write_param, device_field->oldval, newval);
26112540
26122541               device_field->oldval = newval;
26132542            }
r11508r11509
28532782
28542783static int frame_get_digital_field_state(const input_field_config *field, int mouse_down)
28552784{
2856   int curstate = mouse_down || input_seq_pressed(field->port->machine(), input_field_seq(field, SEQ_TYPE_STANDARD));
2785   int curstate = mouse_down || input_seq_pressed(field->machine(), input_field_seq(field, SEQ_TYPE_STANDARD));
28572786   int changed = FALSE;
28582787
28592788   /* if the state changed, look for switch down/switch up */
r11508r11509
28632792      changed = TRUE;
28642793   }
28652794
2866   if (field->type == IPT_KEYBOARD && ui_get_use_natural_keyboard(field->port->machine()))
2795   if (field->type == IPT_KEYBOARD && ui_get_use_natural_keyboard(field->machine()))
28672796      return FALSE;
28682797
28692798   /* if this is a switch-down event, handle impulse and toggle */
r11508r11509
28762805      /* toggle controls: flip the toggle state or advance to the next setting */
28772806      if (field->flags & FIELD_FLAG_TOGGLE)
28782807      {
2879         if (field->settinglist == NULL)
2808         if (field->settinglist().count() == 0)
28802809            field->state->value ^= field->mask;
28812810         else
28822811            input_field_select_next_setting(field);
r11508r11509
29092838   }
29102839
29112840   /* skip locked-out coin inputs */
2912   if (curstate && field->type >= IPT_COIN1 && field->type <= IPT_COIN12 && coin_lockout_get_state(field->port->machine(), field->type - IPT_COIN1) && field->port->machine().options().coin_lockout())
2841   if (curstate && field->type >= IPT_COIN1 && field->type <= IPT_COIN12 && coin_lockout_get_state(field->machine(), field->type - IPT_COIN1) && field->machine().options().coin_lockout())
29132842   {
29142843      ui_popup_time(3, "Coinlock disabled %s.", input_field_name(field));
29152844      return FALSE;
r11508r11509
29282857    of port settings according to device settings
29292858-------------------------------------------------*/
29302859
2931static UINT32 port_default_value(const char *fulltag, UINT32 mask, UINT32 defval, device_t *owner)
2860UINT32 port_default_value(const char *fulltag, UINT32 mask, UINT32 defval, device_t &owner)
29322861{
29332862   astring tempstring;
29342863   const input_device_default *def = NULL;
2935   if (owner!=NULL) {
2936      def = owner->input_ports_defaults();
2937      if (def!=NULL) {
2938         while (def->tag!=NULL) {
2939            if ((strcmp(fulltag,owner->subtag(tempstring,def->tag))==0) &&  (def->mask == mask)) {
2940               return def->defvalue;
2941            }
2942            def++;
2864   def = owner.input_ports_defaults();
2865   if (def!=NULL) {
2866      while (def->tag!=NULL) {
2867         if ((strcmp(fulltag,owner.subtag(tempstring,def->tag))==0) &&  (def->mask == mask)) {
2868            return def->defvalue;
29432869         }
2870         def++;
29442871      }
29452872   }
29462873   return defval;
29472874}
29482875
2949/*-------------------------------------------------
2950    port_config_detokenize - recursively
2951    detokenize a series of input port tokens
2952-------------------------------------------------*/
29532876
2954static void port_config_detokenize(ioport_list &portlist, const input_port_token *ipt, char *errorbuf, int errorbuflen, device_t *owner)
2955{
2956   UINT32 entrytype = INPUT_TOKEN_INVALID;
2957   input_setting_config *cursetting = NULL;
2958   input_field_config *curfield = NULL;
2959   input_port_config *curport = NULL;
2960   input_port_value maskbits = 0;
2961   astring tempstring;
2962   const char *fulltag = NULL;
2963   UINT16 category;   /* (MESS-specific) category */
2964
2965   /* loop over tokens until we hit the end */
2966   while (entrytype != INPUT_TOKEN_END)
2967   {
2968      UINT32 mask, defval, type, val;
2969      input_port_token temptoken;
2970      input_condition condition;
2971      const char *string;
2972      int hasdiploc;
2973      int index;
2974
2975      /* unpack the token from the first entry */
2976      TOKEN_GET_UINT32_UNPACK1(ipt, entrytype, 8);
2977      switch (entrytype)
2978      {
2979         /* end */
2980         case INPUT_TOKEN_END:
2981            break;
2982
2983         /* including */
2984         case INPUT_TOKEN_INCLUDE:
2985            if (curfield != NULL)
2986               field_config_insert(curfield, &maskbits, errorbuf, errorbuflen);
2987            maskbits = 0;
2988
2989            port_config_detokenize(portlist, TOKEN_GET_PTR(ipt, tokenptr), errorbuf, errorbuflen, owner);
2990            curport = NULL;
2991            curfield = NULL;
2992            cursetting = NULL;
2993            break;
2994
2995         /* start of a new input port */
2996         case INPUT_TOKEN_START:
2997            if (curfield != NULL)
2998               field_config_insert(curfield, &maskbits, errorbuf, errorbuflen);
2999            maskbits = 0;
3000
3001            string = TOKEN_GET_STRING(ipt);
3002            if (owner!=NULL) {
3003               fulltag = core_strdup(owner->subtag(tempstring, string));
3004            } else {
3005               fulltag = string;
3006            }
3007            curport = &portlist.append(fulltag, *global_alloc(input_port_config(fulltag)));
3008            curfield = NULL;
3009            cursetting = NULL;
3010            break;
3011
3012         /* modify an existing port */
3013         case INPUT_TOKEN_MODIFY:
3014            if (curfield != NULL)
3015               field_config_insert(curfield, &maskbits, errorbuf, errorbuflen);
3016            maskbits = 0;
3017
3018            curport = portlist.find(TOKEN_GET_STRING(ipt));
3019            curfield = NULL;
3020            cursetting = NULL;
3021            break;
3022
3023         /* input field definition */
3024         case INPUT_TOKEN_FIELD:
3025            TOKEN_UNGET_UINT32(ipt);
3026            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, type, 24);
3027            TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32);
3028
3029            if (curport == NULL)
3030            {
3031               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_FIELD encountered with no active port (mask=%X defval=%X)\n", mask, defval);
3032               return;
3033            }
3034
3035            if (type != IPT_UNKNOWN && type != IPT_UNUSED)
3036               curport->active |= mask;
3037
3038            if (curfield != NULL)
3039               field_config_insert(curfield, &maskbits, errorbuf, errorbuflen);
3040            curfield = field_config_alloc(curport, type, defval, mask);
3041            cursetting = NULL;
3042            break;
3043
3044         /* field or setting condition */
3045         case INPUT_TOKEN_CONDITION:
3046            TOKEN_UNGET_UINT32(ipt);
3047            if (curfield == NULL && cursetting == NULL)
3048            {
3049               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CONDITION encountered with no active field or setting\n");
3050               TOKEN_SKIP_UINT32(ipt);
3051               TOKEN_SKIP_UINT64(ipt);
3052               break;
3053            }
3054            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, condition.condition, 24);
3055            TOKEN_GET_UINT64_UNPACK2(ipt, condition.mask, 32, condition.value, 32);
3056            condition.tag = TOKEN_GET_STRING(ipt);
3057
3058            if (cursetting != NULL)
3059               cursetting->condition = condition;
3060            else
3061               curfield->condition = condition;
3062            break;
3063
3064         /* field player select */
3065         case INPUT_TOKEN_PLAYER1:
3066         case INPUT_TOKEN_PLAYER2:
3067         case INPUT_TOKEN_PLAYER3:
3068         case INPUT_TOKEN_PLAYER4:
3069         case INPUT_TOKEN_PLAYER5:
3070         case INPUT_TOKEN_PLAYER6:
3071         case INPUT_TOKEN_PLAYER7:
3072         case INPUT_TOKEN_PLAYER8:
3073            if (curfield == NULL)
3074            {
3075               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_PLAYERn encountered with no active field\n");
3076               break;
3077            }
3078            curfield->player = entrytype - INPUT_TOKEN_PLAYER1;
3079            break;
3080
3081         /* field category */
3082         case INPUT_TOKEN_CATEGORY:
3083            TOKEN_UNGET_UINT32(ipt);
3084            if (curfield == NULL)
3085            {
3086               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CATEGORY encountered with no active field\n");
3087               TOKEN_SKIP_UINT32(ipt);
3088               break;
3089            }
3090            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->category, 24);
3091            break;
3092
3093         /* field flags */
3094         case INPUT_TOKEN_UNUSED:
3095            if (curfield == NULL)
3096            {
3097               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_UNUSED encountered with no active field\n");
3098               break;
3099            }
3100            curfield->flags |= FIELD_FLAG_UNUSED;
3101            break;
3102
3103         case INPUT_TOKEN_COCKTAIL:
3104            if (curfield == NULL)
3105            {
3106               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_COCKTAIL encountered with no active field\n");
3107               break;
3108            }
3109            curfield->flags |= FIELD_FLAG_COCKTAIL;
3110            curfield->player = 1;
3111            break;
3112
3113         case INPUT_TOKEN_ROTATED:
3114            if (curfield == NULL)
3115            {
3116               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_ROTATED encountered with no active field\n");
3117               break;
3118            }
3119            curfield->flags |= FIELD_FLAG_ROTATED;
3120            break;
3121
3122         case INPUT_TOKEN_TOGGLE:
3123            if (curfield == NULL)
3124            {
3125               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_TOGGLE encountered with no active field\n");
3126               break;
3127            }
3128            curfield->flags |= FIELD_FLAG_TOGGLE;
3129            break;
3130
3131         /* field impulse */
3132         case INPUT_TOKEN_IMPULSE:
3133            TOKEN_UNGET_UINT32(ipt);
3134            if (curfield == NULL)
3135            {
3136               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_IMPULSE encountered with no active field\n");
3137               TOKEN_SKIP_UINT32(ipt);
3138               break;
3139            }
3140            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->impulse, 24);
3141            break;
3142
3143         /* field name */
3144         case INPUT_TOKEN_NAME:
3145            if (curfield == NULL)
3146            {
3147               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_NAME encountered with no active field\n");
3148               TOKEN_SKIP_STRING(ipt);
3149               break;
3150            }
3151            curfield->name = input_port_string_from_token(*ipt++);
3152            break;
3153
3154         /* field code sequence */
3155         case INPUT_TOKEN_CODE:
3156            TOKEN_UNGET_UINT32(ipt);
3157            if (curfield == NULL)
3158            {
3159               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CODE encountered with no active field\n");
3160               TOKEN_SKIP_UINT64(ipt);
3161               break;
3162            }
3163            TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32);
3164            input_seq_append_or(&curfield->seq[SEQ_TYPE_STANDARD], val);
3165            break;
3166
3167         /* field custom callback */
3168         case INPUT_TOKEN_CUSTOM:
3169            if (curfield == NULL)
3170            {
3171               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CUSTOM encountered with no active field\n");
3172               TOKEN_SKIP_PTR(ipt);
3173               TOKEN_SKIP_PTR(ipt);
3174               break;
3175            }
3176            curfield->read_line_device = custom_read_line_device;
3177            curfield->read_device_name = NULL;
3178            curfield->custom = TOKEN_GET_PTR(ipt, customptr);
3179            curfield->custom_param = (void *)TOKEN_GET_PTR(ipt, voidptr);
3180            break;
3181
3182         /* field changed callback */
3183         case INPUT_TOKEN_CHANGED:
3184            if (curfield == NULL)
3185            {
3186               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CHANGED encountered with no active field\n");
3187               TOKEN_SKIP_PTR(ipt);
3188               TOKEN_SKIP_PTR(ipt);
3189               break;
3190            }
3191            curfield->write_line_device = changed_write_line_device;
3192            curfield->write_device_name = NULL;
3193            curfield->changed = TOKEN_GET_PTR(ipt, changedptr);
3194            curfield->changed_param = (void *)TOKEN_GET_PTR(ipt, voidptr);
3195            break;
3196
3197         /* DIP switch location */
3198         case INPUT_TOKEN_DIPLOCATION:
3199            if (curfield == NULL)
3200            {
3201               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_DIPLOCATION encountered with no active field\n");
3202               TOKEN_SKIP_STRING(ipt);
3203               break;
3204            }
3205            if (curfield->diploclist != NULL)
3206            {
3207               error_buf_append(errorbuf, errorbuflen, "multiple INPUT_TOKEN_DIPLOCATIONs encountered for a single field\n");
3208               TOKEN_SKIP_STRING(ipt);
3209               break;
3210            }
3211            curfield->diploclist = diplocation_list_alloc(curfield, TOKEN_GET_STRING(ipt), errorbuf, errorbuflen);
3212            break;
3213
3214         /* joystick flags */
3215         case INPUT_TOKEN_2WAY:
3216         case INPUT_TOKEN_4WAY:
3217         case INPUT_TOKEN_8WAY:
3218         case INPUT_TOKEN_16WAY:
3219            if (curfield == NULL)
3220            {
3221               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_nWAY encountered with no active field\n");
3222               break;
3223            }
3224            curfield->way = 2 << (entrytype - INPUT_TOKEN_2WAY);
3225            break;
3226
3227         /* (MESS) natural keyboard support */
3228         case INPUT_TOKEN_CHAR:
3229            TOKEN_UNGET_UINT32(ipt);
3230            if (curfield == NULL)
3231            {
3232               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CHAR encountered with no active field\n");
3233               TOKEN_SKIP_UINT64(ipt);
3234               break;
3235            }
3236            TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32);
3237            for (index = 0; index < ARRAY_LENGTH(curfield->chars); index++)
3238               if (curfield->chars[index] == 0)
3239               {
3240                  curfield->chars[index] = (unicode_char)val;
3241                  break;
3242               }
3243            break;
3244
3245         /* analog minimum/maximum */
3246         case INPUT_TOKEN_MINMAX:
3247            if (curfield == NULL)
3248            {
3249               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_MINMAX encountered with no active field\n");
3250               TOKEN_SKIP_UINT64(ipt);
3251               break;
3252            }
3253            TOKEN_GET_UINT64_UNPACK2(ipt, curfield->min, 32, curfield->max, 32);
3254            break;
3255
3256         /* analog sensitivity */
3257         case INPUT_TOKEN_SENSITIVITY:
3258            TOKEN_UNGET_UINT32(ipt);
3259            if (curfield == NULL)
3260            {
3261               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_SENSITIVITY encountered with no active field\n");
3262               TOKEN_SKIP_UINT32(ipt);
3263               break;
3264            }
3265            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->sensitivity, 24);
3266            break;
3267
3268         /* analog keyboard delta */
3269         case INPUT_TOKEN_KEYDELTA:
3270            TOKEN_UNGET_UINT32(ipt);
3271            if (curfield == NULL)
3272            {
3273               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_KEYDELTA encountered with no active field\n");
3274               TOKEN_SKIP_UINT32(ipt);
3275               break;
3276            }
3277            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->delta, -24);
3278            curfield->centerdelta = curfield->delta;
3279            break;
3280
3281         /* analog autocenter delta */
3282         case INPUT_TOKEN_CENTERDELTA:
3283            TOKEN_UNGET_UINT32(ipt);
3284            if (curfield == NULL)
3285            {
3286               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CENTERDELTA encountered with no active field\n");
3287               TOKEN_SKIP_UINT32(ipt);
3288               break;
3289            }
3290            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->centerdelta, -24);
3291            break;
3292
3293         /* analog reverse flags */
3294         case INPUT_TOKEN_REVERSE:
3295            if (curfield == NULL)
3296            {
3297               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_REVERSE encountered with no active field\n");
3298               break;
3299            }
3300            curfield->flags |= ANALOG_FLAG_REVERSE;
3301            break;
3302
3303         case INPUT_TOKEN_RESET:
3304            if (curfield == NULL)
3305            {
3306               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_RESET encountered with no active field\n");
3307               break;
3308            }
3309            curfield->flags |= ANALOG_FLAG_RESET;
3310            break;
3311
3312         case INPUT_TOKEN_WRAPS:
3313            if (curfield == NULL)
3314               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_WRAPS encountered with no active field\n");
3315            curfield->flags |= ANALOG_FLAG_WRAPS;
3316            break;
3317
3318         case INPUT_TOKEN_INVERT:
3319            if (curfield == NULL)
3320            {
3321               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_INVERT encountered with no active field\n");
3322               break;
3323            }
3324            curfield->flags |= ANALOG_FLAG_INVERT;
3325            break;
3326
3327         /* analog crosshair parameters */
3328         case INPUT_TOKEN_CROSSHAIR:
3329            TOKEN_UNGET_UINT32(ipt);
3330            if (curfield == NULL)
3331            {
3332               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CROSSHAIR encountered with no active field\n");
3333               TOKEN_SKIP_UINT32(ipt);
3334               TOKEN_SKIP_UINT64(ipt);
3335               break;
3336            }
3337            TOKEN_GET_UINT32_UNPACK3(ipt, entrytype, 8, curfield->crossaxis, 4, curfield->crossaltaxis, -20);
3338            TOKEN_GET_UINT64_UNPACK2(ipt, curfield->crossscale, -32, curfield->crossoffset, -32);
3339            curfield->crossaltaxis *= 1.0f / 65536.0f;
3340            curfield->crossscale *= 1.0f / 65536.0f;
3341            curfield->crossoffset *= 1.0f / 65536.0f;
3342            break;
3343
3344         /* crosshair mapper callback */
3345         case INPUT_TOKEN_CROSSHAIR_MAPPER:
3346            if (curfield == NULL)
3347            {
3348               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CROSSHAIR_MAPPER encountered with no active field\n");
3349               TOKEN_SKIP_PTR(ipt);
3350               break;
3351            }
3352            curfield->crossmapper = TOKEN_GET_PTR(ipt, crossmapptr);
3353            break;
3354
3355         /* analog decrement sequence */
3356         case INPUT_TOKEN_CODE_DEC:
3357            TOKEN_UNGET_UINT32(ipt);
3358            if (curfield == NULL)
3359            {
3360               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CODE_DEC encountered with no active field\n");
3361               TOKEN_SKIP_UINT64(ipt);
3362               break;
3363            }
3364            index = entrytype - INPUT_TOKEN_CODE;
3365            TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32);
3366            input_seq_append_or(&curfield->seq[SEQ_TYPE_DECREMENT], val);
3367            break;
3368
3369         /* analog increment sequence */
3370         case INPUT_TOKEN_CODE_INC:
3371            TOKEN_UNGET_UINT32(ipt);
3372            if (curfield == NULL)
3373            {
3374               TOKEN_SKIP_UINT64(ipt);
3375               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CODE_INC encountered with no active field\n");
3376               break;
3377            }
3378            index = entrytype - INPUT_TOKEN_CODE;
3379            TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32);
3380            input_seq_append_or(&curfield->seq[SEQ_TYPE_INCREMENT], val);
3381            break;
3382
3383         /* analog full turn count */
3384         case INPUT_TOKEN_FULL_TURN_COUNT:
3385            TOKEN_UNGET_UINT32(ipt);
3386            if (curfield == NULL)
3387            {
3388               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_FULL_TURN_COUNT encountered with no active field\n");
3389               TOKEN_SKIP_UINT32(ipt);
3390               break;
3391            }
3392            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->full_turn_count, 24);
3393            break;
3394
3395         case INPUT_TOKEN_POSITIONS:
3396            TOKEN_UNGET_UINT32(ipt);
3397            if (curfield == NULL)
3398            {
3399               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_POSITIONS encountered with no active field\n");
3400               TOKEN_SKIP_UINT32(ipt);
3401               break;
3402            }
3403            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->max, 24);
3404            break;
3405
3406         case INPUT_TOKEN_REMAP_TABLE:
3407            if (curfield == NULL)
3408            {
3409               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_REMAP_TABLE encountered with no active field\n");
3410               TOKEN_SKIP_PTR(ipt);
3411               break;
3412            }
3413            curfield->remap_table = TOKEN_GET_PTR(ipt, ui32ptr);
3414            break;
3415
3416         /* DIP switch definition */
3417         case INPUT_TOKEN_DIPNAME:
3418            if (curport == NULL)
3419            {
3420               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_DIPNAME encountered with no active port\n");
3421               TOKEN_SKIP_UINT64(ipt);
3422               TOKEN_SKIP_STRING(ipt);
3423               break;
3424            }
3425            TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32);
3426            if (curfield != NULL)
3427               field_config_insert(curfield, &maskbits, errorbuf, errorbuflen);
3428            defval = port_default_value(fulltag,mask,defval,owner);
3429            curfield = field_config_alloc(curport, IPT_DIPSWITCH, defval, mask);
3430            cursetting = NULL;
3431            curfield->name = input_port_string_from_token(*ipt++);
3432            break;
3433
3434         /* DIP switch setting */
3435         case INPUT_TOKEN_DIPSETTING:
3436            TOKEN_UNGET_UINT32(ipt);
3437            if (curfield == NULL)
3438            {
3439               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_DIPSETTING encountered with no active field\n");
3440               TOKEN_SKIP_UINT64(ipt);
3441               TOKEN_SKIP_STRING(ipt);
3442               break;
3443            }
3444            TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32);
3445            cursetting = setting_config_alloc(curfield, defval & curfield->mask, input_port_string_from_token(*ipt++));
3446            break;
3447
3448         /* special DIP switch with on/off values */
3449         case INPUT_TOKEN_SPECIAL_ONOFF:
3450            TOKEN_UNGET_UINT32(ipt);
3451            TOKEN_GET_UINT32_UNPACK3(ipt, entrytype, 8, hasdiploc, 1, temptoken.i, 23);
3452            TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32);
3453
3454            if (curport == NULL)
3455            {
3456               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_SPECIAL_ONOFF encountered with no active port\n");
3457               TOKEN_SKIP_UINT32(ipt);
3458               TOKEN_SKIP_UINT64(ipt);
3459               if (hasdiploc)
3460                  TOKEN_SKIP_STRING(ipt);
3461               break;
3462            }
3463            if (curfield != NULL)
3464               field_config_insert(curfield, &maskbits, errorbuf, errorbuflen);
3465            curfield = field_config_alloc(curport, IPT_DIPSWITCH, defval, mask);
3466            cursetting = NULL;
3467
3468            curfield->name = input_port_string_from_token(temptoken);
3469            if (temptoken.i == INPUT_STRING_Service_Mode)
3470            {
3471               curfield->flags |= FIELD_FLAG_TOGGLE;
3472               curfield->seq[SEQ_TYPE_STANDARD].code[0] = KEYCODE_F2;
3473            }
3474            if (hasdiploc)
3475            {
3476               if (curfield->diploclist != NULL)
3477               {
3478                  error_buf_append(errorbuf, errorbuflen, "multiple INPUT_TOKEN_DIPLOCATIONs encountered for a single field\n");
3479                  TOKEN_SKIP_STRING(ipt);
3480                  break;
3481               }
3482               curfield->diploclist = diplocation_list_alloc(curfield, TOKEN_GET_STRING(ipt), errorbuf, errorbuflen);
3483            }
3484
3485            temptoken.i = INPUT_STRING_Off;
3486            cursetting = setting_config_alloc(curfield, defval & mask, input_port_string_from_token(temptoken));
3487
3488            temptoken.i = INPUT_STRING_On;
3489            cursetting = setting_config_alloc(curfield, ~defval & mask, input_port_string_from_token(temptoken));
3490
3491            /* reset cursetting to NULL to allow subsequent conditions to apply to the field */
3492            cursetting = NULL;
3493            break;
3494
3495         /* configuration definition */
3496         case INPUT_TOKEN_CONFNAME:
3497            if (curport == NULL)
3498            {
3499               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CONFNAME encountered with no active port\n");
3500               TOKEN_SKIP_UINT64(ipt);
3501               TOKEN_SKIP_STRING(ipt);
3502               break;
3503            }
3504            TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32);
3505            if (curfield != NULL)
3506               field_config_insert(curfield, &maskbits, errorbuf, errorbuflen);
3507            defval = port_default_value(fulltag,mask,defval,owner);
3508            curfield = field_config_alloc(curport, IPT_CONFIG, defval, mask);
3509            cursetting = NULL;
3510            curfield->name = input_port_string_from_token(*ipt++);
3511            break;
3512
3513         /* configuration setting */
3514         case INPUT_TOKEN_CONFSETTING:
3515            TOKEN_UNGET_UINT32(ipt);
3516            if (curfield == NULL)
3517            {
3518               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CONFSETTING encountered with no active field\n");
3519               TOKEN_SKIP_UINT64(ipt);
3520               TOKEN_SKIP_STRING(ipt);
3521               break;
3522            }
3523            TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32);
3524            cursetting = setting_config_alloc(curfield, defval & curfield->mask, input_port_string_from_token(*ipt++));
3525            break;
3526
3527         /* configuration definition */
3528         case INPUT_TOKEN_CATEGORY_NAME:
3529            if (curport == NULL)
3530            {
3531               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CATEGORY_NAME encountered with no active port\n");
3532               TOKEN_SKIP_UINT64(ipt);
3533               TOKEN_SKIP_STRING(ipt);
3534               break;
3535            }
3536            TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32);
3537            if (curfield != NULL)
3538               field_config_insert(curfield, &maskbits, errorbuf, errorbuflen);
3539            defval = port_default_value(fulltag,mask,defval,owner);
3540            curfield = field_config_alloc(curport, IPT_CATEGORY, defval, mask);
3541            cursetting = NULL;
3542            curfield->name = input_port_string_from_token(*ipt++);
3543            break;
3544
3545         /* category setting */
3546         case INPUT_TOKEN_CATEGORY_SETTING:
3547            TOKEN_UNGET_UINT32(ipt);
3548            if (curfield == NULL)
3549            {
3550               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_CATEGORY_SETTING encountered with no active field\n");
3551               TOKEN_SKIP_UINT64(ipt);
3552               TOKEN_SKIP_STRING(ipt);
3553               break;
3554            }
3555            TOKEN_GET_UINT64_UNPACK3(ipt, entrytype, 8, defval, 32, category, 16);
3556            cursetting = setting_config_alloc(curfield, defval & curfield->mask, input_port_string_from_token(*ipt++));
3557            cursetting->category = category;
3558            break;
3559
3560         /* analog adjuster definition */
3561         case INPUT_TOKEN_ADJUSTER:
3562            TOKEN_UNGET_UINT32(ipt);
3563            if (curport == NULL)
3564            {
3565               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_ADJUSTER encountered with no active port\n");
3566               TOKEN_SKIP_UINT64(ipt);
3567               TOKEN_SKIP_STRING(ipt);
3568               break;
3569            }
3570            TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32);
3571            if (curfield != NULL)
3572               field_config_insert(curfield, &maskbits, errorbuf, errorbuflen);
3573            curfield = field_config_alloc(curport, IPT_ADJUSTER, defval, 0xff);
3574            cursetting = NULL;
3575            curfield->name = TOKEN_GET_STRING(ipt);
3576            break;
3577
3578         /* input device handler */
3579         case INPUT_TOKEN_READ_LINE_DEVICE:
3580            if (curfield == NULL)
3581            {
3582               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_READ_LINE_DEVICE encountered with no active field\n");
3583               TOKEN_SKIP_STRING(ipt);
3584               TOKEN_SKIP_PTR(ipt);
3585               break;
3586            }
3587            curfield->read_device_name = TOKEN_GET_STRING(ipt);
3588            if (!strcmp(curfield->read_device_name, DEVICE_SELF))
3589            {
3590               if (owner)
3591                  curfield->read_device_name = owner->tag();
3592               else
3593                  error_buf_append(errorbuf, errorbuflen, "DEVICE_SELF used while not in device context\n");
3594            }
3595            curfield->read_line_device = TOKEN_GET_PTR(ipt, read_line_device);
3596            break;
3597
3598         /* output device handler */
3599         case INPUT_TOKEN_WRITE_LINE_DEVICE:
3600            if (curfield == NULL)
3601            {
3602               error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_WRITE_LINE_DEVICE encountered with no active field\n");
3603               TOKEN_SKIP_STRING(ipt);
3604               TOKEN_SKIP_PTR(ipt);
3605               break;
3606            }
3607            curfield->write_device_name = TOKEN_GET_STRING(ipt);
3608            if (!strcmp(curfield->write_device_name, DEVICE_SELF))
3609            {
3610               if (owner)
3611                  curfield->write_device_name = owner->tag();
3612               else
3613                  error_buf_append(errorbuf, errorbuflen, "DEVICE_SELF used while not in device context\n");
3614            }
3615            curfield->write_line_device = TOKEN_GET_PTR(ipt, write_line_device);
3616            break;
3617
3618         default:
3619            error_buf_append(errorbuf, errorbuflen, "Invalid token %d in input ports\n", entrytype);
3620            break;
3621      }
3622   }
3623
3624   /* insert any pending fields */
3625   if (curfield != NULL)
3626      field_config_insert(curfield, &maskbits, errorbuf, errorbuflen);
3627}
3628
3629
36302877/*-------------------------------------------------
36312878    input_port_config - constructor for an
36322879    I/O port configuration object
36332880-------------------------------------------------*/
36342881
3635input_port_config::input_port_config(const char *_tag)
3636   : m_next(NULL),
3637     tag(_tag),
3638     fieldlist(NULL),
3639     state(NULL),
3640     owner(NULL),
2882input_port_config::input_port_config(device_t &owner, const char *tag)
2883   : state(NULL),
36412884     active(0),
3642     m_machine(NULL)
2885     m_next(NULL),
2886     m_owner(owner),
2887     m_tag(tag),
2888     m_modcount(0)
36432889{
36442890}
36452891
36462892
3647/*-------------------------------------------------
3648    ~input_port_config - destructor for an
3649    I/O port configuration object
3650-------------------------------------------------*/
3651
3652input_port_config::~input_port_config()
2893running_machine &input_port_config::machine() const
36532894{
3654   while (fieldlist != NULL)
3655      field_config_free((input_field_config **)&fieldlist);
2895   return m_owner.machine();
36562896}
36572897
36582898
3659
36602899/*-------------------------------------------------
36612900    field_config_alloc - allocate a new input
36622901    port field config
36632902-------------------------------------------------*/
36642903
3665static input_field_config *field_config_alloc(input_port_config *port, int type, input_port_value defvalue, input_port_value maskbits)
2904input_field_config::input_field_config(input_port_config &port, int _type, input_port_value _defvalue, input_port_value _maskbits, const char *_name)
2905   : mask(_maskbits),
2906     defvalue(_defvalue & _maskbits),
2907     type(_type),
2908     player(0),
2909     category(0),
2910     flags(0),
2911     impulse(0),
2912     name(_name),
2913     read(NULL),
2914     read_param(NULL),
2915     read_device(NULL),
2916     write(NULL),
2917     write_param(NULL),
2918     write_device(NULL),
2919     min(0),
2920     max(_maskbits),
2921     sensitivity(0),
2922     delta(0),
2923     centerdelta(0),
2924     crossaxis(0),
2925     crossscale(0),
2926     crossoffset(0),
2927     crossaltaxis(0),
2928     crossmapper(NULL),
2929     full_turn_count(0),
2930     remap_table(NULL),
2931     way(0),
2932     state(NULL),
2933     m_next(NULL),
2934     m_port(port),
2935     m_modcount(port.modcount())
36662936{
3667   input_field_config *config;
3668   int seqtype;
2937   memset(&condition, 0, sizeof(condition));
2938   for (int seqtype = 0; seqtype < ARRAY_LENGTH(seq); seqtype++)
2939      input_seq_set_1(&seq[seqtype], SEQCODE_DEFAULT);
2940}
36692941
3670   /* allocate memory */
3671   config = global_alloc_clear(input_field_config);
36722942
3673   /* fill in the basic field values */
3674   config->port = port;
3675   config->type = type;
3676   config->mask = maskbits;
3677   config->defvalue = defvalue & maskbits;
3678   config->max = maskbits;
3679   for (seqtype = 0; seqtype < ARRAY_LENGTH(config->seq); seqtype++)
3680      input_seq_set_1(&config->seq[seqtype], SEQCODE_DEFAULT);
2943input_setting_config::input_setting_config(input_field_config &field, input_port_value _value, const char *_name)
2944   : value(_value),
2945     name(_name),
2946     category(0),
2947     m_field(field),
2948     m_next(NULL)
2949{
2950   memset(&condition, 0, sizeof(condition));
2951}
36812952
3682   return config;
2953input_field_diplocation::input_field_diplocation(const char *string, UINT8 _swnum, bool _invert)
2954   : swname(string),
2955     swnum(_swnum),
2956     invert(_invert)
2957{
36832958}
36842959
3685
36862960/*-------------------------------------------------
36872961    field_config_insert - insert an allocated
36882962    input port field config, replacing any
r11508r11509
36902964    inserting at the correct sorted location
36912965-------------------------------------------------*/
36922966
3693static void field_config_insert(input_field_config *field, input_port_value *disallowedbits, char *errorbuf, int errorbuflen)
2967void input_port_config::collapse_fields(astring &errorbuf)
36942968{
3695   const input_field_config * const *scanfieldptr;
3696   const input_field_config * const *scanfieldnextptr;
3697   input_field_config *config;
3698   input_port_value lowbit;
2969   input_field_config *list = m_fieldlist.detach_all();
2970   input_port_value maskbits = 0;
2971   int lastmodcount = -1;
2972   while (list != NULL)
2973   {
2974      if (list->modcount() != lastmodcount)
2975      {
2976         lastmodcount = list->modcount();
2977         maskbits = 0;
2978      }
2979      input_field_config *current = list;
2980      list = list->next();
2981      field_config_insert(*current, maskbits, errorbuf);
2982   }
2983}
36992984
2985void field_config_insert(input_field_config &newfield, input_port_value &disallowedbits, astring &errorbuf)
2986{
2987   input_port_value lowbit;
2988   
37002989   /* verify against the disallowed bits, but only if we are condition-free */
3701   if (field->condition.condition == PORTCOND_ALWAYS)
2990   if (newfield.condition.condition == PORTCOND_ALWAYS)
37022991   {
3703      if ((field->mask & *disallowedbits) != 0)
3704         error_buf_append(errorbuf, errorbuflen, "INPUT_TOKEN_FIELD specifies duplicate port bits (mask=%X)\n", field->mask);
3705      *disallowedbits |= field->mask;
2992      if ((newfield.mask & disallowedbits) != 0)
2993         errorbuf.catprintf("INPUT_TOKEN_FIELD specifies duplicate port bits (port=%s mask=%X)\n", newfield.port().tag(), newfield.mask);
2994      disallowedbits |= newfield.mask;
37062995   }
37072996
37082997   /* first modify/nuke any entries that intersect our maskbits */
3709   for (scanfieldptr = &field->port->fieldlist; *scanfieldptr != NULL; scanfieldptr = scanfieldnextptr)
2998   input_field_config *nextfield;
2999   for (input_field_config *field = newfield.port().fieldlist().first(); field != NULL; field = nextfield)
37103000   {
3711      scanfieldnextptr = &(*scanfieldptr)->next;
3712      if (((*scanfieldptr)->mask & field->mask) != 0 && (field->condition.condition == PORTCOND_ALWAYS ||
3713                                                         (*scanfieldptr)->condition.condition == PORTCOND_ALWAYS ||
3714                                                         condition_equal(&(*scanfieldptr)->condition, &field->condition)))
3001      nextfield = field->next();
3002      if ((field->mask & newfield.mask) != 0 && (newfield.condition.condition == PORTCOND_ALWAYS ||
3003                                                 field->condition.condition == PORTCOND_ALWAYS ||
3004                                                 condition_equal(&field->condition, &newfield.condition)))
37153005      {
37163006         /* reduce the mask of the field we found */
3717         config = (input_field_config *)*scanfieldptr;
3718         config->mask &= ~field->mask;
3007         field->mask &= ~newfield.mask;
37193008
37203009         /* if the new entry fully overrides the previous one, we nuke */
3721         if (INPUT_PORT_OVERRIDE_FULLY_NUKES_PREVIOUS || config->mask == 0)
3722         {
3723            field_config_free((input_field_config **)scanfieldptr);
3724            scanfieldnextptr = scanfieldptr;
3725         }
3010         if (INPUT_PORT_OVERRIDE_FULLY_NUKES_PREVIOUS || field->mask == 0)
3011            newfield.port().fieldlist().remove(*field);
37263012      }
37273013   }
37283014
37293015   /* make a mask of just the low bit */
3730   lowbit = (field->mask ^ (field->mask - 1)) & field->mask;
3016   lowbit = (newfield.mask ^ (newfield.mask - 1)) & newfield.mask;
37313017
37323018   /* scan forward to find where to insert ourselves */
3733   for (scanfieldptr = (const input_field_config * const *)&field->port->fieldlist; *scanfieldptr != NULL; scanfieldptr = &(*scanfieldptr)->next)
3734      if ((*scanfieldptr)->mask > lowbit)
3019   input_field_config *field;
3020   for (field = newfield.port().fieldlist().first(); field != NULL; field = field->next())
3021      if (field->mask > lowbit)
37353022         break;
37363023
37373024   /* insert it into the list */
3738   field->next = *scanfieldptr;
3739   *(input_field_config **)scanfieldptr = field;
3025   newfield.port().fieldlist().insert_before(newfield, field);
37403026}
37413027
37423028
37433029/*-------------------------------------------------
3744    field_config_free - free an allocated input
3745    field configuration
3746-------------------------------------------------*/
3747
3748static void field_config_free(input_field_config **fieldptr)
3749{
3750   input_field_config *field = *fieldptr;
3751
3752   /* free any settings and DIP locations first */
3753   while (field->settinglist != NULL)
3754      setting_config_free((input_setting_config **)&field->settinglist);
3755   while (field->diploclist != NULL)
3756      diplocation_free((input_field_diplocation **)&field->diploclist);
3757
3758   /* remove ourself from the list */
3759   *fieldptr = (input_field_config *)field->next;
3760
3761   /* free ourself */
3762   global_free(field);
3763}
3764
3765
3766/*-------------------------------------------------
3767    setting_config_alloc - allocate a new input
3768    port setting and append it to the end of the
3769    list
3770-------------------------------------------------*/
3771
3772static input_setting_config *setting_config_alloc(input_field_config *field, input_port_value value, const char *name)
3773{
3774   const input_setting_config * const *tailptr;
3775   input_setting_config *config;
3776
3777   /* allocate memory */
3778   config = global_alloc_clear(input_setting_config);
3779
3780   /* fill in the basic setting values */
3781   config->field = field;
3782   config->value = value;
3783   config->name = name;
3784
3785   /* add it to the tail */
3786   for (tailptr = &field->settinglist; *tailptr != NULL; tailptr = &(*tailptr)->next) ;
3787   *(input_setting_config **)tailptr = config;
3788
3789   return config;
3790}
3791
3792
3793/*-------------------------------------------------
3794    setting_config_free - free an allocated input
3795    setting configuration
3796-------------------------------------------------*/
3797
3798static void setting_config_free(input_setting_config **settingptr)
3799{
3800   input_setting_config *setting = (input_setting_config *)*settingptr;
3801
3802   /* remove ourself from the list */
3803   *settingptr = (input_setting_config *)setting->next;
3804
3805   /* free ourself */
3806   global_free(setting);
3807}
3808
3809
3810/*-------------------------------------------------
38113030    diplocation_expand - expand a string-based
38123031    DIP location into a linked list of
38133032    descriptions
38143033-------------------------------------------------*/
38153034
3816static const input_field_diplocation *diplocation_list_alloc(const input_field_config *field, const char *location, char *errorbuf, int errorbuflen)
3035void diplocation_list_alloc(input_field_config &field, const char *location, astring &errorbuf)
38173036{
3818   input_field_diplocation *head = NULL;
3819   input_field_diplocation **tailptr = &head;
3820   const char *curentry = location;
3821   char *lastname = NULL;
3822   char tempbuf[100];
3823   input_port_value temp;
3824   int entries = 0;
3825   int val, bits;
3826
38273037   /* if nothing present, bail */
38283038   if (location == NULL)
3829      return NULL;
3039      return;
38303040
3041   field.diploclist().reset();
3042
38313043   /* parse the string */
3044   const char *lastname = NULL;
3045   const char *curentry = location;
3046   int entries = 0;
38323047   while (*curentry != 0)
38333048   {
3834      const char *comma, *colon, *number;
3835
3836      /* allocate a new entry */
3837      *tailptr = global_alloc_clear(input_field_diplocation);
3838      entries++;
3839
38403049      /* find the end of this entry */
3841      comma = strchr(curentry, ',');
3050      const char *comma = strchr(curentry, ',');
38423051      if (comma == NULL)
38433052         comma = curentry + strlen(curentry);
38443053
38453054      /* extract it to tempbuf */
3846      strncpy(tempbuf, curentry, comma - curentry);
3847      tempbuf[comma - curentry] = 0;
3055      astring tempstr;
3056      tempstr.cpy(curentry, comma - curentry);
38483057
38493058      /* first extract the switch name if present */
3850      number = tempbuf;
3851      colon = strchr(tempbuf, ':');
3059      const char *number = tempstr;
3060      const char *colon = strchr(tempstr, ':');
38523061
38533062      /* allocate and copy the name if it is present */
3063      astring name;
38543064      if (colon != NULL)
38553065      {
3856         (*tailptr)->swname = lastname = global_alloc_array(char, colon - tempbuf + 1);
3857         strncpy(lastname, tempbuf, colon - tempbuf);
3858         lastname[colon - tempbuf] = 0;
3066         lastname = name.cpy(number, colon - number);
38593067         number = colon + 1;
38603068      }
38613069
38623070      /* otherwise, just copy the last name */
38633071      else
38643072      {
3865         char *namecopy;
38663073         if (lastname == NULL)
38673074         {
3868            error_buf_append(errorbuf, errorbuflen, "Switch location '%s' missing switch name!\n", location);
3075            errorbuf.catprintf("Switch location '%s' missing switch name!\n", location);
38693076            lastname = (char *)"UNK";
38703077         }
3871         (*tailptr)->swname = namecopy = global_alloc_array(char, strlen(lastname) + 1);
3872         strcpy(namecopy, lastname);
3078         name.cpy(lastname);
38733079      }
38743080
38753081      /* if the number is preceded by a '!' it's active high */
3876      (*tailptr)->invert = FALSE;
3082      bool invert = false;
38773083      if (*number == '!')
38783084      {
3879         (*tailptr)->invert = TRUE;
3085         invert = true;
38803086         number++;
38813087      }
38823088
38833089      /* now scan the switch number */
3884      if (sscanf(number, "%d", &val) != 1)
3885         error_buf_append(errorbuf, errorbuflen, "Switch location '%s' has invalid format!\n", location);
3886      else
3887         (*tailptr)->swnum = val;
3090      int swnum = -1;
3091      if (sscanf(number, "%d", &swnum) != 1)
3092         errorbuf.catprintf("Switch location '%s' has invalid format!\n", location);
38883093
3094      /* allocate a new entry */
3095      field.diploclist().append(*global_alloc(input_field_diplocation(name, swnum, invert)));
3096      entries++;
3097
38893098      /* advance to the next item */
38903099      curentry = comma;
38913100      if (*curentry != 0)
38923101         curentry++;
3893      tailptr = &(*tailptr)->next;
38943102   }
38953103
38963104   /* then verify the number of bits in the mask matches */
3897   for (bits = 0, temp = field->mask; temp != 0 && bits < 32; bits++)
3105   input_port_value temp;
3106   int bits;
3107   for (bits = 0, temp = field.mask; temp != 0 && bits < 32; bits++)
38983108      temp &= temp - 1;
38993109   if (bits != entries)
3900      error_buf_append(errorbuf, errorbuflen, "Switch location '%s' does not describe enough bits for mask %X\n", location, field->mask);
3901   return head;
3110      errorbuf.catprintf("Switch location '%s' does not describe enough bits for mask %X\n", location, field.mask);
39023111}
39033112
39043113
3905/*-------------------------------------------------
3906    diplocation_free - free an allocated dip
3907    location
3908-------------------------------------------------*/
39093114
3910static void diplocation_free(input_field_diplocation **diplocptr)
3911{
3912   input_field_diplocation *diploc = (input_field_diplocation *)*diplocptr;
3913
3914   /* free the name */
3915   if (diploc->swname != NULL)
3916      global_free(diploc->swname);
3917
3918   /* remove ourself from the list */
3919   *diplocptr = (input_field_diplocation *)diploc->next;
3920
3921   /* free ourself */
3922   global_free(diploc);
3923}
3924
3925
3926
39273115/***************************************************************************
39283116    TOKENIZATION HELPERS
39293117***************************************************************************/
r11508r11509
41903378   /* find the port we want; if no tag, search them all */
41913379   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
41923380      if (tag == NULL || strcmp(get_port_tag(port, tempbuffer), tag) == 0)
4193         for (field = port->fieldlist; field != NULL; field = field->next)
3381         for (field = port->first_field(); field != NULL; field = field->next())
41943382
41953383            /* find the matching mask and defvalue */
41963384            if (field->type == type && field->player == player &&
r11508r11509
43513539
43523540   /* iterate over ports */
43533541   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
4354      for (field = port->fieldlist; field != NULL; field = field->next)
3542      for (field = port->first_field(); field != NULL; field = field->next())
43553543         if (save_this_input_field_type(field->type))
43563544         {
43573545            int changed = FALSE;
r11508r11509
48294017   const input_port_config *port;
48304018   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
48314019   {
4832      for (field = port->fieldlist; field != NULL; field = field->next)
4020      for (field = port->first_field(); field != NULL; field = field->next())
48334021      {
48344022         if (field->type == IPT_KEYBOARD)
48354023         {
r11508r11509
49084096
49094097   for (port = portconfig; port != NULL; port = port->next())
49104098   {
4911      for (field = port->fieldlist; field != NULL; field = field->next)
4099      for (field = port->first_field(); field != NULL; field = field->next())
49124100      {
49134101         if (field->type == IPT_KEYBOARD)
49144102         {
r11508r11509
55374725
55384726   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
55394727   {
5540      for (field = port->fieldlist; field != NULL; field = field->next)
4728      for (field = port->first_field(); field != NULL; field = field->next())
55414729      {
55424730         if (input_classify_port(field) == inputclass)
55434731            return TRUE;
r11508r11509
55624750   joystick_count = 0;
55634751   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
55644752   {
5565      for (field = port->fieldlist; field != NULL; field = field->next)
4753      for (field = port->first_field(); field != NULL; field = field->next())
55664754      {
55674755         if (input_classify_port(field) == INPUT_CLASS_CONTROLLER)
55684756         {
r11508r11509
55934781   /* loop through the input ports */
55944782   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
55954783   {
5596      for (field = port->fieldlist; field != NULL; field = field->next)
4784      for (field = port->first_field(); field != NULL; field = field->next())
55974785      {
55984786         /* is this field a category? */
55994787         if (field->type == IPT_CATEGORY)
r11508r11509
56014789            /* get the settings value */
56024790            input_field_get_user_settings(field, &settings);
56034791
5604            for (setting = field->settinglist; setting != NULL; setting = setting->next)
4792            for (setting = field->settinglist().first(); setting != NULL; setting = setting->next())
56054793            {
56064794               /* is this the category we want?  if so, is this settings value correct? */
56074795               if ((setting->category == category) && (settings.value == setting->value))
r11508r11509
57034891      fclose(file);
57044892
57054893}
4894
4895
4896
4897input_port_config *ioconfig_alloc_port(ioport_list &portlist, device_t &device, const char *tag)
4898{
4899   astring fulltag;
4900   device.subtag(fulltag, tag);
4901   return &portlist.append(fulltag, *global_alloc(input_port_config(device, fulltag)));
4902}
4903
4904input_port_config *ioconfig_modify_port(ioport_list &portlist, device_t &device, const char *tag)
4905{
4906   astring fulltag;
4907   device.subtag(fulltag, tag);
4908   input_port_config *port = portlist.find(fulltag.cstr());
4909   if (port == NULL)
4910      throw emu_fatalerror("Requested to modify nonexistent port '%s'", fulltag.cstr());
4911   port->bump_modcount();
4912   return port;
4913}
4914
4915input_field_config *ioconfig_alloc_field(input_port_config &port, int type, input_port_value defval, input_port_value mask, const char *name)
4916{
4917   if (&port == NULL)
4918      throw emu_fatalerror("INPUT_TOKEN_FIELD encountered with no active port (mask=%X defval=%X)\n", mask, defval); \
4919   if (type != IPT_UNKNOWN && type != IPT_UNUSED)
4920      port.active |= mask;
4921   if (type == IPT_DIPSWITCH || type == IPT_CONFIG || type == IPT_CATEGORY)
4922      defval = port_default_value(port.tag(), mask, defval, port.owner());
4923   return &port.fieldlist().append(*global_alloc(input_field_config(port, type, defval, mask, input_port_string_from_token(name))));
4924}
4925
4926input_field_config *ioconfig_alloc_onoff(input_port_config &port, const char *name, input_port_value defval, input_port_value mask, const char *diplocation, astring &errorbuf)
4927{
4928   input_field_config *curfield = ioconfig_alloc_field(port, IPT_DIPSWITCH, defval, mask, name);
4929   if (name == DEF_STR(Service_Mode))
4930   {
4931      curfield->flags |= FIELD_FLAG_TOGGLE;
4932      curfield->seq[SEQ_TYPE_STANDARD].code[0] = KEYCODE_F2;
4933   }
4934   if (diplocation != NULL)
4935      diplocation_list_alloc(*curfield, diplocation, errorbuf);
4936   ioconfig_alloc_setting(*curfield, defval & mask, DEF_STR(Off));
4937   ioconfig_alloc_setting(*curfield, ~defval & mask, DEF_STR(On));
4938   return curfield;
4939}
4940
4941input_setting_config *ioconfig_alloc_setting(input_field_config &field, input_port_value value, const char *name)
4942{
4943   return &field.settinglist().append(*global_alloc(input_setting_config(field, value, input_port_string_from_token(name))));
4944}
4945
4946void ioconfig_field_add_char(input_field_config &field, unicode_char ch, astring &errorbuf)
4947{
4948   for (int index = 0; index < ARRAY_LENGTH(field.chars); index++)
4949      if (field.chars[index] == 0)
4950      {
4951         field.chars[index] = ch;
4952         break;
4953      }
4954}
4955
4956void ioconfig_add_code(input_field_config &field, int which, input_code code)
4957{
4958   input_seq_append_or(&field.seq[which], code);
4959}
4960
src/emu/devintrf.c
r11508r11509
809809//  input ports description for this device
810810//-------------------------------------------------
811811
812const input_port_token *device_t::device_input_ports() const
812ioport_constructor device_t::device_input_ports() const
813813{
814814   // none by default
815815   return NULL;
src/emu/inptport.h
r11508r11509
373373};
374374
375375
376/* token types */
377enum
378{
379   INPUT_TOKEN_INVALID,
380   INPUT_TOKEN_END,
381   INPUT_TOKEN_INCLUDE,
382   INPUT_TOKEN_START,
383   INPUT_TOKEN_MODIFY,
384   INPUT_TOKEN_FIELD,
385   INPUT_TOKEN_SPECIAL_ONOFF,
386   INPUT_TOKEN_CODE,
387   INPUT_TOKEN_CODE_DEC,
388   INPUT_TOKEN_CODE_INC,
389   INPUT_TOKEN_2WAY,
390   INPUT_TOKEN_4WAY,
391   INPUT_TOKEN_8WAY,
392   INPUT_TOKEN_16WAY,
393   INPUT_TOKEN_ROTATED,
394   INPUT_TOKEN_PLAYER1,
395   INPUT_TOKEN_PLAYER2,
396   INPUT_TOKEN_PLAYER3,
397   INPUT_TOKEN_PLAYER4,
398   INPUT_TOKEN_PLAYER5,
399   INPUT_TOKEN_PLAYER6,
400   INPUT_TOKEN_PLAYER7,
401   INPUT_TOKEN_PLAYER8,
402   INPUT_TOKEN_COCKTAIL,
403   INPUT_TOKEN_TOGGLE,
404   INPUT_TOKEN_NAME,
405   INPUT_TOKEN_IMPULSE,
406   INPUT_TOKEN_REVERSE,
407   INPUT_TOKEN_RESET,
408   INPUT_TOKEN_MINMAX,
409   INPUT_TOKEN_SENSITIVITY,
410   INPUT_TOKEN_KEYDELTA,
411   INPUT_TOKEN_CENTERDELTA,
412   INPUT_TOKEN_CROSSHAIR,
413   INPUT_TOKEN_CROSSHAIR_MAPPER,
414   INPUT_TOKEN_FULL_TURN_COUNT,
415   INPUT_TOKEN_POSITIONS,
416   INPUT_TOKEN_WRAPS,
417   INPUT_TOKEN_REMAP_TABLE,
418   INPUT_TOKEN_INVERT,
419   INPUT_TOKEN_UNUSED,
420   INPUT_TOKEN_CUSTOM,
421   INPUT_TOKEN_CHANGED,
422   INPUT_TOKEN_DIPNAME,
423   INPUT_TOKEN_DIPSETTING,
424   INPUT_TOKEN_DIPLOCATION,
425   INPUT_TOKEN_CONDITION,
426   INPUT_TOKEN_ADJUSTER,
427   INPUT_TOKEN_CONFNAME,
428   INPUT_TOKEN_CONFSETTING,
429   INPUT_TOKEN_CHAR,
430   INPUT_TOKEN_CATEGORY,
431   INPUT_TOKEN_CATEGORY_NAME,
432   INPUT_TOKEN_CATEGORY_SETTING,
433   INPUT_TOKEN_READ_LINE_DEVICE,
434   INPUT_TOKEN_WRITE_LINE_DEVICE,
435};
436
437
438376/* default strings used in port definitions */
439377enum
440378{
r11508r11509
595533
596534/* forward declarations */
597535class input_port_config;
598typedef struct _input_field_config input_field_config;
536class input_field_config;
599537
600538
601539/* template specializations */
602540typedef tagged_list<input_port_config> ioport_list;
603541
604542
605/* custom input port callback function */
606typedef UINT32 (*input_field_custom_func)(const input_field_config *field, void *param);
543/* read input port callback function */
544typedef UINT32 (*input_field_read_func)(device_t &device, const input_field_config *field, void *param);
607545
608/* input port changed callback function */
609typedef void (*input_field_changed_func)(const input_field_config *field, void *param, UINT32 oldval, UINT32 newval);
546/* input port write callback function */
547typedef void (*input_field_write_func)(device_t &device, const input_field_config *field, void *param, UINT32 oldval, UINT32 newval);
610548
611549/* crosshair mapping function */
612550typedef float (*input_field_crossmap_func)(const input_field_config *field, float linear_value);
613551
614552
615/* this type is used to encode input port definitions */
616typedef union _input_port_token input_port_token;
617union _input_port_token
618{
619   TOKEN_COMMON_FIELDS
620   const input_port_token *   tokenptr;
621   input_field_custom_func    customptr;
622   input_field_changed_func   changedptr;
623   input_field_crossmap_func   crossmapptr;
624   read_line_device_func      read_line_device;
625   write_line_device_func      write_line_device;
626};
627
628
629553/* encapsulates a condition on a port field or setting */
630554typedef struct _input_condition input_condition;
631555struct _input_condition
r11508r11509
638562
639563
640564/* a single setting for a configuration or DIP switch */
641typedef struct _input_setting_config input_setting_config;
642struct _input_setting_config
565class input_setting_config
643566{
644   const input_setting_config *next;         /* pointer to next setting in sequence */
645   const input_field_config *   field;         /* pointer back to the field that owns us */
567   DISABLE_COPYING(input_setting_config);
568   friend class simple_list<input_setting_config>;
569
570public:
571   input_setting_config(input_field_config &field, input_port_value value, const char *name);
572   input_setting_config *next() const { return m_next; }
573
646574   input_port_value         value;         /* value of the bits in this setting */
647575   input_condition            condition;      /* condition under which this setting is valid */
648576   const char *            name;         /* user-friendly name to display */
649577   UINT16                  category;      /* (MESS-specific) category */
578
579private:
580   input_field_config &      m_field;         /* pointer back to the field that owns us */
581   input_setting_config *      m_next;         /* pointer to next setting in sequence */
650582};
651583
652584
653585/* a mapping from a bit to a physical DIP switch description */
654typedef struct _input_field_diplocation input_field_diplocation;
655struct _input_field_diplocation
586class input_field_diplocation
656587{
657   input_field_diplocation *   next;         /* pointer to the next bit */
658   const char *            swname;         /* name of the physical DIP switch */
588   DISABLE_COPYING(input_field_diplocation);
589   friend class simple_list<input_field_diplocation>;
590
591public:
592   input_field_diplocation(const char *string, UINT8 swnum, bool invert);
593   input_field_diplocation *next() const { return m_next; }
594
595   astring                  swname;         /* name of the physical DIP switch */
659596   UINT8                  swnum;         /* physical switch number */
660   UINT8                  invert;         /* is this an active-high DIP? */
597   bool                  invert;         /* is this an active-high DIP? */
598
599private:
600   input_field_diplocation *   m_next;         /* pointer to the next bit */
661601};
662602
663603
664604/* a single bitfield within an input port */
665struct _input_field_config
605class input_field_config
666606{
607   DISABLE_COPYING(input_field_config);
608   friend class simple_list<input_field_config>;
609
610public:
611   input_field_config(input_port_config &port, int type, input_port_value defvalue, input_port_value maskbits, const char *name = NULL);
612
613   input_field_config *next() const { return m_next; }
614   input_port_config &port() const { return m_port; }
615   running_machine &machine() const;
616   simple_list<input_setting_config> &settinglist() { return m_settinglist; }
617   const simple_list<input_setting_config> &settinglist() const { return m_settinglist; }
618   simple_list<input_field_diplocation> &diploclist() { return m_diploclist; }
619   int modcount() const { return m_modcount; }
620
667621   /* generally-applicable data */
668   const input_field_config *   next;         /* pointer to next field in sequence */
669   const input_port_config *   port;         /* pointer back to the port that owns us */
670622   input_port_value         mask;         /* mask of bits belonging to the field */
671623   input_port_value         defvalue;      /* default value of these bits */
672624   input_condition            condition;      /* condition under which this field is relevant */
r11508r11509
677629   UINT8                  impulse;      /* number of frames before reverting to defvalue */
678630   const char *            name;         /* user-friendly name to display */
679631   input_seq               seq[SEQ_TYPE_TOTAL];/* sequences of all types */
680   read_line_device_func      read_line_device;   /* input device handler */
681   const char *            read_device_name;   /* input device name */
682   write_line_device_func      write_line_device;   /* output device handler */
683   const char *            write_device_name;   /* input device name */
684   input_field_custom_func      custom;         /* custom callback routine */
685   void *                  custom_param;   /* parameter for custom callback routine */
686   input_field_changed_func   changed;      /* changed callback routine */
687   void *                  changed_param;   /* parameter for changed callback routine */
632   input_field_read_func      read;         /* read callback routine */
633   void *                  read_param;      /* parameter for read callback routine */
634   const char *            read_device;   /* parameter for read callback routine */
635   input_field_write_func      write;         /* write callback routine */
636   void *                  write_param;   /* parameter for write callback routine */
637   const char *            write_device;   /* parameter for write callback routine */
688638
689639   /* data relevant to analog control types */
690640   INT32                  min;         /* minimum value for absolute axes */
r11508r11509
701651   const input_port_value *   remap_table;   /* pointer to an array that remaps the port value */
702652
703653   /* data relevant to other specific types */
704   const input_setting_config *settinglist;   /* list of input_setting_configs */
705   const input_field_diplocation *diploclist;   /* list of locations for various bits */
706654   UINT8                  way;         /* digital joystick 2/4/8-way descriptions */
707655   unicode_char            chars[3];      /* (MESS-specific) unicode key data */
708656
709657   /* this field is only valid if the device is live */
710658   input_field_state *         state;         /* live state of field (NULL if not live) */
659
660private:
661   input_field_config *      m_next;            /* pointer to next field in sequence */
662   input_port_config &         m_port;            /* pointer back to the port that owns us */
663   int                     m_modcount;
664   simple_list<input_setting_config> m_settinglist;   /* list of input_setting_configs */
665   simple_list<input_field_diplocation> m_diploclist;   /* list of locations for various bits */
711666};
712667
713668
r11508r11509
731686   input_port_value         mask;         /* mask to apply to the port */
732687   input_port_value         defvalue;      /* new default value */
733688};
689
734690/* a single input port configuration */
735691class input_port_config
736692{
737693   DISABLE_COPYING(input_port_config);
694   friend class simple_list<input_port_config>;
738695
739696public:
740   input_port_config(const char *tag);
741   ~input_port_config();
697   // construction/destruction
698   input_port_config(device_t &owner, const char *tag);
742699
700   // getters
743701   input_port_config *next() const { return m_next; }
744   running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
745   void set_machine(running_machine &machine) { m_machine = &machine; }
702   device_t &owner() const { return m_owner; }
703   running_machine &machine() const;
704   input_field_config *first_field() const { return m_fieldlist.first(); }
705   simple_list<input_field_config> &fieldlist() { return m_fieldlist; }
706   const char *tag() const { return m_tag; }
707   int modcount() const { return m_modcount; }
708   
709   void bump_modcount() { m_modcount++; }
710   
711   void collapse_fields(astring &errorbuf);
746712
747   input_port_config *         m_next;         /* pointer to next port */
748   const char *            tag;         /* pointer to this port's tag */
749   const input_field_config *   fieldlist;      /* list of input_field_configs */
750
751713   /* these fields are only valid if the port is live */
752714   input_port_state *         state;         /* live state of port (NULL if not live) */
753   device_t *               owner;         /* associated device, when appropriate */
754715   input_port_value         active;         /* mask of active bits in the port */
755716
756717private:
757   running_machine *         m_machine;      /* machine if port is live */
718   input_port_config *         m_next;         /* pointer to next port */
719   device_t &               m_owner;         /* associated device, when appropriate */
720   simple_list<input_field_config> m_fieldlist;      /* list of input_field_configs */
721   astring                  m_tag;         /* pointer to this port's tag */
722   int                     m_modcount;
758723};
759724
760725
r11508r11509
791756    MACROS
792757***************************************************************************/
793758
794/* macro for a custom callback functions (PORT_CUSTOM) */
795#define CUSTOM_INPUT(name)   UINT32 name(const input_field_config *field, void *param)
759/* macro for a read callback function (PORT_CUSTOM) */
760#define CUSTOM_INPUT(name)   input_port_value name(device_t &device, const input_field_config *field, void *param)
796761
797/* macro for port changed callback functions (PORT_CHANGED) */
798#define INPUT_CHANGED(name)   void name(const input_field_config *field, void *param, UINT32 oldval, UINT32 newval)
762/* macro for port write callback functions (PORT_CHANGED) */
763#define INPUT_CHANGED(name)   void name(device_t &device, const input_field_config *field, void *param, input_port_value oldval, input_port_value newval)
799764
800765/* macro for port changed callback functions (PORT_CROSSHAIR_MAPPER) */
801766#define CROSSHAIR_MAPPER(name)   float name(const input_field_config *field, float linear_value)
r11508r11509
804769#define DEF_STR(str_num) ((const char *)INPUT_STRING_##str_num)
805770
806771
772template<int (*_ReadLine)(device_t *)>
773input_port_value ioport_read_line_wrapper(device_t &device, const input_field_config *field, void *param)
774{
775   return (*_ReadLine)(&device);
776}
807777
778template<void (*_WriteLine)(device_t *, int)>
779void ioport_write_line_wrapper(device_t &device, const input_field_config *field, void *param, input_port_value oldval, input_port_value newval)
780{
781   return (*_WriteLine)(&device, newval);
782}
783
784
785
808786/***************************************************************************
809787    MACROS FOR BUILDING INPUT PORTS
810788***************************************************************************/
811789
790typedef void (*ioport_constructor)(device_t &owner, ioport_list &portlist, astring &errorbuf);
791
812792/* so that "0" can be used for unneeded input ports */
813#define ipt_0 NULL
793#define construct_ioport_0 NULL
814794
815795/* name of table */
816#define INPUT_PORTS_NAME(_name) ipt_##_name
796#define INPUT_PORTS_NAME(_name) construct_ioport_##_name
817797
818798/* start of table */
819799#define INPUT_PORTS_START(_name) \
820   const input_port_token INPUT_PORTS_NAME(_name)[] = {
800void INPUT_PORTS_NAME(_name)(device_t &owner, ioport_list &portlist, astring &errorbuf) \
801{ \
802   astring fulltag; \
803   input_setting_config *cursetting = NULL; \
804   input_field_config *curfield = NULL; \
805   input_port_config *curport = NULL; \
806   input_port_value maskbits = 0; \
807   (void)cursetting; (void)curfield; (void)curport; (void)maskbits; \
821808
822809/* end of table */
823810#define INPUT_PORTS_END \
824   TOKEN_UINT32_PACK1(INPUT_TOKEN_END, 8) };
811}
825812
826813/* aliasing */
827814#define INPUT_PORTS_EXTERN(_name) \
828   extern const input_port_token INPUT_PORTS_NAME(_name)[]
815   extern void INPUT_PORTS_NAME(_name)(device_t &owner, ioport_list &portlist, astring &errorbuf)
829816
830817/* including */
831818#define PORT_INCLUDE(_name) \
832   TOKEN_UINT32_PACK1(INPUT_TOKEN_INCLUDE, 8), \
833   TOKEN_PTR(tokenptr, &INPUT_PORTS_NAME(_name)[0]),
819   INPUT_PORTS_NAME(_name)(owner, portlist, errorbuf); \
834820
835821/* start of a new input port (with included tag) */
836822#define PORT_START(_tag) \
837   TOKEN_UINT32_PACK1(INPUT_TOKEN_START, 8), \
838   TOKEN_STRING(_tag),
823   curport = ioconfig_alloc_port(portlist, owner, _tag); \
824   curfield = NULL; \
825   cursetting = NULL; \
826   maskbits = 0; \
839827
840828/* modify an existing port */
841829#define PORT_MODIFY(_tag) \
842   TOKEN_UINT32_PACK1(INPUT_TOKEN_MODIFY, 8), \
843   TOKEN_STRING(_tag),
830   curport = ioconfig_modify_port(portlist, owner, _tag); \
831   curfield = NULL; \
832   cursetting = NULL; \
833   maskbits = 0; \
844834
845835/* input bit definition */
846836#define PORT_BIT(_mask, _default, _type) \
847   TOKEN_UINT32_PACK2(INPUT_TOKEN_FIELD, 8, _type, 24), \
848   TOKEN_UINT64_PACK2(_mask, 32, _default, 32),
837   curfield = ioconfig_alloc_field(*curport, (_type), (_default), (_mask)); \
838   cursetting = NULL;
849839
850#define PORT_SPECIAL_ONOFF(_mask, _default, _strindex) \
851   TOKEN_UINT32_PACK3(INPUT_TOKEN_SPECIAL_ONOFF, 8, FALSE, 1, INPUT_STRING_##_strindex, 23), \
852   TOKEN_UINT64_PACK2(_mask, 32, _default, 32),
840#define PORT_SPECIAL_ONOFF(_mask, _default, _strindex) PORT_SPECIAL_ONOFF_DIPLOC(_mask, _default, _strindex, NULL)
853841
854842#define PORT_SPECIAL_ONOFF_DIPLOC(_mask, _default, _strindex, _diploc) \
855   TOKEN_UINT32_PACK3(INPUT_TOKEN_SPECIAL_ONOFF, 8, TRUE, 1, INPUT_STRING_##_strindex, 23), \
856   TOKEN_UINT64_PACK2(_mask, 32, _default, 32), \
857   TOKEN_STRING(_diploc),
843   curfield = ioconfig_alloc_onoff(*curport, DEF_STR(_strindex), _default, _mask, _diploc, errorbuf); \
844   cursetting = NULL;
858845
859846/* append a code */
860847#define PORT_CODE(_code) \
861   TOKEN_UINT64_PACK2(INPUT_TOKEN_CODE, 8, _code, 32),
848   ioconfig_add_code(*curfield, SEQ_TYPE_STANDARD, _code);
862849
863850#define PORT_CODE_DEC(_code) \
864   TOKEN_UINT64_PACK2(INPUT_TOKEN_CODE_DEC, 8, _code, 32),
851   ioconfig_add_code(*curfield, SEQ_TYPE_DECREMENT, _code);
865852
866853#define PORT_CODE_INC(_code) \
867   TOKEN_UINT64_PACK2(INPUT_TOKEN_CODE_INC, 8, _code, 32),
854   ioconfig_add_code(*curfield, SEQ_TYPE_INCREMENT, _code);
868855
869856/* joystick flags */
870857#define PORT_2WAY \
871   TOKEN_UINT32_PACK1(INPUT_TOKEN_2WAY, 8),
858   curfield->way = 2;
872859
873860#define PORT_4WAY \
874   TOKEN_UINT32_PACK1(INPUT_TOKEN_4WAY, 8),
861   curfield->way = 4;
875862
876863#define PORT_8WAY \
877   TOKEN_UINT32_PACK1(INPUT_TOKEN_8WAY, 8),
864   curfield->way = 8;
878865
879866#define PORT_16WAY \
880   TOKEN_UINT32_PACK1(INPUT_TOKEN_16WAY, 8),
867   curfield->way = 16;
881868
882869#define PORT_ROTATED \
883   TOKEN_UINT32_PACK1(INPUT_TOKEN_ROTATED, 8),
870   curfield->flags |= FIELD_FLAG_ROTATED
884871
885872/* general flags */
886873#define PORT_NAME(_name) \
887   TOKEN_UINT32_PACK1(INPUT_TOKEN_NAME, 8), \
888   TOKEN_STRING(_name),
874   curfield->name = input_port_string_from_token(_name);
889875
890#define PORT_PLAYER(player_) \
891   TOKEN_UINT32_PACK1(INPUT_TOKEN_PLAYER1 + (((player_) - 1) % MAX_PLAYERS), 8),
876#define PORT_PLAYER(_player) \
877   curfield->player = (_player) - 1;
892878
893879#define PORT_COCKTAIL \
894   TOKEN_UINT32_PACK1(INPUT_TOKEN_COCKTAIL, 8),
880   curfield->flags |= FIELD_FLAG_COCKTAIL; \
881   curfield->player = 1;
895882
896883#define PORT_TOGGLE \
897   TOKEN_UINT32_PACK1(INPUT_TOKEN_TOGGLE, 8),
884   curfield->flags |= FIELD_FLAG_TOGGLE;
898885
899886#define PORT_IMPULSE(_duration) \
900   TOKEN_UINT32_PACK2(INPUT_TOKEN_IMPULSE, 8, _duration, 24),
887   curfield->impulse = _duration;
901888
902889#define PORT_REVERSE \
903   TOKEN_UINT32_PACK1(INPUT_TOKEN_REVERSE, 8),
890   curfield->flags |= ANALOG_FLAG_REVERSE;
904891
905892#define PORT_RESET \
906   TOKEN_UINT32_PACK1(INPUT_TOKEN_RESET, 8),
893   curfield->flags |= ANALOG_FLAG_RESET;
907894
908895#define PORT_UNUSED \
909   TOKEN_UINT32_PACK1(INPUT_TOKEN_UNUSED, 8),
896   curfield->flags |= FIELD_FLAG_UNUSED;
910897
911898/* analog settings */
912899/* if this macro is not used, the minimum defaluts to 0 and maximum defaults to the mask value */
913900#define PORT_MINMAX(_min, _max) \
914   TOKEN_UINT32_PACK1(INPUT_TOKEN_MINMAX, 8), \
915   TOKEN_UINT64_PACK2(_min, 32, _max, 32),
901   curfield->min = _min; \
902   curfield->max = _max;
916903
917904#define PORT_SENSITIVITY(_sensitivity) \
918   TOKEN_UINT32_PACK2(INPUT_TOKEN_SENSITIVITY, 8, _sensitivity, 24),
905   curfield->sensitivity = _sensitivity;
919906
920907#define PORT_KEYDELTA(_delta) \
921   TOKEN_UINT32_PACK2(INPUT_TOKEN_KEYDELTA, 8, _delta, 24),
908   curfield->delta = curfield->centerdelta = _delta;
922909
923910/* note that PORT_CENTERDELTA must appear after PORT_KEYDELTA */
924911#define PORT_CENTERDELTA(_delta) \
925   TOKEN_UINT32_PACK2(INPUT_TOKEN_CENTERDELTA, 8, _delta, 24),
912   curfield->delta = curfield->centerdelta = _delta;
926913
927914#define PORT_CROSSHAIR(axis, scale, offset, altaxis) \
928   TOKEN_UINT32_PACK3(INPUT_TOKEN_CROSSHAIR, 8, CROSSHAIR_AXIS_##axis, 4, (INT32)((altaxis) * 65536.0f), 20), \
929   TOKEN_UINT64_PACK2((INT32)((scale) * 65536.0f), 32, (INT32)((offset) * 65536.0f), 32),
915   curfield->crossaxis = CROSSHAIR_AXIS_##axis; \
916   curfield->crossaltaxis = altaxis; \
917   curfield->crossscale = scale; \
918   curfield->crossoffset = offset;
930919
931920#define PORT_CROSSHAIR_MAPPER(_callback) \
932   TOKEN_UINT32_PACK1(INPUT_TOKEN_CROSSHAIR_MAPPER, 8), \
933   TOKEN_PTR(crossmapptr, _callback),
921   curfield->crossmapper = _callback;
934922
935923/* how many optical counts for 1 full turn of the control */
936924#define PORT_FULL_TURN_COUNT(_count) \
937   TOKEN_UINT32_PACK2(INPUT_TOKEN_FULL_TURN_COUNT, 8, _count, 24),
925   curfield->full_turn_count = _count;
938926
939927/* positional controls can be binary or 1 of X */
940928/* 1 of X not completed yet */
941929/* if it is specified as PORT_REMAP_TABLE then it is binary, but remapped */
942930/* otherwise it is binary */
943931#define PORT_POSITIONS(_positions) \
944   TOKEN_UINT32_PACK2(INPUT_TOKEN_POSITIONS, 8, _positions, 24),
932   curfield->max = _positions;
945933
946934/* positional control wraps at min/max */
947935#define PORT_WRAPS \
948   TOKEN_UINT32_PACK1(INPUT_TOKEN_WRAPS, 8),
936   curfield->flags |= ANALOG_FLAG_WRAPS;
949937
950938/* positional control uses this remap table */
951939#define PORT_REMAP_TABLE(_table) \
952   TOKEN_UINT32_PACK1(INPUT_TOKEN_REMAP_TABLE, 8), \
953   TOKEN_PTR(ui32ptr, _table),
940   curfield->remap_table = _table;
954941
955942/* positional control bits are active low */
956943#define PORT_INVERT \
957   TOKEN_UINT32_PACK1(INPUT_TOKEN_INVERT, 8),
944   curfield->flags |= ANALOG_FLAG_INVERT;
958945
959/* custom callbacks */
946/* read callbacks */
960947#define PORT_CUSTOM(_callback, _param) \
961   TOKEN_UINT32_PACK1(INPUT_TOKEN_CUSTOM, 8), \
962   TOKEN_PTR(customptr, _callback), \
963   TOKEN_PTR(voidptr, _param),
948   curfield->read = _callback; \
949   curfield->read_param = (void *)(_param); \
950   curfield->read_device = NULL;
964951
965/* changed callbacks */
952/* write callbacks */
966953#define PORT_CHANGED(_callback, _param) \
967   TOKEN_UINT32_PACK1(INPUT_TOKEN_CHANGED, 8), \
968   TOKEN_PTR(changedptr, _callback), \
969   TOKEN_PTR(voidptr, _param),
954   curfield->write = _callback; \
955   curfield->write_param = (void *)(_param); \
956   curfield->write_device = NULL;
970957
971958/* input device handler */
972959#define PORT_READ_LINE_DEVICE(_device, _read_line_device) \
973   TOKEN_UINT32_PACK1(INPUT_TOKEN_READ_LINE_DEVICE, 8), \
974   TOKEN_STRING(_device), \
975   TOKEN_PTR(read_line_device, _read_line_device),
960   curfield->read = &ioport_read_line_wrapper<_read_line_device>; \
961   curfield->read_param = NULL; \
962   curfield->read_device = _device;
976963
977964/* output device handler */
978965#define PORT_WRITE_LINE_DEVICE(_device, _write_line_device) \
979   TOKEN_UINT32_PACK1(INPUT_TOKEN_WRITE_LINE_DEVICE, 8), \
980   TOKEN_STRING(_device), \
981   TOKEN_PTR(write_line_device, _write_line_device),
966   curfield->write = &ioport_write_line_wrapper<_write_line_device>; \
967   curfield->write_param = NULL; \
968   curfield->write_device = _device;
982969
983970/* dip switch definition */
984971#define PORT_DIPNAME(_mask, _default, _name) \
985   TOKEN_UINT32_PACK1(INPUT_TOKEN_DIPNAME, 8), \
986   TOKEN_UINT64_PACK2(_mask, 32, _default, 32), \
987   TOKEN_STRING(_name),
972   curfield = ioconfig_alloc_field(*curport, IPT_DIPSWITCH, (_default), (_mask), (_name)); \
973   cursetting = NULL;
988974
989975#define PORT_DIPSETTING(_default, _name) \
990   TOKEN_UINT64_PACK2(INPUT_TOKEN_DIPSETTING, 8, _default, 32), \
991   TOKEN_STRING(_name),
976   cursetting = ioconfig_alloc_setting(*curfield, (_default) & curfield->mask, (_name));
992977
993978/* physical location, of the form: name:[!]sw,[name:][!]sw,... */
994979/* note that these are specified LSB-first */
995980#define PORT_DIPLOCATION(_location) \
996   TOKEN_UINT32_PACK1(INPUT_TOKEN_DIPLOCATION, 8), \
997   TOKEN_STRING(_location),
981   diplocation_list_alloc(*curfield, _location, errorbuf);
998982
999983/* conditionals for dip switch settings */
1000984#define PORT_CONDITION(_tag, _mask, _condition, _value) \
1001   TOKEN_UINT32_PACK2(INPUT_TOKEN_CONDITION, 8, _condition, 24), \
1002   TOKEN_UINT64_PACK2(_mask, 32, _value, 32), \
1003   TOKEN_STRING(_tag),
985{ \
986   input_condition &condition = (cursetting != NULL) ? cursetting->condition : curfield->condition; \
987   condition.tag = (_tag); \
988   condition.mask = (_mask); \
989   condition.condition = (_condition); \
990   condition.value = (_value); \
991}
1004992
1005993/* analog adjuster definition */
1006994#define PORT_ADJUSTER(_default, _name) \
1007   TOKEN_UINT64_PACK2(INPUT_TOKEN_ADJUSTER, 8, _default, 32), \
1008   TOKEN_STRING(_name),
995   curfield = ioconfig_alloc_field(*curport, IPT_ADJUSTER, (_default), 0xff, (_name)); \
996   cursetting = NULL; \
1009997
1010998/* config definition */
1011999#define PORT_CONFNAME(_mask, _default, _name) \
1012   TOKEN_UINT32_PACK1(INPUT_TOKEN_CONFNAME, 8), \
1013   TOKEN_UINT64_PACK2(_mask, 32, _default, 32), \
1014   TOKEN_STRING(_name),
1000   curfield = ioconfig_alloc_field(*curport, IPT_CONFIG, (_default), (_mask), (_name)); \
1001   cursetting = NULL; \
10151002
10161003#define PORT_CONFSETTING(_default, _name) \
1017   TOKEN_UINT64_PACK2(INPUT_TOKEN_CONFSETTING, 8, _default, 32), \
1018   TOKEN_STRING(_name),
1004   cursetting = ioconfig_alloc_setting(*curfield, (_default) & curfield->mask, (_name));
10191005
10201006/* keyboard chars */
10211007#define PORT_CHAR(_ch) \
1022   TOKEN_UINT64_PACK2(INPUT_TOKEN_CHAR, 8, _ch, 32), \
1008   ioconfig_field_add_char(*curfield, _ch, errorbuf);
10231009
10241010/* categories */
10251011#define PORT_CATEGORY(_category) \
1026   TOKEN_UINT32_PACK2(INPUT_TOKEN_CATEGORY, 8, _category, 24),
1012   curfield->category = (_category);
10271013
10281014#define PORT_CATEGORY_CLASS(_mask, _default, _name) \
1029   TOKEN_UINT32_PACK1(INPUT_TOKEN_CATEGORY_NAME, 8), \
1030   TOKEN_UINT64_PACK2(_mask, 32, _default, 32), \
1031   TOKEN_STRING(_name),
1015   curfield = ioconfig_alloc_field(*curport, IPT_CATEGORY, (_default), (_mask), (_name)); \
1016   cursetting = NULL;
10321017
10331018#define PORT_CATEGORY_ITEM(_default, _name, _category) \
1034   TOKEN_UINT64_PACK3(INPUT_TOKEN_CATEGORY_SETTING, 8, _default, 32, _category, 16), \
1035   TOKEN_STRING(_name),
1019   cursetting = ioconfig_alloc_setting(*curfield, (_default) & curfield->mask, (_name)); \
1020   cursetting->category = (_category);
10361021
10371022
10381023/* name of table */
r11508r11509
10851070/* ----- core system management ----- */
10861071
10871072/* initialize the input ports, processing the given token list */
1088time_t input_port_init(running_machine &machine, const device_list &devicelist);
1073time_t input_port_init(running_machine &machine);
10891074
10901075
10911076
10921077/* ----- port configurations ----- */
10931078
10941079/* initialize an input port list structure and allocate ports according to the given tokens */
1095void input_port_list_init(ioport_list &portlist, const input_port_token *tokens, char *errorbuf, int errorbuflen, int allocmap, device_t *owner);
1080void input_port_list_init(device_t &device, ioport_list &portlist, astring &errorbuf);
10961081
10971082/* return the field that matches the given tag and mask */
10981083const input_field_config *input_field_by_tag_and_mask(const ioport_list &portlist, const char *tag, input_port_value mask);
r11508r11509
12071192int input_condition_true(running_machine &machine, const input_condition *condition);
12081193
12091194/* convert an input_port_token to a default string */
1210const char *input_port_string_from_token(const input_port_token token);
1195const char *input_port_string_from_token(const char *token);
12111196
12121197/* return TRUE if machine use full keyboard emulation */
12131198int input_machine_has_keyboard(running_machine &machine);
r11508r11509
12401225int input_count_players(running_machine &machine);
12411226int input_category_active(running_machine &machine, int category);
12421227
1228
1229inline running_machine &input_field_config::machine() const
1230{
1231   return m_port.machine();
1232}
1233
1234
1235// temporary construction helpers
1236void field_config_insert(input_field_config &newfield, input_port_value &disallowedbits, astring &errorbuf);
1237void diplocation_list_alloc(input_field_config &field, const char *location, astring &errorbuf);
1238
1239
1240input_port_config *ioconfig_alloc_port(ioport_list &portlist, device_t &device, const char *tag);
1241input_port_config *ioconfig_modify_port(ioport_list &portlist, device_t &device, const char *tag);
1242input_field_config *ioconfig_alloc_field(input_port_config &port, int type, input_port_value defval, input_port_value mask, const char *name = NULL);
1243input_field_config *ioconfig_alloc_onoff(input_port_config &port, const char *name, input_port_value defval, input_port_value mask, const char *diplocation, astring &errorbuf);
1244input_setting_config *ioconfig_alloc_setting(input_field_config &field, input_port_value value, const char *name);
1245void ioconfig_field_add_char(input_field_config &field, unicode_char ch, astring &errorbuf);
1246void ioconfig_add_code(input_field_config &field, int which, input_code code);
1247
12431248#endif   /* __INPTPORT_H__ */
src/emu/devintrf.h
r11508r11509
9393struct rom_entry;
9494class machine_config;
9595class emu_timer;
96typedef union _input_port_token input_port_token;
9796typedef struct _input_device_default input_device_default;
9897
9998
r11508r11509
207206   const input_device_default *input_ports_defaults() const { return m_input_defaults; }
208207   const rom_entry *rom_region() const { return device_rom_region(); }
209208   machine_config_constructor machine_config_additions() const { return device_mconfig_additions(); }
210   const input_port_token *input_ports() const { return device_input_ports(); }
209   ioport_constructor input_ports() const { return device_input_ports(); }
211210
212211   // iteration helpers
213212   device_t *next() const { return m_next; }
r11508r11509
296295   // device-level overrides
297296   virtual const rom_entry *device_rom_region() const;
298297   virtual machine_config_constructor device_mconfig_additions() const;
299   virtual const input_port_token *device_input_ports() const;
298   virtual ioport_constructor device_input_ports() const;
300299   virtual void device_config_complete();
301300   virtual bool device_validity_check(emu_options &options, const game_driver &driver) const;
302301   virtual void device_start() = 0;
src/emu/emu.h
r11508r11509
6464#include "attotime.h"
6565#include "hash.h"
6666#include "fileio.h" // remove me once NVRAM is implemented as device
67#include "tokenize.h"
6867#include "delegate.h"
6968
7069// memory and address spaces
r11508r11509
8079class machine_config;
8180typedef device_t * (*machine_config_constructor)(machine_config &config, device_t *owner);
8281
82// I/O
83#include "input.h"
84#include "inputseq.h"
85#include "inptport.h"
86#include "output.h"
87
8388// devices and callbacks
8489#include "devintrf.h"
8590#include "distate.h"
r11508r11509
95100#include "schedule.h"
96101#include "timer.h"
97102
98// I/O
99#include "input.h"
100#include "inputseq.h"
101#include "inptport.h"
102#include "output.h"
103
104103// timers, CPU and scheduling
105104#include "devcpu.h"
106105#include "watchdog.h"
src/emu/machine.c
r11508r11509
279279   // initialize the input system and input ports for the game
280280   // this must be done before memory_init in order to allow specifying
281281   // callbacks based on input port tags
282   time_t newbase = input_port_init(*this, devicelist());
282   time_t newbase = input_port_init(*this);
283283   if (newbase != 0)
284284      m_base_time = newbase;
285285
r11508r11509
11451145//  game's input ports
11461146//-------------------------------------------------
11471147
1148const input_port_token *driver_device::device_input_ports() const
1148ioport_constructor driver_device::device_input_ports() const
11491149{
11501150   return m_system->ipt;
11511151}
src/emu/machine.h
r11508r11509
576576
577577   // device-level overrides
578578   virtual const rom_entry *device_rom_region() const;
579   virtual const input_port_token *device_input_ports() const;
579   virtual ioport_constructor device_input_ports() const;
580580   virtual void device_start();
581581   virtual void device_reset();
582582
src/emu/ui.c
r11508r11509
15951595
15961596static slider_state *slider_init(running_machine &machine)
15971597{
1598   const input_field_config *field;
1599   const input_port_config *port;
1598   input_field_config *field;
1599   input_port_config *port;
16001600   device_t *device;
16011601   slider_state *listhead = NULL;
16021602   slider_state **tailptr = &listhead;
r11508r11509
16251625
16261626   /* add analog adjusters */
16271627   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
1628      for (field = port->fieldlist; field != NULL; field = field->next)
1628      for (field = port->fieldlist().first(); field != NULL; field = field->next())
16291629         if (field->type == IPT_ADJUSTER)
16301630         {
16311631            void *param = (void *)field;
r11508r11509
17301730#ifdef MAME_DEBUG
17311731   /* add crosshair adjusters */
17321732   for (port = machine.m_portlist.first(); port != NULL; port = port->next())
1733      for (field = port->fieldlist; field != NULL; field = field->next)
1733      for (field = port->fieldlist().first(); field != NULL; field = field->next())
17341734         if (field->crossaxis != CROSSHAIR_AXIS_NONE && field->player == 0)
17351735         {
17361736            void *param = (void *)field;
src/emu/crsshair.c
r11508r11509
220220   global.auto_time = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT;
221221
222222   /* determine who needs crosshairs */
223   for (const input_port_config *port = machine.m_portlist.first(); port != NULL; port = port->next())
224      for (const input_field_config *field = port->fieldlist; field != NULL; field = field->next)
223   for (input_port_config *port = machine.m_portlist.first(); port != NULL; port = port->next())
224      for (input_field_config *field = port->fieldlist().first(); field != NULL; field = field->next())
225225         if (field->crossaxis != CROSSHAIR_AXIS_NONE)
226226         {
227227            int player = field->player;
src/emu/emutempl.h
r11508r11509
141141         return prepend(object);
142142      object.m_next = insert_after->m_next;
143143      insert_after->m_next = &object;
144      if (m_tail == insert_after)
145         m_tail = &object;
144146      m_count++;
145147      return object;
146148   }
147149
150   // insert the given object before a particular object (NULL means append)
151   _ElementType &insert_before(_ElementType &object, _ElementType *insert_before)
152   {
153      if (insert_before == NULL)
154         return append(object);
155      for (_ElementType **curptr = &m_head; *curptr != NULL; curptr = &(*curptr)->m_next)
156         if (*curptr == insert_before)
157         {
158            object.m_next = insert_before;
159            *curptr = &object;
160            if (m_head == insert_before)
161               m_head = &object;
162            m_count++;
163            return object;
164         }
165      return object;
166   }
167
148168   // replace an item in the list at the same location, and remove it
149169   _ElementType &replace_and_remove(_ElementType &object, _ElementType &toreplace)
150170   {
src/emu/devlegcy.h
r11508r11509
390390   device_nvram_func      nvram;                  // DEVINFO_FCT_NVRAM
391391   const rom_entry *      romregion;               // DEVINFO_PTR_ROM_REGION
392392   machine_config_constructor machine_config;         // DEVINFO_PTR_MACHINE_CONFIG
393   const input_port_token *ipt;                  // DEVINFO_PTR_INPUT_PORTS
393   ioport_constructor ipt;                        // DEVINFO_PTR_INPUT_PORTS
394394   address_map_constructor   internal_map8;            // DEVINFO_PTR_INTERNAL_MEMORY_MAP
395395   address_map_constructor   internal_map16;            // DEVINFO_PTR_INTERNAL_MEMORY_MAP
396396   address_map_constructor   internal_map32;            // DEVINFO_PTR_INTERNAL_MEMORY_MAP
r11508r11509
428428   // device-level overrides
429429   virtual const rom_entry *device_rom_region() const { return reinterpret_cast<const rom_entry *>(get_legacy_ptr(DEVINFO_PTR_ROM_REGION)); }
430430   virtual machine_config_constructor device_mconfig_additions() const { return reinterpret_cast<machine_config_constructor>(get_legacy_ptr(DEVINFO_PTR_MACHINE_CONFIG)); }
431   virtual const input_port_token *device_input_ports() const { return reinterpret_cast<const input_port_token *>(get_legacy_ptr(DEVINFO_PTR_INPUT_PORTS)); }
431   virtual ioport_constructor device_input_ports() const { return reinterpret_cast<ioport_constructor>(get_legacy_ptr(DEVINFO_PTR_INPUT_PORTS)); }
432432   virtual bool device_validity_check(emu_options &options, const game_driver &driver) const;
433433   virtual void device_start();
434434   virtual void device_reset();
src/emu/validity.c
r11508r11509
7575
7676INLINE const char *input_port_string_from_index(UINT32 index)
7777{
78   input_port_token token;
79   token.i = index;
80   return input_port_string_from_token(token);
78   return input_port_string_from_token((const char *)index);
8179}
8280
8381
r11508r11509
741739    analog input field
742740-------------------------------------------------*/
743741
744static void validate_analog_input_field(const input_field_config *field, const game_driver &driver, bool *error)
742static void validate_analog_input_field(input_field_config *field, const game_driver &driver, bool *error)
745743{
746744   INT32 analog_max = field->max;
747745   INT32 analog_min = field->min;
r11508r11509
850848    setting
851849-------------------------------------------------*/
852850
853static void validate_dip_settings(const input_field_config *field, const game_driver &driver, int_map &defstr_map, bool *error)
851static void validate_dip_settings(input_field_config *field, const game_driver &driver, int_map &defstr_map, bool *error)
854852{
855853   const char *demo_sounds = input_port_string_from_index(INPUT_STRING_Demo_Sounds);
856854   const char *flipscreen = input_port_string_from_index(INPUT_STRING_Flip_Screen);
r11508r11509
859857   int coin_error = FALSE;
860858
861859   /* iterate through the settings */
862   for (setting = field->settinglist; setting != NULL; setting = setting->next)
860   for (setting = field->settinglist().first(); setting != NULL; setting = setting->next())
863861   {
864862      int strindex = get_defstr_index(defstr_map, setting->name, driver, error);
865863
r11508r11509
889887      }
890888
891889      /* if we have a neighbor, compare ourselves to him */
892      if (setting->next != NULL)
890      if (setting->next() != NULL)
893891      {
894         int next_strindex = get_defstr_index(defstr_map, setting->next->name, driver, error);
892         int next_strindex = get_defstr_index(defstr_map, setting->next()->name, driver, error);
895893
896894         /* check for inverted off/on dispswitch order */
897895         if (strindex == INPUT_STRING_On && next_strindex == INPUT_STRING_Off)
r11508r11509
916914
917915         /* check for proper coin ordering */
918916         else if (strindex >= INPUT_STRING_9C_1C && strindex <= INPUT_STRING_1C_9C && next_strindex >= INPUT_STRING_9C_1C && next_strindex <= INPUT_STRING_1C_9C &&
919                strindex >= next_strindex && memcmp(&setting->condition, &setting->next->condition, sizeof(setting->condition)) == 0)
917                strindex >= next_strindex && memcmp(&setting->condition, &setting->next()->condition, sizeof(setting->condition)) == 0)
920918         {
921            mame_printf_error("%s: %s has unsorted coinage %s > %s\n", driver.source_file, driver.name, setting->name, setting->next->name);
919            mame_printf_error("%s: %s has unsorted coinage %s > %s\n", driver.source_file, driver.name, setting->name, setting->next()->name);
922920            coin_error = *error = true;
923921         }
924922      }
r11508r11509
943941
944942static bool validate_inputs(driver_enumerator &drivlist, int_map &defstr_map, ioport_list &portlist)
945943{
946   const input_port_config *scanport;
947   const input_port_config *port;
948   const input_field_config *field;
944   input_port_config *scanport;
945   input_port_config *port;
946   input_field_config *field;
949947   const game_driver &driver = drivlist.driver();
950948   const machine_config &config = drivlist.config();
951949   int empty_string_found = FALSE;
952   char errorbuf[1024];
953950   bool error = false;
951   astring errorbuf;
954952
955953   /* skip if no ports */
956954   if (driver.ipt == NULL)
r11508r11509
958956
959957   /* allocate the input ports */
960958   for (device_t *cfg = config.devicelist().first(); cfg != NULL; cfg = cfg->next())
961      if (cfg->input_ports() != NULL)
959   {
960      input_port_list_init(*cfg, portlist, errorbuf);
961      if (errorbuf)
962962      {
963         input_port_list_init(portlist, cfg->input_ports(), errorbuf, sizeof(errorbuf), FALSE, cfg);
964         if (errorbuf[0] != 0)
965         {
966            mame_printf_error("%s: %s has input port errors:\n%s\n", driver.source_file, driver.name, errorbuf);
967            error = true;
968         }
963         mame_printf_error("%s: %s has input port errors:\n%s\n", driver.source_file, driver.name, errorbuf.cstr());
964         error = true;
969965      }
966   }
970967
971968   /* check for duplicate tags */
972969   for (port = portlist.first(); port != NULL; port = port->next())
973      if (port->tag != NULL)
974         for (scanport = port->next(); scanport != NULL; scanport = scanport->next())
975            if (scanport->tag != NULL && strcmp(port->tag, scanport->tag) == 0)
976            {
977               mame_printf_error("%s: %s has a duplicate input port tag '%s'\n", driver.source_file, driver.name, port->tag);
978               error = true;
979            }
970      for (scanport = port->next(); scanport != NULL; scanport = scanport->next())
971         if (strcmp(port->tag(), scanport->tag()) == 0)
972         {
973            mame_printf_error("%s: %s has a duplicate input port tag '%s'\n", driver.source_file, driver.name, port->tag());
974            error = true;
975         }
980976
981977   /* iterate over the results */
982978   for (port = portlist.first(); port != NULL; port = port->next())
983      for (field = port->fieldlist; field != NULL; field = field->next)
979      for (field = port->fieldlist().first(); field != NULL; field = field->next())
984980      {
985         const input_setting_config *setting;
981         input_setting_config *setting;
986982         //int strindex = 0;
987983
988984         /* verify analog inputs */
r11508r11509
10431039         {
10441040            /* find a matching port */
10451041            for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next())
1046               if (scanport->tag != NULL && strcmp(field->condition.tag, scanport->tag) == 0)
1042               if (strcmp(field->condition.tag, scanport->tag()) == 0)
10471043                  break;
10481044
10491045            /* if none, error */
r11508r11509
10551051         }
10561052
10571053         /* verify conditions on the settings */
1058         for (setting = field->settinglist; setting != NULL; setting = setting->next)
1054         for (setting = field->settinglist().first(); setting != NULL; setting = setting->next())
10591055            if (setting->condition.tag != NULL)
10601056            {
10611057               /* find a matching port */
10621058               for (scanport = portlist.first(); scanport != NULL; scanport = scanport->next())
1063                  if (scanport->tag != NULL && strcmp(setting->condition.tag, scanport->tag) == 0)
1059                  if (strcmp(setting->condition.tag, scanport->tag()) == 0)
10641060                     break;
10651061
10661062               /* if none, error */
src/emu/devcpu.h
r11508r11509
368368   // device-level overrides
369369   virtual const rom_entry *device_rom_region() const { return reinterpret_cast<const rom_entry *>(get_legacy_ptr(DEVINFO_PTR_ROM_REGION)); }
370370   virtual machine_config_constructor device_mconfig_additions() const { return reinterpret_cast<machine_config_constructor>(get_legacy_ptr(DEVINFO_PTR_MACHINE_CONFIG)); }
371   virtual const input_port_token *device_input_ports() const { return reinterpret_cast<const input_port_token *>(get_legacy_ptr(DEVINFO_PTR_INPUT_PORTS)); }
371   virtual ioport_constructor device_input_ports() const { return reinterpret_cast<ioport_constructor>(get_legacy_ptr(DEVINFO_PTR_INPUT_PORTS)); }
372372   virtual void device_start();
373373   virtual void device_reset();
374374   virtual void device_stop();
src/emu/info.c
r11508r11509
248248   // allocate input ports
249249   machine_config &config = m_drivlist.config();
250250   ioport_list portlist;
251   astring errors;
251252   for (device_t *device = config.devicelist().first(); device != NULL; device = device->next())
252      if (device->input_ports() != NULL)
253         input_port_list_init(portlist, device->input_ports(), NULL, 0, FALSE, device);
253      input_port_list_init(*device, portlist, errors);
254254
255255   // print the header and the game name
256256   fprintf(m_output, "\t<" XML_TOP);
r11508r11509
693693   bool keyboard = false;
694694
695695   // iterate over the ports
696   for (const input_port_config *port = portlist.first(); port != NULL; port = port->next())
697      for (const input_field_config *field = port->fieldlist; field != NULL; field = field->next)
696   for (input_port_config *port = portlist.first(); port != NULL; port = port->next())
697      for (input_field_config *field = port->fieldlist().first(); field != NULL; field = field->next())
698698      {
699699         int analogtype = -1;
700700
r11508r11509
889889void info_xml_creator::output_switches(const ioport_list &portlist, int type, const char *outertag, const char *innertag)
890890{
891891   // iterate looking for DIP switches
892   for (const input_port_config *port = portlist.first(); port != NULL; port = port->next())
893      for (const input_field_config *field = port->fieldlist; field != NULL; field = field->next)
892   for (input_port_config *port = portlist.first(); port != NULL; port = port->next())
893      for (input_field_config *field = port->fieldlist().first(); field != NULL; field = field->next())
894894         if (field->type == type)
895895         {
896896            // output the switch name information
897897            fprintf(m_output, "\t\t<%s name=\"%s\"", outertag, xml_normalize_string(input_field_name(field)));
898            fprintf(m_output, " tag=\"%s\"", xml_normalize_string(field->port->tag));
898            fprintf(m_output, " tag=\"%s\"", xml_normalize_string(field->port().tag()));
899899            fprintf(m_output, " mask=\"%u\"", field->mask);
900900            fprintf(m_output, ">\n");
901901
902902            // loop over settings
903            for (const input_setting_config *setting = field->settinglist; setting != NULL; setting = setting->next)
903            for (input_setting_config *setting = field->settinglist().first(); setting != NULL; setting = setting->next())
904904            {
905905               fprintf(m_output, "\t\t\t<%s name=\"%s\"", innertag, xml_normalize_string(setting->name));
906906               fprintf(m_output, " value=\"%u\"", setting->value);
r11508r11509
923923void info_xml_creator::output_adjusters(const ioport_list &portlist)
924924{
925925   // iterate looking for Adjusters
926   for (const input_port_config *port = portlist.first(); port != NULL; port = port->next())
927      for (const input_field_config *field = port->fieldlist; field != NULL; field = field->next)
926   for (input_port_config *port = portlist.first(); port != NULL; port = port->next())
927      for (input_field_config *field = port->fieldlist().first(); field != NULL; field = field->next())
928928         if (field->type == IPT_ADJUSTER)
929929            fprintf(m_output, "\t\t<adjuster name=\"%s\" default=\"%d\"/>\n", xml_normalize_string(input_field_name(field)), field->defvalue);
930930}
r11508r11509
10021002void info_xml_creator::output_categories(const ioport_list &portlist)
10031003{
10041004   // iterate looking for Categories
1005   for (const input_port_config *port = portlist.first(); port != NULL; port = port->next())
1006      for (const input_field_config *field = port->fieldlist; field != NULL; field = field->next)
1005   for (input_port_config *port = portlist.first(); port != NULL; port = port->next())
1006      for (input_field_config *field = port->fieldlist().first(); field != NULL; field = field->next())
10071007         if (field->type == IPT_CATEGORY)
10081008         {
10091009            // output the category name information
10101010            fprintf(m_output, "\t\t<category name=\"%s\">\n", xml_normalize_string(input_field_name(field)));
10111011
10121012            // loop over item settings
1013            for (const input_setting_config *setting = field->settinglist; setting != NULL; setting = setting->next)
1013            for (input_setting_config *setting = field->settinglist().first(); setting != NULL; setting = setting->next())
10141014            {
10151015               fprintf(m_output, "\t\t\t<item name=\"%s\"", xml_normalize_string(setting->name));
10161016               if (setting->value == field->defvalue)
src/emu/memory.c
r11508r11509
45924592{
45934593   m_ioport = &ioport;
45944594   if (m_datawidth == 8)
4595      set_delegate(read8_delegate(&handler_entry_read::read_stub_ioport<UINT8>, ioport.tag, this));
4595      set_delegate(read8_delegate(&handler_entry_read::read_stub_ioport<UINT8>, ioport.tag(), this));
45964596   else if (m_datawidth == 16)
4597      set_delegate(read16_delegate(&handler_entry_read::read_stub_ioport<UINT16>, ioport.tag, this));
4597      set_delegate(read16_delegate(&handler_entry_read::read_stub_ioport<UINT16>, ioport.tag(), this));
45984598   else if (m_datawidth == 32)
4599      set_delegate(read32_delegate(&handler_entry_read::read_stub_ioport<UINT32>, ioport.tag, this));
4599      set_delegate(read32_delegate(&handler_entry_read::read_stub_ioport<UINT32>, ioport.tag(), this));
46004600   else if (m_datawidth == 64)
4601      set_delegate(read64_delegate(&handler_entry_read::read_stub_ioport<UINT64>, ioport.tag, this));
4601      set_delegate(read64_delegate(&handler_entry_read::read_stub_ioport<UINT64>, ioport.tag(), this));
46024602}
46034603
46044604
r11508r11509
49194919{
49204920   m_ioport = &ioport;
49214921   if (m_datawidth == 8)
4922      set_delegate(write8_delegate(&handler_entry_write::write_stub_ioport<UINT8>, ioport.tag, this));
4922      set_delegate(write8_delegate(&handler_entry_write::write_stub_ioport<UINT8>, ioport.tag(), this));
49234923   else if (m_datawidth == 16)
4924      set_delegate(write16_delegate(&handler_entry_write::write_stub_ioport<UINT16>, ioport.tag, this));
4924      set_delegate(write16_delegate(&handler_entry_write::write_stub_ioport<UINT16>, ioport.tag(), this));
49254925   else if (m_datawidth == 32)
4926      set_delegate(write32_delegate(&handler_entry_write::write_stub_ioport<UINT32>, ioport.tag, this));
4926      set_delegate(write32_delegate(&handler_entry_write::write_stub_ioport<UINT32>, ioport.tag(), this));
49274927   else if (m_datawidth == 64)
4928      set_delegate(write64_delegate(&handler_entry_write::write_stub_ioport<UINT64>, ioport.tag, this));
4928      set_delegate(write64_delegate(&handler_entry_write::write_stub_ioport<UINT64>, ioport.tag(), this));
49294929}
49304930
49314931
src/emu/machine/generic.c
r11508r11509
748748CUSTOM_INPUT( custom_port_read )
749749{
750750   const char *tag = (const char *)param;
751   return input_port_read(field->port->machine(), tag);
751   return input_port_read(field->machine(), tag);
752752}
src/emu/driver.h
r11508r11509
100100   const char *      year;                  /* year the game was released */
101101   const char *      manufacturer;            /* manufacturer of the game */
102102   machine_config_constructor machine_config;      /* machine driver tokens */
103   const input_port_token *ipt;               /* pointer to array of input port tokens */
103   ioport_constructor    ipt;               /* pointer to array of input port tokens */
104104   void            (*driver_init)(running_machine &machine); /* DRIVER_INIT callback */
105105   const rom_entry *   rom;                  /* pointer to list of ROMs for the game */
106106   const char *      compatible_with;
src/mess/machine/comxpl80.c
r11508r11509
160160//  input_ports - device-specific input ports
161161//-------------------------------------------------
162162
163const input_port_token *comxpl80_device::device_input_ports() const
163ioport_constructor comxpl80_device::device_input_ports() const
164164{
165165   return INPUT_PORTS_NAME( comxpl80 );
166166}
src/mess/machine/comxpl80.h
r11508r11509
5252   // optional information overrides
5353   virtual const rom_entry *device_rom_region() const;
5454   virtual machine_config_constructor device_mconfig_additions() const;
55   virtual const input_port_token *device_input_ports() const;
55   virtual ioport_constructor device_input_ports() const;
5656
5757   DECLARE_WRITE8_MEMBER( pa_w );
5858   DECLARE_WRITE8_MEMBER( pb_w );
src/mess/machine/coco.c
r11508r11509
14891489
14901490INPUT_CHANGED( coco_keyboard_changed )
14911491{
1492   coco_state *state = field->port->machine().driver_data<coco_state>();
1493   (*state->update_keyboard)(field->port->machine());
1492   coco_state *state = field->machine().driver_data<coco_state>();
1493   (*state->update_keyboard)(field->machine());
14941494}
14951495
14961496static TIMER_CALLBACK( coco_m_update_keyboard_timerproc )
r11508r11509
29132913
29142914INPUT_CHANGED( coco_joystick_mode_changed )
29152915{
2916   update_lightgun(field->port->machine());
2916   update_lightgun(field->machine());
29172917}
29182918
29192919static TIMER_CALLBACK( update_lightgun_timer_callback )
src/mess/machine/genpc.c
r11508r11509
509509//  input_ports - device-specific input ports
510510//-------------------------------------------------
511511
512const input_port_token *ibm5160_mb_device::device_input_ports() const
512ioport_constructor ibm5160_mb_device::device_input_ports() const
513513{
514514   return INPUT_PORTS_NAME( ibm5160_mb );
515515}
src/mess/machine/cbmipt.c
r11508r11509
10561056   int bit_mask = (FPTR)param;
10571057   UINT8 port = 0;
10581058
1059   if ((input_port_read(field->port->machine(), "CTRLSEL") & 0xf0) == 0x10)
1060      port |= (input_port_read(field->port->machine(), "FAKE0") & bit_mask) ? 1 : 0;
1059   if ((input_port_read(field->machine(), "CTRLSEL") & 0xf0) == 0x10)
1060      port |= (input_port_read(field->machine(), "FAKE0") & bit_mask) ? 1 : 0;
10611061
1062   if ((input_port_read(field->port->machine(), "CTRLSEL") & 0xf0) == 0x00)
1063      port |= (input_port_read(field->port->machine(), "FAKE1") & bit_mask) ? 1 : 0;
1062   if ((input_port_read(field->machine(), "CTRLSEL") & 0xf0) == 0x00)
1063      port |= (input_port_read(field->machine(), "FAKE1") & bit_mask) ? 1 : 0;
10641064
10651065   return port;
10661066}
src/mess/machine/comx35.c
r11508r11509
627627
628628INPUT_CHANGED( comx35_reset )
629629{
630   comx35_state *state = field->port->machine().driver_data<comx35_state>();
630   comx35_state *state = field->machine().driver_data<comx35_state>();
631631
632   if (BIT(input_port_read(field->port->machine(), "RESET"), 0) && BIT(input_port_read(field->port->machine(), "D6"), 7))
632   if (BIT(input_port_read(field->machine(), "RESET"), 0) && BIT(input_port_read(field->machine(), "D6"), 7))
633633   {
634634      state->machine_reset();
635635   }
src/mess/machine/z80ne.c
r11508r11509
376376INPUT_CHANGED( z80ne_reset )
377377{
378378   UINT8 rst;
379   rst = input_port_read(field->port->machine(), "RST");
379   rst = input_port_read(field->machine(), "RST");
380380
381381   if ( ! BIT(rst, 0))
382382   {
383      running_machine &machine = field->port->machine();
383      running_machine &machine = field->machine();
384384      machine.schedule_soft_reset();
385385   }
386386}
r11508r11509
388388INPUT_CHANGED( z80ne_nmi )
389389{
390390   UINT8 nmi;
391   nmi = input_port_read(field->port->machine(), "LX388_BRK");
391   nmi = input_port_read(field->machine(), "LX388_BRK");
392392
393393   if ( ! BIT(nmi, 0))
394394   {
395      cputag_set_input_line(field->port->machine(), "z80ne", INPUT_LINE_NMI, PULSE_LINE);
395      cputag_set_input_line(field->machine(), "z80ne", INPUT_LINE_NMI, PULSE_LINE);
396396   }
397397}
398398
src/mess/machine/abc99.c
r11508r11509
240240
241241INPUT_CHANGED( abc99_device::keyboard_reset )
242242{
243    abc99_device *keyboard = static_cast<abc99_device *>(field->port->machine().device(ABC99_TAG));
243    abc99_device *keyboard = static_cast<abc99_device *>(field->machine().device(ABC99_TAG));
244244
245245   device_set_input_line(keyboard->m_mousecpu, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
246246}
r11508r11509
445445//  input_ports - device-specific input ports
446446//-------------------------------------------------
447447
448const input_port_token *abc99_device::device_input_ports() const
448ioport_constructor abc99_device::device_input_ports() const
449449{
450450   return INPUT_PORTS_NAME( abc99 );
451451}
src/mess/machine/abc99.h
r11508r11509
5454   // optional information overrides
5555   virtual const rom_entry *device_rom_region() const;
5656   virtual machine_config_constructor device_mconfig_additions() const;
57   virtual const input_port_token *device_input_ports() const;
57   virtual ioport_constructor device_input_ports() const;
5858
5959   static INPUT_CHANGED( keyboard_reset );
6060
src/mess/machine/lux21046.c
r11508r11509
371371//  input_ports - device-specific input ports
372372//-------------------------------------------------
373373
374const input_port_token *luxor_55_21046_device::device_input_ports() const
374ioport_constructor luxor_55_21046_device::device_input_ports() const
375375{
376376   return INPUT_PORTS_NAME( luxor_55_21046 );
377377}
src/mess/machine/lux21046.h
r11508r11509
8181   // optional information overrides
8282   virtual const rom_entry *device_rom_region() const;
8383   virtual machine_config_constructor device_mconfig_additions() const;
84   virtual const input_port_token *device_input_ports() const;
84   virtual ioport_constructor device_input_ports() const;
8585
8686   DECLARE_READ8_MEMBER( _3d_r );
8787   DECLARE_WRITE8_MEMBER( _4d_w );
src/mess/machine/lux10828.c
r11508r11509
411411//  input_ports - device-specific input ports
412412//-------------------------------------------------
413413
414const input_port_token *luxor_55_10828_device::device_input_ports() const
414ioport_constructor luxor_55_10828_device::device_input_ports() const
415415{
416416   return INPUT_PORTS_NAME( luxor_55_10828 );
417417}
src/mess/machine/lux10828.h
r11508r11509
9696   // optional information overrides
9797   virtual const rom_entry *device_rom_region() const;
9898   virtual machine_config_constructor device_mconfig_additions() const;
99   virtual const input_port_token *device_input_ports() const;
99   virtual ioport_constructor device_input_ports() const;
100100
101101protected:
102102    // device-level overrides
src/mess/machine/abc77.c
r11508r11509
181181
182182INPUT_CHANGED( abc77_device::keyboard_reset )
183183{
184    abc77_device *keyboard = static_cast<abc77_device *>(field->port->machine().device(ABC77_TAG));
184    abc77_device *keyboard = static_cast<abc77_device *>(field->machine().device(ABC77_TAG));
185185
186186   if (oldval && !newval)
187187   {
r11508r11509
341341//  input_ports - device-specific input ports
342342//-------------------------------------------------
343343
344const input_port_token *abc77_device::device_input_ports() const
344ioport_constructor abc77_device::device_input_ports() const
345345{
346346   return INPUT_PORTS_NAME( abc77 );
347347}
src/mess/machine/abc77.h
r11508r11509
6161   // optional information overrides
6262   virtual const rom_entry *device_rom_region() const;
6363   virtual machine_config_constructor device_mconfig_additions() const;
64   virtual const input_port_token *device_input_ports() const;
64   virtual ioport_constructor device_input_ports() const;
6565
6666   static INPUT_CHANGED( keyboard_reset );
6767
src/mess/includes/genpc.h
r11508r11509
3737
3838   // optional information overrides
3939   virtual machine_config_constructor device_mconfig_additions() const;
40   virtual const input_port_token *device_input_ports() const;
40   virtual ioport_constructor device_input_ports() const;
4141protected:
4242   // device-level overrides
4343   virtual void device_start();
src/mess/drivers/vip.c
r11508r11509
303303
304304static INPUT_CHANGED( reset_w )
305305{
306   vip_state *state = field->port->machine().driver_data<vip_state>();
306   vip_state *state = field->machine().driver_data<vip_state>();
307307
308308   if (oldval && !newval)
309309   {
src/mess/drivers/elf.c
r11508r11509
8787
8888static INPUT_CHANGED( input_w )
8989{
90   elf2_state *state = field->port->machine().driver_data<elf2_state>();
90   elf2_state *state = field->machine().driver_data<elf2_state>();
9191
9292   if (newval)
9393   {
src/mess/drivers/pc9801.c
r11508r11509
15471547/* TODO: key repeat, remove port impulse! */
15481548static INPUT_CHANGED( key_stroke )
15491549{
1550   pc9801_state *state = field->port->machine().driver_data<pc9801_state>();
1550   pc9801_state *state = field->machine().driver_data<pc9801_state>();
15511551
15521552   if(newval && !oldval)
15531553   {
15541554      state->m_keyb_press = (UINT8)(FPTR)(param) & 0x7f;
1555      pic8259_ir1_w(field->port->machine().device("pic8259_master"), 1);
1555      pic8259_ir1_w(field->machine().device("pic8259_master"), 1);
15561556   }
15571557
15581558   if(oldval && !newval)
r11508r11509
15621562/* for key modifiers */
15631563static INPUT_CHANGED( shift_stroke )
15641564{
1565   pc9801_state *state = field->port->machine().driver_data<pc9801_state>();
1565   pc9801_state *state = field->machine().driver_data<pc9801_state>();
15661566
15671567   if((newval && !oldval) || (oldval && !newval))
15681568   {
15691569      state->m_keyb_press = (UINT8)(FPTR)(param) & 0x7f;
1570      pic8259_ir1_w(field->port->machine().device("pic8259_master"), 1);
1570      pic8259_ir1_w(field->machine().device("pic8259_master"), 1);
15711571   }
15721572   else
15731573      state->m_keyb_press = 0;
15741574}
15751575
1576static READ_LINE_DEVICE_HANDLER( upd1990a_data_out_r )
1576READ_LINE_DEVICE_HANDLER( upd1990a_data_out_pc9801_r )
15771577{
15781578   pc9801_state *state = device->machine().driver_data<pc9801_state>();
15791579
r11508r11509
17421742   PORT_BIT(0x80,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME(" un 7-8") PORT_IMPULSE(1) PORT_CHANGED(key_stroke, 0x7f) //PORT_CODE(KEYCODE_M) PORT_CHAR('M')
17431743
17441744   PORT_START("DSW1")
1745   PORT_BIT(0x0001, IP_ACTIVE_HIGH,IPT_SPECIAL) PORT_READ_LINE_DEVICE("upd1990a", upd1990a_data_out_r)
1745   PORT_BIT(0x0001, IP_ACTIVE_HIGH,IPT_SPECIAL) PORT_READ_LINE_DEVICE("upd1990a", upd1990a_data_out_pc9801_r)
17461746   PORT_DIPNAME( 0x0002, 0x0000, "DSW1" ) // error beep if OFF
17471747   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
17481748   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
src/mess/drivers/nakajies.c
r11508r11509
310310
311311static INPUT_CHANGED( trigger_irq )
312312{
313   nakajies_state *state = field->port->machine().driver_data<nakajies_state>();
314   UINT8 irqs = input_port_read( field->port->machine(), "debug" );
313   nakajies_state *state = field->machine().driver_data<nakajies_state>();
314   UINT8 irqs = input_port_read( field->machine(), "debug" );
315315
316316   state->m_irq_active |= irqs;
317   nakajies_update_irqs(field->port->machine());
317   nakajies_update_irqs(field->machine());
318318}
319319
320320
src/mess/drivers/x1.c
r11508r11509
20072007
20082008static INPUT_CHANGED( ipl_reset )
20092009{
2010   //address_space *space = field->port->machine().device("maincpu")->memory().space(AS_PROGRAM);
2011   x1_state *state = field->port->machine().driver_data<x1_state>();
2010   //address_space *space = field->machine().device("maincpu")->memory().space(AS_PROGRAM);
2011   x1_state *state = field->machine().driver_data<x1_state>();
20122012
2013   cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
2013   cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
20142014
20152015   state->m_ram_bank = 0x00;
20162016   if(state->m_is_turbo) { state->m_ex_bank = 0x10; }
r11508r11509
20202020/* Apparently most games doesn't support this (not even the Konami ones!), one that does is...177 :o */
20212021static INPUT_CHANGED( nmi_reset )
20222022{
2023   cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
2023   cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
20242024}
20252025
20262026static INPUT_PORTS_START( x1 )
src/mess/drivers/palm.c
r11508r11509
3636
3737static INPUT_CHANGED( pen_check )
3838{
39    UINT8 button = input_port_read(field->port->machine(), "PENB");
40    device_t *mc68328_device = field->port->machine().device("dragonball");
39    UINT8 button = input_port_read(field->machine(), "PENB");
40    device_t *mc68328_device = field->machine().device("dragonball");
4141    if(button)
4242    {
4343        mc68328_set_penirq_line(mc68328_device, 1);
r11508r11509
5050
5151static INPUT_CHANGED( button_check )
5252{
53    UINT8 button_state = input_port_read(field->port->machine(), "PORTD");
54    device_t *mc68328_device = field->port->machine().device("dragonball");
53    UINT8 button_state = input_port_read(field->machine(), "PORTD");
54    device_t *mc68328_device = field->machine().device("dragonball");
5555
5656    mc68328_set_port_d_lines(mc68328_device, button_state, (int)(FPTR)param);
5757}
src/mess/drivers/kim1.c
r11508r11509
118118static INPUT_CHANGED( kim1_reset )
119119{
120120   if (newval == 0)
121      field->port->machine().firstcpu->reset();
121      field->machine().firstcpu->reset();
122122}
123123
124124
src/mess/drivers/abc80.c
r11508r11509
399399//  vco_voltage_w - CSG VCO voltage select
400400//-------------------------------------------------
401401
402static WRITE_LINE_DEVICE_HANDLER( vco_voltage_w )
402WRITE_LINE_DEVICE_HANDLER( vco_voltage_w )
403403{
404404   sn76477_vco_voltage_w(device, state ? 2.5 : 0);
405405}
406406
407WRITE_LINE_DEVICE_HANDLER(port_sn76477_enable_w)
408{
409   sn76477_enable_w(device,state);
410}
407411
412WRITE_LINE_DEVICE_HANDLER(port_sn76477_vco_w)
413{
414   sn76477_vco_w(device,state);
415}
408416
417WRITE_LINE_DEVICE_HANDLER(port_sn76477_mixer_b_w)
418{
419   sn76477_mixer_b_w(device,state);
420}
421
422WRITE_LINE_DEVICE_HANDLER(port_sn76477_mixer_a_w)
423{
424   sn76477_mixer_a_w(device,state);
425}
426
427WRITE_LINE_DEVICE_HANDLER(port_sn76477_mixer_c_w)
428{
429   sn76477_mixer_c_w(device,state);
430}
431
432WRITE_LINE_DEVICE_HANDLER(port_sn76477_envelope_2_w)
433{
434   sn76477_envelope_2_w(device,state);
435}
436
437WRITE_LINE_DEVICE_HANDLER(port_sn76477_envelope_1_w)
438{
439   sn76477_envelope_1_w(device,state);
440}
441   
409442//**************************************************************************
410443//  ADDRESS MAPS
411444//**************************************************************************
r11508r11509
458491   PORT_INCLUDE(fake_keyboard)
459492
460493   PORT_START("SN76477")
461   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(SN76477_TAG, sn76477_enable_w)
494   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(SN76477_TAG, port_sn76477_enable_w)
462495   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(SN76477_TAG, vco_voltage_w)
463   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(SN76477_TAG, sn76477_vco_w)
464   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(SN76477_TAG, sn76477_mixer_b_w)
465   PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(SN76477_TAG, sn76477_mixer_a_w)
466   PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(SN76477_TAG, sn76477_mixer_c_w)
467   PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(SN76477_TAG, sn76477_envelope_2_w)
468   PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(SN76477_TAG, sn76477_envelope_1_w)
496   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(SN76477_TAG, port_sn76477_vco_w)
497   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(SN76477_TAG, port_sn76477_mixer_b_w)
498   PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(SN76477_TAG, port_sn76477_mixer_a_w)
499   PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(SN76477_TAG, port_sn76477_mixer_c_w)
500   PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(SN76477_TAG, port_sn76477_envelope_2_w)
501   PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_SPECIAL) PORT_WRITE_LINE_DEVICE(SN76477_TAG, port_sn76477_envelope_1_w)
469502INPUT_PORTS_END
470503
471504
src/mess/drivers/mpf1.c
r11508r11509
7979
8080static INPUT_CHANGED( trigger_nmi )
8181{
82   cputag_set_input_line(field->port->machine(), Z80_TAG, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
82   cputag_set_input_line(field->machine(), Z80_TAG, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
8383}
8484
8585static INPUT_CHANGED( trigger_irq )
8686{
87   cputag_set_input_line(field->port->machine(), Z80_TAG, INPUT_LINE_IRQ0, newval ? CLEAR_LINE : ASSERT_LINE);
87   cputag_set_input_line(field->machine(), Z80_TAG, INPUT_LINE_IRQ0, newval ? CLEAR_LINE : ASSERT_LINE);
8888}
8989
9090static INPUT_PORTS_START( mpf1 )
src/mess/drivers/studio2.c
r11508r11509
259259
260260static INPUT_CHANGED( reset_w )
261261{
262   studio2_state *state = field->port->machine().driver_data<studio2_state>();
262   studio2_state *state = field->machine().driver_data<studio2_state>();
263263
264264   if (oldval && !newval)
265265   {
src/mess/drivers/ex800.c
r11508r11509
179179/* The ON LINE switch is directly connected to the INT1 input of the CPU */
180180static INPUT_CHANGED( online_switch )
181181{
182   ex800_state *state = field->port->machine().driver_data<ex800_state>();
182   ex800_state *state = field->machine().driver_data<ex800_state>();
183183   if (newval)
184184   {
185      cputag_set_input_line(field->port->machine(), "maincpu", UPD7810_INTF1, state->m_irq_state);
185      cputag_set_input_line(field->machine(), "maincpu", UPD7810_INTF1, state->m_irq_state);
186186      state->m_irq_state = (state->m_irq_state == ASSERT_LINE) ? CLEAR_LINE : ASSERT_LINE;
187187   }
188188}
src/mess/drivers/rex6000.c
r11508r11509
411411
412412static INPUT_CHANGED( trigger_irq )
413413{
414   rex6000_state *state = field->port->machine().driver_data<rex6000_state>();
414   rex6000_state *state = field->machine().driver_data<rex6000_state>();
415415
416416   if (!(state->m_irq_mask & IRQ_FLAG_KEYCHANGE))
417417   {
src/mess/drivers/ssem.c
r11508r11509
7979
8080static INPUT_CHANGED( panel_check )
8181{
82   ssem_state *state = field->port->machine().driver_data<ssem_state>();
83    UINT8 edit0_state = input_port_read(field->port->machine(), "EDIT0");
84    UINT8 edit1_state = input_port_read(field->port->machine(), "EDIT1");
85    UINT8 edit2_state = input_port_read(field->port->machine(), "EDIT2");
86    UINT8 edit3_state = input_port_read(field->port->machine(), "EDIT3");
87    UINT8 misc_state = input_port_read(field->port->machine(), "MISC");
88    device_t *ssem_cpu = field->port->machine().device("maincpu");
82   ssem_state *state = field->machine().driver_data<ssem_state>();
83    UINT8 edit0_state = input_port_read(field->machine(), "EDIT0");
84    UINT8 edit1_state = input_port_read(field->machine(), "EDIT1");
85    UINT8 edit2_state = input_port_read(field->machine(), "EDIT2");
86    UINT8 edit3_state = input_port_read(field->machine(), "EDIT3");
87    UINT8 misc_state = input_port_read(field->machine(), "MISC");
88    device_t *ssem_cpu = field->machine().device("maincpu");
8989
9090    switch( (int)(FPTR)param )
9191    {
src/mess/drivers/v1050.c
r11508r11509
429429ADDRESS_MAP_END
430430
431431/* Input Ports */
432
432/*
433433static INPUT_PORTS_START( v1050_real )
434434   PORT_START("X0")
435435   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Left Shift") PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
r11508r11509
551551   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR(']') PORT_CHAR('}')
552552   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )
553553INPUT_PORTS_END
554
554*/
555555static INPUT_PORTS_START( v1050 )
556556   PORT_START("ROW0")
557557   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) /* HELP */
src/mess/drivers/qx10.c
r11508r11509
668668/* TODO: shift break */
669669static INPUT_CHANGED( key_stroke )
670670{
671   qx10_state *state = field->port->machine().driver_data<qx10_state>();
671   qx10_state *state = field->machine().driver_data<qx10_state>();
672672
673673   if(newval && !oldval)
674674   {
675675      state->m_keyb.rx = (UINT8)(FPTR)(param) & 0x7f;
676      pic8259_ir4_w(field->port->machine().device("pic8259_master"), 1);
676      pic8259_ir4_w(field->machine().device("pic8259_master"), 1);
677677   }
678678
679679   if(oldval && !newval)
src/mess/drivers/tmc1800.c
r11508r11509
324324
325325static INPUT_CHANGED( tmc2000_run_pressed )
326326{
327   running_machine &machine = field->port->machine();
327   running_machine &machine = field->machine();
328328   tmc2000_state *state = machine.driver_data<tmc2000_state>();
329329
330330   if (oldval && !newval)
r11508r11509
420420
421421static INPUT_CHANGED( run_pressed )
422422{
423   running_machine &machine = field->port->machine();
423   running_machine &machine = field->machine();
424424   nano_state *state = machine.driver_data<nano_state>();
425425
426426   if (oldval && !newval)
r11508r11509
431431
432432static INPUT_CHANGED( monitor_pressed )
433433{
434   running_machine &machine = field->port->machine();
434   running_machine &machine = field->machine();
435435   nano_state *state = machine.driver_data<nano_state>();
436436
437437   if (oldval && !newval)
src/mess/drivers/crvision.c
r11508r11509
203203
204204static INPUT_CHANGED( trigger_nmi )
205205{
206   crvision_state *state = field->port->machine().driver_data<crvision_state>();
206   crvision_state *state = field->machine().driver_data<crvision_state>();
207207
208208   state->m_maincpu->set_input_line(INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
209209}
src/mess/drivers/gizmondo.c
r11508r11509
116116
117117static INPUT_CHANGED( port_changed )
118118{
119   gizmondo_state *gizmondo = field->port->machine().driver_data<gizmondo_state>();
119   gizmondo_state *gizmondo = field->machine().driver_data<gizmondo_state>();
120120   s3c2440_request_eint( gizmondo->m_s3c2440, 4);
121121   //s3c2440_request_irq( device, S3C2440_INT_EINT1);
122122}
src/mess/drivers/amstrad.c
r11508r11509
312312/* Steph 2000-10-27 I remapped the 'Machine Name' Dip Switches (easier to understand) */
313313static INPUT_CHANGED( cpc_monitor_changed )
314314{
315   running_machine &machine = field->port->machine();
315   running_machine &machine = field->machine();
316316   const UINT8   *color_prom = NULL;
317317
318318   if ( (input_port_read(machine, "green_display")) & 0x01 )
src/mess/drivers/junior.c
r11508r11509
3939static INPUT_CHANGED( junior_reset )
4040{
4141   if (newval == 0)
42      field->port->machine().firstcpu->reset();
42      field->machine().firstcpu->reset();
4343}
4444
4545
src/mess/drivers/pockstat.c
r11508r11509
763763
764764static INPUT_CHANGED( input_update )
765765{
766   UINT32 buttons = input_port_read(field->port->machine(), "BUTTONS");
766   UINT32 buttons = input_port_read(field->machine(), "BUTTONS");
767767
768   ps_intc_set_interrupt_line(field->port->machine(), PS_INT_BTN_ACTION, (buttons &  1) ? 1 : 0);
769   ps_intc_set_interrupt_line(field->port->machine(), PS_INT_BTN_RIGHT,   (buttons &  2) ? 1 : 0);
770   ps_intc_set_interrupt_line(field->port->machine(), PS_INT_BTN_LEFT,   (buttons &  4) ? 1 : 0);
771   ps_intc_set_interrupt_line(field->port->machine(), PS_INT_BTN_DOWN,   (buttons &  8) ? 1 : 0);
772   ps_intc_set_interrupt_line(field->port->machine(), PS_INT_BTN_UP,   (buttons & 16) ? 1 : 0);
768   ps_intc_set_interrupt_line(field->machine(), PS_INT_BTN_ACTION, (buttons &  1) ? 1 : 0);
769   ps_intc_set_interrupt_line(field->machine(), PS_INT_BTN_RIGHT,   (buttons &  2) ? 1 : 0);
770   ps_intc_set_interrupt_line(field->machine(), PS_INT_BTN_LEFT,   (buttons &  4) ? 1 : 0);
771   ps_intc_set_interrupt_line(field->machine(), PS_INT_BTN_DOWN,   (buttons &  8) ? 1 : 0);
772   ps_intc_set_interrupt_line(field->machine(), PS_INT_BTN_UP,   (buttons & 16) ? 1 : 0);
773773}
774774
775775static READ32_HANDLER(ps_rombank_r)
src/mess/drivers/x07.c
r11508r11509
11141114
11151115static INPUT_CHANGED( update_udk )
11161116{
1117   x07_state *state = field->port->machine().driver_data<x07_state>();
1117   x07_state *state = field->machine().driver_data<x07_state>();
11181118
1119   state->draw_udk(field->port->machine());
1119   state->draw_udk(field->machine());
11201120}
11211121
11221122static INPUT_CHANGED( kb_keys )
11231123{
1124   x07_state *state = field->port->machine().driver_data<x07_state>();
1124   x07_state *state = field->machine().driver_data<x07_state>();
11251125
11261126   if (!newval)
1127      state->kb_scan_keys(field->port->machine(), (UINT8)(FPTR)param);
1127      state->kb_scan_keys(field->machine(), (UINT8)(FPTR)param);
11281128}
11291129
11301130static INPUT_CHANGED( kb_func_keys )
11311131{
1132   x07_state *state = field->port->machine().driver_data<x07_state>();
1132   x07_state *state = field->machine().driver_data<x07_state>();
11331133
11341134   if (newval)
1135      state->kb_fun_keys(field->port->machine(), (UINT8)(FPTR)param);
1135      state->kb_fun_keys(field->machine(), (UINT8)(FPTR)param);
11361136}
11371137
11381138static INPUT_CHANGED( kb_break )
11391139{
1140   x07_state *state = field->port->machine().driver_data<x07_state>();
1140   x07_state *state = field->machine().driver_data<x07_state>();
11411141
11421142   if (newval)
11431143   {
src/mess/drivers/vidbrain.c
r11508r11509
240240
241241static INPUT_CHANGED( trigger_reset )
242242{
243   cputag_set_input_line(field->port->machine(), F3850_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
243   cputag_set_input_line(field->machine(), F3850_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
244244}
245245
246246
src/mess/drivers/exp85.c
r11508r11509
4949
5050static INPUT_CHANGED( trigger_reset )
5151{
52   cputag_set_input_line(field->port->machine(), I8085A_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
52   cputag_set_input_line(field->machine(), I8085A_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
5353}
5454
5555static INPUT_CHANGED( trigger_rst75 )
5656{
57   cputag_set_input_line(field->port->machine(), I8085A_TAG, I8085_RST75_LINE, newval ? CLEAR_LINE : ASSERT_LINE);
57   cputag_set_input_line(field->machine(), I8085A_TAG, I8085_RST75_LINE, newval ? CLEAR_LINE : ASSERT_LINE);
5858}
5959
6060static INPUT_PORTS_START( exp85 )
src/mess/drivers/hp49gp.c
r11508r11509
229229
230230static INPUT_CHANGED( port_changed )
231231{
232   hp49gp_state *hp49gp = field->port->machine().driver_data<hp49gp_state>();
232   hp49gp_state *hp49gp = field->machine().driver_data<hp49gp_state>();
233233   s3c2410_request_eint( hp49gp->m_s3c2410, (FPTR)param + 8);
234234}
235235
src/mess/drivers/trs80m2.c
r11508r11509
504504   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("RIGHT CTRL") PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(RCONTROL))
505505INPUT_PORTS_END
506506
507/*
507508static INPUT_PORTS_START( trs80m2_real )
508509   PORT_START("ROW0")
509510   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
r11508r11509
625626   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("TAB") PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t')
626627   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
627628INPUT_PORTS_END
628
629*/
629630/* Video */
630631
631632static MC6845_UPDATE_ROW( trs80m2_update_row )
src/mess/drivers/ngp.c
r11508r11509
554554
555555static INPUT_CHANGED( power_callback )
556556{
557   ngp_state *state = field->port->machine().driver_data<ngp_state>();
557   ngp_state *state = field->machine().driver_data<ngp_state>();
558558
559559   if ( state->m_io_reg[0x33] & 0x04 )
560560   {
561561      device_set_input_line( state->m_tlcs900, TLCS900_NMI,
562         (input_port_read(field->port->machine(), "Power") & 0x01 ) ? CLEAR_LINE : ASSERT_LINE );
562         (input_port_read(field->machine(), "Power") & 0x01 ) ? CLEAR_LINE : ASSERT_LINE );
563563   }
564564}
565565
src/mess/drivers/aquarius.c
r11508r11509
262262/* the 'reset' key is directly tied to the reset line of the cpu */
263263static INPUT_CHANGED( aquarius_reset )
264264{
265   cputag_set_input_line(field->port->machine(), "maincpu", INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
265   cputag_set_input_line(field->machine(), "maincpu", INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
266266}
267267
268268static INPUT_PORTS_START( aquarius )
src/mess/drivers/geneve.c
r11508r11509
237237
238238static INPUT_CHANGED( gm_changed )
239239{
240   device_t *board = field->port->machine().device("geneve_board");
240   device_t *board = field->machine().device("geneve_board");
241241   set_gm_switches(board, (UINT8)((UINT64)param&0x03), newval);
242242}
243243
src/mess/drivers/pc8001.c
r11508r11509
156156
157157/* Input Ports */
158158
159static WRITE_LINE_DEVICE_HANDLER( upd1990a_c0_w )
159WRITE_LINE_DEVICE_HANDLER( upd1990a_c0_w )
160160{
161161   pc8001_state *driver_state = device->machine().driver_data<pc8001_state>();
162162   driver_state->m_rtc->c0_w(state);
163163}
164164
165static WRITE_LINE_DEVICE_HANDLER( upd1990a_c1_w )
165WRITE_LINE_DEVICE_HANDLER( upd1990a_c1_w )
166166{
167167   pc8001_state *driver_state = device->machine().driver_data<pc8001_state>();
168168   driver_state->m_rtc->c1_w(state);
169169}
170170
171static WRITE_LINE_DEVICE_HANDLER( upd1990a_c2_w )
171WRITE_LINE_DEVICE_HANDLER( upd1990a_c2_w )
172172{
173173   pc8001_state *driver_state = device->machine().driver_data<pc8001_state>();
174174   driver_state->m_rtc->c2_w(state);
175175}
176176
177static WRITE_LINE_DEVICE_HANDLER( upd1990a_data_in_w )
177WRITE_LINE_DEVICE_HANDLER( upd1990a_data_in_w )
178178{
179179   pc8001_state *driver_state = device->machine().driver_data<pc8001_state>();
180180   driver_state->m_rtc->data_in_w(state);
181181}
182182
183static WRITE_LINE_DEVICE_HANDLER( upd1990a_stb_w )
183WRITE_LINE_DEVICE_HANDLER( upd1990a_stb_w )
184184{
185185   pc8001_state *driver_state = device->machine().driver_data<pc8001_state>();
186186   driver_state->m_rtc->stb_w(state);
187187}
188188
189static WRITE_LINE_DEVICE_HANDLER( upd1990a_clk_w )
189WRITE_LINE_DEVICE_HANDLER( upd1990a_clk_w )
190190{
191191   pc8001_state *driver_state = device->machine().driver_data<pc8001_state>();
192192   driver_state->m_rtc->clk_w(state);
193193}
194194
195static READ_LINE_DEVICE_HANDLER( upd1990a_data_out_r )
195READ_LINE_DEVICE_HANDLER( upd1990a_data_out_r )
196196{
197197   pc8001_state *state = device->machine().driver_data<pc8001_state>();
198198   return state->m_rtc->data_out_r();
199199}
200200
201static READ_LINE_DEVICE_HANDLER( upd3301_vrtc_r )
201READ_LINE_DEVICE_HANDLER( upd3301_vrtc_r )
202202{
203203   pc8001_state *state = device->machine().driver_data<pc8001_state>();
204204   return state->m_crtc->vrtc_r();
src/mess/drivers/beta.c
r11508r11509
2929
3030static INPUT_CHANGED( trigger_reset )
3131{
32   cputag_set_input_line(field->port->machine(), M6502_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
32   cputag_set_input_line(field->machine(), M6502_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
3333}
3434
3535static INPUT_PORTS_START( beta )
src/mess/drivers/px4.c
r11508r11509
918918
919919static INPUT_CHANGED( key_callback )
920920{
921   px4_state *px4 = field->port->machine().driver_data<px4_state>();
921   px4_state *px4 = field->machine().driver_data<px4_state>();
922922   UINT32 oldvalue = oldval * field->mask, newvalue = newval * field->mask;
923923   UINT32 delta = oldvalue ^ newvalue;
924924   int i, scancode = 0xff, down = 0;
r11508r11509
951951            logerror("upd7508: key interrupt\n");
952952
953953         px4->m_isr |= INT0_7508;
954         gapnit_interrupt(field->port->machine());
954         gapnit_interrupt(field->machine());
955955      }
956956   }
957957}
r11508r11509
13201320INPUT_PORTS_END
13211321
13221322/* item keyboard */
1323static INPUT_PORTS_START( px4_h421a )
1323/*static INPUT_PORTS_START( px4_h421a )
13241324   PORT_INCLUDE(px4_dips)
13251325   PORT_INCLUDE(tf20)
13261326INPUT_PORTS_END
1327*/
13271328
1328
13291329/***************************************************************************
13301330    PALETTE
13311331***************************************************************************/
src/mess/drivers/pc8801.c
r11508r11509
16171617- "Help" is mapped to 'F8'
16181618 */
16191619
1620static READ_LINE_DEVICE_HANDLER( upd1990a_data_out_r )
1620READ_LINE_DEVICE_HANDLER( upd1990a_data_out_pc88001_r )
16211621{
16221622   pc8801_state *state = device->machine().driver_data<pc8801_state>();
16231623
r11508r11509
18121812   PORT_DIPNAME( 0x08, 0x08, "Auto-boot floppy at start-up" )
18131813   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
18141814   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1815   PORT_BIT( 0x10, IP_ACTIVE_HIGH,IPT_SPECIAL ) PORT_READ_LINE_DEVICE("upd1990a", upd1990a_data_out_r)
1815   PORT_BIT( 0x10, IP_ACTIVE_HIGH,IPT_SPECIAL ) PORT_READ_LINE_DEVICE("upd1990a", upd1990a_data_out_pc88001_r)
18161816   PORT_BIT( 0x20, IP_ACTIVE_HIGH,IPT_VBLANK )
18171817   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
18181818
src/mess/drivers/poly880.c
r11508r11509
6565
6666static INPUT_CHANGED( trigger_reset )
6767{
68   cputag_set_input_line(field->port->machine(), Z80_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
68   cputag_set_input_line(field->machine(), Z80_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
6969}
7070
7171static INPUT_CHANGED( trigger_nmi )
7272{
73   cputag_set_input_line(field->port->machine(), Z80_TAG, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
73   cputag_set_input_line(field->machine(), Z80_TAG, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
7474}
7575
7676static INPUT_PORTS_START( poly880 )
src/mess/drivers/atom.c
r11508r11509
217217
218218static INPUT_CHANGED( trigger_reset )
219219{
220   cputag_set_input_line(field->port->machine(), SY6502_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
220   cputag_set_input_line(field->machine(), SY6502_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
221221}
222222
223223/*-------------------------------------------------
src/mess/drivers/lc80.c
r11508r11509
5050
5151static INPUT_CHANGED( trigger_reset )
5252{
53   cputag_set_input_line(field->port->machine(), Z80_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
53   cputag_set_input_line(field->machine(), Z80_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
5454}
5555
5656static INPUT_CHANGED( trigger_nmi )
5757{
58   cputag_set_input_line(field->port->machine(), Z80_TAG, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
58   cputag_set_input_line(field->machine(), Z80_TAG, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
5959}
6060
6161static INPUT_PORTS_START( lc80 )
src/mess/drivers/c80.c
r11508r11509
2727
2828static INPUT_CHANGED( trigger_reset )
2929{
30   cputag_set_input_line(field->port->machine(), Z80_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
30   cputag_set_input_line(field->machine(), Z80_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
3131}
3232
3333static INPUT_CHANGED( trigger_nmi )
3434{
35   cputag_set_input_line(field->port->machine(), Z80_TAG, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
35   cputag_set_input_line(field->machine(), Z80_TAG, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
3636}
3737
3838static INPUT_PORTS_START( c80 )
src/mess/drivers/fidelz80.c
r11508r11509
965965
966966static INPUT_CHANGED( fidelz80_trigger_reset )
967967{
968   fidelz80_state *state = field->port->machine().driver_data<fidelz80_state>();
968   fidelz80_state *state = field->machine().driver_data<fidelz80_state>();
969969
970970   device_set_input_line(state->m_maincpu, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
971971}
972972
973973static INPUT_CHANGED( abc_trigger_reset )
974974{
975   fidelz80_state *state = field->port->machine().driver_data<fidelz80_state>();
975   fidelz80_state *state = field->machine().driver_data<fidelz80_state>();
976976
977977   device_set_input_line(state->m_maincpu, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
978978   device_set_input_line(state->m_i8041, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
src/mess/drivers/apple2.c
r11508r11509
273273    PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1)  PORT_PLAYER(2)         PORT_CODE(JOYCODE_BUTTON1)
274274INPUT_PORTS_END
275275
276static INPUT_PORTS_START( apple2_paddle )
276/*static INPUT_PORTS_START( apple2_paddle )
277277   PORT_START("paddle_0")
278278   PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_NAME("P1 Paddle 0")
279279   PORT_SENSITIVITY(PADDLE_SENSITIVITY)
r11508r11509
308308   PORT_MINMAX(0,0xff) PORT_PLAYER(2)
309309   PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH)      PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH)
310310INPUT_PORTS_END
311
311*/
312312static INPUT_PORTS_START( apple2_gameport )
313313   PORT_INCLUDE( apple2_joystick )
314314   //PORT_INCLUDE( apple2_paddle )
src/mess/drivers/ti89.c
r11508r11509
236236
237237static INPUT_CHANGED( ti68k_on_key )
238238{
239   ti68k_state *state = field->port->machine().driver_data<ti68k_state>();
239   ti68k_state *state = field->machine().driver_data<ti68k_state>();
240240
241241   state->m_on_key = newval;
242242
src/mess/drivers/pc.c
r11508r11509
544544   PORT_INCLUDE( pcvideo_cga )
545545INPUT_PORTS_END
546546
547static INPUT_PORTS_START( ibm5150 )
548   PORT_START("IN0") /* IN0 */
549   PORT_BIT ( 0xf0, 0xf0,    IPT_UNUSED )
550   PORT_BIT ( 0x08, 0x08,    IPT_VBLANK )
551   PORT_BIT ( 0x07, 0x07,    IPT_UNUSED )
552
553   PORT_START("DSW0") /* IN1 */
554   PORT_DIPNAME( 0xc0, 0x40, "Number of floppy drives")
555   PORT_DIPSETTING(   0x00, "1" )
556   PORT_DIPSETTING(   0x40, "2" )
557   PORT_DIPSETTING(   0x80, "3" )
558   PORT_DIPSETTING(   0xc0, "4" )
559   PORT_DIPNAME( 0x30, 0x20, "Graphics adapter")
560   PORT_DIPSETTING(   0x00, "EGA/VGA" )
561   PORT_DIPSETTING(   0x10, "Color 40x25" )
562   PORT_DIPSETTING(   0x20, "Color 80x25" )
563   PORT_DIPSETTING(   0x30, "Monochrome" )
564   PORT_DIPNAME( 0x0c, 0x0c, "RAM banks")
565   PORT_DIPSETTING(   0x00, "1 - 16  64 256K" )
566   PORT_DIPSETTING(   0x04, "2 - 32 128 512K" )
567   PORT_DIPSETTING(   0x08, "3 - 48 192 576K" )
568   PORT_DIPSETTING(   0x0c, "4 - 64 256 640K" )
569   PORT_DIPNAME( 0x02, 0x00, "80387 installed")
570   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
571   PORT_DIPSETTING(   0x02, DEF_STR( Yes ) )
572   PORT_DIPNAME( 0x01, 0x01, "Floppy installed")
573   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
574   PORT_DIPSETTING(   0x01, DEF_STR( Yes ) )
575
576   PORT_START("DSW1") /* IN2 */
577   PORT_DIPNAME( 0x80, 0x80, "COM1: enable")
578   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
579   PORT_DIPSETTING(   0x80, DEF_STR( Yes ) )
580   PORT_DIPNAME( 0x40, 0x40, "COM2: enable")
581   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
582   PORT_DIPSETTING(   0x40, DEF_STR( Yes ) )
583   PORT_DIPNAME( 0x20, 0x00, "COM3: enable")
584   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
585   PORT_DIPSETTING(   0x20, DEF_STR( Yes ) )
586   PORT_DIPNAME( 0x10, 0x00, "COM4: enable")
587   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
588   PORT_DIPSETTING(   0x10, DEF_STR( Yes ) )
589   PORT_DIPNAME( 0x08, 0x08, "LPT1: enable")
590   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
591   PORT_DIPSETTING(   0x08, DEF_STR( Yes ) )
592   PORT_DIPNAME( 0x04, 0x00, "LPT2: enable")
593   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
594   PORT_DIPSETTING(   0x04, DEF_STR( Yes ) )
595   PORT_DIPNAME( 0x02, 0x00, "LPT3: enable")
596   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
597   PORT_DIPSETTING(   0x02, DEF_STR( Yes ) )
598   PORT_DIPNAME( 0x01, 0x00, "Game port enable")
599   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
600   PORT_DIPSETTING(    0x01, DEF_STR( Yes ) )
601
602   PORT_START("DSW2") /* IN3 */
603   PORT_DIPNAME( 0xf0, 0x80, "Serial mouse")
604   PORT_DIPSETTING(   0x80, "COM1" )
605   PORT_DIPSETTING(   0x40, "COM2" )
606   PORT_DIPSETTING(   0x20, "COM3" )
607   PORT_DIPSETTING(   0x10, "COM4" )
608   PORT_DIPSETTING(    0x00, DEF_STR( None ) )
609   PORT_DIPNAME( 0x08, 0x08, "HDC1 (C800:0 port 320-323)")
610   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
611   PORT_DIPSETTING(   0x08, DEF_STR( Yes ) )
612   PORT_DIPNAME( 0x04, 0x04, "HDC2 (CA00:0 port 324-327)")
613   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
614   PORT_DIPSETTING(   0x04, DEF_STR( Yes ) )
615   PORT_BIT( 0x02, 0x02,   IPT_UNUSED ) /* no turbo switch */
616   PORT_BIT( 0x01, 0x01,   IPT_UNUSED )
617
618   PORT_INCLUDE( kb_keytronic_pc )      /* IN4 - IN11 */
619   PORT_INCLUDE( pc_mouse_microsoft )   /* IN12 - IN14 */
620   PORT_INCLUDE( pc_joystick )         /* IN15 - IN19 */
621   PORT_INCLUDE( pcvideo_cga )
622INPUT_PORTS_END
623
624547static INPUT_PORTS_START( europc )
625548   PORT_START("IN0") /* IN0 */
626549   PORT_BIT ( 0xf0, 0xf0,    IPT_UNUSED )
r11508r11509
757680   PORT_INCLUDE( pcvideo_cga )
758681INPUT_PORTS_END
759682
760static INPUT_PORTS_START( xtcga )
761   PORT_START("IN0") /* IN0 */
762   PORT_BIT ( 0xf0, 0xf0,    IPT_UNUSED )
763   PORT_BIT ( 0x08, 0x08,    IPT_VBLANK )
764   PORT_BIT ( 0x07, 0x07,    IPT_UNUSED )
765
766   PORT_START("DSW0") /* IN1 */
767   PORT_DIPNAME( 0xc0, 0x40, "Number of floppy drives")
768   PORT_DIPSETTING(   0x00, "1" )
769   PORT_DIPSETTING(   0x40, "2" )
770   PORT_DIPSETTING(   0x80, "3" )
771   PORT_DIPSETTING(   0xc0, "4" )
772   PORT_DIPNAME( 0x30, 0x20, "Graphics adapter")
773   PORT_DIPSETTING(   0x00, "EGA/VGA" )
774   PORT_DIPSETTING(   0x10, "Color 40x25" )
775   PORT_DIPSETTING(   0x20, "Color 80x25" )
776   PORT_DIPSETTING(   0x30, "Monochrome" )
777   PORT_DIPNAME( 0x0c, 0x0c, "RAM banks")
778   PORT_DIPSETTING(   0x00, "1 - 16  64 256K" )
779   PORT_DIPSETTING(   0x04, "2 - 32 128 512K" )
780   PORT_DIPSETTING(   0x08, "3 - 48 192 576K" )
781   PORT_DIPSETTING(   0x0c, "4 - 64 256 640K" )
782   PORT_DIPNAME( 0x02, 0x00, "80387 installed")
783   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
784   PORT_DIPSETTING(   0x02, DEF_STR( Yes ) )
785   PORT_DIPNAME( 0x01, 0x01, "Floppy installed")
786   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
787   PORT_DIPSETTING(   0x01, DEF_STR( Yes ) )
788
789   PORT_START("DSW1") /* IN2 */
790   PORT_DIPNAME( 0x80, 0x80, "COM1: enable")
791   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
792   PORT_DIPSETTING(   0x80, DEF_STR( Yes ) )
793   PORT_DIPNAME( 0x40, 0x40, "COM2: enable")
794   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
795   PORT_DIPSETTING(   0x40, DEF_STR( Yes ) )
796   PORT_DIPNAME( 0x20, 0x00, "COM3: enable")
797   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
798   PORT_DIPSETTING(   0x20, DEF_STR( Yes ) )
799   PORT_DIPNAME( 0x10, 0x00, "COM4: enable")
800   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
801   PORT_DIPSETTING(   0x10, DEF_STR( Yes ) )
802   PORT_DIPNAME( 0x08, 0x08, "LPT1: enable")
803   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
804   PORT_DIPSETTING(   0x08, DEF_STR( Yes ) )
805   PORT_DIPNAME( 0x04, 0x00, "LPT2: enable")
806   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
807   PORT_DIPSETTING(   0x04, DEF_STR( Yes ) )
808   PORT_DIPNAME( 0x02, 0x00, "LPT3: enable")
809   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
810   PORT_DIPSETTING(   0x02, DEF_STR( Yes ) )
811   PORT_DIPNAME( 0x01, 0x00, "Game port enable")
812   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
813   PORT_DIPSETTING(    0x01, DEF_STR( Yes ) )
814
815   PORT_START("DSW2") /* IN3 */
816   PORT_DIPNAME( 0xf0, 0x80, "Serial mouse")
817   PORT_DIPSETTING(   0x80, "COM1" )
818   PORT_DIPSETTING(   0x40, "COM2" )
819   PORT_DIPSETTING(   0x20, "COM3" )
820   PORT_DIPSETTING(   0x10, "COM4" )
821   PORT_DIPSETTING(    0x00, DEF_STR( None ) )
822   PORT_DIPNAME( 0x08, 0x08, "HDC1 (C800:0 port 320-323)")
823   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
824   PORT_DIPSETTING(   0x08, DEF_STR( Yes ) )
825   PORT_DIPNAME( 0x04, 0x04, "HDC2 (CA00:0 port 324-327)")
826   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
827   PORT_DIPSETTING(   0x04, DEF_STR( Yes ) )
828//  PORT_DIPNAME( 0x02, 0x02, "Turbo Switch" )
829//  PORT_DIPSETTING(    0x00, "Off (4.77 MHz)" )
830//  PORT_DIPSETTING(    0x02, "On (12 MHz)" )
831   PORT_BIT( 0x01, 0x01,   IPT_UNUSED )
832
833   PORT_INCLUDE( pc_keyboard )      /* IN4 - IN11 */
834   PORT_INCLUDE( pc_mouse_microsoft )   /* IN12 - IN14 */
835   PORT_INCLUDE( pc_joystick )         /* IN15 - IN19 */
836   PORT_INCLUDE( pcvideo_cga )
837INPUT_PORTS_END
838
839683static INPUT_PORTS_START( tandy1t )
840684   PORT_START("IN0") /* IN0 */
841685   PORT_BIT ( 0xf0, 0xf0,    IPT_UNUSED )
src/mess/drivers/pecom.c
r11508r11509
5050
5151static INPUT_CHANGED( ef_w )
5252{
53   cputag_set_input_line(field->port->machine(), CDP1802_TAG, (int)(FPTR)param, newval);
53   cputag_set_input_line(field->machine(), CDP1802_TAG, (int)(FPTR)param, newval);
5454}
5555
5656static INPUT_PORTS_START( pecom )
src/mess/drivers/ti99_4x.c
r11508r11509
8888
8989static INPUT_CHANGED( gk_changed )
9090{
91   device_t *cartsys = field->port->machine().device("gromport");
91   device_t *cartsys = field->machine().device("gromport");
9292   set_gk_switches(cartsys, (UINT8)((UINT64)param&0x07), newval);
9393}
9494
src/mess/drivers/cosmicos.c
r11508r11509
159159
160160static INPUT_CHANGED( data )
161161{
162   cosmicos_state *state = field->port->machine().driver_data<cosmicos_state>();
163   UINT8 data = input_port_read(field->port->machine(), "DATA");
162   cosmicos_state *state = field->machine().driver_data<cosmicos_state>();
163   UINT8 data = input_port_read(field->machine(), "DATA");
164164   int i;
165165
166166   for (i = 0; i < 8; i++)
r11508r11509
175175
176176static INPUT_CHANGED( enter )
177177{
178   cosmicos_state *state = field->port->machine().driver_data<cosmicos_state>();
178   cosmicos_state *state = field->machine().driver_data<cosmicos_state>();
179179
180180   if (!newval && !state->m_wait && !state->m_clear)
181181   {
182      cputag_set_input_line(field->port->machine(), CDP1802_TAG, COSMAC_INPUT_LINE_DMAIN, ASSERT_LINE);
182      cputag_set_input_line(field->machine(), CDP1802_TAG, COSMAC_INPUT_LINE_DMAIN, ASSERT_LINE);
183183   }
184184}
185185
r11508r11509
231231   }
232232}
233233
234static INPUT_CHANGED( run )            { cosmicos_state *state = field->port->machine().driver_data<cosmicos_state>(); if (!newval) state->set_cdp1802_mode(MODE_RUN); }
235static INPUT_CHANGED( load )         { cosmicos_state *state = field->port->machine().driver_data<cosmicos_state>(); if (!newval) state->set_cdp1802_mode(MODE_LOAD); }
236static INPUT_CHANGED( cosmicos_pause )   { cosmicos_state *state = field->port->machine().driver_data<cosmicos_state>(); if (!newval) state->set_cdp1802_mode(MODE_PAUSE); }
237static INPUT_CHANGED( reset )         { cosmicos_state *state = field->port->machine().driver_data<cosmicos_state>(); if (!newval) state->set_cdp1802_mode(MODE_RESET); }
234static INPUT_CHANGED( run )            { cosmicos_state *state = field->machine().driver_data<cosmicos_state>(); if (!newval) state->set_cdp1802_mode(MODE_RUN); }
235static INPUT_CHANGED( load )         { cosmicos_state *state = field->machine().driver_data<cosmicos_state>(); if (!newval) state->set_cdp1802_mode(MODE_LOAD); }
236static INPUT_CHANGED( cosmicos_pause )   { cosmicos_state *state = field->machine().driver_data<cosmicos_state>(); if (!newval) state->set_cdp1802_mode(MODE_PAUSE); }
237static INPUT_CHANGED( reset )         { cosmicos_state *state = field->machine().driver_data<cosmicos_state>(); if (!newval) state->set_cdp1802_mode(MODE_RESET); }
238238
239239void cosmicos_state::clear_input_data()
240240{
r11508r11509
250250
251251static INPUT_CHANGED( clear_data )
252252{
253   cosmicos_state *state = field->port->machine().driver_data<cosmicos_state>();
253   cosmicos_state *state = field->machine().driver_data<cosmicos_state>();
254254
255255   state->clear_input_data();
256256}
r11508r11509
279279
280280static INPUT_CHANGED( memory_protect )
281281{
282   cosmicos_state *state = field->port->machine().driver_data<cosmicos_state>();
282   cosmicos_state *state = field->machine().driver_data<cosmicos_state>();
283283
284284   state->m_ram_protect = newval;
285285
r11508r11509
288288
289289static INPUT_CHANGED( memory_disable )
290290{
291   cosmicos_state *state = field->port->machine().driver_data<cosmicos_state>();
291   cosmicos_state *state = field->machine().driver_data<cosmicos_state>();
292292
293293   state->m_ram_disable = newval;
294294
src/mess/drivers/psion.c
r11508r11509
461461
462462static INPUT_CHANGED( psion_on )
463463{
464   cpu_device *cpu = field->port->machine().device<cpu_device>("maincpu");
464   cpu_device *cpu = field->machine().device<cpu_device>("maincpu");
465465
466466   /* reset the CPU for resume from standby */
467467   if (cpu->suspended(SUSPEND_REASON_HALT))

Previous 15994 Revisions Next


© 1998-2018 The MESS Team