Previous 15994 Revisions Next

r2376 Saturday 12th April, 2008 at 16:45:56 UTC by Nathan Woods
Updated to MAME 0.124u2 core
[docs]messnew.txt
[src/emu]cpuexec.h cpuintrf.c emupal.c info.c inptport.c inptport.h input.c mame.c mconfig.h memory.c memory.h state.c state.h streams.c tilemap.c tilemap.h timer.c video.c video.h
[src/emu/cpu]cpu.mak
[src/emu/cpu/alph8201]alph8201.h
[src/emu/cpu/apexc]apexc.c
[src/emu/cpu/ccpu]ccpu.c
[src/emu/cpu/cop400]410ops.c
[src/emu/cpu/e132xs]e132xs.c
[src/emu/cpu/f8]f8.c
[src/emu/cpu/g65816]g65816.h
[src/emu/cpu/h6280]h6280ops.h
[src/emu/cpu/h83002]h83002.c h8periph.c
[src/emu/cpu/hd6309]hd6309.c hd6309.h
[src/emu/cpu/i386]i386.c
[src/emu/cpu/i8039]i8039.h
[src/emu/cpu/i8051]i8051.c
[src/emu/cpu/i8085]i8085.c i8085cpu.h
[src/emu/cpu/i86]i286.h i86mem.c
[src/emu/cpu/i8x41]i8x41.c
[src/emu/cpu/jaguar]jaguar.c
[src/emu/cpu/konami]konami.h
[src/emu/cpu/m37710]m37710.c
[src/emu/cpu/m6502]m4510.c m6502.c m6509.c m65ce02.c minc4510.h mincce02.h ops02.h ops09.h tdeco16.c
[src/emu/cpu/m6800]m6800.c m6800.h
[src/emu/cpu/m68000]m68kcpu.c m68kmame.c
[src/emu/cpu/m6805]m6805.h
[src/emu/cpu/m6809]m6809.h
[src/emu/cpu/mb88xx]mb88xx.c
[src/emu/cpu/minx]minx.c
[src/emu/cpu/mips]dismips.c dismips.mak mips3com.c mips3com.h mips3fe.c mipsdasm.c psx.c psx.h
[src/emu/cpu/nec]nec.c necdasm.c
[src/emu/cpu/pic16c5x]pic16c5x.h
[src/emu/cpu/s2650]s2650.c
[src/emu/cpu/sm8500]sm8500.c
[src/emu/cpu/spc700]spc700.h
[src/emu/cpu/tlcs90]tlcs90.c
[src/emu/cpu/tms34010]tms34010.c
[src/emu/cpu/tms7000]tms7000.c
[src/emu/cpu/tms9900]99xxcore.h
[src/emu/cpu/upd7810]upd7810.c
[src/emu/cpu/v30mz]v30mz.h
[src/emu/cpu/z180]z180.c z180ops.h
[src/emu/cpu/z80]z80.c
[src/emu/cpu/z8000]z8000.c
[src/emu/cpu/z80gb]z80gb.c
[src/emu/drivers]xtal.h
[src/emu/machine]generic.c pit8253.c pit8253.h scsicd.c scsicd.h
[src/emu/sound]2151intf.c 2203intf.c 2608intf.c 2610intf.c 2612intf.c disc_inp.c fmopl.c k054539.c multipcm.c samples.c upd7759.c vlm5030.c ym2151.c ym2151.h ymz280b.c
[src/emu/video]cdp1869.c mc6845.c poly.c
[src/lib/util]xmlfile.c
[src/mame]mame.mak mamedriv.c
[src/mame/audio]8080bw.c atarijsa.c cyberbal.c harddriv.c mcr.c mw8080bw.c
[src/mame/drivers]8080bw.c 88games.c acefruit.c actfancr.c aerofgt.c aladbl.c aleck64.c alg.c alpha68k.c amspdwy.c angelkds.c aquarium.c arabian.c arcadia.c armedf.c artmagic.c astinvad.c astrocde.c astrof.c atarig1.c atarig42.c atarigt.c atarigx2.c atarisy1.c atarisy2.c atetris.c attckufo.c backfire.c badlands.c baraduke.c batman.c battlera.c bbusters.c beaminv.c beathead.c berzerk.c bfcobra.c bfm_sc2.c bigevglf.c bionicc.c bishi.c bishjan.c bladestl.c blktiger.c blmbycar.c blockade.c blstroid.c bmcbowl.c bnstars.c boxer.c btoads.c bwidow.c bwing.c bzone.c cabal.c calomega.c canyon.c capbowl.c cave.c cbasebal.c cbuster.c ccastles.c centiped.c cham24.c champbwl.c changela.c chinsan.c chqflag.c cidelsa.c cinemat.c cischeat.c citycon.c clayshoo.c cliffhgr.c cloud9.c clshroad.c cninja.c cojag.c combatsc.c coolpool.c cop01.c copsnrob.c cosmic.c cps1.c cps2.c cps3.c crbaloon.c crgolf.c crshrace.c crystal.c cshooter.c csk.c cubocd32.c cyberbal.c cybertnk.c darius.c darkhors.c darkseal.c dassault.c dbz.c dcheese.c ddayjlc.c ddenlovr.c deadang.c dec8.c deco156.c deco32.c deco_mlc.c decocass.c destroyr.c djboy.c djmain.c dkong.c dlair.c docastle.c dragrace.c dreamwld.c dribling.c dunhuang.c dynax.c embargo.c enigma2.c eolith.c eolith16.c eprom.c equites.c ertictac.c ettrivia.c exidy.c exidy440.c exprraid.c exterm.c fantland.c fcrash.c fgoal.c filetto.c firebeat.c firetrap.c firetrk.c flkatck.c flstory.c flyball.c foodf.c freekick.c fromanc2.c fromance.c fuukifg3.c gaelco2.c gaelco3d.c galaga.c galaxian.c galaxold.c galpani3.c gamecstl.c gameplan.c gaplus.c gauntlet.c genesis.c gladiatr.c goal92.c gomoku.c goodejan.c gottlieb.c grchamp.c gridlee.c gsword.c gticlub.c guab.c gundealr.c hal21.c halleys.c hanaawas.c hitme.c hnayayoi.c hng64.c homedata.c homerun.c hornet.c hyperspt.c igs_blit.c imolagp.c inufuku.c itech32.c itech8.c jack.c jackal.c jalmah.c jchan.c jcross.c jedi.c jongkyo.c jpmimpct.c kaneko16.c karnov.c kinst.c kinstb.c klax.c koikoi.c konamigq.c konamigv.c konamigx.c kopunch.c ksys573.c ladybug.c laserbat.c lastfght.c lazercmd.c legionna.c lemmings.c lethal.c lethalj.c liberate.c liberatr.c limenko.c lockon.c lordgun.c lvcards.c m10.c m62.c m72.c m79amb.c m90.c m92.c macrossp.c macs.c magicfly.c malzak.c mappy.c marineb.c marinedt.c marvins.c matmania.c maxaflex.c mayumi.c mazerbla.c mcatadv.c mcr.c mcr3.c mcr68.c mediagx.c megadriv.c megaplay.c megasys1.c megatech.c megazone.c meijinsn.c meritm.c metlclsh.c metro.c mgolf.c micro3d.c midas.c midvunit.c midzeus.c mirage.c missile.c mitchell.c mjkjidai.c mjsister.c model1.c model2.c model3.c moo.c mpu4.c mquake.c mrflea.c ms32.c msisaac.c mugsmash.c multigam.c mw8080bw.c mystwarr.c namcoic.c namcona1.c namconb1.c namcos1.c namcos10.c namcos11.c namcos12.c namcos22.c namcos86.c naughtyb.c nbmj9195.c nemesis.c neodrvr.c neogeo.c ninjakd2.c ninjaw.c niyanpai.c nova2001.c nwk-tr.c nycaptor.c offtwall.c ojankohs.c omegrace.c oneshot.c opwolf.c othunder.c pacland.c pacman.c peplus.c pgm.c phoenix.c playmark.c plygonet.c pmpoker.c pntnpuzl.c polepos.c policetr.c polyplay.c poolshrk.c popper.c powerbal.c progolf.c psikyo.c psikyo4.c psikyosh.c quantum.c rabbit.c raiden2.c rcasino.c realbrk.c redalert.c redclash.c relief.c renegade.c rmhaihai.c rockola.c rohga.c route16.c royalmah.c rpunch.c runaway.c rungun.c sbowling.c sbrkout.c sderby.c seattle.c segac2.c segae.c segag80r.c segag80v.c segahang.c segaorun.c segas16a.c segas16b.c segas18.c segas24.c segas32.c segaxbd.c segaybd.c seibuspi.c seicross.c sengokmj.c seta.c seta2.c sf.c sgladiat.c shadfrce.c shootout.c shuuz.c sidearms.c silkroad.c simpl156.c skullxbo.c skyfox.c skykid.c skyraid.c slapshot.c snk.c snk68.c sonson.c spdodgeb.c speedatk.c sprint2.c sprint4.c sprint8.c srmp2.c srmp6.c ssf2md.c ssfindo.c sshangha.c ssingles.c ssozumo.c ssrj.c ssv.c st0016.c stactics.c stadhero.c starfire.c starshp1.c stlforce.c stv.c suna8.c supbtime.c superqix.c suprnova.c suprridr.c system16.c system18.c tagteam.c taito_f2.c taito_f3.c taito_h.c taito_l.c taito_x.c taito_z.c taitoair.c taitojc.c taitosj.c taitowlf.c tankbatt.c tatsumi.c taxidrvr.c tceptor.c tehkanwc.c tempest.c terracre.c tetrisp2.c thedeep.c thief.c thunderj.c tickee.c tmaster.c tmnt.c tnzs.c toaplan1.c toaplan2.c toobin.c topspeed.c toratora.c tourtabl.c toypop.c triplhnt.c truco.c tryout.c tugboat.c tumbleb.c tumblep.c tunhunt.c turbo.c twin16.c twincobr.c tx1.c uapce.c ultraman.c ultratnk.c ultrsprt.c unico.c upscope.c usgames.c vamphalf.c vaportra.c vastar.c vegaeo.c vegas.c vendetta.c vicdual.c videopin.c vindictr.c vmetal.c wardner.c warpwarp.c warriorb.c wc90b.c wecleman.c welltris.c wgp.c wheelfir.c wilytowr.c wink.c wiping.c witch.c wolfpack.c wwfsstar.c wwfwfest.c xain.c xexex.c xmen.c xorworld.c xtheball.c xxmissio.c xybots.c xyonix.c yumefuda.c zaccaria.c zaxxon.c zerozone.c zn.c zr107.c
[src/mame/includes]8080bw.h amiga.h atari.h cps1.h mw8080bw.h neogeo.h phoenix.h psx.h snk.h st0016.h toaplan1.h twincobr.h vicdual.h
[src/mame/machine]ajax.c amiga.c asteroid.c atari.c atarifb.c atarigen.c atarigen.h balsente.c beezer.c bonzeadv.c bublbobl.c carpolo.c cchip.c copsnrob.c daikaiju.c dc.c dec0.c decocass.c decocass.h decoprot.c gaelco2.c galaxold.c gaplus.c harddriv.c irem_cpu.c irobot.c kaneko16.c leland.c lsasquad.c mcr.c mexico86.c mhavoc.c midtunit.c midwayic.c midwunit.c midyunit.c n64.c namcoio.c namcos1.c namcos2.c nb1413m3.c nitedrvr.c opwolf.c pcecommn.c pckeybrd.c pgmprot.c playch10.c psx.c qix.c rainbow.c s16fd.c s24fd.c scramble.c seicop.c* simpsons.c slikshot.c snes.c starwars.c stfight.c strtheat.c subs.c tait8741.c tatsumi.c tnzs.c toaplan1.c twincobr.c vertigo.c volfied.c vsnes.c williams.c xevious.c
[src/mame/video]8080bw.c aeroboto.c aerofgt.c amiga.c asterix.c astrocde.c asuka.c atari.c bionicc.c bking.c blockade.c btime.c bwing.c canyon.c centiped.c chaknpop.c cinemat.c cischeat.c cloak.c combatsc.c cps1.c darius.c dbz.c dcheese.c dkong.c exidy.c exidy440.c fgoal.c gijoe.c gtia.c gtia.h itech8.c jaguar.c konamiic.c konamiic.h lazercmd.c lethal.c lethalj.c lordgun.c m52.c m57.c m58.c m62.c m72.c m92.c madalien.c mario.c momoko.c moo.c mystston.c n8080.c namcofl.c namcona1.c namconb1.c naughtyb.c neogeo.c ninjaw.c nmk16.c oneshot.c orbit.c othunder.c overdriv.c parodius.c phoenix.c polepos.c policetr.c ppu2c0x.c prehisle.c psikyo.c psx.c psychic5.c rastan.c renegade.c segaic24.c simpsons.c snes.c snk.c sonson.c st0016.c stvvdp1.c stvvdp2.c superqix.c surpratk.c system1.c taito_f2.c taito_z.c taitoic.c taitoic.h taitosj.c tceptor.c tmnt.c toaplan1.c topspeed.c travrusa.c turbo.c twincobr.c vendetta.c vicdual.c warpwarp.c warriorb.c wgp.c xexex.c xmen.c ygv608.c zac2650.c
[src/mess]inputx.c inputx.h mess.mak
[src/mess/devices]coco_fdc.c thomflop.c
[src/mess/drivers]a2600.c apexc.c bw2.c coupe.c cpschngr.c psx.c
[src/mess/machine]6883sam.c apple2.c c64.c coco.c cpm_bios.c lynx.c mac.c nascom1.c nes_mmc.c pdp1.c pokemini.c spectrum.c thomson.c trs80.c tx0.c vtech1.c wswan.c
[src/mess/video]coco3.c gb.c m6847.c oric.c pc_video.c
[src/osd/windows]input.c
[src/osd/winui]winui.c

src/mame/audio/cyberbal.c
r2375r2376
4141
4242READ8_HANDLER( cyberbal_special_port3_r )
4343{
44   int temp = readinputport(3);
45   if (!(readinputport(0) & 0x8000)) temp ^= 0x80;
44   int temp = input_port_read_indexed(machine, 3);
45   if (!(input_port_read_indexed(machine, 0) & 0x8000)) temp ^= 0x80;
4646   if (atarigen_cpu_to_sound_ready) temp ^= 0x40;
4747   if (atarigen_sound_to_cpu_ready) temp ^= 0x20;
4848   return temp;
src/mame/audio/atarijsa.c
r2375r2376
221221                0x02 = coin 2
222222                0x01 = coin 1
223223            */
224         result = readinputportbytag("JSAI");
225         if (!(readinputport(test_port) & test_mask)) result ^= 0x80;
224         result = input_port_read(machine, "JSAI");
225         if (!(input_port_read_indexed(machine, test_port) & test_mask)) result ^= 0x80;
226226         if (atarigen_cpu_to_sound_ready) result ^= 0x40;
227227         if (atarigen_sound_to_cpu_ready) result ^= 0x20;
228228         if (!has_tms5220 || tms5220_ready_r()) result ^= 0x10;
r2375r2376
348348                0x02 = coin 2
349349                0x01 = coin 1
350350            */
351         result = readinputportbytag("JSAII");
352         if (!(readinputport(test_port) & test_mask)) result ^= 0x80;
351         result = input_port_read(machine, "JSAII");
352         if (!(input_port_read_indexed(machine, test_port) & test_mask)) result ^= 0x80;
353353         if (atarigen_cpu_to_sound_ready) result ^= 0x40;
354354         if (atarigen_sound_to_cpu_ready) result ^= 0x20;
355355         break;
r2375r2376
467467                0x02 = coin L (active high)
468468                0x01 = coin R (active high)
469469            */
470         result = readinputportbytag("JSAIII");
471         if (!(readinputport(test_port) & test_mask)) result ^= 0x90;
470         result = input_port_read(machine, "JSAIII");
471         if (!(input_port_read_indexed(machine, test_port) & test_mask)) result ^= 0x90;
472472         if (atarigen_cpu_to_sound_ready) result ^= 0x40;
473473         if (atarigen_sound_to_cpu_ready) result ^= 0x20;
474474         break;
r2375r2376
604604                0x02 = coin L (active high)
605605                0x01 = coin R (active high)
606606            */
607         result = readinputportbytag("JSAIII");
608         if (!(readinputport(test_port) & test_mask)) result ^= 0x90;
607         result = input_port_read(machine, "JSAIII");
608         if (!(input_port_read_indexed(machine, test_port) & test_mask)) result ^= 0x90;
609609         if (atarigen_cpu_to_sound_ready) result ^= 0x40;
610610         if (atarigen_sound_to_cpu_ready) result ^= 0x20;
611611         break;
src/mame/audio/mcr.c
r2375r2376
414414READ8_HANDLER( ssio_input_port_r )
415415{
416416   static const char *const port[] = { "SSIO.IP0", "SSIO.IP1", "SSIO.IP2", "SSIO.IP3", "SSIO.IP4" };
417   UINT8 result = readinputportbytag_safe(port[offset], 0xff);
417   UINT8 result = input_port_read_safe(machine, port[offset], 0xff);
418418   if (ssio_custom_input[offset])
419419      result = (result & ~ssio_custom_input_mask[offset]) |
420420               ((*ssio_custom_input[offset])(machine, offset) & ssio_custom_input_mask[offset]);
src/mame/audio/harddriv.c
r2375r2376
179179//            D13 = Test Switch
180180//            D12 = 5220 Ready Flag (0=Ready)
181181   logerror("%06X:hdsnd68k_status_r(%04X)\n", activecpu_get_previouspc(), offset);
182   return (mainflag << 15) | (soundflag << 14) | 0x2000 | 0;//((readinputport(0) & 0x0020) << 8) | 0;
182   return (mainflag << 15) | (soundflag << 14) | 0x2000 | 0;//((input_port_read_indexed(machine, 0) & 0x0020) << 8) | 0;
183183}
184184
185185
src/mame/audio/8080bw.c
r2375r2376
6060   if (rising_bits & 0x08) sample_start_n(0, 4, 6, 0);      /* FLEET */
6161   if (rising_bits & 0x10) sample_start_n(0, 3, 7, 0);      /* SAUCER HIT */
6262
63    c8080bw_flip_screen_w(data & 0x20);
63    c8080bw_flip_screen_w(machine, data & 0x20);
6464
6565   port_2_last = data;
6666}
r2375r2376
145145   if (rising_bits & 0x10) sample_start(3, 6, 0);      /* Shooting Star and Rescue Ship sounds */
146146   if (~data & 0x10 && port_2_last & 0x10) sample_stop (3);   /* This makes the rescue ship sound beep on and off */
147147
148   c8080bw_flip_screen_w(data & 0x20);
148   c8080bw_flip_screen_w(machine, data & 0x20);
149149
150150   port_2_last = data;
151151}
r2375r2376
196196   if (data & 0x04) sample_start(0, 4, 0);      /* Plane is dropping new balloons at start of level */
197197   if (rising_bits & 0x10) sample_start(2, 2, 0);      /* Balloon hit and bomb drops */
198198
199   c8080bw_flip_screen_w(data & 0x20);
199   c8080bw_flip_screen_w(machine, data & 0x20);
200200
201201   port_2_last = data;
202202}
r2375r2376
623623
624624   coin_lockout_global_w(data & 0x04);  /* SX8 */
625625
626   c8080bw_flip_screen_w(data & 0x20);  /* SX11 */
626   c8080bw_flip_screen_w(machine, data & 0x20);  /* SX11 */
627627
628628   /* 0x01 - SX6 - Plane Down */
629629   discrete_sound_w(machine, POLARIS_SX6_EN, data & 0x01);
r2375r2376
854854
855855   schaser_background_control_w(data & 0x18);
856856
857   c8080bw_flip_screen_w(data & 0x20);
857   c8080bw_flip_screen_w(machine, data & 0x20);
858858}
859859
860860
r2375r2376
998998   if (rising_bits & 0x08) sample_start(3, 0, 0);      /* start intermission, end game */
999999   //if (rising_bits & 0x10) sample_start(3, 9, 0);        /* Dog barking */
10001000
1001   c8080bw_flip_screen_w(data & 0x20);
1001   c8080bw_flip_screen_w(machine, data & 0x20);
10021002
10031003   port_2_last = data;
10041004}
r2375r2376
10301030
10311031   sound_global_enable(data & 0x10);
10321032
1033   c8080bw_flip_screen_w(data & 0x20);
1033   c8080bw_flip_screen_w(machine, data & 0x20);
10341034}
10351035
10361036
r2375r2376
10651065
10661066   if (rising_bits & 0x10) sample_start(2, 7, 0);         /* Game Over */
10671067
1068   c8080bw_flip_screen_w(data & 0x20);
1068   c8080bw_flip_screen_w(machine, data & 0x20);
10691069
10701070   port_2_last = data;
10711071}
src/mame/audio/mw8080bw.c
r2375r2376
321321
322322   /* if (data & 0x10)  enable CHEER sound */
323323
324   if (tornbase_get_cabinet_type() == TORNBASE_CAB_TYPE_UPRIGHT_OLD)
324   if (tornbase_get_cabinet_type(machine) == TORNBASE_CAB_TYPE_UPRIGHT_OLD)
325325   {
326326      /* if (data & 0x20)  enable WHISTLE sound */
327327
r2375r2376
570570void maze_write_discrete(running_machine *machine, UINT8 maze_tone_timing_state)
571571{
572572   /* controls need to be active low */
573   int controls = ~readinputport(0) & 0xff;
573   int controls = ~input_port_read_indexed(machine, 0) & 0xff;
574574
575575   discrete_sound_w(machine, MAZE_TONE_TIMING, maze_tone_timing_state);
576576   discrete_sound_w(machine, MAZE_P1_DATA, controls & 0x0f);
r2375r2376
582582   /* A better option might be to update it at vblank or set a timer to do it. */
583583   /* The only noticeable difference doing it here, is that the controls don't */
584584   /* imediately start making tones if pressed right after the coin is inserted. */
585   discrete_sound_w(machine, MAZE_COIN, (~readinputport(1) >> 3) & 0x01);
585   discrete_sound_w(machine, MAZE_COIN, (~input_port_read_indexed(machine, 1) >> 3) & 0x01);
586586}
587587
588588
r2375r2376
36593659   discrete_sound_w(machine, INVADERS_NODE(INVADERS_SAUCER_HIT_EN, 1), data & 0x10);
36603660
36613661   /* the flip screen line is only connected on the cocktail PCB */
3662   if (invaders_is_cabinet_cocktail())
3662   if (invaders_is_cabinet_cocktail(machine))
36633663   {
36643664      invaders_set_flip_screen((data >> 5) & 0x01);
36653665   }
src/mame/machine/rainbow.c
r2375r2376
760760   coin_counter_w(1, CRAM[0][8] & 0x20);
761761   coin_counter_w(0, CRAM[0][8] & 0x10);
762762
763   CRAM[0][3] = readinputportbytag("800007");    /* STARTn + SERVICE1 */
764   CRAM[0][4] = readinputportbytag("800009");    /* COINn */
765   CRAM[0][5] = readinputportbytag("80000B");    /* Player controls + TILT */
766   CRAM[0][6] = readinputportbytag("80000D");    /* Player controls (cocktail) */
763   CRAM[0][3] = input_port_read(machine, "800007");    /* STARTn + SERVICE1 */
764   CRAM[0][4] = input_port_read(machine, "800009");    /* COINn */
765   CRAM[0][5] = input_port_read(machine, "80000B");    /* Player controls + TILT */
766   CRAM[0][6] = input_port_read(machine, "80000D");    /* Player controls (cocktail) */
767767}
768768
769769/*************************************
src/mame/machine/xevious.c
r2375r2376
170170   switch ( offset )
171171   {
172172      default:
173      case 0: return ~BITSWAP8(readinputport(0),6,7,5,4,3,2,1,0) >> 4;
174      case 1: return ~readinputport(1) & 0x0f;
175      case 2: return ~readinputport(1) >> 4;
176      case 3: return ~readinputport(0) & 0x0f;
173      case 0: return ~BITSWAP8(input_port_read_indexed(machine, 0),6,7,5,4,3,2,1,0) >> 4;
174      case 1: return ~input_port_read_indexed(machine, 1) & 0x0f;
175      case 2: return ~input_port_read_indexed(machine, 1) >> 4;
176      case 3: return ~input_port_read_indexed(machine, 0) & 0x0f;
177177   }
178178}
179179
src/mame/machine/irem_cpu.c
r2375r2376
109109
110110const UINT8 lethalth_decryption_table[256] = {
111111   0x7f,0x26,0x5d,xxxx,0xba,xxxx,0x1e,0x5e, 0xb8,xxxx,0xbc,0xe8,0x01,xxxx,0x4a,0x25, /* 00 */
112//       !!!! !!!!      !!!!      !!!! !!!!  !!!!      !!!! !!!! !!!!           !!!!
112113   xxxx,0xbd,xxxx,0x22,0x10,xxxx,0x02,0x57, 0x70,xxxx,0x7c,xxxx,0xe7,0x52,xxxx,0xa9, /* 10 */
113//                      ^^^^                ^^^^
114//                 !!!!           !!!! !!!!                      !!!! !!!!
114115   xxxx,xxxx,0xc6,0x06,0xa0,0xfe,0xcf,0x8e, 0x43,0x8f,0x2d,xxxx,0xd4,0x85,0x75,0xa2, /* 20 */
115//                                             ^^^^
116//            !!!! !!!!      !!!! !!!! !!!!  !!!!                          !!!! !!!!
116117   0x3d,xxxx,xxxx,0x38,0x7c,0x89,0xd1,0x80, 0x3b,0x72,0x07,xxxx,0x42,0x37,0x0a,0x18, /* 30 */
117//                                                                ^^^^
118//                 !!!!      !!!! !!!! !!!!  !!!! !!!! !!!!                !!!!
118119   0x88,0xb4,0x98,0x8b,0xb9,0x9c,0xad,0x0e, 0x2b,xxxx,0xbf,xxxx,0x55,xxxx,0x56,0xb0, /* 40 */
119//                                   ^^^^
120//  !!!!           !!!! !!!! !!!! !!!!                 !!!!      !!!!      !!!! !!!!
120121   0x93,0x91,xxxx,0xeb,xxxx,0x50,0x41,0x29, 0x47,xxxx,xxxx,0x60,xxxx,0xab,xxxx,xxxx, /* 50 */
122//      !!!! !!!!      !!!!      !!!! !!!!                      !!!!      !!!!
121123   0xc3,0xe2,0xd0,0xb2,0x11,0x79,xxxx,0x08, xxxx,0xfb,xxxx,0x2c,0x23,xxxx,0x28,0x0d, /* 60 */
124//  !!!! !!!! !!!! !!!!                           !!!!           !!!!
122125   xxxx,xxxx,xxxx,0x83,0x3c,xxxx,0x1b,0x34, 0x5b,xxxx,0x40,xxxx,xxxx,0x04,0xfc,0x09, /* 70 */
123//                                                                              ^^^^
126//                 !!!! !!!!                 !!!!                     !!!! !!!!
124127   0xb1,0xf3,0x8a,xxxx,xxxx,0x87,xxxx,xxxx, xxxx,xxxx,xxxx,xxxx,0xbe,0x84,0x1f,0xe6, /* 80 */
128//       !!!! !!!!                                               !!!!      !!!!
125129   0xff,xxxx,0x12,xxxx,0xb5,0x36,xxxx,0xb3, xxxx,xxxx,xxxx,0xd2,0x4e,xxxx,xxxx,xxxx, /* 90 */
130//  !!!!                     !!!!      !!!!
126131   0xa5,xxxx,xxxx,0xc7,xxxx,0x27,0x0b,xxxx, 0x20,xxxx,xxxx,xxxx,xxxx,xxxx,0x61,0x7f, /* A0 */
127   xxxx,xxxx,0x86,0x0f,xxxx,0xb7,xxxx,0x4f, xxxx,xxxx,0xc0,0xfd,xxxx,0x39,xxxx,0x7d, /* B0 */
132//  !!!!           !!!!           !!!!                                     !!!!
133   xxxx,xxxx,0x86,0x0f,xxxx,0xb7,xxxx,0x4f, xxxx,xxxx,0xc0,0xfd,xxxx,0x39,xxxx,0x77, /* B0 */
134//            !!!! !!!!                                !!!!           !!!!      !!!!
128135   0x05,0x3a,xxxx,0x48,0x92,0x7a,0x3e,0x03, xxxx,0xf8,xxxx,0x59,0xa8,0x5f,0xf9,0xbb, /* C0 */
136//  !!!! !!!!                          !!!!                 !!!!      !!!! !!!! !!!!
129137   0x81,0xfa,0x9d,0xe9,0x2e,0xa1,0xc1,0x33, xxxx,0x78,xxxx,0x0c,xxxx,0x24,0xaa,0xac, /* D0 */
138//  !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!                           !!!!      !!!!
130139   xxxx,0xb6,xxxx,0xea,xxxx,0x73,0xe5,0x58, 0x00,0xf7,xxxx,0x74,xxxx,0x7e,xxxx,0xa3, /* E0 */
140//                 !!!!           !!!! !!!!       !!!!      !!!!                !!!!
131141   xxxx,0x5a,0xf6,0x32,0x46,0x2a,xxxx,xxxx, 0x53,0x4b,0x90,xxxx,0x51,0x68,0x99,0x13, /* F0 */
132//                                                                          ^^^^
142//       !!!! !!!! !!!! !!!! !!!!            !!!!      !!!!      !!!! !!!!
133143};
144/*
145missing opcode:
146
147"!!!!" -> checked against gussun
148"gggg" -> very probably
149"pppp" -> probably
150"????" -> missing
151
152RZ notes:
1530xbf (0x77) risky challenge use same code
154
155*/
156
134157// 0x2c (0xd4) complete guess
135158// 0x2d (0x85) complete guess
136159// 0xc4 (0x92) guess
137160// 0xbb (0xfd) guess
138// 0x46 (0xad) guess
161// 0x46 (0xad) guess - risky challenge use same code
139162// 0x6e (0x28) guess
140163// 0x76 (0x1b) guess
141164// 0x8d (0x84) guess
142// 0xa6 (0x0b) guess
165// 0xa6 (0x0b) guess - risky challenge use same code
143166// 0xa8 (0x20) guess
144// 0xbd (0x39) guess
167// 0xbd (0x39) guess - risky challenge use same code
145168// 0xc3 (0x48) guess
146169// and our collection of conditional branches:
147170// 0xbf (0x7d) >= (monitor test)
r2375r2376
304327    0x63,xxxx,xxxx,0x36,xxxx,0x52,0xb1,0x5b, 0x68,0xcd,xxxx,xxxx,xxxx,0xa8,xxxx,xxxx, /* 00 */
305328//  gggg                          gggg            gggg                gggg
306329    xxxx,xxxx,0x75,0x24,0x08,0x83,0x32,0xe9, xxxx,0x79,xxxx,0x8f,0x22,xxxx,0xac,xxxx, /* 10 */
307//                      ????                      pppp      gggg
330//                      pppp                      pppp      gggg
308331    0x5d,0xa5,0x11,0x51,0x0a,0x29,xxxx,xxxx ,0xf8,0x98,0x91,0x40,0x28,0x00,0x03,0x5f, /* 20 */
309332//            gggg           gggg            gggg gggg      gggg gggg pppp
310333    0x26,xxxx,xxxx,0x8b,0x2f,0x02,xxxx,xxxx, 0x8e,0xab,xxxx,xxxx,0xbc,0x90,0xb3,xxxx, /* 30 */
r2375r2376
322345    xxxx,xxxx,0x9d,xxxx,0xbb,xxxx,xxxx,0xcb, 0xa9,0xcf,xxxx,0x60,0x43,0x56,xxxx,xxxx, /* 90 */
323346//            gggg                     gggg
324347    xxxx,0xa3,xxxx,xxxx,0x12,xxxx,0xfa,0xb4, xxxx,0x81,0xe6,0x48,0x80,0x8c,0xd4,xxxx, /* a0 */
325//                      gggg           gggg                 ????      gggg gggg
326    0x42,xxxx,0x84,0xb6,0x77,0x3d,0x3e,xxxx, xxxx,0xb7,0x4b,xxxx,0xa4,xxxx,xxxx,xxxx, /* b0 */
327//  gggg      gggg ???? gggg      gggg            ???? pppp      gggg
348//                      gggg           gggg                 pppp      gggg gggg
349    0x42,xxxx,0x84,0xb6,0x77,0x3d,0x3e,xxxx, xxxx,0x0c,0x4b,xxxx,0xa4,xxxx,xxxx,xxxx, /* b0 */
350//  gggg      gggg pppp gggg      gggg            pppp pppp      gggg
328351    xxxx,0xff,0x47,xxxx,0x55,0x1e,xxxx,0x59, 0x93,xxxx,xxxx,xxxx,0x88,0xc1,0x01,0xb2, /* c0 */
329//            gggg                                                         pppp
352//            gggg
330353    0x85,0x2e,0x06,0xc7,0x05,xxxx,0x8a,0x5a, 0x58,0xbe,xxxx,0x4e,xxxx,0x1f,0x23,xxxx, /* d0 */
331354//  gggg                                                    gggg
332355    0xe8,xxxx,0x89,0xa1,0xd0,xxxx,xxxx,0xe2, 0x38,0xfe,0x50,0x9c,xxxx,xxxx,xxxx,0x49, /* e0 */
r2375r2376
343366"gggg" -> very probably
344367"pppp" -> probably
345368"????" -> missing
346"0xHH" -> right code (not supported)
347369
34814 -> 08 (2097b 20980 - routine from 2097a) (08 30) to handle the player number -> probably 08
349ab -> 4f?(19570 - routine from 194e1 to 19619) (when the water go up)
350b3 -> 19 (216b6 - 216cf - 16663 (when you rotate a piece) - 175f1 - 17d2a - 17d36
351b9 -> b7 (21210 - routine from 2117e to ) 2 bytes -
352
353370rz probably:
37114 -> 08 (2097b 20980 - routine from 2097a) (08 30) to handle the player number -> 08
35437219 -> 79 (1df45 routine from 1df27 / 2282f - routine from 2281f to 22871) no 70,78,7a,7b,7c,7e,7f(ok) ok 79,7d
3553735a -> 7c (195eb - (222fc - routine from 222ed to ) (7x j...) no 70,71,79,7a,7b ok (78,7c) -> 7c
35637463 -> 7d (1df7f, 1df8c, 1df95, 21f08 - routine from 1df27 to ) no 70,78,7a,7b,7c,7e,7f(ok) ok 79,7d
3573757b -> 0d
35837682 -> 78 (78,7c) -> 78
35937786 -> 2d
378ab -> 48 (1956f - routine from 194e1 to 19619 - bp 19567) (when the water go up) -> 48
379b3 -> b6 (216b6 - 216cf - 16663 (when you rotate a piece) - 175f1 - 17d2a - 17d36) -> b6
380b9 -> 0c (21210 - routine from 2117e to ) 2 bytes -> to handle messages in level 0 (learning level)
360381ba -> 4b (1094d, 10b28 - routine from 10948 to 10b73) one byte -> probably 4b
361ce -> 01 (10236 - routine from 1017e to 10254) (01, 09, 19, 21, 29, 31) -> probably 01
362382f1 -> 20 to handle the player number
363383
364384rz guess:
src/mame/machine/playch10.c
r2375r2376
6161 *************************************/
6262READ8_HANDLER( pc10_port_0_r )
6363{
64   return readinputport( 0 ) | ( ( ~pc10_int_detect & 1 ) << 3 );
64   return input_port_read_indexed(machine, 0 ) | ( ( ~pc10_int_detect & 1 ) << 3 );
6565}
6666
6767WRITE8_HANDLER( pc10_SDCS_w )
r2375r2376
183183      return;
184184
185185   /* load up the latches */
186   input_latch[0] = readinputport( 3 );
187   input_latch[1] = readinputport( 4 );
186   input_latch[0] = input_port_read_indexed(machine,  3 );
187   input_latch[1] = input_port_read_indexed(machine,  4 );
188188
189189   /* apply any masking from the BIOS */
190190   if ( cntrl_mask )
r2375r2376
218218   /* do the gun thing */
219219   if ( pc10_gun_controller )
220220   {
221      int trigger = readinputport( 3 );
222      int x = readinputport( 5 );
223      int y = readinputport( 6 );
221      int trigger = input_port_read_indexed(machine,  3 );
222      int x = input_port_read_indexed(machine,  5 );
223      int y = input_port_read_indexed(machine,  6 );
224224      UINT32 pix, color_base;
225225
226226      /* no sprite hit (yet) */
src/mame/machine/bublbobl.c
r2375r2376
181181READ8_HANDLER( bublbobl_mcu_port1_r )
182182{
183183//logerror("%04x: 6801U4 port 1 read\n",activecpu_get_pc());
184   port1_in = readinputport(0);
184   port1_in = input_port_read_indexed(machine, 0);
185185   return (port1_out & ddr1) | (port1_in & ~ddr1);
186186}
187187
r2375r2376
230230      {
231231         // read
232232         if ((address & 0x0800) == 0x0000)
233            port3_in = readinputport((address & 3) + 1);
233            port3_in = input_port_read_indexed(machine, (address & 3) + 1);
234234         else if ((address & 0x0c00) == 0x0c00)
235235            port3_in = bublbobl_mcu_sharedram[address & 0x03ff];
236236//          logerror("reading %02x from shared RAM %04x\n",port3_in,address);
r2375r2376
451451         if ((address & 0x0800) == 0x0000)
452452         {
453453//logerror("%04x: 68705 read input port %02x\n",activecpu_get_pc(),address);
454            latch = readinputport((address & 3) + 1);
454            latch = input_port_read_indexed(machine, (address & 3) + 1);
455455         }
456456         else if ((address & 0x0c00) == 0x0c00)
457457         {
src/mame/machine/s16fd.c
r2375r2376
2626static int fd1094_cached_states[CACHE_ENTRIES]; // array of cached state numbers
2727static int fd1094_current_cacheposition; // current position in cache array
2828
29static int fd1094_state;
30static int fd1094_selected_state;
31
2932static void (*fd1094_set_decrypted)(UINT8 *);
3033
3134void *fd1094_get_decrypted_base(void)
r2375r2376
5255   int i;
5356   UINT32 addr;
5457
58   switch (state & 0x300)
59   {
60   case 0x000:
61   case FD1094_STATE_RESET:
62      fd1094_selected_state = state & 0xff;
63      break;
64   }
65
66   fd1094_state = state;
67
5568   cpunum_set_info_int(0, CPUINFO_INT_REGISTER + M68K_PREF_ADDR, 0x0010);   // force a flush of the prefetch cache
5669
5770   /* set the FD1094 state ready to decrypt.. */
r2375r2376
142155   cpunum_set_irq_callback(0, fd1094_int_callback);
143156}
144157
158static STATE_POSTLOAD( fd1094_postload )
159{
160   if (fd1094_state != -1)
161   {
162      int selected_state = fd1094_selected_state;
163      int state = fd1094_state;
145164
165      fd1094_machine_init();
166
167      fd1094_setstate_and_decrypt(selected_state);
168      fd1094_setstate_and_decrypt(state);
169   }
170}
171
172
146173#ifdef ENABLE_DEBUGGER
147174static void key_changed(void)
148175{
r2375r2376
186213      fd1094_cacheregion[i] = auto_malloc(fd1094_cpuregionsize);
187214      fd1094_cached_states[i] = -1;
188215   }
189   fd1094_current_cacheposition = 0;
216     fd1094_current_cacheposition = 0;
217   fd1094_state = -1;
190218
191219#ifdef ENABLE_DEBUGGER
192220   /* key debugging */
r2375r2376
196224      fd1094_init_debugging(REGION_CPU1, REGION_USER1, REGION_USER2, key_changed);
197225   }
198226#endif
227
228   state_save_register_global(fd1094_selected_state);
229   state_save_register_global(fd1094_state);
230   state_save_register_postload(Machine, fd1094_postload, NULL);
199231}
src/mame/machine/tnzs.c
r2375r2376
7777
7878   switch (tnzs_input_select & 0x0f)
7979   {
80      case 0x0a:   data = input_port_4_r(machine,0); break;
81      case 0x0c:   data = input_port_2_r(machine,0); break;
82      case 0x0d:   data = input_port_3_r(machine,0); break;
80      case 0x0a:   data = input_port_read_indexed(machine, 4); break;
81      case 0x0c:   data = input_port_read_indexed(machine, 2); break;
82      case 0x0d:   data = input_port_read_indexed(machine, 3); break;
8383      default:   data = 0xff; break;
8484   }
8585
r2375r2376
9090
9191READ8_HANDLER( tnzs_port2_r )
9292{
93   int data = input_port_4_r(machine,0);
93   int data = input_port_read_indexed(machine, 4);
9494
9595//  logerror("I8742:%04x  Read %02x from port 2\n", activecpu_get_previouspc(), data);
9696
r2375r2376
117117
118118//  logerror("PC %04x: read input %04x\n", activecpu_get_pc(), 0xf000 + offset);
119119
120   val = readinputport(7 + offset/2);
120   val = input_port_read_indexed(machine, 7 + offset/2);
121121   if (offset & 1)
122122   {
123123      return ((val >> 8) & 0xff);
r2375r2376
247247               }
248248               else return mcu_credits;
249249            }
250            else return readinputport(2);   /* buttons */
250            else return input_port_read_indexed(machine, 2);   /* buttons */
251251
252252         default:
253253            logerror("error, unknown mcu command\n");
r2375r2376
338338      switch (mcu_command)
339339      {
340340         case 0x01:
341            return readinputport(2) ^ 0xff;   /* player 1 joystick + buttons */
341            return input_port_read_indexed(machine, 2) ^ 0xff;   /* player 1 joystick + buttons */
342342
343343         case 0x02:
344            return readinputport(3) ^ 0xff;   /* player 2 joystick + buttons */
344            return input_port_read_indexed(machine, 3) ^ 0xff;   /* player 2 joystick + buttons */
345345
346346         case 0x1a:
347            return (readinputport(5) | (readinputport(6) << 1));
347            return (input_port_read_indexed(machine, 5) | (input_port_read_indexed(machine, 6) << 1));
348348
349349         case 0x21:
350            return readinputport(4) & 0x0f;
350            return input_port_read_indexed(machine, 4) & 0x0f;
351351
352352         case 0x41:
353353            return mcu_credits;
r2375r2376
375375               else return mcu_credits;
376376            }
377377            /* buttons */
378            else return ((readinputport(2) & 0xf0) | (readinputport(3) >> 4)) ^ 0xff;
378            else return ((input_port_read_indexed(machine, 2) & 0xf0) | (input_port_read_indexed(machine, 3) >> 4)) ^ 0xff;
379379
380380         default:
381381            logerror("error, unknown mcu command\n");
r2375r2376
660660      case MCU_DRTOPPEL:
661661      case MCU_PLUMPOP:
662662         coin  = 0;
663         coin |= ((readinputport(5) & 1) << 0);
664         coin |= ((readinputport(6) & 1) << 1);
665         coin |= ((readinputport(4) & 3) << 2);
663         coin |= ((input_port_read_indexed(machine, 5) & 1) << 0);
664         coin |= ((input_port_read_indexed(machine, 6) & 1) << 1);
665         coin |= ((input_port_read_indexed(machine, 4) & 3) << 2);
666666         coin ^= 0x0c;
667667         mcu_handle_coins(coin);
668668         break;
src/mame/machine/atari.c
r2375r2376
8080
8181static READ8_HANDLER(atari_pia_pa_r)
8282{
83   return atari_input_disabled() ? 0xFF : readinputportbytag_safe("djoy_0_1", 0);
83   return atari_input_disabled() ? 0xFF : input_port_read_safe(machine, "djoy_0_1", 0);
8484}
8585
8686static READ8_HANDLER(atari_pia_pb_r)
8787{
88   return atari_input_disabled() ? 0xFF : readinputportbytag_safe("djoy_2_3", 0);
88   return atari_input_disabled() ? 0xFF : input_port_read_safe(machine, "djoy_2_3", 0);
8989}
9090
9191static WRITE8_HANDLER(a600xl_pia_pb_w) { a600xl_mmu(data); }
r2375r2376
521521};
522522
523523
524void a800_handle_keyboard(void)
524void a800_handle_keyboard(running_machine *machine)
525525{
526526   static int atari_last = 0xff;
527527   int i, modifiers, atari_code;
r2375r2376
540540   for( i = 0; i < 64; i++ )
541541   {
542542      sprintf(tag, "keyboard_%d", i / 16);
543      if( readinputportbytag_safe(tag, 0) & (1 << (i&15)) )
543      if( input_port_read_safe(machine, tag, 0) & (1 << (i&15)) )
544544      {
545545         atari_code = keys[i][modifiers];
546546         if( atari_code != AKEY_NONE )
r2375r2376
566566#define VKEY_BREAK      0x10
567567
568568/* absolutely no clue what to do here :((( */
569void a5200_handle_keypads(void)
569void a5200_handle_keypads(running_machine *machine)
570570{
571571   int i, modifiers;
572572   static int atari_last = 0xff;
r2375r2376
584584   /* check keypad */
585585   for (i = 0; i < 16; i++)
586586   {
587      if( readinputportbytag("keypad") & (1 << i) )
587      if( input_port_read(machine, "keypad") & (1 << i) )
588588      {
589589         if( i == atari_last )
590590            return;
r2375r2376
600600   }
601601
602602   /* check top button */
603   if ((readinputportbytag("djoy_b") & 0x10) == 0)
603   if ((input_port_read(machine, "djoy_b") & 0x10) == 0)
604604   {
605605      if (atari_last == 0xFE)
606606         return;
r2375r2376
714714
715715static UINT8 console_read(void)
716716{
717   return readinputportbytag("console");
717   return input_port_read(Machine, "console");
718718}
719719
720720
r2375r2376
739739}
740740
741741
742static void atari_machine_start(int type, const pia6821_interface *pia_intf, int has_cart)
742static void atari_machine_start(running_machine *machine, int type, const pia6821_interface *pia_intf, int has_cart)
743743{
744744   gtia_interface gtia_intf;
745745
r2375r2376
751751      gtia_intf.console_read = console_read;
752752   if (sndti_exists(SOUND_DAC, 0))
753753      gtia_intf.console_write = console_write;
754   gtia_init(&gtia_intf);
754   gtia_init(machine, &gtia_intf);
755755
756756   /* pokey */
757757   add_reset_callback(Machine, pokey_reset);
r2375r2376
814814
815815MACHINE_START( a400 )
816816{
817   atari_machine_start(ATARI_400, &atari_pia_interface, TRUE);
817   atari_machine_start(machine, ATARI_400, &atari_pia_interface, TRUE);
818818}
819819
820820MACHINE_START( a600xl )
821821{
822   atari_machine_start(ATARI_600XL, &a600xl_pia_interface, TRUE);
822   atari_machine_start(machine, ATARI_600XL, &a600xl_pia_interface, TRUE);
823823}
824824
825825
r2375r2376
832832
833833MACHINE_START( a800 )
834834{
835   atari_machine_start(ATARI_800, &atari_pia_interface, TRUE);
835   atari_machine_start(machine, ATARI_800, &atari_pia_interface, TRUE);
836836}
837837
838838
r2375r2376
886886
887887MACHINE_START( a800xl )
888888{
889   atari_machine_start(ATARI_800XL, &a800xl_pia_interface, TRUE);
889   atari_machine_start(machine, ATARI_800XL, &a800xl_pia_interface, TRUE);
890890}
891891
892892
r2375r2376
943943
944944MACHINE_START( a5200 )
945945{
946   atari_machine_start(ATARI_800XL, NULL, FALSE);
946   atari_machine_start(machine, ATARI_800XL, NULL, FALSE);
947947}
948948
949949
src/mame/machine/midyunit.c
r2375r2376
142142
143143READ16_HANDLER( midyunit_input_r )
144144{
145   return readinputport(offset);
145   return input_port_read_indexed(machine, offset);
146146}
147147
148148
r2375r2376
156156static READ16_HANDLER( term2_input_r )
157157{
158158   if (offset != 2)
159      return readinputport(offset);
159      return input_port_read_indexed(machine, offset);
160160
161161   switch (term2_analog_select)
162162   {
163163      default:
164      case 0:  return readinputport(2);  break;
165      case 1:  return readinputport(6);  break;
166      case 2:  return readinputport(7);  break;
167      case 3:  return readinputport(8);  break;
164      case 0:  return input_port_read_indexed(machine, 2);  break;
165      case 1:  return input_port_read_indexed(machine, 6);  break;
166      case 2:  return input_port_read_indexed(machine, 7);  break;
167      case 3:  return input_port_read_indexed(machine, 8);  break;
168168   }
169169}
170170
src/mame/machine/asteroid.c
r2375r2376
1717INTERRUPT_GEN( asteroid_interrupt )
1818{
1919   /* Turn off interrupts if self-test is enabled */
20   if (!(readinputport(0) & 0x80))
20   if (!(input_port_read_indexed(machine, 0) & 0x80))
2121      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
2222}
2323
2424INTERRUPT_GEN( asterock_interrupt )
2525{
2626   /* Turn off interrupts if self-test is enabled */
27   if ((readinputport(0) & 0x80))
27   if ((input_port_read_indexed(machine, 0) & 0x80))
2828      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
2929}
3030
3131INTERRUPT_GEN( llander_interrupt )
3232{
3333   /* Turn off interrupts if self-test is enabled */
34   if (readinputport(0) & 0x02)
34   if (input_port_read_indexed(machine, 0) & 0x02)
3535      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
3636}
3737
r2375r2376
4242   int res;
4343   int bitmask;
4444
45   res=readinputport(0);
45   res=input_port_read_indexed(machine, 0);
4646
4747   bitmask = (1 << offset);
4848
r2375r2376
6464{
6565   int res;
6666
67   res=readinputport(0);
67   res=input_port_read_indexed(machine, 0);
6868
6969//  if (activecpu_gettotalcycles() & 0x100)
7070//      res |= 0x02;
r2375r2376
7979   int res;
8080   int bitmask;
8181
82   res=readinputport(0);
82   res=input_port_read_indexed(machine, 0);
8383
8484   bitmask = (1 << offset);
8585
r2375r2376
106106   int res;
107107   int bitmask;
108108
109   res=readinputport(1);
109   res=input_port_read_indexed(machine, 1);
110110   bitmask = (1 << (offset & 0x7));
111111
112112   if (res & bitmask)
r2375r2376
122122   int res;
123123   int res1;
124124
125   res1 = readinputport(2);
125   res1 = input_port_read_indexed(machine, 2);
126126
127127   res = 0xfc | ((res1 >> (2 * (3 - (offset & 0x3)))) & 0x3);
128128   return res;
r2375r2376
182182{
183183   int res;
184184
185   res = readinputport(0);
185   res = input_port_read_indexed(machine, 0);
186186
187187   if (avgdvg_done())
188188      res |= 0x01;
src/mame/machine/mhavoc.c
r2375r2376
225225   /* Bits 7-6 = selected based on Player 1 */
226226   /* Bits 5-4 = common */
227227   if (player_1)
228      res = (readinputport(0) & 0x30) | (readinputport(5) & 0xc0);
228      res = (input_port_read_indexed(machine, 0) & 0x30) | (input_port_read_indexed(machine, 5) & 0xc0);
229229   else
230      res = readinputport(0) & 0xf0;
230      res = input_port_read_indexed(machine, 0) & 0xf0;
231231
232232   /* Bit 3 = Gamma rcvd flag */
233233   if (gamma_rcvd)
r2375r2376
252252READ8_HANDLER( alphaone_port_0_r )
253253{
254254   /* Bits 7-2 = common */
255   UINT8 res = readinputport(0) & 0xfc;
255   UINT8 res = input_port_read_indexed(machine, 0) & 0xfc;
256256
257257   /* Bit 1 = 2.4kHz (divide 2.5MHz by 1024) */
258258   if (!(activecpu_gettotalcycles() & 0x400))
r2375r2376
269269READ8_HANDLER( mhavoc_port_1_r )
270270{
271271   /* Bits 7-2 = input switches */
272   UINT8 res = readinputport(1) & 0xfc;
272   UINT8 res = input_port_read_indexed(machine, 1) & 0xfc;
273273
274274   /* Bit 1 = Alpha rcvd flag */
275275   if (has_gamma_cpu && alpha_rcvd)
r2375r2376
285285READ8_HANDLER( mhavoc_port_1_sp_r )
286286{
287287   /* Bits 7-3 = input switches */
288   UINT8 res = readinputport(1) & 0xf8;
288   UINT8 res = input_port_read_indexed(machine, 1) & 0xf8;
289289
290290   /* Bit 2 = TMS5220 ready flag */
291291   if (!tms5220_ready_r())
src/mame/machine/decocass.c
r2375r2376
208208   switch (offset & 7)
209209   {
210210   case 0: case 1: case 2:
211      data = readinputport(offset & 7);
211      data = input_port_read_indexed(machine, offset & 7);
212212      break;
213213   case 3: case 4: case 5: case 6:
214214      data = decocass_quadrature_decoder[(offset & 7) - 3];
r2375r2376
15891589 *  state save setup
15901590 *
15911591 ***************************************************************************/
1592static void decocass_state_save_postload(void)
1592static STATE_POSTLOAD( decocass_state_save_postload )
15931593{
15941594#if 0
15951595   /* fix me - this won't work anymore */
r2375r2376
16081608}
16091609
16101610/* To be called once from driver_init, i.e. decocass_init */
1611void decocass_machine_state_save_init(void)
1611void decocass_machine_state_save_init(running_machine *machine)
16121612{
1613   state_save_register_func_postload(decocass_state_save_postload);
1613   state_save_register_postload(machine, decocass_state_save_postload, NULL);
16141614   state_save_register_global(tape_dir);
16151615   state_save_register_global(tape_speed);
16161616   state_save_register_global(tape_time0.seconds);
src/mame/machine/copsnrob.c
r2375r2376
2525    default:
2626    case 0x00:
2727        current_car_image = copsnrob_carimage[0];
28        keys = input_port_4_r(machine,0);
28        keys = input_port_read_indexed(machine, 4);
2929        break;
3030    case 0x04:
3131        current_car_image = copsnrob_carimage[1];
32        keys = input_port_5_r(machine,0);
32        keys = input_port_read_indexed(machine, 5);
3333        break;
3434    case 0x08:
3535        current_car_image = copsnrob_carimage[2];
36        keys = input_port_6_r(machine,0);
36        keys = input_port_read_indexed(machine, 6);
3737        break;
3838    case 0x0c:
3939        current_car_image = copsnrob_carimage[3];
40        keys = input_port_7_r(machine,0);
40        keys = input_port_read_indexed(machine, 7);
4141        break;
4242    }
4343
src/mame/machine/twincobr.c
r2375r2376
207207   }
208208}
209209
210static void twincobr_restore_dsp(void)
210static STATE_POSTLOAD( twincobr_restore_dsp )
211211{
212212   twincobr_dsp(twincobr_dsp_on);
213213}
r2375r2376
325325   fsharkbt_8741 = -1;         /* Reset the Flying Shark Bootleg MCU */
326326   twincobr_dsp_BIO = CLEAR_LINE;
327327}
328void twincobr_driver_savestate(void)
328void twincobr_driver_savestate(running_machine *machine)
329329{
330330   state_save_register_global(toaplan_main_cpu);
331331   state_save_register_global(twincobr_intenable);
r2375r2376
335335   state_save_register_global(twincobr_dsp_BIO);
336336   state_save_register_global(dsp_execute);
337337   state_save_register_global(fsharkbt_8741);
338   state_save_register_func_postload(twincobr_restore_dsp);
338   state_save_register_postload(machine, twincobr_restore_dsp, NULL);
339339}
340340
341341MACHINE_RESET( wardner )
r2375r2376
349349   twincobr_dsp_BIO = CLEAR_LINE;
350350   wardner_membank = 0;
351351}
352void wardner_driver_savestate(void)
352void wardner_driver_savestate(running_machine *machine)
353353{
354354   state_save_register_global(toaplan_main_cpu);
355355   state_save_register_global(twincobr_intenable);
r2375r2376
359359   state_save_register_global(twincobr_dsp_BIO);
360360   state_save_register_global(dsp_execute);
361361   state_save_register_global(wardner_membank);
362   state_save_register_func_postload(wardner_restore_bank);   /* Restore the Main CPU bank */
363   state_save_register_func_postload(twincobr_restore_dsp);
362   state_save_register_postload(machine, wardner_restore_bank, NULL);   /* Restore the Main CPU bank */
363   state_save_register_postload(machine, twincobr_restore_dsp, NULL);
364364}
src/mame/machine/decocass.h
r2375r2376
7171extern WRITE8_HANDLER( i8041_p2_w );
7272extern READ8_HANDLER( i8041_p2_r );
7373
74void decocass_machine_state_save_init(void);
74void decocass_machine_state_save_init(running_machine *machine);
7575
7676/*----------- defined in video/decocass.c -----------*/
7777extern WRITE8_HANDLER( decocass_paletteram_w );
src/mame/machine/irobot.c
r2375r2376
226226{
227227
228228   if (irobot_control_num == 0)
229      return readinputport (5);
229      return input_port_read_indexed(machine, 5);
230230   else if (irobot_control_num == 1)
231      return readinputport (6);
231      return input_port_read_indexed(machine, 6);
232232   return 0;
233233
234234}
src/mame/machine/leland.c
r2375r2376
129129
130130READ8_HANDLER( cerberus_dial_1_r )
131131{
132   int original = readinputport(0);
133   int modified = dial_compute_value(readinputport(4), 0);
132   int original = input_port_read_indexed(machine, 0);
133   int modified = dial_compute_value(input_port_read_indexed(machine, 4), 0);
134134   return (original & 0xc0) | ((modified & 0x80) >> 2) | (modified & 0x1f);
135135}
136136
137137
138138READ8_HANDLER( cerberus_dial_2_r )
139139{
140   int original = readinputport(2);
141   int modified = dial_compute_value(readinputport(5), 1);
140   int original = input_port_read_indexed(machine, 2);
141   int modified = dial_compute_value(input_port_read_indexed(machine, 5), 1);
142142   return (original & 0xc0) | ((modified & 0x80) >> 2) | (modified & 0x1f);
143143}
144144
r2375r2376
180180 *
181181 *************************************/
182182
183static void update_dangerz_xy(void)
183static void update_dangerz_xy(running_machine *machine)
184184{
185   UINT8 newy = readinputport(4);
186   UINT8 newx = readinputport(5);
185   UINT8 newy = input_port_read_indexed(machine, 4);
186   UINT8 newx = input_port_read_indexed(machine, 5);
187187   int deltay = newy - dial_last_input[0];
188188   int deltax = newx - dial_last_input[1];
189189
r2375r2376
206206
207207READ8_HANDLER( dangerz_input_y_r )
208208{
209   update_dangerz_xy();
209   update_dangerz_xy(machine);
210210   return dangerz_y & 0xff;
211211}
212212
213213
214214READ8_HANDLER( dangerz_input_x_r )
215215{
216   update_dangerz_xy();
216   update_dangerz_xy(machine);
217217   return dangerz_x & 0xff;
218218}
219219
220220
221221READ8_HANDLER( dangerz_input_upper_r )
222222{
223   update_dangerz_xy();
223   update_dangerz_xy(machine);
224224   return ((dangerz_y >> 2) & 0xc0) | ((dangerz_x >> 8) & 0x03);
225225}
226226
r2375r2376
236236
237237READ8_HANDLER( redline_pedal_1_r )
238238{
239   int pedal = readinputport(0);
239   int pedal = input_port_read_indexed(machine, 0);
240240   return redline_pedal_value[pedal >> 5] | 0x0f;
241241}
242242
243243
244244READ8_HANDLER( redline_pedal_2_r )
245245{
246   int pedal = readinputport(2);
246   int pedal = input_port_read_indexed(machine, 2);
247247   return redline_pedal_value[pedal >> 5] | 0x0f;
248248}
249249
250250
251251READ8_HANDLER( redline_wheel_1_r )
252252{
253   return dial_compute_value(readinputport(4), 0);
253   return dial_compute_value(input_port_read_indexed(machine, 4), 0);
254254}
255255
256256
257257READ8_HANDLER( redline_wheel_2_r )
258258{
259   return dial_compute_value(readinputport(5), 1);
259   return dial_compute_value(input_port_read_indexed(machine, 5), 1);
260260}
261261
262262
r2375r2376
269269
270270READ8_HANDLER( offroad_wheel_1_r )
271271{
272   return dial_compute_value(readinputport(7), 0);
272   return dial_compute_value(input_port_read_indexed(machine, 7), 0);
273273}
274274
275275
276276READ8_HANDLER( offroad_wheel_2_r )
277277{
278   return dial_compute_value(readinputport(8), 1);
278   return dial_compute_value(input_port_read_indexed(machine, 8), 1);
279279}
280280
281281
282282READ8_HANDLER( offroad_wheel_3_r )
283283{
284   return dial_compute_value(readinputport(9), 2);
284   return dial_compute_value(input_port_read_indexed(machine, 9), 2);
285285}
286286
287287
r2375r2376
294294
295295READ8_HANDLER( ataxx_trackball_r )
296296{
297   return dial_compute_value(readinputport(3 + offset), offset);
297   return dial_compute_value(input_port_read_indexed(machine, 3 + offset), offset);
298298}
299299
300300
r2375r2376
307307
308308READ8_HANDLER( indyheat_wheel_r )
309309{
310   return dial_compute_value(readinputport(3 + offset), offset);
310   return dial_compute_value(input_port_read_indexed(machine, 3 + offset), offset);
311311}
312312
313313
r2375r2376
337337   switch (offset)
338338   {
339339      case 3:
340         analog_result = readinputport(6 + data);
340         analog_result = input_port_read_indexed(machine, 6 + data);
341341         break;
342342
343343      case 0:
r2375r2376
493493INTERRUPT_GEN( leland_master_interrupt )
494494{
495495   /* check for coins here */
496   if ((readinputport(1) & 0x0e) != 0x0e)
496   if ((input_port_read_indexed(machine, 1) & 0x0e) != 0x0e)
497497      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, ASSERT_LINE);
498498}
499499
r2375r2376
844844
845845READ8_HANDLER( ataxx_eeprom_r )
846846{
847   int port = readinputport(2);
847   int port = input_port_read_indexed(machine, 2);
848848   if (LOG_EEPROM) logerror("%04X:EE read\n", safe_activecpu_get_pc());
849849   return (port & ~0x01) | EEPROM_read_bit();
850850}
r2375r2376
11141114         break;
11151115
11161116      case 0x01:   /* FE = analog port select/bankswitch */
1117         analog_result = readinputport((data & 15) + 4);
1117         analog_result = input_port_read_indexed(machine, (data & 15) + 4);
11181118
11191119         /* update top board banking for some games */
11201120         if (LOG_BANKSWITCHING_M)
r2375r2376
11451145   switch (offset)
11461146   {
11471147      case 0x00:   /* /GIN0 */
1148         result = readinputport(0);
1148         result = input_port_read_indexed(machine, 0);
11491149         break;
11501150
11511151      case 0x01:   /* /GIN1 */
1152         result = readinputport(1);
1152         result = input_port_read_indexed(machine, 1);
11531153         if (cpunum_get_reg(1, Z80_HALT))
11541154            result ^= 0x01;
11551155         break;
r2375r2376
11651165         break;
11661166
11671167      case 0x10:   /* /GIN0 */
1168         result = readinputport(2);
1168         result = input_port_read_indexed(machine, 2);
11691169         break;
11701170
11711171      case 0x11:   /* /GIN1 */
1172         result = readinputport(3);
1172         result = input_port_read_indexed(machine, 3);
11731173         if (LOG_EEPROM) logerror("%04X:EE read\n", safe_activecpu_get_pc());
11741174         result = (result & ~0x01) | EEPROM_read_bit();
11751175         break;
r2375r2376
12281228   switch (offset)
12291229   {
12301230      case 0x06:   /* /GIN0 */
1231         result = readinputport(0);
1231         result = input_port_read_indexed(machine, 0);
12321232         break;
12331233
12341234      case 0x07:   /* /SLVBLK */
1235         result = readinputport(1);
1235         result = input_port_read_indexed(machine, 1);
12361236         if (cpunum_get_reg(1, Z80_HALT))
12371237            result ^= 0x01;
12381238         break;
src/mame/machine/midwayic.c
r2375r2376
870870   switch (offset)
871871   {
872872      case IOASIC_PORT0:
873         result = readinputport(0);
873         result = input_port_read_indexed(machine, 0);
874874         /* bit 0 seems to be a ready flag before shuffling happens */
875875         if (!ioasic.shuffle_active)
876876         {
r2375r2376
882882         break;
883883
884884      case IOASIC_PORT1:
885         result = readinputport(1);
885         result = input_port_read_indexed(machine, 1);
886886         break;
887887
888888      case IOASIC_PORT2:
889         result = readinputport(2);
889         result = input_port_read_indexed(machine, 2);
890890         break;
891891
892892      case IOASIC_PORT3:
893         result = readinputport(3);
893         result = input_port_read_indexed(machine, 3);
894894         break;
895895
896896      case IOASIC_UARTIN:
src/mame/machine/bonzeadv.c
r2375r2376
445445   {
446446      switch (offset)
447447      {
448      case 0x03: return readinputportbytag("800007");    /* STARTn + SERVICE1 */
449      case 0x04: return readinputportbytag("800009");    /* COINn */
450      case 0x05: return readinputportbytag("80000B");    /* Player controls + TILT */
451      case 0x06: return readinputportbytag("80000D");    /* Player controls (cocktail) */
448      case 0x03: return input_port_read(machine, "800007");    /* STARTn + SERVICE1 */
449      case 0x04: return input_port_read(machine, "800009");    /* COINn */
450      case 0x05: return input_port_read(machine, "80000B");    /* Player controls + TILT */
451      case 0x06: return input_port_read(machine, "80000D");    /* Player controls (cocktail) */
452452      case 0x08: return cc_port;
453453      }
454454
src/mame/machine/toaplan1.c
r2375r2376
129129      cpunum_set_input_line(Machine, 2, INPUT_LINE_HALT, ASSERT_LINE);
130130   }
131131}
132static void demonwld_restore_dsp(void)
132static STATE_POSTLOAD( demonwld_restore_dsp )
133133{
134134   demonwld_dsp(demonwld_dsp_on);
135135}
r2375r2376
299299   toaplan1_unk_reset_port = 0;
300300   coin_lockout_global_w(0);
301301}
302void toaplan1_driver_savestate(void)
302void toaplan1_driver_savestate(running_machine *machine)
303303{
304304   state_save_register_global(toaplan1_intenable);
305305   state_save_register_global(toaplan1_coin_count);
r2375r2376
319319   main_ram_seg = 0;
320320   dsp_execute = 0;
321321}
322void demonwld_driver_savestate(void)
322void demonwld_driver_savestate(running_machine *machine)
323323{
324324   state_save_register_global(demonwld_dsp_on);
325325   state_save_register_global(dsp_addr_w);
326326   state_save_register_global(main_ram_seg);
327327   state_save_register_global(demonwld_dsp_BIO);
328328   state_save_register_global(dsp_execute);
329   state_save_register_func_postload(demonwld_restore_dsp);
329   state_save_register_postload(machine, demonwld_restore_dsp, NULL);
330330}
331331
332332MACHINE_RESET( vimana )
r2375r2376
335335   vimana_credits = 0;
336336   vimana_latch = 0;
337337}
338void vimana_driver_savestate(void)
338void vimana_driver_savestate(running_machine *machine)
339339{
340340   state_save_register_global(vimana_credits);
341341   state_save_register_global(vimana_latch);
src/mame/machine/daikaiju.c
r2375r2376
339339
340340READ8_HANDLER( daikaiju_mcu_status_r )
341341{
342   int res = input_port_3_r(machine,0);
342   int res = input_port_read_indexed(machine, 3);
343343
344344   res^=mame_rand(Machine)&3;
345345   res |=((lsasquad_sound_pending & 0x02)^2)<<3; //inverted flag
src/mame/machine/namcoio.c
r2375r2376
382382               }
383383            }
384384
385            if (~readinputport(0) & 0x80)   /* check test mode switch */
385            if (~input_port_read_indexed(machine, 0) & 0x80)   /* check test mode switch */
386386               return 0xbb;
387387
388388            return (io[chip].credits / 10) * 16 + io[chip].credits % 10;
src/mame/machine/dc.c
r2375r2376
446446                           maple0x86data2[3] = maple0x86data2[3] | 0x0c;
447447                           maple0x86data2[6] = maple0x86data2[6] & 0xcf;
448448
449                           a = readinputportbytag("IN0"); // put keys here
449                           a = input_port_read(machine, "IN0"); // put keys here
450450                           maple0x86data2[6] = maple0x86data2[6] | (a << 4);
451451                           pos = 0x11;
452452                           tocopy = 17;
r2375r2376
524524                                    // first function
525525                                    maple0x86data2[pos+ 9]=1; // report
526526                                    maple0x86data2[pos+10]=0; // bits TEST TILT1 TILT2 TILT3 ? ? ? ?
527                                    maple0x86data2[pos+11]=readinputportbytag("IN1"); // bits 1Pstart 1Pservice 1Pup 1Pdown 1Pleft 1Pright 1Ppush1 1Ppush2
528                                    maple0x86data2[pos+12]=readinputportbytag("IN2"); // bits 1Ppush3 1Ppush4 1Ppush5 1Ppush6 1Ppush7 1Ppush8 ...
529                                    maple0x86data2[pos+13]=readinputportbytag("IN3"); // bits 2Pstart 2Pservice 2Pup 2Pdown 2Pleft 2Pright 2Ppush1 2Ppush2
530                                    maple0x86data2[pos+14]=readinputportbytag("IN4"); // bits 2Ppush3 2Ppush4 2Ppush5 2Ppush6 2Ppush7 2Ppush8 ...
527                                    maple0x86data2[pos+11]=input_port_read(machine, "IN1"); // bits 1Pstart 1Pservice 1Pup 1Pdown 1Pleft 1Pright 1Ppush1 1Ppush2
528                                    maple0x86data2[pos+12]=input_port_read(machine, "IN2"); // bits 1Ppush3 1Ppush4 1Ppush5 1Ppush6 1Ppush7 1Ppush8 ...
529                                    maple0x86data2[pos+13]=input_port_read(machine, "IN3"); // bits 2Pstart 2Pservice 2Pup 2Pdown 2Pleft 2Pright 2Ppush1 2Ppush2
530                                    maple0x86data2[pos+14]=input_port_read(machine, "IN4"); // bits 2Ppush3 2Ppush4 2Ppush5 2Ppush6 2Ppush7 2Ppush8 ...
531531                                    // second function
532532                                    maple0x86data2[pos+15]=1; // report
533533                                    maple0x86data2[pos+16]=(dc_coin_counts[0] >> 8) & 0xff; // 1CONDITION, 1SLOT COIN(bit13-8)
src/mame/machine/scramble.c
r2375r2376
7070
7171   UINT8 res;
7272
73   res = readinputport(2);
73   res = input_port_read_indexed(machine, 2);
7474
7575/*logerror("%04x: read IN2\n",activecpu_get_pc());*/
7676
r2375r2376
9999
100100static READ8_HANDLER( ckongs_input_port_1_r )
101101{
102   return (readinputport(1) & 0xfc) | ((readinputport(2) & 0x06) >> 1);
102   return (input_port_read_indexed(machine, 1) & 0xfc) | ((input_port_read_indexed(machine, 2) & 0x06) >> 1);
103103}
104104
105105static READ8_HANDLER( ckongs_input_port_2_r )
106106{
107   return (readinputport(2) & 0xf9) | ((readinputport(1) & 0x03) << 1);
107   return (input_port_read_indexed(machine, 2) & 0xf9) | ((input_port_read_indexed(machine, 1) & 0x03) << 1);
108108}
109109
110110
r2375r2376
118118   UINT8 sign;
119119   UINT8 delta;
120120
121   delta = (moonwar_port_select ? readinputport(3) : readinputport(4));
121   delta = (moonwar_port_select ? input_port_read_indexed(machine, 3) : input_port_read_indexed(machine, 4));
122122
123123   sign = (delta & 0x80) >> 3;
124124   delta &= 0x0f;
125125
126   return ((readinputport(0) & 0xe0) | delta | sign );
126   return ((input_port_read_indexed(machine, 0) & 0xe0) | delta | sign );
127127}
128128
129129
130130/* the coinage DIPs are spread accross two input ports */
131131static READ8_HANDLER( stratgyx_input_port_2_r )
132132{
133   return (readinputport(2) & ~0x06) | ((readinputport(4) << 1) & 0x06);
133   return (input_port_read_indexed(machine, 2) & ~0x06) | ((input_port_read_indexed(machine, 4) << 1) & 0x06);
134134}
135135
136136static READ8_HANDLER( stratgyx_input_port_3_r )
137137{
138   return (readinputport(3) & ~0x03) | ((readinputport(4) >> 2) & 0x03);
138   return (input_port_read_indexed(machine, 3) & ~0x03) | ((input_port_read_indexed(machine, 4) >> 2) & 0x03);
139139}
140140
141141
r2375r2376
151151                       0x27, 0x26, 0x24, 0x25, 0x05, 0x04, 0x06, 0x07 };
152152   UINT8 val;
153153
154   val = readinputport(1);
154   val = input_port_read_indexed(machine, 1);
155155
156156   return ((val & 0x03) | (remap[val >> 2] << 2));
157157}
src/mame/machine/gaplus.c
r2375r2376
3737        switch (offset)
3838        {
3939            case 0:
40                return readinputport( 4 ); /* cabinet & test mode */
40                return input_port_read_indexed(machine, 4 ); /* cabinet & test mode */
4141                break;
4242            case 2:
4343                return 0x0f;
r2375r2376
5151        switch (offset)
5252        {
5353            case 0:
54                return readinputport( 4 ); /* cabinet & test mode */
54                return input_port_read_indexed(machine, 4 ); /* cabinet & test mode */
5555                break;
5656            case 1:
5757                return 0x0f;
src/mame/machine/midtunit.c
r2375r2376
105105
106106READ16_HANDLER( midtunit_input_r )
107107{
108   return readinputport(offset);
108   return input_port_read_indexed(machine, offset);
109109}
110110
111111
src/mame/machine/carpolo.c
r2375r2376
241241
242242
243243   /* check the coins here as well - they drive the clock of the flip-flops */
244   port_value = readinputport(0);
244   port_value = input_port_read_indexed(machine, 0);
245245
246246   TTL7474_clock_w(TTL7474_2S_1, port_value & 0x01);
247247   TTL7474_clock_w(TTL7474_2S_2, port_value & 0x02);
r2375r2376
261261      int dir_flip_flop      = movement_flip_flop + 1;
262262
263263
264      port_value = readinputport(2 + player);
264      port_value = input_port_read_indexed(machine, 2 + player);
265265
266266      if (port_value != last_wheel_value[player])
267267      {
r2375r2376
282282
283283
284284   /* finally read the accelerator pedals */
285   port_value = readinputport(6);
285   port_value = input_port_read_indexed(machine, 6);
286286
287287   for (player = 0; player < 4; player++)
288288   {
r2375r2376
446446        (TTL7474_output_r(TTL7474_1C_2) ? 0x02 : 0x00) |
447447        (TTL7474_output_r(TTL7474_1D_2) ? 0x04 : 0x00) |
448448        (TTL7474_output_r(TTL7474_1F_2) ? 0x08 : 0x00) |
449        (readinputport(7) & 0xf0);
449        (input_port_read_indexed(machine, 7) & 0xf0);
450450
451451   return ret;
452452}
src/mame/machine/namcos1.c
r2375r2376
12571257      int ret;
12581258
12591259      if (!qnum)
1260         ret = (readinputportbytag("CONTROL0")&0x90) | qstrobe | (readinputportbytag("PADDLE0")&0x0f);
1260         ret = (input_port_read(machine, "CONTROL0")&0x90) | qstrobe | (input_port_read(machine, "PADDLE0")&0x0f);
12611261      else
1262         ret = (readinputportbytag("CONTROL0")&0x90) | qstrobe | (readinputportbytag("PADDLE1")&0x0f);
1262         ret = (input_port_read(machine, "CONTROL0")&0x90) | qstrobe | (input_port_read(machine, "PADDLE1")&0x0f);
12631263
12641264      qstrobe ^= 0x40;
12651265
r2375r2376
12701270      int ret;
12711271
12721272      if (!qnum)
1273         ret = (readinputportbytag("CONTROL1")&0x90) | qnum | (readinputportbytag("PADDLE0")>>4);
1273         ret = (input_port_read(machine, "CONTROL1")&0x90) | qnum | (input_port_read(machine, "PADDLE0")>>4);
12741274      else
1275         ret = (readinputportbytag("CONTROL1")&0x90) | qnum | (readinputportbytag("PADDLE1")>>4);
1275         ret = (input_port_read(machine, "CONTROL1")&0x90) | qnum | (input_port_read(machine, "PADDLE1")>>4);
12761276
12771277      if (!qstrobe) qnum ^= 0x20;
12781278
r2375r2376
13021302   {
13031303      int inp = input_count;
13041304
1305      if (inp == 4) res = readinputportbytag("CONTROL0");
1305      if (inp == 4) res = input_port_read(machine, "CONTROL0");
13061306      else
13071307      {
13081308         char portname[4];
r2375r2376
13111311         static int counter[4];
13121312
13131313         sprintf(portname,"IN%d",inp);   /* IN0-IN3 */
1314         res = readinputportbytag(portname);
1314         res = input_port_read(machine, portname);
13151315         if (res & 0x80)
13161316         {
13171317            if (counter[inp] >= 0)
r2375r2376
13351335            counter[inp] = -1;
13361336#else
13371337         sprintf(portname,"IN%d",inp);   /* IN0-IN3 */
1338         res = readinputportbytag(portname);
1338         res = input_port_read(machine, portname);
13391339         if (res & 1) res = 0x7f;      /* weak */
13401340         else if (res & 2) res = 0x48;   /* medium */
13411341         else if (res & 4) res = 0x40;   /* strong */
r2375r2376
13461346   }
13471347   else
13481348   {
1349      res = readinputportbytag("CONTROL1") & 0x8f;
1349      res = input_port_read(machine, "CONTROL1") & 0x8f;
13501350
13511351      /* the strobe cannot happen too often, otherwise the MCU will waste too
13521352           much time reading the inputs and won't have enough cycles to play two
r2375r2376
13881388
13891389   if (offset == 0)
13901390   {
1391      res = (readinputportbytag("CONTROL0") & 0x80) | stored_input[0];
1391      res = (input_port_read(machine, "CONTROL0") & 0x80) | stored_input[0];
13921392
13931393      return res;
13941394   }
13951395   else
13961396   {
1397      res = readinputportbytag("CONTROL1") & 0x80;
1397      res = input_port_read(machine, "CONTROL1") & 0x80;
13981398
13991399      /* the strobe cannot happen too often, otherwise the MCU will waste too
14001400           much time reading the inputs and won't have enough cycles to play two
r2375r2376
14091409         switch (input_count)
14101410         {
14111411            case 0:
1412               stored_input[0] = readinputportbytag("IN0") & 0x1f;
1413               stored_input[1] = (readinputportbytag("IN3") & 0x07) << 3;
1412               stored_input[0] = input_port_read(machine, "IN0") & 0x1f;
1413               stored_input[1] = (input_port_read(machine, "IN3") & 0x07) << 3;
14141414
14151415            case 3:
1416               stored_input[0] = readinputportbytag("IN2") & 0x1f;
1416               stored_input[0] = input_port_read(machine, "IN2") & 0x1f;
14171417
14181418            case 4:
1419               stored_input[0] = readinputportbytag("IN1") & 0x1f;
1420               stored_input[1] = readinputportbytag("IN3") & 0x18;
1419               stored_input[0] = input_port_read(machine, "IN1") & 0x1f;
1420               stored_input[1] = input_port_read(machine, "IN3") & 0x18;
14211421         }
14221422
14231423         input_count = (input_count + 1) & 7;
src/mame/machine/pckeybrd.c
r2375r2376
1717*/
1818
1919#include "driver.h"
20#include "deprecat.h"
2021#include "machine/pckeybrd.h"
2122
2223#ifdef MESS
r2375r2376
508509{
509510   UINT32 result = 0;
510511   if (keyboard.ports[port] >= 0)
511      result = readinputport(keyboard.ports[port]);
512      result = input_port_read_indexed(Machine, keyboard.ports[port]);
512513   return result;
513514}
514515
src/mame/machine/n64.c
r2375r2376
208208   }
209209}
210210
211
212
213
214211static void sp_set_status(UINT32 status)
215212{
216213   if (status & 0x1)
r2375r2376
566563
567564
568565// Video Interface
569static UINT32 n64_vi_width;
566UINT32 n64_vi_width; // This needs to be non-static
570567UINT32 n64_vi_origin;
571568UINT32 n64_vi_control;
572569static UINT32 n64_vi_burst, n64_vi_vsync,  n64_vi_hsync,  n64_vi_leap,  n64_vi_hstart, n64_vi_vstart;
r2375r2376
703700
704701        /*
705702        Uncomment this for convenient homebrew debugging
703        */
706704        case 0x44/4:        // TEMP DEBUG
707705            printf( "E Ping: %08x\n", data );
708706            break;
709        */
710707
711708      default:
712709         logerror("vi_reg_w: %08X, %08X, %08X at %08X\n", data, offset, mem_mask, activecpu_get_pc());
r2375r2376
725722
726723static emu_timer *audio_timer;
727724
728#define SOUNDBUFFER_LENGTH   0x20000
729#define AUDIO_DMA_DEPTH      2
725#define AUDIO_DMA_DEPTH     2
730726
727static void start_audio_dma(void);
728
731729typedef struct
732730{
733   UINT32 address;
734   UINT32 length;
731    UINT32 address;
732    UINT32 length;
735733} AUDIO_DMA;
736734
737735static AUDIO_DMA audio_fifo[AUDIO_DMA_DEPTH];
r2375r2376
741739
742740static void audio_fifo_push(UINT32 address, UINT32 length)
743741{
744   AUDIO_DMA *current;
745   attotime period;
742    AUDIO_DMA *current;
746743
747   if (audio_fifo_num == AUDIO_DMA_DEPTH)
748   {
749      mame_printf_debug("audio_fifo_push: tried to push to full DMA FIFO!!!\n");
750   }
744    if (audio_fifo_num == AUDIO_DMA_DEPTH)
745    {
746        mame_printf_debug("audio_fifo_push: tried to push to full DMA FIFO!!!\n");
747    }
751748
752749//  mame_printf_debug("fifo_push: adr %08x len %08x\n", address, length);
753750
754   audio_fifo[audio_fifo_wpos].address = address;
755   audio_fifo[audio_fifo_wpos].length = length;
756   current = &audio_fifo[audio_fifo_wpos];
751    audio_fifo[audio_fifo_wpos].address = address;
752    audio_fifo[audio_fifo_wpos].length = length;
753    current = &audio_fifo[audio_fifo_wpos];
757754
758   audio_fifo_wpos++;
759   audio_fifo_num++;
755    audio_fifo_wpos++;
756    audio_fifo_num++;
760757
761   if (audio_fifo_wpos >= AUDIO_DMA_DEPTH)
762   {
763      audio_fifo_wpos = 0;
764   }
758    if (audio_fifo_wpos >= AUDIO_DMA_DEPTH)
759    {
760        audio_fifo_wpos = 0;
761    }
765762
766   if (audio_fifo_num >= AUDIO_DMA_DEPTH)
767   {
768      ai_status |= 0x80000001;   // FIFO full
769   }
763    if (audio_fifo_num >= AUDIO_DMA_DEPTH)
764    {
765        ai_status |= 0x80000001;    // FIFO full
766    }
770767
771   // adjust the timer
772   period = attotime_mul(ATTOTIME_IN_HZ(DACRATE_NTSC), (ai_dacrate + 1) * (current->length / 4));
773   timer_adjust_oneshot(audio_timer, period, 0);
768    if (! (ai_status & 0x40000000))
769    {
770        signal_rcp_interrupt(AI_INTERRUPT);
771        start_audio_dma();
772    }
774773}
775774
776775static void audio_fifo_pop(void)
777776{
778   audio_fifo_rpos++;
779   audio_fifo_num--;
777    audio_fifo_rpos++;
778    audio_fifo_num--;
780779
781   if (audio_fifo_num < 0)
782   {
783      fatalerror("audio_fifo_pop: FIFO underflow!\n");
784   }
780    if (audio_fifo_num < 0)
781    {
782        fatalerror("audio_fifo_pop: FIFO underflow!\n");
783    }
785784
786   if (audio_fifo_rpos >= AUDIO_DMA_DEPTH)
787   {
788      audio_fifo_rpos = 0;
789   }
785    if (audio_fifo_rpos >= AUDIO_DMA_DEPTH)
786    {
787        audio_fifo_rpos = 0;
788    }
790789
791   if (audio_fifo_num < AUDIO_DMA_DEPTH)
792   {
793      ai_status &= ~0x80000001;   // FIFO not full
794   }
795
796   ai_len = 0;
790    if (audio_fifo_num < AUDIO_DMA_DEPTH)
791    {
792        ai_status &= ~0x80000001;   // FIFO not full
793        signal_rcp_interrupt(AI_INTERRUPT);
794    }
797795}
798796
799797static AUDIO_DMA *audio_fifo_get_top(void)
800798{
801   if (audio_fifo_num > 0)
802   {
803      return &audio_fifo[audio_fifo_rpos];
804   }
805   else
806   {
807      return NULL;
808   }
799    if (audio_fifo_num > 0)
800    {
801        return &audio_fifo[audio_fifo_rpos];
802    }
803    else
804    {
805        return NULL;
806    }
809807}
810808
811809static void start_audio_dma(void)
812810{
813   INT16 *ram = (INT16*)rdram;
814   AUDIO_DMA *current = audio_fifo_get_top();
811    INT16 *ram = (INT16*)rdram;
812    AUDIO_DMA *current = audio_fifo_get_top();
813    attotime period;
815814
816   ram = &ram[current->address/2];
815    //static FILE * audio_dump = NULL;
816    //
817    //if (audio_dump == NULL)
818    //    audio_dump = fopen("audio_dump.raw","wb");
819    //
820    //fwrite(&ram[current->address/2],current->length,1,audio_dump);
817821
822    ram = &ram[current->address/2];
823
818824//  mame_printf_debug("DACDMA: %x for %x bytes\n", current->address, current->length);
819825
820   dmadac_transfer(0, 2, 2, 2, current->length/4, ram);
826    dmadac_transfer(0, 2, 2, 2, current->length/4, ram);
827
828    ai_status |= 0x40000000;
829
830   // adjust the timer
831   period = attotime_mul(ATTOTIME_IN_HZ(DACRATE_NTSC), (ai_dacrate + 1) * (current->length / 4));
832   timer_adjust_oneshot(audio_timer, period, 0);
821833}
822834
823835static TIMER_CALLBACK( audio_timer_callback )
824836{
825   audio_fifo_pop();
837    audio_fifo_pop();
826838
827   // keep playing if there's another DMA queued
828   if (audio_fifo_get_top() != NULL)
829   {
830      start_audio_dma();
831      signal_rcp_interrupt(AI_INTERRUPT);
832   }
839    // keep playing if there's another DMA queued
840    if (audio_fifo_get_top() != NULL)
841    {
842        start_audio_dma();
843        signal_rcp_interrupt(AI_INTERRUPT);
844    }
845    else
846    {
847        ai_status &= ~0x40000000;
848    }
833849}
834850
835851READ32_HANDLER( n64_ai_reg_r )
836852{
837   switch (offset)
838   {
839      case 0x04/4:      // AI_LEN_REG
840      {
841         return ai_len;
842      }
853    switch (offset)
854    {
855        case 0x04/4:        // AI_LEN_REG
856        {
857            if (ai_status & 0x80000001)
858            {
859                return ai_len;
860            }
861            else if (ai_status & 0x40000000)
862            {
863                double secs_left = attotime_to_double(attotime_sub(timer_firetime(audio_timer),timer_get_time()));
864                unsigned int samples_left = secs_left * DACRATE_NTSC / (ai_dacrate + 1);
865                return samples_left * 4;
866            }
867            else return 0;
868        }
843869
844      case 0x0c/4:      // AI_STATUS_REG
845         return ai_status;
870        case 0x0c/4:        // AI_STATUS_REG
871            return ai_status;
846872
847      default:
848         logerror("ai_reg_r: %08X, %08X at %08X\n", offset, mem_mask, activecpu_get_pc());
849         break;
850   }
873        default:
874            logerror("ai_reg_r: %08X, %08X at %08X\n", offset, mem_mask, activecpu_get_pc());
875            break;
876    }
851877
852   return 0;
878    return 0;
853879}
854880
855881WRITE32_HANDLER( n64_ai_reg_w )
856882{
857883//  UINT16 *ram = (UINT16*)rdram;
858884
859   switch (offset)
860   {
861      case 0x00/4:      // AI_DRAM_ADDR_REG
885    switch (offset)
886    {
887        case 0x00/4:        // AI_DRAM_ADDR_REG
862888//          mame_printf_debug("ai_dram_addr = %08X at %08X\n", data, activecpu_get_pc());
863         ai_dram_addr = data & 0xffffff;
864         break;
889            ai_dram_addr = data & 0xffffff;
890            break;
865891
866      case 0x04/4:      // AI_LEN_REG
892        case 0x04/4:        // AI_LEN_REG
867893//          mame_printf_debug("ai_len = %08X at %08X\n", data, activecpu_get_pc());
868         ai_len = data & 0x3ffff;      // Hardware v2.0 has 18 bits, v1.0 has 15 bits
869         audio_fifo_push(ai_dram_addr, ai_len);
870         break;
894            ai_len = data & 0x3ffff;        // Hardware v2.0 has 18 bits, v1.0 has 15 bits
895            audio_fifo_push(ai_dram_addr, ai_len);
896            break;
871897
872      case 0x08/4:      // AI_CONTROL_REG
898        case 0x08/4:        // AI_CONTROL_REG
873899//          mame_printf_debug("ai_control = %08X at %08X\n", data, activecpu_get_pc());
874         ai_control = data;
875         break;
900            ai_control = data;
901            break;
876902
877      case 0x0c/4:
878         clear_rcp_interrupt(AI_INTERRUPT);
879         break;
903        case 0x0c/4:
904            clear_rcp_interrupt(AI_INTERRUPT);
905            break;
880906
881      case 0x10/4:      // AI_DACRATE_REG
882         ai_dacrate = data & 0x3fff;
883         dmadac_set_frequency(0, 2, (double)DACRATE_NTSC / (double)(ai_dacrate+1));
884         dmadac_enable(0, 2, 1);
885         break;
907        case 0x10/4:        // AI_DACRATE_REG
908            ai_dacrate = data & 0x3fff;
909            dmadac_set_frequency(0, 2, (double)DACRATE_NTSC / (double)(ai_dacrate+1));
910            printf( "frequency: %f\n", (double)DACRATE_NTSC / (double)(ai_dacrate+1) );
911            dmadac_enable(0, 2, 1);
912            break;
886913
887      case 0x14/4:      // AI_BITRATE_REG
914        case 0x14/4:        // AI_BITRATE_REG
888915//          mame_printf_debug("ai_bitrate = %08X\n", data);
889         ai_bitrate = data & 0xf;
890         break;
916            ai_bitrate = data & 0xf;
917            break;
891918
892      default:
893         logerror("ai_reg_w: %08X, %08X, %08X at %08X\n", data, offset, mem_mask, activecpu_get_pc());
894         break;
895   }
919        default:
920            logerror("ai_reg_w: %08X, %08X, %08X at %08X\n", data, offset, mem_mask, activecpu_get_pc());
921            break;
922    }
896923}
897924
898925
r2375r2376
10921119   return crc;
10931120}
10941121
1095static int pif_channel_handle_command(int channel, int slength, UINT8 *sdata, int rlength, UINT8 *rdata)
1122static int pif_channel_handle_command(running_machine *machine, int channel, int slength, UINT8 *sdata, int rlength, UINT8 *rdata)
10961123{
10971124   int i;
10981125   UINT8 command = sdata[0];
r2375r2376
11561183         {
11571184            case 0:
11581185            {
1159               buttons = readinputport((channel*3) + 0);
1160               x = readinputport((channel*3) + 1) - 128;
1161               y = readinputport((channel*3) + 2) - 128;
1186                    buttons = input_port_read_indexed(machine, (channel*3) + 0);
1187                    x = input_port_read_indexed(machine, (channel*3) + 1) - 128;
1188                    y = input_port_read_indexed(machine, (channel*3) + 2) - 128;
11621189
11631190               rdata[0] = (buttons >> 8) & 0xff;
11641191               rdata[1] = (buttons >> 0) & 0xff;
r2375r2376
13191346   return 0;
13201347}
13211348
1322static void handle_pif(void)
1349static void handle_pif(running_machine *machine)
13231350{
13241351   int j;
13251352
r2375r2376
13711398                  send_buffer[j] = pif_cmd[cmd_ptr++];
13721399               }
13731400
1374               res = pif_channel_handle_command(channel, bytes_to_send, send_buffer, bytes_to_recv, recv_buffer);
1401                    res = pif_channel_handle_command(machine, channel, bytes_to_send, send_buffer, bytes_to_recv, recv_buffer);
13751402
13761403               if (res == 0)
13771404               {
r2375r2376
14111438    */
14121439}
14131440
1414static void pif_dma(int direction)
1441static void pif_dma(running_machine *machine, int direction)
14151442{
14161443   int i;
14171444   UINT32 *src, *dst;
r2375r2376
14381465   }
14391466   else            // PIF RAM -> RDRAM
14401467   {
1441      handle_pif();
1468      handle_pif(machine);
14421469
14431470      dst = (UINT32*)&rdram[(si_dram_addr & 0x1fffffff) / 4];
14441471
r2375r2376
14831510      case 0x04/4:      // SI_PIF_ADDR_RD64B_REG
14841511         // PIF RAM -> RDRAM
14851512         si_pif_addr = data;
1486         pif_dma(0);
1513            pif_dma(machine, 0);
14871514         break;
14881515
14891516      case 0x10/4:      // SI_PIF_ADDR_WR64B_REG
14901517         // RDRAM -> PIF RAM
14911518         si_pif_addr = data;
1492         pif_dma(1);
1519            pif_dma(machine, 1);
14931520         break;
14941521
14951522      case 0x18/4:      // SI_STATUS_REG
src/mame/machine/stfight.c
r2375r2376
118118// Perhaps define dipswitches as active low?
119119READ8_HANDLER( stfight_dsw_r )
120120{
121    return( ~readinputport( 3+offset ) );
121    return( ~input_port_read_indexed(machine, 3+offset ) );
122122}
123123
124124static int stfight_coin_mech_query_active = 0;
r2375r2376
145145     *        since it's read by the 30Hz interrupt ISR
146146     */
147147
148    coin_mech_data = readinputport( 5 );
148    coin_mech_data = input_port_read_indexed(machine, 5 );
149149
150150    for( i=0; i<2; i++ )
151151    {
src/mame/machine/tait8741.c
r2375r2376
470470         break;
471471      case 2:
472472#if 1
473         mcu->rxd = input_port_4_r(machine,0);  /* DSW2 */
473         mcu->rxd = input_port_read_indexed(machine, 4);  /* DSW2 */
474474         mcu->sts |= 0x01; /* RD ready */
475475#endif
476476         break;
src/mame/machine/volfied.c
r2375r2376
437437   {
438438      switch (offset)
439439      {
440      case 0x03: return readinputportbytag("F00007");    /* STARTn + SERVICE1 */
441      case 0x04: return readinputportbytag("F00009");    /* COINn */
442      case 0x05: return readinputportbytag("F0000B");    /* Player controls + TILT */
443      case 0x06: return readinputportbytag("F0000D");    /* Player controls (cocktail) */
440      case 0x03: return input_port_read(machine, "F00007");    /* STARTn + SERVICE1 */
441      case 0x04: return input_port_read(machine, "F00009");    /* COINn */
442      case 0x05: return input_port_read(machine, "F0000B");    /* Player controls + TILT */
443      case 0x06: return input_port_read(machine, "F0000D");    /* Player controls (cocktail) */
444444      case 0x08: return cc_port;
445445      }
446446   }
src/mame/machine/balsente.c
r2375r2376
2121static void counter_set_out(int which, int gate);
2222static TIMER_CALLBACK( counter_callback );
2323static TIMER_CALLBACK( clock_counter_0_ff );
24static void update_grudge_steering(void);
24static void update_grudge_steering(running_machine *machine);
2525
2626/* global data */
2727UINT8 balsente_shooter;
r2375r2376
123123
124124   /* if this is Grudge Match, update the steering */
125125   if (grudge_steering_result & 0x80)
126      update_grudge_steering();
126      update_grudge_steering(machine);
127127
128128   /* if we're a shooter, we do a little more work */
129129   if (balsente_shooter)
r2375r2376
133133      /* we latch the beam values on the first interrupt after VBLANK */
134134      if (param == 64 && balsente_shooter)
135135      {
136         balsente_shooter_x = readinputport(8);
137         balsente_shooter_y = readinputport(9);
136         balsente_shooter_x = input_port_read_indexed(machine, 8);
137         balsente_shooter_y = input_port_read_indexed(machine, 9);
138138      }
139139
140140      /* which bits get returned depends on which scanline we're at */
r2375r2376
611611   /* ports are read once a frame, just at varying intervals. To get around this, we */
612612   /* read all the analog inputs at VBLANK time and just return the cached values. */
613613   for (i = 0; i < 4; i++)
614      analog_input_data[i] = readinputport(4 + i);
614      analog_input_data[i] = input_port_read_indexed(machine, 4 + i);
615615}
616616
617617
r2375r2376
11221122
11231123READ8_HANDLER( nstocker_port2_r )
11241124{
1125   return (readinputport(2) & 0xf0) | nstocker_bits;
1125   return (input_port_read_indexed(machine, 2) & 0xf0) | nstocker_bits;
11261126}
11271127
11281128
r2375r2376
11611161}
11621162
11631163
1164static void update_grudge_steering(void)
1164static void update_grudge_steering(running_machine *machine)
11651165{
11661166   UINT8 wheel[3];
11671167   INT8 diff[3];
11681168
11691169   /* read the current steering values */
1170   wheel[0] = readinputport(4);
1171   wheel[1] = readinputport(5);
1172   wheel[2] = readinputport(6);
1170   wheel[0] = input_port_read_indexed(machine, 4);
1171   wheel[1] = input_port_read_indexed(machine, 5);
1172   wheel[2] = input_port_read_indexed(machine, 6);
11731173
11741174   /* diff the values */
11751175   diff[0] = wheel[0] - grudge_last_steering[0];
src/mame/machine/vsnes.c
r2375r2376
117117   if ( data & 1 )
118118   {
119119      /* load up the latches */
120      input_latch[0] = readinputport( 0 );
121      input_latch[1] = readinputport( 1 );
120      input_latch[0] = input_port_read_indexed(machine,  0 );
121      input_latch[1] = input_port_read_indexed(machine,  1 );
122122   }
123123}
124124
r2375r2376
129129   /* shift */
130130   input_latch[0] >>= 1;
131131
132   ret |= readinputport( 2 );             /* merge coins, etc */
133   ret |= ( readinputport( 3 ) & 3 ) << 3; /* merge 2 dipswitches */
132   ret |= input_port_read_indexed(machine,  2 );             /* merge coins, etc */
133   ret |= ( input_port_read_indexed(machine,  3 ) & 3 ) << 3; /* merge 2 dipswitches */
134134
135135/* The gun games expect a 1 returned on every 5th read after sound_fix is reset*/
136136/* Info Supplied by Ben Parnell <xodnizel@home.com> of FCE Ultra fame */
r2375r2376
155155   /* shift */
156156   input_latch[0] >>= 1;
157157
158   ret |= readinputport( 2 );             /* merge coins, etc */
159   ret |= ( readinputport( 3 ) & 3 ) << 3; /* merge 2 dipswitches */
158   ret |= input_port_read_indexed(machine,  2 );             /* merge coins, etc */
159   ret |= ( input_port_read_indexed(machine,  3 ) & 3 ) << 3; /* merge 2 dipswitches */
160160
161161   return ret;
162162
r2375r2376
167167{
168168   int ret = ( input_latch[1] ) & 1;
169169
170   ret |= readinputport( 3 ) & ~3;         /* merge the rest of the dipswitches */
170   ret |= input_port_read_indexed(machine, 3 ) & ~3;         /* merge the rest of the dipswitches */
171171
172172   /* shift */
173173   input_latch[1] >>= 1;
r2375r2376
181181   if ( data & 1 )
182182   {
183183      /* load up the latches */
184      input_latch[2] = readinputport( 4 );
185      input_latch[3] = readinputport( 5 );
184      input_latch[2] = input_port_read_indexed(machine,  4 );
185      input_latch[3] = input_port_read_indexed(machine,  5 );
186186   }
187187}
188188
r2375r2376
193193   /* shift */
194194   input_latch[2] >>= 1;
195195
196   ret |= readinputport( 6 );             /* merge coins, etc */
197   ret |= ( readinputport( 7 ) & 3 ) << 3; /* merge 2 dipswitches */
196   ret |= input_port_read_indexed(machine,  6 );             /* merge coins, etc */
197   ret |= ( input_port_read_indexed(machine,  7 ) & 3 ) << 3; /* merge 2 dipswitches */
198198   return ret;
199199}
200200
r2375r2376
202202{
203203   int ret = ( input_latch[3] ) & 1;
204204
205   ret |= readinputport( 7 ) & ~3;         /* merge the rest of the dipswitches */
205   ret |= input_port_read_indexed(machine, 7 ) & ~3;         /* merge the rest of the dipswitches */
206206
207207   /* shift */
208208   input_latch[3] >>= 1;
r2375r2376
345345   {
346346
347347      /* load up the latches */
348      input_latch[0] = readinputport( 0 );
348      input_latch[0] = input_port_read_indexed(machine, 0 );
349349
350350      /* do the gun thing */
351351      if ( vsnes_gun_controller )
352352      {
353         int x = readinputport( 4 );
354         int y = readinputport( 5 );
353         int x = input_port_read_indexed(machine,  4 );
354         int y = input_port_read_indexed(machine,  5 );
355355         UINT32 pix, color_base;
356356
357357         /* get the pixel at the gun position */
r2375r2376
368368         }
369369      }
370370
371      input_latch[1] = readinputport( 1 );
371      input_latch[1] = input_port_read_indexed(machine, 1 );
372372   }
373373
374374    if ( ( zapstore & 1 ) && ( !( data & 1 ) ) )
src/mame/machine/qix.c
r2375r2376
466466
467467   UINT8 ddr = state->_68705_ddr[1];
468468   UINT8 out = state->_68705_port_out[1];
469   UINT8 in = (readinputport(1) & 0x0f) | ((readinputport(1) & 0x80) >> 3);
469   UINT8 in = (input_port_read_indexed(machine, 1) & 0x0f) | ((input_port_read_indexed(machine, 1) & 0x80) >> 3);
470470   return (out & ddr) | (in & ~ddr);
471471}
472472
r2375r2376
477477
478478   UINT8 ddr = state->_68705_ddr[2];
479479   UINT8 out = state->_68705_port_out[2];
480   UINT8 in = (state->coinctrl & 0x08) | ((readinputport(1) & 0x70) >> 4);
480   UINT8 in = (state->coinctrl & 0x08) | ((input_port_read_indexed(machine, 1) & 0x70) >> 4);
481481   return (out & ddr) | (in & ~ddr);
482482}
483483
r2375r2376
598598{
599599   qix_state *state = machine->driver_data;
600600
601   return readinputport(state->flip ? 6 : 4);
601   return input_port_read_indexed(machine, state->flip ? 6 : 4);
602602}
603603
604604
r2375r2376
606606{
607607   qix_state *state = machine->driver_data;
608608
609   return readinputport(state->flip ? 5 : 3);
609   return input_port_read_indexed(machine, state->flip ? 5 : 3);
610610}
src/mame/machine/pcecommn.c
r2375r2376
5757   }
5858   else
5959   {
60      data = readinputport(0);
60      data = input_port_read_indexed(machine, 0);
6161   }
6262   if(joystick_data_select) data >>= 4;
6363   ret = (data & 0x0F) | pce.io_port_options;
src/mame/machine/mexico86.c
r2375r2376
4646
4747***************************************************************************/
4848
49static void mcu_simulate(void)
49static void mcu_simulate(running_machine *machine)
5050{
5151   if (!kikikai_mcu_initialised)
5252   {
r2375r2376
7171      int coin_curr;
7272
7373
74      coin_curr = ~readinputport(0) & 1;
74      coin_curr = ~input_port_read_indexed(machine, 0) & 1;
7575      if (coin_curr && !coin_last && mexico86_protection_ram[0x01] < 9)
7676      {
7777         mexico86_protection_ram[0x01]++;   // increase credits counter
r2375r2376
8181
8282      mexico86_protection_ram[0x04] = 0x3c;   // coin inputs
8383
84      mexico86_protection_ram[0x02] = BITSWAP8(readinputport(1), 7,6,5,4,2,3,1,0);   // player 1
85      mexico86_protection_ram[0x03] = BITSWAP8(readinputport(2), 7,6,5,4,2,3,1,0);   // player 2
84      mexico86_protection_ram[0x02] = BITSWAP8(input_port_read_indexed(machine, 1), 7,6,5,4,2,3,1,0);   // player 1
85      mexico86_protection_ram[0x03] = BITSWAP8(input_port_read_indexed(machine, 2), 7,6,5,4,2,3,1,0);   // player 2
8686
8787      if (mexico86_protection_ram[0x19] == 0xaa)   // player 2 active
8888         mexico86_protection_ram[0x1b] = mexico86_protection_ram[0x03];
r2375r2376
154154INTERRUPT_GEN( kikikai_interrupt )
155155{
156156   if (kikikai_mcu_running)
157      mcu_simulate();
157      mcu_simulate(machine);
158158
159159   cpunum_set_input_line_vector(0,0,mexico86_protection_ram[0]);
160160   cpunum_set_input_line(machine, 0,0,HOLD_LINE);
r2375r2376
302302         else
303303         {
304304//logerror("%04x: 68705 read input port %04x\n",activecpu_get_pc(),address);
305            latch = readinputport((address & 1) + 1);
305            latch = input_port_read_indexed(machine, (address & 1) + 1);
306306         }
307307      }
308308      else    /* write */
src/mame/machine/snes.c
r2375r2376
176176   {
177177      int i;
178178
179      joypad[0].low = readinputport( 0 );
180      joypad[0].high = readinputport( 1 );
181      joypad[1].low = readinputport( 2 );
182      joypad[1].high = readinputport( 3 );
183      joypad[2].low = readinputport( 4 );
184      joypad[2].high = readinputport( 5 );
185      joypad[3].low = readinputport( 6 );
186      joypad[3].high = readinputport( 7 );
179      joypad[0].low = input_port_read_indexed(machine,  0 );
180      joypad[0].high = input_port_read_indexed(machine,  1 );
181      joypad[1].low = input_port_read_indexed(machine,  2 );
182      joypad[1].high = input_port_read_indexed(machine,  3 );
183      joypad[2].low = input_port_read_indexed(machine,  4 );
184      joypad[2].high = input_port_read_indexed(machine,  5 );
185      joypad[3].low = input_port_read_indexed(machine,  6 );
186      joypad[3].high = input_port_read_indexed(machine,  7 );
187187
188188      // avoid sending signals that could crash games
189189      for (i = 0; i < 4; i++)
r2375r2376
953953#ifndef MESS
954954      case 0x4100:      /* NSS Dip-Switches */
955955#ifdef MAME_DEBUG
956         return readinputport(12);
956         return input_port_read_indexed(machine, 12);
957957#else
958         return readinputport(9);
958         return input_port_read_indexed(machine, 9);
959959#endif   /* MAME_DEBUG */
960960//      case 0x4101: //PC: a104 - a10e - a12a   //only nss_actr
961961//      case 0x420c: //PC: 9c7d - 8fab          //only nss_ssoc
src/mame/machine/amiga.c
r2375r2376
462462
463463CUSTOM_INPUT( amiga_joystick_convert )
464464{
465   UINT8 bits = readinputportbytag(param);
465   UINT8 bits = input_port_read(machine, param);
466466   int up = (bits >> 0) & 1;
467467   int down = (bits >> 1) & 1;
468468   int left = (bits >> 2) & 1;
r2375r2376
12041204
12051205      case REG_VPOSR:
12061206         CUSTOM_REG(REG_VPOSR) &= 0xff00;
1207         CUSTOM_REG(REG_VPOSR) |= amiga_gethvpos() >> 16;
1207         CUSTOM_REG(REG_VPOSR) |= amiga_gethvpos(machine->primary_screen) >> 16;
12081208         return CUSTOM_REG(REG_VPOSR);
12091209
12101210      case REG_VHPOSR:
1211         return amiga_gethvpos() & 0xffff;
1211         return amiga_gethvpos(machine->primary_screen) & 0xffff;
12121212
12131213      case REG_SERDATR:
12141214         CUSTOM_REG(REG_SERDATR) &= ~0x4000;
r2375r2376
12181218      case REG_JOY0DAT:
12191219         if (amiga_intf->joy0dat_r != NULL)
12201220            return (*amiga_intf->joy0dat_r)();
1221         return readinputportbytag_safe("JOY0DAT", 0xffff);
1221         return input_port_read_safe(machine, "JOY0DAT", 0xffff);
12221222
12231223      case REG_JOY1DAT:
12241224         if (amiga_intf->joy1dat_r != NULL)
12251225            return (*amiga_intf->joy1dat_r)();
1226         return readinputportbytag_safe("JOY1DAT", 0xffff);
1226         return input_port_read_safe(machine, "JOY1DAT", 0xffff);
12271227
12281228      case REG_ADKCONR:
12291229         return CUSTOM_REG(REG_ADKCON);
12301230
12311231      case REG_POTGOR:
1232         return readinputportbytag_safe("POTGO", 0x5500);
1232         return input_port_read_safe(machine, "POTGO", 0x5500);
12331233
12341234      case REG_POT0DAT:
1235         return readinputportbytag_safe("POT0DAT", 0x0000);
1235         return input_port_read_safe(machine, "POT0DAT", 0x0000);
12361236
12371237      case REG_POT1DAT:
1238         return readinputportbytag_safe("POT1DAT", 0x0000);
1238         return input_port_read_safe(machine, "POT1DAT", 0x0000);
12391239
12401240      case REG_DSKBYTR:
12411241         if (amiga_intf->dskbytr_r != NULL)
src/mame/machine/vertigo.c
r2375r2376
126126   if (offset > 2)
127127      adc_result = 0;
128128   else
129      adc_result = readinputport(offset);
129      adc_result = input_port_read_indexed(machine, offset);
130130
131131   update_irq_encoder(INPUT_LINE_IRQ2, ASSERT_LINE);
132132   return 0;
r2375r2376
143143READ16_HANDLER( vertigo_coin_r )
144144{
145145   update_irq_encoder(INPUT_LINE_IRQ6, CLEAR_LINE);
146   return (readinputportbytag("COIN"));
146   return (input_port_read(machine, "COIN"));
147147}
148148
149149
150150INTERRUPT_GEN( vertigo_interrupt )
151151{
152152   /* Coin inputs cause IRQ6 */
153   if ((readinputportbytag("COIN") & 0x7) < 0x7)
153   if ((input_port_read(machine, "COIN") & 0x7) < 0x7)
154154      update_irq_encoder(INPUT_LINE_IRQ6, ASSERT_LINE);
155155}
156156
src/mame/machine/atarigen.c
r2375r2376
502502}
503503
504504
505static void slapstic_postload(void)
505static STATE_POSTLOAD( slapstic_postload )
506506{
507507   update_bank(slapstic_bank());
508508}
r2375r2376
16391639    SAVE STATE
16401640***************************************************************************/
16411641
1642void atarigen_init_save_state(void)
1642void atarigen_init_save_state(running_machine *machine)
16431643{
16441644   state_save_register_global(atarigen_scanline_int_state);
16451645   state_save_register_global(atarigen_sound_int_state);
r2375r2376
16831683   state_save_register_global(playfield2_latch);
16841684
16851685   /* need a postload to reset the state */
1686   state_save_register_func_postload(slapstic_postload);
1686   state_save_register_postload(machine, slapstic_postload, NULL);
16871687}
src/mame/machine/atarigen.h
r2375r2376
238238    STATE SAVE
239239---------------------------------------------------------------*/
240240
241void atarigen_init_save_state(void);
241void atarigen_init_save_state(running_machine *machine);
242242
243243/***************************************************************************
244244    GENERAL ATARI NOTES
src/mame/machine/midwunit.c
r2375r2376
188188      case 1:
189189      case 2:
190190      case 3:
191         return readinputport(offset);
191         return input_port_read_indexed(machine, offset);
192192
193193      case 4:
194194         return (midway_serial_pic_status_r() << 12) | midwunit_sound_state_r(machine,0,0);
r2375r2376
211211      case 1:
212212      case 2:
213213      case 3:
214         return readinputport(offset);
214         return input_port_read_indexed(machine, offset);
215215
216216      default:
217217         logerror("%08X:Unknown I/O read from %d\n", activecpu_get_pc(), offset);
r2375r2376
223223
224224READ16_HANDLER( midxunit_analog_r )
225225{
226   return readinputport(midxunit_analog_port);
226   return input_port_read_indexed(machine, midxunit_analog_port);
227227}
228228
229229
src/mame/machine/namcos2.c
r2375r2376
743743      switch((data>>2)&0x07)
744744      {
745745      case 0:
746         namcos2_mcu_analog_data=input_port_2_r(machine,0);
746         namcos2_mcu_analog_data=input_port_read_indexed(machine, 2);
747747         break;
748748      case 1:
749         namcos2_mcu_analog_data=input_port_3_r(machine,0);
749         namcos2_mcu_analog_data=input_port_read_indexed(machine, 3);
750750         break;
751751      case 2:
752         namcos2_mcu_analog_data=input_port_4_r(machine,0);
752         namcos2_mcu_analog_data=input_port_read_indexed(machine, 4);
753753         break;
754754      case 3:
755         namcos2_mcu_analog_data=input_port_5_r(machine,0);
755         namcos2_mcu_analog_data=input_port_read_indexed(machine, 5);
756756         break;
757757      case 4:
758         namcos2_mcu_analog_data=input_port_6_r(machine,0);
758         namcos2_mcu_analog_data=input_port_read_indexed(machine, 6);
759759         break;
760760      case 5:
761         namcos2_mcu_analog_data=input_port_7_r(machine,0);
761         namcos2_mcu_analog_data=input_port_read_indexed(machine, 7);
762762         break;
763763      case 6:
764         namcos2_mcu_analog_data=input_port_8_r(machine,0);
764         namcos2_mcu_analog_data=input_port_read_indexed(machine, 8);
765765         break;
766766      case 7:
767         namcos2_mcu_analog_data=input_port_9_r(machine,0);
767         namcos2_mcu_analog_data=input_port_read_indexed(machine, 9);
768768         break;
769769      }
770770#if 0
r2375r2376
820820   int data=0;
821821
822822   /* Read/convert the bits one at a time */
823   if(input_port_2_r(machine,0)>threshold) data|=0x01;
824   if(input_port_3_r(machine,0)>threshold) data|=0x02;
825   if(input_port_4_r(machine,0)>threshold) data|=0x04;
826   if(input_port_5_r(machine,0)>threshold) data|=0x08;
827   if(input_port_6_r(machine,0)>threshold) data|=0x10;
828   if(input_port_7_r(machine,0)>threshold) data|=0x20;
829   if(input_port_8_r(machine,0)>threshold) data|=0x40;
830   if(input_port_9_r(machine,0)>threshold) data|=0x80;
823   if(input_port_read_indexed(machine, 2)>threshold) data|=0x01;
824   if(input_port_read_indexed(machine, 3)>threshold) data|=0x02;
825   if(input_port_read_indexed(machine, 4)>threshold) data|=0x04;
826   if(input_port_read_indexed(machine, 5)>threshold) data|=0x08;
827   if(input_port_read_indexed(machine, 6)>threshold) data|=0x10;
828   if(input_port_read_indexed(machine, 7)>threshold) data|=0x20;
829   if(input_port_read_indexed(machine, 8)>threshold) data|=0x40;
830   if(input_port_read_indexed(machine, 9)>threshold) data|=0x80;
831831
832832   /* Return the result */
833833   return data;
r2375r2376
835835
836836READ8_HANDLER( namcos2_input_port_0_r )
837837{
838   int data=readinputport(0);
838   int data=input_port_read_indexed(machine, 0);
839839   return data;
840840}
841841
842842READ8_HANDLER( namcos2_input_port_10_r )
843843{
844   int data=readinputport(10);
844   int data=input_port_read_indexed(machine, 10);
845845   return data;
846846}
847847
848848READ8_HANDLER( namcos2_input_port_12_r )
849849{
850   int data=readinputport(12);
850   int data=input_port_read_indexed(machine, 12);
851851   return data;
852852}
src/mame/machine/gaelco2.c
r2375r2376
193193   /* bit 6 is EEPROM data (DOUT) */
194194   /* bit 7 is EEPROM ready */
195195   /* bits 0-5, COINSW, STARTSW & Service */
196   return (1 << 7) | (EEPROM_read_bit() << 6) | (readinputport(2) & 0x3f);
196   return (1 << 7) | (EEPROM_read_bit() << 6) | (input_port_read_indexed(machine, 2) & 0x3f);
197197}
198198
199199WRITE16_HANDLER( gaelco2_eeprom_cs_w )
src/mame/machine/decoprot.c
r2375r2376
129129{
130130   switch (offset<<1) {
131131      case 0x110: /* Player input */
132         return readinputport(0);
132         return input_port_read_indexed(machine, 0);
133133
134134      case 0x36c: /* Coins */
135135      case 0x334: /* Probably also, c6, 2c0, 2e0, 4b2, 46a, 4da, rohga is 44c */
136         return readinputport(1);
136         return input_port_read_indexed(machine, 1);
137137      case 0x0dc:
138         return readinputport(1)<<4;
138         return input_port_read_indexed(machine, 1)<<4;
139139
140140      case 0x494: /* Dips */
141         return readinputport(2);
141         return input_port_read_indexed(machine, 2);
142142
143143      case 0x244:
144144         return deco16_prot_ram[0];
r2375r2376
361361
362362      /* Player 1 & 2 controls, read in IRQ then written *back* to protection device */
363363      case 0x50: /* written to 9e byte */
364         return readinputport(0);
364         return input_port_read_indexed(machine, 0);
365365      case 0x6f8: /* written to 76 byte */
366         return (readinputport(0)>>8)|(readinputport(0)<<8); /* byte swap IN0 */
366         return (input_port_read_indexed(machine, 0)>>8)|(input_port_read_indexed(machine, 0)<<8); /* byte swap IN0 */
367367
368368      case 0x5c: /* After coin insert, high 0x8000 bit set starts game */
369369         return deco16_prot_ram[0x3b];
r2375r2376
373373         return ((deco16_prot_ram[0x9e/2]&0xff00)>>8) | ((deco16_prot_ram[0x9e/2]&0x00ff)<<8);
374374
375375      case 0xac: /* Dip switches */
376         return readinputport(2);
376         return input_port_read_indexed(machine, 2);
377377      case 0xc2:
378         return readinputport(2) ^ deco16_prot_ram[0x2c/2];
378         return input_port_read_indexed(machine, 2) ^ deco16_prot_ram[0x2c/2];
379379
380380      case 0x5d4: /* The state of the dips last frame */
381381         return deco16_prot_ram[0x34/2];
r2375r2376
387387         return (((deco16_prot_ram[0]&0xfff0)>>0) | ((deco16_prot_ram[0]&0x000c)>>2) | ((deco16_prot_ram[0]&0x0003)<<2)) & (~deco16_prot_ram[0x36/2]);
388388
389389      case 0x76a: /* Coins */
390         return readinputport(1);
390         return input_port_read_indexed(machine, 1);
391391
392392      case 0x284: /* Bit shifting with inverted mask register */
393393         return (((deco16_prot_ram[0x40/2]&0xfff0)>>0) | ((deco16_prot_ram[0x40/2]&0x0007)<<1) | ((deco16_prot_ram[0x40/2]&0x0008)>>3)) & (~deco16_prot_ram[0x36/2]);
r2375r2376
401401         return (((deco16_prot_ram[0x6a/2]&0x00f0)<<4) | ((deco16_prot_ram[0x6a/2]&0x0f00)<<4) | ((deco16_prot_ram[0x6a/2]&0x0007)<<5) | ((deco16_prot_ram[0x6a/2]&0x0008)<<1)) & (~deco16_prot_ram[0x36/2]);
402402
403403      case 0x7d6: /* XOR IN0 */
404         return readinputport(0) ^ deco16_prot_ram[0x2c/2];
404         return input_port_read_indexed(machine, 0) ^ deco16_prot_ram[0x2c/2];
405405      case 0x4b4:
406406         return ((deco16_prot_ram[0x32/2]&0x00f0)<<8) | ((deco16_prot_ram[0x32/2]&0x000e)<<7) | ((deco16_prot_ram[0x32/2]&0x0001)<<11);
407407   }
r2375r2376
462462
463463    switch (offset*2) {
464464      case 0xac: /* Dip switches */
465         return readinputport(2);
465         return input_port_read_indexed(machine, 2);
466466      case 0xc2: /* Dip switches */
467         return readinputport(2) ^ deco16_prot_ram[0x2c/2];
467         return input_port_read_indexed(machine, 2) ^ deco16_prot_ram[0x2c/2];
468468      case 0x46: /* Coins */
469         return readinputport(1) ^ deco16_prot_ram[0x2c/2];
469         return input_port_read_indexed(machine, 1) ^ deco16_prot_ram[0x2c/2];
470470      case 0x50: /* Player 1 & 2 input ports */
471         return readinputport(0);
471         return input_port_read_indexed(machine, 0);
472472      case 0x63c: /* Player 1 & 2 input ports */
473         return readinputport(0) ^ deco16_prot_ram[0x2c/2];
473         return input_port_read_indexed(machine, 0) ^ deco16_prot_ram[0x2c/2];
474474
475475      case 0x5f4:
476476         return deco16_prot_ram[0x18/2];
r2375r2376
645645         return deco16_prot_ram[15];
646646
647647      case 0x36: /* Dip switches */
648         return readinputport(2);
648         return input_port_read_indexed(machine, 2);
649649
650650      case 0x1c8: /* Coins */
651         return readinputport(1);
651         return input_port_read_indexed(machine, 1);
652652
653653      case 0x22c: /* Player 1 & 2 input ports */
654         return readinputport(0);
654         return input_port_read_indexed(machine, 0);
655655   }
656656
657657   logerror("Protection PC %06x: warning - read unmapped memory address %04x\n",activecpu_get_pc(),offset);
r2375r2376
741741         return ((deco16_prot_ram[0x78e>>1]>>4)&0xff00) | (deco16_prot_ram[0x78e>>1]&0x000f) | ((deco16_prot_ram[0x78e>>1]<<8)&0xf000);
742742
743743      case 0x00c >> 1: /* Player 1 & Player 2 joysticks & fire buttons */
744         return (readinputport(0) + (readinputport(1) << 8));
744         return (input_port_read_indexed(machine, 0) + (input_port_read_indexed(machine, 1) << 8));
745745      case 0x778 >> 1: /* Credits */
746         return readinputport(2);
746         return input_port_read_indexed(machine, 2);
747747      case 0x382 >> 1: /* DIPS */
748         return (readinputport(3) + (readinputport(4) << 8));
748         return (input_port_read_indexed(machine, 3) + (input_port_read_indexed(machine, 4) << 8));
749749   }
750750
751751   if (activecpu_get_pc()!=0xc0ea)
752      logerror("CPU #0 PC %06x: warning - read unmapped control address %06x (ctrl %04x)\n",activecpu_get_pc(),offset<<1, readinputport(0));
752      logerror("CPU #0 PC %06x: warning - read unmapped control address %06x (ctrl %04x)\n",activecpu_get_pc(),offset<<1, input_port_read_indexed(machine, 0));
753753
754754   return 0;
755755}
r2375r2376
858858
859859   switch (offset) {
860860      case 0x88/2: /* Player 1 & 2 input ports */
861         return readinputport(0);
861         return input_port_read_indexed(machine, 0);
862862      case 0x36c/2:
863         return readinputport(1);
863         return input_port_read_indexed(machine, 1);
864864      case 0x44c/2:
865865
866         return ((readinputport(1)&0x7)<<13)|((readinputport(1)&0x8)<<9);
866         return ((input_port_read_indexed(machine, 1)&0x7)<<13)|((input_port_read_indexed(machine, 1)&0x8)<<9);
867867      case 0x292/2: /* Dips */
868         return readinputport(2);
868         return input_port_read_indexed(machine, 2);
869869
870870      case 0x44/2:
871871         return ((((DECO_PORT(0x2c)&0x000f)<<12)) ^ deco16_xor) & (~deco16_mask);
r2375r2376
12421242   switch (offset)
12431243   {
12441244   case 0x582: /* Player 1 & Player 2 */
1245      return readinputport(0);
1245      return input_port_read_indexed(machine, 0);
12461246   case 0x04c: /* Coins/VBL */
1247      return readinputport(1);
1247      return input_port_read_indexed(machine, 1);
12481248   case 0x672: /* Dip switches */
1249      return readinputport(2);
1249      return input_port_read_indexed(machine, 2);
12501250
12511251   case 0x13a:
12521252      return ((DECO_PORT(0x190)&0x00f0)<<8) | ((DECO_PORT(0x190)&0x0003)<<10) | ((DECO_PORT(0x190)&0x000c)<<6);
r2375r2376
13041304
13051305   /*********************************************************************************/
13061306
1307//  case 0x582: return readinputport(0); /* IN0 */
1308//  case 0x672: return readinputport(1); /* IN1 */
1307//  case 0x582: return input_port_read_indexed(machine, 0); /* IN0 */
1308//  case 0x672: return input_port_read_indexed(machine, 1); /* IN1 */
13091309//  case 0x04c: return EEPROM_read_bit();
13101310
13111311   case 0x468:
r2375r2376
16531653   /* Special case inputs, because this is the only game with an eprom */
16541654   switch (addr)
16551655   {
1656   case 0x582: return (readinputport(0)<<16) | 0xffff; /* IN0 */
1657   case 0x672: return (readinputport(1)<<16) | 0xffff; /* IN1 */
1656   case 0x582: return (input_port_read_indexed(machine, 0)<<16) | 0xffff; /* IN0 */
1657   case 0x672: return (input_port_read_indexed(machine, 1)<<16) | 0xffff; /* IN1 */
16581658   case 0x04c: return (EEPROM_read_bit()<<16) | 0xffff;
16591659   }
16601660
src/mame/machine/mcr.c
r2375r2376
141141
142142static READ8_HANDLER( zwackery_port_1_r )
143143{
144   UINT8 ret = readinputport(1);
144   UINT8 ret = input_port_read_indexed(machine, 1);
145145
146146   pia_set_port_a_z_mask(3, ret);
147147
r2375r2376
151151
152152static READ8_HANDLER( zwackery_port_3_r )
153153{
154   UINT8 ret = readinputport(3);
154   UINT8 ret = input_port_read_indexed(machine, 3);
155155
156156   pia_set_port_a_z_mask(4, ret);
157157
src/mame/machine/s24fd.c
r2375r2376
2222static int fd1094_cached_states[S16_NUMCACHE]; // array of cached state numbers
2323static int fd1094_current_cacheposition; // current position in cache array
2424
25static int fd1094_state;
26static int fd1094_selected_state;
27
2528/* this function checks the cache to see if the current state is cached,
2629   if it is then it copies the cached data to the user region where code is
2730   executed from, if its not cached then it gets decrypted to the current
r2375r2376
3134   int i;
3235   UINT32 addr;
3336
37   switch (state & 0x300)
38   {
39   case 0x000:
40   case FD1094_STATE_RESET:
41      fd1094_selected_state = state & 0xff;
42      break;
43   }
44
45   fd1094_state = state;
46
3447   cpunum_set_info_int(1, CPUINFO_INT_REGISTER + M68K_PREF_ADDR, 0x0010);   // force a flush of the prefetch cache
3548
3649   /* set the s24_fd1094 state ready to decrypt.. */
r2375r2376
123136   cpunum_set_irq_callback(1, s24_fd1094_int_callback);
124137}
125138
139static STATE_POSTLOAD( s24_fd1094_postload )
140{
141   if (fd1094_state != -1)
142   {
143      int selected_state = fd1094_selected_state;
144      int state = fd1094_state;
145
146      s24_fd1094_machine_init();
147
148      s24_fd1094_setstate_and_decrypt(selected_state);
149      s24_fd1094_setstate_and_decrypt(state);
150   }
151}
152
126153/* startup function, to be called from DRIVER_INIT (once on startup) */
127154void s24_fd1094_driver_init(void)
128155{
r2375r2376
146173      fd1094_cached_states[i] = -1;
147174
148175   fd1094_current_cacheposition = 0;
176
177   fd1094_state = -1;
178
179   state_save_register_global(fd1094_selected_state);
180   state_save_register_global(fd1094_state);
181   state_save_register_postload(Machine, s24_fd1094_postload, NULL);
149182}
src/mame/machine/tatsumi.c
r2375r2376
132132READ8_HANDLER( apache3_adc_r )
133133{
134134   if (apache3_adc==0)
135      return readinputport(1);
136   return readinputport(2);
135      return input_port_read_indexed(machine, 1);
136   return input_port_read_indexed(machine, 2);
137137}
138138
139139WRITE8_HANDLER( apache3_adc_w )
src/mame/machine/galaxold.c
r2375r2376
225225static READ8_HANDLER( kingball_IN0_r )
226226{
227227   if (kingball_speech_dip)
228      return (readinputport(0) & ~0x40) | ((readinputport(3) & 0x01) << 6);
228      return (input_port_read_indexed(machine, 0) & ~0x40) | ((input_port_read_indexed(machine, 3) & 0x01) << 6);
229229   else
230      return readinputport(0);
230      return input_port_read_indexed(machine, 0);
231231}
232232
233233static READ8_HANDLER( kingball_IN1_r )
r2375r2376
236236       that it's working, doesn't actually use return value, so we can just use
237237       rand() */
238238
239   return (readinputport(1) & ~0x20) | (mame_rand(Machine) & 0x20);
239   return (input_port_read_indexed(machine, 1) & ~0x20) | (mame_rand(Machine) & 0x20);
240240}
241241
242242WRITE8_HANDLER( kingball_speech_dip_w )
r2375r2376
282282
283283static READ8_HANDLER( azurian_IN1_r )
284284{
285   return (readinputport(1) & ~0x40) | ((readinputport(3) & 0x01) << 6);
285   return (input_port_read_indexed(machine, 1) & ~0x40) | ((input_port_read_indexed(machine, 3) & 0x01) << 6);
286286}
287287
288288static READ8_HANDLER( azurian_IN2_r )
289289{
290   return (readinputport(2) & ~0x04) | ((readinputport(3) & 0x02) << 1);
290   return (input_port_read_indexed(machine, 2) & ~0x04) | ((input_port_read_indexed(machine, 3) & 0x02) << 1);
291291}
292292
293293
r2375r2376
300300
301301READ8_HANDLER( _4in1_input_port_1_r )
302302{
303   return (readinputport(1) & ~0xc0) | (readinputport(3+_4in1_bank) & 0xc0);
303   return (input_port_read_indexed(machine, 1) & ~0xc0) | (input_port_read_indexed(machine, 3+_4in1_bank) & 0xc0);
304304}
305305
306306READ8_HANDLER( _4in1_input_port_2_r )
307307{
308   return (readinputport(2) & 0x04) | (readinputport(3+_4in1_bank) & ~0xc4);
308   return (input_port_read_indexed(machine, 2) & 0x04) | (input_port_read_indexed(machine, 3+_4in1_bank) & ~0xc4);
309309}
310310
311311
r2375r2376
320320
321321READ8_HANDLER( gmgalax_input_port_0_r )
322322{
323   return readinputport(gmgalax_selected_game ? 3 : 0);
323   return input_port_read_indexed(machine, gmgalax_selected_game ? 3 : 0);
324324}
325325
326326READ8_HANDLER( gmgalax_input_port_1_r )
327327{
328   return readinputport(gmgalax_selected_game ? 4 : 1);
328   return input_port_read_indexed(machine, gmgalax_selected_game ? 4 : 1);
329329}
330330
331331READ8_HANDLER( gmgalax_input_port_2_r )
332332{
333   return readinputport(gmgalax_selected_game ? 5 : 2);
333   return input_port_read_indexed(machine, gmgalax_selected_game ? 5 : 2);
334334}
335335
336336
src/mame/machine/strtheat.c
r2375r2376
152152
153153static READ8_HANDLER( strtheat_inputport_0_r )
154154{
155   if(readinputport(3) & 0x40)
155   if(input_port_read_indexed(machine, 3) & 0x40)
156156   {
157157      /* Joystick inputs */
158      return readinputport(0);
158      return input_port_read_indexed(machine, 0);
159159   }
160160   else
161161   {
162162      /* Steering Wheel inputs */
163      return (readinputport(0) & ~3) | (readinputport(4) & 3);
163      return (input_port_read_indexed(machine, 0) & ~3) | (input_port_read_indexed(machine, 4) & 3);
164164   }
165165}
166166
167167static READ8_HANDLER( strtheat_inputport_1_r )
168168{
169   if(readinputport(3) & 0x40)
169   if(input_port_read_indexed(machine, 3) & 0x40)
170170   {
171171      /* Joystick inputs */
172      return readinputport(1);
172      return input_port_read_indexed(machine, 1);
173173   }
174174   else
175175   {
176176      /* Steering Wheel inputs */
177      return (readinputport(1) & ~3) | (readinputport(5) & 3);
177      return (input_port_read_indexed(machine, 1) & ~3) | (input_port_read_indexed(machine, 5) & 3);
178178   }
179179}
180180
src/mame/machine/slikshot.c
r2375r2376
545545   VIDEO_UPDATE_CALL(itech8_2page);
546546
547547   /* add the current X,Y positions to the list */
548   xbuffer[ybuffer_next % YBUFFER_COUNT] = readinputportbytag_safe("FAKEX", 0);
549   ybuffer[ybuffer_next % YBUFFER_COUNT] = readinputportbytag_safe("FAKEY", 0);
548   xbuffer[ybuffer_next % YBUFFER_COUNT] = input_port_read_safe(screen->machine, "FAKEX", 0);
549   ybuffer[ybuffer_next % YBUFFER_COUNT] = input_port_read_safe(screen->machine, "FAKEY", 0);
550550   ybuffer_next++;
551551
552552   /* determine where to draw the starting point */
src/mame/machine/harddriv.c
r2375r2376
350350            .....
351351        0x8000 = SW1 #1
352352    */
353   int temp = readinputport(0);
353   int temp = input_port_read_indexed(machine, 0);
354354   if (atarigen_get_hblank(machine->primary_screen)) temp ^= 0x0002;
355355   temp ^= 0x0018;      /* both EOCs always high for now */
356356   return temp;
r2375r2376
359359
360360READ16_HANDLER( hdc68k_port1_r )
361361{
362   UINT16 result = readinputport(1);
362   UINT16 result = input_port_read_indexed(machine, 1);
363363   UINT16 diff = result ^ hdc68k_last_port1;
364364
365365   /* if a new shifter position is selected, use it */
r2375r2376
387387
388388READ16_HANDLER( hda68k_port1_r )
389389{
390   UINT16 result = readinputport(1);
390   UINT16 result = input_port_read_indexed(machine, 1);
391391
392392   /* merge in the wheel edge latch bit */
393393   if (hdc68k_wheel_edge)
r2375r2376
400400READ16_HANDLER( hdc68k_wheel_r )
401401{
402402   /* grab the new wheel value and upconvert to 12 bits */
403   UINT16 new_wheel = readinputport(10) << 4;
403   UINT16 new_wheel = input_port_read_indexed(machine, 10) << 4;
404404
405405   /* hack to display the wheel position */
406406   if (input_code_pressed(KEYCODE_LSHIFT))
r2375r2376
451451   if (adc_control & 0x08)
452452   {
453453      adc8_select = adc_control & 0x07;
454      adc8_data = readinputport(2 + adc8_select);
454      adc8_data = input_port_read_indexed(machine, 2 + adc8_select);
455455   }
456456
457457   /* handle a write to the 12-bit ADC address select */
458458   if (adc_control & 0x40)
459459   {
460460      adc12_select = (adc_control >> 4) & 0x03;
461      adc12_data = readinputport(10 + adc12_select) << 4;
461      adc12_data = input_port_read_indexed(machine, 10 + adc12_select) << 4;
462462   }
463463
464464   /* bit 7 selects which byte of the 12 bit data to read */
src/mame/machine/psx.c
r2375r2376
15351535   psx_gpu_reset();
15361536}
15371537
1538static void psx_postload( void )
1538static STATE_POSTLOAD( psx_postload )
15391539{
15401540   int n;
15411541
r2375r2376
15591559   mdec_cos_precalc();
15601560}
15611561
1562void psx_driver_init( void )
1562void psx_driver_init( running_machine *machine )
15631563{
15641564   int n;
15651565
r2375r2376
16481648   state_save_register_global_array( m_p_n_mdec_quantize_uv );
16491649   state_save_register_global_array( m_p_n_mdec_cos );
16501650
1651   state_save_register_func_postload( psx_postload );
1651   state_save_register_postload( machine, psx_postload, NULL );
16521652}
src/mame/machine/dec0.c
r2375r2376
2020   switch (offset<<1)
2121   {
2222      case 0: /* Player 1 & 2 joystick & buttons */
23         return (readinputport(0) + (readinputport(1) << 8));
23         return (input_port_read_indexed(machine, 0) + (input_port_read_indexed(machine, 1) << 8));
2424
2525      case 2: /* Credits, start buttons */
26         return readinputport(2);
26         return input_port_read_indexed(machine, 2);
2727
2828      case 4: /* Byte 4: Dipswitch bank 2, Byte 5: Dipswitch Bank 1 */
29         return (readinputport(3) + (readinputport(4) << 8));
29         return (input_port_read_indexed(machine, 3) + (input_port_read_indexed(machine, 4) << 8));
3030
3131      case 8: /* Intel 8751 mc, Bad Dudes & Heavy Barrel only */
3232         //logerror("CPU #0 PC %06x: warning - read unmapped memory address %06x\n",activecpu_get_pc(),0x30c000+offset);
r2375r2376
4444   switch (offset<<1)
4545   {
4646      case 0: /* Player 1 rotary */
47         return ~(1 << (readinputport(5) * 12 / 256));
47         return ~(1 << (input_port_read_indexed(machine, 5) * 12 / 256));
4848
4949      case 8: /* Player 2 rotary */
50         return ~(1 << (readinputport(6) * 12 / 256));
50         return ~(1 << (input_port_read_indexed(machine, 6) * 12 / 256));
5151
5252      default:
5353         logerror("Unknown rotary read at 300000 %02x\n",offset);
r2375r2376
6363   switch (offset<<1)
6464   {
6565      case 0: /* Player 1 Joystick + start, Player 2 Joystick + start */
66         return (readinputport(0) + (readinputport(1) << 8));
66         return (input_port_read_indexed(machine, 0) + (input_port_read_indexed(machine, 1) << 8));
6767
6868      case 2: /* Dipswitches */
69         return (readinputport(3) + (readinputport(4) << 8));
69         return (input_port_read_indexed(machine, 3) + (input_port_read_indexed(machine, 4) << 8));
7070
7171      case 4: /* Player 1 rotary */
72         return ~(1 << (readinputport(5) * 12 / 256));
72         return ~(1 << (input_port_read_indexed(machine, 5) * 12 / 256));
7373
7474      case 6: /* Player 2 rotary */
75         return ~(1 << (readinputport(6) * 12 / 256));
75         return ~(1 << (input_port_read_indexed(machine, 6) * 12 / 256));
7676
7777      case 8: /* Credits, start buttons */
78         return readinputport(2);
78         return input_port_read_indexed(machine, 2);
7979
8080      case 12:
8181         return 0;   /* ?? watchdog ?? */
r2375r2376
9292   switch (offset<<1)
9393   {
9494      case 0: /* Dip Switches */
95         return (readinputport(3) + (readinputport(4) << 8));
95         return (input_port_read_indexed(machine, 3) + (input_port_read_indexed(machine, 4) << 8));
9696
9797      case 2: /* Player 1 & Player 2 joysticks & fire buttons */
98         return (readinputport(0) + (readinputport(1) << 8));
98         return (input_port_read_indexed(machine, 0) + (input_port_read_indexed(machine, 1) << 8));
9999
100100      case 4: /* Credits */
101         return readinputport(2);
101         return input_port_read_indexed(machine, 2);
102102   }
103103
104104   logerror("Unknown control read at 30c000 %d\n",offset);
src/mame/machine/beezer.c
r2375r2376
7070      switch (data & 0x03)
7171      {
7272      case 0:
73         pbus = input_port_0_r(machine,0);
73         pbus = input_port_read_indexed(machine, 0);
7474         break;
7575      case 1:
76         pbus = input_port_1_r(machine,0) | (input_port_2_r(machine,0) << 4);
76         pbus = input_port_read_indexed(machine, 1) | (input_port_read_indexed(machine, 2) << 4);
7777         break;
7878      case 2:
79         pbus = input_port_3_r(machine,0);
79         pbus = input_port_read_indexed(machine, 3);
8080         break;
8181      case 3:
8282         pbus = 0xff;
src/mame/machine/lsasquad.c
r2375r2376
181181
182182READ8_HANDLER( lsasquad_mcu_status_r )
183183{
184   int res = input_port_3_r(machine,0);
184   int res = input_port_read_indexed(machine, 3);
185185
186186   /* bit 0 = when 1, mcu is ready to receive data from main cpu */
187187   /* bit 1 = when 0, mcu has sent data to the main cpu */
src/mame/machine/kaneko16.c
r2375r2376
27027000207FE0 : may serves for relocating code (written as .l)
271271*/
272272
273static void calc3_mcu_run(void);
273static void calc3_mcu_run(running_machine *machine);
274274
275275static int calc3_mcu_status, calc3_mcu_command_offset;
276276
r2375r2376
284284WRITE16_HANDLER( calc3_mcu_ram_w )
285285{
286286   COMBINE_DATA(&kaneko16_mcu_ram[offset]);
287   calc3_mcu_run();
287   calc3_mcu_run(machine);
288288}
289289
290290#define CALC3_MCU_COM_W(_n_)            \
291291WRITE16_HANDLER( calc3_mcu_com##_n_##_w )   \
292292{                                 \
293293   calc3_mcu_status |= (1 << _n_);         \
294   calc3_mcu_run();                  \
294   calc3_mcu_run(machine);               \
295295}
296296
297297CALC3_MCU_COM_W(0)
r2375r2376
312312    - Supply code snippets to the 68000
313313*/
314314
315static void calc3_mcu_run(void)
315static void calc3_mcu_run(running_machine *machine)
316316{
317317   UINT16 mcu_command;
318318
r2375r2376
343343
344344         // execute the command:
345345
346         kaneko16_mcu_ram[param1 / 2] = ~readinputport(4);   // DSW
346         kaneko16_mcu_ram[param1 / 2] = ~input_port_read_indexed(machine, 4);   // DSW
347347         kaneko16_mcu_ram[param2 / 2] = 0xffff;            // ? -1 / anything else
348348
349349         calc3_mcu_command_offset = param3 / 2;   // where next command will be written?
r2375r2376
542542TODO: look at this one since this remark is only driver-based.
543543*/
544544
545void (*toybox_mcu_run)(void);   /* One of the following */
546void bloodwar_mcu_run(void);
547void bonkadv_mcu_run(void);
548void gtmr_mcu_run(void);
545void (*toybox_mcu_run)(running_machine *machine);   /* One of the following */
546void bloodwar_mcu_run(running_machine *machine);
547void bonkadv_mcu_run(running_machine *machine);
548void gtmr_mcu_run(running_machine *machine);
549549
550550static UINT16 toybox_mcu_com[4];
551551
r2375r2376
564564   if (toybox_mcu_com[3] != 0xFFFF)   return;         \
565565                                          \
566566   memset(toybox_mcu_com, 0, 4 * sizeof( UINT16 ) );   \
567   toybox_mcu_run();                           \
567   toybox_mcu_run(machine);                     \
568568}
569569
570570TOYBOX_MCU_COM_W(0)
r2375r2376
586586                                Blood Warrior
587587***************************************************************************/
588588
589void bloodwar_mcu_run(void)
589void bloodwar_mcu_run(running_machine *machine)
590590{
591591   UINT16 mcu_command   =   kaneko16_mcu_ram[0x0010/2];
592592   UINT16 mcu_offset   =   kaneko16_mcu_ram[0x0012/2] / 2;
r2375r2376
620620
621621      case 0x03:   // DSW
622622      {
623         kaneko16_mcu_ram[mcu_offset] = readinputport(4);
623         kaneko16_mcu_ram[mcu_offset] = input_port_read_indexed(machine, 4);
624624         logerror("PC=%06X : MCU executed command: %04X %04X (read DSW)\n", activecpu_get_pc(), mcu_command, mcu_offset*2);
625625      }
626626      break;
r2375r2376
700700                                Bonk's Adventure
701701***************************************************************************/
702702
703void bonkadv_mcu_run(void)
703void bonkadv_mcu_run(running_machine *machine)
704704{
705705   UINT16 mcu_command   =   kaneko16_mcu_ram[0x0010/2];
706706   UINT16 mcu_offset   =   kaneko16_mcu_ram[0x0012/2] / 2;
r2375r2376
747747
748748      case 0x03:   // DSW
749749      {
750         kaneko16_mcu_ram[mcu_offset] = readinputport(4);
750         kaneko16_mcu_ram[mcu_offset] = input_port_read_indexed(machine, 4);
751751         logerror("PC=%06X : MCU executed command: %04X %04X (read DSW)\n", activecpu_get_pc(), mcu_command, mcu_offset*2);
752752      }
753753      break;
r2375r2376
820820    - Read the DSWs
821821*/
822822
823void gtmr_mcu_run(void)
823void gtmr_mcu_run(running_machine *machine)
824824{
825825   UINT16 mcu_command   =   kaneko16_mcu_ram[0x0010/2];
826826   UINT16 mcu_offset   =   kaneko16_mcu_ram[0x0012/2] / 2;
r2375r2376
855855
856856      case 0x03:   // DSW
857857      {
858         kaneko16_mcu_ram[mcu_offset] = readinputport(4);
858         kaneko16_mcu_ram[mcu_offset] = input_port_read_indexed(machine, 4);
859859      }
860860      break;
861861
src/mame/machine/williams.c
r2375r2376
433433 *
434434 *************************************/
435435
436static void williams2_postload(void)
436static STATE_POSTLOAD( williams2_postload )
437437{
438   williams2_bank_select_w(Machine, 0, vram_bank);
438   williams2_bank_select_w(machine, 0, vram_bank);
439439}
440440
441441
r2375r2376
460460   timer_adjust_oneshot(scan254_timer, video_screen_get_time_until_pos(machine->primary_screen, 254, 0), 0);
461461
462462   state_save_register_global(vram_bank);
463   state_save_register_func_postload(williams2_postload);
463   state_save_register_postload(machine, williams2_postload, NULL);
464464}
465465
466466
r2375r2376
568568
569569READ8_HANDLER( williams_input_port_0_3_r )
570570{
571   return readinputport(port_select ? 3 : 0);
571   return input_port_read_indexed(machine, port_select ? 3 : 0);
572572}
573573
574574
575575READ8_HANDLER( williams_input_port_1_4_r )
576576{
577   return readinputport(port_select ? 4 : 1);
577   return input_port_read_indexed(machine, port_select ? 4 : 1);
578578}
579579
580580
r2375r2376
606606READ8_HANDLER( williams_49way_port_0_r )
607607{
608608   static const UINT8 translate49[7] = { 0x0, 0x4, 0x6, 0x7, 0xb, 0x9, 0x8 };
609   return (translate49[readinputportbytag("49WAYX") >> 4] << 4) | translate49[readinputportbytag("49WAYY") >> 4];
609   return (translate49[input_port_read(machine, "49WAYX") >> 4] << 4) | translate49[input_port_read(machine, "49WAYY") >> 4];
610610}
611611
612612
r2375r2376
615615   if (port_select)
616616      return williams_49way_port_0_r(machine,0);
617617   else
618      return readinputport(5);
618      return input_port_read_indexed(machine, 5);
619619}
620620
621621
r2375r2376
711711 *
712712 *************************************/
713713
714static void defender_postload(void)
714static STATE_POSTLOAD( defender_postload )
715715{
716   defender_bank_select_w(Machine, 0, vram_bank);
716   defender_bank_select_w(machine, 0, vram_bank);
717717}
718718
719719
r2375r2376
725725   memory_configure_bank(1, 0, 9, &memory_region(REGION_CPU1)[0x10000], 0x1000);
726726   defender_bank_select_w(machine, 0, 0);
727727
728   state_save_register_func_postload(defender_postload);
728   state_save_register_postload(machine, defender_postload, NULL);
729729}
730730
731731
src/mame/machine/cchip.c
r2375r2376
125125   {
126126      switch (offset)
127127      {
128      case 0x00: return readinputportbytag("IN0");    /* Player 1 controls + START1 */
129      case 0x01: return readinputportbytag("IN1");    /* Player 2 controls + START2 */
130      case 0x02: return readinputportbytag("IN2");    /* COINn + SERVICE1 + TILT */
128      case 0x00: return input_port_read(machine, "IN0");    /* Player 1 controls + START1 */
129      case 0x01: return input_port_read(machine, "IN1");    /* Player 2 controls + START2 */
130      case 0x02: return input_port_read(machine, "IN2");    /* COINn + SERVICE1 + TILT */
131131      case 0x03: return cc_port;
132132      }
133133   }
src/mame/machine/pgmprot.c
r2375r2376
117117READ16_HANDLER (PSTARS_protram_r)
118118{
119119   if (offset == 4)      //region
120      return readinputport(4);
120      return input_port_read_indexed(machine, 4);
121121   else if (offset >= 0x10)  //timer
122122   {
123123     logerror("PSTARS ACCESS COUNTER %6X\n",pstar_ram[offset-0x10]);
r2375r2376
314314   return (v & (1<<bit)) != 0;
315315}
316316
317static void asic3_compute_hold(void)
317static void asic3_compute_hold(running_machine *machine)
318318{
319319   // The mode is dependant on the region
320320   static const int modes[4] = { 1, 1, 3, 2 };
321   int mode = modes[readinputport(4) & 3];
321   int mode = modes[input_port_read_indexed(machine, 4) & 3];
322322
323323   switch(mode) {
324324   case 1:
r2375r2376
354354   /* region is supplied by the protection device */
355355
356356   switch(asic3_reg) {
357   case 0x00: res = (asic3_latch[0] & 0xf7) | ((readinputport(4) << 3) & 0x08); break;
357   case 0x00: res = (asic3_latch[0] & 0xf7) | ((input_port_read_indexed(machine, 4) << 3) & 0x08); break;
358358   case 0x01: res = asic3_latch[1]; break;
359   case 0x02: res = (asic3_latch[2] & 0x7f) | ((readinputport(4) << 6) & 0x80); break;
359   case 0x02: res = (asic3_latch[2] & 0x7f) | ((input_port_read_indexed(machine, 4) << 6) & 0x80); break;
360360   case 0x03:
361361      res = (bt(asic3_hold, 15) << 0)
362362         | (bt(asic3_hold, 12) << 1)
r2375r2376
414414      } else if(asic3_reg >= 0x80 && asic3_reg <= 0x87) {
415415         asic3_y = asic3_reg & 7;
416416         asic3_z = data;
417         asic3_compute_hold();
417         asic3_compute_hold(machine);
418418      }
419419   }
420420}
r2375r2376
462462   // 4 = hong kong
463463   // 5 = world
464464
465   if (offset == 4)   return readinputport(4);
465   if (offset == 4)   return input_port_read_indexed(machine, 4);
466466
467467   // otherwise it doesn't seem to use the ram for anything important, we return 0 to avoid test mode corruption
468468   // kovplus reads from offset 000e a lot ... why?
src/mame/machine/opwolf.c
r2375r2376
532532static TIMER_CALLBACK( cchip_timer )
533533{
534534   // Update input ports, these are used by both the 68k directly and by the c-chip
535   cchip_ram[0x4]=readinputportbytag("IN0");
536   cchip_ram[0x5]=readinputportbytag("IN1");
535   cchip_ram[0x4]=input_port_read(machine, "IN0");
536   cchip_ram[0x5]=input_port_read(machine, "IN1");
537537
538538   // Coin slots
539539   if (cchip_ram[0x4]!=cchip_last_04)
src/mame/machine/starwars.c
r2375r2376
129129
130130READ8_HANDLER( starwars_input_1_r )
131131{
132   int x = readinputport(1);
132   int x = input_port_read_indexed(machine, 1);
133133
134134   /* set the matrix processor flag */
135135   if (math_run)
r2375r2376
158158{
159159   /* pitch */
160160   if (control_num == kPitch)
161      return readinputport(4);
161      return input_port_read_indexed(machine, 4);
162162
163163   /* yaw */
164164   else if (control_num == kYaw)
165      return readinputport(5);
165      return input_port_read_indexed(machine, 5);
166166
167167   /* default to unused thrust */
168168   else
src/mame/machine/nb1413m3.c
r2375r2376
381381   switch (nb1413m3_type)
382382   {
383383      case NB1413M3_PASTELG:
384         return ((input_port_3_r(machine,0) & 0xfe) | (nb1413m3_busyflag & 0x01));
384         return ((input_port_read_indexed(machine, 3) & 0xfe) | (nb1413m3_busyflag & 0x01));
385385      case NB1413M3_TAIWANMB:
386         return ((input_port_3_r(machine,0) & 0xfc) | ((nb1413m3_outcoin_flag & 0x01) << 1) | (nb1413m3_busyflag & 0x01));
386         return ((input_port_read_indexed(machine, 3) & 0xfc) | ((nb1413m3_outcoin_flag & 0x01) << 1) | (nb1413m3_busyflag & 0x01));
387387      case NB1413M3_HYHOO:
388388      case NB1413M3_HYHOO2:
389         return ((input_port_2_r(machine,0) & 0xfe) | (nb1413m3_busyflag & 0x01));
389         return ((input_port_read_indexed(machine, 2) & 0xfe) | (nb1413m3_busyflag & 0x01));
390390      default:
391         return ((input_port_2_r(machine,0) & 0xfc) | ((nb1413m3_outcoin_flag & 0x01) << 1) | (nb1413m3_busyflag & 0x01));
391         return ((input_port_read_indexed(machine, 2) & 0xfc) | ((nb1413m3_outcoin_flag & 0x01) << 1) | (nb1413m3_busyflag & 0x01));
392392   }
393393}
394394
r2375r2376
401401      case NB1413M3_TAIWANMB:
402402         switch ((nb1413m3_inputport ^ 0xff) & 0x1f)
403403         {
404            case 0x01:   return readinputport(4);
405            case 0x02:   return readinputport(5);
406            case 0x04:   return readinputport(6);
407            case 0x08:   return readinputport(7);
408            case 0x10:   return readinputport(8);
409            default:   return (readinputport(4) & readinputport(5) & readinputport(6) & readinputport(7) & readinputport(8));
404            case 0x01:   return input_port_read_indexed(machine, 4);
405            case 0x02:   return input_port_read_indexed(machine, 5);
406            case 0x04:   return input_port_read_indexed(machine, 6);
407            case 0x08:   return input_port_read_indexed(machine, 7);
408            case 0x10:   return input_port_read_indexed(machine, 8);
409            default:   return (input_port_read_indexed(machine, 4) & input_port_read_indexed(machine, 5) & input_port_read_indexed(machine, 6) & input_port_read_indexed(machine, 7) & input_port_read_indexed(machine, 8));
410410         }
411411         break;
412412      case NB1413M3_HYHOO:
413413      case NB1413M3_HYHOO2:
414414         switch ((nb1413m3_inputport ^ 0xff) & 0x07)
415415         {
416            case 0x01:   return readinputport(3);
417            case 0x02:   return readinputport(4);
416            case 0x01:   return input_port_read_indexed(machine, 3);
417            case 0x02:   return input_port_read_indexed(machine, 4);
418418            case 0x04:   return 0xff;
419419            default:   return 0xff;
420420         }
421421         break;
422422      case NB1413M3_MSJIKEN:
423423      case NB1413M3_TELMAHJN:
424         if (readinputport(0) & 0x80)
424         if (input_port_read_indexed(machine, 0) & 0x80)
425425         {
426426            switch ((nb1413m3_inputport ^ 0xff) & 0x1f)
427427            {
428               case 0x01:   return readinputport(3);
429               case 0x02:   return readinputport(4);
430               case 0x04:   return readinputport(5);
431               case 0x08:   return readinputport(6);
432               case 0x10:   return readinputport(7);
433               default:   return (readinputport(3) & readinputport(4) & readinputport(5) & readinputport(6) & readinputport(7));
428               case 0x01:   return input_port_read_indexed(machine, 3);
429               case 0x02:   return input_port_read_indexed(machine, 4);
430               case 0x04:   return input_port_read_indexed(machine, 5);
431               case 0x08:   return input_port_read_indexed(machine, 6);
432               case 0x10:   return input_port_read_indexed(machine, 7);
433               default:   return (input_port_read_indexed(machine, 3) & input_port_read_indexed(machine, 4) & input_port_read_indexed(machine, 5) & input_port_read_indexed(machine, 6) & input_port_read_indexed(machine, 7));
434434            }
435435         }
436         else return readinputport(14);
436         else return input_port_read_indexed(machine, 14);
437437         break;
438438      case NB1413M3_PAIRSNB:
439439      case NB1413M3_PAIRSTEN:
440         return readinputport(3);
440         return input_port_read_indexed(machine, 3);
441441         break;
442442      default:
443443         switch ((nb1413m3_inputport ^ 0xff) & 0x1f)
444444         {
445            case 0x01:   return readinputport(3);
446            case 0x02:   return readinputport(4);
447            case 0x04:   return readinputport(5);
448            case 0x08:   return readinputport(6);
449            case 0x10:   return readinputport(7);
450            default:   return (readinputport(3) & readinputport(4) & readinputport(5) & readinputport(6) & readinputport(7));
445            case 0x01:   return input_port_read_indexed(machine, 3);
446            case 0x02:   return input_port_read_indexed(machine, 4);
447            case 0x04:   return input_port_read_indexed(machine, 5);
448            case 0x08:   return input_port_read_indexed(machine, 6);
449            case 0x10:   return input_port_read_indexed(machine, 7);
450            default:   return (input_port_read_indexed(machine, 3) & input_port_read_indexed(machine, 4) & input_port_read_indexed(machine, 5) & input_port_read_indexed(machine, 6) & input_port_read_indexed(machine, 7));
451451         }
452452         break;
453453   }
r2375r2376
462462      case NB1413M3_TAIWANMB:
463463         switch ((nb1413m3_inputport ^ 0xff) & 0x1f)
464464         {
465            case 0x01:   return readinputport(9);
466            case 0x02:   return readinputport(10);
467            case 0x04:   return readinputport(11);
468            case 0x08:   return readinputport(12);
469            case 0x10:   return readinputport(13);
470            default:   return (readinputport(9) & readinputport(10) & readinputport(11) & readinputport(12) & readinputport(13));
465            case 0x01:   return input_port_read_indexed(machine, 9);
466            case 0x02:   return input_port_read_indexed(machine, 10);
467            case 0x04:   return input_port_read_indexed(machine, 11);
468            case 0x08:   return input_port_read_indexed(machine, 12);
469            case 0x10:   return input_port_read_indexed(machine, 13);
470            default:   return (input_port_read_indexed(machine, 9) & input_port_read_indexed(machine, 10) & input_port_read_indexed(machine, 11) & input_port_read_indexed(machine, 12) & input_port_read_indexed(machine, 13));
471471         }
472472         break;
473473      case NB1413M3_HYHOO:
r2375r2376
476476         {
477477            case 0x01:   return 0xff;
478478            case 0x02:   return 0xff;
479            case 0x04:   return readinputport(5);
479            case 0x04:   return input_port_read_indexed(machine, 5);
480480            default:   return 0xff;
481481         }
482482         break;
483483      case NB1413M3_MSJIKEN:
484484      case NB1413M3_TELMAHJN:
485         if (readinputport(0) & 0x80)
485         if (input_port_read_indexed(machine, 0) & 0x80)
486486         {
487487            switch ((nb1413m3_inputport ^ 0xff) & 0x1f)
488488            {
489               case 0x01:   return readinputport(8);
490               case 0x02:   return readinputport(9);
491               case 0x04:   return readinputport(10);
492               case 0x08:   return readinputport(11);
493               case 0x10:   return readinputport(12);
494               default:   return (readinputport(8) & readinputport(9) & readinputport(10) & readinputport(11) & readinputport(12));
489               case 0x01:   return input_port_read_indexed(machine, 8);
490               case 0x02:   return input_port_read_indexed(machine, 9);
491               case 0x04:   return input_port_read_indexed(machine, 10);
492               case 0x08:   return input_port_read_indexed(machine, 11);
493               case 0x10:   return input_port_read_indexed(machine, 12);
494               default:   return (input_port_read_indexed(machine, 8) & input_port_read_indexed(machine, 9) & input_port_read_indexed(machine, 10) & input_port_read_indexed(machine, 11) & input_port_read_indexed(machine, 12));
495495            }
496496         }
497         else return readinputport(13);
497         else return input_port_read_indexed(machine, 13);
498498         break;
499499      case NB1413M3_PAIRSNB:
500500      case NB1413M3_PAIRSTEN:
501         return readinputport(4);
501         return input_port_read_indexed(machine, 4);
502502         break;
503503      default:
504504         switch ((nb1413m3_inputport ^ 0xff) & 0x1f)
505505         {
506            case 0x01:   return readinputport(8);
507            case 0x02:   return readinputport(9);
508            case 0x04:   return readinputport(10);
509            case 0x08:   return readinputport(11);
510            case 0x10:   return readinputport(12);
511            default:   return (readinputport(8) & readinputport(9) & readinputport(10) & readinputport(11) & readinputport(12));
506            case 0x01:   return input_port_read_indexed(machine, 8);
507            case 0x02:   return input_port_read_indexed(machine, 9);
508            case 0x04:   return input_port_read_indexed(machine, 10);
509            case 0x08:   return input_port_read_indexed(machine, 11);
510            case 0x10:   return input_port_read_indexed(machine, 12);
511            default:   return (input_port_read_indexed(machine, 8) & input_port_read_indexed(machine, 9) & input_port_read_indexed(machine, 10) & input_port_read_indexed(machine, 11) & input_port_read_indexed(machine, 12));
512512         }
513513         break;
514514   }
r2375r2376
537537      case NB1413M3_MAIKO:
538538      case NB1413M3_MMAIKO:
539539      case NB1413M3_HANAOJI:
540         return ((input_port_13_r(machine,0) & 0xfd) | ((nb1413m3_outcoin_flag & 0x01) << 1));
540         return ((input_port_read_indexed(machine, 13) & 0xfd) | ((nb1413m3_outcoin_flag & 0x01) << 1));
541541         break;
542542      default:
543543         return 0xff;
r2375r2376
551551   {
552552      case NB1413M3_KANATUEN:
553553      case NB1413M3_KYUHITO:
554         return readinputport(1);
554         return input_port_read_indexed(machine, 1);
555555         break;
556556      case NB1413M3_TAIWANMB:
557         return ((readinputport(0) & 0xf0) | ((readinputport(1) & 0xf0) >> 4));
557         return ((input_port_read_indexed(machine, 0) & 0xf0) | ((input_port_read_indexed(machine, 1) & 0xf0) >> 4));
558558         break;
559559      case NB1413M3_OTONANO:
560560      case NB1413M3_MJCAMERA:
561561      case NB1413M3_IDHIMITU:
562562      case NB1413M3_KAGUYA2:
563         return (((readinputport(0) & 0x0f) << 4) | (readinputport(1) & 0x0f));
563         return (((input_port_read_indexed(machine, 0) & 0x0f) << 4) | (input_port_read_indexed(machine, 1) & 0x0f));
564564         break;
565565      case NB1413M3_SCANDAL:
566566      case NB1413M3_SCANDALM:
r2375r2376
572572      case NB1413M3_UCHUUAI:
573573      case NB1413M3_TOKIMBSJ:
574574      case NB1413M3_TOKYOGAL:
575         return ((readinputport(0) & 0x0f) | ((readinputport(1) & 0x0f) << 4));
575         return ((input_port_read_indexed(machine, 0) & 0x0f) | ((input_port_read_indexed(machine, 1) & 0x0f) << 4));
576576         break;
577577      case NB1413M3_TRIPLEW1:
578578      case NB1413M3_NTOPSTAR:
r2375r2376
583583      case NB1413M3_MJLSTORY:
584584      case NB1413M3_QMHAYAKU:
585585      case NB1413M3_MJGOTTUB:
586         return (((readinputport(1) & 0x01) >> 0) | ((readinputport(1) & 0x04) >> 1) |
587                 ((readinputport(1) & 0x10) >> 2) | ((readinputport(1) & 0x40) >> 3) |
588                 ((readinputport(0) & 0x01) << 4) | ((readinputport(0) & 0x04) << 3) |
589                 ((readinputport(0) & 0x10) << 2) | ((readinputport(0) & 0x40) << 1));
586         return (((input_port_read_indexed(machine, 1) & 0x01) >> 0) | ((input_port_read_indexed(machine, 1) & 0x04) >> 1) |
587                 ((input_port_read_indexed(machine, 1) & 0x10) >> 2) | ((input_port_read_indexed(machine, 1) & 0x40) >> 3) |
588                 ((input_port_read_indexed(machine, 0) & 0x01) << 4) | ((input_port_read_indexed(machine, 0) & 0x04) << 3) |
589                 ((input_port_read_indexed(machine, 0) & 0x10) << 2) | ((input_port_read_indexed(machine, 0) & 0x40) << 1));
590590         break;
591591      default:
592         return readinputport(0);
592         return input_port_read_indexed(machine, 0);
593593         break;
594594   }
595595}
r2375r2376
600600   {
601601      case NB1413M3_KANATUEN:
602602      case NB1413M3_KYUHITO:
603         return readinputport(0);
603         return input_port_read_indexed(machine, 0);
604604         break;
605605      case NB1413M3_TAIWANMB:
606         return (((readinputport(0) & 0x0f) << 4) | (readinputport(1) & 0x0f));
606         return (((input_port_read_indexed(machine, 0) & 0x0f) << 4) | (input_port_read_indexed(machine, 1) & 0x0f));
607607         break;
608608      case NB1413M3_OTONANO:
609609      case NB1413M3_MJCAMERA:
610610      case NB1413M3_IDHIMITU:
611611      case NB1413M3_KAGUYA2:
612         return ((readinputport(0) & 0xf0) | ((readinputport(1) & 0xf0) >> 4));
612         return ((input_port_read_indexed(machine, 0) & 0xf0) | ((input_port_read_indexed(machine, 1) & 0xf0) >> 4));
613613         break;
614614      case NB1413M3_SCANDAL:
615615      case NB1413M3_SCANDALM:
r2375r2376
621621      case NB1413M3_UCHUUAI:
622622      case NB1413M3_TOKIMBSJ:
623623      case NB1413M3_TOKYOGAL:
624         return (((readinputport(0) & 0xf0) >> 4) | (readinputport(1) & 0xf0));
624         return (((input_port_read_indexed(machine, 0) & 0xf0) >> 4) | (input_port_read_indexed(machine, 1) & 0xf0));
625625         break;
626626      case NB1413M3_TRIPLEW1:
627627      case NB1413M3_NTOPSTAR:
r2375r2376
632632      case NB1413M3_MJLSTORY:
633633      case NB1413M3_QMHAYAKU:
634634      case NB1413M3_MJGOTTUB:
635         return (((readinputport(1) & 0x02) >> 1) | ((readinputport(1) & 0x08) >> 2) |
636                 ((readinputport(1) & 0x20) >> 3) | ((readinputport(1) & 0x80) >> 4) |
637                 ((readinputport(0) & 0x02) << 3) | ((readinputport(0) & 0x08) << 2) |
638                 ((readinputport(0) & 0x20) << 1) | ((readinputport(0) & 0x80) << 0));
635         return (((input_port_read_indexed(machine, 1) & 0x02) >> 1) | ((input_port_read_indexed(machine, 1) & 0x08) >> 2) |
636                 ((input_port_read_indexed(machine, 1) & 0x20) >> 3) | ((input_port_read_indexed(machine, 1) & 0x80) >> 4) |
637                 ((input_port_read_indexed(machine, 0) & 0x02) << 3) | ((input_port_read_indexed(machine, 0) & 0x08) << 2) |
638                 ((input_port_read_indexed(machine, 0) & 0x20) << 1) | ((input_port_read_indexed(machine, 0) & 0x80) << 0));
639639         break;
640640      default:
641         return readinputport(1);
641         return input_port_read_indexed(machine, 1);
642642         break;
643643   }
644644}
645645
646646READ8_HANDLER( nb1413m3_dipsw3_l_r )
647647{
648   return ((readinputport(2) & 0xf0) >> 4);
648   return ((input_port_read_indexed(machine, 2) & 0xf0) >> 4);
649649}
650650
651651READ8_HANDLER( nb1413m3_dipsw3_h_r )
652652{
653   return ((readinputport(2) & 0x0f) >> 0);
653   return ((input_port_read_indexed(machine, 2) & 0x0f) >> 0);
654654}
655655
656656WRITE8_HANDLER( nb1413m3_outcoin_w )
src/mame/machine/atarifb.c
r2375r2376
161161      int new_x,new_y;
162162
163163      /* Read player 1 trackball */
164      new_x = readinputport(3);
164      new_x = input_port_read_indexed(machine, 3);
165165      if (new_x != counter_x)
166166      {
167167         sign_x_1 = (new_x - counter_x) & 0x80;
168168         counter_x = new_x;
169169      }
170170
171      new_y = readinputport(2);
171      new_y = input_port_read_indexed(machine, 2);
172172      if (new_y != counter_y)
173173      {
174174         sign_y_1 = (new_y - counter_y) & 0x80;
r2375r2376
192192      int new_x,new_y;
193193
194194      /* Read player 2 trackball */
195      new_x = readinputport(5);
195      new_x = input_port_read_indexed(machine, 5);
196196      if (new_x != counter_x)
197197      {
198198         sign_x_2 = (new_x - counter_x) & 0x80;
199199         counter_x = new_x;
200200      }
201201
202      new_y = readinputport(4);
202      new_y = input_port_read_indexed(machine, 4);
203203      if (new_y != counter_y)
204204      {
205205         sign_y_2 = (new_y - counter_y) & 0x80;
r2375r2376
234234      int new_x,new_y;
235235
236236      /* Read player 1 trackball */
237      new_x = readinputport(4);
237      new_x = input_port_read_indexed(machine, 4);
238238      if (new_x != counter_x)
239239      {
240240         sign_x_1 = (new_x - counter_x) & 0x80;
241241         counter_x = new_x;
242242      }
243243
244      new_y = readinputport(3);
244      new_y = input_port_read_indexed(machine, 3);
245245      if (new_y != counter_y)
246246      {
247247         sign_y_1 = (new_y - counter_y) & 0x80;
r2375r2376
257257      int new_x,new_y;
258258
259259      /* Read player 2 trackball */
260      new_x = readinputport(6);
260      new_x = input_port_read_indexed(machine, 6);
261261      if (new_x != counter_x)
262262      {
263263         sign_x_2 = (new_x - counter_x) & 0x80;
264264         counter_x = new_x;
265265      }
266266
267      new_y = readinputport(5);
267      new_y = input_port_read_indexed(machine, 5);
268268      if (new_y != counter_y)
269269      {
270270         sign_y_2 = (new_y - counter_y) & 0x80;
r2375r2376
291291      int new_x,new_y;
292292
293293      /* Read player 3 trackball */
294      new_x = readinputport(8);
294      new_x = input_port_read_indexed(machine, 8);
295295      if (new_x != counter_x)
296296      {
297297         sign_x_3 = (new_x - counter_x) & 0x80;
298298         counter_x = new_x;
299299      }
300300
301      new_y = readinputport(7);
301      new_y = input_port_read_indexed(machine, 7);
302302      if (new_y != counter_y)
303303      {
304304         sign_y_3 = (new_y - counter_y) & 0x80;
r2375r2376
314314      int new_x,new_y;
315315
316316      /* Read player 4 trackball */
317      new_x = readinputport(10);
317      new_x = input_port_read_indexed(machine, 10);
318318      if (new_x != counter_x)
319319      {
320320         sign_x_4 = (new_x - counter_x) & 0x80;
321321         counter_x = new_x;
322322      }
323323
324      new_y = readinputport(9);
324      new_y = input_port_read_indexed(machine, 9);
325325      if (new_y != counter_y)
326326      {
327327         sign_y_4 = (new_y - counter_y) & 0x80;
src/mame/machine/simpsons.c
r2375r2376
5757
5858   res |= 0x20;//konami_eeprom_ack() << 5; /* add the ack */
5959
60   res |= readinputport( 5 ) & 1; /* test switch */
60   res |= input_port_read_indexed(machine, 5 ) & 1; /* test switch */
6161
6262   if (init_eeprom_count)
6363   {
src/mame/machine/subs.c
r2375r2376
7575   int this_val;
7676   int delta;
7777
78   this_val=input_port_4_r(machine,0);
78   this_val=input_port_read_indexed(machine, 4);
7979
8080   delta=this_val-last_val;
8181   last_val=this_val;
src/mame/machine/seicop.c
r0r2376
1
2/* Seibu 'COP' (co-processor)  protection
3
4  there appear to be 3 revisions of this protection (based on the external rom)
5
6  COPX-D1 - Seibu Cup Soccer / Olympic Soccer '92
7          - Legionnaire
8  COPX-D2 - Heated Barrel
9          - Godzilla
10          - SD Gundam Sangokushi Rainbow Tairiku Senki
11          - Denjin Makai
12          - Raiden 2
13          - Raiden DX
14          - Zero Team
15  COPX-D3 - Raiden 2/DX New (V33 PCB version)
16          - New Zero Team
17
18  COPX / COPX-D2 based games appear to function in a similar way to each other
19  while the games using COPX-D3 appears to access the protection device very
20  differently to the others.
21
22  As this is only the external rom it isn't confirmed that the actual protection
23  devices are identical even where the external rom matches.
24
25  Protection features include BCD math protection, 'command sequences', DMA.
26  memory clearing etc.
27
28  it is not confirmed which custom Seibu chip contains the actual co-processor,
29  nor if the co-processor is a real MCU with internal code, or a custom designed
30  'blitter' like device.
31
32  I suspect that for the earlier games it's part of the COP300 or COP1000 chips,
33  for the COPX-D3 based games it's probably inside the system controller SEI333
34
35  the external COP rom is probably used as a lookup for maths operations.
36
37  there should probably only be a single cop2_r / cop2_w function, the chip
38  looks to be configurable via the table uploaded to
39  0x432 / 0x434 / 0x438 / 0x43a / 0x43c, with 'macro' commands triggered via
40  writes to 0x500.
41
42  this simulation is incomplete
43
44  to do:
45  clean it up, consolidate code, make it work!
46
47 */
48
49#include "driver.h"
50#include "audio/seibu.h"
51
52UINT16 *cop_mcu_ram;
53
54static UINT16 copd2_table[0x100];
55static UINT16 copd2_table_2[0x100/8];
56static UINT16 copd2_table_3[0x100/8];
57static UINT16 copd2_table_4[0x100/8];
58
59static UINT16 cop_438;
60static UINT16 cop_43a;
61static UINT16 cop_43c;
62
63
64static UINT16 copd2_offs = 0;
65
66extern UINT16* legionna_scrollram16;
67extern UINT8 sdgndmrb_pri_n;
68extern void heatbrl_setgfxbank(UINT16 data);
69extern void denjinmk_setgfxbank(UINT16 data);
70
71void copd2_set_tableoffset(UINT16 data, running_machine *machine)
72{
73   logerror("mcu_offs %04x\n", data);
74   copd2_offs = data;
75   if (copd2_offs>0xff)
76   {
77      logerror("copd2 offs > 0x100\n");
78   }
79
80   copd2_table_2[copd2_offs/8] = cop_438;
81   copd2_table_3[copd2_offs/8] = cop_43a;
82   copd2_table_4[copd2_offs/8] = cop_43c;
83
84   {
85      FILE *fp;
86      char filename[256];
87      sprintf(filename,"copdat_%s.table2", machine->gamedrv->name);
88      fp=fopen(filename, "w+b");
89      if (fp)
90      {
91         fwrite(copd2_table_2, 0x200/8, 1, fp);
92         fclose(fp);
93      }
94   }
95   {
96      FILE *fp;
97      char filename[256];
98      sprintf(filename,"copdat_%s.table3", machine->gamedrv->name);
99      fp=fopen(filename, "w+b");
100      if (fp)
101      {
102         fwrite(copd2_table_3, 0x200/8, 1, fp);
103         fclose(fp);
104      }
105   }
106   {
107      FILE *fp;
108      char filename[256];
109      sprintf(filename,"copdat_%s.table4", machine->gamedrv->name);
110      fp=fopen(filename, "w+b");
111      if (fp)
112      {
113         fwrite(copd2_table_4, 0x200/8, 1, fp);
114         fclose(fp);
115      }
116   }
117
118}
119
120void copd2_set_tabledata(UINT16 data, running_machine *machine)
121{
122   copd2_table[copd2_offs] = data;
123   logerror("mcu_data %04x\n", data);
124
125   {
126      FILE *fp;
127      char filename[256];
128      sprintf(filename,"copdat_%s.data", machine->gamedrv->name);
129      fp=fopen(filename, "w+b");
130      if (fp)
131      {
132         fwrite(copd2_table, 0x200, 1, fp);
133         fclose(fp);
134      }
135   }
136}
137
138/* Mcu reads in attract in Legionnaire game demo
139
140Guess the 0x400-0x5ff area of the COP is protection related.
141
142CPU0 PC 0032a2 unknown MCU write offset: 0260 data: 9c6c
143CPU0 PC 0032a8 unknown MCU write offset: 0250 data: 0010
144CPU0 PC 0032c8 unknown MCU write offset: 0261 data: 987c
145CPU0 PC 0032ce unknown MCU write offset: 0251 data: 0010
146CPU0 PC 003546 unknown MCU write offset: 0262 data: 02c4
147CPU0 PC 00354a unknown MCU write offset: 0252 data: 0004
148CPU0 PC 00355c unknown MCU write offset: 0263 data: 0000
149CPU0 PC 003560 unknown MCU write offset: 0253 data: 0004
150CPU0 PC 003568 unknown MCU write offset: 0280 data: a180
151CPU0 PC 00356e unknown MCU write offset: 0280 data: a980
152CPU0 PC 003574 unknown MCU write offset: 0280 data: b100
153CPU0 PC 00357a unknown MCU write offset: 0280 data: b900
154CPU0 PC 003580 unknown MCU read offset: 02c4
155CPU0 PC 003588 unknown MCU read offset: 02c2
156CPU0 PC 003594 unknown MCU read offset: 02c1
157CPU0 PC 0035a0 unknown MCU read offset: 02c3
158CPU0 PC 0032a2 unknown MCU write offset: 0260 data: 9c6c
159CPU0 PC 0032a8 unknown MCU write offset: 0250 data: 0010
160CPU0 PC 0032c8 unknown MCU write offset: 0261 data: 987c
161CPU0 PC 0032ce unknown MCU write offset: 0251 data: 0010
162CPU0 PC 003422 unknown MCU write offset: 0280 data: 138e
163CPU0 PC 003428 unknown MCU read offset: 02da
164CPU0 PC 00342e unknown MCU read offset: 02d8
165CPU0 PC 00346c unknown MCU write offset: 0280 data: 3bb0
166CPU0 PC 0032a2 unknown MCU write offset: 0260 data: 987c
167CPU0 PC 0032a8 unknown MCU write offset: 0250 data: 0010
168CPU0 PC 003306 unknown MCU write offset: 0280 data: 8100
169CPU0 PC 00330c unknown MCU write offset: 0280 data: 8900
170
171
172Mcu reads in attract in Heated Barrel game demo (note
173partial similarity)
174
175(i) This sequence repeats a number of times early on:
176
177CPU0 PC 0085b4 unknown MCU write offset: 0210 data: 0064
178CPU0 PC 0085ba unknown MCU write offset: 0211 data: 0000
179CPU0 PC 0085be unknown MCU read offset: 02ca
180CPU0 PC 0085ee unknown MCU read offset: 02c9
181CPU0 PC 008622 unknown MCU read offset: 02c8
182[Protection BCD,see protection_bcd_jsr()]
183
184(ii) This happens a few times:
185
186CPU0 PC 0017ac unknown MCU write offset: 0260 data: b6cc
187CPU0 PC 0017b2 unknown MCU write offset: 0250 data: 0010
188CPU0 PC 0017d2 unknown MCU write offset: 0261 data: babc
189CPU0 PC 0017d8 unknown MCU write offset: 0251 data: 0010
190CPU0 PC 00192c unknown MCU write offset: 0280 data: 138e
191CPU0 PC 001932 unknown MCU read offset: 02da
192CPU0 PC 001938 unknown MCU read offset: 02d8
193CPU0 PC 001976 unknown MCU write offset: 0280 data: 3bb0
194CPU0 PC 0017ac unknown MCU write offset: 0260 data: b6cc
195CPU0 PC 0017b2 unknown MCU write offset: 0250 data: 0010
196CPU0 PC 0017d2 unknown MCU write offset: 0261 data: bb9c
197CPU0 PC 0017d8 unknown MCU write offset: 0251 data: 0010
198CPU0 PC 00192c unknown MCU write offset: 0280 data: 138e
199CPU0 PC 001932 unknown MCU read offset: 02da
200CPU0 PC 001938 unknown MCU read offset: 02d8
201CPU0 PC 001976 unknown MCU write offset: 0280 data: 3bb0
202
203
204
205(iii) Later on this happens a lot:
206
207CPU0 PC 0017ac unknown MCU write offset: 0260 data: c61c
208CPU0 PC 0017b2 unknown MCU write offset: 0250 data: 0010
209CPU0 PC 0017d2 unknown MCU write offset: 0261 data: bb9c
210CPU0 PC 0017d8 unknown MCU write offset: 0251 data: 0010
211CPU0 PC 001a5c unknown MCU write offset: 0262 data: aa48
212CPU0 PC 001a62 unknown MCU write offset: 0252 data: 0003
213CPU0 PC 001a7c unknown MCU write offset: 0263 data: a0c8
214CPU0 PC 001a82 unknown MCU write offset: 0253 data: 0003
215CPU0 PC 001a86 unknown MCU write offset: 0280 data: a100
216CPU0 PC 001a8c unknown MCU write offset: 0280 data: b080
217CPU0 PC 001a92 unknown MCU write offset: 0280 data: a900
218CPU0 PC 001a98 unknown MCU write offset: 0280 data: b880
219CPU0 PC 001a9e unknown MCU read offset: 02c0
220CPU0 PC 001aa6 unknown MCU read offset: 02c2
221CPU0 PC 001ab2 unknown MCU read offset: 02c1
222
223write to $500 these values to determine the kind of sub-routine to do
224hit_check
225a180
226a980
227b100
228b900
229|| b880 (heatbrl)
230
231movement protection
2328100
2338900
234
23500DB2A: D6A8 0048                add.l   ($48,A0), D3
23600DB2E: D8A8 0044                add.l   ($44,A0), D4
23700DB32: 0C83 FFF0 0000           cmpi.l  #-$100000, D3
23800DB38: 6D2E                     blt     $db68
23900DB3A: 0C83 0100 0000           cmpi.l  #$1000000, D3
24000DB40: 6C26                     bge     $db68
24100DB42: 2143 003C                move.l  D3, ($3c,A0)
24200DB46: 0C84 FFF0 0000           cmpi.l  #-$100000, D4
24300DB4C: 6D1A                     blt     $db68
24400DB4E: 0C84 0100 0000           cmpi.l  #$1000000, D4
24500DB54: 6E12                     bgt     $db68
24600DB56: 2144 0038                move.l  D4, ($38,A0)
24700DB5A: 3168 003C 0022           move.w  ($3c,A0), ($22,A0)
24800DB60: 3168 0038 0024           move.w  ($38,A0), ($24,A0)
24900DB66: 4E75                     rts
250
251
252sprite DMA
253
254*/
255/*Movement protection*//*Legionnaire,Heated Barrel*/
256static UINT32 ram_addr[2],rom_addr[2];
257/*Sprite DMA protection*//*SD Gundam*/
258static UINT8 dma_status;
259static UINT32 dma_src,dma_dst;
260static UINT16 prot_data[2],dma_size;
261/*Number protection*//*Heated Barrel,SD Gundam,Godzilla,Denjin Makai*/
262static UINT32 prot_bcd[4];
263/*Hit check protection*//*Legionnaire,Heated Barrel,SD Gundam*/
264static UINT8 xy_check;
265static UINT32 hit_check_x,hit_check_y;
266
267
268
269#define CRT_MODE(_x_,_y_,_flip_) \
270   { \
271   rectangle visarea = *video_screen_get_visible_area(machine->primary_screen); \
272   visarea.min_x = 0; \
273   visarea.max_x = _x_-1; \
274   visarea.min_y = 0; \
275   visarea.max_y = _y_-1; \
276   video_screen_configure(machine->primary_screen, _x_, _y_, &visarea, video_screen_get_frame_period(machine->primary_screen).attoseconds ); \
277   flip_screen_set(_flip_); \
278   } \
279
280/*TODO: numbers over 65535?*/
281static UINT32 protection_bcd_jsr(UINT16 prot_data)
282{
283   UINT32 res,bcd_data;
284
285   res = 0;
286   bcd_data = prot_data;
287   while(bcd_data > 0)
288   {
289      if(bcd_data > 999)
290      {
291         res+=0x01000000;
292         bcd_data-=1000;
293      }
294      else if(bcd_data > 99)
295      {
296         res+=0x00010000;
297         bcd_data-=100;
298      }
299      else if(bcd_data > 9)
300      {
301         res+=0x00000100;
302         bcd_data-=10;
303      }
304      else
305      {
306         res++;
307         bcd_data--;
308      }
309   }
310
311   return res & 0x0f0f0f0f;
312}
313
314/*TODO: -move x-axis limits,to calculate basing on the screen xy-axis values*/
315/*      -the second value should be end of calculation (in other words,check everything between the two values) */
316#define PLAYER 0
317#define ENEMY 1
318static void protection_move_jsr(UINT32 work_ram,UINT8 k)
319{
320   static UINT32 move_data,x_data,y_data;
321   /*Read the movement data to execute*/
322   move_data = ((program_read_word(work_ram+0x34)<<16) & 0xffff0000) |
323                (program_read_word(work_ram+0x36) & 0xffff);
324
325   /*Read the x/y axis of the sprite to change*/
326   x_data = (program_read_word(work_ram+0x8));
327   y_data = (program_read_word(work_ram+0x4));
328   /*it's bit sensitive AFAIK*/
329   /*move_data hi-word on player
330      $17 = walk floor
331      $1b = jump
332      $30 = ?
333    */
334   /*Check the kind of movement that we need to execute*/
335   switch(k & 1)
336   {
337      case PLAYER:
338         switch(move_data & 0xffff)
339         {
340            case 0x0000: x_data++; break; //right
341            case 0x0040: y_data++; break; //down
342            case 0x00c0: y_data--; break; //up
343            case 0x0080: x_data--; break; //left
344            case 0x00a0: y_data--; x_data--; break; //up-left
345            case 0x0060: y_data++; x_data--; break; //down-left
346            case 0x0020: y_data++; x_data++; break; //down-right
347            case 0x00e0: y_data--; x_data++; break; //up-right
348         }
349         break;
350      /*wrong...*/
351      case ENEMY:
352         switch(move_data & 0xffff)
353         {
354            case 0x0000: x_data++; break; //right
355            case 0x0040: y_data++; break; //down
356            case 0x00c0: y_data--; break; //up
357            case 0x0080: x_data--; break; //left
358            case 0x00a0: y_data--; x_data--; break; //up-left
359            case 0x0060: y_data++; x_data--; break; //down-left
360            case 0x0020: y_data++; x_data++; break; //down-right
361            case 0x00e0: y_data--; x_data++; break; //up-right
362            default:
363               popmessage("%08x",move_data);
364            break;
365         }
366         break;
367   }
368   /*Write the new values to the sprite x/y data*/
369   program_write_word(work_ram+0x8,x_data);
370   program_write_word(work_ram+0x4,y_data);
371}
372
373#ifdef UNUSED_FUNCTION
374static void protection_move2_jsr(void)
375{
376//  static UINT32 move_data;
377//  popmessage("%08x %08x %08x %08x",ram_addr[0],ram_addr[1],rom_addr[0],rom_addr[1]);
378}
379#endif
380
381static UINT16 hit_check;
382
383static void protection_hit_jsr(UINT32 work_ram1,UINT32 work_ram2)
384{
385   int x1,y1,x2,y2/*,hit1,hit2*/;
386   x1 = (program_read_word(work_ram1+0x8));
387   y1 = (program_read_word(work_ram1+0x4));
388   //hit1 = (program_read_word(work_ram1-));//this sprite is attacking
389   x2 = (program_read_word(work_ram2+0x8));
390   y2 = (program_read_word(work_ram2+0x4));
391   //hit2 = (program_read_word());
392
393   popmessage("%08x:x=%04x y=%04x %08x:x=%04x y=%04x",work_ram1,x1,y1,work_ram2,x2,y2);
394
395   if((x1 >= (x2-0x80)) &&
396      (x1 <= (x2+0x80)) &&
397      (y1 >= (y2-3))  &&
398      (y1 <= (y2+3)))
399      hit_check = 0;
400   else
401      hit_check = 0xffff;
402}
403
404/*directional movement protection*/
405static void moveprot_jsr(void)
406{
407   static INT16 x_axis,y_axis;
408   static UINT16 move_data,distance,move_type;
409   move_data = program_read_word(ram_addr[0]+0x36);
410   x_axis = program_read_word(ram_addr[0]+0x08);
411   y_axis = program_read_word(ram_addr[0]+0x04);
412
413   distance = (move_data & 0xf);
414   move_type = (move_data & 0xf0)>>4;
415   switch(move_type)
416   {
417      case 0x0f://right
418         program_write_word(ram_addr[0]+0x08,x_axis+distance);
419         //program_write_word(0x110004,);
420         break;
421      case 0x0b://up
422         program_write_word(ram_addr[0]+0x04,y_axis-distance);
423         break;
424      case 0x07://left
425         program_write_word(ram_addr[0]+0x08,x_axis-distance);
426         break;
427      case 0x03://down
428         program_write_word(ram_addr[0]+0x04,y_axis+distance);
429         break;
430      case 0x0d://up-right
431         program_write_word(ram_addr[0]+0x08,x_axis+distance);
432         program_write_word(ram_addr[0]+0x04,y_axis-distance);
433         break;
434      case 0x09://up-left
435         program_write_word(ram_addr[0]+0x04,y_axis-distance);
436         program_write_word(ram_addr[0]+0x08,x_axis-distance);
437         break;
438      case 0x01://down-right
439         program_write_word(ram_addr[0]+0x04,y_axis+distance);
440         program_write_word(ram_addr[0]+0x08,x_axis+distance);
441         break;
442      case 0x05://down-left
443         program_write_word(ram_addr[0]+0x04,y_axis+distance);
444         program_write_word(ram_addr[0]+0x08,x_axis-distance);
445         break;
446      default:
447         logerror("Warning: \"0x205\" command called with move_type parameter = %02x\n",move_type);
448
449         //down-right
450         //down-left
451   }
452   //program_write_word(0x110008,x_axis+tmp);
453   //program_write_word(0x110004,y_axis+tmp);
454
455   //program_write_word(0x110008,x_axis);
456   //program_write_word(0x110004,y_axis);
457}
458
459/*
46000454E: 3028 0008                move.w  ($8,A0), D0 ;player
461004552: 3228 000C                move.w  ($c,A0), D1
462004556: 342B 0008                move.w  ($8,A3), D2 ;enemy
46300455A: 362B 000C                move.w  ($c,A3), D3
46400455E: 33C0 0011 0048           move.w  D0, $110048.l ;player x
465004564: 33C1 0011 0044           move.w  D1, $110044.l ;player y
46600456A: 33C2 0011 0008           move.w  D2, $110008.l ;enemy x
467004570: 33C3 0011 0004           move.w  D3, $110004.l ;enemy y
468
469*/
470/*sprite "look" protection*/
471static void move2prot_jsr(void)
472{
473   static INT16 x_pl,y_pl,x_en,y_en,res;
474   x_pl = program_read_word(ram_addr[1]+0x8);
475   y_pl = program_read_word(ram_addr[1]+0x4);
476   x_en = program_read_word(ram_addr[0]+0x8);
477   y_en = program_read_word(ram_addr[0]+0x4);
478
479   res = 0;
480   if(x_en > x_pl)
481      res|=0x80;
482
483   if((x_en > x_pl-0x20) && (x_en < x_pl+0x20))
484      res|=0x40;
485//...
486   //if(y_en > y_pl)
487   //  res|=0x40;
488
489   program_write_word(ram_addr[0]+0x36,res);
490}
491
492#ifdef UNUSED_FUNCTION
493/*"To point" movement protection*/
494static void move3x_prot_jsr(void)
495{
496   static INT16 x_pl,x_en,x_dis;
497   x_pl = program_read_word(ram_addr[1]+0x8);
498   x_en = program_read_word(ram_addr[0]+0x8);
499   x_dis = ((program_read_word(ram_addr[0]+0x34) & 0xf0) >> 4);
500
501   if(x_en > x_pl)
502      x_dis^=0xffff;
503
504   program_write_word(ram_addr[0]+0x36,-0x40);/*enable command*/
505   program_write_word(ram_addr[0]+0x14,x_dis);
506}
507
508static void move3y_prot_jsr(void)
509{
510   static INT16 y_pl,y_en,y_dis;
511   y_pl = program_read_word(ram_addr[1]+0x4);
512   y_en = program_read_word(ram_addr[0]+0x4);
513   y_dis = (program_read_word(ram_addr[0]+0x34) & 0xf);
514
515   if(y_en > y_pl)
516      y_dis^=0xffff;
517
518   program_write_word(ram_addr[0]+0x36,-0x80);/*enable command*/
519   program_write_word(ram_addr[0]+0x10,y_dis);
520}
521#endif
522
523
524READ16_HANDLER( legionna_mcu_r )
525{
526   UINT16 retvalue = cop_mcu_ram[offset];
527
528   switch (offset)
529   {
530      default:
531      {
532         logerror("%06x: COPX unhandled read returning %04x from offset %04x\n", activecpu_get_pc(), retvalue, offset*2);
533         return retvalue;
534      }
535
536      /*********************************************************************
537        400-5ff -  Protection reads
538        *********************************************************************/
539
540      case (0x470/2):   return (mame_rand(machine) &0xffff); /* read PC $110a, could be some sort of control word:  sometimes a bit is changed then it's poked back in... */
541      case (0x582/2):   return (0); /* read PC $3594 */
542      case (0x584/2):   return (0); /* read PC $3588 */
543      case (0x586/2):   return (0); /* read PC $35a0 */
544      case (0x588/2):   return hit_check; /* read PC $3580 */
545      case (0x5b0/2):   return (0); /* bit 15 is branched on a few times in the $3300 area */
546      case (0x5b4/2):   return (0); /* read and stored in ram before +0x5b0 bit 15 tested */
547
548
549      /*********************************************************************
550        700-7ff - Non-protection reads
551        *********************************************************************/
552
553      /* Seibu Sound System */
554      case (0x708/2):   return seibu_main_word_r(machine,2,0);
555      case (0x70c/2):   return seibu_main_word_r(machine,3,0);
556      case (0x714/2): return seibu_main_word_r(machine,5,0);
557
558      /* Inputs */
559      case (0x740/2): return input_port_1_word_r(machine,0,0);
560      case (0x744/2):   return input_port_2_word_r(machine,0,0);
561      case (0x748/2):   return input_port_0_word_r(machine,0,0);
562      case (0x74c/2):   return input_port_3_word_r(machine,0,0);
563
564   }
565}
566
567
568WRITE16_HANDLER( legionna_mcu_w )
569{
570   COMBINE_DATA(&cop_mcu_ram[offset]);
571
572   switch (offset)
573   {
574      default:
575      {
576         logerror("%06x: COPX unhandled write data %04x at offset %04x\n", activecpu_get_pc(), data, offset*2);
577         break;
578      }
579
580      /*********************************************************************
581        400-5ff -  Protection writes
582        *********************************************************************/
583
584        /* Trigger Table upload */
585      case (0x432/2): { copd2_set_tabledata(data, machine); break; }
586      case (0x434/2):   { copd2_set_tableoffset(data, machine); break; }
587      case (0x438/2):   { cop_438 = data; break; }
588      case (0x43a/2):   { cop_43a = data; break;   }
589      case (0x43c/2): { cop_43c = data; break;   }
590
591      /* Registers */
592      case (0x4c0/2): { prot_data[0] = cop_mcu_ram[offset]; ram_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
593      case (0x4a0/2): { prot_data[1] = cop_mcu_ram[offset]; ram_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
594      case (0x4c2/2): { prot_data[0] = cop_mcu_ram[offset]; ram_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
595      case (0x4a2/2): { prot_data[1] = cop_mcu_ram[offset]; ram_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
596      case (0x4c4/2): { prot_data[0] = cop_mcu_ram[offset]; rom_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
597      case (0x4a4/2): { prot_data[1] = cop_mcu_ram[offset]; rom_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
598      case (0x4c6/2): { prot_data[0] = cop_mcu_ram[offset]; rom_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
599      case (0x4a6/2): { prot_data[1] = cop_mcu_ram[offset]; rom_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
600
601      /* Execute Macro command from table */
602      case (0x500/2):
603      {
604         /*Movement protection*/
605         if(cop_mcu_ram[0x500/2] == 0x8900 || cop_mcu_ram[0x500/2] == 0x0205)
606         {
607            static UINT16 xy_data[2];
608            static UINT8 k;
609            xy_data[0] = program_read_word(rom_addr[0]);
610            xy_data[1] = program_read_word(rom_addr[1]);
611            k = (cop_mcu_ram[0x500/2] == 0x0205) ? ENEMY : PLAYER;
612            protection_move_jsr(ram_addr[0],k);
613            //protection_move_jsr(ram_addr[1]); //???
614            //popmessage("%08x %08x %04x %04x",ram_addr[0],ram_addr[1],xy_data[0],xy_data[1]);
615         }
616         else if(cop_mcu_ram[0x500/2] == 0x3bb0 || cop_mcu_ram[0x500/2] == 0x138e)
617         {
618            protection_hit_jsr(ram_addr[0],ram_addr[1]);
619         }
620         break;
621      }
622
623      /*********************************************************************
624        600-6ff - Video Registers
625        *********************************************************************/
626
627      // 61a bit 0 is flipscreen
628      // 61c probably layer disables, like Dcon
629
630      case (0x620/2): { legionna_scrollram16[0] = cop_mcu_ram[offset]; break; }
631      case (0x622/2): { legionna_scrollram16[1] = cop_mcu_ram[offset]; break; }
632      case (0x624/2): { legionna_scrollram16[2] = cop_mcu_ram[offset]; break; }
633      case (0x626/2): { legionna_scrollram16[3] = cop_mcu_ram[offset]; break; }
634      case (0x628/2): { legionna_scrollram16[4] = cop_mcu_ram[offset]; break; }
635      case (0x62a/2): { legionna_scrollram16[5] = cop_mcu_ram[offset]; break; }
636
637      /*********************************************************************
638        700-7ff - Output (Seibu Sound System)
639        *********************************************************************/
640
641      case (0x700/2):   { seibu_main_word_w(machine,0,cop_mcu_ram[offset],0xff00); break; }
642      case (0x704/2):   { seibu_main_word_w(machine,1,cop_mcu_ram[offset],0xff00); break; }
643      case (0x710/2):   { seibu_main_word_w(machine,4,cop_mcu_ram[offset],0xff00); break; }
644      case (0x718/2):   { seibu_main_word_w(machine,6,cop_mcu_ram[offset],0xff00); break; }
645   }
646}
647
648
649
650/*
651player-1 priorities list:
6521086d8: show this sprite (bit 15)
6531086dc: lives (BCD,bits 3,2,1,0)
6541086de: energy bar (upper byte)
6551086e0: walk animation (lower byte)
6561086ec: "death" status (bit 15)
6571086f4: sprite y axis
6581086f0: sprite x axis
659
660Sprite DMA TODO:
661-sprite priorities,likely to be a protection issue because in-game sprites MUST
662 be behind the foreground layer but the attract mode logos (the ones used when
663 the story is explained) should be above it.They both use 0 as priority number.
664-sprites at the very left border disappears.
665-some bullets STILL remains on screen?
666-3rd mid-boss disappears (0x1f0),2nd boss lasers wrong positioning
667
668spriteram DMA [1]
669001DE4: 3086                     move.w  D6, (A0) ;$100400,color + other stuff
670001DE6: 2440                     movea.l D0, A2
671001DE8: 0269 0004 0002           andi.w  #$4, ($2,A1)
672001DEE: 3152 000C                move.w  (A2), ($c,A0) ;DMA size
673001DF2: 3145 0002                move.w  D5, ($2,A0)
674001DF6: 0245 0040                andi.w  #$40, D5
675001DFA: 2009                     move.l  A1, D0
676001DFC: 3140 00C0                move.w  D0, ($c0,A0) ;RAM -> $1004c0 (work ram index?)
677001E00: 4840                     swap    D0
678001E02: 3140 00A0                move.w  D0, ($a0,A0) ;RAM -> $1004a0
679001E06: 200A                     move.l  A2, D0
680001E08: 3140 0014                move.w  D0, ($14,A0) ;$ROM lo -> $100414 src
681001E0C: 4840                     swap    D0
682001E0E: 3140 0012                move.w  D0, ($12,A0) ;$ROM hi -> $100412
683001E12: 2679 0010 8116           movea.l $108116.l, A3 ;points to dst spriteram
684001E18: 3839 0010 810A           move.w  $10810a.l, D4 ;spriteram index
685001E1E: 260B                     move.l  A3, D3
686001E20: 3143 00C8                move.w  D3, ($c8,A0) ;sets the dst spriteram
687001E24: 4843                     swap    D3
688001E26: 3143 00A8                move.w  D3, ($a8,A0)
689001E2A: 45EA 0004                lea     ($4,A2), A2
690//at this point we're ready for DMAing
691001E2E: 317C A180 0100           move.w  #$a180, ($100,A0) ;<-DMA parameters!?
692001E34: 317C 6980 0102           move.w  #$6980, ($102,A0) ;<-""
693001E3A: 317C C480 0102           move.w  #$c480, ($102,A0) ;<-""
694001E40: 317C 0000 0010           move.w  #$0, ($10,A0)     ;<-""
695001E46: 302A 0002                move.w  ($2,A2), D0
696001E4A: 816B 0006                or.w    D0, ($6,A3)
697001E4E: 45EA 0006                lea     ($6,A2), A2
698001E52: 302B 0008                move.w  ($8,A3), D0
699001E56: B079 0010 8112           cmp.w   $108112.l, D0
700001E5C: 6E00 0054                bgt     $1eb2
701001E60: B079 0010 8110           cmp.w   $108110.l, D0
702001E66: 6D00 004A                blt     $1eb2
703001E6A: 026B 7FFF 000A           andi.w  #$7fff, ($a,A3)
704001E70: 8B6B 0004                or.w    D5, ($4,A3)
705001E74: 47EB 0008                lea     ($8,A3), A3
706001E78: 260B                     move.l  A3, D3
707001E7A: 3143 00C8                move.w  D3, ($c8,A0)
708001E7E: 4843                     swap    D3
709001E80: 3143 00A8                move.w  D3, ($a8,A0)
710001E84: 5244                     addq.w  #1, D4
711001E86: B879 0010 8114           cmp.w   $108114.l, D4
712001E8C: 6500 000C                bcs     $1e9a
713001E90: 0069 0002 0002           ori.w   #$2, ($2,A1)
714001E96: 6000 000C                bra     $1ea4
715//Note: I believe the above program is there just for protection copy
716001E9A: 3028 01B0                move.w  ($1b0,A0), D0 ;bit 1 = DMA job finished
717001E9E: 0240 0002                andi.w  #$2, D0
718001EA2: 6790                     beq     $1e34
719001EA4: 33C4 0010 810A           move.w  D4, $10810a.l
720001EAA: 23CB 0010 8116           move.l  A3, $108116.l
721001EB0: 4E75                     rts
722
723x/y check [2]
724002030: E58D                     lsl.l   #2, D5
725002032: 0685 0003 0000           addi.l  #$30000, D5
726002038: 33C5 0010 04C4           move.w  D5, $1004c4.l
72700203E: 4845                     swap    D5
728002040: 33C5 0010 04A4           move.w  D5, $1004a4.l
729002046: E58E                     lsl.l   #2, D6
730002048: 0686 0003 0000           addi.l  #$30000, D6
73100204E: 33C6 0010 04C6           move.w  D6, $1004c6.l
732002054: 4846                     swap    D6
733002056: 33C6 0010 04A6           move.w  D6, $1004a6.l
73400205C: 33FC A180 0010 0500      move.w  #$a180, $100500.l
735002064: 33FC B100 0010 0500      move.w  #$b100, $100500.l
73600206C: 33FC A980 0010 0500      move.w  #$a980, $100500.l
737002074: 33FC B900 0010 0500      move.w  #$b900, $100500.l
73800207C: 4E75                     rts
739[...]
740//then reads at $580
741
742*/
743
744static UINT16 s_i;
745
746static void dma_transfer(void)
747{
748   static UINT16 rel_xy;
749   static UINT16 abs_x,abs_y;
750   static UINT16 param;
751
752   //for(s_i = dma_size;s_i > 0;s_i--)
753   {
754      /*Sprite Color*/
755      param = program_read_word(0x100400) & 0x3f;
756      /*Write the entire parameters [offs+0]*/
757      program_write_word(dma_dst,program_read_word(dma_src) + param);
758      /*Sprite Priority (guess)*/
759      //param = ((program_read_word(0x100400) & 0x40) ? 0x4000 : 0);
760      /*Write the sprite number [offs+1]*/
761      program_write_word(dma_dst+2,program_read_word(dma_src+2));
762      /*Sprite Relative x/y coords*/
763      rel_xy = program_read_word(dma_src+4); /*???*/
764      /*temporary hardwired,it should point to 0x4c0/0x4a0*/
765      abs_x = (program_read_word(0x110008) - program_read_word(0x10048e));
766      abs_y = (program_read_word(0x110004) - program_read_word(0x10048c));
767      program_write_word(dma_dst+4,((rel_xy & 0x7f) + (abs_x) - ((rel_xy & 0x80) ? 0x80 : 0)) & 0x1ff);
768      program_write_word(dma_dst+6,(((rel_xy & 0x7f00) >> 8) + (abs_y) + (0x10) - ((rel_xy & 0x8000) ? 0x80 : 0)) & 0x1ff);
769      dma_dst+=8;
770      dma_src+=6;
771   }
772}
773
774
775/*
776    switch(program_read_word(hit_check_x))
777    {
778        case 0xb4: xparam = 0x0c/2; break;
779        case 0xb8: xparam = 0x10/2; break;
780        case 0xbc: xparam = 0x14/2; break;
781        case 0xc0: xparam = 0x18/2; break;
782        case 0xc4: xparam = 0x1c/2; break;
783        case 0xd4: xparam = 0x20/2; break;
784        ...
785        case 0xb0: xparam = 0x08/2;
786        case 0xac: xparam = 0x04/2;
787    }
788*/
789static UINT16 check_calc(UINT16 param)
790{
791   UINT16 num,i;
792
793   i = param;
794   i-=0xac;
795   i/=4;
796   num = (0x4/2);
797   for(;i>0;i--)
798      num+=(0x4/2);
799
800   return num;
801}
802
803static UINT16 hit_check_jsr(void)
804{
805   static INT16 xsrc,xdst,ysrc,ydst,xparam,yparam;
806   xsrc = (program_read_word(0x110008));
807   ysrc = (program_read_word(0x110004));
808   xdst = (program_read_word(0x110048));
809   ydst = (program_read_word(0x110044));
810
811   /*Here we check the destination sprite width*/
812   /*0x4a4/0x4c4*/
813   xparam = check_calc(program_read_word(hit_check_x));
814   /*Here we check the destination sprite height*/
815   /*0x4a6/0x4c6*/
816   yparam = check_calc(program_read_word(hit_check_y));
817
818   if(!xparam || !yparam)
819      popmessage("SRC:%04x %04x DST:%04x %04x V:%08x %08x",xsrc,ysrc,xdst,ydst,program_read_word(hit_check_x),program_read_word(hit_check_y));
820   if(xdst >= (xsrc-xparam) && ydst >= (ysrc-yparam) &&
821      xdst <= (xsrc+xparam) && ydst <= (ysrc+yparam))
822      return 0;//sprites collide
823   else
824      return 3;//sprites do not collide
825}
826
827#define UP         0xc0
828#define UP_RIGHT    0xe0
829#define RIGHT       0x00
830#define DOWN_RIGHT   0x20
831#define DOWN      0x40
832#define DOWN_LEFT   0x60
833#define LEFT      0x80
834#define UP_LEFT      0xa0
835
836/*Heated Barrel*/
837/*command 0x8100 will check for the direction of the sprite*/
838/*command 0x8900 will check the "point" movement*/
839static void cop2_move3_prot(void)
840{
841   static INT16 x_pl,x_en;
842   static INT16 y_pl,y_en;
843   static INT16 x_dis,y_dis;
844   static INT16 dir,dis;
845   x_pl = program_read_word(ram_addr[1]+0x8);
846   x_en = program_read_word(ram_addr[0]+0x8);
847   dis = ((program_read_word(ram_addr[0]+0x34) & 0xf0) >> 4);
848   y_pl = program_read_word(ram_addr[1]+0x4);
849   y_en = program_read_word(ram_addr[0]+0x4);
850
851   /*
852    xxxx ---- select the direction of the enemy sprite
853
854                        0xc0 up
855          up-left   0xa0  |  0xe0 up-right
856         left    0x80   <-o->  0x00 right
857        down-left   0x60  |  0x20 down-right
858                        0x40 down
859    */
860
861   if(x_en >= x_pl)
862   {
863      if((y_en >= (y_pl-0x10)) && (y_en <= (y_pl+0x10)))
864         dir = LEFT;
865      else if(y_en < (y_pl-0x10))
866         dir = DOWN_LEFT;
867      else if(y_en > (y_pl+0x10))
868         dir = UP_LEFT;
869   }
870   else if(x_en < x_pl)
871   {
872      if((y_en >= (y_pl-0x10)) && (y_en <= (y_pl+0x10)))
873         dir = RIGHT;
874      else if(y_en < (y_pl-0x10))
875         dir = DOWN_RIGHT;
876      else if(y_en > (y_pl+0x10))
877         dir = UP_RIGHT;
878   }
879   /*UP DOWN cases*/
880   if((x_en >= (x_pl-0x10)) && (x_en <= (x_pl+0x10)))
881   {
882      if(y_en >= y_pl)
883         dir = UP;
884      else if(y_en < y_pl)
885         dir = DOWN;
886   }
887
888   program_write_word(ram_addr[0]+0x36,dir);
889
890   /*TODO*/
891   x_dis = (x_pl-x_en);
892   y_dis = (y_pl-y_en);
893
894   if(x_dis > 4)
895      x_dis = 4;
896
897   if(x_dis < -4)
898      x_dis = -4;
899
900   if(y_dis > 4)
901      y_dis = 4;
902
903   if(y_dis < -4)
904      y_dis = -4;
905
906   //if(y_en > y_pl)
907   //  y_dis^=0xffff;
908
909   //if(x_en > x_pl)
910   //  x_dis^=0xffff;
911
912   program_write_word(ram_addr[0]+0x10,y_dis);
913   program_write_word(ram_addr[0]+0x14,x_dis);
914}
915
916/**/
917static UINT16 cop2_hit_prot(void)
918{
919   static INT16 xsrc,xdst;
920   static INT16 ysrc,ydst;
921   static INT16 xp,yp;
922   static INT16 param1,param2;
923   static INT16 val;
924
925   param1 = program_read_word(rom_addr[0]);
926   param2 = program_read_word(rom_addr[1]);
927
928   xsrc = program_read_word(ram_addr[0]+0x8) + program_read_word(ram_addr[0]+0x14);
929   ysrc = program_read_word(ram_addr[0]+0x4) + program_read_word(ram_addr[0]+0x10);
930   xdst = program_read_word(ram_addr[1]+0x8) + program_read_word(ram_addr[1]+0x14);
931   ydst = program_read_word(ram_addr[1]+0x4) + program_read_word(ram_addr[1]+0x10);
932
933//  xp = (param1 & 0x00f0) >> 4;
934//  yp = (param1 & 0x0f00) >> 8;
935
936//  popmessage("%04x %04x",param1,param2);
937
938   xp = 0;
939   yp = 0;
940   for(val = ((param1 & 0xff0) >> 4); val > 0; val-=5)
941      xp++;
942
943   for(val = ((param1 & 0xff0) >> 4); val > 0; val-=3)
944      yp++;
945
946   /*TODO*/
947//  xp+=4;
948//  yp+=4;
949
950   if(xsrc >= xdst && xsrc <= xdst+xp && ysrc >= xdst && ysrc <= ydst+yp)
951      return 0;
952   else
953      return 3;
954}
955
956static void cop2_move2_prot(void)
957{
958   static INT16 xsrc,ysrc;
959   static INT16 param2;
960
961   xsrc = program_read_word(ram_addr[0]+0x14);
962   ysrc = program_read_word(ram_addr[0]+0x10);
963   param2 = program_read_word(rom_addr[1]);
964
965   switch(param2)
966   {
967      case 0x10:   xsrc++; break; //right
968      case 0x30:   xsrc--; break; //left
969      case 0x40:  ysrc--; break; //up
970      case 0x60:    ysrc++; break; //down
971      case 0x08:  ysrc--; xsrc++; break; //up-right
972      case 0x38:   ysrc--; xsrc--; break; //up-left
973      case 0x28:    ysrc++; xsrc--; break; //down-left
974      case 0x18:  ysrc++; xsrc++; break; //down-right
975   }
976
977   program_write_word(ram_addr[0]+0x14,xsrc);
978   program_write_word(ram_addr[0]+0x10,ysrc);
979}
980
981/******************************************************************************************
982  Heated Barrel Specific
983******************************************************************************************/
984
985READ16_HANDLER( heatbrl_mcu_r )
986{
987   UINT16 retvalue = cop_mcu_ram[offset];
988
989   switch (offset)
990   {
991      default:
992      {
993         logerror("%06x: COPX unhandled read returning %04x from offset %04x\n", activecpu_get_pc(), retvalue, offset*2);
994         return retvalue;
995      }
996
997       /*********************************************************************
998        400-5ff -  Protection reads
999        *********************************************************************/
1000
1001      case (0x580/2):   { return xy_check; } /*hit protection*/
1002      case (0x582/2):   { if(input_code_pressed(KEYCODE_X)) { return 0; } else { return 3; } } /*---- ---- ---- --xx used bits*/
1003      case (0x584/2):   { if(input_code_pressed(KEYCODE_C)) { return 0; } else { return 3; } } /*---- ---- ---- --xx used bits*/
1004
1005      case (0x590/2): { return ((prot_bcd[0] & 0x0000ffff) >> 0 ) + 0x3030; }
1006      case (0x592/2): { return ((prot_bcd[0] & 0xffff0000) >> 16) + 0x3030; }
1007      case (0x594/2): { return ((prot_bcd[1] & 0x0000ffff) >> 0 ) + 0x3030; }
1008      case (0x596/2): { return ((prot_bcd[1] & 0xffff0000) >> 16) + 0x3030; }
1009      case (0x598/2):   { return ((prot_bcd[2] & 0x0000ffff) >> 0 ) + 0x3030; }
1010      case (0x59a/2): { return ((prot_bcd[2] & 0xffff0000) >> 16) + 0x3030; }
1011      case (0x59c/2): { return 0x3030; }
1012
1013     //case (0x5b0/2): return (cop_mcu_ram[offset]); /* bit 15 is branched on a few times in the $1938 area */
1014      case (0x5b4/2):   return (0); /* read at $1932 and stored in ram before +0x5b0 bit 15 tested */
1015
1016      /*********************************************************************
1017        700-7ff - Non-protection reads
1018        *********************************************************************/
1019
1020      /* Seibu Sound System */
1021      case (0x7c8/2):   return seibu_main_word_r(machine,2,0);
1022      case (0x7cc/2):   return seibu_main_word_r(machine,3,0);
1023      case (0x7d4/2): return seibu_main_word_r(machine,5,0);
1024
1025      /* Inputs */
1026      case (0x740/2): return input_port_1_word_r(machine,0,0);
1027      case (0x744/2):   return input_port_2_word_r(machine,0,0);
1028      case (0x748/2): return input_port_4_word_r(machine,0,0);
1029      case (0x74c/2): return input_port_3_word_r(machine,0,0);
1030
1031   }
1032}
1033
1034WRITE16_HANDLER( heatbrl_mcu_w )
1035{
1036   COMBINE_DATA(&cop_mcu_ram[offset]);
1037
1038   switch (offset)
1039   {
1040      default:
1041      {
1042         logerror("%06x: COPX unhandled write data %04x at offset %04x\n", activecpu_get_pc(), data, offset*2);
1043         break;
1044      }
1045
1046      /*********************************************************************
1047        400-5ff -  Protection writes
1048        *********************************************************************/
1049
1050      case (0x420/2):   { prot_bcd[0] = protection_bcd_jsr(cop_mcu_ram[offset]); break; }
1051      case (0x422/2): { prot_bcd[1] = protection_bcd_jsr(cop_mcu_ram[offset]); break; }
1052      case (0x424/2): { prot_bcd[2] = protection_bcd_jsr(cop_mcu_ram[offset]); break; }
1053
1054
1055      case (0x432/2): { copd2_set_tabledata(data, machine); break; }
1056      case (0x434/2): { copd2_set_tableoffset(data, machine); break; }
1057      case (0x438/2):   {cop_438 = data; break; }
1058      case (0x43a/2):   {cop_43a = data; break;   }
1059      case (0x43c/2): {cop_43c = data; break;   }
1060
1061
1062      /* Odd, this is a video register */
1063      case (0x470/2): { heatbrl_setgfxbank( cop_mcu_ram[offset] ); break; }
1064
1065      /* Layer Clearing */
1066      case (0x478/2):
1067      {
1068         static UINT16 i;
1069         /*
1070            AM_RANGE(0x100800, 0x100fff) AM_WRITE(legionna_background_w) AM_BASE(&legionna_back_data)
1071            AM_RANGE(0x101000, 0x1017ff) AM_WRITE(legionna_foreground_w) AM_BASE(&legionna_fore_data)
1072            AM_RANGE(0x101800, 0x101fff) AM_WRITE(legionna_midground_w) AM_BASE(&legionna_mid_data)
1073            AM_RANGE(0x102000, 0x102fff) AM_WRITE(legionna_text_w) AM_BASE(&legionna_textram)
1074            */
1075         switch(cop_mcu_ram[offset])
1076         {
1077            /*layer clearance*/
1078            case 0x4080:
1079            /*text layer*/
1080            for(i=0;i<0x1000;i+=2)
1081               program_write_word(i+0x102000,0x0000);
1082            /*background layer*/
1083            for(i=0;i<0x800;i+=2)
1084               program_write_word(i+0x100800,0x0000);
1085            break;
1086            case 0x4100: break;
1087            case 0x41c0: break;
1088            //default: popmessage("%04x",cop_mcu_ram[offset]);
1089         }
1090         break;
1091      }
1092
1093      /*sprite ram clear(Guess)*/
1094      case (0x47e/2):
1095      {
1096         static UINT16 i;
1097         if(cop_mcu_ram[0x47e/2] == 0x118)
1098         {
1099            for(i=0;i<0x800;i+=2)
1100               program_write_word((0x103000 | i),0x0000);
1101         }
1102         break;
1103      }
1104
1105
1106      /* Registers */
1107      case (0x4c0/2): { prot_data[0] = cop_mcu_ram[offset]; ram_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1108      case (0x4a0/2): { prot_data[1] = cop_mcu_ram[offset]; ram_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1109      case (0x4c2/2): { prot_data[0] = cop_mcu_ram[offset]; ram_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1110      case (0x4a2/2): { prot_data[1] = cop_mcu_ram[offset]; ram_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1111      case (0x4c4/2): { prot_data[0] = cop_mcu_ram[offset]; rom_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1112      case (0x4a4/2): { prot_data[1] = cop_mcu_ram[offset]; rom_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1113      case (0x4c6/2): { prot_data[0] = cop_mcu_ram[offset]; rom_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1114      case (0x4a6/2): { prot_data[1] = cop_mcu_ram[offset]; rom_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1115
1116
1117      /* Macros Command Trigger */
1118      case (0x500/2):
1119      {
1120         switch(cop_mcu_ram[0x500/2])
1121         {
1122            case 0x8100:
1123               break;
1124            case 0x8900:
1125            {
1126               cop2_move3_prot();
1127               break;
1128            }
1129            case 0x205:
1130            {
1131               cop2_move2_prot();
1132               break;
1133            }
1134            case 0xa100:
1135               break;
1136            case 0xb080:
1137               break;
1138            case 0xa900:
1139               break;
1140            case 0xb880:
1141            {
1142               xy_check = cop2_hit_prot();
1143               break;
1144            }
1145            default:
1146               logerror("DMA CMD 0x500 with parameter = %04x PC = %08x\n",cop_mcu_ram[offset],activecpu_get_previouspc());
1147         }
1148         break;
1149      }
1150
1151
1152      /*********************************************************************
1153        600-6ff - Video Registers
1154        *********************************************************************/
1155
1156      // 65a bit 0 is flipscreen
1157      // 65c probably layer disables, like Dcon? Used on screen when you press P1-4 start (values 13, 11, 0 seen)
1158      // 660 - 66a scroll control;  is there a layer priority switch...?
1159      case (0x660/2): { legionna_scrollram16[0] = cop_mcu_ram[offset]; break; }
1160      case (0x662/2): { legionna_scrollram16[1] = cop_mcu_ram[offset]; break; }
1161      case (0x664/2): { legionna_scrollram16[2] = cop_mcu_ram[offset]; break; }
1162      case (0x666/2): { legionna_scrollram16[3] = cop_mcu_ram[offset]; break; }
1163      case (0x668/2): { legionna_scrollram16[4] = cop_mcu_ram[offset]; break; }
1164      case (0x66a/2): { legionna_scrollram16[5] = cop_mcu_ram[offset]; break; }
1165
1166      /*********************************************************************
1167        700-7ff - Output (Seibu Sound System)
1168        *********************************************************************/
1169
1170      case (0x7c0/2):   { seibu_main_word_w(machine,0,cop_mcu_ram[offset],0xff00); break; }
1171      case (0x7c4/2):   { seibu_main_word_w(machine,1,cop_mcu_ram[offset],0xff00); break; }
1172      case (0x7d0/2):   { seibu_main_word_w(machine,4,cop_mcu_ram[offset],0xff00); break; }
1173      case (0x7d8/2):   { seibu_main_word_w(machine,6,cop_mcu_ram[offset],0xff00); break; }
1174   }
1175}
1176
1177
1178READ16_HANDLER( sdgndmrb_cop_mcu_r )
1179{
1180   UINT16 retvalue = cop_mcu_ram[offset];
1181
1182   switch (offset)
1183   {
1184      default:
1185      {
1186         logerror("%06x: COPX unhandled read returning %04x from offset %04x\n", activecpu_get_pc(), retvalue, offset*2);
1187         return retvalue;
1188      }
1189
1190      /*hit protection*/
1191      case (0x580/2): { return xy_check; }
1192
1193      /* BCD protection */
1194      case (0x590/2): { return ((prot_bcd[0] & 0x0000ffff) >> 0 ) + 0x3030; }
1195      case (0x592/2): { return ((prot_bcd[0] & 0xffff0000) >> 16) + 0x3030; }
1196      case (0x594/2): { return ((prot_bcd[1] & 0x0000ffff) >> 0 ) + 0x3030; }
1197      case (0x596/2): { return ((prot_bcd[1] & 0xffff0000) >> 16) + 0x3030; }
1198      case (0x598/2):   { return ((prot_bcd[2] & 0x0000ffff) >> 0 ) + 0x3030; }
1199      case (0x59a/2): { return ((prot_bcd[2] & 0xffff0000) >> 16) + 0x3030; }
1200      case (0x59c/2): { return 0x3030; }
1201
1202      case (0x5b0/2):
1203         /*check if the DMA has been finished*/
1204         if(dma_status == 1)
1205         {
1206            dma_status = 0;
1207            return 2;
1208         }
1209         return cop_mcu_ram[offset];
1210
1211      /* Non-protection reads */
1212      case (0x708/2): return seibu_main_word_r(machine,2,0);
1213      case (0x70c/2): return seibu_main_word_r(machine,3,0);
1214      case (0x714/2): return seibu_main_word_r(machine,5,0);
1215
1216      /* Inputs */
1217      case (0x740/2): return input_port_1_word_r(machine,0,0);
1218      case (0x744/2):   return input_port_2_word_r(machine,0,0);
1219      case (0x748/2): return input_port_4_word_r(machine,0,0);
1220      case (0x74c/2): return input_port_3_word_r(machine,0,0);
1221      case (0x75c/2): return input_port_5_word_r(machine,0,0);
1222   }
1223}
1224
1225WRITE16_HANDLER( sdgndmrb_cop_mcu_w )
1226{
1227   COMBINE_DATA(&cop_mcu_ram[offset]);
1228
1229
1230   switch (offset)
1231   {
1232      default:
1233      {
1234         logerror("%06x: COPX unhandled write data %04x at offset %04x\n", activecpu_get_pc(), data, offset*2);
1235         break;
1236      }
1237
1238      /*********************************************************************
1239        400-5ff -  Protection writes
1240        *********************************************************************/
1241
1242      case (0x40c/2): { dma_size = cop_mcu_ram[offset]; break; }
1243
1244      /*DMA source address*/
1245      case (0x412/2): { prot_data[1] = cop_mcu_ram[offset]; dma_src = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1246      case (0x414/2): { prot_data[0] = cop_mcu_ram[offset]; dma_src = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1247
1248      case (0x420/2):   { prot_bcd[0] = protection_bcd_jsr(cop_mcu_ram[offset]); break; }
1249      case (0x422/2): { prot_bcd[1] = protection_bcd_jsr(cop_mcu_ram[offset]); break; }
1250      case (0x424/2): { prot_bcd[2] = protection_bcd_jsr(cop_mcu_ram[offset]); break; }
1251
1252      case (0x432/2): { copd2_set_tabledata(data, machine); break; }
1253      case (0x434/2): { copd2_set_tableoffset(data, machine); break; }
1254      case (0x438/2):   {cop_438 = data; break; }
1255      case (0x43a/2):   {cop_43a = data; break;   }
1256      case (0x43c/2): {cop_43c = data; break;   }
1257
1258      case (0x478/2):
1259      {
1260         static UINT16 i;
1261         /*
1262            AM_RANGE(0x100800, 0x100fff) AM_WRITE(legionna_background_w) AM_BASE(&legionna_back_data)
1263            AM_RANGE(0x101000, 0x1017ff) AM_WRITE(legionna_foreground_w) AM_BASE(&legionna_fore_data)
1264            AM_RANGE(0x101800, 0x101fff) AM_WRITE(legionna_midground_w) AM_BASE(&legionna_mid_data)
1265            AM_RANGE(0x102000, 0x102fff) AM_WRITE(legionna_text_w) AM_BASE(&legionna_textram)
1266            */
1267         switch(cop_mcu_ram[offset])
1268         {
1269            /*txt layer clearance*/
1270            case 0x4080:
1271            for(i=0;i<0x1000;i+=2)
1272               program_write_word(i+0x102000,0x0000);
1273            break;
1274            case 0x4100: break;
1275            case 0x41c0: break;
1276            //default: popmessage("%04x",cop_mcu_ram[offset]);
1277         }
1278         break;
1279      }
1280
1281      /*sprite ram clear(Guess)*/
1282      case (0x47e/2):
1283      {
1284         static UINT16 i;
1285         if(cop_mcu_ram[0x47e/2] == 0x118)
1286         {
1287            for(i=0;i<0x800;i+=2)
1288               program_write_word((0x107000 | i),0x0000);
1289         }
1290         break;
1291      }
1292
1293      /* MCU registers */
1294      case (0x4c0/2):   { prot_data[0] = cop_mcu_ram[offset]; ram_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1295      case (0x4a0/2): { prot_data[1] = cop_mcu_ram[offset]; ram_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1296      case (0x4c2/2): { prot_data[0] = cop_mcu_ram[offset]; ram_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1297      case (0x4a2/2): { prot_data[1] = cop_mcu_ram[offset]; ram_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1298      case (0x4c4/2):   { prot_data[0] = cop_mcu_ram[offset]; hit_check_x = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1299      case (0x4a4/2):   { prot_data[1] = cop_mcu_ram[offset]; hit_check_x = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1300      case (0x4c6/2):   { prot_data[0] = cop_mcu_ram[offset]; hit_check_y = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1301      case (0x4a6/2):   { prot_data[1] = cop_mcu_ram[offset]; hit_check_y = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16); break; }
1302      case (0x4c8/2):   { prot_data[0] = cop_mcu_ram[offset]; dma_dst = ((prot_data[0]&0xffff)+4)|((prot_data[1]&0xffff)<<16); break; }
1303      case (0x4a8/2): { prot_data[1] = cop_mcu_ram[offset]; dma_dst = ((prot_data[0]&0xffff)+4)|((prot_data[1]&0xffff)<<16); break; }
1304
1305      /* Execute Macro Command */
1306      case (0x500/2):
1307      {
1308         switch(cop_mcu_ram[0x500/2])
1309         {
1310            case 0xa180:/*do the job [1]*/
1311            {
1312               //popmessage("%08x %08x %04x",dma_src,dma_dst,dma_size);
1313               /*fix the offset for easier reading*/
1314               dma_src+=4;
1315               //dma_dst+=4;
1316               s_i = dma_size;
1317               //dma_dst+=((program_read_word(0x110000) & 0x000f) * 8);
1318               //program_write_word(0x1004c8,dma_dst & 0xffff);
1319               //dma_status = 1;
1320               break;
1321            }
1322            case 0xb100:
1323               break;
1324            case 0xa980:
1325               break;
1326            case 0xb900:
1327            {
1328               xy_check = hit_check_jsr();
1329               break;
1330            }
1331            /*bullet movement protection,conflicts with [3],will be worked out*/
1332            case 0x8100:
1333            {
1334               //move3x_prot_jsr();
1335               break;
1336            }
1337            case 0x8900:
1338            {
1339               //move3y_prot_jsr();
1340               break;
1341            }
1342            case 0x0205:/*do the job [3]*/
1343            {
1344               moveprot_jsr();
1345               break;
1346            }
1347            case 0x138e:/*do the job [4]*/
1348               break;
1349            case 0x3bb0:
1350            {
1351               move2prot_jsr();
1352               break;
1353            }
1354            default:
1355               logerror("DMA CMD 0x500 with parameter = %04x PC = %08x\n",cop_mcu_ram[offset],activecpu_get_previouspc());
1356         }
1357         break;
1358      }
1359
1360      case (0x502/2):
1361      {
1362         if(cop_mcu_ram[0x502/2] == 0xc480)
1363         {
1364            dma_transfer();
1365            s_i--;
1366            if(s_i == 0)
1367               dma_status = 1;
1368         }
1369         break;
1370      }
1371
1372      /*Layer Enable,bit wise active low*/
1373      case (0x61c/2):
1374      {
1375         /*
1376            ---x ---- (used in test mode)
1377            ---- x--- Text Layer
1378            ---- -x-- Foreground Layer
1379            ---- --x- Midground Layer
1380            ---- ---x Background Layer
1381            */
1382         sdgndmrb_pri_n = cop_mcu_ram[offset] & 0xf;
1383         break;
1384      }
1385
1386      /* TODO: tilemaps x-axis are offset,we use a temporary kludge for now */
1387      case (0x620/2):   { legionna_scrollram16[0] = 0x10 + cop_mcu_ram[offset]; break; }
1388      case (0x622/2): { legionna_scrollram16[1] = cop_mcu_ram[offset]; break; }
1389      case (0x624/2): { legionna_scrollram16[2] = 0x10 + cop_mcu_ram[offset]; break; }
1390      case (0x626/2): { legionna_scrollram16[3] = cop_mcu_ram[offset]; break; }
1391      case (0x628/2): { legionna_scrollram16[4] = 0x10 + cop_mcu_ram[offset]; break; }
1392      case (0x62a/2): { legionna_scrollram16[5] = cop_mcu_ram[offset]; break; }
1393
1394      /* scroll mirrors? */
1395      case (0x62c/2):
1396      case (0x62e/2):
1397      case (0x630/2):
1398      case (0x632/2):
1399      case (0x634/2):
1400      case (0x636/2):
1401         break;
1402
1403
1404      /* Text Layer scroll registers */
1405      case (0x638/2): { legionna_scrollram16[6] = 0x38 + cop_mcu_ram[offset]; break; }
1406      case (0x63a/2): { legionna_scrollram16[7] = cop_mcu_ram[offset]; break; }
1407      /*C.R.T. Controller (note:game calls it OBJ register)*/
1408      case (0x644/2):
1409         {
1410            /*
1411                data = setting
1412                0x01e = 320x256
1413                0x0e1 = 320x256 REVERSE
1414                0x016 = 320x240
1415                0x0e9 = 320x240 REVERSE
1416                0x004 = 320x224
1417                0x10b = 320x224 REVERSE
1418                It is like to be per cases and not per bits.
1419                */
1420            switch(data)
1421            {
1422               case 0x0000:
1423               case 0x0003:
1424               case 0x001e: CRT_MODE(320,224,0); break;
1425               case 0x00e1: CRT_MODE(320,224,1); break;
1426               case 0x0016: CRT_MODE(320,256,0); break;
1427               case 0x00e9: CRT_MODE(320,256,1); break;
1428               case 0x0004: CRT_MODE(320,240,0); break;
1429               case 0x00fb: CRT_MODE(320,240,1); break;
1430               default:
1431               #ifdef MAME_DEBUG
1432               popmessage("Warning: Undefined CRT Mode %04x",data);
1433               #endif
1434               CRT_MODE(320,256,0);
1435            }
1436         }
1437         break;
1438
1439      /* Seems a mirror for the choices in the test menu... */
1440      case (0x67c/2): break;
1441      case (0x680/2): break;
1442      case (0x6fc/2): break;
1443
1444      case (0x700/2):   { seibu_main_word_w(machine,0,cop_mcu_ram[offset],0xff00); break; }
1445      case (0x704/2):   { seibu_main_word_w(machine,1,cop_mcu_ram[offset],0xff00); break; }
1446      case (0x710/2):   { seibu_main_word_w(machine,4,cop_mcu_ram[offset],0xff00); break; }
1447      case (0x718/2):   { seibu_main_word_w(machine,6,cop_mcu_ram[offset],0xff00); break; }
1448   }
1449}
1450
1451READ16_HANDLER( denjinmk_cop_mcu_r )
1452{
1453   UINT16 retvalue = cop_mcu_ram[offset];
1454
1455   switch (offset)
1456   {
1457      default:
1458      {
1459         logerror("%06x: COPX unhandled read returning %04x from offset %04x\n", activecpu_get_pc(), retvalue, offset*2);
1460         return retvalue;
1461      }
1462
1463      /* BCD protection */
1464      case (0x590/2): { return ((prot_bcd[0] & 0x0000ffff) >> 0 ) + 0x3030; }
1465      case (0x592/2): { return ((prot_bcd[0] & 0xffff0000) >> 16) + 0x3030; }
1466      case (0x594/2): { return ((prot_bcd[1] & 0x0000ffff) >> 0 ) + 0x3030; }
1467      case (0x596/2): { return ((prot_bcd[1] & 0xffff0000) >> 16) + 0x3030; }
1468      case (0x598/2):   { return ((prot_bcd[2] & 0x0000ffff) >> 0 ) + 0x3030; }
1469      case (0x59a/2): { return ((prot_bcd[2] & 0xffff0000) >> 16) + 0x3030; }
1470      case (0x59c/2): { return 0x3030; }
1471
1472      /* Non-protection reads */
1473
1474      case (0x708/2):   return seibu_main_word_r(machine,2,0);
1475      case (0x70c/2):   return seibu_main_word_r(machine,3,0);
1476      case (0x714/2): return seibu_main_word_r(machine,5,0);
1477
1478      /* Inputs */
1479      case (0x740/2): return input_port_1_word_r(machine,0,0);
1480      case (0x744/2):   return input_port_2_word_r(machine,0,0);
1481      case (0x748/2): return input_port_4_word_r(machine,0,0);
1482      case (0x74c/2): return input_port_3_word_r(machine,0,0);
1483      case (0x75c/2): return input_port_5_word_r(machine,0,0);
1484
1485   }
1486}
1487
1488WRITE16_HANDLER( denjinmk_cop_mcu_w )
1489{
1490   COMBINE_DATA(&cop_mcu_ram[offset]);
1491
1492   switch (offset)
1493   {
1494      default:
1495      {
1496         logerror("%06x: COPX unhandled write data %04x at offset %04x\n", activecpu_get_pc(), data, offset*2);
1497         break;
1498      }
1499
1500      /*********************************************************************
1501        400-5ff -  Protection writes
1502        *********************************************************************/
1503
1504      case (0x420/2):   { prot_bcd[0] = protection_bcd_jsr(cop_mcu_ram[offset]); break; }
1505      case (0x422/2): { prot_bcd[1] = protection_bcd_jsr(cop_mcu_ram[offset]); break; }
1506      case (0x424/2): { prot_bcd[2] = protection_bcd_jsr(cop_mcu_ram[offset]); break; }
1507
1508      case (0x432/2):   { copd2_set_tabledata(data, machine); break; }
1509      case (0x434/2): { copd2_set_tableoffset(data, machine); break; }
1510      case (0x438/2):   {cop_438 = data; break; }
1511      case (0x43a/2):   {cop_43a = data; break;   }
1512      case (0x43c/2): {cop_43c = data; break;   }
1513
1514
1515      /* again, strange, this is a video register */
1516      case (0x470/2):   { denjinmk_setgfxbank( cop_mcu_ram[offset] ); break; }
1517
1518      case (0x620/2): { legionna_scrollram16[0] = cop_mcu_ram[offset]; break; }
1519      case (0x622/2): { legionna_scrollram16[1] = cop_mcu_ram[offset]; break; }
1520      case (0x624/2): { legionna_scrollram16[2] = cop_mcu_ram[offset]; break; }
1521      case (0x626/2): { legionna_scrollram16[3] = cop_mcu_ram[offset]; break; }
1522      case (0x628/2): { legionna_scrollram16[4] = cop_mcu_ram[offset]; break; }
1523      case (0x62a/2): { legionna_scrollram16[5] = cop_mcu_ram[offset]; break; }
1524
1525      case (0x700/2):   { seibu_main_word_w(machine,0,cop_mcu_ram[offset],0xff00); break; }
1526      case (0x704/2):   { seibu_main_word_w(machine,1,cop_mcu_ram[offset],0xff00); break; }
1527      case (0x710/2):   { seibu_main_word_w(machine,4,cop_mcu_ram[offset],0xff00); break; }
1528      case (0x718/2):   { seibu_main_word_w(machine,6,cop_mcu_ram[offset],0xff00); break; }
1529   }
1530}
1531
1532READ16_HANDLER( godzilla_cop_mcu_r )
1533{
1534   UINT16 retvalue = cop_mcu_ram[offset];
1535
1536   switch (offset)
1537   {
1538      default:
1539      {
1540         logerror("%06x: COPX unhandled read returning %04x from offset %04x\n", activecpu_get_pc(), retvalue, offset*2);
1541         return retvalue;
1542      }
1543
1544      /* BCD protection */
1545      case (0x590/2): { return ((prot_bcd[0] & 0x0000ffff) >> 0 ) + 0x3030; }
1546      case (0x592/2): { return ((prot_bcd[0] & 0xffff0000) >> 16) + 0x3030; }
1547      case (0x594/2): { return ((prot_bcd[1] & 0x0000ffff) >> 0 ) + 0x3030; }
1548      case (0x596/2): { return ((prot_bcd[1] & 0xffff0000) >> 16) + 0x3030; }
1549      case (0x598/2):   { return ((prot_bcd[2] & 0x0000ffff) >> 0 ) + 0x3030; }
1550      case (0x59a/2): { return ((prot_bcd[2] & 0xffff0000) >> 16) + 0x3030; }
1551      case (0x59c/2): { return 0x3030; }
1552
1553      /* Non-protection reads */
1554      case (0x7c8/2):   return seibu_main_word_r(machine,2,0);
1555      case (0x7cc/2):   return seibu_main_word_r(machine,3,0);
1556      case (0x7d4/2):   return seibu_main_word_r(machine,5,0);
1557
1558      /* Inputs */
1559      case (0x740/2): return input_port_1_word_r(machine,0,0);
1560      case (0x744/2): return input_port_2_word_r(machine,0,0);
1561      case (0x748/2): return input_port_4_word_r(machine,0,0);
1562      case (0x74c/2): return input_port_3_word_r(machine,0,0);
1563   }
1564}
1565
1566WRITE16_HANDLER( godzilla_cop_mcu_w )
1567{
1568   COMBINE_DATA(&cop_mcu_ram[offset]);
1569
1570   switch (offset)
1571   {
1572      default:
1573      {
1574         logerror("%06x: COPX unhandled write data %04x at offset %04x\n", activecpu_get_pc(), data, offset*2);
1575         break;
1576      }
1577
1578      /*********************************************************************
1579        400-5ff -  Protection writes
1580        *********************************************************************/
1581
1582      case (0x420/2):   { prot_bcd[0] = protection_bcd_jsr(cop_mcu_ram[offset]); break; }
1583      case (0x422/2): { prot_bcd[1] = protection_bcd_jsr(cop_mcu_ram[offset]); break; }
1584      case (0x424/2): { prot_bcd[2] = protection_bcd_jsr(cop_mcu_ram[offset]); break; }
1585
1586      case (0x432/2):   { copd2_set_tabledata(data, machine); break; }
1587      case (0x434/2): { copd2_set_tableoffset(data, machine); break; }
1588      case (0x438/2):   {cop_438 = data; break; }
1589      case (0x43a/2):   {cop_43a = data; break;   }
1590      case (0x43c/2): {cop_43c = data; break;   }
1591
1592      /* Layer Clear */
1593      case (0x478/2):
1594      {
1595         static UINT16 i;
1596         /*
1597            */
1598         switch(cop_mcu_ram[offset])
1599         {
1600            /*txt layer clearance*/
1601            case 0x40a0:
1602            for(i=0;i<0x1000;i+=2)
1603               program_write_word(i+0x102800,0x0000);
1604            break;
1605            case 0x4040: break;
1606            case 0x4140: break;
1607            case 0x4180: break;
1608            case 0x4100: break;
1609            case 0x41c0: break;
1610            //default: popmessage("%04x",cop_mcu_ram[offset]);
1611         }
1612         break;
1613      }
1614
1615      case (0x620/2): { legionna_scrollram16[0] = cop_mcu_ram[offset]; break; }
1616      case (0x622/2): { legionna_scrollram16[1] = cop_mcu_ram[offset]; break; }
1617      case (0x624/2): { legionna_scrollram16[2] = cop_mcu_ram[offset]; break; }
1618      case (0x626/2): { legionna_scrollram16[3] = cop_mcu_ram[offset]; break; }
1619      case (0x628/2): { legionna_scrollram16[4] = cop_mcu_ram[offset]; break; }
1620      case (0x62a/2): { legionna_scrollram16[5] = cop_mcu_ram[offset]; break; }
1621
1622      case (0x7c0/2):   { seibu_main_word_w(machine,0,cop_mcu_ram[offset],0xff00); break; }
1623      case (0x7c4/2):   { seibu_main_word_w(machine,1,cop_mcu_ram[offset],0xff00); break; }
1624      case (0x7d0/2):   { seibu_main_word_w(machine,4,cop_mcu_ram[offset],0xff00); break; }
1625      case (0x7d8/2):   { seibu_main_word_w(machine,6,cop_mcu_ram[offset],0xff00); break; }
1626   }
1627}
1628
1629/********************************************************************************************
1630
1631  COPX simulation
1632    - Seibu Cup Soccer
1633
1634 *******************************************************************************************/
1635
1636
1637READ16_HANDLER( copdx_0_r )
1638{
1639   UINT16 retvalue = cop_mcu_ram[offset];
1640
1641   switch(offset)
1642   {
1643      default:
1644      {
1645         logerror("%06x: COPX unhandled read returning %04x from offset %04x\n", activecpu_get_pc(), retvalue, offset*2);
1646         return retvalue;
1647      }
1648
1649      //case (0x47e/2):
1650      //case (0x5b0/2):
1651      //case (0x5b4/2):
1652      //  return cop_mcu_ram[offset];
1653
1654      case (0x700/2): return input_port_1_word_r(machine,0,0);
1655      case (0x704/2): return input_port_2_word_r(machine,0,0);
1656      case (0x708/2): return input_port_4_word_r(machine,0,0);
1657      case (0x70c/2): return input_port_3_word_r(machine,0,0);
1658
1659      case (0x71c/2): return input_port_5_word_r(machine,0,0);
1660      case (0x748/2):   return seibu_main_word_r(machine,2,0);
1661      case (0x74c/2): return seibu_main_word_r(machine,3,0);
1662      case (0x754/2): return seibu_main_word_r(machine,5,0);
1663   }
1664}
1665
1666static UINT16 cop_fct;
1667static UINT32 cop_reg[8];
1668
1669/*This is version 1,so some stuff is different (less complex)*/
1670static void cop_run(void)
1671{
1672   switch(cop_fct)
1673   {
1674      /*???*/
1675      case 0x8100:
1676      {
1677         UINT32 src = cop_reg[0];
1678         program_write_word(src+0x36,0xffc0);
1679         break;
1680      }
1681      case 0x8900:
1682      {
1683         UINT32 src = cop_reg[0];
1684         program_write_word(src+0x36,0xff80);
1685         break;
1686      }
1687      /*Right*/
1688      case 0x0205:
1689      {
1690         UINT32 src = cop_reg[0];
1691         INT16 y = program_read_word(src+0x4);
1692         INT16 x = program_read_word(src+0x8);
1693         INT16 y_rel = program_read_word(src+0x10);
1694         INT16 x_rel = program_read_word(src+0x14);
1695         program_write_word(src+0x4,(y+y_rel));
1696         program_write_word(src+0x8,(x+x_rel));
1697         /*logerror("%08x %08x %08x %08x %08x\n",cop_reg[0],
1698                                           program_read_word(cop_reg[0]+0x4),
1699                                           program_read_word(cop_reg[0]+0x8),
1700                                           program_read_word(cop_reg[0]+0x10),
1701                                           program_read_word(cop_reg[0]+0x14));*/
1702         break;
1703      }
1704      /*???*/
1705      case 0x3bb0:
1706      {
1707         //UINT32 dst = cop_reg[0];
1708         //UINT32 dst = cop_reg[1];
1709         //program_write_word(dst,  mame_rand(Machine)/*program_read_word(src)*/);
1710         //program_write_word(dst+2,mame_rand(Machine)/*program_read_word(src+2)*/);
1711         //program_write_word(dst+4,mame_rand(Machine)/*program_read_word(src+4)*/);
1712         //program_write_word(dst+6,mame_rand(Machine)/*program_read_word(src+6)*/);
1713         //logerror("%04x\n",cop_reg[0]);
1714         break;
1715      }
1716      default:
1717         //logerror("%04x\n",cop_fct);
1718         break;
1719   }
1720}
1721//tmp_data[1] = cop_mcu_ram[offset];
1722//cop_reg[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1723
1724static void cop_reg_w(UINT16 data,UINT8 offset,UINT8 mask)
1725{
1726   if(mask)
1727      cop_reg[offset] = ((data&0xffff)<<16) | (cop_reg[offset]&0xffff);
1728   else
1729      cop_reg[offset] = (cop_reg[offset]&0xffff0000) | (data&0xffff);
1730
1731   //popmessage("%08x",cop_reg[offset]);
1732}
1733
1734WRITE16_HANDLER( copdx_0_w )
1735{
1736
1737   COMBINE_DATA(&cop_mcu_ram[offset]);
1738
1739   switch(offset)
1740   {
1741      default:
1742      {
1743         logerror("%06x: COPX unhandled write data %04x at offset %04x\n", activecpu_get_pc(), data, offset*2);
1744         break;
1745      }
1746
1747      /*********************************************************************
1748        400-5ff -  Protection writes
1749        *********************************************************************/
1750
1751      case (0x432/2): { copd2_set_tabledata(data, machine); break; }
1752      case (0x434/2): { copd2_set_tableoffset(data, machine); break; }
1753      case (0x438/2):   {cop_438 = data; break; }
1754      case (0x43a/2):   {cop_43a = data; break;   }
1755      case (0x43c/2): {cop_43c = data; break;   }
1756
1757      case (0x4a0/2):
1758      case (0x4a2/2):
1759      case (0x4a4/2):
1760      case (0x4a6/2):
1761      case (0x4a8/2):
1762      case (0x4aa/2):
1763      case (0x4ac/2):
1764      case (0x4ae/2):
1765      case (0x4c0/2):
1766      case (0x4c2/2):
1767      case (0x4c4/2):
1768      case (0x4c6/2):
1769      case (0x4c8/2):
1770      case (0x4ca/2):
1771      case (0x4cc/2):
1772      case (0x4ce/2):
1773         cop_reg_w(cop_mcu_ram[offset],offset & 0x000f, (offset < (0x4b0/2)) ? 1 : 0);
1774         break;
1775      /*layer clearance,but the bootleg doesn't send values,so this function is an
1776          original left-over.*/
1777      case (0x478/2):
1778      {
1779         /*
1780    AM_RANGE(0x100800, 0x100fff) AM_READWRITE(SMH_RAM,legionna_background_w) AM_BASE(&legionna_back_data)
1781    AM_RANGE(0x101000, 0x1017ff) AM_READWRITE(SMH_RAM,legionna_foreground_w) AM_BASE(&legionna_fore_data)
1782    AM_RANGE(0x101800, 0x101fff) AM_READWRITE(SMH_RAM,legionna_midground_w) AM_BASE(&legionna_mid_data)
1783    AM_RANGE(0x102000, 0x102fff) AM_READWRITE(SMH_RAM,legionna_text_w) AM_BASE(&legionna_textram)
1784            */
1785         break;
1786      }
1787
1788      /* Trigger Macro Command */
1789      case (0x500/2):
1790      {
1791         cop_fct = cop_mcu_ram[offset];
1792         cop_run();
1793         break;
1794      }
1795
1796      /* Video Regs */
1797      case (0x604/2):
1798      {
1799         //C.R.T. Controller
1800         /*
1801            data = setting
1802            0x01e = 320x256         ---- ---x xxx-
1803            0x0e1 = 320x256 REVERSE ---- xxx- ---x
1804            0x016 = 320x240         ---- ---x -xx-
1805            0x0e9 = 320x240 REVERSE ---- xxx- x--x
1806            0x004 = 320x224         ---- ---- -x--
1807            0x10b = 320x224 REVERSE ---x ---- x-xx
1808            For now we use this by cases and not per bits.
1809            */
1810
1811         switch(data)
1812         {
1813            case 0x0000:
1814            case 0x001e: CRT_MODE(320,256,0); break;
1815            case 0x00e1: CRT_MODE(320,256,1); break;
1816            case 0x0016: CRT_MODE(320,240,0); break;
1817            case 0x00e9: CRT_MODE(320,240,1); break;
1818            case 0x0004: CRT_MODE(320,224,0); break;
1819            case 0x010b: CRT_MODE(320,224,1); break;
1820            default:
1821            #ifdef MAME_DEBUG
1822            popmessage("Warning: Undefined CRT Mode %04x",data);
1823            #endif
1824            CRT_MODE(320,256,0);
1825         }
1826         break;
1827      }
1828      /*TODO: what's going on here,some scroll values aren't sent in these locations
1829                but somewhere else?*/
1830      case (0x62c/2): { legionna_scrollram16[0] = cop_mcu_ram[offset]; break; }
1831      case (0x62e/2): { legionna_scrollram16[1] = cop_mcu_ram[offset]; break; }
1832      case (0x630/2): { legionna_scrollram16[2] = cop_mcu_ram[offset]; break; }
1833      case (0x632/2): { legionna_scrollram16[3] = cop_mcu_ram[offset]; break; }
1834      case (0x634/2): { legionna_scrollram16[4] = cop_mcu_ram[offset]; break; }
1835      case (0x636/2): { legionna_scrollram16[5] = cop_mcu_ram[offset]; break; }
1836      case (0x638/2): { legionna_scrollram16[6] = cop_mcu_ram[offset]; break; }
1837      case (0x63a/2): { legionna_scrollram16[7] = cop_mcu_ram[offset]; break; }
1838      /*video regs (not scrollram,something else)*/
1839      //case (0x660/2):
1840      //case (0x662/2):
1841      //case (0x664/2):
1842      //case (0x666/2):
1843      //case (0x668/2):
1844      //case (0x66a/2):
1845      //case (0x66c/2):
1846      //case (0x66e/2):
1847      //  break;
1848
1849      case (0x740/2):   { seibu_main_word_w(machine,0,cop_mcu_ram[offset],0xff00); break; }
1850      case (0x744/2):   { seibu_main_word_w(machine,1,cop_mcu_ram[offset],0xff00); break; }
1851      case (0x750/2):   { seibu_main_word_w(machine,4,cop_mcu_ram[offset],0xff00); break; }
1852      case (0x758/2):   { seibu_main_word_w(machine,6,cop_mcu_ram[offset],0xff00); break; }
1853   }
1854}
1855
1856/********************************************************************************************
1857
1858  COPX bootleg simulation
1859    - Seibu Cup Soccer (bootleg)
1860
1861 *******************************************************************************************/
1862
1863READ16_HANDLER( copdxbl_0_r )
1864{
1865   UINT16 retvalue = cop_mcu_ram[offset];
1866
1867   switch(offset)
1868   {
1869      default:
1870      {
1871         logerror("%06x: COPX unhandled read returning %04x from offset %04x\n", activecpu_get_pc(), retvalue, offset*2);
1872         return retvalue;
1873      }
1874
1875      //case (0x47e/2):
1876      //case (0x5b0/2):
1877      //case (0x5b4/2):
1878      //  return cop_mcu_ram[offset];
1879
1880      case (0x700/2): return input_port_1_word_r(machine,0,0);
1881      case (0x704/2):   return input_port_2_word_r(machine,0,0);
1882      case (0x708/2):   return input_port_4_word_r(machine,0,0);
1883      case (0x70c/2):   return input_port_3_word_r(machine,0,0);
1884      case (0x71c/2): return input_port_5_word_r(machine,0,0);
1885   }
1886}
1887
1888WRITE16_HANDLER( copdxbl_0_w )
1889{
1890   COMBINE_DATA(&cop_mcu_ram[offset]);
1891
1892   switch(offset)
1893   {
1894
1895      default:
1896      {
1897         logerror("%06x: COPX unhandled write data %04x at offset %04x\n", activecpu_get_pc(), data, offset*2);
1898         break;
1899      }
1900
1901      /*********************************************************************
1902        400-5ff -  Protection writes
1903        *********************************************************************/
1904
1905
1906      case (0x4a0/2):
1907      case (0x4a2/2):
1908      case (0x4a4/2):
1909      case (0x4a6/2):
1910      case (0x4a8/2):
1911      case (0x4aa/2):
1912      case (0x4ac/2):
1913      case (0x4ae/2):
1914      case (0x4c0/2):
1915      case (0x4c2/2):
1916      case (0x4c4/2):
1917      case (0x4c6/2):
1918      case (0x4c8/2):
1919      case (0x4ca/2):
1920      case (0x4cc/2):
1921      case (0x4ce/2):
1922         cop_reg_w(cop_mcu_ram[offset],offset & 0x000f, (offset < (0x4b0/2)) ? 1 : 0);
1923         break;
1924      /*layer clearance,but the bootleg doesn't send values,so this function
1925          is an original left-over.*/
1926      case (0x478/2):
1927      {
1928         /*
1929    AM_RANGE(0x100800, 0x100fff) AM_READWRITE(SMH_RAM,legionna_background_w) AM_BASE(&legionna_back_data)
1930    AM_RANGE(0x101000, 0x1017ff) AM_READWRITE(SMH_RAM,legionna_foreground_w) AM_BASE(&legionna_fore_data)
1931    AM_RANGE(0x101800, 0x101fff) AM_READWRITE(SMH_RAM,legionna_midground_w) AM_BASE(&legionna_mid_data)
1932    AM_RANGE(0x102000, 0x102fff) AM_READWRITE(SMH_RAM,legionna_text_w) AM_BASE(&legionna_textram)
1933            */
1934         break;
1935      }
1936      case (0x500/2):
1937      {
1938         cop_fct = cop_mcu_ram[offset];
1939         cop_run();
1940         break;
1941      }
1942      case (0x604/2):
1943      {
1944         //C.R.T. Controller
1945         /*
1946            data = setting
1947            0x01e = 320x256         ---- ---x xxx-
1948            0x0e1 = 320x256 REVERSE ---- xxx- ---x
1949            0x016 = 320x240         ---- ---x -xx-
1950            0x0e9 = 320x240 REVERSE ---- xxx- x--x
1951            0x004 = 320x224         ---- ---- -x--
1952            0x10b = 320x224 REVERSE ---x ---- x-xx
1953            For now we use this by cases and not per bits.
1954            */
1955
1956         switch(data)
1957         {
1958            case 0x0000:
1959            case 0x001e: CRT_MODE(320,256,0); break;
1960            case 0x00e1: CRT_MODE(320,256,1); break;
1961            case 0x0016: CRT_MODE(320,240,0); break;
1962            case 0x00e9: CRT_MODE(320,240,1); break;
1963            case 0x0004: CRT_MODE(320,224,0); break;
1964            case 0x010b: CRT_MODE(320,224,1); break;
1965            default:
1966            #ifdef MAME_DEBUG
1967            popmessage("Warning: Undefined CRT Mode %04x",data);
1968            #endif
1969            CRT_MODE(320,256,0);
1970         }
1971         break;
1972      }
1973      /*TODO: kludge on x-axis.*/
1974      case (0x660/2): { legionna_scrollram16[0] = cop_mcu_ram[offset] - 0x1f0; break; }
1975      case (0x662/2): { legionna_scrollram16[1] = cop_mcu_ram[offset]; break; }
1976      case (0x664/2): { legionna_scrollram16[2] = cop_mcu_ram[offset] - 0x1f0; break; }
1977      case (0x666/2): { legionna_scrollram16[3] = cop_mcu_ram[offset]; break; }
1978      case (0x668/2): { legionna_scrollram16[4] = cop_mcu_ram[offset] - 0x1f0; break; }
1979      case (0x66a/2): { legionna_scrollram16[5] = cop_mcu_ram[offset]; break; }
1980      case (0x66c/2): { legionna_scrollram16[6] = cop_mcu_ram[offset] - 0x1f0; break; }
1981      case (0x66e/2): { legionna_scrollram16[7] = cop_mcu_ram[offset]; break; }
1982
1983      /*WRONG*/
1984      case (0x65c/2):
1985      {
1986         soundlatch_w(machine,1,data&0xff);
1987         cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE );
1988         break;
1989      }
1990      /*video regs (not scrollram,something else)*/
1991      //case (0x660/2):
1992      //case (0x662/2):
1993      //case (0x664/2):
1994      //case (0x666/2):
1995      //case (0x668/2):
1996      //case (0x66a/2):
1997      //case (0x66c/2):
1998      //case (0x66e/2):
1999      //  break;
2000      /*bootleg sound HW*/
2001      /*case (0x740/2):
2002        {
2003            soundlatch_w(1,data&0x00ff);
2004            cpunum_set_input_line(Machine, 1, INPUT_LINE_NMI, PULSE_LINE );
2005            break;
2006        }*/
2007   }
2008}
2009
2010/********************************************************************************************
2011
2012  COPX-D2 simulation
2013    - Raiden 2
2014    - Zero Team
2015
2016 *******************************************************************************************/
2017
2018
2019/* Raiden 2 COP2 handling.  Note, some important details about table upload in here that the
2020   other simulations are missing */
2021
2022//  COPX functions, terribly incomplete
2023
2024typedef struct _cop_state cop_state;
2025struct _cop_state
2026{
2027   UINT16      offset;                  /* last write offset */
2028   UINT16      ram[0x200/2];            /* RAM from 0x400-0x5ff */
2029
2030   UINT32      reg[4];                  /* registers */
2031
2032   UINT16      func_trigger[0x100/8];      /* function trigger */
2033   UINT16      func_value[0x100/8];      /* function value (?) */
2034   UINT16      func_mask[0x100/8];         /* function mask (?) */
2035   UINT16      program[0x100];            /* program "code" */
2036};
2037
2038static cop_state cop_data;
2039
2040
2041#define VERBOSE 1
2042#define COP_LOG(x)   do { if (VERBOSE) logerror x; } while (0)
2043
2044
2045
2046INLINE UINT16 cop_ram_r(cop_state *cop, UINT16 offset)
2047{
2048   return cop->ram[(offset - 0x400) / 2];
2049}
2050
2051INLINE void cop_ram_w(cop_state *cop, UINT16 offset, UINT16 data)
2052{
2053   cop->ram[(offset - 0x400) / 2] = data;
2054}
2055
2056INLINE UINT32 r32(offs_t address)
2057{
2058   return    (program_read_word(address + 0) << 0) |
2059         (program_read_word(address + 2) << 16);
2060}
2061
2062INLINE void w32(offs_t address, UINT32 data)
2063{
2064   program_write_word(address + 0, data >> 0);
2065   program_write_word(address + 2, data >> 16);
2066}
2067
2068
2069void cop_init(void)
2070{
2071   memset(&cop_data, 0, sizeof(cop_data));
2072}
2073
2074void raiden2_save_cop_table( running_machine* machine )
2075{
2076   cop_state *cop = &cop_data;
2077
2078   {
2079      FILE *fp;
2080      char filename[256];
2081      sprintf(filename,"r2_cop_%s_program", machine->gamedrv->name);
2082      fp=fopen(filename, "w+b");
2083      if (fp)
2084      {
2085         fwrite(cop->program, 0x200, 1, fp);
2086         fclose(fp);
2087      }
2088   }
2089
2090   {
2091      FILE *fp;
2092      char filename[256];
2093      sprintf(filename,"r2_cop_%s_value", machine->gamedrv->name);
2094      fp=fopen(filename, "w+b");
2095      if (fp)
2096      {
2097         fwrite(cop->func_value, 0x200/8, 1, fp);
2098         fclose(fp);
2099      }
2100   }
2101
2102   {
2103      FILE *fp;
2104      char filename[256];
2105      sprintf(filename,"r2_cop_%s_mask", machine->gamedrv->name);
2106      fp=fopen(filename, "w+b");
2107      if (fp)
2108      {
2109         fwrite(cop->func_mask, 0x200/8, 1, fp);
2110         fclose(fp);
2111      }
2112   }
2113
2114   {
2115      FILE *fp;
2116      char filename[256];
2117      sprintf(filename,"r2_cop_%s_trigger", machine->gamedrv->name);
2118      fp=fopen(filename, "w+b");
2119      if (fp)
2120      {
2121         fwrite(cop->func_trigger, 0x200/8, 1, fp);
2122         fclose(fp);
2123      }
2124}
2125}
2126
2127WRITE16_HANDLER( raiden2_cop2_w )
2128{
2129   cop_state *cop = &cop_data;
2130   UINT32 temp32;
2131   UINT8 regnum;
2132   int func;
2133
2134   /* all COP data writes are word-length (?) */
2135   data = COMBINE_DATA(&cop->ram[offset]);
2136
2137   /* handle writes */
2138   switch (offset + (0x400/2))
2139   {
2140      /* ----- BCD conversion ----- */
2141
2142      case 0x420/2:      /* LSW of number */
2143      case 0x422/2:      /* MSW of number */
2144         temp32 = cop_ram_r(cop, 0x420) | (cop_ram_r(cop, 0x422) << 16);
2145         cop_ram_w(cop, 0x590, ((temp32 / 1) % 10) + (((temp32 / 10) % 10) << 8) + 0x3030);
2146         cop_ram_w(cop, 0x592, ((temp32 / 100) % 10) + (((temp32 / 1000) % 10) << 8) + 0x3030);
2147         cop_ram_w(cop, 0x594, ((temp32 / 10000) % 10) + (((temp32 / 100000) % 10) << 8) + 0x3030);
2148         cop_ram_w(cop, 0x596, ((temp32 / 1000000) % 10) + (((temp32 / 10000000) % 10) << 8) + 0x3030);
2149         cop_ram_w(cop, 0x598, ((temp32 / 100000000) % 10) + (((temp32 / 1000000000) % 10) << 8) + 0x3030);
2150         break;
2151
2152      /* ----- program upload registers ----- */
2153
2154      case 0x432/2:      /* COP program data */
2155         COP_LOG(("%05X:COP Prog Data = %04X\n", activecpu_get_pc(), data));
2156         cop->program[cop_ram_r(cop, 0x434)] = data;
2157         break;
2158
2159      case 0x434/2:      /* COP program address */
2160         COP_LOG(("%05X:COP Prog Addr = %04X\n", activecpu_get_pc(), data));
2161         assert((data & ~0xff) == 0);
2162         temp32 = (data & 0xff) / 8;
2163         cop->func_value[temp32] = cop_ram_r(cop, 0x438);
2164         cop->func_mask[temp32] = cop_ram_r(cop, 0x43a);
2165         cop->func_trigger[temp32] = cop_ram_r(cop, 0x43c);
2166
2167         raiden2_save_cop_table(machine);
2168
2169         break;
2170
2171      case 0x438/2:      /* COP program entry value (0,4,5,6,7,8,9,F) */
2172         COP_LOG(("%05X:COP Prog Val  = %04X\n", activecpu_get_pc(), data));
2173         break;
2174
2175      case 0x43a/2:      /* COP program entry mask */
2176         COP_LOG(("%05X:COP Prog Mask = %04X\n", activecpu_get_pc(), data));
2177         break;
2178
2179      case 0x43c/2:      /* COP program trigger value */
2180         COP_LOG(("%05X:COP Prog Trig = %04X\n", activecpu_get_pc(), data));
2181         break;
2182
2183      /* ----- ???? ----- */
2184
2185      case 0x47a/2:      /* clear RAM */
2186         if (cop_ram_r(cop, 0x47e) == 0x118)
2187         {
2188            UINT32 addr = cop_ram_r(cop, 0x478) << 6;
2189            int count = (cop_ram_r(cop, 0x47a) + 1) << 5;
2190            COP_LOG(("%05X:COP RAM clear from %05X to %05X\n", activecpu_get_pc(), addr, addr + count));
2191            while (count--)
2192               program_write_byte(addr++, 0);
2193         }
2194         else
2195         {
2196            COP_LOG(("%05X:COP Unknown RAM clear(%04X) = %04X\n", activecpu_get_pc(), cop_ram_r(cop, 0x47e), data));
2197         }
2198         break;
2199
2200      /* ----- program data registers ----- */
2201
2202      case 0x4a0/2:      /* COP register high word */
2203      case 0x4a2/2:      /* COP register high word */
2204      case 0x4a4/2:      /* COP register high word */
2205      case 0x4a6/2:      /* COP register high word */
2206         regnum = (offset) % 4;
2207         COP_LOG(("%05X:COP RegHi(%d) = %04X\n", activecpu_get_pc(), regnum, data));
2208         cop->reg[regnum] = (cop->reg[regnum] & 0x0000ffff) | (data << 16);
2209         break;
2210
2211      case 0x4c0/2:      /* COP register low word */
2212      case 0x4c2/2:      /* COP register low word */
2213      case 0x4c4/2:      /* COP register low word */
2214      case 0x4c6/2:      /* COP register low word */
2215         regnum = (offset) % 4;
2216         COP_LOG(("%05X:COP RegLo(%d) = %04X\n", activecpu_get_pc(), regnum, data));
2217         cop->reg[regnum] = (cop->reg[regnum] & 0xffff0000) | data;
2218         break;
2219
2220      /* ----- program trigger register ----- */
2221
2222      case 0x500/2:      /* COP trigger */
2223         COP_LOG(("%05X:COP Trigger = %04X\n", activecpu_get_pc(), data));
2224         for (func = 0; func < ARRAY_LENGTH(cop->func_trigger); func++)
2225            if (cop->func_trigger[func] == data)
2226            {
2227               int offs;
2228
2229               COP_LOG(("  Execute:"));
2230               for (offs = 0; offs < 8; offs++)
2231               {
2232                  if (cop->program[func * 8 + offs] == 0)
2233                     break;
2234                  COP_LOG((" %04X", cop->program[func * 8 + offs]));
2235               }
2236               COP_LOG(("\n"));
2237
2238               /* special cases for now */
2239               if (data == 0x5205 || data == 0x5a05)
2240               {
2241                  COP_LOG(("  Copy 32 bits from %05X to %05X\n", cop->reg[0], cop->reg[1]));
2242                  w32(cop->reg[1], r32(cop->reg[0]));
2243               }
2244               else if (data == 0xf205)
2245               {
2246                  COP_LOG(("  Copy 32 bits from %05X to %05X\n", cop->reg[0] + 4, cop->reg[1]));
2247                  w32(cop->reg[2], r32(cop->reg[0] + 4));
2248               }
2249               break;
2250            }
2251         logerror("%05X:COP Warning - can't find command - func != ARRAY_LENGTH(cop->func_trigger)\n",  activecpu_get_pc());
2252         break;
2253
2254      /* ----- other stuff ----- */
2255
2256      default:      /* unknown */
2257         COP_LOG(("%05X:COP Unknown(%04X) = %04X\n", activecpu_get_pc(), offset*2 + 0x400, data));
2258         break;
2259   }
2260}
2261
2262
2263READ16_HANDLER( raiden2_cop2_r )
2264{
2265   cop_state *cop = &cop_data;
2266   COP_LOG(("%05X:COP Read(%04X) = %04X\n", activecpu_get_pc(), offset*2 + 0x400, cop->ram[offset]));
2267   return cop->ram[offset];
2268}
2269
src/mame/machine/ajax.c
r2375r2376
116116         data = mame_rand(Machine);
117117         break;
118118      case 0x04:   /* 2P inputs */
119         data = readinputport(5);
119         data = input_port_read_indexed(machine, 5);
120120         break;
121121      case 0x06:   /* 1P inputs + DIPSW #1 & #2 */
122122         if (offset & 0x02)
123            data = readinputport(offset & 0x01);
123            data = input_port_read_indexed(machine, offset & 0x01);
124124         else
125            data = readinputport(3 + (offset & 0x01));
125            data = input_port_read_indexed(machine, 3 + (offset & 0x01));
126126         break;
127127      case 0x07:   /* DIPSW #3 */
128         data = readinputport(2);
128         data = input_port_read_indexed(machine, 2);
129129         break;
130130
131131      default:
src/mame/machine/nitedrvr.c
r2375r2376
2828because D6 and D7 are apparently checked at different times, and a
2929change in-between can affect the direction you move.
3030***************************************************************************/
31static int nitedrvr_steering(void)
31static int nitedrvr_steering(running_machine *machine)
3232{
3333   int this_val;
3434   int delta;
3535
36   this_val = readinputport(5);
36   this_val = input_port_read_indexed(machine, 5);
3737
3838   delta=this_val-last_steering_val;
3939   last_steering_val=this_val;
r2375r2376
107107{
108108   int gear;
109109
110   gear = readinputport(2);
110   gear = input_port_read_indexed(machine, 2);
111111   if (gear & 0x10)            nitedrvr_gear=1;
112112   else if (gear & 0x20)         nitedrvr_gear=2;
113113   else if (gear & 0x40)         nitedrvr_gear=3;
r2375r2376
116116   switch (offset & 0x03)
117117   {
118118      case 0x00:                  /* No remapping necessary */
119         return readinputport(0);
119         return input_port_read_indexed(machine, 0);
120120      case 0x01:                  /* No remapping necessary */
121         return readinputport(1);
121         return input_port_read_indexed(machine, 1);
122122      case 0x02:                  /* Remap our gear shift */
123123         if (nitedrvr_gear==1)      return 0xE0;
124124         else if (nitedrvr_gear==2)   return 0xD0;
125125         else if (nitedrvr_gear==3)   return 0xB0;
126126         else                  return 0x70;
127127      case 0x03:                  /* Remap our steering */
128         return (readinputport(3) | nitedrvr_steering());
128         return (input_port_read_indexed(machine, 3) | nitedrvr_steering(machine));
129129      default:
130130         return 0xFF;
131131   }
r2375r2376
169169
170170   ac_line=(ac_line+1) % 3;
171171
172   port = readinputport(4);
172   port = input_port_read_indexed(machine, 4);
173173   if (port & 0x10)            nitedrvr_track=0;
174174   else if (port & 0x20)         nitedrvr_track=1;
175175   else if (port & 0x40)         nitedrvr_track=2;
src/mame/mamedriv.c
r2375r2376
548548   DRIVER( fenix )      /* bootleg */
549549   DRIVER( falcon )   /* bootleg */
550550   DRIVER( vautour )   /* bootleg (Jeutel) */
551   DRIVER( vautour2 )   /* bootleg */
551   DRIVER( falconz )   /* bootleg */
552   DRIVER( vautourz )   /* bootleg */
552553   DRIVER( griffon )   /* bootleg (Videotron) */
553   DRIVER( falcona )   /* bootleg */
554554   DRIVER( nextfase )   /* bootleg */
555555   DRIVER( pleiads )   /* (c) 1981 Tehkan */
556556   DRIVER( pleiadbl )   /* bootleg */
r2375r2376
20072007   DRIVER( dendeg2x )   /* E52 (c) 1998 Taito Corporation */
20082008   DRIVER( sidebs )   /* E23 (c) 1996 Taito Corporation */
20092009   DRIVER( sidebs2 )   /* E38 (c) 1997 Taito Corporation */
2010   DRIVER( sidebs2j )   /* E38 (c) 1997 Taito Corporation */
20102011   DRIVER( dangcurv )   /* E09 (c) 1995 Taito Corporation */
20112012
20122013   /* Taito "Wolf" System */
r2375r2376
35613562   DRIVER( smgpu2 )   /* (c) 1989 (FD1094, decrypted) */
35623563   DRIVER( smgpu1 )   /* (c) 1989 (FD1094, decrypted) */
35633564   DRIVER( smgpj )      /* (c) 1989 (FD1094, decrypted) */
3565   DRIVER( smgpja )   /* (c) 1989 (FD1094, decrypted) */
35643566
35653567   /* Y-Board */
35663568   DRIVER( gforce2 )   /* (c) 1988 */
r2375r2376
60896091
60906092   /* Midway Touchmaster / Galaxy Games */
60916093   DRIVER( tm )      /* (c) 1996 Midway Games */
6092   DRIVER( tm3k )      /* (c) 1996 Midway Games */
6093   DRIVER( tm4k )      /* (c) 1996 Midway Games */
6094   DRIVER( tm3k )      /* (c) 1997 Midway Games */
6095   DRIVER( tm4k )      /* (c) 1998 Midway Games */
6096   DRIVER( tm5k )      /* (c) 1998 Midway Games */
6097   DRIVER( tm7k )      /* (c) 1999 Midway Games */
60946098   DRIVER( galgbios )  /* (c) 1998 Creative Electonics & Software (CES) */
60956099
60966100   /* Cinematronics raster games */
r2375r2376
62966300   DRIVER( denjinmk )   /* (c) 199? Banpresto */
62976301   DRIVER( sdgndmrb )   /* (c) 1993 Banpresto */
62986302   DRIVER( cupsoc )   /* (c) 1992 Seibu */
6299   DRIVER( cupsoc2 )   /* (c) 1992 Seibu */
6303   DRIVER( cupsocs )   /* (c) 1992 Seibu */
6304   DRIVER( cupsocs2 )   /* (c) 1992 Seibu */
6305   DRIVER( cupsocsb )   /* bootleg */
63006306   DRIVER( olysoc92 )   /* (c) 1992 Seibu */
6301   DRIVER( cupsocbl )   /* bootleg */
63026307   DRIVER( goal92 )   /* bootleg */
63036308
63046309   /* Jaleco games */
r2375r2376
64316436   DRIVER( pspikesk )   /* (c) 1991 Video System Co. (Korea) */
64326437   DRIVER( svolly91 )   /* (c) 1991 Video System Co. (Japan) */
64336438   DRIVER( pspikesb )   /* bootleg */
6434   DRIVER( pallavol )   /* bootleg */
6439   DRIVER( spikes91 )   /* bootleg */
64356440   DRIVER( pspikesc )   /* bootleg */
64366441   DRIVER( karatblz )   /* (c) 1991 Video System Co. */
64376442   DRIVER( karatblu )   /* (c) 1991 Video System Co. (US) */
src/mame/includes/mw8080bw.h
r2375r2376
4040#define TORNBASE_CAB_TYPE_UPRIGHT_OLD   (0)
4141#define TORNBASE_CAB_TYPE_UPRIGHT_NEW   (1)
4242#define TORNBASE_CAB_TYPE_COCKTAIL      (2)
43UINT8 tornbase_get_cabinet_type(void);
43UINT8 tornbase_get_cabinet_type(running_machine *machine);
4444
4545#define DESERTGU_GUN_X_PORT_TAG         ("GUNX")
4646#define DESERTGU_GUN_Y_PORT_TAG         ("GUNY")
r2375r2376
6363CUSTOM_INPUT( invaders_in2_control_r );
6464UINT8 invaders_is_flip_screen(void);
6565void invaders_set_flip_screen(UINT8 data);
66int invaders_is_cabinet_cocktail(void);
66int invaders_is_cabinet_cocktail(running_machine *machine);
6767
6868#define BLUESHRK_SPEAR_PORT_TAG         ("SPEAR")
6969
src/mame/includes/cps1.h
r2375r2376
7474
7575VIDEO_START( cps1 );
7676VIDEO_START( cps2 );
77void cps1_build_palette(running_machine *machine);
7877
7978WRITE16_HANDLER( cps2_objram_bank_w );
8079READ16_HANDLER( cps2_objram1_r );
src/mame/includes/phoenix.h
r2375r2376
6363WRITE8_HANDLER( pleiads_videoreg_w );
6464WRITE8_HANDLER( phoenix_scroll_w );
6565
66READ8_HANDLER( phoenix_input_port_0_r );
67READ8_HANDLER( pleiads_input_port_0_r );
66CUSTOM_INPUT( player_input_r );
67CUSTOM_INPUT( pleiads_protection_r );
6868READ8_HANDLER( survival_input_port_0_r );
6969READ8_HANDLER( survival_protection_r );
7070
src/mame/includes/snk.h
r2375r2376
3131extern VIDEO_START( sgladiat );
3232
3333extern VIDEO_UPDATE( tnk3 );
34extern VIDEO_UPDATE( athena );
3435extern VIDEO_UPDATE( ikari );
3536extern VIDEO_UPDATE( tdfever );
3637extern VIDEO_UPDATE( gwar );
src/mame/includes/atari.h
r2375r2376
5252WRITE8_HANDLER ( atari_serout_w );
5353void atari_interrupt_cb(int mask);
5454
55void a800_handle_keyboard(void);
56void a5200_handle_keypads(void);
55void a800_handle_keyboard(running_machine *machine);
56void a5200_handle_keypads(running_machine *machine);
5757
5858/* video */
5959
src/mame/includes/twincobr.h
r2375r2376
77
88/*----------- defined in drivers/wardner.c -----------*/
99
10extern void wardner_restore_bank(void);
10extern STATE_POSTLOAD( wardner_restore_bank );
1111
1212/*----------- defined in machine/twincobr.c -----------*/
1313
r2375r2376
3535MACHINE_RESET( twincobr );
3636MACHINE_RESET( wardner );
3737
38extern void twincobr_driver_savestate(void);
39extern void wardner_driver_savestate(void);
38extern void twincobr_driver_savestate(running_machine *machine);
39extern void wardner_driver_savestate(running_machine *machine);
4040
4141extern int toaplan_main_cpu;   /* Main CPU type.  0 = 68000, 1 = Z80 */
4242extern int twincobr_intenable;
src/mame/includes/neogeo.h
r2375r2376
141141READ16_HANDLER( neogeo_video_register_r );
142142WRITE16_HANDLER( neogeo_video_register_w );
143143
144void neogeo_set_palette_bank(UINT8 data);
145void neogeo_set_screen_dark(UINT8 data);
144void neogeo_set_palette_bank(running_machine *machine, UINT8 data);
145void neogeo_set_screen_dark(running_machine *machine, UINT8 data);
146146READ16_HANDLER( neogeo_paletteram_r );
147147WRITE16_HANDLER( neogeo_paletteram_w );
148148
src/mame/includes/toaplan1.h
r2375r2376
3131MACHINE_RESET( vimana );
3232MACHINE_RESET( zerozone );   /* hack for ZeroWing/OutZone. See video */
3333
34extern void toaplan1_driver_savestate(void);
35extern void demonwld_driver_savestate(void);
36extern void vimana_driver_savestate(void);
34extern void toaplan1_driver_savestate(running_machine *machine);
35extern void demonwld_driver_savestate(running_machine *machine);
36extern void vimana_driver_savestate(running_machine *machine);
3737
3838
3939extern int toaplan1_unk_reset_port;
src/mame/includes/8080bw.h
r2375r2376
6969
7070extern UINT8 *c8080bw_colorram;
7171
72void c8080bw_flip_screen_w(int data);
72void c8080bw_flip_screen_w(running_machine *machine, int data);
7373void c8080bw_screen_red_w(int data);
7474void schaser_background_control_w(int data);
7575
src/mame/includes/st0016.h
r2375r2376
5050
5151extern UINT32 st0016_game;
5252
53void st0016_save_init(void);
53void st0016_save_init(running_machine *machine);
5454
5555
src/mame/includes/amiga.h
r2375r2376
409409VIDEO_START( amiga );
410410VIDEO_UPDATE( amiga );
411411
412UINT32 amiga_gethvpos(void);
412UINT32 amiga_gethvpos(const device_config *screen);
413413void copper_setpc(UINT32 pc);
414414void amiga_set_genlock_color(UINT16 color);
415415void amiga_render_scanline(running_machine *machine, bitmap_t *bitmap, int scanline);
src/mame/includes/vicdual.h
r2375r2376
2727UINT8 vicdual_videoram_r(offs_t offset);
2828UINT8 vicdual_characterram_r(offs_t offset);
2929
30int vicdual_is_cabinet_color(void);
30int vicdual_is_cabinet_color(running_machine *machine);
3131
3232
3333/*----------- defined in video/vicdual.c -----------*/
src/mame/includes/psx.h
r2375r2376
5454WRITE32_HANDLER( psx_mdec_w );
5555READ32_HANDLER( psx_mdec_r );
5656extern void psx_machine_init( void );
57extern void psx_driver_init( void );
57extern void psx_driver_init( running_machine *machine );
5858
5959#define PSX_H ( 1 )
6060#endif
src/mame/mame.mak
r2375r2376
203203CPUS += TMS7000_EXL
204204CPUS += SM8500
205205CPUS += V30MZ
206CPUS += CXD8661R
206207
207208
208209
r2375r2376
383384   $(MAMEOBJ)/subsino.a \
384385   $(MAMEOBJ)/sun.a \
385386   $(MAMEOBJ)/suna.a \
386   $(MAMEOBJ)/tad.a \
387387   $(MAMEOBJ)/taito.a \
388388   $(MAMEOBJ)/tatsumi.a \
389389   $(MAMEOBJ)/tch.a \
r2375r2376
12161216   $(DRIVERS)/wiz.o $(VIDEO)/wiz.o \
12171217   $(MACHINE)/spisprit.o \
12181218   $(AUDIO)/seibu.o \
1219   $(DRIVERS)/bloodbro.o $(VIDEO)/bloodbro.o \
1220   $(DRIVERS)/cabal.o $(VIDEO)/cabal.o \
1221   $(DRIVERS)/goal92.o $(VIDEO)/goal92.o \
1222   $(DRIVERS)/legionna.o $(VIDEO)/legionna.o \
1223   $(MACHINE)/seicop.o \
1224   $(DRIVERS)/toki.o $(VIDEO)/toki.o \
12191225
12201226$(MAMEOBJ)/seta.a: \
12211227   $(DRIVERS)/aleck64.o $(MACHINE)/n64.o $(VIDEO)/n64.o \
r2375r2376
12791285   $(DRIVERS)/suna8.o $(AUDIO)/suna8.o $(VIDEO)/suna8.o \
12801286   $(DRIVERS)/suna16.o $(VIDEO)/suna16.o \
12811287
1282$(MAMEOBJ)/tad.a: \
1283   $(DRIVERS)/bloodbro.o $(VIDEO)/bloodbro.o \
1284   $(DRIVERS)/cabal.o $(VIDEO)/cabal.o \
1285   $(DRIVERS)/goal92.o $(VIDEO)/goal92.o \
1286   $(DRIVERS)/legionna.o $(VIDEO)/legionna.o \
1287   $(DRIVERS)/toki.o $(VIDEO)/toki.o \
1288
12891288$(MAMEOBJ)/taito.a: \
12901289   $(DRIVERS)/40love.o $(VIDEO)/40love.o \
12911290   $(DRIVERS)/arkanoid.o $(MACHINE)/arkanoid.o $(VIDEO)/arkanoid.o \
src/mame/video/aerofgt.c
r2375r2376
476476   }
477477}
478478
479static void spikes91_draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
480{
481   int i;
482   UINT8 *lookup;
483   lookup = memory_region(REGION_USER1);
484   spritepalettebank = 1;
485
486   for (i = aerofgt_spriteram3_size/2 - 4 ; i >= 4 ; i -= 4)
487   {
488      int xpos,ypos,color,flipx,flipy,code,realcode;
489
490      code = aerofgt_spriteram3[i + 0] & 0x1fff;
491
492      if (!code) continue;
493
494      xpos = (aerofgt_spriteram3[i + 2] & 0x01ff) - 16;
495      ypos = 256 - (aerofgt_spriteram3[i + 1] & 0x00ff) - 26;
496      flipy = 0;
497      flipx = aerofgt_spriteram3[i + 3] & 0x8000;
498      color = ((aerofgt_spriteram3[i + 3] & 0x00f0) >> 4);
499
500      // look-up table
501      // RZ notes:
502      // in game it's necessary an or with 0x2000;
503      // probably a bit switch the table
504      // almost sure no line swap in the look-up table
505
506      code |= 0x2000;
507      realcode = (lookup[code] << 8) + lookup[0x10000 + code];
508
509      drawgfx(bitmap,machine->gfx[sprite_gfx],
510            realcode,
511            color,
512            flipx,flipy,
513            xpos,ypos,
514            cliprect,TRANSPARENCY_PEN,15);
515
516      /* wrap around y */
517      drawgfx(bitmap,machine->gfx[sprite_gfx],
518            realcode,
519            color,
520            flipx,flipy,
521            xpos,ypos + 512,
522            cliprect,TRANSPARENCY_PEN,15);
523   }
524}
525
479526static void aerfboot_draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
480527{
481   int attr_start;//,base,first;
482//  int notdraw = 0;
528   int attr_start,last;
483529
484//  base = chip * 0x0200;
485//  first = 4 * aerofgt_spriteram3[0x1fe + base];
530   last = ((aerofgt_rasterram[0x404/2] << 5) - 0x8000) / 2;
486531
487   for (attr_start = aerofgt_spriteram3_size/2 - 4 /* - 16 */;attr_start >= 0;attr_start -= 4)
532   for (attr_start = aerofgt_spriteram3_size / 2 - 4 ; attr_start >= last ; attr_start -= 4)
488533   {
489534      int code;
490535      int ox,oy,sx,sy,zoomx,zoomy,flipx,flipy,color,pri;
491// some other drivers still use this wrong table, they have to be upgraded
492//      int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
493536
494537      ox = aerofgt_spriteram3[attr_start + 1] & 0x01ff;
495538      oy = aerofgt_spriteram3[attr_start + 0] & 0x01ff;
r2375r2376
500543      zoomx = (aerofgt_spriteram3[attr_start + 1] & 0xf000) >> 12;
501544      zoomy = (aerofgt_spriteram3[attr_start + 0] & 0xf000) >> 12;
502545      pri = aerofgt_spriteram3[attr_start + 2] & 0x0010;
503//      code = aerofgt_spriteram3[attr_start + 3] & 0x3fff;
504546      code = aerofgt_spriteram3[attr_start + 3] & 0x1fff;
505547
506//      if ((!(aerofgt_spriteram3[attr_start + 0])) & (!(aerofgt_spriteram3[attr_start + 1])) &
507//          (!(aerofgt_spriteram3[attr_start + 2])) & (!(aerofgt_spriteram3[attr_start + 3]))) notdraw = 1;
548      if (!(aerofgt_spriteram3[attr_start + 2] & 0x0040)) code |= 0x2000;
508549
509//      if (notdraw) continue;
550      zoomx = 32 + zoomx;
551      zoomy = 32 + zoomy;
510552
553      sy = ((oy + 16 - 1) & 0x1ff) - 16;
554
555      sx = ((ox + 16 + 3) & 0x1ff) - 16;
556
557      pdrawgfxzoom(bitmap,machine->gfx[sprite_gfx + (code >= 0x1000 ? 0 : 1)],
558            code,
559            color,
560            flipx,flipy,
561            sx,sy,
562            cliprect,TRANSPARENCY_PEN,15,
563            zoomx << 11,zoomy << 11,
564            pri ? 0 : 0x2);
565
566   }
567
568   last = ((aerofgt_rasterram[0x402/2] << 5) - 0x8000) / 2;
569
570   for (attr_start = ((aerofgt_spriteram3_size / 2) / 2) - 4 ; attr_start >= last ; attr_start -= 4)
571   {
572      int code;
573      int ox,oy,sx,sy,zoomx,zoomy,flipx,flipy,color,pri;
574
575      ox = aerofgt_spriteram3[attr_start + 1] & 0x01ff;
576      oy = aerofgt_spriteram3[attr_start + 0] & 0x01ff;
577      flipx = aerofgt_spriteram3[attr_start + 2] & 0x0800;
578      flipy = aerofgt_spriteram3[attr_start + 2] & 0x8000;
579      color = aerofgt_spriteram3[attr_start + 2] & 0x000f;
580
581      zoomx = (aerofgt_spriteram3[attr_start + 1] & 0xf000) >> 12;
582      zoomy = (aerofgt_spriteram3[attr_start + 0] & 0xf000) >> 12;
583      pri = aerofgt_spriteram3[attr_start + 2] & 0x0010;
584      code = aerofgt_spriteram3[attr_start + 3] & 0x1fff;
585
511586      if (!(aerofgt_spriteram3[attr_start + 2] & 0x0040)) code |= 0x2000;
512587
513588      zoomx = 32 + zoomx;
514589      zoomy = 32 + zoomy;
515590
516      sy = ((oy + 16) & 0x1ff) - 16;
591      sy = ((oy + 16 - 1) & 0x1ff) - 16;
517592
518      sx = ((ox + 16) & 0x1ff) - 16;
593      sx = ((ox + 16 + 3) & 0x1ff) - 16;
519594
520595      pdrawgfxzoom(bitmap,machine->gfx[sprite_gfx + (code >= 0x1000 ? 0 : 1)],
521596            code,
r2375r2376
582657   return 0;
583658}
584659
660VIDEO_UPDATE( spikes91 )
661{
662   int i,scrolly;
663
664   tilemap_set_scroll_rows(bg1_tilemap,256);
665   scrolly = bg1scrolly;
666
667   for (i = 0;i < 256;i++)
668      tilemap_set_scrollx(bg1_tilemap,(i + scrolly) & 0xff,aerofgt_rasterram[i+0x01f0/2]+0x96+0x16);
669   tilemap_set_scrolly(bg1_tilemap,0,scrolly);
670
671   tilemap_draw(bitmap,cliprect,bg1_tilemap,0,0);
672   spikes91_draw_sprites(screen->machine,bitmap,cliprect);
673   return 0;
674}
675
585676VIDEO_UPDATE( karatblz )
586677{
587678   tilemap_set_scrollx(bg1_tilemap,0,bg1scrollx-8);
src/mame/video/fgoal.c
r2375r2376
5151
5252   /* draw color overlay foreground and background */
5353
54   if (fgoal_player == 1 && (readinputport(1) & 0x40))
54   if (fgoal_player == 1 && (input_port_read_indexed(screen->machine, 1) & 0x40))
5555   {
5656      drawgfxzoom(fgbitmap, screen->machine->gfx[0],
5757         0, (fgoal_player << 2) | current_color,
src/mame/video/mystston.c
r2375r2376
257257{
258258   mystston_state *state = screen->machine->driver_data;
259259
260   int flip = (*state->video_control & 0x80) ^ ((readinputportbytag("DSW1") & 0x20) << 2);
260   int flip = (*state->video_control & 0x80) ^ ((input_port_read(screen->machine, "DSW1") & 0x20) << 2);
261261
262262   set_palette(screen->machine, state);
263263
src/mame/video/ygv608.c
r2375r2376
474474   }
475475}
476476
477static void ygv608_postload(void)
477static STATE_POSTLOAD( ygv608_postload )
478478{
479479   int i;
480480
r2375r2376
485485      SetPostShortcuts(i);
486486}
487487
488static void ygv608_register_state_save(void)
488static void ygv608_register_state_save(running_machine *machine)
489489{
490490   state_save_register_item_array("ygv608", 0, ygv608.ports.b);
491491   state_save_register_item_array("ygv608", 0, ygv608.regs.b);
r2375r2376
494494   state_save_register_item_2d_array("ygv608", 0, ygv608.scroll_data_table);
495495   state_save_register_item_2d_array("ygv608", 0, ygv608.colour_palette);
496496
497   state_save_register_func_postload(ygv608_postload);
497   state_save_register_postload(machine, ygv608_postload, NULL);
498498}
499499
500500static void ygv608_exit(running_machine *machine)
r2375r2376
534534   tilemap_A = NULL;
535535   tilemap_B = NULL;
536536
537   ygv608_register_state_save();
537   ygv608_register_state_save(machine);
538538   add_exit_callback(machine, ygv608_exit);
539539}
540540
src/mame/video/stvvdp1.c
r2375r2376
20812081   //popmessage("%04x %04x",STV_VDP1_EWRR_X3,STV_VDP1_EWRR_Y3);
20822082}
20832083
2084static void stv_vdp1_state_save_postload(void)
2084static STATE_POSTLOAD( stv_vdp1_state_save_postload )
20852085{
20862086   UINT8 *vdp1 = stv_vdp1_gfx_decode;
20872087   int offset;
r2375r2376
21032103   }
21042104}
21052105
2106int stv_vdp1_start ( void )
2106int stv_vdp1_start ( running_machine *machine )
21072107{
21082108   stv_vdp1_regs = auto_malloc ( 0x040000 );
21092109   stv_vdp1_vram = auto_malloc ( 0x100000 );
r2375r2376
21432143   state_save_register_global(stv_vdp1_clear_framebuffer_on_next_frame);
21442144   state_save_register_global(stvvdp1_local_x);
21452145   state_save_register_global(stvvdp1_local_y);
2146   state_save_register_func_postload(stv_vdp1_state_save_postload);
2146   state_save_register_postload(machine, stv_vdp1_state_save_postload, NULL);
21472147   return 0;
21482148}
src/mame/video/sonson.c
r2375r2376
88
99#include "driver.h"
1010
11UINT8 *sonson_scroll;
1211static tilemap *bg_tilemap;
1312
1413/***************************************************************************
r2375r2376
107106   tilemap_mark_tile_dirty(bg_tilemap, offset);
108107}
109108
109WRITE8_HANDLER( sonson_scrollx_w )
110{
111   int row;
112
113   for (row = 5; row < 32; row++)
114      tilemap_set_scrollx(bg_tilemap, row, data);
115}
116
110117WRITE8_HANDLER( sonson_flipscreen_w )
111118{
112   if (flip_screen_get() != (~data & 0x01))
113   {
114      flip_screen_set(~data & 0x01);
115      tilemap_mark_all_tiles_dirty(ALL_TILEMAPS);
116   }
119   flip_screen_set(~data & 0x01);
117120}
118121
119122static TILE_GET_INFO( get_bg_tile_info )
r2375r2376
164167
165168VIDEO_UPDATE( sonson )
166169{
167   int row;
168
169   for (row = 5; row < 32; row++)
170      tilemap_set_scrollx(bg_tilemap, row, *sonson_scroll);
171
172170   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
173171   draw_sprites(screen->machine, bitmap, cliprect);
174172   return 0;
src/mame/video/twincobr.c
r2375r2376
1919
2020void twincobr_flipscreen(int flip);
2121void twincobr_display(int enable);
22static void twincobr_restore_screen(void);
22static STATE_POSTLOAD( twincobr_restore_screen );
2323
2424INT32 twincobr_fg_rom_bank;
2525INT32 twincobr_bg_ram_bank;
r2375r2376
151151   state_save_register_global(twincobr_bg_ram_bank);
152152   state_save_register_global(twincobr_flip_screen);
153153   state_save_register_global(wardner_sprite_hack);
154   state_save_register_func_postload(twincobr_restore_screen);
154   state_save_register_postload(machine, twincobr_restore_screen, NULL);
155155}
156156
157static void twincobr_restore_screen(void)
157static STATE_POSTLOAD( twincobr_restore_screen )
158158{
159159   twincobr_display(twincobr_display_on);
160160   twincobr_flipscreen(twincobr_flip_screen);
src/mame/video/bking.c
r2375r2376
216216
217217READ8_HANDLER( bking_input_port_5_r )
218218{
219   return readinputport(controller ? 7 : 5);
219   return input_port_read_indexed(machine, controller ? 7 : 5);
220220}
221221
222222READ8_HANDLER( bking_input_port_6_r )
223223{
224   return readinputport(controller ? 8 : 6);
224   return input_port_read_indexed(machine, controller ? 8 : 6);
225225}
226226
227227READ8_HANDLER( bking_pos_r )
src/mame/video/orbit.c
r2375r2376
8686
8787VIDEO_UPDATE( orbit )
8888{
89   orbit_flip_screen = readinputport(3) & 8;
89   orbit_flip_screen = input_port_read_indexed(screen->machine, 3) & 8;
9090
9191   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
9292
src/mame/video/policetr.c
r2375r2376
283283   {
284284      /* latch 0x00 is player 1's gun X coordinate */
285285      case 0x00:
286         inputval = ((readinputport(3) & 0xff) * width) >> 8;
286         inputval = ((input_port_read_indexed(machine, 3) & 0xff) * width) >> 8;
287287         inputval += 0x50;
288288         return (inputval << 20) | 0x20000000;
289289
290290      /* latch 0x01 is player 1's gun Y coordinate */
291291      case 0x01:
292         inputval = ((readinputport(4) & 0xff) * height) >> 8;
292         inputval = ((input_port_read_indexed(machine, 4) & 0xff) * height) >> 8;
293293         inputval += 0x17;
294294         return (inputval << 20);
295295
296296      /* latch 0x02 is player 2's gun X coordinate */
297297      case 0x02:
298         inputval = ((readinputport(5) & 0xff) * width) >> 8;
298         inputval = ((input_port_read_indexed(machine, 5) & 0xff) * width) >> 8;
299299         inputval += 0x50;
300300         return (inputval << 20) | 0x20000000;
301301
302302      /* latch 0x03 is player 2's gun Y coordinate */
303303      case 0x03:
304         inputval = ((readinputport(6) & 0xff) * height) >> 8;
304         inputval = ((input_port_read_indexed(machine, 6) & 0xff) * height) >> 8;
305305         inputval += 0x17;
306306         return (inputval << 20);
307307
src/mame/video/system1.c
r2375r2376
108108   palette_set_color(Machine,offset,MAKE_RGB(r,g,b));
109109}
110110
111static void system1_postload(void)
111static STATE_POSTLOAD( system1_postload )
112112{
113113   memset(sprite_onscreen_map, 255, 256*256);
114114   memset(bg_dirtybuffer, 1, 1024);
r2375r2376
124124
125125   tmp_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
126126
127   state_save_register_func_postload(system1_postload);
127   state_save_register_postload(machine, system1_postload, NULL);
128128   state_save_register_global(system1_background_memory);
129129   state_save_register_global(system1_video_mode);
130130
r2375r2376
145145
146146   system1_sprite_xoffset = 1+7*2;
147147
148   state_save_register_func_postload(system1_postload);
148   state_save_register_postload(machine, system1_postload, NULL);
149149   state_save_register_global(system1_background_memory);
150150   state_save_register_global(system1_video_mode);
151151
src/mame/video/stvvdp2.c
r2375r2376
9797
9898UINT32* stv_vdp2_cram;
9999void video_update_vdp1(running_machine *machine);
100int stv_vdp1_start ( void );
100int stv_vdp1_start (running_machine *machine);
101101static void stv_vdp2_dynamic_res_change(void);
102102static void refresh_palette_data(void);
103103static int stv_vdp2_window_process(int x,int y);
r2375r2376
52385238   return stv_vdp2_regs[offset];
52395239}
52405240
5241static void stv_vdp2_state_save_postload(void)
5241static STATE_POSTLOAD( stv_vdp2_state_save_postload )
52425242{
52435243   UINT8 *stv_vdp2_vram_decode = stv_vdp2_gfx_decode;
52445244   int offset;
r2375r2376
52885288   state_save_register_global_pointer(stv_vdp2_regs, 0x040000/4);
52895289   state_save_register_global_pointer(stv_vdp2_vram, 0x100000/4);
52905290   state_save_register_global_pointer(stv_vdp2_cram, 0x080000/4);
5291   state_save_register_func_postload(stv_vdp2_state_save_postload);
5291   state_save_register_postload(machine, stv_vdp2_state_save_postload, NULL);
52925292
52935293   return 0;
52945294}
r2375r2376
52985298{
52995299   stv_vdp2_roz_bitmap[0] =  stv_vdp2_roz_bitmap[1] = NULL;
53005300   stv_vdp2_start(machine);
5301   stv_vdp1_start();
5301   stv_vdp1_start(machine);
53025302   debug.l_en = 0xff;
53035303   debug.error = 0xffffffff;
53045304   debug.roz = 0;
src/mame/video/namcofl.c
r2375r2376
8787   static int old_coin_state;
8888
8989static void
90handle_mcu( void )
90handle_mcu( running_machine *machine )
9191   {
9292   UINT8 *IORAM = (UINT8 *)namcofl_mcuram;
9393   static int toggle;
94   int new_coin_state = readinputport(3)&0x30;
95   unsigned p1 = readinputport(0);
96   unsigned p2 = readinputport(2);
97   unsigned p3 = readinputport(1);
98   unsigned p4 = readinputport(3);
94   int new_coin_state = input_port_read_indexed(machine, 3)&0x30;
95   unsigned p1 = input_port_read_indexed(machine, 0);
96   unsigned p2 = input_port_read_indexed(machine, 2);
97   unsigned p3 = input_port_read_indexed(machine, 1);
98   unsigned p4 = input_port_read_indexed(machine, 3);
9999
100100   IORAM[BYTE4_XOR_LE(0x6000)] = p1;
101101   IORAM[BYTE4_XOR_LE(0x6003)] = p2;
102102   IORAM[BYTE4_XOR_LE(0x6005)] = p3;
103103   IORAM[BYTE4_XOR_LE(0x60b8)] = p4;
104104
105   IORAM[BYTE4_XOR_LE(0x6014)] = readinputport(6)-1;   // handle
106   IORAM[BYTE4_XOR_LE(0x6016)] = readinputport(5);   // brake
107   IORAM[BYTE4_XOR_LE(0x6018)] = readinputport(4);   // accelerator
105   IORAM[BYTE4_XOR_LE(0x6014)] = input_port_read_indexed(machine, 6)-1;   // handle
106   IORAM[BYTE4_XOR_LE(0x6016)] = input_port_read_indexed(machine, 5);   // brake
107   IORAM[BYTE4_XOR_LE(0x6018)] = input_port_read_indexed(machine, 4);   // accelerator
108108
109109   if (!(new_coin_state & 0x20) && (old_coin_state & 0x20))
110110   {
r2375r2376
145145{
146146   int pri;
147147
148   handle_mcu();
148   handle_mcu(screen->machine);
149149   namcofl_install_palette(screen->machine);
150150
151151   fillbitmap( bitmap, get_black_pen(screen->machine), cliprect );
r2375r2376
180180VIDEO_START( namcofl )
181181{
182182   credits1 = credits2 = 0;
183   old_coin_state = readinputport(3)&0x30;
183   old_coin_state = input_port_read_indexed(machine, 3)&0x30;
184184
185185   namco_tilemap_init( NAMCONB1_TILEGFX, memory_region(NAMCONB1_TILEMASKREGION), TilemapCB );
186186   namco_obj_init(NAMCONB1_SPRITEGFX,0x0,FLobjcode2tile);
src/mame/video/chaknpop.c
r2375r2376
171171  Initialize video hardware emulation
172172***************************************************************************/
173173
174static STATE_POSTLOAD( chaknpop_postload )
175{
176   set_vram_bank();
177   tx_tilemap_mark_all_dirty();
178}
179
180
174181VIDEO_START( chaknpop )
175182{
176183   UINT8 *RAM = memory_region(REGION_CPU1);
r2375r2376
194201   state_save_register_global(flip_x);
195202   state_save_register_global(flip_y);
196203
197   state_save_register_func_postload(set_vram_bank);
198   state_save_register_func_postload(tx_tilemap_mark_all_dirty);
204   state_save_register_postload(machine, chaknpop_postload, NULL);
199205}
200206
201207
src/mame/video/amiga.c
r2375r2376
166166 *
167167 *************************************/
168168
169UINT32 amiga_gethvpos(void)
169UINT32 amiga_gethvpos(const device_config *screen)
170170{
171   UINT32 hvpos = (last_scanline << 8) | (video_screen_get_hpos(Machine->primary_screen) >> 2);
172   UINT32 latchedpos = readinputportbytag_safe("HVPOS", 0);
171   UINT32 hvpos = (last_scanline << 8) | (video_screen_get_hpos(screen) >> 2);
172   UINT32 latchedpos = input_port_read_safe(screen->machine, "HVPOS", 0);
173173
174174   /* if there's no latched position, or if we are in the active display area */
175175   /* but before the latching point, return the live HV position */
src/mame/video/cloak.c
r2375r2376
165165   SET_TILE_INFO(0, code, 0, 0);
166166}
167167
168static STATE_POSTLOAD( cloak_postload )
169{
170   set_current_bitmap_videoram_pointer();
171}
172
168173VIDEO_START( cloak )
169174{
170175   bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
r2375r2376
181186   state_save_register_global_pointer(bitmap_videoram1, 256*256);
182187   state_save_register_global_pointer(bitmap_videoram2, 256*256);
183188   state_save_register_global_pointer(palette_ram, NUM_PENS);
184   state_save_register_func_postload(set_current_bitmap_videoram_pointer);
189   state_save_register_postload(machine, cloak_postload, NULL);
185190}
186191
187192static void draw_bitmap(bitmap_t *bitmap, const rectangle *cliprect)
src/mame/video/namcona1.c
r2375r2376
44TODO:
55- dynamic screen resolution
66- bg pen (or the pen of the lower tilemap?)
7- hook up roz tilemaps with roz enable / disable and tweak it (mainly missing offsets)
8- sprites with shadow bit have bad colors
7- roz centering
8- sprites, that have the shadow bit set but aren't shadows, have bad colors
99- check if the data&0x8000 condition in tilemaps is valid even when 4bpp mode it's used
1010- namco logo in emeralda demo is missing (it's used with a roz effect)
1111- invisible dolphin sprite in emeralda instruction screen
r2375r2376
410410                           pen_t *palette_shadow_table = machine->shadow_table;
411411                           dest[x] = palette_shadow_table[dest[x]];
412412                        }
413                        else if( bShadow && !((gfx_region == 0 && color == 0x0f) || (gfx_region == 1 && color == 0xff)))
414                        {
415                           //bad colors!
416                           dest[x] = pal_base + c;
417                        }
413418                        else
414419                        {
415420                           dest[x] = pal_base + c;
r2375r2376
588593         }
589594         else
590595         {
591            tilemap_set_scrollx( bg_tilemap[which], 0, scrollx );
592            tilemap_set_scrolly( bg_tilemap[which], 0, scrolly );
593            tilemap_draw_primask( bitmap, &clip, bg_tilemap[which], 0, primask, 0 );
596            // used in emeraldia
597            if(which == 1 && namcona1_vreg[0x8a/2] == 0xfd /* maybe reg & 0x4 */)
598            {
599               INT32 incxx = ((INT16)namcona1_vreg[0xc0/2])<<8; //or incyy ?
600               INT32 incxy = ((INT16)namcona1_vreg[0xc2/2])<<8;
601               INT32 incyx = ((INT16)namcona1_vreg[0xc4/2])<<8;
602               INT32 incyy = ((INT16)namcona1_vreg[0xc6/2])<<8; //or incxx ?
603               UINT32 startx = (INT32)(INT16)namcona1_vreg[0xc8/2]<<12;
604               UINT32 starty = (INT32)(INT16)namcona1_vreg[0xca/2]<<12;
605               //namcona1_vreg[0xcc/2]; // changes dx/dy ?
594606
595#if 0
596            INT16 incxy, incyx, incxx, incyy;
597            INT16 xoffset, yoffset;
598            UINT32 startx,starty;
607               // all ROZ parameters now in 16.16 format
599608
600            incxx = (INT16)namcona1_vreg[0xc0/2]; // or incyy ?
601            incxy = (INT16)namcona1_vreg[0xc2/2];
602            incyx = (INT16)namcona1_vreg[0xc4/2];
603            incyy = (INT16)namcona1_vreg[0xc6/2]; // or incxx ?
604            xoffset = namcona1_vreg[0xc8/2];
605            yoffset = namcona1_vreg[0xca/2];
606            //namcona1_vreg[0xcc/2]; // ?
609               // now, apply adjustments to startx, starty to translate the
610               // ROZ plane.  Note that these are corrected by the inc parameters
611               // to account for scale/rotate state.
612               int dx = 46; // horizontal adjust in pixels
613               int dy = -8; // vertical adjust in pixels
614               startx += dx*incxx + dy*incyx;
615               starty += dx*incyx + dy*incyy;
607616
608            startx = ((xoffset + a) << 12);
609            starty = ((yoffset + b) << 12);
617               tilemap_draw_roz_primask(bitmap, &clip, bg_tilemap[which],
618                  startx, starty, incxx, incxy, incyx, incyy,
619                  0, 0, primask, 0);
610620
611            popmessage("scrollx = %x - scrolly = %x - xo = %d - yo = %d",scrollx,scrolly,xoffset,yoffset);
612
613            tilemap_draw_roz_primask(bitmap, &clip, bg_tilemap[which],
614               startx , starty ,
615               incxx << 8, incxy << 8, incyx << 8, incyy << 8,
616               0, 0, primask, 0);
617#endif
618
621            }
622            else
623            {
624               tilemap_set_scrollx( bg_tilemap[which], 0, scrollx );
625               tilemap_set_scrolly( bg_tilemap[which], 0, scrolly );
626               tilemap_draw_primask( bitmap, &clip, bg_tilemap[which], 0, primask, 0 );
627            }
619628         }
620629      }
621630   }
src/mame/video/dkong.c
r2375r2376
840840   num = port_tag_to_index("VIDHW");
841841   if (num>=0)
842842   {
843      newset = readinputport(num);
843      newset = input_port_read_indexed(machine, num);
844844      if (newset != state->vidhw)
845845      {
846846         state->vidhw = newset;
src/mame/video/travrusa.c
r2375r2376
274274WRITE8_HANDLER( travrusa_flipscreen_w )
275275{
276276   /* screen flip is handled both by software and hardware */
277   data ^= ~readinputport(4) & 1;
277   data ^= ~input_port_read_indexed(machine, 4) & 1;
278278
279279   flip_screen_set(data & 1);
280280
src/mame/video/psx.c
r2375r2376
547547
548548#endif
549549
550static void updatevisiblearea( void )
550static STATE_POSTLOAD( updatevisiblearea )
551551{
552552   rectangle visarea;
553553   float refresh;
r2375r2376
617617   video_screen_configure(Machine->primary_screen, m_n_screenwidth, m_n_screenheight, &visarea, HZ_TO_ATTOSECONDS(refresh));
618618}
619619
620static void psx_gpu_init( void )
620static void psx_gpu_init( running_machine *machine )
621621{
622622   int n_line;
623623   int n_level;
r2375r2376
772772   state_save_register_global( psxgpu.n_iy );
773773   state_save_register_global( psxgpu.n_ti );
774774
775   state_save_register_func_postload( updatevisiblearea );
775   state_save_register_postload( machine, updatevisiblearea, NULL );
776776}
777777
778778VIDEO_START( psx_type1 )
779779{
780780   m_n_gputype = 1;
781   psx_gpu_init();
781   psx_gpu_init(machine);
782782}
783783
784784VIDEO_START( psx_type2 )
785785{
786786   m_n_gputype = 2;
787   psx_gpu_init();
787   psx_gpu_init(machine);
788788}
789789
790790VIDEO_UPDATE( psx )
r2375r2376
36943694         m_n_twy = 0;
36953695         m_n_twh = 255;
36963696         m_n_tww = 255;
3697         updatevisiblearea();
3697         updatevisiblearea(machine, NULL);
36983698         break;
36993699      case 0x01:
37003700         verboselog( 1, "not handled: reset command buffer\n" );
r2375r2376
37483748         {
37493749            m_b_reverseflag = ( data >> 7 ) & 1;
37503750         }
3751         updatevisiblearea();
3751         updatevisiblearea(machine, NULL);
37523752         break;
37533753      case 0x09:
37543754         verboselog( 1, "not handled: GPU Control 0x09: %08x\n", data );
src/mame/video/dbz.c
r2375r2376
9393
9494VIDEO_START( dbz )
9595{
96   K053251_vh_start();
96   K053251_vh_start(machine);
9797   K056832_vh_start(machine, REGION_GFX1, K056832_BPP_4, 1, NULL, dbz_tile_callback, 1);
9898   K053247_vh_start(machine, REGION_GFX2, -52, 16, NORMAL_PLANE_ORDER, dbz_sprite_callback);
9999
src/mame/video/prehisle.c
r2375r2376
3232{
3333   switch (offset)
3434   {
35   case 0x08: return readinputport(1);                  // Player 2
36   case 0x10: return readinputport(2);                  // Coins, Tilt, Service
37   case 0x20: return readinputport(0) ^ invert_controls;   // Player 1
38   case 0x21: return readinputport(3);                  // DIPs
39   case 0x22: return readinputport(4);                  // DIPs + VBLANK
35   case 0x08: return input_port_read_indexed(machine, 1);                  // Player 2
36   case 0x10: return input_port_read_indexed(machine, 2);                  // Coins, Tilt, Service
37   case 0x20: return input_port_read_indexed(machine, 0) ^ invert_controls;   // Player 1
38   case 0x21: return input_port_read_indexed(machine, 3);                  // DIPs
39   case 0x22: return input_port_read_indexed(machine, 4);                  // DIPs + VBLANK
4040   default: return 0;
4141   }
4242}
src/mame/video/simpsons.c
r2375r2376
4545
4646VIDEO_START( simpsons )
4747{
48   K053251_vh_start();
48   K053251_vh_start(machine);
4949
5050   K052109_vh_start(machine,REGION_GFX1,NORMAL_PLANE_ORDER,tile_callback);
5151   K053247_vh_start(machine,REGION_GFX2,53,23,NORMAL_PLANE_ORDER,sprite_callback);
src/mame/video/polepos.c
r2375r2376
518518/* original arcade doesn't work in this way */
519519#ifdef MAME_DEBUG
520520   {
521      int in = readinputport( 0 );
521      int in = input_port_read_indexed(screen->machine, 0 );
522522      static int lastin;
523523
524524      if ((in ^ lastin) & polepos_gear_bit)
src/mame/video/taitoic.c
r2375r2376
762762   { PC080SN_get_bg_tile_info_1, PC080SN_get_fg_tile_info_1 }
763763};
764764
765static void PC080SN_restore_scroll(int chip)
765static STATE_POSTLOAD( PC080SN_restore_scroll )
766766{
767   int chip = (FPTR)param;
767768   int flip;
768769
769770   PC080SN_bgscrollx[chip][0] = -PC080SN_ctrl[chip][0];
r2375r2376
779780
780781/* opaque parameter is no longer supported and will be removed */
781782
782void PC080SN_vh_start(int chips,int gfxnum,int x_offset,int y_offset,int y_invert,
783void PC080SN_vh_start(running_machine *machine,int chips,int gfxnum,int x_offset,int y_offset,int y_invert,
783784            int opaque,int dblwidth)
784785{
785786   int i;
r2375r2376
817818
818819      state_save_register_item_pointer("PC080SN", i, PC080SN_ram[i], PC080SN_RAM_SIZE/2);
819820      state_save_register_item_array("PC080SN", i, PC080SN_ctrl[i]);
820      state_save_register_func_postload_int(PC080SN_restore_scroll, i);
821      state_save_register_postload(machine, PC080SN_restore_scroll, (void *)i);
821822
822823      /* use the given gfx set for bg tiles */
823824      PC080SN_bg_gfx[i] = gfxnum;
r2375r2376
12331234   state_save_register_global_pointer(PC090OJ_ram, PC090OJ_RAM_SIZE/2);
12341235   state_save_register_global_pointer(PC090OJ_ram_buffered, PC090OJ_RAM_SIZE/2);
12351236   state_save_register_global(PC090OJ_ctrl);
1236
1237//  state_save_register_func_postload(PC090OJ_restore);
12381237}
12391238
12401239READ16_HANDLER( PC090OJ_word_0_r )   // in case we find a game using 2...
r2375r2376
15041503   TC0080VCO_chars_dirty = 1;
15051504}
15061505
1507static void TC0080VCO_dirty_tilemaps(void)
1508{
1509   tilemap_mark_all_tiles_dirty(TC0080VCO_tilemap[0]);
1510   tilemap_mark_all_tiles_dirty(TC0080VCO_tilemap[1]);
1511   tilemap_mark_all_tiles_dirty(TC0080VCO_tilemap[2]);
1512}
1513
15141506static void TC0080VCO_restore_scroll(void)
15151507{
15161508   TC0080VCO_flipscreen = TC0080VCO_scroll_ram[0] & 0x0c00;
r2375r2376
15261518}
15271519
15281520
1521static STATE_POSTLOAD( TC0080VCO_postload )
1522{
1523   TC0080VCO_set_layer_ptrs();
1524   TC0080VCO_dirty_chars();
1525   TC0080VCO_restore_scroll();
1526}
1527
15291528void TC0080VCO_vh_start(running_machine *machine, int gfxnum,int has_fg0,int bg_xoffs,int bg_yoffs,int bg_flip_yoffs)
15301529{
15311530   int gfx_index=0;
r2375r2376
15551554
15561555   state_save_register_global_pointer(TC0080VCO_ram, TC0080VCO_RAM_SIZE/2);
15571556   state_save_register_global(TC0080VCO_has_tx);
1558   state_save_register_func_postload(TC0080VCO_set_layer_ptrs);
15591557
15601558   /* Perform extra initialisations for text layer */
15611559   {
r2375r2376
15631561      TC0080VCO_char_dirty = auto_malloc(TC0080VCO_TOTAL_CHARS);
15641562
15651563      TC0080VCO_dirty_chars();
1566      state_save_register_func_postload(TC0080VCO_dirty_chars);
15671564
15681565       /* find first empty slot to decode gfx */
15691566      for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++)
r2375r2376
15841581      tilemap_set_transparent_pen( TC0080VCO_tilemap[2],0 );
15851582   }
15861583
1587   state_save_register_func_postload(TC0080VCO_dirty_tilemaps);   // unnecessary ?
1588   state_save_register_func_postload(TC0080VCO_restore_scroll);
1584   state_save_register_postload(machine, TC0080VCO_postload, NULL);
15891585
15901586   /* bg0 tilemap scrollable per pixel row */
15911587   tilemap_set_scroll_rows(TC0080VCO_tilemap[0],512);
r2375r2376
22782274}
22792275
22802276
2277static STATE_POSTLOAD( TC0100SCN_postload )
2278{
2279   int chip = (FPTR)param;
2280
2281   TC0100SCN_set_layer_ptrs(chip);
2282   TC0100SCN_dirty_chars(chip);
2283   TC0100SCN_restore_scroll(chip);
2284}
2285
22812286void TC0100SCN_vh_start(running_machine *machine, int chips,int gfxnum,int x_offset,int y_offset,int flip_xoffs,
22822287      int flip_yoffs,int flip_text_xoffs,int flip_text_yoffs,int multiscrn_xoffs)
22832288{
r2375r2376
23292334         state_save_register_item("TC0100SCN", i, TC0100SCN_dblwidth[i]);
23302335      }
23312336
2332      state_save_register_func_postload_int(TC0100SCN_set_layer_ptrs, i);
2333      state_save_register_func_postload_int(TC0100SCN_dirty_chars, i);
2334      state_save_register_func_postload_int(TC0100SCN_dirty_tilemaps, i);   // unnecessary ?
2335      state_save_register_func_postload_int(TC0100SCN_restore_scroll, i);
2337      state_save_register_postload(machine, TC0100SCN_postload, (void *)i);
23362338
23372339      /* find first empty slot to decode gfx */
23382340      for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++)
r2375r2376
31573159}
31583160
31593161
3162static STATE_POSTLOAD( TC0480SCP_postload )
3163{
3164   TC0480SCP_set_layer_ptrs();
3165   TC0480SCP_dirty_chars();
3166   TC0480SCP_restore_scroll();
3167}
3168
31603169void TC0480SCP_vh_start(running_machine *machine, int gfxnum,int pixels,int x_offset,int y_offset,int text_xoffs,
31613170            int text_yoffs,int flip_xoffs,int flip_yoffs,int col_base)
31623171{
r2375r2376
31943203      state_save_register_global_pointer(TC0480SCP_ram, TC0480SCP_RAM_SIZE/2);
31953204      state_save_register_global_array(TC0480SCP_ctrl);
31963205      state_save_register_global(TC0480SCP_dblwidth);
3197      state_save_register_func_postload(TC0480SCP_set_layer_ptrs);
3198      state_save_register_func_postload(TC0480SCP_dirty_chars);
3199      state_save_register_func_postload(TC0480SCP_dirty_tilemaps);   // unnecessary ?
3200      state_save_register_func_postload(TC0480SCP_restore_scroll);
3206      state_save_register_postload(machine, TC0480SCP_postload, NULL);
32013207
32023208      /* find first empty slot to decode gfx */
32033209      for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++)
r2375r2376
46894695#define TC0110PCR_RAM_SIZE 0x2000
46904696
46914697
4692static void TC0110PCR_restore_colors(int chip)
4698static STATE_POSTLOAD( TC0110PCR_restore_colors )
46934699{
4700   int chip = (FPTR)param;
46944701   int i,color,r=0,g=0,b=0;
46954702
46964703   for (i=0; i<(256*16); i++)
r2375r2376
47304737}
47314738
47324739
4733void TC0110PCR_vh_start(void)
4740void TC0110PCR_vh_start(running_machine *machine)
47344741{
47354742   TC0110PCR_ram[0] = auto_malloc(TC0110PCR_RAM_SIZE * sizeof(*TC0110PCR_ram[0]));
47364743
47374744   state_save_register_global_pointer(TC0110PCR_ram[0], TC0110PCR_RAM_SIZE);
4738   state_save_register_func_postload_int(TC0110PCR_restore_colors, 0);
4745   state_save_register_postload(machine, TC0110PCR_restore_colors, (void *)0);
47394746
47404747   TC0110PCR_type = 0;   /* default, xBBBBBGGGGGRRRRR */
47414748}
47424749
4743void TC0110PCR_1_vh_start(void)
4750void TC0110PCR_1_vh_start(running_machine *machine)
47444751{
47454752   TC0110PCR_ram[1] = auto_malloc(TC0110PCR_RAM_SIZE * sizeof(*TC0110PCR_ram[1]));
47464753
47474754   state_save_register_global_pointer(TC0110PCR_ram[1], TC0110PCR_RAM_SIZE);
4748   state_save_register_func_postload_int(TC0110PCR_restore_colors, 1);
4755   state_save_register_postload(machine, TC0110PCR_restore_colors, (void *)1);
47494756}
47504757
4751void TC0110PCR_2_vh_start(void)
4758void TC0110PCR_2_vh_start(running_machine *machine)
47524759{
47534760   TC0110PCR_ram[2] = auto_malloc(TC0110PCR_RAM_SIZE * sizeof(*TC0110PCR_ram[2]));
47544761
47554762   state_save_register_global_pointer(TC0110PCR_ram[2], TC0110PCR_RAM_SIZE);
4756   state_save_register_func_postload_int(TC0110PCR_restore_colors, 2);
4763   state_save_register_postload(machine, TC0110PCR_restore_colors, (void *)2);
47574764}
47584765
47594766READ16_HANDLER( TC0110PCR_word_r )
r2375r2376
49454952   switch (offset)
49464953   {
49474954      case 0x00:   /* IN00-07 (DSA) */
4948         return input_port_0_r(machine,0);
4955         return input_port_read_indexed(machine, 0);
49494956
49504957      case 0x01:   /* IN08-15 (DSB) */
4951         return input_port_1_r(machine,0);
4958         return input_port_read_indexed(machine, 1);
49524959
49534960      case 0x02:   /* IN16-23 (1P) */
4954         return input_port_2_r(machine,0);
4961         return input_port_read_indexed(machine, 2);
49554962
49564963      case 0x03:   /* IN24-31 (2P) */
4957         return input_port_3_r(machine,0);
4964         return input_port_read_indexed(machine, 3);
49584965
49594966      case 0x04:   /* coin counters and lockout */
49604967         return TC0220IOC_regs[4];
49614968
49624969      case 0x07:   /* INB0-7 (coin) */
4963         return input_port_4_r(machine,0);
4970         return input_port_read_indexed(machine, 4);
49644971
49654972      default:
49664973logerror("PC %06x: warning - read TC0220IOC address %02x\n",activecpu_get_pc(),offset);
r2375r2376
51065113   switch (offset)
51075114   {
51085115      case 0x00:   /* DSA */
5109         return input_port_0_r(machine,0);
5116         return input_port_read_indexed(machine, 0);
51105117
51115118      case 0x01:   /* DSB */
5112         return input_port_1_r(machine,0);
5119         return input_port_read_indexed(machine, 1);
51135120
51145121      case 0x02:   /* 1P */
5115         return input_port_2_r(machine,0);
5122         return input_port_read_indexed(machine, 2);
51165123
51175124      case 0x03:   /* 2P */
5118         return input_port_3_r(machine,0);
5125         return input_port_read_indexed(machine, 3);
51195126
51205127      case 0x04:   /* coin counters and lockout */
51215128         return TC0510NIO_regs[4];
51225129
51235130      case 0x07:   /* coin */
5124         return input_port_4_r(machine,0);
5131         return input_port_read_indexed(machine, 4);
51255132
51265133      default:
51275134logerror("PC %06x: warning - read TC0510NIO address %02x\n",activecpu_get_pc(),offset);
r2375r2376
51895196   switch (offset)
51905197   {
51915198      case 0x00:   /* DSA */
5192         return input_port_0_r(machine,0);
5199         return input_port_read_indexed(machine, 0);
51935200
51945201      case 0x01:   /* DSB */
5195         return input_port_1_r(machine,0);
5202         return input_port_read_indexed(machine, 1);
51965203
51975204      case 0x02:   /* 1P */
5198         return input_port_2_r(machine,0);
5205         return input_port_read_indexed(machine, 2);
51995206
52005207      case 0x03:   /* 2P */
5201         return input_port_3_r(machine,0);
5208         return input_port_read_indexed(machine, 3);
52025209
52035210      case 0x04:   /* coin counters and lockout */
52045211         return TC0640FIO_regs[4];
52055212
52065213      case 0x07:   /* coin */
5207         return input_port_4_r(machine,0);
5214         return input_port_read_indexed(machine, 4);
52085215
52095216      default:
52105217logerror("PC %06x: warning - read TC0640FIO address %02x\n",activecpu_get_pc(),offset);
src/mame/video/btime.c
r2375r2376
309309{
310310   btime_palette = (data >> 2) & 0x03;
311311
312   if (!(input_port_3_r(machine,0) & 0x40)) /* cocktail mode */
312   if (!(input_port_read_indexed(machine, 3) & 0x40)) /* cocktail mode */
313313   {
314314      flip_screen_set(data & 0x01);
315315   }
src/mame/video/taitoic.h
r2375r2376
1717
1818/***************************************************************************/
1919
20void PC080SN_vh_start(int chips,int gfxnum,int x_offset,int y_offset,int y_invert,int opaque,int dblwidth);
20void PC080SN_vh_start(running_machine *machine,int chips,int gfxnum,int x_offset,int y_offset,int y_invert,int opaque,int dblwidth);
2121READ16_HANDLER ( PC080SN_word_0_r );
2222WRITE16_HANDLER( PC080SN_word_0_w );
2323WRITE16_HANDLER( PC080SN_xscroll_word_0_w );
r2375r2376
172172
173173/***************************************************************************/
174174
175void TC0110PCR_vh_start(void);
176void TC0110PCR_1_vh_start(void);   /* 2nd chip */
177void TC0110PCR_2_vh_start(void);   /* 3rd chip */
175void TC0110PCR_vh_start(running_machine *machine);
176void TC0110PCR_1_vh_start(running_machine *machine);   /* 2nd chip */
177void TC0110PCR_2_vh_start(running_machine *machine);   /* 3rd chip */
178178READ16_HANDLER ( TC0110PCR_word_r );
179179READ16_HANDLER ( TC0110PCR_word_1_r );   /* 2nd chip */
180180READ16_HANDLER ( TC0110PCR_word_2_r );   /* 3rd chip */
src/mame/video/cps1.c
r2375r2376
11/***************************************************************************
22
3These are some of the CPS-B chip numbers:
3The CPS1 system is made of 3 boards: A, B and C. The first two games also exist
4a 2-board setups, where the C-board is integrated into the B-board.
45
5NAME                                        CPS-B #                     C-board PAL's  B-board PAL's
6Forgotten Worlds / Lost Worlds              CPS-B-01  DL-0411-10001     None           LWCH1 & LW10
7Ghouls 'n Ghosts                            CPS-B-01  DL-0411-10001     None           DM620, LW10
8Strider                                     CPS-B-01  DL-0411-10001     None           ST24N1 & LW10 or ST22B
9Dynasty Wars                                CPS-B-02  DL-0411-10002     ?              ?
10Willow                                      CPS-B-03  DL-0411-10003     None           WL24B & LW10
11UN Squadron / Area 88                       CPS-B-11  DL-0411-10004     None           AR24B & LW10
12Street Fighter II (ETC Rev G)               CPS-B-11  DL-0411-10004     None           STF29 & IOB1
13Final Fight (World / Japan)                 CPS-B-04  DL-0411-10005     None           S224B & LW10
14Final Fight (US)                            CPS-B-04* DL-0411-10001     None           S224B & LW10
15                                            *actually CPS-B-01, the original number was scratched out and "04" stamped over it
16Varth                                       CPS-B-04  DL-0411-10005     None           VA24B & LW10
171941                                        CPS-B-05  DL-0411-10006     ?              YI24B & ?
18Street Fighter II (US Rev D)                CPS-B-05  DL-0411-10006     C632           STF29 & IOB1
19Mercs (US)                                  CPS-B-12  DL-0411-10007     C628           0224B & IOB1
20Street Fighter II (Japan Rev C)             CPS-B-12  DL-0411-10007     C632           STF29 & IOB1
21Magic Sword (US)                            CPS-B-13  DL-0411-10008     None           MS24B & IOB1
22Street Fighter II (Japan)                   CPS-B-13  DL-0411-10008     C632           STF29 & IOB1
23Chiki Chiki Boys / Mega Twins               CPS-B-14  DL-0411-10009     ?              CK24B & IOB1
24Street Fighter II (US Rev I)                CPS-B-14  DL-0411-10009     C632           STF29 & IOB1
25Nemo                                        CPS-B-15  DL-0411-10010     ?              NM24B & ?
26Carrier Air Wing                            CPS-B-16  DL-0411-10011     None           CA24B & IOB1
27Street Fighter II                           CPS-B-17  DL-0411-10012     C632           STF29 & IOB1
28Three Wonders*                              CPS-B-21  DL-0921-10014     IOC1 & C632    RT24B & IOB1
29King of Dragons*                            CPS-B-21  DL-0921-10014     IOC1 & C632    KD29B & IOB1
30Captain Commando* (US)                      CPS-B-21  DL-0921-10014     IOC1 & C632    CC63B, CCPRG & IOB1
31Knights of the Round*                       CPS-B-21  DL-0921-10014     IOC1 & C632    KR63B, BPRG1 & IOB1
32Street Fighter II' Champion Edition         CPS-B-21  DL-0921-10014     IOC1 & C632    S9263B, BPRG1 & IOB1
33Capcom World 2*                             CPS-B-21  DL-0921-10014     IOC1           Q522B & IOB1
34Quiz and Dragons*                           CPS-B-21  DL-0921-10014     IOC1           QD22B & IOB1
35Warriors of Fate*                           CPS-B-21  DL-0921-10014     IOC1           TK263B, BPRG1 & IOB1
36Street Fighter II Turbo Hyper Fighting      CPS-B-21  DL-0921-10014     IOC1 & C632    S9263B, BPRG1 & IOB1
37Cadillacs and Dinosaurs*                    CPS-B-21  DL-0921-10014     IOC1           CD63B, BPRG1 & IOB1
38Punisher*                                   CPS-B-21  DL-0921-10014     IOC1           PS63B, BPRG1 & IOB1
39Saturday Night Slam Masters*                CPS-B-21  DL-0921-10014     IOC1           MB63B, BPRG1 & IOB1
40Muscle Bomber Duo*                          CPS-B-21  DL-0921-10014     ?              ?
41Pnickies                                    CPS-B-21? DL-0921-10014?    ?              ?
42Pang 3                                      CPS-B-21  DL-0921-10014     IOC1 & C632    CP1B1F, CP1B8K & CP1B9KA
43Megaman the Power Battle                    CPS-B-21  DL-0921-10014     IOC1 & C632    RCM63B, BPRG1 & IOB1
6There are several revisions of the A-board, but they are functionally equivalent
7and interchangeable except for 89626A-4 DASH used by sf2 which has a 12MHz xtal
8replacing the 10Hz one. Note that it's likely that from one point onwards Capcom
9simply switched to make only 89626A-4 DASH board, that is all games after a
10certain point should use the 12MHz xtal not just sf2.
11Verified: Quiz and Dragons (US) comes with the DASH version (original pcb with sticker).
4412
45Street Fighter Zero changer system (Japan)  CPS-B-21  DL-0921-10014     ?              ?
13Known A-board revisions:
1488617A-4
1588617A-5
1688617A-7
1788617A-7b
1889626A-4
1989626A-4 DASH
4620
21NAME                                        Year  B-board #      B-board PALs      C-board #         CPS-B #           C-board PALs
22------------------------------------------- ----  --------  ---------------------  ---------  -----------------------  -------------
23Forgotten Worlds / Lost Worlds              1988  88618B-2  LWCHR            LWIO  None       CPS-B-01  DL-0411-10001  None
24  (alt B-board revision)                          88621B-2  LW621            LWIO  ?
25Ghouls 'n Ghosts (World / US)               1988  88620B-2  DM620            LWIO  None       CPS-B-01  DL-0411-10001  None
26  (alt B-board revision - Japan)                  88622B-2  DM22A            LWIO  88622-C-1  CPS-B-01  DL-0411-10001  None
27Strider                                     1989  89624B-2  ST24M1           LWIO  88622-C-1  CPS-B-01  DL-0411-10001  None
28  (alt B-board version)                           89624B-3  ST24B2           LWIO
29  (alt B-board revision)                          ?         ST22B            ?
30Dynasty Wars                                1989  ?         ?                      ?          CPS-B-02  DL-0411-10002
31Willow                                      1989  89624B-3  WL24B            LWIO  88622-C-4  CPS-B-03  DL-0411-10003  None
32UN Squadron / Area 88                       1989  89624B-3  AR24B            LWIO  88622-C-4  CPS-B-11  DL-0411-10004  None
33  (alt B-board revision)                    1989  88622B-2  AR22B            LWIO
34Final Fight (first rev)                     1989  89624B-3  S224B            IOB1  88622-C-5  CPS-B-04  DL-0411-10005  None
35Final Fight (US 900112)                                                            ?          CPS-B-04@ DL-0411-10001  None
36Final Fight (US 900613)                                                            ?          CPS-B-05  DL-0411-10006
37Final Fight (Japan 900305)                                                         ?          CPS-B-02  DL-0411-10002
381941                                        1990  ?         YI24B            ?     88622-C-5  CPS-B-05  DL-0411-10006  ?
39Mercs (US)                                  1990  89624B-3  0224B            IOB1  90628-C-1  CPS-B-12  DL-0411-10007  C628
40Magic Sword (US)                            1990  89624B-3  MS24B            IOB1  88622-C-5  CPS-B-13  DL-0411-10008  None
41Chiki Chiki Boys / Mega Twins               1990  89624B-3  CK24B            IOB1  88622-C-5  CPS-B-14  DL-0411-10009  None
42Nemo                                        1990  89624B-3  NM24B            IOB1  88622-C-5  CPS-B-15  DL-0411-10010  None
43Carrier Air Wing / U.S. Navy                1990  89624B-3  CA24B            IOB1  88622-C-5  CPS-B-16  DL-0411-10011  None
44  (alt B-board revision)                          89625B-1  CA22B
45Street Fighter II (910214)                  1991  ?         STF29            IOB1  90632C-1   CPS-B-17  DL-0411-10012  C632
46Street Fighter II (US 910206)                                                                 CPS-B-17  DL-0411-10012
47Street Fighter II (US 910228)                                                                 CPS-B-18  ?
48Street Fighter II (Japan 910306)                                                              CPS-B-12  DL-0411-10007
49Street Fighter II (US 910318)                                                                 CPS-B-05  DL-0411-10006
50Street Fighter II (US 910411)                                                                 CPS-B-15  DL-0411-10010
51Street Fighter II (World 910522)                                                              CPS-B-11  DL-0411-10004
52Street Fighter II (US 910522)                                                                 CPS-B-14  DL-0411-10009
53Street Fighter II (US 911101)                                                                 CPS-B-17  DL-0411-10012
54Street Fighter II (Japan 911210)                                                              CPS-B-13  DL-0411-10008
55Three Wonders*                              1991  89624B-3  RT24B            IOB1  90630C-4   CPS-B-21  DL-0921-10014        IOC1
56  (alt B-board revision)                          89625B-1  RT22B            IOB1
57King of Dragons*                            1991  90629B-3  KD29B            IOB1  90631C-5   CPS-B-21  DL-0921-10014  C632  IOC1
58Captain Commando*                           1991  91635B-2  CC63B     CCPRG  IOB1  90631C-5   CPS-B-21  DL-0921-10014  C632  IOC1
59Knights of the Round*                       1991  91635B-2  KR63B     BPRG1  IOB1  90631C-5   CPS-B-21  DL-0921-10014  C632  IOC1
60Street Fighter II' Champion Edition         1992  91635B-2  S9263B    BPRG1  IOB1  92631C-6   CPS-B-21  DL-0921-10014  C632  IOC1
61Varth (World / US)                          1992  89624B-3  VA24B            IOB1  88622-C-5  CPS-B-04  DL-0411-10005  None
62Varth (Japan)*                              1992  ?         ?                      ?          CPS-B-21  DL-0921-10014  ?
63Capcom World 2*                             1992  ?         Q522B            IOB1  ?          CPS-B-21  DL-0921-10014        IOC1
64Quiz and Dragons (US)*                      1992  89625B-1  QD22B            IOB1  92641C-1   CPS-B-21  DL-0921-10014        IOC1
65Quiz and Dragons (Japan)*                   1994  ?         ?                IOB1  ?          CPS-B-21  DL-0921-10014        IOC1
66Warriors of Fate*                           1992  ?         TK263B    BPRG1  IOB1  92641C-1   CPS-B-21  DL-0921-10014        IOC1
67Street Fighter II Turbo Hyper Fighting      1992  91635B-2  S9263B    BPRG1  IOB1  92631C-6   CPS-B-21  DL-0921-10014  C632  IOC1
68Cadillacs and Dinosaurs*                    1993  ?         CD63B     BPRG1  IOB1  92641C-1   CPS-B-21  DL-0921-10014        IOC1
69Punisher*                                   1993  91635B-2  PS63B     BPRG1  IOB1  92641C-1   CPS-B-21  DL-0921-10014        IOC1
70Saturday Night Slam Masters*                1993  ?         MB63B     BPRG1  IOB1  92641C-1   CPS-B-21  DL-0921-10014        IOC1
71Muscle Bomber Duo*                          1993  ?         ?                      92641C-1   CPS-B-21  DL-0921-10014  ?
72Quiz Tonosama no Yabou 2                    1995  ?         ?                      ?          ?
73Pnickies                                    1994  ?         ?                      ?          CPS-B-21? DL-0921-10014? ?
74Pang 3                                      1995  94916-10  CP1B1F,CP1B8K,CP1B9KA  92631C-6   CPS-B-21  DL-0921-10014  C632  IOC1
75Megaman the Power Battle                    1995  ?         RCM63B   BPRG1   IOB1  ?          CPS-B-21  DL-0921-10014  C632  IOC1
76
77@actually CPS-B-01, the original number was scratched out and "04" stamped over it
4778*denotes Suicide Battery
4879
80The C628/C632 PALs on some C-boards probably handle the extra inputs (6 buttons/third player).
81
4982You can set the suicide CPS-B-21 chips to their default layer register and priority bit values
5083if you pull pins 45 and 46 high (floating the pins seems to work, too). The default is the same
5184values as Street Fighter 2 CE/Turbo.
r2375r2376
58910x04-0x05     Scroll2 (16x16) RAM base (/256)
59920x06-0x07     Scroll3 (32x32) RAM base (/256)
60930x08-0x09     rowscroll RAM base (/256)
610x0a-0x0b     Palette base (/256)
940x0a-0x0b     Palette base (/256) after this register is written to, the palette
95              is copied from gfxram to the dedicated ram. The palette control
96              register (see below) determines how the copy should happen.
97              Tests on a msword pcb show that the minimum alignment for the palette
98              is 0x400 bytes. The hardware seems to ignore bit 1, while when bit 0
99              is set the palette doesn't seem to be copied. However, some games set
100              bit 0 during boot (ghouls, strider, 1941) so it still isn't clear
101              what bit 0 should actually do.
621020x0c-0x0d     Scroll 1 X
631030x0e-0x0f     Scroll 1 Y
641040x10-0x11     Scroll 2 X
r2375r2376
701100x1c-0x1d     Starfield 2 X
711110x1e-0x1f     Starfield 2 Y
721120x20-0x21     start offset for the rowscroll matrix
730x22-0x23     unknown but widely used - usually 0x0e. bit 0 enables rowscroll
74              on layer 2. bit 15 is flip screen.
1130x22-0x23     video control. Usually 0x0e.
114              bit 0 enables rowscroll on layer 2.
115              bit 15 is flip screen.
116              ghouls sets bit 14. Purpose unknown.
117              1941 uses bits 1-3 by setting them to 0 on screen transitions,
118              however it also uses the normal layer control register so there
119              doesn't seem to be an obvious effect.
75120
121              Games known to use rowscroll:
122              SF2
123              Mega Twins (underwater, cave)
124              Carrier Air Wing (hazy background at beginning of mission 8, put 07 at ff8501 to jump there)
125              Magic Sword (fire on floor 3; screen distort after continue)
126              Varth (title screen)
127              Captain Commando (end game sequence)
76128
129              Tests done on msword at the beginning of gameplay (many thanks to Corrado Tomaselli for these):
130              3e  is the default value set by the game (not 0e like most games)
131              3c  the last two rows of scroll1 are repeated on the whole screen
132              3a  scroll2 is disabled
133              36  scroll3 is disabled
134              2e  no visible differences
135              1e  no visible differences
136              one might suspect that bits 4&5 should disable the star layers, but
137              Strider sets this register to 0x0e so that's not possible.
138
139              TODO:
140              the scroll2/scroll3 disable bits are supported by the emulation,
141              while the scroll1 weird effect is not (it doesn't seem to make a
142              difference on any game).
143
144
77145Some registers move from game to game.. following example strider
781460x66-0x67   Layer control register
79147            bits 14-15 seem to be unused
80148                ghouls sets bits 15 in service mode when you press button 2 in
81                the input test
149                the input test, with no apparent effect on the pcb.
150                qtono2 sets them both at the game over screen.
82151            bits 6-13 (4 groups of 2 bits) select layer draw order
83152            bits 1-5 enable the three tilemap layers and the two starfield
84153                layers (the bit order changes from game to game).
r2375r2376
86155            bit 0 could be rowscroll related. It is set by captain commando,
87156                varth, mtwins, mssword, cawing while rowscroll is active. However
88157                kodj and sf2 do NOT set this bit while they are using rowscroll.
89                Games known to use row scrolling:
90                SF2
91                Mega Twins (underwater, cave)
92                Carrier Air Wing (hazy background at beginning of mission 8, put 07 at ff8501 to jump there)
93                Magic Sword (fire on floor 3; screen distort after continue)
94                Varth (title screen)
95                Captain Commando (end game sequence)
158                Tests on the msword pcb show that even if this bit is not set,
159                rowscroll still works. Therefore, the purpose of this bit is unclear.
961600x68-0x69   Priority mask \   Tiles in the layer just below sprites can have
971610x6a-0x6b   Priority mask |   four priority levels, each one associated with one
981620x6c-0x6d   Priority mask |   of these masks. The masks indicate pens in the tile
991630x6e-0x6f   Priority mask /   that have priority over sprites.
1000x70-0x71   Control register (usually 0x003f). The details of how this register
101            works are unknown, but it definitely affects the palette, and games
102            always set it together with the palette base register.
103            Experiments on the real board show that values different from 0x3f in
104            the low 6 bits cause wrong colors. The other bits seem to be unused.
105            There is one CPS2 game (Slammasters II) setting this to 0x2f: the
106            purpose is unknown.
107            The only other places where this register seems to be set to a value
108            different from 0x3f is during startup tests. Examples:
1640x70-0x71   Palette control register. This indicates which palette
165            pages to copy when the palette base register is written to.
166            There is one CPS2 game (Slammasters II) setting this to 0x2f; all the other
167            games normally set it to 0x3f, though in some cases different values are
168            used during boot:
109169            ghouls  0x02 (and palette base is set to 9105; palette base is 9100 normally)
110170            strider 0x02 (and palette base is set to 9145; palette base is 9140 normally)
111171            1941    0x02 (and palette base is set to 9145; palette base is 9140 normally)
r2375r2376
113173            kod     0x0f
114174            mtwins  0x0f
115175
176            bit 0: copy page 0 (sprites)
177            bit 1: copy page 1 (scroll1)
178            bit 2: copy page 2 (scroll2)
179            bit 3: copy page 3 (scroll3)
180            bit 4: copy page 4 (stars1)
181            bit 5: copy page 5 (stars2)
182
183            An important quirk is that if bit 0 is not set (sprite page is not copied)
184            page 0 in gfxram is not skipped but instead is copied to page 1; that is,
185            all pages are moved down by one. For the other pages, if the bit is not
186            set the gfxram page is skipped.
187
188            bits 0-3 have been verified with reasonable confidence on a msword pcb,
189            while bits 4-5 are only supposed.
190
116191Fixed registers
1171920x80-0x81     Sound command
1181930x88-0x89     Sound fade
119194
195
196A special note has to be made about tile/sprite codes. Even if all graphics are
197stored together in the same ROMs, the hardware knows which part of the ROM space
198is 8x8 tiles, 16x16 tiles, 16x16 spites, 32x32 tiles, and all games tested only
199draw tiles if their code falls in the valid range. If a tile is out of range, it
200is replaced by transparent pixels.
201Ideally, this shouldn't be important as far as the emulation is concerned, since
202games should only request tiles from valid ranges. In practice, many games contain
203bugs which make them try to display out of range tiles. The masking applied by
204the hardware therefore needs to be emulated properly, otherwise glitches appear.
205
206There are various versions of the ROM board (B-board), so the implementation
207details may vary, but in general the tile ranges are controlled by a PAL found
208on the B-board (see the table at the top of this file).
209
210The A-board passes 23 bits of address to the B-board when requesting gfx ROM data.
211The B-board selects 64 bits of data, that is 16 4bpp pixels, and returns half of
212them depending on a signal from the C board.
213The 23 address bits are laid out this way (note that the top 3 bits select the
214tile type; the purpose of the top bit is unknown):
215
216sprite  000ccccccccccccccccyyyy
217scroll1 001?ccccccccccccccccyyy
218scroll2 010ccccccccccccccccyyyy
219scroll3 011ccccccccccccccyyyyyx
220stars   100000000sxxxxxyyyyyyyy (to be verified)
221
222where
223c is the tile code
224y is the y position in the tile
225x is the x position in the tile (only applicable to 32x32 tiles)
226
227E.g. on the 89624B-3 board, used by cawing and others, the top 13 bits of the
228address are passed to the 16L8B PAL @1A, which outputs the /OE signal for roms
2291,3,5,7 (together), 2,4,6,8 (together), 10,12,14,16,20,22,24,26 (together) or
23011,13,15,17,21,23,25,27 (together).
231Note that in cawing only sockets 1,3,5,7 are populated, so effectively there is
232only one bank.
233
234The above would mean that
2351) 8x8 and 16x16 tiles have a 16-bit tile code, while
236   32x32 tiles have a 14-bit tile code
2372) which ROM bank to use is determined by
238   bits 15-7 of a 8x8 tile code,
239   bits 15-6 of a 16x16 tile code,
240   bits 13-4 of a 32x32 tile code
241
242If the PAL decides that the tile code is out of range and doesn't output any /OE
243signal, no ROM is read and pullup resistors force the result to all 1 (which
244means a transparent tile).
245
246Note that there are several known cases (nemo, cawing, 3wonders, varth, etc.) where
24716x16 tiles are used for BOTH sprites and scroll2.
248
249Ideally, the PALs should be dumped and loaded like the ROMs, and the mapping should
250be derived from the loaded PALs at run time.
251In practice, this is unlikely to happen, so we'll have to tolerate using hardcoded
252maps for every game.
253
254
120255Known Bug List
121256==============
122257CPS2:
r2375r2376
131266* Sprites are currently lagged by one frame to keep sync with backgrounds. This causes
132267  sprites to stay on screen one frame longer (visable in VSAV attract mode).
133268
269* The boot screen of some CPS2 games has a blue background instead of black,
270  however that might be the correct behaviour.
271
134272Marvel Vs. Capcom
135273* Sometimes currupt gfx are displayed on the 32x32 layer as the screen flashes at the
136274  start of super combo moves. The problem seems to be due to tiles being fetched before
r2375r2376
138276
139277CPS1:
140278SF2
141* Missing chain in the foreground in Ken's level, and sign in Cun Li's level.
279* Missing chain in the foreground in Ken's level, and sign in Chun Li's level.
142280  Those graphics are in the backmost layer.
143281
144UN Squadron
145* DOT TEST in service mode shows garbage chars
146
147Magic Sword.
148* during attract mode, characters are shown with a black background. There is
149a background, but the layers are disabled. I think this IS the correct
150behaviour.
151
152282King of Dragons (World).
153283* Distortion effect missing on character description screen during attract
154mode. The game rapidly toggles on and off the layer enable bit. Again, I
155think this IS the correct behaviour. The Japanese version does the
284mode. The game rapidly toggles on and off the layer enable bit.
285I think this IS the correct behaviour. The Japanese version does the
156286distortion as expected.
157287
1582883wonders
159* one bad tile at the end of level 1
160289* writes to output ports 42, 44, 46.
161290
162291qad
163292* layer enable mask incomplete
164293
165wof
166* In round 8, when the player goes over a bridge, there is a problem with
167some sprites. When an enemy falls to the floor near the edge of the bridge,
168parts of it become visible under the bridge.
169294
170varth
171* the background color during startup is brown, while it should most likely be
172  black. This is caused by the background color palette entry (0xbff), however
173  that entry is definitely correct and used by other games (3wonders, mtwins)
174  to make the background different from black.
175  The boot screen of some CPS2 also has a blue background instead of black,
176  however that might be the correct behaviour.
177
178
179295Unknown issues
180296==============
181297
r2375r2376
191307
192308#define VERBOSE 0
193309
194#define CPS1_DUMP_VIDEO 0
195
196310/********************************************************************
197311
198312            Configuration table:
r2375r2376
200314********************************************************************/
201315
202316/* Game specific data */
317
318#define GFXTYPE_SPRITES   (1<<0)
319#define GFXTYPE_SCROLL1   (1<<1)
320#define GFXTYPE_SCROLL2   (1<<2)
321#define GFXTYPE_SCROLL3   (1<<3)
322#define GFXTYPE_STARS     (1<<4)
323
324
325struct gfx_range
326{
327   // start and end are as passed by the game (shift adjusted to be all
328   // in the same scale a 8x8 tiles): they don't necessarily match the
329   // position in ROM.
330   int type;
331   int start;
332   int end;
333   int bank;
334};
335
203336struct CPS1config
204337{
205338   const char *name;             /* game driver name */
r2375r2376
221354
222355   int layer_control;
223356   int priority[4];
224   int control_reg;  /* Control register? seems to be always 0x3f */
357   int palette_control;  /* Control register? seems to be always 0x3f */
225358
226359   /* ideally, the layer enable masks should consist of only one bit, */
227360   /* but in many cases it is unknown which bit is which. */
228361   int layer_enable_mask[5];
229362
363   int bank_size;
364   const struct gfx_range *bank_mapper;
365
230366   int bank_scroll1;
231367   int bank_scroll2;
232368   int bank_scroll3;
r2375r2376
237373   const int start_scroll3;
238374   const int end_scroll3;
239375
240   int kludge;  /* Ghouls n Ghosts sprite kludge */
376   int bootleg_kludge;
241377};
242378
243379static const struct CPS1config *cps1_game_config;
244380
245/*                 CPSB ID    multiply protection  ctrl     priority masks   unknwn     layer enable masks  */
381
382/*                 CPSB ID    multiply protection  ctrl     priority masks   palctrl    layer enable masks  */
246383#define CPS_B_01 0x00,0x0000, 0,0,0,0, /* n/a */   0x66,{0x68,0x6a,0x6c,0x6e},0x70, {0x02,0x04,0x08,0x30,0x30}
247384#define CPS_B_02 0x60,0x0002, 0,0,0,0, /* n/a */   0x6c,{0x6a,0x68,0x66,0x64},0x62, {0x02,0x04,0x08,0x00,0x00}
248385#define CPS_B_03 0x00,0x0000, 0,0,0,0, /* n/a */   0x70,{0x6e,0x6c,0x6a,0x68},0x66, {0x20,0x10,0x08,0x00,0x00}
r2375r2376
272409#define HACK_B_1 0x00,0x0000, 0x00,0x00,0x00,0x00, 0x54,{0x52,0x50,0x4e,0x4c},0x5c, {0xff,0xff,0xff,0x00,0x00}
273410
274411
412static const struct gfx_range mapper_LWCHR[] =
413{
414   // verified from PAL dump (PAL16P8B @ 3A):
415   // bank size = 8000
416   // bank 0 = pin 16
417   // bank 1 = pin 19
418   // pin 12 and pin 14 are always enabled (except for stars)
419   // note that allowed codes go up to 0x1ffff but physical ROM is half that size
420
421   /* type            start    end      bank */
422   { GFXTYPE_STARS,   0x00000, 0x1ffff, 0 },
423   { GFXTYPE_SCROLL2, 0x00000, 0x1ffff, 0 },
424   { GFXTYPE_SCROLL3, 0x00000, 0x1ffff, 0 },
425
426   { GFXTYPE_SPRITES, 0x00000, 0x07fff, 1 },
427   { GFXTYPE_SCROLL1, 0x00000, 0x1ffff, 1 },
428   { 0 }
429};
430
431static const struct gfx_range mapper_DM620[] =
432{
433   /* type            start   end     bank */
434   { GFXTYPE_SPRITES, 0x0000, 0x1fff, 0 },
435   { GFXTYPE_SCROLL1, 0x2000, 0x3fff, 0 },
436   { GFXTYPE_SCROLL2, 0x4000, 0x7fff, 0 },
437
438   { GFXTYPE_SCROLL3, 0x8000, 0x9fff, 1 },
439   { GFXTYPE_SPRITES, 0x2000, 0x7fff, 1 },   // a000-ffff physical
440   { 0 }
441};
442
443static const struct gfx_range mapper_ST24M1[] =
444{
445   // verified from PAL dump:
446   // bank size = 4000
447   // bank 0 = pin 19
448   // bank 1 = pin 16
449   // bank 2 = pin 14
450   // bank 3 = pin 12
451
452   /* type            start    end      bank */
453   { GFXTYPE_STARS,   0x00000, 0x1ffff, 0 },
454   { GFXTYPE_SPRITES, 0x00000, 0x03fff, 0 },
455
456   { GFXTYPE_SPRITES, 0x04000, 0x04fff, 1 },
457   { GFXTYPE_SCROLL2, 0x04000, 0x07fff, 1 },
458
459   { GFXTYPE_SCROLL3, 0x00000, 0x03fff, 2 },
460
461   { GFXTYPE_SCROLL3, 0x04000, 0x07fff, 3 },
462   { GFXTYPE_SCROLL1, 0x07000, 0x07fff, 3 },
463   { 0 }
464};
465
466static const struct gfx_range mapper_dynwar[] =   // unknown PAL
467{
468   /* type            start  end      bank */
469   { GFXTYPE_SPRITES, 0x0000, 0x5fff, 0 },
470   { GFXTYPE_SCROLL1, 0x6000, 0x7fff, 0 },
471
472   { GFXTYPE_SCROLL3, 0x0000, 0x3fff, 1 },   // 8000-bfff physical
473   { GFXTYPE_SCROLL2, 0x4000, 0x7fff, 1 },   // c000-ffff physical
474   { 0 }
475};
476
477static const struct gfx_range mapper_WL24B[] =
478{
479   // verified from PAL dump:
480   // bank size = 8000
481   // bank 0 = pin 16
482   // bank 1 = pin 12
483   // pin 14 and pin 19 are never enabled
484
485   /* type            start  end      bank */
486   { GFXTYPE_SPRITES, 0x0000, 0x4fff, 0 },
487   { GFXTYPE_SCROLL3, 0x5000, 0x6fff, 0 },
488   { GFXTYPE_SCROLL1, 0x7000, 0x7fff, 0 },
489
490   { GFXTYPE_SCROLL2, 0x0000, 0x3fff, 1 },
491   { 0 }
492};
493
494static const struct gfx_range mapper_S224B[] =
495{
496   // verified from PAL dump:
497   // bank size = 8000
498   // bank 0 = pin 16
499   // pin 12 & pin 14 give an alternate half-size mapping which would allow to
500   // populate the 8-bit ROM sockets instead of the 16-bit ones:
501   // pin 12
502   // 0 00000 - 03fff
503   // pin 14
504   // 0 04000 - 043ff
505   // 1 04400 - 04bff
506   // 2 06000 - 07fff
507   // 3 04c00 - 05fff
508   // pin 19 is never enabled
509
510   /* type            start  end      bank */
511   { GFXTYPE_SPRITES, 0x0000, 0x43ff, 0 },
512   { GFXTYPE_SCROLL1, 0x4400, 0x4bff, 0 },
513   { GFXTYPE_SCROLL3, 0x4c00, 0x5fff, 0 },
514   { GFXTYPE_SCROLL2, 0x6000, 0x7fff, 0 },
515   { 0 }
516};
517
518static const struct gfx_range mapper_YI24B[] =
519{
520   // verified from JED:
521   // bank size = 8000
522   // bank 0 = pin 16
523   // pin 12 & pin 14 give an alternate half-size mapping which would allow to
524   // populate the 8-bit ROM sockets instead of the 16-bit ones:
525   // pin 12
526   // 0 0000-1fff
527   // 3 2000-3fff
528   // pin 14
529   // 1 4000-47ff
530   // 2 4800-7fff
531   // pin 19 is never enabled
532
533   /* type            start   end     bank */
534   { GFXTYPE_SPRITES, 0x0000, 0x1fff, 0 },
535   { GFXTYPE_SCROLL3, 0x2000, 0x3fff, 0 },
536   { GFXTYPE_SCROLL1, 0x4000, 0x47ff, 0 },
537   { GFXTYPE_SCROLL2, 0x4800, 0x7fff, 0 },
538   { 0 }
539};
540
541static const struct gfx_range mapper_AR24B[] =
542{
543   // verified from JED:
544   // bank size = 8000
545   // bank 0 = pin 16
546   // pin 12 & pin 14 give an alternate half-size mapping which would allow to
547   // populate the 8-bit ROM sockets instead of the 16-bit ones:
548   // pin 12
549   // 0 0000-2fff
550   // 1 3000-3fff
551   // pin 14
552   // 2 4000-5fff
553   // 3 6000-7fff
554   // pin 19 is never enabled
555
556   /* type            start   end     bank */
557   { GFXTYPE_SPRITES, 0x0000, 0x2fff, 0 },
558   { GFXTYPE_SCROLL1, 0x3000, 0x3fff, 0 },
559   { GFXTYPE_SCROLL2, 0x4000, 0x5fff, 0 },
560   { GFXTYPE_SCROLL3, 0x6000, 0x7fff, 0 },
561   { 0 }
562};
563
564static const struct gfx_range mapper_0224B[] =
565{
566   // verified from PAL dump:
567   // bank size = 8000
568   // bank 0 = pin 19
569   // bank 1 = pin 12
570   // pin 16 & pin 14 appear to be an alternate half-size mapping for bank 0
571   // but scroll1 is missing:
572   // pin 16
573   // 2 00c00 - 03bff
574   // 3 03c00 - 03fff
575   // pin 14
576   // 3 04000 - 04bff
577   // 0 04c00 - 07fff
578
579   /* type            start   end     bank */
580   { GFXTYPE_SCROLL1, 0x0000, 0x0bff, 0 },
581   { GFXTYPE_SCROLL2, 0x0c00, 0x3bff, 0 },
582   { GFXTYPE_SCROLL3, 0x3c00, 0x4bff, 0 },
583   { GFXTYPE_SPRITES, 0x4c00, 0x7fff, 0 },
584
585   { GFXTYPE_SPRITES, 0x8000, 0xa7ff, 1 },
586   { GFXTYPE_SCROLL2, 0xa800, 0xb7ff, 1 },
587   { GFXTYPE_SCROLL3, 0xb800, 0xbfff, 1 },
588   { 0 }
589};
590
591static const struct gfx_range mapper_MS24B[] =
592{
593   // verified from PAL dump:
594   // bank size = 8000
595   // bank 0 = pin 16 or pin 14 (for 16-bit or 8-bit ROMs)
596   // pin 12 is enabled only for sprites, purpose unknown
597   // 0 0000-3fff
598   // pin 19 is never enabled
599
600   /* type            start   end     bank */
601   { GFXTYPE_SPRITES, 0x0000, 0x3fff, 0 },
602   { GFXTYPE_SCROLL1, 0x4000, 0x4fff, 0 },
603   { GFXTYPE_SCROLL2, 0x5000, 0x6fff, 0 },
604   { GFXTYPE_SCROLL3, 0x7000, 0x7fff, 0 },
605   { 0 }
606};
607
608static const struct gfx_range mapper_CK24B[] =
609{
610   /* type            start   end     bank */
611   { GFXTYPE_SPRITES, 0x0000, 0x2fff, 0 },
612   { GFXTYPE_SCROLL1, 0x3000, 0x3fff, 0 },
613   { GFXTYPE_SCROLL2, 0x4000, 0x6fff, 0 },
614   { GFXTYPE_SCROLL3, 0x7000, 0x7fff, 0 },
615   { 0 }
616};
617
618static const struct gfx_range mapper_NM24B[] =
619{
620   // verified from PAL dump:
621   // bank size = 8000
622   // bank 0 = pin 16
623   // pin 12 & pin 14 give an alternate half-size mapping which would allow to
624   // populate the 8-bit ROM sockets instead of the 16-bit ones:
625   // pin 12
626   // 0 00000 - 03fff
627   // 2 00000 - 03fff
628   // pin 14
629   // 1 04000 - 047ff
630   // 0 04800 - 067ff
631   // 2 04800 - 067ff
632   // 3 06800 - 07fff
633   // pin 19 is never enabled
634
635   /* type            start   end     bank */
636   { GFXTYPE_SPRITES, 0x0000, 0x3fff, 0 },
637   { GFXTYPE_SCROLL2, 0x0000, 0x3fff, 0 },
638   { GFXTYPE_SCROLL1, 0x4000, 0x47ff, 0 },
639   { GFXTYPE_SPRITES, 0x4800, 0x67ff, 0 },
640   { GFXTYPE_SCROLL2, 0x4800, 0x67ff, 0 },
641   { GFXTYPE_SCROLL3, 0x6800, 0x7fff, 0 },
642   { 0 }
643};
644
645static const struct gfx_range mapper_CA24B[] =
646{
647   // verified from PAL dump:
648   // bank size = 8000
649   // bank 0 = pin 16
650   // pin 12 & pin 14 give an alternate half-size mapping which would allow to
651   // populate the 8-bit ROM sockets instead of the 16-bit ones:
652   // pin 12
653   // 0 0000-2fff
654   // 2 0000-2fff
655   // 3 3000-3fff
656   // pin 14
657   // 3 4000-4fff
658   // 1 5000-57ff
659   // 0 5800-7fff
660   // 2 5800-7fff
661   // pin 19 is never enabled (actually it is always enabled when PAL pin 1 is 1, purpose unknown)
662
663   /* type            start   end     bank */
664   { GFXTYPE_SPRITES, 0x0000, 0x2fff, 0 },
665   { GFXTYPE_SCROLL2, 0x0000, 0x2fff, 0 },
666   { GFXTYPE_SCROLL3, 0x3000, 0x4fff, 0 },
667   { GFXTYPE_SCROLL1, 0x5000, 0x57ff, 0 },
668   { GFXTYPE_SPRITES, 0x5800, 0x7fff, 0 },
669   { GFXTYPE_SCROLL2, 0x5800, 0x7fff, 0 },
670   { 0 }
671};
672
673static const struct gfx_range mapper_STF29[] =
674{
675   /* type            start    end      bank */
676   { GFXTYPE_SPRITES, 0x00000, 0x07fff, 0 },
677
678   { GFXTYPE_SPRITES, 0x08000, 0x0ffff, 1 },
679
680   { GFXTYPE_SPRITES, 0x10000, 0x11fff, 2 },
681   { GFXTYPE_SCROLL3, 0x02000, 0x03fff, 2 },   // 12000-13fff physical
682   { GFXTYPE_SCROLL1, 0x04000, 0x04fff, 2 },   // 14000-14fff physical
683   { GFXTYPE_SCROLL2, 0x05000, 0x07fff, 2 },   // 15000-17fff physical
684   { 0 }
685};
686
687static const struct gfx_range mapper_RT24B[] =
688{
689   /* type                              start   end     bank */
690   { GFXTYPE_SPRITES,                   0x0000, 0x53ff, 0 },
691   { GFXTYPE_SCROLL1,                   0x5400, 0x6fff, 0 },
692   { GFXTYPE_SCROLL3,                   0x7000, 0x7fff, 0 },
693
694   { GFXTYPE_SCROLL3,                   0x0000, 0x27ff, 1 },   // 8000-a7ff physical
695   { GFXTYPE_SCROLL2,                   0x2800, 0x53ff, 1 },   // a800-d3ff physical
696   { GFXTYPE_SPRITES | GFXTYPE_SCROLL2, 0x5400, 0x7fff, 1 },   // d400-ffff physical
697   { 0 }
698};
699
700static const struct gfx_range mapper_KD29B[] =
701{
702   /* type            start   end     bank */
703   { GFXTYPE_SPRITES, 0x0000, 0x7fff, 0 },
704
705   { GFXTYPE_SPRITES, 0x8000, 0x8fff, 1 },
706   { GFXTYPE_SCROLL2, 0x9000, 0xbfff, 1 },
707   { GFXTYPE_SCROLL1, 0xc000, 0xd7ff, 1 },
708   { GFXTYPE_SCROLL3, 0xd800, 0xffff, 1 },
709   { 0 }
710};
711
712static const struct gfx_range mapper_CC63B[] =
713{
714   /* type            start   end     bank */
715   { GFXTYPE_SPRITES, 0x0000, 0x7fff, 0 },
716
717   { GFXTYPE_SPRITES, 0x8000, 0x9fff, 1 },
718   { GFXTYPE_SCROLL3, 0xa000, 0xbfff, 1 },
719   { GFXTYPE_SCROLL1, 0xc000, 0xcfff, 1 },
720   { GFXTYPE_SCROLL2, 0xd000, 0xffff, 1 },
721   { 0 }
722};
723
724static const struct gfx_range mapper_KR63B[] =
725{
726   /* type            start   end     bank */
727   { GFXTYPE_SPRITES, 0x0000, 0x7fff, 0 },
728
729   { GFXTYPE_SPRITES, 0x8000, 0x87ff, 1 },
730   { GFXTYPE_SCROLL1, 0x8800, 0x97ff, 1 },
731   { GFXTYPE_SCROLL2, 0x9800, 0xcfff, 1 },
732   { GFXTYPE_SCROLL3, 0xd000, 0xffff, 1 },
733   { 0 }
734};
735
736static const struct gfx_range mapper_S9263B[] =
737{
738   /* type            start    end      bank */
739   { GFXTYPE_SPRITES, 0x00000, 0x07fff, 0 },
740
741   { GFXTYPE_SPRITES, 0x08000, 0x0ffff, 1 },
742
743   { GFXTYPE_SPRITES, 0x10000, 0x11fff, 2 },
744   { GFXTYPE_SCROLL3, 0x02000, 0x03fff, 2 },   // 12000-13fff physical
745   { GFXTYPE_SCROLL1, 0x04000, 0x04fff, 2 },   // 14000-14fff physical
746   { GFXTYPE_SCROLL2, 0x05000, 0x07fff, 2 },   // 15000-17fff physical
747   { 0 }
748};
749
750static const struct gfx_range mapper_VA24B[] =
751{
752   /* type                              start   end     bank */
753   { GFXTYPE_SPRITES | GFXTYPE_SCROLL2, 0x0000, 0x57ff, 0 },
754   { GFXTYPE_SCROLL1,                   0x5800, 0x5fff, 0 },
755   { GFXTYPE_SCROLL3,                   0x6000, 0x7fff, 0 },
756   { 0 }
757};
758
759static const struct gfx_range mapper_Q522B[] =
760{
761   /* type                              start   end     bank */
762   { GFXTYPE_SPRITES | GFXTYPE_SCROLL2, 0x0000, 0x6fff, 0 },
763   { GFXTYPE_SCROLL3,                   0x7000, 0x77ff, 0 },
764   { GFXTYPE_SCROLL1,                   0x7800, 0x7fff, 0 },
765   { 0 }
766};
767
768static const struct gfx_range mapper_TK263B[] =
769{
770   /* type                              start   end     bank */
771   { GFXTYPE_SPRITES,                   0x0000, 0x7fff, 0 },
772
773   { GFXTYPE_SPRITES | GFXTYPE_SCROLL2, 0x8000, 0xcfff, 1 },
774   { GFXTYPE_SCROLL1,                   0xd000, 0xdfff, 1 },
775   { GFXTYPE_SCROLL3,                   0xe000, 0xffff, 1 },
776   { 0 }
777};
778
779static const struct gfx_range mapper_CD63B[] =
780{
781   /* type                              start   end     bank */
782   { GFXTYPE_SCROLL1,                   0x0000, 0x0fff, 0 },
783   { GFXTYPE_SPRITES,                   0x1000, 0x7fff, 0 },
784
785   { GFXTYPE_SPRITES | GFXTYPE_SCROLL2, 0x8000, 0xdfff, 1 },
786   { GFXTYPE_SCROLL3,                   0xe000, 0xffff, 1 },
787   { 0 }
788};
789
790static const struct gfx_range mapper_PS63B[] =
791{
792   /* type            start   end     bank */
793   { GFXTYPE_SCROLL1, 0x0000, 0x0fff, 0 },
794   { GFXTYPE_SPRITES, 0x1000, 0x7fff, 0 },
795
796   { GFXTYPE_SPRITES, 0x8000, 0xa7ff, 1 },
797   { GFXTYPE_SCROLL2, 0xa800, 0xdbff, 1 },
798   { GFXTYPE_SCROLL3, 0xdc00, 0xffff, 1 },
799   { 0 }
800};
801
802static const struct gfx_range mapper_MB63B[] =
803{
804   /* type                              start    end      bank */
805   { GFXTYPE_SCROLL1,                   0x00000, 0x00fff, 0 },
806   { GFXTYPE_SPRITES | GFXTYPE_SCROLL2, 0x01000, 0x07fff, 0 },
807
808   { GFXTYPE_SPRITES | GFXTYPE_SCROLL2, 0x08000, 0x0ffff, 1 },
809
810   { GFXTYPE_SPRITES | GFXTYPE_SCROLL2, 0x10000, 0x167ff, 2 },
811   { GFXTYPE_SCROLL3,                   0x16800, 0x17fff, 2 },
812   { 0 }
813};
814
815static const struct gfx_range mapper_QD22B[] =
816{
817   /* type                              start   end     bank */
818   { GFXTYPE_SCROLL1,                   0x0000, 0x07ff, 0 },
819   { GFXTYPE_SPRITES | GFXTYPE_SCROLL2, 0x0800, 0x27ff, 0 },
820   { GFXTYPE_SCROLL3,                   0x2800, 0x3fff, 0 },
821   { 0 }
822};
823
824static const struct gfx_range mapper_qadj[] =
825{
826   /* type                              start   end     bank */
827   { GFXTYPE_SCROLL1,                   0x0000, 0x07ff, 0 },
828   { GFXTYPE_SCROLL3,                   0x0800, 0x1fff, 0 },
829   { GFXTYPE_SPRITES | GFXTYPE_SCROLL2, 0x2000, 0x7fff, 0 },
830   { 0 }
831};
832
833static const struct gfx_range mapper_qtono2[] =
834{
835   /* type                              start   end     bank */
836   { GFXTYPE_SCROLL1,                   0x0000, 0x0fff, 0 },
837   { GFXTYPE_SCROLL3,                   0x1000, 0x3fff, 0 },
838   { GFXTYPE_SPRITES | GFXTYPE_SCROLL2, 0x4000, 0x7fff, 0 },
839
840   { GFXTYPE_SPRITES | GFXTYPE_SCROLL2, 0x8000, 0xffff, 1 },
841   { 0 }
842};
843
844static const struct gfx_range mapper_RCM63B[] =
845{
846   /* type                              start    end      bank */
847   { GFXTYPE_SCROLL1,                   0x00000, 0x017ff, 0 },
848   { GFXTYPE_SPRITES,                   0x01800, 0x07fff, 0 },
849
850   { GFXTYPE_SPRITES,                   0x08000, 0x0ffff, 1 },
851
852   { GFXTYPE_SPRITES | GFXTYPE_SCROLL2, 0x10000, 0x17fff, 2 },
853
854   { GFXTYPE_SCROLL2,                   0x18000, 0x19fff, 3 },
855   { GFXTYPE_SCROLL3,                   0x1a000, 0x1ffff, 3 },
856   { 0 }
857};
858
859static const struct gfx_range mapper_pnickj[] =
860{
861   /* type                              start   end     bank */
862   { GFXTYPE_SCROLL1,                   0x0000, 0x0fff, 0 },
863   { GFXTYPE_SPRITES | GFXTYPE_SCROLL2, 0x1000, 0x5fff, 0 },
864   { GFXTYPE_SCROLL3,                   0x6000, 0x7fff, 0 },
865   { 0 }
866};
867
868static const struct gfx_range mapper_pang3[] =
869{
870   /* type                              start   end     bank */
871   { GFXTYPE_SPRITES | GFXTYPE_SCROLL2, 0x0000, 0x7fff, 0 },
872
873   { GFXTYPE_SPRITES | GFXTYPE_SCROLL2, 0x8000, 0x9fff, 1 },
874   { GFXTYPE_SCROLL1,                   0xa000, 0xbfff, 1 },
875   { GFXTYPE_SCROLL3,                   0xc000, 0xffff, 1 },
876   { 0 }
877};
878
879
880
881/*
882  I don't know if CPS2 ROM boards use PALs as well; since all games seem to be
883  well behaved, I'll just assume that there is no strong checking of gfx type.
884  (sprites are not listed here because they are addressed linearly by the CPS2
885  sprite code)
886 */
887static const struct gfx_range mapper_cps2[] =
888{
889   /* type                                                start    end      bank */
890   { GFXTYPE_SCROLL1 | GFXTYPE_SCROLL2 | GFXTYPE_SCROLL3, 0x00000, 0x07fff, 4 },   // 20000-27fff physical
891   { GFXTYPE_SCROLL1 | GFXTYPE_SCROLL2 | GFXTYPE_SCROLL3, 0x08000, 0x0ffff, 5 },   // 28000-2ffff physical
892   {                   GFXTYPE_SCROLL2 | GFXTYPE_SCROLL3, 0x10000, 0x17fff, 6 },   // 30000-37fff physical
893   {                   GFXTYPE_SCROLL2 | GFXTYPE_SCROLL3, 0x18000, 0x1ffff, 7 },   // 38000-3ffff physical
894   { 0 }
895};
896
897
898
275899static const struct CPS1config cps1_config_table[]=
276900{
277   /* name       CPSB    banks        tile limits            kludge */
278   {"forgottn",CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 7 },
279   {"lostwrld",CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 7 },
280   {"ghouls",  CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 1 },
281   {"ghoulsu", CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 1 },
282   {"daimakai",CPS_B_01, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 1 },
283   {"strider", CPS_B_01, 1,0,1, 0x0000,0xffff,0x0000,0xffff, 11 },
284   {"stridrua",CPS_B_01, 1,0,1, 0x0000,0xffff,0x0000,0xffff, 11 },
285   {"striderj",CPS_B_01, 1,0,1, 0x0000,0xffff,0x0000,0xffff, 11 },
286   {"stridrja",CPS_B_01, 1,0,1, 0x0000,0xffff,0x0000,0xffff, 11 },
287   {"dynwar",  CPS_B_02, 0,1,1, 0x0000,0xffff,0x0000,0xffff },
288   {"dynwarj", CPS_B_02, 0,1,1, 0x0000,0xffff,0x0000,0xffff },
289   {"willow",  CPS_B_03, 0,1,0, 0x0000,0xffff,0x0000,0xffff },
290   {"willowj", CPS_B_03, 0,1,0, 0x0000,0xffff,0x0000,0xffff },
291   {"willowje",CPS_B_03, 0,1,0, 0x0000,0xffff,0x0000,0xffff },
292   {"ffight",  CPS_B_04, 0,0,0, 0x0001,0xffff,0x0001,0xffff },
293   {"ffightu", CPS_B_04, 0,0,0, 0x0001,0xffff,0x0001,0xffff },
294   {"ffightua",CPS_B_01, 0,0,0, 0x0001,0xffff,0x0001,0xffff },
295   {"ffightub",CPS_B_05, 0,0,0, 0x0001,0xffff,0x0001,0xffff }, // I think
296   {"ffightj", CPS_B_04, 0,0,0, 0x0001,0xffff,0x0001,0xffff },
297   {"ffightj1",CPS_B_02, 0,0,0, 0x0001,0xffff,0x0001,0xffff },
298   {"1941",    CPS_B_05, 0,0,0, 0x0000,0xffff,0x0400,0x07ff },
299   {"1941j",   CPS_B_05, 0,0,0, 0x0000,0xffff,0x0400,0x07ff },
300   {"unsquad", CPS_B_11, 0,0,0, 0x0000,0xffff,0x0001,0xffff, 11 },   /* CPSB ID not checked, but it's the same as sf2eg */
301   {"area88",  CPS_B_11, 0,0,0, 0x0000,0xffff,0x0001,0xffff, 11 },   /* CPSB ID not checked, but it's the same as sf2eg */
302   {"mercs",   CPS_B_12, 0,0,0, 0x0600,0x5bff,0x0700,0x17ff, 4 },   /* (uses port 74) */
303   {"mercsu",  CPS_B_12, 0,0,0, 0x0600,0x5bff,0x0700,0x17ff, 4 },   /* (uses port 74) */
304   {"mercsua", CPS_B_12, 0,0,0, 0x0600,0x5bff,0x0700,0x17ff, 4 },   /* (uses port 74) */
305   {"mercsj",  CPS_B_12, 0,0,0, 0x0600,0x5bff,0x0700,0x17ff, 4 },   /* (uses port 74) */
306   {"msword",  CPS_B_13, 0,0,0, 0x2800,0x37ff,0x0000,0xffff, 3 },   /* CPSB ID not checked, but it's the same as sf2j */
307   {"mswordr1",CPS_B_13, 0,0,0, 0x2800,0x37ff,0x0000,0xffff, 3 },   /* CPSB ID not checked, but it's the same as sf2j */
308   {"mswordu", CPS_B_13, 0,0,0, 0x2800,0x37ff,0x0000,0xffff, 3 },   /* CPSB ID not checked, but it's the same as sf2j */
309   {"mswordj", CPS_B_13, 0,0,0, 0x2800,0x37ff,0x0000,0xffff, 3 },   /* CPSB ID not checked, but it's the same as sf2j */
310   {"mtwins",  CPS_B_14, 0,0,0, 0x0000,0x3fff,0x0e00,0xffff },
311   {"chikij",  CPS_B_14, 0,0,0, 0x0000,0x3fff,0x0e00,0xffff },
312   {"nemo",    CPS_B_15, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
313   {"nemoj",   CPS_B_15, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
314   {"cawing",  CPS_B_16, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
315   {"cawingr1",CPS_B_16, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
316   {"cawingu", CPS_B_16, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
317   {"cawingj", CPS_B_16, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
318   {"sf2",     CPS_B_11, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
319   {"sf2eb",   CPS_B_17, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
320   {"sf2ua",   CPS_B_17, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
321   {"sf2ub",   CPS_B_17, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
322   {"sf2ud",   CPS_B_05, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
323   {"sf2ue",   CPS_B_18, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
324   {"sf2uf",   CPS_B_15, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
325   {"sf2ui",   CPS_B_14, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
326   {"sf2uk",   CPS_B_17, 2,2,2, 0x0000,0xffff,0x0000,0xffff }, // check CPS_B
327   {"sf2j",    CPS_B_13, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
328   {"sf2ja",   CPS_B_17, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
329   {"sf2jc",   CPS_B_12, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
901   /* name       CPSB     bank size gfx mapper  kludge */
902   {"forgottn", CPS_B_01, 0x8000, mapper_LWCHR },
903   {"lostwrld", CPS_B_01, 0x8000, mapper_LWCHR },
904   {"ghouls",   CPS_B_01, 0x8000, mapper_DM620 },
905   {"ghoulsu",  CPS_B_01, 0x8000, mapper_DM620 },
906   {"daimakai", CPS_B_01, 0x8000, mapper_DM620 },
907   {"strider",  CPS_B_01, 0x4000, mapper_ST24M1 },
908   {"stridrua", CPS_B_01, 0x4000, mapper_ST24M1 },
909   {"striderj", CPS_B_01, 0x4000, mapper_ST24M1 },
910   {"stridrja", CPS_B_01, 0x4000, mapper_ST24M1 },
911   {"dynwar",   CPS_B_02, 0x8000, mapper_dynwar },
912   {"dynwarj",  CPS_B_02, 0x8000, mapper_dynwar },
913   {"willow",   CPS_B_03, 0x8000, mapper_WL24B },
914   {"willowj",  CPS_B_03, 0x8000, mapper_WL24B },
915   {"willowje", CPS_B_03, 0x8000, mapper_WL24B },
916   {"ffight",   CPS_B_04, 0x8000, mapper_S224B },
917   {"ffightu",  CPS_B_04, 0x8000, mapper_S224B },
918   {"ffightua", CPS_B_01, 0x8000, mapper_S224B },
919   {"ffightub", CPS_B_05, 0x8000, mapper_S224B },
920   {"ffightj",  CPS_B_04, 0x8000, mapper_S224B },
921   {"ffightj1", CPS_B_02, 0x8000, mapper_S224B },
922   {"1941",     CPS_B_05, 0x8000, mapper_YI24B },
923   {"1941j",    CPS_B_05, 0x8000, mapper_YI24B },
924   {"unsquad",  CPS_B_11, 0x8000, mapper_AR24B },   /* CPSB ID not checked, but it's the same as sf2eg */
925   {"area88",   CPS_B_11, 0x8000, mapper_AR24B },   /* CPSB ID not checked, but it's the same as sf2eg */
926   {"mercs",    CPS_B_12, 0x8000, mapper_0224B },   /* (uses port 74) */
927   {"mercsu",   CPS_B_12, 0x8000, mapper_0224B },   /* (uses port 74) */
928   {"mercsua",  CPS_B_12, 0x8000, mapper_0224B },   /* (uses port 74) */
929   {"mercsj",   CPS_B_12, 0x8000, mapper_0224B },   /* (uses port 74) */
930   {"msword",   CPS_B_13, 0x8000, mapper_MS24B },   /* CPSB ID not checked, but it's the same as sf2j */
931   {"mswordr1", CPS_B_13, 0x8000, mapper_MS24B },   /* CPSB ID not checked, but it's the same as sf2j */
932   {"mswordu",  CPS_B_13, 0x8000, mapper_MS24B },   /* CPSB ID not checked, but it's the same as sf2j */
933   {"mswordj",  CPS_B_13, 0x8000, mapper_MS24B },   /* CPSB ID not checked, but it's the same as sf2j */
934   {"mtwins",   CPS_B_14, 0x8000, mapper_CK24B },
935   {"chikij",   CPS_B_14, 0x8000, mapper_CK24B },
936   {"nemo",     CPS_B_15, 0x8000, mapper_NM24B },
937   {"nemoj",    CPS_B_15, 0x8000, mapper_NM24B },
938   {"cawing",   CPS_B_16, 0x8000, mapper_CA24B },
939   {"cawingr1", CPS_B_16, 0x8000, mapper_CA24B },
940   {"cawingu",  CPS_B_16, 0x8000, mapper_CA24B },
941   {"cawingj",  CPS_B_16, 0x8000, mapper_CA24B },
942   {"sf2",      CPS_B_11, 0x8000, mapper_STF29 },
943   {"sf2eb",    CPS_B_17, 0x8000, mapper_STF29 },
944   {"sf2ua",    CPS_B_17, 0x8000, mapper_STF29 },
945   {"sf2ub",    CPS_B_17, 0x8000, mapper_STF29 },
946   {"sf2ud",    CPS_B_05, 0x8000, mapper_STF29 },
947   {"sf2ue",    CPS_B_18, 0x8000, mapper_STF29 },
948   {"sf2uf",    CPS_B_15, 0x8000, mapper_STF29 },
949   {"sf2ui",    CPS_B_14, 0x8000, mapper_STF29 },
950   {"sf2uk",    CPS_B_17, 0x8000, mapper_STF29 }, // check CPS_B
951   {"sf2j",     CPS_B_13, 0x8000, mapper_STF29 },
952   {"sf2ja",    CPS_B_17, 0x8000, mapper_STF29 },
953   {"sf2jc",    CPS_B_12, 0x8000, mapper_STF29 },
330954   /* from here onwards the CPS-B board has suicide battery and multiply protection */
331   {"3wonders",BATTRY_1, 0,1,0, 0x0000,0xffff,0x0000,0xffff, 2 },
332   {"3wonderu",BATTRY_1, 0,1,0, 0x0000,0xffff,0x0000,0xffff, 2 },
333   {"wonder3", BATTRY_1, 0,1,0, 0x0000,0xffff,0x0000,0xffff, 2 },
334   {"kod",     BATTRY_2, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
335   {"kodu",    BATTRY_2, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
336   {"kodj",    BATTRY_2, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
337   {"kodb",    BATTRY_2, 0,0,0, 0x0000,0xffff,0x0000,0xffff },   /* bootleg, doesn't use multiply protection */
338   {"captcomm",BATTRY_3, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 11 },
339   {"captcomu",BATTRY_3, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 11 },
340   {"captcomj",BATTRY_3, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 11 },
341   {"knights", BATTRY_4, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 3 },
342   {"knightsu",BATTRY_4, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 3 },
343   {"knightsj",BATTRY_4, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 3 },
344   {"sf2ce",   NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
345   {"sf2ceua", NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
346   {"sf2ceub", NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
347   {"sf2ceuc", NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
348   {"sf2cej",  NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
349   {"sf2rb",   NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
350   {"sf2rb2",  NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
351   {"sf2red",  NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
352   {"sf2v004", NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
353   {"sf2accp2",NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
354   {"sf2m1",   NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
355   {"sf2m2",   NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
356   {"sf2m3",   NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
357   {"sf2m4",   HACK_B_1, 2,2,2, 0x0000,0xffff,0x0000,0xffff, 10 },
358   {"sf2m5",   NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff, 10 },
359   {"sf2m6",   NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff, 10 },
360   {"sf2m7",   NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff, 10 },
361   {"sf2yyc",  NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff, 10 },
362   {"sf2koryu",NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff, 10 },
363   {"varth",   CPS_B_04, 0,0,0, 0x0000,0xffff,0x0c00,0x0fff },   /* CPSB test has been patched out (60=0008) */
364   {"varthr1", CPS_B_04, 0,0,0, 0x0000,0xffff,0x0c00,0x0fff },   /* CPSB test has been patched out (60=0008) */
365   {"varthu",  CPS_B_04, 0,0,0, 0x0000,0xffff,0x0c00,0x0fff },   /* CPSB test has been patched out (60=0008) */
366   {"varthj",  BATTRY_5, 0,0,0, 0x0000,0xffff,0x0c00,0x0fff },   /* CPSB test has been patched out (72=0001) */
367   {"cworld2j",BATTRY_6, 0,0,0, 0x0000,0xffff,0x0000,0xffff },   /* The 0x76 priority values are incorrect values */
368   {"wof",     NOBATTRY, 0,0,0, 0x0000,0xffff,0x0000,0xffff },   /* bootleg? */
369   {"wofa",    NOBATTRY, 0,0,0, 0x0000,0xffff,0x0000,0xffff },   /* bootleg? */
370   {"wofu",    QSOUND_1, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
371   {"wofj",    QSOUND_1, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
372   {"dino",    QSOUND_2, 0,0,0, 0x0000,0xffff,0x0000,0xffff },   /* layer enable never used */
373   {"dinou",   QSOUND_2, 0,0,0, 0x0000,0xffff,0x0000,0xffff },   /* layer enable never used */
374   {"dinoj",   QSOUND_2, 0,0,0, 0x0000,0xffff,0x0000,0xffff },   /* layer enable never used */
375   {"punisher",QSOUND_3, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
376   {"punishru",QSOUND_3, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
377   {"punishrj",QSOUND_3, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
378   {"slammast",QSOUND_4, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
379   {"slammasu",QSOUND_4, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
380   {"mbomberj",QSOUND_4, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
381   {"mbombrd", QSOUND_5, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
382   {"mbombrdj",QSOUND_5, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
383   {"sf2hf",   NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
384   {"sf2t",    NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
385   {"sf2tj",   NOBATTRY, 2,2,2, 0x0000,0xffff,0x0000,0xffff },
386   {"qad",     BATTRY_7, 0,0,0, 0x0000,0xffff,0x0000,0xffff },   /* TODO: layer enable */
387   {"qadj",    NOBATTRY, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
388   {"qtono2",  NOBATTRY, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
389   {"megaman", NOBATTRY, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
390   {"rockmanj",NOBATTRY, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
391   {"pnickj",  NOBATTRY, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
392   {"pang3",   NOBATTRY, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 5 },   /* EEPROM port is among the CPS registers */
393   {"pang3j",  NOBATTRY, 0,0,0, 0x0000,0xffff,0x0000,0xffff, 5 },   /* EEPROM port is among the CPS registers */
955   {"3wonders", BATTRY_1, 0x8000, mapper_RT24B },
956   {"3wonderu", BATTRY_1, 0x8000, mapper_RT24B },
957   {"wonder3",  BATTRY_1, 0x8000, mapper_RT24B },
958   {"kod",      BATTRY_2, 0x8000, mapper_KD29B },
959   {"kodu",     BATTRY_2, 0x8000, mapper_KD29B },
960   {"kodj",     BATTRY_2, 0x8000, mapper_KD29B },
961   {"kodb",     BATTRY_2, 0x8000, mapper_KD29B },   /* bootleg, doesn't use multiply protection */
962   {"captcomm", BATTRY_3, 0x8000, mapper_CC63B },
963   {"captcomu", BATTRY_3, 0x8000, mapper_CC63B },
964   {"captcomj", BATTRY_3, 0x8000, mapper_CC63B },
965   {"knights",  BATTRY_4, 0x8000, mapper_KR63B },
966   {"knightsu", BATTRY_4, 0x8000, mapper_KR63B },
967   {"knightsj", BATTRY_4, 0x8000, mapper_KR63B },
968   {"sf2ce",    NOBATTRY, 0x8000, mapper_S9263B },
969   {"sf2ceua",  NOBATTRY, 0x8000, mapper_S9263B },
970   {"sf2ceub",  NOBATTRY, 0x8000, mapper_S9263B },
971   {"sf2ceuc",  NOBATTRY, 0x8000, mapper_S9263B },
972   {"sf2cej",   NOBATTRY, 0x8000, mapper_S9263B },
973   {"sf2rb",    NOBATTRY, 0x8000, mapper_S9263B },
974   {"sf2rb2",   NOBATTRY, 0x8000, mapper_S9263B },
975   {"sf2red",   NOBATTRY, 0x8000, mapper_S9263B },
976   {"sf2v004",  NOBATTRY, 0x8000, mapper_S9263B },
977   {"sf2accp2", NOBATTRY, 0x8000, mapper_S9263B },
978   {"sf2m1",    NOBATTRY, 0x8000, mapper_S9263B },
979   {"sf2m2",    NOBATTRY, 0x8000, mapper_S9263B },
980   {"sf2m3",    NOBATTRY, 0x8000, mapper_S9263B },
981   {"sf2m4",    HACK_B_1, 0x8000, mapper_S9263B, 1 },
982   {"sf2m5",    NOBATTRY, 0x8000, mapper_S9263B, 1 },
983   {"sf2m6",    NOBATTRY, 0x8000, mapper_S9263B, 1 },
984   {"sf2m7",    NOBATTRY, 0x8000, mapper_S9263B, 1 },
985   {"sf2yyc",   NOBATTRY, 0x8000, mapper_S9263B, 1 },
986   {"sf2koryu", NOBATTRY, 0x8000, mapper_S9263B, 1 },
987   {"varth",    CPS_B_04, 0x8000, mapper_VA24B },   /* CPSB test has been patched out (60=0008) */
988   {"varthr1",  CPS_B_04, 0x8000, mapper_VA24B },   /* CPSB test has been patched out (60=0008) */
989   {"varthu",   CPS_B_04, 0x8000, mapper_VA24B },   /* CPSB test has been patched out (60=0008) */
990   {"varthj",   BATTRY_5, 0x8000, mapper_VA24B },   /* CPSB test has been patched out (72=0001) */
991   {"cworld2j", BATTRY_6, 0x8000, mapper_Q522B },   /* The 0x76 priority values are incorrect values */
992   {"wof",      NOBATTRY, 0x8000, mapper_TK263B },   /* bootleg? */
993   {"wofa",     NOBATTRY, 0x8000, mapper_TK263B },   /* bootleg? */
994   {"wofu",     QSOUND_1, 0x8000, mapper_TK263B },
995   {"wofj",     QSOUND_1, 0x8000, mapper_TK263B },
996   {"dino",     QSOUND_2, 0x8000, mapper_CD63B },   /* layer enable never used */
997   {"dinou",    QSOUND_2, 0x8000, mapper_CD63B },   /* layer enable never used */
998   {"dinoj",    QSOUND_2, 0x8000, mapper_CD63B },   /* layer enable never used */
999   {"punisher", QSOUND_3, 0x8000, mapper_PS63B },
1000   {"punishru", QSOUND_3, 0x8000, mapper_PS63B },
1001   {"punishrj", QSOUND_3, 0x8000, mapper_PS63B },
1002   {"slammast", QSOUND_4, 0x8000, mapper_MB63B },
1003   {"slammasu", QSOUND_4, 0x8000, mapper_MB63B },
1004   {"mbomberj", QSOUND_4, 0x8000, mapper_MB63B },
1005   {"mbombrd",  QSOUND_5, 0x8000, mapper_MB63B },
1006   {"mbombrdj", QSOUND_5, 0x8000, mapper_MB63B },
1007   {"sf2hf",    NOBATTRY, 0x8000, mapper_S9263B },
1008   {"sf2t",     NOBATTRY, 0x8000, mapper_S9263B },
1009   {"sf2tj",    NOBATTRY, 0x8000, mapper_S9263B },
1010   {"qad",      BATTRY_7, 0x8000, mapper_QD22B },   /* TODO: layer enable */
1011   {"qadj",     NOBATTRY, 0x8000, mapper_qadj },
1012   {"qtono2",   NOBATTRY, 0x8000, mapper_qtono2 },
1013   {"megaman",  NOBATTRY, 0x8000, mapper_RCM63B },
1014   {"rockmanj", NOBATTRY, 0x8000, mapper_RCM63B },
1015   {"pnickj",   NOBATTRY, 0x8000, mapper_pnickj },
1016   {"pang3",    NOBATTRY, 0x8000, mapper_pang3 },   /* EEPROM port is among the CPS registers (handled by DRIVER_INIT) */
1017   {"pang3j",   NOBATTRY, 0x8000, mapper_pang3 },   /* EEPROM port is among the CPS registers (handled by DRIVER_INIT) */
3941018   #ifdef MESS
395   {"sfzch",   NOBATTRY, 0,0,0, 0x0000,0xffff,0x0000,0xffff },
1019   {"sfzch",    NOBATTRY, 0x8000, mapper_cps2 },
3961020   #endif
3971021
3981022    /* CPS2 games */
399   {"cps2",    NOBATTRY, 4,4,4, 0x0000,0xffff,0x0000,0xffff },
400   {"ssf2",    NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff },
401   {"ssf2u",   NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff },
402   {"ssf2a",   NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff },
403   {"ssf2ar1", NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff },
404   {"ssf2j",   NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff },
405   {"ssf2jr1", NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff },
406   {"ssf2jr2", NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff },
407   {"ssf2tb",  NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff },
408   {"ssf2tbr1",NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff },
409   {"ssf2tbj", NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff },
410   {"ssf2t",   NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff, 9 },
411   {"ssf2tu",  NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff, 9 },
412   {"ssf2tur1",NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff, 9 },
413   {"ssf2ta",  NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff, 9 },
414   {"ssf2xj",  NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff, 9 },
415   {"xmcota",  NOBATTRY, 4,4,4, 0x0000,0xffff,0x0000,0xffff, 8 },
416   {"xmcotau", NOBATTRY, 4,4,4, 0x0000,0xffff,0x0000,0xffff, 8 },
417   {"xmcotah", NOBATTRY, 4,4,4, 0x0000,0xffff,0x0000,0xffff, 8 },
418   {"xmcotaj", NOBATTRY, 4,4,4, 0x0000,0xffff,0x0000,0xffff, 8 },
419   {"xmcotaj1",NOBATTRY, 4,4,4, 0x0000,0xffff,0x0000,0xffff, 8 },
420   {"xmcotaj2",NOBATTRY, 4,4,4, 0x0000,0xffff,0x0000,0xffff, 8 },
421   {"xmcotajr",NOBATTRY, 4,4,4, 0x0000,0xffff,0x0000,0xffff, 8 },
422   {"xmcotaa", NOBATTRY, 4,4,4, 0x0000,0xffff,0x0000,0xffff, 8 },
423   {"hsf2",    NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff, 9 },
424   {"hsf2j",   NOBATTRY, 4,4,0, 0x0000,0xffff,0x0000,0xffff, 9 },
1023   {"cps2",     NOBATTRY, 0x8000, mapper_cps2 },
1024
4251025   {0}      /* End of table */
4261026};
4271027
1028
1029
1030/* Public variables */
1031UINT16 *cps1_gfxram;
1032UINT16 *cps1_output;
1033
1034size_t cps1_gfxram_size;
1035size_t cps1_output_size;
1036
1037/* Offset of each palette entry */
1038#define cps1_palette_entries (32*6)  /* Number colour schemes in palette */
1039
1040static const int cps1_scroll_size =0x4000;   /* scroll1, scroll2, scroll3 */
1041static const int cps1_obj_size    =0x0800;
1042static const int cps1_other_size  =0x0800;
1043static const int cps1_palette_align=0x0400;   /* minimum alignment is a single palette page (512 colors). Verified on pcb. */
1044static const int cps1_palette_size=cps1_palette_entries*32; /* Size of palette RAM */
1045
1046static UINT16 *cps1_scroll1;
1047static UINT16 *cps1_scroll2;
1048static UINT16 *cps1_scroll3;
1049static UINT16 *cps1_obj;
1050static UINT16 *cps1_buffered_obj;
1051UINT16 *cps1_other;
1052
1053/* Working variables */
1054static int cps1_last_sprite_offset;     /* Offset of the last sprite */
1055static int cps1_stars_enabled[2];          /* Layer enabled [Y/N] */
1056
1057tilemap *cps1_bg_tilemap[3];
1058
1059
1060int cps1_scroll1x, cps1_scroll1y;
1061int cps1_scroll2x, cps1_scroll2y;
1062int cps1_scroll3x, cps1_scroll3y;
1063static int stars1x, stars1y, stars2x, stars2y;
1064
1065
1066/* Output ports */
1067#define CPS1_OBJ_BASE           0x00    /* Base address of objects */
1068#define CPS1_SCROLL1_BASE       0x02    /* Base address of scroll 1 */
1069#define CPS1_SCROLL2_BASE       0x04    /* Base address of scroll 2 */
1070#define CPS1_SCROLL3_BASE       0x06    /* Base address of scroll 3 */
1071#define CPS1_OTHER_BASE         0x08    /* Base address of other video */
1072#define CPS1_PALETTE_BASE       0x0a    /* Base address of palette */
1073#define CPS1_SCROLL1_SCROLLX    0x0c    /* Scroll 1 X */
1074#define CPS1_SCROLL1_SCROLLY    0x0e    /* Scroll 1 Y */
1075#define CPS1_SCROLL2_SCROLLX    0x10    /* Scroll 2 X */
1076#define CPS1_SCROLL2_SCROLLY    0x12    /* Scroll 2 Y */
1077#define CPS1_SCROLL3_SCROLLX    0x14    /* Scroll 3 X */
1078#define CPS1_SCROLL3_SCROLLY    0x16    /* Scroll 3 Y */
1079#define CPS1_STARS1_SCROLLX     0x18    /* Stars 1 X */
1080#define CPS1_STARS1_SCROLLY     0x1a    /* Stars 1 Y */
1081#define CPS1_STARS2_SCROLLX     0x1c    /* Stars 2 X */
1082#define CPS1_STARS2_SCROLLY     0x1e    /* Stars 2 Y */
1083#define CPS1_ROWSCROLL_OFFS     0x20    /* base of row scroll offsets in other RAM */
1084#define CPS1_VIDEOCONTROL       0x22    /* flip screen, rowscroll enable */
1085
1086#define CPS1_SCROLL2_WIDTH      0x40
1087#define CPS1_SCROLL2_HEIGHT     0x40
1088
1089
1090/*
1091CPS1 VIDEO RENDERER
1092
1093*/
1094/* first 0x4000 of gfx ROM are used, but 0x0000-0x1fff is == 0x2000-0x3fff */
1095static const int stars_rom_size = 0x2000;
1096
1097/* PSL: CPS2 support */
1098static const int cps2_obj_size    =0x2000;
1099UINT16 *cps2_objram1,*cps2_objram2;
1100UINT16 *cps2_output;
1101
1102size_t cps2_output_size;
1103static UINT16 *cps2_buffered_obj;
1104static int pri_ctrl;            /* Sprite layer priorities */
1105static int cps2_objram_bank;
1106static int cps2_last_sprite_offset;     /* Offset of the last sprite */
1107
1108#define CPS2_OBJ_BASE   0x00   /* Unknown (not base address of objects). Could be bass address of bank used when object swap bit set? */
1109#define CPS2_OBJ_UK1   0x02   /* Unknown (nearly always 0x807d, or 0x808e when screen flipped) */
1110#define CPS2_OBJ_PRI   0x04   /* Layers priorities */
1111#define CPS2_OBJ_UK2   0x06   /* Unknown (usually 0x0000, 0x1101 in ssf2, 0x0001 in 19XX) */
1112#define CPS2_OBJ_XOFFS   0x08   /* X offset (usually 0x0040) */
1113#define CPS2_OBJ_YOFFS   0x0a   /* Y offset (always 0x0010) */
1114
1115
4281116static int cps_version;
4291117int cps1_scanline1;
4301118int cps1_scanline2;
4311119int cps1_scancalls;
4321120
4331121
1122static void cps1_build_palette(running_machine *machine, const UINT16* const palette_base);
1123
1124
4341125static MACHINE_RESET( cps )
4351126{
4361127   const char *gamename = machine->gamedrv->name;
r2375r2376
5381229      return (cps1_output[cps1_game_config->mult_factor1/2] *
5391230            cps1_output[cps1_game_config->mult_factor2/2]) >> 16;
5401231
541   /* Pang 3 EEPROM interface */
542   if (cps1_game_config->kludge == 5 && offset == 0x7a/2)
543      return cps1_eeprom_port_r(machine,0,mem_mask);
544
5451232   return cps1_output[offset];
5461233}
5471234
1235
5481236WRITE16_HANDLER( cps1_output_w )
5491237{
550   /* Pang 3 EEPROM interface */
551   if (cps1_game_config->kludge == 5 && offset == 0x7a/2)
552   {
553      cps1_eeprom_port_w(machine,0,data,mem_mask);
554      return;
555   }
556
5571238   data = COMBINE_DATA(&cps1_output[offset]);
5581239
5591240   /* To mark scanlines for raster effects */
r2375r2376
5681249
5691250
5701251#ifdef MAME_DEBUG
571if (cps1_game_config->control_reg && offset == cps1_game_config->control_reg/2 && data != 0x3f)
572   logerror("control_reg = %04x",data);
1252if (cps1_game_config->palette_control && offset == cps1_game_config->palette_control/2 && data != 0x3f)
1253   logerror("palette_control = %04x",data);
5731254#endif
5741255if (VERBOSE)
5751256{
r2375r2376
5791260      offset != cps1_game_config->priority[1]/2 &&
5801261      offset != cps1_game_config->priority[2]/2 &&
5811262      offset != cps1_game_config->priority[3]/2 &&
582      offset != cps1_game_config->control_reg/2)
1263      offset != cps1_game_config->palette_control/2)
5831264   logerror("PC %06x: write %02x to output port %02x\n",activecpu_get_pc(),data,offset*2);
5841265
5851266#ifdef MAME_DEBUG
586if (offset == 0x22/2 && (data & ~0x8001) != 0x0e)
587   logerror("port 22 = %04x",data);
5881267if (cps1_game_config->priority[0] && offset == cps1_game_config->priority[0]/2 && data != 0x00)
5891268   popmessage("priority0 %04x",data);
5901269#endif
5911270}
1271
1272   /*
1273    The main CPU writes the palette to gfxram, and the CPS-B custom copies it
1274    to the real palette RAM, which is separated from gfxram.
1275    This is done ONLY after the palette base register is written to. It is not
1276    known what the exact timing should be, how long it should take and when it
1277    should happen. We are assuming that the copy happens immediately, since it
1278    fixes glitches in the ghouls intro, but it might happen at next vblank.
1279    */
1280   if (offset == CPS1_PALETTE_BASE/2)
1281      cps1_build_palette(machine, cps1_base(CPS1_PALETTE_BASE,cps1_palette_align));
5921282}
5931283
5941284
5951285
596/* Public variables */
597UINT16 *cps1_gfxram;
598UINT16 *cps1_output;
599
600size_t cps1_gfxram_size;
601size_t cps1_output_size;
602
603/* Offset of each palette entry */
604static int palette_basecolor[6];
605#define cps1_palette_entries (32*6)  /* Number colour schemes in palette */
606
607static const int cps1_scroll_size =0x4000;   /* scroll1, scroll2, scroll3 */
608static const int cps1_obj_size    =0x0800;
609static const int cps1_other_size  =0x0800;
610static const int cps1_palette_align=0x0800;   /* can't be larger than this, breaks ringdest & batcirc otherwise */
611static const int cps1_palette_size=cps1_palette_entries*32; /* Size of palette RAM */
612
613static UINT16 *cps1_scroll1;
614static UINT16 *cps1_scroll2;
615static UINT16 *cps1_scroll3;
616static UINT16 *cps1_obj;
617static UINT16 *cps1_buffered_obj;
618static UINT16 *cps1_palette;
619UINT16 *cps1_other;
620static UINT16 *cps1_old_palette;
621
622/* Working variables */
623static int cps1_last_sprite_offset;     /* Offset of the last sprite */
624static int cps1_stars_enabled[2];          /* Layer enabled [Y/N] */
625
626tilemap *cps1_bg_tilemap[3];
627
628
629int cps1_scroll1x, cps1_scroll1y;
630int cps1_scroll2x, cps1_scroll2y;
631int cps1_scroll3x, cps1_scroll3y;
632static int stars1x, stars1y, stars2x, stars2y;
633
634
635/* Output ports */
636#define CPS1_OBJ_BASE         0x00    /* Base address of objects */
637#define CPS1_SCROLL1_BASE       0x02    /* Base address of scroll 1 */
638#define CPS1_SCROLL2_BASE       0x04    /* Base address of scroll 2 */
639#define CPS1_SCROLL3_BASE       0x06    /* Base address of scroll 3 */
640#define CPS1_OTHER_BASE         0x08    /* Base address of other video */
641#define CPS1_PALETTE_BASE       0x0a    /* Base address of palette */
642#define CPS1_SCROLL1_SCROLLX    0x0c    /* Scroll 1 X */
643#define CPS1_SCROLL1_SCROLLY    0x0e    /* Scroll 1 Y */
644#define CPS1_SCROLL2_SCROLLX    0x10    /* Scroll 2 X */
645#define CPS1_SCROLL2_SCROLLY    0x12    /* Scroll 2 Y */
646#define CPS1_SCROLL3_SCROLLX    0x14    /* Scroll 3 X */
647#define CPS1_SCROLL3_SCROLLY    0x16    /* Scroll 3 Y */
648#define CPS1_STARS1_SCROLLX     0x18    /* Stars 1 X */
649#define CPS1_STARS1_SCROLLY     0x1a    /* Stars 1 Y */
650#define CPS1_STARS2_SCROLLX     0x1c    /* Stars 2 X */
651#define CPS1_STARS2_SCROLLY     0x1e    /* Stars 2 Y */
652
653#define CPS1_ROWSCROLL_OFFS     0x20    /* base of row scroll offsets in other RAM */
654
655#define CPS1_SCROLL2_WIDTH      0x40
656#define CPS1_SCROLL2_HEIGHT     0x40
657
658
659/*
660CPS1 VIDEO RENDERER
661
662*/
663/* first 0x4000 of gfx ROM are used, but 0x0000-0x1fff is == 0x2000-0x3fff */
664static const int stars_rom_size = 0x2000;
665
666/* PSL: CPS2 support */
667static const int cps2_obj_size    =0x2000;
668UINT16 *cps2_objram1,*cps2_objram2;
669UINT16 *cps2_output;
670
671size_t cps2_output_size;
672static UINT16 *cps2_buffered_obj;
673static int pri_ctrl;            /* Sprite layer priorities */
674static int cps2_objram_bank;
675static int cps2_last_sprite_offset;     /* Offset of the last sprite */
676
677#define CPS2_OBJ_BASE   0x00   /* Unknown (not base address of objects). Could be bass address of bank used when object swap bit set? */
678#define CPS2_OBJ_UK1   0x02   /* Unknown (nearly always 0x807d, or 0x808e when screen flipped) */
679#define CPS2_OBJ_PRI   0x04   /* Layers priorities */
680#define CPS2_OBJ_UK2   0x06   /* Unknown (usually 0x0000, 0x1101 in ssf2, 0x0001 in 19XX) */
681#define CPS2_OBJ_XOFFS   0x08   /* X offset (usually 0x0040) */
682#define CPS2_OBJ_YOFFS   0x0a   /* Y offset (always 0x0010) */
683
6841286INLINE int cps2_port(int offset)
6851287{
6861288    return cps2_output[offset/2];
r2375r2376
7741376}
7751377
7761378
777#if CPS1_DUMP_VIDEO
778static void cps1_dump_video(void)
779{
780   FILE *fp;
781   fp=fopen("SCROLL1.DMP", "w+b");
782   if (fp)
783   {
784      fwrite(cps1_scroll1, cps1_scroll_size, 1, fp);
785      fclose(fp);
786   }
787   fp=fopen("SCROLL2.DMP", "w+b");
788   if (fp)
789   {
790      fwrite(cps1_scroll2, cps1_scroll_size, 1, fp);
791      fclose(fp);
792   }
793   fp=fopen("SCROLL3.DMP", "w+b");
794   if (fp)
795   {
796      fwrite(cps1_scroll3, cps1_scroll_size, 1, fp);
797      fclose(fp);
798   }
799
800    fp=fopen("OBJ.DMP", "w+b");
801    if (fp)
802    {
803        fwrite(cps1_obj, cps1_obj_size, 1, fp);
804        fclose(fp);
805    }
806    if (cps_version == 2)
807    {
808        /* PSL: CPS2 support */
809        fp=fopen("OBJCPS2.DMP", "w+b");
810        if (fp)
811        {
812            fwrite(cps2_objram1, cps2_obj_size, 1, fp);
813            fwrite(cps2_objram2, cps2_obj_size, 1, fp);
814            fclose(fp);
815        }
816        fp=fopen("CPS2OUTP.DMP", "w+b");
817        if (fp)
818        {
819            fwrite(cps2_output, cps2_output_size, 1, fp);
820            fclose(fp);
821        }
822
823    }
824
825
826   fp=fopen("OTHER.DMP", "w+b");
827   if (fp)
828   {
829      fwrite(cps1_other, cps1_other_size, 1, fp);
830      fclose(fp);
831   }
832
833   fp=fopen("PALETTE.DMP", "w+b");
834   if (fp)
835   {
836      fwrite(cps1_palette, cps1_palette_size, 1, fp);
837      fclose(fp);
838   }
839
840   fp=fopen("OUTPUT.DMP", "w+b");
841   if (fp)
842   {
843      fwrite(cps1_output, cps1_output_size, 1, fp);
844      fclose(fp);
845   }
846   fp=fopen("VIDEO.DMP", "w+b");
847   if (fp)
848   {
849      fwrite(cps1_gfxram, cps1_gfxram_size, 1, fp);
850      fclose(fp);
851   }
852
853}
854#endif
855
856
8571379void cps1_get_video_base(void )
8581380{
859   int layercontrol, scroll1xoff, scroll2xoff, scroll3xoff;
1381   int layercontrol, videocontrol, scroll1xoff, scroll2xoff, scroll3xoff;
8601382
8611383   /* Re-calculate the VIDEO RAM base */
8621384   if (cps1_scroll1 != cps1_base(CPS1_SCROLL1_BASE,cps1_scroll_size))
r2375r2376
8761398   }
8771399
8781400   /* Some of the sf2 hacks use only sprite port 0x9100 and the scroll layers are offset */
879   if (cps1_game_config->kludge == 10)
1401   if (cps1_game_config->bootleg_kludge == 1)
8801402   {
8811403      cps1_output[CPS1_OBJ_BASE/2] = 0x9100;
8821404      cps1_obj=cps1_base(CPS1_OBJ_BASE, cps1_obj_size);
r2375r2376
8911413      scroll2xoff = 0;
8921414      scroll3xoff = 0;
8931415   }
894   cps1_palette=cps1_base(CPS1_PALETTE_BASE,cps1_palette_align);
8951416   cps1_other=cps1_base(CPS1_OTHER_BASE,cps1_other_size);
8961417
8971418   /* Get scroll values */
r2375r2376
9081429
9091430   /* Get layer enable bits */
9101431   layercontrol=cps1_port(cps1_game_config->layer_control);
1432   videocontrol=cps1_port(CPS1_VIDEOCONTROL);
9111433   tilemap_set_enable(cps1_bg_tilemap[0],layercontrol & cps1_game_config->layer_enable_mask[0]);
912   tilemap_set_enable(cps1_bg_tilemap[1],layercontrol & cps1_game_config->layer_enable_mask[1]);
913   tilemap_set_enable(cps1_bg_tilemap[2],layercontrol & cps1_game_config->layer_enable_mask[2]);
1434   tilemap_set_enable(cps1_bg_tilemap[1],(layercontrol & cps1_game_config->layer_enable_mask[1]) && (videocontrol & 4));
1435   tilemap_set_enable(cps1_bg_tilemap[2],(layercontrol & cps1_game_config->layer_enable_mask[2]) && (videocontrol & 8));
9141436   cps1_stars_enabled[0] = layercontrol & cps1_game_config->layer_enable_mask[3];
9151437   cps1_stars_enabled[1] = layercontrol & cps1_game_config->layer_enable_mask[4];
9161438
r2375r2376
9821504
9831505
9841506
1507static int gfxrom_bank_mapper(running_machine *machine, int type, int code)
1508{
1509   const struct gfx_range *range = cps1_game_config->bank_mapper;
1510   int shift = 0;
1511
1512   assert(range);
1513
1514   switch (type)
1515   {
1516      case GFXTYPE_SPRITES: shift = 1; break;
1517      case GFXTYPE_SCROLL1: shift = 0; break;
1518      case GFXTYPE_SCROLL2: shift = 1; break;
1519      case GFXTYPE_SCROLL3: shift = 3; break;
1520   }
1521
1522   code <<= shift;
1523
1524   while (range->type)
1525   {
1526      if (code >= range->start && code <= range->end)
1527      {
1528         if (range->type & type)
1529         {
1530            return ((code & (cps1_game_config->bank_size - 1)) + (range->bank * cps1_game_config->bank_size)) >> shift;
1531         }
1532      }
1533
1534      ++range;
1535   }
1536
1537#ifdef MAME_DEBUG
1538//  popmessage("tile %02x/%04x out of range", type,code>>shift);
1539#endif
1540
1541   return -1;
1542}
1543
1544
9851545/***************************************************************************
9861546
9871547  Start the video hardware emulation.
r2375r2376
10101570
10111571static TILE_GET_INFO( get_tile0_info )
10121572{
1013   int base = cps1_game_config->bank_scroll1 * 0x08000;
10141573   int code = cps1_scroll1[2*tile_index];
10151574   int attr = cps1_scroll1[2*tile_index+1];
10161575   int gfxset;
10171576
1577   code = gfxrom_bank_mapper(machine, GFXTYPE_SCROLL1, code);
1578
10181579   /* allows us to reproduce a problem seen with a ffight board where USA and Japanese
1019       roms have been mixed to be reproduced (ffightua) -- it looks like each column
1020       should alternate between the left and right side of the 16x16 tiles */
1580         roms have been mixed to be reproduced (ffightua) -- it looks like each column
1581         should alternate between the left and right side of the 16x16 tiles */
10211582   gfxset = (tile_index & 0x20) >> 5;
10221583
10231584   SET_TILE_INFO(
10241585         gfxset,
1025         code + base,
1026         (attr & 0x1f) + palette_basecolor[1],
1586         code,
1587         (attr & 0x1f) + 0x20,
10271588         TILE_FLIPYX((attr & 0x60) >> 5));
10281589   tileinfo->group = (attr & 0x0180) >> 7;
10291590
1030   if ((cps1_game_config->kludge == 3  && code == 0xf020) ||   // knights & msword: startup text
1031      (cps1_game_config->kludge == 2  && code == 0x0000) ||   // 3wonders: bottom of screen, between lives of first player and the word INSERT COIN
1032      (cps1_game_config->kludge == 11 && code == 0x0020))      // strider, unsquad, captcomm
1033   {
1591   // for out of range tiles, switch to fully transparent data
1592   // (but still call SET_TILE_INFO, otherwise problems might occur on boot e.g. unsquad)
1593   if (code == -1)
10341594      tileinfo->pen_data = empty_tile;
1035   }
10361595}
10371596
10381597static TILE_GET_INFO( get_tile1_info )
10391598{
1040   int base = cps1_game_config->bank_scroll2 * 0x04000;
1041   const int startcode = cps1_game_config->start_scroll2;
1042   const int endcode   = cps1_game_config->end_scroll2;
10431599   int code = cps1_scroll2[2*tile_index];
10441600   int attr = cps1_scroll2[2*tile_index+1];
10451601
1602   code = gfxrom_bank_mapper(machine, GFXTYPE_SCROLL2, code);
1603
10461604   SET_TILE_INFO(
10471605         2,
1048         code + base,
1049         (attr & 0x1f) + palette_basecolor[2],
1606         code,
1607         (attr & 0x1f) + 0x40,
10501608         TILE_FLIPYX((attr & 0x60) >> 5));
10511609   tileinfo->group = (attr & 0x0180) >> 7;
10521610
1053   if (code < startcode || code > endcode
1054   /*
1055    MERCS has an gap in the scroll 2 layout
1056    (bad tiles at start of level 2)*/
1057      || (cps1_game_config->kludge == 4 && (code >= 0x1e00 && code < 0x5400))
1058   )
1059   {
1611   // for out of range tiles, switch to fully transparent data
1612   if (code == -1)
10601613      tileinfo->pen_data = empty_tile;
1061   }
10621614}
10631615
10641616static TILE_GET_INFO( get_tile2_info )
10651617{
1066   int base = cps1_game_config->bank_scroll3 * 0x1000;
1067   const int startcode = cps1_game_config->start_scroll3;
1068   const int endcode   = cps1_game_config->end_scroll3;
1069   int code = cps1_scroll3[2*tile_index];
1618   int code = cps1_scroll3[2*tile_index] & 0x3fff;
10701619   int attr = cps1_scroll3[2*tile_index+1];
10711620
1072   if (cps1_game_config->kludge == 2 && code < 0x0e00)
1073   {
1074      code += 0x1000;
1075   }
1076   if (cps1_game_config->kludge == 8 && code >= 0x5800)
1077   {
1078      code -= 0x4000;
1079   }
1080   if (cps1_game_config->kludge == 9 && code < 0x5600)
1081   {
1082      code += 0x4000;
1083   }
1621   code = gfxrom_bank_mapper(machine, GFXTYPE_SCROLL3, code);
10841622
10851623   SET_TILE_INFO(
10861624         3,
1087         code + base,
1088         (attr & 0x1f) + palette_basecolor[3],
1625         code,
1626         (attr & 0x1f) + 0x60,
10891627         TILE_FLIPYX((attr & 0x60) >> 5));
10901628   tileinfo->group = (attr & 0x0180) >> 7;
10911629
1092   if (code < startcode || code > endcode)
1093   {
1630   // for out of range tiles, switch to fully transparent data
1631   // (but still call SET_TILE_INFO, otherwise problems might occur on boot e.g. unsquad)
1632   if (code == -1)
10941633      tileinfo->pen_data = empty_tile;
1095   }
10961634}
10971635
10981636
r2375r2376
11161654   }
11171655}
11181656
1119static void cps1_create_empty_8x8_tile(running_machine *machine)
1120{
1121   /* for the 8x8 layer we can't use GFX_RAW so we need to create an empty tile
1122       so that the 'don't draw tile' kludges work */
1123   static const gfx_layout empty_layout8x8 =
1124   {
1125      8,8,
1126      1,
1127      4,
1128      { 0, 1, 2, 3 },
1129      { 1*4, 0*4, 3*4, 2*4, 5*4, 4*4, 7*4, 6*4 },
1130      { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64 },
1131      64*8
1132   };
1133
1134   machine->gfx[4] = allocgfx(&empty_layout8x8);
1135   decodechar(machine->gfx[4], 0, (UINT8 *)empty_tile);
1136   machine->gfx[4]->total_colors = 0x100;
1137
1138}
1139
11401657static VIDEO_START( cps )
11411658{
11421659   int i;
11431660
1144    MACHINE_RESET_CALL(cps);
1661   MACHINE_RESET_CALL(cps);
11451662
11461663   cps1_bg_tilemap[0] = tilemap_create(get_tile0_info,tilemap0_scan, 8, 8,64,64);
11471664   cps1_bg_tilemap[1] = tilemap_create(get_tile1_info,tilemap1_scan,16,16,64,64);
r2375r2376
11491666
11501667   /* front masks will change at runtime to handle sprite occluding */
11511668   cps1_update_transmasks();
1669
11521670   memset(empty_tile,0xff,sizeof(empty_tile));
11531671
1154   cps1_create_empty_8x8_tile(machine);
1155
1156   cps1_old_palette=auto_malloc(cps1_palette_size);
1157   memset(cps1_old_palette, 0x00, cps1_palette_size);
11581672   for (i = 0;i < cps1_palette_entries*16;i++)
11591673   {
11601674      palette_set_color(machine,i,MAKE_RGB(0,0,0));
r2375r2376
11841698   cps1_output[CPS1_SCROLL2_BASE/2] = 0x9040;
11851699   cps1_output[CPS1_SCROLL3_BASE/2] = 0x9080;
11861700   cps1_output[CPS1_OTHER_BASE/2]   = 0x9100;
1187   cps1_output[CPS1_PALETTE_BASE/2] = 0x90c0;
11881701
11891702   assert_always(cps1_game_config, "cps1_game_config hasn't been set up yet");
11901703
11911704   /* Set up old base */
11921705   cps1_get_video_base();   /* Calculate base pointers */
11931706   cps1_get_video_base();   /* Calculate old base pointers */
1194
1195   /* set palette banks */
1196   palette_basecolor[0] = 0*32;   /* obj */
1197   palette_basecolor[1] = 1*32;   /* scroll1 */
1198   palette_basecolor[2] = 2*32;   /* scroll2 */
1199   palette_basecolor[3] = 3*32;   /* scroll3 */
1200   palette_basecolor[4] = 4*32;   /* stars1 */
1201   palette_basecolor[5] = 5*32;   /* stars2 (and bg) */
12021707}
12031708
12041709VIDEO_START( cps1 )
r2375r2376
12211726
12221727***************************************************************************/
12231728
1224void cps1_build_palette(running_machine *machine)
1729static void cps1_build_palette(running_machine *machine, const UINT16* const palette_base)
12251730{
1226   int offset;
1731   int offset, page;
1732   const UINT16 *palette_ram = palette_base;
12271733
1228   for (offset = 0; offset < cps1_palette_entries*16; offset++)
1734   int ctrl = cps1_port(cps1_game_config->palette_control);
1735
1736   /*
1737    The palette is copied only for pages that are enabled in the ctrl
1738    register. Note that if the sprite palette (page 0) is skipped, the
1739    all the following pages are scaled down by one.
1740    */
1741   for (page = 0; page < 6; ++page)
12291742   {
1230      int palette = cps1_palette[offset];
1231
1232      if (palette != cps1_old_palette[offset])
1743      if (BIT(ctrl,page))
12331744      {
1234         int red, green, blue, bright;
1745         for (offset = 0; offset < 0x200; ++offset)
1746         {
1747            int palette = *(palette_ram++);
1748            int r, g, b, bright;
12351749
1236         bright = 0x10 + (palette>>12);
1750            // from my understanding of the schematics, when the 'brightness'
1751            // component is set to 0 it should reduce brightness to 1/3
12371752
1238         red   = ((palette>>8)&0x0f) * bright * 0x11 / 0x1f;
1239         green = ((palette>>4)&0x0f) * bright * 0x11 / 0x1f;
1240         blue  = ((palette>>0)&0x0f) * bright * 0x11 / 0x1f;
1753            bright = 0x0f + ((palette>>12)<<1);
12411754
1242         palette_set_color (machine, offset, MAKE_RGB(red, green, blue));
1243         cps1_old_palette[offset] = palette;
1755            r = ((palette>>8)&0x0f) * 0x11 * bright / 0x2d;
1756            g = ((palette>>4)&0x0f) * 0x11 * bright / 0x2d;
1757            b = ((palette>>0)&0x0f) * 0x11 * bright / 0x2d;
1758
1759            palette_set_color (machine, 0x200*page + offset, MAKE_RGB(r, g, b));
1760         }
12441761      }
1762      else
1763      {
1764         if (page > 0)
1765            palette_ram += 0x200;
1766      }
12451767   }
12461768}
12471769
r2375r2376
13261848   UINT16 *base=cps1_buffered_obj;
13271849
13281850   /* some sf2 hacks draw the sprites in reverse order */
1329   if (cps1_game_config->kludge == 10)
1851   if (cps1_game_config->bootleg_kludge == 1)
13301852   {
13311853      base += cps1_last_sprite_offset;
13321854      baseadd = -4;
r2375r2376
13471869//      x-=0x20;
13481870//      y+=0x20;
13491871
1350      if (cps1_game_config->kludge == 7)
1351      {
1352         code += 0x4000;
1353      }
1354      if (cps1_game_config->kludge == 1 && code >= 0x01000)
1355      {
1356         code += 0x4000;
1357      }
1358      if (cps1_game_config->kludge == 2 && code >= 0x02a00)
1359      {
1360         code += 0x4000;
1361      }
1872      code = gfxrom_bank_mapper(machine, GFXTYPE_SPRITES, code);
13621873
1363      if (code < machine->gfx[1]->total_elements)
1874      if (code != -1)
13641875      {
13651876         if (colour & 0xff00 )
13661877         {
r2375r2376
13861897                        DRAWSPRITE(
13871898//                                      code+(nx-1)-nxs+0x10*(ny-1-nys),
13881899                              (code & ~0xf) + ((code + (nx-1) - nxs) & 0xf) + 0x10*(ny-1-nys),
1389                              (col&0x1f) + palette_basecolor[0],
1900                              (col&0x1f),
13901901                              1,1,
13911902                              sx,sy);
13921903                     }
r2375r2376
14041915                        DRAWSPRITE(
14051916//                                      code+nxs+0x10*(ny-1-nys),
14061917                              (code & ~0xf) + ((code + nxs) & 0xf) + 0x10*(ny-1-nys),
1407                              (col&0x1f) + palette_basecolor[0],
1918                              (col&0x1f),
14081919                              0,1,
14091920                              sx,sy);
14101921                     }
r2375r2376
14251936                        DRAWSPRITE(
14261937//                                      code+(nx-1)-nxs+0x10*nys,
14271938                              (code & ~0xf) + ((code + (nx-1) - nxs) & 0xf) + 0x10*nys,
1428                              (col&0x1f) + palette_basecolor[0],
1939                              (col&0x1f),
14291940                              1,0,
14301941                              sx,sy);
14311942                     }
r2375r2376
14431954                        DRAWSPRITE(
14441955//                                      code+nxs+0x10*nys,
14451956                              (code & ~0xf) + ((code + nxs) & 0xf) + 0x10*nys,   // fix 00406: qadj: When playing as the ninja, there is one broekn frame in his animation loop when walking.
1446                              (col&0x1f) + palette_basecolor[0],
1957                              (col&0x1f),
14471958                              0,0,
14481959                              sx,sy);
14491960                     }
r2375r2376
14561967            /* Simple case... 1 sprite */
14571968                  DRAWSPRITE(
14581969                  code,
1459                  (col&0x1f) + palette_basecolor[0],
1970                  (col&0x1f),
14601971                  colour&0x20,colour&0x40,
14611972                  x & 0x1ff,y & 0x1ff);
14621973         }
r2375r2376
16172128                     sy = (y+nys*16+yoffs) & 0x3ff;
16182129                     DRAWSPRITE(
16192130                           code+(nx-1)-nxs+0x10*(ny-1-nys),
1620                           (col&0x1f) + palette_basecolor[0],
2131                           (col&0x1f),
16212132                           1,1,
16222133                           sx,sy);
16232134                  }
r2375r2376
16342145
16352146                     DRAWSPRITE(
16362147                           code+nxs+0x10*(ny-1-nys),
1637                           (col&0x1f) + palette_basecolor[0],
2148                           (col&0x1f),
16382149                           0,1,
16392150                           sx,sy);
16402151                  }
r2375r2376
16542165
16552166                     DRAWSPRITE(
16562167                           code+(nx-1)-nxs+0x10*nys,
1657                           (col&0x1f) + palette_basecolor[0],
2168                           (col&0x1f),
16582169                           1,0,
16592170                           sx,sy);
16602171                  }
r2375r2376
16722183                     DRAWSPRITE(
16732184//                                      code+nxs+0x10*nys,
16742185                           (code & ~0xf) + ((code + nxs) & 0xf) + 0x10*nys,   //  pgear fix
1675                           (col&0x1f) + palette_basecolor[0],
2186                           (col&0x1f),
16762187                           0,0,
16772188                           sx,sy);
16782189                  }
r2375r2376
16852196         /* Simple case... 1 sprite */
16862197         DRAWSPRITE(
16872198               code,
1688               (col&0x1f) + palette_basecolor[0],
2199               (col&0x1f),
16892200               colour&0x20,colour&0x40,
16902201               (x+xoffs) & 0x3ff,(y+yoffs) & 0x3ff);
16912202      }
r2375r2376
18022313VIDEO_UPDATE( cps1 )
18032314{
18042315   int layercontrol,l0,l1,l2,l3;
1805   int videocontrol=cps1_port(0x22);
2316   int videocontrol=cps1_port(CPS1_VIDEOCONTROL);
18062317
18072318
18082319   flip_screen_set(videocontrol & 0x8000);
r2375r2376
18182329   {
18192330      cps2_find_last_sprite();
18202331   }
1821   /* Build palette */
1822   cps1_build_palette(screen->machine);
18232332
18242333   cps1_update_transmasks();
18252334
r2375r2376
19252434      cps2_render_sprites(screen->machine,bitmap,cliprect,primasks);
19262435   }
19272436
1928#if CPS1_DUMP_VIDEO
1929   if (input_code_pressed(KEYCODE_F))
1930   {
1931      cps1_dump_video();
1932   }
1933#endif
19342437   return 0;
19352438}
19362439
r2375r2376
19562459   cps2_set_sprite_priorities();
19572460   memcpy(cps2_buffered_obj, cps2_objbase(), cps2_obj_size);
19582461}
1959
src/mame/video/lethalj.c
r2375r2376
4040   int width = visarea->max_x + 1 - visarea->min_x;
4141   int height = visarea->max_y + 1 - visarea->min_y;
4242
43   *x = ((readinputport(2 + player * 2) & 0xff) * width) / 255;
44   *y = ((readinputport(3 + player * 2) & 0xff) * height) / 255;
43   *x = ((input_port_read_indexed(machine, 2 + player * 2) & 0xff) * width) / 255;
44   *y = ((input_port_read_indexed(machine, 3 + player * 2) & 0xff) * height) / 255;
4545}
4646
4747
src/mame/video/itech8.c
r2375r2376
479479
480480   /* a read from offsets 12-15 return input port values */
481481   if (offset >= 12 && offset <= 15)
482      result = readinputport(3 + offset - 12);
482      result = input_port_read_indexed(machine, 3 + offset - 12);
483483
484484   return result;
485485}
src/mame/video/snk.c
r2375r2376
169169   const gfx_element *gfx = machine->gfx[2];
170170
171171   int tile_number, attributes, color, sx, sy;
172   int yflip;
172173   int offs;
173174
174175   for(offs = 0; offs < 50*4; offs+=4)
r2375r2376
176177      if(*(UINT32*)(spriteram+offs) == 0 || *(UINT32*)(spriteram+offs) == -1) continue;
177178
178179      tile_number = spriteram[offs+1];
180      attributes  = spriteram[offs+3]; /* YBFX.CCCC */
181      if(attributes & 0x40) tile_number |= 256;
182
183      color = attributes & 0xf;
184      sx =  xscroll - spriteram[offs+2];
185      if(!(attributes & 0x80)) sx += 256;
186      sy = -yscroll + spriteram[offs];
187      if(attributes & 0x10) sy += 256;
188      sx &= 0x1ff;
189      sy &= 0x1ff;
190      if (sx > 512-16) sx -= 512;
191      if (sy > 512-16) sy -= 512;
192      yflip = attributes & 0x20;
193
194      drawgfx(bitmap,gfx,tile_number,color,0,yflip,sx,sy,cliprect,TRANSPARENCY_PEN_TABLE,7);
195   }
196}
197
198VIDEO_UPDATE( tnk3 )
199{
200   UINT8 *ram = snk_rambase - 0xd000;
201   int attributes = ram[0xc800];
202   /*
203        X-------
204        -X------    character bank (for text layer)
205        --X-----
206        ---X----    scrolly MSB (background)
207        ----X---    scrolly MSB (sprites)
208        -----X--
209        ------X-    scrollx MSB (background)
210        -------X    scrollx MSB (sprites)
211    */
212
213   /* to be moved to memmap */
214   spriteram = &ram[0xd000];
215
216   {
217      int bg_scrollx = -ram[0xcc00] + 15;
218      int bg_scrolly = -ram[0xcb00] + 8;
219      if(attributes & 0x02) bg_scrollx += 256;
220      if(attributes & 0x10) bg_scrolly += 256;
221      tnk3_draw_background(screen->machine, bitmap, cliprect, bg_scrollx, bg_scrolly, 64, 64, 0 );
222   }
223
224   {
225      int sp_scrollx = ram[0xca00] + 29;
226      int sp_scrolly = ram[0xc900] + 9;
227      if(attributes & 0x01) sp_scrollx += 256;
228      if(attributes & 0x08) sp_scrolly += 256;
229      tnk3_draw_sprites(screen->machine, bitmap, cliprect, sp_scrollx, sp_scrolly );
230   }
231
232   {
233      int bank = (attributes & 0x40) ? 1:0;
234
235      tnk3_draw_text(screen->machine, bitmap, cliprect, bank, &ram[0xf800] );
236      tnk3_draw_status(screen->machine, bitmap, cliprect, bank, &ram[0xfc00] );
237   }
238   return 0;
239}
240
241void athena_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int xscroll, int yscroll )
242{
243   const gfx_element *gfx = machine->gfx[2];
244
245   int tile_number, attributes, color, sx, sy;
246   int offs;
247
248   for(offs = 0; offs < 50*4; offs+=4)
249   {
250      if(*(UINT32*)(spriteram+offs) == 0 || *(UINT32*)(spriteram+offs) == -1) continue;
251
252      tile_number = spriteram[offs+1];
179253      attributes  = spriteram[offs+3]; /* YBBX.CCCC */
180254      if(attributes & 0x40) tile_number |= 256;
181255      if(attributes & 0x20) tile_number |= 512;
r2375r2376
194268   }
195269}
196270
197VIDEO_UPDATE( tnk3 )
271/* Same as tnk3 but sprite attribute bit 5 is extra bank bit instead of y-flip. */
272VIDEO_UPDATE( athena )
198273{
199274   UINT8 *ram = snk_rambase - 0xd000;
200275   int attributes = ram[0xc800];
r2375r2376
225300      int sp_scrolly = ram[0xc900] + 9;
226301      if(attributes & 0x01) sp_scrollx += 256;
227302      if(attributes & 0x08) sp_scrolly += 256;
228      tnk3_draw_sprites(screen->machine, bitmap, cliprect, sp_scrollx, sp_scrolly );
303      athena_draw_sprites(screen->machine, bitmap, cliprect, sp_scrollx, sp_scrolly );
229304   }
230305
231306   {
src/mame/video/namconb1.c
r2375r2376
106106 * communication with the sound CPU.
107107 */
108108static void
109handle_mcu( void )
109handle_mcu( running_machine *machine )
110110{
111111   static int toggle;
112112   static UINT16 credits;
r2375r2376
115115   static int old_p2;
116116   static int old_p3;
117117   static int old_p4;
118   int new_coin_state = readinputport(0)&0x3; /* coin1,2 */
119   unsigned dsw = readinputport(1)<<16;
120   unsigned p1 = readinputport(2);
121   unsigned p2 = readinputport(3);
118   int new_coin_state = input_port_read_indexed(machine, 0)&0x3; /* coin1,2 */
119   unsigned dsw = input_port_read_indexed(machine, 1)<<16;
120   unsigned p1 = input_port_read_indexed(machine, 2);
121   unsigned p2 = input_port_read_indexed(machine, 3);
122122   unsigned p3;
123123   unsigned p4;
124124   toggle = !toggle;
125125   if( toggle ) dsw &= ~(0x80<<16);
126126   if( namcos2_gametype == NAMCONB2_MACH_BREAKERS )
127127   {
128      p3 = readinputport(4);
129      p4 = readinputport(5);
128      p3 = input_port_read_indexed(machine, 4);
129      p4 = input_port_read_indexed(machine, 5);
130130   }
131131   else
132132   {
r2375r2376
161161video_update_common(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int bROZ )
162162{
163163   int pri;
164   handle_mcu();
164   handle_mcu(machine);
165165   namconb1_install_palette(machine);
166166
167167   if( bROZ )
src/mame/video/segaic24.c
r2375r2376
128128   SET_TILE_INFO(sys24_char_gfx_index, val & sys24_tile_mask, (val >> 7) & 0xff, 0);
129129}
130130
131static void sys24_tile_dirtyall(void)
131static STATE_POSTLOAD( sys24_tile_dirtyall )
132132{
133133   memset(sys24_char_dirtymap, 1, SYS24_TILES);
134134   sys24_char_dirty = 1;
r2375r2376
170170
171171   state_save_register_global_pointer(sys24_tile_ram, 0x10000/2);
172172   state_save_register_global_pointer(sys24_char_ram, 0x80000/2);
173   state_save_register_func_postload(sys24_tile_dirtyall);
173   state_save_register_postload(machine, sys24_tile_dirtyall, NULL);
174174}
175175
176176void sys24_tile_update(running_machine *machine)
src/mame/video/lazercmd.c
r2375r2376
3232   int xbit, ybit, size;
3333
3434    size = 2;
35   if (input_port_2_r(machine,0) & 0x40)
35   if (input_port_read_indexed(machine, 2) & 0x40)
3636    {
3737      size = 4;
3838    }
r2375r2376
5757{
5858   int i,x,y;
5959
60   int video_inverted = readinputport(2) & 0x20;
60   int video_inverted = input_port_read_indexed(screen->machine, 2) & 0x20;
6161
6262   /* The first row of characters are invisible */
6363   for (i = 0; i < (VERT_RES - 1) * HORZ_RES; i++)
src/mame/video/blockade.c
r2375r2376
88   videoram[offset] = data;
99   tilemap_mark_tile_dirty(bg_tilemap, offset);
1010
11   if (input_port_3_r(machine,0) & 0x80)
11   if (input_port_read_indexed(machine, 3) & 0x80)
1212   {
1313      logerror("blockade_videoram_w: scanline %d\n", video_screen_get_vpos(machine->primary_screen));
1414      cpu_spinuntil_int();
src/mame/video/lordgun.c
r2375r2376
187187   0x1B3,0x1B4,0x1B5,0x1B6,0x1B7,0x1B8,0x1B9,0x1BA,0x1BB,0x1BC,0x1BD,0x1BE,0x1BF,0x1BF
188188};
189189
190static void lorddgun_calc_gun_scr(int i)
190static void lorddgun_calc_gun_scr(running_machine *machine, int i)
191191{
192   int x = readinputport(5+i) - 0x3c;
192   int x = input_port_read_indexed(machine, 5+i) - 0x3c;
193193   if ( (x < 0) || (x > sizeof(lordgun_gun_x_table)/sizeof(lordgun_gun_x_table[0])) )
194194      x = 0;
195195
196196   lordgun_gun[i].scr_x = lordgun_gun_x_table[x];
197   lordgun_gun[i].scr_y = readinputport(7+i);
197   lordgun_gun[i].scr_y = input_port_read_indexed(machine, 7+i);
198198}
199199
200void lordgun_update_gun(int i)
200void lordgun_update_gun(running_machine *machine, int i)
201201{
202   const rectangle *visarea = video_screen_get_visible_area(Machine->primary_screen);
202   const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen);
203203
204   lordgun_gun[i].hw_x = readinputport(5+i);
205   lordgun_gun[i].hw_y = readinputport(7+i);
204   lordgun_gun[i].hw_x = input_port_read_indexed(machine, 5+i);
205   lordgun_gun[i].hw_y = input_port_read_indexed(machine, 7+i);
206206
207   lorddgun_calc_gun_scr(i);
207   lorddgun_calc_gun_scr(machine, i);
208208
209209   if (   (lordgun_gun[i].scr_x < visarea->min_x)   ||
210210         (lordgun_gun[i].scr_x > visarea->max_x)   ||
src/mame/video/toaplan1.c
r2375r2376
317317   tilemap_set_scrolly(pf4_tilemap,0,(pf4_scrolly >> 7) - (tiles_offsety - scrolly_offs));
318318}
319319
320static void rallybik_flipscreen(void)
320static STATE_POSTLOAD( rallybik_flipscreen )
321321{
322322   rallybik_bcu_flipscreen_w(Machine, 0, bcu_flipscreen, 0);
323323}
324324
325static void toaplan1_flipscreen(void)
325static STATE_POSTLOAD( toaplan1_flipscreen )
326326{
327327   toaplan1_bcu_flipscreen_w(Machine, 0, bcu_flipscreen, 0);
328328}
r2375r2376
368368   state_save_register_global(pf_voffs);
369369   state_save_register_global(spriteram_offs);
370370
371   state_save_register_func_postload(rallybik_flipscreen);
371   state_save_register_postload(machine, rallybik_flipscreen, NULL);
372372}
373373
374374VIDEO_START( toaplan1 )
r2375r2376
418418   state_save_register_global(pf_voffs);
419419   state_save_register_global(spriteram_offs);
420420
421   state_save_register_func_postload(toaplan1_flipscreen);
421   state_save_register_postload(machine, toaplan1_flipscreen, NULL);
422422}
423423
424424
src/mame/video/tmnt.c
r2375r2376
239239
240240VIDEO_START( punkshot )
241241{
242   K053251_vh_start();
242   K053251_vh_start(machine);
243243   K052109_vh_start(machine,REGION_GFX1,NORMAL_PLANE_ORDER,tmnt_tile_callback);
244244   K051960_vh_start(machine,REGION_GFX2,NORMAL_PLANE_ORDER,punkshot_sprite_callback);
245245}
246246
247247VIDEO_START( lgtnfght )   /* also tmnt2, ssriders */
248248{
249   K053251_vh_start();
249   K053251_vh_start(machine);
250250   K052109_vh_start(machine,REGION_GFX1,NORMAL_PLANE_ORDER,tmnt_tile_callback);
251251   K053245_vh_start(machine,0, REGION_GFX2,NORMAL_PLANE_ORDER,lgtnfght_sprite_callback);
252252
r2375r2376
262262
263263VIDEO_START( sunsetbl )
264264{
265   K053251_vh_start();
265   K053251_vh_start(machine);
266266   K052109_vh_start(machine,REGION_GFX1,NORMAL_PLANE_ORDER,ssbl_tile_callback);
267267   K053245_vh_start(machine,0, REGION_GFX2,NORMAL_PLANE_ORDER,lgtnfght_sprite_callback);
268268}
269269
270270VIDEO_START( blswhstl )
271271{
272   K053251_vh_start();
272   K053251_vh_start(machine);
273273   K052109_vh_start(machine,REGION_GFX1,NORMAL_PLANE_ORDER,blswhstl_tile_callback);
274274   K053245_vh_start(machine,0, REGION_GFX2,NORMAL_PLANE_ORDER,blswhstl_sprite_callback);
275275}
276276
277277VIDEO_START( glfgreat )
278278{
279   K053251_vh_start();
279   K053251_vh_start(machine);
280280   K052109_vh_start(machine,REGION_GFX1,NORMAL_PLANE_ORDER,tmnt_tile_callback);
281281   K053245_vh_start(machine,0, REGION_GFX2,NORMAL_PLANE_ORDER,lgtnfght_sprite_callback);
282282
r2375r2376
290290
291291VIDEO_START( thndrx2 )
292292{
293   K053251_vh_start();
293   K053251_vh_start(machine);
294294   K052109_vh_start(machine,REGION_GFX1,NORMAL_PLANE_ORDER,tmnt_tile_callback);
295295   K051960_vh_start(machine,REGION_GFX2,NORMAL_PLANE_ORDER,thndrx2_sprite_callback);
296296}
297297
298298VIDEO_START( prmrsocr )
299299{
300   K053251_vh_start();
300   K053251_vh_start(machine);
301301   K052109_vh_start(machine,REGION_GFX1,NORMAL_PLANE_ORDER,tmnt_tile_callback);
302302   K053245_vh_start(machine,0, REGION_GFX2,NORMAL_PLANE_ORDER,prmrsocr_sprite_callback);
303303
src/mame/video/bionicc.c
r2375r2376
9393
9494VIDEO_START( bionicc )
9595{
96   tx_tilemap = tilemap_create(get_tx_tile_info,tilemap_scan_rows,  8,8,32,32);
97   fg_tilemap = tilemap_create(get_fg_tile_info,tilemap_scan_rows,      16,16,64,64);
98   bg_tilemap = tilemap_create(get_bg_tile_info,tilemap_scan_rows,  8,8,64,64);
96   tx_tilemap = tilemap_create(get_tx_tile_info,tilemap_scan_rows, 8, 8,32,32);
97   fg_tilemap = tilemap_create(get_fg_tile_info,tilemap_scan_rows,16,16,64,64);
98   bg_tilemap = tilemap_create(get_bg_tile_info,tilemap_scan_rows, 8, 8,64,64);
9999
100100   tilemap_set_transparent_pen(tx_tilemap,3);
101101   tilemap_set_transmask(fg_tilemap,0,0xffff,0x8000); /* split type 0 is completely transparent in front half */
r2375r2376
219219
220220VIDEO_UPDATE( bionicc )
221221{
222   fillbitmap(bitmap,0,cliprect);
222   fillbitmap(bitmap,get_black_pen(screen->machine),cliprect);
223223   tilemap_draw(bitmap,cliprect,fg_tilemap,1|TILEMAP_DRAW_LAYER1,0);   /* nothing in FRONT */
224224   tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
225225   tilemap_draw(bitmap,cliprect,fg_tilemap,0|TILEMAP_DRAW_LAYER1,0);
src/mame/video/psikyo.c
r2375r2376
434434
435435   tilemap *tmptilemap0, *tmptilemap1;
436436
437   flip_screen_set(~readinputport(2) & 1);   // hardwired to a DSW bit
437   flip_screen_set(~input_port_read_indexed(screen->machine, 2) & 1);   // hardwired to a DSW bit
438438
439439   /* Layers enable (not quite right) */
440440
src/mame/video/darius.c
r2375r2376
3636   actual_get_fg_tile_info(machine, tileinfo, tile_index, darius_fg_ram, 2);
3737}
3838
39static void dirty_fg_tilemap(void)
40{
41   tilemap_mark_all_tiles_dirty(fg_tilemap);
42}
43
4439/***************************************************************************/
4540
4641VIDEO_START( darius )
r2375r2376
5045   spritelist = auto_malloc(0x800 * sizeof(*spritelist));
5146
5247   /* (chips, gfxnum, x_offs, y_offs, y_invert, opaque, dblwidth) */
53   PC080SN_vh_start(1,1,-16,8,0,1,1);
48   PC080SN_vh_start(machine,1,1,-16,8,0,1,1);
5449
5550   tilemap_set_transparent_pen(fg_tilemap,0);
56
57   /* colors from saved states are often screwy (and this doesn't help...) */
58   state_save_register_func_postload(dirty_fg_tilemap);
5951}
6052
6153/***************************************************************************/
src/mame/video/st0016.c
r2375r2376
418418   }
419419}
420420
421static void st0016_postload(void)
421static STATE_POSTLOAD( st0016_postload )
422422{
423423   int i;
424424   st0016_rom_bank_w(Machine,0,st0016_rom_bank);
r2375r2376
427427}
428428
429429
430void st0016_save_init(void)
430void st0016_save_init(running_machine *machine)
431431{
432432   state_save_register_global(st0016_spr_bank);
433433   state_save_register_global(st0016_spr2_bank);
r2375r2376
438438   state_save_register_global_pointer(st0016_charram, ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE);
439439   state_save_register_global_pointer(st0016_paletteram, ST0016_MAX_PAL_BANK*ST0016_PAL_BANK_SIZE);
440440   state_save_register_global_pointer(st0016_spriteram, ST0016_MAX_SPR_BANK*ST0016_SPR_BANK_SIZE);
441   state_save_register_func_postload(st0016_postload);
441   state_save_register_postload(machine, st0016_postload, NULL);
442442}
443443
444444
r2375r2376
499499
500500   }
501501
502   st0016_save_init();
502   st0016_save_init(machine);
503503}
504504
505505
r2375r2376
670670   {
671671      if(ISMACS1)
672672      {
673         if(!(readinputportbytag("SYS1")&1))   //fake coins - MACS2 system
673         if(!(input_port_read(screen->machine, "SYS1")&1))   //fake coins - MACS2 system
674674         {
675675            macs_ram2[0]++;
676676         }
src/mame/video/xexex.c
r2375r2376
4040
4141   cur_alpha = 0;
4242
43   K053251_vh_start();
43   K053251_vh_start(machine);
4444   K054338_vh_start();
4545   K053250_vh_start(1, &region);
4646
src/mame/video/snes.c
r2375r2376
14431443             * Stop drawing if exceeded 32 objects and
14441444             * enforcing that limit is enabled */
14451445         range_over++;
1446         if( range_over == 32 ) //&& (readinputport( 16 ) & 0x10) )
1446         if( range_over == 32 ) //&& (input_port_read_indexed(machine, 16 ) & 0x10) )
14471447         {
14481448            /* Set the flag in STAT77 register */
14491449            snes_ram[STAT77] |= 0x40;
r2375r2376
19841984
19851985      if( !debug_options.input_count-- )
19861986      {
1987         UINT8 toggles = readinputport( 10 );
1987         UINT8 toggles = input_port_read_indexed(machine, 10 );
19881988         if( toggles & 0x1 )
19891989            debug_options.bg_disabled[0] = !debug_options.bg_disabled[0];
19901990         if( toggles & 0x2 )
r2375r2376
20012001            debug_options.bg_disabled[5] = !debug_options.bg_disabled[5];
20022002         if( toggles & 0x80 )
20032003            debug_options.windows_disabled = !debug_options.windows_disabled;
2004         toggles = readinputport( 11 );
2004         toggles = input_port_read_indexed(machine, 11 );
20052005         if( toggles & 0x4 )
20062006            debug_options.transparency_disabled = !debug_options.transparency_disabled;
20072007         debug_options.input_count = 5;
r2375r2376
21112111   }
21122112   /* Just for testing, draw as many tiles as possible */
21132113   {
2114      UINT8 adjust = readinputport( 1 );
2115      UINT8 dip = readinputport( 9 );
2116      UINT8 inp = readinputport( 11 );
2114      UINT8 adjust = input_port_read_indexed(machine,  1 );
2115      UINT8 dip = input_port_read_indexed(machine,  9 );
2116      UINT8 inp = input_port_read_indexed(machine,  11 );
21172117      UINT8 dt = 1 << ((dip & 0x3) - 1);
21182118      UINT8 dm = 1 << (((dip & 0xc) >> 2) - 1);
21192119      if( dt )
src/mame/video/cinemat.c
r2375r2376
243243
244244VIDEO_UPDATE( spacewar )
245245{
246   int sw_option = readinputportbytag("INPUTS");
246   int sw_option = input_port_read(screen->machine, "INPUTS");
247247
248248   VIDEO_UPDATE_CALL(cinemat);
249249
src/mame/video/cischeat.c
r2375r2376
183183
184184    and allows the shift to be handled using two buttons */
185185
186static int read_shift(void)
186static int read_shift(running_machine *machine)
187187{
188188   static int ret = 1; /* start with low shift */
189   switch ( (readinputport(0) >> 2) & 3 )
189   switch ( (input_port_read_indexed(machine, 0) >> 2) & 3 )
190190   {
191191      case 1 : ret = 1;   break;   // low  shift: button 3
192192      case 2 : ret = 0;   break;   // high shift: button 4
r2375r2376
204204    We support just 2 values for now..
205205*/
206206
207static int read_accelerator(void)
207static int read_accelerator(running_machine *machine)
208208{
209   if (readinputport(0) & 1)   return 0x00;   // pedal pressed
209   if (input_port_read_indexed(machine, 0) & 1)   return 0x00;   // pedal pressed
210210   else                  return 0xff;
211211}
212212
r2375r2376
219219{
220220   switch (offset)
221221   {
222      case 0x0000/2 : return readinputport(1);   // Coins
223      case 0x0002/2 : return readinputport(2) +
224                  (read_shift()<<1);         // Buttons
225      case 0x0004/2 : return readinputport(3);   // Motor Limit Switches
226      case 0x0006/2 : return readinputport(4);   // DSW 1 & 2
222      case 0x0000/2 : return input_port_read_indexed(machine, 1);   // Coins
223      case 0x0002/2 : return input_port_read_indexed(machine, 2) +
224                  (read_shift(machine)<<1);         // Buttons
225      case 0x0004/2 : return input_port_read_indexed(machine, 3);   // Motor Limit Switches
226      case 0x0006/2 : return input_port_read_indexed(machine, 4);   // DSW 1 & 2
227227
228228      case 0x0008/2 :   return soundlatch2_word_r(machine,0,0);   // From sound cpu
229229
230230      case 0x0010/2 :
231231         switch (cischeat_ip_select & 0x3)
232232         {
233            case 0 : return readinputport(6);      // Driving Wheel
233            case 0 : return input_port_read_indexed(machine, 6);      // Driving Wheel
234234            case 1 : return 0xffff;               // Cockpit: Up / Down Position
235235            case 2 : return 0xffff;               // Cockpit: Left / Right Position?
236            case 3 : return ~read_accelerator();   // Accelerator (Pedal)
236            case 3 : return ~read_accelerator(machine);   // Accelerator (Pedal)
237237            default: return 0xffff;
238238         }
239239
240240
241      case 0x2200/2 : return readinputport(5);   // DSW 3 (4 bits)
241      case 0x2200/2 : return input_port_read_indexed(machine, 5);   // DSW 3 (4 bits)
242242
243243      default:   SHOW_READ_ERROR("vreg %04X read!",offset*2);
244244               return megasys1_vregs[offset];
r2375r2376
316316{
317317   switch (offset)
318318   {
319      case 0x0000/2 : return readinputport(1);   // Coins
320      case 0x0002/2 : return readinputport(2) +
321                  (read_shift()<<1);         // Buttons
322      case 0x0004/2 : return readinputport(3);   // Motor Limit Switches
323      case 0x0006/2 : return readinputport(4);   // DSW 1 & 2
319      case 0x0000/2 : return input_port_read_indexed(machine, 1);   // Coins
320      case 0x0002/2 : return input_port_read_indexed(machine, 2) +
321                  (read_shift(machine)<<1);         // Buttons
322      case 0x0004/2 : return input_port_read_indexed(machine, 3);   // Motor Limit Switches
323      case 0x0006/2 : return input_port_read_indexed(machine, 4);   // DSW 1 & 2
324324
325325      case 0x0010/2 :
326326         switch (cischeat_ip_select & 0x3)
327327         {
328            case 0 : return readinputport(6);   // Driving Wheel
328            case 0 : return input_port_read_indexed(machine, 6);   // Driving Wheel
329329            case 1 : return ~0;               // Cockpit: Up / Down Position?
330330            case 2 : return ~0;               // Cockpit: Left / Right Position?
331331            default: return ~0;
332332         }
333333
334      case 0x2200/2 : return readinputport(5);   // DSW 3 (4 bits)
334      case 0x2200/2 : return input_port_read_indexed(machine, 5);   // DSW 3 (4 bits)
335335      case 0x2300/2 : return soundlatch2_r(machine,0);   // From sound cpu
336336
337337      default:   SHOW_READ_ERROR("vreg %04X read!",offset*2);
r2375r2376
412412   {
413413      case 0x0000/2 :   // DSW 1&2: coinage changes with Country
414414      {
415         int val = readinputport(1);
416         if (val & 0x0200)   return readinputport(6) | val;    // JP, US
417         else            return readinputport(7) | val;    // UK, FR
415         int val = input_port_read_indexed(machine, 1);
416         if (val & 0x0200)   return input_port_read_indexed(machine, 6) | val;    // JP, US
417         else            return input_port_read_indexed(machine, 7) | val;    // UK, FR
418418      }
419419
420420//      case 0x0002/2 : return 0xFFFF;
421      case 0x0004/2 :   return readinputport(2) +
422                         (read_shift()<<5);   // Buttons
421      case 0x0004/2 :   return input_port_read_indexed(machine, 2) +
422                         (read_shift(machine)<<5);   // Buttons
423423
424      case 0x0006/2 :   return readinputport(3);   // ? Read at boot only
424      case 0x0006/2 :   return input_port_read_indexed(machine, 3);   // ? Read at boot only
425425      case 0x0008/2 :   return soundlatch2_r(machine,0);   // From sound cpu
426426
427      case 0x000c/2 :   return readinputport(4);   // DSW 3
427      case 0x000c/2 :   return input_port_read_indexed(machine, 4);   // DSW 3
428428
429429      case 0x0010/2 :   // Accel + Driving Wheel
430         return (read_accelerator()&0xff) + ((readinputport(5)&0xff)<<8);
430         return (read_accelerator(machine)&0xff) + ((input_port_read_indexed(machine, 5)&0xff)<<8);
431431
432432      default:      SHOW_READ_ERROR("vreg %04X read!",offset*2);
433433                  return megasys1_vregs[offset];
r2375r2376
460460
461461   switch (offset)
462462   {
463      case 0x0000/2 :   return readinputport(0); // DSW 1 & 2
463      case 0x0000/2 :   return input_port_read_indexed(machine, 0); // DSW 1 & 2
464464
465      case 0x0004/2 :   return readinputport(1); // Buttons
465      case 0x0004/2 :   return input_port_read_indexed(machine, 1); // Buttons
466466
467467      case 0x0008/2 :   return soundlatch2_r(machine,0); // From sound cpu
468468
469469      case 0x0010/2 :   // X, Y
470         return readinputport(2) | (readinputport(3)<<8);
470         return input_port_read_indexed(machine, 2) | (input_port_read_indexed(machine, 3)<<8);
471471
472472      case 0x0018/2 :
473473         return (f1gpstr2_ioready[0]&1) ? 0xff : 0xf0;
src/mame/video/vicdual.c
r2375r2376
141141
142142VIDEO_UPDATE( vicdual_bw_or_color )
143143{
144   if (vicdual_is_cabinet_color())
144   if (vicdual_is_cabinet_color(screen->machine))
145145      VIDEO_UPDATE_CALL(vicdual_color);
146146   else
147147      VIDEO_UPDATE_CALL(vicdual_bw);
src/mame/video/centiped.c
r2375r2376
103103   bg_tilemap = tilemap_create(warlords_get_tile_info, tilemap_scan_rows,  8,8, 32,32);
104104
105105   /* we overload centiped_flipscreen here to track the cocktail/upright state */
106   centiped_flipscreen = readinputport(0) & 0x80;
106   centiped_flipscreen = input_port_read_indexed(machine, 0) & 0x80;
107107   tilemap_set_flip(bg_tilemap, centiped_flipscreen ? TILEMAP_FLIPX : 0);
108108}
109109
r2375r2376
443443
444444VIDEO_UPDATE( warlords )
445445{
446   int upright_mode = readinputport(0) & 0x80;
446   int upright_mode = input_port_read_indexed(screen->machine, 0) & 0x80;
447447   int offs;
448448
449449   /* if the cocktail/upright switch flipped, force refresh */
src/mame/video/wgp.c
r2375r2376
4646   common_get_piv_tile_info(machine,tileinfo,tile_index,2);
4747}
4848
49static void dirty_piv_tilemaps(void)
50{
51   tilemap_mark_all_tiles_dirty(wgp_piv_tilemap[0]);
52   tilemap_mark_all_tiles_dirty(wgp_piv_tilemap[1]);
53   tilemap_mark_all_tiles_dirty(wgp_piv_tilemap[2]);
54}
5549
56
5750static void wgp_core_vh_start(running_machine *machine, int x_offs,int y_offs,int piv_xoffs,int piv_yoffs)
5851{
5952   wgp_piv_tilemap[0] = tilemap_create(get_piv0_tile_info,tilemap_scan_rows,16,16,64,64);
r2375r2376
6356   TC0100SCN_vh_start(machine,1,TC0100SCN_GFX_NUM,x_offs,y_offs,0,0,0,0,0);
6457
6558   if (has_TC0110PCR())
66      TC0110PCR_vh_start();
59      TC0110PCR_vh_start(machine);
6760
6861   wgp_piv_xoffs = piv_xoffs;
6962   wgp_piv_yoffs = piv_yoffs;
r2375r2376
8477       applies rowscroll manually */
8578
8679   TC0100SCN_set_colbanks(0x80,0xc0,0x40);
87
88   /* colors from saved states are often screwy (and this doesn't help...) */
89   state_save_register_func_postload(dirty_piv_tilemaps);
9080}
9181
9282VIDEO_START( wgp )
src/mame/video/tceptor.c
r2375r2376
395395   free(dst);
396396}
397397
398static void mark_all_tiles_dirty(void)
399{
400   tilemap_mark_all_tiles_dirty(tx_tilemap);
401   tilemap_mark_all_tiles_dirty(bg1_tilemap);
402   tilemap_mark_all_tiles_dirty(bg2_tilemap);
403}
404
405398VIDEO_START( tceptor )
406399{
407400   int gfx_index;
r2375r2376
445438   state_save_register_global(bg1_scroll_y);
446439   state_save_register_global(bg2_scroll_x);
447440   state_save_register_global(bg2_scroll_y);
448
449   state_save_register_func_postload(mark_all_tiles_dirty);
450441}
451442
452443
src/mame/video/surpratk.c
r2375r2376
4444
4545VIDEO_START( surpratk )
4646{
47   K053251_vh_start();
47   K053251_vh_start(machine);
4848
4949   K052109_vh_start(machine,REGION_GFX1,NORMAL_PLANE_ORDER,tile_callback);
5050   K053245_vh_start(machine,0,REGION_GFX2,NORMAL_PLANE_ORDER,sprite_callback);
src/mame/video/gtia.c
r2375r2376
2929#define VERBOSE         0
3030
3131static void gtia_reset(running_machine *machine);
32static void gtia_state(void);
33static void gtia_state_postload(void);
32static void gtia_state(running_machine *machine);
33static STATE_POSTLOAD( gtia_state_postload );
3434
3535/**********************************************
3636 * split a color into hue and luminance values
r2375r2376
6464 *
6565 *************************************/
6666
67void gtia_init(const gtia_interface *intf)
67void gtia_init(running_machine *machine, const gtia_interface *intf)
6868{
6969   memset(&gtia, 0, sizeof(gtia));
7070   gtia.intf = *intf;
r2375r2376
7272   add_reset_callback(Machine, gtia_reset);
7373
7474   /* state saves */
75   gtia_state();
75   gtia_state(machine);
7676}
7777
7878
7979
80static void gtia_state(void)
80static void gtia_state(running_machine *machine)
8181{
8282   state_save_register_global(gtia.r.m0pf);
8383   state_save_register_global(gtia.r.m1pf);
r2375r2376
140140   state_save_register_global(gtia.w.gractl);
141141   state_save_register_global(gtia.w.hitclr);
142142   state_save_register_global(gtia.w.cons);
143   state_save_register_func_postload(gtia_state_postload);
143   state_save_register_postload(machine, gtia_state_postload, NULL);
144144}
145145
146146
r2375r2376
758758
759759
760760
761static void gtia_state_postload(void)
761static STATE_POSTLOAD( gtia_state_postload )
762762{
763763   recalc_p0();
764764   recalc_p1();
src/mame/video/gtia.h
r2375r2376
138138
139139extern gtia_struct gtia;
140140
141void gtia_init(const gtia_interface *intf);
141void gtia_init(running_machine *machine, const gtia_interface *intf);
142142READ8_HANDLER( atari_gtia_r );
143143WRITE8_HANDLER( atari_gtia_w );
144144
src/mame/video/m52.c
r2375r2376
279279WRITE8_HANDLER( m52_flipscreen_w )
280280{
281281   /* screen flip is handled both by software and hardware */
282   flip_screen_set((data & 0x01) ^ (~readinputportbytag("DSW2") & 0x01));
282   flip_screen_set((data & 0x01) ^ (~input_port_read(machine, "DSW2") & 0x01));
283283
284284   coin_counter_w(0, data & 0x02);
285285   coin_counter_w(1, data & 0x20);
src/mame/video/warpwarp.c
r2375r2376
242242{
243243   /* use an overlay only in upright mode */
244244   if (geebee_handleoverlay)
245      output_set_value("overlay", (readinputport(2) & 0x01) == 0);
245      output_set_value("overlay", (input_port_read_indexed(screen->machine, 2) & 0x01) == 0);
246246
247247   tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
248248
src/mame/video/jaguar.c
r2375r2376
241241
242242   int width = visarea->max_x + 1 - visarea->min_x;
243243   int height = visarea->max_y + 1 - visarea->min_y;
244   *x = visarea->min_x + (((readinputport(3 + player * 2) & 0xff) * width) >> 8);
245   *y = visarea->min_y + (((readinputport(4 + player * 2) & 0xff) * height) >> 8);
244   *x = visarea->min_x + (((input_port_read_indexed(machine, 3 + player * 2) & 0xff) * width) >> 8);
245   *y = visarea->min_y + (((input_port_read_indexed(machine, 4 + player * 2) & 0xff) * height) >> 8);
246246}
247247
248248
r2375r2376
741741         return (beamy << 16) | (beamx ^ 0x1ff);
742742
743743      case 2:
744         return readinputport(7) << 16;
744         return input_port_read_indexed(machine, 7) << 16;
745745   }
746746   return 0;
747747}
r2375r2376
802802   } while (!adjust_object_timer(machine, vc));
803803}
804804
805static STATE_POSTLOAD( cojag_postload )
806{
807   update_cpu_irq();
808}
805809
806810VIDEO_START( cojag )
807811{
r2375r2376
818822   state_save_register_global_array(blitter_regs);
819823   state_save_register_global_array(gpu_regs);
820824   state_save_register_global(cpu_irq_state);
821   state_save_register_func_postload(update_cpu_irq);
825   state_save_register_postload(machine, cojag_postload, NULL);
822826}
823827
824828
src/mame/video/n8080.c
r2375r2376
269269
270270VIDEO_UPDATE( helifire )
271271{
272   int SUN_BRIGHTNESS = readinputport(4);
273   int SEA_BRIGHTNESS = readinputport(5);
272   int SUN_BRIGHTNESS = input_port_read_indexed(screen->machine, 4);
273   int SEA_BRIGHTNESS = input_port_read_indexed(screen->machine, 5);
274274
275275   static const int wave[8] = { 0, 1, 2, 2, 2, 1, 0, 0 };
276276
src/mame/video/turbo.c
r2375r2376
274274 *
275275 *************************************/
276276
277static void turbo_prepare_sprites(turbo_state *state, UINT8 y, sprite_info *info)
277static void turbo_prepare_sprites(running_machine *machine, turbo_state *state, UINT8 y, sprite_info *info)
278278{
279279   const UINT8 *pr1119 = memory_region(REGION_PROMS) + 0x200;
280280   int sprnum;
r2375r2376
334334                    VR1 = 310 Ohm
335335                    VR2 = 910 Ohm
336336            */
337         info->step[level] = sprite_xscale(xscale, 1.0e3 * readinputportbytag("VR1") / 100.0, 1.0e3 * readinputportbytag("VR2") / 100.0, 100e-12);
337         info->step[level] = sprite_xscale(xscale, 1.0e3 * input_port_read(machine, "VR1") / 100.0, 1.0e3 * input_port_read(machine, "VR2") / 100.0, 100e-12);
338338      }
339339   }
340340}
r2375r2376
428428
429429      /* compute the sprite information; we use y-1 since this info was computed during HBLANK */
430430      /* on the previous scanline */
431      turbo_prepare_sprites(state, y, &sprinfo);
431      turbo_prepare_sprites(screen->machine, state, y, &sprinfo);
432432
433433      /* loop over columns */
434434      for (x = 0; x <= cliprect->max_x; x += TURBO_X_SCALE)
src/mame/video/warriorb.c
r2375r2376
1616   TC0100SCN_vh_start(machine,chips,TC0100SCN_GFX_NUM,x_offs,0,0,0,0,0,multiscrn_xoffs);
1717
1818   if (has_TC0110PCR())
19      TC0110PCR_vh_start();
19      TC0110PCR_vh_start(machine);
2020
2121   if (has_second_TC0110PCR())
22      TC0110PCR_1_vh_start();
22      TC0110PCR_1_vh_start(machine);
2323
2424   /* Ensure palette from correct TC0110PCR used for each screen */
2525   TC0100SCN_set_chip_colbanks(0,0x100,0x0);
src/mame/video/m62.c
r2375r2376
295295WRITE8_HANDLER( m62_flipscreen_w )
296296{
297297   /* screen flip is handled both by software and hardware */
298   data ^= ~readinputport(4) & 1;
298   data ^= ~input_port_read_indexed(machine, 4) & 1;
299299
300300   flipscreen = data & 0x01;
301301   if (flipscreen)
src/mame/video/astrocde.c
r2375r2376
532532         break;
533533
534534      case 0x10:   /* player 1 handle */
535         result = readinputportbytag_safe("P1HANDLE", 0xff);
535         result = input_port_read_safe(machine, "P1HANDLE", 0xff);
536536         break;
537537
538538      case 0x11:   /* player 2 handle */
539         result = readinputportbytag_safe("P2HANDLE", 0xff);
539         result = input_port_read_safe(machine, "P2HANDLE", 0xff);
540540         break;
541541
542542      case 0x12:   /* player 3 handle */
543         result = readinputportbytag_safe("P3HANDLE", 0xff);
543         result = input_port_read_safe(machine, "P3HANDLE", 0xff);
544544         break;
545545
546546      case 0x13:   /* player 4 handle */
547         result = readinputportbytag_safe("P4HANDLE", 0xff);
547         result = input_port_read_safe(machine, "P4HANDLE", 0xff);
548548         break;
549549
550550      case 0x14:   /* keypad column 0 */
551         result = readinputportbytag_safe("KEYPAD0", 0xff);
551         result = input_port_read_safe(machine, "KEYPAD0", 0xff);
552552         break;
553553
554554      case 0x15:   /* keypad column 1 */
555         result = readinputportbytag_safe("KEYPAD1", 0xff);
555         result = input_port_read_safe(machine, "KEYPAD1", 0xff);
556556         break;
557557
558558      case 0x16:   /* keypad column 2 */
559         result = readinputportbytag_safe("KEYPAD2", 0xff);
559         result = input_port_read_safe(machine, "KEYPAD2", 0xff);
560560         break;
561561
562562      case 0x17:   /* keypad column 3 */
563         result = readinputportbytag_safe("KEYPAD3", 0xff);
563         result = input_port_read_safe(machine, "KEYPAD3", 0xff);
564564         break;
565565
566566      case 0x1c:   /* player 1 knob */
567         result = readinputportbytag_safe("P1_KNOB", 0xff);
567         result = input_port_read_safe(machine, "P1_KNOB", 0xff);
568568         break;
569569
570570      case 0x1d:   /* player 2 knob */
571         result = readinputportbytag_safe("P2_KNOB", 0xff);
571         result = input_port_read_safe(machine, "P2_KNOB", 0xff);
572572         break;
573573
574574      case 0x1e:   /* player 3 knob */
575         result = readinputportbytag_safe("P3_KNOB", 0xff);
575         result = input_port_read_safe(machine, "P3_KNOB", 0xff);
576576         break;
577577
578578      case 0x1f:   /* player 4 knob */
579         result = readinputportbytag_safe("P4_KNOB", 0xff);
579         result = input_port_read_safe(machine, "P4_KNOB", 0xff);
580580         break;
581581   }
582582
r2375r2376
727727   /* OR/XOR */
728728   if (funcgen_control & 0x30)
729729   {
730      UINT8 olddata = program_read_byte_8(0x4000 + offset);
730      UINT8 olddata = program_read_byte(0x4000 + offset);
731731
732732      /* compute any intercepts */
733733      funcgen_intercept &= 0x0f;
r2375r2376
748748   }
749749
750750   /* write the result */
751   program_write_byte_8(0x4000 + offset, data);
751   program_write_byte(0x4000 + offset, data);
752752}
753753
754754
r2375r2376
842842         if (curwidth == 0 && (pattern_mode & 0x08) != 0)
843843            busdata = 0;
844844         else
845            busdata = program_read_byte_8(busaddr);
845            busdata = program_read_byte(busaddr);
846846
847847         /* increment the appropriate address */
848848         if ((pattern_mode & 0x01) == 0)
r2375r2376
854854
855855         /* address is selected between source/dest based on mode.d0 */
856856         busaddr = ((pattern_mode & 0x01) != 0) ? pattern_source : pattern_dest;
857         program_write_byte_8(busaddr, busdata);
857         program_write_byte(busaddr, busdata);
858858
859859         /* increment the appropriate address */
860860         if ((pattern_mode & 0x01) == 0)
src/mame/video/renegade.c
r2375r2376
6262      0);
6363}
6464
65static void all_tiles_dirty(void)
66{
67   tilemap_mark_all_tiles_dirty(bg_tilemap);
68   tilemap_mark_all_tiles_dirty(fg_tilemap);
69}
70
7165VIDEO_START( renegade )
7266{
7367   bg_tilemap = tilemap_create(get_bg_tilemap_info, tilemap_scan_rows,      16, 16, 64, 16);
r2375r2376
7771   tilemap_set_scrolldx(bg_tilemap, 256, 0);
7872
7973   state_save_register_global(renegade_scrollx);
80   state_save_register_func_postload(all_tiles_dirty);
8174}
8275
8376static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
src/mame/video/psychic5.c
r2375r2376
171171         switch(offset)
172172         {
173173            case 0x00:
174               val = input_port_0_r(machine,0);
174               val = input_port_read_indexed(machine, 0);
175175               break;
176176            case 0x01:
177               val = input_port_1_r(machine,0);
177               val = input_port_read_indexed(machine, 1);
178178               break;
179179            case 0x02:
180               val = input_port_2_r(machine,0);
180               val = input_port_read_indexed(machine, 2);
181181               break;
182182            case 0x03:
183               val = input_port_3_r(machine,0);
183               val = input_port_read_indexed(machine, 3);
184184               break;
185185            case 0x04:
186               val = input_port_4_r(machine,0);
186               val = input_port_read_indexed(machine, 4);
187187               break;
188188            default:
189189               val = ps5_io_ram[offset];
src/mame/video/othunder.c
r2375r2376
2929   TC0100SCN_vh_start(machine,1,TC0100SCN_GFX_NUM,4,0,0,0,0,0,0);
3030
3131   if (has_TC0110PCR())
32      TC0110PCR_vh_start();
32      TC0110PCR_vh_start(machine);
3333}
3434
3535
src/mame/video/8080bw.c
r2375r2376
2424
2525
2626
27void c8080bw_flip_screen_w(int data)
27void c8080bw_flip_screen_w(running_machine *machine, int data)
2828{
2929   color_map = data;
30   c8080bw_flip_screen = data && (readinputportbytag(CABINET_PORT_TAG) & 0x01);
30   c8080bw_flip_screen = data && (input_port_read(machine, CABINET_PORT_TAG) & 0x01);
3131}
3232
3333
src/mame/video/taitosj.c
r2375r2376
154154}
155155
156156
157static void taitosj_postload(void)
157static STATE_POSTLOAD( taitosj_postload )
158158{
159159   memset(dirtycharacter1, 1, sizeof(dirtycharacter1));
160160   memset(dirtycharacter2, 1, sizeof(dirtycharacter2));
r2375r2376
221221
222222   compute_draw_order();
223223
224   state_save_register_func_postload(taitosj_postload);
224   state_save_register_postload(machine, taitosj_postload, NULL);
225225}
226226
227227
src/mame/video/canyon.c
r2375r2376
9191   draw_bombs(bitmap, cliprect);
9292
9393   /* watchdog is disabled during service mode */
94   watchdog_enable(screen->machine, !(readinputport(2) & 0x10));
94   watchdog_enable(screen->machine, !(input_port_read_indexed(screen->machine, 2) & 0x10));
9595
9696   return 0;
9797}
src/mame/video/exidy440.c
r2375r2376
446446   {
447447      int i;
448448
449      int beamx = ((readinputport(4) & 0xff) * (HBSTART - HBEND)) >> 8;
450      int beamy = ((readinputport(5) & 0xff) * (VBSTART - VBEND)) >> 8;
449      int beamx = ((input_port_read_indexed(screen->machine, 4) & 0xff) * (HBSTART - HBEND)) >> 8;
450      int beamy = ((input_port_read_indexed(screen->machine, 5) & 0xff) * (VBSTART - VBEND)) >> 8;
451451
452452      /* The timing of this FIRQ is very important. The games look for an FIRQ
453453            and then wait about 650 cycles, clear the old FIRQ, and wait a
src/mame/video/konamiic.c
r2375r2376
19691969static TILE_GET_INFO( K052109_get_tile_info2 ) { K052109_get_tile_info(machine,tileinfo,tile_index,2,K052109_colorram_B,K052109_videoram_B,K052109_videoram2_B); }
19701970
19711971
1972static void K052109_tileflip_reset(void)
1972static STATE_POSTLOAD( K052109_tileflip_reset )
19731973{
19741974   int data = K052109_ram[0x1e80];
19751975   tilemap_set_flip(K052109_tilemap[0],(data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
r2375r2376
20792079   state_save_register_global_array(K052109_dy);
20802080   state_save_register_global(has_extra_video_ram);
20812081
2082   state_save_register_func_postload(K052109_tileflip_reset);
2082   state_save_register_postload(machine, K052109_tileflip_reset, NULL);
20832083}
20842084
20852085READ8_HANDLER( K052109_r )
r2375r2376
50775077static tilemap *K053251_tilemaps[5];
50785078static int K053251_tilemaps_set;
50795079
5080static void K053251_reset_indexes(void)
5080static STATE_POSTLOAD( K053251_reset_indexes )
50815081{
50825082   K053251_palette_index[0] = 32 * ((K053251_ram[9] >> 0) & 0x03);
50835083   K053251_palette_index[1] = 32 * ((K053251_ram[9] >> 2) & 0x03);
r2375r2376
50865086   K053251_palette_index[4] = 16 * ((K053251_ram[10] >> 3) & 0x07);
50875087}
50885088
5089void K053251_vh_start(void)
5089void K053251_vh_start(running_machine *machine)
50905090{
50915091   K053251_set_tilemaps(NULL,NULL,NULL,NULL,NULL);
50925092
50935093   state_save_register_global_array(K053251_ram);
5094   state_save_register_func_postload(K053251_reset_indexes);
5094   state_save_register_postload(machine, K053251_reset_indexes, NULL);
50955095}
50965096
50975097void K053251_set_tilemaps(tilemap *ci0,tilemap *ci1,tilemap *ci2,tilemap *ci3,tilemap *ci4)
r2375r2376
56155615   K056832_change_rombank();
56165616}
56175617
5618static STATE_POSTLOAD( K056832_postload )
5619{
5620   K056832_UpdatePageLayout();
5621   K056832_change_rambank();
5622   K056832_change_rombank();
5623}
5624
56185625void K056832_vh_start(running_machine *machine, int gfx_memory_region, int bpp, int big,
56195626   int (*scrolld)[4][2],
56205627   void (*callback)(int layer, int *code, int *color, int *flags),
r2375r2376
58255832   state_save_register_global_array(K056832_dy);
58265833   state_save_register_global_array(K056832_LayerTileMode);
58275834
5828   state_save_register_func_postload(K056832_UpdatePageLayout);
5829   state_save_register_func_postload(K056832_change_rambank);
5830   state_save_register_func_postload(K056832_change_rombank);
5835   state_save_register_postload(machine, K056832_postload, NULL);
58315836}
58325837
58335838/* call if a game uses external linescroll */
src/mame/video/konamiic.h
r2375r2376
241241int K053251_get_priority(int ci);
242242int K053251_get_palette_index(int ci);
243243void K053251_set_tilemaps(tilemap *ci0,tilemap *ci1,tilemap *ci2,tilemap *ci3,tilemap *ci4);
244void K053251_vh_start(void);
244void K053251_vh_start(running_machine *machine);
245245
246246
247247WRITE8_HANDLER( K054000_w );
src/mame/video/m72.c
r2375r2376
346346      coin_counter_w(1,data & 0x02);
347347
348348      /* bit 2 is flip screen (handled both by software and hardware) */
349      flip_screen_set(((data & 0x04) >> 2) ^ ((~readinputport(2) >> 8) & 1));
349      flip_screen_set(((data & 0x04) >> 2) ^ ((~input_port_read_indexed(machine, 2) >> 8) & 1));
350350
351351      /* bit 3 is display disable */
352352      video_off = data & 0x08;
r2375r2376
372372      coin_counter_w(1,data & 0x02);
373373
374374      /* bit 2 is flip screen (handled both by software and hardware) */
375      flip_screen_set(((data & 0x04) >> 2) ^ ((~readinputport(2) >> 8) & 1));
375      flip_screen_set(((data & 0x04) >> 2) ^ ((~input_port_read_indexed(machine, 2) >> 8) & 1));
376376
377377      /* bit 3 is display disable */
378378      video_off = data & 0x08;
src/mame/video/madalien.c
r2375r2376
253253
254254static VIDEO_UPDATE( madalien )
255255{
256   int flip = BIT(readinputportbytag("DIP"), 6) && BIT(*madalien_video_control, 0);
256   int flip = BIT(input_port_read(screen->machine, "DIP"), 6) && BIT(*madalien_video_control, 0);
257257
258258   // bits #0 and #1 define scrolling mode
259259   //
src/mame/video/aeroboto.c
r2375r2376
7575
7676READ8_HANDLER( aeroboto_in0_r )
7777{
78   return readinputport(flip_screen_get() ? 1 : 0);
78   return input_port_read_indexed(machine, flip_screen_get() ? 1 : 0);
7979}
8080
8181WRITE8_HANDLER( aeroboto_3000_w )
src/mame/video/oneshot.c
r2375r2376
7676   tilemap_set_transparent_pen(oneshot_fg_tilemap,0);
7777}
7878
79static void draw_crosshairs( bitmap_t *bitmap, const rectangle *cliprect )
79static void draw_crosshairs( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
8080{
8181    int xpos,ypos;
8282    /* get gun raw coordonates (player 1) */
83    gun_x_p1 = (readinputport(5) & 0xff) * 320 / 256;
84    gun_y_p1 = (readinputport(6) & 0xff) * 240 / 256;
83    gun_x_p1 = (input_port_read_indexed(machine, 5) & 0xff) * 320 / 256;
84    gun_y_p1 = (input_port_read_indexed(machine, 6) & 0xff) * 240 / 256;
8585
8686    /* compute the coordonates for drawing (from routine at 0x009ab0) */
8787    xpos = gun_x_p1;
r2375r2376
9595
9696
9797    /* get gun raw coordonates (player 2) */
98    gun_x_p2 = (readinputport(7) & 0xff) * 320 / 256;
99    gun_y_p2 = (readinputport(8) & 0xff) * 240 / 256;
98    gun_x_p2 = (input_port_read_indexed(machine, 7) & 0xff) * 320 / 256;
99    gun_y_p2 = (input_port_read_indexed(machine, 8) & 0xff) * 240 / 256;
100100    /* compute the coordonates for drawing (from routine at 0x009b6e) */
101101    xpos = gun_x_p2;
102102    ypos = gun_y_p2;
r2375r2376
177177   tilemap_draw(bitmap,cliprect,oneshot_mid_tilemap,0,0);
178178   draw_sprites(screen->machine,bitmap,cliprect);
179179   tilemap_draw(bitmap,cliprect,oneshot_fg_tilemap,0,0);
180   draw_crosshairs(bitmap,cliprect);
180   draw_crosshairs(screen->machine,bitmap,cliprect);
181181   return 0;
182182}
183183
r2375r2376
191191   tilemap_draw(bitmap,cliprect,oneshot_fg_tilemap,0,0);
192192   tilemap_draw(bitmap,cliprect,oneshot_bg_tilemap,0,0);
193193   draw_sprites(screen->machine,bitmap,cliprect);
194//  draw_crosshairs(bitmap,cliprect); // not a gun game
194//  draw_crosshairs(screen->machine,bitmap,cliprect); // not a gun game
195195
196196//  popmessage ("%04x %04x %04x %04x %04x %04x %04x %04x", oneshot_scroll[0],oneshot_scroll[1],oneshot_scroll[2],oneshot_scroll[3],oneshot_scroll[4],oneshot_scroll[5],oneshot_scroll[6],oneshot_scroll[7]);
197197   return 0;
src/mame/video/topspeed.c
r2375r2376
99VIDEO_START( topspeed )
1010{
1111   /* (chips, gfxnum, x_offs, y_offs, y_invert, opaque, dblwidth) */
12   PC080SN_vh_start(2,1,0,8,0,0,0);
12   PC080SN_vh_start(machine,2,1,0,8,0,0,0);
1313}
1414
1515
src/mame/video/overdriv.c
r2375r2376
5151
5252VIDEO_START( overdriv )
5353{
54   K053251_vh_start();
54   K053251_vh_start(machine);
5555   K051316_vh_start_0(machine,REGION_GFX2,4,TRUE,0,zoom_callback_0);
5656   K051316_vh_start_1(machine,REGION_GFX3,4,FALSE,0,zoom_callback_1);
5757   K053247_vh_start(machine, REGION_GFX1,77,22,NORMAL_PLANE_ORDER,overdriv_sprite_callback);
src/mame/video/mario.c
r2375r2376
212212   mario_state   *state = screen->machine->driver_data;
213213   int t;
214214
215   t = readinputportbytag("MONITOR");
215   t = input_port_read(screen->machine, "MONITOR");
216216   if (t != state->monitor)
217217   {
218218      state->monitor = t;
src/mame/video/xmen.c
r2375r2376
4848
4949VIDEO_START( xmen )
5050{
51   K053251_vh_start();
51   K053251_vh_start(machine);
5252
5353   K052109_vh_start(machine,REGION_GFX1,NORMAL_PLANE_ORDER,xmen_tile_callback);
5454   K053247_vh_start(machine,REGION_GFX2,53,-2,NORMAL_PLANE_ORDER,xmen_sprite_callback);
r2375r2376
6060
6161VIDEO_START( xmen6p )
6262{
63   K053251_vh_start();
63   K053251_vh_start(machine);
6464
6565   K052109_vh_start(machine,REGION_GFX1,NORMAL_PLANE_ORDER,xmen_tile_callback);
6666   K053247_vh_start(machine,REGION_GFX2,53,-2,NORMAL_PLANE_ORDER,xmen_sprite_callback);
src/mame/video/lethal.c
r2375r2376
1010#include "driver.h"
1111#include "video/konamiic.h"
1212
13#define GUNX( a ) ( ( readinputport( a ) * 287 ) / 0xff )
14#define GUNY( a ) ( ( readinputport( a ) * 223 ) / 0xff )
13#define GUNX( a ) ( ( input_port_read_indexed(machine,  a ) * 287 ) / 0xff )
14#define GUNY( a ) ( ( input_port_read_indexed(machine,  a ) * 223 ) / 0xff )
1515
1616static int sprite_colorbase;
1717static int layer_colorbase[4];
r2375r2376
4949{
5050   int i;
5151
52   K053251_vh_start();
52   K053251_vh_start(machine);
5353
5454   K056832_vh_start(machine, REGION_GFX1, K056832_BPP_8LE, 1, NULL, lethalen_tile_callback, 0);
5555
src/mame/video/naughtyb.c
r2375r2376
128128   pleiads_sound_control_c_w(machine,offset,data);
129129
130130   naughtyb_cocktail =
131      ( ( input_port_2_r(machine,0) & 0x80 ) &&   // cabinet == cocktail
131      ( ( input_port_read_indexed(machine, 2) & 0x80 ) &&   // cabinet == cocktail
132132        ( data & 0x01 ) );            // handling player 2
133133   palreg  = (data >> 1) & 0x03;         // pallette sel is bit 1 & 2
134134   bankreg = (data >> 2) & 0x01;         // banksel is just bit 2
r2375r2376
140140   pleiads_sound_control_c_w(machine,offset,data);
141141
142142   naughtyb_cocktail =
143      ( ( input_port_2_r(machine,0) & 0x80 ) &&   // cabinet == cocktail
143      ( ( input_port_read_indexed(machine, 2) & 0x80 ) &&   // cabinet == cocktail
144144        ( data & 0x01 ) );            // handling player 2
145145   palreg  = (data >> 1) & 0x03;         // pallette sel is bit 1 & 2
146146   bankreg = (data >> 3) & 0x01;         // banksel is just bit 3
src/mame/video/momoko.c
r2375r2376
111111   UINT8 *TEXT_COLOR = memory_region( REGION_PROMS );
112112
113113
114   flip = momoko_flipscreen ^ (readinputport(4) & 0x01);
114   flip = momoko_flipscreen ^ (input_port_read_indexed(screen->machine, 4) & 0x01);
115115
116116/* draw BG layer */
117117
src/mame/video/taito_z.c
r2375r2376
2424      TC0150ROD_vh_start();
2525
2626   if (has_TC0110PCR())
27      TC0110PCR_vh_start();
27      TC0110PCR_vh_start(machine);
2828}
2929
3030VIDEO_START( taitoz )
src/mame/video/phoenix.c
r2375r2376
234234      videoram_pg_index = data & 1;
235235      memory_set_bank(1, videoram_pg_index);
236236
237      cocktail_mode = videoram_pg_index && (input_port_3_r(machine,0) & 0x01);
237      cocktail_mode = videoram_pg_index && (input_port_read(machine, "CAB") & 0x01);
238238
239239      tilemap_set_flip(ALL_TILEMAPS, cocktail_mode ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0);
240240      tilemap_mark_all_tiles_dirty(ALL_TILEMAPS);
r2375r2376
257257      videoram_pg_index = data & 1;
258258      memory_set_bank(1, videoram_pg_index);
259259
260      cocktail_mode = videoram_pg_index && (input_port_3_r(machine,0) & 0x01);
260      cocktail_mode = videoram_pg_index && (input_port_read(machine, "CAB") & 0x01);
261261
262262      tilemap_set_flip(ALL_TILEMAPS, cocktail_mode ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0);
263263      tilemap_mark_all_tiles_dirty(ALL_TILEMAPS);
r2375r2376
290290}
291291
292292
293READ8_HANDLER( phoenix_input_port_0_r )
293CUSTOM_INPUT( player_input_r )
294294{
295295   if (cocktail_mode)
296      return (readinputportbytag("IN0") & 0x07) | (readinputportbytag("IN1") & 0xf8);
296      return (input_port_read(machine, "CTRL") & 0xf0) >> 4;
297297   else
298      return readinputportbytag("IN0");
298      return (input_port_read(machine, "CTRL") & 0x0f) >> 0;
299299}
300300
301READ8_HANDLER( pleiads_input_port_0_r )
301CUSTOM_INPUT( pleiads_protection_r )
302302{
303   int ret = readinputportbytag("IN0") & 0xf7;
304
305303   /* handle Pleiads protection */
306304   switch (pleiads_protection_question)
307305   {
308306   case 0x00:
309307   case 0x20:
310308      /* Bit 3 is 0 */
309      return 0;
311310      break;
312311   case 0x0c:
313312   case 0x30:
314313      /* Bit 3 is 1 */
315      ret   |= 0x08;
314      return 1;
316315      break;
317316   default:
318317      logerror("Unknown protection question %02X at %04X\n", pleiads_protection_question, activecpu_get_pc());
318      return 0;
319319   }
320
321   return ret;
322320}
323321
324322READ8_HANDLER( survival_input_port_0_r )
325323{
326   int ret = readinputportbytag("IN0");
324   int ret = input_port_read(machine, "IN0");
327325
328326   if (survival_protection_value)
329327   {
src/mame/video/superqix.c
r2375r2376
6464   state_save_register_global(pbillian_show_power);
6565}
6666
67static void superqix_postload(void)
68{
69   tilemap_mark_all_tiles_dirty(bg_tilemap);
70}
71
7267VIDEO_START( superqix )
7368{
7469   fg_bitmap[0] = auto_bitmap_alloc(256, 256, video_screen_get_format(machine->primary_screen));
r2375r2376
8277   state_save_register_global(show_bitmap);
8378   state_save_register_global_bitmap(fg_bitmap[0]);
8479   state_save_register_global_bitmap(fg_bitmap[1]);
85   state_save_register_func_postload(superqix_postload);
8680}
8781
8882
r2375r2376
241235   {
242236      int curr_power;
243237
244      curr_power = ((readinputport(4)&0x3f)*100)/0x3f;
238      curr_power = ((input_port_read_indexed(screen->machine, 4)&0x3f)*100)/0x3f;
245239      if (last_power[0] != curr_power)
246240      {
247241         popmessage   ("Power %d%%", curr_power);
248242         last_power[0] = curr_power;
249243      }
250244
251      curr_power = ((readinputport(6)&0x3f)*100)/0x3f;
245      curr_power = ((input_port_read_indexed(screen->machine, 6)&0x3f)*100)/0x3f;
252246      if (last_power[1] != curr_power)
253247      {
254248         popmessage   ("Power %d%%", curr_power);
src/mame/video/rastan.c
r2375r2376
2020VIDEO_START( rastan )
2121{
2222   /* (chips, gfxnum, x_offs, y_offs, y_invert, opaque, dblwidth) */
23   PC080SN_vh_start(1,0,0,0,0,0,0);
23   PC080SN_vh_start(machine,1,0,0,0,0,0,0);
2424   PC090OJ_vh_start(1,0,0,0);
2525}
2626
2727VIDEO_START( opwolf )
2828{
29   PC080SN_vh_start(1,1,0,0,0,0,0);
29   PC080SN_vh_start(machine,1,1,0,0,0,0,0);
3030   PC090OJ_vh_start(0,0,0,0);
3131}
3232
3333VIDEO_START( rainbow )
3434{
3535   /* (chips, gfxnum, x_offs, y_offs, y_invert, opaque, dblwidth) */
36   PC080SN_vh_start(1,1,0,0,0,0,0);
36   PC080SN_vh_start(machine,1,1,0,0,0,0,0);
3737   PC090OJ_vh_start(0,0,0,0);
3838}
3939
4040VIDEO_START( jumping )
4141{
42   PC080SN_vh_start(1,1,0,0,1,0,0);
42   PC080SN_vh_start(machine,1,1,0,0,1,0,0);
4343
4444   PC080SN_set_trans_pen(0,1,15);
4545
src/mame/video/gijoe.c
r2375r2376
4141{
4242   int i;
4343
44   K053251_vh_start();
44   K053251_vh_start(machine);
4545   K056832_vh_start(machine, REGION_GFX1, K056832_BPP_4, 1, NULL, gijoe_tile_callback, 0);
4646
4747   K056832_linemap_enable(1);
src/mame/video/atari.c
r2375r2376
781781
782782   VIDEO_UPDATE_CALL(generic_bitmapped);
783783
784   new_tv_artifacts = readinputportbytag_safe("artifacts", 0);
784   new_tv_artifacts = input_port_read_safe(screen->machine, "artifacts", 0);
785785   if( tv_artifacts != new_tv_artifacts )
786786   {
787787      tv_artifacts = new_tv_artifacts;
r2375r2376
14921492 *
14931493 *****************************************************************************/
14941494
1495static void generic_atari_interrupt(void (*handle_keyboard)(void), int button_count)
1495static void generic_atari_interrupt(running_machine *machine, void (*handle_keyboard)(running_machine *machine), int button_count)
14961496{
14971497   int button_port, i;
14981498
r2375r2376
15061506
15071507    if( antic.scanline == VBL_START )
15081508    {
1509      button_port = readinputportbytag_safe("djoy_b", 0);
1509      button_port = input_port_read_safe(machine, "djoy_b", 0);
15101510
15111511      /* specify buttons relevant to this Atari variant */
15121512      for (i = 0; i < button_count; i++)
r2375r2376
15201520      for (i = button_count; i < 4; i++)
15211521         gtia.r.but[i] = 1;
15221522
1523      handle_keyboard();
1523      handle_keyboard(machine);
15241524
15251525      /* do nothing new for the rest of the frame */
15261526      antic.modelines = video_screen_get_height(Machine->primary_screen) - VBL_START;
r2375r2376
15441544
15451545INTERRUPT_GEN( a400_interrupt )
15461546{
1547   generic_atari_interrupt(a800_handle_keyboard, 4);
1547   generic_atari_interrupt(machine, a800_handle_keyboard, 4);
15481548}
15491549
15501550INTERRUPT_GEN( a800_interrupt )
15511551{
1552   generic_atari_interrupt(a800_handle_keyboard, 4);
1552   generic_atari_interrupt(machine, a800_handle_keyboard, 4);
15531553}
15541554
15551555INTERRUPT_GEN( a800xl_interrupt )
15561556{
1557   generic_atari_interrupt(a800_handle_keyboard, 2);
1557   generic_atari_interrupt(machine, a800_handle_keyboard, 2);
15581558}
15591559
15601560INTERRUPT_GEN( a5200_interrupt )
15611561{
1562   generic_atari_interrupt(a5200_handle_keypads, 4);
1562   generic_atari_interrupt(machine, a5200_handle_keypads, 4);
15631563}
src/mame/video/m57.c
r2375r2376
158158WRITE8_HANDLER( m57_flipscreen_w )
159159{
160160   /* screen flip is handled both by software and hardware */
161   flipscreen = (data & 0x01) ^ (~readinputportbytag("DSW2") & 0x01);
161   flipscreen = (data & 0x01) ^ (~input_port_read(machine, "DSW2") & 0x01);
162162   tilemap_set_flip(bg_tilemap, flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
163163
164164   coin_counter_w(0,data & 0x02);
src/mame/video/neogeo.c
r2375r2376
168168}
169169
170170
171static void regenerate_pens(void)
171static STATE_POSTLOAD( regenerate_pens )
172172{
173173   int i;
174174
r2375r2376
177177}
178178
179179
180void neogeo_set_palette_bank(UINT8 data)
180void neogeo_set_palette_bank(running_machine *machine, UINT8 data)
181181{
182182   if (data != palette_bank)
183183   {
184184      palette_bank = data;
185185
186      regenerate_pens();
186      regenerate_pens(machine, NULL);
187187   }
188188}
189189
190190
191void neogeo_set_screen_dark(UINT8 data)
191void neogeo_set_screen_dark(running_machine *machine, UINT8 data)
192192{
193193   if (data != screen_dark)
194194   {
195195      screen_dark = data;
196196
197      regenerate_pens();
197      regenerate_pens(machine, NULL);
198198   }
199199}
200200
r2375r2376
899899   state_save_register_global(auto_animation_counter);
900900   state_save_register_global(auto_animation_frame_counter);
901901
902   state_save_register_func_postload(regenerate_pens);
902   state_save_register_postload(machine, regenerate_pens, NULL);
903903}
904904
905905
src/mame/video/parodius.c
r2375r2376
4444
4545VIDEO_START( parodius )
4646{
47   K053251_vh_start();
47   K053251_vh_start(machine);
4848   K052109_vh_start(machine,REGION_GFX1,NORMAL_PLANE_ORDER,tile_callback);
4949   K053245_vh_start(machine,0,REGION_GFX2,NORMAL_PLANE_ORDER,sprite_callback);
5050}
src/mame/video/combatsc.c
r2375r2376
346346
347347static READ8_HANDLER( combascb_io_r )
348348{
349   return readinputport(offset);
349   return input_port_read_indexed(machine, offset);
350350}
351351
352352static WRITE8_HANDLER( combascb_priority_w )
src/mame/video/ppu2c0x.c
r2375r2376
13091309//logerror("   sprite DMA: %d (scanline: %d)\n", page, chips[num].scanline);
13101310   for (i = 0; i < SPRITERAM_SIZE; i++)
13111311   {
1312      UINT8 spriteData = program_read_byte_8 (address + i);
1312      UINT8 spriteData = program_read_byte(address + i);
13131313      ppu2c0x_w (num, PPU_SPRITE_DATA, spriteData);
13141314   }
13151315
src/mame/video/taito_f2.c
r2375r2376
111111   }
112112
113113   if (has_TC0110PCR())
114      TC0110PCR_vh_start();
114      TC0110PCR_vh_start(machine);
115115
116116   if (has_TC0280GRD())
117117      TC0280GRD_vh_start(TC0280GRD_GFX_NUM);
src/mame/video/asterix.c
r2375r2376
4444
4545VIDEO_START( asterix )
4646{
47   K053251_vh_start();
47   K053251_vh_start(machine);
4848   K056832_vh_start(machine, REGION_GFX1, K056832_BPP_4, 1, NULL, asterix_tile_callback, 1);
4949   K053245_vh_start(machine,0, REGION_GFX2,NORMAL_PLANE_ORDER, asterix_sprite_callback);
5050
src/mame/video/exidy.c
r2375r2376
7070 *
7171 *************************************/
7272
73INLINE void latch_condition(int collision)
73INLINE void latch_condition(running_machine *machine, int collision)
7474{
7575   collision ^= collision_invert;
76   int_condition = (readinputportbytag("INTSOURCE") & ~0x1c) | (collision & collision_mask);
76   int_condition = (input_port_read(machine, "INTSOURCE") & ~0x1c) | (collision & collision_mask);
7777}
7878
7979
8080INTERRUPT_GEN( exidy_vblank_interrupt )
8181{
8282   /* latch the current condition */
83   latch_condition(0);
83   latch_condition(machine, 0);
8484   int_condition &= ~0x80;
8585
8686   /* set the IRQ line */
r2375r2376
283283static TIMER_CALLBACK( collision_irq_callback )
284284{
285285   /* latch the collision bits */
286   latch_condition(param);
286   latch_condition(machine, param);
287287
288288   /* set the IRQ line */
289289   cpunum_set_input_line(machine, 0, 0, ASSERT_LINE);
src/mame/video/moo.c
r2375r2376
4747
4848   alpha_enabled = 0;
4949
50   K053251_vh_start();
50   K053251_vh_start(machine);
5151   K054338_vh_start();
5252
5353   K056832_vh_start(machine, REGION_GFX1, K056832_BPP_4, 1, NULL, moo_tile_callback, 0);
src/mame/video/m92.c
r2375r2376
463463   m92_screenrefresh(screen->machine, bitmap, cliprect);
464464
465465   /* Flipscreen appears hardwired to the dipswitch - strange */
466   if (readinputportbytag("DIPS21") & 0x100)
466   if (input_port_read(screen->machine, "DIPS21") & 0x100)
467467      flip_screen_set(0);
468468   else
469469      flip_screen_set(1);
src/mame/video/m58.c
r2375r2376
203203WRITE8_HANDLER( yard_flipscreen_w )
204204{
205205   /* screen flip is handled both by software and hardware */
206   flip_screen_set((data & 0x01) ^ (~readinputportbytag("DSW2") & 0x01));
206   flip_screen_set((data & 0x01) ^ (~input_port_read(machine, "DSW2") & 0x01));
207207
208208   coin_counter_w(0, data & 0x02);
209209   coin_counter_w(1, data & 0x20);
src/mame/video/vendetta.c
r2375r2376
5454
5555VIDEO_START( vendetta )
5656{
57   K053251_vh_start();
57   K053251_vh_start(machine);
5858
5959   K052109_vh_start(machine,REGION_GFX1,NORMAL_PLANE_ORDER,vendetta_tile_callback);
6060   K053247_vh_start(machine,REGION_GFX2,53,6,NORMAL_PLANE_ORDER,sprite_callback);
r2375r2376
6262
6363VIDEO_START( esckids )
6464{
65    K053251_vh_start();
65    K053251_vh_start(machine);
6666
6767    K052109_vh_start(machine,REGION_GFX1,NORMAL_PLANE_ORDER,esckids_tile_callback);
6868   K053247_vh_start(machine,REGION_GFX2,101,6,NORMAL_PLANE_ORDER,sprite_callback);
src/mame/video/zac2650.c
r2375r2376
3737
3838READ8_HANDLER( tinvader_port_0_r )
3939{
40   return input_port_0_r(machine,0) - CollisionBackground;
40   return input_port_read_indexed(machine, 0) - CollisionBackground;
4141}
4242
4343/*****************************************/
src/mame/video/ninjaw.c
r2375r2376
3333   TC0100SCN_vh_start(machine,chips,TC0100SCN_GFX_NUM,taito_hide_pixels,0,0,0,0,0,2);
3434
3535   if (has_TC0110PCR())
36      TC0110PCR_vh_start();
36      TC0110PCR_vh_start(machine);
3737
3838   if (has_second_TC0110PCR())
39      TC0110PCR_1_vh_start();
39      TC0110PCR_1_vh_start(machine);
4040
4141   if (has_third_TC0110PCR())
42      TC0110PCR_2_vh_start();
42      TC0110PCR_2_vh_start(machine);
4343
4444   /* Ensure palette from correct TC0110PCR used for each screen */
4545   TC0100SCN_set_chip_colbanks(0x0,0x100,0x200);
src/mame/video/dcheese.c
r2375r2376
317317{
318318   /* analog inputs seem to be hooked up here -- might not actually map to blitter */
319319   if (offset == 0x02/2)
320      return readinputport(3);
320      return input_port_read_indexed(machine, 3);
321321   if (offset == 0x0e/2)
322      return readinputport(4);
322      return input_port_read_indexed(machine, 4);
323323
324324   /* early code polls on this bit, wants it to be 0 */
325325   if (offset == 0x36/2)
src/mame/video/bwing.c
r2375r2376
144144   g = ((g<<5) + (g<<2) + (g>>1));
145145   b = ((b<<5) + (b<<2) + (b>>1));
146146
147   if ((i = readinputport(7)) < 4)
147   if ((i = input_port_read_indexed(machine, 7)) < 4)
148148   {
149149      r = (float)r * rgb[i][0];
150150      g = (float)g * rgb[i][1];
src/mame/video/asuka.c
r2375r2376
1010{
1111   PC090OJ_vh_start(0,0,8,buffering);   /* gfxset, x offset, y offset, buffering */
1212   TC0100SCN_vh_start(machine,1,TC0100SCN_GFX_NUM,x_offs,0,0,0,0,0,0);
13   TC0110PCR_vh_start();
13   TC0110PCR_vh_start(machine);
1414}
1515
1616VIDEO_START( asuka )
src/mame/video/nmk16.c
r2375r2376
554554}
555555
556556/*coin setting MCU simulation*/
557static void mcu_run(UINT8 dsw_setting)
557static void mcu_run(running_machine *machine, UINT8 dsw_setting)
558558{
559559   static UINT8 read_coin;
560560   static UINT8 old_value;
r2375r2376
563563   /*needed because of the uncompatibility of the dsw settings.*/
564564   if(dsw_setting)
565565   {
566      dsw_a = (readinputport(2+dsw_setting) & 0x7);
567      dsw_b = (readinputport(2+dsw_setting) & 0x38) >> 3;
566      dsw_a = (input_port_read_indexed(machine, 2+dsw_setting) & 0x7);
567      dsw_b = (input_port_read_indexed(machine, 2+dsw_setting) & 0x38) >> 3;
568568   }
569569   else
570570   {
571      dsw_a = (readinputport(2) & 0x0700) >> 8;
572      dsw_b = (readinputport(2) & 0x3800) >> 11;
571      dsw_a = (input_port_read_indexed(machine, 2) & 0x0700) >> 8;
572      dsw_b = (input_port_read_indexed(machine, 2) & 0x3800) >> 11;
573573   }
574574
575575   read_coin = old_value;
576   old_value = readinputport(0);
576   old_value = input_port_read_indexed(machine, 0);
577577
578578   if(dsw_a == 0 || dsw_b == 0)
579579      nmk16_mainram[0x9000/2]|=0x4000; //free_play
580580
581581   if(read_coin != old_value)
582582   {
583      if(!(readinputport(0) & 0x01))//COIN1
583      if(!(input_port_read_indexed(machine, 0) & 0x01))//COIN1
584584      {
585585         switch(dsw_a & 7)
586586         {
r2375r2376
615615         }
616616      }
617617
618      if(!(readinputport(0) & 0x02))//COIN2
618      if(!(input_port_read_indexed(machine, 0) & 0x02))//COIN2
619619      {
620620         switch(dsw_b & 7)
621621         {
r2375r2376
650650         }
651651      }
652652
653      if(!(readinputport(0) & 0x04))//SERVICE_COIN
653      if(!(input_port_read_indexed(machine, 0) & 0x04))//SERVICE_COIN
654654         nmk16_mainram[0xef00/2]++;
655655
656656      if(nmk16_mainram[0xef00/2] >= 1 && (nmk16_mainram[0x9000/2] & 0x8000))/*enable start button*/
657657      {
658658         /*Start a 1-player game,but don't decrement if the player 1 is already playing*/
659         if((!(readinputport(0) & 0x08)) /*START1*/
659         if((!(input_port_read_indexed(machine, 0) & 0x08)) /*START1*/
660660         && (!(nmk16_mainram[0x9000/2] & 0x0200)) /*PLAYER-1 playing*/
661661         )
662662            nmk16_mainram[0xef00/2]--;
663663
664664         /*Start a 2-players game,but don't decrement if the player 2 is already playing*/
665         if((!(readinputport(0) & 0x10))
665         if((!(input_port_read_indexed(machine, 0) & 0x10))
666666         && (!(nmk16_mainram[0x9000/2] & 0x0100))
667667         )
668668         {
r2375r2376
679679
680680VIDEO_UPDATE( tdragon )
681681{
682   mcu_run(1);
682   mcu_run(screen->machine, 1);
683683
684684   tilemap_set_scrollx(tx_tilemap,0,-videoshift);
685685
r2375r2376
696696
697697VIDEO_UPDATE( hachamf )
698698{
699   mcu_run(0);
699   mcu_run(screen->machine, 0);
700700
701701   tilemap_set_scrollx(tx_tilemap,0,-videoshift);
702702
r2375r2376
10521052   if (dsw_flipscreen)
10531053   {
10541054
1055      flip_screen_x_set(~readinputport(2) & 0x0100);
1056      flip_screen_y_set(~readinputport(2) & 0x0200);
1055      flip_screen_x_set(~input_port_read_indexed(machine, 2) & 0x0100);
1056      flip_screen_y_set(~input_port_read_indexed(machine, 2) & 0x0200);
10571057   }
10581058
10591059   tilemap_set_scrollx(tilemap_0, 0, afega_scroll_0[1] + xoffset);
src/mame/drivers/bfcobra.c
r2375r2376
865865      }
866866      case 0x22:
867867      {
868         val = 0x40 | readinputportbytag("JOYSTICK");
868         val = 0x40 | input_port_read(machine, "JOYSTICK");
869869         break;
870870      }
871871      default:
r2375r2376
14091409
14101410            /* Clock is low */
14111411            if (!(data & 0x08))
1412               mux_input = readinputport(input_strobe);
1412               mux_input = input_port_read_indexed(machine, input_strobe);
14131413         }
14141414         break;
14151415      }
src/mame/drivers/rcasino.c
r2375r2376
165165       pulse = 0;
166166       else pulse = 0x04;
167167   }
168   return readinputport(1) + pulse;
168   return input_port_read_indexed(machine, 1) + pulse;
169169}
170170
171171static ADDRESS_MAP_START( rcasino_map, ADDRESS_SPACE_PROGRAM, 8 )
src/mame/drivers/nycaptor.c
r2375r2376
226226
227227static READ8_HANDLER( nycaptor_by_r )
228228{
229   int port=readinputport(6);
229   int port=input_port_read_indexed(machine, 6);
230230   if(nyc_gametype==1)
231231         port=255-port;
232232      return port-8;
r2375r2376
234234
235235static READ8_HANDLER( nycaptor_bx_r )
236236{
237      return (readinputport(5)+0x27)|1;
237      return (input_port_read_indexed(machine, 5)+0x27)|1;
238238}
239239
240240
src/mame/drivers/mitchell.c
r2375r2376
193193      if (pang_port5_kludge)   /* hack... music doesn't work otherwise */
194194         bit ^= 0x08;
195195
196   return (input_port_0_r(machine,0) & 0x76) | bit;
196   return (input_port_read_indexed(machine, 0) & 0x76) | bit;
197197}
198198
199199static WRITE8_HANDLER( eeprom_cs_w )
r2375r2376
229229   {
230230      int delta;
231231
232      delta = (readinputport(4 + offset) - dial[offset]) & 0xff;
232      delta = (input_port_read_indexed(machine, 4 + offset) - dial[offset]) & 0xff;
233233      if (delta & 0x80)
234234      {
235235         delta = (-delta) & 0xff;
r2375r2376
256256   {
257257      int res;
258258
259      res = readinputport(2 + offset) & 0xf7;
259      res = input_port_read_indexed(machine, 2 + offset) & 0xf7;
260260      if (dir[offset]) res |= 0x08;
261261
262262      return res;
r2375r2376
268268   if (data == 0x08)
269269   {
270270      /* reset the dial counters */
271      dial[0] = readinputport(4);
272      dial[1] = readinputport(5);
271      dial[0] = input_port_read_indexed(machine, 4);
272      dial[1] = input_port_read_indexed(machine, 5);
273273   }
274274   else if (data == 0x80)
275275      dial_selected = 0;
r2375r2376
285285   int i;
286286
287287   for (i = 0;i < 5;i++)
288      if (keymatrix & (0x80 >> i)) return readinputport(2 + 5 * offset + i);
288      if (keymatrix & (0x80 >> i)) return input_port_read_indexed(machine, 2 + 5 * offset + i);
289289
290290   return 0xff;
291291}
r2375r2376
304304   {
305305      case 0:
306306      default:
307         return readinputport(1 + offset);
307         return input_port_read_indexed(machine, 1 + offset);
308308         break;
309309      case 1:   /* Mahjong games */
310310         if (offset) return mahjong_input_r(machine,offset-1);
311         else return readinputport(1);
311         else return input_port_read_indexed(machine, 1);
312312         break;
313313      case 2:   /* Block Block - dial control */
314314         if (offset) return block_input_r(machine,offset-1);
315         else return readinputport(1);
315         else return input_port_read_indexed(machine, 1);
316316         break;
317317      case 3:   /* Super Pang - simulate START 1 press to initialize EEPROM */
318         if (offset || init_eeprom_count == 0) return readinputport(1 + offset);
318         if (offset || init_eeprom_count == 0) return input_port_read_indexed(machine, 1 + offset);
319319         else
320320         {
321321            init_eeprom_count--;
322            return readinputport(1) & ~0x08;
322            return input_port_read_indexed(machine, 1) & ~0x08;
323323         }
324324         break;
325325   }
src/mame/drivers/blktiger.c
r2375r2376
5454
5555static WRITE8_HANDLER( blktiger_coinlockout_w )
5656{
57   if (readinputportbytag("COIN_LOCKOUT") & 0x01)
57   if (input_port_read(machine, "COIN_LOCKOUT") & 0x01)
5858   {
5959      coin_lockout_w(0,~data & 0x01);
6060      coin_lockout_w(1,~data & 0x02);
src/mame/drivers/mgolf.c
r2375r2376
7171}
7272
7373
74static void update_plunger(void)
74static void update_plunger(running_machine *machine)
7575{
76   UINT8 val = readinputport(5);
76   UINT8 val = input_port_read_indexed(machine, 5);
7777
7878   if (prev != val)
7979   {
r2375r2376
9696{
9797   int scanline = param;
9898
99   update_plunger();
99   update_plunger(machine);
100100
101101   cpunum_set_input_line(machine, 0, 0, PULSE_LINE);
102102
r2375r2376
138138
139139static READ8_HANDLER( mgolf_dial_r )
140140{
141   UINT8 val = readinputport(1);
141   UINT8 val = input_port_read_indexed(machine, 1);
142142
143   if ((readinputport(4) + 0x00) & 0x20)
143   if ((input_port_read_indexed(machine, 4) + 0x00) & 0x20)
144144   {
145145      val |= 0x01;
146146   }
147   if ((readinputport(4) + 0x10) & 0x20)
147   if ((input_port_read_indexed(machine, 4) + 0x10) & 0x20)
148148   {
149149      val |= 0x02;
150150   }
r2375r2376
157157{
158158   double plunger = calc_plunger_pos(); /* see Video Pinball */
159159
160   UINT8 val = readinputport(3);
160   UINT8 val = input_port_read_indexed(machine, 3);
161161
162162   if (plunger >= 0.000 && plunger <= 0.001)
163163   {
src/mame/drivers/deco_mlc.c
r2375r2376
118118
119119static READ32_HANDLER( avengrs_control_r )
120120{
121   return (readinputport(1)<<16) | (EEPROM_read_bit()<<23) | readinputport(0);
121   return (input_port_read_indexed(machine, 1)<<16) | (EEPROM_read_bit()<<23) | input_port_read_indexed(machine, 0);
122122}
123123
124124static READ32_HANDLER(test2_r)
125125{
126126//  if (offset==0)
127//      return readinputport(0); //0xffffffff;
127//      return input_port_read_indexed(machine, 0); //0xffffffff;
128128//   logerror("%08x:  Test2_r %d\n",activecpu_get_pc(),offset);
129129   return mame_rand(Machine); //0xffffffff;
130130}
src/mame/drivers/tunhunt.c
r2375r2376
9797
9898static READ8_HANDLER( tunhunt_button_r )
9999{
100   int data = readinputportbytag("IN0");
100   int data = input_port_read(machine, "IN0");
101101   return ((data>>offset)&1)?0x00:0x80;
102102}
103103
104104
105105static READ8_HANDLER( dsw1_r )
106106{
107   return readinputportbytag("DSW")&0xff;
107   return input_port_read(machine, "DSW")&0xff;
108108}
109109
110110
111111static READ8_HANDLER( dsw2_0r )
112112{
113   return (readinputportbytag("DSW")&0x0100)?0x80:0x00;
113   return (input_port_read(machine, "DSW")&0x0100)?0x80:0x00;
114114}
115115
116116
117117static READ8_HANDLER( dsw2_1r )
118118{
119   return (readinputportbytag("DSW")&0x0200)?0x80:0x00;
119   return (input_port_read(machine, "DSW")&0x0200)?0x80:0x00;
120120}
121121
122122
123123static READ8_HANDLER( dsw2_2r )
124124{
125   return (readinputportbytag("DSW")&0x0400)?0x80:0x00;
125   return (input_port_read(machine, "DSW")&0x0400)?0x80:0x00;
126126}
127127
128128
129129static READ8_HANDLER( dsw2_3r )
130130{
131   return (readinputportbytag("DSW")&0x0800)?0x80:0x00;
131   return (input_port_read(machine, "DSW")&0x0800)?0x80:0x00;
132132}
133133
134134
135135static READ8_HANDLER( dsw2_4r )
136136{
137   return (readinputportbytag("DSW")&0x1000)?0x80:0x00;
137   return (input_port_read(machine, "DSW")&0x1000)?0x80:0x00;
138138}
139139
140140
src/mame/drivers/tryout.c
r2375r2376
183183
184184static INTERRUPT_GEN( tryout_interrupt )
185185{
186   if ((input_port_3_r(machine,0) & 0x1c)!=0x1c)
186   if ((input_port_read_indexed(machine, 3) & 0x1c)!=0x1c)
187187      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, ASSERT_LINE);
188188}
189189
src/mame/drivers/rungun.c
r2375r2376
9494   switch (offset)
9595   {
9696      case 0x00/2:
97         if (readinputport(1) & 0x20)
98            return(readinputport(2) | readinputport(4)<<8);
97         if (input_port_read_indexed(machine, 1) & 0x20)
98            return(input_port_read_indexed(machine, 2) | input_port_read_indexed(machine, 4)<<8);
9999         else
100100         {
101            data = readinputport(2) & readinputport(4);
101            data = input_port_read_indexed(machine, 2) & input_port_read_indexed(machine, 4);
102102            return(data<<8 | data);
103103         }
104104      break;
105105
106106      case 0x02/2:
107         if (readinputport(1) & 0x20)
108            return(readinputport(3) | readinputport(5)<<8);
107         if (input_port_read_indexed(machine, 1) & 0x20)
108            return(input_port_read_indexed(machine, 3) | input_port_read_indexed(machine, 5)<<8);
109109         else
110110         {
111            data = readinputport(3) & readinputport(5);
111            data = input_port_read_indexed(machine, 3) & input_port_read_indexed(machine, 5);
112112            return(data<<8 | data);
113113         }
114114      break;
r2375r2376
125125      case 0x06/2:
126126         if (ACCESSING_BITS_0_7)
127127         {
128            data = readinputport(1) | EEPROM_read_bit();
128            data = input_port_read_indexed(machine, 1) | EEPROM_read_bit();
129129
130130            if (init_eeprom_count)
131131            {
src/mame/drivers/crystal.c
r2375r2376
181181static READ32_HANDLER(Input_r)
182182{
183183   if(offset==0)
184      return readinputport(0)|(readinputport(1)<<16);
184      return input_port_read_indexed(machine, 0)|(input_port_read_indexed(machine, 1)<<16);
185185   else if(offset==1)
186      return readinputport(2)|(readinputport(3)<<16);
186      return input_port_read_indexed(machine, 2)|(input_port_read_indexed(machine, 3)<<16);
187187   else if(offset==2)
188188   {
189      UINT8 Port4=readinputport(4);
189      UINT8 Port4=input_port_read_indexed(machine, 4);
190190      if(!(Port4&0x10) && ((OldPort4^Port4)&0x10))   //coin buttons trigger IRQs
191191         IntReq(machine, 12);
192192      if(!(Port4&0x20) && ((OldPort4^Port4)&0x20))
193193         IntReq(machine, 19);
194194      OldPort4=Port4;
195      return /*dips*/readinputport(5)|(Port4<<16);
195      return /*dips*/input_port_read_indexed(machine, 5)|(Port4<<16);
196196   }
197197   return 0;
198198}
src/mame/drivers/tempest.c
r2375r2376
320320
321321   if (tempest_player_select)
322322   {
323      ret = readinputportbytag(TEMPEST_KNOB_P2_TAG);
323      ret = input_port_read(machine, TEMPEST_KNOB_P2_TAG);
324324   }
325325   else
326326   {
327      ret = readinputportbytag(TEMPEST_KNOB_P1_TAG);
327      ret = input_port_read(machine, TEMPEST_KNOB_P1_TAG);
328328   }
329329
330330   return ret;
r2375r2376
336336
337337   if (tempest_player_select)
338338   {
339      ret = readinputportbytag(TEMPEST_BUTTONS_P2_TAG);
339      ret = input_port_read(machine, TEMPEST_BUTTONS_P2_TAG);
340340   }
341341   else
342342   {
343      ret = readinputportbytag(TEMPEST_BUTTONS_P1_TAG);
343      ret = input_port_read(machine, TEMPEST_BUTTONS_P1_TAG);
344344   }
345345
346346   return ret;
r2375r2376
349349
350350static READ8_HANDLER( tempest_IN0_r )
351351{
352   int res = readinputport(0);
352   int res = input_port_read_indexed(machine, 0);
353353
354354   if (avgdvg_done())
355355      res |= 0x40;
r2375r2376
364364
365365static READ8_HANDLER( input_port_1_bit_r )
366366{
367   return (readinputport(1) & (1 << offset)) ? 0 : 228;
367   return (input_port_read_indexed(machine, 1) & (1 << offset)) ? 0 : 228;
368368}
369369
370370
371371static READ8_HANDLER( input_port_2_bit_r )
372372{
373   return (readinputport(2) & (1 << offset)) ? 0 : 228;
373   return (input_port_read_indexed(machine, 2) & (1 << offset)) ? 0 : 228;
374374}
375375
376376
src/mame/drivers/eprom.c
r2375r2376
7070   atarigen_interrupt_reset(update_interrupts);
7171   atarigen_scanline_timer_reset(machine->primary_screen, eprom_scanline_update, 8);
7272   atarijsa_reset();
73   atarigen_init_save_state();
73   atarigen_init_save_state(machine);
7474}
7575
7676
r2375r2376
9090
9191static READ16_HANDLER( special_port1_r )
9292{
93   int result = readinputport(1);
93   int result = input_port_read_indexed(machine, 1);
9494
9595   if (atarigen_sound_to_cpu_ready) result ^= 0x0004;
9696   if (atarigen_cpu_to_sound_ready) result ^= 0x0008;
r2375r2376
103103static READ16_HANDLER( adc_r )
104104{
105105   static int last_offset;
106   int result = readinputport(2 + (last_offset & 3));
106   int result = input_port_read_indexed(machine, 2 + (last_offset & 3));
107107   last_offset = offset;
108108   return result;
109109}
src/mame/drivers/chinsan.c
r2375r2376
130130      /* i doubt these are both really the same.. */
131131      case 0x40:
132132      case 0x4f:
133         return readinputportbytag("MAHJONG_P2_1");
133         return input_port_read(machine, "MAHJONG_P2_1");
134134
135135      case 0x53:
136         return readinputportbytag("MAHJONG_P2_2");
136         return input_port_read(machine, "MAHJONG_P2_2");
137137
138138      case 0x57:
139         return readinputportbytag("MAHJONG_P2_3");
139         return input_port_read(machine, "MAHJONG_P2_3");
140140
141141      case 0x5b:
142         return readinputportbytag("MAHJONG_P2_4");
142         return input_port_read(machine, "MAHJONG_P2_4");
143143
144144      case 0x5d:
145         return readinputportbytag("MAHJONG_P2_5");
145         return input_port_read(machine, "MAHJONG_P2_5");
146146
147147      case 0x5e:
148         return readinputportbytag("MAHJONG_P2_6");
148         return input_port_read(machine, "MAHJONG_P2_6");
149149   }
150150
151151   printf("chinsan_input_port_0_r unk_r %02x\n", chinsan_port_select);
r2375r2376
159159      /* i doubt these are both really the same.. */
160160      case 0x40:
161161      case 0x4f:
162         return readinputportbytag("MAHJONG_P1_1");
162         return input_port_read(machine, "MAHJONG_P1_1");
163163
164164      case 0x53:
165         return readinputportbytag("MAHJONG_P1_2");
165         return input_port_read(machine, "MAHJONG_P1_2");
166166
167167      case 0x57:
168         return readinputportbytag("MAHJONG_P1_3");
168         return input_port_read(machine, "MAHJONG_P1_3");
169169
170170      case 0x5b:
171         return readinputportbytag("MAHJONG_P1_4");
171         return input_port_read(machine, "MAHJONG_P1_4");
172172
173173      case 0x5d:
174         return readinputportbytag("MAHJONG_P1_5");
174         return input_port_read(machine, "MAHJONG_P1_5");
175175
176176      case 0x5e:
177         return readinputportbytag("MAHJONG_P1_6");
177         return input_port_read(machine, "MAHJONG_P1_6");
178178   }
179179
180180   printf("chinsan_input_port_1_r unk_r %02x\n", chinsan_port_select);
src/mame/drivers/skyfox.c
r2375r2376
248248   skyfox_bg_pos += (skyfox_bg_ctrl >> 1) & 0x7;   // maybe..
249249
250250   /* Check coin 1 & 2 */
251   if ((readinputportbytag("IN4") & 3) != 3) cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
251   if ((input_port_read(machine, "IN4") & 3) != 3) cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
252252}
253253
254254static MACHINE_DRIVER_START( skyfox )
src/mame/drivers/cshooter.c
r2375r2376
9595
9696static void ar_coin_hack(void)
9797{
98   if(input_port_5_r(Machine,0)&1)
98   if(input_port_read_indexed(Machine, 5)&1)
9999   {
100100      if(coin_stat==0)
101101      {
r2375r2376
221221   /* Even reads must return 0xff - Odd reads must return the contents of input port 5.
222222       Code at 0x5061 is executed once during P.O.S.T. where there is one read.
223223       Code at 0x50b4 is then executed each frame (not sure) where there are 2 reads. */
224   return ( (cshooter_counter++ & 1) ? 0xff : input_port_5_r(machine,0) );
224   return ( (cshooter_counter++ & 1) ? 0xff : input_port_read_indexed(machine, 5) );
225225}
226226
227227static WRITE8_HANDLER ( cshooter_c500_w )
src/mame/drivers/aerofgt.c
r2375r2376
9292VIDEO_START( turbofrc );
9393VIDEO_UPDATE( pspikes );
9494VIDEO_UPDATE( pspikesb );
95VIDEO_UPDATE( spikes91 );
9596VIDEO_UPDATE( karatblz );
9697VIDEO_UPDATE( spinlbrk );
9798VIDEO_UPDATE( turbofrc );
r2375r2376
192193   AM_RANGE(0xfff008, 0xfff009) AM_WRITE(pspikesb_oki_banking_w)
193194ADDRESS_MAP_END
194195
195static ADDRESS_MAP_START( pallavol_map, ADDRESS_SPACE_PROGRAM, 16 )
196static ADDRESS_MAP_START( spikes91_map, ADDRESS_SPACE_PROGRAM, 16 )
196197   AM_RANGE(0x000000, 0x03ffff) AM_ROM
197198   AM_RANGE(0x100000, 0x10ffff) AM_RAM   /* work RAM */
198199   AM_RANGE(0x200000, 0x203fff) AM_RAM AM_BASE(&aerofgt_spriteram1) AM_SIZE(&aerofgt_spriteram1_size)
r2375r2376
11491150   128*8
11501151};
11511152
1152static const gfx_layout pallavol_spritelayout =
1153static const gfx_layout spikes91_spritelayout =
11531154{
11541155   16,16,
11551156   RGN_FRAC(1,4),
r2375r2376
12021203   GFXDECODE_ENTRY( REGION_GFX2, 0, pspikesb_spritelayout, 1024, 64 )   /* colors 1024-2047 in 4 banks */
12031204GFXDECODE_END
12041205
1205static GFXDECODE_START( pallavol )
1206static GFXDECODE_START( spikes91 )
12061207   GFXDECODE_ENTRY( REGION_GFX1, 0, pspikesb_charlayout,      0, 64 )   /* colors    0-1023 in 8 banks */
1207   GFXDECODE_ENTRY( REGION_GFX2, 0, pallavol_spritelayout, 1024, 64 )   /* colors 1024-2047 in 4 banks */
1208   GFXDECODE_ENTRY( REGION_GFX2, 0, spikes91_spritelayout, 1024, 64 )   /* colors 1024-2047 in 4 banks */
12081209GFXDECODE_END
12091210
12101211
r2375r2376
12981299   MDRV_SOUND_ROUTE(2, "right", 1.0)
12991300MACHINE_DRIVER_END
13001301
1301static MACHINE_DRIVER_START( pallavol )
1302static MACHINE_DRIVER_START( spikes91 )
13021303
13031304/* basic machine hardware */
13041305   MDRV_CPU_ADD(M68000,20000000/2)   /* 10 MHz (?) */
1305   MDRV_CPU_PROGRAM_MAP(pallavol_map,0)
1306   MDRV_CPU_PROGRAM_MAP(spikes91_map,0)
13061307   MDRV_CPU_VBLANK_INT("main", irq1_line_hold)/* all irq vectors are the same */
13071308
13081309   /* + Z80 for sound */
r2375r2376
13141315   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
13151316   MDRV_SCREEN_SIZE(64*8, 32*8)
13161317   MDRV_SCREEN_VISIBLE_AREA(0*8+4, 44*8+4-1, 0*8, 30*8-1)
1317   MDRV_GFXDECODE(pallavol)
1318   MDRV_GFXDECODE(spikes91)
13181319   MDRV_PALETTE_LENGTH(2048)
13191320
13201321   MDRV_VIDEO_START(pspikes)
1321   MDRV_VIDEO_UPDATE(pspikesb)
1322   MDRV_VIDEO_UPDATE(spikes91)
13221323
13231324   /* sound hardware */
13241325   /* the sound hardware is completely different on this:
r2375r2376
17621763
17631764/*
17641765
1765Pallavolo (Italian Power Spikes bootleg)
17661991 Spikes (Italian bootleg)
17661767
17671768Anno    1991
17681769Produttore
r2375r2376
18101811
18111812*/
18121813
1813ROM_START( pallavol )
1814ROM_START( spikes91 )
18141815   ROM_REGION( 0x40000, REGION_CPU1, 0 )   /* 68000 code */
18151816   ROM_LOAD16_BYTE( "7.ic2",    0x00001, 0x20000, CRC(41e38d7e) SHA1(d0c226a8b61a2311c781ed5747d78b8dbddbc7ef) )
18161817   ROM_LOAD16_BYTE( "8.ic3",    0x00000, 0x20000, CRC(9c488daa) SHA1(8336fec855786c6cc6a836d86b74e130d60013b7) )
r2375r2376
18271828   ROM_LOAD( "13.ic120",   0x80000, 0x40000, CRC(89213a8c) SHA1(8524d5c14669d9b03f1fe050c4318d4111bc8ef7) )
18281829   ROM_LOAD( "14.ic121",   0xc0000, 0x40000, CRC(468cbf5b) SHA1(60fbc2771e40f8de51a51891b8ddcc14e2b1e52c) )
18291830
1830   ROM_REGION( 0x020000, REGION_USER1, 0 ) /* ??? Unknown, interleaved - near sprite roms, lookup tables? */
1831   ROM_REGION( 0x020000, REGION_USER1, 0 ) /* lookup tables for the sprites */
18311832   ROM_LOAD( "10.ic104",   0x00000, 0x10000, CRC(769ade77) SHA1(9cb581d02592c69f37d4b5a902d3515f40915ec4) )
18321833   ROM_LOAD( "9.ic103",    0x10000, 0x10000, CRC(201cb748) SHA1(f78d384e4e9c5996a278f76fb4d5f28812a27de5) )
18331834
r2375r2376
23352336GAME( 1991, pspikesk, pspikes,  pspikes,  pspikes,  0, ROT0,   "Video System Co.", "Power Spikes (Korea)", GAME_NO_COCKTAIL )
23362337GAME( 1991, svolly91, pspikes,  pspikes,  pspikes,  0, ROT0,   "Video System Co.", "Super Volley '91 (Japan)", GAME_NO_COCKTAIL )
23372338GAME( 1991, pspikesb, pspikes,  pspikesb, pspikesb, 0, ROT0,   "bootleg",          "Power Spikes (bootleg)", GAME_NO_COCKTAIL )
2338GAME( 1991, pallavol, pspikes,  pallavol, pspikes,   0, ROT0,   "bootleg",          "Pallavolo (Italian Power Spikes bootleg)", GAME_NOT_WORKING | GAME_NO_SOUND | GAME_NO_COCKTAIL )
2339GAME( 1991, spikes91, pspikes,  spikes91, pspikes,  0, ROT0,   "bootleg",          "1991 Spikes (Italian bootleg)", GAME_NOT_WORKING | GAME_NO_SOUND | GAME_NO_COCKTAIL )
23392340GAME( 1991, pspikesc, pspikes,  pspikesc, pspikesc, 0, ROT0,   "bootleg",          "Power Spikes (China)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND )
23402341GAME( 1991, karatblz, 0,        karatblz, karatblz, 0, ROT0,   "Video System Co.", "Karate Blazers (World?)", GAME_NO_COCKTAIL )
23412342GAME( 1991, karatblu, karatblz, karatblz, karatblz, 0, ROT0,   "Video System Co.", "Karate Blazers (US)", GAME_NO_COCKTAIL )
r2375r2376
23452346GAME( 1992, aerofgtb, aerofgt,  aerofgtb, aerofgtb, 0, ROT270, "Video System Co.", "Aero Fighters (Turbo Force hardware set 1)", GAME_NO_COCKTAIL )
23462347GAME( 1992, aerofgtc, aerofgt,  aerofgtb, aerofgtb, 0, ROT270, "Video System Co.", "Aero Fighters (Turbo Force hardware set 2)", GAME_NO_COCKTAIL )
23472348GAME( 1992, sonicwi,  aerofgt,  aerofgtb, aerofgtb, 0, ROT270, "Video System Co.", "Sonic Wings (Japan)", GAME_NO_COCKTAIL )
2348GAME( 1992, aerfboot, aerofgt,  aerfboot, aerofgtb, 0, ROT270, "bootleg",          "Aero Fighters (bootleg)", GAME_NO_COCKTAIL | GAME_NO_SOUND | GAME_NOT_WORKING )
2349GAME( 1992, aerfboot, aerofgt,  aerfboot, aerofgtb, 0, ROT270, "bootleg",          "Aero Fighters (bootleg)", GAME_NO_COCKTAIL | GAME_NO_SOUND )
23492350GAME( 1997, wbbc97,   0,        wbbc97,   wbbc97,   0, ROT0,   "Comad",            "Beach Festival World Championship 1997", GAME_NO_COCKTAIL )
src/mame/drivers/fgoal.c
r2375r2376
8282static TIMER_CALLBACK( interrupt_callback )
8383{
8484   int scanline;
85   int coin = (readinputport(1) & 2);
85   int coin = (input_port_read_indexed(machine, 1) & 2);
8686
8787   cpunum_set_input_line(machine, 0, 0, ASSERT_LINE);
8888
r2375r2376
114114
115115static READ8_HANDLER( fgoal_analog_r )
116116{
117   return readinputport(2 + fgoal_player); /* PCB can be jumpered to use a single dial */
117   return input_port_read_indexed(machine, 2 + fgoal_player); /* PCB can be jumpered to use a single dial */
118118}
119119
120120
121121static READ8_HANDLER( fgoal_switches_r )
122122{
123123   if (video_screen_get_vpos(machine->primary_screen) & 0x80)
124      return readinputport(1) | 0x80;
124      return input_port_read_indexed(machine, 1) | 0x80;
125125   else
126      return readinputport(1);
126      return input_port_read_indexed(machine, 1);
127127}
128128
129129
src/mame/drivers/docastle.c
r2375r2376
105105a800      sound port 3
106106ac00      sound port 4
107107
108Note:
109idsoccer seems to run on a modified version of this board which allows for
110more sprite tiles, it also has a MSM5205 chip for sample playback.
108Notes:
109------
110- idsoccer seems to run on a modified version of this board which allows for
111  more sprite tiles, it also has a MSM5205 chip for sample playback.
111112
112***************************************************************************/
113TODO:
114-----
113115
114/*
116- third CPU
117- dip switch reading bug. dorunrun and docastle are VERY timing sensitive, and
118  dip switch reading will fail if the main CPU is running at the nominally correct
119  4MHz speed. This is kludge by slighly lowering the speed to 3.98MHz.
120- the dorunrun attract mode sequence is also very timing sensitive. The behaviour
121  of the "dorunru2" set, verified on the real board, with all dips in the OFF
122  position (easiest difficulty setting), should be, for the first 12 rounds of
123  demo play:
124  1) Mr do moves right. Kills all monsters and a letter 'E'.
125  2) Mr do moves Left. Picks up 'A' letter, but dies.
126  3) Mr do moves right. Kills all monsters.
127  4) Mr do moves left. Kills 'X' monster.
128  5) Mr do moves right.
129  6) Mr do moves left. Get 'T' monster.
130  7) Mr do moves right.
131  8) Mr do moves left. Kills 'E' monster - but already has this.
132  9) Mr do moves right.
133  10) Mr do moves left. Kills 'R' monster.
134  11) Mr do moves right.
135  12) Mr do moves. Kills 'A' monster. Shows winning extra Mr do.
115136
116    TODO:
137  Small changes to the CPU speed alter the demo timing and can cause the above
138  sequence not to work (e.g. Mr Do might not fill all monsters at once on the
139  first round). The 3.98MHz speed makes the sequence work.
140  Note that this only works in the dorunru2 set. The dorunrun set works slightly
141  differently, however it hasn't been compared with the real board so it might be
142  right.
143- unknown ports 0 and 2
144- bad communication in idsoccer
145- adpcm status in idsoccer
146- real values for the adpcm interface in idsoccer
147- handle flipscreen on/off based on address line A7 (cX0X/cX8X)
117148
118    - third CPU
119    - dip switch reading bug
120    - unknown ports 0 and 2
121    - bad communication in idsoccer
122    - adpcm status in idsoccer
123    - real values for the adpcm interface in idsoccer
124    - handle flipscreen on/off based on address line A7 (cX0X/cX8X)
149***************************************************************************/
125150
126*/
127
128151#include "driver.h"
129152#include "deprecat.h"
130153#include "sound/msm5205.h"
r2375r2376
628651static MACHINE_DRIVER_START( docastle )
629652   // basic machine hardware
630653//  MDRV_CPU_ADD_TAG("main", Z80, 4000000)  // 4 MHz
631   MDRV_CPU_ADD_TAG("main", Z80, 3900000)   // make dip switches work in docastle and dorunrun
654   MDRV_CPU_ADD_TAG("main", Z80, 3980000)   // make dip switches work in docastle and dorunrun and fix dorunru2 attract sequence
632655   MDRV_CPU_PROGRAM_MAP(docastle_map, 0)
633656   MDRV_CPU_IO_MAP(docastle_io_map, 0)
634657   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
src/mame/drivers/ultrsprt.c
r2375r2376
5252   UINT32 r = 0;
5353
5454   if (ACCESSING_BITS_24_31)
55      r |= (((EEPROM_read_bit()) << 1) | (readinputport(6) << 3)) << 24;
55      r |= (((EEPROM_read_bit()) << 1) | (input_port_read_indexed(machine, 6) << 3)) << 24;
5656
5757   return r;
5858}
r2375r2376
6969
7070static READ32_HANDLER( control1_r )
7171{
72   return (readinputport(0) << 28) | ((readinputport(1) & 0xfff) << 16) | (readinputport(2) & 0xfff);
72   return (input_port_read_indexed(machine, 0) << 28) | ((input_port_read_indexed(machine, 1) & 0xfff) << 16) | (input_port_read_indexed(machine, 2) & 0xfff);
7373}
7474
7575static READ32_HANDLER( control2_r )
7676{
77   return (readinputport(3) << 28) | ((readinputport(4) & 0xfff) << 16) | (readinputport(5) & 0xfff);
77   return (input_port_read_indexed(machine, 3) << 28) | ((input_port_read_indexed(machine, 4) & 0xfff) << 16) | (input_port_read_indexed(machine, 5) & 0xfff);
7878}
7979
8080static WRITE32_HANDLER( int_ack_w )
src/mame/drivers/hitme.c
r2375r2376
6868static VIDEO_UPDATE(hitme)
6969{
7070   /* the card width resistor comes from an input port, scaled to the range 0-25 kOhms */
71   double width_resist = readinputport(7) * 25000 / 100;
71   double width_resist = input_port_read_indexed(screen->machine, 7) * 25000 / 100;
7272   /* this triggers a oneshot for the following length of time */
7373   double width_duration = 0.45 * 1000e-12 * width_resist;
7474   /* the dot clock runs at the standard horizontal frequency * 320+16 clocks per scanline */
r2375r2376
126126 *
127127 *************************************/
128128
129static UINT8 read_port_and_t0(int port)
129static UINT8 read_port_and_t0(running_machine *machine, int port)
130130{
131   UINT8 val = readinputport(port);
131   UINT8 val = input_port_read_indexed(machine, port);
132132   if (attotime_compare(timer_get_time(), timeout_time) > 0)
133133      val ^= 0x80;
134134   return val;
r2375r2376
137137
138138static UINT8 read_port_and_t0_and_hblank(running_machine *machine, int port)
139139{
140   UINT8 val = read_port_and_t0(port);
140   UINT8 val = read_port_and_t0(machine, port);
141141   if (video_screen_get_hpos(machine->primary_screen) < (video_screen_get_width(machine->primary_screen) * 9 / 10))
142142      val ^= 0x04;
143143   return val;
r2375r2376
152152
153153static READ8_HANDLER( hitme_port_1_r )
154154{
155   return read_port_and_t0(1);
155   return read_port_and_t0(machine, 1);
156156}
157157
158158
r2375r2376
164164
165165static READ8_HANDLER( hitme_port_3_r )
166166{
167   return read_port_and_t0(3);
167   return read_port_and_t0(machine, 3);
168168}
169169
170170
r2375r2376
183183        In fact, it is very important that our timing calculation timeout AFTER the sound
184184        system's equivalent computation, or else we will hang notes.
185185    */
186   UINT8 raw_game_speed = readinputport(6);
186   UINT8 raw_game_speed = input_port_read_indexed(machine, 6);
187187   double resistance = raw_game_speed * 25000 / 100;
188188   attotime duration = attotime_make(0, ATTOSECONDS_PER_SECOND * 0.45 * 6.8e-6 * resistance * (data+1));
189189   timeout_time = attotime_add(timer_get_time(), duration);
src/mame/drivers/bzone.c
r2375r2376
252252
253253static INTERRUPT_GEN( bzone_interrupt )
254254{
255   if (readinputport(0) & 0x10)
255   if (input_port_read_indexed(machine, 0) & 0x10)
256256      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
257257}
258258
r2375r2376
268268{
269269   int res;
270270
271   res = readinputportbytag("IN0");
271   res = input_port_read(machine, "IN0");
272272
273273   if (activecpu_gettotalcycles() & 0x100)
274274      res |= IN0_3KHZ;
r2375r2376
299299
300300static READ8_HANDLER( redbaron_joy_r )
301301{
302   return readinputport(rb_input_select ? 5 : 6);
302   return input_port_read_indexed(machine, rb_input_select ? 5 : 6);
303303}
304304
305305
r2375r2376
807807static WRITE8_HANDLER( analog_select_w )
808808{
809809   if (offset <= 2)
810      analog_data = readinputport(6 + offset);
810      analog_data = input_port_read_indexed(machine, 6 + offset);
811811}
812812
813813
src/mame/drivers/segaxbd.c
r2375r2376
240240   int which = (iochip_regs[0][2] >> 2) & 7;
241241
242242   /* on the write, latch the selected input port and stash the value */
243   int value = readinputportbytag_safe(ports[which], 0x0010);
243   int value = input_port_read_safe(machine, ports[which], 0x0010);
244244
245245   /* reverse some port values */
246246   if (adc_reverse[which])
r2375r2376
300300                D6: /INTR of ADC0804
301301                D5-D0: CN C pin 24-19 (switch state 0= open, 1= closed)
302302            */
303         return iochip_r(0, 0, readinputport(0));
303         return iochip_r(0, 0, input_port_read_indexed(machine, 0));
304304
305305      case 1:
306306         /* I/O port: CN C pins 17,15,13,11,9,7,5,3 */
307         return iochip_r(0, 1, readinputport(1));
307         return iochip_r(0, 1, input_port_read_indexed(machine, 1));
308308
309309      case 2:
310310         /* Output port */
r2375r2376
375375   {
376376      case 0:
377377         /* Input port: switches, CN D pin A1-8 (switch state 1= open, 0= closed) */
378         return iochip_r(1, 0, readinputport(2));
378         return iochip_r(1, 0, input_port_read_indexed(machine, 2));
379379
380380      case 1:
381381         /* Input port: switches, CN D pin A9-16 (switch state 1= open, 0= closed) */
382         return iochip_r(1, 1, readinputport(3));
382         return iochip_r(1, 1, input_port_read_indexed(machine, 3));
383383
384384      case 2:
385385         /* Input port: DIP switches (1= off, 0= on) */
386         return iochip_r(1, 2, readinputport(4));
386         return iochip_r(1, 2, input_port_read_indexed(machine, 4));
387387
388388      case 3:
389389         /* Input port: DIP switches (1= off, 0= on) */
390         return iochip_r(1, 3, readinputport(5));
390         return iochip_r(1, 3, input_port_read_indexed(machine, 5));
391391
392392      case 4:
393393         /* Unused */
r2375r2376
21782178   ROM_LOAD( "epr12587.14",    0x00000, 0x8000, CRC(2afe648b) SHA1(b5bf86f3acbcc23c136185110acecf2c971294fa) )
21792179ROM_END
21802180
2181/**************************************************************************************************************************
2182    Super Monaco GP, Sega X-board
2183    CPU: FD1094 (317-0124a)
2184*/
2185ROM_START( smgpja )
2186   ROM_REGION( 0x80000, REGION_CPU1, 0 ) /* 68000 code */
2187   ROM_LOAD16_BYTE( "epr12432a.58", 0x00000, 0x20000, CRC(22517672) SHA1(db9ac40e83e9786bc9dad70f62c2080d3df694ee) )
2188   ROM_LOAD16_BYTE( "epr12433a.63", 0x00001, 0x20000, CRC(a46b5d13) SHA1(3a7de5cb6f3e6d726f0ea886a87125dedc6f849f) )
21812189
2190   ROM_REGION( 0x2000, REGION_USER1, 0 )   /* decryption key */
2191   ROM_LOAD( "317-0124a.key", 0x0000, 0x2000, CRC(022a8a16) SHA1(4fd80105cb85ccba77cf1e76a21d6e245d5d2e7d) )
2192
2193   ROM_REGION( 0x80000, REGION_CPU2, 0 ) /* 2nd 68000 code */
2194   ROM_LOAD16_BYTE( "epr12441a.20", 0x00000, 0x20000, CRC(2c9599c1) SHA1(79206f38c2976bd9299ed37bf62ac26dd3fba801) )
2195   ROM_LOAD16_BYTE( "epr12442a.29", 0x00001, 0x20000, CRC(77a5ec16) SHA1(b8cf6a3f12689d89bbdd9fb39d1cb7d1a3c10602) )
2196
2197   ROM_REGION( 0x30000, REGION_GFX1, ROMREGION_DISPOSE ) /* tiles */
2198   ROM_LOAD( "epr12429.154", 0x00000, 0x10000, CRC(5851e614) SHA1(3dc97237ede2c6125e92ea6efc68a748d0ec69be) )
2199   ROM_LOAD( "epr12430.153", 0x10000, 0x10000, CRC(05e00134) SHA1(8baaa80815d5dabd38dc8600e357975b96d23b95) )
2200   ROM_LOAD( "epr12431.152", 0x20000, 0x10000, CRC(35572f4a) SHA1(d66456ecf7b59f81736fb873c553926b56bb3977))
2201
2202   ROM_REGION32_LE( 0x200000, REGION_GFX2, 0 ) /* sprites */
2203   ROM_LOAD32_BYTE( "mpr12425.90",  0x000000, 0x20000, CRC(14bf2a15) SHA1(84db3ac09e4a8fe470ac051d8d5de1814b48bc72) )
2204   ROM_LOAD32_BYTE( "mpr12426.94",  0x000001, 0x20000, CRC(28b60dc0) SHA1(ad69d449434853445a076319a55a29014217a100) )
2205   ROM_LOAD32_BYTE( "mpr12427.98",  0x000002, 0x20000, CRC(0a367928) SHA1(bcb558b7c23906397e66a7f046b09eb5036c0888) )
2206   ROM_LOAD32_BYTE( "mpr12428.102", 0x000003, 0x20000, CRC(efa80ad5) SHA1(9bc7c3fb60cc076f29a0af487d58e5b48f1c4b06) )
2207   ROM_LOAD32_BYTE( "mpr12421.91",  0x080000, 0x20000, CRC(25f46140) SHA1(ea75e364cf52636d100158f79be627e36da8c327) )
2208   ROM_LOAD32_BYTE( "mpr12422.95",  0x080001, 0x20000, CRC(cb51c8f6) SHA1(5af56ae1916c3212b8d5b9e4bccbbe1916694f89) )
2209   ROM_LOAD32_BYTE( "mpr12423.99",  0x080002, 0x20000, CRC(0be9818e) SHA1(637a8201416e73d53f7e2502ea0a5277e43c167d) )
2210   ROM_LOAD32_BYTE( "mpr12424.103", 0x080003, 0x20000, CRC(0ce00dfc) SHA1(3b1990977ec7ad4c3bea66527707cff2cd8d5a98) )
2211   ROM_LOAD32_BYTE( "mpr12417.92",  0x100000, 0x20000, CRC(a806eabf) SHA1(1a61a2135d92b42ee131fd3240bc8a17a96696ab) )
2212   ROM_LOAD32_BYTE( "mpr12418.96",  0x100001, 0x20000, CRC(ed1a0f2b) SHA1(1aa87292ca0465fa129d6be81d95dbb77332ecab) )
2213   ROM_LOAD32_BYTE( "mpr12419.100", 0x100002, 0x20000, CRC(ce4568cb) SHA1(1ed66e74ce94d41593b498827d9cc243f775d4ba) )
2214   ROM_LOAD32_BYTE( "mpr12420.104", 0x100003, 0x20000, CRC(679442eb) SHA1(f88ef0219497f955d8db6783f3636dad52928f46) )
2215   ROM_LOAD32_BYTE( "epr12413.93",  0x180000, 0x20000, CRC(2f1693df) SHA1(ba1e654a1b5fae661b0dae4a8ed04ff50fb546a2) )
2216   ROM_LOAD32_BYTE( "epr12414.97",  0x180001, 0x20000, CRC(c78f3d45) SHA1(665750907ed11c89c2ea5c410eac2808445131ae) )
2217   ROM_LOAD32_BYTE( "epr12415.101", 0x180002, 0x20000, CRC(6080e9ed) SHA1(eb1b871453f76e6a65d20fa9d4bddc1c9f940b4d) )
2218   ROM_LOAD32_BYTE( "epr12416.105", 0x180003, 0x20000, CRC(6f1f2769) SHA1(d00d26cd1052d4b46c432b6b69cb2d83179d52a6) )
2219
2220   ROM_REGION( 0x10000, REGION_GFX3, ROMREGION_ERASE00 ) /* road gfx */
2221   /* none?? */
2222
2223   ROM_REGION( 0x10000, REGION_CPU3, 0 ) /* sound CPU */
2224   ROM_LOAD( "epr12436.17",    0x00000, 0x10000, CRC(16ec5f0a) SHA1(307b7388b5c36fd4bc2a61f7941db44858e03c5c) )
2225
2226   ROM_REGION( 0x80000, REGION_SOUND1, ROMREGION_ERASEFF ) /* Sega PCM sound data */
2227   ROM_LOAD( "mpr12437.11",    0x00000, 0x20000, CRC(a1c7e712) SHA1(fa7fa8c39690ae5dab8b28af5aeed5ffae2cd6de) )
2228   ROM_LOAD( "mpr12438.12",    0x20000, 0x20000, CRC(6573d46b) SHA1(c4a4a0ea35250eff28a5bfd5e9cd372f52fd1308) )
2229   ROM_LOAD( "mpr12439.13",    0x40000, 0x20000, CRC(13bf6de5) SHA1(92228a05ec33d606491a1da98c4989f69cddbb49) )
2230
2231   ROM_REGION( 0x10000, REGION_CPU4, 0 ) /* comms */
2232   ROM_LOAD( "epr12587.14",    0x00000, 0x8000, CRC(2afe648b) SHA1(b5bf86f3acbcc23c136185110acecf2c971294fa) )
2233ROM_END
2234
2235
21822236/**************************************************************************************************************************
21832237 **************************************************************************************************************************
21842238 **************************************************************************************************************************
r2375r2376
24232477GAME( 1989, loffireu, loffire,  xboard,  loffire,  loffire,        ROT0, "Sega", "Line of Fire / Bakudan Yarou (US, FD1094 317-0135)", 0 )
24242478GAME( 1989, loffirej, loffire,  xboard,  loffire,  loffire,        ROT0, "Sega", "Line of Fire / Bakudan Yarou (Japan, FD1094 317-0134)", 0 )
24252479GAME( 1989, rachero,  0,        xboard,  rachero,  generic_xboard, ROT0, "Sega", "Racing Hero (FD1094 317-0144)", 0 )
2426GAME( 1989, smgp,     0,        smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 8, World, Rev B, 'Twin', FD1094 317-0126a)", 0 )
2427GAME( 1989, smgp6,    smgp,     smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 7, World, Rev A, FD1094 317-0126a)", 0 )
2428GAME( 1989, smgp5,    smgp,     smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 6, World, 'Air Drive Cabinet', FD1094 317-0126)", 0 )
2429GAME( 1989, smgpu,    smgp,     smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 5, US, Rev C, FD1094 317-0125a)", 0 )
2430GAME( 1989, smgpu1,   smgp,     smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 4, US, Rev B, FD1094 317-0125a)", 0 )
2431GAME( 1989, smgpu2,   smgp,     smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 3, US, Rev A, FD1094 317-0125a)", 0 )
2432GAME( 1989, smgpu3,   smgp,     smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 2, US, FD1094 317-0125a)", 0 )
2433GAME( 1989, smgpj,    smgp,     smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 1, Japan, Rev B, FD1094 317-0124a)", 0 )
2480GAME( 1989, smgp,     0,        smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 9, World, Rev B, 'Twin', FD1094 317-0126a)", 0 )
2481GAME( 1989, smgp6,    smgp,     smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 8, World, Rev A, FD1094 317-0126a)", 0 )
2482GAME( 1989, smgp5,    smgp,     smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 7, World, 'Air Drive Cabinet', FD1094 317-0126)", 0 )
2483GAME( 1989, smgpu,    smgp,     smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 6, US, Rev C, FD1094 317-0125a)", 0 )
2484GAME( 1989, smgpu1,   smgp,     smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 5, US, Rev B, FD1094 317-0125a)", 0 )
2485GAME( 1989, smgpu2,   smgp,     smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 4, US, Rev A, FD1094 317-0125a)", 0 )
2486GAME( 1989, smgpu3,   smgp,     smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 3, US, FD1094 317-0125a)", 0 )
2487GAME( 1989, smgpj,    smgp,     smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 2, Japan, Rev B, FD1094 317-0124a)", 0 )
2488GAME( 1989, smgpja,   smgp,     smgp,    smgp,     smgp,           ROT0, "Sega", "Super Monaco GP (set 1, Japan, Rev A, FD1094 317-0124a)", 0 )
24342489GAME( 1990, abcop,    0,        xboard,  abcop,    generic_xboard, ROT0, "Sega", "A.B. Cop (FD1094 317-0169b)", 0 )
24352490GAME( 1990, gprider,  0,        xboard,  gprider,  gprider,        ROT0, "Sega", "GP Rider (set 2, World, FD1094 317-0163)", GAME_NOT_WORKING ) // no prg roms
24362491GAME( 1990, gprider1, gprider,  xboard,  gprider,  gprider,        ROT0, "Sega", "GP Rider (set 1, US, FD1094 317-0162)", 0 )
src/mame/drivers/nbmj9195.c
r2375r2376
117117   nbmj9195_inputport = (data ^ 0xff);
118118}
119119
120static int nbmj9195_dipsw_r(void)
120static int nbmj9195_dipsw_r(running_machine *machine)
121121{
122   return ((((readinputport(0) & 0xff) | ((readinputport(1) & 0xff) << 8)) >> nbmj9195_dipswbitsel) & 0x01);
122   return ((((input_port_read_indexed(machine, 0) & 0xff) | ((input_port_read_indexed(machine, 1) & 0xff) << 8)) >> nbmj9195_dipswbitsel) & 0x01);
123123}
124124
125125static void nbmj9195_dipswbitsel_w(int data)
r2375r2376
149149static READ8_HANDLER( mscoutm_dipsw_0_r )
150150{
151151   // DIPSW A
152   return (((readinputport(0) & 0x01) << 7) | ((readinputport(0) & 0x02) << 5) |
153           ((readinputport(0) & 0x04) << 3) | ((readinputport(0) & 0x08) << 1) |
154           ((readinputport(0) & 0x10) >> 1) | ((readinputport(0) & 0x20) >> 3) |
155           ((readinputport(0) & 0x40) >> 5) | ((readinputport(0) & 0x80) >> 7));
152   return (((input_port_read_indexed(machine, 0) & 0x01) << 7) | ((input_port_read_indexed(machine, 0) & 0x02) << 5) |
153           ((input_port_read_indexed(machine, 0) & 0x04) << 3) | ((input_port_read_indexed(machine, 0) & 0x08) << 1) |
154           ((input_port_read_indexed(machine, 0) & 0x10) >> 1) | ((input_port_read_indexed(machine, 0) & 0x20) >> 3) |
155           ((input_port_read_indexed(machine, 0) & 0x40) >> 5) | ((input_port_read_indexed(machine, 0) & 0x80) >> 7));
156156}
157157
158158static READ8_HANDLER( mscoutm_dipsw_1_r )
159159{
160160   // DIPSW B
161   return (((readinputport(1) & 0x01) << 7) | ((readinputport(1) & 0x02) << 5) |
162           ((readinputport(1) & 0x04) << 3) | ((readinputport(1) & 0x08) << 1) |
163           ((readinputport(1) & 0x10) >> 1) | ((readinputport(1) & 0x20) >> 3) |
164           ((readinputport(1) & 0x40) >> 5) | ((readinputport(1) & 0x80) >> 7));
161   return (((input_port_read_indexed(machine, 1) & 0x01) << 7) | ((input_port_read_indexed(machine, 1) & 0x02) << 5) |
162           ((input_port_read_indexed(machine, 1) & 0x04) << 3) | ((input_port_read_indexed(machine, 1) & 0x08) << 1) |
163           ((input_port_read_indexed(machine, 1) & 0x10) >> 1) | ((input_port_read_indexed(machine, 1) & 0x20) >> 3) |
164           ((input_port_read_indexed(machine, 1) & 0x40) >> 5) | ((input_port_read_indexed(machine, 1) & 0x80) >> 7));
165165}
166166
167167
r2375r2376
182182      {
183183         case 0:         /* PA_0 */
184184            // COIN IN, ETC...
185            portdata = readinputport(2);
185            portdata = input_port_read_indexed(machine, 2);
186186            break;
187187         case 1:         /* PB_0 */
188188            // PLAYER1 KEY, DIPSW A/B
189189            switch (mscoutm_inputport)
190190            {
191191               case 0x01:
192                  portdata = readinputport(3);
192                  portdata = input_port_read_indexed(machine, 3);
193193                  break;
194194               case 0x02:
195                  portdata = readinputport(4);
195                  portdata = input_port_read_indexed(machine, 4);
196196                  break;
197197               case 0x04:
198                  portdata = readinputport(5);
198                  portdata = input_port_read_indexed(machine, 5);
199199                  break;
200200               case 0x08:
201                  portdata = readinputport(6);
201                  portdata = input_port_read_indexed(machine, 6);
202202                  break;
203203               case 0x10:
204                  portdata = readinputport(7);
204                  portdata = input_port_read_indexed(machine, 7);
205205                  break;
206206               default:
207                  portdata = (readinputport(3) & readinputport(4) & readinputport(5) & readinputport(6) & readinputport(7));
207                  portdata = (input_port_read_indexed(machine, 3) & input_port_read_indexed(machine, 4) & input_port_read_indexed(machine, 5) & input_port_read_indexed(machine, 6) & input_port_read_indexed(machine, 7));
208208                  break;
209209            }
210210            break;
r2375r2376
213213            switch (mscoutm_inputport)
214214            {
215215               case 0x01:
216                  portdata = readinputport(8);
216                  portdata = input_port_read_indexed(machine, 8);
217217                  break;
218218               case 0x02:
219                  portdata = readinputport(9);
219                  portdata = input_port_read_indexed(machine, 9);
220220                  break;
221221               case 0x04:
222                  portdata = readinputport(10);
222                  portdata = input_port_read_indexed(machine, 10);
223223                  break;
224224               case 0x08:
225                  portdata = readinputport(11);
225                  portdata = input_port_read_indexed(machine, 11);
226226                  break;
227227               case 0x10:
228                  portdata = readinputport(12);
228                  portdata = input_port_read_indexed(machine, 12);
229229                  break;
230230               default:
231                  portdata = (readinputport(8) & readinputport(9) & readinputport(10) & readinputport(11) & readinputport(12));
231                  portdata = (input_port_read_indexed(machine, 8) & input_port_read_indexed(machine, 9) & input_port_read_indexed(machine, 10) & input_port_read_indexed(machine, 11) & input_port_read_indexed(machine, 12));
232232                  break;
233233            }
234234            break;
r2375r2376
267267      {
268268         case 0:         /* PA_0 */
269269            // COIN IN, ETC...
270            portdata = ((readinputport(2) & 0xfe) | nbmj9195_outcoin_flag);
270            portdata = ((input_port_read_indexed(machine, 2) & 0xfe) | nbmj9195_outcoin_flag);
271271            break;
272272         case 1:         /* PB_0 */
273273            // PLAYER1 KEY, DIPSW A/B
274274            switch (nbmj9195_inputport)
275275            {
276276               case 0x01:
277                  portdata = readinputport(3);
277                  portdata = input_port_read_indexed(machine, 3);
278278                  break;
279279               case 0x02:
280                  portdata = readinputport(4);
280                  portdata = input_port_read_indexed(machine, 4);
281281                  break;
282282               case 0x04:
283                  portdata = readinputport(5);
283                  portdata = input_port_read_indexed(machine, 5);
284284                  break;
285285               case 0x08:
286                  portdata = readinputport(6);
286                  portdata = input_port_read_indexed(machine, 6);
287287                  break;
288288               case 0x10:
289                  portdata = ((readinputport(7) & 0x7f) | (nbmj9195_dipsw_r() << 7));
289                  portdata = ((input_port_read_indexed(machine, 7) & 0x7f) | (nbmj9195_dipsw_r(machine) << 7));
290290                  break;
291291               default:
292                  portdata = (readinputport(3) & readinputport(4) & readinputport(5) & readinputport(6) & (readinputport(12) & 0x7f));
292                  portdata = (input_port_read_indexed(machine, 3) & input_port_read_indexed(machine, 4) & input_port_read_indexed(machine, 5) & input_port_read_indexed(machine, 6) & (input_port_read_indexed(machine, 12) & 0x7f));
293293                  break;
294294            }
295295            break;
r2375r2376
298298            switch (nbmj9195_inputport)
299299            {
300300               case 0x01:
301                  portdata = readinputport(8);
301                  portdata = input_port_read_indexed(machine, 8);
302302                  break;
303303               case 0x02:
304                  portdata = readinputport(9);
304                  portdata = input_port_read_indexed(machine, 9);
305305                  break;
306306               case 0x04:
307                  portdata = readinputport(10);
307                  portdata = input_port_read_indexed(machine, 10);
308308                  break;
309309               case 0x08:
310                  portdata = readinputport(11);
310                  portdata = input_port_read_indexed(machine, 11);
311311                  break;
312312               case 0x10:
313                  portdata = readinputport(12) & 0x7f;
313                  portdata = input_port_read_indexed(machine, 12) & 0x7f;
314314                  break;
315315               default:
316                  portdata = (readinputport(8) & readinputport(9) & readinputport(10) & readinputport(11) & (readinputport(12) & 0x7f));
316                  portdata = (input_port_read_indexed(machine, 8) & input_port_read_indexed(machine, 9) & input_port_read_indexed(machine, 10) & input_port_read_indexed(machine, 11) & (input_port_read_indexed(machine, 12) & 0x7f));
317317                  break;
318318            }
319319            break;
src/mame/drivers/sonson.c
r2375r2376
5353#include "sound/ay8910.h"
5454
5555
56extern UINT8 *sonson_scroll;
57
5856WRITE8_HANDLER( sonson_videoram_w );
5957WRITE8_HANDLER( sonson_colorram_w );
60WRITE8_HANDLER( sonson_scroll_w );
58WRITE8_HANDLER( sonson_scrollx_w );
6159WRITE8_HANDLER( sonson_flipscreen_w );
6260
6361PALETTE_INIT( sonson );
r2375r2376
6866{
6967   static int last;
7068
69   data &= 1;
70
7171   if (last == 0 && data == 1)
7272   {
7373      /* setting bit 0 low then high triggers IRQ on the sound CPU */
r2375r2376
7979
8080
8181
82static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 )
83   AM_RANGE(0x0000, 0x17ff) AM_READ(SMH_RAM)
84   AM_RANGE(0x4000, 0xffff) AM_READ(SMH_ROM)
82static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
83   AM_RANGE(0x0000, 0x0fff) AM_RAM
84   AM_RANGE(0x1000, 0x13ff) AM_RAM AM_WRITE(sonson_videoram_w) AM_BASE(&videoram) AM_SIZE(&videoram_size)
85   AM_RANGE(0x1400, 0x17ff) AM_RAM AM_WRITE(sonson_colorram_w) AM_BASE(&colorram)
86   AM_RANGE(0x2020, 0x207f) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
87   AM_RANGE(0x3000, 0x3000) AM_WRITE(sonson_scrollx_w)
8588   AM_RANGE(0x3002, 0x3002) AM_READ(input_port_0_r)   /* IN0 */
8689   AM_RANGE(0x3003, 0x3003) AM_READ(input_port_1_r)   /* IN1 */
8790   AM_RANGE(0x3004, 0x3004) AM_READ(input_port_2_r)   /* IN2 */
8891   AM_RANGE(0x3005, 0x3005) AM_READ(input_port_3_r)   /* DSW0 */
8992   AM_RANGE(0x3006, 0x3006) AM_READ(input_port_4_r)   /* DSW1 */
90ADDRESS_MAP_END
91
92static ADDRESS_MAP_START( writemem, ADDRESS_SPACE_PROGRAM, 8 )
93   AM_RANGE(0x0000, 0x0fff) AM_WRITE(SMH_RAM)
94   AM_RANGE(0x1000, 0x13ff) AM_WRITE(sonson_videoram_w) AM_BASE(&videoram) AM_SIZE(&videoram_size)
95   AM_RANGE(0x1400, 0x17ff) AM_WRITE(sonson_colorram_w) AM_BASE(&colorram)
96   AM_RANGE(0x2020, 0x207f) AM_WRITE(SMH_RAM) AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
97   AM_RANGE(0x3000, 0x3000) AM_WRITE(SMH_RAM) AM_BASE(&sonson_scroll)
98   AM_RANGE(0x3008, 0x3008) AM_WRITE(SMH_NOP)
93   AM_RANGE(0x3008, 0x3008) AM_WRITENOP   // might be Y scroll, but the game always sets it to 0
9994   AM_RANGE(0x3010, 0x3010) AM_WRITE(soundlatch_w)
10095   AM_RANGE(0x3018, 0x3018) AM_WRITE(sonson_flipscreen_w)
10196   AM_RANGE(0x3019, 0x3019) AM_WRITE(sonson_sh_irqtrigger_w)
102   AM_RANGE(0x4000, 0xffff) AM_WRITE(SMH_ROM)
97   AM_RANGE(0x4000, 0xffff) AM_ROM
10398ADDRESS_MAP_END
10499
105static ADDRESS_MAP_START( sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
106   AM_RANGE(0x0000, 0x07ff) AM_READ(SMH_RAM)
107   AM_RANGE(0xa000, 0xa000) AM_READ(soundlatch_r)
108   AM_RANGE(0xe000, 0xffff) AM_READ(SMH_ROM)
109ADDRESS_MAP_END
110
111static ADDRESS_MAP_START( sound_writemem, ADDRESS_SPACE_PROGRAM, 8 )
112   AM_RANGE(0x0000, 0x07ff) AM_WRITE(SMH_RAM)
100static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
101   AM_RANGE(0x0000, 0x07ff) AM_RAM
113102   AM_RANGE(0x2000, 0x2000) AM_WRITE(AY8910_control_port_0_w)
114103   AM_RANGE(0x2001, 0x2001) AM_WRITE(AY8910_write_port_0_w)
115104   AM_RANGE(0x4000, 0x4000) AM_WRITE(AY8910_control_port_1_w)
116105   AM_RANGE(0x4001, 0x4001) AM_WRITE(AY8910_write_port_1_w)
117   AM_RANGE(0xe000, 0xffff) AM_WRITE(SMH_ROM)
106   AM_RANGE(0xa000, 0xa000) AM_READ(soundlatch_r)
107   AM_RANGE(0xe000, 0xffff) AM_ROM
118108ADDRESS_MAP_END
119109
120110
r2375r2376
239229
240230   /* basic machine hardware */
241231   MDRV_CPU_ADD(M6809,12000000/6)   /* 2 MHz ??? */
242   MDRV_CPU_PROGRAM_MAP(readmem,writemem)
232   MDRV_CPU_PROGRAM_MAP(main_map,0)
243233   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
244234
245235   MDRV_CPU_ADD(M6809,12000000/6)
246236   /* audio CPU */   /* 2 MHz ??? */
247   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
237   MDRV_CPU_PROGRAM_MAP(sound_map,0)
248238   MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold,4)   /* FIRQs are triggered by the main CPU */
249239
250240
251241   /* video hardware */
252242   MDRV_SCREEN_ADD("main", RASTER)
253243   MDRV_SCREEN_REFRESH_RATE(60)
254   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
255244   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
256245   MDRV_SCREEN_SIZE(32*8, 32*8)
257246   MDRV_SCREEN_VISIBLE_AREA(1*8, 31*8-1, 1*8, 31*8-1)
src/mame/drivers/simpl156.c
r2375r2376
141141   int eep = EEPROM_read_bit();
142142   UINT32 returndata;
143143
144   returndata = readinputport(0)^0xffff0000;
144   returndata = input_port_read_indexed(machine, 0)^0xffff0000;
145145
146146   returndata^= ( (eep<<8)  );
147147   return returndata;
r2375r2376
172172{
173173   UINT32 returndata;
174174
175   returndata = readinputport(1);
175   returndata = input_port_read_indexed(machine, 1);
176176
177177   return returndata;
178178}
src/mame/drivers/deadang.c
r2375r2376
5353
5454static READ16_HANDLER( ghunter_trackball_low_r )
5555{
56   return (readinputport(3) & 0xff) | ((readinputport(4) & 0xff) << 8);
56   return (input_port_read_indexed(machine, 3) & 0xff) | ((input_port_read_indexed(machine, 4) & 0xff) << 8);
5757}
5858static READ16_HANDLER( ghunter_trackball_high_r )
5959{
60   return ((readinputport(3) & 0x0f00) >> 4) | (readinputport(4) & 0x0f00);
60   return ((input_port_read_indexed(machine, 3) & 0x0f00) >> 4) | (input_port_read_indexed(machine, 4) & 0x0f00);
6161}
6262
6363/* Memory Maps */
src/mame/drivers/cliffhgr.c
r2375r2376
165165{
166166   if ( port_bank < 7 )
167167   {
168      return readinputport( port_bank );
168      return input_port_read_indexed(machine, port_bank );
169169   }
170170
171171   /* output is pulled up for non-mapped ports */
src/mame/drivers/copsnrob.c
r2375r2376
8282
8383static READ8_HANDLER( copsnrob_misc_r )
8484{
85   return misc | (readinputport(0) & 0x80);
85   return misc | (input_port_read_indexed(machine, 0) & 0x80);
8686}
8787
8888static WRITE8_HANDLER( copsnrob_misc_w )
src/mame/drivers/artmagic.c
r2375r2376
148148      hack_irq = 0;
149149      update_irq_state(Machine);
150150   }
151   return readinputport(0);
151   return input_port_read_indexed(machine, 0);
152152}
153153
154154
r2375r2376
378378
379379static READ16_HANDLER( special_port5_r )
380380{
381   return readinputport(5) | prot_output_bit;
381   return input_port_read_indexed(machine, 5) | prot_output_bit;
382382}
383383
384384
src/mame/drivers/twincobr.c
r2375r2376
10801080
10811081static DRIVER_INIT( twincobr )
10821082{
1083   twincobr_driver_savestate();
1083   twincobr_driver_savestate(machine);
10841084}
10851085
10861086
src/mame/drivers/arabian.c
r2375r2376
148148      case 3:
149149      case 4:
150150      case 5:
151         return readinputport(2 + offset);
151         return input_port_read_indexed(machine, 2 + offset);
152152
153153      /* busy flag; this is polled to check the custom CPU's readiness */
154154      /* we just toggle it on and off until the main CPU gets the result */
src/mame/drivers/hornet.c
r2375r2376
596596      if (ACCESSING_BITS_24_31)
597597      {
598598         //printf("read sysreg 0\n");
599         r |= readinputport(0) << 24;
599         r |= input_port_read_indexed(machine, 0) << 24;
600600      }
601601      if (ACCESSING_BITS_16_23)
602602      {
603         r |= readinputport(1) << 16;
603         r |= input_port_read_indexed(machine, 1) << 16;
604604      }
605605      if (ACCESSING_BITS_8_15)
606606      {
607         r |= readinputport(2) << 8;
607         r |= input_port_read_indexed(machine, 2) << 8;
608608      }
609609      if (ACCESSING_BITS_0_7)
610610      {
r2375r2376
615615   {
616616      if (ACCESSING_BITS_24_31)
617617      {
618         r |= readinputport(3) << 24;
618         r |= input_port_read_indexed(machine, 3) << 24;
619619      }
620620   }
621621   return r;
src/mame/drivers/thief.c
r2375r2376
5353static INTERRUPT_GEN( thief_interrupt )
5454{
5555   /* SLAM switch causes an NMI if it's pressed */
56   if( (input_port_3_r(machine,0) & 0x10) == 0 )
56   if( (input_port_read_indexed(machine, 3) & 0x10) == 0 )
5757      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
5858   else
5959      cpunum_set_input_line(machine, 0, 0, HOLD_LINE);
r2375r2376
158158{
159159   switch( thief_input_select )
160160   {
161      case 0x01: return readinputport(0); /* dsw#1 */
162      case 0x02: return readinputport(1); /* dsw#2 */
163      case 0x04: return readinputport(2); /* inp#1 */
164      case 0x08: return readinputport(3); /* inp#2 */
161      case 0x01: return input_port_read_indexed(machine, 0); /* dsw#1 */
162      case 0x02: return input_port_read_indexed(machine, 1); /* dsw#2 */
163      case 0x04: return input_port_read_indexed(machine, 2); /* inp#1 */
164      case 0x08: return input_port_read_indexed(machine, 3); /* inp#2 */
165165   }
166166   return 0x00;
167167}
src/mame/drivers/ccastles.c
r2375r2376
291291
292292static READ8_HANDLER( leta_r )
293293{
294   return readinputport(2 + offset);
294   return input_port_read_indexed(machine, 2 + offset);
295295}
296296
297297
src/mame/drivers/sprint2.c
r2375r2376
4747}
4848
4949
50static int service_mode(void)
50static int service_mode(running_machine *machine)
5151{
52   UINT8 v = readinputport(2);
52   UINT8 v = input_port_read_indexed(machine, 2);
5353
5454   if (GAME_IS_SPRINT1)
5555   {
r2375r2376
8080
8181      for (i = 0; i < 2; i++)
8282      {
83         signed char delta = readinputport(6 + i) - dial[i];
83         signed char delta = input_port_read_indexed(machine, 6 + i) - dial[i];
8484
8585         if (delta < 0)
8686         {
r2375r2376
9393
9494         dial[i] += delta;
9595
96         switch (readinputport(4 + i) & 15)
96         switch (input_port_read_indexed(machine, 4 + i) & 15)
9797         {
9898         case 1: gear[i] = 1; break;
9999         case 2: gear[i] = 2; break;
r2375r2376
109109
110110   /* interrupts and watchdog are disabled during service mode */
111111
112   watchdog_enable(machine, !service_mode());
112   watchdog_enable(machine, !service_mode(machine));
113113
114   if (!service_mode())
114   if (!service_mode(machine))
115115      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
116116}
117117
r2375r2376
124124
125125static READ8_HANDLER( sprint2_dip_r )
126126{
127   return (readinputport(0) << (2 * ((offset & 3) ^ 3))) & 0xc0;
127   return (input_port_read_indexed(machine, 0) << (2 * ((offset & 3) ^ 3))) & 0xc0;
128128}
129129
130130
131131static READ8_HANDLER( sprint2_input_A_r )
132132{
133   UINT8 val = readinputport(1);
133   UINT8 val = input_port_read_indexed(machine, 1);
134134
135135   if (GAME_IS_SPRINT2)
136136   {
r2375r2376
148148
149149static READ8_HANDLER( sprint2_input_B_r )
150150{
151   UINT8 val = readinputport(2);
151   UINT8 val = input_port_read_indexed(machine, 2);
152152
153153   if (GAME_IS_SPRINT1)
154154   {
src/mame/drivers/exterm.c
r2375r2376
140140   UINT16 port;
141141
142142   /* Read the fake input port */
143   UINT8 trackball_pos = readinputport(3 + which);
143   UINT8 trackball_pos = input_port_read_indexed(machine, 3 + which);
144144
145145   /* Calculate the change from the last position. */
146146   UINT8 trackball_diff = trackball_old[which] - trackball_pos;
src/mame/drivers/dragrace.c
r2375r2376
2020
2121   for (i = 0; i < 2; i++)
2222   {
23      switch (readinputport(5 + i))
23      switch (input_port_read_indexed(machine, 5 + i))
2424      {
2525      case 0x01: dragrace_gear[i] = 1; break;
2626      case 0x02: dragrace_gear[i] = 2; break;
r2375r2376
3131   }
3232
3333   /* watchdog is disabled during service mode */
34   watchdog_enable(machine, readinputport(0) & 0x20);
34   watchdog_enable(machine, input_port_read_indexed(machine, 0) & 0x20);
3535}
3636
3737
r2375r2376
116116
117117static READ8_HANDLER( dragrace_input_r )
118118{
119   int val = readinputport(2);
119   int val = input_port_read_indexed(machine, 2);
120120
121121   UINT8 maskA = 1 << (offset % 8);
122122   UINT8 maskB = 1 << (offset / 8);
r2375r2376
125125
126126   for (i = 0; i < 2; i++)
127127   {
128      int in = readinputport(i);
128      int in = input_port_read_indexed(machine, i);
129129
130130      if (dragrace_gear[i] != 0)
131131      {
r2375r2376
151151
152152   for (i = 0; i < 2; i++)
153153   {
154      int dial = readinputport(3 + i);
154      int dial = input_port_read_indexed(machine, 3 + i);
155155
156156      bitA[i] = ((dial + 1) / 2) & 1;
157157      bitB[i] = ((dial + 0) / 2) & 1;
src/mame/drivers/mediagx.c
r2375r2376
508508
509509   if (ACCESSING_BITS_8_15)
510510   {
511      UINT8 nibble = parallel_latched;//(readinputport(parallel_pointer / 3) >> (4 * (parallel_pointer % 3))) & 15;
511      UINT8 nibble = parallel_latched;//(input_port_read_indexed(machine, parallel_pointer / 3) >> (4 * (parallel_pointer % 3))) & 15;
512512      r |= ((~nibble & 0x08) << 12) | ((nibble & 0x07) << 11);
513513      logerror("%08X:parallel_port_r()\n", activecpu_get_pc());
514514/*      if (controls_data == 0x18)
515515        {
516            r |= readinputport(0) << 8;
516            r |= input_port_read_indexed(machine, 0) << 8;
517517        }
518518        else if (controls_data == 0x60)
519519        {
520            r |= readinputport(1) << 8;
520            r |= input_port_read_indexed(machine, 1) << 8;
521521        }
522522        else if (controls_data == 0xff ||  controls_data == 0x50)
523523        {
524            r |= readinputport(2) << 8;
524            r |= input_port_read_indexed(machine, 2) << 8;
525525        }
526526
527527        //r |= control_read << 8;*/
r2375r2376
557557
558558      logerror("%08X:", activecpu_get_pc());
559559
560      parallel_latched = (readinputport(parallel_pointer / 3) >> (4 * (parallel_pointer % 3))) & 15;
560      parallel_latched = (input_port_read_indexed(machine, parallel_pointer / 3) >> (4 * (parallel_pointer % 3))) & 15;
561561//      parallel_pointer++;
562562//      logerror("[%02X] Advance pointer to %d\n", data, parallel_pointer);
563563      switch (data & 0xfc)
r2375r2376
814814
815815static const struct dma8237_interface dma8237_2_config =
816816{
817   0,
818   1.0e-6, // 1us
817   0,
818   1.0e-6, // 1us
819819
820820   NULL,
821821   NULL,
r2375r2376
10661066   pic8259_set_irq_line(1, 6, state);
10671067}
10681068
1069static int mediagx_get_out2(running_machine *machine) {
1070   return pit8253_get_output((device_config*)device_list_find_by_tag( machine->config->devicelist, PIT8254, "pit8254" ), 2 );
1071}
1072
10691073static const struct kbdc8042_interface at8042 =
10701074{
1071   KBDC8042_AT386, set_gate_a20, keyboard_interrupt
1075   KBDC8042_AT386, set_gate_a20, keyboard_interrupt, mediagx_get_out2
10721076};
10731077
10741078static const struct ide_interface ide_intf =
src/mame/drivers/policetr.c
r2375r2376
141141
142142static READ32_HANDLER( port0_r )
143143{
144   return readinputport(0) << 16;
144   return input_port_read_indexed(machine, 0) << 16;
145145}
146146
147147
148148static READ32_HANDLER( port1_r )
149149{
150   return (readinputport(1) << 16) | (EEPROM_read_bit() << 29);
150   return (input_port_read_indexed(machine, 1) << 16) | (EEPROM_read_bit() << 29);
151151}
152152
153153
154154static READ32_HANDLER( port2_r )
155155{
156   return readinputport(2) << 16;
156   return input_port_read_indexed(machine, 2) << 16;
157157}
158158
159159
src/mame/drivers/seibuspi.c
r2375r2376
923923static READ32_HANDLER( spi_controls1_r )
924924{
925925   if( ACCESSING_BITS_0_7 ) {
926      return (readinputport(1) << 8) | readinputport(0) | 0xffff0000;
926      return (input_port_read_indexed(machine, 1) << 8) | input_port_read_indexed(machine, 0) | 0xffff0000;
927927   }
928928   return 0xffffffff;
929929}
r2375r2376
931931static READ32_HANDLER( spi_controls2_r )
932932{
933933   if( ACCESSING_BITS_0_7 ) {
934      return ((readinputport(2) | 0xffffff00) & ~0x40) | (EEPROM_read_bit() << 6);
934      return ((input_port_read_indexed(machine, 2) | 0xffffff00) & ~0x40) | (EEPROM_read_bit() << 6);
935935   }
936936   return 0xffffffff;
937937}
r2375r2376
995995
996996static READ8_HANDLER( z80_jp1_r )
997997{
998   return readinputport(3);
998   return input_port_read_indexed(machine, 3);
999999}
10001000
10011001static READ8_HANDLER( z80_coin_r )
10021002{
1003   return readinputport(4);
1003   return input_port_read_indexed(machine, 4);
10041004}
10051005
10061006static READ32_HANDLER( soundrom_r )
r2375r2376
19711971      cpu_spinuntil_int(); // idle
19721972      // Hack to enter test mode
19731973      r = spimainram[(0x002894c-0x800)/4] & (~0x400);
1974      return r | (((readinputport(2) ^ 0xFF)<<8) & 0x400);
1974      return r | (((input_port_read_indexed(machine, 2) ^ 0xFF)<<8) & 0x400);
19751975   }
19761976
19771977   /* rfjetj */
src/mame/drivers/coolpool.c
r2375r2376
255255         break;
256256
257257      case 0x100:
258         iop_answer = (INT8)(-readinputportbytag("YAXIS2") - readinputportbytag("XAXIS2")) << 6;
258         iop_answer = (INT8)(-input_port_read(machine, "YAXIS2") - input_port_read(machine, "XAXIS2")) << 6;
259259         break;
260260      case 0x101:
261         iop_answer = (INT8)(-readinputportbytag("YAXIS2") + readinputportbytag("XAXIS2")) << 6;
261         iop_answer = (INT8)(-input_port_read(machine, "YAXIS2") + input_port_read(machine, "XAXIS2")) << 6;
262262         break;
263263      case 0x102:
264         iop_answer = (INT8)(-readinputportbytag("YAXIS1") - readinputportbytag("XAXIS1")) << 6;
264         iop_answer = (INT8)(-input_port_read(machine, "YAXIS1") - input_port_read(machine, "XAXIS1")) << 6;
265265         break;
266266      case 0x103:
267         iop_answer = (INT8)(-readinputportbytag("YAXIS1") + readinputportbytag("XAXIS1")) << 6;
267         iop_answer = (INT8)(-input_port_read(machine, "YAXIS1") + input_port_read(machine, "XAXIS1")) << 6;
268268         break;
269269
270270      case 0x500:
271         iop_answer = readinputport(0);
271         iop_answer = input_port_read_indexed(machine, 0);
272272         break;
273273   }
274274
r2375r2376
420420   static UINT8 oldx, oldy;
421421   static UINT16 lastresult;
422422
423   int result = (readinputportbytag("IN1") & 0x00ff) | (lastresult & 0xff00);
424   UINT8 newx = readinputportbytag("XAXIS");
425   UINT8 newy = readinputportbytag("YAXIS");
423   int result = (input_port_read(machine, "IN1") & 0x00ff) | (lastresult & 0xff00);
424   UINT8 newx = input_port_read(machine, "XAXIS");
425   UINT8 newy = input_port_read(machine, "YAXIS");
426426   int dx = (INT8)(newx - oldx);
427427   int dy = (INT8)(newy - oldy);
428428
src/mame/drivers/gaplus.c
r2375r2376
180180
181181***************************************************************************/
182182
183static READ8_HANDLER( in0_l )   { return readinputport(0); }      // P1 joystick
184static READ8_HANDLER( in0_h )   { return readinputport(0) >> 4; }   // P2 joystick
185static READ8_HANDLER( in1_l )   { return readinputport(1); }      // fire and start buttons
186static READ8_HANDLER( in1_h )   { return readinputport(1) >> 4; }   // coins
187static READ8_HANDLER( dipA_l )   { return readinputport(2); }      // dips A
188static READ8_HANDLER( dipA_h )   { return readinputport(2) >> 4; }   // dips A
189static READ8_HANDLER( dipB_l )   { return readinputport(3); }      // dips B
190static READ8_HANDLER( dipB_h )   { return readinputport(3) >> 4; }   // dips B
183static READ8_HANDLER( in0_l )   { return input_port_read_indexed(machine, 0); }      // P1 joystick
184static READ8_HANDLER( in0_h )   { return input_port_read_indexed(machine, 0) >> 4; }   // P2 joystick
185static READ8_HANDLER( in1_l )   { return input_port_read_indexed(machine, 1); }      // fire and start buttons
186static READ8_HANDLER( in1_h )   { return input_port_read_indexed(machine, 1) >> 4; }   // coins
187static READ8_HANDLER( dipA_l )   { return input_port_read_indexed(machine, 2); }      // dips A
188static READ8_HANDLER( dipA_h )   { return input_port_read_indexed(machine, 2) >> 4; }   // dips A
189static READ8_HANDLER( dipB_l )   { return input_port_read_indexed(machine, 3); }      // dips B
190static READ8_HANDLER( dipB_h )   { return input_port_read_indexed(machine, 3) >> 4; }   // dips B
191191static WRITE8_HANDLER( out_lamps0 )
192192{
193193   set_led_status(0,data & 1);
src/mame/drivers/speedatk.c
r2375r2376
9696   {
9797      case 0x02:
9898      {
99         switch(readinputport(1))
99         switch(input_port_read_indexed(machine, 1))
100100         {
101101            case 0x002: return 0x02;
102102            case 0x001: return 0x01;
r2375r2376
115115      }
116116      case 0x04:
117117      {
118         switch(readinputport(2))
118         switch(input_port_read_indexed(machine, 2))
119119         {
120120            case 0x002: return 0x02;
121121            case 0x001: return 0x01;
src/mame/drivers/niyanpai.c
r2375r2376
248248{
249249   UINT8 dipsw_a, dipsw_b;
250250
251   dipsw_a = (((readinputport(0) & 0x01) << 7) | ((readinputport(0) & 0x02) << 5) |
252            ((readinputport(0) & 0x04) << 3) | ((readinputport(0) & 0x08) << 1) |
253            ((readinputport(0) & 0x10) >> 1) | ((readinputport(0) & 0x20) >> 3) |
254            ((readinputport(0) & 0x40) >> 5) | ((readinputport(0) & 0x80) >> 7));
251   dipsw_a = (((input_port_read_indexed(machine, 0) & 0x01) << 7) | ((input_port_read_indexed(machine, 0) & 0x02) << 5) |
252            ((input_port_read_indexed(machine, 0) & 0x04) << 3) | ((input_port_read_indexed(machine, 0) & 0x08) << 1) |
253            ((input_port_read_indexed(machine, 0) & 0x10) >> 1) | ((input_port_read_indexed(machine, 0) & 0x20) >> 3) |
254            ((input_port_read_indexed(machine, 0) & 0x40) >> 5) | ((input_port_read_indexed(machine, 0) & 0x80) >> 7));
255255
256   dipsw_b = (((readinputport(1) & 0x01) << 7) | ((readinputport(1) & 0x02) << 5) |
257            ((readinputport(1) & 0x04) << 3) | ((readinputport(1) & 0x08) << 1) |
258            ((readinputport(1) & 0x10) >> 1) | ((readinputport(1) & 0x20) >> 3) |
259            ((readinputport(1) & 0x40) >> 5) | ((readinputport(1) & 0x80) >> 7));
256   dipsw_b = (((input_port_read_indexed(machine, 1) & 0x01) << 7) | ((input_port_read_indexed(machine, 1) & 0x02) << 5) |
257            ((input_port_read_indexed(machine, 1) & 0x04) << 3) | ((input_port_read_indexed(machine, 1) & 0x08) << 1) |
258            ((input_port_read_indexed(machine, 1) & 0x10) >> 1) | ((input_port_read_indexed(machine, 1) & 0x20) >> 3) |
259            ((input_port_read_indexed(machine, 1) & 0x40) >> 5) | ((input_port_read_indexed(machine, 1) & 0x80) >> 7));
260260
261261   return ((dipsw_a << 8) | dipsw_b);
262262}
263263
264264static READ16_HANDLER( niyanpai_inputport_0_r )
265265{
266   return ((readinputport(3) << 8) | (readinputport(4) << 0));
266   return ((input_port_read_indexed(machine, 3) << 8) | (input_port_read_indexed(machine, 4) << 0));
267267}
268268
269269static READ16_HANDLER( niyanpai_inputport_1_r )
270270{
271   return ((readinputport(2) << 8) | 0xff);
271   return ((input_port_read_indexed(machine, 2) << 8) | 0xff);
272272}
273273
274274static READ16_HANDLER( musobana_inputport_0_r )
r2375r2376
277277
278278   switch ((musobana_inputport ^ 0xff00) >> 8)
279279   {
280      case 0x01:   portdata = ((readinputport(3) << 8) | (readinputport(8))); break;
281      case 0x02:   portdata = ((readinputport(4) << 8) | (readinputport(9))); break;
282      case 0x04:   portdata = ((readinputport(5) << 8) | (readinputport(10))); break;
283      case 0x08:   portdata = ((readinputport(6) << 8) | (readinputport(11))); break;
284      case 0x10:   portdata = ((readinputport(7) << 8) | (readinputport(12))); break;
285      default:   portdata = (((readinputport(3) << 8) | (readinputport(8)))) & (((readinputport(4) << 8) | (readinputport(9)))) & (((readinputport(5) << 8) | (readinputport(10)))) & (((readinputport(6) << 8) | (readinputport(11)))) & (((readinputport(7) << 8) | (readinputport(12)))); break;
280      case 0x01:   portdata = ((input_port_read_indexed(machine, 3) << 8) | (input_port_read_indexed(machine, 8))); break;
281      case 0x02:   portdata = ((input_port_read_indexed(machine, 4) << 8) | (input_port_read_indexed(machine, 9))); break;
282      case 0x04:   portdata = ((input_port_read_indexed(machine, 5) << 8) | (input_port_read_indexed(machine, 10))); break;
283      case 0x08:   portdata = ((input_port_read_indexed(machine, 6) << 8) | (input_port_read_indexed(machine, 11))); break;
284      case 0x10:   portdata = ((input_port_read_indexed(machine, 7) << 8) | (input_port_read_indexed(machine, 12))); break;
285      default:   portdata = (((input_port_read_indexed(machine, 3) << 8) | (input_port_read_indexed(machine, 8)))) & (((input_port_read_indexed(machine, 4) << 8) | (input_port_read_indexed(machine, 9)))) & (((input_port_read_indexed(machine, 5) << 8) | (input_port_read_indexed(machine, 10)))) & (((input_port_read_indexed(machine, 6) << 8) | (input_port_read_indexed(machine, 11)))) & (((input_port_read_indexed(machine, 7) << 8) | (input_port_read_indexed(machine, 12)))); break;
286286   }
287287
288288   return (portdata);
r2375r2376
298298   if (tmp68301_parallel_interface_r(machine, 0x0005, 0x00ff) & 0x0004) musobana_outcoin_flag ^= 1;
299299   else musobana_outcoin_flag = 1;
300300
301   return (((readinputport(2) & 0xdf) | ((musobana_outcoin_flag & 0x01) << 5)) << 8);
301   return (((input_port_read_indexed(machine, 2) & 0xdf) | ((musobana_outcoin_flag & 0x01) << 5)) << 8);
302302}
303303
304304static WRITE16_HANDLER ( musobana_inputport_w )
src/mame/drivers/jedi.c
r2375r2376
215215
216216   switch (state->a2d_select)
217217   {
218      case 0: ret = readinputport(2); break;
219      case 2: ret = readinputport(3); break;
218      case 0: ret = input_port_read_indexed(machine, 2); break;
219      case 2: ret = input_port_read_indexed(machine, 3); break;
220220   }
221221
222222   return ret;
src/mame/drivers/bfm_sc2.c
r2375r2376
655655      t1 = input_override[offset];   // strobe 0-7 data 0-4
656656      t2 = input_override[offset+idx];   // strobe 8-B data 0-4
657657
658      t1 = (sc2_Inputs[offset]   & t1) | ( ( readinputport(offset+1)   & ~t1) & 0x1F);
658      t1 = (sc2_Inputs[offset]   & t1) | ( ( input_port_read_indexed(machine, offset+1)   & ~t1) & 0x1F);
659659      if (idx == 8)
660         t2 = (sc2_Inputs[offset+8] & t2) | ( ( readinputport(offset+1+8) & ~t2) << 5);
660         t2 = (sc2_Inputs[offset+8] & t2) | ( ( input_port_read_indexed(machine, offset+1+8) & ~t2) << 5);
661661      else
662         t2 =  (sc2_Inputs[offset+4] & t2) | ( ( ( readinputport(offset+1+4) & ~t2) << 2) & 0x60);
662         t2 =  (sc2_Inputs[offset+4] & t2) | ( ( ( input_port_read_indexed(machine, offset+1+4) & ~t2) << 2) & 0x60);
663663
664664      sc2_Inputs[offset]   = (sc2_Inputs[offset]   & ~0x1F) | t1;
665665      sc2_Inputs[offset+idx] = (sc2_Inputs[offset+idx] & ~0x60) | t2;
src/mame/drivers/suprnova.c
r2375r2376
702702
703703static READ32_HANDLER( nova_input_port_0_r )
704704{
705   return readinputport(0)<<24 | readinputport(1)<<16 | readinputport(2)<<8 | readinputport(3);
705   return input_port_read_indexed(machine, 0)<<24 | input_port_read_indexed(machine, 1)<<16 | input_port_read_indexed(machine, 2)<<8 | input_port_read_indexed(machine, 3);
706706}
707707
708708static READ32_HANDLER( nova_input_port_3_r )
709709{
710   return readinputport(8) | 0xffffff00;
710   return input_port_read_indexed(machine, 8) | 0xffffff00;
711711}
712712
713713static READ32_HANDLER( nova_input_port_dip_r )
714714{
715   return readinputport(4)<<24 | readinputport(5)<<16 | readinputport(6)<<8 | readinputport(7);
715   return input_port_read_indexed(machine, 4)<<24 | input_port_read_indexed(machine, 5)<<16 | input_port_read_indexed(machine, 6)<<8 | input_port_read_indexed(machine, 7);
716716}
717717
718718static UINT32 timer_0_temp[4];
src/mame/drivers/seta2.c
r2375r2376
564564{
565565   switch (keyboard_row)
566566   {
567      case 0x01: return readinputport(3);
568      case 0x02: return readinputport(4);
569      case 0x04: return readinputport(5);
570      case 0x08: return readinputport(6);
571      case 0x10: return readinputport(7);
567      case 0x01: return input_port_read_indexed(machine, 3);
568      case 0x02: return input_port_read_indexed(machine, 4);
569      case 0x04: return input_port_read_indexed(machine, 5);
570      case 0x08: return input_port_read_indexed(machine, 6);
571      case 0x10: return input_port_read_indexed(machine, 7);
572572      default:   logerror("p1_r with keyboard_row = %02x\n",keyboard_row); return 0xffff;
573573   }
574574}
r2375r2376
686686
687687static READ16_HANDLER( pzlbowl_coins_r )
688688{
689   return readinputport(4) | (mame_rand(Machine) & 0x80 );
689   return input_port_read_indexed(machine, 4) | (mame_rand(Machine) & 0x80 );
690690}
691691
692692static WRITE16_HANDLER( pzlbowl_coin_counter_w )
r2375r2376
770770
771771static READ16_HANDLER( samshoot_lightgun1_r )
772772{
773//  popmessage("%02x %02x",readinputport(3),readinputport(2));
774   return (readinputport(2) << 8) | readinputport(3);
773//  popmessage("%02x %02x",input_port_read_indexed(machine, 3),input_port_read_indexed(machine, 2));
774   return (input_port_read_indexed(machine, 2) << 8) | input_port_read_indexed(machine, 3);
775775}
776776static READ16_HANDLER( samshoot_lightgun2_r )
777777{
778   return (readinputport(4) << 8) | readinputport(5);
778   return (input_port_read_indexed(machine, 4) << 8) | input_port_read_indexed(machine, 5);
779779}
780780
781781static WRITE16_HANDLER( samshoot_coin_w )
src/mame/drivers/witch.c
r2375r2376
319319 switch(offset)
320320 {
321321   case 0x02: return reg_a002;
322   case 0x04: return readinputportbytag("A004");
323  case 0x05: return readinputportbytag("A005");
324  case 0x0c: return input_port_0_r(machine,0); // stats / reset
325   case 0x0e: return readinputportbytag("A00E");// coin/reset
322   case 0x04: return input_port_read(machine, "A004");
323  case 0x05: return input_port_read(machine, "A005");
324  case 0x0c: return input_port_read_indexed(machine, 0); // stats / reset
325   case 0x0e: return input_port_read(machine, "A00E");// coin/reset
326326 }
327327
328328
r2375r2376
331331    switch(reg_a002&0x3f)
332332    {
333333      case 0x3b:
334        return input_port_2_r(machine,0);//bet10 / pay out
334        return input_port_read_indexed(machine, 2);//bet10 / pay out
335335      case 0x3e:
336        return input_port_3_r(machine,0);//TODO : trace f564
336        return input_port_read_indexed(machine, 3);//TODO : trace f564
337337      case 0x3d:
338         return input_port_4_r(machine,0);
338         return input_port_read_indexed(machine, 4);
339339      default:
340340        logerror("A000 read with mux=0x%02x\n",reg_a002&0x3f);
341341    }
r2375r2376
411411   scrolly=data;
412412}
413413
414static READ8_HANDLER(portA_r) {   return readinputportbytag("YM_PortA"); }
415static READ8_HANDLER(portB_r) {   return readinputportbytag("YM_PortB");}
414static READ8_HANDLER(portA_r) {   return input_port_read(machine, "YM_PortA"); }
415static READ8_HANDLER(portB_r) {   return input_port_read(machine, "YM_PortB");}
416416
417417static const struct YM2203interface ym2203_interface_0 =
418418{
src/mame/drivers/flkatck.c
r2375r2376
6363   switch ((offset & 0x1c) >> 2){
6464      case 0x00:   /* inputs + DIPSW #3 + coinsw */
6565         if (offset & 0x02)
66            data = readinputport(2 + (offset & 0x01));
66            data = input_port_read_indexed(machine, 2 + (offset & 0x01));
6767         else
68            data = readinputport(4 + (offset & 0x01));
68            data = input_port_read_indexed(machine, 4 + (offset & 0x01));
6969         break;
7070      case 0x01:   /* DIPSW #1 & DIPSW #2 */
7171         if (offset & 0x02)
72            data = readinputport(1 - (offset & 0x01));
72            data = input_port_read_indexed(machine, 1 - (offset & 0x01));
7373         break;
7474   }
7575
src/mame/drivers/dynax.c
r2375r2376
237237   int res = 0x3f;
238238
239239   /* the game reads all rows at once (keyb = 0) to check if a key is pressed */
240   if (~keyb & 0x01) res &= readinputport(3);
241   if (~keyb & 0x02) res &= readinputport(4);
242   if (~keyb & 0x04) res &= readinputport(5);
243   if (~keyb & 0x08) res &= readinputport(6);
244   if (~keyb & 0x10) res &= readinputport(7);
240   if (~keyb & 0x01) res &= input_port_read_indexed(machine, 3);
241   if (~keyb & 0x02) res &= input_port_read_indexed(machine, 4);
242   if (~keyb & 0x04) res &= input_port_read_indexed(machine, 5);
243   if (~keyb & 0x08) res &= input_port_read_indexed(machine, 6);
244   if (~keyb & 0x10) res &= input_port_read_indexed(machine, 7);
245245
246246   return res;
247247}
r2375r2376
251251   int res = 0x3f;
252252
253253   /* the game reads all rows at once (keyb = 0) to check if a key is pressed */
254   if (~keyb & 0x01) res &= readinputport(8);
255   if (~keyb & 0x02) res &= readinputport(9);
256   if (~keyb & 0x04) res &= readinputport(10);
257   if (~keyb & 0x08) res &= readinputport(11);
258   if (~keyb & 0x10) res &= readinputport(12);
254   if (~keyb & 0x01) res &= input_port_read_indexed(machine, 8);
255   if (~keyb & 0x02) res &= input_port_read_indexed(machine, 9);
256   if (~keyb & 0x04) res &= input_port_read_indexed(machine, 10);
257   if (~keyb & 0x08) res &= input_port_read_indexed(machine, 11);
258   if (~keyb & 0x10) res &= input_port_read_indexed(machine, 12);
259259
260260   return res;
261261}
r2375r2376
614614         switch( yarunara_select )
615615         {
616616            case 0x00:
617               return readinputportbytag("IN2");   // coins
617               return input_port_read(machine, "IN2");   // coins
618618
619619            case 0x02:
620620               return 0xff;   // bit 7 must be 1. Bit 2?
r2375r2376
631631            // player 2
632632            case 0x01:   //quiztvqq
633633            case 0x81:
634               return readinputport(3 + 5 + yarunara_ip++);
634               return input_port_read_indexed(machine, 3 + 5 + yarunara_ip++);
635635
636636            // player 1
637637            case 0x02:   //quiztvqq
638638            case 0x82:
639               return readinputport(3 + yarunara_ip++);
639               return input_port_read_indexed(machine, 3 + yarunara_ip++);
640640
641641            default:
642642               return 0xff;
r2375r2376
954954
955955static READ8_HANDLER( mjelctrn_keyboard_1_r )
956956{
957   return (hanamai_keyboard_1_r(machine,0) & 0x3f) | (readinputport(15) ? 0x40 : 0);
957   return (hanamai_keyboard_1_r(machine,0) & 0x3f) | (input_port_read_indexed(machine, 15) ? 0x40 : 0);
958958}
959959
960960static READ8_HANDLER( mjelctrn_dsw_r )
961961{
962962   int dsw = (keyb & 0xc0) >> 6;
963963   if (dsw >= 2)   dsw = dsw - 2 + 13;   // 0-3 -> IN0,IN1,IN13,IN14
964   return readinputport(dsw);
964   return input_port_read_indexed(machine, dsw);
965965}
966966
967967static WRITE8_HANDLER( mjelctrn_blitter_ack_w )
r2375r2376
10271027static READ8_HANDLER( htengoku_dsw_r )
10281028{
10291029
1030   if (!(htengoku_dsw & 0x01))   return readinputport(11);
1031   if (!(htengoku_dsw & 0x02))   return readinputport(12);
1032   if (!(htengoku_dsw & 0x04))   return readinputport(13);
1033   if (!(htengoku_dsw & 0x08))   return readinputport(14);
1034   if (!(htengoku_dsw & 0x10))   return readinputport(15);
1030   if (!(htengoku_dsw & 0x01))   return input_port_read_indexed(machine, 11);
1031   if (!(htengoku_dsw & 0x02))   return input_port_read_indexed(machine, 12);
1032   if (!(htengoku_dsw & 0x04))   return input_port_read_indexed(machine, 13);
1033   if (!(htengoku_dsw & 0x08))   return input_port_read_indexed(machine, 14);
1034   if (!(htengoku_dsw & 0x10))   return input_port_read_indexed(machine, 15);
10351035   logerror("%06x: warning, unknown bits read, htengoku_dsw = %02x\n", activecpu_get_pc(), htengoku_dsw);
10361036
10371037   return 0xff;
r2375r2376
10641064{
10651065   switch( htengoku_select )
10661066   {
1067      case 0x81:   return readinputport(1 + 5 + htengoku_ip++);
1068      case 0x82:   return readinputport(1 + htengoku_ip++);
1067      case 0x81:   return input_port_read_indexed(machine, 1 + 5 + htengoku_ip++);
1068      case 0x82:   return input_port_read_indexed(machine, 1 + htengoku_ip++);
10691069      case 0x0d:   return 0xff;   // unused
10701070   }
10711071   logerror("%04x: input_r with select = %02x\n",activecpu_get_pc(),htengoku_select);
r2375r2376
10761076{
10771077   switch( htengoku_select )
10781078   {
1079      case 0x00:   return readinputport(0);
1079      case 0x00:   return input_port_read_indexed(machine, 0);
10801080      case 0x01:   return 0xff;   //?
10811081      case 0x02:   return 0xbf | ((htengoku_hopper && !(video_screen_get_frame_number(machine->primary_screen)%10)) ? 0 : (1<<6));;   // bit 7 = blitter busy, bit 6 = hopper
10821082      case 0x03:   return htengoku_coins;
r2375r2376
11961196         switch( tenkai_ipsel )
11971197         {
11981198            case 0x00:
1199               return readinputport(5);   // coins
1199               return input_port_read_indexed(machine, 5);   // coins
12001200
12011201            default:
12021202               logerror("%04x: unmapped ip_sel=%02x read from offs %x\n",activecpu_get_pc(),tenkai_ipsel,offset);
r2375r2376
12151215            case 0x81:
12161216               if (tenkai_ip >= 5)
12171217                  logerror("%04x: unmapped tenkai_ip=%02x read\n",activecpu_get_pc(),tenkai_ip);
1218               return 0xff;//readinputport(6 + 5 + tenkai_ip++);
1218               return 0xff;//input_port_read_indexed(machine, 6 + 5 + tenkai_ip++);
12191219
12201220            // player 1
12211221            case 0x82:
12221222               if (tenkai_ip >= 5)
12231223                  logerror("%04x: unmapped tenkai_ip=%02x read\n",activecpu_get_pc(),tenkai_ip);
1224               return readinputport(6 + tenkai_ip++);
1224               return input_port_read_indexed(machine, 6 + tenkai_ip++);
12251225
12261226            default:
12271227               logerror("%04x: unmapped ip_sel=%02x read from offs %x\n",activecpu_get_pc(),tenkai_ipsel,offset);
r2375r2376
12391239}
12401240static READ8_HANDLER( tenkai_dsw_r )
12411241{
1242   if (~tenkai_dswsel & 0x01) return readinputport(0);
1243   if (~tenkai_dswsel & 0x02) return readinputport(1);
1244   if (~tenkai_dswsel & 0x04) return readinputport(2);
1245   if (~tenkai_dswsel & 0x08) return readinputport(3);
1246   if (~tenkai_dswsel & 0x10) return readinputport(4);
1242   if (~tenkai_dswsel & 0x01) return input_port_read_indexed(machine, 0);
1243   if (~tenkai_dswsel & 0x02) return input_port_read_indexed(machine, 1);
1244   if (~tenkai_dswsel & 0x04) return input_port_read_indexed(machine, 2);
1245   if (~tenkai_dswsel & 0x08) return input_port_read_indexed(machine, 3);
1246   if (~tenkai_dswsel & 0x10) return input_port_read_indexed(machine, 4);
12471247   logerror("%04x: unmapped dsw %02x read\n",activecpu_get_pc(),tenkai_dswsel);
12481248   return 0xff;
12491249}
src/mame/drivers/shootout.c
r2375r2376
291291{
292292   static int coin = 0;
293293
294   if ( readinputport( 2 ) & 0xc0 ) {
294   if ( input_port_read_indexed(machine, 2 ) & 0xc0 ) {
295295      if ( coin == 0 ) {
296296         coin = 1;
297297         nmi_line_pulse(machine, cpunum);
src/mame/drivers/zn.c
r2375r2376
246246   {
247247      if( m_b_lastclock )
248248      {
249         verboselog( 2, "read dip %02x -> %02x\n", n_data, ( ( readinputport( 7 ) >> m_n_dip_bit ) & 1 ) * PSX_SIO_IN_DATA );
250         psx_sio_input( 0, PSX_SIO_IN_DATA, ( ( readinputport( 7 ) >> m_n_dip_bit ) & 1 ) * PSX_SIO_IN_DATA );
249         verboselog( 2, "read dip %02x -> %02x\n", n_data, ( ( input_port_read_indexed(Machine,  7 ) >> m_n_dip_bit ) & 1 ) * PSX_SIO_IN_DATA );
250         psx_sio_input( 0, PSX_SIO_IN_DATA, ( ( input_port_read_indexed(Machine,  7 ) >> m_n_dip_bit ) & 1 ) * PSX_SIO_IN_DATA );
251251         m_n_dip_bit++;
252252         m_n_dip_bit &= 7;
253253      }
r2375r2376
379379   AM_RANGE(0xfffe0130, 0xfffe0133) AM_WRITENOP
380380ADDRESS_MAP_END
381381
382static ADDRESS_MAP_START( link_readmem, ADDRESS_SPACE_PROGRAM, 8 )
382static ADDRESS_MAP_START( link_map, ADDRESS_SPACE_PROGRAM, 8 )
383383ADDRESS_MAP_END
384384
385static ADDRESS_MAP_START( link_writemem, ADDRESS_SPACE_PROGRAM, 8 )
386ADDRESS_MAP_END
387
388static void zn_driver_init( void )
385static void zn_driver_init( running_machine *machine )
389386{
390387   int n_game;
391388
392   psx_driver_init();
389   psx_driver_init(machine);
393390
394391   n_game = 0;
395392   while( zn_config_table[ n_game ].s_name != NULL )
r2375r2376
638635   memory_install_read32_handler ( 0, ADDRESS_SPACE_PROGRAM, 0x1fb80000, 0x1fbfffff, 0, 0, SMH_BANK3 );     /* country rom */
639636   memory_install_write32_handler( 0, ADDRESS_SPACE_PROGRAM, 0x1fb60000, 0x1fb60003, 0, 0, zn_qsound_w );
640637
641   zn_driver_init();
638   zn_driver_init(machine);
642639
643640   if( strcmp( machine->gamedrv->name, "glpracr" ) == 0 ||
644641      strcmp( machine->gamedrv->name, "glprac2l" ) == 0 )
r2375r2376
870867   memory_install_read32_handler ( 0, ADDRESS_SPACE_PROGRAM, 0x1fb80000, 0x1fbfffff, 0, 0, SMH_BANK3 );     /* country rom */
871868   memory_install_write32_handler( 0, ADDRESS_SPACE_PROGRAM, 0x1fb60000, 0x1fb60003, 0, 0, zn_qsound_w );
872869
873   zn_driver_init();
870   zn_driver_init(machine);
874871}
875872
876873static MACHINE_RESET( coh3002c )
r2375r2376
12181215   memory_install_read32_handler ( 0, ADDRESS_SPACE_PROGRAM, 0x1fbe0000, 0x1fbe0000 + ( taitofx1_eeprom_size1 - 1 ), 0, 0, SMH_BANK2 );
12191216   memory_install_write32_handler( 0, ADDRESS_SPACE_PROGRAM, 0x1fbe0000, 0x1fbe0000 + ( taitofx1_eeprom_size1 - 1 ), 0, 0, SMH_BANK2 );
12201217
1221   zn_driver_init();
1218   zn_driver_init(machine);
12221219   mb3773_init();
12231220}
12241221
r2375r2376
12571254   }
12581255}
12591256
1260static ADDRESS_MAP_START( fx1a_sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
1261   AM_RANGE(0x0000, 0x3fff) AM_READ(SMH_ROM)
1262   AM_RANGE(0x4000, 0x7fff) AM_READ(SMH_BANK10)
1263   AM_RANGE(0xc000, 0xdfff) AM_READ(SMH_RAM)
1264   AM_RANGE(0xe000, 0xe000) AM_READ(YM2610_status_port_0_A_r)
1265   AM_RANGE(0xe001, 0xe001) AM_READ(YM2610_read_port_0_r)
1266   AM_RANGE(0xe002, 0xe002) AM_READ(YM2610_status_port_0_B_r)
1267   AM_RANGE(0xe200, 0xe200) AM_READ(SMH_NOP)
1268   AM_RANGE(0xe201, 0xe201) AM_READ(taitosound_slave_comm_r)
1269   AM_RANGE(0xea00, 0xea00) AM_READ(SMH_NOP)
1270ADDRESS_MAP_END
1271
1272static ADDRESS_MAP_START( fx1a_sound_writemem, ADDRESS_SPACE_PROGRAM, 8 )
1273   AM_RANGE(0x0000, 0x7fff) AM_WRITE(SMH_ROM)
1274   AM_RANGE(0xc000, 0xdfff) AM_WRITE(SMH_RAM)
1275   AM_RANGE(0xe000, 0xe000) AM_WRITE(YM2610_control_port_0_A_w)
1276   AM_RANGE(0xe001, 0xe001) AM_WRITE(YM2610_data_port_0_A_w)
1277   AM_RANGE(0xe002, 0xe002) AM_WRITE(YM2610_control_port_0_B_w)
1257static ADDRESS_MAP_START( fx1a_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
1258   AM_RANGE(0x4000, 0x7fff) AM_READ(SMH_BANK10)   /* Fallthrough */
1259   AM_RANGE(0x0000, 0x7fff) AM_ROM
1260   AM_RANGE(0xc000, 0xdfff) AM_RAM
1261   AM_RANGE(0xe000, 0xe000) AM_READWRITE(YM2610_status_port_0_A_r, YM2610_control_port_0_A_w)
1262   AM_RANGE(0xe001, 0xe001) AM_READWRITE(YM2610_read_port_0_r, YM2610_data_port_0_A_w)
1263   AM_RANGE(0xe002, 0xe002) AM_READWRITE(YM2610_status_port_0_B_r, YM2610_control_port_0_B_w)
12781264   AM_RANGE(0xe003, 0xe003) AM_WRITE(YM2610_data_port_0_B_w)
1279   AM_RANGE(0xe200, 0xe200) AM_WRITE(taitosound_slave_port_w)
1280   AM_RANGE(0xe201, 0xe201) AM_WRITE(taitosound_slave_comm_w)
1265   AM_RANGE(0xe200, 0xe200) AM_READWRITE(SMH_NOP, taitosound_slave_port_w)
1266   AM_RANGE(0xe201, 0xe201) AM_READWRITE(taitosound_slave_comm_r, taitosound_slave_comm_w)
12811267   AM_RANGE(0xe400, 0xe403) AM_WRITE(SMH_NOP) /* pan */
1282   AM_RANGE(0xee00, 0xee00) AM_WRITE(SMH_NOP) /* ? */
1268   AM_RANGE(0xee00, 0xee00) AM_NOP /* ? */
12831269   AM_RANGE(0xf000, 0xf000) AM_WRITE(SMH_NOP) /* ? */
12841270   AM_RANGE(0xf200, 0xf200) AM_WRITE(fx1a_sound_bankswitch_w)
12851271ADDRESS_MAP_END
r2375r2376
13051291
13061292   MDRV_CPU_ADD( Z80, 16000000 / 4 )
13071293   /* audio CPU */   /* 4 MHz */
1308   MDRV_CPU_PROGRAM_MAP( fx1a_sound_readmem, fx1a_sound_writemem )
1294   MDRV_CPU_PROGRAM_MAP( fx1a_sound_map, 0 )
13091295   MDRV_MACHINE_RESET( coh1000ta )
13101296   MDRV_NVRAM_HANDLER( coh1000ta )
13111297
r2375r2376
13491335   memory_install_read32_handler ( 0, ADDRESS_SPACE_PROGRAM, 0x1fbe0000, 0x1fbe0000 + ( taitofx1_eeprom_size2 - 1 ), 0, 0, SMH_BANK3 );
13501336   memory_install_write32_handler( 0, ADDRESS_SPACE_PROGRAM, 0x1fbe0000, 0x1fbe0000 + ( taitofx1_eeprom_size2 - 1 ), 0, 0, SMH_BANK3 );
13511337
1352   zn_driver_init();
1338   zn_driver_init(machine);
13531339   mb3773_init();
13541340}
13551341
r2375r2376
15401526   memory_install_write32_handler( 0, ADDRESS_SPACE_PROGRAM, 0x1fb40000, 0x1fb40003, 0, 0, coh3002t_unknown_w );
15411527   memory_install_read32_handler ( 0, ADDRESS_SPACE_PROGRAM, 0x1fb40000, 0x1fb40003, 0, 0, coh3002t_unknown_r );
15421528
1543   zn_driver_init();
1529   zn_driver_init(machine);
15441530}
15451531
15461532static MACHINE_RESET( coh3002t )
r2375r2376
17251711   // init hard disk
17261712   ide_controller_init(0, &atpsx_intf);
17271713
1728   zn_driver_init();
1714   zn_driver_init(machine);
17291715}
17301716
17311717static MACHINE_RESET( coh1000w )
r2375r2376
19131899   memory_install_write32_handler( 0, ADDRESS_SPACE_PROGRAM, 0x1fa10300, 0x1fa10303, 0, 0, coh1002e_bank_w );
19141900   memory_install_write32_handler( 0, ADDRESS_SPACE_PROGRAM, 0x1fb00000, 0x1fb00007, 0, 0, coh1002e_latch_w );
19151901
1916   zn_driver_init();
1902   zn_driver_init(machine);
19171903}
19181904
19191905static MACHINE_RESET( coh1002e )
r2375r2376
22572243      ide_controller_init( 0, &jdredd_ide_intf );
22582244   }
22592245
2260   zn_driver_init();
2246   zn_driver_init(machine);
22612247}
22622248
22632249static MACHINE_RESET( coh1000a )
r2375r2376
24042390   memory_install_read32_handler ( 0, ADDRESS_SPACE_PROGRAM, 0x1f000000, 0x1f7fffff, 0, 0, SMH_BANK1 ); /* banked rom */
24052391   memory_install_write32_handler( 0, ADDRESS_SPACE_PROGRAM, 0x1fb00000, 0x1fb00003, 0, 0, coh1001l_bnk_w );
24062392
2407   zn_driver_init();
2393   zn_driver_init(machine);
24082394}
24092395
24102396static MACHINE_RESET( coh1001l )
r2375r2376
24502436   memory_install_read32_handler ( 0, ADDRESS_SPACE_PROGRAM, 0x1fb00000, 0x1fbfffff, 0, 0, SMH_BANK2 );
24512437   memory_install_write32_handler( 0, ADDRESS_SPACE_PROGRAM, 0x1fb00000, 0x1fb00003, 0, 0, coh1002v_bnk_w );
24522438
2453   zn_driver_init();
2439   zn_driver_init(machine);
24542440}
24552441
24562442static MACHINE_RESET( coh1002v )
r2375r2376
26752661   memory_install_write32_handler( 0, ADDRESS_SPACE_PROGRAM, 0x1fb00000, 0x1fb00003, 0, 0, cbaj_z80_w );
26762662   memory_install_write32_handler( 0, ADDRESS_SPACE_PROGRAM, 0x1fb00004, 0x1fb00007, 0, 0, coh1002m_bank_w );
26772663
2678   zn_driver_init();
2664   zn_driver_init(machine);
26792665}
26802666
26812667static MACHINE_RESET( coh1002m )
r2375r2376
27522738   MDRV_IMPORT_FROM( zn1_2mb_vram )
27532739
27542740   MDRV_CPU_ADD( Z80, 8000000 )
2755   MDRV_CPU_PROGRAM_MAP( link_readmem, link_writemem )
2741   MDRV_CPU_PROGRAM_MAP( link_map, 0 )
27562742
27572743   MDRV_MACHINE_RESET( coh1002m )
27582744   MDRV_NVRAM_HANDLER( at28c16_0 )
r2375r2376
43494335GAME( 1999, flamegun, tps,      coh1002m, zn, coh1002m, ROT0, "GAPS Inc.", "Flame Gunner", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
43504336GAME( 1999, flameguj, flamegun, coh1002m, zn, coh1002m, ROT0, "GAPS Inc.", "Flame Gunner (Japan)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
43514337GAME( 2000, tblkkuzu, tps,   coh1002m, zn, coh1002m, ROT0, "Tamsoft/D3 Publisher", "The Block Kuzushi (JAPAN)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4352GAME( 2000, 1on1gov,  tps,   coh1002m, zn, coh1002m, ROT0, "Tecmo", "1 on 1 Government (JAPAN)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
4338GAME( 2000, 1on1gov,  tps,   coh1002m, zn, coh1002m, ROT0, "Tecmo", "1 on 1 Government (JAPAN)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
43534339GAME( 2000, tecmowcm, tps,      coh1002m, zn, coh1002m, ROT0, "Tecmo", "Tecmo World Cup Millennium (JAPAN)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
43544340GAME( 2001, mfjump,   tps,      coh1002m, zn, coh1002m, ROT0, "Tecmo", "Monster Farm Jump (JAPAN)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
43554341
src/mame/drivers/dribling.c
r2375r2376
7878{
7979   /* low value in the given bit selects */
8080   if (!(input_mux & 0x01))
81      return readinputport(0);
81      return input_port_read_indexed(machine, 0);
8282   else if (!(input_mux & 0x02))
83      return readinputport(1);
83      return input_port_read_indexed(machine, 1);
8484   else if (!(input_mux & 0x04))
85      return readinputport(2);
85      return input_port_read_indexed(machine, 2);
8686   return 0xff;
8787}
8888
src/mame/drivers/megadriv.c
r2375r2376
17081708INPUT_PORTS_END
17091709
17101710
1711#define MODE_BUTTON(player) ( (readinputport(player) & 0x800) >> 11 )
1712#define Z_BUTTON(player) ( (readinputport(player) & 0x400) >> 10 )
1713#define Y_BUTTON(player) ( (readinputport(player) & 0x200) >> 9 )
1714#define X_BUTTON(player) ( (readinputport(player) & 0x100) >> 8 )
1711#define MODE_BUTTON(player) ( (input_port_read_indexed(Machine, player) & 0x800) >> 11 )
1712#define Z_BUTTON(player) ( (input_port_read_indexed(Machine, player) & 0x400) >> 10 )
1713#define Y_BUTTON(player) ( (input_port_read_indexed(Machine, player) & 0x200) >> 9 )
1714#define X_BUTTON(player) ( (input_port_read_indexed(Machine, player) & 0x100) >> 8 )
17151715
17161716
1717#define START_BUTTON(player) ( (readinputport(player) & 0x80) >> 7 )
1718#define C_BUTTON(player)     ( (readinputport(player) & 0x40) >> 6 )
1719#define B_BUTTON(player)     ( (readinputport(player) & 0x20) >> 5 )
1720#define A_BUTTON(player)     ( (readinputport(player) & 0x10) >> 4 )
1721#define RIGHT_BUTTON(player) ( (readinputport(player) & 0x08) >> 3 )
1722#define LEFT_BUTTON(player)  ( (readinputport(player) & 0x04) >> 2 )
1723#define DOWN_BUTTON(player)  ( (readinputport(player) & 0x02) >> 1 )
1724#define UP_BUTTON(player)    ( (readinputport(player) & 0x01) >> 0 )
1725#define MD_RESET_BUTTON      ( (readinputportbytag_safe("RESET",0x00)      & 0x01) >> 0 )
1717#define START_BUTTON(player) ( (input_port_read_indexed(Machine, player) & 0x80) >> 7 )
1718#define C_BUTTON(player)     ( (input_port_read_indexed(Machine, player) & 0x40) >> 6 )
1719#define B_BUTTON(player)     ( (input_port_read_indexed(Machine, player) & 0x20) >> 5 )
1720#define A_BUTTON(player)     ( (input_port_read_indexed(Machine, player) & 0x10) >> 4 )
1721#define RIGHT_BUTTON(player) ( (input_port_read_indexed(Machine, player) & 0x08) >> 3 )
1722#define LEFT_BUTTON(player)  ( (input_port_read_indexed(Machine, player) & 0x04) >> 2 )
1723#define DOWN_BUTTON(player)  ( (input_port_read_indexed(Machine, player) & 0x02) >> 1 )
1724#define UP_BUTTON(player)    ( (input_port_read_indexed(Machine, player) & 0x01) >> 0 )
1725#define MD_RESET_BUTTON      ( (input_port_read_safe(Machine, "RESET",0x00)      & 0x01) >> 0 )
17261726
17271727static UINT8 megadrive_io_data_regs[3];
17281728static UINT8 megadrive_io_ctrl_regs[3];
r2375r2376
29092909/* emulate testmode plug */
29102910static UINT8 megadrive_io_read_data_port_svp(int portnum)
29112911{
2912   if (portnum == 0 && readinputportbytag_safe("MEMORY_TEST", 0x00))
2912   if (portnum == 0 && input_port_read_safe(Machine, "MEMORY_TEST", 0x00))
29132913   {
29142914      return (megadrive_io_data_regs[0] & 0xc0);
29152915   }
r2375r2376
47554755   /* default state of z80 = reset, with bus */
47564756   mame_printf_debug("Resetting Megadrive / Genesis\n");
47574757
4758   switch (readinputportbytag_safe("REGION",0x00))
4758   switch (input_port_read_safe(machine, "REGION",0x00))
47594759   {
47604760
47614761      case 1: // US
src/mame/drivers/galpani3.c
r2375r2376
197197***************************************************************************/
198198static UINT16 *mcu_ram, galpani3_mcu_com[4];
199199
200static void galpani3_mcu_run(void)
200static void galpani3_mcu_run(running_machine *machine)
201201{
202202   UINT16 mcu_command = mcu_ram[0x0010/2];      /* command nb */
203203   UINT16 mcu_offset  = mcu_ram[0x0012/2] / 2;   /* offset in shared RAM where MCU will write */
r2375r2376
215215   {
216216      case 0x03:   // DSW
217217      {
218         mcu_ram[mcu_offset] = readinputport(3);
218         mcu_ram[mcu_offset] = input_port_read_indexed(machine, 3);
219219         logerror("PC=%06X : MCU executed command: %04X %04X (read DSW)\n",activecpu_get_pc(),mcu_command,mcu_offset*2);
220220      }
221221      break;
r2375r2376
295295   if (galpani3_mcu_com[3] != 0xFFFF)   return; \
296296\
297297   memset(galpani3_mcu_com, 0, 4 * sizeof( UINT16 ) ); \
298   galpani3_mcu_run(); \
298   galpani3_mcu_run(machine); \
299299}
300300
301301GALPANI3_MCU_COM_W(0)
src/mame/drivers/itech32.c
r2375r2376
354354
355355static READ16_HANDLER( special_port3_r )
356356{
357   int result = readinputport(3);
357   int result = input_port_read_indexed(machine, 3);
358358   if (sound_int_state) result ^= 0x08;
359359   return result;
360360}
r2375r2376
362362
363363static READ16_HANDLER( special_port4_r )
364364{
365   int result = readinputport(4);
365   int result = input_port_read_indexed(machine, 4);
366366   if (sound_int_state) result ^= 0x08;
367367   return result;
368368}
r2375r2376
370370
371371static READ16_HANDLER( trackball_r )
372372{
373   int lower = readinputportbytag("TRACKX1");
374   int upper = readinputportbytag("TRACKY1");
373   int lower = input_port_read(machine, "TRACKX1");
374   int upper = input_port_read(machine, "TRACKY1");
375375
376376   return (lower & 15) | ((upper & 15) << 4);
377377}
r2375r2376
379379
380380static READ32_HANDLER( trackball32_8bit_r )
381381{
382   int lower = readinputportbytag("TRACKX1");
383   int upper = readinputportbytag("TRACKY1");
382   int lower = input_port_read(machine, "TRACKX1");
383   int upper = input_port_read(machine, "TRACKY1");
384384
385385   return (lower & 255) | ((upper & 255) << 8);
386386}
r2375r2376
398398      int upper, lower;
399399      int dx, dy;
400400
401      int curx = readinputportbytag("TRACKX1");
402      int cury = readinputportbytag("TRACKY1");
401      int curx = input_port_read(machine, "TRACKX1");
402      int cury = input_port_read(machine, "TRACKY1");
403403
404404      dx = curx - effx;
405405      if (dx < -0x80) dx += 0x100;
r2375r2376
437437      int upper, lower;
438438      int dx, dy;
439439
440      int curx = readinputportbytag("TRACKX2");
441      int cury = readinputportbytag("TRACKY2");
440      int curx = input_port_read(machine, "TRACKX2");
441      int cury = input_port_read(machine, "TRACKY2");
442442
443443      dx = curx - effx;
444444      if (dx < -0x80) dx += 0x100;
r2375r2376
473473
474474static READ32_HANDLER( drivedge_steering_r )
475475{
476   int val = readinputport(5) * 2 - 0x100;
476   int val = input_port_read_indexed(machine, 5) * 2 - 0x100;
477477   if (val < 0) val = 0x100 | (-val);
478478   return val << 16;
479479}
r2375r2376
481481
482482static READ32_HANDLER( drivedge_gas_r )
483483{
484   int val = readinputport(6);
484   int val = input_port_read_indexed(machine, 6);
485485   return val << 16;
486486}
487487
src/mame/drivers/filetto.c
r2375r2376
301301{
302302   printf("Read Prototyping card [%02x] @ PC=%05x\n",offset,activecpu_get_pc());
303303   if(offset == 1)
304      return readinputport(1);
304      return input_port_read_indexed(machine, 1);
305305
306306   return disk_data[offset];
307307}
src/mame/drivers/terracre.c
r2375r2376
146146
147147static READ16_HANDLER( horekid_IN2_r )
148148{
149   int data = readinputportbytag("IN1");
149   int data = input_port_read(machine, "IN1");
150150
151151   if (!(data & 0x40))      // FAKE button 3 for "Debug Mode"
152152   {
src/mame/drivers/malzak.c
r2375r2376
7575   // POT switch position, read from port A of the first S2636
7676   // Not sure of the correct values to return, but these should
7777   // do based on the game code.
78   switch(readinputport(1))
78   switch(input_port_read_indexed(machine, 1))
7979   {
8080      case 0:  // Normal play
8181         return 0xf0;
src/mame/drivers/deco32.c
r2375r2376
331331{
332332   /* Protection/IO chip 75, same as Lemmings & Robocop 2 */
333333   switch (offset<<2) {
334   case 0x0a0: return readinputport(0); /* Player 1 & 2 controls */
335   case 0x158: return readinputport(1); /* Player 3 & 4 controls */
336   case 0xed4: return readinputport(2); /* Misc */
334   case 0x0a0: return input_port_read_indexed(machine, 0); /* Player 1 & 2 controls */
335   case 0x158: return input_port_read_indexed(machine, 1); /* Player 3 & 4 controls */
336   case 0xed4: return input_port_read_indexed(machine, 2); /* Misc */
337337   }
338338
339339   logerror("%08x: Unmapped protection read %04x\n",activecpu_get_pc(),offset<<2);
r2375r2376
343343static READ32_HANDLER( captaven_soundcpu_r )
344344{
345345   /* Top byte - top bit low == sound cpu busy, bottom word is dips */
346   return 0xffff0000 | readinputport(3);
346   return 0xffff0000 | input_port_read_indexed(machine, 3);
347347}
348348
349349static READ32_HANDLER( fghthist_control_r )
350350{
351351   switch (offset) {
352   case 0: return 0xffff0000 | readinputport(0);
353   case 1: return 0xffff0000 | readinputport(1); //check top bits??
352   case 0: return 0xffff0000 | input_port_read_indexed(machine, 0);
353   case 1: return 0xffff0000 | input_port_read_indexed(machine, 1); //check top bits??
354354   case 2: return 0xfffffffe | EEPROM_read_bit();
355355   }
356356
r2375r2376
375375static READ32_HANDLER( dragngun_service_r )
376376{
377377//  logerror("%08x:Read service\n",activecpu_get_pc());
378   return readinputport(3);
378   return input_port_read_indexed(machine, 3);
379379}
380380
381381static READ32_HANDLER( lockload_gun_mirror_r )
r2375r2376
383383//logerror("%08x:Read gun %d\n",activecpu_get_pc(),offset);
384384//return ((mame_rand(Machine)%0xffff)<<16) | mame_rand(Machine)%0xffff;
385385   if (offset) /* Mirror of player 1 and player 2 fire buttons */
386      return readinputport(5) | ((mame_rand(Machine)%0xff)<<16);
387   return readinputport(4) | readinputport(6) | (readinputport(6)<<16) | (readinputport(6)<<24); //((mame_rand(Machine)%0xff)<<16);
386      return input_port_read_indexed(machine, 5) | ((mame_rand(Machine)%0xff)<<16);
387   return input_port_read_indexed(machine, 4) | input_port_read_indexed(machine, 6) | (input_port_read_indexed(machine, 6)<<16) | (input_port_read_indexed(machine, 6)<<24); //((mame_rand(Machine)%0xff)<<16);
388388}
389389
390390static READ32_HANDLER( dragngun_prot_r )
r2375r2376
398398//definitely vblank in locked load
399399
400400   switch (offset<<1) {
401   case 0x140/2: return 0xffff0000 | readinputport(0); /* IN0 */
402   case 0xadc/2: return 0xffff0000 | readinputport(1) | strobe; /* IN1 */
403   case 0x6a0/2: return 0xffff0000 | readinputport(2); /* IN2 (Dip switch) */
401   case 0x140/2: return 0xffff0000 | input_port_read_indexed(machine, 0); /* IN0 */
402   case 0xadc/2: return 0xffff0000 | input_port_read_indexed(machine, 1) | strobe; /* IN1 */
403   case 0x6a0/2: return 0xffff0000 | input_port_read_indexed(machine, 2); /* IN2 (Dip switch) */
404404   }
405405   return 0xffffffff;
406406}
r2375r2376
411411{
412412   /* Ports 0-3 are read, but seem unused */
413413   switch (dragngun_lightgun_port) {
414   case 4: return readinputport(4); break;
415   case 5: return readinputport(5); break;
416   case 6: return readinputport(6); break;
417   case 7: return readinputport(7); break;
414   case 4: return input_port_read_indexed(machine, 4); break;
415   case 5: return input_port_read_indexed(machine, 5); break;
416   case 6: return input_port_read_indexed(machine, 6); break;
417   case 7: return input_port_read_indexed(machine, 7); break;
418418   }
419419
420420//  logerror("Illegal lightgun port %d read \n",dragngun_lightgun_port);
r2375r2376
460460static READ32_HANDLER( tattass_prot_r )
461461{
462462   switch (offset<<1) {
463   case 0x280: return readinputport(0) << 16; /* IN0 */
464   case 0x4c4: return readinputport(1) << 16; /* IN1 */
463   case 0x280: return input_port_read_indexed(machine, 0) << 16; /* IN0 */
464   case 0x4c4: return input_port_read_indexed(machine, 1) << 16; /* IN1 */
465465   case 0x35a: return tattass_eprom_bit << 16;
466466   }
467467
r2375r2376
623623{
624624
625625   switch (offset<<1) {
626   case 0x280: return readinputport(0) << 16| 0xffff; /* IN0 */
627   case 0x4c4: return readinputport(1) << 16| 0xffff; /* IN1 */
626   case 0x280: return input_port_read_indexed(machine, 0) << 16| 0xffff; /* IN0 */
627   case 0x4c4: return input_port_read_indexed(machine, 1) << 16| 0xffff; /* IN1 */
628628   case 0x35a: return (EEPROM_read_bit()<< 16) | 0xffff; // Debug switch in low word??
629629   }
630630
src/mame/drivers/midzeus.c
r2375r2376
451451   static const UINT8 translate49[7] = { 0x8, 0xc, 0xe, 0xf, 0x3, 0x1, 0x0 };
452452   const char *namex = param;
453453   const char *namey = namex + strlen(namex) + 1;
454   return (translate49[readinputportbytag(namey) >> 4] << 4) | translate49[readinputportbytag(namex) >> 4];
454   return (translate49[input_port_read(machine, namey) >> 4] << 4) | translate49[input_port_read(machine, namex) >> 4];
455455}
456456
457457
r2375r2376
464464
465465static CUSTOM_INPUT( keypad_r )
466466{
467   UINT32 bits = readinputportbytag(param);
467   UINT32 bits = input_port_read(machine, param);
468468   UINT8 select = keypad_select;
469469   while ((select & 1) != 0)
470470   {
r2375r2376
487487   static const char * const tags[] = { "ANALOG0", "ANALOG1", "ANALOG2", "ANALOG3" };
488488   if (offset < 8 || offset > 11)
489489      logerror("%06X:analog_r(%X)\n", activecpu_get_pc(), offset);
490   return readinputportbytag(tags[offset & 3]);
490   return input_port_read(machine, tags[offset & 3]);
491491}
492492
493493
r2375r2376
553553            { "GUNX1", "GUNY1" },
554554            { "GUNX2", "GUNY2" }
555555         };
556         gun_x[player] = readinputportbytag(names[player][0]) * (visarea->max_x + 1 - visarea->min_x) / 255 + visarea->min_x + BEAM_XOFFS;
557         gun_y[player] = readinputportbytag(names[player][1]) * (visarea->max_y + 1 - visarea->min_y) / 255 + visarea->min_y;
556         gun_x[player] = input_port_read(machine, names[player][0]) * (visarea->max_x + 1 - visarea->min_x) / 255 + visarea->min_x + BEAM_XOFFS;
557         gun_y[player] = input_port_read(machine, names[player][1]) * (visarea->max_y + 1 - visarea->min_y) / 255 + visarea->min_y;
558558         timer_adjust_oneshot(gun_timer[player], video_screen_get_time_until_pos(machine->primary_screen, MAX(0, gun_y[player] - BEAM_DY), MAX(0, gun_x[player] - BEAM_DX)), player);
559559      }
560560   }
src/mame/drivers/grchamp.c
r2375r2376
7979static MACHINE_START( grchamp )
8080{
8181   /* if the coin system is 1 way, lock Coin B (Page 40) */
82   if (readinputport(1) & 0x10)
82   if (input_port_read_indexed(machine, 1) & 0x10)
8383      coin_lockout_w(1, 1);
8484}
8585
src/mame/drivers/goodejan.c
r2375r2376
7979
8080   switch(goodejan_mux_data)
8181   {
82      case 1:    ret = readinputport(1); break;
83      case 2:    ret = readinputport(2); break;
84      case 4:    ret = readinputport(3); break;
85      case 8:    ret = readinputport(4); break;
86      case 0x10: ret = readinputport(5); break;
82      case 1:    ret = input_port_read_indexed(machine, 1); break;
83      case 2:    ret = input_port_read_indexed(machine, 2); break;
84      case 4:    ret = input_port_read_indexed(machine, 3); break;
85      case 8:    ret = input_port_read_indexed(machine, 4); break;
86      case 0x10: ret = input_port_read_indexed(machine, 5); break;
8787   }
8888
8989   return ret;
src/mame/drivers/zaxxon.c
r2375r2376
422422   int num = (FPTR)param;
423423   int delta, res;
424424
425   delta = readinputportbytag(dialname[num]);
425   delta = input_port_read(machine, dialname[num]);
426426
427427   if (delta < 0x80)
428428   {
src/mame/drivers/aleck64.c
r2375r2376
175175{
176176   if (offset == 0)
177177   {
178      return (readinputport(3));
178      return (input_port_read_indexed(machine, 3));
179179   }
180180   else if (offset == 1)
181181   {
182      return (readinputport(4));
182      return (input_port_read_indexed(machine, 4));
183183   }
184184
185185   return 0;
src/mame/drivers/astrof.c
r2375r2376
123123
124124static CUSTOM_INPUT( astrof_p1_controls_r )
125125{
126   return readinputportbytag("P1");
126   return input_port_read(machine, "P1");
127127}
128128
129129
r2375r2376
134134   /* on an upright cabinets, a single set of controls
135135       is connected to both sets of pins on the edge
136136       connector */
137   if (readinputportbytag("CAB"))
138      ret = readinputportbytag("P2");
137   if (input_port_read(machine, "CAB"))
138      ret = input_port_read(machine, "P2");
139139   else
140      ret = readinputportbytag("P1");
140      ret = input_port_read(machine, "P1");
141141
142142   return ret;
143143}
r2375r2376
223223
224224static WRITE8_HANDLER( video_control_1_w )
225225{
226   flipscreen = ((data >> 0) & 0x01) & readinputportbytag("FLIP");
226   flipscreen = ((data >> 0) & 0x01) & input_port_read(machine, "FLIP");
227227
228228   /* this ties to the CLR pin of the shift registers */
229229   screen_off = (data & 0x02) ? TRUE : FALSE;
src/mame/drivers/karnov.c
r2375r2376
326326{
327327   switch (offset<<1) {
328328      case 0: /* Player controls */
329         return ( readinputportbytag("IN0") + (readinputportbytag("IN1")<<8));
329         return ( input_port_read(machine, "IN0") + (input_port_read(machine, "IN1")<<8));
330330      case 2: /* Start buttons & VBL */
331         return readinputportbytag("IN2");
331         return input_port_read(machine, "IN2");
332332      case 4: /* Dipswitch A & B */
333         return ( readinputportbytag("DSW1") + (readinputportbytag("DSW2")<<8));
333         return ( input_port_read(machine, "DSW1") + (input_port_read(machine, "DSW2")<<8));
334334      case 6: /* i8751 return values */
335335         return i8751_return;
336336   }
r2375r2376
652652   static int latch;
653653
654654   /* Coin input to the i8751 generates an interrupt to the main cpu */
655   if (readinputport(3) == coin_mask) latch=1;
656   if (readinputport(3) != coin_mask && latch) {
655   if (input_port_read_indexed(machine, 3) == coin_mask) latch=1;
656   if (input_port_read_indexed(machine, 3) != coin_mask && latch) {
657657      if (i8751_needs_ack) {
658658         /* i8751 is busy - queue the command */
659         i8751_coin_pending=readinputport(3) | 0x8000;
659         i8751_coin_pending=input_port_read_indexed(machine, 3) | 0x8000;
660660      } else {
661         i8751_return=readinputport(3) | 0x8000;
661         i8751_return=input_port_read_indexed(machine, 3) | 0x8000;
662662         cpunum_set_input_line(machine, 0,6,HOLD_LINE);
663663         i8751_needs_ack=1;
664664      }
src/mame/drivers/xtheball.c
r2375r2376
207207
208208static READ16_HANDLER( port0_r )
209209{
210   int result = readinputport(0);
210   int result = input_port_read_indexed(machine, 0);
211211   result ^= ticket_dispenser_r(machine,0) >> 3;
212212   return result;
213213}
r2375r2376
215215
216216static READ16_HANDLER( analogx_r )
217217{
218   return (readinputportbytag("ANALOGX") << 8) | 0x00ff;
218   return (input_port_read(machine, "ANALOGX") << 8) | 0x00ff;
219219}
220220
221221
r2375r2376
223223{
224224   /* doubles as a watchdog address */
225225   watchdog_reset_w(machine,0,0);
226   return (readinputportbytag("ANALOGY") << 8) | 0x00ff;
226   return (input_port_read(machine, "ANALOGY") << 8) | 0x00ff;
227227}
228228
229229
src/mame/drivers/maxaflex.c
r2375r2376
4646
4747static READ8_HANDLER( mcu_portA_r )
4848{
49   portA_in = readinputport(5) | (readinputport(4) << 4) | (readinputport(0) << 5);
49   portA_in = input_port_read_indexed(machine, 5) | (input_port_read_indexed(machine, 4) << 4) | (input_port_read_indexed(machine, 0) << 5);
5050   return (portA_in & ~ddrA) | (portA_out & ddrA);
5151}
5252
src/mame/drivers/vegas.c
r2375r2376
14571457{
14581458   if (data < 8 || data > 15)
14591459      logerror("%08X:Unexpected analog port select = %08X\n", activecpu_get_pc(), data);
1460   pending_analog_read = readinputport(4 + (data & 7));
1460   pending_analog_read = input_port_read_indexed(machine, 4 + (data & 7));
14611461}
14621462
14631463
src/mame/drivers/kopunch.c
r2375r2376
1818{
1919   if (cpu_getiloops() == 0)
2020   {
21      if (~input_port_1_r(machine,0) & 0x80)   /* coin 1 */
21      if (~input_port_read_indexed(machine, 1) & 0x80)   /* coin 1 */
2222      {
2323         cpunum_set_input_line_and_vector(machine, 0,0,HOLD_LINE,0xf7);   /* RST 30h */
2424         return;
2525      }
26      else if (~input_port_1_r(machine,0) & 0x08)   /* coin 2 */
26      else if (~input_port_read_indexed(machine, 1) & 0x08)   /* coin 2 */
2727      {
2828         cpunum_set_input_line_and_vector(machine, 0,0,HOLD_LINE,0xef);   /* RST 28h */
2929         return;
r2375r2376
3939   if (offset == 0)
4040      return mame_rand(machine);
4141   else
42      return (mame_rand(machine) & 0x07) | input_port_1_r(machine,0);
42      return (mame_rand(machine) & 0x07) | input_port_read_indexed(machine, 1);
4343}
4444
4545static WRITE8_HANDLER( kopunch_lamp_w )
src/mame/drivers/segaybd.c
r2375r2376
256256            return misc_io_data[offset];
257257
258258         /* otherwise, return an input port */
259         return readinputport(offset);
259         return input_port_read_indexed(machine, offset);
260260
261261      /* 'SEGA' protection */
262262      case 0x10/2:
r2375r2376
357357{
358358   static const char *const ports[] = { "ADC0", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6" };
359359   int selected = ((offset & 3) == 3) ? (3 + (misc_io_data[0x08/2] & 3)) : (offset & 3);
360   int value = readinputportbytag_safe(ports[selected], 0xff);
360   int value = input_port_read_safe(machine, ports[selected], 0xff);
361361   analog_data[offset & 3] = value;
362362}
363363
src/mame/drivers/shuuz.c
r2375r2376
9999   /* when reading the even ports, do a real analog port update */
100100   if (which == 0)
101101   {
102      int dx = (INT8)readinputport(2);
103      int dy = (INT8)readinputport(3);
102      int dx = (INT8)input_port_read_indexed(machine, 2);
103      int dy = (INT8)input_port_read_indexed(machine, 3);
104104
105105      cur[0] = dx + dy;
106106      cur[1] = dx - dy;
r2375r2376
140140
141141static READ16_HANDLER( special_port0_r )
142142{
143   int result = readinputport(0);
143   int result = input_port_read_indexed(machine, 0);
144144
145145   if ((result & 0x0800) && atarigen_get_hblank(machine->primary_screen))
146146      result &= ~0x0800;
src/mame/drivers/xorworld.c
r2375r2376
7676/* the EEPROM is read thru bit 4 */
7777static READ16_HANDLER( xorworld_input_r )
7878{
79   return readinputport(0) | ((EEPROM_read_bit() & 0x01) << 4);
79   return input_port_read_indexed(machine, 0) | ((EEPROM_read_bit() & 0x01) << 4);
8080}
8181
8282static WRITE16_HANDLER( eeprom_chip_select_w )
src/mame/drivers/enigma2.c
r2375r2376
323323      if (protection_data != 0xff)
324324         ret = protection_data ^ 0x88;
325325      else
326         ret = readinputport(2);
326         ret = input_port_read_indexed(machine, 2);
327327      break;
328328
329329   case 0x02:
r2375r2376
369369
370370static WRITE8_HANDLER( enigma2_flip_screen_w )
371371{
372   engima2_flip_screen = ((data >> 5) & 0x01) && ((readinputport(2) & 0x20) == 0x20);
372   engima2_flip_screen = ((data >> 5) & 0x01) && ((input_port_read_indexed(machine, 2) & 0x20) == 0x20);
373373}
374374
375375
376376static CUSTOM_INPUT( p1_controls_r )
377377{
378   return readinputportbytag("P1CONTROLS");
378   return input_port_read(machine, "P1CONTROLS");
379379}
380380
381381
382382static CUSTOM_INPUT( p2_controls_r )
383383{
384384   if (engima2_flip_screen)
385      return readinputportbytag("P2CONTROLS");
385      return input_port_read(machine, "P2CONTROLS");
386386   else
387      return readinputportbytag("P1CONTROLS");
387      return input_port_read(machine, "P1CONTROLS");
388388}
389389
390390
src/mame/drivers/segaorun.c
r2375r2376
388388         return ppi8255_0_r(machine, offset & 3);
389389
390390      case 0x10/2:
391         return readinputport(offset & 3);
391         return input_port_read_indexed(machine, offset & 3);
392392
393393      case 0x30/2:
394394      {
395395         static const char *const ports[] = { "ADC0", "ADC1", "ADC2", "ADC3", "ADC4", "ADC5", "ADC6", "ADC7" };
396         return readinputportbytag_safe(ports[adc_select], 0x0010);
396         return input_port_read_safe(machine, ports[adc_select], 0x0010);
397397      }
398398
399399      case 0x60/2:
r2375r2376
451451      case 0x1002/2:
452452      case 0x1004/2:
453453      case 0x1006/2:
454         return readinputport(offset & 3);
454         return input_port_read_indexed(machine, offset & 3);
455455
456456      case 0x3020/2:
457457      {
458458         static const char *const ports[] = { "ADC0", "ADC1", "ADC2", "ADC3" };
459         return readinputportbytag_safe(ports[adc_select], 0x0010);
459         return input_port_read_safe(machine, ports[adc_select], 0x0010);
460460      }
461461   }
462462   logerror("%06X:misc_io_r - unknown read access to address %04X\n", activecpu_get_pc(), offset * 2);
src/mame/drivers/koikoi.c
r2375r2376
104104{
105105   if(!offset)
106106   {
107         return input_port_1_r(machine,0)^ioram[4]; //coin
107         return input_port_read_indexed(machine, 1)^ioram[4]; //coin
108108   }
109109   return 0;
110110}
src/mame/drivers/gticlub.c
r2375r2376
205205   adc1038_data_in = bit & 1;
206206}
207207
208static void adc1038_clk_w(int bit)
208static void adc1038_clk_w(running_machine *machine, int bit)
209209{
210210   // GTI Club doesn't sync on SARS
211211   if (adc1038_gticlub_hack)
r2375r2376
216216
217217         switch (adc1038_adr)
218218         {
219            case 0: adc1038_adc_data = readinputport(4); break;
220            case 1: adc1038_adc_data = readinputport(5); break;
221            case 2: adc1038_adc_data = readinputport(6); break;
222            case 3: adc1038_adc_data = readinputport(7); break;
219            case 0: adc1038_adc_data = input_port_read_indexed(machine, 4); break;
220            case 1: adc1038_adc_data = input_port_read_indexed(machine, 5); break;
221            case 2: adc1038_adc_data = input_port_read_indexed(machine, 6); break;
222            case 3: adc1038_adc_data = input_port_read_indexed(machine, 7); break;
223223            case 4: adc1038_adc_data = 0x000; break;
224224            case 5: adc1038_adc_data = 0x000; break;
225225            case 6: adc1038_adc_data = 0x000; break;
r2375r2376
255255   adc1038_clk = bit;
256256}
257257
258static int adc1038_sars_r(void)
258static int adc1038_sars_r(running_machine *machine)
259259{
260260   adc1038_cycle = 0;
261261
262262   switch (adc1038_adr)
263263   {
264      case 0: adc1038_adc_data = readinputport(4); break;
265      case 1: adc1038_adc_data = readinputport(5); break;
266      case 2: adc1038_adc_data = readinputport(6); break;
267      case 3: adc1038_adc_data = readinputport(7); break;
264      case 0: adc1038_adc_data = input_port_read_indexed(machine, 4); break;
265      case 1: adc1038_adc_data = input_port_read_indexed(machine, 5); break;
266      case 2: adc1038_adc_data = input_port_read_indexed(machine, 6); break;
267      case 3: adc1038_adc_data = input_port_read_indexed(machine, 7); break;
268268      case 4: adc1038_adc_data = 0x000; break;
269269      case 5: adc1038_adc_data = 0x000; break;
270270      case 6: adc1038_adc_data = 0x000; break;
r2375r2376
285285   {
286286      if (ACCESSING_BITS_24_31)
287287      {
288         r |= readinputport(0) << 24;
288         r |= input_port_read_indexed(machine, 0) << 24;
289289      }
290290      if (ACCESSING_BITS_16_23)
291291      {
292         r |= readinputport(1) << 16;
292         r |= input_port_read_indexed(machine, 1) << 16;
293293      }
294294      if (ACCESSING_BITS_8_15)
295295      {
296         r |= (adc1038_sars_r() << 7) << 8;
296         r |= (adc1038_sars_r(machine) << 7) << 8;
297297      }
298298      if (ACCESSING_BITS_0_7)
299299      {
300         r |= readinputport(3) << 0;
300         r |= input_port_read_indexed(machine, 3) << 0;
301301      }
302302      return r;
303303   }
r2375r2376
357357         }
358358
359359         adc1038_di_w((data >> 24) & 1);
360         adc1038_clk_w((data >> 25) & 1);
360         adc1038_clk_w(machine, (data >> 25) & 1);
361361
362362         set_cgboard_id((data >> 28) & 0x3);
363363      }
src/mame/drivers/mazerbla.c
r2375r2376
440440
441441   if (bcd_7445<10)
442442   {
443      ret = readinputport( bcd_7445 );
443      ret = input_port_read_indexed(machine, bcd_7445 );
444444   }
445445   return ret;
446446}
src/mame/drivers/foodf.c
r2375r2376
202202
203203static READ16_HANDLER( analog_r )
204204{
205   return readinputport(whichport);
205   return input_port_read_indexed(machine, whichport);
206206}
207207
208208
r2375r2376
353353
354354static READ8_HANDLER( pot_r )
355355{
356   return (readinputport(5) >> offset) << 7;
356   return (input_port_read_indexed(machine, 5) >> offset) << 7;
357357}
358358
359359static const struct POKEYinterface pokey_interface =
src/mame/drivers/namcona1.c
r2375r2376
514514/***************************************************************************/
515515
516516static void
517simulate_mcu( void )
517simulate_mcu( running_machine *machine )
518518{
519519   int i;
520520   UINT16 data;
r2375r2376
524524
525525   if (is_na2)
526526   {
527      mcu_ram[0xfc0/2] = readinputport(0x0); /* dipswitch */
527      mcu_ram[0xfc0/2] = input_port_read_indexed(machine, 0x0); /* dipswitch */
528528
529529      for( i=1; i<=4; i++ )
530530      {
531         data = readinputport(i)<<8;
531         data = input_port_read_indexed(machine, i)<<8;
532532         switch( namcona1_gametype )
533533         {
534534         case NAMCO_KNCKHEAD:
r2375r2376
547547            if( data&0x4000 ) data |= 0x10; /* jump */
548548            if( i==1 )
549549            {
550               if( readinputport(1)&0x80 ) data |= 0x80; /* P1 start */
550               if( input_port_read_indexed(machine, 1)&0x80 ) data |= 0x80; /* P1 start */
551551            }
552552            if( i==2 )
553553            {
554               if( readinputport(2)&0x80 ) data |= 0x80; /* P2 start */
554               if( input_port_read_indexed(machine, 2)&0x80 ) data |= 0x80; /* P2 start */
555555            }
556556            break;
557557
r2375r2376
570570      mcu_ram[0xfc0/2+0x08] = 0xffff; /* analog6,7 */
571571      mcu_ram[0xfc0/2+0x09] = 0xffff; /* encoder0,1 */
572572
573      poll_coins = readinputport(5); /* coin input */
573      poll_coins = input_port_read_indexed(machine, 5); /* coin input */
574574      if( (poll_coins&0x8)&~(mCoinState&0x8) ) mCoinCount[0]++;
575575      if( (poll_coins&0x4)&~(mCoinState&0x4) ) mCoinCount[1]++;
576576      if( (poll_coins&0x2)&~(mCoinState&0x2) ) mCoinCount[2]++;
r2375r2376
581581      mcu_ram[0xfc0/2+0xb] = (mCoinCount[2]<<8)|mCoinCount[3];
582582
583583      /* special handling for F/A */
584      data = ~((readinputport(1)<<8)|readinputport(2));
584      data = ~((input_port_read_indexed(machine, 1)<<8)|input_port_read_indexed(machine, 2));
585585      mcu_ram[0xffc/2] = data;
586586      mcu_ram[0xffe/2] = data;
587587
588588      if( namcona1_gametype == NAMCO_XDAY2 )
589589      {
590         int p1 = readinputport(1);
591         int p2 = readinputport(2);
590         int p1 = input_port_read_indexed(machine, 1);
591         int p2 = input_port_read_indexed(machine, 2);
592592         UINT32 code = 0;
593593         if( p2&0x40 ) code |= 0x2000; // enter (top-level of self-test)
594594         if( p2&0x20 ) code |= 0x1000; // exit  (top-level of self-test)
r2375r2376
11951195   switch (mcu_port6 & 0xe0)
11961196   {
11971197      case 0x40:
1198         return readinputport(0);
1198         return input_port_read_indexed(machine, 0);
11991199         break;
12001200
12011201        case 0x60:
1202         return readinputport(1);
1202         return input_port_read_indexed(machine, 1);
12031203         break;
12041204
12051205      case 0x20:
1206         return readinputport(4);
1206         return input_port_read_indexed(machine, 4);
12071207         break;
12081208
12091209      case 0x00:
1210         return readinputport(3);
1210         return input_port_read_indexed(machine, 3);
12111211         break;
12121212   }
12131213
r2375r2376
12561256static READ8_HANDLER( portana_r )
12571257{
12581258   static const UINT8 bitnum[8] = { 0x40, 0x20, 0x10, 0x01, 0x02, 0x04, 0x08, 0x80 };
1259   UINT8 port = readinputport(2);
1259   UINT8 port = input_port_read_indexed(machine, 2);
12601260
12611261   return (port & bitnum[offset>>1]) ? 0xff : 0x00;
12621262}
r2375r2376
12751275   int level = cpu_getiloops(); /* 0,1,2,3,4 */
12761276   if( level==0 )
12771277   {
1278      simulate_mcu();
1278      simulate_mcu(machine);
12791279   }
1280   if(1)// mEnableInterrupts )
1280   if( mEnableInterrupts )
12811281   {
12821282      if( (namcona1_vreg[0x1a/2]&(1<<level))==0 )
12831283      {
src/mame/drivers/armedf.c
r2375r2376
835835   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
836836
837837   MDRV_SOUND_ADD(DAC, 0)
838   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
838   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
839839
840840   MDRV_SOUND_ADD(DAC, 0)
841   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
841   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
842842MACHINE_DRIVER_END
843843
844844static MACHINE_DRIVER_START( armedf )
src/mame/drivers/acefruit.c
r2375r2376
146146   switch (bit_mask)
147147   {
148148      case 0x01:
149         return ((readinputportbytag("PAYOUT") & bit_mask) >> 0);
149         return ((input_port_read(machine, "PAYOUT") & bit_mask) >> 0);
150150      case 0x02:
151         return ((readinputportbytag("PAYOUT") & bit_mask) >> 1);
151         return ((input_port_read(machine, "PAYOUT") & bit_mask) >> 1);
152152      default:
153153         logerror("sidewndr_payout_r : invalid %02X bit_mask\n",bit_mask);
154154         return 0;
r2375r2376
162162   switch (bit_mask)
163163   {
164164      case 0x01:
165         return ((readinputportbytag("COINAGE") & bit_mask) >> 0);
165         return ((input_port_read(machine, "COINAGE") & bit_mask) >> 0);
166166      case 0x02:
167         return ((readinputportbytag("COINAGE") & bit_mask) >> 1);
167         return ((input_port_read(machine, "COINAGE") & bit_mask) >> 1);
168168      case 0x04:
169         return ((readinputportbytag("COINAGE") & bit_mask) >> 2);
169         return ((input_port_read(machine, "COINAGE") & bit_mask) >> 2);
170170      case 0x08:
171         return ((readinputportbytag("COINAGE") & bit_mask) >> 3);
171         return ((input_port_read(machine, "COINAGE") & bit_mask) >> 3);
172172      default:
173173         logerror("starspnr_coinage_r : invalid %02X bit_mask\n",bit_mask);
174174         return 0;
r2375r2376
182182   switch (bit_mask)
183183   {
184184      case 0x01:
185         return ((readinputportbytag("PAYOUT") & bit_mask) >> 0);
185         return ((input_port_read(machine, "PAYOUT") & bit_mask) >> 0);
186186      case 0x02:
187         return ((readinputportbytag("PAYOUT") & bit_mask) >> 1);
187         return ((input_port_read(machine, "PAYOUT") & bit_mask) >> 1);
188188      case 0x04:
189         return ((readinputportbytag("PAYOUT") & bit_mask) >> 2);
189         return ((input_port_read(machine, "PAYOUT") & bit_mask) >> 2);
190190      default:
191191         logerror("starspnr_payout_r : invalid %02X bit_mask\n",bit_mask);
192192         return 0;
src/mame/drivers/dkong.c
r2375r2376
593593#if DEBUG_DISC_SOUND
594594   static UINT8 ui_snd = 0;
595595   static UINT8 lst = 0;
596   if  (!lst && (readinputportbytag("TST") & 0x01))
596   if  (!lst && (input_port_read(machine, "TST") & 0x01))
597597   {
598598      ui_snd = (ui_snd + 1) % 10;
599599      popmessage("Sound %d", ui_snd);
600600   }
601   lst = readinputportbytag("TST") & 0x01;
601   lst = input_port_read(machine, "TST") & 0x01;
602602   if (ui_snd<8)
603      dkongjr_snd_w1(ui_snd, (readinputportbytag("TST") & 0x02)>>1);
603      dkongjr_snd_w1(ui_snd, (input_port_read(machine, "TST") & 0x02)>>1);
604604   else
605      dkongjr_snd_w2(ui_snd-8, (readinputportbytag("TST") & 0x02)>>1);
605      dkongjr_snd_w2(ui_snd-8, (input_port_read(machine, "TST") & 0x02)>>1);
606606#endif
607607
608   r = (readinputportbytag("IN2") & 0xBF) | (dkong_audio_status_r(machine,0) << 6);
608   r = (input_port_read(machine, "IN2") & 0xBF) | (dkong_audio_status_r(machine,0) << 6);
609609   coin_counter_w(offset, r >> 7);
610610   if (r & 0x10)
611611      r = (r & ~0x10) | 0x80; /* service ==> coint */
src/mame/drivers/sprint4.c
r2375r2376
6666
6767   UINT8 wheel[4] =
6868   {
69      readinputportbytag("WHEEL1"),
70      readinputportbytag("WHEEL2"),
71      readinputportbytag("WHEEL3"),
72      readinputportbytag("WHEEL4")
69      input_port_read(machine, "WHEEL1"),
70      input_port_read(machine, "WHEEL2"),
71      input_port_read(machine, "WHEEL3"),
72      input_port_read(machine, "WHEEL4")
7373   };
7474   UINT8 lever[4] =
7575   {
76      readinputportbytag("LEVER1"),
77      readinputportbytag("LEVER2"),
78      readinputportbytag("LEVER3"),
79      readinputportbytag("LEVER4")
76      input_port_read(machine, "LEVER1"),
77      input_port_read(machine, "LEVER2"),
78      input_port_read(machine, "LEVER3"),
79      input_port_read(machine, "LEVER4")
8080   };
8181
8282   int i;
r2375r2376
115115
116116   /* NMI and watchdog are disabled during service mode */
117117
118   watchdog_enable(machine, readinputport(0) & 0x40);
118   watchdog_enable(machine, input_port_read_indexed(machine, 0) & 0x40);
119119
120   if (readinputport(0) & 0x40)
120   if (input_port_read_indexed(machine, 0) & 0x40)
121121      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
122122
123123   timer_set(video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, nmi_callback);
r2375r2376
148148
149149static READ8_HANDLER( sprint4_analog_r )
150150{
151   return (readinputportbytag("ANALOG") << (~offset & 7)) & 0x80;
151   return (input_port_read(machine, "ANALOG") << (~offset & 7)) & 0x80;
152152}
153153static READ8_HANDLER( sprint4_coin_r )
154154{
155   return (readinputportbytag("COIN") << (~offset & 7)) & 0x80;
155   return (input_port_read(machine, "COIN") << (~offset & 7)) & 0x80;
156156}
157157static READ8_HANDLER( sprint4_collision_r )
158158{
159   return (readinputportbytag("COLLISION") << (~offset & 7)) & 0x80;
159   return (input_port_read(machine, "COLLISION") << (~offset & 7)) & 0x80;
160160}
161161
162162
163163static READ8_HANDLER( sprint4_options_r )
164164{
165   return (readinputportbytag("DIP") >> (2 * (offset & 3))) & 3;
165   return (input_port_read(machine, "DIP") >> (2 * (offset & 3))) & 3;
166166}
167167
168168
src/mame/drivers/skyraid.c
r2375r2376
5252
5353static READ8_HANDLER( skyraid_port_0_r )
5454{
55   UINT8 val = readinputport(0);
55   UINT8 val = input_port_read_indexed(machine, 0);
5656
57   if (readinputport(4) > analog_range)
57   if (input_port_read_indexed(machine, 4) > analog_range)
5858      val |= 0x40;
59   if (readinputport(5) > analog_range)
59   if (input_port_read_indexed(machine, 5) > analog_range)
6060      val |= 0x80;
6161
6262   return val;
src/mame/drivers/metlclsh.c
r2375r2376
302302   if (cpu_getiloops() == 0)
303303      return;
304304   /* generate NMI on coin insertion */
305   if ((~readinputport(2) & 0xc0) || (~readinputport(3) & 0x40))
305   if ((~input_port_read_indexed(machine, 2) & 0xc0) || (~input_port_read_indexed(machine, 3) & 0x40))
306306      cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, ASSERT_LINE);
307307}
308308
src/mame/drivers/88games.c
r2375r2376
7878   static int cheat = 0;
7979   static const int bits[] = { 0xee, 0xff, 0xbb, 0xaa };
8080
81   res = readinputportbytag("IN1");
81   res = input_port_read(machine, "IN1");
8282
83   if ((readinputportbytag("IN0") & 0x08) == 0)
83   if ((input_port_read(machine, "IN0") & 0x08) == 0)
8484   {
8585      res |= 0x55;
8686      res &= bits[cheat];
r2375r2376
9696   static int cheat = 0;
9797   static const int bits[] = { 0xee, 0xff, 0xbb, 0xaa };
9898
99   res = readinputportbytag("IN2");
99   res = input_port_read(machine, "IN2");
100100
101   if ((readinputportbytag("IN0") & 0x08) == 0)
101   if ((input_port_read(machine, "IN0") & 0x08) == 0)
102102   {
103103      res |= 0x55;
104104      res &= bits[cheat];
src/mame/drivers/ddenlovr.c
r2375r2376
13051305
13061306static READ16_HANDLER( ddenlovr_special_r )
13071307{
1308   int res = readinputport(2) | (ddenlovr_blitter_irq_flag << 6);
1308   int res = input_port_read_indexed(machine, 2) | (ddenlovr_blitter_irq_flag << 6);
13091309
13101310   return res;
13111311}
r2375r2376
14861486   /* 0 and 1 are read from offset 1, 2 from offset 0... */
14871487   switch( ddenlovr_select2 )
14881488   {
1489      case 0x00:   return readinputport(0);
1490      case 0x01:   return readinputport(1);
1491      case 0x02:   return readinputport(2);
1489      case 0x00:   return input_port_read_indexed(machine, 0);
1490      case 0x01:   return input_port_read_indexed(machine, 1);
1491      case 0x02:   return input_port_read_indexed(machine, 2);
14921492   }
14931493   return 0xff;
14941494}
r2375r2376
14961496
14971497static READ8_HANDLER( quiz365_input_r )
14981498{
1499   if (!(ddenlovr_select & 0x01))   return readinputport(3);
1500   if (!(ddenlovr_select & 0x02))   return readinputport(4);
1501   if (!(ddenlovr_select & 0x04))   return readinputport(5);
1499   if (!(ddenlovr_select & 0x01))   return input_port_read_indexed(machine, 3);
1500   if (!(ddenlovr_select & 0x02))   return input_port_read_indexed(machine, 4);
1501   if (!(ddenlovr_select & 0x04))   return input_port_read_indexed(machine, 5);
15021502   if (!(ddenlovr_select & 0x08))   return 0xff;//mame_rand(machine);
15031503   if (!(ddenlovr_select & 0x10))   return 0xff;//mame_rand(machine);
15041504   return 0xff;
r2375r2376
15101510   /* 0 and 1 are read from offset 1, 2 from offset 0... */
15111511   switch( ddenlovr_select2 )
15121512   {
1513      case 0x10:   return readinputport(0);
1514      case 0x11:   return readinputport(1);
1515      case 0x12:   return readinputport(2) | (ddenlovr_blitter_irq_flag << 6);
1513      case 0x10:   return input_port_read_indexed(machine, 0);
1514      case 0x11:   return input_port_read_indexed(machine, 1);
1515      case 0x12:   return input_port_read_indexed(machine, 2) | (ddenlovr_blitter_irq_flag << 6);
15161516   }
15171517   return 0xff;
15181518}
r2375r2376
16151615static READ16_HANDLER( ddenlvrj_dsw_r )
16161616{
16171617   UINT16 dsw = 0;
1618   if ((~*ddenlvrj_dsw_sel) & 0x01)   dsw |= readinputport(3);   // dsw 1
1619   if ((~*ddenlvrj_dsw_sel) & 0x02)   dsw |= readinputport(4);   // dsw 2
1620   if ((~*ddenlvrj_dsw_sel) & 0x04)   dsw |= readinputport(5);   // ?
1618   if ((~*ddenlvrj_dsw_sel) & 0x01)   dsw |= input_port_read_indexed(machine, 3);   // dsw 1
1619   if ((~*ddenlvrj_dsw_sel) & 0x02)   dsw |= input_port_read_indexed(machine, 4);   // dsw 2
1620   if ((~*ddenlvrj_dsw_sel) & 0x04)   dsw |= input_port_read_indexed(machine, 5);   // ?
16211621   return dsw;
16221622}
16231623
r2375r2376
16331633
16341634static READ16_HANDLER( ddenlvrj_blitter_r )
16351635{
1636   return readinputport(2) | (ddenlovr_blitter_irq_flag ? 0x60 : 0x00 );   // bit 4 = 1 -> blitter busy
1636   return input_port_read_indexed(machine, 2) | (ddenlovr_blitter_irq_flag ? 0x60 : 0x00 );   // bit 4 = 1 -> blitter busy
16371637}
16381638
16391639static ADDRESS_MAP_START( ddenlvrj_readmem, ADDRESS_SPACE_PROGRAM, 16 )
r2375r2376
17181718
17191719static READ16_HANDLER( nettoqc_special_r )
17201720{
1721   return readinputport(2) | (ddenlovr_blitter_irq_flag ? 0x60 : 0x00 );
1721   return input_port_read_indexed(machine, 2) | (ddenlovr_blitter_irq_flag ? 0x60 : 0x00 );
17221722}
17231723
17241724static READ16_HANDLER( nettoqc_input_r )
17251725{
1726   if (!(ddenlovr_select & 0x01))   return readinputport(3);
1727   if (!(ddenlovr_select & 0x02))   return readinputport(4);
1728   if (!(ddenlovr_select & 0x04))   return readinputport(5);
1726   if (!(ddenlovr_select & 0x01))   return input_port_read_indexed(machine, 3);
1727   if (!(ddenlovr_select & 0x02))   return input_port_read_indexed(machine, 4);
1728   if (!(ddenlovr_select & 0x04))   return input_port_read_indexed(machine, 5);
17291729   return 0xffff;
17301730}
17311731
r2375r2376
18101810
18111811static READ8_HANDLER( rongrong_input_r )
18121812{
1813   if (!(ddenlovr_select & 0x01))   return readinputport(3);
1814   if (!(ddenlovr_select & 0x02))   return readinputport(4);
1813   if (!(ddenlovr_select & 0x01))   return input_port_read_indexed(machine, 3);
1814   if (!(ddenlovr_select & 0x02))   return input_port_read_indexed(machine, 4);
18151815   if (!(ddenlovr_select & 0x04))   return 0xff;//mame_rand(machine);
18161816   if (!(ddenlovr_select & 0x08))   return 0xff;//mame_rand(machine);
1817   if (!(ddenlovr_select & 0x10))   return readinputport(5);
1817   if (!(ddenlovr_select & 0x10))   return input_port_read_indexed(machine, 5);
18181818   return 0xff;
18191819}
18201820
r2375r2376
21312131
21322132static READ8_HANDLER( funkyfig_dsw_r )
21332133{
2134   if (!(ddenlovr_select & 0x01))   return readinputport(3);
2135   if (!(ddenlovr_select & 0x02))   return readinputport(4);
2136   if (!(ddenlovr_select & 0x04))   return readinputport(5);
2134   if (!(ddenlovr_select & 0x01))   return input_port_read_indexed(machine, 3);
2135   if (!(ddenlovr_select & 0x02))   return input_port_read_indexed(machine, 4);
2136   if (!(ddenlovr_select & 0x04))   return input_port_read_indexed(machine, 5);
21372137   logerror("%06x: warning, unknown bits read, ddenlovr_select = %02x\n", activecpu_get_pc(), ddenlovr_select);
21382138   return 0xff;
21392139}
r2375r2376
21442144{
21452145   switch( ddenlovr_select2 )
21462146   {
2147      case 0x22:   return readinputport(2);
2147      case 0x22:   return input_port_read_indexed(machine, 2);
21482148      case 0x23:   return funkyfig_lockout;
21492149   }
21502150   logerror("%06x: warning, unknown bits read, ddenlovr_select2 = %02x\n", activecpu_get_pc(), ddenlovr_select2);
r2375r2376
21552155{
21562156   switch( ddenlovr_select2 )
21572157   {
2158      case 0x20:   return readinputport(0);
2159      case 0x21:   return readinputport(1);
2158      case 0x20:   return input_port_read_indexed(machine, 0);
2159      case 0x21:   return input_port_read_indexed(machine, 1);
21602160   }
21612161   logerror("%06x: warning, unknown bits read, ddenlovr_select2 = %02x\n", activecpu_get_pc(), ddenlovr_select2);
21622162   return 0xff;
r2375r2376
22662266{
22672267   UINT8 val = 0xff;
22682268
2269   if      (!(keyb & 0x01))   val = readinputport(offset * 5 + 1);
2270   else if (!(keyb & 0x02))   val = readinputport(offset * 5 + 2);
2271   else if (!(keyb & 0x04))   val = readinputport(offset * 5 + 3);
2272   else if (!(keyb & 0x08))   val = readinputport(offset * 5 + 4);
2273   else if (!(keyb & 0x10))   val = readinputport(offset * 5 + 5);
2269   if      (!(keyb & 0x01))   val = input_port_read_indexed(machine, offset * 5 + 1);
2270   else if (!(keyb & 0x02))   val = input_port_read_indexed(machine, offset * 5 + 2);
2271   else if (!(keyb & 0x04))   val = input_port_read_indexed(machine, offset * 5 + 3);
2272   else if (!(keyb & 0x08))   val = input_port_read_indexed(machine, offset * 5 + 4);
2273   else if (!(keyb & 0x10))   val = input_port_read_indexed(machine, offset * 5 + 5);
22742274
2275   val |= readinputport(16 + offset);
2275   val |= input_port_read_indexed(machine, 16 + offset);
22762276   return val;
22772277}
22782278
22792279static READ8_HANDLER( hanakanz_dsw_r )
22802280{
2281   if (!(dsw & 0x01))   return readinputport(11);
2282   if (!(dsw & 0x02))   return readinputport(12);
2283   if (!(dsw & 0x04))   return readinputport(13);
2284   if (!(dsw & 0x08))   return readinputport(14);
2285   if (!(dsw & 0x10))   return readinputport(15);
2281   if (!(dsw & 0x01))   return input_port_read_indexed(machine, 11);
2282   if (!(dsw & 0x02))   return input_port_read_indexed(machine, 12);
2283   if (!(dsw & 0x04))   return input_port_read_indexed(machine, 13);
2284   if (!(dsw & 0x08))   return input_port_read_indexed(machine, 14);
2285   if (!(dsw & 0x10))   return input_port_read_indexed(machine, 15);
22862286   return 0xff;
22872287}
22882288
r2375r2376
24712471{
24722472   UINT8 val = 0xff;
24732473
2474   if      (!(keyb & 0x01))   val = readinputport(offset * 5 + 1);
2475   else if (!(keyb & 0x02))   val = readinputport(offset * 5 + 2);
2476   else if (!(keyb & 0x04))   val = readinputport(offset * 5 + 3);
2477   else if (!(keyb & 0x08))   val = readinputport(offset * 5 + 4);
2478   else if (!(keyb & 0x10))   val = readinputport(offset * 5 + 5);
2474   if      (!(keyb & 0x01))   val = input_port_read_indexed(machine, offset * 5 + 1);
2475   else if (!(keyb & 0x02))   val = input_port_read_indexed(machine, offset * 5 + 2);
2476   else if (!(keyb & 0x04))   val = input_port_read_indexed(machine, offset * 5 + 3);
2477   else if (!(keyb & 0x08))   val = input_port_read_indexed(machine, offset * 5 + 4);
2478   else if (!(keyb & 0x10))   val = input_port_read_indexed(machine, offset * 5 + 5);
24792479
2480   val |= readinputport(16 + offset);
2480   val |= input_port_read_indexed(machine, 16 + offset);
24812481   if (offset)   val |= 0x80;   // blitter busy
24822482   return val;
24832483}
r2375r2376
26332633{
26342634   switch( ddenlovr_select2 )
26352635   {
2636      case 0x00:   return readinputport(0);
2636      case 0x00:   return input_port_read_indexed(machine, 0);
26372637      case 0x01:   return 0xff;
26382638      case 0x02:   return 0xff;   // bit 7 = 0 -> blitter busy, + hopper switch
26392639      case 0x03:   return 0xff;
r2375r2376
26482648{
26492649   UINT8 ret = 0xff;
26502650
2651   if      (keyb & 0x01)   ret = readinputport(1);
2652   else if   (keyb & 0x02)   ret = readinputport(2);
2653   else if   (keyb & 0x04)   ret = readinputport(3);
2654   else if   (keyb & 0x08)   ret = readinputport(4);
2655   else if   (keyb & 0x10)   ret = readinputport(5);
2651   if      (keyb & 0x01)   ret = input_port_read_indexed(machine, 1);
2652   else if   (keyb & 0x02)   ret = input_port_read_indexed(machine, 2);
2653   else if   (keyb & 0x04)   ret = input_port_read_indexed(machine, 3);
2654   else if   (keyb & 0x08)   ret = input_port_read_indexed(machine, 4);
2655   else if   (keyb & 0x10)   ret = input_port_read_indexed(machine, 5);
26562656   else   logerror("%06x: warning, unknown bits read, keyb = %02x\n", activecpu_get_pc(), keyb);
26572657
26582658   keyb <<= 1;
r2375r2376
26622662
26632663static READ8_HANDLER( mjmyster_dsw_r )
26642664{
2665   if (!(ddenlovr_select & 0x01))   return readinputport(9);
2666   if (!(ddenlovr_select & 0x02))   return readinputport(8);
2667   if (!(ddenlovr_select & 0x04))   return readinputport(7);
2668   if (!(ddenlovr_select & 0x08))   return readinputport(6);
2669   if (!(ddenlovr_select & 0x10))   return readinputport(10);
2665   if (!(ddenlovr_select & 0x01))   return input_port_read_indexed(machine, 9);
2666   if (!(ddenlovr_select & 0x02))   return input_port_read_indexed(machine, 8);
2667   if (!(ddenlovr_select & 0x04))   return input_port_read_indexed(machine, 7);
2668   if (!(ddenlovr_select & 0x08))   return input_port_read_indexed(machine, 6);
2669   if (!(ddenlovr_select & 0x10))   return input_port_read_indexed(machine, 10);
26702670   logerror("%06x: warning, unknown bits read, ddenlovr_select = %02x\n", activecpu_get_pc(), ddenlovr_select);
26712671   return 0xff;
26722672}
r2375r2376
27652765
27662766static READ8_HANDLER( hginga_dsw_r )
27672767{
2768   if (!(ddenlovr_select & 0x01))   return readinputport(11);
2769   if (!(ddenlovr_select & 0x02))   return readinputport(12);
2770   if (!(ddenlovr_select & 0x04))   return readinputport(13);
2771   if (!(ddenlovr_select & 0x08))   return readinputport(14);
2772   if (!(ddenlovr_select & 0x10))   return readinputport(15);
2768   if (!(ddenlovr_select & 0x01))   return input_port_read_indexed(machine, 11);
2769   if (!(ddenlovr_select & 0x02))   return input_port_read_indexed(machine, 12);
2770   if (!(ddenlovr_select & 0x04))   return input_port_read_indexed(machine, 13);
2771   if (!(ddenlovr_select & 0x08))   return input_port_read_indexed(machine, 14);
2772   if (!(ddenlovr_select & 0x10))   return input_port_read_indexed(machine, 15);
27732773   logerror("%06x: warning, unknown bits read, ddenlovr_select = %02x\n", activecpu_get_pc(), ddenlovr_select);
27742774   return 0xff;
27752775}
r2375r2376
27862786{
27872787   switch( hginga_select )
27882788   {
2789      case 0x20:   return readinputport(0);
2790      case 0x21:   return readinputport(16);
2789      case 0x20:   return input_port_read_indexed(machine, 0);
2790      case 0x21:   return input_port_read_indexed(machine, 16);
27912791      case 0x22:   return 0x7f;   // bit 7 = blitter busy, bit 6 = hopper
27922792      case 0x23:   return hginga_coins;
27932793   }
r2375r2376
28322832
28332833      // player 1
28342834      case 0xa1:
2835         return readinputport(1 + hginga_ip++);
2835         return input_port_read_indexed(machine, 1 + hginga_ip++);
28362836
28372837      // player 2
28382838      case 0xa2:
2839         return readinputport(1 + 5 + hginga_ip++);
2839         return input_port_read_indexed(machine, 1 + 5 + hginga_ip++);
28402840   }
28412841   logerror("%04x: input_r with select = %02x\n",activecpu_get_pc(),hginga_select);
28422842   return 0xff;
r2375r2376
29142914{
29152915   UINT8 hopper_bit = ((hgokou_hopper && !(video_screen_get_frame_number(machine->primary_screen)%10)) ? 0 : (1<<6));
29162916
2917   if (!(ddenlovr_select2 & 0x01))   return readinputport(player * 5 + 1) | hopper_bit;
2918   if (!(ddenlovr_select2 & 0x02))   return readinputport(player * 5 + 2) | hopper_bit;
2919   if (!(ddenlovr_select2 & 0x04))   return readinputport(player * 5 + 3) | hopper_bit;
2920   if (!(ddenlovr_select2 & 0x08))   return readinputport(player * 5 + 4) | hopper_bit;
2921   if (!(ddenlovr_select2 & 0x10))   return readinputport(player * 5 + 5) | hopper_bit;
2917   if (!(ddenlovr_select2 & 0x01))   return input_port_read_indexed(machine, player * 5 + 1) | hopper_bit;
2918   if (!(ddenlovr_select2 & 0x02))   return input_port_read_indexed(machine, player * 5 + 2) | hopper_bit;
2919   if (!(ddenlovr_select2 & 0x04))   return input_port_read_indexed(machine, player * 5 + 3) | hopper_bit;
2920   if (!(ddenlovr_select2 & 0x08))   return input_port_read_indexed(machine, player * 5 + 4) | hopper_bit;
2921   if (!(ddenlovr_select2 & 0x10))   return input_port_read_indexed(machine, player * 5 + 5) | hopper_bit;
29222922
29232923   return 0x7f;   // bit 7 = blitter busy, bit 6 = hopper
29242924}
r2375r2376
29272927{
29282928   switch (hginga_select)
29292929   {
2930      case 0x20:   return readinputport(0);
2930      case 0x20:   return input_port_read_indexed(machine, 0);
29312931      case 0x21:   return hgokou_player_r(machine, 1);
29322932      case 0x22:   return hgokou_player_r(machine, 0);
29332933      case 0x23:   return hginga_coins;
r2375r2376
30373037{
30383038   switch (hginga_select)
30393039   {
3040      case 0x00:   return readinputport(0);            // P1 (Joy)
3041      case 0x01:   return readinputport(1);            // P2 (Joy)
3042      case 0x02:   return readinputport(2);            // Coins
3040      case 0x00:   return input_port_read_indexed(machine, 0);            // P1 (Joy)
3041      case 0x01:   return input_port_read_indexed(machine, 1);            // P2 (Joy)
3042      case 0x02:   return input_port_read_indexed(machine, 2);            // Coins
30433043      case 0x0d:   return 0x00;
3044      case 0x80:   return readinputport(3 + hginga_ip++);   // P1 (Keys)
3045      case 0x81:   return readinputport(8 + hginga_ip++);   // P2 (Keys)
3044      case 0x80:   return input_port_read_indexed(machine, 3 + hginga_ip++);   // P1 (Keys)
3045      case 0x81:   return input_port_read_indexed(machine, 8 + hginga_ip++);   // P2 (Keys)
30463046   }
30473047   logerror("%06x: warning, unknown bits read, hginga_select = %02x\n", activecpu_get_pc(), hginga_select);
30483048   return 0xff;
r2375r2376
30503050
30513051static READ8_HANDLER( hparadis_dsw_r )
30523052{
3053   if (!(ddenlovr_select & 0x01))   return readinputport(13);
3054   if (!(ddenlovr_select & 0x02))   return readinputport(14);
3053   if (!(ddenlovr_select & 0x01))   return input_port_read_indexed(machine, 13);
3054   if (!(ddenlovr_select & 0x02))   return input_port_read_indexed(machine, 14);
30553055   if (!(ddenlovr_select & 0x04))   return 0xff;
30563056   if (!(ddenlovr_select & 0x08))   return 0xff;
3057   if (!(ddenlovr_select & 0x10))   return readinputport(15);
3057   if (!(ddenlovr_select & 0x10))   return input_port_read_indexed(machine, 15);
30583058   return 0xff;
30593059}
30603060
r2375r2376
31183118{
31193119   switch( ddenlovr_select2 )
31203120   {
3121      case 0x80:   return readinputport(0);
3121      case 0x80:   return input_port_read_indexed(machine, 0);
31223122      case 0x81:   return 0x00;
31233123      case 0x82:   return 0xff;   // bit 7 = 0 -> blitter busy, + hopper switch
31243124      case 0x83:   return 0x00;
r2375r2376
31943194static READ16_HANDLER( akamaru_dsw_r )
31953195{
31963196   UINT16 dsw = 0;
3197   if (akamaru_dsw_sel[1] == 0xff)   dsw |= readinputport(3);
3198   if (akamaru_dsw_sel[0] == 0xff)   dsw |= readinputport(4);
3197   if (akamaru_dsw_sel[1] == 0xff)   dsw |= input_port_read_indexed(machine, 3);
3198   if (akamaru_dsw_sel[0] == 0xff)   dsw |= input_port_read_indexed(machine, 4);
31993199   return dsw;
32003200}
32013201
r2375r2376
32803280{
32813281   UINT8 val = 0xff;
32823282
3283   if      (!(keyb & 0x01))   val = readinputport(offset * 5 + 1);
3284   else if (!(keyb & 0x02))   val = readinputport(offset * 5 + 2);
3285   else if (!(keyb & 0x04))   val = readinputport(offset * 5 + 3);
3286   else if (!(keyb & 0x08))   val = readinputport(offset * 5 + 4);
3287   else if (!(keyb & 0x10))   val = readinputport(offset * 5 + 5);
3283   if      (!(keyb & 0x01))   val = input_port_read_indexed(machine, offset * 5 + 1);
3284   else if (!(keyb & 0x02))   val = input_port_read_indexed(machine, offset * 5 + 2);
3285   else if (!(keyb & 0x04))   val = input_port_read_indexed(machine, offset * 5 + 3);
3286   else if (!(keyb & 0x08))   val = input_port_read_indexed(machine, offset * 5 + 4);
3287   else if (!(keyb & 0x10))   val = input_port_read_indexed(machine, offset * 5 + 5);
32883288
32893289   return val;
32903290}
r2375r2376
32963296   // bit 7 = 1 -> blitter busy
32973297   // bit 6 = 0 -> VBLANK?
32983298   // bit 5 = 0 -> RTC?
3299   return readinputport(0) | mjflove_irq_cause;
3299   return input_port_read_indexed(machine, 0) | mjflove_irq_cause;
33003300}
33013301
33023302static WRITE8_HANDLER( mjflove_blitter_w )
src/mame/drivers/kaneko16.c
r2375r2376
7878#include "sound/2151intf.h"
7979#include "sound/okim6295.h"
8080
81extern void (*toybox_mcu_run)(void);   /* one of the following */
82void bloodwar_mcu_run(void);
83void bonkadv_mcu_run(void);
84void gtmr_mcu_run(void);
81extern void (*toybox_mcu_run)(running_machine *machine);   /* one of the following */
82void bloodwar_mcu_run(running_machine *machine);
83void bonkadv_mcu_run(running_machine *machine);
84void gtmr_mcu_run(running_machine *machine);
8585
8686/***************************************************************************
8787
r2375r2376
603603
604604static READ16_HANDLER( gtmr_wheel_r )
605605{
606   if ( (readinputport(4) & 0x1800) == 0x10)   // DSW setting
607      return   readinputport(5)<<8;         // 360' Wheel
606   if ( (input_port_read_indexed(machine, 4) & 0x1800) == 0x10)   // DSW setting
607      return   input_port_read_indexed(machine, 5)<<8;         // 360' Wheel
608608   else
609      return   readinputport(5);            // 270' Wheel
609      return   input_port_read_indexed(machine, 5);            // 270' Wheel
610610}
611611
612612static WRITE16_HANDLER( gtmr_oki_0_bank_w )
r2375r2376
708708
709709static READ16_HANDLER( gtmr2_wheel_r )
710710{
711   switch (readinputport(4) & 0x1800)
711   switch (input_port_read_indexed(machine, 4) & 0x1800)
712712   {
713713      case 0x0000:   // 270' A. Wheel
714         return   (readinputport(5));
714         return   (input_port_read_indexed(machine, 5));
715715         break;
716716      case 0x1000:   // 270' D. Wheel
717         return   (readinputport(6) << 8);
717         return   (input_port_read_indexed(machine, 6) << 8);
718718         break;
719719      case 0x0800:   // 360' Wheel
720         return   (readinputport(7) << 8);
720         return   (input_port_read_indexed(machine, 7) << 8);
721721         break;
722722      default:
723723         logerror("gtmr2_wheel_r : read at %06x with joystick\n", activecpu_get_pc());
r2375r2376
728728
729729static READ16_HANDLER( gtmr2_IN1_r )
730730{
731   return   (readinputport(1) & (readinputport(8) | ~0x7100));
731   return   (input_port_read_indexed(machine, 1) & (input_port_read_indexed(machine, 8) | ~0x7100));
732732}
733733
734734static ADDRESS_MAP_START( gtmr2_readmem, ADDRESS_SPACE_PROGRAM, 16 )
src/mame/drivers/dbz.c
r2375r2376
115115
116116static READ16_HANDLER( dbz_inp0_r )
117117{
118   return readinputportbytag("IN0") | (readinputportbytag("IN1")<<8);
118   return input_port_read(machine, "IN0") | (input_port_read(machine, "IN1")<<8);
119119}
120120
121121static READ16_HANDLER( dbz_inp1_r )
122122{
123   return readinputportbytag("IN3") | (readinputportbytag("DSW1")<<8);
123   return input_port_read(machine, "IN3") | (input_port_read(machine, "DSW1")<<8);
124124}
125125
126126static READ16_HANDLER( dbz_inp2_r )
127127{
128   return readinputportbytag("DSW2") | (readinputportbytag("DSW2")<<8);
128   return input_port_read(machine, "DSW2") | (input_port_read(machine, "DSW2")<<8);
129129}
130130
131131static WRITE16_HANDLER( dbz_sound_command_w )
src/mame/drivers/cybertnk.c
r2375r2376
236236   switch( offset )
237237   {
238238      case 2/2:
239         return ( (readinputportbytag("DSW1") << 8) | readinputportbytag("DSW2") );
239         return ( (input_port_read(machine, "DSW1") << 8) | input_port_read(machine, "DSW2") );
240240
241241      // 0x00110007 is controller device select
242242      // 0x001100D5 is controller data
r2375r2376
245245         switch( (io_ram[7/2]) & 0xff )
246246         {
247247            case 0:
248               io_ram[0xd5/2] = readinputportbytag("TRAVERSE");
248               io_ram[0xd5/2] = input_port_read(machine, "TRAVERSE");
249249               break;
250250
251251            case 0x20:
252               io_ram[0xd5/2] = readinputportbytag("ELEVATE");
252               io_ram[0xd5/2] = input_port_read(machine, "ELEVATE");
253253               break;
254254
255255            case 0x40:
256               io_ram[0xd5/2] = readinputportbytag("ACCEL");
256               io_ram[0xd5/2] = input_port_read(machine, "ACCEL");
257257               break;
258258
259259            case 0x42:
r2375r2376
265265               break;
266266
267267            case 0x60:
268               io_ram[0xd5/2] = readinputportbytag("HANDLE");
268               io_ram[0xd5/2] = input_port_read(machine, "HANDLE");
269269               break;
270270
271271            default:
r2375r2376
274274         return 0;
275275
276276      case 6/2:
277         return readinputportbytag("IN0"); // high half
277         return input_port_read(machine, "IN0"); // high half
278278
279279      case 9/2:
280         return readinputportbytag("IN0"); // low half
280         return input_port_read(machine, "IN0"); // low half
281281
282282      case 0xb/2:
283         return readinputportbytag("DSW3");
283         return input_port_read(machine, "DSW3");
284284
285285      case 0xd5/2:
286286         return io_ram[offset]; // controller data
src/mame/drivers/namcos10.c
r2375r2376
304304   }
305305}
306306
307static void memm_driver_init( void )
307static void memm_driver_init( running_machine *machine )
308308{
309   psx_driver_init();
309   psx_driver_init(machine);
310310}
311311
312static void memn_driver_init( void )
312static void memn_driver_init( running_machine *machine )
313313{
314314   UINT8 *BIOS = (UINT8 *)memory_region( REGION_USER1 );
315315   UINT8 *ROM = (UINT8 *)memory_region( REGION_USER2 );
r2375r2376
317317   memcpy32le( (UINT32 *)( BIOS + 0x0000000 ), ROM + 0x08000, 0x001c000 );
318318   memcpy32le( (UINT32 *)( BIOS + 0x0020000 ), ROM + 0x24000, 0x03dffff );
319319
320   psx_driver_init();
320   psx_driver_init(machine);
321321}
322322
323323static void decrypt_bios( int b15, int b14, int b13, int b12, int b11, int b10, int b9, int b8,
r2375r2376
336336
337337static DRIVER_INIT( mrdrilr2 )
338338{
339   memm_driver_init();
339   memm_driver_init(machine);
340340   decrypt_bios( 0xc, 0xd, 0xf, 0xe, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x4, 0x1, 0x2, 0x5, 0x0, 0x3 );
341341}
342342
343343static DRIVER_INIT( gjspace )
344344{
345   memn_driver_init();
345   memn_driver_init(machine);
346346   decrypt_bios( 0x0, 0x2, 0xe, 0xd, 0xf, 0x6, 0xc, 0x7, 0x5, 0x1, 0x9, 0x8, 0xa, 0x3, 0x4, 0xb );
347347}
348348
349349static DRIVER_INIT( mrdrilrg )
350350{
351   memn_driver_init();
351   memn_driver_init(machine);
352352   decrypt_bios( 0x6, 0x4, 0x7, 0x5, 0x2, 0x1, 0x0, 0x3, 0xc, 0xd, 0xe, 0xf, 0x8, 0x9, 0xb, 0xa );
353353}
354354
355355static DRIVER_INIT( knpuzzle )
356356{
357   memn_driver_init();
357   memn_driver_init(machine);
358358   decrypt_bios( 0x6, 0x7, 0x4, 0x5, 0x2, 0x0, 0x3, 0x1, 0xc, 0xd, 0xe, 0xf, 0x9, 0xb, 0x8, 0xa );
359359}
360360
361361static DRIVER_INIT( startrgn )
362362{
363   memn_driver_init();
363   memn_driver_init(machine);
364364   decrypt_bios( 0x6, 0x5, 0x4, 0x7, 0x1, 0x3, 0x0, 0x2, 0xc, 0xd, 0xe, 0xf, 0x8, 0xb, 0xa, 0x9 );
365365}
366366
367367static DRIVER_INIT( gamshara )
368368{
369   memn_driver_init();
369   memn_driver_init(machine);
370370   decrypt_bios( 0x5, 0x4, 0x7, 0x6, 0x0, 0x1, 0x3, 0x2, 0xd, 0xf, 0xc, 0xe, 0x8, 0x9, 0xa, 0xb );
371371}
372372
src/mame/drivers/gauntlet.c
r2375r2376
193193
194194static READ16_HANDLER( port4_r )
195195{
196   int temp = readinputport(4);
196   int temp = input_port_read_indexed(machine, 4);
197197   if (atarigen_cpu_to_sound_ready) temp ^= 0x0020;
198198   if (atarigen_sound_to_cpu_ready) temp ^= 0x0010;
199199   return temp;
r2375r2376
237237   if (atarigen_cpu_to_sound_ready) temp ^= 0x80;
238238   if (atarigen_sound_to_cpu_ready) temp ^= 0x40;
239239   if (tms5220_ready_r()) temp ^= 0x20;
240   if (!(readinputport(4) & 0x0008)) temp ^= 0x10;
240   if (!(input_port_read_indexed(machine, 4) & 0x0008)) temp ^= 0x10;
241241
242242   return temp;
243243}
src/mame/drivers/ms32.c
r2375r2376
213213static READ32_HANDLER ( ms32_read_inputs1 )
214214{
215215   int a,b,c,d;
216   a = readinputport(0);   // unknown
217   b = readinputport(1);   // System inputs
218   c = readinputport(2);   // Player 1 inputs
219   d = readinputport(3);   // Player 2 inputs
216   a = input_port_read_indexed(machine, 0);   // unknown
217   b = input_port_read_indexed(machine, 1);   // System inputs
218   c = input_port_read_indexed(machine, 2);   // Player 1 inputs
219   d = input_port_read_indexed(machine, 3);   // Player 2 inputs
220220   return a << 24 | b << 16 | c << 0 | d << 8;
221221}
222222
r2375r2376
224224static READ32_HANDLER ( ms32_mahjong_read_inputs1 )
225225{
226226   int a,b,c,d;
227   a = readinputport(0);   // unknown
228   b = readinputport(1);   // System inputs
227   a = input_port_read_indexed(machine, 0);   // unknown
228   b = input_port_read_indexed(machine, 1);   // System inputs
229229
230230   switch (ms32_mahjong_input_select[0])
231231   {
232232      case 0x01:
233         c = readinputport(8);   // Player 1 inputs
233         c = input_port_read_indexed(machine, 8);   // Player 1 inputs
234234         break;
235235      case 0x02:
236         c = readinputport(9);   // Player 1 inputs
236         c = input_port_read_indexed(machine, 9);   // Player 1 inputs
237237         break;
238238      case 0x04:
239         c = readinputport(10);   // Player 1 inputs
239         c = input_port_read_indexed(machine, 10);   // Player 1 inputs
240240         break;
241241      case 0x08:
242         c = readinputport(11);   // Player 1 inputs
242         c = input_port_read_indexed(machine, 11);   // Player 1 inputs
243243         break;
244244      case 0x10:
245         c = readinputport(12);   // Player 1 inputs
245         c = input_port_read_indexed(machine, 12);   // Player 1 inputs
246246         break;
247247      default:
248248         c = 0;
249249
250250   }
251   d = readinputport(3);   // Player 2 inputs
251   d = input_port_read_indexed(machine, 3);   // Player 2 inputs
252252   return a << 24 | b << 16 | c << 0 | d << 8;
253253}
254254
r2375r2376
256256static READ32_HANDLER ( ms32_read_inputs2 )
257257{
258258   int a,b,c,d;
259   a = readinputport(4);   // Dip 1
260   b = readinputport(5);   // Dip 2
261   c = readinputport(6);   // Dip 3
262   d = readinputport(7);   // unused ?
259   a = input_port_read_indexed(machine, 4);   // Dip 1
260   b = input_port_read_indexed(machine, 5);   // Dip 2
261   c = input_port_read_indexed(machine, 6);   // Dip 3
262   d = input_port_read_indexed(machine, 7);   // unused ?
263263   return a << 8 | b << 0 | c << 16 | d << 24;
264264}
265265
266266static READ32_HANDLER ( ms32_read_inputs3 )
267267{
268268   int a,b,c,d;
269   a = readinputport(10); // unused?
270   b = readinputport(10); // unused?
271   c = readinputport(9);
272   d = (readinputport(8) - 0xb0) & 0xff;
269   a = input_port_read_indexed(machine, 10); // unused?
270   b = input_port_read_indexed(machine, 10); // unused?
271   c = input_port_read_indexed(machine, 9);
272   d = (input_port_read_indexed(machine, 8) - 0xb0) & 0xff;
273273   return a << 24 | b << 16 | c << 8 | d << 0;
274274}
275275
src/mame/drivers/mpu4.c
r2375r2376
705705static READ8_HANDLER( pia_ic5_porta_r )
706706{
707707   LOG(("%04x IC5 PIA Read of Port A (AUX1)\n",activecpu_get_previouspc()));
708   return readinputportbytag("AUX1");
708   return input_port_read(machine, "AUX1");
709709}
710710
711711
r2375r2376
716716   coin_lockout_w(1, (pia_get_output_b(2) & 0x02) );
717717   coin_lockout_w(2, (pia_get_output_b(2) & 0x04) );
718718   coin_lockout_w(3, (pia_get_output_b(2) & 0x08) );
719   return readinputportbytag("AUX2");
719   return input_port_read(machine, "AUX2");
720720}
721721
722722
r2375r2376
956956/* The orange inputs are polled twice as often as the black ones, for reasons of efficiency.
957957   This is achieved via connecting every input line to an AND gate, thus allowing two strobes
958958   to represent each orange input bank (strobes are active low). */
959   pia_set_input_cb1(2, (readinputportbytag("AUX2") & 0x80));
960   return readinputport(input_read);
959   pia_set_input_cb1(2, (input_port_read(machine, "AUX2") & 0x80));
960   return input_port_read_indexed(machine, input_read);
961961}
962962
963963
src/mame/drivers/darkseal.c
r2375r2376
5454   switch (offset<<1)
5555   {
5656      case 0: /* Dip Switches */
57         return (readinputport(3) + (readinputport(4) << 8));
57         return (input_port_read_indexed(machine, 3) + (input_port_read_indexed(machine, 4) << 8));
5858
5959      case 2: /* Player 1 & Player 2 joysticks & fire buttons */
60         return (readinputport(0) + (readinputport(1) << 8));
60         return (input_port_read_indexed(machine, 0) + (input_port_read_indexed(machine, 1) << 8));
6161
6262      case 4: /* Credits */
63         return readinputport(2);
63         return input_port_read_indexed(machine, 2);
6464   }
6565
6666   return ~0;
src/mame/drivers/seicross.c
r2375r2376
9292
9393static READ8_HANDLER( friskyt_portB_r )
9494{
95   return (portb & 0x9f) | (readinputport(6) & 0x60);
95   return (portb & 0x9f) | (input_port_read_indexed(machine, 6) & 0x60);
9696}
9797
9898static WRITE8_HANDLER( friskyt_portB_w )
src/mame/drivers/system16.c
r2375r2376
12011201/***************************************************************************/
12021202
12031203static READ16_HANDLER( ga_io_players_r ) {
1204   return (readinputport(0) << 8) | readinputport(1);
1204   return (input_port_read_indexed(machine, 0) << 8) | input_port_read_indexed(machine, 1);
12051205}
12061206static READ16_HANDLER( ga_io_service_r )
12071207{
r2375r2376
14011401static READ16_HANDLER( passht4b_service_r )
14021402{
14031403   UINT16 val=input_port_2_word_r(machine,offset,0);
1404   if(!(readinputport(0) & 0x40)) val&=0xef;
1405   if(!(readinputport(1) & 0x40)) val&=0xdf;
1406   if(!(readinputport(5) & 0x40)) val&=0xbf;
1407   if(!(readinputport(6) & 0x40)) val&=0x7f;
1404   if(!(input_port_read_indexed(machine, 0) & 0x40)) val&=0xef;
1405   if(!(input_port_read_indexed(machine, 1) & 0x40)) val&=0xdf;
1406   if(!(input_port_read_indexed(machine, 5) & 0x40)) val&=0xbf;
1407   if(!(input_port_read_indexed(machine, 6) & 0x40)) val&=0x7f;
14081408
1409   passht4b_io3_val=(readinputport(0)<<4) | (readinputport(5)&0xf);
1410   passht4b_io2_val=(readinputport(1)<<4) | (readinputport(6)&0xf);
1409   passht4b_io3_val=(input_port_read_indexed(machine, 0)<<4) | (input_port_read_indexed(machine, 5)&0xf);
1410   passht4b_io2_val=(input_port_read_indexed(machine, 1)<<4) | (input_port_read_indexed(machine, 6)&0xf);
14111411
14121412   passht4b_io1_val=0xff;
14131413
14141414   // player 1 buttons
1415   if(!(readinputport(0) & 0x10)) passht4b_io1_val &=0xfe;
1416   if(!(readinputport(0) & 0x20)) passht4b_io1_val &=0xfd;
1417   if(!(readinputport(0) & 0x80)) passht4b_io1_val &=0xfc;
1415   if(!(input_port_read_indexed(machine, 0) & 0x10)) passht4b_io1_val &=0xfe;
1416   if(!(input_port_read_indexed(machine, 0) & 0x20)) passht4b_io1_val &=0xfd;
1417   if(!(input_port_read_indexed(machine, 0) & 0x80)) passht4b_io1_val &=0xfc;
14181418
14191419   // player 2 buttons
1420   if(!(readinputport(1) & 0x10)) passht4b_io1_val &=0xfb;
1421   if(!(readinputport(1) & 0x20)) passht4b_io1_val &=0xf7;
1422   if(!(readinputport(1) & 0x80)) passht4b_io1_val &=0xf3;
1420   if(!(input_port_read_indexed(machine, 1) & 0x10)) passht4b_io1_val &=0xfb;
1421   if(!(input_port_read_indexed(machine, 1) & 0x20)) passht4b_io1_val &=0xf7;
1422   if(!(input_port_read_indexed(machine, 1) & 0x80)) passht4b_io1_val &=0xf3;
14231423
14241424   // player 3 buttons
1425   if(!(readinputport(5) & 0x10)) passht4b_io1_val &=0xef;
1426   if(!(readinputport(5) & 0x20)) passht4b_io1_val &=0xdf;
1427   if(!(readinputport(5) & 0x80)) passht4b_io1_val &=0xcf;
1425   if(!(input_port_read_indexed(machine, 5) & 0x10)) passht4b_io1_val &=0xef;
1426   if(!(input_port_read_indexed(machine, 5) & 0x20)) passht4b_io1_val &=0xdf;
1427   if(!(input_port_read_indexed(machine, 5) & 0x80)) passht4b_io1_val &=0xcf;
14281428
14291429   // player 4 buttons
1430   if(!(readinputport(6) & 0x10)) passht4b_io1_val &=0xbf;
1431   if(!(readinputport(6) & 0x20)) passht4b_io1_val &=0x7f;
1432   if(!(readinputport(6) & 0x80)) passht4b_io1_val &=0x3f;
1430   if(!(input_port_read_indexed(machine, 6) & 0x10)) passht4b_io1_val &=0xbf;
1431   if(!(input_port_read_indexed(machine, 6) & 0x20)) passht4b_io1_val &=0x7f;
1432   if(!(input_port_read_indexed(machine, 6) & 0x80)) passht4b_io1_val &=0x3f;
14331433
14341434   return val;
14351435}
src/mame/drivers/limenko.c
r2375r2376
3939
4040static READ32_HANDLER( port2_r )
4141{
42   return (EEPROM_read_bit() << 23) | (readinputport(2) & ~(1<<23));
42   return (EEPROM_read_bit() << 23) | (input_port_read_indexed(machine, 2) & ~(1<<23));
4343}
4444
4545static WRITE32_HANDLER( eeprom_w )
src/mame/drivers/redalert.c
r2375r2376
8686
8787static INTERRUPT_GEN( redalert_vblank_interrupt )
8888{
89   if( readinputport(3) )
89   if( input_port_read_indexed(machine, 3) )
9090      /* the service coin as conntected to the CPU's RDY pin as well */
9191      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
9292
src/mame/drivers/mcr3.c
r2375r2376
120120
121121static READ8_HANDLER( demoderm_ip1_r )
122122{
123   return readinputportbytag(input_mux ? "MONO.IP1.ALT" : "MONO.IP1");
123   return input_port_read(machine, input_mux ? "MONO.IP1.ALT" : "MONO.IP1");
124124}
125125
126126
127127static READ8_HANDLER( demoderm_ip2_r )
128128{
129   return readinputportbytag(input_mux ? "MONO.IP2.ALT" : "MONO.IP2");
129   return input_port_read(machine, input_mux ? "MONO.IP2.ALT" : "MONO.IP2");
130130}
131131
132132
r2375r2376
157157static READ8_HANDLER( maxrpm_ip2_r )
158158{
159159   static const UINT8 shift_bits[5] = { 0x00, 0x05, 0x06, 0x01, 0x02 };
160   UINT8 start = readinputportbytag("MONO.IP0");
161   UINT8 shift = readinputportbytag("SHIFT");
160   UINT8 start = input_port_read(machine, "MONO.IP0");
161   UINT8 shift = input_port_read(machine, "SHIFT");
162162
163163   /* reset on a start */
164164   if (!(start & 0x08))
r2375r2376
231231
232232   /* when the read is toggled is when the ADC value is latched */
233233   if (!(data & 0x80))
234      latched_input = readinputportbytag(inputs[maxrpm_adc_select]);
234      latched_input = input_port_read(machine, inputs[maxrpm_adc_select]);
235235
236236   /* when both the write and the enable are low, it's a write to the ADC0844 */
237237   /* unfortunately the behavior below doesn't match up with the inputs on the */
r2375r2376
253253
254254static READ8_HANDLER( rampage_ip4_r )
255255{
256   return readinputportbytag("MONO.IP4") | (soundsgood_status_r(machine,0) << 7);
256   return input_port_read(machine, "MONO.IP4") | (soundsgood_status_r(machine,0) << 7);
257257}
258258
259259
r2375r2376
276276
277277static READ8_HANDLER( powerdrv_ip2_r )
278278{
279   return readinputportbytag("MONO.IP2") | (soundsgood_status_r(machine, 0) << 7);
279   return input_port_read(machine, "MONO.IP2") | (soundsgood_status_r(machine, 0) << 7);
280280}
281281
282282
r2375r2376
320320
321321static READ8_HANDLER( stargrds_ip0_r )
322322{
323   UINT8 result = readinputportbytag(input_mux ? "MONO.IP0.ALT" : "MONO.IP0");
323   UINT8 result = input_port_read(machine, input_mux ? "MONO.IP0.ALT" : "MONO.IP0");
324324   return result | ((soundsgood_status_r(machine, 0) << 4) & 0x10);
325325}
326326
r2375r2376
361361
362362static READ8_HANDLER( spyhunt_ip1_r )
363363{
364   return readinputportbytag("SSIO.IP1") | (csdeluxe_status_r(machine, 0) << 5);
364   return input_port_read(machine, "SSIO.IP1") | (csdeluxe_status_r(machine, 0) << 5);
365365}
366366
367367
368368static READ8_HANDLER( spyhunt_ip2_r )
369369{
370370   /* multiplexed steering wheel/gas pedal */
371   return readinputportbytag(input_mux ? "SSIO.IP2.ALT" : "SSIO.IP2");
371   return input_port_read(machine, input_mux ? "SSIO.IP2.ALT" : "SSIO.IP2");
372372}
373373
374374
r2375r2376
420420{
421421   /* multiplexed steering wheel/gas pedal */
422422   if (input_mux)
423      return readinputportbytag("SSIO.IP2.ALT");
423      return input_port_read(machine, "SSIO.IP2.ALT");
424424
425   return readinputportbytag("SSIO.IP2") + 5 * (video_screen_get_frame_number(machine->primary_screen) & 1);
425   return input_port_read(machine, "SSIO.IP2") + 5 * (video_screen_get_frame_number(machine->primary_screen) & 1);
426426}
427427
428428
src/mame/drivers/stadhero.c
r2375r2376
3232   switch (offset<<1)
3333   {
3434      case 0: /* Player 1 & 2 joystick & buttons */
35         return (readinputport(0) + (readinputport(1) << 8));
35         return (input_port_read(machine, "P1") | (input_port_read(machine, "P2") << 8));
3636
3737      case 2: /* Credits, start buttons */
38         return readinputport(2) | (readinputport(2)<<8);
38         return (input_port_read(machine, "COIN") | (input_port_read(machine, "COIN") << 8));
3939
40      case 4: /* Byte 4: Dipswitch bank 2, Byte 5: Dipswitch Bank 1 */
41         return (readinputport(3) + (readinputport(4) << 8));
40      case 4: /* Dip switches */
41         return (input_port_read(machine, "DSW1") | (input_port_read(machine, "DSW2") << 8));
4242   }
4343
4444   logerror("CPU #0 PC %06x: warning - read unmapped memory address %06x\n",activecpu_get_pc(),0x30c000+offset);
r2375r2376
114114/******************************************************************************/
115115
116116static INPUT_PORTS_START( stadhero )
117   PORT_START   /* Player 1 controls */
118   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
119   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
120   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
121   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
122   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
123   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
124   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 )
117   PORT_START_TAG("P1")   /* 0x30c001 : Player 1 controls */
118   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    ) PORT_8WAY PORT_PLAYER(1)
119   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  ) PORT_8WAY PORT_PLAYER(1)
120   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  ) PORT_8WAY PORT_PLAYER(1)
121   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
122   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
123   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
124   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
125125   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
126126
127   PORT_START   /* Player 2 controls */
128   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
129   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
130   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
127   PORT_START_TAG("P2")   /* 0x30c000 : Player 2 controls */
128   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    ) PORT_8WAY PORT_PLAYER(2)
129   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  ) PORT_8WAY PORT_PLAYER(2)
130   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  ) PORT_8WAY PORT_PLAYER(2)
131131   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
132132   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
133133   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
134134   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
135135   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
136136
137   PORT_START   /* Credits, start buttons */
138   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
139   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
140   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 )
141   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 )
137   PORT_START_TAG("COIN")   /* 0x30c002 & 0x30c003 : Credits, start buttons */
138   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )            /* related to music/sound */
139   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )            /* related to music/sound */
140   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )            /* related to music/sound */
141   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )            /* related to music/sound */
142142   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1 )
143143   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 )
144   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN3 ) /* Service */
144   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 )
145145   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )
146146
147   PORT_START   /* Dip switch bank 1 */
147   PORT_START_TAG("DSW1")   /* 0x30c005 : Dip switch bank 1 */
148148   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) )
149149   PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
150150   PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
r2375r2376
155155   PORT_DIPSETTING(    0x04, DEF_STR( 2C_1C ) )
156156   PORT_DIPSETTING(    0x0c, DEF_STR( 1C_1C ) )
157157   PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) )
158   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
159   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
160   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
158   PORT_DIPUNUSED( 0x10, IP_ACTIVE_LOW )
161159   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
162160   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
163161   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
164162   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Flip_Screen ) )
165163   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
166164   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
167   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
168   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
169   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
165   PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )
170166
171   PORT_START   /* Dip switch bank 2 */
172   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
173   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
174   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
175   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
176   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
177   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
178   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
179   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
180   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
181   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
182   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
183   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
184   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
185   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
186   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
187   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
188   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
189   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
190   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
191   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
192   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
193   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
194   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
195   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
167   PORT_START_TAG("DSW2")   /* 0x30c004 : Dip switch bank 2 */
168   PORT_DIPNAME( 0x03, 0x03, "Time (1P Vs CPU)" )          /* Table at 0x0014f6 */
169   PORT_DIPSETTING(    0x02, "600" )
170   PORT_DIPSETTING(    0x03, "500" )
171   PORT_DIPSETTING(    0x01, "450" )
172   PORT_DIPSETTING(    0x00, "400" )
173   PORT_DIPNAME( 0x0c, 0x0c, "Time (1P Vs 2P)" )           /* Table at 0x0014fe */
174   PORT_DIPSETTING(    0x08, "270" )
175   PORT_DIPSETTING(    0x0c, "210" )
176   PORT_DIPSETTING(    0x04, "180" )
177   PORT_DIPSETTING(    0x00, "120" )
178   PORT_DIPNAME( 0x30, 0x30, "Final Set" )                 /* Table at 0x00078c */
179   PORT_DIPSETTING(    0x20, "3 Credits" )
180   PORT_DIPSETTING(    0x30, "4 Credits" )
181   PORT_DIPSETTING(    0x10, "5 Credits" )
182   PORT_DIPSETTING(    0x00, "6 Credits" )
183   PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )
184   PORT_DIPUNUSED( 0x80, IP_ACTIVE_LOW )
196185INPUT_PORTS_END
197186
198187/******************************************************************************/
src/mame/drivers/marvins.c
r2375r2376
2020   (great now I can fall under the skyway like I did at Chuck'n Cheese;)
2121 - fixed Vanguard2 scroll offsets
2222 - tuned music tempo and wavegen frequency
23
242008.04.04: Small note regarding DipSwitches. Locations and values have been
25verified with the manual for both Marvin's Maze and Mad Crasher. Vanguard II
26DIPs have been checked against jammaboards diplist, no manual available ATM.
27DSW2:7 in madcrash is listed as Difficulty, but it's not clear how it affects
28the gameplay difficulty
29
2330*/
2431
2532#include "driver.h"
r2375r2376
127134/* this input port has one of its bits mapped to sound CPU status */
128135static READ8_HANDLER( marvins_port_0_r )
129136{
130   return(input_port_0_r(machine,0) | sound_cpu_busy);
137   return(input_port_read_indexed(machine, 0) | sound_cpu_busy);
131138}
132139
133140static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
r2375r2376
163170   AM_RANGE(0x0000, 0x5fff) AM_ROM
164171   AM_RANGE(0x6000, 0x6000) AM_WRITE(marvins_palette_bank_w)
165172   AM_RANGE(0x8000, 0x8000) AM_READ(marvins_port_0_r)   /* coin input, start, sound CPU status */
166   AM_RANGE(0x8100, 0x8100) AM_READ(input_port_1_r)      /* player #1 controls */
167   AM_RANGE(0x8200, 0x8200) AM_READ(input_port_2_r)      /* player #2 controls */
173   AM_RANGE(0x8100, 0x8100) AM_READ_PORT("IN1")         /* player #1 controls */
174   AM_RANGE(0x8200, 0x8200) AM_READ_PORT("IN2")         /* player #2 controls */
168175   AM_RANGE(0x8300, 0x8300) AM_WRITE(sound_command_w)
169   AM_RANGE(0x8400, 0x8400) AM_READ(input_port_3_r)      /* dipswitch#1 */
170   AM_RANGE(0x8500, 0x8500) AM_READ(input_port_4_r)      /* dipswitch#2 */
171   AM_RANGE(0x8600, 0x8600) AM_RAM   // video attribute
176   AM_RANGE(0x8400, 0x8400) AM_READ_PORT("DSW1")      /* dipswitch#1 */
177   AM_RANGE(0x8500, 0x8500) AM_READ_PORT("DSW2")      /* dipswitch#2 */
178   AM_RANGE(0x8600, 0x8600) AM_RAM                  /* video attribute */
172179   AM_RANGE(0x8700, 0x8700) AM_READWRITE(snk_cpuB_nmi_trigger_r, snk_cpuA_nmi_ack_w)
173180   AM_RANGE(0xc000, 0xcfff) AM_RAM AM_BASE(&spriteram) AM_SHARE(1)
174181   AM_RANGE(0xd000, 0xdfff) AM_READWRITE(SMH_RAM, marvins_background_ram_w) AM_SHARE(2) AM_BASE(&spriteram_3)
r2375r2376
189196static ADDRESS_MAP_START( madcrash_cpuA_map, ADDRESS_SPACE_PROGRAM, 8 )
190197   AM_RANGE(0x0000, 0x7fff) AM_ROM
191198   AM_RANGE(0x8000, 0x8000) AM_READ(marvins_port_0_r)   /* coin input, start, sound CPU status */
192   AM_RANGE(0x8100, 0x8100) AM_READ(input_port_1_r)      /* player #1 controls */
193   AM_RANGE(0x8200, 0x8200) AM_READ(input_port_2_r)      /* player #2 controls */
199   AM_RANGE(0x8100, 0x8100) AM_READ_PORT("IN1")         /* player #1 controls */
200   AM_RANGE(0x8200, 0x8200) AM_READ_PORT("IN2")         /* player #2 controls */
194201   AM_RANGE(0x8300, 0x8300) AM_WRITE(sound_command_w)
195   AM_RANGE(0x8400, 0x8400) AM_READ(input_port_3_r)      /* dipswitch#1 */
196   AM_RANGE(0x8500, 0x8500) AM_READ(input_port_4_r)      /* dipswitch#2 */
202   AM_RANGE(0x8400, 0x8400) AM_READ_PORT("DSW1")      /* dipswitch#1 */
203   AM_RANGE(0x8500, 0x8500) AM_READ_PORT("DSW2")      /* dipswitch#2 */
197204   AM_RANGE(0x8600, 0x86ff) AM_RAM   // video attribute
198205   AM_RANGE(0x8700, 0x8700) AM_READWRITE(snk_cpuB_nmi_trigger_r, snk_cpuA_nmi_ack_w)
199206//  AM_RANGE(0xc800, 0xc800) AM_WRITE(marvins_palette_bank_w)   // palette bank switch (c8f1 for Vanguard)
r2375r2376
245252   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
246253
247254   PORT_START_TAG("DSW1")
248   PORT_DIPNAME( 0x03, 0x02, DEF_STR( Lives ) )
255   PORT_DIPNAME( 0x03, 0x02, DEF_STR( Lives ) )      PORT_DIPLOCATION("SW1:1,2")
249256   PORT_DIPSETTING(    0x00, "1" )
250257   PORT_DIPSETTING(    0x01, "2" )
251258   PORT_DIPSETTING(    0x02, "3" )
252259   PORT_DIPSETTING(    0x03, "5" )
253   PORT_DIPNAME(0x04,  0x04, "Infinite Lives (Cheat)")
260   PORT_DIPNAME(0x04,  0x04, "Infinite Lives (Cheat)")   PORT_DIPLOCATION("SW1:3")
254261   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
255262   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
256   PORT_DIPNAME( 0x38, 0x00, DEF_STR( Coinage ) )
263   PORT_DIPNAME( 0x38, 0x00, DEF_STR( Coinage ) )      PORT_DIPLOCATION("SW1:4,5,6")
257264   PORT_DIPSETTING(    0x38, DEF_STR( 5C_1C ) )
258265   PORT_DIPSETTING(    0x30, DEF_STR( 3C_1C ) )
259266   PORT_DIPSETTING(    0x28, DEF_STR( 2C_1C ) )
r2375r2376
262269   PORT_DIPSETTING(    0x10, DEF_STR( 1C_3C ) )
263270   PORT_DIPSETTING(    0x18, DEF_STR( 1C_5C ) )
264271   PORT_DIPSETTING(    0x20, DEF_STR( 1C_6C ) )
265   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Free_Play ) )
272   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Free_Play ) )   PORT_DIPLOCATION("SW1:7")
266273   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
267274   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
268   PORT_DIPNAME( 0x80, 0x80, "Freeze" )
275   PORT_DIPNAME( 0x80, 0x80, "Freeze" )            PORT_DIPLOCATION("SW1:8")
269276   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
270277   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
271278
272279   PORT_START_TAG("DSW2")
273   PORT_DIPNAME( 0x07, 0x00, "1st Bonus Life" )
280   PORT_DIPNAME( 0x07, 0x00, "1st Bonus Life" )      PORT_DIPLOCATION("SW2:1,2,3")
274281   PORT_DIPSETTING(    0x00, "10000" )
275282   PORT_DIPSETTING(    0x01, "20000" )
276283   PORT_DIPSETTING(    0x02, "30000" )
r2375r2376
279286   PORT_DIPSETTING(    0x05, "60000" )
280287   PORT_DIPSETTING(    0x06, "70000" )
281288   PORT_DIPSETTING(    0x07, "80000" )
282   PORT_DIPNAME( 0x18, 0x08, "2nd Bonus Life" )
289   PORT_DIPNAME( 0x18, 0x08, "2nd Bonus Life" )      PORT_DIPLOCATION("SW2:4,5")
283290   PORT_DIPSETTING(    0x08, "1st bonus*2" )
284291   PORT_DIPSETTING(    0x10, "1st bonus*3" )
285292   PORT_DIPSETTING(    0x18, "1st bonus*4" )
286293   PORT_DIPSETTING(    0x00, DEF_STR( None ) )
287   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
294   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )   PORT_DIPLOCATION("SW2:6")
288295   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
289296   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
290   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Cabinet ) )
297   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Cabinet ) )      PORT_DIPLOCATION("SW2:7")
291298   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
292299   PORT_DIPSETTING(    0x40, DEF_STR( Cocktail ) )
293   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) )
300   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) )   PORT_DIPLOCATION("SW2:8")
294301   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
295302   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
296303INPUT_PORTS_END
r2375r2376
326333   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
327334
328335   PORT_START_TAG("DSW1")
329   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) )
336   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) )         PORT_DIPLOCATION("SW1:1,2,3")
330337   PORT_DIPSETTING(    0x00, DEF_STR( 6C_1C ) )
331338   PORT_DIPSETTING(    0x01, DEF_STR( 5C_1C ) )
332339   PORT_DIPSETTING(    0x02, DEF_STR( 3C_1C ) )
r2375r2376
335342   PORT_DIPSETTING(    0x06, DEF_STR( 1C_2C ) )
336343   PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )
337344   PORT_DIPSETTING(    0x04, DEF_STR( 1C_5C ) )
338   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Bonus_Life ) )
345   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Bonus_Life ) )      PORT_DIPLOCATION("SW1:4,5,6")
339346   PORT_DIPSETTING(    0x38, "30000" )
340347   PORT_DIPSETTING(    0x30, "40000" )
341348   PORT_DIPSETTING(    0x28, "50000" )
r2375r2376
344351   PORT_DIPSETTING(    0x10, "80000" )
345352   PORT_DIPSETTING(    0x08, "90000" )
346353   PORT_DIPSETTING(    0x00, "100000" )
347   PORT_DIPNAME( 0xc0, 0x80, DEF_STR( Lives ) )
354   PORT_DIPNAME( 0xc0, 0x80, DEF_STR( Lives ) )         PORT_DIPLOCATION("SW1:7,8")
348355   PORT_DIPSETTING(    0x00, "1" )
349356   PORT_DIPSETTING(    0x40, "2" )
350357   PORT_DIPSETTING(    0x80, "3" )
351358   PORT_DIPSETTING(    0xc0, "5" )
352359
353360   PORT_START_TAG("DSW2")
354   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Demo_Sounds ) )
361   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Demo_Sounds ) )      PORT_DIPLOCATION("SW2:1")
355362   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
356363   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
357   PORT_DIPNAME( 0x02, 0x02, "Freeze" )
364   PORT_DIPNAME( 0x02, 0x02, "Freeze" )               PORT_DIPLOCATION("SW2:2")
358365   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
359366   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
360   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Cabinet ) )
367   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Cabinet ) )         PORT_DIPLOCATION("SW2:3")
361368   PORT_DIPSETTING(    0x04, DEF_STR( Upright ) )
362369   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
363   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Language ) )
370   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Language ) )         PORT_DIPLOCATION("SW2:4")
364371   PORT_DIPSETTING(    0x08, DEF_STR( English ) )
365372   PORT_DIPSETTING(    0x00, DEF_STR( Japanese ) )
366   PORT_DIPNAME( 0x10, 0x00, "Bonus Life Occurence" )
373   PORT_DIPNAME( 0x10, 0x00, "Bonus Life Occurence" )      PORT_DIPLOCATION("SW2:5")
367374   PORT_DIPSETTING(    0x00, "Every bonus" )
368375   PORT_DIPSETTING(    0x10, "Bonus only" )
369   PORT_DIPNAME( 0x20, 0x20, "Infinite Lives (Cheat)")
376   PORT_DIPNAME( 0x20, 0x20, "Infinite Lives (Cheat)")      PORT_DIPLOCATION("SW2:6")
370377   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
371378   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
372   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Free_Play ) )
379   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Free_Play ) )      PORT_DIPLOCATION("SW2:7")
373380   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
374381   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
375   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) )
382   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) )      PORT_DIPLOCATION("SW2:8")
376383   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
377384   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
378385INPUT_PORTS_END
r2375r2376
408415   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
409416
410417   PORT_START_TAG("DSW1")
411   PORT_DIPNAME( 0x01, 0x01, "Unused SW 1-0" )
412   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
413   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
414   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Cabinet ) )
418   PORT_DIPUNUSED_DIPLOC(0x01, IP_ACTIVE_LOW, "SW1:1")   /* Listed as Unused */
419   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Cabinet ) )      PORT_DIPLOCATION("SW1:2")
415420   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
416421   PORT_DIPSETTING(    0x02, DEF_STR( Cocktail ) )
417   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Lives ) )
422   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Lives ) )      PORT_DIPLOCATION("SW1:3")
418423   PORT_DIPSETTING(    0x04, "3" )
419424   PORT_DIPSETTING(    0x00, "5" )
420   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coinage ) )
425   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coinage ) )      PORT_DIPLOCATION("SW1:4,5,6")
421426//  PORT_DIPSETTING(    0x08, DEF_STR( 5C_1C ) )
422427   PORT_DIPSETTING(    0x10, DEF_STR( 5C_1C ) )
423428   PORT_DIPSETTING(    0x20, DEF_STR( 3C_1C ) )
r2375r2376
426431   PORT_DIPSETTING(    0x30, DEF_STR( 1C_2C ) )
427432   PORT_DIPSETTING(    0x28, DEF_STR( 1C_3C ) )
428433   PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
429   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Bonus_Life ) )
434   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION("SW1:7,8")
430435   PORT_DIPSETTING(    0xc0, "20000 60000" )
431436   PORT_DIPSETTING(    0x80, "40000 90000" )
432437   PORT_DIPSETTING(    0x40, "50000 120000" )
433438   PORT_DIPSETTING(    0x00, DEF_STR( None ) )
434439
435440   PORT_START_TAG("DSW2")
436   PORT_DIPNAME( 0x01, 0x00, "Bonus Life Occurence" )
437   PORT_DIPSETTING(    0x01, "1st, 2nd, then every 2nd" )   // Check the "Non Bugs" page
441   PORT_DIPNAME( 0x01, 0x00, "Bonus Life Occurence" )      PORT_DIPLOCATION("SW2:1")
442   PORT_DIPSETTING(    0x01, "1st, 2nd, then every 2nd" )   /* Check the "Non Bugs" page */
438443   PORT_DIPSETTING(    0x00, "1st and 2nd only" )
439   PORT_DIPNAME( 0x06, 0x04, DEF_STR( Difficulty ) )
440   PORT_DIPSETTING(    0x06, DEF_STR( Easy ) )
444   PORT_DIPNAME( 0x06, 0x04, "Scroll Speed" )            PORT_DIPLOCATION("SW2:2,3")
445   PORT_DIPSETTING(    0x06, "Slow" )//DEF_STR( Easy ) )
441446   PORT_DIPSETTING(    0x04, DEF_STR( Normal ) )
442   PORT_DIPSETTING(    0x02, DEF_STR( Hard ) )
443   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
444   PORT_DIPNAME( 0x18, 0x10, "Game mode" )
447   PORT_DIPSETTING(    0x02, "Fast" )//DEF_STR( Hard ) )
448   PORT_DIPSETTING(    0x00, "Faster" )
449   PORT_DIPNAME( 0x18, 0x10, "Game mode" )               PORT_DIPLOCATION("SW2:4,5")
445450   PORT_DIPSETTING(    0x18, "Demo Sounds Off" )
446451   PORT_DIPSETTING(    0x10, "Demo Sounds On" )
447452   PORT_DIPSETTING(    0x08, "Infinite Lives (Cheat)")
448453   PORT_DIPSETTING(    0x00, "Freeze" )
449   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Flip_Screen ) )
454   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Flip_Screen ) )      PORT_DIPLOCATION("SW2:6")
450455   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
451   PORT_DIPSETTING(    0x00, DEF_STR( On ) )            // Check the "Non Bugs" page
452   PORT_DIPNAME( 0x40, 0x40, "Unused SW 2-6" )
453   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
454   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
455   PORT_DIPNAME( 0x80, 0x80, "Unknown SW 2-7" )         // tested in many places
456   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
457   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
456   PORT_DIPSETTING(    0x00, DEF_STR( On ) )            /* Check the "Non Bugs" page */
457   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Difficulty ) )      PORT_DIPLOCATION("SW2:7")
458   PORT_DIPSETTING(    0x40, DEF_STR( Easy ) )
459   PORT_DIPSETTING(    0x00, DEF_STR( Hard ) )
460   PORT_DIPUNKNOWN_DIPLOC(0x80, IP_ACTIVE_LOW, "SW2:8")   /* Listed as Unused, it is actually tested in many places */
458461INPUT_PORTS_END
459462
460463
src/mame/drivers/aladbl.c
r2375r2376
143143
144144static READ16_HANDLER( aladbl_r )
145145{
146   if (activecpu_get_pc()==0x1b2a56) return (readinputportbytag("MCU") & 0xff0f);             // coins
146   if (activecpu_get_pc()==0x1b2a56) return (input_port_read(machine, "MCU") & 0xff0f);             // coins
147147   if (activecpu_get_pc()==0x1b2a72) return 0x0000;
148   if (activecpu_get_pc()==0x1b2d24) return (readinputportbytag("MCU") & 0x00f0) | 0x1200;    // difficulty
148   if (activecpu_get_pc()==0x1b2d24) return (input_port_read(machine, "MCU") & 0x00f0) | 0x1200;    // difficulty
149149   if (activecpu_get_pc()==0x1b2d4e) return 0x0000;
150150
151151   logerror("aladbl_r : %06x\n",activecpu_get_pc());
src/mame/drivers/wwfsstar.c
r2375r2376
191191
192192static READ16_HANDLER( input_port_2_word_r_cust )
193193{
194   return readinputport(2) | vblank;
194   return input_port_read_indexed(machine, 2) | vblank;
195195}
196196
197197/*******************************************************************************
src/mame/drivers/actfancr.c
r2375r2376
4848
4949static READ8_HANDLER( actfan_control_0_r )
5050{
51   return readinputport(2); /* VBL */
51   return input_port_read_indexed(machine, 2); /* VBL */
5252}
5353
5454static READ8_HANDLER( actfan_control_1_r )
5555{
5656   switch (offset) {
57      case 0: return readinputport(0); /* Player 1 */
58      case 1: return readinputport(1); /* Player 2 */
59      case 2: return readinputport(3); /* Dip 1 */
60      case 3: return readinputport(4); /* Dip 2 */
57      case 0: return input_port_read_indexed(machine, 0); /* Player 1 */
58      case 1: return input_port_read_indexed(machine, 1); /* Player 2 */
59      case 2: return input_port_read_indexed(machine, 3); /* Dip 1 */
60      case 3: return input_port_read_indexed(machine, 4); /* Dip 2 */
6161   }
6262   return 0xff;
6363}
r2375r2376
7272static READ8_HANDLER( triothep_control_r )
7373{
7474   switch (trio_control_select) {
75      case 0: return readinputportbytag("IN0"); /* Player 1 */
76      case 1: return readinputportbytag("IN1"); /* Player 2 */
77      case 2: return readinputportbytag("DSW1"); /* Dip 1 */
78      case 3: return readinputportbytag("DSW2"); /* Dip 2 */
79      case 4: return readinputportbytag("IN2"); /* VBL */
75      case 0: return input_port_read(machine, "IN0"); /* Player 1 */
76      case 1: return input_port_read(machine, "IN1"); /* Player 2 */
77      case 2: return input_port_read(machine, "DSW1"); /* Dip 1 */
78      case 3: return input_port_read(machine, "DSW2"); /* Dip 2 */
79      case 4: return input_port_read(machine, "IN2"); /* VBL */
8080   }
8181
8282   return 0xff;
src/mame/drivers/model1.c
r2375r2376
670670static READ16_HANDLER( io_r )
671671{
672672   if(offset < 0x8)
673      return readinputport(offset);
673      return input_port_read_indexed(machine, offset);
674674   if(offset < 0x10) {
675675      offset -= 0x8;
676676      if(offset < 3)
677         return readinputport(offset+8) | 0xff00;
677         return input_port_read_indexed(machine, offset+8) | 0xff00;
678678      return 0xff;
679679   }
680680
src/mame/drivers/polepos.c
r2375r2376
302302
303303static READ8_HANDLER( polepos_adc_r )
304304{
305   return readinputport(3 + adc_input);
305   return input_port_read_indexed(machine, 3 + adc_input);
306306}
307307
308308static READ8_HANDLER( polepos_ready_r )
r2375r2376
377377}
378378
379379
380static READ8_HANDLER( in0_l )   { return readinputport(0) & auto_start_mask; }   // fire and start buttons
381static READ8_HANDLER( in0_h )   { return readinputport(0) >> 4; }   // coins
382static READ8_HANDLER( dipA_l )   { return readinputport(1); }      // dips A
383static READ8_HANDLER( dipA_h )   { return readinputport(1) >> 4; }   // dips A
384static READ8_HANDLER( dipB_l )   { return readinputport(2); }      // dips B
385static READ8_HANDLER( dipB_h )   { return readinputport(2) >> 4; }   // dips B
386static READ8_HANDLER( in1_l )   { return readinputport(5); }      // wheel
387static READ8_HANDLER( in1_h )   { return readinputport(5) >> 4; }   // wheel
380static READ8_HANDLER( in0_l )   { return input_port_read_indexed(machine, 0) & auto_start_mask; }   // fire and start buttons
381static READ8_HANDLER( in0_h )   { return input_port_read_indexed(machine, 0) >> 4; }   // coins
382static READ8_HANDLER( dipA_l )   { return input_port_read_indexed(machine, 1); }      // dips A
383static READ8_HANDLER( dipA_h )   { return input_port_read_indexed(machine, 1) >> 4; }   // dips A
384static READ8_HANDLER( dipB_l )   { return input_port_read_indexed(machine, 2); }      // dips B
385static READ8_HANDLER( dipB_h )   { return input_port_read_indexed(machine, 2) >> 4; }   // dips B
386static READ8_HANDLER( in1_l )   { return input_port_read_indexed(machine, 5); }      // wheel
387static READ8_HANDLER( in1_h )   { return input_port_read_indexed(machine, 5) >> 4; }   // wheel
388388static WRITE8_HANDLER( out_0 )
389389{
390390// no start lamps in pole position
src/mame/drivers/jackal.c
r2375r2376
5252
5353static READ8_HANDLER( topgunbl_rotary_r )
5454{
55   return (1 << (readinputport(5 + offset) * 8 / 256)) ^ 0xff;
55   return (1 << (input_port_read_indexed(machine, 5 + offset) * 8 / 256)) ^ 0xff;
5656}
5757
5858static WRITE8_HANDLER( jackal_flipscreen_w )
src/mame/drivers/mw8080bw.c
r2375r2376
319319
320320static CUSTOM_INPUT( seawolf_erase_input_r )
321321{
322   return readinputportbytag(SEAWOLF_ERASE_SW_PORT_TAG) &
323         readinputportbytag(SEAWOLF_ERASE_DIP_PORT_TAG);
322   return input_port_read(machine, SEAWOLF_ERASE_SW_PORT_TAG) &
323         input_port_read(machine, SEAWOLF_ERASE_DIP_PORT_TAG);
324324}
325325
326326
r2375r2376
542542#define TORNBASE_CAB_TYPE_PORT_TAG      ("CAB")
543543
544544
545UINT8 tornbase_get_cabinet_type()
545UINT8 tornbase_get_cabinet_type(running_machine *machine)
546546{
547   return readinputportbytag(TORNBASE_CAB_TYPE_PORT_TAG);
547   return input_port_read(machine, TORNBASE_CAB_TYPE_PORT_TAG);
548548}
549549
550550
551551static CUSTOM_INPUT( tornbase_hit_left_input_r )
552552{
553   return readinputportbytag(TORNBASE_L_HIT_PORT_TAG);
553   return input_port_read(machine, TORNBASE_L_HIT_PORT_TAG);
554554}
555555
556556
r2375r2376
558558{
559559   UINT32 ret;
560560
561   switch (tornbase_get_cabinet_type())
561   switch (tornbase_get_cabinet_type(machine))
562562   {
563563   case TORNBASE_CAB_TYPE_UPRIGHT_OLD:
564      ret = readinputportbytag(TORNBASE_L_HIT_PORT_TAG);
564      ret = input_port_read(machine, TORNBASE_L_HIT_PORT_TAG);
565565      break;
566566
567567   case TORNBASE_CAB_TYPE_UPRIGHT_NEW:
568568   case TORNBASE_CAB_TYPE_COCKTAIL:
569569   default:
570      ret = readinputportbytag(TORNBASE_R_HIT_PORT_TAG);
570      ret = input_port_read(machine, TORNBASE_R_HIT_PORT_TAG);
571571      break;
572572   }
573573
r2375r2376
579579{
580580   UINT32 ret;
581581
582   switch (tornbase_get_cabinet_type())
582   switch (tornbase_get_cabinet_type(machine))
583583   {
584584   case TORNBASE_CAB_TYPE_UPRIGHT_OLD:
585585   case TORNBASE_CAB_TYPE_UPRIGHT_NEW:
586      ret = readinputportbytag(TORNBASE_L_PITCH_PORT_TAG);
586      ret = input_port_read(machine, TORNBASE_L_PITCH_PORT_TAG);
587587      break;
588588
589589   case TORNBASE_CAB_TYPE_COCKTAIL:
590590   default:
591      ret = readinputportbytag(TORNBASE_R_PITCH_PORT_TAG);
591      ret = input_port_read(machine, TORNBASE_R_PITCH_PORT_TAG);
592592      break;
593593   }
594594
r2375r2376
598598
599599static CUSTOM_INPUT( tornbase_pitch_right_input_r )
600600{
601   return readinputportbytag(TORNBASE_L_PITCH_PORT_TAG);
601   return input_port_read(machine, TORNBASE_L_PITCH_PORT_TAG);
602602}
603603
604604
605605static CUSTOM_INPUT( tornbase_score_input_r )
606606{
607   return readinputportbytag(TORNBASE_SCORE_SW_PORT_TAG) &
608         readinputportbytag(TORNBASE_SCORE_DIP_PORT_TAG);
607   return input_port_read(machine, TORNBASE_SCORE_SW_PORT_TAG) &
608         input_port_read(machine, TORNBASE_SCORE_DIP_PORT_TAG);
609609}
610610
611611
r2375r2376
857857static UINT8 maze_tone_timing_state;
858858
859859
860static void maze_update_discrete(void)
860static STATE_POSTLOAD( maze_update_discrete )
861861{
862   maze_write_discrete(Machine, maze_tone_timing_state);
862   maze_write_discrete(machine, maze_tone_timing_state);
863863}
864864
865865
r2375r2376
880880
881881   /* setup for save states */
882882   state_save_register_global(maze_tone_timing_state);
883   state_save_register_func_postload(maze_update_discrete);
883   state_save_register_postload(machine, maze_update_discrete, NULL);
884884
885885   MACHINE_START_CALL(mw8080bw);
886886}
r2375r2376
11821182   UINT32 ret;
11831183
11841184   if (desertgu_controller_select)
1185      ret = readinputportbytag(DESERTGU_GUN_X_PORT_TAG);
1185      ret = input_port_read(machine, DESERTGU_GUN_X_PORT_TAG);
11861186   else
1187      ret = readinputportbytag(DESERTGU_GUN_Y_PORT_TAG);
1187      ret = input_port_read(machine, DESERTGU_GUN_Y_PORT_TAG);
11881188
11891189   return ret;
11901190}
r2375r2376
11951195   UINT32 ret;
11961196
11971197   if (desertgu_controller_select)
1198      ret = readinputportbytag(DESERTGU_DIP_SW_0_1_SET_2_TAG);
1198      ret = input_port_read(machine, DESERTGU_DIP_SW_0_1_SET_2_TAG);
11991199   else
1200      ret = readinputportbytag(DESERTGU_DIP_SW_0_1_SET_1_TAG);
1200      ret = input_port_read(machine, DESERTGU_DIP_SW_0_1_SET_1_TAG);
12011201
12021202   return ret;
12031203}
r2375r2376
13081308{
13091309   UINT32 ret;
13101310
1311   if (readinputportbytag(DPLAY_CAB_TYPE_PORT_TAG) == DPLAY_CAB_TYPE_UPRIGHT)
1312      ret = readinputportbytag(DPLAY_L_PITCH_PORT_TAG);
1311   if (input_port_read(machine, DPLAY_CAB_TYPE_PORT_TAG) == DPLAY_CAB_TYPE_UPRIGHT)
1312      ret = input_port_read(machine, DPLAY_L_PITCH_PORT_TAG);
13131313   else
1314      ret = readinputportbytag(DPLAY_R_PITCH_PORT_TAG);
1314      ret = input_port_read(machine, DPLAY_R_PITCH_PORT_TAG);
13151315
13161316   return ret;
13171317}
r2375r2376
13191319
13201320static CUSTOM_INPUT( dplay_pitch_right_input_r )
13211321{
1322   return readinputportbytag(DPLAY_L_PITCH_PORT_TAG);
1322   return input_port_read(machine, DPLAY_L_PITCH_PORT_TAG);
13231323}
13241324
13251325
r2375r2376
16981698
16991699   if (clowns_controller_select)
17001700   {
1701      ret = readinputportbytag(CLOWNS_CONTROLLER_P2_TAG);
1701      ret = input_port_read(machine, CLOWNS_CONTROLLER_P2_TAG);
17021702   }
17031703   else
17041704   {
1705      ret = readinputportbytag(CLOWNS_CONTROLLER_P1_TAG);
1705      ret = input_port_read(machine, CLOWNS_CONTROLLER_P1_TAG);
17061706   }
17071707
17081708   return ret;
r2375r2376
24472447
24482448static CUSTOM_INPUT( invaders_coin_input_r )
24492449{
2450   UINT32 ret = readinputportbytag(INVADERS_COIN_INPUT_PORT_TAG);
2450   UINT32 ret = input_port_read(machine, INVADERS_COIN_INPUT_PORT_TAG);
24512451
24522452   coin_counter_w(0, !ret);
24532453
r2375r2376
24622462   /* upright PCB : switches visible
24632463       cocktail PCB: HI */
24642464
2465   if (invaders_is_cabinet_cocktail())
2465   if (invaders_is_cabinet_cocktail(machine))
24662466      ret = 0x03;
24672467   else
2468      ret = readinputportbytag(INVADERS_SW6_SW7_PORT_TAG);
2468      ret = input_port_read(machine, INVADERS_SW6_SW7_PORT_TAG);
24692469
24702470   return ret;
24712471}
r2375r2376
24782478   /* upright PCB : switch visible
24792479       cocktail PCB: HI */
24802480
2481   if (invaders_is_cabinet_cocktail())
2481   if (invaders_is_cabinet_cocktail(machine))
24822482      ret = 0x01;
24832483   else
2484      ret = readinputportbytag(INVADERS_SW5_PORT_TAG);
2484      ret = input_port_read(machine, INVADERS_SW5_PORT_TAG);
24852485
24862486   return ret;
24872487}
r2375r2376
24942494   /* upright PCB : P1 controls
24952495       cocktail PCB: HI */
24962496
2497   if (invaders_is_cabinet_cocktail())
2497   if (invaders_is_cabinet_cocktail(machine))
24982498      ret = 0x07;
24992499   else
2500      ret = readinputportbytag(INVADERS_P1_CONTROL_PORT_TAG);
2500      ret = input_port_read(machine, INVADERS_P1_CONTROL_PORT_TAG);
25012501
25022502   return ret;
25032503}
r2375r2376
25102510   /* upright PCB : P1 controls
25112511       cocktail PCB: P2 controls */
25122512
2513   if (invaders_is_cabinet_cocktail())
2514      ret = readinputportbytag(INVADERS_P2_CONTROL_PORT_TAG);
2513   if (invaders_is_cabinet_cocktail(machine))
2514      ret = input_port_read(machine, INVADERS_P2_CONTROL_PORT_TAG);
25152515   else
2516      ret = readinputportbytag(INVADERS_P1_CONTROL_PORT_TAG);
2516      ret = input_port_read(machine, INVADERS_P1_CONTROL_PORT_TAG);
25172517
25182518   return ret;
25192519}
25202520
25212521
2522int invaders_is_cabinet_cocktail()
2522int invaders_is_cabinet_cocktail(running_machine *machine)
25232523{
2524   return readinputportbytag(INVADERS_CAB_TYPE_PORT_TAG);
2524   return input_port_read(machine, INVADERS_CAB_TYPE_PORT_TAG);
25252525}
25262526
25272527
r2375r2376
26472647
26482648static CUSTOM_INPUT( blueshrk_coin_input_r )
26492649{
2650   UINT32 ret = readinputportbytag(BLUESHRK_COIN_INPUT_PORT_TAG);
2650   UINT32 ret = input_port_read(machine, BLUESHRK_COIN_INPUT_PORT_TAG);
26512651
26522652   coin_counter_w(0, !ret);
26532653
r2375r2376
27242724#ifdef UNUSED_FUNCTION
27252725static UINT32 invad2ct_coin_input_r(void *param)
27262726{
2727   UINT32 ret = readinputportbytag(INVAD2CT_COIN_INPUT_PORT_TAG);
2727   UINT32 ret = input_port_read(machine, INVAD2CT_COIN_INPUT_PORT_TAG);
27282728
27292729   coin_counter_w(0, !ret);
27302730
src/mame/drivers/namcos86.c
r2375r2376
233233{
234234   int rhi, rlo;
235235
236   rhi  = ( readinputportbytag("DSWA") & 0x01 ) << 4;
237   rhi |= ( readinputportbytag("DSWA") & 0x04 ) << 3;
238   rhi |= ( readinputportbytag("DSWA") & 0x10 ) << 2;
239   rhi |= ( readinputportbytag("DSWA") & 0x40 ) << 1;
236   rhi  = ( input_port_read(machine, "DSWA") & 0x01 ) << 4;
237   rhi |= ( input_port_read(machine, "DSWA") & 0x04 ) << 3;
238   rhi |= ( input_port_read(machine, "DSWA") & 0x10 ) << 2;
239   rhi |= ( input_port_read(machine, "DSWA") & 0x40 ) << 1;
240240
241   rlo  = ( readinputportbytag("DSWB") & 0x01 );
242   rlo |= ( readinputportbytag("DSWB") & 0x04 ) >> 1;
243   rlo |= ( readinputportbytag("DSWB") & 0x10 ) >> 2;
244   rlo |= ( readinputportbytag("DSWB") & 0x40 ) >> 3;
241   rlo  = ( input_port_read(machine, "DSWB") & 0x01 );
242   rlo |= ( input_port_read(machine, "DSWB") & 0x04 ) >> 1;
243   rlo |= ( input_port_read(machine, "DSWB") & 0x10 ) >> 2;
244   rlo |= ( input_port_read(machine, "DSWB") & 0x40 ) >> 3;
245245
246246   return rhi | rlo;
247247}
r2375r2376
250250{
251251   int rhi, rlo;
252252
253   rhi  = ( readinputportbytag("DSWA") & 0x02 ) << 3;
254   rhi |= ( readinputportbytag("DSWA") & 0x08 ) << 2;
255   rhi |= ( readinputportbytag("DSWA") & 0x20 ) << 1;
256   rhi |= ( readinputportbytag("DSWA") & 0x80 );
253   rhi  = ( input_port_read(machine, "DSWA") & 0x02 ) << 3;
254   rhi |= ( input_port_read(machine, "DSWA") & 0x08 ) << 2;
255   rhi |= ( input_port_read(machine, "DSWA") & 0x20 ) << 1;
256   rhi |= ( input_port_read(machine, "DSWA") & 0x80 );
257257
258   rlo  = ( readinputportbytag("DSWB") & 0x02 ) >> 1;
259   rlo |= ( readinputportbytag("DSWB") & 0x08 ) >> 2;
260   rlo |= ( readinputportbytag("DSWB") & 0x20 ) >> 3;
261   rlo |= ( readinputportbytag("DSWB") & 0x80 ) >> 4;
258   rlo  = ( input_port_read(machine, "DSWB") & 0x02 ) >> 1;
259   rlo |= ( input_port_read(machine, "DSWB") & 0x08 ) >> 2;
260   rlo |= ( input_port_read(machine, "DSWB") & 0x20 ) >> 3;
261   rlo |= ( input_port_read(machine, "DSWB") & 0x80 ) >> 4;
262262
263263   return rhi | rlo;
264264}
src/mame/drivers/suna8.c
r2375r2376
490490{
491491   switch (*hardhead_ip)
492492   {
493      case 0:   return readinputport(0);
494      case 1:   return readinputport(1);
495      case 2:   return readinputport(2);
496      case 3:   return readinputport(3);
493      case 0:   return input_port_read_indexed(machine, 0);
494      case 1:   return input_port_read_indexed(machine, 1);
495      case 2:   return input_port_read_indexed(machine, 2);
496      case 3:   return input_port_read_indexed(machine, 3);
497497      default:
498498         logerror("CPU #0 - PC %04X: Unknown IP read: %02X\n",activecpu_get_pc(),*hardhead_ip);
499499         return 0xff;
src/mame/drivers/vaportra.c
r2375r2376
3838   switch (offset<<1)
3939   {
4040      case 4: /* Dip Switches */
41         return (readinputport(4) + (readinputport(3) << 8));
41         return (input_port_read_indexed(machine, 4) + (input_port_read_indexed(machine, 3) << 8));
4242      case 2: /* Credits */
43         return readinputport(2);
43         return input_port_read_indexed(machine, 2);
4444      case 0: /* Player 1 & Player 2 joysticks & fire buttons */
45         return (readinputport(0) + (readinputport(1) << 8));
45         return (input_port_read_indexed(machine, 0) + (input_port_read_indexed(machine, 1) << 8));
4646   }
4747
4848   logerror("Unknown control read at %d\n",offset);
r2375r2376
5151
5252/******************************************************************************/
5353
54static ADDRESS_MAP_START( vaportra_readmem, ADDRESS_SPACE_PROGRAM, 16 )
55   AM_RANGE(0x000000, 0x07ffff) AM_READ(SMH_ROM)
56   AM_RANGE(0x100000, 0x10000f) AM_READ(vaportra_control_r)
57
58   AM_RANGE(0x200000, 0x201fff) AM_READ(SMH_RAM)
59   AM_RANGE(0x202000, 0x203fff) AM_READ(SMH_RAM)
60   AM_RANGE(0x280000, 0x281fff) AM_READ(SMH_RAM)
61   AM_RANGE(0x282000, 0x283fff) AM_READ(SMH_RAM)
62
63   AM_RANGE(0x300000, 0x300fff) AM_READ(SMH_RAM)
64   AM_RANGE(0x304000, 0x304fff) AM_READ(SMH_RAM)
65   AM_RANGE(0x308000, 0x308001) AM_READ(SMH_NOP)
66   AM_RANGE(0xff8000, 0xff87ff) AM_READ(SMH_RAM)
67   AM_RANGE(0xffc000, 0xffffff) AM_READ(SMH_RAM)
68ADDRESS_MAP_END
69
70static ADDRESS_MAP_START( vaportra_writemem, ADDRESS_SPACE_PROGRAM, 16 )
71   AM_RANGE(0x000000, 0x07ffff) AM_WRITE(SMH_ROM)
54static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 )
55   AM_RANGE(0x000000, 0x07ffff) AM_ROM
7256   AM_RANGE(0x100000, 0x100003) AM_WRITE(vaportra_priority_w)
7357   AM_RANGE(0x100006, 0x100007) AM_WRITE(vaportra_sound_w)
74
75   AM_RANGE(0x200000, 0x201fff) AM_WRITE(deco16_pf3_data_w) AM_BASE(&deco16_pf3_data)
76   AM_RANGE(0x202000, 0x203fff) AM_WRITE(deco16_pf4_data_w) AM_BASE(&deco16_pf4_data)
58   AM_RANGE(0x100000, 0x10000f) AM_READ(vaportra_control_r)
59   AM_RANGE(0x200000, 0x201fff) AM_RAM AM_WRITE(deco16_pf3_data_w) AM_BASE(&deco16_pf3_data)
60   AM_RANGE(0x202000, 0x203fff) AM_RAM AM_WRITE(deco16_pf4_data_w) AM_BASE(&deco16_pf4_data)
7761   AM_RANGE(0x240000, 0x24000f) AM_WRITE(SMH_RAM) AM_BASE(&deco16_pf34_control)
78
79   AM_RANGE(0x280000, 0x281fff) AM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
80   AM_RANGE(0x282000, 0x283fff) AM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
62   AM_RANGE(0x280000, 0x281fff) AM_RAM AM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
63   AM_RANGE(0x282000, 0x283fff) AM_RAM AM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
8164   AM_RANGE(0x2c0000, 0x2c000f) AM_WRITE(SMH_RAM) AM_BASE(&deco16_pf12_control)
82
83   AM_RANGE(0x300000, 0x3009ff) AM_WRITE(vaportra_palette_24bit_rg_w) AM_BASE(&paletteram16)
84   AM_RANGE(0x304000, 0x3049ff) AM_WRITE(vaportra_palette_24bit_b_w) AM_BASE(&paletteram16_2)
85
86   AM_RANGE(0x308000, 0x308001) AM_WRITE(SMH_NOP)
65   AM_RANGE(0x300000, 0x3009ff) AM_RAM AM_WRITE(vaportra_palette_24bit_rg_w) AM_BASE(&paletteram16)
66   AM_RANGE(0x304000, 0x3049ff) AM_RAM AM_WRITE(vaportra_palette_24bit_b_w) AM_BASE(&paletteram16_2)
67   AM_RANGE(0x308000, 0x308001) AM_NOP
8768   AM_RANGE(0x30c000, 0x30c001) AM_WRITE(buffer_spriteram16_w)
88   AM_RANGE(0xff8000, 0xff87ff) AM_WRITE(SMH_RAM) AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
89   AM_RANGE(0xffc000, 0xffffff) AM_WRITE(SMH_RAM)
69   AM_RANGE(0xff8000, 0xff87ff) AM_RAM AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
70   AM_RANGE(0xffc000, 0xffffff) AM_RAM
9071ADDRESS_MAP_END
9172
73
9274/******************************************************************************/
9375
9476static READ8_HANDLER( vaportra_soundlatch_r )
r2375r2376
121103   }
122104}
123105
124static ADDRESS_MAP_START( sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
125   AM_RANGE(0x000000, 0x00ffff) AM_READ(SMH_ROM)
126   AM_RANGE(0x100000, 0x100001) AM_READ(YM2203_status_port_0_r)
127   AM_RANGE(0x110000, 0x110001) AM_READ(YM2151_status_port_0_r)
128   AM_RANGE(0x120000, 0x120001) AM_READ(OKIM6295_status_0_r)
129   AM_RANGE(0x130000, 0x130001) AM_READ(OKIM6295_status_1_r)
106static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
107   AM_RANGE(0x000000, 0x00ffff) AM_ROM
108   AM_RANGE(0x100000, 0x100001) AM_READWRITE(YM2203_status_port_0_r, YM2203_w)
109   AM_RANGE(0x110000, 0x110001) AM_READWRITE(YM2151_status_port_0_r, YM2151_w)
110   AM_RANGE(0x120000, 0x120001) AM_READWRITE(OKIM6295_status_0_r, OKIM6295_data_0_w)
111   AM_RANGE(0x130000, 0x130001) AM_READWRITE(OKIM6295_status_1_r, OKIM6295_data_1_w)
130112   AM_RANGE(0x140000, 0x140001) AM_READ(vaportra_soundlatch_r)
131   AM_RANGE(0x1f0000, 0x1f1fff) AM_READ(SMH_BANK8)
132ADDRESS_MAP_END
133
134static ADDRESS_MAP_START( sound_writemem, ADDRESS_SPACE_PROGRAM, 8 )
135   AM_RANGE(0x000000, 0x00ffff) AM_WRITE(SMH_ROM)
136   AM_RANGE(0x100000, 0x100001) AM_WRITE(YM2203_w)
137   AM_RANGE(0x110000, 0x110001) AM_WRITE(YM2151_w)
138   AM_RANGE(0x120000, 0x120001) AM_WRITE(OKIM6295_data_0_w)
139   AM_RANGE(0x130000, 0x130001) AM_WRITE(OKIM6295_data_1_w)
140   AM_RANGE(0x1f0000, 0x1f1fff) AM_WRITE(SMH_BANK8)
113   AM_RANGE(0x1f0000, 0x1f1fff) AM_READWRITE(SMH_BANK8,SMH_BANK8)  /* ??? LOOKUP ??? */
141114   AM_RANGE(0x1fec00, 0x1fec01) AM_WRITE(H6280_timer_w)
142115   AM_RANGE(0x1ff400, 0x1ff403) AM_WRITE(H6280_irq_status_w)
143116ADDRESS_MAP_END
r2375r2376
274247
275248   /* basic machine hardware */
276249   MDRV_CPU_ADD(M68000,12000000) /* Custom chip 59 */
277   MDRV_CPU_PROGRAM_MAP(vaportra_readmem,vaportra_writemem)
250   MDRV_CPU_PROGRAM_MAP(main_map,0)
278251   MDRV_CPU_VBLANK_INT("main", irq6_line_hold)
279252
280253   MDRV_CPU_ADD(H6280, 32220000/4) /* Custom chip 45; Audio section crystal is 32.220 MHz */
281254   /* audio CPU */
282   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
255   MDRV_CPU_PROGRAM_MAP(sound_map,0)
283256
284257   /* video hardware */
285258   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
src/mame/drivers/cps1.c
r2375r2376
164164READ16_HANDLER( cps1_dsw_r )
165165{
166166   static const char *const dswname[3] = { "DSWA", "DSWB", "DSWC" };
167   int control = readinputportbytag(dswname[offset]);
167   int control = input_port_read(machine, dswname[offset]);
168168   return control << 8 | control;
169169}
170170
171171READ16_HANDLER( cps1_in0_r )
172172{
173   int buttons = readinputportbytag("IN0");
173   int buttons = input_port_read(machine, "IN0");
174174   return buttons << 8 | buttons;
175175}
176176
177177READ16_HANDLER( cps1_in1_r )
178178{
179   int buttons = readinputportbytag("IN1");
179   int buttons = input_port_read(machine, "IN1");
180180   return buttons;
181181}
182182
183183READ16_HANDLER( cps1_in2_r )
184184{
185   int buttons = readinputportbytag("IN2");
185   int buttons = input_port_read(machine, "IN2");
186186   return buttons << 8 | buttons;
187187}
188188
189189READ16_HANDLER( cps1_in3_r )
190190{
191   int buttons = readinputportbytag("IN3");
191   int buttons = input_port_read(machine, "IN3");
192192   return buttons << 8 | buttons;
193193}
194194
r2375r2376
197197
198198static READ16_HANDLER( forgottn_dial_0_r )
199199{
200   return ((readinputportbytag("DIAL0") - dial[0]) >> (8*offset)) & 0xff;
200   return ((input_port_read(machine, "DIAL0") - dial[0]) >> (8*offset)) & 0xff;
201201}
202202
203203static READ16_HANDLER( forgottn_dial_1_r )
204204{
205   return ((readinputportbytag("DIAL1") - dial[1]) >> (8*offset)) & 0xff;
205   return ((input_port_read(machine, "DIAL1") - dial[1]) >> (8*offset)) & 0xff;
206206}
207207
208208static WRITE16_HANDLER( forgottn_dial_0_reset_w )
209209{
210   dial[0] = readinputportbytag("DIAL0");
210   dial[0] = input_port_read(machine, "DIAL0");
211211}
212212
213213static WRITE16_HANDLER( forgottn_dial_1_reset_w )
214214{
215   dial[1] = readinputportbytag("DIAL1");
215   dial[1] = input_port_read(machine, "DIAL1");
216216}
217217
218218
r2375r2376
33903390INPUT_PORTS_END
33913391
33923392/*
3393Previously only the Right Hand Side of each 16x16 tile was used to make the 8x8 tiles
3394with the following comment
3395
3396"fixes cawing which uses character 0x0002 as space, typo instead of 0x20?"
3397
3398A Final Fight board with mismatched USA and Japan GFX appears to prove this statement
3399wrong as the columns of the tilemap alternate between sides of the 16x16 tile resulting
3393A Final Fight board with mismatched USA and Japan GFX proves that the columns
3394of the 8x8 tilemap alternate between sides of the 16x16 tile resulting
34003395in a corrupt WDUD screen (see ffightua)
34013396*/
34023397
r2375r2376
34553450*
34563451********************************************************************/
34573452
3458static MACHINE_DRIVER_START( cps1 )
3453static MACHINE_DRIVER_START( cps1_10MHz )
34593454
34603455   /* basic machine hardware */
34613456   MDRV_CPU_ADD_TAG("main", M68000, 10000000)
r2375r2376
34953490MACHINE_DRIVER_END
34963491
34973492#ifndef MESS
3498static MACHINE_DRIVER_START( sf2 )
3493static MACHINE_DRIVER_START( cps1_12MHz )
34993494
35003495   /* basic machine hardware */
3501   MDRV_IMPORT_FROM(cps1)
3496   MDRV_IMPORT_FROM(cps1_10MHz)
3497
35023498   MDRV_CPU_REPLACE("main", M68000, 12000000)
35033499MACHINE_DRIVER_END
35043500
35053501static MACHINE_DRIVER_START( pang3 )
35063502
35073503   /* basic machine hardware */
3508   MDRV_IMPORT_FROM(cps1)
3504   MDRV_IMPORT_FROM(cps1_12MHz)
3505
35093506   MDRV_NVRAM_HANDLER(pang3)
35103507MACHINE_DRIVER_END
35113508
35123509static MACHINE_DRIVER_START( qsound )
35133510
35143511   /* basic machine hardware */
3515   MDRV_IMPORT_FROM(cps1)
3512   MDRV_IMPORT_FROM(cps1_12MHz)
3513
35163514   MDRV_CPU_REPLACE("main", M68000, 12000000)
35173515   MDRV_CPU_VBLANK_INT("main", cps1_qsound_interrupt)  /* ??? interrupts per frame */
35183516
r2375r2376
73037301
73047302static DRIVER_INIT( pang3 )
73057303{
7304   /* Pang 3 EEPROM interface is at a different address */
7305   memory_install_readwrite16_handler (0, ADDRESS_SPACE_PROGRAM, 0x80017a, 0x80017b, 0, 0, cps1_eeprom_port_r, cps1_eeprom_port_w);
7306
7307   DRIVER_INIT_CALL(cps1);
7308}
7309
7310static DRIVER_INIT( pang3j )
7311{
73067312   UINT16 *rom = (UINT16 *)memory_region(REGION_CPU1);
73077313   int A,src,dst;
73087314
r2375r2376
73227328      rom[A/2] = dst;
73237329   }
73247330
7325   DRIVER_INIT_CALL(cps1);
7331   DRIVER_INIT_CALL(pang3);
73267332}
73277333#endif
73287334
73297335
7330GAME( 1988, forgottn, 0,        cps1,     forgottn, cps1,     ROT0,   "Capcom", "Forgotten Worlds (US)", 0 )
7331GAME( 1988, lostwrld, forgottn, cps1,     forgottn, cps1,     ROT0,   "Capcom", "Lost Worlds (Japan)", 0 )
7332GAME( 1988, ghouls,   0,        cps1,     ghouls,   cps1,     ROT0,   "Capcom", "Ghouls'n Ghosts (World)" , 0)                  // Wed.26.10.1988 in the ROMS
7333GAME( 1988, ghoulsu,  ghouls,   cps1,     ghoulsu,  cps1,     ROT0,   "Capcom", "Ghouls'n Ghosts (US)" , 0)                  // Wed.26.10.1988 in the ROMS
7334GAME( 1988, daimakai, ghouls,   cps1,     daimakai, cps1,     ROT0,   "Capcom", "Dai Makai-Mura (Japan)" , 0)                  // Wed.26.10.1988 in the ROMS
7335GAME( 1989, strider,  0,        cps1,     strider,  cps1,     ROT0,   "Capcom", "Strider (US set 1)", 0 )
7336GAME( 1989, stridrua, strider,  cps1,     stridrua, cps1,     ROT0,   "Capcom", "Strider (US set 2)", 0 )
7337GAME( 1989, striderj, strider,  cps1,     strider,  cps1,     ROT0,   "Capcom", "Strider Hiryu (Japan set 1)", 0 )
7338GAME( 1989, stridrja, strider,  cps1,     strider,  cps1,     ROT0,   "Capcom", "Strider Hiryu (Japan set 2)", 0 )
7339GAME( 1989, dynwar,   0,        cps1,     dynwar,   cps1,     ROT0,   "Capcom", "Dynasty Wars (World)", 0 )                  // (c) Capcom U.S.A.
7340GAME( 1989, dynwarj,  dynwar,   cps1,     dynwar,   cps1,     ROT0,   "Capcom", "Tenchi wo Kurau (Japan)", 0 )
7341GAME( 1989, willow,   0,        cps1,     willow,   cps1,     ROT0,   "Capcom", "Willow (US)", 0 )
7342GAME( 1989, willowj,  willow,   cps1,     willow,   cps1,     ROT0,   "Capcom", "Willow (Japan, Japanese)" , 0)               // Japan "warning"
7343GAME( 1989, willowje, willow,   cps1,     willow,   cps1,     ROT0,   "Capcom", "Willow (Japan, English)", 0 )                  // (c) Capcom U.S.A. but Japan "warning"
7344GAME( 1989, unsquad,  0,        cps1,     unsquad,  cps1,     ROT0,   "Capcom", "U.N. Squadron (US)", 0 )
7345GAME( 1989, area88,   unsquad,  cps1,     unsquad,  cps1,     ROT0,   "Capcom", "Area 88 (Japan)", 0 )
7346GAME( 1989, ffight,   0,        cps1,     ffight,   cps1,     ROT0,   "Capcom", "Final Fight (World)", 0 )
7347GAME( 1989, ffightu,  ffight,   cps1,     ffight,   cps1,     ROT0,   "Capcom", "Final Fight (US)", 0 )
7348GAME( 1989, ffightua, ffight,   cps1,     ffight,   cps1,     ROT0,   "Capcom", "Final Fight (US 900112)", 0 )
7349GAME( 1989, ffightub, ffight,   cps1,     ffight,   cps1,     ROT0,   "Capcom", "Final Fight (US 900613)", 0 )
7350GAME( 1989, ffightj,  ffight,   cps1,     ffight,   cps1,     ROT0,   "Capcom", "Final Fight (Japan)", 0 )
7351GAME( 1989, ffightj1, ffight,   cps1,     ffight,   cps1,     ROT0,   "Capcom", "Final Fight (Japan 900305)", 0 )
7352GAME( 1990, 1941,     0,        cps1,     1941,     cps1,     ROT270, "Capcom", "1941 - Counter Attack (World)", 0 )
7353GAME( 1990, 1941j,    1941,     cps1,     1941,     cps1,     ROT270, "Capcom", "1941 - Counter Attack (Japan)", 0 )
7354GAME( 1990, mercs,    0,        cps1,     mercs,    cps1,     ROT270, "Capcom", "Mercs (World 900302)" , 0)                  // "ETC"
7355GAME( 1990, mercsu,   mercs,    cps1,     mercs,    cps1,     ROT270, "Capcom", "Mercs (US 900302)", 0 )
7356GAME( 1990, mercsua,  mercs,    cps1,     mercs,    cps1,     ROT270, "Capcom", "Mercs (US 900608)", 0 )
7357GAME( 1990, mercsj,   mercs,    cps1,     mercs,    cps1,     ROT270, "Capcom", "Senjou no Ookami II (Japan 900302)", 0 )
7358GAME( 1990, mtwins,   0,        cps1,     mtwins,   cps1,     ROT0,   "Capcom", "Mega Twins (World 900619)", 0 )               // "ETC" - (c) Capcom U.S.A. with World "warning"
7359GAME( 1990, chikij,   mtwins,   cps1,     mtwins,   cps1,     ROT0,   "Capcom", "Chiki Chiki Boys (Japan 900619)", 0 )
7360GAME( 1990, msword,   0,        cps1,     msword,   cps1,     ROT0,   "Capcom", "Magic Sword - Heroic Fantasy (World 900725)" , 0)      // 25.07.1990  "Other Country"
7361GAME( 1990, mswordr1, msword,   cps1,     msword,   cps1,     ROT0,   "Capcom", "Magic Sword - Heroic Fantasy (World 900623)" , 0)      // 23.06.1990  "Other Country"
7362GAME( 1990, mswordu,  msword,   cps1,     msword,   cps1,     ROT0,   "Capcom", "Magic Sword - Heroic Fantasy (US 900725)" , 0)         // 25.07.1990  "U.S.A."
7363GAME( 1990, mswordj,  msword,   cps1,     msword,   cps1,     ROT0,   "Capcom", "Magic Sword (Japan 900623)" , 0)               // 23.06.1990  "Japan"
7364GAME( 1990, cawing,   0,        cps1,     cawing,   cps1,     ROT0,   "Capcom", "Carrier Air Wing (World 901012)" , 0)            // "ETC"
7365GAME( 1990, cawingr1, cawing,   cps1,     cawing,   cps1,     ROT0,   "Capcom", "Carrier Air Wing (World 901009)" , 0)            // "ETC"
7366GAME( 1990, cawingu,  cawing,   cps1,     cawing,   cps1,     ROT0,   "Capcom", "Carrier Air Wing (US 901012)", 0 )
7367GAME( 1990, cawingj,  cawing,   cps1,     cawing,   cps1,     ROT0,   "Capcom", "U.S. Navy (Japan 901012)", 0 )
7368GAME( 1990, nemo,     0,        cps1,     nemo,     cps1,     ROT0,   "Capcom", "Nemo (World 901130)" , 0)                  // "ETC"
7369GAME( 1990, nemoj,    nemo,     cps1,     nemo,     cps1,     ROT0,   "Capcom", "Nemo (Japan 901120)", 0 )
7370GAME( 1991, sf2,      0,        sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (World 910522)" , 0)   // "ETC"
7371GAME( 1991, sf2eb,    sf2,      sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (World 910214)" , 0)   // "ETC"
7372GAME( 1991, sf2ua,    sf2,      sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910206)", 0 )
7373GAME( 1991, sf2ub,    sf2,      sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910214)", 0 )
7374GAME( 1991, sf2ud,    sf2,      sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910318)", 0 )
7375GAME( 1991, sf2ue,    sf2,      sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910228)", 0 )
7376GAME( 1991, sf2uf,    sf2,      sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910411)", 0 )
7377GAME( 1991, sf2ui,    sf2,      sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910522)", 0 )
7378GAME( 1991, sf2uk,    sf2,      sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 911101)", 0 )
7379GAME( 1991, sf2j,     sf2,      sf2,      sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (Japan 911210)", 0 )
7380GAME( 1991, sf2ja,    sf2,      sf2,      sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (Japan 910214)", 0 )
7381GAME( 1991, sf2jc,    sf2,      sf2,      sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (Japan 910306)", 0 )
7382GAME( 1991, 3wonders, 0,        cps1,     3wonders, cps1,     ROT0,   "Capcom", "Three Wonders (World 910520)" , 0)               // "ETC"
7383GAME( 1991, 3wonderu, 3wonders, cps1,     3wonders, cps1,     ROT0,   "Capcom", "Three Wonders (US 910520)", 0 )
7384GAME( 1991, wonder3,  3wonders, cps1,     3wonders, cps1,     ROT0,   "Capcom", "Wonder 3 (Japan 910520)", 0 )
7385GAME( 1991, kod,      0,        cps1,     kod,      cps1,     ROT0,   "Capcom", "The King of Dragons (World 910711)" , 0)            // "ETC"
7386GAME( 1991, kodu,     kod,      cps1,     kodj,     cps1,     ROT0,   "Capcom", "The King of Dragons (US 910910)", 0 )
7387GAME( 1991, kodj,     kod,      cps1,     kodj,     cps1,     ROT0,   "Capcom", "The King of Dragons (Japan 910805)", 0 )
7388GAME( 1991, kodb,     kod,      cps1,     kod,      cps1,     ROT0,   "Capcom", "The King of Dragons (bootleg)", GAME_NOT_WORKING )      // 910731  "ETC"
7389GAME( 1991, captcomm, 0,        cps1,     captcomm, cps1,     ROT0,   "Capcom", "Captain Commando (World 911014)" , 0)            // "OTHER COUNTRY"
7390GAME( 1991, captcomu, captcomm, cps1,     captcomm, cps1,     ROT0,   "Capcom", "Captain Commando (US 910928)", 0 )
7391GAME( 1991, captcomj, captcomm, cps1,     captcomm, cps1,     ROT0,   "Capcom", "Captain Commando (Japan 911202)", 0 )
7392GAME( 1991, knights,  0,        cps1,     knights,  cps1,     ROT0,   "Capcom", "Knights of the Round (World 911127)" , 0)            // "ETC"
7393GAME( 1991, knightsu, knights,  cps1,     knights,  cps1,     ROT0,   "Capcom", "Knights of the Round (US 911127)", 0 )
7394GAME( 1991, knightsj, knights,  cps1,     knights,  cps1,     ROT0,   "Capcom", "Knights of the Round (Japan 911127)", 0 )
7395GAME( 1992, sf2ce,    0,        sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (World 920313)" , 0)   // "ETC"
7396GAME( 1992, sf2ceua,  sf2ce,    sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (US 920313)", 0 )
7397GAME( 1992, sf2ceub,  sf2ce,    sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (US 920513)", 0 )
7398GAME( 1992, sf2ceuc,  sf2ce,    sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (US 920803)", 0 )
7399GAME( 1992, sf2cej,   sf2ce,    sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (Japan 920513)", 0 )
7400GAME( 1992, sf2rb,    sf2ce,    sf2,      sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Rainbow set 1)" , 0)   // 920322 - based on World version
7401GAME( 1992, sf2rb2,   sf2ce,    sf2,      sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Rainbow set 2)" , 0)   // 920322 - based on World version
7402GAME( 1992, sf2red,   sf2ce,    sf2,      sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Red Wave)" , 0)      // 920313 - based on World version
7403GAME( 1992, sf2v004,  sf2ce,    sf2,      sf2,      cps1,     ROT0,   "bootleg","Street Fighter II! - Champion Edition (V004)", 0 )      // "102092" !!! - based on (heavily modified) World version
7404GAME( 1992, sf2accp2, sf2ce,    sf2,      sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Accelerator Pt.II)" , 0)  // 920313 - based on USA version
7405GAME( 1992, sf2m1,    sf2ce,    sf2,      sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M1)", GAME_NOT_WORKING )
7406GAME( 1992, sf2m2,    sf2ce,    sf2,      sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M2)", GAME_NOT_WORKING )
7407GAME( 1992, sf2m3,    sf2ce,    sf2,      sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M3)", GAME_NOT_WORKING )
7408GAME( 1992, sf2m4,    sf2ce,    sf2,      sf2j,     cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M4)", 0 )
7409GAME( 1992, sf2m5,    sf2ce,    sf2,      sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M5)", 0 )
7410GAME( 1992, sf2m6,    sf2ce,    sf2,      sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M6)", 0 )
7411GAME( 1992, sf2m7,    sf2ce,    sf2,      sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M7)", 0 )
7412GAME( 1992, sf2yyc,   sf2ce,    sf2,      sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (YYC)", 0 )
7413GAME( 1992, sf2koryu, sf2ce,    sf2,      sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Kouryu)", 0 )
7414GAME( 1992, varth,    0,        cps1,     varth,    cps1,     ROT270, "Capcom", "Varth - Operation Thunderstorm (World 920714)" , 0)      // "ETC"
7415GAME( 1992, varthr1,  varth,    cps1,     varth,    cps1,     ROT270, "Capcom", "Varth - Operation Thunderstorm (World 920612)" , 0)      // "ETC"
7416GAME( 1992, varthu,   varth,    cps1,     varth,    cps1,     ROT270, "Capcom (Romstar license)", "Varth - Operation Thunderstorm (US 920612)", 0 )
7417GAME( 1992, varthj,   varth,    cps1,     varth,    cps1,     ROT270, "Capcom", "Varth - Operation Thunderstorm (Japan 920714)", 0 )
7418GAME( 1992, cworld2j, 0,        cps1,     cworld2j, cps1,     ROT0,   "Capcom", "Capcom World 2 (Japan 920611)", 0 )
7419GAME( 1992, sf2hf,    sf2ce,    sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Hyper Fighting (World 921209)", 0 )
7420GAME( 1992, sf2t,     sf2ce,    sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Hyper Fighting (US 921209)", 0 )
7421GAME( 1992, sf2tj,    sf2ce,    sf2,      sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II' Turbo - Hyper Fighting (Japan 921209)", 0 )
7422GAME( 1992, qad,      0,        cps1,     qad,      cps1,     ROT0,   "Capcom", "Quiz & Dragons (US 920701)", 0 )
7423GAME( 1994, qadj,     qad,      cps1,     qadj,     cps1,     ROT0,   "Capcom", "Quiz & Dragons (Japan 940921)", 0 )
7424GAME( 1995, qtono2,   0,        cps1,     qtono2,   cps1,     ROT0,   "Capcom", "Quiz Tonosama no Yabou 2 Zenkoku-ban (Japan 950123)", 0 )
7425GAME( 1995, megaman,  0,        cps1,     megaman,  cps1,     ROT0,   "Capcom", "Mega Man - The Power Battle (CPS1 Asia 951006)", 0 )
7426GAME( 1995, rockmanj, megaman,  cps1,     rockmanj, cps1,     ROT0,   "Capcom", "Rockman - The Power Battle (CPS1 Japan 950922)", 0 )
7336GAME( 1988, forgottn, 0,        cps1_10MHz, forgottn, cps1,     ROT0,   "Capcom", "Forgotten Worlds (US)", 0 )
7337GAME( 1988, lostwrld, forgottn, cps1_10MHz, forgottn, cps1,     ROT0,   "Capcom", "Lost Worlds (Japan)", 0 )
7338GAME( 1988, ghouls,   0,        cps1_10MHz, ghouls,   cps1,     ROT0,   "Capcom", "Ghouls'n Ghosts (World)" , 0)                  // Wed.26.10.1988 in the ROMS
7339GAME( 1988, ghoulsu,  ghouls,   cps1_10MHz, ghoulsu,  cps1,     ROT0,   "Capcom", "Ghouls'n Ghosts (US)" , 0)                  // Wed.26.10.1988 in the ROMS
7340GAME( 1988, daimakai, ghouls,   cps1_10MHz, daimakai, cps1,     ROT0,   "Capcom", "Dai Makai-Mura (Japan)" , 0)                  // Wed.26.10.1988 in the ROMS
7341GAME( 1989, strider,  0,        cps1_10MHz, strider,  cps1,     ROT0,   "Capcom", "Strider (US set 1)", 0 )
7342GAME( 1989, stridrua, strider,  cps1_10MHz, stridrua, cps1,     ROT0,   "Capcom", "Strider (US set 2)", 0 )
7343GAME( 1989, striderj, strider,  cps1_10MHz, strider,  cps1,     ROT0,   "Capcom", "Strider Hiryu (Japan set 1)", 0 )
7344GAME( 1989, stridrja, strider,  cps1_10MHz, strider,  cps1,     ROT0,   "Capcom", "Strider Hiryu (Japan set 2)", 0 )
7345GAME( 1989, dynwar,   0,        cps1_10MHz, dynwar,   cps1,     ROT0,   "Capcom", "Dynasty Wars (World)", 0 )                  // (c) Capcom U.S.A.
7346GAME( 1989, dynwarj,  dynwar,   cps1_10MHz, dynwar,   cps1,     ROT0,   "Capcom", "Tenchi wo Kurau (Japan)", 0 )
7347GAME( 1989, willow,   0,        cps1_10MHz, willow,   cps1,     ROT0,   "Capcom", "Willow (US)", 0 )
7348GAME( 1989, willowj,  willow,   cps1_10MHz, willow,   cps1,     ROT0,   "Capcom", "Willow (Japan, Japanese)" , 0)               // Japan "warning"
7349GAME( 1989, willowje, willow,   cps1_10MHz, willow,   cps1,     ROT0,   "Capcom", "Willow (Japan, English)", 0 )                  // (c) Capcom U.S.A. but Japan "warning"
7350GAME( 1989, unsquad,  0,        cps1_10MHz, unsquad,  cps1,     ROT0,   "Capcom", "U.N. Squadron (US)", 0 )
7351GAME( 1989, area88,   unsquad,  cps1_10MHz, unsquad,  cps1,     ROT0,   "Capcom", "Area 88 (Japan)", 0 )
7352GAME( 1989, ffight,   0,        cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (World)", 0 )
7353GAME( 1989, ffightu,  ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (US)", 0 )
7354GAME( 1989, ffightua, ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (US 900112)", 0 )
7355GAME( 1989, ffightub, ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (US 900613)", 0 )
7356GAME( 1989, ffightj,  ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (Japan)", 0 )
7357GAME( 1989, ffightj1, ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (Japan 900305)", 0 )
7358GAME( 1990, 1941,     0,        cps1_10MHz, 1941,     cps1,     ROT270, "Capcom", "1941 - Counter Attack (World)", 0 )
7359GAME( 1990, 1941j,    1941,     cps1_10MHz, 1941,     cps1,     ROT270, "Capcom", "1941 - Counter Attack (Japan)", 0 )
7360GAME( 1990, mercs,    0,        cps1_10MHz, mercs,    cps1,     ROT270, "Capcom", "Mercs (World 900302)" , 0)                  // "ETC"
7361GAME( 1990, mercsu,   mercs,    cps1_10MHz, mercs,    cps1,     ROT270, "Capcom", "Mercs (US 900302)", 0 )
7362GAME( 1990, mercsua,  mercs,    cps1_10MHz, mercs,    cps1,     ROT270, "Capcom", "Mercs (US 900608)", 0 )
7363GAME( 1990, mercsj,   mercs,    cps1_10MHz, mercs,    cps1,     ROT270, "Capcom", "Senjou no Ookami II (Japan 900302)", 0 )
7364GAME( 1990, mtwins,   0,        cps1_10MHz, mtwins,   cps1,     ROT0,   "Capcom", "Mega Twins (World 900619)", 0 )               // "ETC" - (c) Capcom U.S.A. with World "warning"
7365GAME( 1990, chikij,   mtwins,   cps1_10MHz, mtwins,   cps1,     ROT0,   "Capcom", "Chiki Chiki Boys (Japan 900619)", 0 )
7366GAME( 1990, msword,   0,        cps1_10MHz, msword,   cps1,     ROT0,   "Capcom", "Magic Sword - Heroic Fantasy (World 900725)" , 0)      // 25.07.1990  "Other Country"
7367GAME( 1990, mswordr1, msword,   cps1_10MHz, msword,   cps1,     ROT0,   "Capcom", "Magic Sword - Heroic Fantasy (World 900623)" , 0)      // 23.06.1990  "Other Country"
7368GAME( 1990, mswordu,  msword,   cps1_10MHz, msword,   cps1,     ROT0,   "Capcom", "Magic Sword - Heroic Fantasy (US 900725)" , 0)         // 25.07.1990  "U.S.A."
7369GAME( 1990, mswordj,  msword,   cps1_10MHz, msword,   cps1,     ROT0,   "Capcom", "Magic Sword (Japan 900623)" , 0)               // 23.06.1990  "Japan"
7370GAME( 1990, cawing,   0,        cps1_10MHz, cawing,   cps1,     ROT0,   "Capcom", "Carrier Air Wing (World 901012)" , 0)            // "ETC"
7371GAME( 1990, cawingr1, cawing,   cps1_10MHz, cawing,   cps1,     ROT0,   "Capcom", "Carrier Air Wing (World 901009)" , 0)            // "ETC"
7372GAME( 1990, cawingu,  cawing,   cps1_10MHz, cawing,   cps1,     ROT0,   "Capcom", "Carrier Air Wing (US 901012)", 0 )
7373GAME( 1990, cawingj,  cawing,   cps1_10MHz, cawing,   cps1,     ROT0,   "Capcom", "U.S. Navy (Japan 901012)", 0 )
7374GAME( 1990, nemo,     0,        cps1_10MHz, nemo,     cps1,     ROT0,   "Capcom", "Nemo (World 901130)" , 0)                  // "ETC"
7375GAME( 1990, nemoj,    nemo,     cps1_10MHz, nemo,     cps1,     ROT0,   "Capcom", "Nemo (Japan 901120)", 0 )
7376GAME( 1991, sf2,      0,        cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (World 910522)" , 0)   // "ETC"
7377GAME( 1991, sf2eb,    sf2,      cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (World 910214)" , 0)   // "ETC"
7378GAME( 1991, sf2ua,    sf2,      cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910206)", 0 )
7379GAME( 1991, sf2ub,    sf2,      cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910214)", 0 )
7380GAME( 1991, sf2ud,    sf2,      cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910318)", 0 )
7381GAME( 1991, sf2ue,    sf2,      cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910228)", 0 )
7382GAME( 1991, sf2uf,    sf2,      cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910411)", 0 )
7383GAME( 1991, sf2ui,    sf2,      cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910522)", 0 )
7384GAME( 1991, sf2uk,    sf2,      cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 911101)", 0 )
7385GAME( 1991, sf2j,     sf2,      cps1_12MHz, sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (Japan 911210)", 0 )
7386GAME( 1991, sf2ja,    sf2,      cps1_12MHz, sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (Japan 910214)", 0 )
7387GAME( 1991, sf2jc,    sf2,      cps1_12MHz, sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (Japan 910306)", 0 )
7388GAME( 1991, 3wonders, 0,        cps1_10MHz, 3wonders, cps1,     ROT0,   "Capcom", "Three Wonders (World 910520)" , 0)               // "ETC"
7389GAME( 1991, 3wonderu, 3wonders, cps1_10MHz, 3wonders, cps1,     ROT0,   "Capcom", "Three Wonders (US 910520)", 0 )
7390GAME( 1991, wonder3,  3wonders, cps1_10MHz, 3wonders, cps1,     ROT0,   "Capcom", "Wonder 3 (Japan 910520)", 0 )
7391GAME( 1991, kod,      0,        cps1_10MHz, kod,      cps1,     ROT0,   "Capcom", "The King of Dragons (World 910711)" , 0)            // "ETC"
7392GAME( 1991, kodu,     kod,      cps1_10MHz, kodj,     cps1,     ROT0,   "Capcom", "The King of Dragons (US 910910)", 0 )
7393GAME( 1991, kodj,     kod,      cps1_10MHz, kodj,     cps1,     ROT0,   "Capcom", "The King of Dragons (Japan 910805)", 0 )
7394GAME( 1991, kodb,     kod,      cps1_10MHz, kod,      cps1,     ROT0,   "Capcom", "The King of Dragons (bootleg)", GAME_NOT_WORKING )      // 910731  "ETC"
7395GAME( 1991, captcomm, 0,        cps1_10MHz, captcomm, cps1,     ROT0,   "Capcom", "Captain Commando (World 911014)" , 0)            // "OTHER COUNTRY"
7396GAME( 1991, captcomu, captcomm, cps1_10MHz, captcomm, cps1,     ROT0,   "Capcom", "Captain Commando (US 910928)", 0 )
7397GAME( 1991, captcomj, captcomm, cps1_10MHz, captcomm, cps1,     ROT0,   "Capcom", "Captain Commando (Japan 911202)", 0 )
7398GAME( 1991, knights,  0,        cps1_10MHz, knights,  cps1,     ROT0,   "Capcom", "Knights of the Round (World 911127)" , 0)            // "ETC"
7399GAME( 1991, knightsu, knights,  cps1_10MHz, knights,  cps1,     ROT0,   "Capcom", "Knights of the Round (US 911127)", 0 )
7400GAME( 1991, knightsj, knights,  cps1_10MHz, knights,  cps1,     ROT0,   "Capcom", "Knights of the Round (Japan 911127)", 0 )
7401GAME( 1992, sf2ce,    0,        cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (World 920313)" , 0)   // "ETC"
7402GAME( 1992, sf2ceua,  sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (US 920313)", 0 )
7403GAME( 1992, sf2ceub,  sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (US 920513)", 0 )
7404GAME( 1992, sf2ceuc,  sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (US 920803)", 0 )
7405GAME( 1992, sf2cej,   sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (Japan 920513)", 0 )
7406GAME( 1992, sf2rb,    sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Rainbow set 1)" , 0)   // 920322 - based on World version
7407GAME( 1992, sf2rb2,   sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Rainbow set 2)" , 0)   // 920322 - based on World version
7408GAME( 1992, sf2red,   sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Red Wave)" , 0)      // 920313 - based on World version
7409GAME( 1992, sf2v004,  sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II! - Champion Edition (V004)", 0 )      // "102092" !!! - based on (heavily modified) World version
7410GAME( 1992, sf2accp2, sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Accelerator Pt.II)" , 0)  // 920313 - based on USA version
7411GAME( 1992, sf2m1,    sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M1)", GAME_NOT_WORKING )
7412GAME( 1992, sf2m2,    sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M2)", GAME_NOT_WORKING )
7413GAME( 1992, sf2m3,    sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M3)", GAME_NOT_WORKING )
7414GAME( 1992, sf2m4,    sf2ce,    cps1_12MHz, sf2j,     cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M4)", 0 )
7415GAME( 1992, sf2m5,    sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M5)", 0 )
7416GAME( 1992, sf2m6,    sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M6)", 0 )
7417GAME( 1992, sf2m7,    sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M7)", 0 )
7418GAME( 1992, sf2yyc,   sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (YYC)", 0 )
7419GAME( 1992, sf2koryu, sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Kouryu)", 0 )
7420GAME( 1992, varth,    0,        cps1_10MHz, varth,    cps1,     ROT270, "Capcom", "Varth - Operation Thunderstorm (World 920714)" , 0)      // "ETC"
7421GAME( 1992, varthr1,  varth,    cps1_10MHz, varth,    cps1,     ROT270, "Capcom", "Varth - Operation Thunderstorm (World 920612)" , 0)      // "ETC"
7422GAME( 1992, varthu,   varth,    cps1_10MHz, varth,    cps1,     ROT270, "Capcom (Romstar license)", "Varth - Operation Thunderstorm (US 920612)", 0 )
7423GAME( 1992, varthj,   varth,    cps1_10MHz, varth,    cps1,     ROT270, "Capcom", "Varth - Operation Thunderstorm (Japan 920714)", 0 )
7424GAME( 1992, cworld2j, 0,        cps1_10MHz, cworld2j, cps1,     ROT0,   "Capcom", "Capcom World 2 (Japan 920611)", 0 )
7425GAME( 1992, sf2hf,    sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Hyper Fighting (World 921209)", 0 )
7426GAME( 1992, sf2t,     sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Hyper Fighting (US 921209)", 0 )
7427GAME( 1992, sf2tj,    sf2ce,    cps1_12MHz, sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II' Turbo - Hyper Fighting (Japan 921209)", 0 )
7428GAME( 1992, qad,      0,        cps1_12MHz, qad,      cps1,     ROT0,   "Capcom", "Quiz & Dragons (US 920701)", 0 )   // 12MHz verified
7429GAME( 1994, qadj,     qad,      cps1_10MHz, qadj,     cps1,     ROT0,   "Capcom", "Quiz & Dragons (Japan 940921)", 0 )
7430GAME( 1995, qtono2,   0,        cps1_10MHz, qtono2,   cps1,     ROT0,   "Capcom", "Quiz Tonosama no Yabou 2 Zenkoku-ban (Japan 950123)", 0 )
7431GAME( 1995, megaman,  0,        cps1_10MHz, megaman,  cps1,     ROT0,   "Capcom", "Mega Man - The Power Battle (CPS1 Asia 951006)", 0 )
7432GAME( 1995, rockmanj, megaman,  cps1_10MHz, rockmanj, cps1,     ROT0,   "Capcom", "Rockman - The Power Battle (CPS1 Japan 950922)", 0 )
74277433
7428GAME( 1992, wof,      0,        qsound,   wof,      wof,      ROT0,   "Capcom", "Warriors of Fate (World 921002)" , 0)            // "ETC"
7429GAME( 1992, wofa,     wof,      qsound,   wof,      wof,      ROT0,   "Capcom", "Sangokushi II (Asia 921005)" , 0)               // World "warning"
7430GAME( 1992, wofu,     wof,      qsound,   wof,      wof,      ROT0,   "Capcom", "Warriors of Fate (US 921031)" , 0)               // World "warning"
7431GAME( 1992, wofj,     wof,      qsound,   wof,      wof,      ROT0,   "Capcom", "Tenchi wo Kurau II - Sekiheki no Tatakai (Japan 921031)", 0 )
7432GAME( 1993, dino,     0,        qsound,   dino,     dino,     ROT0,   "Capcom", "Cadillacs and Dinosaurs (World 930201)" , 0)         // "ETC"
7433GAME( 1993, dinou,    dino,     qsound,   dino,     dino ,    ROT0,   "Capcom", "Cadillacs and Dinosaurs (US 930201)", 0 )
7434GAME( 1993, dinoj,    dino,     qsound,   dino,     dino ,    ROT0,   "Capcom", "Cadillacs Kyouryuu-Shinseiki (Japan 930201)", 0 )
7435GAME( 1993, punisher, 0,        qsound,   punisher, punisher, ROT0,   "Capcom", "The Punisher (World 930422)" , 0)               // "ETC"
7436GAME( 1993, punishru, punisher, qsound,   punisher, punisher, ROT0,   "Capcom", "The Punisher (US 930422)", 0 )
7437GAME( 1993, punishrj, punisher, qsound,   punisher, punisher, ROT0,   "Capcom", "The Punisher (Japan 930422)", 0 )
7438GAME( 1993, slammast, 0,        qsound,   slammast, slammast, ROT0,   "Capcom", "Saturday Night Slam Masters (World 930713)" , 0)      // "ETC"
7439GAME( 1993, slammasu, slammast, qsound,   slammast, slammast, ROT0,   "Capcom", "Saturday Night Slam Masters (US 930713)", 0 )
7440GAME( 1993, mbomberj, slammast, qsound,   slammast, slammast, ROT0,   "Capcom", "Muscle Bomber - The Body Explosion (Japan 930713)", 0 )
7441GAME( 1993, mbombrd,  slammast, qsound,   slammast, slammast, ROT0,   "Capcom", "Muscle Bomber Duo - Ultimate Team Battle (World 931206)" , 0)  // "ETC"
7442GAME( 1993, mbombrdj, slammast, qsound,   slammast, slammast, ROT0,   "Capcom", "Muscle Bomber Duo - Heat Up Warriors (Japan 931206)", 0 )
7434GAME( 1992, wof,      0,        qsound,     wof,      wof,      ROT0,   "Capcom", "Warriors of Fate (World 921002)" , 0)            // "ETC"
7435GAME( 1992, wofa,     wof,      qsound,     wof,      wof,      ROT0,   "Capcom", "Sangokushi II (Asia 921005)" , 0)               // World "warning"
7436GAME( 1992, wofu,     wof,      qsound,     wof,      wof,      ROT0,   "Capcom", "Warriors of Fate (US 921031)" , 0)               // World "warning"
7437GAME( 1992, wofj,     wof,      qsound,     wof,      wof,      ROT0,   "Capcom", "Tenchi wo Kurau II - Sekiheki no Tatakai (Japan 921031)", 0 )
7438GAME( 1993, dino,     0,        qsound,     dino,     dino,     ROT0,   "Capcom", "Cadillacs and Dinosaurs (World 930201)" , 0)         // "ETC"
7439GAME( 1993, dinou,    dino,     qsound,     dino,     dino ,    ROT0,   "Capcom", "Cadillacs and Dinosaurs (US 930201)", 0 )
7440GAME( 1993, dinoj,    dino,     qsound,     dino,     dino ,    ROT0,   "Capcom", "Cadillacs Kyouryuu-Shinseiki (Japan 930201)", 0 )
7441GAME( 1993, punisher, 0,        qsound,     punisher, punisher, ROT0,   "Capcom", "The Punisher (World 930422)" , 0)               // "ETC"
7442GAME( 1993, punishru, punisher, qsound,     punisher, punisher, ROT0,   "Capcom", "The Punisher (US 930422)", 0 )
7443GAME( 1993, punishrj, punisher, qsound,     punisher, punisher, ROT0,   "Capcom", "The Punisher (Japan 930422)", 0 )
7444GAME( 1993, slammast, 0,        qsound,     slammast, slammast, ROT0,   "Capcom", "Saturday Night Slam Masters (World 930713)" , 0)      // "ETC"
7445GAME( 1993, slammasu, slammast, qsound,     slammast, slammast, ROT0,   "Capcom", "Saturday Night Slam Masters (US 930713)", 0 )
7446GAME( 1993, mbomberj, slammast, qsound,     slammast, slammast, ROT0,   "Capcom", "Muscle Bomber - The Body Explosion (Japan 930713)", 0 )
7447GAME( 1993, mbombrd,  slammast, qsound,     slammast, slammast, ROT0,   "Capcom", "Muscle Bomber Duo - Ultimate Team Battle (World 931206)" , 0)  // "ETC"
7448GAME( 1993, mbombrdj, slammast, qsound,     slammast, slammast, ROT0,   "Capcom", "Muscle Bomber Duo - Heat Up Warriors (Japan 931206)", 0 )
74437449
7444GAME( 1994, pnickj,   0,        cps1,    pnickj,   cps1,     ROT0,   "Compile (Capcom license)", "Pnickies (Japan 940608)", 0 )
7450GAME( 1994, pnickj,   0,        cps1_10MHz, pnickj,   cps1,     ROT0,   "Compile (Capcom license)", "Pnickies (Japan 940608)", 0 )
74457451/* Japanese version of Pang 3 is encrypted, Euro version is not */
7446GAME( 1995, pang3,    0,        pang3,    pang3,    cps1,     ROT0,   "Mitchell", "Pang! 3 (Euro 950511)", 0 )
7447GAME( 1995, pang3j,   pang3,    pang3,    pang3,    pang3,    ROT0,   "Mitchell", "Pang! 3 (Japan 950511)", 0 )
7452GAME( 1995, pang3,    0,        pang3,      pang3,    pang3,    ROT0,   "Mitchell", "Pang! 3 (Euro 950511)", 0 )
7453GAME( 1995, pang3j,   pang3,    pang3,      pang3,    pang3j,   ROT0,   "Mitchell", "Pang! 3 (Japan 950511)", 0 )
src/mame/drivers/nova2001.c
r2375r2376
135135
136136static READ8_HANDLER( ninjakun_io_A002_r )
137137{
138   return ninjakun_io_a002_ctrl | readinputport(2); /* vblank */
138   return ninjakun_io_a002_ctrl | input_port_read_indexed(machine, 2); /* vblank */
139139}
140140
141141static WRITE8_HANDLER( ninjakun_cpu1_io_A002_w )
src/mame/drivers/stactics.c
r2375r2376
7878}
7979
8080
81static void move_motor(stactics_state *state)
81static void move_motor(running_machine *machine, stactics_state *state)
8282{
8383    /* monitor motor under joystick control */
8484    if (*state->motor_on & 0x01)
8585    {
86      int ip3 = readinputport(3);
87      int ip4 = readinputport(4);
86      int ip3 = input_port_read_indexed(machine, 3);
87      int ip4 = input_port_read_indexed(machine, 4);
8888
8989      /* up */
9090      if (((ip4 & 0x01) == 0) && (state->vert_pos > -128))
r2375r2376
157157{
158158   stactics_state *state = machine->driver_data;
159159
160   move_motor(state);
160   move_motor(machine, state);
161161
162162    cpunum_set_input_line(machine, 0, 0, HOLD_LINE);
163163}
src/mame/drivers/gaelco3d.c
r2375r2376
354354 *
355355 *************************************/
356356
357static READ32_HANDLER( input_port_0_020_r ) { return readinputport(0) << 16; }
358static READ32_HANDLER( input_port_1_020_r ) { return readinputport(1) << 16; }
359static READ32_HANDLER( input_port_2_020_r ) { return readinputport(2) << 16; }
360static READ32_HANDLER( input_port_3_020_r ) { return readinputport(3) << 16; }
357static READ32_HANDLER( input_port_0_020_r ) { return input_port_read_indexed(machine, 0) << 16; }
358static READ32_HANDLER( input_port_1_020_r ) { return input_port_read_indexed(machine, 1) << 16; }
359static READ32_HANDLER( input_port_2_020_r ) { return input_port_read_indexed(machine, 2) << 16; }
360static READ32_HANDLER( input_port_3_020_r ) { return input_port_read_indexed(machine, 3) << 16; }
361361
362362
363363static CUSTOM_INPUT( analog_bit_r )
r2375r2376
393393   {
394394      if (!(data & 0xff))
395395      {
396         analog_ports[0] = readinputportbytag_safe("ANALOG0", 0);
397         analog_ports[1] = readinputportbytag_safe("ANALOG1", 0);
398         analog_ports[2] = readinputportbytag_safe("ANALOG2", 0);
399         analog_ports[3] = readinputportbytag_safe("ANALOG3", 0);
396         analog_ports[0] = input_port_read_safe(machine, "ANALOG0", 0);
397         analog_ports[1] = input_port_read_safe(machine, "ANALOG1", 0);
398         analog_ports[2] = input_port_read_safe(machine, "ANALOG2", 0);
399         analog_ports[3] = input_port_read_safe(machine, "ANALOG3", 0);
400400      }
401401   }
402402   else
src/mame/drivers/namcos11.c
r2375r2376
575575   UINT16 n_coin;
576576   UINT32 n_input;
577577
578   n_input = ( readinputportbytag( "PLAYER1" ) << 16 );
578   n_input = ( input_port_read(machine, "PLAYER1" ) << 16 );
579579   SHRAM( 0xbd00 ) = n_input | ( ( n_input & ~SHRAM( 0xbd00 ) ) >> 8 ) | ( SHRAM( 0xbd00 ) & 0x0000ffff );
580580
581   n_input = readinputportbytag( "PLAYER2" ) | ( readinputportbytag( "PLAYER3" ) << 16 );
581   n_input = input_port_read(machine, "PLAYER2" ) | ( input_port_read(machine, "PLAYER3" ) << 16 );
582582   SHRAM( 0xbd04 ) = n_input | ( ( n_input & ~SHRAM( 0xbd04 ) ) >> 8 );
583583
584   n_input = readinputportbytag( "PLAYER4" );
584   n_input = input_port_read(machine, "PLAYER4" );
585585   SHRAM( 0xbd08 ) = n_input | ( ( n_input & ~SHRAM( 0xbd08 ) ) >> 8 ) | ( SHRAM( 0xbd08 ) & 0xffff0000 );
586586
587   n_coin = readinputportbytag( "COIN" );
587   n_coin = input_port_read(machine, "COIN" );
588588
589589   if( ( n_coin & m_n_oldcoin & 0x08 ) != 0 )
590590   {
r2375r2376
627627
628628      SHRAM( 0xbd30 ) = ( SHRAM( 0xbd30 ) & 0x0000ffff ) | ( 0x0080 << 16 );
629629
630      SHRAM( 0xbd08 ) = ( SHRAM( 0xbd08 ) & 0x0000ffff ) | ( readinputportbytag( "STEERING" ) << 16 );
631      SHRAM( 0xbd0c ) = ( SHRAM( 0xbd0c ) & 0xffff0000 ) | ( readinputportbytag( "GAS" ) << 0 );
630      SHRAM( 0xbd08 ) = ( SHRAM( 0xbd08 ) & 0x0000ffff ) | ( input_port_read(machine,  "STEERING" ) << 16 );
631      SHRAM( 0xbd0c ) = ( SHRAM( 0xbd0c ) & 0xffff0000 ) | ( input_port_read(machine,  "GAS" ) << 0 );
632632   }
633633}
634634
635635static TIMER_CALLBACK( mcu_timer )
636636{
637   SHRAM( 0xbd00 ) = ( SHRAM( 0xbd00 ) & 0xffffff00 ) | readinputportbytag( "SWITCH" );
637   SHRAM( 0xbd00 ) = ( SHRAM( 0xbd00 ) & 0xffffff00 ) | input_port_read(machine, "SWITCH" );
638638}
639639
640640static UINT32 m_n_bankoffset;
r2375r2376
715715   switch( offset )
716716   {
717717   case 0:
718      data = readinputportbytag( "GUN1X" );
718      data = input_port_read(machine, "GUN1X" );
719719      break;
720720   case 1:
721      data = ( readinputportbytag( "GUN1Y" ) ) | ( ( readinputportbytag( "GUN1Y" ) + 1 ) << 16 );
721      data = ( input_port_read(machine, "GUN1Y" ) ) | ( ( input_port_read(machine, "GUN1Y" ) + 1 ) << 16 );
722722      break;
723723   case 2:
724      data = readinputportbytag( "GUN2X" );
724      data = input_port_read(machine, "GUN2X" );
725725      break;
726726   case 3:
727      data = ( readinputportbytag( "GUN2Y" ) ) | ( ( readinputportbytag( "GUN2Y" ) + 1 ) << 16 );
727      data = ( input_port_read(machine, "GUN2Y" ) ) | ( ( input_port_read(machine, "GUN2Y" ) + 1 ) << 16 );
728728      break;
729729   }
730730   verboselog( 2, "lightgun_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
r2375r2376
800800   timer = timer_alloc( mcu_timer , NULL);
801801   timer_adjust_periodic( timer, ATTOTIME_IN_HZ( 600 ), 0, ATTOTIME_IN_HZ( 600 ) );
802802
803   psx_driver_init();
803   psx_driver_init(machine);
804804   namcoc7x_on_driver_init();
805805   namcoc7x_set_host_ram(namcos11_sharedram);
806806
src/mame/drivers/lethalj.c
r2375r2376
7070
7171static CUSTOM_INPUT( cclownz_paddle )
7272{
73   int value = readinputportbytag("PADDLE");
73   int value = input_port_read(machine, "PADDLE");
7474   return ((value << 4) & 0xf00) | (value & 0x00f);
7575}
7676
src/mame/drivers/itech8.c
r2375r2376
714714/* used by most games */
715715static READ8_HANDLER( special_port0_r )
716716{
717   UINT8 result = readinputport(0);
717   UINT8 result = input_port_read_indexed(machine, 0);
718718   result = (result & 0xfe) | (pia_portb_data & 0x01);
719719   return result;
720720}
r2375r2376
723723/* used by Rim Rockin' Basketball */
724724static READ8_HANDLER( special_port1_r )
725725{
726   UINT8 result = readinputport(1);
726   UINT8 result = input_port_read_indexed(machine, 1);
727727   result = (result & 0x7f) | ((pia_portb_data & 0x01) << 7);
728728   return result;
729729}
src/mame/drivers/galaxian.c
r2375r2376
360360static READ8_HANDLER( konami_porta_0_r )
361361{
362362//  logerror("%04X:ppi0_porta_r\n", activecpu_get_pc());
363   return readinputportbytag("IN0");
363   return input_port_read(machine, "IN0");
364364}
365365
366366
367367static READ8_HANDLER( konami_portb_0_r )
368368{
369369//  logerror("%04X:ppi0_portb_r\n", activecpu_get_pc());
370   return readinputportbytag("IN1");
370   return input_port_read(machine, "IN1");
371371}
372372
373373
374374static READ8_HANDLER( konami_portc_0_r )
375375{
376376   logerror("%04X:ppi0_portc_r\n", activecpu_get_pc());
377   return readinputportbytag("IN2");
377   return input_port_read(machine, "IN2");
378378}
379379
380380
381381static READ8_HANDLER( konami_portc_1_r )
382382{
383383   logerror("%04X:ppi1_portc_r\n", activecpu_get_pc());
384   return readinputportbytag("IN3");
384   return input_port_read(machine, "IN3");
385385}
386386
387387
r2375r2376
761761   const char *portname = param;
762762   if (gmgalax_selected_game != 0)
763763      portname += strlen(portname) + 1;
764   return readinputportbytag(portname);
764   return input_port_read(machine, portname);
765765}
766766
767767
r2375r2376
817817
818818static CUSTOM_INPUT( azurian_port_r )
819819{
820   return (readinputportbytag("FAKE") >> (FPTR)param) & 1;
820   return (input_port_read(machine, "FAKE") >> (FPTR)param) & 1;
821821}
822822
823823
r2375r2376
831831static CUSTOM_INPUT( kingball_muxbit_r )
832832{
833833   /* multiplex the service mode switch with a speech DIP switch */
834   return (readinputportbytag("FAKE") >> kingball_speech_dip) & 1;
834   return (input_port_read(machine, "FAKE") >> kingball_speech_dip) & 1;
835835}
836836
837837
src/mame/drivers/bbusters.c
r2375r2376
211211static MACHINE_RESET( bbusters )
212212{
213213   UINT16 *RAM = (UINT16 *)memory_region(REGION_CPU1);
214   int data = readinputportbytag("FAKE1") & 0x03;
214   int data = input_port_read(machine, "FAKE1") & 0x03;
215215
216216   /* Country/Version :
217217         - 0x0000 : Japan?
r2375r2376
230230static MACHINE_RESET( mechatt )
231231{
232232   UINT16 *RAM = (UINT16 *)memory_region(REGION_CPU1);
233   int data = readinputportbytag("FAKE1") & 0x03;
233   int data = input_port_read(machine, "FAKE1") & 0x03;
234234
235235   /* Country :
236236         - 0x0000 : Japan
r2375r2376
260260
261261static READ16_HANDLER( control_3_r )
262262{
263   return readinputport(gun_select);
263   return input_port_read_indexed(machine, gun_select);
264264}
265265
266266static WRITE16_HANDLER( gun_select_w )
r2375r2376
272272
273273static READ16_HANDLER( kludge_r )
274274{
275   bbuster_ram[0xa692/2]=readinputportbytag("IN5")<<1;
276   bbuster_ram[0xa694/2]=readinputportbytag("IN6")<<1;
277   bbuster_ram[0xa696/2]=readinputportbytag("IN7")<<1;
278   bbuster_ram[0xa698/2]=readinputportbytag("IN8")<<1;
279   bbuster_ram[0xa69a/2]=readinputportbytag("IN9")<<1;
280   bbuster_ram[0xa69c/2]=readinputportbytag("IN10")<<1;
275   bbuster_ram[0xa692/2]=input_port_read(machine, "IN5")<<1;
276   bbuster_ram[0xa694/2]=input_port_read(machine, "IN6")<<1;
277   bbuster_ram[0xa696/2]=input_port_read(machine, "IN7")<<1;
278   bbuster_ram[0xa698/2]=input_port_read(machine, "IN8")<<1;
279   bbuster_ram[0xa69a/2]=input_port_read(machine, "IN9")<<1;
280   bbuster_ram[0xa69c/2]=input_port_read(machine, "IN10")<<1;
281281   return 0;
282282}
283283
r2375r2376
292292   int baseport=2,x,y;
293293   if (offset) baseport=4; /* Player 2 */
294294
295   x=readinputport(baseport);
296   y=readinputport(baseport+1);
295   x=input_port_read_indexed(machine, baseport);
296   y=input_port_read_indexed(machine, baseport+1);
297297
298298   /* Todo - does the hardware really clamp like this? */
299299   x+=0x18;
src/mame/drivers/snk.c
r2375r2376
290290/*********************************************************************/
291291
292292
293static int snk_rot( int which ){
293static int snk_rot( running_machine *machine, int which ){
294294   static int last_value[2] = {0, 0};
295295   static int cp_count[2] = {0, 0};
296296   int bttn;
297   int value = readinputport(which + 1);
297   int value = input_port_read_indexed(machine, which + 1);
298298
299299   /* For Guerilla War we add a 0xf0 value for 1 input read once every 8 rotations.
300300     * 0xf0 isn't a valid direction, but avoids the "joystick error" protection
r2375r2376
325325         return value;
326326      }
327327
328      case SNK_ROT_PLAYER1: return snk_rot( 0 );
329      case SNK_ROT_PLAYER2: return snk_rot( 1 );
328      case SNK_ROT_PLAYER1: return snk_rot( machine, 0 );
329      case SNK_ROT_PLAYER2: return snk_rot( machine, 1 );
330330
331      case SNK_INP1: return input_port_1_r(machine,0);
332      case SNK_INP2: return input_port_2_r(machine,0);
333      case SNK_INP3: return input_port_3_r(machine,0);
334      case SNK_INP4: return input_port_4_r(machine,0);
335      case SNK_INP5: return input_port_5_r(machine,0);
336      case SNK_INP6: return input_port_6_r(machine,0);
337      case SNK_INP7: return input_port_7_r(machine,0);
338      case SNK_INP8: return input_port_8_r(machine,0);
339      case SNK_INP9: return input_port_9_r(machine,0);
340      case SNK_INP10: return input_port_10_r(machine,0);
341      case SNK_INP11: return input_port_11_r(machine,0);
331      case SNK_INP1: return input_port_read_indexed(machine, 1);
332      case SNK_INP2: return input_port_read_indexed(machine, 2);
333      case SNK_INP3: return input_port_read_indexed(machine, 3);
334      case SNK_INP4: return input_port_read_indexed(machine, 4);
335      case SNK_INP5: return input_port_read_indexed(machine, 5);
336      case SNK_INP6: return input_port_read_indexed(machine, 6);
337      case SNK_INP7: return input_port_read_indexed(machine, 7);
338      case SNK_INP8: return input_port_read_indexed(machine, 8);
339      case SNK_INP9: return input_port_read_indexed(machine, 9);
340      case SNK_INP10: return input_port_read_indexed(machine, 10);
341      case SNK_INP11: return input_port_read_indexed(machine, 11);
342342
343343      default:
344344      logerror("read from unmapped input port:%d\n", which );
src/mame/drivers/namconb1.c
r2375r2376
664664
665665   switch( offset )
666666   {
667   case 0: case 1: result = (UINT8)(0x0f+readinputport(7)*224/255); break; /* Y (p2) */
668   case 2: case 3: result = (UINT8)(0x26+readinputport(6)*288/314); break; /* X (p2) */
669   case 4: case 5: result = (UINT8)(0x0f+readinputport(5)*224/255); break; /* Y (p1) */
670   case 6: case 7: result = (UINT8)(0x26+readinputport(4)*288/314); break; /* X (p1) */
667   case 0: case 1: result = (UINT8)(0x0f+input_port_read_indexed(machine, 7)*224/255); break; /* Y (p2) */
668   case 2: case 3: result = (UINT8)(0x26+input_port_read_indexed(machine, 6)*288/314); break; /* X (p2) */
669   case 4: case 5: result = (UINT8)(0x0f+input_port_read_indexed(machine, 5)*224/255); break; /* Y (p1) */
670   case 6: case 7: result = (UINT8)(0x26+input_port_read_indexed(machine, 4)*288/314); break; /* X (p1) */
671671   }
672672   return result<<24;
673673} /* gunbulet_gun_r */
src/mame/drivers/flstory.c
r2375r2376
163163
164164static READ8_HANDLER( victnine_port_5_r )
165165{
166   return (victnine_mcu_status_r(machine,0) & 3) | (readinputport(5) & ~3);
166   return (victnine_mcu_status_r(machine,0) & 3) | (input_port_read_indexed(machine, 5) & ~3);
167167}
168168
169169static ADDRESS_MAP_START( victnine_map, ADDRESS_SPACE_PROGRAM, 8 )
src/mame/drivers/fcrash.c
r2375r2376
122122   }
123123}
124124
125static void fcrash_build_palette(running_machine *machine)
126{
127   int offset;
128
129   for (offset = 0; offset < 32*6*16; offset++)
130   {
131      int palette = cps1_gfxram[0x14000/2 + offset];
132      int r, g, b, bright;
133
134      // from my understanding of the schematics, when the 'brightness'
135      // component is set to 0 it should reduce brightness to 1/3
136
137      bright = 0x0f + ((palette>>12)<<1);
138
139      r = ((palette>>8)&0x0f) * 0x11 * bright / 0x2d;
140      g = ((palette>>4)&0x0f) * 0x11 * bright / 0x2d;
141      b = ((palette>>0)&0x0f) * 0x11 * bright / 0x2d;
142
143      palette_set_color (machine, offset, MAKE_RGB(r, g, b));
144   }
145}
146
125147static VIDEO_UPDATE( fcrash )
126148{
127149      int layercontrol,l0,l1,l2,l3;
r2375r2376
136158   cps1_get_video_base();
137159
138160   /* Build palette */
139   cps1_build_palette(screen->machine);
161   fcrash_build_palette(screen->machine);
140162
141163   fcrash_update_transmasks();
142164
r2375r2376
172194   tilemap_set_enable(cps1_bg_tilemap[2],1);
173195
174196   /* Blank screen */
175   fillbitmap(bitmap,4095,cliprect);
197   fillbitmap(bitmap,0xbff,cliprect);
176198
177199   fillbitmap(priority_bitmap,0,cliprect);
178200   l0 = (layercontrol >> 0x06) & 03;
src/mame/drivers/calomega.c
r2375r2376
10501050{
10511051   switch( mux_data&0xf0 )   /* bits 4-7 */
10521052   {
1053      case 0x10: return input_port_0_r(machine,0);
1054      case 0x20: return input_port_1_r(machine,0);
1055      case 0x40: return input_port_2_r(machine,0);
1056      case 0x80: return input_port_3_r(machine,0);
1053      case 0x10: return input_port_read_indexed(machine, 0);
1054      case 0x20: return input_port_read_indexed(machine, 1);
1055      case 0x40: return input_port_read_indexed(machine, 2);
1056      case 0x80: return input_port_read_indexed(machine, 3);
10571057   }
10581058   return 0xff;
10591059}
src/mame/drivers/atetris.c
r2375r2376
110110}
111111
112112
113static STATE_POSTLOAD( atetris_postload )
114{
115   reset_bank();
116}
117
118
113119static MACHINE_START( atetris )
114120{
115121   /* Allocate interrupt timer */
r2375r2376
118124   /* Set up save state */
119125   state_save_register_global(current_bank);
120126   state_save_register_global(nvram_write_enable);
121   state_save_register_func_postload(reset_bank);
127   state_save_register_postload(machine, atetris_postload, NULL);
122128}
123129
124130
src/mame/drivers/cosmic.c
r2375r2376
189189        /* mostly not noticed since sound is */
190190      /* only enabled if game in progress! */
191191
192       if ((input_port_3_r(machine,0) & 0xc0) != 0xc0)
192       if ((input_port_read_indexed(machine, 3) & 0xc0) != 0xc0)
193193           panic_sound_output_w(machine,17,1);
194194
195195      cpunum_set_input_line_and_vector(machine, 0, 0, HOLD_LINE, 0xcf);   /* RST 08h */
r2375r2376
204204
205205    if (pixel_clock == 0)
206206    {
207      if (readinputport(3) & 1)   /* Left Coin */
207      if (input_port_read_indexed(machine, 3) & 1)   /* Left Coin */
208208         cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
209209    }
210210}
r2375r2376
218218    It makes sense and works fine, but I cannot be 100% sure this is correct,
219219    as I have no Cosmic Guerilla console :-) . */
220220
221   if ((readinputport(2) & 1)) /* Coin */
221   if ((input_port_read_indexed(machine, 2) & 1)) /* Coin */
222222      /* on tms9980, a 6 on the interrupt bus means level 4 interrupt */
223223      cpunum_set_input_line_and_vector(machine, 0, 0, ASSERT_LINE, 6);
224224   else
r2375r2376
228228static INTERRUPT_GEN( magspot_interrupt )
229229{
230230   /* Coin 1 causes an IRQ, Coin 2 an NMI */
231   if (input_port_4_r(machine,0) & 0x01)
231   if (input_port_read_indexed(machine, 4) & 0x01)
232232        cpunum_set_input_line(machine, 0, 0, HOLD_LINE);
233   else if (input_port_4_r(machine,0) & 0x02)
233   else if (input_port_read_indexed(machine, 4) & 0x02)
234234      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
235235}
236236
237237static INTERRUPT_GEN( nomnlnd_interrupt )
238238{
239239   /* Coin causes an NMI */
240   if (input_port_4_r(machine,0) & 0x01)
240   if (input_port_read_indexed(machine, 4) & 0x01)
241241      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
242242}
243243
r2375r2376
252252{
253253   /* The top four address lines from the CRTC are bits 0-3 */
254254
255   return (input_port_0_r(machine,0) & 0xf0) | ((video_screen_get_vpos(machine->primary_screen) & 0xf0) >> 4);
255   return (input_port_read_indexed(machine, 0) & 0xf0) | ((video_screen_get_vpos(machine->primary_screen) & 0xf0) >> 4);
256256}
257257
258258static READ8_HANDLER( magspot_coinage_dip_r )
259259{
260   return (input_port_5_r(machine,0) & (1 << (7 - offset))) ? 0 : 1;
260   return (input_port_read_indexed(machine, 5) & (1 << (7 - offset))) ? 0 : 1;
261261}
262262
263263
r2375r2376
266266static READ8_HANDLER( nomnlnd_port_0_1_r )
267267{
268268   int control;
269    int fire = input_port_3_r(machine,0);
269    int fire = input_port_read_indexed(machine, 3);
270270
271271   if (offset)
272      control = input_port_1_r(machine,0);
272      control = input_port_read_indexed(machine, 1);
273273    else
274      control = input_port_0_r(machine,0);
274      control = input_port_read_indexed(machine, 0);
275275
276276    /* If firing - stop tank */
277277
src/mame/drivers/model2.c
r2375r2376
433433
434434static READ32_HANDLER(ctrl0_r)
435435{
436   UINT32 ret = readinputport(0);
436   UINT32 ret = input_port_read_indexed(machine, 0);
437437   ret <<= 16;
438438   if(model2_ctrlmode==0)
439439   {
r2375r2376
447447}
448448static READ32_HANDLER(ctrl1_r)
449449{
450   return readinputport(1) | readinputport(2)<<16;
450   return input_port_read_indexed(machine, 1) | input_port_read_indexed(machine, 2)<<16;
451451}
452452
453453static READ32_HANDLER(ctrl10_r)
454454{
455   return readinputport(0) | readinputport(1)<<16;
455   return input_port_read_indexed(machine, 0) | input_port_read_indexed(machine, 1)<<16;
456456}
457457
458458static READ32_HANDLER(ctrl14_r)
459459{
460   return readinputport(2);
460   return input_port_read_indexed(machine, 2);
461461}
462462
463463static READ32_HANDLER(analog_r)
464464{
465465   if (offset)
466      return readinputport(5);
466      return input_port_read_indexed(machine, 5);
467467
468   return readinputport(3) | readinputport(4)<<16;
468   return input_port_read_indexed(machine, 3) | input_port_read_indexed(machine, 4)<<16;
469469}
470470
471471static READ32_HANDLER(fifoctl_r)
src/mame/drivers/bmcbowl.c
r2375r2376
225225
226226static READ8_HANDLER(via_b_in)
227227{
228   return input_port_3_r(machine,0);
228   return input_port_read_indexed(machine, 3);
229229}
230230
231231
r2375r2376
447447{
448448   switch(bmc_input)
449449   {
450         case 0x00:   return  input_port_1_r(machine,0);
451         case 0x40:   return  input_port_2_r(machine,0);
450         case 0x00:   return  input_port_read_indexed(machine, 1);
451         case 0x40:   return  input_port_read_indexed(machine, 2);
452452   }
453453   logerror("unknown input - %X (PC=%X)\n",bmc_input,activecpu_get_previouspc());
454454   return 0xff;
src/mame/drivers/sshangha.c
r2375r2376
9999   switch (offset)
100100   {
101101      case 0x050 >> 1: /* Player 1 & Player 2 joysticks & fire buttons */
102         return (readinputport(0) + (readinputport(1) << 8));
102         return (input_port_read_indexed(machine, 0) + (input_port_read_indexed(machine, 1) << 8));
103103      case 0x76a >> 1: /* Credits */
104         return readinputport(2);
104         return input_port_read_indexed(machine, 2);
105105      case 0x0ac >> 1: /* DIPS */
106         return (readinputport(3) + (readinputport(4) << 8));
106         return (input_port_read_indexed(machine, 3) + (input_port_read_indexed(machine, 4) << 8));
107107
108108      // Protection TODO
109109   }
r2375r2376
117117   switch (offset)
118118   {
119119      case 0x050 >> 1: /* Player 1 & Player 2 joysticks & fire buttons */
120         return (readinputport(0) + (readinputport(1) << 8));
120         return (input_port_read_indexed(machine, 0) + (input_port_read_indexed(machine, 1) << 8));
121121      case 0x76a >> 1: /* Credits */
122         return readinputport(2);
122         return input_port_read_indexed(machine, 2);
123123      case 0x0ac >> 1: /* DIPS */
124         return (readinputport(3) + (readinputport(4) << 8));
124         return (input_port_read_indexed(machine, 3) + (input_port_read_indexed(machine, 4) << 8));
125125   }
126126   return sshangha_prot_data[offset];
127127}
src/mame/drivers/wiping.c
r2375r2376
7979
8080   res = 0;
8181   for (i = 0;i < 8;i++)
82      res |= ((readinputport(i) >> offset) & 1) << i;
82      res |= ((input_port_read_indexed(machine, i) >> offset) & 1) << i;
8383
8484   return res;
8585}
src/mame/drivers/lazercmd.c
r2375r2376
286286static READ8_HANDLER( lazercmd_data_port_r )
287287{
288288   int data;
289   data = input_port_2_r(machine,0) & 0x0f;
289   data = input_port_read_indexed(machine, 2) & 0x0f;
290290   return data;
291291}
292292
r2375r2376
381381   switch (offset)
382382   {
383383      case 0:             /* player 1 joysticks */
384         data = input_port_0_r(machine,0);
384         data = input_port_read_indexed(machine, 0);
385385         break;
386386      case 1:             /* player 2 joysticks */
387         data = input_port_1_r(machine,0);
387         data = input_port_read_indexed(machine, 1);
388388         break;
389389      case 2:             /* player 1 + 2 buttons */
390         data = input_port_4_r(machine,0);
390         data = input_port_read_indexed(machine, 4);
391391         break;
392392      case 3:             /* coin slot + start buttons */
393         data = input_port_3_r(machine,0);
393         data = input_port_read_indexed(machine, 3);
394394         break;
395395      case 4:             /* vertical scan counter */
396396         data = ((timer_count&0x10)>>1)|((timer_count&0x20)>>3)|((timer_count&0x40)>>5)|((timer_count&0x80)>>7);
src/mame/drivers/taxidrvr.c
r2375r2376
6161
6262static READ8_HANDLER( p1c_r )
6363{
64   return (s2 << 7) | (s4 << 6) | ((readinputportbytag("IN2") & 1) << 4);
64   return (s2 << 7) | (s4 << 6) | ((input_port_read(machine, "IN2") & 1) << 4);
6565}
6666
6767static WRITE8_HANDLER( p1a_w )
src/mame/drivers/blockade.c
r2375r2376
6767{
6868   cpunum_resume(0, SUSPEND_ANY_REASON);
6969
70   if ((input_port_0_r(machine,0) & 0x80) == 0)
70   if ((input_port_read_indexed(machine, 0) & 0x80) == 0)
7171   {
7272      just_been_reset = 1;
7373      cpunum_set_input_line(machine, 0, INPUT_LINE_RESET, PULSE_LINE);
r2375r2376
7878{
7979    /* coin latch is bit 7 */
8080
81    UINT8 temp = (input_port_0_r(machine,0)&0x7f);
81    UINT8 temp = (input_port_read_indexed(machine, 0)&0x7f);
8282    return (coin_latch<<7) | (temp);
8383}
8484
src/mame/drivers/cps2.c
r2375r2376
848848static READ16_HANDLER( joy_or_paddle_r )
849849{
850850   if (readpaddle != 0)
851      return (readinputportbytag("IN0"));
851      return (input_port_read(machine, "IN0"));
852852   else
853      return (readinputportbytag("PADDLE1") & 0xff) | (readinputportbytag("PADDLE2") << 8);
853      return (input_port_read(machine, "PADDLE1") & 0xff) | (input_port_read(machine, "PADDLE2") << 8);
854854}
855855
856856
r2375r2376
12891289   ROM_LOAD16_WORD_SWAP( "nff.04",  0x080000, 0x80000, CRC(dba1c66e) SHA1(4764e77d4da5d19d9acded27df1e1bcba06b0fcf) )
12901290   ROM_LOAD16_WORD_SWAP( "nffu.05", 0x100000, 0x80000, CRC(ea813eb7) SHA1(34e0175a5f22d08c3538369b4bfd077a7427a128) )
12911291
1292   ROM_REGION( 0x2000000, REGION_GFX1, 0 )
1292   ROM_REGION( 0x1400000, REGION_GFX1, 0 )
12931293   ROMX_LOAD( "nff.13m",   0x0000000, 0x400000, CRC(c9fca741) SHA1(1781d4fc18b6d6f79b7b39d9bcace750fb61a5cf) , ROM_GROUPWORD | ROM_SKIP(6) )
12941294   ROMX_LOAD( "nff.15m",   0x0000002, 0x400000, CRC(f809d898) SHA1(a0b6af49e1780678d808c317b875161cedddb314) , ROM_GROUPWORD | ROM_SKIP(6) )
12951295   ROMX_LOAD( "nff.17m",   0x0000004, 0x400000, CRC(15ba4507) SHA1(bed6a82bf1dc1aa501d4c2d098115a15e18d446a) , ROM_GROUPWORD | ROM_SKIP(6) )
r2375r2376
13141314   ROM_LOAD16_WORD_SWAP( "nff.04",  0x080000, 0x80000, CRC(dba1c66e) SHA1(4764e77d4da5d19d9acded27df1e1bcba06b0fcf) )
13151315   ROM_LOAD16_WORD_SWAP( "nffj.05", 0x100000, 0x80000, CRC(7f20c2ef) SHA1(380dc54d94c29c049a4c00ed58013e04eec87086) )
13161316
1317   ROM_REGION( 0x2000000, REGION_GFX1, 0 )
1317   ROM_REGION( 0x1400000, REGION_GFX1, 0 )
13181318   ROMX_LOAD( "nff.13m",   0x0000000, 0x400000, CRC(c9fca741) SHA1(1781d4fc18b6d6f79b7b39d9bcace750fb61a5cf) , ROM_GROUPWORD | ROM_SKIP(6) )
13191319   ROMX_LOAD( "nff.15m",   0x0000002, 0x400000, CRC(f809d898) SHA1(a0b6af49e1780678d808c317b875161cedddb314) , ROM_GROUPWORD | ROM_SKIP(6) )
13201320   ROMX_LOAD( "nff.17m",   0x0000004, 0x400000, CRC(15ba4507) SHA1(bed6a82bf1dc1aa501d4c2d098115a15e18d446a) , ROM_GROUPWORD | ROM_SKIP(6) )
r2375r2376
19261926
19271927   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
19281928   ROM_FILL(              0x000000, 0x800000, 0 )
1929   ROMX_LOAD( "csc.14m",   0x800000, 0x200000, CRC(e8904afa) SHA1(39713ffca4e3a754c7c44c0ef4d99fb5a77d8da7) , ROM_GROUPWORD | ROM_SKIP(6) ) /* roms 73 to 76 joined in all eprom version */
1930   ROMX_LOAD( "csc.16m",   0x800002, 0x200000, CRC(c98c8079) SHA1(22d68ba2ef62b51981bb3e99ec2cde8d1b36514b) , ROM_GROUPWORD | ROM_SKIP(6) ) /* roms 63 to 66 joined in all eprom version */
1931   ROMX_LOAD( "csc.18m",   0x800004, 0x200000, CRC(c030df5a) SHA1(6d5e5a05531e168d0d44c591f9185ae300908fc2) , ROM_GROUPWORD | ROM_SKIP(6) ) /* roms 83 to 86 joined in all eprom version */
1932   ROMX_LOAD( "csc.20m",   0x800006, 0x200000, CRC(b4e55863) SHA1(da66f0a36266b906e4c149aec152c323bb184c57) , ROM_GROUPWORD | ROM_SKIP(6) ) /* roms 93 to 96 joined in all eprom version */
1929   ROMX_LOAD( "csc.14m",  0x800000, 0x200000, CRC(e8904afa) SHA1(39713ffca4e3a754c7c44c0ef4d99fb5a77d8da7) , ROM_GROUPWORD | ROM_SKIP(6) ) /* roms 73 to 76 joined in all eprom version */
1930   ROMX_LOAD( "csc.16m",  0x800002, 0x200000, CRC(c98c8079) SHA1(22d68ba2ef62b51981bb3e99ec2cde8d1b36514b) , ROM_GROUPWORD | ROM_SKIP(6) ) /* roms 63 to 66 joined in all eprom version */
1931   ROMX_LOAD( "csc.18m",  0x800004, 0x200000, CRC(c030df5a) SHA1(6d5e5a05531e168d0d44c591f9185ae300908fc2) , ROM_GROUPWORD | ROM_SKIP(6) ) /* roms 83 to 86 joined in all eprom version */
1932   ROMX_LOAD( "csc.20m",  0x800006, 0x200000, CRC(b4e55863) SHA1(da66f0a36266b906e4c149aec152c323bb184c57) , ROM_GROUPWORD | ROM_SKIP(6) ) /* roms 93 to 96 joined in all eprom version */
19331933
19341934   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
19351935   ROM_LOAD( "csc.01",   0x00000, 0x08000, CRC(ee162111) SHA1(ce8d4bd32bb10ee8b0274ba6fcef05a583b39d48) )
r2375r2376
19501950
19511951   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
19521952   ROM_FILL(              0x000000, 0x800000, 0 )
1953   ROMX_LOAD( "csc.14m",   0x800000, 0x200000, CRC(e8904afa) SHA1(39713ffca4e3a754c7c44c0ef4d99fb5a77d8da7) , ROM_GROUPWORD | ROM_SKIP(6) )
1954   ROMX_LOAD( "csc.16m",   0x800002, 0x200000, CRC(c98c8079) SHA1(22d68ba2ef62b51981bb3e99ec2cde8d1b36514b) , ROM_GROUPWORD | ROM_SKIP(6) )
1955   ROMX_LOAD( "csc.18m",   0x800004, 0x200000, CRC(c030df5a) SHA1(6d5e5a05531e168d0d44c591f9185ae300908fc2) , ROM_GROUPWORD | ROM_SKIP(6) )
1956   ROMX_LOAD( "csc.20m",   0x800006, 0x200000, CRC(b4e55863) SHA1(da66f0a36266b906e4c149aec152c323bb184c57) , ROM_GROUPWORD | ROM_SKIP(6) )
1953   ROMX_LOAD( "csc.14m",  0x800000, 0x200000, CRC(e8904afa) SHA1(39713ffca4e3a754c7c44c0ef4d99fb5a77d8da7) , ROM_GROUPWORD | ROM_SKIP(6) )
1954   ROMX_LOAD( "csc.16m",  0x800002, 0x200000, CRC(c98c8079) SHA1(22d68ba2ef62b51981bb3e99ec2cde8d1b36514b) , ROM_GROUPWORD | ROM_SKIP(6) )
1955   ROMX_LOAD( "csc.18m",  0x800004, 0x200000, CRC(c030df5a) SHA1(6d5e5a05531e168d0d44c591f9185ae300908fc2) , ROM_GROUPWORD | ROM_SKIP(6) )
1956   ROMX_LOAD( "csc.20m",  0x800006, 0x200000, CRC(b4e55863) SHA1(da66f0a36266b906e4c149aec152c323bb184c57) , ROM_GROUPWORD | ROM_SKIP(6) )
19571957
19581958   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
19591959   ROM_LOAD( "csc.01",   0x00000, 0x08000, CRC(ee162111) SHA1(ce8d4bd32bb10ee8b0274ba6fcef05a583b39d48) )
r2375r2376
19741974
19751975   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
19761976   ROM_FILL(              0x000000, 0x800000, 0 )
1977   ROMX_LOAD( "csc.14m",   0x800000, 0x200000, CRC(e8904afa) SHA1(39713ffca4e3a754c7c44c0ef4d99fb5a77d8da7) , ROM_GROUPWORD | ROM_SKIP(6) )
1978   ROMX_LOAD( "csc.16m",   0x800002, 0x200000, CRC(c98c8079) SHA1(22d68ba2ef62b51981bb3e99ec2cde8d1b36514b) , ROM_GROUPWORD | ROM_SKIP(6) )
1979   ROMX_LOAD( "csc.18m",   0x800004, 0x200000, CRC(c030df5a) SHA1(6d5e5a05531e168d0d44c591f9185ae300908fc2) , ROM_GROUPWORD | ROM_SKIP(6) )
1980   ROMX_LOAD( "csc.20m",   0x800006, 0x200000, CRC(b4e55863) SHA1(da66f0a36266b906e4c149aec152c323bb184c57) , ROM_GROUPWORD | ROM_SKIP(6) )
1977   ROMX_LOAD( "csc.14m",  0x800000, 0x200000, CRC(e8904afa) SHA1(39713ffca4e3a754c7c44c0ef4d99fb5a77d8da7) , ROM_GROUPWORD | ROM_SKIP(6) )
1978   ROMX_LOAD( "csc.16m",  0x800002, 0x200000, CRC(c98c8079) SHA1(22d68ba2ef62b51981bb3e99ec2cde8d1b36514b) , ROM_GROUPWORD | ROM_SKIP(6) )
1979   ROMX_LOAD( "csc.18m",  0x800004, 0x200000, CRC(c030df5a) SHA1(6d5e5a05531e168d0d44c591f9185ae300908fc2) , ROM_GROUPWORD | ROM_SKIP(6) )
1980   ROMX_LOAD( "csc.20m",  0x800006, 0x200000, CRC(b4e55863) SHA1(da66f0a36266b906e4c149aec152c323bb184c57) , ROM_GROUPWORD | ROM_SKIP(6) )
19811981
19821982   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
19831983   ROM_LOAD( "csc.01",   0x00000, 0x08000, CRC(ee162111) SHA1(ce8d4bd32bb10ee8b0274ba6fcef05a583b39d48) )
r2375r2376
19981998
19991999   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
20002000   ROM_FILL(              0x000000, 0x800000, 0 )
2001   ROMX_LOAD( "csc.14m",   0x800000, 0x200000, CRC(e8904afa) SHA1(39713ffca4e3a754c7c44c0ef4d99fb5a77d8da7) , ROM_GROUPWORD | ROM_SKIP(6) ) /* roms 73 to 76 joined in all eprom version */
2002   ROMX_LOAD( "csc.16m",   0x800002, 0x200000, CRC(c98c8079) SHA1(22d68ba2ef62b51981bb3e99ec2cde8d1b36514b) , ROM_GROUPWORD | ROM_SKIP(6) ) /* roms 63 to 66 joined in all eprom version */
2003   ROMX_LOAD( "csc.18m",   0x800004, 0x200000, CRC(c030df5a) SHA1(6d5e5a05531e168d0d44c591f9185ae300908fc2) , ROM_GROUPWORD | ROM_SKIP(6) ) /* roms 83 to 86 joined in all eprom version */
2004   ROMX_LOAD( "csc.20m",   0x800006, 0x200000, CRC(b4e55863) SHA1(da66f0a36266b906e4c149aec152c323bb184c57) , ROM_GROUPWORD | ROM_SKIP(6) ) /* roms 93 to 96 joined in all eprom version */
2001   ROMX_LOAD( "csc.14m",  0x800000, 0x200000, CRC(e8904afa) SHA1(39713ffca4e3a754c7c44c0ef4d99fb5a77d8da7) , ROM_GROUPWORD | ROM_SKIP(6) ) /* roms 73 to 76 joined in all eprom version */
2002   ROMX_LOAD( "csc.16m",  0x800002, 0x200000, CRC(c98c8079) SHA1(22d68ba2ef62b51981bb3e99ec2cde8d1b36514b) , ROM_GROUPWORD | ROM_SKIP(6) ) /* roms 63 to 66 joined in all eprom version */
2003   ROMX_LOAD( "csc.18m",  0x800004, 0x200000, CRC(c030df5a) SHA1(6d5e5a05531e168d0d44c591f9185ae300908fc2) , ROM_GROUPWORD | ROM_SKIP(6) ) /* roms 83 to 86 joined in all eprom version */
2004   ROMX_LOAD( "csc.20m",  0x800006, 0x200000, CRC(b4e55863) SHA1(da66f0a36266b906e4c149aec152c323bb184c57) , ROM_GROUPWORD | ROM_SKIP(6) ) /* roms 93 to 96 joined in all eprom version */
20052005
20062006   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
20072007   ROM_LOAD( "csc.01",   0x00000, 0x08000, CRC(ee162111) SHA1(ce8d4bd32bb10ee8b0274ba6fcef05a583b39d48) )
r2375r2376
32223222
32233223   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
32243224   ROM_FILL(              0x000000, 0x800000, 0 )
3225   ROMX_LOAD( "rm2.14m",   0x800000, 0x200000, CRC(9b1f00b4) SHA1(c1c5c2d9d00121425ae6598444d704f420ef4eef) , ROM_GROUPWORD | ROM_SKIP(6) )
3226   ROMX_LOAD( "rm2.16m",   0x800002, 0x200000, CRC(c2bb0c24) SHA1(38724c49d9db49765a4ed9bc2dc8f57cec45ec7c) , ROM_GROUPWORD | ROM_SKIP(6) )
3227   ROMX_LOAD( "rm2.18m",   0x800004, 0x200000, CRC(12257251) SHA1(20cb58afda0e6200991277817485340a6a41ae2b) , ROM_GROUPWORD | ROM_SKIP(6) )
3228   ROMX_LOAD( "rm2.20m",   0x800006, 0x200000, CRC(f9b6e786) SHA1(aeb4acff7208e66a35198143fd2478039fdaa3a6) , ROM_GROUPWORD | ROM_SKIP(6) )
3225   ROMX_LOAD( "rm2.14m",  0x800000, 0x200000, CRC(9b1f00b4) SHA1(c1c5c2d9d00121425ae6598444d704f420ef4eef) , ROM_GROUPWORD | ROM_SKIP(6) )
3226   ROMX_LOAD( "rm2.16m",  0x800002, 0x200000, CRC(c2bb0c24) SHA1(38724c49d9db49765a4ed9bc2dc8f57cec45ec7c) , ROM_GROUPWORD | ROM_SKIP(6) )
3227   ROMX_LOAD( "rm2.18m",  0x800004, 0x200000, CRC(12257251) SHA1(20cb58afda0e6200991277817485340a6a41ae2b) , ROM_GROUPWORD | ROM_SKIP(6) )
3228   ROMX_LOAD( "rm2.20m",  0x800006, 0x200000, CRC(f9b6e786) SHA1(aeb4acff7208e66a35198143fd2478039fdaa3a6) , ROM_GROUPWORD | ROM_SKIP(6) )
32293229
32303230   ROM_REGION(QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
32313231   ROM_LOAD( "rm2.01a",  0x00000, 0x08000, CRC(d18e7859) SHA1(0939fac70042d0b4db5c2fdcef1f79b95febd45e) )
r2375r2376
32453245
32463246   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
32473247   ROM_FILL(              0x000000, 0x800000, 0 )
3248   ROMX_LOAD( "rm2.14m",   0x800000, 0x200000, CRC(9b1f00b4) SHA1(c1c5c2d9d00121425ae6598444d704f420ef4eef) , ROM_GROUPWORD | ROM_SKIP(6) )
3249   ROMX_LOAD( "rm2.16m",   0x800002, 0x200000, CRC(c2bb0c24) SHA1(38724c49d9db49765a4ed9bc2dc8f57cec45ec7c) , ROM_GROUPWORD | ROM_SKIP(6) )
3250   ROMX_LOAD( "rm2.18m",   0x800004, 0x200000, CRC(12257251) SHA1(20cb58afda0e6200991277817485340a6a41ae2b) , ROM_GROUPWORD | ROM_SKIP(6) )
3251   ROMX_LOAD( "rm2.20m",   0x800006, 0x200000, CRC(f9b6e786) SHA1(aeb4acff7208e66a35198143fd2478039fdaa3a6) , ROM_GROUPWORD | ROM_SKIP(6) )
3248   ROMX_LOAD( "rm2.14m",  0x800000, 0x200000, CRC(9b1f00b4) SHA1(c1c5c2d9d00121425ae6598444d704f420ef4eef) , ROM_GROUPWORD | ROM_SKIP(6) )
3249   ROMX_LOAD( "rm2.16m",  0x800002, 0x200000, CRC(c2bb0c24) SHA1(38724c49d9db49765a4ed9bc2dc8f57cec45ec7c) , ROM_GROUPWORD | ROM_SKIP(6) )
3250   ROMX_LOAD( "rm2.18m",  0x800004, 0x200000, CRC(12257251) SHA1(20cb58afda0e6200991277817485340a6a41ae2b) , ROM_GROUPWORD | ROM_SKIP(6) )
3251   ROMX_LOAD( "rm2.20m",  0x800006, 0x200000, CRC(f9b6e786) SHA1(aeb4acff7208e66a35198143fd2478039fdaa3a6) , ROM_GROUPWORD | ROM_SKIP(6) )
32523252
32533253   ROM_REGION(QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
32543254   ROM_LOAD( "rm2.01a",  0x00000, 0x08000, CRC(d18e7859) SHA1(0939fac70042d0b4db5c2fdcef1f79b95febd45e) )
r2375r2376
32683268
32693269   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
32703270   ROM_FILL(              0x000000, 0x800000, 0 )
3271   ROMX_LOAD( "rm2.14m",   0x800000, 0x200000, CRC(9b1f00b4) SHA1(c1c5c2d9d00121425ae6598444d704f420ef4eef) , ROM_GROUPWORD | ROM_SKIP(6) )
3272   ROMX_LOAD( "rm2.16m",   0x800002, 0x200000, CRC(c2bb0c24) SHA1(38724c49d9db49765a4ed9bc2dc8f57cec45ec7c) , ROM_GROUPWORD | ROM_SKIP(6) )
3273   ROMX_LOAD( "rm2.18m",   0x800004, 0x200000, CRC(12257251) SHA1(20cb58afda0e6200991277817485340a6a41ae2b) , ROM_GROUPWORD | ROM_SKIP(6) )
3274   ROMX_LOAD( "rm2.20m",   0x800006, 0x200000, CRC(f9b6e786) SHA1(aeb4acff7208e66a35198143fd2478039fdaa3a6) , ROM_GROUPWORD | ROM_SKIP(6) )
3271   ROMX_LOAD( "rm2.14m",  0x800000, 0x200000, CRC(9b1f00b4) SHA1(c1c5c2d9d00121425ae6598444d704f420ef4eef) , ROM_GROUPWORD | ROM_SKIP(6) )
3272   ROMX_LOAD( "rm2.16m",  0x800002, 0x200000, CRC(c2bb0c24) SHA1(38724c49d9db49765a4ed9bc2dc8f57cec45ec7c) , ROM_GROUPWORD | ROM_SKIP(6) )
3273   ROMX_LOAD( "rm2.18m",  0x800004, 0x200000, CRC(12257251) SHA1(20cb58afda0e6200991277817485340a6a41ae2b) , ROM_GROUPWORD | ROM_SKIP(6) )
3274   ROMX_LOAD( "rm2.20m",  0x800006, 0x200000, CRC(f9b6e786) SHA1(aeb4acff7208e66a35198143fd2478039fdaa3a6) , ROM_GROUPWORD | ROM_SKIP(6) )
32753275
32763276   ROM_REGION(QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
32773277   ROM_LOAD( "rm2.01a",  0x00000, 0x08000, CRC(d18e7859) SHA1(0939fac70042d0b4db5c2fdcef1f79b95febd45e) )
r2375r2376
41444144   ROM_LOAD16_WORD_SWAP( "mpn.03", 0x000000, 0x80000, CRC(6e7ed03c) SHA1(3562362d9573252d4d19dbfd0ec7e47e9eaa5f46) ) /* USA version, but has no "u" in label code */
41454145   ROM_LOAD16_WORD_SWAP( "mpn.04", 0x080000, 0x80000, CRC(de079131) SHA1(95da2a03cb642963aabfebd8337003961ca4db71) )
41464146
4147   ROM_REGION( 0x0800000, REGION_GFX1, 0 )
4148   ROMX_LOAD( "mpn.13m",   0x0000000, 0x200000, CRC(c5f123dc) SHA1(e459571416ab64f0280cda7dfa0d8836faa745c9) , ROM_GROUPWORD | ROM_SKIP(6) ) /* This version uses roms chips */
4149   ROMX_LOAD( "mpn.15m",   0x0000002, 0x200000, CRC(8e033265) SHA1(d05ca8fb825423ff6b099c06aaa500c0a947454a) , ROM_GROUPWORD | ROM_SKIP(6) )
4150   ROMX_LOAD( "mpn.17m",   0x0000004, 0x200000, CRC(cfcd73d2) SHA1(3415c063ac3632159df0fa74899bde8c90f4a2a1) , ROM_GROUPWORD | ROM_SKIP(6) )
4151   ROMX_LOAD( "mpn.19m",   0x0000006, 0x200000, CRC(2db1ffbc) SHA1(ca58c9359c2c629896c40e78c14907f562e2cdad) , ROM_GROUPWORD | ROM_SKIP(6) )
4147   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
4148   ROM_FILL(              0x000000, 0x800000, 0 )
4149   ROMX_LOAD( "mpn.13m",  0x800000, 0x200000, CRC(c5f123dc) SHA1(e459571416ab64f0280cda7dfa0d8836faa745c9) , ROM_GROUPWORD | ROM_SKIP(6) ) /* This version uses roms chips */
4150   ROMX_LOAD( "mpn.15m",  0x800002, 0x200000, CRC(8e033265) SHA1(d05ca8fb825423ff6b099c06aaa500c0a947454a) , ROM_GROUPWORD | ROM_SKIP(6) )
4151   ROMX_LOAD( "mpn.17m",  0x800004, 0x200000, CRC(cfcd73d2) SHA1(3415c063ac3632159df0fa74899bde8c90f4a2a1) , ROM_GROUPWORD | ROM_SKIP(6) )
4152   ROMX_LOAD( "mpn.19m",  0x800006, 0x200000, CRC(2db1ffbc) SHA1(ca58c9359c2c629896c40e78c14907f562e2cdad) , ROM_GROUPWORD | ROM_SKIP(6) )
41524153
41534154   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
41544155   ROM_LOAD( "mpn.01",   0x00000, 0x08000, CRC(90c7adb6) SHA1(a2653e977e5e0457b249e098e5ca0abc93dac336) )
r2375r2376
45414542
45424543   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
45434544   ROM_FILL(              0x000000, 0x800000, 0 )
4544   ROMX_LOAD( "tqz.14m",   0x800000, 0x200000, CRC(98af88a2) SHA1(d3620faf2162a1f3a62a238715da4da429376d3c) , ROM_GROUPWORD | ROM_SKIP(6) )
4545   ROMX_LOAD( "tqz.16m",   0x800002, 0x200000, CRC(df82d491) SHA1(fd3c8303cbcacb132a90398ff61f47d2d68157ae) , ROM_GROUPWORD | ROM_SKIP(6) )
4546   ROMX_LOAD( "tqz.18m",   0x800004, 0x200000, CRC(42f132ff) SHA1(0e0a128524010dba033a9b9ab2c56fe92a1767da) , ROM_GROUPWORD | ROM_SKIP(6) )
4547   ROMX_LOAD( "tqz.20m",   0x800006, 0x200000, CRC(b2e128a3) SHA1(8ae3161749d5206f16b755c29466cd5ca249b665) , ROM_GROUPWORD | ROM_SKIP(6) )
4545   ROMX_LOAD( "tqz.14m",  0x800000, 0x200000, CRC(98af88a2) SHA1(d3620faf2162a1f3a62a238715da4da429376d3c) , ROM_GROUPWORD | ROM_SKIP(6) )
4546   ROMX_LOAD( "tqz.16m",  0x800002, 0x200000, CRC(df82d491) SHA1(fd3c8303cbcacb132a90398ff61f47d2d68157ae) , ROM_GROUPWORD | ROM_SKIP(6) )
4547   ROMX_LOAD( "tqz.18m",  0x800004, 0x200000, CRC(42f132ff) SHA1(0e0a128524010dba033a9b9ab2c56fe92a1767da) , ROM_GROUPWORD | ROM_SKIP(6) )
4548   ROMX_LOAD( "tqz.20m",  0x800006, 0x200000, CRC(b2e128a3) SHA1(8ae3161749d5206f16b755c29466cd5ca249b665) , ROM_GROUPWORD | ROM_SKIP(6) )
45484549
45494550   ROM_REGION(QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
45504551   ROM_LOAD( "tqz.01",   0x00000, 0x08000, CRC(e9ce9d0a) SHA1(29f2987788e914e0a55f9130a99e411d15a7cc9b) )
r2375r2376
46624663
46634664   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
46644665   ROM_FILL(              0x000000, 0x800000, 0 )
4665   ROMX_LOAD( "rcm.73",   0x800000, 0x80000, CRC(774c6e04) SHA1(6bd14960218e31d5a043b20a1b9d2d69cace761e) , ROM_GROUPWORD | ROM_SKIP(6) )
4666   ROMX_LOAD( "rcm.63",   0x800002, 0x80000, CRC(acad7c62) SHA1(eec10990339c9fd8fdae896a5fd98d5bf0220ed1) , ROM_GROUPWORD | ROM_SKIP(6) )
4667   ROMX_LOAD( "rcm.83",   0x800004, 0x80000, CRC(6af30499) SHA1(a97bf2f382b6edc1e920e18d8ad5ca18131a2f21) , ROM_GROUPWORD | ROM_SKIP(6) )
4668   ROMX_LOAD( "rcm.93",   0x800006, 0x80000, CRC(7a5a5166) SHA1(2160015e2e43e2c024a3af56da961ac02ffc74e9) , ROM_GROUPWORD | ROM_SKIP(6) )
4669   ROMX_LOAD( "rcm.74",   0xa00000, 0x80000, CRC(004ec725) SHA1(b1d3bcf920b0a1d0f4b59c77f5962e8162bbef65) , ROM_GROUPWORD | ROM_SKIP(6) )
4670   ROMX_LOAD( "rcm.64",   0xa00002, 0x80000, CRC(65c0464e) SHA1(4a035f4d28fc8aa72bfe0a06392b93b0abfba458) , ROM_GROUPWORD | ROM_SKIP(6) )
4671   ROMX_LOAD( "rcm.84",   0xa00004, 0x80000, CRC(fb3097cc) SHA1(7bff2372809cdfa4dcd8537a448b177c0e86a94e) , ROM_GROUPWORD | ROM_SKIP(6) )
4672   ROMX_LOAD( "rcm.94",   0xa00006, 0x80000, CRC(2e16557a) SHA1(f4a916c1524a8de23fc6afabc8c724a89530c631) , ROM_GROUPWORD | ROM_SKIP(6) )
4673   ROMX_LOAD( "rcm.75",   0xc00000, 0x80000, CRC(70a73f99) SHA1(6dd126b4e64e34d5911ed5877b1b94b503404249) , ROM_GROUPWORD | ROM_SKIP(6) )
4674   ROMX_LOAD( "rcm.65",   0xc00002, 0x80000, CRC(ecedad3d) SHA1(dea1377f086ea3a45ced983e258beb6607b295c9) , ROM_GROUPWORD | ROM_SKIP(6) )
4675   ROMX_LOAD( "rcm.85",   0xc00004, 0x80000, CRC(3d6186d8) SHA1(70f1ff678dd1ec533360458a564953fc5634cbc5) , ROM_GROUPWORD | ROM_SKIP(6) )
4676   ROMX_LOAD( "rcm.95",   0xc00006, 0x80000, CRC(8c7700f1) SHA1(84846af535e9e333e911486d545988568554b67b) , ROM_GROUPWORD | ROM_SKIP(6) )
4677   ROMX_LOAD( "rcm.76",   0xe00000, 0x80000, CRC(89a889ad) SHA1(1ffe112051a3afc94df1326f17ef58dc2fc531aa) , ROM_GROUPWORD | ROM_SKIP(6) )
4678   ROMX_LOAD( "rcm.66",   0xe00002, 0x80000, CRC(1300eb7b) SHA1(db4f53b1cf521df99d073dcf0bfafe7b113e95d5) , ROM_GROUPWORD | ROM_SKIP(6) )
4679   ROMX_LOAD( "rcm.86",   0xe00004, 0x80000, CRC(6d974ebd) SHA1(41de66481a64fa8a6471c512fc5dcaf96d95ee69) , ROM_GROUPWORD | ROM_SKIP(6) )
4680   ROMX_LOAD( "rcm.96",   0xe00006, 0x80000, CRC(7da4cd24) SHA1(dd44377ff9f83f15cac032c4e7ef2071adcfa196) , ROM_GROUPWORD | ROM_SKIP(6) )
4666   ROMX_LOAD( "rcm.73",   0x800000, 0x080000, CRC(774c6e04) SHA1(6bd14960218e31d5a043b20a1b9d2d69cace761e) , ROM_GROUPWORD | ROM_SKIP(6) )
4667   ROMX_LOAD( "rcm.63",   0x800002, 0x080000, CRC(acad7c62) SHA1(eec10990339c9fd8fdae896a5fd98d5bf0220ed1) , ROM_GROUPWORD | ROM_SKIP(6) )
4668   ROMX_LOAD( "rcm.83",   0x800004, 0x080000, CRC(6af30499) SHA1(a97bf2f382b6edc1e920e18d8ad5ca18131a2f21) , ROM_GROUPWORD | ROM_SKIP(6) )
4669   ROMX_LOAD( "rcm.93",   0x800006, 0x080000, CRC(7a5a5166) SHA1(2160015e2e43e2c024a3af56da961ac02ffc74e9) , ROM_GROUPWORD | ROM_SKIP(6) )
4670   ROMX_LOAD( "rcm.74",   0xa00000, 0x080000, CRC(004ec725) SHA1(b1d3bcf920b0a1d0f4b59c77f5962e8162bbef65) , ROM_GROUPWORD | ROM_SKIP(6) )
4671   ROMX_LOAD( "rcm.64",   0xa00002, 0x080000, CRC(65c0464e) SHA1(4a035f4d28fc8aa72bfe0a06392b93b0abfba458) , ROM_GROUPWORD | ROM_SKIP(6) )
4672   ROMX_LOAD( "rcm.84",   0xa00004, 0x080000, CRC(fb3097cc) SHA1(7bff2372809cdfa4dcd8537a448b177c0e86a94e) , ROM_GROUPWORD | ROM_SKIP(6) )
4673   ROMX_LOAD( "rcm.94",   0xa00006, 0x080000, CRC(2e16557a) SHA1(f4a916c1524a8de23fc6afabc8c724a89530c631) , ROM_GROUPWORD | ROM_SKIP(6) )
4674   ROMX_LOAD( "rcm.75",   0xc00000, 0x080000, CRC(70a73f99) SHA1(6dd126b4e64e34d5911ed5877b1b94b503404249) , ROM_GROUPWORD | ROM_SKIP(6) )
4675   ROMX_LOAD( "rcm.65",   0xc00002, 0x080000, CRC(ecedad3d) SHA1(dea1377f086ea3a45ced983e258beb6607b295c9) , ROM_GROUPWORD | ROM_SKIP(6) )
4676   ROMX_LOAD( "rcm.85",   0xc00004, 0x080000, CRC(3d6186d8) SHA1(70f1ff678dd1ec533360458a564953fc5634cbc5) , ROM_GROUPWORD | ROM_SKIP(6) )
4677   ROMX_LOAD( "rcm.95",   0xc00006, 0x080000, CRC(8c7700f1) SHA1(84846af535e9e333e911486d545988568554b67b) , ROM_GROUPWORD | ROM_SKIP(6) )
4678   ROMX_LOAD( "rcm.76",   0xe00000, 0x080000, CRC(89a889ad) SHA1(1ffe112051a3afc94df1326f17ef58dc2fc531aa) , ROM_GROUPWORD | ROM_SKIP(6) )
4679   ROMX_LOAD( "rcm.66",   0xe00002, 0x080000, CRC(1300eb7b) SHA1(db4f53b1cf521df99d073dcf0bfafe7b113e95d5) , ROM_GROUPWORD | ROM_SKIP(6) )
4680   ROMX_LOAD( "rcm.86",   0xe00004, 0x080000, CRC(6d974ebd) SHA1(41de66481a64fa8a6471c512fc5dcaf96d95ee69) , ROM_GROUPWORD | ROM_SKIP(6) )
4681   ROMX_LOAD( "rcm.96",   0xe00006, 0x080000, CRC(7da4cd24) SHA1(dd44377ff9f83f15cac032c4e7ef2071adcfa196) , ROM_GROUPWORD | ROM_SKIP(6) )
46814682
46824683   ROM_REGION(QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
46834684   ROM_LOAD( "rcm.01",   0x00000, 0x08000, CRC(d60cf8a3) SHA1(dccd84b93e62489c703011422d0fe84444c7f7db) )
r2375r2376
47024703
47034704   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
47044705   ROM_FILL(              0x000000, 0x800000, 0 )
4705   ROMX_LOAD( "rcm.73",   0x800000, 0x80000, CRC(774c6e04) SHA1(6bd14960218e31d5a043b20a1b9d2d69cace761e) , ROM_GROUPWORD | ROM_SKIP(6) )
4706   ROMX_LOAD( "rcm.63",   0x800002, 0x80000, CRC(acad7c62) SHA1(eec10990339c9fd8fdae896a5fd98d5bf0220ed1) , ROM_GROUPWORD | ROM_SKIP(6) )
4707   ROMX_LOAD( "rcm.83",   0x800004, 0x80000, CRC(6af30499) SHA1(a97bf2f382b6edc1e920e18d8ad5ca18131a2f21) , ROM_GROUPWORD | ROM_SKIP(6) )
4708   ROMX_LOAD( "rcm.93",   0x800006, 0x80000, CRC(7a5a5166) SHA1(2160015e2e43e2c024a3af56da961ac02ffc74e9) , ROM_GROUPWORD | ROM_SKIP(6) )
4709   ROMX_LOAD( "rcm.74",   0xa00000, 0x80000, CRC(004ec725) SHA1(b1d3bcf920b0a1d0f4b59c77f5962e8162bbef65) , ROM_GROUPWORD | ROM_SKIP(6) )
4710   ROMX_LOAD( "rcm.64",   0xa00002, 0x80000, CRC(65c0464e) SHA1(4a035f4d28fc8aa72bfe0a06392b93b0abfba458) , ROM_GROUPWORD | ROM_SKIP(6) )
4711   ROMX_LOAD( "rcm.84",   0xa00004, 0x80000, CRC(fb3097cc) SHA1(7bff2372809cdfa4dcd8537a448b177c0e86a94e) , ROM_GROUPWORD | ROM_SKIP(6) )
4712   ROMX_LOAD( "rcm.94",   0xa00006, 0x80000, CRC(2e16557a) SHA1(f4a916c1524a8de23fc6afabc8c724a89530c631) , ROM_GROUPWORD | ROM_SKIP(6) )
4713   ROMX_LOAD( "rcm.75",   0xc00000, 0x80000, CRC(70a73f99) SHA1(6dd126b4e64e34d5911ed5877b1b94b503404249) , ROM_GROUPWORD | ROM_SKIP(6) )
4714   ROMX_LOAD( "rcm.65",   0xc00002, 0x80000, CRC(ecedad3d) SHA1(dea1377f086ea3a45ced983e258beb6607b295c9) , ROM_GROUPWORD | ROM_SKIP(6) )
4715   ROMX_LOAD( "rcm.85",   0xc00004, 0x80000, CRC(3d6186d8) SHA1(70f1ff678dd1ec533360458a564953fc5634cbc5) , ROM_GROUPWORD | ROM_SKIP(6) )
4716   ROMX_LOAD( "rcm.95",   0xc00006, 0x80000, CRC(8c7700f1) SHA1(84846af535e9e333e911486d545988568554b67b) , ROM_GROUPWORD | ROM_SKIP(6) )
4717   ROMX_LOAD( "rcm.76",   0xe00000, 0x80000, CRC(89a889ad) SHA1(1ffe112051a3afc94df1326f17ef58dc2fc531aa) , ROM_GROUPWORD | ROM_SKIP(6) )
4718   ROMX_LOAD( "rcm.66",   0xe00002, 0x80000, CRC(1300eb7b) SHA1(db4f53b1cf521df99d073dcf0bfafe7b113e95d5) , ROM_GROUPWORD | ROM_SKIP(6) )
4719   ROMX_LOAD( "rcm.86",   0xe00004, 0x80000, CRC(6d974ebd) SHA1(41de66481a64fa8a6471c512fc5dcaf96d95ee69) , ROM_GROUPWORD | ROM_SKIP(6) )
4720   ROMX_LOAD( "rcm.96",   0xe00006, 0x80000, CRC(7da4cd24) SHA1(dd44377ff9f83f15cac032c4e7ef2071adcfa196) , ROM_GROUPWORD | ROM_SKIP(6) )
4706   ROMX_LOAD( "rcm.73",   0x800000, 0x080000, CRC(774c6e04) SHA1(6bd14960218e31d5a043b20a1b9d2d69cace761e) , ROM_GROUPWORD | ROM_SKIP(6) )
4707   ROMX_LOAD( "rcm.63",   0x800002, 0x080000, CRC(acad7c62) SHA1(eec10990339c9fd8fdae896a5fd98d5bf0220ed1) , ROM_GROUPWORD | ROM_SKIP(6) )
4708   ROMX_LOAD( "rcm.83",   0x800004, 0x080000, CRC(6af30499) SHA1(a97bf2f382b6edc1e920e18d8ad5ca18131a2f21) , ROM_GROUPWORD | ROM_SKIP(6) )
4709   ROMX_LOAD( "rcm.93",   0x800006, 0x080000, CRC(7a5a5166) SHA1(2160015e2e43e2c024a3af56da961ac02ffc74e9) , ROM_GROUPWORD | ROM_SKIP(6) )
4710   ROMX_LOAD( "rcm.74",   0xa00000, 0x080000, CRC(004ec725) SHA1(b1d3bcf920b0a1d0f4b59c77f5962e8162bbef65) , ROM_GROUPWORD | ROM_SKIP(6) )
4711   ROMX_LOAD( "rcm.64",   0xa00002, 0x080000, CRC(65c0464e) SHA1(4a035f4d28fc8aa72bfe0a06392b93b0abfba458) , ROM_GROUPWORD | ROM_SKIP(6) )
4712   ROMX_LOAD( "rcm.84",   0xa00004, 0x080000, CRC(fb3097cc) SHA1(7bff2372809cdfa4dcd8537a448b177c0e86a94e) , ROM_GROUPWORD | ROM_SKIP(6) )
4713   ROMX_LOAD( "rcm.94",   0xa00006, 0x080000, CRC(2e16557a) SHA1(f4a916c1524a8de23fc6afabc8c724a89530c631) , ROM_GROUPWORD | ROM_SKIP(6) )
4714   ROMX_LOAD( "rcm.75",   0xc00000, 0x080000, CRC(70a73f99) SHA1(6dd126b4e64e34d5911ed5877b1b94b503404249) , ROM_GROUPWORD | ROM_SKIP(6) )
4715   ROMX_LOAD( "rcm.65",   0xc00002, 0x080000, CRC(ecedad3d) SHA1(dea1377f086ea3a45ced983e258beb6607b295c9) , ROM_GROUPWORD | ROM_SKIP(6) )
4716   ROMX_LOAD( "rcm.85",   0xc00004, 0x080000, CRC(3d6186d8) SHA1(70f1ff678dd1ec533360458a564953fc5634cbc5) , ROM_GROUPWORD | ROM_SKIP(6) )
4717   ROMX_LOAD( "rcm.95",   0xc00006, 0x080000, CRC(8c7700f1) SHA1(84846af535e9e333e911486d545988568554b67b) , ROM_GROUPWORD | ROM_SKIP(6) )
4718   ROMX_LOAD( "rcm.76",   0xe00000, 0x080000, CRC(89a889ad) SHA1(1ffe112051a3afc94df1326f17ef58dc2fc531aa) , ROM_GROUPWORD | ROM_SKIP(6) )
4719   ROMX_LOAD( "rcm.66",   0xe00002, 0x080000, CRC(1300eb7b) SHA1(db4f53b1cf521df99d073dcf0bfafe7b113e95d5) , ROM_GROUPWORD | ROM_SKIP(6) )
4720   ROMX_LOAD( "rcm.86",   0xe00004, 0x080000, CRC(6d974ebd) SHA1(41de66481a64fa8a6471c512fc5dcaf96d95ee69) , ROM_GROUPWORD | ROM_SKIP(6) )
4721   ROMX_LOAD( "rcm.96",   0xe00006, 0x080000, CRC(7da4cd24) SHA1(dd44377ff9f83f15cac032c4e7ef2071adcfa196) , ROM_GROUPWORD | ROM_SKIP(6) )
47214722
47224723   ROM_REGION(QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
47234724   ROM_LOAD( "rcm.01",   0x00000, 0x08000, CRC(d60cf8a3) SHA1(dccd84b93e62489c703011422d0fe84444c7f7db) )
r2375r2376
47434744
47444745   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
47454746   ROM_FILL(              0x000000, 0x800000, 0 )
4746   ROMX_LOAD( "sfz.14m",   0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4747   ROMX_LOAD( "sfz.16m",   0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4748   ROMX_LOAD( "sfz.18m",   0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4749   ROMX_LOAD( "sfz.20m",   0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
4747   ROMX_LOAD( "sfz.14m",  0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4748   ROMX_LOAD( "sfz.16m",  0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4749   ROMX_LOAD( "sfz.18m",  0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4750   ROMX_LOAD( "sfz.20m",  0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
47504751
47514752   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
47524753   ROM_LOAD( "sfz.01",   0x00000, 0x08000, CRC(ffffec7d) SHA1(75b4aef001b72a0f571b51b2b97803facc1832dd) )
r2375r2376
47674768
47684769   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
47694770   ROM_FILL(              0x000000, 0x800000, 0 )
4770   ROMX_LOAD( "sfz.14m",   0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4771   ROMX_LOAD( "sfz.16m",   0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4772   ROMX_LOAD( "sfz.18m",   0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4773   ROMX_LOAD( "sfz.20m",   0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
4771   ROMX_LOAD( "sfz.14m",  0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4772   ROMX_LOAD( "sfz.16m",  0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4773   ROMX_LOAD( "sfz.18m",  0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4774   ROMX_LOAD( "sfz.20m",  0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
47744775
47754776   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
47764777   ROM_LOAD( "sfz.01",   0x00000, 0x08000, CRC(ffffec7d) SHA1(75b4aef001b72a0f571b51b2b97803facc1832dd) )
r2375r2376
47914792
47924793   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
47934794   ROM_FILL(              0x000000, 0x800000, 0 )
4794   ROMX_LOAD( "sfz.14m",   0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4795   ROMX_LOAD( "sfz.16m",   0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4796   ROMX_LOAD( "sfz.18m",   0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4797   ROMX_LOAD( "sfz.20m",   0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
4795   ROMX_LOAD( "sfz.14m",  0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4796   ROMX_LOAD( "sfz.16m",  0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4797   ROMX_LOAD( "sfz.18m",  0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4798   ROMX_LOAD( "sfz.20m",  0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
47984799
47994800   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
48004801   ROM_LOAD( "sfz.01",   0x00000, 0x08000, CRC(ffffec7d) SHA1(75b4aef001b72a0f571b51b2b97803facc1832dd) )
r2375r2376
48154816
48164817   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
48174818   ROM_FILL(              0x000000, 0x800000, 0 )
4818   ROMX_LOAD( "sfz.14m",   0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4819   ROMX_LOAD( "sfz.16m",   0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4820   ROMX_LOAD( "sfz.18m",   0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4821   ROMX_LOAD( "sfz.20m",   0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
4819   ROMX_LOAD( "sfz.14m",  0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4820   ROMX_LOAD( "sfz.16m",  0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4821   ROMX_LOAD( "sfz.18m",  0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4822   ROMX_LOAD( "sfz.20m",  0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
48224823
48234824   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
48244825   ROM_LOAD( "sfz.01",   0x00000, 0x08000, CRC(ffffec7d) SHA1(75b4aef001b72a0f571b51b2b97803facc1832dd) )
r2375r2376
48394840
48404841   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
48414842   ROM_FILL(              0x000000, 0x800000, 0 )
4842   ROMX_LOAD( "sfz.14m",   0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4843   ROMX_LOAD( "sfz.16m",   0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4844   ROMX_LOAD( "sfz.18m",   0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4845   ROMX_LOAD( "sfz.20m",   0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
4843   ROMX_LOAD( "sfz.14m",  0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4844   ROMX_LOAD( "sfz.16m",  0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4845   ROMX_LOAD( "sfz.18m",  0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4846   ROMX_LOAD( "sfz.20m",  0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
48464847
48474848   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
48484849   ROM_LOAD( "sfz.01",   0x00000, 0x08000, CRC(ffffec7d) SHA1(75b4aef001b72a0f571b51b2b97803facc1832dd) )
r2375r2376
48634864
48644865   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
48654866   ROM_FILL(              0x000000, 0x800000, 0 )
4866   ROMX_LOAD( "sfz.14m",   0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4867   ROMX_LOAD( "sfz.16m",   0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4868   ROMX_LOAD( "sfz.18m",   0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4869   ROMX_LOAD( "sfz.20m",   0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
4867   ROMX_LOAD( "sfz.14m",  0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4868   ROMX_LOAD( "sfz.16m",  0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4869   ROMX_LOAD( "sfz.18m",  0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4870   ROMX_LOAD( "sfz.20m",  0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
48704871
48714872   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
48724873   ROM_LOAD( "sfz.01",   0x00000, 0x08000, CRC(ffffec7d) SHA1(75b4aef001b72a0f571b51b2b97803facc1832dd) )
r2375r2376
48874888
48884889   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
48894890   ROM_FILL(              0x000000, 0x800000, 0 )
4890   ROMX_LOAD( "sfz.14m",   0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4891   ROMX_LOAD( "sfz.16m",   0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4892   ROMX_LOAD( "sfz.18m",   0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4893   ROMX_LOAD( "sfz.20m",   0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
4891   ROMX_LOAD( "sfz.14m",  0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4892   ROMX_LOAD( "sfz.16m",  0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4893   ROMX_LOAD( "sfz.18m",  0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4894   ROMX_LOAD( "sfz.20m",  0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
48944895
48954896   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
48964897   ROM_LOAD( "sfz.01",   0x00000, 0x08000, CRC(ffffec7d) SHA1(75b4aef001b72a0f571b51b2b97803facc1832dd) )
r2375r2376
49114912
49124913   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
49134914   ROM_FILL(              0x000000, 0x800000, 0 )
4914   ROMX_LOAD( "sfz.14m",   0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4915   ROMX_LOAD( "sfz.16m",   0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4916   ROMX_LOAD( "sfz.18m",   0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4917   ROMX_LOAD( "sfz.20m",   0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
4915   ROMX_LOAD( "sfz.14m",  0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4916   ROMX_LOAD( "sfz.16m",  0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4917   ROMX_LOAD( "sfz.18m",  0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4918   ROMX_LOAD( "sfz.20m",  0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
49184919
49194920   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
49204921   ROM_LOAD( "sfz.01",   0x00000, 0x08000, CRC(ffffec7d) SHA1(75b4aef001b72a0f571b51b2b97803facc1832dd) )
r2375r2376
49354936
49364937   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
49374938   ROM_FILL(              0x000000, 0x800000, 0 )
4938   ROMX_LOAD( "sfz.14m",   0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4939   ROMX_LOAD( "sfz.16m",   0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4940   ROMX_LOAD( "sfz.18m",   0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4941   ROMX_LOAD( "sfz.20m",   0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
4939   ROMX_LOAD( "sfz.14m",  0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4940   ROMX_LOAD( "sfz.16m",  0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4941   ROMX_LOAD( "sfz.18m",  0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4942   ROMX_LOAD( "sfz.20m",  0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
49424943
49434944   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
49444945   ROM_LOAD( "sfz.01",   0x00000, 0x08000, CRC(ffffec7d) SHA1(75b4aef001b72a0f571b51b2b97803facc1832dd) )
r2375r2376
49594960
49604961   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
49614962   ROM_FILL(              0x000000, 0x800000, 0 )
4962   ROMX_LOAD( "sfz.14m",   0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4963   ROMX_LOAD( "sfz.16m",   0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4964   ROMX_LOAD( "sfz.18m",   0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4965   ROMX_LOAD( "sfz.20m",   0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
4963   ROMX_LOAD( "sfz.14m",  0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4964   ROMX_LOAD( "sfz.16m",  0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4965   ROMX_LOAD( "sfz.18m",  0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4966   ROMX_LOAD( "sfz.20m",  0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
49664967
49674968   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
49684969   ROM_LOAD( "sfz.01",   0x00000, 0x08000, CRC(ffffec7d) SHA1(75b4aef001b72a0f571b51b2b97803facc1832dd) )
r2375r2376
49834984
49844985   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
49854986   ROM_FILL(              0x000000, 0x800000, 0 )
4986   ROMX_LOAD( "sfz.14m",   0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4987   ROMX_LOAD( "sfz.16m",   0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4988   ROMX_LOAD( "sfz.18m",   0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4989   ROMX_LOAD( "sfz.20m",   0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
4987   ROMX_LOAD( "sfz.14m",  0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
4988   ROMX_LOAD( "sfz.16m",  0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
4989   ROMX_LOAD( "sfz.18m",  0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
4990   ROMX_LOAD( "sfz.20m",  0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
49904991
49914992   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
49924993   ROM_LOAD( "sfz.01",   0x00000, 0x08000, CRC(ffffec7d) SHA1(75b4aef001b72a0f571b51b2b97803facc1832dd) )
r2375r2376
50075008
50085009   ROM_REGION( 0x1000000, REGION_GFX1, 0 )
50095010   ROM_FILL(              0x000000, 0x800000, 0 )
5010   ROMX_LOAD( "sfz.14m",   0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
5011   ROMX_LOAD( "sfz.16m",   0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
5012   ROMX_LOAD( "sfz.18m",   0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
5013   ROMX_LOAD( "sfz.20m",   0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
5011   ROMX_LOAD( "sfz.14m",  0x800000, 0x200000, CRC(90fefdb3) SHA1(5eb28c8de57acfeaefebdd01509c7d9ba5244705) , ROM_GROUPWORD | ROM_SKIP(6) )
5012   ROMX_LOAD( "sfz.16m",  0x800002, 0x200000, CRC(5354c948) SHA1(07588f1ba6addc04fef3274c971174aaf3e632ab) , ROM_GROUPWORD | ROM_SKIP(6) )
5013   ROMX_LOAD( "sfz.18m",  0x800004, 0x200000, CRC(41a1e790) SHA1(ce25dad542308691dbe9606b26279bbd59ea4b81) , ROM_GROUPWORD | ROM_SKIP(6) )
5014   ROMX_LOAD( "sfz.20m",  0x800006, 0x200000, CRC(a549df98) SHA1(f054e95df650a891ef56da8bfb31cb2c945a9aed) , ROM_GROUPWORD | ROM_SKIP(6) )
50145015
50155016   ROM_REGION( QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
50165017   ROM_LOAD( "sfz.01",   0x00000, 0x08000, CRC(ffffec7d) SHA1(75b4aef001b72a0f571b51b2b97803facc1832dd) )
r2375r2376
57395740
57405741   ROM_REGION( 0xC00000, REGION_GFX1, 0 )
57415742   ROM_FILL(             0x000000, 0x800000, 0 )
5742   ROMX_LOAD( "pzf.14m",  0x800000, 0x100000, CRC(2d4881cb) SHA1(fd3baa183c25bed153b19c251980e2fb761600e2) , ROM_GROUPWORD | ROM_SKIP(6) )
5743   ROMX_LOAD( "pzf.16m",  0x800002, 0x100000, CRC(4b0fd1be) SHA1(377aafdcdb7a866b1c8487670e3598d8197976e4) , ROM_GROUPWORD | ROM_SKIP(6) )
5744   ROMX_LOAD( "pzf.18m",  0x800004, 0x100000, CRC(e43aac33) SHA1(d041e0688c3807d3363861a7f216de43b34d846c) , ROM_GROUPWORD | ROM_SKIP(6) )
5745   ROMX_LOAD( "pzf.20m",  0x800006, 0x100000, CRC(7f536ff1) SHA1(905b9d62ef7bef47297c7f4a4dd697aed6df38a5) , ROM_GROUPWORD | ROM_SKIP(6) )
5743   ROMX_LOAD( "pzf.14m", 0x800000, 0x100000, CRC(2d4881cb) SHA1(fd3baa183c25bed153b19c251980e2fb761600e2) , ROM_GROUPWORD | ROM_SKIP(6) )
5744   ROMX_LOAD( "pzf.16m", 0x800002, 0x100000, CRC(4b0fd1be) SHA1(377aafdcdb7a866b1c8487670e3598d8197976e4) , ROM_GROUPWORD | ROM_SKIP(6) )
5745   ROMX_LOAD( "pzf.18m", 0x800004, 0x100000, CRC(e43aac33) SHA1(d041e0688c3807d3363861a7f216de43b34d846c) , ROM_GROUPWORD | ROM_SKIP(6) )
5746   ROMX_LOAD( "pzf.20m", 0x800006, 0x100000, CRC(7f536ff1) SHA1(905b9d62ef7bef47297c7f4a4dd697aed6df38a5) , ROM_GROUPWORD | ROM_SKIP(6) )
57465747
57475748   ROM_REGION(QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
57485749   ROM_LOAD( "pzf.01",   0x00000, 0x08000, CRC(600fb2a3) SHA1(1fab1c2a23bf6ad8309d29ddbbc29435a8aeea13) )
r2375r2376
57615762
57625763   ROM_REGION( 0xC00000, REGION_GFX1, 0 )
57635764   ROM_FILL(             0x000000, 0x800000, 0 )
5764   ROMX_LOAD( "pzf.14m",  0x800000, 0x100000, CRC(2d4881cb) SHA1(fd3baa183c25bed153b19c251980e2fb761600e2) , ROM_GROUPWORD | ROM_SKIP(6) )
5765   ROMX_LOAD( "pzf.16m",  0x800002, 0x100000, CRC(4b0fd1be) SHA1(377aafdcdb7a866b1c8487670e3598d8197976e4) , ROM_GROUPWORD | ROM_SKIP(6) )
5766   ROMX_LOAD( "pzf.18m",  0x800004, 0x100000, CRC(e43aac33) SHA1(d041e0688c3807d3363861a7f216de43b34d846c) , ROM_GROUPWORD | ROM_SKIP(6) )
5767   ROMX_LOAD( "pzf.20m",  0x800006, 0x100000, CRC(7f536ff1) SHA1(905b9d62ef7bef47297c7f4a4dd697aed6df38a5) , ROM_GROUPWORD | ROM_SKIP(6) )
5765   ROMX_LOAD( "pzf.14m", 0x800000, 0x100000, CRC(2d4881cb) SHA1(fd3baa183c25bed153b19c251980e2fb761600e2) , ROM_GROUPWORD | ROM_SKIP(6) )
5766   ROMX_LOAD( "pzf.16m", 0x800002, 0x100000, CRC(4b0fd1be) SHA1(377aafdcdb7a866b1c8487670e3598d8197976e4) , ROM_GROUPWORD | ROM_SKIP(6) )
5767   ROMX_LOAD( "pzf.18m", 0x800004, 0x100000, CRC(e43aac33) SHA1(d041e0688c3807d3363861a7f216de43b34d846c) , ROM_GROUPWORD | ROM_SKIP(6) )
5768   ROMX_LOAD( "pzf.20m", 0x800006, 0x100000, CRC(7f536ff1) SHA1(905b9d62ef7bef47297c7f4a4dd697aed6df38a5) , ROM_GROUPWORD | ROM_SKIP(6) )
57685769
57695770   ROM_REGION(QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
57705771   ROM_LOAD( "pzf.01",   0x00000, 0x08000, CRC(600fb2a3) SHA1(1fab1c2a23bf6ad8309d29ddbbc29435a8aeea13) )
r2375r2376
57835784
57845785   ROM_REGION( 0xC00000, REGION_GFX1, 0 )
57855786   ROM_FILL(             0x000000, 0x800000, 0 )
5786   ROMX_LOAD( "pzf.14m",  0x800000, 0x100000, CRC(2d4881cb) SHA1(fd3baa183c25bed153b19c251980e2fb761600e2) , ROM_GROUPWORD | ROM_SKIP(6) )
5787   ROMX_LOAD( "pzf.16m",  0x800002, 0x100000, CRC(4b0fd1be) SHA1(377aafdcdb7a866b1c8487670e3598d8197976e4) , ROM_GROUPWORD | ROM_SKIP(6) )
5788   ROMX_LOAD( "pzf.18m",  0x800004, 0x100000, CRC(e43aac33) SHA1(d041e0688c3807d3363861a7f216de43b34d846c) , ROM_GROUPWORD | ROM_SKIP(6) )
5789   ROMX_LOAD( "pzf.20m",  0x800006, 0x100000, CRC(7f536ff1) SHA1(905b9d62ef7bef47297c7f4a4dd697aed6df38a5) , ROM_GROUPWORD | ROM_SKIP(6) )
5787   ROMX_LOAD( "pzf.14m", 0x800000, 0x100000, CRC(2d4881cb) SHA1(fd3baa183c25bed153b19c251980e2fb761600e2) , ROM_GROUPWORD | ROM_SKIP(6) )
5788   ROMX_LOAD( "pzf.16m", 0x800002, 0x100000, CRC(4b0fd1be) SHA1(377aafdcdb7a866b1c8487670e3598d8197976e4) , ROM_GROUPWORD | ROM_SKIP(6) )
5789   ROMX_LOAD( "pzf.18m", 0x800004, 0x100000, CRC(e43aac33) SHA1(d041e0688c3807d3363861a7f216de43b34d846c) , ROM_GROUPWORD | ROM_SKIP(6) )
5790   ROMX_LOAD( "pzf.20m", 0x800006, 0x100000, CRC(7f536ff1) SHA1(905b9d62ef7bef47297c7f4a4dd697aed6df38a5) , ROM_GROUPWORD | ROM_SKIP(6) )
57905791
57915792   ROM_REGION(QSOUND_SIZE, REGION_CPU2, 0 ) /* 64k for the audio CPU (+banks) */
57925793   ROM_LOAD( "pzf.01",   0x00000, 0x08000, CRC(600fb2a3) SHA1(1fab1c2a23bf6ad8309d29ddbbc29435a8aeea13) )
src/mame/drivers/lordgun.c
r2375r2376
5555WRITE16_HANDLER( lordgun_vram_2_w );
5656WRITE16_HANDLER( lordgun_vram_3_w );
5757
58void lordgun_update_gun(int i);
58void lordgun_update_gun(running_machine *machine, int i);
5959
6060VIDEO_START( lordgun );
6161VIDEO_UPDATE( lordgun );
r2375r2376
111111
112112static READ8_HANDLER( lordgun_eeprom_r )
113113{
114   return readinputport(0) | ((EEPROM_read_bit() & 1) << 7);
114   return input_port_read_indexed(machine, 0) | ((EEPROM_read_bit() & 1) << 7);
115115}
116116
117117static WRITE8_HANDLER( lordgun_eeprom_w )
r2375r2376
130130   // Update light guns positions
131131   for (i = 0; i < 2; i++)
132132      if ( (data & (0x04 << i)) && !(old & (0x04 << i)) )
133         lordgun_update_gun(i);
133         lordgun_update_gun(machine, i);
134134
135135   // latch the bit
136136   EEPROM_write_bit(data & 0x40);
src/mame/drivers/lemmings.c
r2375r2376
3333static READ16_HANDLER( lemmings_trackball_r )
3434{
3535   switch (offset) {
36   case 0: return readinputport(4); break;
37   case 1: return readinputport(5); break;
38   case 4: return readinputport(6); break;
39   case 5: return readinputport(7); break;
36   case 0: return input_port_read_indexed(machine, 4); break;
37   case 1: return input_port_read_indexed(machine, 5); break;
38   case 4: return input_port_read_indexed(machine, 6); break;
39   case 5: return input_port_read_indexed(machine, 7); break;
4040   }
4141   return 0;
4242}
r2375r2376
4646{
4747    switch (offset<<1) {
4848      case 0x41a: /* Player input */
49         return readinputport(0);
49         return input_port_read_indexed(machine, 0);
5050
5151      case 0x320: /* Coins */
52         return readinputport(1);
52         return input_port_read_indexed(machine, 1);
5353
5454      case 0x4e6: /* Dips */
55         return (readinputport(2) + (readinputport(3) << 8));
55         return (input_port_read_indexed(machine, 2) + (input_port_read_indexed(machine, 3) << 8));
5656   }
5757
5858   return 0;
src/mame/drivers/zerozone.c
r2375r2376
4242   switch (offset)
4343   {
4444      case 0x00:
45         return readinputport(0); /* IN0 */
45         return input_port_read_indexed(machine, 0); /* IN0 */
4646      case 0x01:
47         return (readinputport(1) | (readinputport(2) << 8)); /* IN1 & IN2 */
47         return (input_port_read_indexed(machine, 1) | (input_port_read_indexed(machine, 2) << 8)); /* IN1 & IN2 */
4848      case 0x04:
49         return (readinputport(4) << 8);
49         return (input_port_read_indexed(machine, 4) << 8);
5050      case 0x05:
51         return readinputport(3);
51         return input_port_read_indexed(machine, 3);
5252   }
5353
5454logerror("CPU #0 PC %06x: warning - read unmapped memory address %06x\n",activecpu_get_pc(),0x800000+offset);
src/mame/drivers/hyperspt.c
r2375r2376
4545   static int cheat = 0;
4646   static const int bits[] = { 0xee, 0xff, 0xbb, 0xaa };
4747
48   res = readinputportbytag("IN1");
48   res = input_port_read(machine, "IN1");
4949
5050   if ((res & 0x80) == 0)
5151   {
src/mame/drivers/toaplan1.c
r2375r2376
13571357   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
13581358
13591359   MDRV_SCREEN_ADD("main", RASTER)
1360   MDRV_SCREEN_REFRESH_RATE(60)
1360   MDRV_SCREEN_REFRESH_RATE( (28000000.0 / 4) / (450 * 282) )   /* fixed by SUZ */
13611361   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
13621362   MDRV_SCREEN_SIZE(432, 262)   /* copied these from toaplan2, to be verified */
13631363   MDRV_SCREEN_VISIBLE_AREA(0, 319, 16, 255)
r2375r2376
20892089
20902090static DRIVER_INIT( toaplan1 )
20912091{
2092   toaplan1_driver_savestate();
2092   toaplan1_driver_savestate(machine);
20932093}
20942094
20952095static DRIVER_INIT( demonwld )
20962096{
2097   toaplan1_driver_savestate();
2098   demonwld_driver_savestate();
2097   toaplan1_driver_savestate(machine);
2098   demonwld_driver_savestate(machine);
20992099}
21002100
21012101static DRIVER_INIT( vimana )
21022102{
2103   toaplan1_driver_savestate();
2104   vimana_driver_savestate();
2103   toaplan1_driver_savestate(machine);
2104   vimana_driver_savestate(machine);
21052105}
21062106
21072107
src/mame/drivers/segag80r.c
r2375r2376
231231   /* read as two bits from each of 4 ports. For this reason, the input   */
232232   /* ports have been organized logically, and are demangled at runtime.  */
233233   /* 4 input ports each provide 8 bits of information. */
234   UINT8 d7d6 = readinputportbytag("D7D6");
235   UINT8 d5d4 = readinputportbytag("D5D4");
236   UINT8 d3d2 = readinputportbytag("D3D2");
237   UINT8 d1d0 = readinputportbytag("D1D0");
234   UINT8 d7d6 = input_port_read(machine, "D7D6");
235   UINT8 d5d4 = input_port_read(machine, "D5D4");
236   UINT8 d3d2 = input_port_read(machine, "D3D2");
237   UINT8 d1d0 = input_port_read(machine, "D1D0");
238238   int shift = offset & 3;
239239   return demangle(d7d6 >> shift, d5d4 >> shift, d3d2 >> shift, d1d0 >> shift);
240240}
r2375r2376
246246   /* versus cocktail cabinets; we fix this here. The input ports are */
247247   /* coded for cocktail mode; for upright mode, we manually shuffle the */
248248   /* bits around. */
249   UINT8 d7d6 = readinputportbytag("D7D6");
250   UINT8 d5d4 = readinputportbytag("D5D4");
251   UINT8 d3d2 = readinputportbytag("D3D2");
252   UINT8 d1d0 = readinputportbytag("D1D0");
249   UINT8 d7d6 = input_port_read(machine, "D7D6");
250   UINT8 d5d4 = input_port_read(machine, "D5D4");
251   UINT8 d3d2 = input_port_read(machine, "D3D2");
252   UINT8 d1d0 = input_port_read(machine, "D1D0");
253253   int shift = offset & 3;
254254
255255   /* tweak bits for the upright case */
256256   UINT8 upright = d3d2 & 0x04;
257257   if (upright)
258258   {
259      UINT8 fc = readinputportbytag("FC");
259      UINT8 fc = input_port_read(machine, "FC");
260260      d7d6 |= 0x60;
261261      d5d4 = (d5d4 & ~0x1c) |
262262            ((~fc & 0x20) >> 3) | /* IPT_BUTTON2 */
r2375r2376
270270
271271static READ8_HANDLER( spaceod_port_fc_r )
272272{
273   UINT8 upright = readinputportbytag("D3D2") & 0x04;
274   UINT8 fc = readinputportbytag("FC");
273   UINT8 upright = input_port_read(machine, "D3D2") & 0x04;
274   UINT8 fc = input_port_read(machine, "FC");
275275
276276   /* tweak bits for the upright case */
277277   if (upright)
src/mame/drivers/hnayayoi.c
r2375r2376
5656   int i;
5757
5858   for (i = 0;i < 5;i++)
59      if (~keyb & (1 << i)) res &= readinputport(4+i);
59      if (~keyb & (1 << i)) res &= input_port_read_indexed(machine, 4+i);
6060
6161   return res;
6262}
src/mame/drivers/tmnt.c
r2375r2376
25632563   MDRV_SPEAKER_STANDARD_STEREO("left", "right")
25642564
25652565   MDRV_SOUND_ADD(YM2151, XTAL_3_579545MHz)
2566   MDRV_SOUND_ROUTE(0, "left", 1.0)
2567   MDRV_SOUND_ROUTE(1, "right", 1.0)
2566   MDRV_SOUND_ROUTE(0, "left", 0.70)
2567   MDRV_SOUND_ROUTE(1, "right", 0.70)
25682568
25692569   MDRV_SOUND_ADD(K053260, XTAL_3_579545MHz)
25702570   MDRV_SOUND_CONFIG(k053260_interface)
2571   MDRV_SOUND_ROUTE(0, "right", 0.75)   /* fixed inverted stereo channels */
2572   MDRV_SOUND_ROUTE(1, "left", 0.75)
2571   MDRV_SOUND_ROUTE(0, "right", 0.50)   /* fixed inverted stereo channels */
2572   MDRV_SOUND_ROUTE(1, "left", 0.50)
25732573MACHINE_DRIVER_END
25742574
25752575
r2375r2376
27212721
27222722   MDRV_SOUND_ADD(K053260, XTAL_3_579545MHz)
27232723   MDRV_SOUND_CONFIG(k053260_interface)
2724   MDRV_SOUND_ROUTE(0, "left", 0.70)
2725   MDRV_SOUND_ROUTE(1, "right", 0.70)
2724   MDRV_SOUND_ROUTE(0, "left", 0.75)
2725   MDRV_SOUND_ROUTE(1, "right", 0.75)
27262726MACHINE_DRIVER_END
27272727
27282728
r2375r2376
27642764
27652765   MDRV_SOUND_ADD(K053260, XTAL_3_579545MHz)
27662766   MDRV_SOUND_CONFIG(k053260_interface)
2767   MDRV_SOUND_ROUTE(0, "left", 0.75)
2768   MDRV_SOUND_ROUTE(1, "right", 0.75)
2767   MDRV_SOUND_ROUTE(0, "left", 0.70)
2768   MDRV_SOUND_ROUTE(1, "right", 0.70)
27692769MACHINE_DRIVER_END
27702770
27712771
r2375r2376
28392839
28402840   MDRV_SOUND_ADD(K053260, XTAL_3_579545MHz)
28412841   MDRV_SOUND_CONFIG(k053260_interface)
2842   MDRV_SOUND_ROUTE(0, "left", 0.70)
2843   MDRV_SOUND_ROUTE(1, "right", 0.70)
2842   MDRV_SOUND_ROUTE(0, "left", 0.75)
2843   MDRV_SOUND_ROUTE(1, "right", 0.75)
28442844MACHINE_DRIVER_END
28452845
28462846
src/mame/drivers/jpmimpct.c
r2375r2376
295295      }
296296      case 0xd:
297297      {
298         val = readinputportbytag("TEST/DEMO");
298         val = input_port_read(machine, "TEST/DEMO");
299299         break;
300300      }
301301      case 0xe:
r2375r2376
409409      {
410410         if (touch_cnt == 0)
411411         {
412            if ( readinputportbytag("TOUCH") & 0x1 )
412            if ( input_port_read(machine, "TOUCH") & 0x1 )
413413            {
414414               touch_data[0] = 0x2a;
415               touch_data[1] = 0x7 - (readinputportbytag("TOUCH_Y") >> 5) + 0x30;
416               touch_data[2] = (readinputportbytag("TOUCH_X") >> 5) + 0x30;
415               touch_data[1] = 0x7 - (input_port_read(machine, "TOUCH_Y") >> 5) + 0x30;
416               touch_data[2] = (input_port_read(machine, "TOUCH_X") >> 5) + 0x30;
417417
418418               /* Return RXRDY */
419419               return 0x1;
r2375r2376
477477   {
478478      case 0:
479479      {
480         val = readinputportbytag("DSW");
480         val = input_port_read(machine, "DSW");
481481         break;
482482      }
483483      case 2:
484484      {
485         val = readinputportbytag("SW2");
485         val = input_port_read(machine, "SW2");
486486         break;
487487      }
488488      case 4:
489489      {
490         val = readinputportbytag("SW1");
490         val = input_port_read(machine, "SW1");
491491         break;
492492      }
493493      case 9:
494494      {
495         val = readinputportbytag("COINS");
495         val = input_port_read(machine, "COINS");
496496         break;
497497      }
498498   }
src/mame/drivers/namcos12.c
r2375r2376
11451145   switch( offset )
11461146   {
11471147   case 0:
1148      data = readinputport( 3 );
1148      data = input_port_read_indexed(machine, 3 );
11491149      break;
11501150   case 1:
1151      data = ( readinputport( 4 ) ) | ( ( readinputport( 4 ) + 1 ) << 16 );
1151      data = ( input_port_read_indexed(machine, 4 ) ) | ( ( input_port_read_indexed(machine, 4 ) + 1 ) << 16 );
11521152      break;
11531153   case 2:
1154      data = readinputport( 5 );
1154      data = input_port_read_indexed(machine, 5 );
11551155      break;
11561156   case 3:
1157      data = ( readinputport( 6 ) ) | ( ( readinputport( 6 ) + 1 ) << 16 );
1157      data = ( input_port_read_indexed(machine, 6 ) ) | ( ( input_port_read_indexed(machine, 6 ) + 1 ) << 16 );
11581158      break;
11591159   }
11601160   verboselog( 2, "system11gun_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
r2375r2376
13871387   int index = port_tag_to_index("IN3");
13881388   if( index != -1 )
13891389   {
1390      int rv = readinputport( index ) << 6;
1390      int rv = input_port_read_indexed(machine, index ) << 6;
13911391
13921392      if( ( offset & 1 ) != 0 )
13931393      {
r2375r2376
14061406   int index = port_tag_to_index("IN4");
14071407   if( index != -1 )
14081408   {
1409      int rv = readinputport( index ) << 6;
1409      int rv = input_port_read_indexed(machine, index ) << 6;
14101410
14111411      if( ( offset & 1 ) != 0 )
14121412      {
r2375r2376
14391439
14401440static DRIVER_INIT( namcos12 )
14411441{
1442   psx_driver_init();
1442   psx_driver_init(machine);
14431443
14441444   psx_dma_install_read_handler( 5, namcos12_rom_read );
14451445
r2375r2376
14731473
14741474static MACHINE_DRIVER_START( coh700 )
14751475   /* basic machine hardware */
1476   MDRV_CPU_ADD( PSXCPU, XTAL_100MHz )
1476   MDRV_CPU_ADD( CXD8661R, XTAL_100MHz )
14771477   MDRV_CPU_PROGRAM_MAP( namcos12_map, 0 )
14781478   MDRV_CPU_VBLANK_INT("main", psx_vblank)
14791479
src/mame/drivers/raiden2.c
r2375r2376
7272   COMBINE_DATA(dest);
7373}
7474
75/* machine/seicop.c */
76extern READ16_HANDLER( raiden2_cop2_r );
77extern WRITE16_HANDLER( raiden2_cop2_w );
78extern void cop_init(void);
7579
80
81
7682/* SPRITE DRAWING (move to video file) */
7783
7884static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ,int pri_mask )
r2375r2376
476482
477483static INTERRUPT_GEN( raiden2_interrupt )
478484{
479   mainram[0x740/2] = readinputport(2) | (readinputport(3) << 8);
485   mainram[0x740/2] = input_port_read_indexed(machine, 2) | (input_port_read_indexed(machine, 3) << 8);
480486   mainram[0x742/2] = 0xffff;
481   mainram[0x744/2] = readinputport(0) | (readinputport(1) << 8);
487   mainram[0x744/2] = input_port_read_indexed(machine, 0) | (input_port_read_indexed(machine, 1) << 8);
482488   mainram[0x746/2] = 0xffff;
483489   mainram[0x748/2] = 0xffff;
484490   mainram[0x74a/2] = 0xffff;
485   mainram[0x74c/2] = readinputport(4) | 0xff00;
491   mainram[0x74c/2] = input_port_read_indexed(machine, 4) | 0xff00;
486492   mainram[0x74e/2] = 0xffff;
487493
488494   cpunum_set_input_line_and_vector(machine, cpunum, 0, HOLD_LINE, 0xc0/4);   /* VBL */
r2375r2376
491497
492498
493499
494//  COPX functions, terribly incomplete
495500
496typedef struct _cop_state cop_state;
497struct _cop_state
498{
499   UINT16      offset;                  /* last write offset */
500   UINT16      ram[0x200/2];            /* RAM from 0x400-0x5ff */
501
502   UINT32      reg[4];                  /* registers */
503
504   UINT16      func_trigger[0x100/8];      /* function trigger */
505   UINT16      func_value[0x100/8];      /* function value (?) */
506   UINT16      func_mask[0x100/8];         /* function mask (?) */
507   UINT16      program[0x100];            /* program "code" */
508};
509
510static cop_state cop_data;
511
512
513#define VERBOSE 1
514#define COP_LOG(x)   do { if (VERBOSE) logerror x; } while (0)
515
516
517
518INLINE UINT16 cop_ram_r(cop_state *cop, UINT16 offset)
519{
520   return cop->ram[(offset - 0x400) / 2];
521}
522
523INLINE void cop_ram_w(cop_state *cop, UINT16 offset, UINT16 data)
524{
525   cop->ram[(offset - 0x400) / 2] = data;
526}
527
528INLINE UINT32 r32(offs_t address)
529{
530   return    (program_read_word(address + 0) << 0) |
531         (program_read_word(address + 2) << 16);
532}
533
534INLINE void w32(offs_t address, UINT32 data)
535{
536   program_write_word(address + 0, data >> 0);
537   program_write_word(address + 2, data >> 16);
538}
539
540
541static void cop_init(void)
542{
543   memset(&cop_data, 0, sizeof(cop_data));
544}
545
546
547static WRITE16_HANDLER( cop_w )
548{
549   cop_state *cop = &cop_data;
550   UINT32 temp32;
551   UINT8 regnum;
552   int func;
553
554   /* all COP data writes are word-length (?) */
555   data = COMBINE_DATA(&cop->ram[offset]);
556
557   /* handle writes */
558   switch (offset + 0x400)
559   {
560      /* ----- BCD conversion ----- */
561
562      case 0x420:      /* LSW of number */
563      case 0x422:      /* MSW of number */
564         temp32 = cop_ram_r(cop, 0x420) | (cop_ram_r(cop, 0x422) << 16);
565         cop_ram_w(cop, 0x590, ((temp32 / 1) % 10) + (((temp32 / 10) % 10) << 8) + 0x3030);
566         cop_ram_w(cop, 0x592, ((temp32 / 100) % 10) + (((temp32 / 1000) % 10) << 8) + 0x3030);
567         cop_ram_w(cop, 0x594, ((temp32 / 10000) % 10) + (((temp32 / 100000) % 10) << 8) + 0x3030);
568         cop_ram_w(cop, 0x596, ((temp32 / 1000000) % 10) + (((temp32 / 10000000) % 10) << 8) + 0x3030);
569         cop_ram_w(cop, 0x598, ((temp32 / 100000000) % 10) + (((temp32 / 1000000000) % 10) << 8) + 0x3030);
570         break;
571
572      /* ----- program upload registers ----- */
573
574      case 0x432:      /* COP program data */
575         COP_LOG(("%05X:COP Prog Data = %04X\n", activecpu_get_pc(), data));
576         cop->program[cop_ram_r(cop, 0x434)] = data;
577         break;
578
579      case 0x434:      /* COP program address */
580         COP_LOG(("%05X:COP Prog Addr = %04X\n", activecpu_get_pc(), data));
581         assert((data & ~0xff) == 0);
582         temp32 = (data & 0xff) / 8;
583         cop->func_value[temp32] = cop_ram_r(cop, 0x438);
584         cop->func_mask[temp32] = cop_ram_r(cop, 0x43a);
585         cop->func_trigger[temp32] = cop_ram_r(cop, 0x43c);
586         break;
587
588      case 0x438:      /* COP program entry value (0,4,5,6,7,8,9,F) */
589         COP_LOG(("%05X:COP Prog Val  = %04X\n", activecpu_get_pc(), data));
590         break;
591
592      case 0x43a:      /* COP program entry mask */
593         COP_LOG(("%05X:COP Prog Mask = %04X\n", activecpu_get_pc(), data));
594         break;
595
596      case 0x43c:      /* COP program trigger value */
597         COP_LOG(("%05X:COP Prog Trig = %04X\n", activecpu_get_pc(), data));
598         break;
599
600      /* ----- ???? ----- */
601
602      case 0x47a:      /* clear RAM */
603         if (cop_ram_r(cop, 0x47e) == 0x118)
604         {
605            UINT32 addr = cop_ram_r(cop, 0x478) << 6;
606            int count = (cop_ram_r(cop, 0x47a) + 1) << 5;
607            COP_LOG(("%05X:COP RAM clear from %05X to %05X\n", activecpu_get_pc(), addr, addr + count));
608            while (count--)
609               program_write_byte(addr++, 0);
610         }
611         else
612         {
613            COP_LOG(("%05X:COP Unknown RAM clear(%04X) = %04X\n", activecpu_get_pc(), cop_ram_r(cop, 0x47e), data));
614         }
615         break;
616
617      /* ----- program data registers ----- */
618
619      case 0x4a0:      /* COP register high word */
620      case 0x4a2:      /* COP register high word */
621      case 0x4a4:      /* COP register high word */
622      case 0x4a6:      /* COP register high word */
623         regnum = (offset / 2) % 4;
624         COP_LOG(("%05X:COP RegHi(%d) = %04X\n", activecpu_get_pc(), regnum, data));
625         cop->reg[regnum] = (cop->reg[regnum] & 0x0000ffff) | (data << 16);
626         break;
627
628      case 0x4c0:      /* COP register low word */
629      case 0x4c2:      /* COP register low word */
630      case 0x4c4:      /* COP register low word */
631      case 0x4c6:      /* COP register low word */
632         regnum = (offset / 2) % 4;
633         COP_LOG(("%05X:COP RegLo(%d) = %04X\n", activecpu_get_pc(), regnum, data));
634         cop->reg[regnum] = (cop->reg[regnum] & 0xffff0000) | data;
635         break;
636
637      /* ----- program trigger register ----- */
638
639      case 0x500:      /* COP trigger */
640         COP_LOG(("%05X:COP Trigger = %04X\n", activecpu_get_pc(), data));
641         for (func = 0; func < ARRAY_LENGTH(cop->func_trigger); func++)
642            if (cop->func_trigger[func] == data)
643            {
644               int offs;
645
646               COP_LOG(("  Execute:"));
647               for (offs = 0; offs < 8; offs++)
648               {
649                  if (cop->program[func * 8 + offs] == 0)
650                     break;
651                  COP_LOG((" %04X", cop->program[func * 8 + offs]));
652               }
653               COP_LOG(("\n"));
654
655               /* special cases for now */
656               if (data == 0x5205 || data == 0x5a05)
657               {
658                  COP_LOG(("  Copy 32 bits from %05X to %05X\n", cop->reg[0], cop->reg[1]));
659                  w32(cop->reg[1], r32(cop->reg[0]));
660               }
661               else if (data == 0xf205)
662               {
663                  COP_LOG(("  Copy 32 bits from %05X to %05X\n", cop->reg[0] + 4, cop->reg[1]));
664                  w32(cop->reg[2], r32(cop->reg[0] + 4));
665               }
666               break;
667            }
668         assert(func != ARRAY_LENGTH(cop->func_trigger));
669         break;
670
671      /* ----- other stuff ----- */
672
673      default:      /* unknown */
674         COP_LOG(("%05X:COP Unknown(%04X) = %04X\n", activecpu_get_pc(), offset + 0x400, data));
675         break;
676   }
677}
678
679
680static READ16_HANDLER( cop_r )
681{
682   cop_state *cop = &cop_data;
683   COP_LOG(("%05X:COP Read(%04X) = %04X\n", activecpu_get_pc(), offset*2 + 0x400, cop->ram[offset]));
684   return cop->ram[offset];
685}
686
687
688501// Sprite encryption key upload
689502
690503static UINT32 sprcpt_adr, sprcpt_idx;
r2375r2376
935748/* MEMORY MAPS */
936749
937750static ADDRESS_MAP_START( raiden2_mem, ADDRESS_SPACE_PROGRAM, 16 )
938   AM_RANGE(0x00400, 0x005ff) AM_READWRITE(cop_r, cop_w)
751   AM_RANGE(0x00400, 0x005ff) AM_READWRITE(raiden2_cop2_r, raiden2_cop2_w)
939752
940753   AM_RANGE(0x006a0, 0x006a3) AM_WRITE(sprcpt_val_1_w)
941754   AM_RANGE(0x006a4, 0x006a7) AM_WRITE(sprcpt_data_3_w)
r2375r2376
18871700   ROM_LOAD( "6.pcm", 0x00000, 0x40000,  CRC(48be32b1) SHA1(969d2191a3c46871ee8bf93088b3cecce3eccf0c) ) // 6.4a
18881701ROM_END
18891702
1890/* Different hardware, COP-D3? */
1703/* Different hardware, uses COPX-D3 for protection */
18911704ROM_START( nzerotea )
18921705   ROM_REGION( 0x200000, REGION_USER1, 0 ) /* v30 main cpu */
18931706   ROM_LOAD16_BYTE("prg1",   0x000000, 0x80000, CRC(3c7d9410) SHA1(25f2121b6c2be73f11263934266901ed5d64d2ee) )
r2375r2376
20591872
20601873static READ16_HANDLER( rdx_v33_eeprom_r )
20611874{
2062   return readinputport(0) | (EEPROM_read_bit()<<4);
1875   return input_port_read_indexed(machine, 0) | (EEPROM_read_bit()<<4);
20631876}
20641877
20651878
r2375r2376
20931906
20941907static READ16_HANDLER( r2_playerin_r )
20951908{
2096   return readinputport(1);
1909   return input_port_read_indexed(machine, 1);
20971910}
20981911static READ16_HANDLER( rdx_v33_oki_r )
20991912{
r2375r2376
23022115GAME( 1993, zeroteaa, zeroteam,raiden2,  raiden2,  raiden2,  ROT0,   "Seibu Kaihatsu", "Zero Team (set 2)", GAME_NOT_WORKING|GAME_NO_SOUND)
23032116GAME( 1993, zeroteab, zeroteam,raiden2,  raiden2,  raiden2,  ROT0,   "Seibu Kaihatsu", "Zero Team (set 3)", GAME_NOT_WORKING|GAME_NO_SOUND)
23042117GAME( 1993, zerotsel, zeroteam,raiden2,  raiden2,  raiden2,  ROT0,   "Seibu Kaihatsu", "Zero Team Selection", GAME_NOT_WORKING|GAME_NO_SOUND)
2305GAME( 1993, nzerotea, zeroteam,raiden2,  raiden2,  raiden2,  ROT0,   "Seibu Kaihatsu", "New Zero Team", GAME_NOT_WORKING|GAME_NO_SOUND)
23062118
2119// 'V33 system type_b' - uses V33 CPU, COPX-D3 external protection rom, but still has the proper sound system
2120GAME( 1993, nzerotea, zeroteam,raiden2,  raiden2,  raiden2,  ROT0,   "Seibu Kaihatsu", "New Zero Team", GAME_NOT_WORKING|GAME_NO_SOUND) // this uses a v33 and COPD3
2121
23072122// newer PCB, with V33 CPU and COPD3 protection, but weak sound hardware. - was marked as Raiden DX New in the rom dump, but boots as Raiden 2 New version, is it switchable?
23082123GAME( 1996, r2dx_v33, 0, rdx_v33,  rdx_v33, rdx_v33,  ROT270, "Seibu Kaihatsu", "Raiden 2 / DX (newer V33 PCB)", GAME_NOT_WORKING|GAME_NO_SOUND)
src/mame/drivers/system18.c
r2375r2376
490490                  if(io_reg[0x0F] & 0x01)
491491                     return io_reg[0x00];
492492                  else
493                     return readinputport(0);
493                     return input_port_read_indexed(machine, 0);
494494                  break;
495495
496496               case 0x01: /* Port B - 2P controls */
497497                  if(io_reg[0x0F] & 0x02)
498498                     return io_reg[0x01];
499499                  else
500                     return readinputport(1);
500                     return input_port_read_indexed(machine, 1);
501501                  break;
502502
503503               case 0x02: /* Port C - Bidirectional I/O port */
r2375r2376
518518                  if(io_reg[0x0F] & 0x10)
519519                     return io_reg[0x04];
520520                  else
521                     return readinputport(2);
521                     return input_port_read_indexed(machine, 2);
522522                  break;
523523
524524               case 0x05: /* Port F - DIP switch #1 */
525525                  if(io_reg[0x0F] & 0x20)
526526                     return io_reg[0x05];
527527                  else
528                     return readinputport(3);
528                     return input_port_read_indexed(machine, 3);
529529                  break;
530530
531531               case 0x06: /* Port G - DIP switch #2 */
532532                  if(io_reg[0x0F] & 0x40)
533533                     return io_reg[0x06];
534534                  else
535                     return readinputport(4);
535                     return input_port_read_indexed(machine, 4);
536536                  break;
537537
538538               case 0x07: /* Port H - Tile banking control */
src/mame/drivers/taitojc.c
r2375r2376
421421      {
422422         if (ACCESSING_BITS_24_31)
423423         {
424            r |= ((readinputport(0) & 0x2) << 2) << 24;
424            r |= ((input_port_read_indexed(machine, 0) & 0x2) << 2) << 24;
425425         }
426426         return r;
427427      }
r2375r2376
430430         if (ACCESSING_BITS_24_31)
431431         {
432432            UINT32 data = EEPROM_read_bit() & 1;
433            data |= readinputport(0) & 0xfe;
433            data |= input_port_read_indexed(machine, 0) & 0xfe;
434434            r |= data << 24;
435435         }
436436         return r;
r2375r2376
439439      {
440440         if (ACCESSING_BITS_24_31)
441441         {
442            r |= readinputport(1) << 24;
442            r |= input_port_read_indexed(machine, 1) << 24;
443443         }
444444         return r;
445445      }
r2375r2376
447447      {
448448         if (ACCESSING_BITS_24_31)
449449         {
450            r |= readinputport(2) << 24;
450            r |= input_port_read_indexed(machine, 2) << 24;
451451         }
452452         return r;
453453      }
r2375r2376
463463      {
464464         if (ACCESSING_BITS_24_31)
465465         {
466            r |= readinputport(3) << 24;
466            r |= input_port_read_indexed(machine, 3) << 24;
467467         }
468468         return r;
469469      }
r2375r2376
869869
870870static READ8_HANDLER(hc11_analog_r)
871871{
872   return readinputport(4 + offset);
872   return input_port_read_indexed(machine, 4 + offset);
873873}
874874
875875
r2375r2376
14231423    */
14241424ROM_END
14251425
1426ROM_START( sidebs2j )
1427   ROM_REGION(0x200000, REGION_CPU1, 0)      /* 68040 code */
1428    ROM_LOAD32_BYTE( "e38-23.36", 0x000000, 0x80000, CRC(b3d8e2d9) SHA1(6de6a51c3d9ace532fa03517bab93101b5a3eaae) )
1429   ROM_LOAD32_BYTE( "e38-24.37", 0x000001, 0x80000, CRC(2a47d80d) SHA1(41b889e4a1397c7f0d4f6ef136ed8abfd7e1ed86) )
1430   ROM_LOAD32_BYTE( "e38-25.38", 0x000002, 0x80000, CRC(f1a8a4df) SHA1(e4cf75969fb0503df2290522194b097f5cb983a3) )
1431   ROM_LOAD32_BYTE( "e38-26.39", 0x000003, 0x80000, CRC(b550fbf2) SHA1(a0a461af7e71c6ad6468cfdee2bc7161ae31bbfb) )
1432
1433   ROM_REGION( 0x180000, REGION_CPU2, 0 )      /* 68000 Code */
1434   ROM_LOAD16_BYTE( "e38-19.30", 0x100001, 0x040000, CRC(3f50cb7b) SHA1(76af65c9b74ede843a3182f79cecda8c3e3febe6) )
1435   ROM_LOAD16_BYTE( "e38-20.31", 0x100000, 0x040000, CRC(d01340e7) SHA1(76ee48d644dc1ec415d47e0df4864c64ac928b9d) )
1436
1437   ROM_REGION( 0x010000, REGION_USER1, 0 )      /* MC68HC11M0 code */
1438   ROM_LOAD( "e17-23.65",  0x000000, 0x010000, CRC(80ac1428) SHA1(5a2a1e60a11ecdb8743c20ddacfb61f9fd00f01c) )
1439
1440   ROM_REGION( 0x00080, REGION_USER2, 0 )      /* eeprom */
1441   ROM_LOAD( "93c46.87",  0x000000, 0x000080, CRC(50fdcce0) SHA1(6e901856755ccdcf478a457c510c0de58683216a) )
1442
1443   ROM_REGION( 0x1800000, REGION_GFX1, 0 )
1444   ROM_LOAD32_WORD( "e38-05.9",  0x0800002, 0x200000, CRC(bda366bf) SHA1(a7558e6d5e4583a2d8e3d2bfa8cabcc459d3ee83) )
1445   ROM_LOAD32_WORD( "e38-13.22", 0x0800000, 0x200000, CRC(1bd7582b) SHA1(35763b9489f995433f66ef72d4f6b6ac67df5480) )
1446   ROM_LOAD32_WORD( "e38-06.10", 0x0c00002, 0x200000, CRC(308d2783) SHA1(22c309273444bc6c1df78069850958a739664998) )
1447   ROM_LOAD32_WORD( "e38-14.23", 0x0c00000, 0x200000, CRC(f1699f27) SHA1(3c9a9cefe6f215fd9f0a9746da97147d14df1da4) )
1448   ROM_LOAD32_WORD( "e38-07.11", 0x1000002, 0x200000, CRC(226ba93d) SHA1(98e6342d070ddd988c1e9bff21afcfb28df86844) )
1449   ROM_LOAD32_WORD( "e38-15.24", 0x1000000, 0x200000, CRC(2853c2e3) SHA1(046dbbd4bcb3b07cddab19a284fee9fe736f8def) )
1450   ROM_LOAD32_WORD( "e38-08.12", 0x1400002, 0x200000, CRC(9c513b32) SHA1(fe26e39d3d65073d23d525bc17771f0c244a38c2) )
1451   ROM_LOAD32_WORD( "e38-16.25", 0x1400000, 0x200000, CRC(fceafae2) SHA1(540ecd5d1aa64c0428a08ea1e4e634e00f7e6bd6) )
1452
1453   ROM_REGION( 0x1000000, REGION_GFX2, 0 )      /* only accessible to the TMS */
1454   ROM_LOAD( "e38-01.5",  0x0000000, 0x200000, CRC(a3c2e2c7) SHA1(538208534f996782167e4cf0d157ad93ce2937bd) )
1455   ROM_LOAD( "e38-02.6",  0x0200000, 0x200000, CRC(ecdfb75a) SHA1(85e7afa321846816fa3bd9074ad9dec95abe23fe) )
1456   ROM_LOAD( "e38-03.7",  0x0400000, 0x200000, CRC(28e9cb59) SHA1(a2651fd81a1263573f868864ee049f8fc4177ffa) )
1457   ROM_LOAD( "e38-04.8",  0x0600000, 0x080000, CRC(26cab05b) SHA1(d5bcf021646dade834840051e0ce083319c53985) )
1458   ROM_RELOAD( 0x680000, 0x80000 )
1459   ROM_RELOAD( 0x700000, 0x80000 )
1460   ROM_RELOAD( 0x780000, 0x80000 )
1461   ROM_LOAD( "e38-09.18", 0x0800000, 0x200000, CRC(03c95a7f) SHA1(fc046cf5fcfcf5648f68af4bed78576f6d67b32f) )
1462   ROM_LOAD( "e38-10.19", 0x0a00000, 0x200000, CRC(0fb06794) SHA1(2d0e3b07ded698235572fe9e907a84d5779ac2c5) )
1463   ROM_LOAD( "e38-11.20", 0x0c00000, 0x200000, CRC(6a312351) SHA1(8037e377f8eef4cc6dd84aec9c829106f0bb130c) )
1464   ROM_LOAD( "e38-12.21", 0x0e00000, 0x080000, CRC(193a5774) SHA1(aa017ae4fec92bb87c0eb94f59d093853ddbabc9) )
1465   ROM_RELOAD( 0xe80000, 0x80000 )
1466   ROM_RELOAD( 0xf00000, 0x80000 )
1467   ROM_RELOAD( 0xf80000, 0x80000 )
1468
1469   ROM_REGION16_BE( 0x1000000, REGION_SOUND1, ROMREGION_ERASE00  )
1470   ROM_LOAD16_BYTE( "e23-15.32", 0x000000, 0x200000, CRC(8955b7c7) SHA1(767626bd5cf6810b0368ee85e487c12ef7e8a23d) ) // from sidebs (redump)
1471   ROM_LOAD16_BYTE( "e38-17.33", 0x400000, 0x200000, CRC(61e81c7f) SHA1(aa650bc139685ad456c233b79aa60005a8fd6d79) )
1472   ROM_LOAD16_BYTE( "e38-18.34", 0x800000, 0x200000, CRC(43e2f149) SHA1(32ea9156948a886dda5bd071e9f493ddc2b06212) )
1473   ROM_LOAD16_BYTE( "e38-21.35", 0xc00000, 0x200000, CRC(25373c5f) SHA1(ab9f917dbde7c808be2cd836ce2d3fc558e290f1) )
1474
1475   /* PALS
1476    e23-28.18    NOT A ROM
1477    e23-27.13    NOT A ROM
1478    e23-26.4     NOT A ROM
1479    e23-25-1.3   NOT A ROM
1480    e23-30.40    NOT A ROM
1481    e23-29.39    NOT A ROM
1482    e23-31.46    NOT A ROM
1483    e23-32-1.51  NOT A ROM
1484    e23-34.72    NOT A ROM
1485    e23-33.53    NOT A ROM
1486    e23-35.110   NOT A ROM
1487    e23-38.73    NOT A ROM
1488    e23-37.69    NOT A ROM
1489    */
1490ROM_END
1491
14261492ROM_START( dendeg )
14271493   ROM_REGION(0x200000, REGION_CPU1, 0)      /* 68040 code */
14281494    ROM_LOAD32_BYTE( "e35-21.036", 0x000000, 0x80000, CRC(bc70ca97) SHA1(724a24da9d6f163c26e7528ee2c15bd06f2c4382) )
r2375r2376
17251791GAME( 1998, dendeg2x, dendeg2, taitojc, dendeg,   taitojc,  ROT0, "Taito", "Densya De Go 2 Ex", GAME_NOT_WORKING )
17261792GAME( 1996, sidebs,   0,       taitojc, sidebs,   taitojc,  ROT0, "Taito", "Side By Side", GAME_NOT_WORKING )
17271793GAME( 1997, sidebs2,  0,       taitojc, sidebs,   taitojc,  ROT0, "Taito", "Side By Side 2", GAME_IMPERFECT_GRAPHICS )
1794GAME( 1997, sidebs2j, sidebs2, taitojc, sidebs,   taitojc,  ROT0, "Taito", "Side By Side 2 (Japan)", GAME_IMPERFECT_GRAPHICS )
17281795GAME( 1995, landgear, 0,       taitojc, landgear, taitojc,  ROT0, "Taito", "Landing Gear", GAME_NOT_WORKING )
17291796GAME( 1995, dangcurv, 0,       taitojc, dangcurv, taitojc,  ROT0, "Taito", "Dangerous Curves", GAME_NOT_WORKING )
src/mame/drivers/liberatr.c
r2375r2376
177177   /* input becomes the starting point for the trackball counters */
178178   if (((data ^ ctrld) & 0x10) && (data & 0x10))
179179   {
180      UINT8 trackball = readinputport(4);
181      UINT8 switches = readinputport(0);
180      UINT8 trackball = input_port_read_indexed(machine, 4);
181      UINT8 switches = input_port_read_indexed(machine, 0);
182182      trackball_offset = ((trackball & 0xf0) - (switches & 0xf0)) | ((trackball - switches) & 0x0f);
183183   }
184184   ctrld = data & 0x10;
r2375r2376
190190   /* if ctrld is high, the /ld signal on the LS191 is NOT set, meaning that the trackball is counting */
191191   if (ctrld)
192192   {
193      UINT8 trackball = readinputport(4);
193      UINT8 trackball = input_port_read_indexed(machine, 4);
194194      return ((trackball & 0xf0) - (trackball_offset & 0xf0)) | ((trackball - trackball_offset) & 0x0f);
195195   }
196196
197197   /* otherwise, the LS191 is simply passing through the raw switch inputs */
198198   else
199      return readinputport(0);
199      return input_port_read_indexed(machine, 0);
200200}
201201
202202
src/mame/drivers/berzerk.c
r2375r2376
383383}
384384
385385
386static void get_pens(pen_t *pens)
386static void get_pens(running_machine *machine, pen_t *pens)
387387{
388388   static const int resistances_wg[] = { 750, 0 };
389389   static const int resistances_el[] = { 1.0 / ((1.0 / 750.0) + (1.0 / 360.0)), 0 };
r2375r2376
391391   int color;
392392   double color_weights[2];
393393
394   if (readinputportbytag(MONITOR_TYPE_PORT_TAG) == 0)
394   if (input_port_read(machine, MONITOR_TYPE_PORT_TAG) == 0)
395395      compute_resistor_weights(0, 0xff, -1.0,
396396                         2, resistances_wg, color_weights, 0, 270,
397397                         2, resistances_wg, color_weights, 0, 270,
r2375r2376
423423   pen_t pens[NUM_PENS];
424424   offs_t offs;
425425
426   get_pens(pens);
426   get_pens(screen->machine, pens);
427427
428428   for (offs = 0; offs < berzerk_videoram_size; offs++)
429429   {
src/mame/drivers/tehkanwc.c
r2375r2376
133133{
134134   int joy;
135135
136   joy = readinputport(10) >> (2*offset);
136   joy = input_port_read_indexed(machine, 10) >> (2*offset);
137137   if (joy & 1) return -63;
138138   if (joy & 2) return 63;
139   return readinputport(3 + offset) - track0[offset];
139   return input_port_read_indexed(machine, 3 + offset) - track0[offset];
140140}
141141
142142static READ8_HANDLER( tehkanwc_track_1_r )
143143{
144144   int joy;
145145
146   joy = readinputport(10) >> (4+2*offset);
146   joy = input_port_read_indexed(machine, 10) >> (4+2*offset);
147147   if (joy & 1) return -63;
148148   if (joy & 2) return 63;
149   return readinputport(6 + offset) - track1[offset];
149   return input_port_read_indexed(machine, 6 + offset) - track1[offset];
150150}
151151
152152static WRITE8_HANDLER( tehkanwc_track_0_reset_w )
153153{
154154   /* reset the trackball counters */
155   track0[offset] = readinputport(3 + offset) + data;
155   track0[offset] = input_port_read_indexed(machine, 3 + offset) + data;
156156}
157157
158158static WRITE8_HANDLER( tehkanwc_track_1_reset_w )
159159{
160160   /* reset the trackball counters */
161   track1[offset] = readinputport(6 + offset) + data;
161   track1[offset] = input_port_read_indexed(machine, 6 + offset) + data;
162162}
163163
164164
src/mame/drivers/bionicc.c
r2375r2376
2626      - sprite / background priority ( see level 1: birds walk through
2727        branches of different trees )
2828      - see the beginning of level 3: background screwed
29      - gray tiles around the title in Top Secret
2930
3031ToDo:
3132- get rid of input port hack
r2375r2376
9697
9798static WRITE16_HANDLER( bionicc_mpu_trigger_w )
9899{
99   data = readinputport(0) >> 12;
100   data = input_port_read_indexed(machine, 0) >> 12;
100101   bionicc_inp[0] = data ^ 0x0f;
101102
102   data = readinputport(3); /* player 2 controls */
103   data = input_port_read_indexed(machine, 3); /* player 2 controls */
103104   bionicc_inp[1] = data ^ 0xff;
104105
105   data = readinputport(2); /* player 1 controls */
106   data = input_port_read_indexed(machine, 2); /* player 1 controls */
106107   bionicc_inp[2] = data ^ 0xff;
107108}
108109
src/mame/drivers/citycon.c
r2375r2376
2121
2222static READ8_HANDLER( citycon_in_r )
2323{
24   return readinputport(flip_screen_get() ? 1 : 0);
24   return input_port_read_indexed(machine, flip_screen_get() ? 1 : 0);
2525}
2626
2727
src/mame/drivers/suprridr.c
r2375r2376
229229
230230   /* screen flip multiplexes controls */
231231   if (suprridr_is_screen_flipped())
232      ret = readinputportbytag(SUPRRIDR_P2_CONTROL_PORT_TAG);
232      ret = input_port_read(machine, SUPRRIDR_P2_CONTROL_PORT_TAG);
233233   else
234      ret = readinputportbytag(SUPRRIDR_P1_CONTROL_PORT_TAG);
234      ret = input_port_read(machine, SUPRRIDR_P1_CONTROL_PORT_TAG);
235235
236236   return ret;
237237}
r2375r2376
352352static MACHINE_DRIVER_START( suprridr )
353353
354354   /* basic machine hardware */
355   MDRV_CPU_ADD(Z80, 10000000/4)      /* just a guess */
355   MDRV_CPU_ADD(Z80, XTAL_49_152MHz/16)      /* 3 MHz */
356356   MDRV_CPU_PROGRAM_MAP(main_map,0)
357357   MDRV_CPU_IO_MAP(main_portmap,0)
358358   MDRV_CPU_VBLANK_INT("main", main_nmi_gen)
359359
360   MDRV_CPU_ADD(Z80, 10000000/4)      /* just a guess */
360   MDRV_CPU_ADD(Z80, 10000000/4)      /* 2.5 MHz */
361361   /* audio CPU */
362362   MDRV_CPU_PROGRAM_MAP(sound_map,0)
363363   MDRV_CPU_IO_MAP(sound_portmap,0)
r2375r2376
380380   /* sound hardware */
381381   MDRV_SPEAKER_STANDARD_MONO("mono")
382382
383   MDRV_SOUND_ADD(AY8910, 10000000/8)
383   MDRV_SOUND_ADD(AY8910, XTAL_49_152MHz/32)
384384   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
385385
386   MDRV_SOUND_ADD(AY8910, 10000000/8)
386   MDRV_SOUND_ADD(AY8910, XTAL_49_152MHz/32)
387387   MDRV_SOUND_CONFIG(ay8910_interface)
388388   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
389389MACHINE_DRIVER_END
src/mame/drivers/psikyo.c
r2375r2376
101101
102102***************************************************************************/
103103
104static int psikyo_readcoinport(int has_mcu)
104static int psikyo_readcoinport(running_machine *machine, int has_mcu)
105105{
106   int ret = readinputport(1) & ~0x84;
106   int ret = input_port_read_indexed(machine, 1) & ~0x84;
107107
108108   if (has_mcu)
109109   {
r2375r2376
142142{
143143   switch(offset)
144144   {
145      case 0x0:   return (readinputport(0) << 16) | 0xffff;
146      case 0x1:   return (readinputport(2) << 16) | readinputport(4);
147      case 0x2:   return (psikyo_readcoinport(0) << 16) | readinputport(3);
145      case 0x0:   return (input_port_read_indexed(machine, 0) << 16) | 0xffff;
146      case 0x1:   return (input_port_read_indexed(machine, 2) << 16) | input_port_read_indexed(machine, 4);
147      case 0x2:   return (psikyo_readcoinport(machine, 0) << 16) | input_port_read_indexed(machine, 3);
148148      default:   logerror("PC %06X - Read input %02X !\n", activecpu_get_pc(), offset*2);
149149               return 0;
150150   }
r2375r2376
154154{
155155   switch(offset)
156156   {
157      case 0x0:   return (readinputport(0) << 16) | psikyo_readcoinport(0);
158      case 0x1:   return (readinputport(2) << 16) | readinputport(3);
157      case 0x0:   return (input_port_read_indexed(machine, 0) << 16) | psikyo_readcoinport(machine, 0);
158      case 0x1:   return (input_port_read_indexed(machine, 2) << 16) | input_port_read_indexed(machine, 3);
159159      default:   logerror("PC %06X - Read input %02X !\n", activecpu_get_pc(), offset*2);
160160               return 0;
161161   }
r2375r2376
310310{
311311   switch(offset)
312312   {
313      case 0x0:   return (readinputport(0) << 16) | psikyo_readcoinport(1);
314      case 0x1:   return (((readinputport(2) << 16) | readinputport(3)) & 0xffff000f) | s1945_mcu_r(machine, offset-1, mem_mask);
313      case 0x0:   return (input_port_read_indexed(machine, 0) << 16) | psikyo_readcoinport(machine, 1);
314      case 0x1:   return (((input_port_read_indexed(machine, 2) << 16) | input_port_read_indexed(machine, 3)) & 0xffff000f) | s1945_mcu_r(machine, offset-1, mem_mask);
315315      case 0x2:   return s1945_mcu_r(machine, offset-1, mem_mask);
316316      default:   logerror("PC %06X - Read input %02X !\n", activecpu_get_pc(), offset*2);
317317               return 0;
src/mame/drivers/playmark.c
r2375r2376
137137
138138   bit = EEPROM_read_bit() << 7;
139139
140   return (input_port_0_r(machine,0) & 0x7f) | bit;
140   return (input_port_read_indexed(machine, 0) & 0x7f) | bit;
141141}
142142
143143static READ16_HANDLER( hotmind_port2_r )
r2375r2376
146146
147147   bit = EEPROM_read_bit() << 7;
148148
149   return (input_port_2_r(machine,0) & 0x7f) | bit;
149   return (input_port_read_indexed(machine, 2) & 0x7f) | bit;
150150}
151151
152152static WRITE16_HANDLER( wbeachvl_coin_eeprom_w )
src/mame/drivers/model3.c
r2375r2376
10581058         {
10591059            if(model3_controls_bank & 0x1) {
10601060               eeprom_bit = EEPROM_read_bit() << 5;
1061               return ((readinputport(1) & ~0x20) | eeprom_bit) << 24;
1061               return ((input_port_read_indexed(machine, 1) & ~0x20) | eeprom_bit) << 24;
10621062            }
10631063            else {
1064               return (readinputport(0)) << 24;
1064               return (input_port_read_indexed(machine, 0)) << 24;
10651065            }
10661066         }
10671067         break;
r2375r2376
10691069      case 1:
10701070         if (ACCESSING_BITS_56_63)
10711071         {
1072            return (UINT64)readinputport(2) << 56;
1072            return (UINT64)input_port_read_indexed(machine, 2) << 56;
10731073         }
10741074         else if (ACCESSING_BITS_24_31)
10751075         {
1076            return readinputport(3) << 24;
1076            return input_port_read_indexed(machine, 3) << 24;
10771077         }
10781078         break;
10791079
r2375r2376
11071107      case 7:
11081108         if (ACCESSING_BITS_24_31)      /* ADC Data read */
11091109         {
1110            UINT8 adc_data = readinputport(5 + adc_channel);
1110            UINT8 adc_data = input_port_read_indexed(machine, 5 + adc_channel);
11111111            adc_channel++;
11121112            adc_channel &= 0x7;
11131113            return (UINT64)adc_data << 24;
r2375r2376
11591159                  switch(lightgun_reg_sel)      /* read lightrun register */
11601160                  {
11611161                     case 0:      /* player 1 gun X-position, lower 8-bits */
1162                        model3_serial_fifo2 = readinputport(6) & 0xff;
1162                        model3_serial_fifo2 = input_port_read_indexed(machine, 6) & 0xff;
11631163                        break;
11641164                     case 1:      /* player 1 gun X-position, upper 2-bits */
1165                        model3_serial_fifo2 = (readinputport(6) >> 8) & 0x3;
1165                        model3_serial_fifo2 = (input_port_read_indexed(machine, 6) >> 8) & 0x3;
11661166                        break;
11671167                     case 2:      /* player 1 gun Y-position, lower 8-bits */
1168                        model3_serial_fifo2 = readinputport(5) & 0xff;
1168                        model3_serial_fifo2 = input_port_read_indexed(machine, 5) & 0xff;
11691169                        break;
11701170                     case 3:      /* player 1 gun Y-position, upper 2-bits */
1171                        model3_serial_fifo2 = (readinputport(5) >> 8) & 0x3;
1171                        model3_serial_fifo2 = (input_port_read_indexed(machine, 5) >> 8) & 0x3;
11721172                        break;
11731173                     case 4:      /* player 2 gun X-position, lower 8-bits */
1174                        model3_serial_fifo2 = readinputport(8) & 0xff;
1174                        model3_serial_fifo2 = input_port_read_indexed(machine, 8) & 0xff;
11751175                        break;
11761176                     case 5:      /* player 2 gun X-position, upper 2-bits */
1177                        model3_serial_fifo2 = (readinputport(8) >> 8) & 0x3;
1177                        model3_serial_fifo2 = (input_port_read_indexed(machine, 8) >> 8) & 0x3;
11781178                        break;
11791179                     case 6:      /* player 2 gun Y-position, lower 8-bits */
1180                        model3_serial_fifo2 = readinputport(7) & 0xff;
1180                        model3_serial_fifo2 = input_port_read_indexed(machine, 7) & 0xff;
11811181                        break;
11821182                     case 7:      /* player 2 gun Y-position, upper 2-bits */
1183                        model3_serial_fifo2 = (readinputport(7) >> 8) & 0x3;
1183                        model3_serial_fifo2 = (input_port_read_indexed(machine, 7) >> 8) & 0x3;
11841184                        break;
11851185                     case 8:      /* gun offscreen (bit set = gun offscreen, bit clear = gun on screen) */
11861186                        model3_serial_fifo2 = 0;   /* bit 0 = player 1, bit 1 = player 2 */
1187                        if(readinputport(9) & 0x1) {
1187                        if(input_port_read_indexed(machine, 9) & 0x1) {
11881188                           model3_serial_fifo2 |= 0x01;
11891189                        }
11901190                        break;
src/mame/drivers/pgm.c
r2375r2376
20612061      else if(kb_cmd==5)
20622062      {
20632063         UINT32 protvalue;
2064         protvalue = 0x89911400|readinputport(4); // region
2064         protvalue = 0x89911400|input_port_read_indexed(machine, 4); // region
20652065         res=(protvalue>>(8*(ptr-1)))&0xff;
20662066
20672067      }
r2375r2376
21402140{
21412141   if (PGMLOGERROR) logerror("prot_r %04x, %04x\n", offset,ddp2_protram[offset]);
21422142
2143   if (offset == 0x02/2) return readinputport(4);
2143   if (offset == 0x02/2) return input_port_read_indexed(machine, 4);
21442144
21452145   if (offset == 0x1f00/2) return 0;
21462146
r2375r2376
22522252         res=olds_cmd3;
22532253      else if(kb_cmd==5)
22542254      {
2255         UINT32 protvalue = 0x900000|readinputport(4); // region from protection device.
2255         UINT32 protvalue = 0x900000|input_port_read_indexed(machine, 4); // region from protection device.
22562256         res=(protvalue>>(8*(ptr-1)))&0xff; // includes region 1 = taiwan , 2 = china, 3 = japan (title = orlegend special), 4 = korea, 5 = hongkong, 6 = world
22572257
22582258      }
src/mame/drivers/gameplan.c
r2375r2376
9898{
9999   gameplan_state *state = machine->driver_data;
100100
101   return readinputport(state->current_port);
101   return input_port_read_indexed(machine, state->current_port);
102102}
103103
104104
src/mame/drivers/capbowl.c
r2375r2376
111111
112112static INTERRUPT_GEN( capbowl_interrupt )
113113{
114   if (readinputport(4) & 1)   /* get status of the F2 key */
114   if (input_port_read_indexed(machine, 4) & 1)   /* get status of the F2 key */
115115      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);   /* trigger self test */
116116}
117117
src/mame/drivers/darius.c
r2375r2376
11921192}
11931193
11941194
1195static STATE_POSTLOAD( darius_postload )
1196{
1197   parse_control();
1198   reset_sound_region();
1199}
1200
11951201static MACHINE_START( darius )
11961202{
11971203   state_save_register_global(cpua_ctrl);
1198   state_save_register_func_postload(parse_control);
11991204
12001205   // (there are other sound vars that may need saving too) //
12011206   state_save_register_global(banknum);
12021207   state_save_register_global(adpcm_command);
12031208   state_save_register_global(nmi_enable);
1204   state_save_register_func_postload(reset_sound_region);
1209   state_save_register_postload(machine, darius_postload, NULL);
12051210}
12061211
12071212
src/mame/drivers/ssingles.c
r2375r2376
146146static READ8_HANDLER(controls_r)
147147{
148148   int data=7;
149   switch(input_port_1_r(machine,0)) //multiplexed
149   switch(input_port_read_indexed(machine, 1)) //multiplexed
150150   {
151151      case 0x01: data=1; break;
152152      case 0x02: data=2; break;
r2375r2376
156156      case 0x20: data=6; break;
157157      case 0x40: data=0; break;
158158   }
159   return (input_port_0_r(machine,0)&(~0x1c))|(data<<2);
159   return (input_port_read_indexed(machine, 0)&(~0x1c))|(data<<2);
160160}
161161
162162static ADDRESS_MAP_START( ssingles_map, ADDRESS_SPACE_PROGRAM, 8 )
src/mame/drivers/kinst.c
r2375r2376
313313   switch (offset)
314314   {
315315      case 2:      /* $90 -- sound return */
316         result = 0xffff0000 | readinputport(offset);
316         result = 0xffff0000 | input_port_read_indexed(machine, offset);
317317         result &= ~0x0002;
318318         if (dcs_control_r() & 0x800)
319319            result |= 0x0002;
r2375r2376
322322      case 0:      /* $80 */
323323      case 1:      /* $88 */
324324      case 3:      /* $98 */
325         result = 0xffff0000 | readinputport(offset);
325         result = 0xffff0000 | input_port_read_indexed(machine, offset);
326326         break;
327327
328328      case 4:      /* $a0 */
329         result = 0xffff0000 | readinputport(offset);
329         result = 0xffff0000 | input_port_read_indexed(machine, offset);
330330         if (activecpu_get_pc() == 0x802d428)
331331            cpu_spinuntil_int();
332332         break;
src/mame/drivers/cbasebal.c
r2375r2376
122122
123123   bit = EEPROM_read_bit() << 7;
124124
125   return (input_port_2_r(machine,0) & 0x7f) | bit;
125   return (input_port_read_indexed(machine, 2) & 0x7f) | bit;
126126}
127127
128128static WRITE8_HANDLER( eeprom_cs_w )
src/mame/drivers/beathead.c
r2375r2376
270270
271271static READ32_HANDLER( input_0_r )
272272{
273   return readinputport(0);
273   return input_port_read_indexed(machine, 0);
274274}
275275
276276
277277static READ32_HANDLER( input_1_r )
278278{
279   return readinputport(1);
279   return input_port_read_indexed(machine, 1);
280280}
281281
282282
283283static READ32_HANDLER( input_2_r )
284284{
285   int result = readinputport(2);
285   int result = input_port_read_indexed(machine, 2);
286286   if (atarigen_sound_to_cpu_ready) result ^= 0x10;
287287   if (atarigen_cpu_to_sound_ready) result ^= 0x20;
288288   return result;
r2375r2376
291291
292292static READ32_HANDLER( input_3_r )
293293{
294   return readinputport(3);
294   return input_port_read_indexed(machine, 3);
295295}
296296
297297
src/mame/drivers/st0016.c
r2375r2376
4444        xxxx - input port #2
4545    xxxx     - dip switches (2x8 bits) (multiplexed)
4646*/
47   int retval=input_port_2_r(machine,0)&0x0f;
47   int retval=input_port_read_indexed(machine, 2)&0x0f;
4848   switch(mux_port&0x30)
4949   {
50      case 0x00: retval|=((input_port_4_r(machine,0)&1)<<4)|((input_port_4_r(machine,0)&0x10)<<1)|((input_port_5_r(machine,0)&1)<<6)|((input_port_5_r(machine,0)&0x10)<<3);break;
51      case 0x10: retval|=((input_port_4_r(machine,0)&2)<<3)|((input_port_4_r(machine,0)&0x20)   )|((input_port_5_r(machine,0)&2)<<5)|((input_port_5_r(machine,0)&0x20)<<2);break;
52      case 0x20: retval|=((input_port_4_r(machine,0)&4)<<2)|((input_port_4_r(machine,0)&0x40)>>1)|((input_port_5_r(machine,0)&4)<<4)|((input_port_5_r(machine,0)&0x40)<<1);break;
53      case 0x30: retval|=((input_port_4_r(machine,0)&8)<<1)|((input_port_4_r(machine,0)&0x80)>>2)|((input_port_5_r(machine,0)&8)<<3)|((input_port_5_r(machine,0)&0x80)   );break;
50      case 0x00: retval|=((input_port_read_indexed(machine, 4)&1)<<4)|((input_port_read_indexed(machine, 4)&0x10)<<1)|((input_port_read_indexed(machine, 5)&1)<<6)|((input_port_read_indexed(machine, 5)&0x10)<<3);break;
51      case 0x10: retval|=((input_port_read_indexed(machine, 4)&2)<<3)|((input_port_read_indexed(machine, 4)&0x20)   )|((input_port_read_indexed(machine, 5)&2)<<5)|((input_port_read_indexed(machine, 5)&0x20)<<2);break;
52      case 0x20: retval|=((input_port_read_indexed(machine, 4)&4)<<2)|((input_port_read_indexed(machine, 4)&0x40)>>1)|((input_port_read_indexed(machine, 5)&4)<<4)|((input_port_read_indexed(machine, 5)&0x40)<<1);break;
53      case 0x30: retval|=((input_port_read_indexed(machine, 4)&8)<<1)|((input_port_read_indexed(machine, 4)&0x80)>>2)|((input_port_read_indexed(machine, 5)&8)<<3)|((input_port_read_indexed(machine, 5)&0x80)   );break;
5454   }
5555   return retval;
5656}
src/mame/drivers/xexex.c
r2375r2376
608608   K054539_init_flags(0, K054539_REVERSE_STEREO);
609609}
610610
611static STATE_POSTLOAD( xexex_postload )
612{
613   parse_control2();
614   reset_sound_region();
615}
616
611617static MACHINE_START( xexex )
612618{
613619   state_save_register_global(cur_control2);
614   state_save_register_func_postload(parse_control2);
615620   state_save_register_global(cur_sound_region);
616   state_save_register_func_postload(reset_sound_region);
621   state_save_register_postload(machine, xexex_postload, NULL);
617622
618623   resume_trigger = 1000;
619624
src/mame/drivers/marinedt.c
r2375r2376
133133//might need to be reversed for cocktail stuff
134134
135135   /* x/y multiplexed */
136   return readinputport(3 + ((marinedt_pf&0x08)>>3));
136   return input_port_read_indexed(machine, 3 + ((marinedt_pf&0x08)>>3));
137137}
138138
139139static READ8_HANDLER( marinedt_coll_r )
src/mame/drivers/skullxbo.c
r2375r2376
9696
9797static READ16_HANDLER( special_port1_r )
9898{
99   int temp = readinputport(1);
99   int temp = input_port_read_indexed(machine, 1);
100100   if (atarigen_cpu_to_sound_ready) temp ^= 0x0040;
101101   if (atarigen_get_hblank(machine->primary_screen)) temp ^= 0x0010;
102102   return temp;
src/mame/drivers/konamigq.c
r2375r2376
342342
343343static DRIVER_INIT( konamigq )
344344{
345   psx_driver_init();
345   psx_driver_init(machine);
346346
347347   m_p_n_pcmram = memory_region( REGION_SOUND1 ) + 0x80000;
348348}
src/mame/drivers/mrflea.c
r2375r2376
205205/*******************************************************/
206206
207207static READ8_HANDLER( mrflea_input0_r ){
208   if( mrflea_select0 == 0x0f ) return readinputport(0);
209   if( mrflea_select0 == 0x0e ) return readinputport(1);
208   if( mrflea_select0 == 0x0f ) return input_port_read_indexed(machine, 0);
209   if( mrflea_select0 == 0x0e ) return input_port_read_indexed(machine, 1);
210210   return 0x00;
211211}
212212
r2375r2376
215215}
216216
217217static READ8_HANDLER( mrflea_input2_r ){
218   if( mrflea_select2 == 0x0f ) return readinputport(2);
219   if( mrflea_select2 == 0x0e ) return readinputport(3);
218   if( mrflea_select2 == 0x0f ) return input_port_read_indexed(machine, 2);
219   if( mrflea_select2 == 0x0e ) return input_port_read_indexed(machine, 3);
220220   return 0x00;
221221}
222222
src/mame/drivers/cps3.c
r2375r2376
17821782
17831783static READ32_HANDLER( cps3_io1_r )
17841784{
1785   return readinputport(0);
1785   return input_port_read_indexed(machine, 0);
17861786}
17871787
17881788static READ32_HANDLER( cps3_io2_r )
17891789{
1790   return readinputport(1);
1790   return input_port_read_indexed(machine, 1);
17911791}
17921792
17931793// this seems to be dma active flags, and maybe vblank... not if it is anything else
src/mame/drivers/mcatadv.c
r2375r2376
156156
157157static READ16_HANDLER( mcatadv_dsw_r )
158158{
159   return readinputport(2+offset) << 8;
159   return input_port_read_indexed(machine, 2+offset) << 8;
160160}
161161
162162static WRITE16_HANDLER( mcat_soundlatch_w )
src/mame/drivers/cinemat.c
r2375r2376
8787
8888static READ8_HANDLER( inputs_r )
8989{
90   return (readinputportbytag("INPUTS") >> offset) & 1;
90   return (input_port_read(machine, "INPUTS") >> offset) & 1;
9191}
9292
9393
9494static READ8_HANDLER( switches_r )
9595{
9696   static const UINT8 switch_shuffle[8] = { 2,5,4,3,0,1,6,7 };
97   return (readinputportbytag("SWITCHES") >> switch_shuffle[offset]) & 1;
97   return (input_port_read(machine, "SWITCHES") >> switch_shuffle[offset]) & 1;
9898}
9999
100100
r2375r2376
154154   if (port_tag_to_index("ANALOGX") != -1)
155155   {
156156      int xval = (INT16)(cpunum_get_reg(0, CCPU_X) << 4) >> 4;
157      return (readinputportbytag(mux_select ? "ANALOGX" : "ANALOGY") - xval) < 0x800;
157      return (input_port_read(Machine, mux_select ? "ANALOGX" : "ANALOGY") - xval) < 0x800;
158158   }
159159   return 0;
160160}
r2375r2376
173173   int delta_wheel;
174174
175175    /* the shift register is cleared once per 'frame' */
176    delta_wheel = (INT8)readinputportbytag("WHEEL") / 8;
176    delta_wheel = (INT8)input_port_read(machine, "WHEEL") / 8;
177177    if (delta_wheel > 3)
178178        delta_wheel = 3;
179179    else if (delta_wheel < -3)
r2375r2376
186186static READ8_HANDLER( speedfrk_gear_r )
187187{
188188   static int gear = 0x0e;
189    int gearval = readinputportbytag("GEAR");
189    int gearval = input_port_read(machine, "GEAR");
190190
191191   /* check the fake gear input port and determine the bit settings for the gear */
192192   if ((gearval & 0x0f) != 0x0f)
193193        gear = gearval & 0x0f;
194194
195195   /* add the start key into the mix -- note that it overlaps 4th gear */
196   if (!(readinputportbytag("INPUTS") & 0x80))
196   if (!(input_port_read(machine, "INPUTS") & 0x80))
197197        gear &= ~0x08;
198198
199199   return (gear >> offset) & 1;
r2375r2376
239239{
240240   /* handle special keys first */
241241   if (sundance_port_map[offset].portname)
242      return (readinputportbytag(sundance_port_map[offset].portname) & sundance_port_map[offset].bitmask) ? 0 : 1;
242      return (input_port_read(machine, sundance_port_map[offset].portname) & sundance_port_map[offset].bitmask) ? 0 : 1;
243243   else
244      return (readinputportbytag("INPUTS") >> offset) & 1;
244      return (input_port_read(machine, "INPUTS") >> offset) & 1;
245245}
246246
247247
r2375r2376
254254
255255static READ8_HANDLER( boxingb_dial_r )
256256{
257   int value = readinputportbytag("DIAL");
257   int value = input_port_read(machine, "DIAL");
258258   if (!mux_select) offset += 4;
259259   return (value >> offset) & 1;
260260}
src/mame/drivers/toaplan2.c
r2375r2376
721721   }
722722   if (mcu_data == 0xff) mcu_data = 0x10;
723723   else mcu_data = 0x00;
724   return ( mcu_data | input_port_6_r(machine,0) );
724   return ( mcu_data | input_port_read_indexed(machine, 6) );
725725}
726726
727727static READ16_HANDLER( pipibibi_z80_status_r )
r2375r2376
741741{
742742   INT8 value, new_value;
743743
744   new_value = input_port_7_r(machine,0);
744   new_value = input_port_read_indexed(machine, 7);
745745   if (new_value == old_p1_paddle_h) return 0;
746746   value = new_value - old_p1_paddle_h;
747747   old_p1_paddle_h = new_value;
r2375r2376
752752{
753753   INT8 value, new_value;
754754
755   new_value = input_port_8_r(machine,0);
755   new_value = input_port_read_indexed(machine, 8);
756756   if (new_value == old_p2_paddle_h) return 0;
757757   value = new_value - old_p2_paddle_h;
758758   old_p2_paddle_h = new_value;
src/mame/drivers/mjkjidai.c
r2375r2376
110110   {
111111      if (~keyb & (1 << i))
112112      {
113         res = readinputport(4+i) & 0x3f;
113         res = input_port_read_indexed(machine, 4+i) & 0x3f;
114114         break;
115115      }
116116   }
117117
118   res |= (readinputport(3) & 0xc0);
118   res |= (input_port_read_indexed(machine, 3) & 0xc0);
119119
120120   if (nvram_init_count)
121121   {
src/mame/drivers/jchan.c
r2375r2376
220220***************************************************************************/
221221static UINT16 *mcu_ram, jchan_mcu_com[4];
222222
223static void jchan_mcu_run(void)
223static void jchan_mcu_run(running_machine *machine)
224224{
225225   UINT16 mcu_command = mcu_ram[0x0010/2];      /* command nb */
226226   UINT16 mcu_offset  = mcu_ram[0x0012/2] / 2;   /* offset in shared RAM where MCU will write */
r2375r2376
302302
303303      case 0x03:    // DSW
304304      {
305         mcu_ram[mcu_offset] = readinputport(3);
305         mcu_ram[mcu_offset] = input_port_read_indexed(machine, 3);
306306         logerror("PC=%06X : MCU executed command: %04X %04X (read DSW)\n",activecpu_get_pc(),mcu_command,mcu_offset*2);
307307      }
308308      break;
r2375r2376
377377   if (jchan_mcu_com[3] != 0xFFFF)   return; \
378378\
379379   memset(jchan_mcu_com, 0, 4 * sizeof( UINT16 ) ); \
380   jchan_mcu_run(); \
380   jchan_mcu_run(machine); \
381381}
382382
383383JCHAN_MCU_COM_W(0)
r2375r2376
455455{
456456   switch(offset)
457457   {
458      case 0/2: return readinputport(0); // Player 1 controls
459      case 2/2: return readinputport(1); // Player 2 controls
458      case 0/2: return input_port_read_indexed(machine, 0); // Player 1 controls
459      case 2/2: return input_port_read_indexed(machine, 1); // Player 2 controls
460460      default: logerror("jchan_ctrl_r unknown!"); break;
461461   }
462462   return jchan_ctrl[offset];
src/mame/drivers/sgladiat.c
r2375r2376
8383
8484static READ8_HANDLER( sgladiat_inp0_r )
8585{
86   return(readinputportbytag("IN0") | snk_sound_busy_bit);
86   return(input_port_read(machine, "IN0") | snk_sound_busy_bit);
8787}
8888
8989static WRITE8_HANDLER( sglatiat_flipscreen_w )
src/mame/drivers/wecleman.c
r2375r2376
688688   K007232_set_bank( 0, 0, ~data&1 );   //* (wecleman062gre)
689689}
690690
691static ADDRESS_MAP_START( wecleman_sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
692   AM_RANGE(0x0000, 0x7fff) AM_READ(SMH_ROM)   // ROM
693   AM_RANGE(0x8000, 0x83ff) AM_READ(SMH_RAM)   // RAM
694   AM_RANGE(0x9000, 0x9000) AM_READ(multiply_r)   // Protection
695   AM_RANGE(0xa000, 0xa000) AM_READ(soundlatch_r)   // From main CPU
696   AM_RANGE(0xb000, 0xb00d) AM_READ(K007232_read_port_0_r)   // K007232 (Reading offset 5/b triggers the sample)
697   AM_RANGE(0xc001, 0xc001) AM_READ(YM2151_status_port_0_r)   // YM2151
698ADDRESS_MAP_END
699
700static ADDRESS_MAP_START( wecleman_sound_writemem, ADDRESS_SPACE_PROGRAM, 8 )
701   AM_RANGE(0x0000, 0x7fff) AM_WRITE(SMH_ROM)   // ROM
702   AM_RANGE(0x8000, 0x83ff) AM_WRITE(SMH_RAM)   // RAM
691static ADDRESS_MAP_START( wecleman_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
692   AM_RANGE(0x0000, 0x7fff) AM_ROM
693   AM_RANGE(0x8000, 0x83ff) AM_RAM
703694   AM_RANGE(0x8500, 0x8500) AM_WRITE(SMH_NOP)   // incresed with speed (global volume)?
695   AM_RANGE(0x9000, 0x9000) AM_READ(multiply_r)   // Protection
704696   AM_RANGE(0x9000, 0x9001) AM_WRITE(multiply_w)   // Protection
705697   AM_RANGE(0x9006, 0x9006) AM_WRITE(SMH_NOP)   // ?
706   AM_RANGE(0xb000, 0xb00d) AM_WRITE(K007232_write_port_0_w)   // K007232
698   AM_RANGE(0xa000, 0xa000) AM_READ(soundlatch_r)   // From main CPU
699   AM_RANGE(0xb000, 0xb00d) AM_READWRITE(K007232_read_port_0_r, K007232_write_port_0_w)   // K007232 (Reading offset 5/b triggers the sample)
707700   AM_RANGE(0xc000, 0xc000) AM_WRITE(YM2151_register_port_0_w)   // YM2151
708   AM_RANGE(0xc001, 0xc001) AM_WRITE(YM2151_data_port_0_w)
701   AM_RANGE(0xc001, 0xc001) AM_READWRITE(YM2151_status_port_0_r, YM2151_data_port_0_w)
709702   AM_RANGE(0xf000, 0xf000) AM_WRITE(wecleman_K00723216_bank_w)   // Samples banking
710703ADDRESS_MAP_END
711704
r2375r2376
803796HOTCHASE_K007232_RW(1)
804797HOTCHASE_K007232_RW(2)
805798
806static ADDRESS_MAP_START( hotchase_sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
807   AM_RANGE(0x0000, 0x07ff) AM_READ(SMH_RAM)   // RAM
808   AM_RANGE(0x1000, 0x100d) AM_READ(hotchase_K007232_0_r)   // 3 x  K007232
809   AM_RANGE(0x2000, 0x200d) AM_READ(hotchase_K007232_1_r)
810   AM_RANGE(0x3000, 0x300d) AM_READ(hotchase_K007232_2_r)
811   AM_RANGE(0x6000, 0x6000) AM_READ(soundlatch_r)   // From main CPU (Read on IRQ)
812   AM_RANGE(0x8000, 0xffff) AM_READ(SMH_ROM)   // ROM
813ADDRESS_MAP_END
814
815static ADDRESS_MAP_START( hotchase_sound_writemem, ADDRESS_SPACE_PROGRAM, 8 )
816   AM_RANGE(0x0000, 0x07ff) AM_WRITE(SMH_RAM)   // RAM
817   AM_RANGE(0x1000, 0x100d) AM_WRITE(hotchase_K007232_0_w)   // 3 x K007232
818   AM_RANGE(0x2000, 0x200d) AM_WRITE(hotchase_K007232_1_w)
819   AM_RANGE(0x3000, 0x300d) AM_WRITE(hotchase_K007232_2_w)
799static ADDRESS_MAP_START( hotchase_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
800   AM_RANGE(0x0000, 0x07ff) AM_RAM
801   AM_RANGE(0x1000, 0x100d) AM_READWRITE(hotchase_K007232_0_r, hotchase_K007232_0_w)   // 3 x K007232
802   AM_RANGE(0x2000, 0x200d) AM_READWRITE(hotchase_K007232_1_r, hotchase_K007232_1_w)
803   AM_RANGE(0x3000, 0x300d) AM_READWRITE(hotchase_K007232_2_r, hotchase_K007232_2_w)
820804   AM_RANGE(0x4000, 0x4007) AM_WRITE(hotchase_sound_control_w)   // Sound volume, banking, etc.
821805   AM_RANGE(0x5000, 0x5000) AM_WRITE(SMH_NOP)   // ? (written with 0 on IRQ, 1 on FIRQ)
806   AM_RANGE(0x6000, 0x6000) AM_READ(soundlatch_r)   // From main CPU (Read on IRQ)
822807   AM_RANGE(0x7000, 0x7000) AM_WRITE(SMH_NOP)   // Command acknowledge ?
823   AM_RANGE(0x8000, 0xffff) AM_WRITE(SMH_ROM)   // ROM
808   AM_RANGE(0x8000, 0xffff) AM_ROM
824809ADDRESS_MAP_END
825810
826811
r2375r2376
11231108   /* Schems: can be reset, no nmi, soundlatch, 3.58MHz */
11241109   MDRV_CPU_ADD(Z80, 3579545)
11251110   /* audio CPU */
1126   MDRV_CPU_PROGRAM_MAP(wecleman_sound_readmem,wecleman_sound_writemem)
1111   MDRV_CPU_PROGRAM_MAP(wecleman_sound_map,0)
11271112
11281113   MDRV_INTERLEAVE(100)
11291114
r2375r2376
11791164
11801165   MDRV_CPU_ADD(M6809, 3579545 / 2)
11811166   /* audio CPU */   /* 3.579/2 MHz - PCB is drawn in one set's readme */
1182   MDRV_CPU_PROGRAM_MAP(hotchase_sound_readmem,hotchase_sound_writemem)
1167   MDRV_CPU_PROGRAM_MAP(hotchase_sound_map,0)
11831168   MDRV_CPU_PERIODIC_INT( hotchase_sound_timer, 496 )
11841169
11851170   /* Amuse: every 2 ms */
src/mame/drivers/crbaloon.c
r2375r2376
7575
7676   /* enable coin & start input? Wild guess!!! */
7777   if (pc3092_data[1] & 0x02)
78      ret = readinputportbytag("PC3092");
78      ret = input_port_read(machine, "PC3092");
7979   else
8080      ret = 0x00;
8181
r2375r2376
145145
146146   if (LOG_PC3259) logerror("%04X:  read PC3259 #%d = 0x%02x\n", safe_activecpu_get_pc(), reg, ret);
147147
148   return ret | (readinputportbytag("DSW1") & 0xf0);
148   return ret | (input_port_read(machine, "DSW1") & 0xf0);
149149}
150150
151151
src/mame/drivers/seattle.c
r2375r2376
14001400{
14011401   if (data < 8 || data > 15)
14021402      logerror("%08X:Unexpected analog port select = %08X\n", activecpu_get_pc(), data);
1403   pending_analog_read = readinputport(4 + (data & 7));
1403   pending_analog_read = input_port_read_indexed(machine, 4 + (data & 7));
14041404}
14051405
14061406
r2375r2376
14181418   switch (offset)
14191419   {
14201420      case 0:      /* low 8 bits of X */
1421         result = (readinputport(4) << 4) & 0xff;
1421         result = (input_port_read_indexed(machine, 4) << 4) & 0xff;
14221422         break;
14231423
14241424      case 1:      /* upper 4 bits of X */
1425         result = (readinputport(4) >> 4) & 0x0f;
1426         result |= (readinputport(8) & 0x03) << 4;
1425         result = (input_port_read_indexed(machine, 4) >> 4) & 0x0f;
1426         result |= (input_port_read_indexed(machine, 8) & 0x03) << 4;
14271427         result |= 0x40;
14281428         break;
14291429
14301430      case 2:      /* low 8 bits of Y */
1431         result = (readinputport(5) << 2) & 0xff;
1431         result = (input_port_read_indexed(machine, 5) << 2) & 0xff;
14321432         break;
14331433
14341434      case 3:      /* upper 4 bits of Y */
1435         result = (readinputport(5) >> 6) & 0x03;
1435         result = (input_port_read_indexed(machine, 5) >> 6) & 0x03;
14361436         break;
14371437
14381438      case 4:      /* low 8 bits of X */
1439         result = (readinputport(6) << 4) & 0xff;
1439         result = (input_port_read_indexed(machine, 6) << 4) & 0xff;
14401440         break;
14411441
14421442      case 5:      /* upper 4 bits of X */
1443         result = (readinputport(6) >> 4) & 0x0f;
1444         result |= (readinputport(8) & 0x30);
1443         result = (input_port_read_indexed(machine, 6) >> 4) & 0x0f;
1444         result |= (input_port_read_indexed(machine, 8) & 0x30);
14451445         result |= 0x40;
14461446         break;
14471447
14481448      case 6:      /* low 8 bits of Y */
1449         result = (readinputport(7) << 2) & 0xff;
1449         result = (input_port_read_indexed(machine, 7) << 2) & 0xff;
14501450         break;
14511451
14521452      case 7:      /* upper 4 bits of Y */
1453         result = (readinputport(7) >> 6) & 0x03;
1453         result = (input_port_read_indexed(machine, 7) >> 6) & 0x03;
14541454         break;
14551455   }
14561456   return result;
src/mame/drivers/btoads.c
r2375r2376
8484
8585static READ16_HANDLER( special_port_4_r )
8686{
87   int result = readinputport(4) & ~0x81;
87   int result = input_port_read_indexed(machine, 4) & ~0x81;
8888
8989   if (sound_to_main_ready)
9090      result |= 0x01;
src/mame/drivers/tetrisp2.c
r2375r2376
230230
231231static READ16_HANDLER( tetrisp2_ip_1_word_r )
232232{
233   return   ( readinputportbytag("IN1") &  0xfcff ) |
233   return   ( input_port_read(machine, "IN1") &  0xfcff ) |
234234         (           mame_rand(Machine) & ~0xfcff ) |
235235         (      1 << (8 + (mame_rand(Machine)&1)) );
236236}
r2375r2376
306306
307307static READ16_HANDLER( rocknms_port_0_r )
308308{
309   return ((readinputport(0) & 0xfffc ) | (rocknms_sub2main & 0x0003));
309   return ((input_port_read_indexed(machine, 0) & 0xfffc ) | (rocknms_sub2main & 0x0003));
310310}
311311
312312static WRITE16_HANDLER( rocknms_sub2main_w )
src/mame/drivers/alpha68k.c
r2375r2376
265265
266266static READ16_HANDLER( kyros_dip_r )
267267{
268   return readinputportbytag("IN1")<<8;
268   return input_port_read(machine, "IN1")<<8;
269269}
270270
271271static READ16_HANDLER( control_1_r )
272272{
273273   if (invert_controls)
274      return ~(readinputportbytag("IN0") + (readinputportbytag("IN1") << 8));
274      return ~(input_port_read(machine, "IN0") + (input_port_read(machine, "IN1") << 8));
275275
276   return (readinputport(0) + (readinputport(1) << 8));
276   return (input_port_read_indexed(machine, 0) + (input_port_read_indexed(machine, 1) << 8));
277277}
278278
279279static READ16_HANDLER( control_2_r )
280280{
281281   if (invert_controls)
282      return ~(readinputportbytag("IN3") + ((~(1 << (readinputportbytag("IN5") * 12 / 256))) << 8));
282      return ~(input_port_read(machine, "IN3") + ((~(1 << (input_port_read(machine, "IN5") * 12 / 256))) << 8));
283283
284   return readinputportbytag("IN3") + /* Low byte of CN1 */
285      ((~(1 << (readinputportbytag("IN5") * 12 / 256))) << 8);
284   return input_port_read(machine, "IN3") + /* Low byte of CN1 */
285      ((~(1 << (input_port_read(machine, "IN5") * 12 / 256))) << 8);
286286}
287287
288288static READ16_HANDLER( control_2_V_r )
289289{
290   return readinputportbytag("IN3");
290   return input_port_read(machine, "IN3");
291291}
292292
293293static READ16_HANDLER( control_3_r )
294294{
295295   if (invert_controls)
296      return ~((( ~(1 << (readinputportbytag("IN6") * 12 / 256)) )<<8)&0xff00);
296      return ~((( ~(1 << (input_port_read(machine, "IN6") * 12 / 256)) )<<8)&0xff00);
297297
298   return (( ~(1 << (readinputportbytag("IN6") * 12 / 256)) )<<8)&0xff00;
298   return (( ~(1 << (input_port_read(machine, "IN6") * 12 / 256)) )<<8)&0xff00;
299299}
300300
301301/* High 4 bits of CN1 & CN2 */
302302static READ16_HANDLER( control_4_r )
303303{
304304   if (invert_controls)
305      return ~(((( ~(1 << (readinputportbytag("IN6") * 12 / 256))  ) <<4)&0xf000)
306       + ((( ~(1 << (readinputportbytag("IN5") * 12 / 256))  )    )&0x0f00));
305      return ~(((( ~(1 << (input_port_read(machine, "IN6") * 12 / 256))  ) <<4)&0xf000)
306       + ((( ~(1 << (input_port_read(machine, "IN5") * 12 / 256))  )    )&0x0f00));
307307
308   return ((( ~(1 << (readinputportbytag("IN6") * 12 / 256))  ) <<4)&0xf000)
309       + ((( ~(1 << (readinputportbytag("IN5") * 12 / 256))  )    )&0x0f00);
308   return ((( ~(1 << (input_port_read(machine, "IN6") * 12 / 256))  ) <<4)&0xf000)
309       + ((( ~(1 << (input_port_read(machine, "IN5") * 12 / 256))  )    )&0x0f00);
310310}
311311
312312static READ16_HANDLER( jongbou_inputs_r )
313313{
314   UINT8 inp1 = readinputportbytag("IN3");
315   UINT8 inp2 = readinputportbytag("IN4");
314   UINT8 inp1 = input_port_read(machine, "IN3");
315   UINT8 inp2 = input_port_read(machine, "IN4");
316316   inp1 = ((inp1 & 0x01) << 3) + ((inp1 & 0x02) << 1) + ((inp1 & 0x04) >> 1) + ((inp1 & 0x08) >> 3);
317317   inp2 = ((inp2 & 0x01) << 3) + ((inp2 & 0x02) << 1) + ((inp2 & 0x04) >> 1) + ((inp2 & 0x08) >> 3);
318   return readinputportbytag("IN0") | inp1 | inp2 << 4;
318   return input_port_read(machine, "IN0") | inp1 | inp2 << 4;
319319}
320320
321321/******************************************************************************/
r2375r2376
381381         return 0;
382382      case 0x29: /* Query microcontroller for coin insert */
383383         trigstate++;
384         if ((readinputportbytag("IN2")&0x3)==3) latch=0;
385         if ((readinputportbytag("IN2")&0x1)==0 && !latch)
384         if ((input_port_read(machine, "IN2")&0x3)==3) latch=0;
385         if ((input_port_read(machine, "IN2")&0x1)==0 && !latch)
386386         {
387387            shared_ram[0x29] = (source&0xff00)|(coin_id&0xff);   // coinA
388388            shared_ram[0x22] = (source&0xff00)|0x0;
389389            latch=1;
390390
391            coinvalue = (~readinputportbytag("IN1")>>1) & 7;
391            coinvalue = (~input_port_read(machine, "IN1")>>1) & 7;
392392            deposits1++;
393393            if (deposits1 == coinage1[coinvalue][0])
394394            {
r2375r2376
398398            else
399399               credits = 0;
400400         }
401         else if ((readinputportbytag("IN2")&0x2)==0 && !latch)
401         else if ((input_port_read(machine, "IN2")&0x2)==0 && !latch)
402402         {
403403            shared_ram[0x29] = (source&0xff00)|(coin_id>>8);   // coinB
404404            shared_ram[0x22] = (source&0xff00)|0x0;
405405            latch=1;
406406
407            coinvalue = (~readinputportbytag("IN1")>>1) & 7;
407            coinvalue = (~input_port_read(machine, "IN1")>>1) & 7;
408408            deposits2++;
409409            if (deposits2 == coinage2[coinvalue][0])
410410            {
r2375r2376
460460   switch (offset)
461461   {
462462      case 0: /* Dipswitch 2 */
463         shared_ram[0] = (source&0xff00)|readinputportbytag("IN4");
463         shared_ram[0] = (source&0xff00)|input_port_read(machine, "IN4");
464464         return 0;
465465
466466      case 0x22: /* Coin value */
r2375r2376
468468         return 0;
469469
470470      case 0x29: /* Query microcontroller for coin insert */
471         if ((readinputportbytag("IN2")&0x3)==3) latch=0;
472         if ((readinputportbytag("IN2")&0x1)==0 && !latch)
471         if ((input_port_read(machine, "IN2")&0x3)==3) latch=0;
472         if ((input_port_read(machine, "IN2")&0x1)==0 && !latch)
473473         {
474474            shared_ram[0x29] = (source&0xff00)|(coin_id&0xff);   // coinA
475475            shared_ram[0x22] = (source&0xff00)|0x0;
r2375r2376
478478            if ((coin_id&0xff) == 0x22)
479479            {
480480               if(!strcmp(machine->gamedrv->name, "btlfildb"))
481                  coinvalue = (readinputportbytag("IN4")>>0) & 7;
481                  coinvalue = (input_port_read(machine, "IN4")>>0) & 7;
482482               else
483                  coinvalue = (~readinputportbytag("IN4")>>0) & 7;
483                  coinvalue = (~input_port_read(machine, "IN4")>>0) & 7;
484484
485485               deposits1++;
486486               if (deposits1 == coinage1[coinvalue][0])
r2375r2376
492492                  credits = 0;
493493            }
494494         }
495         else if ((readinputportbytag("IN2")&0x2)==0 && !latch)
495         else if ((input_port_read(machine, "IN2")&0x2)==0 && !latch)
496496         {
497497            shared_ram[0x29] = (source&0xff00)|(coin_id>>8);   // coinB
498498            shared_ram[0x22] = (source&0xff00)|0x0;
r2375r2376
501501            if ((coin_id>>8) == 0x22)
502502            {
503503               if(!strcmp(machine->gamedrv->name, "btlfildb"))
504                  coinvalue = (readinputportbytag("IN4")>>0) & 7;
504                  coinvalue = (input_port_read(machine, "IN4")>>0) & 7;
505505               else
506                  coinvalue = (~readinputportbytag("IN4")>>0) & 7;
506                  coinvalue = (~input_port_read(machine, "IN4")>>0) & 7;
507507
508508               deposits2++;
509509               if (deposits2 == coinage2[coinvalue][0])
r2375r2376
556556   switch (offset)
557557   {
558558      case 0: /* Dipswitch 1 */
559         shared_ram[0] = (source&0xff00)|readinputportbytag("IN4");
559         shared_ram[0] = (source&0xff00)|input_port_read(machine, "IN4");
560560         return 0;
561561      case 0x22: /* Coin value */
562562         shared_ram[0x22] = (source&0xff00)|(credits&0x00ff);
563563         return 0;
564564      case 0x29: /* Query microcontroller for coin insert */
565         if ((readinputportbytag("IN2")&0x3)==3) latch=0;
566         if ((readinputportbytag("IN2")&0x1)==0 && !latch)
565         if ((input_port_read(machine, "IN2")&0x3)==3) latch=0;
566         if ((input_port_read(machine, "IN2")&0x1)==0 && !latch)
567567         {
568568            shared_ram[0x29] = (source&0xff00)|(coin_id&0xff);   // coinA
569569            shared_ram[0x22] = (source&0xff00)|0x0;
r2375r2376
571571
572572            if ((coin_id&0xff) == 0x22)
573573            {
574               coinvalue = (~readinputportbytag("IN4")>>1) & 7;
574               coinvalue = (~input_port_read(machine, "IN4")>>1) & 7;
575575               deposits1++;
576576               if (deposits1 == coinage1[coinvalue][0])
577577               {
r2375r2376
582582                  credits = 0;
583583            }
584584         }
585         else if ((readinputportbytag("IN2")&0x2)==0 && !latch)
585         else if ((input_port_read(machine, "IN2")&0x2)==0 && !latch)
586586         {
587587            shared_ram[0x29] = (source&0xff00)|(coin_id>>8);   // coinB
588588            shared_ram[0x22] = (source&0xff00)|0x0;
r2375r2376
590590
591591            if ((coin_id>>8) == 0x22)
592592            {
593               coinvalue = (~readinputportbytag("IN4")>>1) & 7;
593               coinvalue = (~input_port_read(machine, "IN4")>>1) & 7;
594594               deposits2++;
595595               if (deposits2 == coinage2[coinvalue][0])
596596               {
r2375r2376
616616         break;
617617
618618      case 0x1f00: /* Dipswitch 1 */
619         shared_ram[0x1f00] = (source&0xff00)|readinputportbytag("IN4");
619         shared_ram[0x1f00] = (source&0xff00)|input_port_read(machine, "IN4");
620620         return 0;
621621      case 0x1f29: /* Query microcontroller for coin insert */
622         if ((readinputportbytag("IN2")&0x3)==3) latch=0;
623         if ((readinputportbytag("IN2")&0x1)==0 && !latch)
622         if ((input_port_read(machine, "IN2")&0x3)==3) latch=0;
623         if ((input_port_read(machine, "IN2")&0x1)==0 && !latch)
624624         {
625625            shared_ram[0x1f29] = (source&0xff00)|(coin_id&0xff);   // coinA
626626            shared_ram[0x1f22] = (source&0xff00)|0x0;
r2375r2376
628628
629629            if ((coin_id&0xff) == 0x22)
630630            {
631               coinvalue = (~readinputportbytag("IN4")>>1) & 7;
631               coinvalue = (~input_port_read(machine, "IN4")>>1) & 7;
632632               deposits1++;
633633               if (deposits1 == coinage1[coinvalue][0])
634634               {
r2375r2376
639639                  credits = 0;
640640            }
641641         }
642         else if ((readinputportbytag("IN2")&0x2)==0 && !latch)
642         else if ((input_port_read(machine, "IN2")&0x2)==0 && !latch)
643643         {
644644            shared_ram[0x1f29] = (source&0xff00)|(coin_id>>8);   // coinB
645645            shared_ram[0x1f22] = (source&0xff00)|0x0;
r2375r2376
647647
648648            if ((coin_id>>8) == 0x22)
649649            {
650               coinvalue = (~readinputportbytag("IN4")>>1) & 7;
650               coinvalue = (~input_port_read(machine, "IN4")>>1) & 7;
651651               deposits2++;
652652               if (deposits2 == coinage2[coinvalue][0])
653653               {
r2375r2376
668668               the microcontroller supplies it (it does for all the other games,
669669               but usually to 0x0 in RAM) when 0x21 is read (code at 0x009332) */
670670         source=shared_ram[0x0163];
671         shared_ram[0x0163] = (source&0x00ff)|(readinputportbytag("IN4")<<8);
671         shared_ram[0x0163] = (source&0x00ff)|(input_port_read(machine, "IN4")<<8);
672672
673673         return 0;
674674      case 0x1ffe:  /* Custom ID check */
src/mame/drivers/boxer.c
r2375r2376
4545
4646      memset(mask, 0, sizeof mask);
4747
48      mask[readinputport(3)] |= 0x01;
49      mask[readinputport(4)] |= 0x02;
50      mask[readinputport(5)] |= 0x04;
51      mask[readinputport(6)] |= 0x08;
52      mask[readinputport(7)] |= 0x10;
53      mask[readinputport(8)] |= 0x20;
48      mask[input_port_read_indexed(machine, 3)] |= 0x01;
49      mask[input_port_read_indexed(machine, 4)] |= 0x02;
50      mask[input_port_read_indexed(machine, 5)] |= 0x04;
51      mask[input_port_read_indexed(machine, 6)] |= 0x08;
52      mask[input_port_read_indexed(machine, 7)] |= 0x10;
53      mask[input_port_read_indexed(machine, 8)] |= 0x20;
5454
5555      for (i = 1; i < 256; i++)
5656         if (mask[i] != 0)
r2375r2376
8888
8989static READ8_HANDLER( boxer_input_r )
9090{
91   UINT8 val = readinputport(0);
91   UINT8 val = input_port_read_indexed(machine, 0);
9292
93   if (readinputport(9) < video_screen_get_vpos(machine->primary_screen))
93   if (input_port_read_indexed(machine, 9) < video_screen_get_vpos(machine->primary_screen))
9494      val |= 0x02;
9595
9696   return (val << ((offset & 7) ^ 7)) & 0x80;
r2375r2376
112112      break;
113113
114114   case 2:
115      val = readinputport(1);
115      val = input_port_read_indexed(machine, 1);
116116      break;
117117
118118   case 3:
119      val = readinputport(2);
119      val = input_port_read_indexed(machine, 2);
120120      break;
121121   }
122122
src/mame/drivers/starfire.c
r2375r2376
105105{
106106   switch (offset & 15)
107107   {
108      case 0:   return input_port_0_r(machine,0);
109      case 1:   return input_port_1_r(machine,0);   /* Note: need to loopback sounds lengths on that one */
110      case 5: return input_port_4_r(machine,0);
111      case 6:   return input_port_2_r(machine,0);
112      case 7:   return input_port_3_r(machine,0);
108      case 0:   return input_port_read_indexed(machine, 0);
109      case 1:   return input_port_read_indexed(machine, 1);   /* Note: need to loopback sounds lengths on that one */
110      case 5: return input_port_read_indexed(machine, 4);
111      case 6:   return input_port_read_indexed(machine, 2);
112      case 7:   return input_port_read_indexed(machine, 3);
113113      default: return 0xff;
114114   }
115115}
r2375r2376
132132
133133   switch (offset & 15)
134134   {
135      case 0:   return input_port_0_r(machine,0);
136      case 1: return input_port_1_r(machine,0);
135      case 0:   return input_port_read_indexed(machine, 0);
136      case 1: return input_port_read_indexed(machine, 1);
137137      case 2:
138         temp = fireone_select ? input_port_2_r(machine,0) : input_port_3_r(machine,0);
138         temp = fireone_select ? input_port_read_indexed(machine, 2) : input_port_read_indexed(machine, 3);
139139         temp = (temp & 0xc0) | fireone_paddle_map[temp & 0x3f];
140140         return temp;
141141      default: return 0xff;
src/mame/drivers/tmaster.c
r2375r2376
1717
1818- Proper touchscreen controller emulation. Currently it's flakey and
1919  tends to stop registering user input (try coining up in that case)
20- Protection in tm4k
20- Protection in tm4k and later games
2121- Coin optics
2222- RTC emulation (there's code to check the upper bytes of NVRAM to see if
2323  the real time clock is present, and to only use it in that case)
2424
25To be dumped and added:
26
27Touch Master 2000
28Touch Master 6000
29Touch Master 7000 *
30Touch Master 8000 *(?)
31
32* There is a reported "Minnesota" version with modifications due to legal issues
33  Touch Master 5000 is labeled "DOMESTIC" (AKA "Standard"), is there an EXPORT version?
34  Is there a Touch Master 6000?  TM5K is version 7.10, then TM7K is version 8, TM8K is version 9.04
35  Starting with Touch Master 2000, each later version is a chipswap for the mainboard.
36   IE: Touch Master 8000 chips can update any Touch Master mainboard 2000 through 7000
37
38Touch Master 8000 part lists:
39
40A-5343-60194-3  U8  Sound
41A-5343-60194-2  U51 Program code
42A-5343-60194-1  U52 Program code
43A-5343-60194-6  U36 Graphics
44A-5343-60194-4  U37 Graphics
45A-5343-60194-7  U38 Graphics
46A-5343-60194-5  U39 Graphics
47A-5343-60194-8  U40 Graphics
48A-5343-60194-9  U41 Graphics
49A-21657-007     Security Key
50
51******************************************************************
52
2553[Galaxy Games]
2654
2755Input:  Trackballs and buttons
r2375r2376
6795
6896static int touchscreen;
6997
70static void show_touchscreen(void)
98static void show_touchscreen(running_machine *machine)
7199{
72100#ifdef MAME_DEBUG
73   popmessage("% d] %03x %03x - %d",touchscreen,readinputportbytag("TSCREEN_X")&0x1ff,readinputportbytag("TSCREEN_Y"),okibank);
101   popmessage("% d] %03x %03x - %d",touchscreen,input_port_read(machine, "TSCREEN_X")&0x1ff,input_port_read(machine, "TSCREEN_Y"),okibank);
74102#endif
75103}
76104
r2375r2376
79107   if (ACCESSING_BITS_0_7 && data == 0x05)
80108   {
81109      touchscreen = 0;
82      show_touchscreen();
110      show_touchscreen(machine);
83111   }
84112}
85113
r2375r2376
89117      touchscreen++;
90118   if (touchscreen == 6)
91119      touchscreen = -1;
92   show_touchscreen();
120   show_touchscreen(machine);
93121
94122   return 0;
95123}
r2375r2376
107135{
108136   UINT16 val = 0;
109137
110   int press1 = readinputportbytag("TSCREEN_X") & 0x4000;
111   int press2 = readinputportbytag("TSCREEN_X") & 0x8000;
138   int press1 = input_port_read(machine, "TSCREEN_X") & 0x4000;
139   int press2 = input_port_read(machine, "TSCREEN_X") & 0x8000;
112140   if (press1)   press2 = 1;
113141
114142   switch (touchscreen)
115143   {
116144      case 1:   val = press1 ? 0 : 1<<6;   break;   // press
117      case 2:   val = readinputportbytag("TSCREEN_X") & 0x003;   break;
118      case 3:   val = (readinputportbytag("TSCREEN_X") >> 2) & 0x7f;   break;
145      case 2:   val = input_port_read(machine, "TSCREEN_X") & 0x003;   break;
146      case 3:   val = (input_port_read(machine, "TSCREEN_X") >> 2) & 0x7f;   break;
119147      case 4:   val = 0;   break;
120      case 5:   val = ((readinputportbytag("TSCREEN_Y")^0xff) >> 1) & 0x7f;   break;
148      case 5:   val = ((input_port_read(machine, "TSCREEN_Y")^0xff) >> 1) & 0x7f;   break;
121149
122150      default:
123151         return 0;
r2375r2376
356384
357385static READ16_HANDLER( tmaster_coins_r )
358386{
359   return readinputportbytag("COIN")|(mame_rand(Machine)&0x0800);
387   return input_port_read(machine, "COIN")|(mame_rand(Machine)&0x0800);
360388}
361389
362390static ADDRESS_MAP_START( tmaster_map, ADDRESS_SPACE_PROGRAM, 16 )
r2375r2376
840868TM3K_u40.bin               5.0  Video Images & Graphics         ccb4
841869TM3K_u41.bin               5.0  Video Images & Graphics         54a7
842870u62 (NOT INCLUDED)         N/A  Battery Memory Module           N/A
843J12 (NOT INCLUDED)         N/A  Security Key(not required for this Version)
871J12 DALLAS DS1204V         N/A  Security Key (required for this Version) - Labeled A-21657-002
844872-----------------------------------------------------------------------------------
845873
846874SCN68681c1n40
r2375r2376
850878
851879ROM_START( tm3k )
852880   ROM_REGION( 0x200000, REGION_CPU1, 0 ) // 68000 Code
853   ROM_LOAD16_BYTE( "tm3k_u52.bin", 0x000001, 0x100000, CRC(8c6a0db7) SHA1(6b0eae60ea471cd8c4001749ac2677d8d4532567) )
854   ROM_LOAD16_BYTE( "tm3k_u51.bin", 0x000000, 0x100000, CRC(c9522279) SHA1(e613b791f831271722f05b7e96c35519fa9fc174) )
881   ROM_LOAD16_BYTE( "tm3k_u52.bin", 0x000001, 0x100000, CRC(8c6a0db7) SHA1(6b0eae60ea471cd8c4001749ac2677d8d4532567) ) /* Ver: 5.01 Standard 11-4-97 */
882   ROM_LOAD16_BYTE( "tm3k_u51.bin", 0x000000, 0x100000, CRC(c9522279) SHA1(e613b791f831271722f05b7e96c35519fa9fc174) ) /* Ver: 5.01 Standard 11-4-97 */
855883
856884   ROM_REGION( 0x600000, REGION_GFX1, 0 )   // Blitter gfx
857885   ROM_LOAD16_BYTE( "tm3k_u38.bin", 0x000000, 0x100000, CRC(a6683899) SHA1(d05024390917cdb1871d030996da8e1eb6460918) )
r2375r2376
887915TM4K_u40.bin               6.0  Video Images & Graphics         208A
888916TM4K_u41.bin               6.0  Video Images & Graphics         385D
889917u62 (NOT INCLUDED)         N/A  Battery Memory Module           N/A
890J12 (NOT INCLUDED)         N/A  Security Key(required for this Version)
918J12 DALLAS DS1204V         N/A  Security Key (required for this Version) - Labeled A-21657-003
891919-----------------------------------------------------------------------------------
892920
893921SCN68681c1n40
r2375r2376
897925
898926ROM_START( tm4k )
899927   ROM_REGION( 0x200000, REGION_CPU1, 0 ) // 68000 Code
900   ROM_LOAD16_BYTE( "tm4k_u51.bin", 0x000000, 0x100000, CRC(3d8d7848) SHA1(31638f23cdd5e6cfbb2270e953f84fe1bd437950) )
901   ROM_LOAD16_BYTE( "tm4k_u52.bin", 0x000001, 0x100000, CRC(6d412871) SHA1(ae27c7723b292daf6682c53bafac22e4a3cd1ece) )
928   ROM_LOAD16_BYTE( "tm4k_u51.bin", 0x000000, 0x100000, CRC(3d8d7848) SHA1(31638f23cdd5e6cfbb2270e953f84fe1bd437950) ) /* Ver: 6.02 Standard 4-14-98 */
929   ROM_LOAD16_BYTE( "tm4k_u52.bin", 0x000001, 0x100000, CRC(6d412871) SHA1(ae27c7723b292daf6682c53bafac22e4a3cd1ece) ) /* Ver: 6.02 Standard 4-14-98 */
902930
903931   ROM_REGION( 0x600000, REGION_GFX1, 0 )   // Blitter gfx
904   ROM_LOAD16_BYTE( "tm4k_u38.bin", 0x000000, 0x100000, CRC(a6683899) SHA1(d05024390917cdb1871d030996da8e1eb6460918) )
905   ROM_LOAD16_BYTE( "tm4k_u36.bin", 0x000001, 0x100000, CRC(7bde520d) SHA1(77750b689e2f0d47804042456e54bbd9c28deeac) )
906   ROM_LOAD16_BYTE( "tm4k_u39.bin", 0x200000, 0x100000, CRC(bac88cfb) SHA1(26ed169296b890c5f5b50c418c15299355a6592f) )
907   ROM_LOAD16_BYTE( "tm4k_u37.bin", 0x200001, 0x100000, CRC(bf49fafa) SHA1(b400667bf654dc9cd01a85c8b99670459400fd60) )
908   ROM_LOAD16_BYTE( "tm4k_u41.bin", 0x400000, 0x100000, CRC(e97edb1e) SHA1(75510676cf1692ad03efd4ccd57d25af1cc8ef2a) )
909   ROM_LOAD16_BYTE( "tm4k_u40.bin", 0x400001, 0x100000, CRC(f6771a09) SHA1(74f71d5e910006c83a38170f24aa811c38a3e020) )
932   ROM_LOAD16_BYTE( "tm4k_u38.bin", 0x000000, 0x100000, CRC(a6683899) SHA1(d05024390917cdb1871d030996da8e1eb6460918) ) /* Mask rom labeled 5341-15746-03 U38 VIDEO IMAGE */
933   ROM_LOAD16_BYTE( "tm4k_u36.bin", 0x000001, 0x100000, CRC(7bde520d) SHA1(77750b689e2f0d47804042456e54bbd9c28deeac) ) /* Mask rom labeled 5341-15746-01 U36 VIDEO IMAGE */
934   ROM_LOAD16_BYTE( "tm4k_u39.bin", 0x200000, 0x100000, CRC(bac88cfb) SHA1(26ed169296b890c5f5b50c418c15299355a6592f) ) /* Mask rom labeled 5341-15746-04 U39 VIDEO IMAGE */
935   ROM_LOAD16_BYTE( "tm4k_u37.bin", 0x200001, 0x100000, CRC(bf49fafa) SHA1(b400667bf654dc9cd01a85c8b99670459400fd60) ) /* Mask rom labeled 5341-15746-02 U37 VIDEO IMAGE */
936   ROM_LOAD16_BYTE( "tm4k_u41.bin", 0x400000, 0x100000, CRC(e97edb1e) SHA1(75510676cf1692ad03efd4ccd57d25af1cc8ef2a) ) /* Mask rom labeled 5341-15746-06 U41 VIDEO IMAGE */
937   ROM_LOAD16_BYTE( "tm4k_u40.bin", 0x400001, 0x100000, CRC(f6771a09) SHA1(74f71d5e910006c83a38170f24aa811c38a3e020) ) /* Mask rom labeled 5341-15746-05 U40 VIDEO IMAGE */
910938
911939   ROM_REGION( 0x100000, REGION_SOUND1, 0 ) // Samples
912   ROM_LOAD( "tm4k_u8.bin", 0x00000, 0x100000, CRC(48c3782b) SHA1(bfe105ddbde8bbbd84665dfdd565d6d41926834a) )
940   ROM_LOAD( "tm4k_u8.bin", 0x00000, 0x100000, CRC(48c3782b) SHA1(bfe105ddbde8bbbd84665dfdd565d6d41926834a) ) /* Mask rom labeled 5341-15746-07 U8 SOUND IMAGE */
913941ROM_END
914942
915943/***************************************************************************
916944
945Touchmaster 5000
946by Midway (c) 1998
947touchscreen game
948
949All chips are ST M27C801
950---------------------------
951
952Name Board Location        Version               Use                      Checksum
953-----------------------------------------------------------------------------------
954tm5k_sound.u8              7.0  Audio Program & sounds          F474
955tm5k_v7_10.u51             7.10 Game Program & Cpu instructions 1A51
956tm5k_v7_10.u52             7.10 Game Program & Cpu instructions 5A01
957tm5k_graphic.u36           7.0  Video Images & Graphics         DB7F
958tm5k_graphic.u37           7.0  Video Images & Graphics         871B
959tm5k_graphic.u38           7.0  Video Images & Graphics         EDCE
960tm5k_graphic.u39           7.0  Video Images & Graphics         657F
961tm5k_graphic.u40           7.0  Video Images & Graphics         93E0
962tm5k_graphic.u41           7.0  Video Images & Graphics         FCA5
963
964J12 DALLAS DS1204V         N/A  Security Key (required for this Version) - Labeled A-21657-004
965-----------------------------------------------------------------------------------
966
967
968***************************************************************************/
969
970ROM_START( tm5k )
971   ROM_REGION( 0x200000, REGION_CPU1, 0 ) // 68000 Code
972   ROM_LOAD16_BYTE( "tm5k_v7_10.u51", 0x000000, 0x100000, CRC(df0bd25e) SHA1(db1a197ed4c868743397f3823f3f1d42b9329f80) ) /* TOUCHMASTER 5000 U51 DOMESTIC 7.10 (Standard 10-9-98) */
973   ROM_LOAD16_BYTE( "tm5k_v7_10.u52", 0x000001, 0x100000, CRC(ddf9e8dc) SHA1(3228f2eba067bdf1bd639116bffc589585ea3e72) ) /* TOUCHMASTER 5000 U52 DOMESTIC 7.10 (Standard 10-9-98) */
974
975   ROM_REGION( 0x600000, REGION_GFX1, 0 )   // Blitter gfx
976   ROM_LOAD16_BYTE( "tm5k_graphic.u38", 0x000000, 0x100000, CRC(93038e7c) SHA1(448f69bf51ac992f6b35b471cba9675c67984cd7) ) /* Labeled GRAPHIC U38  7.0 */
977   ROM_LOAD16_BYTE( "tm5k_graphic.u36", 0x000001, 0x100000, CRC(5453a44a) SHA1(094439a56336ca933b0b7ede8c057546d1d490b2) ) /* Labeled GRAPHIC U36  7.0 */
978   ROM_LOAD16_BYTE( "tm5k_graphic.u39", 0x200000, 0x100000, CRC(1349fdc7) SHA1(5118983be584455320f0d6006133f38e6a8ee0d8) ) /* Labeled GRAPHIC U39  7.0 */
979   ROM_LOAD16_BYTE( "tm5k_graphic.u37", 0x200001, 0x100000, CRC(8bcc376c) SHA1(0588f6f96090b26a3ce0eb3a933a5cc9d8ce742d) ) /* Labeled GRAPHIC U37  7.0 */
980   ROM_LOAD16_BYTE( "tm5k_graphic.u41", 0x400000, 0x100000, CRC(c8717fef) SHA1(fbd13321db0f35b7bdf207468f28792a7666bb2e) ) /* Labeled GRAPHIC U41  7.0 */
981   ROM_LOAD16_BYTE( "tm5k_graphic.u40", 0x400001, 0x100000, CRC(cff3f962) SHA1(2389d94ffa0eaf2d2f62315822273db031eea033) ) /* Labeled GRAPHIC U40  7.0 */
982
983   ROM_REGION( 0x100000, REGION_SOUND1, 0 ) // Samples
984   ROM_LOAD( "tm5k_sound.u8", 0x00000, 0x100000, CRC(c6070a60) SHA1(2dc20bf2217a36374b5a691133ad43f53dbe29ca) ) /* Labeled SOUND U8  7.0 */
985ROM_END
986
987/***************************************************************************
988
989Touchmaster 7000
990by Midway (c) 1998
991touchscreen game
992
993All chips are ST M27C801
994---------------------------
995
996Name Board Location        Version               Use                      Checksum
997-----------------------------------------------------------------------------------
998tm7k_sound.u8              8.0  Audio Program & sounds          F474 (same as TM5K)
999tm7k_v8.u51                8.00 Game Program & Cpu instructions 82A5
1000tm7k_v8.u52                8.00 Game Program & Cpu instructions 81E1
1001tm7k_graphic.u36           8.0  Video Images & Graphics         DB7F (same as TM5K)
1002tm7k_graphic.u37           8.0  Video Images & Graphics         7461
1003tm7k_graphic.u38           8.0  Video Images & Graphics         EDCE (same as TM5K)
1004tm7k_graphic.u39           8.0  Video Images & Graphics         2BB6
1005tm7k_graphic.u40           8.0  Video Images & Graphics         B103
1006tm7k_graphic.u41           8.0  Video Images & Graphics         11CA
1007
1008J12 DALLAS DS1204V         N/A  Security Key (required for this Version) - Labeled A-21657-005
1009-----------------------------------------------------------------------------------
1010
1011
1012***************************************************************************/
1013
1014ROM_START( tm7k )
1015   ROM_REGION( 0x200000, REGION_CPU1, 0 ) // 68000 Code
1016   ROM_LOAD16_BYTE( "tm7k_v8.u51", 0x000000, 0x100000, CRC(83ec3da7) SHA1(37fa7183e7acc2eab35ac431d99cbbfe4862979e) ) /* TOUCHMASTER 7000 U51 DOMESTIC 8.00 (Standard 03/26/99) */
1017   ROM_LOAD16_BYTE( "tm7k_v8.u52", 0x000001, 0x100000, CRC(e2004282) SHA1(aa73029f31e2062cabedfcd778db97b314624ae8) ) /* TOUCHMASTER 7000 U52 DOMESTIC 8.00 (Standard 03/26/99) */
1018
1019   ROM_REGION( 0x600000, REGION_GFX1, 0 )   // Blitter gfx
1020   ROM_LOAD16_BYTE( "tm7k_graphic.u38", 0x000000, 0x100000, CRC(93038e7c) SHA1(448f69bf51ac992f6b35b471cba9675c67984cd7) ) /* Labeled GRAPHIC U38  8.0 */
1021   ROM_LOAD16_BYTE( "tm7k_graphic.u36", 0x000001, 0x100000, CRC(5453a44a) SHA1(094439a56336ca933b0b7ede8c057546d1d490b2) ) /* Labeled GRAPHIC U36  8.0 */
1022   ROM_LOAD16_BYTE( "tm7k_graphic.u39", 0x200000, 0x100000, CRC(26af8da8) SHA1(02555b1597a4962f1fd0c3ffc89e5c8338aa3085) ) /* Labeled GRAPHIC U39  8.0 */
1023   ROM_LOAD16_BYTE( "tm7k_graphic.u37", 0x200001, 0x100000, CRC(9a705043) SHA1(cffb31859544c1c4082be78b3bca5ad9cd0d2a45) ) /* Labeled GRAPHIC U37  8.0 */
1024   ROM_LOAD16_BYTE( "tm7k_graphic.u41", 0x400000, 0x100000, CRC(99b6edda) SHA1(c0ee2834fdbfbc1159a6d08c45552d4d9c1c4ea4) ) /* Labeled GRAPHIC U41  8.0 */
1025   ROM_LOAD16_BYTE( "tm7k_graphic.u40", 0x400001, 0x100000, CRC(a3925379) SHA1(74836325ab10466e23105a3b54fc706c0dd5f06c) ) /* Labeled GRAPHIC U40  8.0 */
1026
1027   ROM_REGION( 0x100000, REGION_SOUND1, 0 ) // Samples
1028   ROM_LOAD( "tm7k_sound.u8", 0x00000, 0x100000, CRC(c6070a60) SHA1(2dc20bf2217a36374b5a691133ad43f53dbe29ca) ) /* Labeled SOUND U8  8.0 */
1029ROM_END
1030
1031/***************************************************************************
1032
9171033Galaxy Games BIOS v. 1.90
9181034
9191035This is a multi-game cocktail cabinet released in 1998.  Namco seems to have
r2375r2376
9921108
9931109   ROM[0x8342C/2] = 0x601a;
9941110   ROM[0x8346C/2] = 0x6002;
1111/*
1112Protection starts:
1113
1114 8341C: addi.w  #$384, D0       0640 0384
1115 83420: move.w  D0, $207a86.l   33C0 0020 7A86
1116 83426: btst    #$7, ($1,A5)    082D 0007 0001
1117 8342C: beq     $83448          671A           <-- First patch goes here
1118
1119*/
1120
9951121}
9961122
1123static DRIVER_INIT( tm5k )
1124{
1125   UINT16 *ROM = (UINT16 *)memory_region( REGION_CPU1 );
1126
1127   // protection
1128   ROM[0x96002/2] = 0x4e75;
1129
1130   ROM[0x95fd0/2] = 0x6002;
1131   ROM[0x95ff8/2] = 0x6002;
1132/*
1133Protection starts:
1134
1135 95FBE: addi.w  #$384, D0       0640 0384
1136 95FC2: move.w  D0, $207e9a.l   33C0 0020 7E9A
1137 95FC8: moveq   #$f, D0         700F
1138 95FCA: and.w   (A4), D0        C054
1139 95FCC: cmpi.w  #$3, D0         0C40 0003
1140 95FD0: bcs     $95fd4          6502          <-- First patch goes here
1141
1142*/
1143
1144}
1145
1146static DRIVER_INIT( tm7k )
1147{
1148   UINT16 *ROM = (UINT16 *)memory_region( REGION_CPU1 );
1149
1150   // protection
1151   ROM[0x81594/2] = 0x4e75;
1152
1153   ROM[0x81564/2] = 0x6004;
1154   ROM[0x8158c/2] = 0x6002;
1155/*
1156Protection starts:
1157
1158 81552: addi.w  #$76c, D0       0640 076C
1159 81556: move.w  D0, $207104.l   33C0 0020 7104
1160 8155C: moveq   #$f, D0         700F
1161 8155E: and.w   (A4), D0        C054
1162 81560: cmpi.w  #$3, D0         0C40 0003
1163 81564: bcs     $8156A          6504          <-- First patch goes here
1164
1165*/
1166
1167}
1168
9971169static DRIVER_INIT( galgames )
9981170{
9991171   // configure memory banks
r2375r2376
10071179GAME( 1996, tm,       0, tm,       tmaster,  0,        ROT0, "Midway",                         "Touchmaster",               GAME_NOT_WORKING )
10081180GAME( 1997, tm3k,     0, tm3k,     tmaster,  tm3k,     ROT0, "Midway",                         "Touchmaster 3000 (v5.01)",  GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS)   // imp. graphics due to bad dump
10091181GAME( 1998, tm4k,     0, tm3k,     tmaster,  tm4k,     ROT0, "Midway",                         "Touchmaster 4000 (v6.02)",  GAME_NOT_WORKING )
1182GAME( 1998, tm5k,     0, tm3k,     tmaster,  tm5k,     ROT0, "Midway",                         "Touchmaster 5000 (v7.10)",  GAME_NOT_WORKING )
1183GAME( 1999, tm7k,     0, tm3k,     tmaster,  tm7k,     ROT0, "Midway",                         "Touchmaster 7000 (v8.00)",  GAME_NOT_WORKING )
10101184GAME( 1998, galgbios, 0, galgames, galgames, galgames, ROT0, "Creative Electonics & Software", "Galaxy Games (BIOS v1.90)", GAME_IS_BIOS_ROOT )
src/mame/drivers/freekick.c
r2375r2376
9393
9494static READ8_HANDLER( spinner_r )
9595{
96   return readinputport(5 + spinner);
96   return input_port_read_indexed(machine, 5 + spinner);
9797}
9898
9999static READ8_HANDLER( gigas_spinner_r )
100100{
101   return readinputport( spinner );
101   return input_port_read_indexed(machine, spinner );
102102}
103103
104104static MACHINE_RESET( pbillrd )
src/mame/drivers/cischeat.c
r2375r2376
532532
533533READ16_HANDLER( scudhamm_analog_r )
534534{
535   return readinputport(1);
535   return input_port_read_indexed(machine, 1);
536536}
537537
538538/*
r2375r2376
627627   int armdelta;
628628   static int armold = 0;
629629
630   armdelta = readinputport(1) - armold;
631   armold = readinputport(1);
630   armdelta = input_port_read_indexed(machine, 1) - armold;
631   armold = input_port_read_indexed(machine, 1);
632632
633633   return ~( scudhamm_motor_command + armdelta );   // + x : x<=0 and player loses, x>0 and player wins
634634}
635635
636636static READ16_HANDLER( armchmp2_buttons_r )
637637{
638   int arm_x = readinputport(1);
638   int arm_x = input_port_read_indexed(machine, 1);
639639
640   UINT16 ret = readinputport(0);
640   UINT16 ret = input_port_read_indexed(machine, 0);
641641
642642   if (arm_x < 0x40)      ret &= ~1;
643643   else if (arm_x > 0xc0)   ret &= ~2;
src/mame/drivers/namcos22.c
r2375r2376
203203
204204/* TODO: REMOVE (THIS IS HANDLED BY "SUBCPU") */
205205static void
206ReadAnalogDrivingPorts( UINT16 *gas, UINT16 *brake, UINT16 *steer )
206ReadAnalogDrivingPorts( running_machine *machine, UINT16 *gas, UINT16 *brake, UINT16 *steer )
207207{
208   *gas   = readinputport(2);
209   *brake = readinputport(3);
210   *steer = readinputport(4);
208   *gas   = input_port_read_indexed(machine, 2);
209   *brake = input_port_read_indexed(machine, 3);
210   *steer = input_port_read_indexed(machine, 4);
211211}
212212
213213/* TODO: REMOVE (THIS IS HANDLED BY "SUBCPU") */
214214static UINT16
215AnalogAsDigital( void )
215AnalogAsDigital( running_machine *machine )
216216{
217   UINT16 stick = readinputport(1);
218   UINT16 gas   = readinputport(2);
219   UINT16 steer = readinputport(4);
217   UINT16 stick = input_port_read_indexed(machine, 1);
218   UINT16 gas   = input_port_read_indexed(machine, 2);
219   UINT16 steer = input_port_read_indexed(machine, 4);
220220   UINT16 result = 0xffff;
221221
222222   switch( namcos22_gametype )
r2375r2376
263263
264264/* TODO: REMOVE (THIS IS HANDLED BY "SUBCPU") */
265265static void
266HandleCoinage(int slots)
266HandleCoinage(running_machine *machine, int slots)
267267{
268268   UINT16 *share16 = (UINT16 *)namcos22_shareram;
269269   UINT32 coin_state;
270270
271   coin_state = readinputport(1) & 0x1200;
271   coin_state = input_port_read_indexed(machine, 1) & 0x1200;
272272
273273   if (!(coin_state & 0x1000) && (old_coin_state & 0x1000))
274274   {
r2375r2376
292292
293293/* TODO: REMOVE (THIS IS HANDLED BY "SUBCPU") */
294294static void
295HandleDrivingIO( void )
295HandleDrivingIO( running_machine *machine )
296296{
297297   if( nthbyte(namcos22_system_controller,0x18)!=0 )
298298   {
299      UINT16 flags = readinputport(1);
299      UINT16 flags = input_port_read_indexed(machine, 1);
300300      UINT16 gas,brake,steer;
301      ReadAnalogDrivingPorts( &gas, &brake, &steer );
301      ReadAnalogDrivingPorts( machine, &gas, &brake, &steer );
302302
303      HandleCoinage(2);
303      HandleCoinage(machine, 2);
304304
305305      switch (namcos22_gametype)
306306      {
r2375r2376
348348
349349/* TODO: REMOVE (THIS IS HANDLED BY "SUBCPU") */
350350static void
351HandleCyberCommandoIO( void )
351HandleCyberCommandoIO( running_machine *machine )
352352{
353353   if( nthbyte(namcos22_system_controller,0x18)!=0 )
354354   {
355      UINT16 flags = readinputport(1);
355      UINT16 flags = input_port_read_indexed(machine, 1);
356356
357      UINT16 volume0 = readinputport(2)*0x10;
358      UINT16 volume1 = readinputport(3)*0x10;
359      UINT16 volume2 = readinputport(4)*0x10;
360      UINT16 volume3 = readinputport(5)*0x10;
357      UINT16 volume0 = input_port_read_indexed(machine, 2)*0x10;
358      UINT16 volume1 = input_port_read_indexed(machine, 3)*0x10;
359      UINT16 volume2 = input_port_read_indexed(machine, 4)*0x10;
360      UINT16 volume3 = input_port_read_indexed(machine, 5)*0x10;
361361
362362      namcos22_shareram[0x030/4] = (flags<<16)|volume0;
363363      namcos22_shareram[0x034/4] = (volume1<<16)|volume2;
364364      namcos22_shareram[0x038/4] = volume3<<16;
365365
366      HandleCoinage(1);
366      HandleCoinage(machine, 1);
367367   }
368368} /* HandleCyberCommandoIO */
369369
r2375r2376
12991299}
13001300static WRITE32_HANDLER( namcos22_portbit_w )
13011301{
1302   unsigned dat50000008 = AnalogAsDigital();
1302   unsigned dat50000008 = AnalogAsDigital(machine);
13031303   unsigned dat5000000a = 0xffff;
13041304   mSys22PortBits = (dat50000008<<16)|dat5000000a;
13051305}
13061306
13071307static READ32_HANDLER( namcos22_dipswitch_r )
13081308{
1309   return readinputport(0)<<16;
1309   return input_port_read_indexed(machine, 0)<<16;
13101310}
13111311
13121312static READ32_HANDLER( namcos22_mcuram_r )
r2375r2376
13761376
13771377static READ32_HANDLER( namcos22_gun_r )
13781378{
1379   int xpos = readinputport(1)*640/0xff;
1380   int ypos = readinputport(2)*480/0xff;
1379   int xpos = input_port_read_indexed(machine, 1)*640/0xff;
1380   int ypos = input_port_read_indexed(machine, 2)*480/0xff;
13811381   switch( offset )
13821382   {
13831383   case 0: /* 430000 */
r2375r2376
15411541      {
15421542         if (mFrameCount & 1)
15431543         {
1544            return readinputportbytag_safe("MCUP5A", 0xff) | 0x80;
1544            return input_port_read_safe(machine, "MCUP5A", 0xff) | 0x80;
15451545         }
15461546         else
15471547         {
1548            return readinputportbytag_safe("MCUP5A", 0xff) & 0x7f;
1548            return input_port_read_safe(machine, "MCUP5A", 0xff) & 0x7f;
15491549         }
15501550      }
15511551      else
r2375r2376
15641564   {
15651565      if (p4 & 8)
15661566      {
1567         return readinputportbytag_safe("MCUP5A", 0xff);
1567         return input_port_read_safe(machine, "MCUP5A", 0xff);
15681568      }
15691569      else
15701570      {
1571         return readinputportbytag_safe("MCUP5B", 0xff);
1571         return input_port_read_safe(machine, "MCUP5B", 0xff);
15721572      }
15731573   }
15741574}
r2375r2376
16111611{
16121612   static UINT16 ddx, ddy;
16131613
1614   ddx = ((readinputport(2)^0xff)-1)<<2;
1615   ddy = (readinputport(3)-1)<<2;
1614   ddx = ((input_port_read_indexed(machine, 2)^0xff)-1)<<2;
1615   ddy = (input_port_read_indexed(machine, 3)-1)<<2;
16161616
16171617   switch (offset)
16181618   {
r2375r2376
16251625         // and timer A3 is configured by the MCU program to cause an interrupt each time
16261626         // it's clocked.  by counting the number of interrupts in a frame, we can determine
16271627         // how fast the user is pedaling.
1628         if( readinputport(1) & 0x10 )
1628         if( input_port_read_indexed(machine, 1) & 0x10 )
16291629         {
16301630            int i;
16311631            for (i = 0; i < 16; i++)
r2375r2376
16541654// 0 H+L = swing, 1 H+L = edge
16551655static READ8_HANDLER( alpineracer_mcu_adc_r )
16561656{
1657   UINT16 swing = (0xff-readinputport(2))<<2;
1658   UINT16 edge = (0xff-readinputport(3))<<2;
1657   UINT16 swing = (0xff-input_port_read_indexed(machine, 2))<<2;
1658   UINT16 edge = (0xff-input_port_read_indexed(machine, 3))<<2;
16591659
16601660   // fake out the centering a bit
1661   if (readinputport(2) == 0x80) swing = 0x200;
1662   if (readinputport(3) == 0x80) edge = 0x200;
1661   if (input_port_read_indexed(machine, 2) == 0x80) swing = 0x200;
1662   if (input_port_read_indexed(machine, 3) == 0x80) edge = 0x200;
16631663
16641664   switch (offset)
16651665   {
r2375r2376
16881688static READ8_HANDLER( cybrcycc_mcu_adc_r )
16891689{
16901690   UINT16 gas,brake,steer;
1691   ReadAnalogDrivingPorts( &gas, &brake, &steer );
1691   ReadAnalogDrivingPorts( machine, &gas, &brake, &steer );
16921692
16931693   gas <<= 2;
16941694   brake <<= 2;
r2375r2376
17301730{
17311731   UINT16 pedal, x, y;
17321732
1733   pedal = readinputport(1)<<2;
1734   x = readinputport(2)<<2;
1735   y = readinputport(3)<<2;
1733   pedal = input_port_read_indexed(machine, 1)<<2;
1734   x = input_port_read_indexed(machine, 2)<<2;
1735   y = input_port_read_indexed(machine, 3)<<2;
17361736
17371737
17381738   switch (offset)
r2375r2376
21272127   switch( namcos22_gametype )
21282128   {
21292129   case NAMCOS22_RIDGE_RACER:
2130      HandleDrivingIO();
2130      HandleDrivingIO(machine);
21312131      irq_level1 = 4;
21322132      irq_level2 = 5;
21332133      // 1:0a0b6
r2375r2376
21402140      break;
21412141
21422142   case NAMCOS22_RIDGE_RACER2:
2143      HandleDrivingIO();
2143      HandleDrivingIO(machine);
21442144      irq_level1 = 1;
21452145      irq_level2 = 5;
21462146      //1:0d10c  40000005
r2375r2376
21532153      break;
21542154
21552155   case NAMCOS22_RAVE_RACER:
2156      HandleDrivingIO();
2156      HandleDrivingIO(machine);
21572157      break;
21582158
21592159   case NAMCOS22_VICTORY_LAP:
2160      HandleDrivingIO();
2160      HandleDrivingIO(machine);
21612161      // a54 indir to 21c2 (hblank?)
21622162      // a5a (rte)
21632163      // a5c (rte)
r2375r2376
21702170      break;
21712171
21722172   case NAMCOS22_ACE_DRIVER:
2173      HandleDrivingIO();
2173      HandleDrivingIO(machine);
21742174      // 9f8 (rte)
21752175      // 9fa (rte)
21762176      // 9fc (rte)
r2375r2376
21882188      //move.b  #$35, $40000004.l
21892189      //
21902190      //move.b  #$34, $40000004.l
2191      HandleCyberCommandoIO();
2191      HandleCyberCommandoIO(machine);
21922192      irq_level1 = nthbyte(namcos22_system_controller,0x04)&0x7;
21932193      irq_level2 = nthbyte(namcos22_system_controller,0x02)&0x7;
21942194      break;
r2375r2376
43314331
43324332   install_c74_speedup();
43334333
4334   old_coin_state = readinputport(1) & 0x1200;
4334   old_coin_state = input_port_read_indexed(machine, 1) & 0x1200;
43354335   credits1 = credits2 = 0;
43364336}
43374337
r2375r2376
43414341
43424342   install_c74_speedup();
43434343
4344   old_coin_state = readinputport(1) & 0x1200;
4344   old_coin_state = input_port_read_indexed(machine, 1) & 0x1200;
43454345   credits1 = credits2 = 0;
43464346}
43474347
r2375r2376
43514351
43524352   install_c74_speedup();
43534353
4354   old_coin_state = readinputport(1) & 0x1200;
4354   old_coin_state = input_port_read_indexed(machine, 1) & 0x1200;
43554355   credits1 = credits2 = 0;
43564356}
43574357
r2375r2376
43614361
43624362   install_c74_speedup();
43634363
4364   old_coin_state = readinputport(1) & 0x1200;
4364   old_coin_state = input_port_read_indexed(machine, 1) & 0x1200;
43654365   credits1 = credits2 = 0;
43664366}
43674367
r2375r2376
43714371
43724372   install_c74_speedup();
43734373
4374   old_coin_state = readinputport(1) & 0x1200;
4374   old_coin_state = input_port_read_indexed(machine, 1) & 0x1200;
43754375   credits1 = credits2 = 0;
43764376}
43774377
r2375r2376
43884388
43894389   install_c74_speedup();
43904390
4391   old_coin_state = readinputport(1) & 0x1200;
4391   old_coin_state = input_port_read_indexed(machine, 1) & 0x1200;
43924392   credits1 = credits2 = 0;
43934393}
43944394
src/mame/drivers/flyball.c
r2375r2376
4141
4242   memset(potsense, 0, sizeof potsense);
4343
44   potsense[readinputport(1)] |= 1;
45   potsense[readinputport(2)] |= 2;
46   potsense[readinputport(3)] |= 4;
47   potsense[readinputport(4)] |= 8;
44   potsense[input_port_read_indexed(machine, 1)] |= 1;
45   potsense[input_port_read_indexed(machine, 2)] |= 2;
46   potsense[input_port_read_indexed(machine, 3)] |= 4;
47   potsense[input_port_read_indexed(machine, 4)] |= 8;
4848
4949   for (i = 0; i < 64; i++)
5050      if (potsense[i] != 0)
r2375r2376
7979
8080static READ8_HANDLER( flyball_input_r )
8181{
82   return readinputport(0) & readinputport(5);
82   return input_port_read_indexed(machine, 0) & input_port_read_indexed(machine, 5);
8383}
8484
8585static READ8_HANDLER( flyball_scanline_r )
src/mame/drivers/redclash.c
r2375r2376
4545*/
4646static INTERRUPT_GEN( redclash_interrupt )
4747{
48   if (readinputport(4) & 1)   /* Left Coin */
48   if (input_port_read_indexed(machine, 4) & 1)   /* Left Coin */
4949      cpunum_set_input_line(machine, 0,0,ASSERT_LINE);
50   else if (readinputport(4) & 2)   /* Right Coin */
50   else if (input_port_read_indexed(machine, 4) & 2)   /* Right Coin */
5151      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
5252}
5353
src/mame/drivers/vicdual.c
r2375r2376
8585
8686static CUSTOM_INPUT( vicdual_read_coin_status )
8787{
88   UINT32 coin_input = readinputportbytag(COIN_PORT_TAG);
88   UINT32 coin_input = input_port_read(machine, COIN_PORT_TAG);
8989
9090   if (coin_input && !last_coin_input)
9191   {
r2375r2376
188188#define COLOR_BW_PORT_TAG      "COLOR_BW"
189189
190190
191int vicdual_is_cabinet_color(void)
191int vicdual_is_cabinet_color(running_machine *machine)
192192{
193   return (readinputportbytag(COLOR_BW_PORT_TAG) == 0);
193   return (input_port_read(machine, COLOR_BW_PORT_TAG) == 0);
194194}
195195
196196
r2375r2376
352352{
353353   UINT8 ret = 0;
354354
355   if (offset & 0x01)  ret = input_port_0_r(machine,0);
356   if (offset & 0x08)  ret = input_port_1_r(machine,0);
355   if (offset & 0x01)  ret = input_port_read_indexed(machine, 0);
356   if (offset & 0x08)  ret = input_port_read_indexed(machine, 1);
357357
358358   return ret;
359359}
r2375r2376
436436{
437437   UINT8 ret = 0;
438438
439   if (offset & 0x01)  ret = input_port_0_r(machine,0);
440   if (offset & 0x08)  ret = input_port_1_r(machine,0);
439   if (offset & 0x01)  ret = input_port_read_indexed(machine, 0);
440   if (offset & 0x08)  ret = input_port_read_indexed(machine, 1);
441441
442442   return ret;
443443}
r2375r2376
544544{
545545   UINT8 ret = 0;
546546
547   if (offset & 0x01)  ret = input_port_0_r(machine,0);
548   if (offset & 0x08)  ret = input_port_1_r(machine,0);
547   if (offset & 0x01)  ret = input_port_read_indexed(machine, 0);
548   if (offset & 0x08)  ret = input_port_read_indexed(machine, 1);
549549
550550   return ret;
551551}
r2375r2376
20982098{
20992099   UINT8 ret = 0;
21002100
2101   if (offset & 0x01)  ret = input_port_0_r(machine,0);
2102   if (offset & 0x08)  ret = input_port_1_r(machine,0);
2101   if (offset & 0x01)  ret = input_port_read_indexed(machine, 0);
2102   if (offset & 0x08)  ret = input_port_read_indexed(machine, 1);
21032103
21042104   return ret;
21052105}
r2375r2376
21932193{
21942194   UINT8 ret = 0;
21952195
2196   if (offset & 0x01)  ret = input_port_0_r(machine,0);
2197   if (offset & 0x02)  ret = input_port_1_r(machine,0);
2198   if (offset & 0x08)  ret = input_port_2_r(machine,0);
2196   if (offset & 0x01)  ret = input_port_read_indexed(machine, 0);
2197   if (offset & 0x02)  ret = input_port_read_indexed(machine, 1);
2198   if (offset & 0x08)  ret = input_port_read_indexed(machine, 2);
21992199
22002200   return ret;
22012201}
src/mame/drivers/xybots.c
r2375r2376
6666{
6767   static int h256 = 0x0400;
6868
69   int result = readinputport(1);
69   int result = input_port_read_indexed(machine, 1);
7070
7171   if (atarigen_cpu_to_sound_ready) result ^= 0x0200;
7272   result ^= h256 ^= 0x0400;
src/mame/drivers/rockola.c
r2375r2376
10001000{
10011001   if (cpu_getiloops() != 0)
10021002   {
1003      UINT8 val = readinputportbytag("IN2");
1003      UINT8 val = input_port_read(machine, "IN2");
10041004
10051005      coin_counter_w(0, val & 1);
10061006
r2375r2376
10161016{
10171017   if (cpu_getiloops() != 0)
10181018   {
1019      UINT8 val = readinputportbytag("IN2");
1019      UINT8 val = input_port_read(machine, "IN2");
10201020
10211021      coin_counter_w(0, val & 1);
10221022      coin_counter_w(1, val & 2);
src/mame/drivers/magicfly.c
r2375r2376
444444{
445445   switch( mux_data & 0x0f )   /* bits 0-3 */
446446   {
447      case 0x01: return input_port_0_r(machine,0);
448      case 0x02: return input_port_1_r(machine,0);
449      case 0x04: return input_port_2_r(machine,0);
450      case 0x08: return input_port_3_r(machine,0);
451      case 0x00: return input_port_4_r(machine,0);
447      case 0x01: return input_port_read_indexed(machine, 0);
448      case 0x02: return input_port_read_indexed(machine, 1);
449      case 0x04: return input_port_read_indexed(machine, 2);
450      case 0x08: return input_port_read_indexed(machine, 3);
451      case 0x00: return input_port_read_indexed(machine, 4);
452452   }
453453   return 0xff;
454454}
src/mame/drivers/galaxold.c
r2375r2376
546546
547547
548548static READ8_HANDLER( scramb2_protection_r ) { return 0x25; }
549static READ8_HANDLER( scramb2_port0_r ) { return (readinputport(0)>>offset)&0x1; }
550static READ8_HANDLER( scramb2_port1_r ) { return (readinputport(1)>>offset)&0x1; }
551static READ8_HANDLER( scramb2_port2_r ) { return (readinputport(2)>>offset)&0x1; }
549static READ8_HANDLER( scramb2_port0_r ) { return (input_port_read_indexed(machine, 0)>>offset)&0x1; }
550static READ8_HANDLER( scramb2_port1_r ) { return (input_port_read_indexed(machine, 1)>>offset)&0x1; }
551static READ8_HANDLER( scramb2_port2_r ) { return (input_port_read_indexed(machine, 2)>>offset)&0x1; }
552552
553553static ADDRESS_MAP_START( scramb2_readmem, ADDRESS_SPACE_PROGRAM, 8 )
554554   AM_RANGE(0x0000, 0x3fff) AM_READ(SMH_ROM)
src/mame/drivers/centiped.c
r2375r2376
507507 * to prevent the counter from wrapping around between reads.
508508 */
509509
510INLINE int read_trackball(int idx, int switch_port)
510INLINE int read_trackball(running_machine *machine, int idx, int switch_port)
511511{
512512   UINT8 newpos;
513513
r2375r2376
517517
518518   /* if we're to read the dipswitches behind the trackball data, do it now */
519519   if (dsw_select)
520      return (readinputport(switch_port) & 0x7f) | sign[idx];
520      return (input_port_read_indexed(machine, switch_port) & 0x7f) | sign[idx];
521521
522522   /* get the new position and adjust the result */
523   newpos = readinputport(6 + idx);
523   newpos = input_port_read_indexed(machine, 6 + idx);
524524   if (newpos != oldpos[idx])
525525   {
526526      sign[idx] = (newpos - oldpos[idx]) & 0x80;
r2375r2376
528528   }
529529
530530   /* blend with the bits from the switch port */
531   return (readinputport(switch_port) & 0x70) | (oldpos[idx] & 0x0f) | sign[idx];
531   return (input_port_read_indexed(machine, switch_port) & 0x70) | (oldpos[idx] & 0x0f) | sign[idx];
532532}
533533
534534
535535static READ8_HANDLER( centiped_IN0_r )
536536{
537   return read_trackball(0, 0);
537   return read_trackball(machine, 0, 0);
538538}
539539
540540
541541static READ8_HANDLER( centiped_IN2_r )
542542{
543   return read_trackball(1, 2);
543   return read_trackball(machine, 1, 2);
544544}
545545
546546
547547static READ8_HANDLER( milliped_IN1_r )
548548{
549   return read_trackball(1, 1);
549   return read_trackball(machine, 1, 1);
550550}
551551
552552static READ8_HANDLER( milliped_IN2_r )
553553{
554   UINT8 data = readinputport(2);
554   UINT8 data = input_port_read_indexed(machine, 2);
555555
556556   /* MSH - 15 Feb, 2007
557557     * The P2 X Joystick inputs are not properly handled in
r2375r2376
562562     */
563563   if (0 != control_select) {
564564      /* Bottom 4 bits is our joystick inputs */
565      UINT8 joy2data = readinputport(3) & 0x0f;
565      UINT8 joy2data = input_port_read_indexed(machine, 3) & 0x0f;
566566      data = data & 0xf0; /* Keep the top 4 bits */
567567      data |= (joy2data & 0x0a) >> 1; /* flip left and up */
568568      data |= (joy2data & 0x05) << 1; /* flip right and down */
r2375r2376
584584
585585static READ8_HANDLER( mazeinv_input_r )
586586{
587   return readinputport(6 + control_select);
587   return input_port_read_indexed(machine, 6 + control_select);
588588}
589589
590590
src/mame/drivers/atarisy1.c
r2375r2376
214214
215215   /* digital joystick type */
216216   if (joystick_type == 1)
217      newval = (readinputport(0) & (0x80 >> offset)) ? 0xf0 : 0x00;
217      newval = (input_port_read_indexed(machine, 0) & (0x80 >> offset)) ? 0xf0 : 0x00;
218218
219219   /* Hall-effect analog joystick */
220220   else if (joystick_type == 2)
221      newval = readinputport(offset & 1);
221      newval = input_port_read_indexed(machine, offset & 1);
222222
223223   /* Road Blasters gas pedal */
224224   else if (joystick_type == 3)
225      newval = readinputport(1);
225      newval = input_port_read_indexed(machine, 1);
226226
227227   /* the A4 bit enables/disables joystick IRQs */
228228   joystick_int_enable = ((offset >> 3) & 1) ^ 1;
r2375r2376
268268
269269         if (player == 0)
270270         {
271            posx = (INT8)readinputport(0);
272            posy = (INT8)readinputport(1);
271            posx = (INT8)input_port_read_indexed(machine, 0);
272            posy = (INT8)input_port_read_indexed(machine, 1);
273273         }
274274         else
275275         {
276            posx = (INT8)readinputport(2);
277            posy = (INT8)readinputport(3);
276            posx = (INT8)input_port_read_indexed(machine, 2);
277            posy = (INT8)input_port_read_indexed(machine, 3);
278278         }
279279
280280         cur[player][0] = posx + posy;
r2375r2376
286286
287287   /* Road Blasters steering wheel */
288288   else if (trackball_type == 2)
289      result = readinputport(0);
289      result = input_port_read_indexed(machine, 0);
290290
291291   return result;
292292}
r2375r2376
301301
302302static READ16_HANDLER( port4_r )
303303{
304   int temp = readinputport(4);
304   int temp = input_port_read_indexed(machine, 4);
305305   if (atarigen_cpu_to_sound_ready) temp ^= 0x0080;
306306   return temp;
307307}
r2375r2376
316316
317317static READ8_HANDLER( switch_6502_r )
318318{
319   int temp = readinputport(5);
319   int temp = input_port_read_indexed(machine, 5);
320320
321321   if (atarigen_cpu_to_sound_ready) temp ^= 0x08;
322322   if (atarigen_sound_to_cpu_ready) temp ^= 0x10;
323   if (!(readinputport(4) & 0x0040)) temp ^= 0x80;
323   if (!(input_port_read_indexed(machine, 4) & 0x0040)) temp ^= 0x80;
324324
325325   return temp;
326326}
src/mame/drivers/wgp.c
r2375r2376
548548static READ16_HANDLER( wgp_adinput_r )
549549{
550550   int steer = 0x40;
551   int fake = readinputportbytag_safe(FAKE_PORT_TAG,0x00);
551   int fake = input_port_read_safe(machine, FAKE_PORT_TAG,0x00);
552552
553553   if (!(fake & 0x10))   /* Analogue steer (the real control method) */
554554   {
555555      /* Reduce span to 0x80 */
556      steer = (readinputportbytag_safe(STEER_PORT_TAG,0x00) * 0x80) / 0x100;
556      steer = (input_port_read_safe(machine, STEER_PORT_TAG,0x00) * 0x80) / 0x100;
557557   }
558558   else   /* Digital steer */
559559   {
r2375r2376
598598      }
599599
600600      case 0x05:
601         return readinputportbytag_safe(UNKNOWN_PORT_TAG,0x00);   /* unknown */
601         return input_port_read_safe(machine, UNKNOWN_PORT_TAG,0x00);   /* unknown */
602602   }
603603
604604logerror("CPU #0 PC %06x: warning - read unmapped a/d input offset %06x\n",activecpu_get_pc(),offset);
r2375r2376
935935graphics glitches.
936936***********************************************************/
937937
938static STATE_POSTLOAD( wgp_postload )
939{
940   parse_control();
941   reset_sound_region();
942}
943
938944static MACHINE_START( wgp )
939945{
940946   state_save_register_global(cpua_ctrl);
941   state_save_register_func_postload(parse_control);
942
943947   state_save_register_global(banknum);
944   state_save_register_func_postload(reset_sound_region);
948   state_save_register_postload(machine, wgp_postload, NULL);
945949}
946950
947951static MACHINE_DRIVER_START( wgp )
src/mame/drivers/welltris.c
r2375r2376
354354
355355static READ16_HANDLER( in0_r )
356356{
357   return readinputport(0) | (pending_command ? 0x80 : 0);
357   return input_port_read_indexed(machine, 0) | (pending_command ? 0x80 : 0);
358358}
359359
360360static WRITE8_HANDLER( pending_command_clear_w )
src/mame/drivers/sprint8.c
r2375r2376
3434
3535   for (i = 0; i < 8; i++)
3636   {
37      UINT8 val = readinputport(8 + i) >> 4;
37      UINT8 val = input_port_read_indexed(machine, 8 + i) >> 4;
3838
3939      signed char delta = (val - dial[i]) & 15;
4040
r2375r2376
7171
7272static READ8_HANDLER( sprint8_input_r )
7373{
74   UINT8 val = readinputport(offset);
74   UINT8 val = input_port_read_indexed(machine, offset);
7575
7676   if (steer_dir[offset])
7777   {
src/mame/drivers/ssv.c
r2375r2376
491491
492492static READ16_HANDLER( gdfs_eeprom_r )
493493{
494   return (((gdfs_lightgun_select & 1) ? 0 : 0xff) ^ readinputport(5 + gdfs_lightgun_select)) | (EEPROM_read_bit() << 8);
494   return (((gdfs_lightgun_select & 1) ? 0 : 0xff) ^ input_port_read_indexed(machine, 5 + gdfs_lightgun_select)) | (EEPROM_read_bit() << 8);
495495}
496496
497497static WRITE16_HANDLER( gdfs_eeprom_w )
r2375r2376
644644static READ16_HANDLER( hypreact_input_r )
645645{
646646   UINT16 input_sel = *ssv_input_sel;
647   if (input_sel & 0x0001)   return readinputport(5);
648   if (input_sel & 0x0002)   return readinputport(6);
649   if (input_sel & 0x0004)   return readinputport(7);
650   if (input_sel & 0x0008)   return readinputport(8);
647   if (input_sel & 0x0001)   return input_port_read_indexed(machine, 5);
648   if (input_sel & 0x0002)   return input_port_read_indexed(machine, 6);
649   if (input_sel & 0x0004)   return input_port_read_indexed(machine, 7);
650   if (input_sel & 0x0008)   return input_port_read_indexed(machine, 8);
651651   logerror("CPU #0 PC %06X: unknown input read: %04X\n",activecpu_get_pc(),input_sel);
652652   return 0xffff;
653653}
r2375r2376
792792static READ16_HANDLER( srmp4_input_r )
793793{
794794   UINT16 input_sel = *ssv_input_sel;
795   if (input_sel & 0x0002)   return readinputport(5);
796   if (input_sel & 0x0004)   return readinputport(6);
797   if (input_sel & 0x0008)   return readinputport(7);
798   if (input_sel & 0x0010)   return readinputport(8);
795   if (input_sel & 0x0002)   return input_port_read_indexed(machine, 5);
796   if (input_sel & 0x0004)   return input_port_read_indexed(machine, 6);
797   if (input_sel & 0x0008)   return input_port_read_indexed(machine, 7);
798   if (input_sel & 0x0010)   return input_port_read_indexed(machine, 8);
799799   logerror("CPU #0 PC %06X: unknown input read: %04X\n",activecpu_get_pc(),input_sel);
800800   return 0xffff;
801801}
r2375r2376
841841static READ16_HANDLER( srmp7_input_r )
842842{
843843   UINT16 input_sel = *ssv_input_sel;
844   if (input_sel & 0x0002)   return readinputport(5);
845   if (input_sel & 0x0004)   return readinputport(6);
846   if (input_sel & 0x0008)   return readinputport(7);
847   if (input_sel & 0x0010)   return readinputport(8);
844   if (input_sel & 0x0002)   return input_port_read_indexed(machine, 5);
845   if (input_sel & 0x0004)   return input_port_read_indexed(machine, 6);
846   if (input_sel & 0x0008)   return input_port_read_indexed(machine, 7);
847   if (input_sel & 0x0010)   return input_port_read_indexed(machine, 8);
848848   logerror("CPU #0 PC %06X: unknown input read: %04X\n",activecpu_get_pc(),input_sel);
849849   return 0xffff;
850850}
r2375r2376
898898
899899static READ16_HANDLER( sxyreact_ballswitch_r )
900900{
901   return readinputport(5);
901   return input_port_read_indexed(machine, 5);
902902}
903903
904904static READ16_HANDLER( sxyreact_dial_r )
r2375r2376
913913      static int old;
914914
915915      if (data & 0x20)
916         serial = readinputport(6) & 0xff;
916         serial = input_port_read_indexed(machine, 6) & 0xff;
917917
918918      if ( (old & 0x40) && !(data & 0x40) )   // $40 -> $00
919919         serial <<= 1;                  // shift 1 bit
r2375r2376
10711071{
10721072   switch(trackball_select)
10731073   {
1074      case 0x60:   return (readinputport(5) >> 8) & 0xff;
1075      case 0x40:   return (readinputport(5) >> 0) & 0xff;
1074      case 0x60:   return (input_port_read_indexed(machine, 5) >> 8) & 0xff;
1075      case 0x40:   return (input_port_read_indexed(machine, 5) >> 0) & 0xff;
10761076
1077      case 0x70:   return (readinputport(6) >> 8) & 0xff;
1078      case 0x50:   return (readinputport(6) >> 0) & 0xff;
1077      case 0x70:   return (input_port_read_indexed(machine, 6) >> 8) & 0xff;
1078      case 0x50:   return (input_port_read_indexed(machine, 6) >> 0) & 0xff;
10791079   }
10801080   return 0;
10811081}
src/mame/drivers/taitoair.c
r2375r2376
312312   switch( offset )
313313   {
314314      case 0x00:   /* "counter 1" lo */
315         return readinputportbytag(STICK1_PORT_TAG);
315         return input_port_read(machine, STICK1_PORT_TAG);
316316
317317      case 0x01:   /* "counter 2" lo */
318         return readinputportbytag(STICK2_PORT_TAG);
318         return input_port_read(machine, STICK2_PORT_TAG);
319319
320320      case 0x02:   /* "counter 1" hi */
321         return (readinputportbytag(STICK1_PORT_TAG) & 0xff00) >> 8;
321         return (input_port_read(machine, STICK1_PORT_TAG) & 0xff00) >> 8;
322322
323323      case 0x03:   /* "counter 2" hi */
324         return (readinputportbytag(STICK2_PORT_TAG) & 0xff00) >> 8;
324         return (input_port_read(machine, STICK2_PORT_TAG) & 0xff00) >> 8;
325325   }
326326
327327   return 0;
r2375r2376
332332   switch( offset )
333333   {
334334      case 0x00:   /* "counter 3" lo */
335         return readinputportbytag(STICK3_PORT_TAG);
335         return input_port_read(machine, STICK3_PORT_TAG);
336336
337337      case 0x02:   /* "counter 3" hi */
338         return (readinputportbytag(STICK3_PORT_TAG) & 0xff00) >> 8;
338         return (input_port_read(machine, STICK3_PORT_TAG) & 0xff00) >> 8;
339339   }
340340
341341   return 0;
r2375r2376
355355   reset_sound_region();
356356}
357357
358static STATE_POSTLOAD( taitoair_postload )
359{
360   reset_sound_region();
361}
358362
359363static MACHINE_START( taitoair )
360364{
361365   dsp_HOLD_signal = ASSERT_LINE;
362366
363367   state_save_register_global(banknum);
364   state_save_register_func_postload(reset_sound_region);
368   state_save_register_postload(machine, taitoair_postload, NULL);
365369}
366370
367371
src/mame/drivers/atarig42.c
r2375r2376
8383
8484static READ16_HANDLER( special_port2_r )
8585{
86   int temp = readinputport(2);
86   int temp = input_port_read_indexed(machine, 2);
8787   if (atarigen_cpu_to_sound_ready) temp ^= 0x0020;
8888   if (atarigen_sound_to_cpu_ready) temp ^= 0x0010;
8989   temp ^= 0x0008;      /* A2D.EOC always high for now */
r2375r2376
9393
9494static WRITE16_HANDLER( a2d_select_w )
9595{
96   analog_data = readinputport(4 + (offset != 0));
96   analog_data = input_port_read_indexed(machine, 4 + (offset != 0));
9797}
9898
9999
src/mame/drivers/tceptor.c
r2375r2376
150150
151151static READ8_HANDLER( dsw0_r )
152152{
153   return fix_input0(readinputport(0), readinputport(1));
153   return fix_input0(input_port_read_indexed(machine, 0), input_port_read_indexed(machine, 1));
154154}
155155
156156static READ8_HANDLER( dsw1_r )
157157{
158   return fix_input1(readinputport(0), readinputport(1));
158   return fix_input1(input_port_read_indexed(machine, 0), input_port_read_indexed(machine, 1));
159159}
160160
161161static READ8_HANDLER( input0_r )
162162{
163   return fix_input0(readinputport(2), readinputport(3));
163   return fix_input0(input_port_read_indexed(machine, 2), input_port_read_indexed(machine, 3));
164164}
165165
166166static READ8_HANDLER( input1_r )
167167{
168   return fix_input1(readinputport(2), readinputport(3));
168   return fix_input1(input_port_read_indexed(machine, 2), input_port_read_indexed(machine, 3));
169169}
170170
171171static READ8_HANDLER( readFF )
src/mame/drivers/cop01.c
r2375r2376
101101   switch (offset)
102102   {
103103      case 0 :
104         data = (readinputportbytag("DSW1") & 0x7f) | ((readinputportbytag("FAKE") & 0x04) << 5);
104         data = (input_port_read(machine, "DSW1") & 0x7f) | ((input_port_read(machine, "FAKE") & 0x04) << 5);
105105         break;
106106      case 1 :
107         data = (readinputportbytag("DSW2") & 0x3f) | ((readinputportbytag("FAKE") & 0x03) << 6);
107         data = (input_port_read(machine, "DSW2") & 0x3f) | ((input_port_read(machine, "FAKE") & 0x03) << 6);
108108         break;
109109      }
110110
src/mame/drivers/vindictr.c
r2375r2376
6464
6565static READ16_HANDLER( port1_r )
6666{
67   int result = readinputport(1);
67   int result = input_port_read_indexed(machine, 1);
6868   if (atarigen_sound_to_cpu_ready) result ^= 0x0004;
6969   if (atarigen_cpu_to_sound_ready) result ^= 0x0008;
7070   result ^= 0x0010;
src/mame/drivers/hanaawas.c
r2375r2376
4747   switch( mux )
4848   {
4949   case 1: /* start buttons */
50      buttons = readinputport(4);
50      buttons = input_port_read_indexed(machine, 4);
5151      break;
5252   case 2: /* player 1 buttons */
53      buttons = readinputport(2);
53      buttons = input_port_read_indexed(machine, 2);
5454      break;
5555   case 4: /* player 2 buttons */
56      buttons = readinputport(3);
56      buttons = input_port_read_indexed(machine, 3);
5757      break;
5858   }
5959
r2375r2376
6969      }
7070   }
7171
72   return (input_port_0_r(machine,0) & 0xf0) | ordinal;
72   return (input_port_read_indexed(machine, 0) & 0xf0) | ordinal;
7373}
7474
7575static WRITE8_HANDLER( hanaawas_inputs_mux_w )
src/mame/drivers/aquarium.c
r2375r2376
7575static MACHINE_RESET( aquarium )
7676{
7777   UINT16 *RAM = (UINT16 *)memory_region(REGION_CPU1);
78   int data = readinputportbytag("FAKE");
78   int data = input_port_read(machine, "FAKE");
7979
8080   /* Language : 0x0000 = Japanese - Other value = English */
8181
src/mame/drivers/metro.c
r2375r2376
374374
375375static READ16_HANDLER( daitorid_soundstatus_r )
376376{
377   return readinputport(0) | (busy_sndcpu ? 0x80 : 0x00);
377   return input_port_read_indexed(machine, 0) | (busy_sndcpu ? 0x80 : 0x00);
378378}
379379
380380static WRITE16_HANDLER( metro_soundstatus_w )
r2375r2376
908908/* Really weird way of mapping 3 DSWs */
909909static READ16_HANDLER( balcube_dsw_r )
910910{
911   UINT16 dsw1 = readinputport(2) >> 0;
912   UINT16 dsw2 = readinputport(2) >> 8;
913   UINT16 dsw3 = readinputport(3);
911   UINT16 dsw1 = input_port_read_indexed(machine, 2) >> 0;
912   UINT16 dsw2 = input_port_read_indexed(machine, 2) >> 8;
913   UINT16 dsw3 = input_port_read_indexed(machine, 3);
914914
915915   switch (offset*2)
916916   {
r2375r2376
14151415{
14161416   UINT16 input_sel = (*gakusai_input_sel) ^ 0x3e;
14171417   // Bit 0 ??
1418   if (input_sel & 0x0002)   return readinputport(0);
1419   if (input_sel & 0x0004)   return readinputport(1);
1420   if (input_sel & 0x0008)   return readinputport(2);
1421   if (input_sel & 0x0010)   return readinputport(3);
1422   if (input_sel & 0x0020)   return readinputport(4);
1418   if (input_sel & 0x0002)   return input_port_read_indexed(machine, 0);
1419   if (input_sel & 0x0004)   return input_port_read_indexed(machine, 1);
1420   if (input_sel & 0x0008)   return input_port_read_indexed(machine, 2);
1421   if (input_sel & 0x0010)   return input_port_read_indexed(machine, 3);
1422   if (input_sel & 0x0020)   return input_port_read_indexed(machine, 4);
14231423   return 0xffff;
14241424}
14251425
r2375r2376
20972097
20982098static READ16_HANDLER( puzzlet_dsw_r )
20992099{
2100   return readinputport(3);
2100   return input_port_read_indexed(machine, 3);
21012101}
21022102
21032103static WRITE16_HANDLER( puzzlet_irq_enable_w )
src/mame/drivers/angelkds.c
r2375r2376
181181
182182static READ8_HANDLER( angelkds_input_r )
183183{
184   int fake = readinputport(6+offset);
184   int fake = input_port_read_indexed(machine, 6+offset);
185185
186   return ((fake & 0x01) ? fake  : readinputport(4+offset));
186   return ((fake & 0x01) ? fake  : input_port_read_indexed(machine, 4+offset));
187187}
188188
189189#else
190190
191191static READ8_HANDLER( angelkds_input_r )
192192{
193   return readinputport(4+offset);
193   return input_port_read_indexed(machine, 4+offset);
194194}
195195
196196#endif
src/mame/drivers/midvunit.c
r2375r2376
104104
105105static READ32_HANDLER( port0_r )
106106{
107   UINT16 val = readinputport(0);
107   UINT16 val = input_port_read_indexed(machine, 0);
108108   UINT16 diff = val ^ last_port0;
109109
110110   /* make sure the shift controls are mutually exclusive */
r2375r2376
126126
127127static READ32_HANDLER( port1_r )
128128{
129   return (readinputport(1) << 16) | readinputport(1);
129   return (input_port_read_indexed(machine, 1) << 16) | input_port_read_indexed(machine, 1);
130130}
131131
132132
133133static READ32_HANDLER( port2_r )
134134{
135   return (readinputport(2) << 16) | readinputport(2);
135   return (input_port_read_indexed(machine, 2) << 16) | input_port_read_indexed(machine, 2);
136136}
137137
138138
r2375r2376
169169      int which = (data >> adc_shift) - 4;
170170      if (which < 0 || which > 2)
171171         logerror("adc_w: unexpected which = %02X\n", which + 4);
172      adc_data = readinputport(3 + which);
172      adc_data = input_port_read_indexed(machine, 3 + which);
173173      timer_set(ATTOTIME_IN_MSEC(1), NULL, 0, adc_ready);
174174   }
175175   else
src/mame/drivers/usgames.c
r2375r2376
6868
6969
7070
71static ADDRESS_MAP_START( usgames_readmem, ADDRESS_SPACE_PROGRAM, 8 )
72   AM_RANGE(0x0000, 0x1fff) AM_READ(SMH_RAM)
73
71static ADDRESS_MAP_START( usgames_map, ADDRESS_SPACE_PROGRAM, 8 )
72   AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)
7473   AM_RANGE(0x2000, 0x2000) AM_READ(input_port_1_r)
7574   AM_RANGE(0x2010, 0x2010) AM_READ(input_port_0_r)
76   AM_RANGE(0x2041, 0x2041) AM_READ(input_port_2_r)
77   AM_RANGE(0x2070, 0x2070) AM_READ(input_port_3_r)
78
79   AM_RANGE(0x2800, 0x2fff) AM_READ(SMH_RAM)
80   AM_RANGE(0x3000, 0x3fff) AM_READ(SMH_RAM)
81   AM_RANGE(0x4000, 0x7fff) AM_READ(SMH_BANK1)
82   AM_RANGE(0x8000, 0xffff) AM_READ(SMH_ROM)
83ADDRESS_MAP_END
84
85static ADDRESS_MAP_START( usg185_readmem, ADDRESS_SPACE_PROGRAM, 8 )
86   AM_RANGE(0x0000, 0x1fff) AM_READ(SMH_RAM)
87
88   AM_RANGE(0x2400, 0x2400) AM_READ(input_port_1_r)
89   AM_RANGE(0x2410, 0x2410) AM_READ(input_port_0_r)
90   AM_RANGE(0x2441, 0x2441) AM_READ(input_port_2_r)
91   AM_RANGE(0x2470, 0x2470) AM_READ(input_port_3_r)
92
93   AM_RANGE(0x2800, 0x2fff) AM_READ(SMH_RAM)
94   AM_RANGE(0x3000, 0x3fff) AM_READ(SMH_RAM)
95   AM_RANGE(0x4000, 0x7fff) AM_READ(SMH_BANK1)
96   AM_RANGE(0x8000, 0xffff) AM_READ(SMH_ROM)
97ADDRESS_MAP_END
98
99static ADDRESS_MAP_START( usgames_writemem, ADDRESS_SPACE_PROGRAM, 8 )
100   AM_RANGE(0x0000, 0x1fff) AM_WRITE(SMH_RAM) AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)
101
10275   AM_RANGE(0x2020, 0x2020) AM_WRITE(lamps1_w)
10376   AM_RANGE(0x2030, 0x2030) AM_WRITE(lamps2_w)
104
10577   AM_RANGE(0x2040, 0x2040) AM_DEVWRITE(MC6845, "crtc", mc6845_address_w)
78   AM_RANGE(0x2041, 0x2041) AM_READ(input_port_2_r)
10679   AM_RANGE(0x2041, 0x2041) AM_DEVWRITE(MC6845, "crtc", mc6845_register_w)
107
80   AM_RANGE(0x2060, 0x2060) AM_WRITE(usgames_rombank_w)
81   AM_RANGE(0x2070, 0x2070) AM_READ(input_port_3_r)
10882   AM_RANGE(0x2400, 0x2400) AM_WRITE(AY8910_control_port_0_w)
10983   AM_RANGE(0x2401, 0x2401) AM_WRITE(AY8910_write_port_0_w)
110
111   AM_RANGE(0x2060, 0x2060) AM_WRITE(usgames_rombank_w)
112
113   AM_RANGE(0x2800, 0x2fff) AM_WRITE(usgames_charram_w) AM_BASE(&usgames_charram)
114   AM_RANGE(0x3000, 0x3fff) AM_WRITE(usgames_videoram_w) AM_BASE(&usgames_videoram)
115   AM_RANGE(0x4000, 0x7fff) AM_WRITE(SMH_ROM)
116   AM_RANGE(0x8000, 0xffff) AM_WRITE(SMH_ROM)
84   AM_RANGE(0x2800, 0x2fff) AM_RAM AM_WRITE(usgames_charram_w) AM_BASE(&usgames_charram)
85   AM_RANGE(0x3000, 0x3fff) AM_RAM AM_WRITE(usgames_videoram_w) AM_BASE(&usgames_videoram)
86   AM_RANGE(0x4000, 0x7fff) AM_READWRITE(SMH_BANK1, SMH_ROM)
87   AM_RANGE(0x8000, 0xffff) AM_ROM
11788ADDRESS_MAP_END
11889
119static ADDRESS_MAP_START( usg185_writemem, ADDRESS_SPACE_PROGRAM, 8 )
120   AM_RANGE(0x0000, 0x1fff) AM_WRITE(SMH_RAM) AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)
12190
91static ADDRESS_MAP_START( usg185_map, ADDRESS_SPACE_PROGRAM, 8 )
92   AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)
93   AM_RANGE(0x2000, 0x2000) AM_WRITE(AY8910_control_port_0_w)
94   AM_RANGE(0x2001, 0x2001) AM_WRITE(AY8910_write_port_0_w)
95   AM_RANGE(0x2400, 0x2400) AM_READ(input_port_1_r)
96   AM_RANGE(0x2410, 0x2410) AM_READ(input_port_0_r)
12297   AM_RANGE(0x2420, 0x2420) AM_WRITE(lamps1_w)
12398   AM_RANGE(0x2430, 0x2430) AM_WRITE(lamps2_w)
124
12599   AM_RANGE(0x2440, 0x2440) AM_DEVWRITE(MC6845, "crtc", mc6845_address_w)
100   AM_RANGE(0x2441, 0x2441) AM_READ(input_port_2_r)
126101   AM_RANGE(0x2441, 0x2441) AM_DEVWRITE(MC6845, "crtc", mc6845_register_w)
127
128   AM_RANGE(0x2000, 0x2000) AM_WRITE(AY8910_control_port_0_w)
129   AM_RANGE(0x2001, 0x2001) AM_WRITE(AY8910_write_port_0_w)
130
131102   AM_RANGE(0x2460, 0x2460) AM_WRITE(usgames_rombank_w)
132
133   AM_RANGE(0x2800, 0x2fff) AM_WRITE(usgames_charram_w) AM_BASE(&usgames_charram)
134   AM_RANGE(0x3000, 0x3fff) AM_WRITE(usgames_videoram_w) AM_BASE(&usgames_videoram)
135   AM_RANGE(0x4000, 0x7fff) AM_WRITE(SMH_ROM)
136   AM_RANGE(0x8000, 0xffff) AM_WRITE(SMH_ROM)
103   AM_RANGE(0x2470, 0x2470) AM_READ(input_port_3_r)
104   AM_RANGE(0x2800, 0x2fff) AM_RAM AM_WRITE(usgames_charram_w) AM_BASE(&usgames_charram)
105   AM_RANGE(0x3000, 0x3fff) AM_RAM AM_WRITE(usgames_videoram_w) AM_BASE(&usgames_videoram)
106   AM_RANGE(0x4000, 0x7fff) AM_READWRITE(SMH_BANK1, SMH_ROM)
107   AM_RANGE(0x8000, 0xffff) AM_ROM
137108ADDRESS_MAP_END
138109
139110#define USGIN0\
r2375r2376
290261
291262   /* basic machine hardware */
292263   MDRV_CPU_ADD_TAG("main", M6809, 2000000) /* ?? */
293   MDRV_CPU_PROGRAM_MAP(usgames_readmem,usgames_writemem)
264   MDRV_CPU_PROGRAM_MAP(usgames_map,0)
294265   MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold,5) /* ?? */
295266
296267   MDRV_NVRAM_HANDLER(generic_0fill)
r2375r2376
322293static MACHINE_DRIVER_START( usg185 )
323294   MDRV_IMPORT_FROM(usg32)
324295   MDRV_CPU_MODIFY("main")
325   MDRV_CPU_PROGRAM_MAP(usg185_readmem,usg185_writemem)
296   MDRV_CPU_PROGRAM_MAP(usg185_map,0)
326297MACHINE_DRIVER_END
327298
328299
src/mame/drivers/opwolf.c
r2375r2376
140140static READ16_HANDLER( opwolf_in_r )
141141{
142142   static const char *const inname[2] = { "IN0", "IN1" };
143   return readinputportbytag(inname[offset]);
143   return input_port_read(machine, inname[offset]);
144144}
145145
146146static READ16_HANDLER( opwolf_dsw_r )
147147{
148148   static const char *const dswname[2] = { "DSWA", "DSWB" };
149   return readinputportbytag(dswname[offset]);
149   return input_port_read(machine, dswname[offset]);
150150}
151151
152152static READ16_HANDLER( opwolf_lightgun_r )
r2375r2376
156156   switch (offset)
157157   {
158158      case 0x00:   /* P1X - Have to remap 8 bit input value, into 0-319 visible range */
159         scaled=(readinputportbytag(P1X_PORT_TAG) * 320 ) / 256;
159         scaled=(input_port_read(machine, P1X_PORT_TAG) * 320 ) / 256;
160160         return (scaled + 0x15 + opwolf_gun_xoffs);
161161      case 0x01:   /* P1Y */
162         return (readinputportbytag(P1Y_PORT_TAG) - 0x24 + opwolf_gun_yoffs);
162         return (input_port_read(machine, P1Y_PORT_TAG) - 0x24 + opwolf_gun_yoffs);
163163   }
164164
165165   return 0xff;
r2375r2376
167167
168168static READ8_HANDLER( z80_input1_r )
169169{
170   return readinputportbytag("IN0");   /* irrelevant mirror ? */
170   return input_port_read(machine, "IN0");   /* irrelevant mirror ? */
171171}
172172
173173static READ8_HANDLER( z80_input2_r )
174174{
175   return readinputportbytag("IN0");   /* needed for coins */
175   return input_port_read(machine, "IN0");   /* needed for coins */
176176}
177177
178178
src/mame/drivers/pmpoker.c
r2375r2376
885885{
886886   switch( mux_data&0xf0 )   /* bits 4-7 */
887887   {
888      case 0x10: return input_port_0_r(machine,0);
889      case 0x20: return input_port_1_r(machine,0);
890      case 0x40: return input_port_2_r(machine,0);
891      case 0x80: return input_port_3_r(machine,0);
888      case 0x10: return input_port_read_indexed(machine, 0);
889      case 0x20: return input_port_read_indexed(machine, 1);
890      case 0x40: return input_port_read_indexed(machine, 2);
891      case 0x80: return input_port_read_indexed(machine, 3);
892892   }
893893   return 0xff;
894894}
src/mame/drivers/zaccaria.c
r2375r2376
7979
8080static READ8_HANDLER( zaccaria_dsw_r )
8181{
82   return readinputport(dsw);
82   return input_port_read_indexed(machine, dsw);
8383}
8484
8585
r2375r2376
300300   switch (offset)
301301   {
302302      case 0:
303         return (input_port_6_r(machine,0) & 0x07) | (acs & 0x08);   /* bits 4 and 5 must be 0 in Jack Rabbit */
303         return (input_port_read_indexed(machine, 6) & 0x07) | (acs & 0x08);   /* bits 4 and 5 must be 0 in Jack Rabbit */
304304
305305      case 2:
306306         return 0x10;    /* Jack Rabbit */
r2375r2376
329329
330330
331331
332static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 )
333   AM_RANGE(0x0000, 0x5fff) AM_READ(SMH_ROM)
332static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
333   AM_RANGE(0x0000, 0x5fff) AM_ROM
334334   AM_RANGE(0x6000, 0x63ff) AM_READ(SMH_RAM)
335335   AM_RANGE(0x6400, 0x6407) AM_READ(zaccaria_prot1_r)
336   AM_RANGE(0x6c00, 0x6c07) AM_READ(zaccaria_prot2_r)
337   AM_RANGE(0x6e00, 0x6e00) AM_READ(zaccaria_dsw_r)
338   AM_RANGE(0x7000, 0x77ff) AM_READ(SMH_RAM)
339   AM_RANGE(0x7800, 0x7803) AM_READ(ppi8255_0_r)
340   AM_RANGE(0x7c00, 0x7c00) AM_READ(watchdog_reset_r)
341   AM_RANGE(0x8000, 0xdfff) AM_READ(SMH_ROM)
342ADDRESS_MAP_END
343
344static ADDRESS_MAP_START( writemem, ADDRESS_SPACE_PROGRAM, 8 )
345   AM_RANGE(0x0000, 0x5fff) AM_WRITE(SMH_ROM)
346336   AM_RANGE(0x6000, 0x67ff) AM_WRITE(zaccaria_videoram_w) AM_BASE(&zaccaria_videoram)   /* 6400-67ff is 4 bits wide */
347337   AM_RANGE(0x6800, 0x683f) AM_WRITE(zaccaria_attributes_w) AM_BASE(&zaccaria_attributesram)
348   AM_RANGE(0x6840, 0x685f) AM_WRITE(SMH_RAM) AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
349   AM_RANGE(0x6881, 0x68bc) AM_WRITE(SMH_RAM) AM_BASE(&spriteram_2) AM_SIZE(&spriteram_2_size)
338   AM_RANGE(0x6840, 0x685f) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
339   AM_RANGE(0x6881, 0x68bc) AM_RAM AM_BASE(&spriteram_2) AM_SIZE(&spriteram_2_size)
350340   AM_RANGE(0x6c00, 0x6c00) AM_WRITE(zaccaria_flip_screen_x_w)
351341   AM_RANGE(0x6c01, 0x6c01) AM_WRITE(zaccaria_flip_screen_y_w)
352342   AM_RANGE(0x6c02, 0x6c02) AM_WRITE(SMH_NOP)    /* sound reset */
353   AM_RANGE(0x6e00, 0x6e00) AM_WRITE(sound_command_w)
354343   AM_RANGE(0x6c06, 0x6c06) AM_WRITE(coin_w)
355344   AM_RANGE(0x6c07, 0x6c07) AM_WRITE(nmienable_w)
356   AM_RANGE(0x7000, 0x77ff) AM_WRITE(SMH_RAM)
357   AM_RANGE(0x7800, 0x7803) AM_WRITE(ppi8255_0_w)
358   AM_RANGE(0x8000, 0xdfff) AM_WRITE(SMH_ROM)
345   AM_RANGE(0x6c00, 0x6c07) AM_READ(zaccaria_prot2_r)
346   AM_RANGE(0x6e00, 0x6e00) AM_READWRITE(zaccaria_dsw_r, sound_command_w)
347   AM_RANGE(0x7000, 0x77ff) AM_RAM
348   AM_RANGE(0x7800, 0x7803) AM_READWRITE(ppi8255_0_r, ppi8255_0_w)
349   AM_RANGE(0x7c00, 0x7c00) AM_READ(watchdog_reset_r)
350   AM_RANGE(0x8000, 0xdfff) AM_ROM
359351ADDRESS_MAP_END
360352
361static ADDRESS_MAP_START( sound_readmem1, ADDRESS_SPACE_PROGRAM, 8 )
362   AM_RANGE(0x0000, 0x007f) AM_READ(SMH_RAM)
363   AM_RANGE(0x500c, 0x500f) AM_READ(pia_0_r)
364   AM_RANGE(0xa000, 0xbfff) AM_READ(SMH_ROM)
365   AM_RANGE(0xe000, 0xffff) AM_READ(SMH_ROM)
353static ADDRESS_MAP_START( sound_map_1, ADDRESS_SPACE_PROGRAM, 8 )
354   AM_RANGE(0x0000, 0x007f) AM_RAM
355   AM_RANGE(0x500c, 0x500f) AM_READWRITE(pia_0_r, pia_0_w)
356   AM_RANGE(0xa000, 0xbfff) AM_ROM
357   AM_RANGE(0xe000, 0xffff) AM_ROM
366358ADDRESS_MAP_END
367359
368static ADDRESS_MAP_START( sound_writemem1, ADDRESS_SPACE_PROGRAM, 8 )
369   AM_RANGE(0x0000, 0x007f) AM_WRITE(SMH_RAM)
370   AM_RANGE(0x500c, 0x500f) AM_WRITE(pia_0_w)
371   AM_RANGE(0xa000, 0xbfff) AM_WRITE(SMH_ROM)
372   AM_RANGE(0xe000, 0xffff) AM_WRITE(SMH_ROM)
373ADDRESS_MAP_END
374
375static ADDRESS_MAP_START( sound_readmem2, ADDRESS_SPACE_PROGRAM, 8 )
376   AM_RANGE(0x0000, 0x007f) AM_READ(SMH_RAM)
377   AM_RANGE(0x0090, 0x0093) AM_READ(pia_1_r)
378   AM_RANGE(0x1800, 0x1800) AM_READ(soundlatch_r)
379   AM_RANGE(0xa000, 0xbfff) AM_READ(SMH_ROM)
380   AM_RANGE(0xe000, 0xffff) AM_READ(SMH_ROM)
381ADDRESS_MAP_END
382
383static ADDRESS_MAP_START( sound_writemem2, ADDRESS_SPACE_PROGRAM, 8 )
384   AM_RANGE(0x0000, 0x007f) AM_WRITE(SMH_RAM)
385   AM_RANGE(0x0090, 0x0093) AM_WRITE(pia_1_w)
360static ADDRESS_MAP_START( sound_map_2, ADDRESS_SPACE_PROGRAM, 8 )
361   AM_RANGE(0x0000, 0x007f) AM_RAM
362   AM_RANGE(0x0090, 0x0093) AM_READWRITE(pia_1_r, pia_1_w)
386363   AM_RANGE(0x1000, 0x1000) AM_WRITE(mc1408_data_w)   /* MC1408 */
387364   AM_RANGE(0x1400, 0x1400) AM_WRITE(sound1_command_w)
388   AM_RANGE(0xa000, 0xbfff) AM_WRITE(SMH_ROM)
389   AM_RANGE(0xe000, 0xffff) AM_WRITE(SMH_ROM)
365   AM_RANGE(0x1800, 0x1800) AM_READ(soundlatch_r)
366   AM_RANGE(0xa000, 0xbfff) AM_ROM
367   AM_RANGE(0xe000, 0xffff) AM_ROM
390368ADDRESS_MAP_END
391369
392370
r2375r2376
661639
662640   /* basic machine hardware */
663641   MDRV_CPU_ADD(Z80,XTAL_18_432MHz/6)   /* verified on pcb */
664   MDRV_CPU_PROGRAM_MAP(readmem,writemem)
642   MDRV_CPU_PROGRAM_MAP(main_map,0)
665643   MDRV_CPU_VBLANK_INT("main", nmi_line_pulse)
666644
667645   MDRV_CPU_ADD(M6802,XTAL_3_579545MHz) /* verified on pcb */
668   MDRV_CPU_PROGRAM_MAP(sound_readmem1,sound_writemem1)
646   MDRV_CPU_PROGRAM_MAP(sound_map_1,0)
669647   MDRV_CPU_PERIODIC_INT(zaccaria_cb1_toggle,(double)3580000/4096)
670648
671649   MDRV_CPU_ADD(M6802,XTAL_3_579545MHz) /* verified on pcb */
672   MDRV_CPU_PROGRAM_MAP(sound_readmem2,sound_writemem2)
650   MDRV_CPU_PROGRAM_MAP(sound_map_2,0)
673651
674652   MDRV_MACHINE_START(zaccaria)
675653   MDRV_MACHINE_RESET(zaccaria)
src/mame/drivers/shadfrce.c
r2375r2376
191191   switch (offset)
192192   {
193193      case 0 :
194         data = (readinputport(0) & 0xff) | ((readinputport(7) & 0xc0) << 6) | ((readinputport(4) & 0x0f) << 8);
194         data = (input_port_read_indexed(machine, 0) & 0xff) | ((input_port_read_indexed(machine, 7) & 0xc0) << 6) | ((input_port_read_indexed(machine, 4) & 0x0f) << 8);
195195         break;
196196      case 1 :
197         data = (readinputport(1) & 0xff) | ((readinputport(7) & 0x3f) << 8);
197         data = (input_port_read_indexed(machine, 1) & 0xff) | ((input_port_read_indexed(machine, 7) & 0x3f) << 8);
198198         break;
199199      case 2 :
200         data = (readinputport(2) & 0xff) | ((readinputport(6) & 0x3f) << 8);
200         data = (input_port_read_indexed(machine, 2) & 0xff) | ((input_port_read_indexed(machine, 6) & 0x3f) << 8);
201201         break;
202202      case 3 :
203         data = (readinputport(3) & 0xff) | ((readinputport(6) & 0xc0) << 2) | ((readinputport(5) & 0x3c) << 8);
203         data = (input_port_read_indexed(machine, 3) & 0xff) | ((input_port_read_indexed(machine, 6) & 0xc0) << 2) | ((input_port_read_indexed(machine, 5) & 0x3c) << 8);
204204         break;
205205   }
206206
src/mame/drivers/yumefuda.c
r2375r2376
161161{
162162   switch(mux_data)
163163   {
164      case 0x00: return readinputport(0);
165      case 0x01: return readinputport(1);
166      case 0x02: return readinputport(2);
167      case 0x04: return readinputport(3);
168      case 0x08: return readinputport(4);
164      case 0x00: return input_port_read_indexed(machine, 0);
165      case 0x01: return input_port_read_indexed(machine, 1);
166      case 0x02: return input_port_read_indexed(machine, 2);
167      case 0x04: return input_port_read_indexed(machine, 3);
168      case 0x08: return input_port_read_indexed(machine, 4);
169169      /* FIXME: Was this a quick hack? */
170      case 0x10: return 0xff; //return readinputport(5);
171      case 0x20: return 0xff; //return readinputport(6);
170      case 0x10: return 0xff; //return input_port_read_indexed(machine, 5);
171      case 0x20: return 0xff; //return input_port_read_indexed(machine, 6);
172172   }
173173   return 0xff;
174174}
src/mame/drivers/jongkyo.c
r2375r2376
109109   {
110110
111111      case 0xef:
112         return  readinputportbytag("0");
112         return  input_port_read(machine, "0");
113113
114114      case 0xf7:
115         return  readinputportbytag("1");
115         return  input_port_read(machine, "1");
116116
117117      case 0xfb:
118         return  readinputportbytag("2");
118         return  input_port_read(machine, "2");
119119
120120      case 0xfd:
121         return  readinputportbytag("3");
121         return  input_port_read(machine, "3");
122122
123123      case 0xfe:
124         return  readinputportbytag("4");
124         return  input_port_read(machine, "4");
125125
126126      default:
127127         printf("keyboard1_r, select %02x\n",keyboard_select);
r2375r2376
137137   switch (keyboard_select)
138138   {
139139      case 0xef:
140         return  readinputportbytag("5");
140         return  input_port_read(machine, "5");
141141
142142      case 0xf7:
143         return  readinputportbytag("6");
143         return  input_port_read(machine, "6");
144144
145145      case 0xfb:
146         return  readinputportbytag("7");
146         return  input_port_read(machine, "7");
147147
148148      case 0xfd:
149         return  readinputportbytag("8");
149         return  input_port_read(machine, "8");
150150
151151      case 0xfe:
152         return  readinputportbytag("9");
152         return  input_port_read(machine, "9");
153153
154154      default:
155155         printf("keyboard2_r, select %02x\n",keyboard_select);
src/mame/drivers/attckufo.c
r2375r2376
6464{
6565   switch(offset)
6666   {
67      case 0: return input_port_0_r(machine,0);
68      case 2: return input_port_1_r(machine,0);
67      case 0: return input_port_read_indexed(machine, 0);
68      case 2: return input_port_read_indexed(machine, 1);
6969   }
7070   return 0xff;
7171}
src/mame/drivers/firebeat.c
r2375r2376
674674
675675   if (ACCESSING_BITS_24_31)
676676   {
677      r |= (readinputport(0) & 0xff) << 24;
677      r |= (input_port_read_indexed(machine, 0) & 0xff) << 24;
678678   }
679679   if (ACCESSING_BITS_8_15)
680680   {
681      r |= (readinputport(1) & 0xff) << 8;
681      r |= (input_port_read_indexed(machine, 1) & 0xff) << 8;
682682   }
683683   if (ACCESSING_BITS_0_7)
684684   {
685      r |= (readinputport(2) & 0xff);
685      r |= (input_port_read_indexed(machine, 2) & 0xff);
686686   }
687687
688688   return r;
r2375r2376
692692{
693693   if (offset == 0)
694694   {
695      return readinputport(3) | 0x01000100;
695      return input_port_read_indexed(machine, 3) | 0x01000100;
696696   }
697697   else
698698   {
699      return readinputport(4) | 0x01000100;
699      return input_port_read_indexed(machine, 4) | 0x01000100;
700700   }
701701}
702702
r2375r2376
13831383{
13841384   if (offset == 0)      // Keyboard Wheel (P1)
13851385   {
1386      return readinputport(3) << 24;
1386      return input_port_read_indexed(machine, 3) << 24;
13871387   }
13881388   else if (offset == 2)   // Keyboard Wheel (P2)
13891389   {
1390      return readinputport(4) << 24;
1390      return input_port_read_indexed(machine, 4) << 24;
13911391   }
13921392
13931393   return 0;
r2375r2376
14711471
14721472   for (keyboard=0; keyboard < 2; keyboard++)
14731473   {
1474      UINT32 kbstate = readinputport(5 + keyboard);
1474      UINT32 kbstate = input_port_read_indexed(machine, 5 + keyboard);
14751475      int uart_channel = kb_uart_channel[keyboard];
14761476
14771477      if (kbstate != keyboard_state[keyboard])
src/mame/drivers/clayshoo.c
r2375r2376
3939}
4040
4141
42static UINT8 difficulty_input_port_r(int bit)
42static UINT8 difficulty_input_port_r(running_machine *machine, int bit)
4343{
4444   UINT8 ret = 0;
4545
4646   /* read fake port and remap the buttons to 2 bits */
47   UINT8   raw = readinputportbytag("FAKE");
47   UINT8   raw = input_port_read(machine, "FAKE");
4848
4949   if (raw & (1 << (bit + 1)))
5050      ret = 0x03;      /* expert */
r2375r2376
6363
6464   switch (input_port_select)
6565   {
66   case 0x01:   ret = readinputportbytag("IN0"); break;
67   case 0x02:   ret = readinputportbytag("IN1"); break;
68   case 0x04:   ret = (readinputportbytag("IN2") & 0xf0) |
69                  difficulty_input_port_r(0) |
70                 (difficulty_input_port_r(3) << 2); break;
71   case 0x08:   ret = readinputportbytag("IN3"); break;
66   case 0x01:   ret = input_port_read(machine, "IN0"); break;
67   case 0x02:   ret = input_port_read(machine, "IN1"); break;
68   case 0x04:   ret = (input_port_read(machine, "IN2") & 0xf0) |
69                  difficulty_input_port_r(machine, 0) |
70                 (difficulty_input_port_r(machine, 3) << 2); break;
71   case 0x08:   ret = input_port_read(machine, "IN3"); break;
7272   case 0x10:
7373   case 0x20:   break;   /* these two are not really used */
7474   default: logerror("Unexpected port read: %02X\n", input_port_select);
r2375r2376
107107
108108   analog_port_val = 0xff;
109109
110   timer_adjust_oneshot(analog_timer_1, compute_duration(readinputportbytag("AN1")), 0x02);
111   timer_adjust_oneshot(analog_timer_2, compute_duration(readinputportbytag("AN2")), 0x01);
110   timer_adjust_oneshot(analog_timer_1, compute_duration(input_port_read(machine, "AN1")), 0x02);
111   timer_adjust_oneshot(analog_timer_2, compute_duration(input_port_read(machine, "AN2")), 0x01);
112112}
113113
114114
src/mame/drivers/tagteam.c
r2375r2376
100100   static int coin;
101101   int port;
102102
103   port = readinputportbytag("IN0") & 0xc0;
103   port = input_port_read(machine, "IN0") & 0xc0;
104104
105105   if (port != 0xc0)    /* Coin */
106106   {
src/mame/drivers/eolith.c
r2375r2376
104104    */
105105   eolith_speedup_read();
106106
107   return (readinputport(0) & ~0x308) | (EEPROM_read_bit() << 3) | (mame_rand(Machine) & 0x300);
107   return (input_port_read_indexed(machine, 0) & ~0x308) | (EEPROM_read_bit() << 3) | (mame_rand(Machine) & 0x300);
108108}
109109
110110static WRITE32_HANDLER( systemcontrol_w )
src/mame/drivers/bigevglf.c
r2375r2376
377377
378378    */
379379   bit5 ^= 0x20;
380   return bigevglf_mcu_status_r(machine,0) | (readinputport(1) & 3) | bit5; /* bit 0 and bit 1 - coin inputs */
380   return bigevglf_mcu_status_r(machine,0) | (input_port_read_indexed(machine, 1) & 3) | bit5; /* bit 0 and bit 1 - coin inputs */
381381}
382382
383383static ADDRESS_MAP_START( bigevglf_sub_readport, ADDRESS_SPACE_IO, 8 )
src/mame/drivers/inufuku.c
r2375r2376
159159
160160   soundflag = pending_command ? 0x0000 : 0x0080;   // bit7
161161   eeprom = (EEPROM_read_bit() & 1) << 6;         // bit6
162   inputport = readinputport(4) & 0xff3f;         // bit5-0
162   inputport = input_port_read_indexed(machine, 4) & 0xff3f;         // bit5-0
163163
164164   return (soundflag | eeprom | inputport);
165165}
src/mame/drivers/atarisy2.c
r2375r2376
172172 *
173173 *************************************/
174174
175static void bankselect_postload(void);
175static STATE_POSTLOAD( bankselect_postload );
176176
177177
178178
r2375r2376
252252   state_save_register_global(which_adc);
253253   state_save_register_global(p2portwr_state);
254254   state_save_register_global(p2portrd_state);
255   state_save_register_func_postload(bankselect_postload);
255   state_save_register_postload(machine, bankselect_postload, NULL);
256256   state_save_register_global(sound_reset_state);
257257}
258258
r2375r2376
359359}
360360
361361
362static void bankselect_postload(void)
362static STATE_POSTLOAD( bankselect_postload )
363363{
364364   bankselect_w(Machine, 0, bankselect[0], 0);
365365   bankselect_w(Machine, 1, bankselect[1], 0);
r2375r2376
425425static READ16_HANDLER( adc_r )
426426{
427427   if (which_adc < pedal_count)
428      return ~readinputport(3 + which_adc);
428      return ~input_port_read_indexed(machine, 3 + which_adc);
429429
430   return readinputport(3 + which_adc) | 0xff00;
430   return input_port_read_indexed(machine, 3 + which_adc) | 0xff00;
431431}
432432
433433
r2375r2376
444444            static double last_angle;
445445            static int rotations;
446446
447            int analogx = readinputport(7) - 128;
448            int analogy = readinputport(8) - 128;
447            int analogx = input_port_read_indexed(machine, 7) - 128;
448            int analogy = input_port_read_indexed(machine, 8) - 128;
449449            double angle;
450450
451451            /* if the joystick is centered, leave the rest of this alone */
r2375r2376
481481      }
482482   }
483483
484   return readinputport(7 + (offset & 3));
484   return input_port_read_indexed(machine, 7 + (offset & 3));
485485}
486486
487487
src/mame/drivers/mjsister.c
r2375r2376
141141   for (i=0; i<6; i++)
142142   {
143143      if (p & (1 << i))
144         ret |= readinputport(i+3);
144         ret |= input_port_read_indexed(machine, i+3);
145145   }
146146
147147   return ret;
src/mame/drivers/ninjakd2.c
r2375r2376
326326      case 1:   // dip switches
327327         switch (offset)
328328         {
329            case 0: result = readinputportbytag("DIPSW1"); break;
330            case 1: result = readinputportbytag("DIPSW2"); break;
329            case 0: result = input_port_read(machine, "DIPSW1"); break;
330            case 1: result = input_port_read(machine, "DIPSW2"); break;
331331            case 2: result = 0x02;                         break;
332332         }
333333         break;
r2375r2376
335335      case 2:   // player inputs
336336         switch (offset)
337337         {
338            case 0: result = readinputportbytag("PAD1"); break;
339            case 1: result = readinputportbytag("PAD2"); break;
338            case 0: result = input_port_read(machine, "PAD1"); break;
339            case 1: result = input_port_read(machine, "PAD2"); break;
340340            case 2: result = 0x01;                       break;
341341         }
342342         break;
src/mame/drivers/warpwarp.c
r2375r2376
147147   int res;
148148
149149   offset &= 3;
150   res = readinputport(offset);
150   res = input_port_read_indexed(machine, offset);
151151   if (offset == 3)
152152   {
153      res = readinputport(3 + (flip_screen_get() & 1));   // read player 2 input in cocktail mode
153      res = input_port_read_indexed(machine, 3 + (flip_screen_get() & 1));   // read player 2 input in cocktail mode
154154      if (handle_joystick)
155155      {
156156         /* map digital two-way joystick to two fixed VOLIN values */
r2375r2376
218218/* Read Switch Inputs */
219219static READ8_HANDLER( warpwarp_sw_r )
220220{
221   return (readinputport(0) >> (offset & 7)) & 1;
221   return (input_port_read_indexed(machine, 0) >> (offset & 7)) & 1;
222222}
223223
224224/* Read Dipswitches */
225225static READ8_HANDLER( warpwarp_dsw1_r )
226226{
227   return (readinputport(1) >> (offset & 7)) & 1;
227   return (input_port_read_indexed(machine, 1) >> (offset & 7)) & 1;
228228}
229229
230230/* Read mux Controller Inputs */
r2375r2376
232232{
233233   int res;
234234
235   res = readinputport(2 + (flip_screen_get() & 1));
235   res = input_port_read_indexed(machine, 2 + (flip_screen_get() & 1));
236236   if (handle_joystick)
237237   {
238238      if (res & 1) return 0x0f;
src/mame/drivers/cubocd32.c
r2375r2376
4545*/
4646
4747#include "driver.h"
48#include "deprecat.h"
4849#include "memconv.h"
4950#include "sound/custom.h"
5051#include "includes/amiga.h"
r2375r2376
106107
107108static UINT8 cd32_cia_0_porta_r(void)
108109{
109   return readinputportbytag("CIA0PORTA");
110   return input_port_read(Machine, "CIA0PORTA");
110111}
111112
112113static void cd32_cia_0_porta_w(UINT8 data)
r2375r2376
148149
149150static READ32_HANDLER( dipswitch_r )
150151{
151   return readinputportbytag("DIPSW1");
152   return input_port_read(machine, "DIPSW1");
152153}
153154
154155static ADDRESS_MAP_START( cd32_map, ADDRESS_SPACE_PROGRAM, 32 )
src/mame/drivers/wheelfir.c
r2375r2376
5959
6060
6161
62   return readinputport(0)^toggle_bit;// mame_rand(Machine);
62   return input_port_read_indexed(machine, 0)^toggle_bit;// mame_rand(Machine);
6363}
6464
6565static READ16_HANDLER( wheelfir_rand2 )
6666{
67   return readinputport(1);// mame_rand(Machine);
67   return input_port_read_indexed(machine, 1);// mame_rand(Machine);
6868}
6969
7070
src/mame/drivers/cbuster.c
r2375r2376
8989   switch (offset<<1)
9090   {
9191      case 0: /* Player 1 & Player 2 joysticks & fire buttons */
92         return (readinputport(0) + (readinputport(1) << 8));
92         return (input_port_read_indexed(machine, 0) + (input_port_read_indexed(machine, 1) << 8));
9393
9494      case 2: /* Dip Switches */
95         return (readinputport(3) + (readinputport(4) << 8));
95         return (input_port_read_indexed(machine, 3) + (input_port_read_indexed(machine, 4) << 8));
9696
9797      case 4: /* Protection */
9898         logerror("%04x : protection control read at 30c000 %d\n",activecpu_get_pc(),offset);
9999         return prot;
100100
101101      case 6: /* Credits, VBL in byte 7 */
102         return readinputport(2);
102         return input_port_read_indexed(machine, 2);
103103   }
104104
105105   return ~0;
src/mame/drivers/dunhuang.c
r2375r2376
345345static WRITE8_HANDLER( dunhuang_input_w )   {   dunhuang_input = data;   }
346346static READ8_HANDLER( dunhuang_service_r )
347347{
348   return readinputport(5)
348   return input_port_read_indexed(machine, 5)
349349    | ((dunhuang_hopper && !(video_screen_get_frame_number(machine->primary_screen)%10)) ? 0x00 : 0x08)   // bit 3: hopper sensor
350350    | 0x80                                                // bit 7 low -> tiles block transferrer busy
351351   ;
r2375r2376
353353
354354static READ8_HANDLER( dunhuang_dsw_r )
355355{
356   if (!(dunhuang_input & 0x01))   return readinputport(0);
357   if (!(dunhuang_input & 0x02))   return readinputport(1);
358   if (!(dunhuang_input & 0x04))   return readinputport(2);
359   if (!(dunhuang_input & 0x08))   return readinputport(3);
360   if (!(dunhuang_input & 0x10))   return readinputport(4);
356   if (!(dunhuang_input & 0x01))   return input_port_read_indexed(machine, 0);
357   if (!(dunhuang_input & 0x02))   return input_port_read_indexed(machine, 1);
358   if (!(dunhuang_input & 0x04))   return input_port_read_indexed(machine, 2);
359   if (!(dunhuang_input & 0x08))   return input_port_read_indexed(machine, 3);
360   if (!(dunhuang_input & 0x10))   return input_port_read_indexed(machine, 4);
361361   logerror("%06x: warning, unknown dsw bits read, dunhuang_input = %02x\n", activecpu_get_pc(), dunhuang_input);
362362   return 0xff;
363363}
364364static READ8_HANDLER( dunhuang_input_r )
365365{
366   if (!(dunhuang_input & 0x01))   return readinputport(6);
367   if (!(dunhuang_input & 0x02))   return readinputport(7);
368   if (!(dunhuang_input & 0x04))   return readinputport(8);
369   if (!(dunhuang_input & 0x08))   return readinputport(9);
370   if (!(dunhuang_input & 0x10))   return readinputport(10);
366   if (!(dunhuang_input & 0x01))   return input_port_read_indexed(machine, 6);
367   if (!(dunhuang_input & 0x02))   return input_port_read_indexed(machine, 7);
368   if (!(dunhuang_input & 0x04))   return input_port_read_indexed(machine, 8);
369   if (!(dunhuang_input & 0x08))   return input_port_read_indexed(machine, 9);
370   if (!(dunhuang_input & 0x10))   return input_port_read_indexed(machine, 10);
371371   logerror("%06x: warning, unknown input bits read, dunhuang_input = %02x\n", activecpu_get_pc(), dunhuang_input);
372372   return 0xff;
373373}
src/mame/drivers/ojankohs.c
r2375r2376
146146   int ret;
147147
148148   switch (ojankohs_portselect) {
149      case 0x01:   ret = readinputportbytag("IN4");   break;
150      case 0x02:   ret = readinputportbytag("IN5"); break;
151      case 0x04:   ret = readinputportbytag("IN6"); break;
152      case 0x08:   ret = readinputportbytag("IN7"); break;
153      case 0x10:   ret = readinputportbytag("IN8"); break;
149      case 0x01:   ret = input_port_read(machine, "IN4");   break;
150      case 0x02:   ret = input_port_read(machine, "IN5"); break;
151      case 0x04:   ret = input_port_read(machine, "IN6"); break;
152      case 0x08:   ret = input_port_read(machine, "IN7"); break;
153      case 0x10:   ret = input_port_read(machine, "IN8"); break;
154154      case 0x20:   ret = 0xff; break;
155155      case 0x3f:   ret = 0xff;
156               ret &= readinputportbytag("IN4");
157               ret &= readinputportbytag("IN5");
158               ret &= readinputportbytag("IN6");
159               ret &= readinputportbytag("IN7");
160               ret &= readinputportbytag("IN8");
156               ret &= input_port_read(machine, "IN4");
157               ret &= input_port_read(machine, "IN5");
158               ret &= input_port_read(machine, "IN6");
159               ret &= input_port_read(machine, "IN7");
160               ret &= input_port_read(machine, "IN8");
161161               break;
162162      default:   ret = 0xff;
163163               logerror("PC:%04X unknown %02X\n", activecpu_get_pc(), ojankohs_portselect);
r2375r2376
174174
175175   for (i = 0; i < 5; i++) {
176176      if (~ojankohs_portselect & (1 << i))
177         ret |= readinputport(i + offset * 5 + 2);
177         ret |= input_port_read_indexed(machine, i + offset * 5 + 2);
178178   }
179179
180   return (ret & 0x3f) | (readinputport(12 + offset) & 0xc0);
180   return (ret & 0x3f) | (input_port_read_indexed(machine, 12 + offset) & 0xc0);
181181}
182182
183183static READ8_HANDLER( ojankohs_ay8910_0_r )
184184{
185185   // DIPSW 1
186   return (((readinputportbytag("DSW1") & 0x01) << 7) | ((readinputportbytag("DSW1") & 0x02) << 5) |
187           ((readinputportbytag("DSW1") & 0x04) << 3) | ((readinputportbytag("DSW1") & 0x08) << 1) |
188           ((readinputportbytag("DSW1") & 0x10) >> 1) | ((readinputportbytag("DSW1") & 0x20) >> 3) |
189           ((readinputportbytag("DSW1") & 0x40) >> 5) | ((readinputportbytag("DSW1") & 0x80) >> 7));
186   return (((input_port_read(machine, "DSW1") & 0x01) << 7) | ((input_port_read(machine, "DSW1") & 0x02) << 5) |
187           ((input_port_read(machine, "DSW1") & 0x04) << 3) | ((input_port_read(machine, "DSW1") & 0x08) << 1) |
188           ((input_port_read(machine, "DSW1") & 0x10) >> 1) | ((input_port_read(machine, "DSW1") & 0x20) >> 3) |
189           ((input_port_read(machine, "DSW1") & 0x40) >> 5) | ((input_port_read(machine, "DSW1") & 0x80) >> 7));
190190}
191191
192192static READ8_HANDLER( ojankohs_ay8910_1_r )
193193{
194194   // DIPSW 1
195   return (((readinputportbytag("DSW2") & 0x01) << 7) | ((readinputportbytag("DSW2") & 0x02) << 5) |
196           ((readinputportbytag("DSW2") & 0x04) << 3) | ((readinputportbytag("DSW2") & 0x08) << 1) |
197           ((readinputportbytag("DSW2") & 0x10) >> 1) | ((readinputportbytag("DSW2") & 0x20) >> 3) |
198           ((readinputportbytag("DSW2") & 0x40) >> 5) | ((readinputportbytag("DSW2") & 0x80) >> 7));
195   return (((input_port_read(machine, "DSW2") & 0x01) << 7) | ((input_port_read(machine, "DSW2") & 0x02) << 5) |
196           ((input_port_read(machine, "DSW2") & 0x04) << 3) | ((input_port_read(machine, "DSW2") & 0x08) << 1) |
197           ((input_port_read(machine, "DSW2") & 0x10) >> 1) | ((input_port_read(machine, "DSW2") & 0x20) >> 3) |
198           ((input_port_read(machine, "DSW2") & 0x40) >> 5) | ((input_port_read(machine, "DSW2") & 0x80) >> 7));
199199}
200200
201201static READ8_HANDLER( ojankoy_ay8910_0_r )
202202{
203   return readinputportbytag("DSW1");            // DIPSW 1
203   return input_port_read(machine, "DSW1");            // DIPSW 1
204204}
205205
206206static READ8_HANDLER( ojankoy_ay8910_1_r )
207207{
208   return readinputportbytag("DSW2");            // DIPSW 2
208   return input_port_read(machine, "DSW2");            // DIPSW 2
209209}
210210
211211static READ8_HANDLER( ccasino_dipsw3_r )
212212{
213   return (readinputportbytag("DSW3") ^ 0xff);      // DIPSW 3
213   return (input_port_read(machine, "DSW3") ^ 0xff);      // DIPSW 3
214214}
215215
216216static READ8_HANDLER( ccasino_dipsw4_r )
217217{
218   return (readinputportbytag("DSW4") ^ 0xff);      // DIPSW 4
218   return (input_port_read(machine, "DSW4") ^ 0xff);      // DIPSW 4
219219}
220220
221221static WRITE8_HANDLER( ojankoy_coinctr_w )
src/mame/drivers/wc90b.c
r2375r2376
6868Last but not least, the set of ROMs i have for Euro League seem to have
6969the sprites corrupted. The game seems to be exactly the same as the
7070World Cup 90 bootleg.
71
72Noted added by ClawGrip 28-Mar-2008:
73-----------------------------------
74-Dumped and added the all the PCB GALs.
75-Removed the second YM2203, Ernesto said it wasn't present on his board,
76 and also isn't on mine.
77-My PCB has a different ROM (a05.bin), but only two bytes are different.
78 Dox suggested that it can be just a year or text mod, so I decided not
79 to include my set. If anyone wants it, please mail me:
80 clawgrip at hotmail dot com. I can't find any graphical difference
81 between my set and the one already on MAME.
82
7183*/
7284
7385#include "driver.h"
r2375r2376
151163}
152164
153165
154static ADDRESS_MAP_START( wc90b_readmem1, ADDRESS_SPACE_PROGRAM, 8 )
155   AM_RANGE(0x0000, 0x7fff) AM_READ(SMH_ROM)
156   AM_RANGE(0x8000, 0x9fff) AM_READ(SMH_RAM) /* Main RAM */
157   AM_RANGE(0xa000, 0xafff) AM_READ(SMH_RAM) /* fg video ram */
158   AM_RANGE(0xc000, 0xcfff) AM_READ(SMH_RAM) /* bg video ram */
159   AM_RANGE(0xe000, 0xefff) AM_READ(SMH_RAM) /* tx video ram */
160   AM_RANGE(0xf000, 0xf7ff) AM_READ(SMH_BANK1)
161   AM_RANGE(0xf800, 0xfbff) AM_READ(wc90b_shared_r)
166static ADDRESS_MAP_START( wc90b_map1, ADDRESS_SPACE_PROGRAM, 8 )
167   AM_RANGE(0x0000, 0x7fff) AM_ROM
168   AM_RANGE(0x8000, 0x9fff) AM_RAM /* Main RAM */
169   AM_RANGE(0xa000, 0xafff) AM_RAM AM_WRITE(wc90b_fgvideoram_w) AM_BASE(&wc90b_fgvideoram)
170   AM_RANGE(0xc000, 0xcfff) AM_RAM AM_WRITE(wc90b_bgvideoram_w) AM_BASE(&wc90b_bgvideoram)
171   AM_RANGE(0xe000, 0xefff) AM_RAM AM_WRITE(wc90b_txvideoram_w) AM_BASE(&wc90b_txvideoram)
172   AM_RANGE(0xf000, 0xf7ff) AM_ROMBANK(1)
173   AM_RANGE(0xf800, 0xfbff) AM_READWRITE(wc90b_shared_r, wc90b_shared_w) AM_BASE(&wc90b_shared)
174   AM_RANGE(0xfc00, 0xfc00) AM_WRITE(wc90b_bankswitch_w)
175   AM_RANGE(0xfd00, 0xfd00) AM_WRITE(wc90b_sound_command_w)
176   AM_RANGE(0xfd04, 0xfd04) AM_WRITEONLY AM_BASE(&wc90b_scroll1y)
177   AM_RANGE(0xfd06, 0xfd06) AM_WRITEONLY AM_BASE(&wc90b_scroll1x)
178   AM_RANGE(0xfd08, 0xfd08) AM_WRITEONLY AM_BASE(&wc90b_scroll2y)
179   AM_RANGE(0xfd0a, 0xfd0a) AM_WRITEONLY AM_BASE(&wc90b_scroll2x)
162180   AM_RANGE(0xfd00, 0xfd00) AM_READ(input_port_0_r) /* Stick 1, Coin 1 & Start 1 */
163181   AM_RANGE(0xfd02, 0xfd02) AM_READ(input_port_1_r) /* Stick 2, Coin 2 & Start 2 */
164182   AM_RANGE(0xfd06, 0xfd06) AM_READ(input_port_2_r) /* DIP Switch A */
165183   AM_RANGE(0xfd08, 0xfd08) AM_READ(input_port_3_r) /* DIP Switch B */
166   AM_RANGE(0xfd00, 0xffff) AM_READ(SMH_RAM)
167184ADDRESS_MAP_END
168185
169static ADDRESS_MAP_START( wc90b_readmem2, ADDRESS_SPACE_PROGRAM, 8 )
170   AM_RANGE(0x0000, 0xbfff) AM_READ(SMH_ROM)
171   AM_RANGE(0xc000, 0xc1ff) AM_READ(SMH_RAM)
172   AM_RANGE(0xc200, 0xe1ff) AM_READ(SMH_RAM)
173   AM_RANGE(0xe000, 0xe7ff) AM_READ(SMH_RAM)
174   AM_RANGE(0xe800, 0xefff) AM_READ(SMH_ROM)
175   AM_RANGE(0xf000, 0xf7ff) AM_READ(SMH_BANK2)
176   AM_RANGE(0xf800, 0xfbff) AM_READ(wc90b_shared_r)
177ADDRESS_MAP_END
178
179static ADDRESS_MAP_START( wc90b_writemem1, ADDRESS_SPACE_PROGRAM, 8 )
180   AM_RANGE(0x0000, 0x7fff) AM_WRITE(SMH_ROM)
181   AM_RANGE(0x8000, 0x9fff) AM_WRITE(SMH_RAM)
182   AM_RANGE(0xa000, 0xafff) AM_WRITE(wc90b_fgvideoram_w) AM_BASE(&wc90b_fgvideoram)
183   AM_RANGE(0xc000, 0xcfff) AM_WRITE(wc90b_bgvideoram_w) AM_BASE(&wc90b_bgvideoram)
184   AM_RANGE(0xe000, 0xefff) AM_WRITE(wc90b_txvideoram_w) AM_BASE(&wc90b_txvideoram)
185   AM_RANGE(0xf000, 0xf7ff) AM_WRITE(SMH_ROM)
186   AM_RANGE(0xf800, 0xfbff) AM_WRITE(wc90b_shared_w) AM_BASE(&wc90b_shared)
187   AM_RANGE(0xfc00, 0xfc00) AM_WRITE(wc90b_bankswitch_w)
188   AM_RANGE(0xfd00, 0xfd00) AM_WRITE(wc90b_sound_command_w)
189   AM_RANGE(0xfd04, 0xfd04) AM_WRITE(SMH_RAM) AM_BASE(&wc90b_scroll1y)
190   AM_RANGE(0xfd06, 0xfd06) AM_WRITE(SMH_RAM) AM_BASE(&wc90b_scroll1x)
191   AM_RANGE(0xfd08, 0xfd08) AM_WRITE(SMH_RAM) AM_BASE(&wc90b_scroll2y)
192   AM_RANGE(0xfd0a, 0xfd0a) AM_WRITE(SMH_RAM) AM_BASE(&wc90b_scroll2x)
193ADDRESS_MAP_END
194
195static ADDRESS_MAP_START( wc90b_writemem2, ADDRESS_SPACE_PROGRAM, 8 )
196   AM_RANGE(0x0000, 0xbfff) AM_WRITE(SMH_ROM)
197   AM_RANGE(0xc000, 0xcfff) AM_WRITE(SMH_RAM)
198   AM_RANGE(0xd000, 0xd7ff) AM_WRITE(SMH_RAM) AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
199   AM_RANGE(0xd800, 0xdfff) AM_WRITE(SMH_RAM)
200   AM_RANGE(0xe000, 0xe7ff) AM_WRITE(paletteram_xxxxBBBBGGGGRRRR_be_w) AM_BASE(&paletteram)
201   AM_RANGE(0xe800, 0xefff) AM_WRITE(SMH_ROM)
202   AM_RANGE(0xf000, 0xf7ff) AM_WRITE(SMH_ROM)
203   AM_RANGE(0xf800, 0xfbff) AM_WRITE(wc90b_shared_w)
186static ADDRESS_MAP_START( wc90b_map2, ADDRESS_SPACE_PROGRAM, 8 )
187   AM_RANGE(0x0000, 0xbfff) AM_ROM
188   AM_RANGE(0xc000, 0xcfff) AM_RAM
189   AM_RANGE(0xd000, 0xd7ff) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
190   AM_RANGE(0xd800, 0xdfff) AM_RAM
191   AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_WRITE(paletteram_xxxxBBBBGGGGRRRR_be_w) AM_BASE(&paletteram)
192   AM_RANGE(0xe800, 0xefff) AM_ROM
193   AM_RANGE(0xf000, 0xf7ff) AM_ROMBANK(2)
194   AM_RANGE(0xf800, 0xfbff) AM_READWRITE(wc90b_shared_r, wc90b_shared_w)
204195   AM_RANGE(0xfc00, 0xfc00) AM_WRITE(wc90b_bankswitch1_w)
205196ADDRESS_MAP_END
206197
r2375r2376
211202   AM_RANGE(0xe400, 0xe400) AM_WRITE(adpcm_data_w)
212203   AM_RANGE(0xe800, 0xe800) AM_READWRITE(YM2203_status_port_0_r, YM2203_control_port_0_w)
213204   AM_RANGE(0xe801, 0xe801) AM_READWRITE(YM2203_read_port_0_r, YM2203_write_port_0_w)
214   AM_RANGE(0xec00, 0xec00) AM_READWRITE(YM2203_status_port_1_r, YM2203_control_port_1_w)
215   AM_RANGE(0xec01, 0xec01) AM_READWRITE(YM2203_read_port_1_r, YM2203_write_port_1_w)
216205   AM_RANGE(0xf000, 0xf7ff) AM_RAM
217206   AM_RANGE(0xf800, 0xf800) AM_READ(soundlatch_r)
218207ADDRESS_MAP_END
r2375r2376
391380static MACHINE_DRIVER_START( wc90b )
392381
393382   /* basic machine hardware */
394   MDRV_CPU_ADD(Z80, 6000000)   /* 6.0 MHz ??? */
395   MDRV_CPU_PROGRAM_MAP(wc90b_readmem1,wc90b_writemem1)
383   MDRV_CPU_ADD(Z80, XTAL_14MHz/2)
384   MDRV_CPU_PROGRAM_MAP(wc90b_map1,0)
396385   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
397386
398   MDRV_CPU_ADD(Z80, 6000000)   /* 6.0 MHz ??? */
399   MDRV_CPU_PROGRAM_MAP(wc90b_readmem2,wc90b_writemem2)
387   MDRV_CPU_ADD(Z80, XTAL_14MHz/2)
388   MDRV_CPU_PROGRAM_MAP(wc90b_map2,0)
400389   MDRV_CPU_VBLANK_INT("main", irq0_line_hold)
401390
402   MDRV_CPU_ADD(Z80, 2510000) // based on goal92 speed measured by guru (although maybe it should be 10mhz / 4 which is close)
403   /* audio CPU */   /* 2.51 MHz */
391   MDRV_CPU_ADD(Z80, XTAL_19_6608MHz/8)
404392   MDRV_CPU_PROGRAM_MAP(sound_cpu,0)
405                        /* IRQs are triggered by the main CPU */
393   /* IRQs are triggered by the main CPU */
406394
407395   /* video hardware */
408396   MDRV_SCREEN_ADD("main", RASTER)
r2375r2376
423411
424412   MDRV_SOUND_ADD(YM2203, 2510000/2)
425413   MDRV_SOUND_CONFIG(ym2203_interface)
426   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
414   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20)
427415
428   MDRV_SOUND_ADD(YM2203, 2510000/2)
429   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
430
431416   MDRV_SOUND_ADD(MSM5205, 384000)
432417   MDRV_SOUND_CONFIG(msm5205_interface)
433   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60)
418   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30)
434419MACHINE_DRIVER_END
435420
436421ROM_START( wc90b )
r2375r2376
467452   ROM_LOAD( "151_a17.bin",  0x050000, 0x10000, CRC(228429d8) SHA1(3b2dbea53807929c24d593c469a83172f7747f66) )
468453   ROM_LOAD( "152_a18.bin",  0x060000, 0x10000, CRC(516b6c09) SHA1(9d02514dece864b087f67886009ce54bd51b5575) )
469454   ROM_LOAD( "153_a19.bin",  0x070000, 0x10000, CRC(f36390a9) SHA1(e5ea36e91b3ced068281524ee79d0432f489715c) )
455
456   ROM_REGION( 0x1000, REGION_PLDS, ROMREGION_DISPOSE )
457   ROM_LOAD( "el_ic39_gal16v8_0.bin", 0x0000, 0x0117, NO_DUMP SHA1(894b345b395097acf6cf52ab8bc922099f97a85f) )
458   ROM_LOAD( "el_ic44_gal16v8_1.bin", 0x0200, 0x0117, NO_DUMP SHA1(fd41f55d857995fe87217dd9679c42760c241dc4) )
459   ROM_LOAD( "el_ic54_gal16v8_2.bin", 0x0400, 0x0117, NO_DUMP SHA1(f6d138fe42549219e11ee8524b05fe3c2b43f5d3) )
460   ROM_LOAD( "el_ic100_gal16v8_3.bin", 0x0600, 0x0117, NO_DUMP SHA1(515fcdf378e75ed078f54439fefce8807403bdd5) )
461   ROM_LOAD( "el_ic143_gal16v8_4.bin", 0x0800, 0x0117, NO_DUMP SHA1(fbe632437eac2418da7a3c3e947cfd36f6211407) )
470462ROM_END
471463
472464
465#if 0
466/* Different bootleg set with only one new ROM, a05 (added as "el_ic98_27c512_05.bin"), not included because it's
467probably just a minor text mod from the supported set (only two bytes differs), although I cannot find the difference:
468   Comparing files a05.bin and el_ic98_27c512_05.bin
469    00000590: 0F 0B
470    00000591: FF FA
471*/
472ROM_START( wc90ba )
473   ROM_REGION( 0x20000, REGION_CPU1, 0 )
474   ROM_LOAD( "a02.bin",      0x00000, 0x10000, CRC(192a03dd) SHA1(ab98d370bba5437f956631b0199b173be55f1c27) )   /* c000-ffff is not used */
475   ROM_LOAD( "a03.bin",      0x10000, 0x10000, CRC(f54ff17a) SHA1(a19850fc28a5a0da20795a5cc6b56d9c16554bce) )   /* banked at f000-f7ff */
476
477   ROM_REGION( 0x20000, REGION_CPU2, 0 )  /* Second CPU */
478   ROM_LOAD( "a04.bin",              0x00000, 0x10000, CRC(3d535e2f) SHA1(f1e1878b5a8316e770c74a1e1f29a7a81a4e5dfe) )   /* c000-ffff is not used */
479   ROM_LOAD( "el_ic98_27c512_05.bin",0x10000, 0x10000, CRC(c70d8c13) SHA1(365718725ea7d0355c68ba703b7f9624cb1134bc) )
480
481   ROM_REGION( 0x18000, REGION_CPU3, 0 )
482   ROM_LOAD( "a01.bin",      0x00000, 0x8000, CRC(3d317622) SHA1(ae4e8c5247bc215a2769786cb8639bce2f80db22) )
483   ROM_CONTINUE(             0x10000, 0x8000 ) /* banked at 8000-bfff */
484
485   ROM_REGION( 0x010000, REGION_GFX1, ROMREGION_DISPOSE )
486   ROM_LOAD( "a06.bin",      0x000000, 0x04000, CRC(3b5387b7) SHA1(b839b4eafe8bf6f9e841e19fee1bdb64a66f3448) )
487   ROM_LOAD( "a08.bin",      0x004000, 0x04000, CRC(c622a5a3) SHA1(468c8c24af1f6f244228b66df04cb0ea81c1875e) )
488   ROM_LOAD( "a10.bin",      0x008000, 0x04000, CRC(0923d9f6) SHA1(4b10ee3fc17bb63cda51b2a978d066b6a140a551) )
489   ROM_LOAD( "a20.bin",      0x00c000, 0x04000, CRC(b8dec83e) SHA1(fe617ddccdd0dbd05ca09a1507074aa14b529322) )
490
491   ROM_REGION( 0x080000, REGION_GFX2, ROMREGION_DISPOSE )
492   ROM_LOAD( "a07.bin",      0x000000, 0x20000, CRC(38c31817) SHA1(cb24ed8702d62066366924c033c07ffc78bd1fad) )
493   ROM_LOAD( "a09.bin",      0x020000, 0x20000, CRC(32e39e29) SHA1(44f22ed6c983541c7fea5857ba0456aaa87b36d1) )
494   ROM_LOAD( "a11.bin",      0x040000, 0x20000, CRC(5ccec796) SHA1(2cc191a4267819eb31962726e2ed4567c825c39e) )
495   ROM_LOAD( "a21.bin",      0x060000, 0x20000, CRC(0c54a091) SHA1(3eecb285b5a7bbc310c87492516d7ffb2841aa3b) )
496
497   ROM_REGION( 0x080000, REGION_GFX3, ROMREGION_DISPOSE | ROMREGION_INVERT )
498   ROM_LOAD( "146_a12.bin",  0x000000, 0x10000, CRC(d5a60096) SHA1(a8e351a4b020b4fc2b2cb7d3f0fdfb43fc44d7d9) )
499   ROM_LOAD( "147_a13.bin",  0x010000, 0x10000, CRC(36bbf467) SHA1(627b5847ffb098c92edfd58c25391799f3b209e0) )
500   ROM_LOAD( "148_a14.bin",  0x020000, 0x10000, CRC(26371c18) SHA1(0887041d86dc9f19dad264ae27dc56fb89ac3265) )
501   ROM_LOAD( "149_a15.bin",  0x030000, 0x10000, CRC(75aa9b86) SHA1(0c221bd2e8a5472bb0e515f27fb72b0c8e8c0ca4) )
502   ROM_LOAD( "150_a16.bin",  0x040000, 0x10000, CRC(0da825f9) SHA1(cfba0c85fc767726c1d63f87468335d1c2f1eed8) )
503   ROM_LOAD( "151_a17.bin",  0x050000, 0x10000, CRC(228429d8) SHA1(3b2dbea53807929c24d593c469a83172f7747f66) )
504   ROM_LOAD( "152_a18.bin",  0x060000, 0x10000, CRC(516b6c09) SHA1(9d02514dece864b087f67886009ce54bd51b5575) )
505   ROM_LOAD( "153_a19.bin",  0x070000, 0x10000, CRC(f36390a9) SHA1(e5ea36e91b3ced068281524ee79d0432f489715c) )
506
507   ROM_REGION( 0x1000, REGION_PLDS, ROMREGION_DISPOSE )
508   ROM_LOAD( "el_ic39_gal16v8_0.bin", 0x0000, 0x0117, NO_DUMP SHA1(894b345b395097acf6cf52ab8bc922099f97a85f) )
509   ROM_LOAD( "el_ic44_gal16v8_1.bin", 0x0200, 0x0117, NO_DUMP SHA1(fd41f55d857995fe87217dd9679c42760c241dc4) )
510   ROM_LOAD( "el_ic54_gal16v8_2.bin", 0x0400, 0x0117, NO_DUMP SHA1(f6d138fe42549219e11ee8524b05fe3c2b43f5d3) )
511   ROM_LOAD( "el_ic100_gal16v8_3.bin", 0x0600, 0x0117, NO_DUMP SHA1(515fcdf378e75ed078f54439fefce8807403bdd5) )
512   ROM_LOAD( "el_ic143_gal16v8_4.bin", 0x0800, 0x0117, NO_DUMP SHA1(fbe632437eac2418da7a3c3e947cfd36f6211407) )
513ROM_END
514#endif
515
516
473517GAME( 1989, wc90b, wc90, wc90b, wc90b, 0, ROT0, "bootleg", "Euro League", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND )
518//GAME( 1989, wc90ba, wc90, wc90b, wc90b, 0, ROT0, "bootleg", "Euro League (alt version)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND )
src/mame/drivers/liberate.c
r2375r2376
7070   const UINT8 *ROM = memory_region(REGION_CPU1);
7171
7272   if (deco16_bank) {
73      if (offset==0) return readinputportbytag("IN1"); /* Player 1 controls */
74      if (offset==1) return readinputportbytag("IN2"); /* Player 2 controls */
75      if (offset==2) return readinputportbytag("IN3"); /* Vblank, coins */
76      if (offset==3) return readinputportbytag("DSW1"); /* Dip 1 */
77      if (offset==4) return readinputportbytag("DSW2"); /* Dip 2 */
73      if (offset==0) return input_port_read(machine, "IN1"); /* Player 1 controls */
74      if (offset==1) return input_port_read(machine, "IN2"); /* Player 2 controls */
75      if (offset==2) return input_port_read(machine, "IN3"); /* Vblank, coins */
76      if (offset==3) return input_port_read(machine, "DSW1"); /* Dip 1 */
77      if (offset==4) return input_port_read(machine, "DSW2"); /* Dip 2 */
7878
7979      logerror("%04x:  Read input %d\n",activecpu_get_pc(),offset);
8080      return 0xff;
r2375r2376
498498static INTERRUPT_GEN( deco16_interrupt )
499499{
500500   static int latch=0;
501   int p=~readinputport(3);
501   int p=~input_port_read_indexed(machine, 3);
502502   if (p&0x43 && !latch) {
503503      cpunum_set_input_line(machine, 0,DECO16_IRQ_LINE,ASSERT_LINE);
504504      latch=1;
src/mame/drivers/spdodgeb.c
r2375r2376
104104static int inputs[4];
105105
106106#if 0   // default - more sensitive (state change and timing measured on real board?)
107static void mcu63705_update_inputs(void)
107static void mcu63705_update_inputs(running_machine *machine)
108108{
109109   static int running[2],jumped[2];
110110   int buttons[2];
r2375r2376
116116      static int prev[2][2],countup[2][2],countdown[2][2];
117117      int curr[2][2];
118118
119      curr[p][0] = readinputport(2+p) & 0x01;
120      curr[p][1] = readinputport(2+p) & 0x02;
119      curr[p][0] = input_port_read_indexed(machine, 2+p) & 0x01;
120      curr[p][1] = input_port_read_indexed(machine, 2+p) & 0x02;
121121
122122      for (j = 0;j <= 1;j++)
123123      {
r2375r2376
152152      static int prev[2];
153153      int curr[2];
154154
155      curr[p] = readinputport(2+p) & 0x30;
155      curr[p] = input_port_read_indexed(machine, 2+p) & 0x30;
156156
157157      if (jumped[p]) buttons[p] = 0;   /* jump only momentarily flips the buttons */
158158      else buttons[p] = curr[p];
r2375r2376
163163      prev[p] = curr[p];
164164   }
165165
166   inputs[0] = readinputport(2) & 0xcf;
167   inputs[1] = readinputport(3) & 0x0f;
166   inputs[0] = input_port_read_indexed(machine, 2) & 0xcf;
167   inputs[1] = input_port_read_indexed(machine, 3) & 0x0f;
168168   inputs[2] = running[0] | buttons[0];
169169   inputs[3] = running[1] | buttons[1];
170170}
171171#else   // alternate - less sensitive
172static void mcu63705_update_inputs(void)
172static void mcu63705_update_inputs(running_machine *machine)
173173{
174174#define DBLTAP_TOLERANCE 5
175175
r2375r2376
187187
188188   for (p=0; p<=1; p++)
189189   {
190      curr_port[p] = readinputport(p+2);
190      curr_port[p] = input_port_read_indexed(machine, p+2);
191191      curr_dash[p] = 0;
192192
193193      if (curr_port[p] & R)
r2375r2376
242242      case 1: return inputs[1];
243243      case 2: return inputs[2];
244244      case 3: return inputs[3];
245      case 4: return readinputport(4);
245      case 4: return input_port_read_indexed(machine, 4);
246246   }
247247}
248248
r2375r2376
250250{
251251//  logerror("CPU #0 PC %04x: write %02x to 63701 control address 3800\n",activecpu_get_pc(),data);
252252   mcu63701_command = data;
253   mcu63705_update_inputs();
253   mcu63705_update_inputs(machine);
254254}
255255
256256
257257static READ8_HANDLER( port_0_r )
258258{
259   int port = readinputport(0);
259   int port = input_port_read_indexed(machine, 0);
260260
261261   toggle^=0x02;   /* mcu63701_busy flag */
262262
src/mame/drivers/turbo.c
r2375r2376
410410      {
411411         /* read sensor RAM */
412412         case 0x40:
413            result = ~readinputport(1);  /* DSW 1 - inverted! */
413            result = ~input_port_read_indexed(machine, 1);  /* DSW 1 - inverted! */
414414            break;
415415
416416         /* read display RAM */
r2375r2376
545545{
546546   turbo_state *state = machine->driver_data;
547547   video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen));
548   return readinputport(3) | (state->turbo_collision & 15);
548   return input_port_read_indexed(machine, 3) | (state->turbo_collision & 15);
549549}
550550
551551
r2375r2376
560560static READ8_HANDLER( turbo_analog_r )
561561{
562562   turbo_state *state = machine->driver_data;
563   return readinputport(4) - state->turbo_last_analog;
563   return input_port_read_indexed(machine, 4) - state->turbo_last_analog;
564564}
565565
566566
567567static WRITE8_HANDLER( turbo_analog_reset_w )
568568{
569569   turbo_state *state = machine->driver_data;
570   state->turbo_last_analog = readinputport(4);
570   state->turbo_last_analog = input_port_read_indexed(machine, 4);
571571}
572572
573573
r2375r2376
606606
607607static READ8_HANDLER( buckrog_port_2_r )
608608{
609   int inp1 = readinputport(2);
610   int inp2 = readinputport(3);
609   int inp1 = input_port_read_indexed(machine, 2);
610   int inp2 = input_port_read_indexed(machine, 3);
611611
612612   return  (((inp2 >> 6) & 1) << 7) |
613613         (((inp2 >> 4) & 1) << 6) |
r2375r2376
622622
623623static READ8_HANDLER( buckrog_port_3_r )
624624{
625   int inp1 = readinputport(2);
626   int inp2 = readinputport(3);
625   int inp1 = input_port_read_indexed(machine, 2);
626   int inp2 = input_port_read_indexed(machine, 3);
627627
628628   return  (((inp2 >> 7) & 1) << 7) |
629629         (((inp2 >> 5) & 1) << 6) |
src/mame/drivers/seta.c
r2375r2376
15201520/* DSW reading for 16 bit CPUs */
15211521static READ16_HANDLER( seta_dsw_r )
15221522{
1523   UINT16 dsw = readinputport(3);
1523   UINT16 dsw = input_port_read_indexed(machine, 3);
15241524   if (offset == 0)   return (dsw >> 8) & 0xff;
15251525   else            return (dsw >> 0) & 0xff;
15261526}
r2375r2376
15301530
15311531static READ8_HANDLER( dsw1_r )
15321532{
1533   return (readinputport(3) >> 8) & 0xff;
1533   return (input_port_read_indexed(machine, 3) >> 8) & 0xff;
15341534}
15351535
15361536static READ8_HANDLER( dsw2_r )
15371537{
1538   return (readinputport(3) >> 0) & 0xff;
1538   return (input_port_read_indexed(machine, 3) >> 0) & 0xff;
15391539}
15401540
15411541
r2375r2376
16541654
16551655static READ16_HANDLER ( calibr50_ip_r )
16561656{
1657   int dir1 = readinputportbytag("IN4") & 0xfff;   // analog port
1658   int dir2 = readinputportbytag("IN5") & 0xfff;   // analog port
1657   int dir1 = input_port_read(machine, "IN4") & 0xfff;   // analog port
1658   int dir2 = input_port_read(machine, "IN5") & 0xfff;   // analog port
16591659
16601660   switch (offset)
16611661   {
1662      case 0x00/2:   return readinputportbytag("IN0");   // p1
1663      case 0x02/2:   return readinputportbytag("IN1");   // p2
1662      case 0x00/2:   return input_port_read(machine, "IN0");   // p1
1663      case 0x02/2:   return input_port_read(machine, "IN1");   // p2
16641664
1665      case 0x08/2:   return readinputport(2);   // Coins
1665      case 0x08/2:   return input_port_read_indexed(machine, 2);   // Coins
16661666
16671667      case 0x10/2:   return (dir1&0xff);         // lower 8 bits of p1 rotation
16681668      case 0x12/2:   return (dir1>>8);         // upper 4 bits of p1 rotation
r2375r2376
17291729{
17301730   switch (offset)
17311731   {
1732      case 0/2:   return (readinputport(3) >>  8) & 0xf;
1733      case 2/2:   return (readinputport(3) >> 12) & 0xf;
1734      case 4/2:   return (readinputport(3) >>  0) & 0xf;
1735      case 6/2:   return (readinputport(3) >>  4) & 0xf;
1732      case 0/2:   return (input_port_read_indexed(machine, 3) >>  8) & 0xf;
1733      case 2/2:   return (input_port_read_indexed(machine, 3) >> 12) & 0xf;
1734      case 4/2:   return (input_port_read_indexed(machine, 3) >>  0) & 0xf;
1735      case 6/2:   return (input_port_read_indexed(machine, 3) >>  4) & 0xf;
17361736   }
17371737   return 0;
17381738}
r2375r2376
17411741{
17421742   switch (offset)
17431743   {
1744      case 0/2:   return (readinputport(0) >> 0) & 0xff;
1745      case 2/2:   return (readinputport(0) >> 8) & 0xff;
1744      case 0/2:   return (input_port_read_indexed(machine, 0) >> 0) & 0xff;
1745      case 2/2:   return (input_port_read_indexed(machine, 0) >> 8) & 0xff;
17461746   }
17471747   return 0;
17481748}
r2375r2376
17511751{
17521752   switch (offset)
17531753   {
1754      case 0/2:   return (readinputport(1) >> 0) & 0xff;
1755      case 2/2:   return (readinputport(1) >> 8) & 0xff;
1754      case 0/2:   return (input_port_read_indexed(machine, 1) >> 0) & 0xff;
1755      case 2/2:   return (input_port_read_indexed(machine, 1) >> 8) & 0xff;
17561756   }
17571757   return 0;
17581758}
r2375r2376
19601960
19611961static READ16_HANDLER( zombraid_gun_r ) // Serial interface
19621962{
1963   int data = readinputport(4 + gun_input_src); // Input Ports 5-8
1963   int data = input_port_read_indexed(machine, 4 + gun_input_src); // Input Ports 5-8
19641964   return (data >> gun_input_bit) & 1;
19651965}
19661966
r2375r2376
23712371static READ16_HANDLER( krzybowl_input_r )
23722372{
23732373   // analog ports
2374   int dir1x = readinputport(4) & 0xfff;
2375   int dir1y = readinputport(5) & 0xfff;
2376   int dir2x = readinputport(6) & 0xfff;
2377   int dir2y = readinputport(7) & 0xfff;
2374   int dir1x = input_port_read_indexed(machine, 4) & 0xfff;
2375   int dir1y = input_port_read_indexed(machine, 5) & 0xfff;
2376   int dir2x = input_port_read_indexed(machine, 6) & 0xfff;
2377   int dir2y = input_port_read_indexed(machine, 7) & 0xfff;
23782378
23792379   switch (offset)
23802380   {
r2375r2376
26042604
26052605   switch( offset )
26062606   {
2607      case 0x00/2:   return readinputport( i );
2607      case 0x00/2:   return input_port_read_indexed(machine, i );
26082608      case 0x02/2:   return 0xffff;
2609      case 0x04/2:   return readinputport( 2 );
2609      case 0x04/2:   return input_port_read_indexed(machine, 2 );
26102610//      case 0x06/2:
26112611      case 0x08/2:   return 0xffff;
26122612
r2375r2376
28852885
28862886static READ8_HANDLER( downtown_ip_r )
28872887{
2888   int dir1 = readinputport(4);   // analog port
2889   int dir2 = readinputport(5);   // analog port
2888   int dir1 = input_port_read_indexed(machine, 4);   // analog port
2889   int dir2 = input_port_read_indexed(machine, 5);   // analog port
28902890
28912891   dir1 = (~ (0x800 >> ((dir1 * 12)/0x100)) ) & 0xfff;
28922892   dir2 = (~ (0x800 >> ((dir2 * 12)/0x100)) ) & 0xfff;
28932893
28942894   switch (offset)
28952895   {
2896      case 0:   return (readinputport(2) & 0xf0) + (dir1>>8);   // upper 4 bits of p1 rotation + coins
2896      case 0:   return (input_port_read_indexed(machine, 2) & 0xf0) + (dir1>>8);   // upper 4 bits of p1 rotation + coins
28972897      case 1:   return (dir1&0xff);         // lower 8 bits of p1 rotation
2898      case 2:   return readinputport(0);   // p1
2898      case 2:   return input_port_read_indexed(machine, 0);   // p1
28992899      case 3:   return 0xff;            // ?
29002900      case 4:   return (dir2>>8);         // upper 4 bits of p2 rotation + ?
29012901      case 5:   return (dir2&0xff);         // lower 8 bits of p2 rotation
2902      case 6:   return readinputport(1);   // p2
2902      case 6:   return input_port_read_indexed(machine, 1);   // p2
29032903      case 7:   return 0xff;            // ?
29042904   }
29052905
r2375r2376
31023102static READ16_HANDLER( inttoote_dsw_r )
31033103{
31043104   int shift = offset * 4;
3105   return   ((((readinputport(0) >> shift)     & 0xf)) << 0) |
3106         ((((readinputport(1) >> shift)     & 0xf)) << 4) |
3107         ((((readinputport(1) >> (shift+8)) & 0xf)) << 8) ;
3105   return   ((((input_port_read_indexed(machine, 0) >> shift)     & 0xf)) << 0) |
3106         ((((input_port_read_indexed(machine, 1) >> shift)     & 0xf)) << 4) |
3107         ((((input_port_read_indexed(machine, 1) >> (shift+8)) & 0xf)) << 8) ;
31083108}
31093109
31103110static UINT16 *inttoote_key_select;
r2375r2376
31123112{
31133113   switch( *inttoote_key_select )
31143114   {
3115      case 0x08:   return readinputport(4+0);
3116      case 0x10:   return readinputport(4+1);
3117      case 0x20:   return readinputport(4+2);
3118      case 0x40:   return readinputport(4+3);
3119      case 0x80:   return readinputport(4+4);
3115      case 0x08:   return input_port_read_indexed(machine, 4+0);
3116      case 0x10:   return input_port_read_indexed(machine, 4+1);
3117      case 0x20:   return input_port_read_indexed(machine, 4+2);
3118      case 0x40:   return input_port_read_indexed(machine, 4+3);
3119      case 0x80:   return input_port_read_indexed(machine, 4+4);
31203120   }
31213121   logerror("%06X: unknown read, select = %04x\n",activecpu_get_pc(),*inttoote_key_select);
31223122   return 0xffff;
src/mame/drivers/truco.c
r2375r2376
133133   /* coinup */
134134   static int trigger = 0;
135135
136   if ( readinputport( 2 ) & 1 )
136   if ( input_port_read_indexed(machine, 2 ) & 1 )
137137   {
138138      if ( trigger == 0 )
139139      {
src/mame/drivers/laserbat.c
r2375r2376
9191static READ8_HANDLER( laserbat_input_r )
9292{
9393   // Add coktail inputs
94   return readinputport(0 + laserbat_input_mux);
94   return input_port_read_indexed(machine, 0 + laserbat_input_mux);
9595}
9696
9797static WRITE8_HANDLER( laserbat_cnteff_w )
src/mame/drivers/ssf2md.c
r2375r2376
1313static READ16_HANDLER( ssf2ghw_dsw_r )
1414{
1515   static const char *const dswname[3] = { "DSWA", "DSWB", "DSWC" };
16   return readinputportbytag(dswname[offset]);
16   return input_port_read(machine, dswname[offset]);
1717}
1818
1919static DRIVER_INIT( ssf2ghw )
src/mame/drivers/tnzs.c
r2375r2376
281281{
282282   int   dsw, dsw1, dsw2;
283283
284   dsw1 = readinputportbytag("DSWA");
285   dsw2 = readinputportbytag("DSWB");
284   dsw1 = input_port_read(machine, "DSWA");
285   dsw2 = input_port_read(machine, "DSWB");
286286
287287   switch (kageki_csport_sel)
288288   {
src/mame/drivers/rohga.c
r2375r2376
125125VIDEO_UPDATE( nitrobal );
126126WRITE16_HANDLER( rohga_buffer_spriteram16_w );
127127
128static READ16_HANDLER( rohga_dip3_r ) { return readinputport(3); }
129static READ16_HANDLER( nitrobal_control_r ) { return readinputport(3); }
130static READ16_HANDLER( schmeisr_control_r ) { return readinputport(1); }
128static READ16_HANDLER( rohga_dip3_r ) { return input_port_read_indexed(machine, 3); }
129static READ16_HANDLER( nitrobal_control_r ) { return input_port_read_indexed(machine, 3); }
130static READ16_HANDLER( schmeisr_control_r ) { return input_port_read_indexed(machine, 1); }
131131
132132/**********************************************************************************/
133133
src/mame/drivers/plygonet.c
r2375r2376
107107   }
108108   else
109109   {
110      return (readinputport(0)<<24);
110      return (input_port_read_indexed(machine, 0)<<24);
111111   }
112112
113113   /* FIXME: code will never execute */
src/mame/drivers/batman.c
r2375r2376
6363   atarivc_reset(machine->primary_screen, atarivc_eof_data, 2);
6464   atarigen_scanline_timer_reset(machine->primary_screen, batman_scanline_update, 8);
6565   atarijsa_reset();
66   atarigen_init_save_state();
66   atarigen_init_save_state(machine);
6767   state_save_register_global(latch_data);
6868
6969}
r2375r2376
9797
9898static READ16_HANDLER( special_port2_r )
9999{
100   int result = readinputport(2);
100   int result = input_port_read_indexed(machine, 2);
101101   if (atarigen_sound_to_cpu_ready) result ^= 0x0010;
102102   if (atarigen_cpu_to_sound_ready) result ^= 0x0020;
103103   return result;
src/mame/drivers/nemesis.c
r2375r2376
217217    bit 12-15: accel
218218*/
219219
220   int data=readinputport(7);
221   int data2=readinputport(6);
220   int data=input_port_read_indexed(machine, 7);
221   int data2=input_port_read_indexed(machine, 6);
222222
223223   int ret=0x0000;
224224
src/mame/drivers/progolf.c
r2375r2376
193193#ifdef UNUSED_FUNCTION
194194static INTERRUPT_GEN( progolf_interrupt )
195195{
196   //if (readinputport(2) & 0xc0)
196   //if (input_port_read_indexed(machine, 2) & 0xc0)
197197      cpunum_set_input_line(machine, 0, /*0*/INPUT_LINE_NMI, /*HOLD_LINE*/PULSE_LINE);
198198}
199199#endif
src/mame/drivers/powerbal.c
r2375r2376
6363
6464static READ16_HANDLER( magicstk_port2_r )
6565{
66   return (input_port_2_r(machine,0) & 0xfe) | EEPROM_read_bit();
66   return (input_port_read_indexed(machine, 2) & 0xfe) | EEPROM_read_bit();
6767}
6868
6969static WRITE16_HANDLER( magicstk_coin_eeprom_w )
src/mame/drivers/stv.c
r2375r2376
507507   /*Order is surely wrong but whatever...*/
508508}
509509
510static UINT8 stv_SMPC_r8 (int offset)
510static UINT8 stv_SMPC_r8 (running_machine *machine, int offset)
511511{
512512   int return_data;
513513
r2375r2376
518518      return_data = 0x20 ^ 0xff;
519519
520520   if (offset == 0x75)//PDR1 read
521      return_data = readinputport(0);
521      return_data = input_port_read_indexed(machine, 0);
522522
523523   if (offset == 0x77)//PDR2 read
524524      return_data=  (0xfe | EEPROM_read_bit());
525525
526526//  if (offset == 0x33) //country code
527//      return_data = readinputport(7);
527//      return_data = input_port_read_indexed(machine, 7);
528528
529529   if (activecpu_get_pc()==0x060020E6) return_data = 0x10;//???
530530
r2375r2376
683683
684684            smpc_ram[0x31]=0x00;  //?
685685
686            //smpc_ram[0x33]=readinputport(7);
686            //smpc_ram[0x33]=input_port_read_indexed(machine, 7);
687687
688688            smpc_ram[0x35]=0x00;
689689            smpc_ram[0x37]=0x00;
r2375r2376
769769   /* registers are all byte accesses, convert here */
770770   offset = offset << 2; // multiply offset by 4
771771
772   if (ACCESSING_BITS_24_31)   { byte = 0; readdata = stv_SMPC_r8(offset+byte) << 24; }
773   if (ACCESSING_BITS_16_23)   { byte = 1; readdata = stv_SMPC_r8(offset+byte) << 16; }
774   if (ACCESSING_BITS_8_15)   { byte = 2; readdata = stv_SMPC_r8(offset+byte) << 8;  }
775   if (ACCESSING_BITS_0_7)   { byte = 3; readdata = stv_SMPC_r8(offset+byte) << 0;  }
772   if (ACCESSING_BITS_24_31)   { byte = 0; readdata = stv_SMPC_r8(machine, offset+byte) << 24; }
773   if (ACCESSING_BITS_16_23)   { byte = 1; readdata = stv_SMPC_r8(machine, offset+byte) << 16; }
774   if (ACCESSING_BITS_8_15)   { byte = 2; readdata = stv_SMPC_r8(machine, offset+byte) << 8;  }
775   if (ACCESSING_BITS_0_7)   { byte = 3; readdata = stv_SMPC_r8(machine, offset+byte) << 0;  }
776776
777777   return readdata;
778778}
r2375r2376
952952      case 0:
953953      switch(port_sel)
954954      {
955         case 0x77: return 0xff000000|(readinputport(2) << 16) |0x0000ff00|(readinputport(3));
955         case 0x77: return 0xff000000|(input_port_read_indexed(machine, 2) << 16) |0x0000ff00|(input_port_read_indexed(machine, 3));
956956         case 0x67:
957957         {
958958            switch(mux_data)
959959            {
960960               /*Mahjong panel interface,bit wise(ACTIVE LOW)*/
961               case 0xfe:   return 0xff000000 | (readinputport(7)  << 16) | 0x0000ff00 | (readinputport(12));
962               case 0xfd:  return 0xff000000 | (readinputport(8)  << 16) | 0x0000ff00 | (readinputport(13));
963               case 0xfb:   return 0xff000000 | (readinputport(9)  << 16) | 0x0000ff00 | (readinputport(14));
964               case 0xf7:   return 0xff000000 | (readinputport(10) << 16) | 0x0000ff00 | (readinputport(15));
965               case 0xef:  return 0xff000000 | (readinputport(11) << 16) | 0x0000ff00 | (readinputport(16));
961               case 0xfe:   return 0xff000000 | (input_port_read_indexed(machine, 7)  << 16) | 0x0000ff00 | (input_port_read_indexed(machine, 12));
962               case 0xfd:  return 0xff000000 | (input_port_read_indexed(machine, 8)  << 16) | 0x0000ff00 | (input_port_read_indexed(machine, 13));
963               case 0xfb:   return 0xff000000 | (input_port_read_indexed(machine, 9)  << 16) | 0x0000ff00 | (input_port_read_indexed(machine, 14));
964               case 0xf7:   return 0xff000000 | (input_port_read_indexed(machine, 10) << 16) | 0x0000ff00 | (input_port_read_indexed(machine, 15));
965               case 0xef:  return 0xff000000 | (input_port_read_indexed(machine, 11) << 16) | 0x0000ff00 | (input_port_read_indexed(machine, 16));
966966               /*Joystick panel*/
967967               default:
968968               //popmessage("%02x MUX DATA",mux_data);
969                return (readinputport(2) << 16) | (readinputport(3));
969                return (input_port_read_indexed(machine, 2) << 16) | (input_port_read_indexed(machine, 3));
970970            }
971971         }
972972         case 0x47:
r2375r2376
976976               int data1 = 0, data2 = 0;
977977
978978               /* Critter Crusher */
979               data1 = readinputport(7);
979               data1 = input_port_read_indexed(machine, 7);
980980               data1 = BITSWAP8(data1, 2, 3, 0, 1, 6, 7, 5, 4) & 0xf3;
981               data1 |= (readinputport(2) & 1) ? 0x0 : 0x4;
982               data2 = readinputport(8);
981               data1 |= (input_port_read_indexed(machine, 2) & 1) ? 0x0 : 0x4;
982               data2 = input_port_read_indexed(machine, 8);
983983               data2 = BITSWAP8(data2, 2, 3, 0, 1, 6, 7, 5, 4) & 0xf3;
984               data2 |= (readinputport(2) & 1) ? 0x0 : 0x4;
984               data2 |= (input_port_read_indexed(machine, 2) & 1) ? 0x0 : 0x4;
985985
986986               return 0xff000000 | data1 << 16 | 0x0000ff00 | data2;
987987            }
r2375r2376
989989         //default:
990990         default:
991991         //popmessage("%02x PORT SEL",port_sel);
992         return (readinputport(2) << 16) | (readinputport(3));
992         return (input_port_read_indexed(machine, 2) << 16) | (input_port_read_indexed(machine, 3));
993993      }
994994      case 1:
995995      if ( strcmp(machine->gamedrv->name,"critcrsh") == 0 )
996996      {
997         return ((readinputport(4) << 16) & ((readinputport(2) & 1) ? 0xffef0000 : 0xffff0000)) | (ioga[1]);
997         return ((input_port_read_indexed(machine, 4) << 16) & ((input_port_read_indexed(machine, 2) & 1) ? 0xffef0000 : 0xffff0000)) | (ioga[1]);
998998      }
999999      else
10001000      {
1001         return (readinputport(4) << 16) | (ioga[1]);
1001         return (input_port_read_indexed(machine, 4) << 16) | (ioga[1]);
10021002      }
10031003      case 2:
10041004      switch(port_sel)
10051005      {
1006         case 0x77:   return (readinputport(5) << 16) | (readinputport(6));
1006         case 0x77:   return (input_port_read_indexed(machine, 5) << 16) | (input_port_read_indexed(machine, 6));
10071007         case 0x67:   return 0xffffffff;/**/
10081008         case 0x20:  return 0xffff0000 | (ioga[2] & 0xffff);
10091009         case 0x10:  return ((ioga[2] & 0xffff) << 16) | 0xffff;
r2375r2376
25212521    smpc_ram[0x2d] = DectoBCD(systime.local_time.minute);
25222522    smpc_ram[0x2f] = DectoBCD(systime.local_time.second);
25232523    smpc_ram[0x31] = 0x00; //CTG1=0 CTG0=0 (correct??)
2524//  smpc_ram[0x33] = readinputport(7);
2524//  smpc_ram[0x33] = input_port_read_indexed(machine, 7);
25252525    smpc_ram[0x5f] = 0x10;
25262526
25272527    #ifdef MAME_DEBUG
src/mame/drivers/megatech.c
r2375r2376
503503}
504504
505505
506static READ8_HANDLER( megaplay_r0) { return readinputportbytag("BIOS_IN0") ; }
507static READ8_HANDLER( megaplay_r1) { return readinputportbytag("BIOS_IN1") ; }
508static READ8_HANDLER( megaplay_r2) { return readinputportbytag("BIOS_DSW0") ; }
509static READ8_HANDLER( megaplay_r3) { return readinputportbytag("BIOS_DSW1") ; }
506static READ8_HANDLER( megaplay_r0) { return input_port_read(machine, "BIOS_IN0") ; }
507static READ8_HANDLER( megaplay_r1) { return input_port_read(machine, "BIOS_IN1") ; }
508static READ8_HANDLER( megaplay_r2) { return input_port_read(machine, "BIOS_DSW0") ; }
509static READ8_HANDLER( megaplay_r3) { return input_port_read(machine, "BIOS_DSW1") ; }
510510
511511static int mt_bank_bank_pos = 0;
512512static int mt_bank_partial = 0;
src/mame/drivers/warriorb.c
r2375r2376
735735//  ROM_LOAD( "d24-16.79", 0x00000, 0xa??, NO_DUMP )
736736ROM_END
737737
738static STATE_POSTLOAD( warriorb_postload )
739{
740   reset_sound_region();
741}
738742
739743static MACHINE_START( warriorb )
740744{
741745   state_save_register_global(banknum);
742   state_save_register_func_postload(reset_sound_region);
746   state_save_register_postload(machine, warriorb_postload, NULL);
743747}
744748
745749static MACHINE_RESET( taito_dualscreen )
src/mame/drivers/igs_blit.c
r2375r2376
334334                                    \
335335   for (i = 0; i < NUM; i++)               \
336336      if ((~igs_input_sel) & (1 << i) )      \
337         ret = readinputport(i);            \
337         ret = input_port_read_indexed(machine, i);            \
338338                                    \
339339   /* 0x0100 is blitter busy */            \
340340   return    (ret & 0xff) | 0x0000;            \
r2375r2376
663663   switch(igs_magic[0])
664664   {
665665      case 0x01:
666         if (~igs_input_sel2 & 0x01)   return readinputport(4);
667         if (~igs_input_sel2 & 0x02)   return readinputport(5);
668         if (~igs_input_sel2 & 0x04)   return readinputport(6);
669         if (~igs_input_sel2 & 0x08)   return readinputport(7);
670         if (~igs_input_sel2 & 0x10)   return readinputport(8);
666         if (~igs_input_sel2 & 0x01)   return input_port_read_indexed(machine, 4);
667         if (~igs_input_sel2 & 0x02)   return input_port_read_indexed(machine, 5);
668         if (~igs_input_sel2 & 0x04)   return input_port_read_indexed(machine, 6);
669         if (~igs_input_sel2 & 0x08)   return input_port_read_indexed(machine, 7);
670         if (~igs_input_sel2 & 0x10)   return input_port_read_indexed(machine, 8);
671671         /* fall through */
672672      default:
673673         logerror("%06x: warning, reading with igs_magic = %02x\n", activecpu_get_pc(), igs_magic[0]);
r2375r2376
736736{
737737   switch(igs_magic[0])
738738   {
739      case 0x00:   return readinputport(4);
740      case 0x01:   return readinputport(5);
741      case 0x02:   return readinputport(6);
739      case 0x00:   return input_port_read_indexed(machine, 4);
740      case 0x01:   return input_port_read_indexed(machine, 5);
741      case 0x02:   return input_port_read_indexed(machine, 6);
742742
743743      case 0x20:   return 0x49;
744744      case 0x21:   return 0x47;
r2375r2376
803803{
804804   switch(igs_magic[0])
805805   {
806      case 0x00:   return readinputport(5);
806      case 0x00:   return input_port_read_indexed(machine, 5);
807807
808808      case 0x20:   return 0x49;
809809      case 0x21:   return 0x47;
r2375r2376
873873      case 0:      return igs_input_sel2;
874874
875875      case 1:
876         if (~igs_input_sel2 & 0x01)   return readinputport(6);
877         if (~igs_input_sel2 & 0x02)   return readinputport(7);
878         if (~igs_input_sel2 & 0x04)   return readinputport(8);
879         if (~igs_input_sel2 & 0x08)   return readinputport(9);
880         if (~igs_input_sel2 & 0x10)   return readinputport(10);
876         if (~igs_input_sel2 & 0x01)   return input_port_read_indexed(machine, 6);
877         if (~igs_input_sel2 & 0x02)   return input_port_read_indexed(machine, 7);
878         if (~igs_input_sel2 & 0x04)   return input_port_read_indexed(machine, 8);
879         if (~igs_input_sel2 & 0x08)   return input_port_read_indexed(machine, 9);
880         if (~igs_input_sel2 & 0x10)   return input_port_read_indexed(machine, 10);
881881
882882         logerror("%06x: warning, reading with igs_input_sel2 = %02x\n", activecpu_get_pc(), igs_input_sel2);
883883         break;
r2375r2376
918918{
919919   switch(igs_magic[0])
920920   {
921      case 0x00:   return readinputport(5);
922      case 0x01:   return readinputport(6);
921      case 0x00:   return input_port_read_indexed(machine, 5);
922      case 0x01:   return input_port_read_indexed(machine, 6);
923923
924924      case 0x20:   return 0x49;
925925      case 0x21:   return 0x47;
r2375r2376
985985{
986986   switch(igs_magic[0])
987987   {
988      case 0x00:   return readinputport(3);
988      case 0x00:   return input_port_read_indexed(machine, 3);
989989
990990      case 0x02:
991         if (~igs_input_sel2 & 0x01)   return readinputport(4);
992         if (~igs_input_sel2 & 0x02)   return readinputport(5);
993         if (~igs_input_sel2 & 0x04)   return readinputport(6);
994         if (~igs_input_sel2 & 0x08)   return readinputport(7);
995         if (~igs_input_sel2 & 0x10)   return readinputport(8);
991         if (~igs_input_sel2 & 0x01)   return input_port_read_indexed(machine, 4);
992         if (~igs_input_sel2 & 0x02)   return input_port_read_indexed(machine, 5);
993         if (~igs_input_sel2 & 0x04)   return input_port_read_indexed(machine, 6);
994         if (~igs_input_sel2 & 0x08)   return input_port_read_indexed(machine, 7);
995         if (~igs_input_sel2 & 0x10)   return input_port_read_indexed(machine, 8);
996996         /* fall through */
997997      default:
998998         logerror("%06x: warning, reading with igs_magic = %02x\n", activecpu_get_pc(), igs_magic[0]);
r2375r2376
11941194static VIDEO_EOF( vbowl )
11951195{
11961196   vbowl_trackball[0] = vbowl_trackball[1];
1197   vbowl_trackball[1] = (readinputport(8) << 8) | readinputport(7);
1197   vbowl_trackball[1] = (input_port_read_indexed(machine, 8) << 8) | input_port_read_indexed(machine, 7);
11981198}
11991199
12001200static WRITE16_HANDLER( vbowl_pen_hi_w )
src/mame/drivers/goal92.c
r2375r2376
4141   switch(offset)
4242   {
4343      case 0:
44         return readinputport(0);
44         return input_port_read_indexed(machine, 0);
4545      case 1:
46         return readinputport(1);
46         return input_port_read_indexed(machine, 1);
4747      case 2:
48         return readinputport(2);
48         return input_port_read_indexed(machine, 2);
4949      case 3:
50         return readinputport(3);
50         return input_port_read_indexed(machine, 3);
5151      case 7:
52         return readinputport(4);
52         return input_port_read_indexed(machine, 4);
5353
5454      default:
5555         logerror("reading unhandled goal92 inputs %04X %04X @ PC = %04X\n",offset, mem_mask,activecpu_get_pc());
src/mame/drivers/champbwl.c
r2375r2376
159159static READ8_HANDLER( trackball_r )
160160{
161161   UINT8 ret;
162   UINT8 port4 = readinputport(4);
163   UINT8 port5 = readinputport(5);
162   UINT8 port4 = input_port_read_indexed(machine, 4);
163   UINT8 port5 = input_port_read_indexed(machine, 5);
164164
165165   ret = (((port4 - last_trackball_val[0]) & 0x0f)<<4) | ((port5 - last_trackball_val[1]) & 0x0f);
166166
src/mame/drivers/bishi.c
r2375r2376
159159
160160static READ16_HANDLER( dipsw_r )   // dips
161161{
162   return input_port_1_r(machine,0) | (input_port_5_r(machine,0)<<8);
162   return input_port_read_indexed(machine, 1) | (input_port_read_indexed(machine, 5)<<8);
163163}
164164
165165static READ16_HANDLER( player1_r )    // players 1 and 3
166166{
167   return 0xff | (input_port_2_r(machine,0)<<8);
167   return 0xff | (input_port_read_indexed(machine, 2)<<8);
168168}
169169
170170static READ16_HANDLER( player2_r )   // players 2 and 4
171171{
172   return input_port_3_r(machine,0) | (input_port_4_r(machine,0)<<8);
172   return input_port_read_indexed(machine, 3) | (input_port_read_indexed(machine, 4)<<8);
173173}
174174
175175static READ16_HANDLER( bishi_K056832_rom_r )
src/mame/drivers/vamphalf.c
r2375r2376
203203
204204static READ32_HANDLER( finalgdr_input0_r )
205205{
206   return readinputport(0) << 16;
206   return input_port_read_indexed(machine, 0) << 16;
207207}
208208
209209static READ32_HANDLER( finalgdr_input1_r )
210210{
211   return readinputport(1) << 16;
211   return input_port_read_indexed(machine, 1) << 16;
212212}
213213
214214static WRITE32_HANDLER( finalgdr_oki_bank_w )
r2375r2376
617617
618618static MACHINE_DRIVER_START( sound_qs1000 )
619619   MDRV_CPU_ADD(I8052, 24000000/4)   /* 6 MHz? */
620   MDRV_CPU_PROGRAM_MAP( qs1000_prg_map, 0 )
620   MDRV_CPU_PROGRAM_MAP(qs1000_prg_map, 0)
621621   MDRV_CPU_DATA_MAP( qs1000_data_map, 0 )
622622
623623MACHINE_DRIVER_END
src/mame/drivers/mayumi.c
r2375r2376
6060   for (i=0; i<5; i++)
6161   {
6262      if (p & (1 << i))
63         ret &= readinputport(i+7-offset*5);
63         ret &= input_port_read_indexed(machine, i+7-offset*5);
6464   }
6565
6666   return ret;
src/mame/drivers/poolshrk.c
r2375r2376
7272
7373static READ8_HANDLER( poolshrk_input_r )
7474{
75   UINT8 val = readinputport(offset & 3);
75   UINT8 val = input_port_read_indexed(machine, offset & 3);
7676
77   int x = readinputport(4 + (offset & 1));
78   int y = readinputport(6 + (offset & 1));
77   int x = input_port_read_indexed(machine, 4 + (offset & 1));
78   int y = input_port_read_indexed(machine, 6 + (offset & 1));
7979
8080   if (x >= poolshrk_da_latch) val |= 8;
8181   if (y >= poolshrk_da_latch) val |= 4;
src/mame/drivers/alg.c
r2375r2376
2222
2323#include "driver.h"
2424#include "render.h"
25#include "deprecat.h"
2526#include "includes/amiga.h"
2627#include "machine/laserdsc.h"
2728
r2375r2376
5051{
5152   const rectangle *visarea = video_screen_get_visible_area(screen);
5253
53   int xpos = readinputportbytag_safe((player == 0) ? "GUN1X" : "GUN2X", -1);
54   int ypos = readinputportbytag_safe((player == 0) ? "GUN1Y" : "GUN2Y", -1);
54   int xpos = input_port_read_safe(screen->machine, (player == 0) ? "GUN1X" : "GUN2X", -1);
55   int ypos = input_port_read_safe(screen->machine, (player == 0) ? "GUN1Y" : "GUN2Y", -1);
5556
5657   if (xpos == -1 || ypos == -1)
5758      return FALSE;
r2375r2376
251252static CUSTOM_INPUT( lightgun_trigger_r )
252253{
253254   /* read the trigger control based on the input select */
254   return (readinputportbytag("TRIGGERS") >> input_select) & 1;
255   return (input_port_read(machine, "TRIGGERS") >> input_select) & 1;
255256}
256257
257258
258259static CUSTOM_INPUT( lightgun_holster_r )
259260{
260261   /* read the holster control based on the input select */
261   return (readinputportbytag("TRIGGERS") >> (2 + input_select)) & 1;
262   return (input_port_read(machine, "TRIGGERS") >> (2 + input_select)) & 1;
262263}
263264
264265
r2375r2376
287288
288289static UINT8 alg_cia_0_porta_r(void)
289290{
290   return readinputportbytag("FIRE") | 0x3f;
291   return input_port_read(Machine, "FIRE") | 0x3f;
291292}
292293
293294
src/mame/drivers/vegaeo.c
r2375r2376
7777static READ32_HANDLER( vegaeo_custom_read )
7878{
7979   eolith_speedup_read();
80   return readinputport(0);
80   return input_port_read_indexed(machine, 0);
8181}
8282static ADDRESS_MAP_START( vega_map, ADDRESS_SPACE_PROGRAM, 32 )
8383   AM_RANGE(0x00000000, 0x001fffff) AM_RAM
src/mame/drivers/fromanc2.c
r2375r2376
156156   UINT16 ret;
157157
158158   switch (fromanc2_portselect) {
159      case 0x01:   ret = readinputportbytag("IN1");   break;
160      case 0x02:   ret = readinputportbytag("IN2"); break;
161      case 0x04:   ret = readinputportbytag("IN3"); break;
162      case 0x08:   ret = readinputportbytag("IN4"); break;
159      case 0x01:   ret = input_port_read(machine, "IN1");   break;
160      case 0x02:   ret = input_port_read(machine, "IN2"); break;
161      case 0x04:   ret = input_port_read(machine, "IN3"); break;
162      case 0x08:   ret = input_port_read(machine, "IN4"); break;
163163      default:   ret = 0xffff;
164164               logerror("PC:%08X unknown %02X\n", activecpu_get_pc(), fromanc2_portselect);
165165               break;
r2375r2376
176176          ((fromanc2_subcpu_nmi_flag & 1) << 6) |
177177          ((fromanc2_sndcpu_nmi_flag & 1) << 5));
178178   eeprom = (EEPROM_read_bit() & 1) << 7;      // EEPROM DATA
179   coinsw = readinputport(0) & 0x030f;         // COIN, TEST
179   coinsw = input_port_read_indexed(machine, 0) & 0x030f;         // COIN, TEST
180180
181181   return (cflag | eeprom | coinsw);
182182}
r2375r2376
187187
188188   cflag = (fromanc2_sndcpu_nmi_flag & 1) << 5;
189189   eeprom = (EEPROM_read_bit() & 1) << 7;      // EEPROM DATA
190   coinsw = readinputport(0) & 0x001f;         // COIN, TEST
190   coinsw = input_port_read_indexed(machine, 0) & 0x001f;         // COIN, TEST
191191
192192   return (cflag | eeprom | coinsw);
193193}
src/mame/drivers/gridlee.c
r2375r2376
174174   UINT8 newval;
175175
176176   /* first read the new trackball value and compute the signed delta */
177   newval = readinputport(offset + 2 * gridlee_cocktail_flip);
177   newval = input_port_read_indexed(machine, offset + 2 * gridlee_cocktail_flip);
178178   delta = (int)newval - (int)last_analog_input[offset];
179179
180180   /* handle the case where we wrap around from 0x00 to 0xff, or vice versa */
src/mame/drivers/bnstars.c
r2375r2376
12021202         return 0xffffffff;
12031203
12041204      case 0x0000:
1205         return readinputport(0);
1205         return input_port_read_indexed(machine, 0);
12061206
12071207      case 0x0080:
1208         return readinputport(1);
1208         return input_port_read_indexed(machine, 1);
12091209
12101210      case 0x2000:
1211         return readinputport(2);
1211         return input_port_read_indexed(machine, 2);
12121212
12131213      case 0x2080:
1214         return readinputport(3);
1214         return input_port_read_indexed(machine, 3);
12151215
12161216   }
12171217}
12181218
12191219static READ32_HANDLER( bnstars2_r )
12201220{
1221   return readinputport(4);
1221   return input_port_read_indexed(machine, 4);
12221222}
12231223
12241224static READ32_HANDLER( bnstars3_r )
12251225{
1226   return readinputport(5);
1226   return input_port_read_indexed(machine, 5);
12271227}
12281228
12291229static WRITE32_HANDLER( bnstars1_mahjong_select_w )
src/mame/drivers/unico.c
r2375r2376
128128/* Light Gun - need to wiggle the input slightly otherwise fire doesn't work */
129129static READ16_HANDLER( unico_gunx_0_msb_r )
130130{
131   int x=readinputportbytag("X0");
131   int x=input_port_read(machine, "X0");
132132
133133   x=x*384/256; /* On screen pixel X */
134134   if (x<0x160) x=0x30 + (x*0xd0/0x15f);
r2375r2376
139139
140140static READ16_HANDLER( unico_guny_0_msb_r )
141141{
142   int y=readinputportbytag("Y0");
142   int y=input_port_read(machine, "Y0");
143143
144144   y=0x18+((y*0xe0)/0xff);
145145
r2375r2376
148148
149149static READ16_HANDLER( unico_gunx_1_msb_r )
150150{
151   int x=readinputportbytag("X1");
151   int x=input_port_read(machine, "X1");
152152
153153   x=x*384/256; /* On screen pixel X */
154154   if (x<0x160) x=0x30 + (x*0xd0/0x15f);
r2375r2376
159159
160160static READ16_HANDLER( unico_guny_1_msb_r )
161161{
162   int y=readinputportbytag("Y1");
162   int y=input_port_read(machine, "Y1");
163163
164164   y=0x18+((y*0xe0)/0xff);
165165
r2375r2376
214214                                Zero Point 2
215215***************************************************************************/
216216
217static READ32_HANDLER( zeropnt2_coins_r )         { return (readinputportbytag("IN0") << 16) | 0xffff; }
218static READ32_HANDLER( zeropnt2_dsw1_r )         { return (readinputportbytag("DSW1") << 16) | 0xffff; }
219static READ32_HANDLER( zeropnt2_dsw2_r )         { return (readinputportbytag("DSW2") << 16) | 0xffff; }
220static READ32_HANDLER( zeropnt2_buttons_r )         { return ((readinputportbytag("IN7") | ((EEPROM_read_bit() & 0x01) << 7)) << 16) | 0xffff; }
217static READ32_HANDLER( zeropnt2_coins_r )         { return (input_port_read(machine, "IN0") << 16) | 0xffff; }
218static READ32_HANDLER( zeropnt2_dsw1_r )         { return (input_port_read(machine, "DSW1") << 16) | 0xffff; }
219static READ32_HANDLER( zeropnt2_dsw2_r )         { return (input_port_read(machine, "DSW2") << 16) | 0xffff; }
220static READ32_HANDLER( zeropnt2_buttons_r )         { return ((input_port_read(machine, "IN7") | ((EEPROM_read_bit() & 0x01) << 7)) << 16) | 0xffff; }
221221
222222static READ32_HANDLER( zeropnt2_gunx_0_msb_r )      { return (unico_gunx_0_msb_r(machine,0,0)-0x0800) << 16; }
223223static READ32_HANDLER( zeropnt2_guny_0_msb_r )      { return (unico_guny_0_msb_r(machine,0,0)+0x0800) << 16; }
src/mame/drivers/realbrk.c
r2375r2376
5353static READ16_HANDLER( realbrk_dsw_r )
5454{
5555   UINT16 sel = ~realbrk_dsw_select[0];
56   if (sel & 0x01)   return   (readinputport(2) & 0x00ff) << 8;      // DSW1 low bits
57   if (sel & 0x02)   return   (readinputport(3) & 0x00ff) << 8;      // DSW2 low bits
58   if (sel & 0x04)   return   (readinputport(4) & 0x00ff) << 8;      // DSW3 low bits
59   if (sel & 0x08)   return   (readinputport(5) & 0x00ff) << 8;      // DSW4 low bits
56   if (sel & 0x01)   return   (input_port_read_indexed(machine, 2) & 0x00ff) << 8;      // DSW1 low bits
57   if (sel & 0x02)   return   (input_port_read_indexed(machine, 3) & 0x00ff) << 8;      // DSW2 low bits
58   if (sel & 0x04)   return   (input_port_read_indexed(machine, 4) & 0x00ff) << 8;      // DSW3 low bits
59   if (sel & 0x08)   return   (input_port_read_indexed(machine, 5) & 0x00ff) << 8;      // DSW4 low bits
6060
61   if (sel & 0x10)   return   ((readinputport(2) & 0x0300) << 0) |   // DSWs high 2 bits
62                     ((readinputport(3) & 0x0300) << 2) |
63                     ((readinputport(4) & 0x0300) << 4) |
64                     ((readinputport(5) & 0x0300) << 6) ;
61   if (sel & 0x10)   return   ((input_port_read_indexed(machine, 2) & 0x0300) << 0) |   // DSWs high 2 bits
62                     ((input_port_read_indexed(machine, 3) & 0x0300) << 2) |
63                     ((input_port_read_indexed(machine, 4) & 0x0300) << 4) |
64                     ((input_port_read_indexed(machine, 5) & 0x0300) << 6) ;
6565
6666   logerror("CPU #0 PC %06X: read with unknown dsw_select = %02x\n",activecpu_get_pc(),realbrk_dsw_select[0]);
6767   return 0xffff;
src/mame/drivers/arcadia.c
r2375r2376
4848***************************************************************************/
4949
5050#include "driver.h"
51#include "deprecat.h"
5152#include "sound/custom.h"
5253#include "includes/amiga.h"
5354
r2375r2376
9394
9495static UINT8 arcadia_cia_0_porta_r(void)
9596{
96   return readinputportbytag("CIA0PORTA");
97   return input_port_read(Machine, "CIA0PORTA");
9798}
9899
99100static void arcadia_cia_0_porta_w(UINT8 data)
r2375r2376
133134
134135static UINT8 arcadia_cia_0_portb_r(void)
135136{
136   return readinputportbytag("CIA0PORTB");
137   return input_port_read(Machine, "CIA0PORTB");
137138}
138139
139140static void arcadia_cia_0_portb_w(UINT8 data)
src/mame/drivers/segag80v.c
r2375r2376
257257   /* read as two bits from each of 4 ports. For this reason, the input   */
258258   /* ports have been organized logically, and are demangled at runtime.  */
259259   /* 4 input ports each provide 8 bits of information. */
260   UINT8 d7d6 = readinputportbytag("D7D6");
261   UINT8 d5d4 = readinputportbytag("D5D4");
262   UINT8 d3d2 = readinputportbytag("D3D2");
263   UINT8 d1d0 = readinputportbytag("D1D0");
260   UINT8 d7d6 = input_port_read(machine, "D7D6");
261   UINT8 d5d4 = input_port_read(machine, "D5D4");
262   UINT8 d3d2 = input_port_read(machine, "D3D2");
263   UINT8 d1d0 = input_port_read(machine, "D1D0");
264264   int shift = offset & 3;
265265   return demangle(d7d6 >> shift, d5d4 >> shift, d3d2 >> shift, d1d0 >> shift);
266266}
r2375r2376
284284   INT8 delta;
285285
286286   if (spinner_select & 1)
287      return readinputportbytag("FC");
287      return input_port_read(machine, "FC");
288288
289289/*
290290 * The values returned are always increasing.  That is, regardless of whether
r2375r2376
294294 */
295295
296296   /* I'm sure this can be further simplified ;-) BW */
297   delta = readinputportbytag("SPINNER");
297   delta = input_port_read(machine, "SPINNER");
298298   if (delta != 0)
299299   {
300300      spinner_sign = (delta >> 7) & 1;
r2375r2376
313313
314314static CUSTOM_INPUT( elim4_joint_coin_r )
315315{
316   return (readinputportbytag("COINS") & 0xf) != 0xf;
316   return (input_port_read(machine, "COINS") & 0xf) != 0xf;
317317}
318318
319319
r2375r2376
329329      {
330330         case 6:
331331            /* player 3 & 4 controls */
332            result = readinputportbytag("FC");
332            result = input_port_read(machine, "FC");
333333            break;
334334         case 7:
335335            /* the 4 coin inputs */
336            result = readinputportbytag("COINS");
336            result = input_port_read(machine, "COINS");
337337            break;
338338      }
339339   }
src/mame/drivers/vmetal.c
r2375r2376
144144}
145145
146146
147static READ16_HANDLER ( varia_dips_bit8_r ) { return ((readinputport(3) & 0x80) << 0) | ((readinputport(2) & 0x80) >> 1); }
148static READ16_HANDLER ( varia_dips_bit7_r ) { return ((readinputport(3) & 0x40) << 1) | ((readinputport(2) & 0x40) >> 0); }
149static READ16_HANDLER ( varia_dips_bit6_r ) { return ((readinputport(3) & 0x20) << 2) | ((readinputport(2) & 0x20) << 1); }
150static READ16_HANDLER ( varia_dips_bit5_r ) { return ((readinputport(3) & 0x10) << 3) | ((readinputport(2) & 0x10) << 2); }
151static READ16_HANDLER ( varia_dips_bit4_r ) { return ((readinputport(3) & 0x08) << 4) | ((readinputport(2) & 0x08) << 3); }
152static READ16_HANDLER ( varia_dips_bit3_r ) { return ((readinputport(3) & 0x04) << 5) | ((readinputport(2) & 0x04) << 4); }
153static READ16_HANDLER ( varia_dips_bit2_r ) { return ((readinputport(3) & 0x02) << 6) | ((readinputport(2) & 0x02) << 5); }
154static READ16_HANDLER ( varia_dips_bit1_r ) { return ((readinputport(3) & 0x01) << 7) | ((readinputport(2) & 0x01) << 6); }
147static READ16_HANDLER ( varia_dips_bit8_r ) { return ((input_port_read_indexed(machine, 3) & 0x80) << 0) | ((input_port_read_indexed(machine, 2) & 0x80) >> 1); }
148static READ16_HANDLER ( varia_dips_bit7_r ) { return ((input_port_read_indexed(machine, 3) & 0x40) << 1) | ((input_port_read_indexed(machine, 2) & 0x40) >> 0); }
149static READ16_HANDLER ( varia_dips_bit6_r ) { return ((input_port_read_indexed(machine, 3) & 0x20) << 2) | ((input_port_read_indexed(machine, 2) & 0x20) << 1); }
150static READ16_HANDLER ( varia_dips_bit5_r ) { return ((input_port_read_indexed(machine, 3) & 0x10) << 3) | ((input_port_read_indexed(machine, 2) & 0x10) << 2); }
151static READ16_HANDLER ( varia_dips_bit4_r ) { return ((input_port_read_indexed(machine, 3) & 0x08) << 4) | ((input_port_read_indexed(machine, 2) & 0x08) << 3); }
152static READ16_HANDLER ( varia_dips_bit3_r ) { return ((input_port_read_indexed(machine, 3) & 0x04) << 5) | ((input_port_read_indexed(machine, 2) & 0x04) << 4); }
153static READ16_HANDLER ( varia_dips_bit2_r ) { return ((input_port_read_indexed(machine, 3) & 0x02) << 6) | ((input_port_read_indexed(machine, 2) & 0x02) << 5); }
154static READ16_HANDLER ( varia_dips_bit1_r ) { return ((input_port_read_indexed(machine, 3) & 0x01) << 7) | ((input_port_read_indexed(machine, 2) & 0x01) << 6); }
155155
156156static WRITE16_HANDLER( vmetal_control_w )
157157{
src/mame/drivers/battlera.c
r2375r2376
6262static READ8_HANDLER( control_data_r )
6363{
6464   switch (control_port_select) {
65      case 0xfe: return readinputportbytag("IN0"); /* Player 1 */
66      case 0xfd: return readinputportbytag("IN1"); /* Player 2 */
67      case 0xfb: return readinputportbytag("IN2"); /* Coins */
68      case 0xf7: return readinputportbytag("DSW2"); /* Dip 2 */
69      case 0xef: return readinputportbytag("DSW1"); /* Dip 1 */
65      case 0xfe: return input_port_read(machine, "IN0"); /* Player 1 */
66      case 0xfd: return input_port_read(machine, "IN1"); /* Player 2 */
67      case 0xfb: return input_port_read(machine, "IN2"); /* Coins */
68      case 0xf7: return input_port_read(machine, "DSW2"); /* Dip 2 */
69      case 0xef: return input_port_read(machine, "DSW1"); /* Dip 1 */
7070   }
7171
7272    return 0xff;
src/mame/drivers/dreamwld.c
r2375r2376
193193
194194static READ32_HANDLER( dreamwld_inputs_r )
195195{
196   return readinputport(1)|(readinputport(0)<<16);
196   return input_port_read_indexed(machine, 1)|(input_port_read_indexed(machine, 0)<<16);
197197}
198198
199199static READ32_HANDLER( dreamwld_dips_r )
200200{
201201   int x;
202   x= readinputport(2);
202   x= input_port_read_indexed(machine, 2);
203203   return x|(x<<16);
204204}
205205
src/mame/drivers/xain.c
r2375r2376
245245
246246static READ8_HANDLER( xain_input_port_4_r )
247247{
248   return readinputport(4) | vblank;
248   return input_port_read_indexed(machine, 4) | vblank;
249249}
250250
251251static INTERRUPT_GEN( xain_interrupt )
src/mame/drivers/gundealr.c
r2375r2376
7373   {
7474      if (input_ports_hack)
7575      {
76         rambase[0x004] = readinputport(4);   /* COIN */
77         rambase[0x005] = readinputport(3);   /* IN1 */
78         rambase[0x006] = readinputport(2);   /* IN0 */
76         rambase[0x004] = input_port_read_indexed(machine, 4);   /* COIN */
77         rambase[0x005] = input_port_read_indexed(machine, 3);   /* IN1 */
78         rambase[0x006] = input_port_read_indexed(machine, 2);   /* IN0 */
7979      }
8080      cpunum_set_input_line_and_vector(machine, 0, 0, HOLD_LINE, 0xd7);   /* RST 10h vblank */
8181   }
src/mame/drivers/namcos1.c
r2375r2376
412412
413413static READ8_HANDLER( dsw_r )
414414{
415   int ret = readinputportbytag("DIPSW");
415   int ret = input_port_read(machine, "DIPSW");
416416   if (!(offset & 2)) ret >>= 4;
417417   return 0xf0 | ret;
418418}
src/mame/drivers/m62.c
r2375r2376
13901390
13911391   /* video hardware */
13921392   MDRV_GFXDECODE(ldrun3)
1393   MDRV_VIDEO_START(ldrun2)
1394   MDRV_VIDEO_UPDATE(ldrun)
13931395MACHINE_DRIVER_END
13941396
13951397
src/mame/drivers/astrocde.c
r2375r2376
258258static CUSTOM_INPUT( ebases_trackball_r )
259259{
260260   static const char *const names[] = { "TRACKX2", "TRACKY2", "TRACKX1", "TRACKY1" };
261   return readinputportbytag(names[input_select]);
261   return input_port_read(machine, names[input_select]);
262262}
263263
264264
r2375r2376
285285{
286286   coin_counter_w(0, (offset >> 8) & 1);
287287   coin_counter_w(1, (offset >> 9) & 1);
288   return readinputportbytag_safe("P3HANDLE", 0xff);
288   return input_port_read_safe(machine, "P3HANDLE", 0xff);
289289}
290290
291291
r2375r2376
447447}
448448
449449
450static void profbank_banksw_restore(void)
450static STATE_POSTLOAD( profbank_banksw_restore )
451451{
452452   profpac_banksw_w(Machine, 0, profpac_bank);
453453}
r2375r2376
474474static CUSTOM_INPUT( demndragn_joystick_r )
475475{
476476   static const char *const names[] = { "MOVEX", "MOVEY" };
477   return readinputportbytag(names[input_select]);
477   return input_port_read(machine, names[input_select]);
478478}
479479
480480
r2375r2376
17271727
17281728   /* reset banking */
17291729   profpac_banksw_w(machine, 0, 0);
1730   state_save_register_func_postload(profbank_banksw_restore);
1730   state_save_register_postload(machine, profbank_banksw_restore, NULL);
17311731}
17321732
17331733
r2375r2376
17411741
17421742   /* reset banking */
17431743   profpac_banksw_w(machine, 0, 0);
1744   state_save_register_func_postload(profbank_banksw_restore);
1744   state_save_register_postload(machine, profbank_banksw_restore, NULL);
17451745}
17461746
17471747
r2375r2376
17601760
17611761   /* reset banking */
17621762   profpac_banksw_w(machine, 0, 0);
1763   state_save_register_func_postload(profbank_banksw_restore);
1763   state_save_register_postload(machine, profbank_banksw_restore, NULL);
17641764}
17651765
17661766
src/mame/drivers/megazone.c
r2375r2376
117117
118118static ADDRESS_MAP_START( sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
119119   AM_RANGE(0x0000, 0x1fff) AM_READ(SMH_ROM)
120   AM_RANGE(0x6000, 0x6000) AM_READ(input_port_0_r) /* IO Coin */
121   AM_RANGE(0x6001, 0x6001) AM_READ(input_port_1_r) /* P1 IO */
122   AM_RANGE(0x6002, 0x6002) AM_READ(input_port_2_r) /* P2 IO */
123   AM_RANGE(0x8000, 0x8000) AM_READ(input_port_3_r) /* DIP 1 */
124   AM_RANGE(0x8001, 0x8001) AM_READ(input_port_4_r) /* DIP 2 */
120   AM_RANGE(0x6000, 0x6000) AM_READ_PORT("IN0")  /* IO Coin */
121   AM_RANGE(0x6001, 0x6001) AM_READ_PORT("IN1")  /* P1 IO */
122   AM_RANGE(0x6002, 0x6002) AM_READ_PORT("IN2")  /* P2 IO */
123   AM_RANGE(0x8000, 0x8000) AM_READ_PORT("DSW1") /* DIP 1 */
124   AM_RANGE(0x8001, 0x8001) AM_READ_PORT("DSW2") /* DIP 2 */
125125   AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_SHARE(1)
126126ADDRESS_MAP_END
127127
r2375r2376
163163ADDRESS_MAP_END
164164
165165static INPUT_PORTS_START( megazone )
166   /* 0x6000 -> 0xe320 (CPU1) = 0x3b20 (CPU0) */
166167   PORT_START_TAG("IN0")
167168   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
168169   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
r2375r2376
173174   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
174175   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
175176
177   /* 0x6001 -> 0xe31e (CPU1) = 0x3b1e (CPU0) */
176178   PORT_START_TAG("IN1")
177   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
179   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
178180   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
179   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
180   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
181   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    ) PORT_8WAY
182   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  ) PORT_8WAY
181183   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
182   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
184   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
183185   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
184186   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
185187
188   /* 0x6002 -> 0xe31e (CPU1) = 0x3b1e (CPU0) or 0xe31f (CPU1) = 0x3b1f (CPU0) in "test mode" */
186189   PORT_START_TAG("IN2")
187   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
190   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
188191   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL
189   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_8WAY PORT_COCKTAIL
190   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_8WAY PORT_COCKTAIL
192   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    ) PORT_8WAY PORT_COCKTAIL
193   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  ) PORT_8WAY PORT_COCKTAIL
191194   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
192   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
195   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
193196   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
194197   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
195198
199   /* 0x8000 -> 0xe020 (CPU1) = 0x3820 (CPU0) */
196200   PORT_START_TAG("DSW1")
197201   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
198202   PORT_DIPSETTING(    0x03, "3" )
199203   PORT_DIPSETTING(    0x02, "4" )
200204   PORT_DIPSETTING(    0x01, "5" )
201   PORT_DIPSETTING(    0x00, "Infinite (Cheat)")
205   PORT_DIPSETTING(    0x00, "7" )
202206   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) )
203207   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
204208   PORT_DIPSETTING(    0x04, DEF_STR( Cocktail ) )
205209   PORT_DIPNAME( 0x18, 0x18, DEF_STR( Bonus_Life ) )
206   PORT_DIPSETTING(    0x18, "20k 70k" )
207   PORT_DIPSETTING(    0x10, "20k 80k" )
208   PORT_DIPSETTING(    0x08, "30k 90k" )
209   PORT_DIPSETTING(    0x00, "30k 100k" )
210   PORT_DIPSETTING(    0x18, "20k 70k 70k+" )
211   PORT_DIPSETTING(    0x10, "20k 80k 80k+" )
212   PORT_DIPSETTING(    0x08, "30k 90k 90k+" )
213   PORT_DIPSETTING(    0x00, "30k 100k 100k+" )
210214   PORT_DIPNAME( 0x60, 0x40, DEF_STR( Difficulty ) )
211215   PORT_DIPSETTING(    0x60, DEF_STR( Easy ) )
212216   PORT_DIPSETTING(    0x40, DEF_STR( Normal ) )
213   PORT_DIPSETTING(    0x20, "Difficult" )
214   PORT_DIPSETTING(    0x00, "Very Difficult" )
217   PORT_DIPSETTING(    0x20, DEF_STR( Hard ) )
218   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
215219   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Demo_Sounds ) )
216220   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
217221   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
218222
223   /* 0x8001 -> 0xe021 (CPU1) = 0x3821 (CPU0) */
219224   PORT_START_TAG("DSW2")
220225   PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )
221226   PORT_DIPSETTING(    0x02, DEF_STR( 4C_1C ) )
r2375r2376
250255   PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
251256   PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
252257   PORT_DIPSETTING(    0x90, DEF_STR( 1C_7C ) )
253   PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
258//  PORT_DIPSETTING(    0x00, DEF_STR( 1C_0C ) )            "Not use"
254259INPUT_PORTS_END
255260
261static INPUT_PORTS_START( megazona )
262   PORT_INCLUDE( megazone )
256263
264   PORT_MODIFY("DSW1")
265   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
266   PORT_DIPSETTING(    0x03, "2" )
267   PORT_DIPSETTING(    0x02, "3" )
268   PORT_DIPSETTING(    0x01, "4" )
269   PORT_DIPSETTING(    0x00, "7" )
270INPUT_PORTS_END
257271
272
258273static const gfx_layout charlayout =
259274{
260275   8,8,    /* 8*8 characters */
r2375r2376
577592
578593/* these just display a Konami copyright, no logo */
579594GAME( 1983, megazone, 0,        megazone, megazone, megazone, ROT90, "Konami",                       "Mega Zone (Konami set 1)", 0 )
580GAME( 1983, megazona, megazone, megazone, megazone, megazone, ROT90, "Konami",                       "Mega Zone (Konami set 2)", 0 )
595GAME( 1983, megazona, megazone, megazone, megazona, megazone, ROT90, "Konami",                       "Mega Zone (Konami set 2)", 0 )
581596
582597/* these display Konami and Kosuka copyright, no logo */
583598GAME( 1983, megazonb, megazone, megazone, megazone, megazone, ROT90, "Konami / Kosuka",              "Mega Zone (Kosuka set 1)", 0 )
src/mame/drivers/deco156.c
r2375r2376
153153
154154static READ32_HANDLER(hvysmsh_eeprom_r)
155155{
156   return (EEPROM_read_bit()<<24) | readinputport(0) | (readinputport(1)<<16);
156   return (EEPROM_read_bit()<<24) | input_port_read_indexed(machine, 0) | (input_port_read_indexed(machine, 1)<<16);
157157}
158158
159159static WRITE32_HANDLER(hvysmsh_eeprom_w)
r2375r2376
196196
197197static READ32_HANDLER(wcvol95_eeprom_r)
198198{
199   return (EEPROM_read_bit()<<24) | readinputport(0) | ((readinputport(1)&0xff)<<16);
199   return (EEPROM_read_bit()<<24) | input_port_read_indexed(machine, 0) | ((input_port_read_indexed(machine, 1)&0xff)<<16);
200200}
201201
202202static WRITE32_HANDLER(wcvol95_eeprom_w)
src/mame/drivers/renegade.c
r2375r2376
243243   memory_set_bankptr(1, &RAM[bank ? 0x10000 : 0x4000]);
244244}
245245
246static STATE_POSTLOAD( renegade_postload )
247{
248   setbank();
249}
250
246251static MACHINE_START( renegade )
247252{
248253   state_save_register_global_array(mcu_buffer);
r2375r2376
251256   state_save_register_global(mcu_key);
252257
253258   state_save_register_global(bank);
254   state_save_register_func_postload(setbank);
259   state_save_register_postload(machine, renegade_postload, NULL);
255260}
256261
257262static DRIVER_INIT( kuniokun )
r2375r2376
489494{
490495/*
491496    static int coin;
492    int port = readinputport(1) & 0xc0;
497    int port = input_port_read_indexed(machine, 1) & 0xc0;
493498    if (port != 0xc0)
494499    {
495500        if (coin == 0)
src/mame/drivers/galaga.c
r2375r2376
716716{
717717   int bit0,bit1;
718718
719   bit0 = (readinputportbytag("DSWB") >> offset) & 1;
720   bit1 = (readinputportbytag("DSWA") >> offset) & 1;
719   bit0 = (input_port_read(machine, "DSWB") >> offset) & 1;
720   bit1 = (input_port_read(machine, "DSWA") >> offset) & 1;
721721
722722   return bit0 | (bit1 << 1);
723723}
r2375r2376
771771}
772772
773773
774static READ8_HANDLER( in0_l )   { return readinputportbytag("IN0"); }      // fire and start buttons
775static READ8_HANDLER( in0_h )   { return readinputportbytag("IN0") >> 4; }   // coins
776static READ8_HANDLER( in1_l )   { return readinputportbytag("IN1"); }      // P1 joystick
777static READ8_HANDLER( in1_h )   { return readinputportbytag("IN1") >> 4; }   // P2 joystick
778static READ8_HANDLER( dipA_l )   { return readinputportbytag("DSWA"); }      // dips A
779static READ8_HANDLER( dipA_h )   { return readinputportbytag("DSWA") >> 4; }   // dips A
780static READ8_HANDLER( dipB_l )   { return readinputportbytag("DSWB"); }      // dips B
781static READ8_HANDLER( dipB_h )   { return readinputportbytag("DSWB") >> 4; }   // dips B
774static READ8_HANDLER( in0_l )   { return input_port_read(machine, "IN0"); }      // fire and start buttons
775static READ8_HANDLER( in0_h )   { return input_port_read(machine, "IN0") >> 4; }   // coins
776static READ8_HANDLER( in1_l )   { return input_port_read(machine, "IN1"); }      // P1 joystick
777static READ8_HANDLER( in1_h )   { return input_port_read(machine, "IN1") >> 4; }   // P2 joystick
778static READ8_HANDLER( dipA_l )   { return input_port_read(machine, "DSWA"); }      // dips A
779static READ8_HANDLER( dipA_h )   { return input_port_read(machine, "DSWA") >> 4; }   // dips A
780static READ8_HANDLER( dipB_l )   { return input_port_read(machine, "DSWB"); }      // dips B
781static READ8_HANDLER( dipB_h )   { return input_port_read(machine, "DSWB") >> 4; }   // dips B
782782static WRITE8_HANDLER( out_0 )
783783{
784784   set_led_status(1,data & 1);
src/mame/drivers/macs.c
r2375r2376
9595         /*It's bit-wise*/
9696         switch(macs_mux_data&0x0f)
9797         {
98            case 0x00: return readinputportbytag("IN0");
99            case 0x01: return readinputportbytag("IN1");
100            case 0x02: return readinputportbytag("IN2");
101            case 0x04: return readinputportbytag("IN3");
102            case 0x08: return readinputportbytag("IN4");
98            case 0x00: return input_port_read(machine, "IN0");
99            case 0x01: return input_port_read(machine, "IN1");
100            case 0x02: return input_port_read(machine, "IN2");
101            case 0x04: return input_port_read(machine, "IN3");
102            case 0x08: return input_port_read(machine, "IN4");
103103            default:
104104            logerror("Unmapped mahjong panel mux data %02x\n",macs_mux_data);
105105            return 0xff;
106106         }
107107      }
108      case 1: return readinputportbytag("SYS0");
109      case 2: return readinputportbytag("DSW0");
110      case 3: return readinputportbytag("DSW1");
111      case 4: return readinputportbytag("DSW2");
112      case 5: return readinputportbytag("DSW3");
113      case 6: return readinputportbytag("DSW4");
114      case 7: return readinputportbytag("SYS1");
108      case 1: return input_port_read(machine, "SYS0");
109      case 2: return input_port_read(machine, "DSW0");
110      case 3: return input_port_read(machine, "DSW1");
111      case 4: return input_port_read(machine, "DSW2");
112      case 5: return input_port_read(machine, "DSW3");
113      case 6: return input_port_read(machine, "DSW4");
114      case 7: return input_port_read(machine, "SYS1");
115115      default:    popmessage("Unmapped I/O read at PC = %06x offset = %02x",activecpu_get_pc(),offset+0xc0);
116116   }
117117
src/mame/drivers/sbowling.c
r2375r2376
177177static READ8_HANDLER (controls_r)
178178{
179179   if(sbw_system&2)
180      return input_port_2_r(machine,0);
180      return input_port_read_indexed(machine, 2);
181181   else
182      return input_port_3_r(machine,0);
182      return input_port_read_indexed(machine, 3);
183183}
184184
185185static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
src/mame/drivers/taito_h.c
r2375r2376
205205   switch( port )
206206   {
207207      case 0x08:            /* trackball y coords bottom 8 bits for 2nd player */
208         return readinputportbytag(P2TRACKY_PORT_TAG);
208         return input_port_read(machine, P2TRACKY_PORT_TAG);
209209
210210      case 0x09:            /* trackball y coords top 8 bits for 2nd player */
211         if (readinputportbytag(P2TRACKY_PORT_TAG) & 0x80)   /* y- direction (negative value) */
211         if (input_port_read(machine, P2TRACKY_PORT_TAG) & 0x80)   /* y- direction (negative value) */
212212            return 0xff;
213213         else                                    /* y+ direction (positive value) */
214214            return 0x00;
215215
216216      case 0x0a:            /* trackball x coords bottom 8 bits for 2nd player */
217         return readinputportbytag(P2TRACKX_PORT_TAG);
217         return input_port_read(machine, P2TRACKX_PORT_TAG);
218218
219219      case 0x0b:            /* trackball x coords top 8 bits for 2nd player */
220         if (readinputportbytag(P2TRACKX_PORT_TAG) & 0x80)   /* x- direction (negative value) */
220         if (input_port_read(machine, P2TRACKX_PORT_TAG) & 0x80)   /* x- direction (negative value) */
221221            return 0xff;
222222         else                                    /* x+ direction (positive value) */
223223            return 0x00;
224224
225225      case 0x0c:            /* trackball y coords bottom 8 bits for 1st player */
226         return readinputportbytag(P1TRACKY_PORT_TAG);
226         return input_port_read(machine, P1TRACKY_PORT_TAG);
227227
228228      case 0x0d:            /* trackball y coords top 8 bits for 1st player */
229         if (readinputportbytag(P1TRACKY_PORT_TAG) & 0x80)   /* y- direction (negative value) */
229         if (input_port_read(machine, P1TRACKY_PORT_TAG) & 0x80)   /* y- direction (negative value) */
230230            return 0xff;
231231         else                                    /* y+ direction (positive value) */
232232            return 0x00;
233233
234234      case 0x0e:            /* trackball x coords bottom 8 bits for 1st player */
235         return readinputportbytag(P1TRACKX_PORT_TAG);
235         return input_port_read(machine, P1TRACKX_PORT_TAG);
236236
237237      case 0x0f:            /* trackball x coords top 8 bits for 1st player */
238         if (readinputportbytag(P1TRACKX_PORT_TAG) & 0x80)   /* x- direction (negative value) */
238         if (input_port_read(machine, P1TRACKX_PORT_TAG) & 0x80)   /* x- direction (negative value) */
239239            return 0xff;
240240         else                                    /* x+ direction (positive value) */
241241            return 0x00;
r2375r2376
566566GFXDECODE_END
567567
568568
569static STATE_POSTLOAD( taitoh_postload )
570{
571   reset_sound_region();
572}
573
569574static MACHINE_START( taitoh )
570575{
571576   state_save_register_global(banknum);
572   state_save_register_func_postload(reset_sound_region);
577   state_save_register_postload(machine, taitoh_postload, NULL);
573578}
574579
575580
src/mame/drivers/8080bw.c
r2375r2376
892892static READ8_HANDLER( sfl_input_r )
893893{
894894   sfl_int^=0x80;//vblank flag ?
895   return sfl_int|input_port_1_r(machine,0);
895   return sfl_int|input_port_read_indexed(machine, 1);
896896}
897897
898898static ADDRESS_MAP_START( sflush_map, ADDRESS_SPACE_PROGRAM, 8 )
src/mame/drivers/othunder.c
r2375r2376
416416static READ16_HANDLER( othunder_lightgun_r )
417417{
418418   static const char *const dswname[4] = { P1X_PORT_TAG, P1Y_PORT_TAG, P2X_PORT_TAG, P2Y_PORT_TAG };
419   return readinputportbytag(dswname[offset]);
419   return input_port_read(machine, dswname[offset]);
420420}
421421
422422static WRITE16_HANDLER( othunder_lightgun_w )
r2375r2376
441441   memory_set_bankptr( 10, memory_region(REGION_CPU2) + (banknum * 0x4000) + 0x10000 );
442442}
443443
444static STATE_POSTLOAD( othunder_postload )
445{
446   reset_sound_region();
447}
448
444449static MACHINE_START( othunder )
445450{
446451   state_save_register_global(banknum);
447   state_save_register_func_postload(reset_sound_region);
452   state_save_register_postload(machine, othunder_postload, NULL);
448453}
449454
450455
src/mame/drivers/m79amb.c
r2375r2376
111111
112112static READ8_HANDLER( gray5bit_controller0_r )
113113{
114    return (input_port_2_r(machine,0) & 0xe0) | (~ControllerTable[input_port_2_r(machine,0) & 0x1f] & 0x1f);
114    return (input_port_read_indexed(machine, 2) & 0xe0) | (~ControllerTable[input_port_read_indexed(machine, 2) & 0x1f] & 0x1f);
115115}
116116
117117static READ8_HANDLER( gray5bit_controller1_r )
118118{
119    return (input_port_3_r(machine,0) & 0xe0) | (~ControllerTable[input_port_3_r(machine,0) & 0x1f] & 0x1f);
119    return (input_port_read_indexed(machine, 3) & 0xe0) | (~ControllerTable[input_port_read_indexed(machine, 3) & 0x1f] & 0x1f);
120120}
121121
122122static WRITE8_HANDLER( sound_w )
src/mame/drivers/meritm.c
r2375r2376
261261   }
262262
263263   // send format tablet packet
264   if ( readinputportbytag("TOUCH") & 0x01 )
264   if ( input_port_read(machine, "TOUCH") & 0x01 )
265265   {
266      int tx = readinputportbytag("TOUCH_X");
267      int ty = readinputportbytag("TOUCH_Y");
266      int tx = input_port_read(machine, "TOUCH_X");
267      int ty = input_port_read(machine, "TOUCH_Y");
268268
269269      if ( microtouch.touch_callback == NULL ||
270270          microtouch.touch_callback( &tx, &ty ) != 0 )
r2375r2376
864864
865865static READ8_HANDLER(meritm_ay8930_port_a_r)
866866{
867   return readinputportbytag_safe("DSW", 0);
867   return input_port_read_safe(machine, "DSW", 0);
868868};
869869
870870static WRITE8_HANDLER(meritm_ay8930_port_b_w)
r2375r2376
922922
923923static READ8_HANDLER(meritm_io_pio_port_a_r)
924924{
925   return readinputportbytag("PIO1_PORTA");
925   return input_port_read(machine, "PIO1_PORTA");
926926};
927927
928928static READ8_HANDLER(meritm_io_pio_port_b_r)
929929{
930   return readinputportbytag("PIO1_PORTB");
930   return input_port_read(machine, "PIO1_PORTB");
931931};
932932
933933static WRITE8_HANDLER(meritm_io_pio_port_a_w)
src/mame/drivers/slapshot.c
r2375r2376
212212
213213static READ16_HANDLER( opwolf3_adc_r )
214214{
215   return readinputport(6 + offset)<<8;
215   return input_port_read_indexed(machine, 6 + offset)<<8;
216216}
217217
218218static WRITE16_HANDLER( opwolf3_adc_req_w )
r2375r2376
232232   memory_set_bankptr( 10, memory_region(REGION_CPU2) + (banknum * 0x4000) + 0x10000 );
233233}
234234
235static STATE_POSTLOAD( slapshot_postload )
236{
237   reset_sound_region();
238}
239
235240static MACHINE_START( slapshot )
236241{
237242   state_save_register_global(banknum);
238   state_save_register_func_postload(reset_sound_region);
243   state_save_register_postload(machine, slapshot_postload, NULL);
239244}
240245
241246
src/mame/drivers/ertictac.c
r2375r2376
4242
4343static READ32_HANDLER(IOCR_r)
4444{
45   return (input_port_5_r(machine,0)&0x80)|0x34;
45   return (input_port_read_indexed(machine, 5)&0x80)|0x34;
4646}
4747
4848static WRITE32_HANDLER(IOCR_w)
src/mame/drivers/xyonix.c
r2375r2376
4343
4444static int e0_data,credits,coins;
4545
46static void handle_coins(int coin)
46static void handle_coins(running_machine *machine, int coin)
4747{
4848   static const int coinage_table[4][2] = {{2,3},{2,1},{1,2},{1,1}};
4949   int tmp = 0;
r2375r2376
5252
5353   if (coin & 1)   // Coin 2 !
5454   {
55      tmp = (readinputport(2) & 0xc0) >> 6;
55      tmp = (input_port_read_indexed(machine, 2) & 0xc0) >> 6;
5656      coins++;
5757      if (coins >= coinage_table[tmp][0])
5858      {
r2375r2376
6565
6666   if (coin & 2)   // Coin 1 !
6767   {
68      tmp = (readinputport(2) & 0x30) >> 4;
68      tmp = (input_port_read_indexed(machine, 2) & 0x30) >> 4;
6969      coins++;
7070      if (coins >= coinage_table[tmp][0])
7171      {
r2375r2376
9999      switch (e0_data)
100100      {
101101         case 0x81 :
102            return readinputport(0) & 0x7f;
102            return input_port_read_indexed(machine, 0) & 0x7f;
103103            break;
104104         case 0x82 :
105            return readinputport(1) & 0x7f;
105            return input_port_read_indexed(machine, 1) & 0x7f;
106106            break;
107107         case 0x91:
108108            /* check coin inputs */
109            coin = ((readinputport(0) & 0x80) >> 7) | ((readinputport(1) & 0x80) >> 6);
109            coin = ((input_port_read_indexed(machine, 0) & 0x80) >> 7) | ((input_port_read_indexed(machine, 1) & 0x80) >> 6);
110110            if (coin ^ prev_coin && coin != 3)
111111            {
112               if (credits < 9) handle_coins(coin);
112               if (credits < 9) handle_coins(machine, coin);
113113            }
114114            prev_coin = coin;
115115            return credits;
116116            break;
117117         case 0x92:
118            return ((readinputport(0) & 0x80) >> 7) | ((readinputport(1) & 0x80) >> 6);
118            return ((input_port_read_indexed(machine, 0) & 0x80) >> 7) | ((input_port_read_indexed(machine, 1) & 0x80) >> 6);
119119            break;
120120         case 0xe0:   /* reset? */
121121            coins = 0;
r2375r2376
127127            return 0xff;
128128            break;
129129         case 0xfe:   /* Dip Switches 1 to 4 */
130            return readinputport(2) & 0x0f;
130            return input_port_read_indexed(machine, 2) & 0x0f;
131131            break;
132132         case 0xff:   /* Dip Switches 5 to 8 */
133            return readinputport(2) >> 4;
133            return input_port_read_indexed(machine, 2) >> 4;
134134            break;
135135      }
136136   }
src/mame/drivers/cninja.c
r2375r2376
133133   logerror("%08x:  Unmapped IRQ write %d %04x\n",activecpu_get_pc(),offset,data);
134134}
135135
136static READ16_HANDLER( robocop2_dip3_r ) { return readinputport(3); }
136static READ16_HANDLER( robocop2_dip3_r ) { return input_port_read_indexed(machine, 3); }
137137
138138static READ16_HANDLER( robocop2_prot_r )
139139{
140140    switch (offset<<1) {
141141      case 0x41a: /* Player 1 & 2 input ports */
142         return readinputport(0);
142         return input_port_read_indexed(machine, 0);
143143      case 0x320: /* Coins */
144         return readinputport(1);
144         return input_port_read_indexed(machine, 1);
145145      case 0x4e6: /* Dip switches */
146         return readinputport(2);
146         return input_port_read_indexed(machine, 2);
147147      case 0x504: /* PC: 6b6.  b4, 2c, 36 written before read */
148148         logerror("Protection PC %06x: warning - read unmapped memory address %04x\n",activecpu_get_pc(),offset);
149149         return 0x84;
src/mame/drivers/pacland.c
r2375r2376
210210{
211211   int shift = 4 * (offset & 1);
212212   int port = offset & 2;
213   int r = ( readinputport( port+0 ) << shift ) & 0xf0;
214   r |= ( readinputport( port+1 ) >> (4-shift) ) & 0x0f;
213   int r = ( input_port_read_indexed(machine,  port+0 ) << shift ) & 0xf0;
214   r |= ( input_port_read_indexed(machine,  port+1 ) >> (4-shift) ) & 0x0f;
215215   return r;
216216}
217217
src/mame/drivers/psikyo4.c
r2375r2376
221221
222222//  logerror("Unk EEPROM read mask %x\n", mem_mask);
223223
224   return readinputportbytag("JP4")<<16;
224   return input_port_read(machine, "JP4")<<16;
225225}
226226
227227static INTERRUPT_GEN(psikyosh_interrupt)
r2375r2376
234234   int ret = 0xff;
235235   int sel = (ps4_io_select[0] & 0x0000ff00) >> 8;
236236
237   if (sel & 1) ret &= readinputport(0+4*offset);
238   if (sel & 2) ret &= readinputport(1+4*offset);
239   if (sel & 4) ret &= readinputport(2+4*offset);
240   if (sel & 8) ret &= readinputport(3+4*offset);
237   if (sel & 1) ret &= input_port_read_indexed(machine, 0+4*offset);
238   if (sel & 2) ret &= input_port_read_indexed(machine, 1+4*offset);
239   if (sel & 4) ret &= input_port_read_indexed(machine, 2+4*offset);
240   if (sel & 8) ret &= input_port_read_indexed(machine, 3+4*offset);
241241
242   return ret<<24 | readinputport(8);
242   return ret<<24 | input_port_read_indexed(machine, 8);
243243}
244244
245245static READ32_HANDLER(ps4_io32_r) /* used by loderndf/hotdebut */
246246{
247   return ((readinputport(0+4*offset) << 24) | (readinputport(1+4*offset) << 16) | (readinputport(2+4*offset) << 8) | (readinputport(3+4*offset) << 0));
247   return ((input_port_read_indexed(machine, 0+4*offset) << 24) | (input_port_read_indexed(machine, 1+4*offset) << 16) | (input_port_read_indexed(machine, 2+4*offset) << 8) | (input_port_read_indexed(machine, 3+4*offset) << 0));
248248}
249249
250250static WRITE32_HANDLER( ps4_paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w )
r2375r2376
10681068   return ps4_ram[0x00001c/4];
10691069}
10701070
1071static void install_hotgmck_pcm_bank(void)
1071static STATE_POSTLOAD( hotgmck_pcm_bank_postload )
10721072{
1073   set_hotgmck_pcm_bank((FPTR)param);
1074}
1075
1076static void install_hotgmck_pcm_bank(running_machine *machine)
1077{
10731078   UINT8 *ymf_pcm = memory_region(REGION_SOUND1);
10741079   UINT8 *pcm_rom = memory_region(REGION_SOUND2);
10751080
r2375r2376
10801085   set_hotgmck_pcm_bank(1);
10811086
10821087   memory_install_write32_handler(0, ADDRESS_SPACE_PROGRAM, 0x5800008, 0x580000b, 0, 0, hotgmck_pcm_bank_w );
1083   state_save_register_func_postload_int(set_hotgmck_pcm_bank, 0);
1084   state_save_register_func_postload_int(set_hotgmck_pcm_bank, 1);
1088   state_save_register_postload(machine, hotgmck_pcm_bank_postload, (void *)0);
1089   state_save_register_postload(machine, hotgmck_pcm_bank_postload, (void *)1);
10851090}
10861091
10871092static DRIVER_INIT( hotgmck )
r2375r2376
10891094   UINT8 *RAM = memory_region(REGION_CPU1);
10901095   memory_set_bankptr(1,&RAM[0x100000]);
10911096   memory_install_read32_handler(0, ADDRESS_SPACE_PROGRAM, 0x5800000, 0x5800007, 0, 0, hotgmck_io32_r ); // Different Inputs
1092   install_hotgmck_pcm_bank();   // Banked PCM ROM
1097   install_hotgmck_pcm_bank(machine);   // Banked PCM ROM
10931098}
10941099
10951100static DRIVER_INIT( loderndf )
src/mame/drivers/wardner.c
r2375r2376
172172   }
173173}
174174
175void wardner_restore_bank(void)
175STATE_POSTLOAD( wardner_restore_bank )
176176{
177177   wardner_ramrom_bank_sw(Machine,0,1);   /* Dummy value to ensure restoration */
178178   wardner_ramrom_bank_sw(Machine,0,wardner_membank);
r2375r2376
674674
675675static DRIVER_INIT( wardner )
676676{
677   wardner_driver_savestate();   /* Save-State stuff in src/machine/twincobr.c */
677   wardner_driver_savestate(machine);   /* Save-State stuff in src/machine/twincobr.c */
678678}
679679
680680
src/mame/drivers/jcross.c
r2375r2376
7373
7474static READ8_HANDLER( jcross_port_0_r )
7575{
76   return(input_port_0_r(machine,0) | sound_cpu_busy);
76   return(input_port_read_indexed(machine, 0) | sound_cpu_busy);
7777}
7878
7979static WRITE8_HANDLER(jcross_vregs0_w){jcross_vregs[0]=data;}
src/mame/drivers/mirage.c
r2375r2376
133133
134134static READ16_HANDLER( mirage_controls_r )
135135{
136   return readinputportbytag("SYSTEM_IN");
136   return input_port_read(machine, "SYSTEM_IN");
137137}
138138
139139static READ16_HANDLER( random_readers )
r2375r2376
143143
144144static READ16_HANDLER( mirage_input_r )
145145{
146   UINT16 port = readinputportbytag("MIRAGE0");
146   UINT16 port = input_port_read(machine, "MIRAGE0");
147147   return port;
148148}
149149
src/mame/drivers/missile.c
r2375r2376
658658      if (ctrld)   /* trackball */
659659      {
660660         if (!flipscreen)
661               result = ((readinputport(5) << 4) & 0xf0) | (readinputport(4) & 0x0f);
661               result = ((input_port_read_indexed(machine, 5) << 4) & 0xf0) | (input_port_read_indexed(machine, 4) & 0x0f);
662662         else
663               result = ((readinputport(7) << 4) & 0xf0) | (readinputport(6) & 0x0f);
663               result = ((input_port_read_indexed(machine, 7) << 4) & 0xf0) | (input_port_read_indexed(machine, 6) & 0x0f);
664664      }
665665      else   /* buttons */
666         result = readinputport(0);
666         result = input_port_read_indexed(machine, 0);
667667   }
668668
669669   /* IN1 */
670670   else if (offset < 0x4a00)
671      result = readinputport(1);
671      result = input_port_read_indexed(machine, 1);
672672
673673   /* IN2 */
674674   else if (offset < 0x4b00)
675      result = readinputport(2);
675      result = input_port_read_indexed(machine, 2);
676676
677677   /* anything else */
678678   else
src/mame/drivers/popper.c
r2375r2376
136136   switch (offset)
137137   {
138138      //           player inputs        dsw1                           dsw2
139      case 0: data=readinputport(0) | ((readinputport(4)&0x02)<<5) | ((readinputport(5)&0x01)<<4); break;
140      case 1: data=readinputport(1) | ((readinputport(4)&0x01)<<6) | ((readinputport(5)&0x02)<<3); break;
141      case 2: data=readinputport(2) | ((readinputport(4)&0x08)<<3) | ((readinputport(5)&0x04)<<2); break;
142      case 3: data=readinputport(3) | ((readinputport(4)&0x04)<<4) | ((readinputport(5)&0x08)<<1); break;
143      case 4: data=                   ((readinputport(4)&0x20)<<2) | ((readinputport(5)&0x10)<<1); break;
144      case 5: data=                   ((readinputport(4)&0x10)<<3) | ((readinputport(5)&0x20)<<0); break;
145      case 6: data=                   ((readinputport(4)&0x80)<<0) | ((readinputport(5)&0x40)>>1); break;
146      case 7: data=                   ((readinputport(4)&0x40)<<1) | ((readinputport(5)&0x80)>>2); break;
139      case 0: data=input_port_read_indexed(machine, 0) | ((input_port_read_indexed(machine, 4)&0x02)<<5) | ((input_port_read_indexed(machine, 5)&0x01)<<4); break;
140      case 1: data=input_port_read_indexed(machine, 1) | ((input_port_read_indexed(machine, 4)&0x01)<<6) | ((input_port_read_indexed(machine, 5)&0x02)<<3); break;
141      case 2: data=input_port_read_indexed(machine, 2) | ((input_port_read_indexed(machine, 4)&0x08)<<3) | ((input_port_read_indexed(machine, 5)&0x04)<<2); break;
142      case 3: data=input_port_read_indexed(machine, 3) | ((input_port_read_indexed(machine, 4)&0x04)<<4) | ((input_port_read_indexed(machine, 5)&0x08)<<1); break;
143      case 4: data=                   ((input_port_read_indexed(machine, 4)&0x20)<<2) | ((input_port_read_indexed(machine, 5)&0x10)<<1); break;
144      case 5: data=                   ((input_port_read_indexed(machine, 4)&0x10)<<3) | ((input_port_read_indexed(machine, 5)&0x20)<<0); break;
145      case 6: data=                   ((input_port_read_indexed(machine, 4)&0x80)<<0) | ((input_port_read_indexed(machine, 5)&0x40)>>1); break;
146      case 7: data=                   ((input_port_read_indexed(machine, 4)&0x40)<<1) | ((input_port_read_indexed(machine, 5)&0x80)>>2); break;
147147   }
148148   return data;
149149}
src/mame/drivers/djboy.c
r2375r2376
225225} /* ProtectionOut */
226226
227227static int
228GetLives( void )
228GetLives( running_machine *machine )
229229{
230   int dsw = readinputport(4);
230   int dsw = input_port_read_indexed(machine, 4);
231231   switch( dsw&0x30 )
232232   {
233233   case 0x10: return 3;
r2375r2376
240240
241241static WRITE8_HANDLER( coinplus_w )
242242{
243   int dsw = readinputport(3);
243   int dsw = input_port_read_indexed(machine, 3);
244244   coin_counter_w( 0, data&1 );
245245   coin_counter_w( 1, data&2 );
246246   if( data&1 )
r2375r2376
268268} /* coinplus_w */
269269
270270static void
271OutputProtectionState( int i, int type )
271OutputProtectionState( running_machine *machine, int i, int type )
272272{
273   int io = ~readinputport(0);
273   int io = ~input_port_read_indexed(machine, 0);
274274   int dat = 0x00;
275275
276276   switch( mDjBoyState )
r2375r2376
337337      { /* p1 start */
338338         dat = 0x16;
339339         mDjBoyState = eDJBOY_ACTIVE_GAMEPLAY;
340         lives[0] = GetLives();
340         lives[0] = GetLives(machine);
341341         logerror( "P1 START!\n" );
342342         coin-=4;
343343      }
r2375r2376
345345      { /* p2 start */
346346         dat = 0x0a;
347347         mDjBoyState = eDJBOY_ACTIVE_GAMEPLAY;
348         lives[0] = GetLives();
349         lives[1] = GetLives();
348         lives[0] = GetLives(machine);
349         lives[1] = GetLives(machine);
350350         logerror( "P2 START!\n" );
351351         coin-=8;
352352      }
r2375r2376
364364         if( (io&1) && lives[0]==0 )
365365         {
366366            dat = 0x12; /* continue (P1) */
367            lives[0] = GetLives();
367            lives[0] = GetLives(machine);
368368            mDjBoyState = eDJBOY_ACTIVE_GAMEPLAY;
369369            coin-=4;
370370            logerror( "P1 CONTINUE!\n" );
r2375r2376
372372         else if( (io&2) && lives[1]==0 )
373373         {
374374            dat = 0x08; /* continue (P2) */
375            lives[1] = GetLives();
375            lives[1] = GetLives(machine);
376376            mDjBoyState = eDJBOY_ACTIVE_GAMEPLAY;
377377            coin-=4;
378378            logerror( "P2 CONTINUE!\n" );
r2375r2376
385385} /* OutputProtectionState */
386386
387387static void
388CommonProt( int i, int type )
388CommonProt( running_machine *machine, int i, int type )
389389{
390390   int displayedCredits = coin/4;
391391   if( displayedCredits>9 )
r2375r2376
393393      displayedCredits = 9;
394394   }
395395   ProtectionOut( i++, displayedCredits );
396   ProtectionOut( i++, readinputport(0) ); /* COIN/START */
397   OutputProtectionState( i, type );
396   ProtectionOut( i++, input_port_read_indexed(machine, 0) ); /* COIN/START */
397   OutputProtectionState( machine, i, type );
398398} /* CommonProt */
399399
400400static WRITE8_HANDLER( beast_data_w )
r2375r2376
408408   if( prot_mode == ePROT_WAIT_DSW1_WRITEBACK )
409409   {
410410      logerror( "[DSW1_WRITEBACK]\n" );
411      ProtectionOut( 0, readinputport(4) ); /* DSW2 */
411      ProtectionOut( 0, input_port_read_indexed(machine, 4) ); /* DSW2 */
412412      prot_mode = ePROT_WAIT_DSW2_WRITEBACK;
413413   }
414414   else if( prot_mode == ePROT_WAIT_DSW2_WRITEBACK )
r2375r2376
454454         break;
455455
456456      case 0x01: // pc=7389
457         OutputProtectionState( 0, 0x01 );
457         OutputProtectionState( machine, 0, 0x01 );
458458         break;
459459
460460      case 0x02:
461         CommonProt( 0,0x02 );
461         CommonProt( machine,0,0x02 );
462462         break;
463463
464464      case 0x03: /* prepare for memory write to protection device ram (pc == 0x7987) */ // -> 0x02
r2375r2376
472472         ProtectionOut( 1,0 ); // ?
473473         ProtectionOut( 2,0 ); // ?
474474         ProtectionOut( 3,0 ); // ?
475         CommonProt(    4,0x04 );
475         CommonProt(    machine, 4,0x04 );
476476         break;
477477
478478      case 0x05: /* 0x71f4 */
479         ProtectionOut( 0,readinputport(1) ); // to $42
479         ProtectionOut( 0,input_port_read_indexed(machine, 1) ); // to $42
480480         ProtectionOut( 1,0 ); // ?
481         ProtectionOut( 2,readinputport(2) ); // to $43
481         ProtectionOut( 2,input_port_read_indexed(machine, 2) ); // to $43
482482         ProtectionOut( 3,0 ); // ?
483483         ProtectionOut( 4,0 ); // ?
484         CommonProt(    5,0x05 );
484         CommonProt(    machine, 5,0x05 );
485485         break;
486486
487487      case 0x07:
488         CommonProt( 0,0x07 );
488         CommonProt( machine, 0,0x07 );
489489         break;
490490
491491      case 0x08: /* pc == 0x727a */
492         ProtectionOut( 0,readinputport(0) ); /* COIN/START */
493         ProtectionOut( 1,readinputport(1) ); /* JOY1 */
494         ProtectionOut( 2,readinputport(2) ); /* JOY2 */
495         ProtectionOut( 3,readinputport(3) ); /* DSW1 */
496         ProtectionOut( 4,readinputport(4) ); /* DSW2 */
497         CommonProt(    5, 0x08 );
492         ProtectionOut( 0,input_port_read_indexed(machine, 0) ); /* COIN/START */
493         ProtectionOut( 1,input_port_read_indexed(machine, 1) ); /* JOY1 */
494         ProtectionOut( 2,input_port_read_indexed(machine, 2) ); /* JOY2 */
495         ProtectionOut( 3,input_port_read_indexed(machine, 3) ); /* DSW1 */
496         ProtectionOut( 4,input_port_read_indexed(machine, 4) ); /* DSW2 */
497         CommonProt(    machine, 5, 0x08 );
498498         break;
499499
500500      case 0x09:
501501         ProtectionOut( 0,0 ); // ?
502502         ProtectionOut( 1,0 ); // ?
503503         ProtectionOut( 2,0 ); // ?
504         CommonProt(    3, 0x09 );
504         CommonProt(    machine, 3, 0x09 );
505505         break;
506506
507507      case 0x0a:
508         CommonProt( 0,0x0a );
508         CommonProt( machine,0,0x0a );
509509         break;
510510
511511      case 0x0c:
512         CommonProt( 1,0x0c );
512         CommonProt( machine,1,0x0c );
513513         break;
514514
515515      case 0x0d:
516         CommonProt( 2,0x0d );
516         CommonProt( machine,2,0x0d );
517517         break;
518518
519519      case 0xfe: /* prepare for memory read from protection device ram (pc == 0x79ee, 0x7a3f) */
r2375r2376
531531         break;
532532
533533      case 0xff: /* read DSW (pc == 0x714d) */
534         ProtectionOut( 0,readinputport(3) ); /* DSW1 */
534         ProtectionOut( 0,input_port_read_indexed(machine, 3) ); /* DSW1 */
535535         prot_mode = ePROT_WAIT_DSW1_WRITEBACK;
536536         break;
537537
src/mame/drivers/sidearms.c
r2375r2376
7979
8080   res = 0;
8181   for (i = 0;i < 8;i++)
82      res |= ((readinputport(i) >> offset) & 1) << i;
82      res |= ((input_port_read_indexed(machine, i) >> offset) & 1) << i;
8383
8484   return res;
8585}
src/mame/drivers/taito_x.c
r2375r2376
332332   switch (offset)
333333   {
334334      case 0x00:
335         return  readinputportbytag("DSWA") & 0x0f;
335         return  input_port_read(machine, "DSWA") & 0x0f;
336336      case 0x01:
337         return (readinputportbytag("DSWA") & 0xf0) >> 4;
337         return (input_port_read(machine, "DSWA") & 0xf0) >> 4;
338338      case 0x02:
339         return  readinputportbytag("DSWB") & 0x0f;
339         return  input_port_read(machine, "DSWB") & 0x0f;
340340      case 0x03:
341         return (readinputportbytag("DSWB") & 0xf0) >> 4;
341         return (input_port_read(machine, "DSWB") & 0xf0) >> 4;
342342      default:
343343         logerror("taitox unknown dsw read offset: %04x\n", offset);
344344         return 0x00;
r2375r2376
350350   switch (offset)
351351   {
352352      case 0x00:
353         return readinputportbytag("IN0");    /* Player 1 controls + START1 */
353         return input_port_read(machine, "IN0");    /* Player 1 controls + START1 */
354354      case 0x01:
355         return readinputportbytag("IN1");    /* Player 2 controls + START2 */
355         return input_port_read(machine, "IN1");    /* Player 2 controls + START2 */
356356      case 0x02:
357         return readinputportbytag("IN2");    /* COINn + SERVICE1 + TILT */
357         return input_port_read(machine, "IN2");    /* COINn + SERVICE1 + TILT */
358358
359359      default:
360360         logerror("taitox unknown input read offset: %04x\n", offset);
r2375r2376
995995   irqhandler
996996};
997997
998static STATE_POSTLOAD( taitox_postload )
999{
1000   reset_sound_region();
1001}
9981002
9991003static MACHINE_START( taitox )
10001004{
10011005   state_save_register_global(banknum);
1002   state_save_register_func_postload(reset_sound_region);
1006   state_save_register_postload(machine, taitox_postload, NULL);
10031007}
10041008
10051009/**************************************************************************/
src/mame/drivers/jack.c
r2375r2376
8989
9090static READ8_HANDLER( joinem_input1_r )
9191{
92   UINT8 ret = readinputport(1) & ~0x20;
92   UINT8 ret = input_port_read_indexed(machine, 1) & ~0x20;
9393
94   if((readinputport(4) & 0x80) && !joinem_snd_bit)
94   if((input_port_read_indexed(machine, 4) & 0x80) && !joinem_snd_bit)
9595      ret |= 0x20;
9696
9797   return ret;
r2375r2376
918918      cpunum_set_input_line(machine, 0, 0, HOLD_LINE);
919919   else
920920   {
921      if(!(readinputport(4) & 0x80))
921      if(!(input_port_read_indexed(machine, 4) & 0x80))
922922         cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
923923   }
924924}
src/mame/drivers/tumblep.c
r2375r2376
9191    switch (offset<<1)
9292   {
9393      case 0: /* Player 1 & Player 2 joysticks & fire buttons */
94         return (readinputport(0) + (readinputport(1) << 8));
94         return (input_port_read_indexed(machine, 0) + (input_port_read_indexed(machine, 1) << 8));
9595      case 2: /* Dips */
96         return (readinputport(3) + (readinputport(4) << 8));
96         return (input_port_read_indexed(machine, 3) + (input_port_read_indexed(machine, 4) << 8));
9797      case 8: /* Credits */
98         return readinputport(2);
98         return input_port_read_indexed(machine, 2);
9999      case 10: /* ? */
100100      case 12:
101101           return 0;
src/mame/drivers/taitosj.c
r2375r2376
337337      port_tag = "GEARP2";
338338
339339   /* gear MUST be 1, 2 or 3 */
340   if (readinputportbytag(port_tag) & 0x01) kikstart_gears[player] = 0x02;
341   if (readinputportbytag(port_tag) & 0x02) kikstart_gears[player] = 0x03;
342   if (readinputportbytag(port_tag) & 0x04) kikstart_gears[player] = 0x01;
340   if (input_port_read(machine, port_tag) & 0x01) kikstart_gears[player] = 0x02;
341   if (input_port_read(machine, port_tag) & 0x02) kikstart_gears[player] = 0x03;
342   if (input_port_read(machine, port_tag) & 0x04) kikstart_gears[player] = 0x01;
343343
344344   return kikstart_gears[player];
345345}
r2375r2376
552552   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
553553   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
554554   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
555   PORT_DIPNAME( 0x18, 0x18, DEF_STR( Lives ) )
555   PORT_DIPNAME( 0x18, 0x00, DEF_STR( Lives ) )
556556   PORT_DIPSETTING(    0x00, "3" )
557557   PORT_DIPSETTING(    0x08, "4" )
558558   PORT_DIPSETTING(    0x10, "5" )
r2375r2376
561561   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
562562   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
563563   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
564   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Cabinet ) )
565   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
566   PORT_DIPSETTING(    0x80, DEF_STR( Cocktail ) )
564   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) )
565   PORT_DIPSETTING(    0x80, DEF_STR( Upright ) )
566   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
567567
568568   PORT_START_TAG("DSW2")      /* Coinage */
569569   DSW2_PORT
r2375r2376
26472647   state_save_register_global(dac_vol);
26482648}
26492649
2650GAME( 1981, spaceskr, 0,        nomcu,    spaceskr,   0,       ROT180, "Taito Corporation", "Space Seeker", GAME_SUPPORTS_SAVE )
2650GAME( 1981, spaceskr, 0,        nomcu,    spaceskr,   0,       ROT0,  "Taito Corporation", "Space Seeker", GAME_SUPPORTS_SAVE )
26512651GAME( 1981, spacecr,  0,        nomcu,    spacecr,    spacecr, ROT90,  "Taito Corporation", "Space Cruiser", GAME_SUPPORTS_SAVE )
26522652GAME( 1982, junglek,  0,        nomcu,    junglek,    0,       ROT180, "Taito Corporation", "Jungle King (Japan)", GAME_SUPPORTS_SAVE )
26532653GAME( 1982, junglkj2, junglek,  nomcu,    junglek,    0,       ROT180, "Taito Corporation", "Jungle King (Japan, earlier)", GAME_SUPPORTS_SAVE )
src/mame/drivers/canyon.c
r2375r2376
6464{
6565   UINT8 val = 0;
6666
67   if ((readinputport(2) >> (offset & 7)) & 1)
67   if ((input_port_read_indexed(machine, 2) >> (offset & 7)) & 1)
6868   {
6969      val |= 0x80;
7070   }
71   if ((readinputport(1) >> (offset & 3)) & 1)
71   if ((input_port_read_indexed(machine, 1) >> (offset & 3)) & 1)
7272   {
7373      val |= 0x01;
7474   }
r2375r2376
7979
8080static READ8_HANDLER( canyon_options_r )
8181{
82   return (readinputport(0) >> (2 * (~offset & 3))) & 3;
82   return (input_port_read_indexed(machine, 0) >> (2 * (~offset & 3))) & 3;
8383}
8484
8585
src/mame/drivers/ettrivia.c
r2375r2376
220220
221221static INTERRUPT_GEN( ettrivia_interrupt )
222222{
223   if( readinputport(2) & 0x01 )
223   if( input_port_read_indexed(machine, 2) & 0x01 )
224224      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
225225   else
226226      cpunum_set_input_line(machine, 0, 0, HOLD_LINE);
src/mame/drivers/jalmah.c
r2375r2376
195195}
196196
197197#define MCU_READ(_number_,_bit_,_offset_,_retval_)\
198if((0xffff - readinputport(_number_)) & _bit_) { jm_regs[_offset_] = _retval_; }
198if((0xffff - input_port_read_indexed(machine, _number_)) & _bit_) { jm_regs[_offset_] = _retval_; }
199199
200200/*RAM-based protection handlings*/
201201static void daireika_mcu_run(running_machine *machine)
src/mame/drivers/lvcards.c
r2375r2376
136136
137137static READ8_HANDLER( payout_r )
138138{
139   result = readinputport(2);
139   result = input_port_read_indexed(machine, 2);
140140
141141   if (payout)
142142   {
src/mame/drivers/route16.c
r2375r2376
174174
175175   switch (ttmahjng_port_select)
176176   {
177   case 1:  ret = readinputport(2); break;
178   case 2:  ret = readinputport(3); break;
179   case 4:  ret = readinputport(4); break;
180   case 8:  ret = readinputport(5); break;
177   case 1:  ret = input_port_read_indexed(machine, 2); break;
178   case 2:  ret = input_port_read_indexed(machine, 3); break;
179   case 4:  ret = input_port_read_indexed(machine, 4); break;
180   case 8:  ret = input_port_read_indexed(machine, 5); break;
181181   default: break;
182182   }
183183
src/mame/drivers/polyplay.c
r2375r2376
148148{
149149   static int last = 0;
150150
151   if (readinputport(0) & 0x80)
151   if (input_port_read_indexed(machine, 0) & 0x80)
152152      last = 0;
153153   else
154154   {
src/mame/drivers/exidy440.c
r2375r2376
290290static CUSTOM_INPUT( hitnmiss_button1_r )
291291{
292292   /* button 1 shows up in two bits */
293   UINT32 button1 = readinputportbytag("HITNMISS_BUTTON1");
293   UINT32 button1 = input_port_read(machine, "HITNMISS_BUTTON1");
294294   return (button1 << 1) | button1;
295295}
296296
r2375r2376
343343{
344344   /* I/O1 accesses clear the CIRQ flip/flop */
345345   cpunum_set_input_line(machine, 0, 0, CLEAR_LINE);
346   return readinputport(3);
346   return input_port_read_indexed(machine, 3);
347347}
348348
349349
src/mame/drivers/tx1.c
r2375r2376
389389
390390static READ16_HANDLER( dipswitches_r )
391391{
392   return (readinputport(0) & 0xfffe) | ts;
392   return (input_port_read_indexed(machine, 0) & 0xfffe) | ts;
393393}
394394
395395/*
r2375r2376
448448
449449static WRITE8_HANDLER( tx1_ppi_latch_w )
450450{
451   tx1_ppi_latch_a = ((readinputportbytag("AN_BRAKE") & 0xf) << 4) | (readinputportbytag("AN_ACCELERATOR") & 0xf);
452   tx1_ppi_latch_b = readinputportbytag("AN_STEERING");
451   tx1_ppi_latch_a = ((input_port_read(machine, "AN_BRAKE") & 0xf) << 4) | (input_port_read(machine, "AN_ACCELERATOR") & 0xf);
452   tx1_ppi_latch_b = input_port_read(machine, "AN_STEERING");
453453}
454454
455455static READ8_HANDLER( tx1_ppi_porta_r )
r2375r2376
459459
460460static READ8_HANDLER( tx1_ppi_portb_r )
461461{
462   return readinputportbytag("PPI_PORTD") | tx1_ppi_latch_b;
462   return input_port_read(machine, "PPI_PORTD") | tx1_ppi_latch_b;
463463}
464464
465465static ADDRESS_MAP_START( tx1_sound_prg, ADDRESS_SPACE_PROGRAM, 8 )
r2375r2376
535535{
536536   if ( offset == 1 )
537537   {
538      return ((readinputportbytag("AN_ACCELERATOR") & 0xf) << 4) | readinputportbytag("AN_STEERING");
538      return ((input_port_read(machine, "AN_ACCELERATOR") & 0xf) << 4) | input_port_read(machine, "AN_STEERING");
539539   }
540540   else
541541   {
542      return (readinputportbytag("AN_BRAKE") & 0xf) << 4;
542      return (input_port_read(machine, "AN_BRAKE") & 0xf) << 4;
543543   }
544544}
545545
r2375r2376
547547{
548548   if ( offset == 0 )
549549   {
550      return ((readinputportbytag("AN_ACCELERATOR") & 0xf) << 4) | readinputportbytag("AN_STEERING");
550      return ((input_port_read(machine, "AN_ACCELERATOR") & 0xf) << 4) | input_port_read(machine, "AN_STEERING");
551551   }
552552   else
553553   {
554      return (readinputportbytag("AN_BRAKE") & 0xf) << 4;
554      return (input_port_read(machine, "AN_BRAKE") & 0xf) << 4;
555555   }
556556}
557557
src/mame/drivers/dassault.c
r2375r2376
138138   switch (offset<<1)
139139   {
140140      case 0: /* Player 1 & Player 2 joysticks & fire buttons */
141         return (readinputport(0) + (readinputport(1) << 8));
141         return (input_port_read_indexed(machine, 0) + (input_port_read_indexed(machine, 1) << 8));
142142
143143      case 2: /* Player 3 & Player 4 joysticks & fire buttons */
144         return (readinputport(6) + (readinputport(7) << 8));
144         return (input_port_read_indexed(machine, 6) + (input_port_read_indexed(machine, 7) << 8));
145145
146146      case 4: /* Dip 1 (stored at 0x3f8035) */
147         return readinputport(3);
147         return input_port_read_indexed(machine, 3);
148148
149149      case 6: /* Dip 2 (stored at 0x3f8034) */
150         return readinputport(4);
150         return input_port_read_indexed(machine, 4);
151151
152152      case 8: /* VBL, Credits */
153         return readinputport(2);
153         return input_port_read_indexed(machine, 2);
154154   }
155155
156156   return 0xffff;
r2375r2376
165165
166166static READ16_HANDLER( dassault_sub_control_r )
167167{
168   return readinputport(5);
168   return input_port_read_indexed(machine, 5);
169169}
170170
171171static WRITE16_HANDLER( dassault_sound_w )
src/mame/drivers/ssrj.c
r2375r2376
5656
5757static READ8_HANDLER(ssrj_wheel_r)
5858{
59   int port= input_port_1_r(machine,0) -0x80;
59   int port= input_port_read_indexed(machine, 1) -0x80;
6060   int retval=port-oldport;
6161   oldport=port;
6262   return retval;
src/mame/drivers/blstroid.c
r2375r2376
7272
7373static READ16_HANDLER( inputs_r )
7474{
75   int temp = readinputport(2 + (offset & 1));
75   int temp = input_port_read_indexed(machine, 2 + (offset & 1));
7676   if (atarigen_cpu_to_sound_ready) temp ^= 0x0040;
7777   if (atarigen_get_hblank(machine->primary_screen)) temp ^= 0x0010;
7878   return temp;
src/mame/drivers/tatsumi.c
r2375r2376
162162static READ16_HANDLER(cyclwarr_palette_r) { return paletteram16[offset]; }
163163static READ16_HANDLER(cyclwarr_sprite_r) { return spriteram16[offset]; }
164164static WRITE16_HANDLER(cyclwarr_sprite_w) { COMBINE_DATA(&spriteram16[offset]); }
165static READ16_HANDLER(cyclwarr_input_r) { return readinputport(offset); }
166static READ16_HANDLER(cyclwarr_input2_r) { return readinputport(offset+4); }
165static READ16_HANDLER(cyclwarr_input_r) { return input_port_read_indexed(machine, offset); }
166static READ16_HANDLER(cyclwarr_input2_r) { return input_port_read_indexed(machine, offset+4); }
167167static WRITE16_HANDLER(bigfight_a20000_w) { COMBINE_DATA(&bigfight_a20000[offset]); }
168168static WRITE16_HANDLER(bigfight_a40000_w) { COMBINE_DATA(&bigfight_a40000[offset]); }
169169static WRITE16_HANDLER(bigfight_a60000_w) { COMBINE_DATA(&bigfight_a60000[offset]); }
src/mame/drivers/supbtime.c
r2375r2376
3737    switch (offset<<1)
3838   {
3939      case 0: /* Player 1 & Player 2 joysticks & fire buttons */
40         return (readinputport(0) + (readinputport(1) << 8));
40         return (input_port_read_indexed(machine, 0) + (input_port_read_indexed(machine, 1) << 8));
4141      case 2: /* Dips */
42         return (readinputport(3) + (readinputport(4) << 8));
42         return (input_port_read_indexed(machine, 3) + (input_port_read_indexed(machine, 4) << 8));
4343      case 8: /* Credits */
44         return readinputport(2);
44         return input_port_read_indexed(machine, 2);
4545      case 10: /* ?  Not used for anything */
4646      case 12:
4747         return 0;
src/mame/drivers/blmbycar.c
r2375r2376
7777static WRITE16_HANDLER( blmbycar_pot_wheel_reset_w )
7878{
7979   if (ACCESSING_BITS_0_7)
80      pot_wheel = ~readinputport(2) & 0xff;
80      pot_wheel = ~input_port_read_indexed(machine, 2) & 0xff;
8181}
8282
8383static WRITE16_HANDLER( blmbycar_pot_wheel_shift_w )
r2375r2376
102102
103103static READ16_HANDLER( blmbycar_opt_wheel_r )
104104{
105   return   (~readinputport(2) & 0xff) << 8;
105   return   (~input_port_read_indexed(machine, 2) & 0xff) << 8;
106106}
107107
108108
src/mame/drivers/toratora.c
r2375r2376
3939static READ8_HANDLER( port_b_u3_r )
4040{
4141   logerror("%04x: read DIP\n",activecpu_get_pc());
42   return readinputport(1);
42   return input_port_read_indexed(machine, 1);
4343}
4444
4545
src/mame/drivers/megaplay.c
r2375r2376
136136    PORT_BIT ( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN ) \
137137    PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_SERVICE1 ) \
138138    PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) \
139    PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_START1 ) \
140    PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_START2 )
139    PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) \
140    PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
141141
142/* Caused 01081:
143 *  PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_START1 ) \
144 *  PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_START2 )
145 */
146
142147#define MEGAPLAY_DSWA \
143148   PORT_START \
144149   PORT_DIPNAME( 0x0f, 0x0f, "Coin slot 1" ) PORT_DIPLOCATION("SW1:1,2,3,4") \
r2375r2376
878883      case 1: /* port A data (joypad 1) */
879884
880885         if (genesis_io_ram[offset] & 0x40)
881            return_value = readinputport(1) & (genesis_io_ram[4]^0xff);
886            return_value = input_port_read_indexed(machine, 1) & (genesis_io_ram[4]^0xff);
882887         else
883888         {
884            return_value = readinputport(2) & (genesis_io_ram[4]^0xff);
885            return_value |= readinputport(1) & 0x03;
889            return_value = input_port_read_indexed(machine, 2) & (genesis_io_ram[4]^0xff);
890            return_value |= input_port_read_indexed(machine, 1) & 0x03;
886891         }
887892         return_value = (genesis_io_ram[offset] & 0x80) | return_value;
888893//          logerror ("reading joypad 1 , type %02x %02x\n",genesis_io_ram[offset] & 0xb0, return_value &0x7f);
r2375r2376
891896      case 2: /* port B data (joypad 2) */
892897
893898         if (genesis_io_ram[offset] & 0x40)
894            return_value = readinputport(3) & (genesis_io_ram[5]^0xff);
899            return_value = input_port_read_indexed(machine, 3) & (genesis_io_ram[5]^0xff);
895900         else
896901         {
897            return_value = readinputport(4) & (genesis_io_ram[5]^0xff);
898            return_value |= readinputport(3) & 0x03;
902            return_value = input_port_read_indexed(machine, 4) & (genesis_io_ram[5]^0xff);
903            return_value |= input_port_read_indexed(machine, 3) & 0x03;
899904         }
900905         return_value = (genesis_io_ram[offset] & 0x80) | return_value;
901906//          logerror ("reading joypad 2 , type %02x %02x\n",genesis_io_ram[offset] & 0xb0, return_value &0x7f);
src/mame/drivers/srmp2.c
r2375r2376
304304
305305         for (t = 0 ; t < 8 ; t ++)
306306         {
307            if (!(readinputport(j) & ( 1 << t )))
307            if (!(input_port_read_indexed(machine, j) & ( 1 << t )))
308308            {
309309               return (i + t);
310310            }
r2375r2376
313313   }
314314   else                        /* Analizer and memory reset keys */
315315   {
316      return readinputportbytag("IN7");
316      return input_port_read(machine, "IN7");
317317   }
318318
319319   return 0xffff;
r2375r2376
527527
528528         for (t = 0 ; t < 8 ; t ++)
529529         {
530            if (!(readinputport(j) & ( 1 << t )))
530            if (!(input_port_read_indexed(machine, j) & ( 1 << t )))
531531            {
532532               keydata = (i + t);
533533            }
r2375r2376
540540
541541   if ((activecpu_get_pc() == 0x8926) || (activecpu_get_pc() == 0x7822))   /* Analizer and memory reset keys */
542542   {
543      keydata = readinputport(7);
543      keydata = input_port_read_indexed(machine, 7);
544544   }
545545
546546   return keydata;
src/mame/drivers/m72.c
r2375r2376
617617
618618      for (i = 0;i < 4;i++)
619619      {
620         curr = readinputport(3+i);
620         curr = input_port_read_indexed(machine, 3+i);
621621         diff[i] = (curr - prev[i]);
622622         prev[i] = curr;
623623      }
r2375r2376
629629      case 0:
630630         return (diff[0] & 0xff) | ((diff[2] & 0xff) << 8);
631631      case 1:
632         return ((diff[0] >> 8) & 0x1f) | (diff[2] & 0x1f00) | (readinputport(0) & 0xe0e0);
632         return ((diff[0] >> 8) & 0x1f) | (diff[2] & 0x1f00) | (input_port_read_indexed(machine, 0) & 0xe0e0);
633633      case 2:
634634         return (diff[1] & 0xff) | ((diff[3] & 0xff) << 8);
635635      case 3:
src/mame/drivers/snk68.c
r2375r2376
7878
7979static READ16_HANDLER( control_1_r )
8080{
81   return (readinputportbytag("IN0") + (readinputportbytag("IN1") << 8));
81   return (input_port_read(machine, "IN0") + (input_port_read(machine, "IN1") << 8));
8282}
8383
8484static READ16_HANDLER( control_2_r )
8585{
86   return readinputportbytag("IN2");
86   return input_port_read(machine, "IN2");
8787}
8888
8989static READ16_HANDLER( dip_1_r )
9090{
91   return readinputportbytag("DSW1") << 8;
91   return input_port_read(machine, "DSW1") << 8;
9292}
9393
9494static READ16_HANDLER( dip_2_r )
9595{
96   return readinputportbytag("DSW2") << 8;
96   return input_port_read(machine, "DSW2") << 8;
9797}
9898
9999static READ16_HANDLER( rotary_1_r )
100100{
101   return (( ~(1 << readinputportbytag("ROT1")) )<<8)&0xff00;
101   return (( ~(1 << input_port_read(machine, "ROT1")) )<<8)&0xff00;
102102}
103103
104104static READ16_HANDLER( rotary_2_r )
105105{
106   return (( ~(1 << readinputportbytag("ROT2")) )<<8)&0xff00;
106   return (( ~(1 << input_port_read(machine, "ROT2")) )<<8)&0xff00;
107107}
108108
109109static READ16_HANDLER( rotary_lsb_r )
110110{
111   return ((( ~(1 << readinputportbytag("ROT2"))  ) <<4)&0xf000)
112       + ((( ~(1 << readinputportbytag("ROT1"))  )    )&0x0f00);
111   return ((( ~(1 << input_port_read(machine, "ROT2"))  ) <<4)&0xf000)
112       + ((( ~(1 << input_port_read(machine, "ROT1"))  )    )&0x0f00);
113113}
114114
115115static READ16_HANDLER( protcontrols_r )
116116{
117   return readinputport(offset) ^ invert_controls;
117   return input_port_read_indexed(machine, offset) ^ invert_controls;
118118}
119119
120120static WRITE16_HANDLER( protection_w )
src/mame/drivers/konamigv.c
r2375r2376
313313
314314static DRIVER_INIT( konamigv )
315315{
316   psx_driver_init();
316   psx_driver_init(machine);
317317
318318   /* init the scsi controller and hook up it's DMA */
319319   am53cf96_init(&scsi_intf);
r2375r2376
525525
526526      for( axis = 0; axis < 2; axis++ )
527527      {
528         value = readinputport( axis + 3 );
528         value = input_port_read_indexed(machine, axis + 3 );
529529         diff = value - trackball_prev[ axis ];
530530         trackball_prev[ axis ] = value;
531531         trackball_data[ axis ] = ( ( diff & 0xf00 ) << 16 ) | ( ( diff & 0xff ) << 8 );
r2375r2376
610610
611611      for( axis = 0; axis < 4; axis++ )
612612      {
613         value = readinputport( axis + 3 );
613         value = input_port_read_indexed(machine, axis + 3 );
614614         diff = value - btc_trackball_prev[ axis ];
615615         btc_trackball_prev[ axis ] = value;
616616         btc_trackball_data[ axis ] = ( ( diff & 0xf00 ) << 16 ) | ( ( diff & 0xff ) << 8 );
src/mame/drivers/firetrap.c
r2375r2376
101101   /* Check for coin insertion */
102102   /* the following only works in the bootleg version, which doesn't have an */
103103   /* 8751 - the real thing is much more complicated than that. */
104   if ((readinputport(2) & 0x70) != 0x70) return 0xff;
104   if ((input_port_read_indexed(machine, 2) & 0x70) != 0x70) return 0xff;
105105   return 0;
106106}
107107
r2375r2376
545545
546546   /* Check for coin IRQ */
547547   if (cpu_getiloops()) {
548      if ((readinputport(5) & 0x7) != 0x7 && !latch) {
549         coin_command_pending=~readinputport(5);
548      if ((input_port_read_indexed(machine, 5) & 0x7) != 0x7 && !latch) {
549         coin_command_pending=~input_port_read_indexed(machine, 5);
550550         latch=1;
551551      }
552      if ((readinputport(5) & 0x7) == 0x7)
552      if ((input_port_read_indexed(machine, 5) & 0x7) == 0x7)
553553         latch=0;
554554
555555      /* Make sure coin IRQ's aren't generated when another command is pending, the main cpu
src/mame/drivers/crgolf.c
r2375r2376
8181
8282static READ8_HANDLER( switch_input_r )
8383{
84   return readinputport(port_select);
84   return input_port_read_indexed(machine, port_select);
8585}
8686
8787
8888static READ8_HANDLER( analog_input_r )
8989{
90   return ((readinputport(7) >> 4) | (readinputport(8) & 0xf0)) ^ 0x88;
90   return ((input_port_read_indexed(machine, 7) >> 4) | (input_port_read_indexed(machine, 8) & 0xf0)) ^ 0x88;
9191}
9292
9393
src/mame/drivers/thedeep.c
r2375r2376
338338   {
339339      if (protection_command != 0x59)
340340      {
341         int coins = readinputport(4);
341         int coins = input_port_read_indexed(machine, 4);
342342         if      (coins & 1)   protection_data = 1;
343343         else if   (coins & 2)   protection_data = 2;
344344         else if   (coins & 4)   protection_data = 3;
src/mame/drivers/oneshot.c
r2375r2376
5454
5555static READ16_HANDLER( oneshot_in0_word_r )
5656{
57   int data = readinputport(0);
57   int data = input_port_read_indexed(machine, 0);
5858
5959   switch (data & 0x0c)
6060   {
src/mame/drivers/stlforce.c
r2375r2376
8686
8787static READ16_HANDLER( stlforce_input_port_1_r )
8888{
89   return (readinputport(1) & ~0x40) | (EEPROM_read_bit() << 6);
89   return (input_port_read_indexed(machine, 1) & ~0x40) | (EEPROM_read_bit() << 6);
9090}
9191
9292static WRITE16_HANDLER( eeprom_w )
src/mame/drivers/rmhaihai.c
r2375r2376
8787
8888         for (i = 0;i < 31;i++)
8989         {
90            if (readinputport(2 + i/16) & (1<<(i&15))) return i+1;
90            if (input_port_read_indexed(machine, 2 + i/16) & (1<<(i&15))) return i+1;
9191         }
92         if (readinputport(3) & 0x8000) return 0x80;   // coin
92         if (input_port_read_indexed(machine, 3) & 0x8000) return 0x80;   // coin
9393         return 0;
9494      }
9595      case 0x5c7b:   // rmhaihai, rmhaisei, rmhaijin
src/mame/drivers/topspeed.c
r2375r2376
332332{
333333   UINT8 port = TC0220IOC_port_r(machine,0);   /* read port number */
334334   int steer = 0;
335   int analogue_steer = readinputportbytag_safe(STEER_PORT_TAG,0x00);
336   int fake = readinputportbytag_safe(FAKE_PORT_TAG,0x00);
335   int analogue_steer = input_port_read_safe(machine, STEER_PORT_TAG,0x00);
336   int fake = input_port_read_safe(machine, FAKE_PORT_TAG,0x00);
337337
338338   if (!(fake & 0x10))   /* Analogue steer (the real control method) */
339339   {
r2375r2376
679679                     MACHINE DRIVERS
680680***********************************************************/
681681
682static STATE_POSTLOAD( topspeed_postload )
683{
684   parse_control();
685   reset_sound_region();
686}
687
682688static MACHINE_START( topspeed )
683689{
684690   state_save_register_global(cpua_ctrl);
685   state_save_register_func_postload(parse_control);
686
687691   state_save_register_global(ioc220_port);
688
689692   state_save_register_global(banknum);
690   state_save_register_func_postload(reset_sound_region);
693   state_save_register_postload(machine, topspeed_postload, NULL);
691694}
692695
693696static MACHINE_DRIVER_START( topspeed )
src/mame/drivers/zr107.c
r2375r2376
171171   {
172172      if (ACCESSING_BITS_24_31)
173173      {
174         r |= readinputport(0) << 24;
174         r |= input_port_read_indexed(machine, 0) << 24;
175175      }
176176      if (ACCESSING_BITS_16_23)
177177      {
178         r |= readinputport(1) << 16;
178         r |= input_port_read_indexed(machine, 1) << 16;
179179      }
180180      if (ACCESSING_BITS_8_15)
181181      {
182182         int adc_bit = adc083x_do_read(0);
183         r |= ((readinputport(2) & 0x7f) | (adc_bit << 7)) << 8;
183         r |= ((input_port_read_indexed(machine, 2) & 0x7f) | (adc_bit << 7)) << 8;
184184      }
185185      if (ACCESSING_BITS_0_7)
186186      {
187         r |= readinputport(3) << 0;
187         r |= input_port_read_indexed(machine, 3) << 0;
188188      }
189189   }
190190   else if (offset == 1)
r2375r2376
249249   switch (input)
250250   {
251251      case ADC083X_CH0:
252         return (double)(5 * readinputport(4)) / 255.0;
252         return (double)(5 * input_port_read_indexed(Machine, 4)) / 255.0;
253253      case ADC083X_CH1:
254         return (double)(5 * readinputport(5)) / 255.0;
254         return (double)(5 * input_port_read_indexed(Machine, 5)) / 255.0;
255255      case ADC083X_CH2:
256         return (double)(5 * readinputport(6)) / 255.0;
256         return (double)(5 * input_port_read_indexed(Machine, 6)) / 255.0;
257257      case ADC083X_CH3:
258258         return 0;
259259      case ADC083X_COM:
src/mame/drivers/amspdwy.c
r2375r2376
4747static READ8_HANDLER( amspdwy_wheel_##_n_##_r ) \
4848{ \
4949   static UINT8 wheel_old, ret; \
50   UINT8 wheel = readinputport(5 + _n_); \
50   UINT8 wheel = input_port_read_indexed(machine, 5 + _n_); \
5151   if (wheel != wheel_old) \
5252   { \
5353      wheel = (wheel & 0x7fff) - (wheel & 0x8000); \
r2375r2376
5555      else               ret = ((-wheel) & 0xf) | 0x10; \
5656      wheel_old = wheel; \
5757   } \
58   return ret | readinputport(2 + _n_); \
58   return ret | input_port_read_indexed(machine, 2 + _n_); \
5959}
6060AMSPDWY_WHEEL_R( 0 )
6161AMSPDWY_WHEEL_R( 1 )
r2375r2376
6363
6464static READ8_HANDLER( amspdwy_sound_r )
6565{
66   return (YM2151_status_port_0_r(machine,0) & ~ 0x30) | readinputport(4);
66   return (YM2151_status_port_0_r(machine,0) & ~ 0x30) | input_port_read_indexed(machine, 4);
6767}
6868
6969static WRITE8_HANDLER( amspdwy_sound_w )
src/mame/drivers/segae.c
r2375r2376
22882288   temp = 0;
22892289
22902290   if (port_fa_last == 0x08)  /* 0000 1000 */ /* Angle */
2291      temp = readinputport(4);
2291      temp = input_port_read_indexed(machine, 4);
22922292
22932293   if (port_fa_last == 0x09)  /* 0000 1001 */ /* Accel */
2294      temp = readinputport(5);
2294      temp = input_port_read_indexed(machine, 5);
22952295
22962296   return temp;
22972297}
r2375r2376
23272327
23282328   if (data & 1)
23292329   {
2330      int curr = readinputport(4);
2330      int curr = input_port_read_indexed(machine, 4);
23312331      diff1 = ((curr - last1) & 0x0fff) | (curr & 0xf000);
23322332      last1 = curr;
23332333   }
23342334   if (data & 2)
23352335   {
2336      int curr = readinputport(5) & 0x0fff;
2336      int curr = input_port_read_indexed(machine, 5) & 0x0fff;
23372337      diff2 = ((curr - last2) & 0x0fff) | (curr & 0xf000);
23382338      last2 = curr;
23392339   }
src/mame/drivers/fantland.c
r2375r2376
179179   static int old_x[2], old_y[2], old_f[2];
180180   static UINT8 ret[2];
181181
182   switch (readinputport(7) & 0x03)
182   switch (input_port_read_indexed(machine, 7) & 0x03)
183183   {
184184      case 3:
185      case 1:   return readinputport(0 + offset);   // Lightgun buttons
186      case 2:   return readinputport(4 + offset);   // Joystick
185      case 1:   return input_port_read_indexed(machine, 0 + offset);   // Lightgun buttons
186      case 2:   return input_port_read_indexed(machine, 4 + offset);   // Joystick
187187   }
188188
189189   // Trackball
190190
191   x = readinputport(13 + offset * 2);
192   y = readinputport(12 + offset * 2);
191   x = input_port_read_indexed(machine, 13 + offset * 2);
192   y = input_port_read_indexed(machine, 12 + offset * 2);
193193   f = video_screen_get_frame_number(machine->primary_screen);
194194
195   ret[offset]   =   (ret[offset] & 0x14) | (readinputport(2 + offset) & 0xc3);
195   ret[offset]   =   (ret[offset] & 0x14) | (input_port_read_indexed(machine, 2 + offset) & 0xc3);
196196
197197   x =  (x & 0x7f) - (x & 0x80);
198198   y =  (y & 0x7f) - (y & 0x80);
r2375r2376
696696static CUSTOM_INPUT( wheelrun_wheel_r )
697697{
698698   int player = (FPTR)param;
699   int delta = readinputport(4 + player);
699   int delta = input_port_read_indexed(machine, 4 + player);
700700   delta = (delta & 0x7f) - (delta & 0x80) + 4;
701701
702702   if      (delta > 7)   delta = 7;
src/mame/drivers/ksys573.c
r2375r2376
205205*/
206206
207207#include "driver.h"
208#include "deprecat.h"
208209#include "cdrom.h"
209210#include "cpu/mips/psx.h"
210211#include "includes/psx.h"
r2375r2376
300301   switch (offset)
301302   {
302303   case 0:
303      data = readinputport(0);
304      data = input_port_read_indexed(machine, 0);
304305      break;
305306   case 1:
306307   {
307      data = readinputport(1);
308      data = input_port_read_indexed(machine, 1);
308309      data |= 0x000000c0;
309310
310311      if( has_ds2401[ security_cart_number ] )
r2375r2376
340341      break;
341342   }
342343   case 2:
343      data = readinputport(2);
344      data = input_port_read_indexed(machine, 2);
344345      break;
345346   case 3:
346      data = readinputport(3);
347      data = input_port_read_indexed(machine, 3);
347348      break;
348349   }
349350
r2375r2376
13851386   switch( input )
13861387   {
13871388   case ADC083X_CH0:
1388      return (double) ( readinputportbytag_safe( "analog0", 0 ) * 5 ) / 255;
1389      return (double) ( input_port_read_safe(Machine, "analog0", 0 ) * 5 ) / 255;
13891390   case ADC083X_CH1:
1390      return (double) ( readinputportbytag_safe( "analog1", 0 ) * 5 ) / 255;
1391      return (double) ( input_port_read_safe(Machine, "analog1", 0 ) * 5 ) / 255;
13911392   case ADC083X_CH2:
1392      return (double) ( readinputportbytag_safe( "analog2", 0 ) * 5 ) / 255;
1393      return (double) ( input_port_read_safe(Machine, "analog2", 0 ) * 5 ) / 255;
13931394   case ADC083X_CH3:
1394      return (double) ( readinputportbytag_safe( "analog3", 0 ) * 5 ) / 255;
1395      return (double) ( input_port_read_safe(Machine, "analog3", 0 ) * 5 ) / 255;
13951396   case ADC083X_AGND:
13961397      return 0;
13971398   case ADC083X_VREF:
r2375r2376
14901491{
14911492   int i;
14921493
1493   psx_driver_init();
1494   psx_driver_init(machine);
14941495   atapi_init(machine);
14951496   psx_dma_install_read_handler(5, cdrom_dma_read);
14961497   psx_dma_install_write_handler(5, cdrom_dma_write);
r2375r2376
15371538   psx_dma_install_write_handler
15381539};
15391540
1540static void update_mode( void )
1541static void update_mode( running_machine *machine )
15411542{
1542   int cart = readinputportbytag( "CART" );
1543   int cd = readinputportbytag( "CD" );
1543   int cart = input_port_read(machine,  "CART" );
1544   int cd = input_port_read(machine,  "CD" );
15441545   static SCSIInstance *new_cdrom;
15451546
15461547   if( chiptype[ 1 ] != 0 )
r2375r2376
15701571
15711572static INTERRUPT_GEN( sys573_vblank )
15721573{
1573   update_mode();
1574   update_mode(machine);
15741575
15751576   if( strcmp( machine->gamedrv->name, "ddr2ml" ) == 0 )
15761577   {
r2375r2376
16041605   switch( offset )
16051606   {
16061607   case 0x26:
1607      uPD4701_y_add( 0, readinputportbytag_safe( "uPD4701_y", 0 ) );
1608      uPD4701_switches_set( 0, readinputportbytag_safe( "uPD4701_switches", 0 ) );
1608      uPD4701_y_add( 0, input_port_read_safe(machine,  "uPD4701_y", 0 ) );
1609      uPD4701_switches_set( 0, input_port_read_safe(machine,  "uPD4701_switches", 0 ) );
16091610
16101611      uPD4701_cs_w( 0, 0 );
16111612      uPD4701_xy_w( 0, 1 );
r2375r2376
18811882
18821883static CUSTOM_INPUT( gn845pwbb_read )
18831884{
1884   return readinputportbytag( "STAGE" ) & stage_mask;
1885   return input_port_read(machine, "STAGE" ) & stage_mask;
18851886}
18861887
18871888static void gn845pwbb_output_callback( int offset, int data )
src/mame/drivers/atarig1.c
r2375r2376
110110
111111static READ16_HANDLER( special_port0_r )
112112{
113   int temp = readinputport(0);
113   int temp = input_port_read_indexed(machine, 0);
114114   if (atarigen_cpu_to_sound_ready) temp ^= 0x1000;
115115   temp ^= 0x2000;      /* A2DOK always high for now */
116116   return temp;
r2375r2376
127127{
128128   /* Pit Fighter has no A2D, just another input port */
129129   if (atarig1_pitfight)
130      return readinputport(1);
130      return input_port_read_indexed(machine, 1);
131131
132132   /* otherwise, assume it's hydra */
133133   if (which_input < 3)
134      return readinputport(1 + which_input) << 8;
134      return input_port_read_indexed(machine, 1 + which_input) << 8;
135135
136136   return 0;
137137}
r2375r2376
161161}
162162
163163
164static void pitfighb_state_postload(void)
164static STATE_POSTLOAD( pitfighb_state_postload )
165165{
166166   int bank = bslapstic_bank;
167167   bslapstic_bank = -1;
r2375r2376
964964      pitfighb_cheap_slapstic_init();
965965      state_save_register_global(bslapstic_bank);
966966      state_save_register_global(bslapstic_primed);
967      state_save_register_func_postload(pitfighb_state_postload);
967      state_save_register_postload(machine, pitfighb_state_postload, NULL);
968968   }
969969   else if (slapstic != 0)
970970      atarigen_slapstic_init(0, slapstic_base, 0, slapstic);
src/mame/drivers/sbrkout.c
r2375r2376
125125   /* on the VBLANK, read the pot and schedule an interrupt time for it */
126126   if (scanline == video_screen_get_visible_area(machine->primary_screen)->max_y + 1)
127127   {
128      UINT8 potvalue = readinputportbytag("PADDLE");
128      UINT8 potvalue = input_port_read(machine, "PADDLE");
129129      timer_adjust_oneshot(pot_timer, video_screen_get_time_until_pos(machine->primary_screen, 72 + (potvalue / 2), (potvalue % 2) * 128), 0);
130130   }
131131
r2375r2376
156156
157157   /* DIP switches are selected by ADR0+ADR1 if ADR3 == 0 */
158158   if ((offset & 0x0b) == 0x00)
159      result &= (readinputportbytag("DIPS") << 6) | 0x3f;
159      result &= (input_port_read(machine, "DIPS") << 6) | 0x3f;
160160   if ((offset & 0x0b) == 0x01)
161      result &= (readinputportbytag("DIPS") << 4) | 0x3f;
161      result &= (input_port_read(machine, "DIPS") << 4) | 0x3f;
162162   if ((offset & 0x0b) == 0x02)
163      result &= (readinputportbytag("DIPS") << 0) | 0x3f;
163      result &= (input_port_read(machine, "DIPS") << 0) | 0x3f;
164164   if ((offset & 0x0b) == 0x03)
165      result &= (readinputportbytag("DIPS") << 2) | 0x3f;
165      result &= (input_port_read(machine, "DIPS") << 2) | 0x3f;
166166
167167   /* other switches are selected by ADR0+ADR1+ADR2 if ADR4 == 0 */
168168   if ((offset & 0x17) == 0x00)
169      result &= (readinputportbytag("SELECT") << 7) | 0x7f;
169      result &= (input_port_read(machine, "SELECT") << 7) | 0x7f;
170170   if ((offset & 0x17) == 0x04)
171171      result &= ((pot_trigger[0] & ~pot_mask[0]) << 7) | 0x7f;
172172   if ((offset & 0x17) == 0x05)
173173      result &= ((pot_trigger[1] & ~pot_mask[1]) << 7) | 0x7f;
174174   if ((offset & 0x17) == 0x06)
175      result &= readinputportbytag("SERVE");
175      result &= input_port_read(machine, "SERVE");
176176   if ((offset & 0x17) == 0x07)
177      result &= (readinputportbytag("SELECT") << 6) | 0x7f;
177      result &= (input_port_read(machine, "SELECT") << 6) | 0x7f;
178178
179179   return result;
180180}
src/mame/drivers/bladestl.c
r2375r2376
5757   int curr,delta;
5858
5959
60   curr = readinputport(5 + offset);
60   curr = input_port_read_indexed(machine, 5 + offset);
6161   delta = (curr - last[offset]) & 0xff;
6262   last[offset] = curr;
6363   return (delta & 0x80) | (curr >> 1);
src/mame/drivers/toobin.c
r2375r2376
9595
9696static READ16_HANDLER( special_port1_r )
9797{
98   int result = readinputport(1);
98   int result = input_port_read_indexed(machine, 1);
9999   if (atarigen_get_hblank(machine->primary_screen)) result ^= 0x8000;
100100   if (atarigen_cpu_to_sound_ready) result ^= 0x2000;
101101   return result;
src/mame/drivers/bwidow.c
r2375r2376
253253   int res1;
254254   int res2;
255255
256   res1 = readinputportbytag("IN3");
257   res2 = readinputportbytag("IN4");
256   res1 = input_port_read(machine, "IN3");
257   res2 = input_port_read(machine, "IN4");
258258   res = 0x00;
259259
260260   switch (offset & 0x07)
src/mame/drivers/legionna.c
r2375r2376
1313different tiles available for use in the foreground layer.
1414
1515
16Legionnaire BK3 charsets
17------------------------
1816
19The GFX roms contain two odd sections of 256 16x16 tiles marked as BK3.
20These need to be brought together and decoded as a single section of
210x200 tiles.
22
23The 0x104000 area appears to be extra paletteram?
24
25
2617TODO
2718----
2819
2920Unemulated protection messes up both games.
3021
31Seibu sound system mentioned in log.
22Sound System isn't working properly, hangs / denjinmk isn't happy with status without a hack
3223
3324
3425Legionnaire
r2375r2376
3829
3930Need 16 px off top of vis area?
4031
32The 0x104000 area appears to be extra paletteram?
4133
42Heated Barrel
43-------------
4434
45Big problems with layers not being cleared, especially the text
46layer. There may be a write to the COP controlling layer clearance?
47
48Ends with Access violation when you die on round 1 boss. A lot of
49non-existent area reads in log - maybe because of bad reads from
50the COP.
51
52
5335Denjin Makai
5436------------
5537
5638Palette Ram format correct,but color offset wrong?
57Probably protection related,game updates paletteram with rom data...
39Probably protection related,game updates paletteram with rom data (or bad program rom?)..
5840
5941Need a sound kludge to start.
6042
61Sprite GFX ROM order wrong,causes wrong sprite graphics.
43Bad Sprite rom - half size, causes missing sprite graphics.
6244
6345
6446Godzilla
r2375r2376
9779#include "sound/3812intf.h"
9880#include "cpu/m68000/m68000.h"
9981
82/* machine/seicop.c */
83extern UINT16* cop_mcu_ram;
84extern READ16_HANDLER( legionna_mcu_r );
85extern WRITE16_HANDLER( legionna_mcu_w );
86extern READ16_HANDLER( heatbrl_mcu_r );
87extern WRITE16_HANDLER( heatbrl_mcu_w );
88extern READ16_HANDLER( godzilla_cop_mcu_r );
89extern WRITE16_HANDLER( godzilla_cop_mcu_w );
90extern READ16_HANDLER( denjinmk_cop_mcu_r );
91extern WRITE16_HANDLER( denjinmk_cop_mcu_w );
92extern READ16_HANDLER( sdgndmrb_cop_mcu_r );
93extern WRITE16_HANDLER( sdgndmrb_cop_mcu_w );
94extern READ16_HANDLER( copdx_0_r );
95extern WRITE16_HANDLER( copdx_0_w );
96extern READ16_HANDLER( copdxbl_0_r );
97extern WRITE16_HANDLER( copdxbl_0_w );
98
99
100
101
102
100103extern WRITE16_HANDLER( legionna_background_w );
101104extern WRITE16_HANDLER( legionna_foreground_w );
102105extern WRITE16_HANDLER( legionna_midground_w );
r2375r2376
109112extern VIDEO_UPDATE( legionna );
110113extern VIDEO_UPDATE( godzilla );
111114extern VIDEO_UPDATE( sdgndmrb );
112void heatbrl_setgfxbank(UINT16 data);
113void denjinmk_setgfxbank(UINT16 data);
114115
116
115117extern UINT16 *legionna_back_data,*legionna_fore_data,*legionna_mid_data,*legionna_scrollram16,*legionna_textram;
116static UINT16 *mcu_ram;
117extern UINT8 sdgndmrb_pri_n;
118118
119
119120static WRITE16_HANDLER( legionna_paletteram16_w )   /* xBBBBxRRRRxGGGGx */
120121{
121122   int a;
r2375r2376
124125   palette_set_color_rgb(Machine,offset,pal4bit(a >> 1),pal4bit(a >> 6),pal4bit(a >> 11));
125126}
126127
127
128/* Mcu reads in attract in Legionnaire game demo
129
130Guess the 0x400-0x5ff area of the COP is protection related.
131
132CPU0 PC 0032a2 unknown MCU write offset: 0260 data: 9c6c
133CPU0 PC 0032a8 unknown MCU write offset: 0250 data: 0010
134CPU0 PC 0032c8 unknown MCU write offset: 0261 data: 987c
135CPU0 PC 0032ce unknown MCU write offset: 0251 data: 0010
136CPU0 PC 003546 unknown MCU write offset: 0262 data: 02c4
137CPU0 PC 00354a unknown MCU write offset: 0252 data: 0004
138CPU0 PC 00355c unknown MCU write offset: 0263 data: 0000
139CPU0 PC 003560 unknown MCU write offset: 0253 data: 0004
140CPU0 PC 003568 unknown MCU write offset: 0280 data: a180
141CPU0 PC 00356e unknown MCU write offset: 0280 data: a980
142CPU0 PC 003574 unknown MCU write offset: 0280 data: b100
143CPU0 PC 00357a unknown MCU write offset: 0280 data: b900
144CPU0 PC 003580 unknown MCU read offset: 02c4
145CPU0 PC 003588 unknown MCU read offset: 02c2
146CPU0 PC 003594 unknown MCU read offset: 02c1
147CPU0 PC 0035a0 unknown MCU read offset: 02c3
148CPU0 PC 0032a2 unknown MCU write offset: 0260 data: 9c6c
149CPU0 PC 0032a8 unknown MCU write offset: 0250 data: 0010
150CPU0 PC 0032c8 unknown MCU write offset: 0261 data: 987c
151CPU0 PC 0032ce unknown MCU write offset: 0251 data: 0010
152CPU0 PC 003422 unknown MCU write offset: 0280 data: 138e
153CPU0 PC 003428 unknown MCU read offset: 02da
154CPU0 PC 00342e unknown MCU read offset: 02d8
155CPU0 PC 00346c unknown MCU write offset: 0280 data: 3bb0
156CPU0 PC 0032a2 unknown MCU write offset: 0260 data: 987c
157CPU0 PC 0032a8 unknown MCU write offset: 0250 data: 0010
158CPU0 PC 003306 unknown MCU write offset: 0280 data: 8100
159CPU0 PC 00330c unknown MCU write offset: 0280 data: 8900
160
161
162Mcu reads in attract in Heated Barrel game demo (note
163partial similarity)
164
165(i) This sequence repeats a number of times early on:
166
167CPU0 PC 0085b4 unknown MCU write offset: 0210 data: 0064
168CPU0 PC 0085ba unknown MCU write offset: 0211 data: 0000
169CPU0 PC 0085be unknown MCU read offset: 02ca
170CPU0 PC 0085ee unknown MCU read offset: 02c9
171CPU0 PC 008622 unknown MCU read offset: 02c8
172[Protection BCD,see protection_bcd_jsr()]
173
174(ii) This happens a few times:
175
176CPU0 PC 0017ac unknown MCU write offset: 0260 data: b6cc
177CPU0 PC 0017b2 unknown MCU write offset: 0250 data: 0010
178CPU0 PC 0017d2 unknown MCU write offset: 0261 data: babc
179CPU0 PC 0017d8 unknown MCU write offset: 0251 data: 0010
180CPU0 PC 00192c unknown MCU write offset: 0280 data: 138e
181CPU0 PC 001932 unknown MCU read offset: 02da
182CPU0 PC 001938 unknown MCU read offset: 02d8
183CPU0 PC 001976 unknown MCU write offset: 0280 data: 3bb0
184CPU0 PC 0017ac unknown MCU write offset: 0260 data: b6cc
185CPU0 PC 0017b2 unknown MCU write offset: 0250 data: 0010
186CPU0 PC 0017d2 unknown MCU write offset: 0261 data: bb9c
187CPU0 PC 0017d8 unknown MCU write offset: 0251 data: 0010
188CPU0 PC 00192c unknown MCU write offset: 0280 data: 138e
189CPU0 PC 001932 unknown MCU read offset: 02da
190CPU0 PC 001938 unknown MCU read offset: 02d8
191CPU0 PC 001976 unknown MCU write offset: 0280 data: 3bb0
192
193
194
195(iii) Later on this happens a lot:
196
197CPU0 PC 0017ac unknown MCU write offset: 0260 data: c61c
198CPU0 PC 0017b2 unknown MCU write offset: 0250 data: 0010
199CPU0 PC 0017d2 unknown MCU write offset: 0261 data: bb9c
200CPU0 PC 0017d8 unknown MCU write offset: 0251 data: 0010
201CPU0 PC 001a5c unknown MCU write offset: 0262 data: aa48
202CPU0 PC 001a62 unknown MCU write offset: 0252 data: 0003
203CPU0 PC 001a7c unknown MCU write offset: 0263 data: a0c8
204CPU0 PC 001a82 unknown MCU write offset: 0253 data: 0003
205CPU0 PC 001a86 unknown MCU write offset: 0280 data: a100
206CPU0 PC 001a8c unknown MCU write offset: 0280 data: b080
207CPU0 PC 001a92 unknown MCU write offset: 0280 data: a900
208CPU0 PC 001a98 unknown MCU write offset: 0280 data: b880
209CPU0 PC 001a9e unknown MCU read offset: 02c0
210CPU0 PC 001aa6 unknown MCU read offset: 02c2
211CPU0 PC 001ab2 unknown MCU read offset: 02c1
212
213write to $500 these values to determine the kind of sub-routine to do
214hit_check
215a180
216a980
217b100
218b900
219|| b880 (heatbrl)
220
221movement protection
2228100
2238900
224
22500DB2A: D6A8 0048                add.l   ($48,A0), D3
22600DB2E: D8A8 0044                add.l   ($44,A0), D4
22700DB32: 0C83 FFF0 0000           cmpi.l  #-$100000, D3
22800DB38: 6D2E                     blt     $db68
22900DB3A: 0C83 0100 0000           cmpi.l  #$1000000, D3
23000DB40: 6C26                     bge     $db68
23100DB42: 2143 003C                move.l  D3, ($3c,A0)
23200DB46: 0C84 FFF0 0000           cmpi.l  #-$100000, D4
23300DB4C: 6D1A                     blt     $db68
23400DB4E: 0C84 0100 0000           cmpi.l  #$1000000, D4
23500DB54: 6E12                     bgt     $db68
23600DB56: 2144 0038                move.l  D4, ($38,A0)
23700DB5A: 3168 003C 0022           move.w  ($3c,A0), ($22,A0)
23800DB60: 3168 0038 0024           move.w  ($38,A0), ($24,A0)
23900DB66: 4E75                     rts
240
241
242sprite DMA
243
244*/
245/*Movement protection*//*Legionnaire,Heated Barrel*/
246static UINT32 ram_addr[2],rom_addr[2];
247/*Sprite DMA protection*//*SD Gundam*/
248static UINT8 dma_status;
249static UINT32 dma_src,dma_dst;
250static UINT16 prot_data[2],dma_size;
251/*Number protection*//*Heated Barrel,SD Gundam,Godzilla,Denjin Makai*/
252static UINT32 prot_bcd[4];
253/*Hit check protection*//*Legionnaire,Heated Barrel,SD Gundam*/
254static UINT8 xy_check;
255static UINT32 hit_check_x,hit_check_y;
256
257
258
259#define CRT_MODE(_x_,_y_,_flip_) \
260   { \
261   rectangle visarea = *video_screen_get_visible_area(machine->primary_screen); \
262   visarea.min_x = 0; \
263   visarea.max_x = _x_-1; \
264   visarea.min_y = 0; \
265   visarea.max_y = _y_-1; \
266   video_screen_configure(machine->primary_screen, _x_, _y_, &visarea, video_screen_get_frame_period(machine->primary_screen).attoseconds ); \
267   flip_screen_set(_flip_); \
268   } \
269
270/*TODO: numbers over 65535?*/
271static UINT32 protection_bcd_jsr(UINT16 prot_data)
272{
273   UINT32 res,bcd_data;
274
275   res = 0;
276   bcd_data = prot_data;
277   while(bcd_data > 0)
278   {
279      if(bcd_data > 999)
280      {
281         res+=0x01000000;
282         bcd_data-=1000;
283      }
284      else if(bcd_data > 99)
285      {
286         res+=0x00010000;
287         bcd_data-=100;
288      }
289      else if(bcd_data > 9)
290      {
291         res+=0x00000100;
292         bcd_data-=10;
293      }
294      else
295      {
296         res++;
297         bcd_data--;
298      }
299   }
300
301   return res & 0x0f0f0f0f;
302}
303
304/*TODO: -move x-axis limits,to calculate basing on the screen xy-axis values*/
305/*      -the second value should be end of calculation (in other words,check everything between the two values) */
306#define PLAYER 0
307#define ENEMY 1
308static void protection_move_jsr(UINT32 work_ram,UINT8 k)
309{
310   static UINT32 move_data,x_data,y_data;
311   /*Read the movement data to execute*/
312   move_data = ((program_read_word(work_ram+0x34)<<16) & 0xffff0000) |
313                (program_read_word(work_ram+0x36) & 0xffff);
314
315   /*Read the x/y axis of the sprite to change*/
316   x_data = (program_read_word(work_ram+0x8));
317   y_data = (program_read_word(work_ram+0x4));
318   /*it's bit sensitive AFAIK*/
319   /*move_data hi-word on player
320      $17 = walk floor
321      $1b = jump
322      $30 = ?
323    */
324   /*Check the kind of movement that we need to execute*/
325   switch(k & 1)
326   {
327      case PLAYER:
328         switch(move_data & 0xffff)
329         {
330            case 0x0000: x_data++; break; //right
331            case 0x0040: y_data++; break; //down
332            case 0x00c0: y_data--; break; //up
333            case 0x0080: x_data--; break; //left
334            case 0x00a0: y_data--; x_data--; break; //up-left
335            case 0x0060: y_data++; x_data--; break; //down-left
336            case 0x0020: y_data++; x_data++; break; //down-right
337            case 0x00e0: y_data--; x_data++; break; //up-right
338         }
339         break;
340      /*wrong...*/
341      case ENEMY:
342         switch(move_data & 0xffff)
343         {
344            case 0x0000: x_data++; break; //right
345            case 0x0040: y_data++; break; //down
346            case 0x00c0: y_data--; break; //up
347            case 0x0080: x_data--; break; //left
348            case 0x00a0: y_data--; x_data--; break; //up-left
349            case 0x0060: y_data++; x_data--; break; //down-left
350            case 0x0020: y_data++; x_data++; break; //down-right
351            case 0x00e0: y_data--; x_data++; break; //up-right
352            default:
353               popmessage("%08x",move_data);
354            break;
355         }
356         break;
357   }
358   /*Write the new values to the sprite x/y data*/
359   program_write_word(work_ram+0x8,x_data);
360   program_write_word(work_ram+0x4,y_data);
361}
362
363#ifdef UNUSED_FUNCTION
364static void protection_move2_jsr(void)
365{
366//  static UINT32 move_data;
367//  popmessage("%08x %08x %08x %08x",ram_addr[0],ram_addr[1],rom_addr[0],rom_addr[1]);
368}
369#endif
370
371static UINT16 hit_check;
372
373static void protection_hit_jsr(UINT32 work_ram1,UINT32 work_ram2)
374{
375   int x1,y1,x2,y2/*,hit1,hit2*/;
376   x1 = (program_read_word(work_ram1+0x8));
377   y1 = (program_read_word(work_ram1+0x4));
378   //hit1 = (program_read_word(work_ram1-));//this sprite is attacking
379   x2 = (program_read_word(work_ram2+0x8));
380   y2 = (program_read_word(work_ram2+0x4));
381   //hit2 = (program_read_word());
382
383   popmessage("%08x:x=%04x y=%04x %08x:x=%04x y=%04x",work_ram1,x1,y1,work_ram2,x2,y2);
384
385   if((x1 >= (x2-0x80)) &&
386      (x1 <= (x2+0x80)) &&
387      (y1 >= (y2-3))  &&
388      (y1 <= (y2+3)))
389      hit_check = 0;
390   else
391      hit_check = 0xffff;
392}
393
394/*directional movement protection*/
395static void moveprot_jsr(void)
396{
397   static INT16 x_axis,y_axis;
398   static UINT16 move_data,distance,move_type;
399   move_data = program_read_word(ram_addr[0]+0x36);
400   x_axis = program_read_word(ram_addr[0]+0x08);
401   y_axis = program_read_word(ram_addr[0]+0x04);
402
403   distance = (move_data & 0xf);
404   move_type = (move_data & 0xf0)>>4;
405   switch(move_type)
406   {
407      case 0x0f://right
408         program_write_word(ram_addr[0]+0x08,x_axis+distance);
409         //program_write_word(0x110004,);
410         break;
411      case 0x0b://up
412         program_write_word(ram_addr[0]+0x04,y_axis-distance);
413         break;
414      case 0x07://left
415         program_write_word(ram_addr[0]+0x08,x_axis-distance);
416         break;
417      case 0x03://down
418         program_write_word(ram_addr[0]+0x04,y_axis+distance);
419         break;
420      case 0x0d://up-right
421         program_write_word(ram_addr[0]+0x08,x_axis+distance);
422         program_write_word(ram_addr[0]+0x04,y_axis-distance);
423         break;
424      case 0x09://up-left
425         program_write_word(ram_addr[0]+0x04,y_axis-distance);
426         program_write_word(ram_addr[0]+0x08,x_axis-distance);
427         break;
428      case 0x01://down-right
429         program_write_word(ram_addr[0]+0x04,y_axis+distance);
430         program_write_word(ram_addr[0]+0x08,x_axis+distance);
431         break;
432      case 0x05://down-left
433         program_write_word(ram_addr[0]+0x04,y_axis+distance);
434         program_write_word(ram_addr[0]+0x08,x_axis-distance);
435         break;
436      default:
437         logerror("Warning: \"0x205\" command called with move_type parameter = %02x\n",move_type);
438
439         //down-right
440         //down-left
441   }
442   //program_write_word(0x110008,x_axis+tmp);
443   //program_write_word(0x110004,y_axis+tmp);
444
445   //program_write_word(0x110008,x_axis);
446   //program_write_word(0x110004,y_axis);
447}
448
449/*
45000454E: 3028 0008                move.w  ($8,A0), D0 ;player
451004552: 3228 000C                move.w  ($c,A0), D1
452004556: 342B 0008                move.w  ($8,A3), D2 ;enemy
45300455A: 362B 000C                move.w  ($c,A3), D3
45400455E: 33C0 0011 0048           move.w  D0, $110048.l ;player x
455004564: 33C1 0011 0044           move.w  D1, $110044.l ;player y
45600456A: 33C2 0011 0008           move.w  D2, $110008.l ;enemy x
457004570: 33C3 0011 0004           move.w  D3, $110004.l ;enemy y
458
459*/
460/*sprite "look" protection*/
461static void move2prot_jsr(void)
462{
463   static INT16 x_pl,y_pl,x_en,y_en,res;
464   x_pl = program_read_word(ram_addr[1]+0x8);
465   y_pl = program_read_word(ram_addr[1]+0x4);
466   x_en = program_read_word(ram_addr[0]+0x8);
467   y_en = program_read_word(ram_addr[0]+0x4);
468
469   res = 0;
470   if(x_en > x_pl)
471      res|=0x80;
472
473   if((x_en > x_pl-0x20) && (x_en < x_pl+0x20))
474      res|=0x40;
475//...
476   //if(y_en > y_pl)
477   //  res|=0x40;
478
479   program_write_word(ram_addr[0]+0x36,res);
480}
481
482#ifdef UNUSED_FUNCTION
483/*"To point" movement protection*/
484static void move3x_prot_jsr(void)
485{
486   static INT16 x_pl,x_en,x_dis;
487   x_pl = program_read_word(ram_addr[1]+0x8);
488   x_en = program_read_word(ram_addr[0]+0x8);
489   x_dis = ((program_read_word(ram_addr[0]+0x34) & 0xf0) >> 4);
490
491   if(x_en > x_pl)
492      x_dis^=0xffff;
493
494   program_write_word(ram_addr[0]+0x36,-0x40);/*enable command*/
495   program_write_word(ram_addr[0]+0x14,x_dis);
496}
497
498static void move3y_prot_jsr(void)
499{
500   static INT16 y_pl,y_en,y_dis;
501   y_pl = program_read_word(ram_addr[1]+0x4);
502   y_en = program_read_word(ram_addr[0]+0x4);
503   y_dis = (program_read_word(ram_addr[0]+0x34) & 0xf);
504
505   if(y_en > y_pl)
506      y_dis^=0xffff;
507
508   program_write_word(ram_addr[0]+0x36,-0x80);/*enable command*/
509   program_write_word(ram_addr[0]+0x10,y_dis);
510}
511#endif
512
513
514static READ16_HANDLER( mcu_r )
515{
516   switch (offset)
517   {
518      /* Protection is not understood */
519
520      case (0x470/2):   /* read PC $110a, could be some sort of control word:
521                sometimes a bit is changed then it's poked back in... */
522         return (mame_rand(Machine) &0xffff);
523
524      case (0x582/2):   /* read PC $3594 */
525         return (0);
526
527      case (0x584/2):   /* read PC $3588 */
528         return (0);
529
530      case (0x586/2):   /* read PC $35a0 */
531         return (0);
532
533      case (0x588/2):   /* read PC $3580 */
534         return hit_check;
535
536      case (0x5b0/2):   /* bit 15 is branched on a few times in the $3300 area */
537         return (0);
538
539      case (0x5b4/2):   /* read and stored in ram before +0x5b0 bit 15 tested */
540         return (0);
541
542      /* Non-protection reads */
543
544      case (0x708/2):   /* seibu sound: these three around $b10 on */
545         return seibu_main_word_r(machine,2,0);
546
547      case (0x70c/2):
548         return seibu_main_word_r(machine,3,0);
549
550      case (0x714/2):
551         return seibu_main_word_r(machine,5,0);
552
553      /* Inputs */
554
555      case (0x740/2):   /* code at $b00 sticks waiting for bit 6 hi */
556         return input_port_1_word_r(machine,0,0);
557
558      case (0x744/2):
559         return input_port_2_word_r(machine,0,0);
560
561      case (0x748/2):   /* code at $f4a reads this 4 times in _weird_ fashion */
562         return input_port_0_word_r(machine,0,0);
563
564      case (0x74c/2):
565         return input_port_3_word_r(machine,0,0);
566
567   }
568//logerror("CPU0 PC %06x unknown MCU read offset: %04x\n",activecpu_get_previouspc(),offset);
569
570   return mcu_ram[offset];
571}
572
573static WRITE16_HANDLER( mcu_w )
574{
575   COMBINE_DATA(&mcu_ram[offset]);
576
577   switch (offset)
578   {
579
580      case (0x4c0/2):
581      {
582         /*---- ---- ---- ---- xxxx xxxx xxxx xxxx*/
583         prot_data[0] = mcu_ram[offset];
584         ram_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
585         break;
586      }
587
588      case (0x4a0/2):
589      {
590         /*xxxx xxxx xxxx xxxx ---- ---- ---- ----*/
591         prot_data[1] = mcu_ram[offset];
592         ram_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
593         break;
594      }
595
596      case (0x4c2/2):
597      {
598         /*---- ---- ---- ---- xxxx xxxx xxxx xxxx*/
599         prot_data[0] = mcu_ram[offset];
600         ram_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
601         break;
602      }
603
604      case (0x4a2/2):
605      {
606         /*xxxx xxxx xxxx xxxx ---- ---- ---- ----*/
607         prot_data[1] = mcu_ram[offset];
608         ram_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
609         break;
610      }
611
612      case (0x4c4/2):
613      {
614         /*---- ---- ---- ---- xxxx xxxx xxxx xxxx*/
615         prot_data[0] = mcu_ram[offset];
616         rom_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
617         break;
618      }
619
620      case (0x4a4/2):
621      {
622         /*xxxx xxxx xxxx xxxx ---- ---- ---- ----*/
623         prot_data[1] = mcu_ram[offset];
624         rom_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
625         break;
626      }
627
628      case (0x4c6/2):
629      {
630         /*---- ---- ---- ---- xxxx xxxx xxxx xxxx*/
631         prot_data[0] = mcu_ram[offset];
632         rom_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
633         break;
634      }
635
636      case (0x4a6/2):
637      {
638         /*xxxx xxxx xxxx xxxx ---- ---- ---- ----*/
639         prot_data[1] = mcu_ram[offset];
640         rom_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
641         break;
642      }
643
644      case (0x500/2):
645      {
646         /*Movement protection*/
647         if(mcu_ram[0x500/2] == 0x8900 || mcu_ram[0x500/2] == 0x0205)
648         {
649            static UINT16 xy_data[2];
650            static UINT8 k;
651            xy_data[0] = program_read_word(rom_addr[0]);
652            xy_data[1] = program_read_word(rom_addr[1]);
653            k = (mcu_ram[0x500/2] == 0x0205) ? ENEMY : PLAYER;
654            protection_move_jsr(ram_addr[0],k);
655            //protection_move_jsr(ram_addr[1]); //???
656            //popmessage("%08x %08x %04x %04x",ram_addr[0],ram_addr[1],xy_data[0],xy_data[1]);
657         }
658         else if(mcu_ram[0x500/2] == 0x3bb0 || mcu_ram[0x500/2] == 0x138e)
659         {
660            protection_hit_jsr(ram_addr[0],ram_addr[1]);
661         }
662         break;
663      }
664
665      // 61a bit 0 is flipscreen
666      // 61c probably layer disables, like Dcon
667      // 620 - 62a scroll control;  is there a layer priority switch...?
668
669      case (0x620/2):
670      {
671         legionna_scrollram16[0] = mcu_ram[offset];
672         break;
673      }
674      case (0x622/2):
675      {
676         legionna_scrollram16[1] = mcu_ram[offset];
677         break;
678      }
679      case (0x624/2):
680      {
681         legionna_scrollram16[2] = mcu_ram[offset];
682         break;
683      }
684      case (0x626/2):
685      {
686         legionna_scrollram16[3] = mcu_ram[offset];
687         break;
688      }
689      case (0x628/2):
690      {
691         legionna_scrollram16[4] = mcu_ram[offset];
692         break;
693      }
694      case (0x62a/2):
695      {
696         legionna_scrollram16[5] = mcu_ram[offset];
697         break;
698      }
699      case (0x700/2):   /* seibu(0) */
700      {
701         seibu_main_word_w(machine,0,mcu_ram[offset],0xff00);
702         break;
703      }
704      case (0x704/2):   /* seibu(1) */
705      {
706         seibu_main_word_w(machine,1,mcu_ram[offset],0xff00);
707         break;
708      }
709      case (0x710/2):   /* seibu(4) */
710      {
711         seibu_main_word_w(machine,4,mcu_ram[offset],0xff00);
712         break;
713      }
714      case (0x718/2):   /* seibu(6) */
715      {
716         seibu_main_word_w(machine,6,mcu_ram[offset],0xff00);
717         break;
718      }
719//      default:
720//logerror("CPU0 PC %06x unknown MCU write offset: %04x data: %04x\n",activecpu_get_previouspc(),offset,data);
721   }
722}
723
724
725
726/*
727player-1 priorities list:
7281086d8: show this sprite (bit 15)
7291086dc: lives (BCD,bits 3,2,1,0)
7301086de: energy bar (upper byte)
7311086e0: walk animation (lower byte)
7321086ec: "death" status (bit 15)
7331086f4: sprite y axis
7341086f0: sprite x axis
735
736Sprite DMA TODO:
737-sprite priorities,likely to be a protection issue because in-game sprites MUST
738 be behind the foreground layer but the attract mode logos (the ones used when
739 the story is explained) should be above it.They both use 0 as priority number.
740-sprites at the very left border disappears.
741-some bullets STILL remains on screen?
742-3rd mid-boss disappears (0x1f0),2nd boss lasers wrong positioning
743
744spriteram DMA [1]
745001DE4: 3086                     move.w  D6, (A0) ;$100400,color + other stuff
746001DE6: 2440                     movea.l D0, A2
747001DE8: 0269 0004 0002           andi.w  #$4, ($2,A1)
748001DEE: 3152 000C                move.w  (A2), ($c,A0) ;DMA size
749001DF2: 3145 0002                move.w  D5, ($2,A0)
750001DF6: 0245 0040                andi.w  #$40, D5
751001DFA: 2009                     move.l  A1, D0
752001DFC: 3140 00C0                move.w  D0, ($c0,A0) ;RAM -> $1004c0 (work ram index?)
753001E00: 4840                     swap    D0
754001E02: 3140 00A0                move.w  D0, ($a0,A0) ;RAM -> $1004a0
755001E06: 200A                     move.l  A2, D0
756001E08: 3140 0014                move.w  D0, ($14,A0) ;$ROM lo -> $100414 src
757001E0C: 4840                     swap    D0
758001E0E: 3140 0012                move.w  D0, ($12,A0) ;$ROM hi -> $100412
759001E12: 2679 0010 8116           movea.l $108116.l, A3 ;points to dst spriteram
760001E18: 3839 0010 810A           move.w  $10810a.l, D4 ;spriteram index
761001E1E: 260B                     move.l  A3, D3
762001E20: 3143 00C8                move.w  D3, ($c8,A0) ;sets the dst spriteram
763001E24: 4843                     swap    D3
764001E26: 3143 00A8                move.w  D3, ($a8,A0)
765001E2A: 45EA 0004                lea     ($4,A2), A2
766//at this point we're ready for DMAing
767001E2E: 317C A180 0100           move.w  #$a180, ($100,A0) ;<-DMA parameters!?
768001E34: 317C 6980 0102           move.w  #$6980, ($102,A0) ;<-""
769001E3A: 317C C480 0102           move.w  #$c480, ($102,A0) ;<-""
770001E40: 317C 0000 0010           move.w  #$0, ($10,A0)     ;<-""
771001E46: 302A 0002                move.w  ($2,A2), D0
772001E4A: 816B 0006                or.w    D0, ($6,A3)
773001E4E: 45EA 0006                lea     ($6,A2), A2
774001E52: 302B 0008                move.w  ($8,A3), D0
775001E56: B079 0010 8112           cmp.w   $108112.l, D0
776001E5C: 6E00 0054                bgt     $1eb2
777001E60: B079 0010 8110           cmp.w   $108110.l, D0
778001E66: 6D00 004A                blt     $1eb2
779001E6A: 026B 7FFF 000A           andi.w  #$7fff, ($a,A3)
780001E70: 8B6B 0004                or.w    D5, ($4,A3)
781001E74: 47EB 0008                lea     ($8,A3), A3
782001E78: 260B                     move.l  A3, D3
783001E7A: 3143 00C8                move.w  D3, ($c8,A0)
784001E7E: 4843                     swap    D3
785001E80: 3143 00A8                move.w  D3, ($a8,A0)
786001E84: 5244                     addq.w  #1, D4
787001E86: B879 0010 8114           cmp.w   $108114.l, D4
788001E8C: 6500 000C                bcs     $1e9a
789001E90: 0069 0002 0002           ori.w   #$2, ($2,A1)
790001E96: 6000 000C                bra     $1ea4
791//Note: I believe the above program is there just for protection copy
792001E9A: 3028 01B0                move.w  ($1b0,A0), D0 ;bit 1 = DMA job finished
793001E9E: 0240 0002                andi.w  #$2, D0
794001EA2: 6790                     beq     $1e34
795001EA4: 33C4 0010 810A           move.w  D4, $10810a.l
796001EAA: 23CB 0010 8116           move.l  A3, $108116.l
797001EB0: 4E75                     rts
798
799x/y check [2]
800002030: E58D                     lsl.l   #2, D5
801002032: 0685 0003 0000           addi.l  #$30000, D5
802002038: 33C5 0010 04C4           move.w  D5, $1004c4.l
80300203E: 4845                     swap    D5
804002040: 33C5 0010 04A4           move.w  D5, $1004a4.l
805002046: E58E                     lsl.l   #2, D6
806002048: 0686 0003 0000           addi.l  #$30000, D6
80700204E: 33C6 0010 04C6           move.w  D6, $1004c6.l
808002054: 4846                     swap    D6
809002056: 33C6 0010 04A6           move.w  D6, $1004a6.l
81000205C: 33FC A180 0010 0500      move.w  #$a180, $100500.l
811002064: 33FC B100 0010 0500      move.w  #$b100, $100500.l
81200206C: 33FC A980 0010 0500      move.w  #$a980, $100500.l
813002074: 33FC B900 0010 0500      move.w  #$b900, $100500.l
81400207C: 4E75                     rts
815[...]
816//then reads at $580
817
818*/
819
820static UINT16 s_i;
821
822static void dma_transfer(void)
823{
824   static UINT16 rel_xy;
825   static UINT16 abs_x,abs_y;
826   static UINT16 param;
827
828   //for(s_i = dma_size;s_i > 0;s_i--)
829   {
830      /*Sprite Color*/
831      param = program_read_word(0x100400) & 0x3f;
832      /*Write the entire parameters [offs+0]*/
833      program_write_word(dma_dst,program_read_word(dma_src) + param);
834      /*Sprite Priority (guess)*/
835      //param = ((program_read_word(0x100400) & 0x40) ? 0x4000 : 0);
836      /*Write the sprite number [offs+1]*/
837      program_write_word(dma_dst+2,program_read_word(dma_src+2));
838      /*Sprite Relative x/y coords*/
839      rel_xy = program_read_word(dma_src+4); /*???*/
840      /*temporary hardwired,it should point to 0x4c0/0x4a0*/
841      abs_x = (program_read_word(0x110008) - program_read_word(0x10048e));
842      abs_y = (program_read_word(0x110004) - program_read_word(0x10048c));
843      program_write_word(dma_dst+4,((rel_xy & 0x7f) + (abs_x) - ((rel_xy & 0x80) ? 0x80 : 0)) & 0x1ff);
844      program_write_word(dma_dst+6,(((rel_xy & 0x7f00) >> 8) + (abs_y) + (0x10) - ((rel_xy & 0x8000) ? 0x80 : 0)) & 0x1ff);
845      dma_dst+=8;
846      dma_src+=6;
847   }
848}
849
850
851/*
852    switch(program_read_word(hit_check_x))
853    {
854        case 0xb4: xparam = 0x0c/2; break;
855        case 0xb8: xparam = 0x10/2; break;
856        case 0xbc: xparam = 0x14/2; break;
857        case 0xc0: xparam = 0x18/2; break;
858        case 0xc4: xparam = 0x1c/2; break;
859        case 0xd4: xparam = 0x20/2; break;
860        ...
861        case 0xb0: xparam = 0x08/2;
862        case 0xac: xparam = 0x04/2;
863    }
864*/
865static UINT16 check_calc(UINT16 param)
866{
867   UINT16 num,i;
868
869   i = param;
870   i-=0xac;
871   i/=4;
872   num = (0x4/2);
873   for(;i>0;i--)
874      num+=(0x4/2);
875
876   return num;
877}
878
879static UINT16 hit_check_jsr(void)
880{
881   static INT16 xsrc,xdst,ysrc,ydst,xparam,yparam;
882   xsrc = (program_read_word(0x110008));
883   ysrc = (program_read_word(0x110004));
884   xdst = (program_read_word(0x110048));
885   ydst = (program_read_word(0x110044));
886
887   /*Here we check the destination sprite width*/
888   /*0x4a4/0x4c4*/
889   xparam = check_calc(program_read_word(hit_check_x));
890   /*Here we check the destination sprite height*/
891   /*0x4a6/0x4c6*/
892   yparam = check_calc(program_read_word(hit_check_y));
893
894   if(!xparam || !yparam)
895      popmessage("SRC:%04x %04x DST:%04x %04x V:%08x %08x",xsrc,ysrc,xdst,ydst,program_read_word(hit_check_x),program_read_word(hit_check_y));
896   if(xdst >= (xsrc-xparam) && ydst >= (ysrc-yparam) &&
897      xdst <= (xsrc+xparam) && ydst <= (ysrc+yparam))
898      return 0;//sprites collide
899   else
900      return 3;//sprites do not collide
901}
902
903#define UP         0xc0
904#define UP_RIGHT    0xe0
905#define RIGHT       0x00
906#define DOWN_RIGHT   0x20
907#define DOWN      0x40
908#define DOWN_LEFT   0x60
909#define LEFT      0x80
910#define UP_LEFT      0xa0
911
912/*Heated Barrel*/
913/*command 0x8100 will check for the direction of the sprite*/
914/*command 0x8900 will check the "point" movement*/
915static void cop2_move3_prot(void)
916{
917   static INT16 x_pl,x_en;
918   static INT16 y_pl,y_en;
919   static INT16 x_dis,y_dis;
920   static INT16 dir,dis;
921   x_pl = program_read_word(ram_addr[1]+0x8);
922   x_en = program_read_word(ram_addr[0]+0x8);
923   dis = ((program_read_word(ram_addr[0]+0x34) & 0xf0) >> 4);
924   y_pl = program_read_word(ram_addr[1]+0x4);
925   y_en = program_read_word(ram_addr[0]+0x4);
926
927   /*
928    xxxx ---- select the direction of the enemy sprite
929
930                        0xc0 up
931          up-left   0xa0  |  0xe0 up-right
932         left    0x80   <-o->  0x00 right
933        down-left   0x60  |  0x20 down-right
934                        0x40 down
935    */
936
937   if(x_en >= x_pl)
938   {
939      if((y_en >= (y_pl-0x10)) && (y_en <= (y_pl+0x10)))
940         dir = LEFT;
941      else if(y_en < (y_pl-0x10))
942         dir = DOWN_LEFT;
943      else if(y_en > (y_pl+0x10))
944         dir = UP_LEFT;
945   }
946   else if(x_en < x_pl)
947   {
948      if((y_en >= (y_pl-0x10)) && (y_en <= (y_pl+0x10)))
949         dir = RIGHT;
950      else if(y_en < (y_pl-0x10))
951         dir = DOWN_RIGHT;
952      else if(y_en > (y_pl+0x10))
953         dir = UP_RIGHT;
954   }
955   /*UP DOWN cases*/
956   if((x_en >= (x_pl-0x10)) && (x_en <= (x_pl+0x10)))
957   {
958      if(y_en >= y_pl)
959         dir = UP;
960      else if(y_en < y_pl)
961         dir = DOWN;
962   }
963
964   program_write_word(ram_addr[0]+0x36,dir);
965
966   /*TODO*/
967   x_dis = (x_pl-x_en);
968   y_dis = (y_pl-y_en);
969
970   if(x_dis > 4)
971      x_dis = 4;
972
973   if(x_dis < -4)
974      x_dis = -4;
975
976   if(y_dis > 4)
977      y_dis = 4;
978
979   if(y_dis < -4)
980      y_dis = -4;
981
982   //if(y_en > y_pl)
983   //  y_dis^=0xffff;
984
985   //if(x_en > x_pl)
986   //  x_dis^=0xffff;
987
988   program_write_word(ram_addr[0]+0x10,y_dis);
989   program_write_word(ram_addr[0]+0x14,x_dis);
990}
991
992/**/
993static UINT16 cop2_hit_prot(void)
994{
995   static INT16 xsrc,xdst;
996   static INT16 ysrc,ydst;
997   static INT16 xp,yp;
998   static INT16 param1,param2;
999   static INT16 val;
1000
1001   param1 = program_read_word(rom_addr[0]);
1002   param2 = program_read_word(rom_addr[1]);
1003
1004   xsrc = program_read_word(ram_addr[0]+0x8) + program_read_word(ram_addr[0]+0x14);
1005   ysrc = program_read_word(ram_addr[0]+0x4) + program_read_word(ram_addr[0]+0x10);
1006   xdst = program_read_word(ram_addr[1]+0x8) + program_read_word(ram_addr[1]+0x14);
1007   ydst = program_read_word(ram_addr[1]+0x4) + program_read_word(ram_addr[1]+0x10);
1008
1009//  xp = (param1 & 0x00f0) >> 4;
1010//  yp = (param1 & 0x0f00) >> 8;
1011
1012//  popmessage("%04x %04x",param1,param2);
1013
1014   xp = 0;
1015   yp = 0;
1016   for(val = ((param1 & 0xff0) >> 4); val > 0; val-=5)
1017      xp++;
1018
1019   for(val = ((param1 & 0xff0) >> 4); val > 0; val-=3)
1020      yp++;
1021
1022   /*TODO*/
1023//  xp+=4;
1024//  yp+=4;
1025
1026   if(xsrc >= xdst && xsrc <= xdst+xp && ysrc >= xdst && ysrc <= ydst+yp)
1027      return 0;
1028   else
1029      return 3;
1030}
1031
1032static void cop2_move2_prot(void)
1033{
1034   static INT16 xsrc,ysrc;
1035   static INT16 param2;
1036
1037   xsrc = program_read_word(ram_addr[0]+0x14);
1038   ysrc = program_read_word(ram_addr[0]+0x10);
1039   param2 = program_read_word(rom_addr[1]);
1040
1041   switch(param2)
1042   {
1043      case 0x10:   xsrc++; break; //right
1044      case 0x30:   xsrc--; break; //left
1045      case 0x40:  ysrc--; break; //up
1046      case 0x60:    ysrc++; break; //down
1047      case 0x08:  ysrc--; xsrc++; break; //up-right
1048      case 0x38:   ysrc--; xsrc--; break; //up-left
1049      case 0x28:    ysrc++; xsrc--; break; //down-left
1050      case 0x18:  ysrc++; xsrc++; break; //down-right
1051   }
1052
1053   program_write_word(ram_addr[0]+0x14,xsrc);
1054   program_write_word(ram_addr[0]+0x10,ysrc);
1055}
1056
1057
1058static READ16_HANDLER( cop2_mcu_r )
1059{
1060   switch (offset)
1061   {
1062      /* Protection is not understood */
1063
1064      /*hit protection*/
1065      case (0x580/2):
1066      {
1067         return xy_check;
1068      }
1069      case (0x582/2):
1070      {
1071         if(input_code_pressed(KEYCODE_X))
1072            return 0;//xy_check;
1073         else
1074            return 3;
1075      }
1076      case (0x584/2):
1077      {
1078         /*---- ---- ---- --xx used bits*/
1079         //if(!xy_check)
1080         //{
1081         //  xy_check = 3;
1082         //  return 0;
1083         //}
1084         //else return 3;
1085         if(input_code_pressed(KEYCODE_C))
1086            return 0;//xy_check;
1087         else
1088            return 3;
1089      }
1090
1091      /*number protection*/
1092      case (0x590/2):
1093      {
1094         /*BCD read*/
1095         return (prot_bcd[0] & 0xffff) + 0x3030;
1096      }
1097      case (0x592/2):
1098      {
1099         return ((prot_bcd[0] & 0xffff0000) >> 16) + 0x3030;
1100      }
1101      case (0x594/2):
1102      {
1103         return (prot_bcd[1] & 0xffff) + 0x3030;
1104      }
1105      case (0x596/2):
1106      {
1107         return ((prot_bcd[1] & 0xffff0000) >> 16) + 0x3030;
1108      }
1109      case (0x598/2):
1110      {
1111         return (prot_bcd[2] & 0xffff) + 0x3030;
1112      }
1113      case (0x59a/2):
1114      {
1115         return ((prot_bcd[2] & 0xffff0000) >> 16) + 0x3030;
1116      }
1117      case (0x59c/2):
1118      {
1119         return 0x3030;
1120      }
1121
1122      case (0x5b0/2):   /* bit 15 is branched on a few times in the $1938 area */
1123         return (mcu_ram[offset]);
1124
1125      case (0x5b4/2):   /* read at $1932 and stored in ram before +0x5b0 bit 15 tested */
1126         return (0);
1127
1128      /* Non-protection reads */
1129
1130      case (0x7c8/2):   /* seibu sound */
1131         return seibu_main_word_r(machine,2,0);
1132
1133      case (0x7cc/2):
1134         return seibu_main_word_r(machine,3,0);
1135
1136      case (0x7d4/2):
1137         return seibu_main_word_r(machine,5,0);
1138
1139      /* Inputs */
1140
1141      case (0x740/2):
1142         return input_port_1_word_r(machine,0,0);
1143
1144      case (0x744/2):
1145         return input_port_2_word_r(machine,0,0);
1146
1147      case (0x748/2):
1148         return input_port_4_word_r(machine,0,0);
1149
1150      case (0x74c/2):
1151         return input_port_3_word_r(machine,0,0);
1152
1153   }
1154//logerror("CPU0 PC %06x unknown MCU read offset: %04x\n",activecpu_get_previouspc(),offset);
1155
1156   return mcu_ram[offset];
1157}
1158
1159static WRITE16_HANDLER( cop2_mcu_w )
1160{
1161   COMBINE_DATA(&mcu_ram[offset]);
1162
1163   switch (offset)
1164   {
1165      case (0x470/2):
1166      {
1167         heatbrl_setgfxbank( mcu_ram[offset] );
1168         break;
1169      }
1170
1171      /*"Number protection" sub-routine*/
1172      case (0x420/2):
1173      {
1174         //coin counter write
1175         //popmessage("%04x",mcu_ram[offset]);
1176         prot_bcd[0] = protection_bcd_jsr(mcu_ram[offset]);
1177         //prot_bcd = mcu_ram[offset] - 0x22;
1178         break;
1179      }
1180      case (0x422/2):
1181      {
1182         prot_bcd[1] = protection_bcd_jsr(mcu_ram[offset]);
1183         break;
1184      }
1185
1186      case (0x478/2):
1187      {
1188         static UINT16 i;
1189         /*
1190            AM_RANGE(0x100800, 0x100fff) AM_WRITE(legionna_background_w) AM_BASE(&legionna_back_data)
1191            AM_RANGE(0x101000, 0x1017ff) AM_WRITE(legionna_foreground_w) AM_BASE(&legionna_fore_data)
1192            AM_RANGE(0x101800, 0x101fff) AM_WRITE(legionna_midground_w) AM_BASE(&legionna_mid_data)
1193            AM_RANGE(0x102000, 0x102fff) AM_WRITE(legionna_text_w) AM_BASE(&legionna_textram)
1194            */
1195         switch(mcu_ram[offset])
1196         {
1197            /*layer clearance*/
1198            case 0x4080:
1199            /*text layer*/
1200            for(i=0;i<0x1000;i+=2)
1201               program_write_word(i+0x102000,0x0000);
1202            /*background layer*/
1203            for(i=0;i<0x800;i+=2)
1204               program_write_word(i+0x100800,0x0000);
1205            break;
1206            case 0x4100: break;
1207            case 0x41c0: break;
1208            //default: popmessage("%04x",mcu_ram[offset]);
1209         }
1210         break;
1211      }
1212
1213      /*sprite ram clear(Guess)*/
1214      case (0x47e/2):
1215      {
1216         static UINT16 i;
1217         if(mcu_ram[0x47e/2] == 0x118)
1218         {
1219            for(i=0;i<0x800;i+=2)
1220               program_write_word((0x103000 | i),0x0000);
1221         }
1222         break;
1223      }
1224
1225      // 65a bit 0 is flipscreen
1226      // 65c probably layer disables, like Dcon? Used on screen when you press P1-4 start (values 13, 11, 0 seen)
1227      // 660 - 66a scroll control;  is there a layer priority switch...?
1228      case (0x4c0/2):
1229      {
1230         /*---- ---- ---- ---- xxxx xxxx xxxx xxxx*/
1231         prot_data[0] = mcu_ram[offset];
1232         ram_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1233         break;
1234      }
1235
1236      case (0x4a0/2):
1237      {
1238         /*xxxx xxxx xxxx xxxx ---- ---- ---- ----*/
1239         prot_data[1] = mcu_ram[offset];
1240         ram_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1241         break;
1242      }
1243
1244      case (0x4c2/2):
1245      {
1246         /*---- ---- ---- ---- xxxx xxxx xxxx xxxx*/
1247         prot_data[0] = mcu_ram[offset];
1248         ram_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1249         break;
1250      }
1251
1252      case (0x4a2/2):
1253      {
1254         /*xxxx xxxx xxxx xxxx ---- ---- ---- ----*/
1255         prot_data[1] = mcu_ram[offset];
1256         ram_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1257         break;
1258      }
1259
1260
1261      /*Hit Check x address*/
1262      case (0x4c4/2):
1263      {
1264         /*---- ---- ---- ---- xxxx xxxx xxxx xxxx*/
1265         prot_data[0] = mcu_ram[offset];
1266         rom_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1267         break;
1268      }
1269
1270      case (0x4a4/2):
1271      {
1272         /*xxxx xxxx xxxx xxxx ---- ---- ---- ----*/
1273         prot_data[1] = mcu_ram[offset];
1274         rom_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1275         break;
1276      }
1277
1278      /*Hit Check y address*/
1279      case (0x4c6/2):
1280      {
1281         /*---- ---- ---- ---- xxxx xxxx xxxx xxxx*/
1282         prot_data[0] = mcu_ram[offset];
1283         rom_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1284         break;
1285      }
1286
1287      case (0x4a6/2):
1288      {
1289         /*xxxx xxxx xxxx xxxx ---- ---- ---- ----*/
1290         prot_data[1] = mcu_ram[offset];
1291         rom_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1292         break;
1293      }
1294
1295      case (0x500/2):
1296      {
1297         switch(mcu_ram[0x500/2])
1298         {
1299            case 0x8100:
1300               break;
1301            case 0x8900:
1302            {
1303               cop2_move3_prot();
1304               break;
1305            }
1306            case 0x205:
1307            {
1308               cop2_move2_prot();
1309               break;
1310            }
1311            case 0xa100:
1312               break;
1313            case 0xb080:
1314               break;
1315            case 0xa900:
1316               break;
1317            case 0xb880:
1318            {
1319               xy_check = cop2_hit_prot();
1320               break;
1321            }
1322            default:
1323               logerror("DMA CMD 0x500 with parameter = %04x PC = %08x\n",mcu_ram[offset],activecpu_get_previouspc());
1324         }
1325         break;
1326      }
1327
1328
1329      case (0x660/2):
1330      {
1331         legionna_scrollram16[0] = mcu_ram[offset];
1332         break;
1333      }
1334      case (0x662/2):
1335      {
1336         legionna_scrollram16[1] = mcu_ram[offset];
1337         break;
1338      }
1339      case (0x664/2):
1340      {
1341         legionna_scrollram16[2] = mcu_ram[offset];
1342         break;
1343      }
1344      case (0x666/2):
1345      {
1346         legionna_scrollram16[3] = mcu_ram[offset];
1347         break;
1348      }
1349      case (0x668/2):
1350      {
1351         legionna_scrollram16[4] = mcu_ram[offset];
1352         break;
1353      }
1354      case (0x66a/2):
1355      {
1356         legionna_scrollram16[5] = mcu_ram[offset];
1357         break;
1358      }
1359      case (0x7c0/2):   /* seibu(0) */
1360      {
1361         seibu_main_word_w(machine,0,mcu_ram[offset],0xff00);
1362         break;
1363      }
1364      case (0x7c4/2):   /* seibu(1) */
1365      {
1366         seibu_main_word_w(machine,1,mcu_ram[offset],0xff00);
1367         break;
1368      }
1369      case (0x7d0/2):   /* seibu(4) */
1370      {
1371         seibu_main_word_w(machine,4,mcu_ram[offset],0xff00);
1372         break;
1373      }
1374      case (0x7d8/2):   /* seibu(6) */
1375      {
1376         seibu_main_word_w(machine,6,mcu_ram[offset],0xff00);
1377         break;
1378      }
1379      default:
1380logerror("CPU0 PC %06x unknown MCU write offset: %04x data: %04x\n",activecpu_get_previouspc(),offset,data);
1381   }
1382}
1383
1384
1385static READ16_HANDLER( sdgndmrb_cop_mcu_r )
1386{
1387   switch (offset)
1388   {
1389      /*hit protection*/
1390      case (0x580/2):
1391      {
1392         /*PC=ce96*/
1393         /*---- ---- ---- --xx used bits*/
1394         //if(!xy_check)
1395         //{
1396         //  xy_check = 3;
1397         //  return 0;
1398         //}
1399         //else return 3;
1400         return xy_check;
1401      }
1402
1403      /*number protection*/
1404      case (0x590/2):
1405      {
1406         /*BCD read*/
1407         return (prot_bcd[0] & 0xffff) + 0x3030;
1408      }
1409      case (0x592/2):
1410      {
1411         return ((prot_bcd[0] & 0xffff0000) >> 16) + 0x3030;
1412      }
1413      case (0x594/2):
1414      {
1415         return (prot_bcd[1] & 0xffff) + 0x3030;
1416      }
1417      case (0x596/2):
1418      {
1419         return ((prot_bcd[1] & 0xffff0000) >> 16) + 0x3030;
1420      }
1421      case (0x598/2):
1422      {
1423         return (prot_bcd[2] & 0xffff) + 0x3030;
1424      }
1425      case (0x59a/2):
1426      {
1427         return ((prot_bcd[2] & 0xffff0000) >> 16) + 0x3030;
1428      }
1429      case (0x59c/2):
1430      {
1431         return 0x3030;
1432      }
1433
1434      case (0x5b0/2):
1435         /*check if the DMA has been finished*/
1436         if(dma_status == 1)
1437         {
1438            dma_status = 0;
1439            return 2;
1440         }
1441         return mcu_ram[offset];
1442
1443      /* Non-protection reads */
1444      case (0x708/2):   /* seibu sound */
1445         return seibu_main_word_r(machine,2,0);
1446
1447      case (0x70c/2):
1448         return seibu_main_word_r(machine,3,0);
1449
1450      case (0x714/2):
1451         return seibu_main_word_r(machine,5,0);
1452
1453      /* Inputs */
1454
1455      case (0x740/2):
1456         return input_port_1_word_r(machine,0,0);
1457
1458      case (0x744/2):
1459         return input_port_2_word_r(machine,0,0);
1460
1461      case (0x748/2):
1462         return input_port_4_word_r(machine,0,0);
1463
1464      case (0x74c/2):
1465         return input_port_3_word_r(machine,0,0);
1466
1467      case (0x75c/2):
1468         return input_port_5_word_r(machine,0,0);
1469   }
1470//  return mame_rand(Machine);
1471     if(offset > (0x500/2) && offset < (0x600/2))
1472     {
1473        logerror("CPU0 PC %06x MCU read offset: %04x\n",activecpu_get_previouspc(),offset*2);
1474      //popmessage("PC %06x MCU read: %04x",activecpu_get_previouspc(),offset*2);
1475   }
1476
1477   return mcu_ram[offset];
1478}
1479
1480static WRITE16_HANDLER( sdgndmrb_cop_mcu_w )
1481{
1482   COMBINE_DATA(&mcu_ram[offset]);
1483
1484   switch (offset)
1485   {
1486      case (0x478/2):
1487      {
1488         static UINT16 i;
1489         /*
1490            AM_RANGE(0x100800, 0x100fff) AM_WRITE(legionna_background_w) AM_BASE(&legionna_back_data)
1491            AM_RANGE(0x101000, 0x1017ff) AM_WRITE(legionna_foreground_w) AM_BASE(&legionna_fore_data)
1492            AM_RANGE(0x101800, 0x101fff) AM_WRITE(legionna_midground_w) AM_BASE(&legionna_mid_data)
1493            AM_RANGE(0x102000, 0x102fff) AM_WRITE(legionna_text_w) AM_BASE(&legionna_textram)
1494            */
1495         switch(mcu_ram[offset])
1496         {
1497            /*txt layer clearance*/
1498            case 0x4080:
1499            for(i=0;i<0x1000;i+=2)
1500               program_write_word(i+0x102000,0x0000);
1501            break;
1502            case 0x4100: break;
1503            case 0x41c0: break;
1504            //default: popmessage("%04x",mcu_ram[offset]);
1505         }
1506         break;
1507      }
1508
1509      /*The following two transfers the index of the work ram that should be picked up,
1510          Both of them are united into one index of 32-bits*/
1511
1512      /*DMA source address*/
1513      case (0x414/2):
1514      {
1515         /*---- ---- ---- ---- xxxx xxxx xxxx xxxx*/
1516         prot_data[0] = mcu_ram[offset];
1517         dma_src = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1518         break;
1519      }
1520
1521      case (0x412/2):
1522      {
1523         /*xxxx xxxx xxxx xxxx ---- ---- ---- ----*/
1524         prot_data[1] = mcu_ram[offset];
1525         dma_src = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1526         break;
1527      }
1528
1529      case (0x4c0/2):
1530      {
1531         /*---- ---- ---- ---- xxxx xxxx xxxx xxxx*/
1532         prot_data[0] = mcu_ram[offset];
1533         ram_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1534         break;
1535      }
1536
1537      case (0x4a0/2):
1538      {
1539         /*xxxx xxxx xxxx xxxx ---- ---- ---- ----*/
1540         prot_data[1] = mcu_ram[offset];
1541         ram_addr[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1542         break;
1543      }
1544
1545      case (0x4c2/2):
1546      {
1547         /*---- ---- ---- ---- xxxx xxxx xxxx xxxx*/
1548         prot_data[0] = mcu_ram[offset];
1549         ram_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1550         break;
1551      }
1552
1553      case (0x4a2/2):
1554      {
1555         /*xxxx xxxx xxxx xxxx ---- ---- ---- ----*/
1556         prot_data[1] = mcu_ram[offset];
1557         ram_addr[1] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1558         break;
1559      }
1560
1561
1562      /*Hit Check x address*/
1563      case (0x4c4/2):
1564      {
1565         /*---- ---- ---- ---- xxxx xxxx xxxx xxxx*/
1566         prot_data[0] = mcu_ram[offset];
1567         hit_check_x = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1568         break;
1569      }
1570
1571      case (0x4a4/2):
1572      {
1573         /*xxxx xxxx xxxx xxxx ---- ---- ---- ----*/
1574         prot_data[1] = mcu_ram[offset];
1575         hit_check_x = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1576         break;
1577      }
1578
1579      /*Hit Check y address*/
1580      case (0x4c6/2):
1581      {
1582         /*---- ---- ---- ---- xxxx xxxx xxxx xxxx*/
1583         prot_data[0] = mcu_ram[offset];
1584         hit_check_y = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1585         break;
1586      }
1587
1588      case (0x4a6/2):
1589      {
1590         /*xxxx xxxx xxxx xxxx ---- ---- ---- ----*/
1591         prot_data[1] = mcu_ram[offset];
1592         hit_check_y = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
1593         break;
1594      }
1595
1596      /*DMA destination address*/
1597      case (0x4c8/2):
1598      {
1599         /*---- ---- ---- ---- xxxx xxxx xxxx xxxx*/
1600         prot_data[0] = mcu_ram[offset];
1601         dma_dst = ((prot_data[0]&0xffff)+4)|((prot_data[1]&0xffff)<<16);
1602         break;
1603      }
1604
1605      case (0x4a8/2):
1606      {
1607         /*xxxx xxxx xxxx xxxx ---- ---- ---- ----*/
1608         prot_data[1] = mcu_ram[offset];
1609         dma_dst = ((prot_data[0]&0xffff)+4)|((prot_data[1]&0xffff)<<16);
1610         break;
1611      }
1612
1613      /*"Number protection" sub-routine*/
1614      case (0x420/2):
1615      {
1616         //coin counter write
1617         //popmessage("%04x",mcu_ram[offset]);
1618         prot_bcd[0] = protection_bcd_jsr(mcu_ram[offset]);
1619         //prot_bcd = mcu_ram[offset] - 0x22;
1620         break;
1621      }
1622
1623      case (0x422/2):
1624      {
1625         prot_bcd[1] = protection_bcd_jsr(mcu_ram[offset]);
1626         break;
1627      }
1628
1629      case (0x424/2):
1630      {
1631         prot_bcd[2] = protection_bcd_jsr(mcu_ram[offset]);
1632         break;
1633      }
1634
1635      /*sprite ram clear(Guess)*/
1636      case (0x47e/2):
1637      {
1638         static UINT16 i;
1639         if(mcu_ram[0x47e/2] == 0x118)
1640         {
1641            for(i=0;i<0x800;i+=2)
1642               program_write_word((0x107000 | i),0x0000);
1643         }
1644         break;
1645      }
1646
1647      case (0x40c/2):
1648      {
1649         dma_size = mcu_ram[offset];
1650         break;
1651      }
1652
1653      case (0x500/2):
1654      {
1655         switch(mcu_ram[0x500/2])
1656         {
1657            case 0xa180:/*do the job [1]*/
1658            {
1659               //popmessage("%08x %08x %04x",dma_src,dma_dst,dma_size);
1660               /*fix the offset for easier reading*/
1661               dma_src+=4;
1662               //dma_dst+=4;
1663               s_i = dma_size;
1664               //dma_dst+=((program_read_word(0x110000) & 0x000f) * 8);
1665               //program_write_word(0x1004c8,dma_dst & 0xffff);
1666               //dma_status = 1;
1667               break;
1668            }
1669            case 0xb100:
1670               break;
1671            case 0xa980:
1672               break;
1673            case 0xb900:
1674            {
1675               xy_check = hit_check_jsr();
1676               break;
1677            }
1678            /*bullet movement protection,conflicts with [3],will be worked out*/
1679            case 0x8100:
1680            {
1681               //move3x_prot_jsr();
1682               break;
1683            }
1684            case 0x8900:
1685            {
1686               //move3y_prot_jsr();
1687               break;
1688            }
1689            case 0x0205:/*do the job [3]*/
1690            {
1691               moveprot_jsr();
1692               break;
1693            }
1694            case 0x138e:/*do the job [4]*/
1695               break;
1696            case 0x3bb0:
1697            {
1698               move2prot_jsr();
1699               break;
1700            }
1701            default:
1702               logerror("DMA CMD 0x500 with parameter = %04x PC = %08x\n",mcu_ram[offset],activecpu_get_previouspc());
1703         }
1704         break;
1705      }
1706
1707      case (0x502/2):
1708      {
1709         if(mcu_ram[0x502/2] == 0xc480)
1710         {
1711            dma_transfer();
1712            s_i--;
1713            if(s_i == 0)
1714               dma_status = 1;
1715         }
1716         break;
1717      }
1718
1719      /* TODO: tilemaps x-axis are offset,we use a temporary kludge for now */
1720      case (0x620/2):
1721      {
1722         legionna_scrollram16[0] = 0x10 + mcu_ram[offset];
1723         break;
1724      }
1725      case (0x622/2):
1726      {
1727         legionna_scrollram16[1] = mcu_ram[offset];
1728         break;
1729      }
1730      case (0x624/2):
1731      {
1732         legionna_scrollram16[2] = 0x10 + mcu_ram[offset];
1733         break;
1734      }
1735      case (0x626/2):
1736      {
1737         legionna_scrollram16[3] = mcu_ram[offset];
1738         break;
1739      }
1740      case (0x628/2):
1741      {
1742         legionna_scrollram16[4] = 0x10 + mcu_ram[offset];
1743         break;
1744      }
1745      case (0x62a/2):
1746      {
1747         legionna_scrollram16[5] = mcu_ram[offset];
1748         break;
1749      }
1750      /* scroll mirrors? */
1751      case (0x62c/2):
1752      case (0x62e/2):
1753      case (0x630/2):
1754      case (0x632/2):
1755      case (0x634/2):
1756      case (0x636/2):
1757         break;
1758      /*Layer Enable,bit wise active low*/
1759      case (0x61c/2):
1760      {
1761         /*
1762            ---x ---- (used in test mode)
1763            ---- x--- Text Layer
1764            ---- -x-- Foreground Layer
1765            ---- --x- Midground Layer
1766            ---- ---x Background Layer
1767            */
1768         sdgndmrb_pri_n = mcu_ram[offset] & 0xf;
1769         break;
1770      }
1771
1772      /* Text Layer scroll registers */
1773      case (0x638/2):
1774      {
1775         legionna_scrollram16[6] = 0x38 + mcu_ram[offset];
1776         break;
1777      }
1778      case (0x63a/2):
1779      {
1780         legionna_scrollram16[7] = mcu_ram[offset];
1781         break;
1782      }
1783      /*C.R.T. Controller (note:game calls it OBJ register)*/
1784      case (0x644/2):
1785         {
1786            /*
1787                data = setting
1788                0x01e = 320x256
1789                0x0e1 = 320x256 REVERSE
1790                0x016 = 320x240
1791                0x0e9 = 320x240 REVERSE
1792                0x004 = 320x224
1793                0x10b = 320x224 REVERSE
1794                It is like to be per cases and not per bits.
1795                */
1796            switch(data)
1797            {
1798               case 0x0000:
1799               case 0x0003:
1800               case 0x001e: CRT_MODE(320,224,0); break;
1801               case 0x00e1: CRT_MODE(320,224,1); break;
1802               case 0x0016: CRT_MODE(320,256,0); break;
1803               case 0x00e9: CRT_MODE(320,256,1); break;
1804               case 0x0004: CRT_MODE(320,240,0); break;
1805               case 0x00fb: CRT_MODE(320,240,1); break;
1806               default:
1807               #ifdef MAME_DEBUG
1808               popmessage("Warning: Undefined CRT Mode %04x",data);
1809               #endif
1810               CRT_MODE(320,256,0);
1811            }
1812         }
1813         break;
1814
1815      /* Seems a mirror for the choices in the test menu... */
1816      case (0x67c/2):
1817      case (0x680/2):
1818         break;
1819      case (0x6fc/2):
1820         break;
1821
1822      case (0x700/2):   /* seibu(0) */
1823      {
1824         seibu_main_word_w(machine,0,mcu_ram[offset],0xff00);
1825         break;
1826      }
1827      case (0x704/2):   /* seibu(1) */
1828      {
1829         seibu_main_word_w(machine,1,mcu_ram[offset],0xff00);
1830         break;
1831      }
1832      case (0x710/2):   /* seibu(4) */
1833      {
1834         seibu_main_word_w(machine,4,mcu_ram[offset],0xff00);
1835         break;
1836      }
1837      case (0x718/2):   /* seibu(6) */
1838      {
1839         seibu_main_word_w(machine,6,mcu_ram[offset],0xff00);
1840         break;
1841      }
1842
1843//      default:
1844//      logerror("CPU0 PC %06x MCU write offset: %04x data: %04x\n",activecpu_get_previouspc(),offset*2,data);
1845//      popmessage("CPU0 PC %06x MCU write offset: %04x data: %04x",activecpu_get_previouspc(),offset*2,data);
1846   }
1847}
1848
1849static READ16_HANDLER( denjinmk_cop_mcu_r )
1850{
1851   switch (offset)
1852   {
1853      /*number protection*/
1854      case (0x590/2):
1855      {
1856         /*BCD read*/
1857         return (prot_bcd[0] & 0xffff) + 0x3030;
1858      }
1859      case (0x592/2):
1860      {
1861         return ((prot_bcd[0] & 0xffff0000) >> 16) + 0x3030;
1862      }
1863      case (0x594/2):
1864      {
1865         return 0x3030;
1866      }
1867      case (0x596/2):
1868      {
1869         return 0x3030;
1870      }
1871      case (0x598/2):
1872      {
1873         return 0x3030;
1874      }
1875      case (0x59a/2):
1876      {
1877         return 0x3030;
1878      }
1879      case (0x59c/2):
1880      {
1881         return 0x3030;
1882      }
1883
1884      /* Non-protection reads */
1885
1886      case (0x708/2):   /* seibu sound */
1887         return seibu_main_word_r(machine,2,0);
1888
1889      case (0x70c/2):
1890         return seibu_main_word_r(machine,3,0);
1891
1892      case (0x714/2):
1893         return seibu_main_word_r(machine,5,0);
1894
1895      /* Inputs */
1896
1897      case (0x740/2):
1898         return input_port_1_word_r(machine,0,0);
1899
1900      case (0x744/2):
1901         return input_port_2_word_r(machine,0,0);
1902
1903      case (0x748/2):
1904         return input_port_4_word_r(machine,0,0);
1905
1906      case (0x74c/2):
1907         return input_port_3_word_r(machine,0,0);
1908
1909   }
1910//logerror("CPU0 PC %06x unknown MCU read offset: %04x\n",activecpu_get_previouspc(),offset);
1911
1912   return mcu_ram[offset];
1913}
1914
1915static WRITE16_HANDLER( denjinmk_cop_mcu_w )
1916{
1917   COMBINE_DATA(&mcu_ram[offset]);
1918
1919   switch (offset)
1920   {
1921      /*"Number protection" sub-routine*/
1922      case (0x420/2):
1923      {
1924         //coin counter write
1925         //popmessage("%04x",mcu_ram[offset]);
1926         prot_bcd[0] = protection_bcd_jsr(mcu_ram[offset]);
1927         //prot_bcd = mcu_ram[offset] - 0x22;
1928         break;
1929      }
1930
1931
1932      case (0x470/2):
1933      {
1934         denjinmk_setgfxbank( mcu_ram[offset] );
1935         break;
1936      }
1937      case (0x620/2):
1938      {
1939         legionna_scrollram16[0] = mcu_ram[offset];
1940         break;
1941      }
1942      case (0x622/2):
1943      {
1944         legionna_scrollram16[1] = mcu_ram[offset];
1945         break;
1946      }
1947      case (0x624/2):
1948      {
1949         legionna_scrollram16[2] = mcu_ram[offset];
1950         break;
1951      }
1952      case (0x626/2):
1953      {
1954         legionna_scrollram16[3] = mcu_ram[offset];
1955         break;
1956      }
1957      case (0x628/2):
1958      {
1959         legionna_scrollram16[4] = mcu_ram[offset];
1960         break;
1961      }
1962      case (0x62a/2):
1963      {
1964         legionna_scrollram16[5] = mcu_ram[offset];
1965         break;
1966      }
1967      case (0x700/2):   /* seibu(0) */
1968      {
1969         seibu_main_word_w(machine,0,mcu_ram[offset],0xff00);
1970         break;
1971      }
1972      case (0x704/2):   /* seibu(1) */
1973      {
1974         seibu_main_word_w(machine,1,mcu_ram[offset],0xff00);
1975         break;
1976      }
1977      case (0x710/2):   /* seibu(4) */
1978      {
1979         seibu_main_word_w(machine,4,mcu_ram[offset],0xff00);
1980         break;
1981      }
1982      case (0x718/2):   /* seibu(6) */
1983      {
1984         seibu_main_word_w(machine,6,mcu_ram[offset],0xff00);
1985         break;
1986      }
1987       //  default:
1988       //  if(offset >= (0x700/2) && offset < (0x800/2))
1989         //printf("CPU0 PC %06x MCU write offset: %04x data: %04x\n",activecpu_get_previouspc(),offset*2,data);
1990   }
1991}
1992
1993static READ16_HANDLER( godzilla_cop_mcu_r )
1994{
1995   switch (offset)
1996   {
1997      /*number protection*/
1998      case (0x590/2):
1999      {
2000         /*BCD read*/
2001         return (prot_bcd[0] & 0xffff) + 0x3030;
2002      }
2003      case (0x592/2):
2004      {
2005         return ((prot_bcd[0] & 0xffff0000) >> 16) + 0x3030;
2006      }
2007      case (0x594/2):
2008      {
2009         return 0x3030;
2010      }
2011      case (0x596/2):
2012      {
2013         return 0x3030;
2014      }
2015      case (0x598/2):
2016      {
2017         return 0x3030;
2018      }
2019      case (0x59a/2):
2020      {
2021         return 0x3030;
2022      }
2023      case (0x59c/2):
2024      {
2025         return 0x3030;
2026      }
2027
2028      /* Non-protection reads */
2029
2030      case (0x7c8/2):   /* seibu sound */
2031         return seibu_main_word_r(machine,2,0);
2032
2033      case (0x7cc/2):
2034         return seibu_main_word_r(machine,3,0);
2035
2036      case (0x7d4/2):
2037         return seibu_main_word_r(machine,5,0);
2038
2039      /* Inputs */
2040
2041      case (0x740/2):
2042         return input_port_1_word_r(machine,0,0);
2043
2044      case (0x744/2):
2045         return input_port_2_word_r(machine,0,0);
2046
2047      case (0x748/2):
2048         return input_port_4_word_r(machine,0,0);
2049
2050      case (0x74c/2):
2051         return input_port_3_word_r(machine,0,0);
2052
2053   }
2054//  if(offset >= (0x400/2) && offset < (0x600/2) && offset != (0x5a4/2))
2055//  popmessage("CPU0 PC %06x unknown MCU read offset: %04x\n",activecpu_get_previouspc(),offset*2);
2056
2057   return mcu_ram[offset];
2058}
2059
2060static WRITE16_HANDLER( godzilla_cop_mcu_w )
2061{
2062   COMBINE_DATA(&mcu_ram[offset]);
2063
2064   switch (offset)
2065   {
2066      /*"Number protection" sub-routine*/
2067      case (0x420/2):
2068      {
2069         //coin counter write
2070         //popmessage("%04x",mcu_ram[offset]);
2071         prot_bcd[0] = protection_bcd_jsr(mcu_ram[offset]);
2072         //prot_bcd = mcu_ram[offset] - 0x22;
2073         break;
2074      }
2075
2076      case (0x478/2):
2077      {
2078         static UINT16 i;
2079         /*
2080            */
2081         switch(mcu_ram[offset])
2082         {
2083            /*txt layer clearance*/
2084            case 0x40a0:
2085            for(i=0;i<0x1000;i+=2)
2086               program_write_word(i+0x102800,0x0000);
2087            break;
2088            case 0x4040: break;
2089            case 0x4140: break;
2090            case 0x4180: break;
2091            case 0x4100: break;
2092            case 0x41c0: break;
2093            //default: popmessage("%04x",mcu_ram[offset]);
2094         }
2095         break;
2096      }
2097
2098      case (0x620/2):
2099      {
2100         legionna_scrollram16[0] = mcu_ram[offset];
2101         break;
2102      }
2103      case (0x622/2):
2104      {
2105         legionna_scrollram16[1] = mcu_ram[offset];
2106         break;
2107      }
2108      case (0x624/2):
2109      {
2110         legionna_scrollram16[2] = mcu_ram[offset];
2111         break;
2112      }
2113      case (0x626/2):
2114      {
2115         legionna_scrollram16[3] = mcu_ram[offset];
2116         break;
2117      }
2118      case (0x628/2):
2119      {
2120         legionna_scrollram16[4] = mcu_ram[offset];
2121         break;
2122      }
2123      case (0x62a/2):
2124      {
2125         legionna_scrollram16[5] = mcu_ram[offset];
2126         break;
2127      }
2128
2129      case (0x7c0/2):   /* seibu(0) */
2130      {
2131         seibu_main_word_w(machine,0,mcu_ram[offset],0xff00);
2132         break;
2133      }
2134      case (0x7c4/2):   /* seibu(1) */
2135      {
2136         seibu_main_word_w(machine,1,mcu_ram[offset],0xff00);
2137         break;
2138      }
2139      case (0x7d0/2):   /* seibu(4) */
2140      {
2141         seibu_main_word_w(machine,4,mcu_ram[offset],0xff00);
2142         break;
2143      }
2144      case (0x7d8/2):   /* seibu(6) */
2145      {
2146         seibu_main_word_w(machine,6,mcu_ram[offset],0xff00);
2147         break;
2148      }
2149//      default:
2150//      logerror("CPU0 PC %06x MCU write offset: %04x data: %04x\n",activecpu_get_previouspc(),offset*2,data);
2151   }
2152}
2153
2154static READ16_HANDLER( copdx_0_r )
2155{
2156   switch(offset)
2157   {
2158      //case (0x47e/2):
2159      //case (0x5b0/2):
2160      //case (0x5b4/2):
2161      //  return mcu_ram[offset];
2162
2163      case (0x700/2):
2164         return input_port_1_word_r(machine,0,0);
2165
2166      case (0x704/2):
2167         return input_port_2_word_r(machine,0,0);
2168
2169      case (0x708/2):
2170         return input_port_4_word_r(machine,0,0);
2171
2172      case (0x70c/2):
2173         return input_port_3_word_r(machine,0,0);
2174
2175      case (0x71c/2):
2176         return input_port_5_word_r(machine,0,0);
2177
2178      case (0x748/2):   /* seibu sound */
2179         return seibu_main_word_r(machine,2,0);
2180      case (0x74c/2):
2181         return seibu_main_word_r(machine,3,0);
2182      case (0x754/2):
2183         return seibu_main_word_r(machine,5,0);
2184
2185   }
2186
2187   //logerror("COP has read at PC=%06x offset = %04x\n",activecpu_get_pc(),offset*2);
2188
2189   return mcu_ram[offset];
2190}
2191
2192static UINT16 cop_fct;
2193static UINT32 cop_reg[8];
2194
2195/*This is version 1,so some stuff is different (less complex)*/
2196static void cop_run(void)
2197{
2198   switch(cop_fct)
2199   {
2200      /*???*/
2201      case 0x8100:
2202      {
2203         UINT32 src = cop_reg[0];
2204         program_write_word(src+0x36,0xffc0);
2205         break;
2206      }
2207      case 0x8900:
2208      {
2209         UINT32 src = cop_reg[0];
2210         program_write_word(src+0x36,0xff80);
2211         break;
2212      }
2213      /*Right*/
2214      case 0x0205:
2215      {
2216         UINT32 src = cop_reg[0];
2217         INT16 y = program_read_word(src+0x4);
2218         INT16 x = program_read_word(src+0x8);
2219         INT16 y_rel = program_read_word(src+0x10);
2220         INT16 x_rel = program_read_word(src+0x14);
2221         program_write_word(src+0x4,(y+y_rel));
2222         program_write_word(src+0x8,(x+x_rel));
2223         /*printf("%08x %08x %08x %08x %08x\n",cop_reg[0],
2224                                           program_read_word(cop_reg[0]+0x4),
2225                                           program_read_word(cop_reg[0]+0x8),
2226                                           program_read_word(cop_reg[0]+0x10),
2227                                           program_read_word(cop_reg[0]+0x14));*/
2228         break;
2229      }
2230      /*???*/
2231      case 0x3bb0:
2232      {
2233         //UINT32 dst = cop_reg[0];
2234         //UINT32 dst = cop_reg[1];
2235         //program_write_word(dst,  mame_rand(Machine)/*program_read_word(src)*/);
2236         //program_write_word(dst+2,mame_rand(Machine)/*program_read_word(src+2)*/);
2237         //program_write_word(dst+4,mame_rand(Machine)/*program_read_word(src+4)*/);
2238         //program_write_word(dst+6,mame_rand(Machine)/*program_read_word(src+6)*/);
2239         //printf("%04x\n",cop_reg[0]);
2240         break;
2241      }
2242      default:
2243         //printf("%04x\n",cop_fct);
2244         break;
2245   }
2246}
2247//tmp_data[1] = mcu_ram[offset];
2248//cop_reg[0] = (prot_data[0]&0xffff)|((prot_data[1]&0xffff)<<16);
2249
2250static void cop_reg_w(UINT16 data,UINT8 offset,UINT8 mask)
2251{
2252   if(mask)
2253      cop_reg[offset] = ((data&0xffff)<<16) | (cop_reg[offset]&0xffff);
2254   else
2255      cop_reg[offset] = (cop_reg[offset]&0xffff0000) | (data&0xffff);
2256
2257   //popmessage("%08x",cop_reg[offset]);
2258}
2259
2260static WRITE16_HANDLER( copdx_0_w )
2261{
2262   COMBINE_DATA(&mcu_ram[offset]);
2263
2264   switch(offset)
2265   {
2266      case (0x4a0/2):
2267      case (0x4a2/2):
2268      case (0x4a4/2):
2269      case (0x4a6/2):
2270      case (0x4a8/2):
2271      case (0x4aa/2):
2272      case (0x4ac/2):
2273      case (0x4ae/2):
2274      case (0x4c0/2):
2275      case (0x4c2/2):
2276      case (0x4c4/2):
2277      case (0x4c6/2):
2278      case (0x4c8/2):
2279      case (0x4ca/2):
2280      case (0x4cc/2):
2281      case (0x4ce/2):
2282         cop_reg_w(mcu_ram[offset],offset & 0x000f, (offset < (0x4b0/2)) ? 1 : 0);
2283         break;
2284      /*layer clearance,but the bootleg doesn't send values,so this function is an
2285          original left-over.*/
2286      case (0x478/2):
2287      {
2288         /*
2289    AM_RANGE(0x100800, 0x100fff) AM_READWRITE(SMH_RAM,legionna_background_w) AM_BASE(&legionna_back_data)
2290    AM_RANGE(0x101000, 0x1017ff) AM_READWRITE(SMH_RAM,legionna_foreground_w) AM_BASE(&legionna_fore_data)
2291    AM_RANGE(0x101800, 0x101fff) AM_READWRITE(SMH_RAM,legionna_midground_w) AM_BASE(&legionna_mid_data)
2292    AM_RANGE(0x102000, 0x102fff) AM_READWRITE(SMH_RAM,legionna_text_w) AM_BASE(&legionna_textram)
2293            */
2294         break;
2295      }
2296      case (0x500/2):
2297      {
2298         cop_fct = mcu_ram[offset];
2299         cop_run();
2300         break;
2301      }
2302      case (0x604/2):
2303      {
2304         //C.R.T. Controller
2305         /*
2306            data = setting
2307            0x01e = 320x256         ---- ---x xxx-
2308            0x0e1 = 320x256 REVERSE ---- xxx- ---x
2309            0x016 = 320x240         ---- ---x -xx-
2310            0x0e9 = 320x240 REVERSE ---- xxx- x--x
2311            0x004 = 320x224         ---- ---- -x--
2312            0x10b = 320x224 REVERSE ---x ---- x-xx
2313            For now we use this by cases and not per bits.
2314            */
2315
2316         switch(data)
2317         {
2318            case 0x0000:
2319            case 0x001e: CRT_MODE(320,256,0); break;
2320            case 0x00e1: CRT_MODE(320,256,1); break;
2321            case 0x0016: CRT_MODE(320,240,0); break;
2322            case 0x00e9: CRT_MODE(320,240,1); break;
2323            case 0x0004: CRT_MODE(320,224,0); break;
2324            case 0x010b: CRT_MODE(320,224,1); break;
2325            default:
2326            #ifdef MAME_DEBUG
2327            popmessage("Warning: Undefined CRT Mode %04x",data);
2328            #endif
2329            CRT_MODE(320,256,0);
2330         }
2331         break;
2332      }
2333      /*TODO: what's going on here,some scroll values aren't sent in these locations
2334                but somewhere else?*/
2335      case (0x62c/2):
2336      {
2337         legionna_scrollram16[0] = mcu_ram[offset];
2338         break;
2339      }
2340      case (0x62e/2):
2341      {
2342         legionna_scrollram16[1] = mcu_ram[offset];
2343         break;
2344      }
2345      case (0x630/2):
2346      {
2347         legionna_scrollram16[2] = mcu_ram[offset];
2348         break;
2349      }
2350      case (0x632/2):
2351      {
2352         legionna_scrollram16[3] = mcu_ram[offset];
2353         break;
2354      }
2355      case (0x634/2):
2356      {
2357         legionna_scrollram16[4] = mcu_ram[offset];
2358         break;
2359      }
2360      case (0x636/2):
2361      {
2362         legionna_scrollram16[5] = mcu_ram[offset];
2363         break;
2364      }
2365      case (0x638/2):
2366      {
2367         legionna_scrollram16[6] = mcu_ram[offset];
2368         break;
2369      }
2370      case (0x63a/2):
2371      {
2372         legionna_scrollram16[7] = mcu_ram[offset];
2373         break;
2374      }
2375      /*video regs (not scrollram,something else)*/
2376      //case (0x660/2):
2377      //case (0x662/2):
2378      //case (0x664/2):
2379      //case (0x666/2):
2380      //case (0x668/2):
2381      //case (0x66a/2):
2382      //case (0x66c/2):
2383      //case (0x66e/2):
2384      //  break;
2385
2386      case (0x740/2):   /* seibu(0) */
2387      {
2388         seibu_main_word_w(machine,0,mcu_ram[offset],0xff00);
2389         break;
2390      }
2391      case (0x744/2):   /* seibu(1) */
2392      {
2393         seibu_main_word_w(machine,1,mcu_ram[offset],0xff00);
2394         break;
2395      }
2396      case (0x750/2):   /* seibu(4) */
2397      {
2398         seibu_main_word_w(machine,4,mcu_ram[offset],0xff00);
2399         break;
2400      }
2401      case (0x758/2):   /* seibu(6) */
2402      {
2403         seibu_main_word_w(machine,6,mcu_ram[offset],0xff00);
2404         break;
2405      }
2406   }
2407   //usrintf_showmessage("COP:write at PC=%06x offset = %04x data %04x\n",activecpu_get_pc(),offset*2,data);
2408}
2409
2410static READ16_HANDLER( copdxbl_0_r )
2411{
2412   switch(offset)
2413   {
2414      //case (0x47e/2):
2415      //case (0x5b0/2):
2416      //case (0x5b4/2):
2417      //  return mcu_ram[offset];
2418
2419      case (0x700/2):
2420         return input_port_1_word_r(machine,0,0);
2421
2422      case (0x704/2):
2423         return input_port_2_word_r(machine,0,0);
2424
2425      case (0x708/2):
2426         return input_port_4_word_r(machine,0,0);
2427
2428      case (0x70c/2):
2429         return input_port_3_word_r(machine,0,0);
2430
2431      case (0x71c/2):
2432         return input_port_5_word_r(machine,0,0);
2433#if 0
2434      case (0x748/2):   /* seibu sound */
2435         return seibu_main_word_r(2,0);
2436      case (0x74c/2):
2437         return seibu_main_word_r(3,0);
2438      case (0x754/2):
2439         return seibu_main_word_r(5,0);
2440         #endif
2441
2442   }
2443
2444   //logerror("COP has read at PC=%06x offset = %04x\n",activecpu_get_pc(),offset*2);
2445
2446   return mcu_ram[offset];
2447}
2448
2449static WRITE16_HANDLER( copdxbl_0_w )
2450{
2451   COMBINE_DATA(&mcu_ram[offset]);
2452
2453   switch(offset)
2454   {
2455      case (0x4a0/2):
2456      case (0x4a2/2):
2457      case (0x4a4/2):
2458      case (0x4a6/2):
2459      case (0x4a8/2):
2460      case (0x4aa/2):
2461      case (0x4ac/2):
2462      case (0x4ae/2):
2463      case (0x4c0/2):
2464      case (0x4c2/2):
2465      case (0x4c4/2):
2466      case (0x4c6/2):
2467      case (0x4c8/2):
2468      case (0x4ca/2):
2469      case (0x4cc/2):
2470      case (0x4ce/2):
2471         cop_reg_w(mcu_ram[offset],offset & 0x000f, (offset < (0x4b0/2)) ? 1 : 0);
2472         break;
2473      /*layer clearance,but the bootleg doesn't send values,so this function
2474          is an original left-over.*/
2475      case (0x478/2):
2476      {
2477         /*
2478    AM_RANGE(0x100800, 0x100fff) AM_READWRITE(SMH_RAM,legionna_background_w) AM_BASE(&legionna_back_data)
2479    AM_RANGE(0x101000, 0x1017ff) AM_READWRITE(SMH_RAM,legionna_foreground_w) AM_BASE(&legionna_fore_data)
2480    AM_RANGE(0x101800, 0x101fff) AM_READWRITE(SMH_RAM,legionna_midground_w) AM_BASE(&legionna_mid_data)
2481    AM_RANGE(0x102000, 0x102fff) AM_READWRITE(SMH_RAM,legionna_text_w) AM_BASE(&legionna_textram)
2482            */
2483         break;
2484      }
2485      case (0x500/2):
2486      {
2487         cop_fct = mcu_ram[offset];
2488         cop_run();
2489         break;
2490      }
2491      case (0x604/2):
2492      {
2493         //C.R.T. Controller
2494         /*
2495            data = setting
2496            0x01e = 320x256         ---- ---x xxx-
2497            0x0e1 = 320x256 REVERSE ---- xxx- ---x
2498            0x016 = 320x240         ---- ---x -xx-
2499            0x0e9 = 320x240 REVERSE ---- xxx- x--x
2500            0x004 = 320x224         ---- ---- -x--
2501            0x10b = 320x224 REVERSE ---x ---- x-xx
2502            For now we use this by cases and not per bits.
2503            */
2504
2505         switch(data)
2506         {
2507            case 0x0000:
2508            case 0x001e: CRT_MODE(320,256,0); break;
2509            case 0x00e1: CRT_MODE(320,256,1); break;
2510            case 0x0016: CRT_MODE(320,240,0); break;
2511            case 0x00e9: CRT_MODE(320,240,1); break;
2512            case 0x0004: CRT_MODE(320,224,0); break;
2513            case 0x010b: CRT_MODE(320,224,1); break;
2514            default:
2515            #ifdef MAME_DEBUG
2516            popmessage("Warning: Undefined CRT Mode %04x",data);
2517            #endif
2518            CRT_MODE(320,256,0);
2519         }
2520         break;
2521      }
2522      /*TODO: kludge on x-axis.*/
2523      case (0x660/2):
2524      {
2525         legionna_scrollram16[0] = mcu_ram[offset] - 0x1f0;
2526         break;
2527      }
2528      case (0x662/2):
2529      {
2530         legionna_scrollram16[1] = mcu_ram[offset];
2531         break;
2532      }
2533      case (0x664/2):
2534      {
2535         legionna_scrollram16[2] = mcu_ram[offset] - 0x1f0;
2536         break;
2537      }
2538      case (0x666/2):
2539      {
2540         legionna_scrollram16[3] = mcu_ram[offset];
2541         break;
2542      }
2543      case (0x668/2):
2544      {
2545         legionna_scrollram16[4] = mcu_ram[offset] - 0x1f0;
2546         break;
2547      }
2548      case (0x66a/2):
2549      {
2550         legionna_scrollram16[5] = mcu_ram[offset];
2551         break;
2552      }
2553      case (0x66c/2):
2554      {
2555         legionna_scrollram16[6] = mcu_ram[offset] - 0x1f0;
2556         break;
2557      }
2558      case (0x66e/2):
2559      {
2560         legionna_scrollram16[7] = mcu_ram[offset];
2561         break;
2562      }
2563      /*WRONG*/
2564      case (0x65c/2):
2565      {
2566         soundlatch_w(machine,1,data&0xff);
2567         cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE );
2568         break;
2569      }
2570      /*video regs (not scrollram,something else)*/
2571      //case (0x660/2):
2572      //case (0x662/2):
2573      //case (0x664/2):
2574      //case (0x666/2):
2575      //case (0x668/2):
2576      //case (0x66a/2):
2577      //case (0x66c/2):
2578      //case (0x66e/2):
2579      //  break;
2580      /*bootleg sound HW*/
2581      /*case (0x740/2):
2582        {
2583            soundlatch_w(1,data&0x00ff);
2584            cpunum_set_input_line(Machine, 1, INPUT_LINE_NMI, PULSE_LINE );
2585            break;
2586        }*/
2587      #if 0
2588      case (0x740/2):   /* seibu(0) */
2589      {
2590         seibu_main_word_w(0,mcu_ram[offset],0xff00);
2591         break;
2592      }
2593      case (0x744/2):   /* seibu(1) */
2594      {
2595         seibu_main_word_w(1,mcu_ram[offset],0xff00);
2596         break;
2597      }
2598      case (0x750/2):   /* seibu(4) */
2599      {
2600         seibu_main_word_w(4,mcu_ram[offset],0xff00);
2601         break;
2602      }
2603      case (0x758/2):   /* seibu(6) */
2604      {
2605         seibu_main_word_w(6,mcu_ram[offset],0xff00);
2606         break;
2607      }
2608      #endif
2609   }
2610   //usrintf_showmessage("COP:write at PC=%06x offset = %04x data %04x\n",activecpu_get_pc(),offset*2,data);
2611}
2612
2613128/*****************************************************************************/
2614129
2615static ADDRESS_MAP_START( legionna_readmem, ADDRESS_SPACE_PROGRAM, 16 )
2616   AM_RANGE(0x000000, 0x07ffff) AM_READ(SMH_ROM)
2617   AM_RANGE(0x100000, 0x1007ff) AM_READ(mcu_r)   /* COP mcu */
2618   AM_RANGE(0x101000, 0x1017ff) AM_READ(SMH_RAM)   /* 32x16 bg layer, 16x16 tiles */
2619   AM_RANGE(0x101800, 0x101fff) AM_READ(SMH_RAM)   /* 32x16 bg layer, 16x16 tiles */
2620   AM_RANGE(0x102000, 0x1027ff) AM_READ(SMH_RAM)   /* 32x16 bg layer, 16x16 tiles */
2621   AM_RANGE(0x102800, 0x1037ff) AM_READ(SMH_RAM)   /* 64x32 text/front layer, 8x8 tiles */
2622130
2623   /* The 4000-4fff area contains PALETTE words and may be extra paletteram? */
2624   AM_RANGE(0x104000, 0x104fff) AM_READ(SMH_RAM)   /* palette mirror ? */
2625//  AM_RANGE(0x104000, 0x10401f) AM_READ(SMH_RAM) /* debugging... */
2626//  AM_RANGE(0x104200, 0x1043ff) AM_READ(SMH_RAM) /* ??? */
2627//  AM_RANGE(0x104600, 0x1047ff) AM_READ(SMH_RAM) /* ??? */
2628//  AM_RANGE(0x104800, 0x10481f) AM_READ(SMH_RAM) /* ??? */
2629
2630   AM_RANGE(0x105000, 0x105fff) AM_READ(SMH_RAM)   /* spriteram */
2631   AM_RANGE(0x106000, 0x106fff) AM_READ(SMH_RAM)
2632   AM_RANGE(0x107000, 0x107fff) AM_READ(SMH_RAM)   /* palette */
2633   AM_RANGE(0x108000, 0x11ffff) AM_READ(SMH_RAM)   /* main ram */
131static ADDRESS_MAP_START( legionna_map, ADDRESS_SPACE_PROGRAM, 16 )
132   AM_RANGE(0x000000, 0x07ffff) AM_ROM
133   //AM_RANGE(0x100000, 0x1003ff) AM_RAM
134   AM_RANGE(0x100000, 0x1007ff) AM_RAM AM_READWRITE(legionna_mcu_r, legionna_mcu_w) AM_BASE(&cop_mcu_ram)   /* COP mcu */
135   AM_RANGE(0x101000, 0x1017ff) AM_RAM AM_WRITE(legionna_background_w) AM_BASE(&legionna_back_data)
136   AM_RANGE(0x101800, 0x101fff) AM_RAM AM_WRITE(legionna_foreground_w) AM_BASE(&legionna_fore_data)
137   AM_RANGE(0x102000, 0x1027ff) AM_RAM AM_WRITE(legionna_midground_w) AM_BASE(&legionna_mid_data)
138   AM_RANGE(0x102800, 0x1037ff) AM_RAM AM_WRITE(legionna_text_w) AM_BASE(&legionna_textram)
139   AM_RANGE(0x104000, 0x104fff) AM_RAM /* The 4000-4fff area contains PALETTE words and may be extra paletteram? */
140   AM_RANGE(0x105000, 0x105fff) AM_RAM AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
141   AM_RANGE(0x106000, 0x106fff) AM_RAM /* is this used outside inits ?? */
142   AM_RANGE(0x107000, 0x107fff) AM_RAM AM_WRITE(legionna_paletteram16_w) AM_BASE(&paletteram16)   /* palette xRRRRxGGGGxBBBBx ? */
143   AM_RANGE(0x108000, 0x11ffff) AM_RAM /* main ram */
2634144ADDRESS_MAP_END
2635145
2636static ADDRESS_MAP_START( legionna_writemem, ADDRESS_SPACE_PROGRAM, 16 )
2637   AM_RANGE(0x000000, 0x07ffff) AM_WRITE(SMH_ROM)
2638   AM_RANGE(0x100000, 0x1007ff) AM_WRITE(mcu_w) AM_BASE(&mcu_ram)   /* COP mcu */
2639   AM_RANGE(0x101000, 0x1017ff) AM_WRITE(legionna_background_w) AM_BASE(&legionna_back_data)
2640   AM_RANGE(0x101800, 0x101fff) AM_WRITE(legionna_foreground_w) AM_BASE(&legionna_fore_data)
2641   AM_RANGE(0x102000, 0x1027ff) AM_WRITE(legionna_midground_w) AM_BASE(&legionna_mid_data)
2642   AM_RANGE(0x102800, 0x1037ff) AM_WRITE(legionna_text_w) AM_BASE(&legionna_textram)
2643146
2644   /* The 4000-4fff area contains PALETTE words and may be extra paletteram? */
2645   AM_RANGE(0x104000, 0x104fff) AM_WRITE(SMH_RAM)
2646//  AM_RANGE(0x104000, 0x104fff) AM_WRITE(legionna_paletteram16_w)
2647//  AM_RANGE(0x104000, 0x10401f) AM_WRITE(SMH_RAM)
2648//  AM_RANGE(0x104200, 0x1043ff) AM_WRITE(SMH_RAM)
2649//  AM_RANGE(0x104600, 0x1047ff) AM_WRITE(SMH_RAM)
2650//  AM_RANGE(0x104800, 0x10481f) AM_WRITE(SMH_RAM)
2651
2652   AM_RANGE(0x105000, 0x105fff) AM_WRITE(SMH_RAM) AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
2653   AM_RANGE(0x106000, 0x106fff) AM_WRITE(SMH_RAM)   /* is this used outside inits ?? */
2654   AM_RANGE(0x107000, 0x107fff) AM_WRITE(legionna_paletteram16_w) AM_BASE(&paletteram16)   /* palette xRRRRxGGGGxBBBBx ? */
2655   AM_RANGE(0x108000, 0x11ffff) AM_WRITE(SMH_RAM)
147static ADDRESS_MAP_START( heatbrl_map, ADDRESS_SPACE_PROGRAM, 16 )
148   AM_RANGE(0x000000, 0x07ffff) AM_ROM
149   //AM_RANGE(0x100000, 0x1003ff) AM_RAM
150   AM_RANGE(0x100000, 0x1007ff) AM_RAM AM_READWRITE(heatbrl_mcu_r, heatbrl_mcu_w) AM_BASE(&cop_mcu_ram)   /* COP mcu */
151   AM_RANGE(0x100800, 0x100fff) AM_RAM AM_WRITE(legionna_background_w) AM_BASE(&legionna_back_data)
152   AM_RANGE(0x101000, 0x1017ff) AM_RAM AM_WRITE(legionna_foreground_w) AM_BASE(&legionna_fore_data)
153   AM_RANGE(0x101800, 0x101fff) AM_RAM AM_WRITE(legionna_midground_w) AM_BASE(&legionna_mid_data)
154   AM_RANGE(0x102000, 0x102fff) AM_RAM AM_WRITE(legionna_text_w) AM_BASE(&legionna_textram)
155   AM_RANGE(0x103000, 0x103fff) AM_RAM AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
156   AM_RANGE(0x104000, 0x104fff) AM_RAM AM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE(&paletteram16)
157   AM_RANGE(0x108000, 0x11ffff) AM_RAM
2656158ADDRESS_MAP_END
2657159
2658static ADDRESS_MAP_START( heatbrl_readmem, ADDRESS_SPACE_PROGRAM, 16 )
2659   AM_RANGE(0x000000, 0x07ffff) AM_READ(SMH_ROM)
2660   AM_RANGE(0x100000, 0x1007ff) AM_READ(cop2_mcu_r)   /* COP mcu */
2661   AM_RANGE(0x100800, 0x100fff) AM_READ(SMH_RAM)   /* 32x16 bg layer, 16x16 tiles */
2662   AM_RANGE(0x101000, 0x1017ff) AM_READ(SMH_RAM)   /* 32x16 bg layer, 16x16 tiles */
2663   AM_RANGE(0x101800, 0x101fff) AM_READ(SMH_RAM)   /* 32x16 bg layer, 16x16 tiles */
2664   AM_RANGE(0x102000, 0x102fff) AM_READ(SMH_RAM)   /* 64x32 text/front layer, 8x8 tiles */
2665   AM_RANGE(0x103000, 0x103fff) AM_READ(SMH_RAM)   /* spriteram */
2666   AM_RANGE(0x104000, 0x104fff) AM_READ(SMH_RAM)   /* palette */
2667   AM_RANGE(0x108000, 0x11ffff) AM_READ(SMH_RAM)   /* main ram */
160static ADDRESS_MAP_START( godzilla_map, ADDRESS_SPACE_PROGRAM, 16 )
161   AM_RANGE(0x000000, 0x0fffff) AM_ROM
162   //AM_RANGE(0x100000, 0x1003ff) AM_RAM
163   AM_RANGE(0x100000, 0x1007ff) AM_RAM AM_READWRITE(godzilla_cop_mcu_r, godzilla_cop_mcu_w) AM_BASE(&cop_mcu_ram)   /* COP mcu */
164   AM_RANGE(0x100800, 0x100fff) AM_RAM
165   AM_RANGE(0x101000, 0x101fff) AM_RAM AM_WRITE(legionna_background_w) AM_BASE(&legionna_back_data)
166   AM_RANGE(0x102000, 0x1027ff) AM_RAM AM_WRITE(legionna_midground_w) AM_BASE(&legionna_mid_data)
167   AM_RANGE(0x102800, 0x1037ff) AM_RAM AM_WRITE(legionna_text_w) AM_BASE(&legionna_textram)
168   AM_RANGE(0x103800, 0x103fff) AM_RAM AM_WRITE(legionna_foreground_w) AM_BASE(&legionna_fore_data)
169   AM_RANGE(0x104000, 0x104fff) AM_RAM AM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE(&paletteram16)
170   AM_RANGE(0x105000, 0x105fff) AM_RAM AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
171   AM_RANGE(0x106000, 0x1067ff) AM_RAM
172   AM_RANGE(0x106800, 0x106fff) AM_RAM
173   AM_RANGE(0x107000, 0x107fff) AM_RAM /*Ani-DSP ram*/
174   AM_RANGE(0x108000, 0x11ffff) AM_RAM
2668175ADDRESS_MAP_END
2669176
2670static ADDRESS_MAP_START( heatbrl_writemem, ADDRESS_SPACE_PROGRAM, 16 )
2671   AM_RANGE(0x000000, 0x07ffff) AM_WRITE(SMH_ROM)
2672   AM_RANGE(0x100000, 0x1007ff) AM_WRITE(cop2_mcu_w) AM_BASE(&mcu_ram)   /* COP mcu */
2673   AM_RANGE(0x100800, 0x100fff) AM_WRITE(legionna_background_w) AM_BASE(&legionna_back_data)
2674   AM_RANGE(0x101000, 0x1017ff) AM_WRITE(legionna_foreground_w) AM_BASE(&legionna_fore_data)
2675   AM_RANGE(0x101800, 0x101fff) AM_WRITE(legionna_midground_w) AM_BASE(&legionna_mid_data)
2676   AM_RANGE(0x102000, 0x102fff) AM_WRITE(legionna_text_w) AM_BASE(&legionna_textram)
2677   AM_RANGE(0x103000, 0x103fff) AM_WRITE(SMH_RAM) AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
2678   AM_RANGE(0x104000, 0x104fff) AM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE(&paletteram16)
2679   AM_RANGE(0x108000, 0x11ffff) AM_WRITE(SMH_RAM)
177static ADDRESS_MAP_START( denjinmk_map, ADDRESS_SPACE_PROGRAM, 16 )
178   AM_RANGE(0x000000, 0x0fffff) AM_ROM
179   //AM_RANGE(0x100000, 0x1003ff) AM_RAM
180   AM_RANGE(0x100000, 0x1007ff) AM_RAM AM_READWRITE(denjinmk_cop_mcu_r, denjinmk_cop_mcu_w) AM_BASE(&cop_mcu_ram)   /* COP mcu */
181   AM_RANGE(0x100800, 0x100fff) AM_RAM
182   AM_RANGE(0x101000, 0x1017ff) AM_RAM AM_WRITE(legionna_background_w) AM_BASE(&legionna_back_data)
183   AM_RANGE(0x101800, 0x101fff) AM_RAM AM_WRITE(legionna_foreground_w) AM_BASE(&legionna_fore_data)
184   AM_RANGE(0x102000, 0x1027ff) AM_RAM AM_WRITE(legionna_midground_w) AM_BASE(&legionna_mid_data)
185   AM_RANGE(0x102800, 0x103fff) AM_RAM AM_WRITE(legionna_text_w) AM_BASE(&legionna_textram)
186   AM_RANGE(0x104000, 0x104fff) AM_RAM
187   AM_RANGE(0x105000, 0x105fff) AM_RAM AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
188   AM_RANGE(0x106000, 0x107fff) AM_RAM
189   AM_RANGE(0x108000, 0x11dfff) AM_RAM
190   AM_RANGE(0x11e000, 0x11efff) AM_RAM AM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE(&paletteram16)
191   AM_RANGE(0x11f000, 0x11ffff) AM_RAM
2680192ADDRESS_MAP_END
2681193
2682static ADDRESS_MAP_START( godzilla_readmem, ADDRESS_SPACE_PROGRAM, 16 )
2683   AM_RANGE(0x000000, 0x0fffff) AM_READ(SMH_ROM)
2684   AM_RANGE(0x100000, 0x1007ff) AM_READ(godzilla_cop_mcu_r)   /* COP mcu */
2685   AM_RANGE(0x100800, 0x100fff) AM_READ(SMH_RAM)
2686   AM_RANGE(0x101000, 0x101fff) AM_READ(SMH_RAM)
2687   AM_RANGE(0x102000, 0x102fff) AM_READ(SMH_RAM)
2688   AM_RANGE(0x103000, 0x103fff) AM_READ(SMH_RAM)
2689   AM_RANGE(0x104000, 0x104fff) AM_READ(SMH_RAM)
2690   AM_RANGE(0x105000, 0x106fff) AM_READ(SMH_RAM)
2691   AM_RANGE(0x107000, 0x107fff) AM_READ(SMH_RAM) /*Ani-DSP ram*/
2692   AM_RANGE(0x108000, 0x11ffff) AM_READ(SMH_RAM)   /* main ram */
194static ADDRESS_MAP_START( sdgndmrb_map, ADDRESS_SPACE_PROGRAM, 16 )
195   AM_RANGE(0x000000, 0x0fffff) AM_ROM
196   //AM_RANGE(0x100000, 0x1003ff) AM_RAM
197   AM_RANGE(0x100000, 0x1007ff) AM_RAM AM_READWRITE(sdgndmrb_cop_mcu_r, sdgndmrb_cop_mcu_w) AM_BASE(&cop_mcu_ram)   /* COP mcu */
198   AM_RANGE(0x100800, 0x100fff) AM_RAM AM_WRITE(legionna_background_w) AM_BASE(&legionna_back_data)
199   AM_RANGE(0x101000, 0x1017ff) AM_RAM AM_WRITE(legionna_foreground_w) AM_BASE(&legionna_fore_data)
200   AM_RANGE(0x101800, 0x101fff) AM_RAM AM_WRITE(legionna_midground_w) AM_BASE(&legionna_mid_data)
201   AM_RANGE(0x102000, 0x102fff) AM_RAM AM_WRITE(legionna_text_w) AM_BASE(&legionna_textram)
202   AM_RANGE(0x103000, 0x103fff) AM_RAM AM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE(&paletteram16)
203   AM_RANGE(0x104000, 0x104fff) AM_RAM AM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w)
204   AM_RANGE(0x105000, 0x105fff) AM_RAM
205   AM_RANGE(0x106000, 0x106fff) AM_RAM
206   AM_RANGE(0x107000, 0x107fff) AM_RAM AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
207   AM_RANGE(0x108000, 0x11ffff) AM_RAM
2693208ADDRESS_MAP_END
2694209
2695static ADDRESS_MAP_START( godzilla_writemem, ADDRESS_SPACE_PROGRAM, 16 )
2696   AM_RANGE(0x000000, 0x0fffff) AM_WRITE(SMH_ROM)
2697   AM_RANGE(0x100000, 0x1007ff) AM_WRITE(godzilla_cop_mcu_w) AM_BASE(&mcu_ram)   /* COP mcu */
2698   AM_RANGE(0x100800, 0x100fff) AM_WRITE(SMH_RAM)
2699   AM_RANGE(0x101000, 0x101fff) AM_WRITE(legionna_background_w) AM_BASE(&legionna_back_data)
2700   AM_RANGE(0x102000, 0x1027ff) AM_WRITE(legionna_midground_w) AM_BASE(&legionna_mid_data)
2701   AM_RANGE(0x102800, 0x1037ff) AM_WRITE(legionna_text_w) AM_BASE(&legionna_textram)
2702   AM_RANGE(0x103800, 0x103fff) AM_WRITE(legionna_foreground_w) AM_BASE(&legionna_fore_data)
2703   AM_RANGE(0x104000, 0x104fff) AM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE(&paletteram16)
2704   AM_RANGE(0x105000, 0x105fff) AM_WRITE(SMH_RAM) AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
2705   AM_RANGE(0x106000, 0x1067ff) AM_WRITE(SMH_RAM)
2706   AM_RANGE(0x106800, 0x106fff) AM_WRITE(SMH_RAM)
2707   AM_RANGE(0x107000, 0x107fff) AM_WRITE(SMH_RAM) /*Ani-DSP ram*/
2708   AM_RANGE(0x108000, 0x11ffff) AM_WRITE(SMH_RAM)
2709ADDRESS_MAP_END
2710
2711static ADDRESS_MAP_START( denjinmk_readmem, ADDRESS_SPACE_PROGRAM, 16 )
2712   AM_RANGE(0x000000, 0x0fffff) AM_READ(SMH_ROM)
2713   AM_RANGE(0x100000, 0x1007ff) AM_READ(denjinmk_cop_mcu_r)   /* COP mcu */
2714   AM_RANGE(0x100800, 0x100fff) AM_READ(SMH_RAM)
2715   AM_RANGE(0x101000, 0x101fff) AM_READ(SMH_RAM)
2716   AM_RANGE(0x102000, 0x103fff) AM_READ(SMH_RAM)
2717   AM_RANGE(0x104000, 0x104fff) AM_READ(SMH_RAM)
2718   AM_RANGE(0x105000, 0x105fff) AM_READ(SMH_RAM)
2719   AM_RANGE(0x106000, 0x106fff) AM_READ(SMH_RAM)
2720   AM_RANGE(0x107000, 0x107fff) AM_READ(SMH_RAM)
2721   AM_RANGE(0x108000, 0x11dfff) AM_READ(SMH_RAM)   /* main ram */
2722   AM_RANGE(0x11e000, 0x11efff) AM_READ(SMH_RAM)
2723   AM_RANGE(0x11f000, 0x11ffff) AM_READ(SMH_RAM)
2724ADDRESS_MAP_END
2725
2726static ADDRESS_MAP_START( denjinmk_writemem, ADDRESS_SPACE_PROGRAM, 16 )
2727   AM_RANGE(0x000000, 0x0fffff) AM_WRITE(SMH_ROM)
2728   AM_RANGE(0x100000, 0x1007ff) AM_WRITE(denjinmk_cop_mcu_w) AM_BASE(&mcu_ram)   /* COP mcu */
2729   AM_RANGE(0x100800, 0x100fff) AM_WRITE(SMH_RAM)
2730   AM_RANGE(0x101000, 0x1017ff) AM_WRITE(legionna_background_w) AM_BASE(&legionna_back_data)
2731   AM_RANGE(0x101800, 0x101fff) AM_WRITE(legionna_foreground_w) AM_BASE(&legionna_fore_data)
2732   AM_RANGE(0x102000, 0x1027ff) AM_WRITE(legionna_midground_w) AM_BASE(&legionna_mid_data)
2733   AM_RANGE(0x102800, 0x103fff) AM_WRITE(legionna_text_w) AM_BASE(&legionna_textram)
2734   AM_RANGE(0x104000, 0x104fff) AM_WRITE(SMH_RAM)
2735   AM_RANGE(0x105000, 0x105fff) AM_WRITE(SMH_RAM) AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
2736   AM_RANGE(0x106000, 0x107fff) AM_WRITE(SMH_RAM)
2737   AM_RANGE(0x108000, 0x11dfff) AM_WRITE(SMH_RAM)   /* main ram */
2738   AM_RANGE(0x11e000, 0x11efff) AM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE(&paletteram16)
2739   AM_RANGE(0x11f000, 0x11ffff) AM_WRITE(SMH_RAM)
2740ADDRESS_MAP_END
2741
2742static ADDRESS_MAP_START( sdgndmrb_readmem, ADDRESS_SPACE_PROGRAM, 16 )
2743   AM_RANGE(0x000000, 0x0fffff) AM_READ(SMH_ROM)
2744   AM_RANGE(0x100000, 0x1007ff) AM_READ(sdgndmrb_cop_mcu_r)   /* COP mcu */
2745   AM_RANGE(0x100800, 0x100fff) AM_READ(SMH_RAM)   /* 32x16 bg layer, 16x16 tiles */
2746   AM_RANGE(0x101000, 0x1017ff) AM_READ(SMH_RAM)   /* 32x16 bg layer, 16x16 tiles */
2747   AM_RANGE(0x101800, 0x101fff) AM_READ(SMH_RAM)   /* 32x16 bg layer, 16x16 tiles */
2748   AM_RANGE(0x102000, 0x102fff) AM_READ(SMH_RAM)   /* 64x32 text/front layer, 8x8 tiles */
2749   AM_RANGE(0x103000, 0x103fff) AM_READ(SMH_RAM)   /* palette */
2750   AM_RANGE(0x104000, 0x104fff) AM_READ(SMH_RAM)   /* palette mirror */
2751   AM_RANGE(0x105000, 0x105fff) AM_READ(SMH_RAM)
2752   AM_RANGE(0x107000, 0x107fff) AM_READ(SMH_RAM)   /* extra spriteram? */
2753   AM_RANGE(0x108000, 0x11ffff) AM_READ(SMH_RAM)   /* main ram */
2754ADDRESS_MAP_END
2755
2756static ADDRESS_MAP_START( sdgndmrb_writemem, ADDRESS_SPACE_PROGRAM, 16 )
2757   AM_RANGE(0x000000, 0x0fffff) AM_WRITE(SMH_ROM)
2758   AM_RANGE(0x100000, 0x1007ff) AM_WRITE(sdgndmrb_cop_mcu_w) AM_BASE(&mcu_ram)   /* COP mcu */
2759   AM_RANGE(0x100800, 0x100fff) AM_WRITE(legionna_background_w) AM_BASE(&legionna_back_data)
2760   AM_RANGE(0x101000, 0x1017ff) AM_WRITE(legionna_foreground_w) AM_BASE(&legionna_fore_data)
2761   AM_RANGE(0x101800, 0x101fff) AM_WRITE(legionna_midground_w) AM_BASE(&legionna_mid_data)
2762   AM_RANGE(0x102000, 0x102fff) AM_WRITE(legionna_text_w) AM_BASE(&legionna_textram)
2763   AM_RANGE(0x103000, 0x103fff) AM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE(&paletteram16)
2764   AM_RANGE(0x104000, 0x104fff) AM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w)
2765   AM_RANGE(0x105000, 0x105fff) AM_WRITE(SMH_RAM)
2766   AM_RANGE(0x106000, 0x106fff) AM_WRITE(SMH_RAM)
2767   AM_RANGE(0x107000, 0x107fff) AM_WRITE(SMH_RAM) AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
2768   AM_RANGE(0x108000, 0x11ffff) AM_WRITE(SMH_RAM)
2769ADDRESS_MAP_END
2770
2771210static ADDRESS_MAP_START( cupsoc_mem, ADDRESS_SPACE_PROGRAM, 16 )
2772211   AM_RANGE(0x000000, 0x0fffff) AM_ROM
2773   AM_RANGE(0x100000, 0x1007ff) AM_READWRITE(copdx_0_r,copdx_0_w) AM_BASE(&mcu_ram)
2774   AM_RANGE(0x100800, 0x100fff) AM_READWRITE(SMH_RAM,legionna_background_w) AM_BASE(&legionna_back_data)
2775   AM_RANGE(0x101000, 0x1017ff) AM_READWRITE(SMH_RAM,legionna_foreground_w) AM_BASE(&legionna_fore_data)
2776   AM_RANGE(0x101800, 0x101fff) AM_READWRITE(SMH_RAM,legionna_midground_w) AM_BASE(&legionna_mid_data)
2777   AM_RANGE(0x102000, 0x102fff) AM_READWRITE(SMH_RAM,legionna_text_w) AM_BASE(&legionna_textram)
2778   AM_RANGE(0x103000, 0x103fff) AM_READWRITE(SMH_RAM,paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE(&paletteram16)
2779   AM_RANGE(0x104000, 0x104fff) AM_READWRITE(SMH_RAM,paletteram16_xBBBBBGGGGGRRRRR_word_w) /*<according to the debug mode,there is a DMA that copies from here to the paletteram>*/
212   //AM_RANGE(0x100000, 0x1003ff) AM_RAM
213   AM_RANGE(0x100000, 0x1007ff) AM_RAM AM_READWRITE(copdx_0_r,copdx_0_w) AM_BASE(&cop_mcu_ram)
214   AM_RANGE(0x100800, 0x100fff) AM_RAM AM_READWRITE(SMH_RAM,legionna_background_w) AM_BASE(&legionna_back_data)
215   AM_RANGE(0x101000, 0x1017ff) AM_RAM AM_WRITE(legionna_foreground_w) AM_BASE(&legionna_fore_data)
216   AM_RANGE(0x101800, 0x101fff) AM_RAM AM_WRITE(legionna_midground_w) AM_BASE(&legionna_mid_data)
217   AM_RANGE(0x102000, 0x102fff) AM_RAM AM_WRITE(legionna_text_w) AM_BASE(&legionna_textram)
218   AM_RANGE(0x103000, 0x103fff) AM_RAM AM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE(&paletteram16)
219   AM_RANGE(0x104000, 0x104fff) AM_RAM AM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) /*<according to the debug mode,there is a DMA that copies from here to the paletteram>*/
2780220   AM_RANGE(0x105000, 0x106fff) AM_RAM
2781221   AM_RANGE(0x107000, 0x1077ff) AM_RAM AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
2782222   AM_RANGE(0x107800, 0x107fff) AM_RAM /*Ani Dsp(?) Ram*/
r2375r2376
2788228
2789229static ADDRESS_MAP_START( cupsocbl_mem, ADDRESS_SPACE_PROGRAM, 16 )
2790230   AM_RANGE(0x000000, 0x0fffff) AM_ROM
2791   AM_RANGE(0x100000, 0x1007ff) AM_READWRITE(copdxbl_0_r,copdxbl_0_w) AM_BASE(&mcu_ram)
2792   AM_RANGE(0x100800, 0x100fff) AM_READWRITE(SMH_RAM,legionna_background_w) AM_BASE(&legionna_back_data)
2793   AM_RANGE(0x101000, 0x1017ff) AM_READWRITE(SMH_RAM,legionna_foreground_w) AM_BASE(&legionna_fore_data)
2794   AM_RANGE(0x101800, 0x101fff) AM_READWRITE(SMH_RAM,legionna_midground_w) AM_BASE(&legionna_mid_data)
2795   AM_RANGE(0x102000, 0x102fff) AM_READWRITE(SMH_RAM,legionna_text_w) AM_BASE(&legionna_textram)
2796   AM_RANGE(0x103000, 0x103fff) AM_READWRITE(SMH_RAM,paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE(&paletteram16)
2797   AM_RANGE(0x104000, 0x104fff) AM_READWRITE(SMH_RAM,paletteram16_xBBBBBGGGGGRRRRR_word_w) /*<according to the debug mode,there is a DMA that copies from here to the paletteram>*/
231   //AM_RANGE(0x100000, 0x1003ff) AM_RAM
232   AM_RANGE(0x100000, 0x1007ff) AM_RAM AM_READWRITE(copdxbl_0_r,copdxbl_0_w) AM_BASE(&cop_mcu_ram)
233   AM_RANGE(0x100800, 0x100fff) AM_RAM AM_WRITE(legionna_background_w) AM_BASE(&legionna_back_data)
234   AM_RANGE(0x101000, 0x1017ff) AM_RAM AM_WRITE(legionna_foreground_w) AM_BASE(&legionna_fore_data)
235   AM_RANGE(0x101800, 0x101fff) AM_RAM AM_WRITE(legionna_midground_w) AM_BASE(&legionna_mid_data)
236   AM_RANGE(0x102000, 0x102fff) AM_RAM AM_WRITE(legionna_text_w) AM_BASE(&legionna_textram)
237   AM_RANGE(0x103000, 0x103fff) AM_RAM AM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE(&paletteram16)
238   AM_RANGE(0x104000, 0x104fff) AM_RAM AM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) /*<according to the debug mode,there is a DMA that copies from here to the paletteram>*/
2798239   AM_RANGE(0x105000, 0x106fff) AM_RAM
2799240   AM_RANGE(0x107000, 0x1077ff) AM_RAM AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
2800241   AM_RANGE(0x107800, 0x107fff) AM_RAM /*Ani Dsp(?) Ram*/
r2375r2376
3249690   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
3250691INPUT_PORTS_END
3251692
693static INPUT_PORTS_START( denjinmk )
694   SEIBU_COIN_INPUTS   /* coin inputs read through sound cpu */
695
696   PORT_START
697   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Unknown ) )
698   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
699   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
700   PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
701   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
702   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
703   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
704   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
705   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
706   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
707   PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
708   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
709   PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
710   PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
711   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
712   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
713   PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
714   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
715   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
716   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
717   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
718   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
719   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
720   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
721   PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
722   PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
723   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
724   PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
725   PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
726   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
727   PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
728   PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
729   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
730   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
731   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
732   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
733   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
734   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
735   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
736   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
737   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
738   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
739   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Service_Mode ) )
740   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
741   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
742
743   PORT_START
744   PORT_BIT( 0x0001, IP_ACTIVE_LOW,  IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
745   PORT_BIT( 0x0002, IP_ACTIVE_LOW,  IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
746   PORT_BIT( 0x0004, IP_ACTIVE_LOW,  IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
747   PORT_BIT( 0x0008, IP_ACTIVE_LOW,  IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
748   PORT_BIT( 0x0010, IP_ACTIVE_LOW,  IPT_BUTTON1 ) PORT_PLAYER(1)
749   PORT_BIT( 0x0020, IP_ACTIVE_LOW,  IPT_BUTTON2 ) PORT_PLAYER(1)
750   PORT_BIT( 0x0040, IP_ACTIVE_LOW,  IPT_BUTTON3 ) PORT_PLAYER(1) //debug button
751   PORT_BIT( 0x0080, IP_ACTIVE_LOW,  IPT_UNKNOWN )
752   PORT_BIT( 0x0100, IP_ACTIVE_LOW,  IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
753   PORT_BIT( 0x0200, IP_ACTIVE_LOW,  IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
754   PORT_BIT( 0x0400, IP_ACTIVE_LOW,  IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
755   PORT_BIT( 0x0800, IP_ACTIVE_LOW,  IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
756   PORT_BIT( 0x1000, IP_ACTIVE_LOW,  IPT_BUTTON1 ) PORT_PLAYER(2)
757   PORT_BIT( 0x2000, IP_ACTIVE_LOW,  IPT_BUTTON2 ) PORT_PLAYER(2)
758   PORT_BIT( 0x4000, IP_ACTIVE_LOW,  IPT_UNKNOWN )
759   PORT_BIT( 0x8000, IP_ACTIVE_LOW,  IPT_UNKNOWN )
760
761   PORT_START
762   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START1 )
763   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_START2 )
764   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN )
765   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN )
766   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN )
767   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_UNKNOWN )
768   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
769   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
770   PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
771
772   PORT_START
773   PORT_BIT( 0x0001, IP_ACTIVE_LOW,  IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(3)
774   PORT_BIT( 0x0002, IP_ACTIVE_LOW,  IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(3)
775   PORT_BIT( 0x0004, IP_ACTIVE_LOW,  IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(3)
776   PORT_BIT( 0x0008, IP_ACTIVE_LOW,  IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(3)
777   PORT_BIT( 0x0010, IP_ACTIVE_LOW,  IPT_BUTTON1  ) PORT_PLAYER(3)
778   PORT_BIT( 0x0020, IP_ACTIVE_LOW,  IPT_BUTTON2  ) PORT_PLAYER(3)
779   PORT_BIT( 0x0040, IP_ACTIVE_LOW,  IPT_UNKNOWN )
780   PORT_BIT( 0x0080, IP_ACTIVE_LOW,  IPT_UNKNOWN )
781   PORT_BIT( 0x0100, IP_ACTIVE_LOW,  IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(4)
782   PORT_BIT( 0x0200, IP_ACTIVE_LOW,  IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(4)
783   PORT_BIT( 0x0400, IP_ACTIVE_LOW,  IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(4)
784   PORT_BIT( 0x0800, IP_ACTIVE_LOW,  IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(4)
785   PORT_BIT( 0x1000, IP_ACTIVE_LOW,  IPT_BUTTON1 ) PORT_PLAYER(4)
786   PORT_BIT( 0x2000, IP_ACTIVE_LOW,  IPT_BUTTON2 ) PORT_PLAYER(4)
787   PORT_BIT( 0x4000, IP_ACTIVE_LOW,  IPT_UNKNOWN )
788   PORT_BIT( 0x8000, IP_ACTIVE_LOW,  IPT_UNKNOWN )
789
790   PORT_START
791   PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Unknown ) )
792   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
793   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
794   PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
795   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
796   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
797   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
798   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
799   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
800   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
801   PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
802   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
803   PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
804   PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
805   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
806   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
807   PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
808   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
809   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
810   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
811   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
812   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
813   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
814   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
815   PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
816   PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
817   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
818   PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
819   PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
820   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
821   PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
822   PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
823   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
824   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
825   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
826   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
827   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
828   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
829   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
830   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
831   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
832   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
833   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
834   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
835   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
836INPUT_PORTS_END
837
838
3252839static INPUT_PORTS_START( cupsoc )
3253840   SEIBU_COIN_INPUTS   /* coin inputs read through sound cpu */
3254841
r2375r2376
3365952
3366953/*****************************************************************************/
3367954
3368
3369static const gfx_layout legionna_charlayout =
955static const gfx_layout legionna_new_charlayout =
3370956{
3371957   8,8,
3372   RGN_FRAC(1,4),   /* other half is BK3, decoded in char2layout */
958   RGN_FRAC(1,1),
3373959   4,
3374   { 0, 4, 4096*16*8+0, 4096*16*8+4 },
3375   { 3, 2, 1, 0, 8+3, 8+2, 8+1, 8+0 },
3376   { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
3377   16*8
960   { 0, 4, 8, 12 },
961   { 3, 2, 1, 0, 16+3, 16+2, 16+1, 16+0 },
962   { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
963   32*8
3378964};
3379965
3380static const gfx_layout heatbrl_charlayout =
966
967void descramble_legionnaire_gfx(UINT8* src)
3381968{
3382   8,8,
3383   RGN_FRAC(1,2),   /* second half is junk, like legionna we may need a different decode */
3384   4,
3385   { 0, 4, 4096*16*8+0, 4096*16*8+4 },
3386   { 3, 2, 1, 0, 8+3, 8+2, 8+1, 8+0 },
3387   { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
3388   16*8
3389};
969   UINT8 *buffer;
970   int len = 0x10000;
3390971
972   /*  rearrange gfx */
973   buffer = malloc_or_die(len);
974   {
975      int i;
976      for (i = 0;i < len; i++)
977      {
978         buffer[i] = src[BITSWAP24(i,
979         23,22,21,20,
980         19,18,17,16,
981         6,5,15,14,13,12,
982         11,10,9,8,
983         7,4,
984         3,2,1,0)];
985      }
986      memcpy(src,buffer,len);
987      free(buffer);
988   }
3391989
3392static const gfx_layout legionna_char2layout =
3393{
3394   16,16,
3395   256,   /* Can't use RGN_FRAC as (1,16) not supported */
3396   4,
3397   { 0, 4, 4096*16*8+0, 4096*16*8+4 },
3398   { 3, 2, 1, 0, 11, 10, 9, 8,
3399     1024*16*8 +3,  1024*16*8 +2,  1024*16*8 +1, 1024*16*8 +0,
3400     1024*16*8 +11, 1024*16*8 +10, 1024*16*8 +9, 1024*16*8 +8 },
3401   { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16,
3402     512*16*8 +0*16, 512*16*8 +1*16, 512*16*8 +2*16, 512*16*8 +3*16,
3403     512*16*8 +4*16, 512*16*8 +5*16, 512*16*8 +6*16, 512*16*8 +7*16 },
3404   16*8
3405};
990}
3406991
992
3407993static const gfx_layout legionna_tilelayout =
3408994{
3409995   16,16,
r2375r2376
34311017};
34321018
34331019static GFXDECODE_START( legionna )
3434   GFXDECODE_ENTRY( REGION_GFX1, 0, legionna_charlayout,   48*16, 16 )
1020   GFXDECODE_ENTRY( REGION_GFX1, 0, legionna_new_charlayout,   48*16, 16 )
34351021   GFXDECODE_ENTRY( REGION_GFX3, 0, legionna_tilelayout,    0*16, 16 )
3436   GFXDECODE_ENTRY( REGION_GFX4, 0, legionna_char2layout,  32*16, 16 )   /* example BK3 decode */
1022   GFXDECODE_ENTRY( REGION_GFX4, 0, legionna_tilelayout,  32*16, 16 )
34371023   GFXDECODE_ENTRY( REGION_GFX2, 0, legionna_spritelayout,  0*16, 8*16 )
3438   GFXDECODE_ENTRY( REGION_GFX5, 0, legionna_tilelayout,   32*16, 16 )   /* this should be the BK3 decode */
1024   GFXDECODE_ENTRY( REGION_GFX5, 0, legionna_tilelayout,   32*16, 16 )
34391025   GFXDECODE_ENTRY( REGION_GFX6, 0, legionna_tilelayout,   16*16, 16 )
34401026GFXDECODE_END
34411027
34421028static GFXDECODE_START( heatbrl )
3443   GFXDECODE_ENTRY( REGION_GFX1, 0, heatbrl_charlayout,    48*16, 16 )
1029   GFXDECODE_ENTRY( REGION_GFX1, 0, legionna_new_charlayout,    48*16, 16 )
34441030   GFXDECODE_ENTRY( REGION_GFX3, 0, legionna_tilelayout,    0*16, 16 )
3445   GFXDECODE_ENTRY( REGION_GFX4, 0, legionna_char2layout,  32*16, 16 )   /* unused */
1031   GFXDECODE_ENTRY( REGION_GFX4, 0, legionna_tilelayout,  32*16, 16 ) /* unused */
34461032   GFXDECODE_ENTRY( REGION_GFX2, 0, legionna_spritelayout,  0*16, 8*16 )
34471033   GFXDECODE_ENTRY( REGION_GFX5, 0, legionna_tilelayout,   32*16, 16 )
34481034   GFXDECODE_ENTRY( REGION_GFX6, 0, legionna_tilelayout,   16*16, 16 )
34491035GFXDECODE_END
34501036
34511037static GFXDECODE_START( sdgndmrb )
3452   GFXDECODE_ENTRY( REGION_GFX1, 0, heatbrl_charlayout,    48*16, 16 )
1038   GFXDECODE_ENTRY( REGION_GFX1, 0, legionna_new_charlayout,    48*16, 16 )
34531039   GFXDECODE_ENTRY( REGION_GFX3, 0, legionna_tilelayout,    0*16, 16 )
3454   GFXDECODE_ENTRY( REGION_GFX4, 0, legionna_char2layout,  32*16, 16 )   /* unused */
1040   GFXDECODE_ENTRY( REGION_GFX4, 0, legionna_tilelayout,  32*16, 16 )   /* unused */
34551041   GFXDECODE_ENTRY( REGION_GFX2, 0, legionna_spritelayout,  0*16, 8*16 )
34561042   GFXDECODE_ENTRY( REGION_GFX5, 0, legionna_tilelayout,   32*16, 16 )
34571043   GFXDECODE_ENTRY( REGION_GFX6, 0, legionna_tilelayout,   16*16, 16 )
r2375r2376
34631049
34641050   /* basic machine hardware */
34651051   MDRV_CPU_ADD(M68000,20000000/2)    /* ??? */
3466   MDRV_CPU_PROGRAM_MAP(legionna_readmem,legionna_writemem)
1052   MDRV_CPU_PROGRAM_MAP(legionna_map,0)
34671053   MDRV_CPU_VBLANK_INT("main", irq4_line_hold)/* VBL */
34681054
34691055   SEIBU_SOUND_SYSTEM_CPU(14318180/4)
r2375r2376
34951081
34961082   /* basic machine hardware */
34971083   MDRV_CPU_ADD(M68000,20000000/2)    /* ??? */
3498   MDRV_CPU_PROGRAM_MAP(heatbrl_readmem,heatbrl_writemem)
1084   MDRV_CPU_PROGRAM_MAP(heatbrl_map,0)
34991085   MDRV_CPU_VBLANK_INT("main", irq4_line_hold)/* VBL */
35001086
35011087   SEIBU_SOUND_SYSTEM_CPU(14318180/4)
r2375r2376
35261112
35271113   /* basic machine hardware */
35281114   MDRV_CPU_ADD(M68000, 20000000/2)
3529   MDRV_CPU_PROGRAM_MAP(godzilla_readmem,godzilla_writemem)
1115   MDRV_CPU_PROGRAM_MAP(godzilla_map,0)
35301116   MDRV_CPU_VBLANK_INT("main", irq4_line_hold)
35311117
35321118   SEIBU2_SOUND_SYSTEM_CPU(14318180/4)
r2375r2376
35571143
35581144   /* basic machine hardware */
35591145   MDRV_CPU_ADD(M68000, 20000000/2)
3560   MDRV_CPU_PROGRAM_MAP(denjinmk_readmem,denjinmk_writemem)
1146   MDRV_CPU_PROGRAM_MAP(denjinmk_map,0)
35611147   MDRV_CPU_VBLANK_INT("main", irq4_line_hold)
35621148
35631149   SEIBU2_SOUND_SYSTEM_CPU(14318180/4)
r2375r2376
35881174
35891175   /* basic machine hardware */
35901176   MDRV_CPU_ADD(M68000, 20000000/2)
3591   MDRV_CPU_PROGRAM_MAP(sdgndmrb_readmem,sdgndmrb_writemem)
1177   MDRV_CPU_PROGRAM_MAP(sdgndmrb_map, 0)
35921178   MDRV_CPU_VBLANK_INT("main", irq4_line_hold)
35931179
35941180   SEIBU2_SOUND_SYSTEM_CPU(14318180/4)
r2375r2376
37081294   ROM_LOAD( "6",   0x00000, 0x08000, CRC(fe7b8d06) SHA1(1e5b52ea4b4042940e2ee2db75c7c0f24973422a) )
37091295   ROM_CONTINUE(    0x10000, 0x08000 )   /* banked stuff */
37101296
3711   ROM_REGION( 0x020000, REGION_GFX1, ROMREGION_DISPOSE )
3712   ROM_LOAD( "7",   0x000000, 0x10000, CRC(88e26809) SHA1(40ee55d3b5329b6f657e0621d93c4caf6a035fdf) )   /* chars, some BK3 tiles too */
3713   ROM_LOAD( "8",   0x010000, 0x10000, CRC(06e35407) SHA1(affeeb97b7f3cfa9b65a584ebe25c16a5b2c9a89) )
1297   ROM_REGION( 0x020000, REGION_USER1, ROMREGION_DISPOSE ) /* load the tiles here so we can split them up into the required regions by hand */
1298   ROM_LOAD16_BYTE( "7",   0x000000, 0x10000, CRC(88e26809) SHA1(40ee55d3b5329b6f657e0621d93c4caf6a035fdf) )
1299   ROM_LOAD16_BYTE( "8",   0x000001, 0x10000, CRC(06e35407) SHA1(affeeb97b7f3cfa9b65a584ebe25c16a5b2c9a89) )
37141300
1301   ROM_REGION( 0x010000, REGION_GFX1, ROMREGION_DISPOSE )  /* FG Tiles */
1302   ROM_COPY( REGION_USER1, 0x010000, 0x000000, 0x010000 )
1303
1304   ROM_REGION( 0x010000, REGION_GFX5, ROMREGION_DISPOSE )  /* BK3 */
1305   ROM_COPY( REGION_USER1, 0x000000, 0x000000, 0x010000 ) /* decrambled in INIT */
1306
37151307   ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )
37161308   ROM_LOAD( "obj1",     0x000000, 0x100000, CRC(d35602f5) SHA1(79379abf1c8131df47f81f42b2dc6876926a4e9d) )   /* sprites */
37171309   ROM_LOAD( "obj2",     0x100000, 0x100000, CRC(351d3917) SHA1(014562ac55c09227c08275df3129df19d81af164) )
37181310
3719   ROM_REGION( 0x100000, REGION_GFX3, ROMREGION_DISPOSE )
1311   ROM_REGION( 0x100000, REGION_USER2, ROMREGION_DISPOSE ) /* load the tiles here so we can split them up into the required regions by hand */
37201312   ROM_LOAD( "back",     0x000000, 0x100000, CRC(58280989) SHA1(e3eef1f52829a91b8f87cfe27776a1f12679b3ca) )   /* 3 sets of tiles ('MBK','LBK','BK3') */
37211313
3722   ROM_REGION( 0x020000, REGION_GFX4, ROMREGION_DISPOSE )   /* example BK3 decode */
3723   ROM_COPY( REGION_GFX1, 0x00000, 0x00000, 0x20000 )
1314   ROM_REGION( 0x80000, REGION_GFX3, ROMREGION_DISPOSE )  /* MBK */
1315   ROM_COPY( REGION_USER2, 0x000000, 0x000000, 0x80000 )
37241316
3725   ROM_REGION( 0x020000, REGION_GFX5, ROMREGION_DISPOSE )   /* we _should_ decode all BK3 tiles here */
1317   ROM_REGION( 0x100000, REGION_GFX4, ROMREGION_DISPOSE )
1318   /* Not Used */
37261319
3727   ROM_REGION( 0x080000, REGION_GFX6, ROMREGION_DISPOSE )   /* LBK tiles (plus BK3 at end) */
3728   ROM_COPY( REGION_GFX3, 0x80000, 0x00000, 0x80000 )
1320   ROM_REGION( 0x80000, REGION_GFX6, ROMREGION_DISPOSE )   /* LBK */
1321   ROM_COPY( REGION_USER2, 0x080000, 0x000000, 0x78000 )
37291322
37301323   ROM_REGION( 0x020000, REGION_SOUND1, 0 )   /* ADPCM samples */
37311324   ROM_LOAD( "5",   0x00000, 0x20000, CRC(21d09bde) SHA1(8dce5011e083706ac7b57c5aee4b79d30fa8d4cb) )
r2375r2376
37421335   ROM_LOAD( "6",   0x00000, 0x08000, CRC(fe7b8d06) SHA1(1e5b52ea4b4042940e2ee2db75c7c0f24973422a) )
37431336   ROM_CONTINUE(    0x10000, 0x08000 )   /* banked stuff */
37441337
3745   ROM_REGION( 0x020000, REGION_GFX1, ROMREGION_DISPOSE )
3746   ROM_LOAD( "7",   0x000000, 0x10000, CRC(88e26809) SHA1(40ee55d3b5329b6f657e0621d93c4caf6a035fdf) )   /* chars, some BK3 tiles too */
3747   ROM_LOAD( "8",   0x010000, 0x10000, CRC(06e35407) SHA1(affeeb97b7f3cfa9b65a584ebe25c16a5b2c9a89) )
1338   ROM_REGION( 0x020000, REGION_USER1, ROMREGION_DISPOSE ) /* load the tiles here so we can split them up into the required regions by hand */
1339   ROM_LOAD16_BYTE( "7",   0x000000, 0x10000, CRC(88e26809) SHA1(40ee55d3b5329b6f657e0621d93c4caf6a035fdf) )   /* chars, some BK3 tiles too */
1340   ROM_LOAD16_BYTE( "8",   0x000001, 0x10000, CRC(06e35407) SHA1(affeeb97b7f3cfa9b65a584ebe25c16a5b2c9a89) )
37481341
1342   ROM_REGION( 0x010000, REGION_GFX1, ROMREGION_DISPOSE )  /* FG Tiles */
1343   ROM_COPY( REGION_USER1, 0x010000, 0x000000, 0x010000 )
1344
1345   ROM_REGION( 0x010000, REGION_GFX5, ROMREGION_DISPOSE )  /* BK3 */
1346   ROM_COPY( REGION_USER1, 0x000000, 0x000000, 0x010000 ) /* decrambled in INIT */
1347
37491348   ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )
37501349   ROM_LOAD( "obj1",     0x000000, 0x100000, CRC(d35602f5) SHA1(79379abf1c8131df47f81f42b2dc6876926a4e9d) )   /* sprites */
37511350   ROM_LOAD( "obj2",     0x100000, 0x100000, CRC(351d3917) SHA1(014562ac55c09227c08275df3129df19d81af164) )
37521351
3753   ROM_REGION( 0x100000, REGION_GFX3, ROMREGION_DISPOSE )
1352   ROM_REGION( 0x100000, REGION_USER2, ROMREGION_DISPOSE ) /* load the tiles here so we can split them up into the required regions by hand */
37541353   ROM_LOAD( "back",     0x000000, 0x100000, CRC(58280989) SHA1(e3eef1f52829a91b8f87cfe27776a1f12679b3ca) )   /* 3 sets of tiles ('MBK','LBK','BK3') */
37551354
3756   ROM_REGION( 0x020000, REGION_GFX4, ROMREGION_DISPOSE )   /* example BK3 decode */
3757   ROM_COPY( REGION_GFX1, 0x00000, 0x00000, 0x20000 )
1355   ROM_REGION( 0x80000, REGION_GFX3, ROMREGION_DISPOSE )  /* MBK */
1356   ROM_COPY( REGION_USER2, 0x000000, 0x000000, 0x80000 )
37581357
3759   ROM_REGION( 0x020000, REGION_GFX5, ROMREGION_DISPOSE )   /* we _should_ decode all BK3 tiles here */
1358   ROM_REGION( 0x100000, REGION_GFX4, ROMREGION_DISPOSE )
1359   /* Not Used */
37601360
3761   ROM_REGION( 0x080000, REGION_GFX6, ROMREGION_DISPOSE )   /* LBK tiles (plus BK3 at end) */
3762   ROM_COPY( REGION_GFX3, 0x80000, 0x00000, 0x80000 )
1361   ROM_REGION( 0x80000, REGION_GFX6, ROMREGION_DISPOSE )   /* LBK */
1362   ROM_COPY( REGION_USER2, 0x080000, 0x000000, 0x78000 )
37631363
37641364   ROM_REGION( 0x020000, REGION_SOUND1, 0 )   /* ADPCM samples */
37651365   ROM_LOAD( "5",   0x00000, 0x20000, CRC(21d09bde) SHA1(8dce5011e083706ac7b57c5aee4b79d30fa8d4cb) )
r2375r2376
37771377   ROM_CONTINUE(    0x10000, 0x08000 )   /* banked stuff */
37781378
37791379   ROM_REGION( 0x020000, REGION_GFX1, ROMREGION_DISPOSE )
3780   ROM_LOAD( "barrel.6",   0x000000, 0x10000, CRC(bea3c581) SHA1(7f7f0a74bf106acaf57c182d47f0c707da2011bd) )   /* chars */
3781   ROM_LOAD( "barrel.5",   0x010000, 0x10000, CRC(5604d155) SHA1(afc30347b1e1316ec25056c0c1576f78be5f1a72) )
1380   ROM_LOAD16_BYTE( "barrel.6",   0x000000, 0x10000, CRC(bea3c581) SHA1(7f7f0a74bf106acaf57c182d47f0c707da2011bd) )   /* chars */
1381   ROM_LOAD16_BYTE( "barrel.5",   0x000001, 0x10000, CRC(5604d155) SHA1(afc30347b1e1316ec25056c0c1576f78be5f1a72) )
37821382
37831383   ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )
37841384   ROM_LOAD( "obj1",     0x000000, 0x100000, CRC(f7a7c31c) SHA1(683e5c7a0732ff5fd56167dd82035ca050de0507) )   /* sprites */
r2375r2376
37871387   ROM_REGION( 0x100000, REGION_GFX3, ROMREGION_DISPOSE )   /* MBK tiles */
37881388   ROM_LOAD( "bg-1",     0x000000, 0x100000, CRC(2f5d8baa) SHA1(0bf687c46c603150eadb304adcd78d53a338e615) )
37891389
3790   ROM_REGION( 0x020000, REGION_GFX4, ROMREGION_DISPOSE )   /* not used */
1390   ROM_REGION( 0x020000, REGION_GFX4, ROMREGION_DISPOSE )   /* not used? */
1391   ROM_COPY( REGION_GFX1, 0x010000, 0x000000, 0x010000 ) // this is just corrupt tiles if we decode it
37911392
37921393   ROM_REGION( 0x080000, REGION_GFX5, ROMREGION_DISPOSE )   /* BK3 tiles */
37931394   ROM_LOAD( "bg-3",     0x000000, 0x080000, CRC(83850e2d) SHA1(cdc2df8e3bc58319c50768ea2a05b9c7ddc2a652) )
r2375r2376
38111412   ROM_CONTINUE(    0x10000, 0x08000 )   /* banked stuff */
38121413
38131414   ROM_REGION( 0x020000, REGION_GFX1, ROMREGION_DISPOSE )
3814   ROM_LOAD( "barrel.6",   0x000000, 0x10000, CRC(bea3c581) SHA1(7f7f0a74bf106acaf57c182d47f0c707da2011bd) )   /* chars */
3815   ROM_LOAD( "barrel.5",   0x010000, 0x10000, CRC(5604d155) SHA1(afc30347b1e1316ec25056c0c1576f78be5f1a72) )
1415   ROM_LOAD16_BYTE( "barrel.6",   0x000000, 0x10000, CRC(bea3c581) SHA1(7f7f0a74bf106acaf57c182d47f0c707da2011bd) )   /* chars */
1416   ROM_LOAD16_BYTE( "barrel.5",   0x000001, 0x10000, CRC(5604d155) SHA1(afc30347b1e1316ec25056c0c1576f78be5f1a72) )
38161417
38171418/* Sprite + tilemap gfx roms not dumped, for now we use ones from heatbrlu
38181419Readme mentions as undumped:
r2375r2376
38501451   ROM_CONTINUE(    0x10000, 0x08000 )   /* banked stuff */
38511452
38521453   ROM_REGION( 0x020000, REGION_GFX1, ROMREGION_DISPOSE )
3853   ROM_LOAD( "barrel.6",   0x000000, 0x10000, CRC(bea3c581) SHA1(7f7f0a74bf106acaf57c182d47f0c707da2011bd) )   /* chars */
3854   ROM_LOAD( "barrel.5",   0x010000, 0x10000, CRC(5604d155) SHA1(afc30347b1e1316ec25056c0c1576f78be5f1a72) )
1454   ROM_LOAD16_BYTE( "barrel.6",   0x000000, 0x10000, CRC(bea3c581) SHA1(7f7f0a74bf106acaf57c182d47f0c707da2011bd) )   /* chars */
1455   ROM_LOAD16_BYTE( "barrel.5",   0x000001, 0x10000, CRC(5604d155) SHA1(afc30347b1e1316ec25056c0c1576f78be5f1a72) )
38551456
38561457   ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )
38571458   ROM_LOAD( "obj1",     0x000000, 0x100000, CRC(f7a7c31c) SHA1(683e5c7a0732ff5fd56167dd82035ca050de0507) )   /* sprites */
r2375r2376
39341535   ROM_CONTINUE(           0x010000, 0x08000 )   /* banked stuff */
39351536
39361537   ROM_REGION( 0x020000, REGION_GFX1, ROMREGION_DISPOSE )
3937   ROM_LOAD( "11.620",       0x000000, 0x010000, CRC(58e0e41f) SHA1(563c633eb3d4df41e467c93957c74b540a0ae43c) )
3938   ROM_LOAD( "10.615",       0x010000, 0x010000, CRC(9c22bc13) SHA1(a94d9ed63ee1f5e358ebcaf517e6a1c986fa5d96) )
1538   ROM_LOAD16_BYTE( "11.620",       0x000000, 0x010000, CRC(58e0e41f) SHA1(563c633eb3d4df41e467c93957c74b540a0ae43c) )
1539   ROM_LOAD16_BYTE( "10.615",       0x000001, 0x010000, CRC(9c22bc13) SHA1(a94d9ed63ee1f5e358ebcaf517e6a1c986fa5d96) )
39391540
39401541   ROM_REGION( 0x400000, REGION_GFX2, ROMREGION_DISPOSE )
3941   ROM_LOAD( "obj1.748",     0x300000, 0x100000, CRC(146bacb0) SHA1(1331f04f3d9e6236cec7524e9da1782ed1916ff7) )
1542   ROM_LOAD( "obj1.748",     0x300000, 0x100000, CRC(146bacb0) SHA1(1331f04f3d9e6236cec7524e9da1782ed1916ff7) ) // this might be half size like denjinmk, same pcb..
39421543   ROM_LOAD( "obj2.756",     0x200000, 0x100000, CRC(91c2a6a5) SHA1(0e9d9d94c3d99a54c6f9f99270e65682eb0a8b6a) )
39431544   ROM_LOAD( "obj3.743",     0x100000, 0x100000, CRC(5af0114e) SHA1(9362de9ade6db67ab0e3a2dfea580e688bbf7729) )
39441545   ROM_LOAD( "obj4.757",     0x000000, 0x100000, CRC(7448b054) SHA1(5c08319329eb8c90b63e5393c0011bc39911ebbb) )
r2375r2376
40511652   ROM_CONTINUE(           0x010000, 0x08000 )   /* banked stuff */
40521653
40531654   ROM_REGION( 0x020000, REGION_GFX1, ROMREGION_DISPOSE )
4054   ROM_LOAD( "rom7.620",       0x000000, 0x010000, CRC(e1f759b1) SHA1(ddc60e78e7791a59c59403dd4089b3f6e1ecf8cb) )
4055   ROM_LOAD( "rom8.615",       0x010000, 0x010000, CRC(cc36af0d) SHA1(69c2ae38f03be79be4d138fcc73a6a86407eb285) )
1655   ROM_LOAD16_BYTE( "rom7.620",       0x000000, 0x010000, CRC(e1f759b1) SHA1(ddc60e78e7791a59c59403dd4089b3f6e1ecf8cb) )
1656   ROM_LOAD16_BYTE( "rom8.615",       0x000001, 0x010000, CRC(cc36af0d) SHA1(69c2ae38f03be79be4d138fcc73a6a86407eb285) )
40561657
4057   ROM_REGION( 0x400000, REGION_GFX2, ROMREGION_DISPOSE )
4058/**/ROM_LOAD( "obj-0-3.748",     0x000000, 0x100000, CRC(3dcc7b04) SHA1(3c3ad5ddc18a42046348dcb54e65f6173c003d72) )
4059   ROM_LOAD( "obj-8-9.757",     0x100000, 0x100000, CRC(c8f7e1c9) SHA1(a746d187b50a0ecdd5a7f687a2601e5dc8bfe272) )
4060   ROM_LOAD( "obj-4-5.756",     0x200000, 0x100000, CRC(01f8d4e6) SHA1(25b69da693be8c3404f750b419c330a7a56e88ec) )
4061   ROM_LOAD( "obj-6-7.743",     0x300000, 0x100000, CRC(e5805757) SHA1(9d392c27eef7c1fcda560dac17ba9d7ae2287ac8) )
1658   ROM_REGION( 0x500000, REGION_GFX2, ROMREGION_DISPOSE )
1659    ROM_LOAD( "obj-0-3.748",     0x000000, 0x100000, BAD_DUMP CRC(3dcc7b04) SHA1(3c3ad5ddc18a42046348dcb54e65f6173c003d72) ) /* half size?# 0,1 */
1660   /* the graphics for this region are missing, the previous rom should probably be twice the size, note the filename 0-3 */
1661   ROM_LOAD( "obj-4-5.756",     0x200000, 0x100000, CRC(01f8d4e6) SHA1(25b69da693be8c3404f750b419c330a7a56e88ec) ) /* 4,5 */
1662   ROM_LOAD( "obj-6-7.743",     0x300000, 0x100000, CRC(e5805757) SHA1(9d392c27eef7c1fcda560dac17ba9d7ae2287ac8) ) /* 6,7 */
1663   ROM_LOAD( "obj-8-9.757",     0x400000, 0x100000, CRC(c8f7e1c9) SHA1(a746d187b50a0ecdd5a7f687a2601e5dc8bfe272) ) /* 8,9 */
40621664
40631665   ROM_REGION( 0x100000, REGION_GFX3, ROMREGION_DISPOSE )   /* MBK tiles */
40641666   ROM_LOAD( "bg-1-ab.618",      0x000000, 0x100000, CRC(eaad151a) SHA1(bdd1d83ee8497efe20f21baf873e786446372bcb) )
r2375r2376
41461748   ROM_CONTINUE(             0x010000, 0x08000 )
41471749
41481750   ROM_REGION( 0x020000, REGION_GFX1, ROMREGION_DISPOSE )
4149   ROM_LOAD( "rb-f1.620",    0x000000, 0x010000, CRC(792c403d) SHA1(3c606af696fe8f3d6edefdab3940bd5eb341bca9) )
4150   ROM_LOAD( "rb-f2.615",    0x010000, 0x010000, CRC(a30e0903) SHA1(b9e7646da1ccab6dadaca6beda08125b34946653) )
1751   ROM_LOAD16_BYTE( "rb-f1.620",    0x000000, 0x010000, CRC(792c403d) SHA1(3c606af696fe8f3d6edefdab3940bd5eb341bca9) )
1752   ROM_LOAD16_BYTE( "rb-f2.615",    0x000001, 0x010000, CRC(a30e0903) SHA1(b9e7646da1ccab6dadaca6beda08125b34946653) )
41511753
41521754   ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )
41531755   ROM_LOAD( "rb-spr01.748", 0x000000, 0x100000, CRC(11a3479d) SHA1(4d2d06d62da02c6e9884735de8c319f37ca1715c) )
r2375r2376
41721774   ROM_LOAD( "copx-d2.313",  0x0000, 0x040000, CRC(a6732ff9) SHA1(c4856ec77869d9098da24b1bb3d7d58bb74b4cda) )
41731775ROM_END
41741776
1777
41751778ROM_START( cupsoc )
41761779   ROM_REGION( 0x100000, REGION_CPU1, 0 )   /* 68000 code */
4177   ROM_LOAD32_BYTE( "seibu1.10n",   0x000000, 0x040000, CRC(e91fdc95) SHA1(71c56fffabca79e73dfc61aad17bc58e09a28680) )
4178   ROM_LOAD32_BYTE( "seibu2.10q",   0x000001, 0x040000, CRC(7816df3c) SHA1(d5cfbf493cc00c47406b314c08e9cbf159a7f98c) )
4179   ROM_LOAD32_BYTE( "seibu3.10f",   0x000002, 0x040000, CRC(3be8a330) SHA1(f821080acd29c5801abc36da3341aabaea82ceb0) )
4180   ROM_LOAD32_BYTE( "seibu4.10k",   0x000003, 0x040000, CRC(f30167ea) SHA1(5431296e3245631c90362373027c54166f8fba16) )
1780   ROM_LOAD32_BYTE( "scc_01.bin",   0x000000, 0x040000, CRC(c122203c) SHA1(93c0ae90c0ed3889b9159774ba89536108c9b259) )
1781   ROM_LOAD32_BYTE( "scc_02.bin",   0x000001, 0x040000, CRC(105511b4) SHA1(f2ebe95a10f5928f57d4f532e2d2432f13b774b2) )
1782   ROM_LOAD32_BYTE( "scc_03.bin",   0x000002, 0x040000, CRC(2d23d78f) SHA1(c479ded8782f2d23e123b7d00ec57c18a8f80578) )
1783   ROM_LOAD32_BYTE( "scc_04.bin",   0x000003, 0x040000, CRC(e8877461) SHA1(3be44459699fd455b0daaac10e8a37d1b7985607) )
41811784
41821785   ROM_REGION( 0x20000*2, REGION_CPU2, 0 )   /* Z80 code, banked data */
41831786   ROM_LOAD( "seibu7.8a",    0x000000, 0x08000, CRC(f63329f9) SHA1(51736de48efc14415cfdf169b43623d4c95fde2b) )
41841787   ROM_CONTINUE(           0x010000, 0x08000 )   /* banked stuff */
41851788
41861789   ROM_REGION( 0x020000, REGION_GFX1, ROMREGION_DISPOSE )
4187   ROM_LOAD( "seibu6.7x",    0x000000, 0x010000, CRC(21c1e1b8) SHA1(30928c8ef98bf32ba0bf795ddadba1c95fcffe9d) )
4188   ROM_LOAD( "seibu5.7y",    0x010000, 0x010000, CRC(955d9fd7) SHA1(782451e8e85f7ba285d6cacd9d3fdcf48bde60bc) )
1790   ROM_LOAD16_BYTE( "scc_06.bin",   0x000000, 0x010000, CRC(f1a18ec6) SHA1(43f8ec3fc541b8dc2a17533329dd3448afadcb3b) )
1791   ROM_LOAD16_BYTE( "scc_05.bin",   0x000001, 0x010000, CRC(c0358503) SHA1(e87991c6a6f3e060a1b03b4899fa891510fca15f) )
41891792
41901793   ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )
41911794   ROM_LOAD( "obj.8c",       0x000000, 0x100000, CRC(e2377895) SHA1(1d1c7f31a08a464139cdaf383a5e1ade0717dc9f) )
r2375r2376
42031806
42041807   ROM_REGION( 0x040000, REGION_SOUND1, 0 )   /* ADPCM samples */
42051808   ROM_LOAD( "seibu8.7a",    0x000000, 0x040000, CRC(6f594808) SHA1(218aa12068aa587c7656355f6a6b86d97c868774) )
1809
1810   ROM_REGION( 0x080000, REGION_USER1, 0 )
1811   ROM_LOAD( "copx-d1.bin",  0x000000, 0x080000, CRC(029bc402) SHA1(0f64e4c32d95abfa3920b39ed3cf0cc6eb50191b) )
42061812ROM_END
42071813
4208ROM_START( cupsoc2 )
1814ROM_START( cupsocs )
42091815   ROM_REGION( 0x100000, REGION_CPU1, 0 )   /* 68000 code */
4210   ROM_LOAD32_BYTE( "scc_01.bin",   0x000000, 0x040000, CRC(c122203c) SHA1(93c0ae90c0ed3889b9159774ba89536108c9b259) )
4211   ROM_LOAD32_BYTE( "scc_02.bin",   0x000001, 0x040000, CRC(105511b4) SHA1(f2ebe95a10f5928f57d4f532e2d2432f13b774b2) )
4212   ROM_LOAD32_BYTE( "scc_03.bin",   0x000002, 0x040000, CRC(2d23d78f) SHA1(c479ded8782f2d23e123b7d00ec57c18a8f80578) )
4213   ROM_LOAD32_BYTE( "scc_04.bin",   0x000003, 0x040000, CRC(e8877461) SHA1(3be44459699fd455b0daaac10e8a37d1b7985607) )
1816   ROM_LOAD32_BYTE( "1_10n.bin",   0x000000, 0x040000, CRC(b67835c5) SHA1(4fa562630d1f9cfb6f5bfff3295ebbdd227e4da5) )
1817   ROM_LOAD32_BYTE( "2_10q.bin",   0x000001, 0x040000, CRC(de65509c) SHA1(3362258b6d86fc63afa205712416a4aac0cf10e4) )
1818   ROM_LOAD32_BYTE( "3_10f.bin",   0x000002, 0x040000, CRC(c0333f0c) SHA1(ed02897724de4cf981aa8c6ce98551b9e79efff3) )
1819   ROM_LOAD32_BYTE( "4_10k.bin",   0x000003, 0x040000, CRC(288f11d4) SHA1(424cb3d1428f7195decce2ba6eebc1e24d9bb207) )
42141820
42151821   ROM_REGION( 0x20000*2, REGION_CPU2, 0 )   /* Z80 code, banked data */
4216   ROM_LOAD( "seibu7.8a",    0x000000, 0x08000, CRC(f63329f9) SHA1(51736de48efc14415cfdf169b43623d4c95fde2b) )
1822   ROM_LOAD( "7_8a.bin",    0x000000, 0x08000, CRC(f63329f9) SHA1(51736de48efc14415cfdf169b43623d4c95fde2b) )
42171823   ROM_CONTINUE(           0x010000, 0x08000 )   /* banked stuff */
42181824
42191825   ROM_REGION( 0x020000, REGION_GFX1, ROMREGION_DISPOSE )
4220   ROM_LOAD( "scc_06.bin",   0x000000, 0x010000, CRC(f1a18ec6) SHA1(43f8ec3fc541b8dc2a17533329dd3448afadcb3b) )
4221   ROM_LOAD( "scc_05.bin",   0x010000, 0x010000, CRC(c0358503) SHA1(e87991c6a6f3e060a1b03b4899fa891510fca15f) )
1826   ROM_LOAD16_BYTE( "6_7x.bin",   0x000000, 0x010000, CRC(7981366e) SHA1(b859bf23c5ae466f4020958a06935192fa68ee8d) )
1827   ROM_LOAD16_BYTE( "5_7y.bin",   0x000001, 0x010000, CRC(26cbfaf0) SHA1(1ba7bc1cecb4bd06ba5c2d3eaa9c9e38e2106cd2) )
42221828
42231829   ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )
42241830   ROM_LOAD( "obj.8c",       0x000000, 0x100000, CRC(e2377895) SHA1(1d1c7f31a08a464139cdaf383a5e1ade0717dc9f) )
r2375r2376
42351841   ROM_COPY( REGION_GFX5, 0x00000, 0x00000, 0x080000 )
42361842
42371843   ROM_REGION( 0x040000, REGION_SOUND1, 0 )   /* ADPCM samples */
4238   ROM_LOAD( "seibu8.7a",    0x000000, 0x040000, CRC(6f594808) SHA1(218aa12068aa587c7656355f6a6b86d97c868774) )
1844   ROM_LOAD( "8_7a.bin",    0x000000, 0x040000, CRC(6f594808) SHA1(218aa12068aa587c7656355f6a6b86d97c868774) )
42391845
42401846   ROM_REGION( 0x080000, REGION_USER1, 0 )
42411847   ROM_LOAD( "copx-d1.bin",  0x000000, 0x080000, CRC(029bc402) SHA1(0f64e4c32d95abfa3920b39ed3cf0cc6eb50191b) )
42421848ROM_END
42431849
1850ROM_START( cupsocs2 )
1851   ROM_REGION( 0x100000, REGION_CPU1, 0 )   /* 68000 code */
1852   ROM_LOAD32_BYTE( "seibu1.10n",   0x000000, 0x040000, CRC(e91fdc95) SHA1(71c56fffabca79e73dfc61aad17bc58e09a28680) )
1853   ROM_LOAD32_BYTE( "seibu2.10q",   0x000001, 0x040000, CRC(7816df3c) SHA1(d5cfbf493cc00c47406b314c08e9cbf159a7f98c) )
1854   ROM_LOAD32_BYTE( "seibu3.10f",   0x000002, 0x040000, CRC(3be8a330) SHA1(f821080acd29c5801abc36da3341aabaea82ceb0) )
1855   ROM_LOAD32_BYTE( "seibu4.10k",   0x000003, 0x040000, CRC(f30167ea) SHA1(5431296e3245631c90362373027c54166f8fba16) )
1856
1857   ROM_REGION( 0x20000*2, REGION_CPU2, 0 )   /* Z80 code, banked data */
1858   ROM_LOAD( "seibu7.8a",    0x000000, 0x08000, CRC(f63329f9) SHA1(51736de48efc14415cfdf169b43623d4c95fde2b) )
1859   ROM_CONTINUE(           0x010000, 0x08000 )   /* banked stuff */
1860
1861   ROM_REGION( 0x020000, REGION_GFX1, ROMREGION_DISPOSE )
1862   ROM_LOAD16_BYTE( "seibu6.7x",    0x000000, 0x010000, CRC(21c1e1b8) SHA1(30928c8ef98bf32ba0bf795ddadba1c95fcffe9d) )
1863   ROM_LOAD16_BYTE( "seibu5.7y",    0x000001, 0x010000, CRC(955d9fd7) SHA1(782451e8e85f7ba285d6cacd9d3fdcf48bde60bc) )
1864
1865   ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )
1866   ROM_LOAD( "obj.8c",       0x000000, 0x100000, CRC(e2377895) SHA1(1d1c7f31a08a464139cdaf383a5e1ade0717dc9f) )
1867
1868   ROM_REGION( 0x100000, REGION_GFX3, ROMREGION_DISPOSE )   /* MBK tiles */
1869   ROM_LOAD( "back-1.4y",    0x000000, 0x100000, CRC(3dfea0ec) SHA1(8f41d267e488e07831946ef898d593897f10bfe2) )
1870
1871   ROM_REGION( 0x020000, REGION_GFX4, ROMREGION_DISPOSE )   /* not used */
1872
1873   ROM_REGION( 0x080000, REGION_GFX5, ROMREGION_DISPOSE )   /* BK3 tiles */
1874   ROM_LOAD( "back-2.6y",    0x000000, 0x080000, CRC(e07712af) SHA1(2a0285d6a1e0141838e898252b8d922a6263b05f) )
1875
1876   ROM_REGION( 0x080000, REGION_GFX6, ROMREGION_DISPOSE )   /* LBK tiles */
1877   ROM_COPY( REGION_GFX5, 0x00000, 0x00000, 0x080000 )
1878
1879   ROM_REGION( 0x040000, REGION_SOUND1, 0 )   /* ADPCM samples */
1880   ROM_LOAD( "seibu8.7a",    0x000000, 0x040000, CRC(6f594808) SHA1(218aa12068aa587c7656355f6a6b86d97c868774) )
1881ROM_END
1882
1883
42441884ROM_START( olysoc92 )
42451885   ROM_REGION( 0x100000, REGION_CPU1, 0 )   /* 68000 code */
42461886   ROM_LOAD32_BYTE( "u025.1",       0x000000, 0x040000, CRC(a94e7780) SHA1(abbe328be425b4529e6b75ffa723c6771e4b6fcf) )
r2375r2376
42531893   ROM_CONTINUE(           0x010000, 0x08000 )   /* banked stuff */
42541894
42551895   ROM_REGION( 0x020000, REGION_GFX1, ROMREGION_DISPOSE )
4256   ROM_LOAD( "seibu6.7x",    0x000000, 0x010000, CRC(21c1e1b8) SHA1(30928c8ef98bf32ba0bf795ddadba1c95fcffe9d) )
4257   ROM_LOAD( "seibu5.7y",    0x010000, 0x010000, CRC(955d9fd7) SHA1(782451e8e85f7ba285d6cacd9d3fdcf48bde60bc) )
1896   ROM_LOAD16_BYTE( "seibu6.7x",    0x000000, 0x010000, CRC(21c1e1b8) SHA1(30928c8ef98bf32ba0bf795ddadba1c95fcffe9d) )
1897   ROM_LOAD16_BYTE( "seibu5.7y",    0x000001, 0x010000, CRC(955d9fd7) SHA1(782451e8e85f7ba285d6cacd9d3fdcf48bde60bc) )
42581898
42591899   ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )
42601900   ROM_LOAD( "obj.8c",       0x000000, 0x100000, CRC(e2377895) SHA1(1d1c7f31a08a464139cdaf383a5e1ade0717dc9f) )
r2375r2376
43041944
43051945*/
43061946
4307ROM_START( cupsocbl )
1947ROM_START( cupsocsb )
43081948   ROM_REGION( 0x100000, REGION_CPU1, 0 ) /* 68000 Code */
43091949   ROM_LOAD16_BYTE( "sc_04.bin", 0x00001, 0x80000, CRC(22566087) SHA1(4392f46ca50cc9947823a5190aa25f5e9654aa0d) )
43101950   ROM_LOAD16_BYTE( "sc_05.bin", 0x00000, 0x80000, CRC(2f977dff) SHA1(4d8d6e7d06ce17bb7292072965911f8b1f1067e2) )
r2375r2376
43151955   ROM_CONTINUE(           0x000000, 0x08000 )
43161956
43171957   ROM_REGION( 0x020000, REGION_GFX1, ROMREGION_DISPOSE )
4318   ROM_LOAD( "seibu6.7x",    0x000000, 0x010000, CRC(21c1e1b8) SHA1(30928c8ef98bf32ba0bf795ddadba1c95fcffe9d) )
4319   ROM_LOAD( "seibu5.7y",    0x010000, 0x010000, CRC(955d9fd7) SHA1(782451e8e85f7ba285d6cacd9d3fdcf48bde60bc) )
1958   ROM_LOAD16_BYTE( "seibu6.7x",    0x000000, 0x010000, CRC(21c1e1b8) SHA1(30928c8ef98bf32ba0bf795ddadba1c95fcffe9d) )
1959   ROM_LOAD16_BYTE( "seibu5.7y",    0x000001, 0x010000, CRC(955d9fd7) SHA1(782451e8e85f7ba285d6cacd9d3fdcf48bde60bc) )
43201960
43211961   ROM_REGION( 0x200000, REGION_GFX2, ROMREGION_DISPOSE )
43221962   ROM_LOAD( "obj.8c",       0x000000, 0x100000, CRC(e2377895) SHA1(1d1c7f31a08a464139cdaf383a5e1ade0717dc9f) )
r2375r2376
43541994   ROM_LOAD( "sc_03.bin",    0x000000, 0x080000, CRC(6e254d12) SHA1(857779dbd276b688201a8ea3afd5817e38acad2e) )
43551995ROM_END
43561996
4357static DRIVER_INIT( legionna )
4358{
4359   /* Unscramble gfx: quarters 1&2 swapped, quarters 3&4 swapped */
43601997
4361   UINT8 *gfx = memory_region(REGION_GFX1);
4362   int len = memory_region_length(REGION_GFX1)/2;
4363   int a,i;
43641998
4365   for (i = 0; i < len/2; i++)
4366   {
4367      a = gfx[i];
4368      gfx[i] = gfx[i + len/2];
4369      gfx[i+len/2] = a;
4370
4371      a = gfx[i+len];
4372      gfx[i+len] = gfx[i + len/2 + len];
4373      gfx[i + len/2 +len] = a;
4374   }
4375}
4376
43771999#define CUPSOC_DEBUG_MODE 1
43782000
43792001static DRIVER_INIT( cupsoc )
r2375r2376
43872009   #endif
43882010}
43892011
2012static DRIVER_INIT( denjinmk )
2013{
2014   /* problem with audio comms? */
2015   UINT16 *ROM = (UINT16 *)memory_region(REGION_CPU1);
2016   ROM[0x5fe4/2] = 0x4e71;
2017}
43902018
4391GAME( 1992, legionna, 0,        legionna, legionna, legionna, ROT0, "Tad", "Legionnaire (World)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
4392GAME( 1992, legionnu, legionna, legionna, legionna, legionna, ROT0, "Tad (Fabtek license)", "Legionnaire (US)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
2019DRIVER_INIT( legiongfx )
2020{
2021   descramble_legionnaire_gfx( memory_region(REGION_GFX5) );
2022}
43932023
4394GAME( 1992, heatbrl,  0,        heatbrl,  heatbrl,  0,        ROT0, "Tad", "Heated Barrel (World)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
4395GAME( 1992, heatbrlo, heatbrl,  heatbrl,  heatbrl,  0,        ROT0, "Tad", "Heated Barrel (World old version)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
4396GAME( 1992, heatbrlu, heatbrl,  heatbrl,  heatbrl,  0,        ROT0, "Tad", "Heated Barrel (US)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
43972024
2025
2026GAME( 1992, legionna, 0,        legionna, legionna, legiongfx, ROT0, "Tad", "Legionnaire (World)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
2027GAME( 1992, legionnu, legionna, legionna, legionna, legiongfx, ROT0, "Tad (Fabtek license)", "Legionnaire (US)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
2028
2029GAME( 1992, heatbrl,  0,        heatbrl,  heatbrl,  0,   ROT0, "Tad", "Heated Barrel (World)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
2030GAME( 1992, heatbrlo, heatbrl,  heatbrl,  heatbrl,  0,   ROT0, "Tad", "Heated Barrel (World old version)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
2031GAME( 1992, heatbrlu, heatbrl,  heatbrl,  heatbrl,  0,   ROT0, "Tad", "Heated Barrel (US)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
2032
43982033GAME( 1993, godzilla, 0,        godzilla, godzilla, 0,        ROT0, "Banpresto", "Godzilla", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
43992034GAME( 1993, sdgndmrb, 0,        sdgndmrb, sdgndmrb, 0,         ROT0, "Banpresto", "SD Gundam Sangokushi Rainbow Tairiku Senki", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
4400GAME( 1993, denjinmk, 0,        denjinmk, godzilla, 0,        ROT0, "Banpresto", "Denjin Makai", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
2035GAME( 1993, denjinmk, 0,        denjinmk, denjinmk, denjinmk, ROT0, "Banpresto", "Denjin Makai", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
44012036
4402GAME( 1992, cupsoc,   0,        cupsoc,   cupsoc,   0,        ROT0, "Seibu", "Seibu Cup Soccer (set 1)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
4403GAME( 1992, cupsoc2,  cupsoc,   cupsoc,   cupsoc,   0,        ROT0, "Seibu", "Seibu Cup Soccer (set 2)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
2037GAME( 1992, cupsoc,   0,        cupsoc,   cupsoc,   0,        ROT0, "Seibu", "Seibu Cup Soccer", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
2038GAME( 1992, cupsocs,  cupsoc,   cupsoc,   cupsoc,   0,        ROT0, "Seibu", "Seibu Cup Soccer :Selection: (set 1)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
2039GAME( 1992, cupsocs2, cupsoc,   cupsoc,   cupsoc,   0,        ROT0, "Seibu", "Seibu Cup Soccer :Selection: (set 2)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
2040GAME( 1992, cupsocsb, cupsoc,   cupsocbl, cupsoc,   cupsoc,   ROT0, "bootleg", "Seibu Cup Soccer :Selection: (bootleg)", GAME_NOT_WORKING | GAME_NO_SOUND )
44042041GAME( 1992, olysoc92, cupsoc,   cupsoc,   cupsoc,   0,        ROT0, "Seibu", "Olympic Soccer '92", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
4405GAME( 1992, cupsocbl, cupsoc,   cupsocbl, cupsoc,   cupsoc,   ROT0, "bootleg", "Seibu Cup Soccer (bootleg)", GAME_NOT_WORKING | GAME_NO_SOUND )
src/mame/drivers/midas.c
r2375r2376
180180
181181static READ16_HANDLER( livequiz_eeprom_r )
182182{
183   return readinputport(2) | (EEPROM_read_bit() << 3);
183   return input_port_read_indexed(machine, 2) | (EEPROM_read_bit() << 3);
184184}
185185
186186static WRITE16_HANDLER( livequiz_eeprom_w )
src/mame/drivers/mcr68.c
r2375r2376
7474
7575READ8_HANDLER( zwackery_port_2_r )
7676{
77   int result = readinputport(2);
78   int wheel = readinputport(5);
77   int result = input_port_read_indexed(machine, 2);
78   int wheel = input_port_read_indexed(machine, 5);
7979
8080   return result | ((wheel >> 2) & 0x3e);
8181}
r2375r2376
135135
136136static READ16_HANDLER( spyhunt2_port_0_r )
137137{
138   int result = readinputportbytag("IN0");
138   int result = input_port_read(machine, "IN0");
139139   int which = (control_word >> 3) & 3;
140   int analog = readinputport(3 + which);
140   int analog = input_port_read_indexed(machine, 3 + which);
141141   return result | ((soundsgood_status_r(machine, 0) & 1) << 5) | (analog << 8);
142142}
143143
144144
145145static READ16_HANDLER( spyhunt2_port_1_r )
146146{
147   int result = readinputportbytag("IN1");
147   int result = input_port_read(machine, "IN1");
148148   return result | ((turbocs_status_r(machine, 0) & 1) << 7);
149149}
150150
r2375r2376
197197
198198static READ16_HANDLER( archrivl_port_1_r )
199199{
200   return (translate49[readinputportbytag("49WAYY2") >> 4] << 12) |
201         (translate49[readinputportbytag("49WAYX2") >> 4] << 8) |
202         (translate49[readinputportbytag("49WAYY1") >> 4] << 4) |
203         (translate49[readinputportbytag("49WAYX1") >> 4] << 0);
200   return (translate49[input_port_read(machine, "49WAYY2") >> 4] << 12) |
201         (translate49[input_port_read(machine, "49WAYX2") >> 4] << 8) |
202         (translate49[input_port_read(machine, "49WAYY1") >> 4] << 4) |
203         (translate49[input_port_read(machine, "49WAYX1") >> 4] << 0);
204204}
205205
206206
r2375r2376
259259static READ16_HANDLER( pigskin_port_1_r )
260260{
261261   /* see archrivl_port_1_r for 49-way joystick description */
262   return readinputportbytag("IN1") |
263         (translate49[readinputportbytag("49WAYX1") >> 4] << 12) |
264         (translate49[readinputportbytag("49WAYY1") >> 4] << 8);
262   return input_port_read(machine, "IN1") |
263         (translate49[input_port_read(machine, "49WAYX1") >> 4] << 12) |
264         (translate49[input_port_read(machine, "49WAYY1") >> 4] << 8);
265265}
266266
267267
268268static READ16_HANDLER( pigskin_port_2_r )
269269{
270270   /* see archrivl_port_1_r for 49-way joystick description */
271   return readinputportbytag("DSW") |
272         (translate49[readinputportbytag("49WAYX2") >> 4] << 12) |
273         (translate49[readinputportbytag("49WAYY2") >> 4] << 8);
271   return input_port_read(machine, "DSW") |
272         (translate49[input_port_read(machine, "49WAYX2") >> 4] << 12) |
273         (translate49[input_port_read(machine, "49WAYY2") >> 4] << 8);
274274}
275275
276276
r2375r2376
283283
284284static READ16_HANDLER( trisport_port_1_r )
285285{
286   int xaxis = (INT8)readinputportbytag("AN1");
287   int yaxis = (INT8)readinputportbytag("AN2");
288   int result = readinputportbytag("IN1");
286   int xaxis = (INT8)input_port_read(machine, "AN1");
287   int yaxis = (INT8)input_port_read(machine, "AN2");
288   int result = input_port_read(machine, "IN1");
289289
290290   result |= (xaxis & 0x3c) << 6;
291291   result |= (yaxis & 0x3c) << 10;
src/mame/drivers/gsword.c
r2375r2376
177177static int gsword_coins_in(void)
178178{
179179   /* emulate 8741 coin slot */
180   if (readinputport(4)&0xc0)
180   if (input_port_read_indexed(machine, 4)&0xc0)
181181   {
182182      logerror("Coin In\n");
183183      return 0x80;
r2375r2376
215215   switch (offset)
216216   {
217217   case 0x01: /* start button , coins */
218      return readinputport(0);
218      return input_port_read_indexed(machine, 0);
219219   case 0x02: /* Player 1 Controller */
220      return readinputport(1);
220      return input_port_read_indexed(machine, 1);
221221   case 0x04: /* Player 2 Controller */
222      return readinputport(3);
222      return input_port_read_indexed(machine, 3);
223223//  default:
224224//      logerror("8741-2 unknown read %d PC=%04x\n",offset,activecpu_get_pc());
225225   }
r2375r2376
232232   switch (offset)
233233   {
234234   case 0x01: /* start button  */
235      return readinputport(2);
235      return input_port_read_indexed(machine, 2);
236236   case 0x02: /* Player 1 Controller? */
237      return readinputport(1);
237      return input_port_read_indexed(machine, 1);
238238   case 0x04: /* Player 2 Controller? */
239      return readinputport(3);
239      return input_port_read_indexed(machine, 3);
240240   }
241241   /* unknown */
242242//  logerror("8741-3 unknown read %d PC=%04x\n",offset,activecpu_get_pc());
src/mame/drivers/xmen.c
r2375r2376
460460   else irq3_line_hold(machine, cpunum);
461461}
462462
463static STATE_POSTLOAD( xmen_postload )
464{
465   sound_reset_bank();
466}
467
463468static MACHINE_START( xmen )
464469{
465470   state_save_register_global(sound_curbank);
466   state_save_register_func_postload(sound_reset_bank);
471   state_save_register_postload(machine, xmen_postload, NULL);
467472}
468473
469474static MACHINE_DRIVER_START( xmen )
r2375r2376
489494   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
490495   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
491496   MDRV_SCREEN_SIZE(64*8, 32*8)
492   MDRV_SCREEN_VISIBLE_AREA(14*8, (64-14)*8-1, 2*8, 30*8-1 )
493
497   MDRV_SCREEN_VISIBLE_AREA(13*8, (64-13)*8-1, 2*8, 30*8-1 )   /* correct, same issue of TMNT2 */
494498   MDRV_PALETTE_LENGTH(2048)
495499
496500   MDRV_VIDEO_START(xmen)
src/mame/drivers/silkroad.c
r2375r2376
148148/* player inputs */
149149static READ32_HANDLER(io32_r)
150150{
151   return ((readinputport(0) << 16) |  (readinputport(1) << 0));
151   return ((input_port_read_indexed(machine, 0) << 16) |  (input_port_read_indexed(machine, 1) << 0));
152152}
153153
154154/* dipswitches */
155155static READ32_HANDLER(io32_1_r)
156156{
157   return readinputport(2)<<16;
157   return input_port_read_indexed(machine, 2)<<16;
158158}
159159
160160/* sound I/O */
src/mame/drivers/wink.c
r2375r2376
4646
4747static READ8_HANDLER( analog_port_r )
4848{
49   return readinputport(0 /*+ 2 * player_mux*/);
49   return input_port_read_indexed(machine, 0 /*+ 2 * player_mux*/);
5050}
5151
5252static READ8_HANDLER( player_inputs_r )
5353{
54   return readinputport(1 /*+ 2 * player_mux*/);
54   return input_port_read_indexed(machine, 1 /*+ 2 * player_mux*/);
5555}
5656
5757static WRITE8_HANDLER( sound_irq_w )
src/mame/drivers/lethal.c
r2375r2376
177177#define SOUND_CLOCK      XTAL_18_432MHz
178178
179179
180#define GUNX( a ) (( ( readinputport( a ) * 287 ) / 0xff ) + 16)
181#define GUNY( a ) (( ( readinputport( a ) * 223 ) / 0xff ) + 10)
180#define GUNX( a ) (( ( input_port_read_indexed(machine,  a ) * 287 ) / 0xff ) + 16)
181#define GUNY( a ) (( ( input_port_read_indexed(machine,  a ) * 223 ) / 0xff ) + 10)
182182
183183VIDEO_START(lethalen);
184184VIDEO_UPDATE(lethalen);
r2375r2376
230230
231231static READ8_HANDLER( control2_r )
232232{
233   return 0x02 | EEPROM_read_bit() | (input_port_1_r(machine,0) & 0xf0);
233   return 0x02 | EEPROM_read_bit() | (input_port_read_indexed(machine, 1) & 0xf0);
234234}
235235
236236static WRITE8_HANDLER( control2_w )
src/mame/drivers/videopin.c
r2375r2376
2626static WRITE8_HANDLER(videopin_out2_w);
2727
2828
29static void update_plunger(void)
29static void update_plunger(running_machine *machine)
3030{
31   UINT8 val = readinputport(3);
31   UINT8 val = input_port_read_indexed(machine, 3);
3232
3333   if (prev != val)
3434   {
r2375r2376
5151{
5252   int scanline = param;
5353
54   update_plunger();
54   update_plunger(machine);
5555
5656   cpunum_set_input_line(machine, 0, 0, ASSERT_LINE);
5757
r2375r2376
9494   // signals received. This results in the MPU displaying the
9595   // ball being shot onto the playfield at a certain speed.
9696
97   UINT8 val = readinputport(2);
97   UINT8 val = input_port_read_indexed(machine, 2);
9898
9999   if (plunger >= 0.000 && plunger <= 0.001)
100100   {
src/mame/drivers/exprraid.c
r2375r2376
105105
106106static READ8_HANDLER( vblank_r )
107107{
108   return readinputport( 0 );
108   return input_port_read_indexed(machine, 0 );
109109}
110110
111111static ADDRESS_MAP_START( master_map, ADDRESS_SPACE_PROGRAM, 8 )
r2375r2376
288288{
289289   static int coin = 0;
290290
291   if ( ( ~readinputport( 3 ) ) & 0xc0 ) {
291   if ( ( ~input_port_read_indexed(machine, 3 ) ) & 0xc0 ) {
292292      if ( coin == 0 ) {
293293         coin = 1;
294294         cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
src/mame/drivers/csk.c
r2375r2376
161161{
162162   switch (data)
163163   {
164      case 0x00: protection_res = readinputport(7); break;
164      case 0x00: protection_res = input_port_read_indexed(machine, 7); break;
165165      case 0x20: protection_res = 0x49; break;
166166      case 0x21: protection_res = 0x47; break;
167167      case 0x22: protection_res = 0x53; break;
src/mame/drivers/naughtyb.c
r2375r2376
111111
112112static READ8_HANDLER( in0_port_r )
113113{
114   int in0 = input_port_0_r(machine,0);
114   int in0 = input_port_read_indexed(machine, 0);
115115
116116   if ( naughtyb_cocktail )
117117   {
118118      // cabinet == cocktail -AND- handling player 2
119119
120120      in0 = ( in0 & 0x03 ) |            // start buttons
121           ( input_port_1_r(machine,0) & 0xFC );   // cocktail inputs
121           ( input_port_read_indexed(machine, 1) & 0xFC );   // cocktail inputs
122122   }
123123
124124   return in0;
r2375r2376
128128{
129129   // vblank replaces the cabinet dip
130130
131   return ( ( input_port_2_r(machine,0) & 0x7F ) |      // dsw0
132             ( input_port_3_r(machine,0) & 0x80 ) );   // vblank
131   return ( ( input_port_read_indexed(machine, 2) & 0x7F ) |      // dsw0
132             ( input_port_read_indexed(machine, 3) & 0x80 ) );   // vblank
133133}
134134
135135/* Pop Flamer
r2375r2376
217217
218218static INTERRUPT_GEN( naughtyb_interrupt )
219219{
220   if (readinputport(3) & 1)
220   if (input_port_read_indexed(machine, 3) & 1)
221221      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
222222}
223223
src/mame/drivers/runaway.c
r2375r2376
5454{
5555   UINT8 val = 0;
5656
57   if (readinputport(0) & (1 << offset))
57   if (input_port_read_indexed(machine, 0) & (1 << offset))
5858   {
5959      val |= 0x80;
6060   }
61   if (readinputport(1) & (1 << offset))
61   if (input_port_read_indexed(machine, 1) & (1 << offset))
6262   {
6363      val |= 0x40;
6464   }
r2375r2376
6969
7070static READ8_HANDLER( runaway_pot_r )
7171{
72   return (readinputport(4) << (7 - offset)) & 0x80;
72   return (input_port_read_indexed(machine, 4) << (7 - offset)) & 0x80;
7373}
7474
7575
src/mame/drivers/taitowlf.c
r2375r2376
394394
395395static const struct dma8237_interface dma8237_2_config =
396396{
397   0,
398   1.0e-6, // 1us
397   0,
398   1.0e-6, // 1us
399399
400400   NULL,
401401   NULL,
r2375r2376
616616   pic8259_set_irq_line(1, 6, state);
617617}
618618
619static int taitowlf_get_out2(running_machine *machine) {
620   return pit8253_get_output((device_config*)device_list_find_by_tag( machine->config->devicelist, PIT8254, "pit8254" ), 2 );
621}
622
619623static const struct kbdc8042_interface at8042 =
620624{
621   KBDC8042_AT386, set_gate_a20, keyboard_interrupt
625   KBDC8042_AT386, set_gate_a20, keyboard_interrupt, taitowlf_get_out2
622626};
623627
624628static const struct ide_interface ide_intf =
src/mame/drivers/toypop.c
r2375r2376
5656
5757***************************************************************************/
5858
59static READ8_HANDLER( in0_l )   { return readinputport(0); }      // P1 joystick
60static READ8_HANDLER( in0_h )   { return readinputport(0) >> 4; }   // P2 joystick
61static READ8_HANDLER( in1_l )   { return readinputport(1); }      // fire and start buttons
62static READ8_HANDLER( in1_h )   { return readinputport(1) >> 4; }   // coins
63static READ8_HANDLER( dipA_l )   { return readinputport(2); }      // dips A
64static READ8_HANDLER( dipA_h )   { return readinputport(2) >> 4; }   // dips A
65static READ8_HANDLER( dipB_l )   { return readinputport(3); }      // dips B
66static READ8_HANDLER( dipB_h )   { return readinputport(3) >> 4; }   // dips B
67static READ8_HANDLER( in2_l )   { return readinputport(4); }      // P1 joystick left in liblrabl
68static READ8_HANDLER( in2_h )   { return readinputport(4) >> 4; }   // P2 joystick left in liblrabl
69static READ8_HANDLER( in3 )      { return readinputport(5); }      // test, cocktail, optional buttons
59static READ8_HANDLER( in0_l )   { return input_port_read_indexed(machine, 0); }      // P1 joystick
60static READ8_HANDLER( in0_h )   { return input_port_read_indexed(machine, 0) >> 4; }   // P2 joystick
61static READ8_HANDLER( in1_l )   { return input_port_read_indexed(machine, 1); }      // fire and start buttons
62static READ8_HANDLER( in1_h )   { return input_port_read_indexed(machine, 1) >> 4; }   // coins
63static READ8_HANDLER( dipA_l )   { return input_port_read_indexed(machine, 2); }      // dips A
64static READ8_HANDLER( dipA_h )   { return input_port_read_indexed(machine, 2) >> 4; }   // dips A
65static READ8_HANDLER( dipB_l )   { return input_port_read_indexed(machine, 3); }      // dips B
66static READ8_HANDLER( dipB_h )   { return input_port_read_indexed(machine, 3) >> 4; }   // dips B
67static READ8_HANDLER( in2_l )   { return input_port_read_indexed(machine, 4); }      // P1 joystick left in liblrabl
68static READ8_HANDLER( in2_h )   { return input_port_read_indexed(machine, 4) >> 4; }   // P2 joystick left in liblrabl
69static READ8_HANDLER( in3 )      { return input_port_read_indexed(machine, 5); }      // test, cocktail, optional buttons
7070static WRITE8_HANDLER( out_coin0 )
7171{
7272   coin_lockout_global_w(data & 4);
src/mame/drivers/tumbleb.c
r2375r2376
355355    switch (offset<<1)
356356   {
357357      case 0: /* Player 1 & Player 2 joysticks & fire buttons */
358         return (readinputport(0) + (readinputport(1) << 8));
358         return (input_port_read_indexed(machine, 0) + (input_port_read_indexed(machine, 1) << 8));
359359      case 2: /* Dips */
360         return (readinputport(3) + (readinputport(4) << 8));
360         return (input_port_read_indexed(machine, 3) + (input_port_read_indexed(machine, 4) << 8));
361361      case 8: /* Credits */
362         return readinputport(2);
362         return input_port_read_indexed(machine, 2);
363363      case 10: /* ? */
364364      case 12:
365365           return 0;
r2375r2376
33603360{
33613361//  mame_printf_debug("bcstory_io %06x\n",activecpu_get_pc());
33623362   if (activecpu_get_pc()==0x0560) return 0x1a0;
3363   else return readinputport(2);
3363   else return input_port_read_indexed(machine, 2);
33643364}
33653365
33663366static DRIVER_INIT ( bcstory )
src/mame/drivers/micro3d.c
r2375r2376
811811
812812switch(offset)
813813{
814        case 0x01:  return readinputport(3);                           /* Test push switch */
814        case 0x01:  return input_port_read_indexed(machine, 3);                           /* Test push switch */
815815        case 0x03:  return (int)(upd7759_0_busy_r(machine,0))<<3;
816816        default:    return 0;
817817}
src/mame/drivers/ultratnk.c
r2375r2376
2828
2929static CUSTOM_INPUT( get_joystick )
3030{
31   UINT8 joy = readinputportbytag(param) & 3;
31   UINT8 joy = input_port_read(machine, param) & 3;
3232
3333   if (joy == 1)
3434   {
r2375r2376
5252
5353   /* NMI and watchdog are disabled during service mode */
5454
55   watchdog_enable(machine, readinputport(0) & 0x40);
55   watchdog_enable(machine, input_port_read_indexed(machine, 0) & 0x40);
5656
57   if (readinputport(0) & 0x40)
57   if (input_port_read_indexed(machine, 0) & 0x40)
5858      cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
5959
6060   timer_set(video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, nmi_callback);
r2375r2376
7575
7676static READ8_HANDLER( ultratnk_analog_r )
7777{
78   return (readinputportbytag("ANALOG") << (~offset & 7)) & 0x80;
78   return (input_port_read(machine, "ANALOG") << (~offset & 7)) & 0x80;
7979}
8080static READ8_HANDLER( ultratnk_coin_r )
8181{
82   return (readinputportbytag("COIN") << (~offset & 7)) & 0x80;
82   return (input_port_read(machine, "COIN") << (~offset & 7)) & 0x80;
8383}
8484static READ8_HANDLER( ultratnk_collision_r )
8585{
86   return (readinputportbytag("COLLISION") << (~offset & 7)) & 0x80;
86   return (input_port_read(machine, "COLLISION") << (~offset & 7)) & 0x80;
8787}
8888
8989
9090static READ8_HANDLER( ultratnk_options_r )
9191{
92   return (readinputportbytag("DIP") >> (2 * (offset & 3))) & 3;
92   return (input_port_read(machine, "DIP") >> (2 * (offset & 3))) & 3;
9393}
9494
9595
src/mame/drivers/m90.c
r2375r2376
11551155
11561156
11571157
1158static STATE_POSTLOAD( quizf1_postload )
1159{
1160   set_m90_bank();
1161}
11581162
11591163static DRIVER_INIT( quizf1 )
11601164{
r2375r2376
11621166   set_m90_bank();
11631167
11641168   state_save_register_global(bankaddress);
1165   state_save_register_func_postload(set_m90_bank);
1169   state_save_register_postload(machine, quizf1_postload, NULL);
11661170}
11671171
11681172
src/mame/drivers/tugboat.c
r2375r2376
130130static READ8_HANDLER( tugboat_input_r )
131131{
132132   if (~ctrl & 0x80)
133      return readinputport(0);
133      return input_port_read_indexed(machine, 0);
134134   else if (~ctrl & 0x40)
135      return readinputport(1);
135      return input_port_read_indexed(machine, 1);
136136   else if (~ctrl & 0x20)
137      return readinputport(2);
137      return input_port_read_indexed(machine, 2);
138138   else if (~ctrl & 0x10)
139      return readinputport(3);
139      return input_port_read_indexed(machine, 3);
140140   else
141      return readinputport(4);
141      return input_port_read_indexed(machine, 4);
142142}
143143
144144static READ8_HANDLER( tugboat_ctrl_r )
src/mame/drivers/taito_z.c
r2375r2376
520520TODO Lists
521521==========
522522
523Add cpu idle time skip to improve speed.
524
525523Is the no-Z80 sound handling correct: some voices in Bshark
526524aren't that clear.
527525
r2375r2376
582580
583581Some layer offsets are out a little.
584582
583Road layer has wrong colors--regression?
585584
585
586586Battle Shark
587587------------
588588
r2375r2376
777777#include "video/taitoic.h"
778778#include "audio/taitosnd.h"
779779#include "sound/2610intf.h"
780#include "sound/flt_vol.h"
780781
781782VIDEO_START( taitoz );
782783VIDEO_START( spacegun );
r2375r2376
13991400#endif
14001401
14011402
1403/**** sound pan control ****/
1404static WRITE8_HANDLER( taitoz_pancontrol )
1405{
1406//  static UINT8 taitoz_pandata[4];
1407
1408   offset = offset&3;
1409
1410//  taitoz_pandata[offset] = data;
1411//  popmessage(" pan %02x %02x %02x %02x", taitoz_pandata[0], taitoz_pandata[1], taitoz_pandata[2], taitoz_pandata[3] );
1412
1413   flt_volume_set_volume(offset, data / 255.0f);
1414}
1415
1416static WRITE16_HANDLER( spacegun_pancontrol )
1417{
1418   if (ACCESSING_BITS_0_7)
1419      taitoz_pancontrol(machine,offset,data & 0xff);
1420}
1421
1422
14021423/***********************************************************
14031424                   SAVE STATES
14041425***********************************************************/
14051426
1427static STATE_POSTLOAD( taitoz_postload )
1428{
1429   parse_control();
1430   reset_sound_region();
1431}
1432
14061433static MACHINE_START( taitoz )
14071434{
14081435   state_save_register_global(cpua_ctrl);
1409   state_save_register_func_postload(parse_control);
14101436
14111437   /* these are specific to various games: we ought to split the inits */
14121438   state_save_register_global(sci_int6);
r2375r2376
14141440   state_save_register_global(ioc220_port);
14151441
14161442   state_save_register_global(banknum);
1417   state_save_register_func_postload(reset_sound_region);
1443   state_save_register_postload(machine, taitoz_postload, NULL);
14181444}
14191445
14201446
r2375r2376
15951621   AM_RANGE(0x000000, 0x07ffff) AM_WRITE(SMH_ROM)
15961622   AM_RANGE(0x108000, 0x10bfff) AM_WRITE(SMH_RAM)
15971623   AM_RANGE(0x110000, 0x113fff) AM_WRITE(sharedram_w)
1598//  AM_RANGE(0x400000, 0x400007) AM_WRITE(SMH_NOP)  // pan ???
1624   AM_RANGE(0x400000, 0x400007) AM_WRITE(spacegun_pancontrol)  /* pan */
15991625   AM_RANGE(0x600000, 0x600001) AM_WRITE(YM2610_control_port_0_A_lsb_w)
16001626   AM_RANGE(0x600002, 0x600003) AM_WRITE(YM2610_data_port_0_A_lsb_w)
16011627   AM_RANGE(0x600004, 0x600005) AM_WRITE(YM2610_control_port_0_B_lsb_w)
r2375r2376
17841810   AM_RANGE(0xc00006, 0xc00007) AM_WRITE(YM2610_data_port_0_B_lsb_w)
17851811   AM_RANGE(0xc0000c, 0xc0000d) AM_WRITE(SMH_NOP)   // interrupt controller?
17861812   AM_RANGE(0xc0000e, 0xc0000f) AM_WRITE(SMH_NOP)
1787//  AM_RANGE(0xc20000, 0xc20003) AM_WRITE(YM2610_????)  /* Pan (acc. to Raine) */
1813   AM_RANGE(0xc20000, 0xc20007) AM_WRITE(spacegun_pancontrol)  /* pan */
17881814//  AM_RANGE(0xe00000, 0xe00001) AM_WRITE(SMH_NOP)    /* ??? */
17891815   AM_RANGE(0xf00000, 0xf00007) AM_WRITE(spacegun_lightgun_w)
17901816ADDRESS_MAP_END
r2375r2376
19041930   AM_RANGE(0xe003, 0xe003) AM_WRITE(YM2610_data_port_0_B_w)
19051931   AM_RANGE(0xe200, 0xe200) AM_WRITE(taitosound_slave_port_w)
19061932   AM_RANGE(0xe201, 0xe201) AM_WRITE(taitosound_slave_comm_w)
1907   AM_RANGE(0xe400, 0xe403) AM_WRITE(SMH_NOP) /* pan */
1933   AM_RANGE(0xe400, 0xe403) AM_WRITE(taitoz_pancontrol) /* pan */
19081934   AM_RANGE(0xee00, 0xee00) AM_WRITE(SMH_NOP) /* ? */
19091935   AM_RANGE(0xf000, 0xf000) AM_WRITE(SMH_NOP) /* ? */
19101936   AM_RANGE(0xf200, 0xf200) AM_WRITE(sound_bankswitch_w)
r2375r2376
20032029   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_COIN2 )
20042030   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN1 )
20052031   PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_SERVICE1 )
2006   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_PLAYER(1)   /* 3 for accel [7 levels] */
2007   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_PLAYER(1)
2032   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_PLAYER(1)   /* 3 for accel [7 levels] */
2033   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(1)
20082034   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1)   /* main accel key */
20092035
20102036   PORT_START      /* IN1: b3 not mapped: standardized on holding b4=lo gear */
r2375r2376
20122038   PORT_BIT( 0x02, IP_ACTIVE_LOW,  IPT_UNKNOWN )
20132039   PORT_BIT( 0x04, IP_ACTIVE_LOW,  IPT_TILT )
20142040   PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_START1 )
2015   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(1)   /* gear shift lo/hi */
2016   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_PLAYER(1)   /* 3 for brake [7 levels] */
2017   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_PLAYER(1)
2041   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(1)   /* gear shift lo/hi */
2042   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_PLAYER(1)   /* 3 for brake [7 levels] */
2043   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_PLAYER(1)
20182044   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1)   /* main brake key */
20192045
20202046   PORT_START      /* IN2, unused */
r2375r2376
28622888   MDRV_VIDEO_UPDATE(contcirc)
28632889
28642890   /* sound hardware */
2865   MDRV_SPEAKER_STANDARD_STEREO("left", "right")
2891   MDRV_SPEAKER_ADD("front", 0.0, 0.0,  0.7)
2892   MDRV_SPEAKER_ADD("rear",  0.0, 0.0,  1.3)
2893   MDRV_SPEAKER_ADD("subwoofer", 0.0, 0.0, 1.0)
28662894
28672895   MDRV_SOUND_ADD(YM2610, 16000000/2)
28682896   MDRV_SOUND_CONFIG(ym2610_interface)
2869   MDRV_SOUND_ROUTE(0, "left",  0.25)
2870   MDRV_SOUND_ROUTE(0, "right", 0.25)
2871   MDRV_SOUND_ROUTE(1, "left",  1.0)
2872   MDRV_SOUND_ROUTE(2, "right", 1.0)
2897   MDRV_SOUND_ROUTE(0, "subwoofer", 0.20)
2898   MDRV_SOUND_ROUTE(1, "2610.1.l", 2.0)
2899   MDRV_SOUND_ROUTE(1, "2610.1.r", 2.0)
2900   MDRV_SOUND_ROUTE(2, "2610.2.l", 2.0)
2901   MDRV_SOUND_ROUTE(2, "2610.2.r", 2.0)
28732902
2903   MDRV_SOUND_ADD_TAG("2610.1.r", FILTER_VOLUME, 0)
2904   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rear", 1.0)
2905   MDRV_SOUND_ADD_TAG("2610.1.l", FILTER_VOLUME, 0)
2906   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "front", 1.0)
2907   MDRV_SOUND_ADD_TAG("2610.2.r", FILTER_VOLUME, 0)
2908   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rear", 1.0)
2909   MDRV_SOUND_ADD_TAG("2610.2.l", FILTER_VOLUME, 0)
2910   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "front", 1.0)
2911
28742912//  MDRV_SOUND_ADD(CUSTOM, subwoofer_interface)
28752913MACHINE_DRIVER_END
28762914
r2375r2376
29092947   /* sound hardware */
29102948   MDRV_SPEAKER_ADD("front",  0.0, 0.0, 0.7)
29112949   MDRV_SPEAKER_ADD("rear",   0.0, 0.0, 1.3)
2950   MDRV_SPEAKER_ADD("subwoofer", 0.0, 0.0, 1.0)
29122951
29132952   MDRV_SOUND_ADD(YM2610, 16000000/2)
29142953   MDRV_SOUND_CONFIG(ym2610_interface)
2915   MDRV_SOUND_ROUTE(0, "rear",  0.25)
2916   MDRV_SOUND_ROUTE(0, "front", 0.25)
2917   MDRV_SOUND_ROUTE(1, "rear",  1.0)
2918   MDRV_SOUND_ROUTE(2, "front", 1.0)
2954   MDRV_SOUND_ROUTE(0, "subwoofer", 0.20)
2955   MDRV_SOUND_ROUTE(1, "2610.1.l", 1.0)
2956   MDRV_SOUND_ROUTE(1, "2610.1.r", 1.0)
2957   MDRV_SOUND_ROUTE(2, "2610.2.l", 1.0)
2958   MDRV_SOUND_ROUTE(2, "2610.2.r", 1.0)
2959
2960   MDRV_SOUND_ADD_TAG("2610.1.r", FILTER_VOLUME, 0)
2961   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rear", 1.0)
2962   MDRV_SOUND_ADD_TAG("2610.1.l", FILTER_VOLUME, 0)
2963   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "front", 1.0)
2964   MDRV_SOUND_ADD_TAG("2610.2.r", FILTER_VOLUME, 0)
2965   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rear", 1.0)
2966   MDRV_SOUND_ADD_TAG("2610.2.l", FILTER_VOLUME, 0)
2967   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "front", 1.0)
29192968MACHINE_DRIVER_END
29202969
29212970
r2375r2376
29593008   MDRV_SOUND_CONFIG(ym2610_interface)
29603009   MDRV_SOUND_ROUTE(0, "left",  0.25)
29613010   MDRV_SOUND_ROUTE(0, "right", 0.25)
2962   MDRV_SOUND_ROUTE(1, "left",  1.0)
2963   MDRV_SOUND_ROUTE(2, "right", 1.0)
3011   MDRV_SOUND_ROUTE(1, "2610.1.l", 20.0)
3012   MDRV_SOUND_ROUTE(1, "2610.1.r", 20.0)
3013   MDRV_SOUND_ROUTE(2, "2610.2.l", 20.0)
3014   MDRV_SOUND_ROUTE(2, "2610.2.r", 20.0)
29643015
3016   MDRV_SOUND_ADD_TAG("2610.1.r", FILTER_VOLUME, 0)
3017   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
3018   MDRV_SOUND_ADD_TAG("2610.1.l", FILTER_VOLUME, 0)
3019   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
3020   MDRV_SOUND_ADD_TAG("2610.2.r", FILTER_VOLUME, 0)
3021   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
3022   MDRV_SOUND_ADD_TAG("2610.2.l", FILTER_VOLUME, 0)
3023   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
3024
29653025//  MDRV_SOUND_ADD(CUSTOM, subwoofer_interface)
29663026MACHINE_DRIVER_END
29673027
r2375r2376
30023062   MDRV_SOUND_CONFIG(ym2610_interfaceb)
30033063   MDRV_SOUND_ROUTE(0, "left",  0.25)
30043064   MDRV_SOUND_ROUTE(0, "right", 0.25)
3005   MDRV_SOUND_ROUTE(1, "left",  1.0)
3006   MDRV_SOUND_ROUTE(2, "right", 1.0)
3065   MDRV_SOUND_ROUTE(1, "2610.1.l", 28.0)
3066   MDRV_SOUND_ROUTE(1, "2610.1.r", 28.0)
3067   MDRV_SOUND_ROUTE(2, "2610.2.l", 28.0)
3068   MDRV_SOUND_ROUTE(2, "2610.2.r", 28.0)
3069
3070   MDRV_SOUND_ADD_TAG("2610.1.r", FILTER_VOLUME, 0)
3071   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
3072   MDRV_SOUND_ADD_TAG("2610.1.l", FILTER_VOLUME, 0)
3073   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
3074   MDRV_SOUND_ADD_TAG("2610.2.r", FILTER_VOLUME, 0)
3075   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
3076   MDRV_SOUND_ADD_TAG("2610.2.l", FILTER_VOLUME, 0)
3077   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
30073078MACHINE_DRIVER_END
30083079
30093080
r2375r2376
30473118   MDRV_SOUND_CONFIG(ym2610_interface)
30483119   MDRV_SOUND_ROUTE(0, "left",  0.25)
30493120   MDRV_SOUND_ROUTE(0, "right", 0.25)
3050   MDRV_SOUND_ROUTE(1, "left",  1.0)
3051   MDRV_SOUND_ROUTE(2, "right", 1.0)
3121   MDRV_SOUND_ROUTE(1, "2610.1.l", 2.0)
3122   MDRV_SOUND_ROUTE(1, "2610.1.r", 2.0)
3123   MDRV_SOUND_ROUTE(2, "2610.2.l", 2.0)
3124   MDRV_SOUND_ROUTE(2, "2610.2.r", 2.0)
3125
3126   MDRV_SOUND_ADD_TAG("2610.1.r", FILTER_VOLUME, 0)
3127   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
3128   MDRV_SOUND_ADD_TAG("2610.1.l", FILTER_VOLUME, 0)
3129   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
3130   MDRV_SOUND_ADD_TAG("2610.2.r", FILTER_VOLUME, 0)
3131   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
3132   MDRV_SOUND_ADD_TAG("2610.2.l", FILTER_VOLUME, 0)
3133   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
30523134MACHINE_DRIVER_END
30533135
30543136
r2375r2376
30883170   /* sound hardware */
30893171   MDRV_SPEAKER_ADD("front",  0.0, 0.0, 0.7)
30903172   MDRV_SPEAKER_ADD("rear",   0.0, 0.0, 1.3)
3173   MDRV_SPEAKER_ADD("subwoofer", 0.0, 0.0, 1.0)
30913174
30923175   MDRV_SOUND_ADD(YM2610, 16000000/2)
30933176   MDRV_SOUND_CONFIG(ym2610_interface)
3094   MDRV_SOUND_ROUTE(0, "front", 0.25)
3095   MDRV_SOUND_ROUTE(0, "rear",  0.25)
3096   MDRV_SOUND_ROUTE(1, "front", 1.0)
3097   MDRV_SOUND_ROUTE(2, "rear",  1.0)
3177   MDRV_SOUND_ROUTE(0, "subwoofer", 0.20)
3178   MDRV_SOUND_ROUTE(1, "2610.1.l", 2.0)
3179   MDRV_SOUND_ROUTE(1, "2610.1.r", 2.0)
3180   MDRV_SOUND_ROUTE(2, "2610.2.l", 2.0)
3181   MDRV_SOUND_ROUTE(2, "2610.2.r", 2.0)
3182
3183   MDRV_SOUND_ADD_TAG("2610.1.r", FILTER_VOLUME, 0)
3184   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rear", 1.0)
3185   MDRV_SOUND_ADD_TAG("2610.1.l", FILTER_VOLUME, 0)
3186   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "front", 1.0)
3187   MDRV_SOUND_ADD_TAG("2610.2.r", FILTER_VOLUME, 0)
3188   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rear", 1.0)
3189   MDRV_SOUND_ADD_TAG("2610.2.l", FILTER_VOLUME, 0)
3190   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "front", 1.0)
30983191MACHINE_DRIVER_END
30993192
31003193
r2375r2376
31383231   MDRV_SOUND_CONFIG(ym2610_interface)
31393232   MDRV_SOUND_ROUTE(0, "left",  0.25)
31403233   MDRV_SOUND_ROUTE(0, "right", 0.25)
3141   MDRV_SOUND_ROUTE(1, "left",  1.0)
3142   MDRV_SOUND_ROUTE(2, "right", 1.0)
3234   MDRV_SOUND_ROUTE(1, "2610.1.l", 2.0)
3235   MDRV_SOUND_ROUTE(1, "2610.1.r", 2.0)
3236   MDRV_SOUND_ROUTE(2, "2610.2.l", 2.0)
3237   MDRV_SOUND_ROUTE(2, "2610.2.r", 2.0)
3238
3239   MDRV_SOUND_ADD_TAG("2610.1.r", FILTER_VOLUME, 0)
3240   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
3241   MDRV_SOUND_ADD_TAG("2610.1.l", FILTER_VOLUME, 0)
3242   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
3243   MDRV_SOUND_ADD_TAG("2610.2.r", FILTER_VOLUME, 0)
3244   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
3245   MDRV_SOUND_ADD_TAG("2610.2.l", FILTER_VOLUME, 0)
3246   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
31433247MACHINE_DRIVER_END
31443248
31453249
r2375r2376
31793283   MDRV_SOUND_CONFIG(ym2610_interfaceb)
31803284   MDRV_SOUND_ROUTE(0, "left",  0.25)
31813285   MDRV_SOUND_ROUTE(0, "right", 0.25)
3182   MDRV_SOUND_ROUTE(1, "left",  1.0)
3183   MDRV_SOUND_ROUTE(2, "right", 1.0)
3286   MDRV_SOUND_ROUTE(1, "2610.1.l", 8.0)
3287   MDRV_SOUND_ROUTE(1, "2610.1.r", 8.0)
3288   MDRV_SOUND_ROUTE(2, "2610.2.l", 8.0)
3289   MDRV_SOUND_ROUTE(2, "2610.2.r", 8.0)
3290
3291   MDRV_SOUND_ADD_TAG("2610.1.r", FILTER_VOLUME, 0)
3292   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
3293   MDRV_SOUND_ADD_TAG("2610.1.l", FILTER_VOLUME, 0)
3294   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
3295   MDRV_SOUND_ADD_TAG("2610.2.r", FILTER_VOLUME, 0)
3296   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
3297   MDRV_SOUND_ADD_TAG("2610.2.l", FILTER_VOLUME, 0)
3298   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
31843299MACHINE_DRIVER_END
31853300
31863301
r2375r2376
32243339   MDRV_SOUND_CONFIG(ym2610_interface)
32253340   MDRV_SOUND_ROUTE(0, "left",  0.25)
32263341   MDRV_SOUND_ROUTE(0, "right", 0.25)
3227   MDRV_SOUND_ROUTE(1, "left",  1.0)
3228   MDRV_SOUND_ROUTE(2, "right", 1.0)
3342   MDRV_SOUND_ROUTE(1, "2610.1.l", 8.0)
3343   MDRV_SOUND_ROUTE(1, "2610.1.r", 8.0)
3344   MDRV_SOUND_ROUTE(2, "2610.2.l", 8.0)
3345   MDRV_SOUND_ROUTE(2, "2610.2.r", 8.0)
3346
3347   MDRV_SOUND_ADD_TAG("2610.1.r", FILTER_VOLUME, 0)
3348   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
3349   MDRV_SOUND_ADD_TAG("2610.1.l", FILTER_VOLUME, 0)
3350   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
3351   MDRV_SOUND_ADD_TAG("2610.2.r", FILTER_VOLUME, 0)
3352   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
3353   MDRV_SOUND_ADD_TAG("2610.2.l", FILTER_VOLUME, 0)
3354   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
32293355MACHINE_DRIVER_END
32303356
32313357
r2375r2376
32683394   MDRV_SOUND_CONFIG(ym2610_interface)
32693395   MDRV_SOUND_ROUTE(0, "left",  0.25)
32703396   MDRV_SOUND_ROUTE(0, "right", 0.25)
3271   MDRV_SOUND_ROUTE(1, "left",  1.0)
3272   MDRV_SOUND_ROUTE(2, "right", 1.0)
3397   MDRV_SOUND_ROUTE(1, "2610.1.l", 8.0)
3398   MDRV_SOUND_ROUTE(1, "2610.1.r", 8.0)
3399   MDRV_SOUND_ROUTE(2, "2610.2.l", 8.0)
3400   MDRV_SOUND_ROUTE(2, "2610.2.r", 8.0)
3401
3402   MDRV_SOUND_ADD_TAG("2610.1.r", FILTER_VOLUME, 0)
3403   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
3404   MDRV_SOUND_ADD_TAG("2610.1.l", FILTER_VOLUME, 0)
3405   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
3406   MDRV_SOUND_ADD_TAG("2610.2.r", FILTER_VOLUME, 0)
3407   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
3408   MDRV_SOUND_ADD_TAG("2610.2.l", FILTER_VOLUME, 0)
3409   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
32733410MACHINE_DRIVER_END
32743411
32753412
r2375r2376
40864223   ROM_LOAD16_WORD( "c78-04.3", 0x00000, 0x80000, CRC(cc1aa37c) SHA1(cfa2eb338dc81c98c637c2f0b14d2baea8b115f5) )   /* STY spritemap */
40874224
40884225   ROM_REGION( 0x180000, REGION_SOUND1, 0 )   /* ADPCM samples */
4089   ROM_LOAD( "c78-12.33", 0x000000, 0x80000, CRC(fbb39585) SHA1(4b7cdf9a3fba71155871b3e52d2301e50bf817ca) )   // Half size ??
4226   ROM_LOAD( "c78-12.33", 0x000000, 0x80000, BAD_DUMP CRC(fbb39585) SHA1(4b7cdf9a3fba71155871b3e52d2301e50bf817ca) )   // Half size ??
40904227   // ??? gap 0x80000-fffff //
40914228   ROM_LOAD( "c78-13.46", 0x100000, 0x80000, CRC(1b363aa2) SHA1(0aae3988024654e98cc0c784307b1c329c8f0783) )
40924229
r2375r2376
42014338   cpua_ctrl = 0xff;
42024339}
42034340
4341static STATE_POSTLOAD( bshark_postload )
4342{
4343   parse_control_noz80();
4344}
4345
42044346static DRIVER_INIT( bshark )
42054347{
42064348   cpua_ctrl = 0xff;
4207   state_save_register_func_postload(parse_control_noz80);
4349   state_save_register_postload(machine, bshark_postload, NULL);
42084350
42094351   state_save_register_global(eep_latch);
42104352}
src/mame/drivers/phoenix.c
r2375r2376
5151   AM_RANGE(0x5800, 0x5bff) AM_WRITE(phoenix_scroll_w)
5252   AM_RANGE(0x6000, 0x63ff) AM_WRITE(phoenix_sound_control_a_w)
5353   AM_RANGE(0x6800, 0x6bff) AM_WRITE(phoenix_sound_control_b_w)
54   AM_RANGE(0x7000, 0x73ff) AM_READ(phoenix_input_port_0_r)             /* IN0 or IN1 */
54   AM_RANGE(0x7000, 0x73ff) AM_READ_PORT("IN0")                      /* IN0 or IN1 */
5555   AM_RANGE(0x7800, 0x7bff) AM_READ_PORT("DSW0")                      /* DSW */
5656ADDRESS_MAP_END
5757
r2375r2376
6262   AM_RANGE(0x5800, 0x5bff) AM_WRITE(phoenix_scroll_w)
6363   AM_RANGE(0x6000, 0x63ff) AM_WRITE(pleiads_sound_control_a_w)
6464   AM_RANGE(0x6800, 0x6bff) AM_WRITE(pleiads_sound_control_b_w)
65   AM_RANGE(0x7000, 0x73ff) AM_READ(pleiads_input_port_0_r)             /* IN0 or IN1 + protection */
65   AM_RANGE(0x7000, 0x73ff) AM_READ_PORT("IN0")                      /* IN0 or IN1 + protection */
6666   AM_RANGE(0x7800, 0x7bff) AM_READ_PORT("DSW0")                      /* DSW */
6767ADDRESS_MAP_END
6868
r2375r2376
8080
8181
8282static INPUT_PORTS_START( phoenix )
83   PORT_START_TAG("IN0")      /* IN0 */
83   PORT_START_TAG("IN0")
8484   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
8585   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START1 )
8686   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START2 )
8787   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
88   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
89   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY
90   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY
91   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 )
88   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(player_input_r, 0)
9289
93   PORT_START_TAG("IN1")      /* IN1 */
94   PORT_BIT( 0x07, IP_ACTIVE_LOW, IPT_SPECIAL )   /* comes from IN0 0-2 */
95   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
96   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
97   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT  ) PORT_2WAY PORT_COCKTAIL
98   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  ) PORT_2WAY PORT_COCKTAIL
99   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2  ) PORT_COCKTAIL
100
101   PORT_START_TAG("DSW0")      /* DSW0 */
102   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )      PORT_DIPLOCATION( "SW1:1,2" )
90   PORT_START_TAG("DSW0")
91   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )            PORT_DIPLOCATION( "SW1:1,2" )
10392   PORT_DIPSETTING(   0x00, "3" )
10493   PORT_DIPSETTING(   0x01, "4" )
10594   PORT_DIPSETTING(   0x02, "5" )
10695   PORT_DIPSETTING(   0x03, "6" )
107   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION( "SW1:3,4" )
96   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )       PORT_DIPLOCATION( "SW1:3,4" )
10897   PORT_DIPSETTING(   0x00, "3K 30K" )
10998   PORT_DIPSETTING(   0x04, "4K 40K" )
11099   PORT_DIPSETTING(   0x08, "5K 50K" )
111100   PORT_DIPSETTING(   0x0c, "6K 60K" )
112   PORT_DIPNAME( 0x10, 0x00, DEF_STR( Coinage ) )      PORT_DIPLOCATION( "SW1:5" )
101   PORT_DIPNAME( 0x10, 0x00, DEF_STR( Coinage ) )          PORT_DIPLOCATION( "SW1:5" )
113102   PORT_DIPSETTING(   0x10, DEF_STR( 2C_1C ) )
114103   PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )
115   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )      PORT_DIPLOCATION( "SW1:6" )
104   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )          PORT_DIPLOCATION( "SW1:6" )
116105   PORT_DIPSETTING(   0x20, DEF_STR( Off ) )
117106   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
118   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )      PORT_DIPLOCATION( "SW1:7" )
107   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )          PORT_DIPLOCATION( "SW1:7" )
119108   PORT_DIPSETTING(   0x40, DEF_STR( Off ) )
120109   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
121110   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_VBLANK )
122111
123112   PORT_START_TAG("CAB")      /* fake port for non-memory mapped dip switch */
124   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )      PORT_DIPLOCATION( "SW1:!8" )
113   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )          PORT_DIPLOCATION( "SW1:!8" )
125114   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
126115   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ) )
116
117   PORT_START_TAG("CTRL")      /* fake port for multiplexed controls */
118   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 )
119   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY
120   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  ) PORT_2WAY
121   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON2 )
122   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL                  PORT_CONDITION("CAB",0x01,PORTCOND_EQUALS,0x01)
123   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL PORT_CONDITION("CAB",0x01,PORTCOND_EQUALS,0x01)
124   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  ) PORT_2WAY PORT_COCKTAIL PORT_CONDITION("CAB",0x01,PORTCOND_EQUALS,0x01)
125   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL                  PORT_CONDITION("CAB",0x01,PORTCOND_EQUALS,0x01)
127126INPUT_PORTS_END
128127
129128static INPUT_PORTS_START( phoenixa )
r2375r2376
131130
132131   PORT_MODIFY("DSW0")
133132   /* Coinage is backwards from phoenix (Amstar) */
134   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Coinage ) )      PORT_DIPLOCATION( "SW1:5" )
133   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Coinage ) )          PORT_DIPLOCATION( "SW1:5" )
135134   PORT_DIPSETTING(   0x00, DEF_STR( 2C_1C ) )
136135   PORT_DIPSETTING(   0x10, DEF_STR( 1C_1C ) )
137136INPUT_PORTS_END
r2375r2376
139138static INPUT_PORTS_START( phoenixt )
140139   PORT_INCLUDE( phoenix )
141140
142PORT_MODIFY("DSW0")
143   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )      PORT_DIPLOCATION( "SW1:5" )
141   PORT_MODIFY("DSW0")
142   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )          PORT_DIPLOCATION( "SW1:5" )
144143   PORT_DIPSETTING(   0x10, DEF_STR( Off ) )
145144   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
146145INPUT_PORTS_END
r2375r2376
148147static INPUT_PORTS_START( phoenix3 )
149148   PORT_INCLUDE( phoenix )
150149
150   PORT_MODIFY("IN0")
151   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN2 )
152
151153   PORT_MODIFY("DSW0")
152   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )      PORT_DIPLOCATION( "SW1:5" )
154   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )          PORT_DIPLOCATION( "SW1:5" )
153155   PORT_DIPSETTING(   0x10, DEF_STR( Off ) )
154156   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
155   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )      PORT_DIPLOCATION( "SW1:6" )
157   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )          PORT_DIPLOCATION( "SW1:6" )
156158   PORT_DIPSETTING(   0x20, DEF_STR( Off ) )
157159   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
158   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Coinage ) )      PORT_DIPLOCATION( "SW1:7" )
160   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Coinage ) )          PORT_DIPLOCATION( "SW1:7" )
159161   PORT_DIPSETTING(   0x40, "A - 2C/1C B - 1C/3C" )
160162   PORT_DIPSETTING(   0x00, "A - 1C/1C B - 1C/6C" )
161163INPUT_PORTS_END
162164
163165static INPUT_PORTS_START( condor )
164   PORT_INCLUDE( phoenix )
166   PORT_START_TAG("IN0")
167   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )
168   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_START1 )
169   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_START2 )
170   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN2 )
171   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(player_input_r, 0)
165172
166   PORT_MODIFY("DSW0")
167   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )      PORT_DIPLOCATION( "SW1:1,2" )
173   PORT_START_TAG("DSW0")
174   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )            PORT_DIPLOCATION( "SW1:1,2" )
168175   PORT_DIPSETTING(   0x00, "2" )
169176   PORT_DIPSETTING(   0x01, "3" )
170177   PORT_DIPSETTING(   0x02, "4" )
171178   PORT_DIPSETTING(   0x03, "5" )
172   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION( "SW1:3,4" )
179   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )       PORT_DIPLOCATION( "SW1:3,4" )
173180   PORT_DIPSETTING(   0x00, "Every 6000" )
174181   PORT_DIPSETTING(   0x08, "Every 10000" )
175182   PORT_DIPSETTING(   0x04, "Every 14000" )
176183   PORT_DIPSETTING(   0x0c, "Every 18000" )
177   PORT_DIPNAME( 0x70, 0x30, "Fuel Consumption" )      PORT_DIPLOCATION( "SW1:5,6,7" )
184   PORT_DIPNAME( 0x70, 0x30, "Fuel Consumption" )          PORT_DIPLOCATION( "SW1:5,6,7" )
178185   PORT_DIPSETTING(   0x00, "Slowest" )
179186   PORT_DIPSETTING(   0x10, "Slower" )
180187   PORT_DIPSETTING(   0x20, "Slow" )
r2375r2376
183190   PORT_DIPSETTING(   0x50, "Fast" )
184191   PORT_DIPSETTING(   0x60, "Faster" )
185192   PORT_DIPSETTING(   0x70, "Fastest" )
193   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_VBLANK )
186194
187   PORT_START_TAG("COINAGE")
188   PORT_DIPNAME( 0x0f, 0x00, DEF_STR( Coin_B ) )
195   PORT_START_TAG("DSW1")
196   PORT_DIPNAME( 0x0f, 0x00, DEF_STR( Coin_B ) )           PORT_DIPLOCATION( "SW2:1,2,3,4" )
189197   PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
190198   PORT_DIPSETTING(    0x09, DEF_STR( 2C_2C ) )
191199   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
r2375r2376
202210   PORT_DIPSETTING(    0x05, DEF_STR( 1C_6C ) )
203211   PORT_DIPSETTING(    0x06, DEF_STR( 1C_7C ) )
204212   PORT_DIPSETTING(    0x07, DEF_STR( 1C_8C ) )
205   PORT_DIPNAME( 0xf0, 0x00, DEF_STR( Coin_A ) )
213   PORT_DIPNAME( 0xf0, 0x00, DEF_STR( Coin_A ) )           PORT_DIPLOCATION( "SW2:5,6,7,8" )
206214   PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
207215   PORT_DIPSETTING(    0x90, DEF_STR( 2C_2C ) )
208216   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
r2375r2376
219227   PORT_DIPSETTING(    0x50, DEF_STR( 1C_6C ) )
220228   PORT_DIPSETTING(    0x60, DEF_STR( 1C_7C ) )
221229   PORT_DIPSETTING(    0x70, DEF_STR( 1C_8C ) )
230
231   PORT_START_TAG("CAB")      /* fake port for non-memory mapped dip switch */
232   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )          PORT_DIPLOCATION( "SW1:!8" )
233   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
234   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ) )
235
236   PORT_START_TAG("CTRL")      /* fake port for multiplexed controls */
237   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 )
238   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY
239   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  ) PORT_2WAY
240   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON2 )
241   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL                  PORT_CONDITION("CAB",0x01,PORTCOND_EQUALS,0x01)
242   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL PORT_CONDITION("CAB",0x01,PORTCOND_EQUALS,0x01)
243   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  ) PORT_2WAY PORT_COCKTAIL PORT_CONDITION("CAB",0x01,PORTCOND_EQUALS,0x01)
244   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_COCKTAIL                  PORT_CONDITION("CAB",0x01,PORTCOND_EQUALS,0x01)
222245INPUT_PORTS_END
223246
224static INPUT_PORTS_START( falcona )
247static INPUT_PORTS_START( falconz )
225248   PORT_INCLUDE( phoenix )
226249
227250   PORT_MODIFY("DSW0")
228   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )      PORT_DIPLOCATION( "SW1:1,2" )
251   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )            PORT_DIPLOCATION( "SW1:1,2" )
229252   PORT_DIPSETTING(   0x00, "2" )
230253   PORT_DIPSETTING(   0x01, "3" )
231254   PORT_DIPSETTING(   0x02, "4" )
232255   PORT_DIPSETTING(   0x03, "5" )
233   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION( "SW1:3,4" )
256   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )       PORT_DIPLOCATION( "SW1:3,4" )
234257   PORT_DIPSETTING(   0x00, "3K 30K" )
235258   PORT_DIPSETTING(   0x04, "4K 40K" )
236259   PORT_DIPSETTING(   0x08, "5K 50K" )
237260   PORT_DIPSETTING(   0x0c, "6K 60K" )
238   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )      PORT_DIPLOCATION( "SW1:5" )
261   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )          PORT_DIPLOCATION( "SW1:5" )
239262   PORT_DIPSETTING(   0x10, DEF_STR( Off ) )
240263   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
241   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )      PORT_DIPLOCATION( "SW1:6" )
264   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )          PORT_DIPLOCATION( "SW1:6" )
242265   PORT_DIPSETTING(   0x20, DEF_STR( Off ) )
243266   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
244   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Coinage ) )      PORT_DIPLOCATION( "SW1:7" )
267   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Coinage ) )          PORT_DIPLOCATION( "SW1:7" )
245268   PORT_DIPSETTING(   0x00, DEF_STR( 2C_1C ) )
246269   PORT_DIPSETTING(   0x40, DEF_STR( 1C_1C ) )
247270INPUT_PORTS_END
248271
249
250272static INPUT_PORTS_START( nextfase )
251273   PORT_INCLUDE( phoenix )
252274
253275   PORT_MODIFY("DSW0")
254   PORT_DIPNAME( 0x03, 0x02, DEF_STR( Lives ) )      PORT_DIPLOCATION( "SW1:1,2" )
276   PORT_DIPNAME( 0x03, 0x02, DEF_STR( Lives ) )            PORT_DIPLOCATION( "SW1:1,2" )
255277   PORT_DIPSETTING(   0x00, "1" )
256278   PORT_DIPSETTING(   0x01, "2" )
257279   PORT_DIPSETTING(   0x02, "3" )
258280   PORT_DIPSETTING(   0x03, "4" )
259   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION( "SW1:3,4" )
281   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )       PORT_DIPLOCATION( "SW1:3,4" )
260282   PORT_DIPSETTING(   0x00, "3K 30K" )
261283   PORT_DIPSETTING(   0x04, "4K 40K" )
262284   PORT_DIPSETTING(   0x08, "5K 50K" )
263285   PORT_DIPSETTING(   0x0c, "6K 60K" )
264   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )      PORT_DIPLOCATION( "SW1:5" )
286   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )          PORT_DIPLOCATION( "SW1:5" )
265287   PORT_DIPSETTING(   0x10, DEF_STR( Off ) )
266288   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
267   PORT_DIPNAME( 0x60, 0x00, DEF_STR( Coinage ) )      PORT_DIPLOCATION( "SW1:6,7" )
268   PORT_DIPSETTING(   0x00, "1C/1C & 1C/2C" )
269   PORT_DIPSETTING(   0x20, "2C/3C & 1C/3C" )
270   PORT_DIPSETTING(   0x40, "1C/2C & 1C/4C" )
271   PORT_DIPSETTING(   0x60, "2C/5C & 1C/5C" )
289   PORT_DIPNAME( 0x60, 0x00, DEF_STR( Coinage ) )          PORT_DIPLOCATION( "SW1:6,7" )
290   PORT_DIPSETTING(   0x00, "A - 1C/1C B - 1C/2C" )
291   PORT_DIPSETTING(   0x20, "A - 2C/3C B - 1C/3C" )
292   PORT_DIPSETTING(   0x40, "A - 1C/2C B - 1C/4C" )
293   PORT_DIPSETTING(   0x60, "A - 2C/5C B - 1C/5C" )
272294INPUT_PORTS_END
273295
274296
r2375r2376
276298   PORT_INCLUDE( phoenix )
277299
278300   PORT_MODIFY("IN0")
279   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SPECIAL )       /* Protection. See 0x0552 */
301   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(pleiads_protection_r, 0)     /* Protection. See 0x0552 */
280302
281303   PORT_MODIFY("DSW0")
282   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )   PORT_DIPLOCATION( "SW1:7" )
304   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )      PORT_DIPLOCATION( "SW1:7" )
283305   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
284306   PORT_DIPSETTING(   0x40, DEF_STR( On ) )
285307INPUT_PORTS_END
r2375r2376
288310   PORT_INCLUDE( pleiads )
289311
290312   PORT_MODIFY("DSW0")
291   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION( "SW1:3,4" )
313   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )       PORT_DIPLOCATION( "SW1:3,4" )
292314   PORT_DIPSETTING(   0x00, "7K 70K" )
293315   PORT_DIPSETTING(   0x04, "8K 80K" )
294316   PORT_DIPSETTING(   0x08, "9K 90K" )
295  /*PORT_DIPSETTING(    0x0c, "INVALID" )   Sets bonus to A000 */
317  /*PORT_DIPSETTING(    0x0c, "INVALID" )                   Sets bonus to A000 */
296318INPUT_PORTS_END
297319
298320static INPUT_PORTS_START( capitol )
299321   PORT_INCLUDE( phoenix )
300322
301323   PORT_MODIFY("DSW0")
302   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )   PORT_DIPLOCATION( "SW1:7" )
324   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )      PORT_DIPLOCATION( "SW1:7" )
303325   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
304326   PORT_DIPSETTING(   0x40, DEF_STR( On ) )
305327INPUT_PORTS_END
306328
329
307330static INPUT_PORTS_START( survival )
308331   PORT_START_TAG("IN0")      /* IN0 */
309332   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
310333   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START1 )
311334   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START2 )
312335   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 )
313   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )
336   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )
314337   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )
315   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )
316   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )
338   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    )
339   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  )
317340
318341   PORT_START_TAG("IN1")      /* IN1 */
319342   PORT_BIT( 0x07, IP_ACTIVE_LOW, IPT_SPECIAL )   /* comes from IN0 0-2 */
320343   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
321   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_COCKTAIL
322   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT  ) PORT_COCKTAIL
323   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_UP  ) PORT_COCKTAIL
344   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  ) PORT_COCKTAIL
345   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_COCKTAIL
346   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    ) PORT_COCKTAIL
324347   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  ) PORT_COCKTAIL
325348
326349    PORT_START_TAG("DSW0")
r2375r2376
749772   ROM_LOAD( "mmi6301.ic41",   0x0100, 0x0100, CRC(e176b768) SHA1(e2184dd495ed579f10b6da0b78379e02d7a6229f) )  /* palette high bits */
750773ROM_END
751774
752ROM_START( vautour2 )
775ROM_START( falconz )
753776   ROM_REGION( 0x10000, REGION_CPU1, 0 )
777   ROM_LOAD( "f45.bin",      0x0000, 0x0800, CRC(9158b43b) SHA1(222cbcfb3f95d09bb90148813541c2613d8b7e1c) )
778   ROM_LOAD( "f46.bin",      0x0800, 0x0800, CRC(22ddb600) SHA1(9606d11722261990c34b788baae5dc7516ba52d6) )
779   ROM_LOAD( "f47.bin",      0x1000, 0x0800, CRC(cb2838d9) SHA1(332e339475b17d17eeb43a524c5cb3bf9818837a) )
780   ROM_LOAD( "f48.bin",      0x1800, 0x0800, CRC(552cf57a) SHA1(d9d36495f0cb25c1648e0807c8d37daf49bbf0d4) )
781   ROM_LOAD( "f49.bin",      0x2000, 0x0800, CRC(1ff3a982) SHA1(66fb39e7abdf7a9c6e2eb01d41cfe9429781d6aa) )
782   ROM_LOAD( "f50.bin",      0x2800, 0x0800, CRC(8c83bff7) SHA1(3dfb090d7e3a9ae8da882b06e166c48555eaf77c) )
783   ROM_LOAD( "f51.bin",      0x3000, 0x0800, CRC(805ec2e8) SHA1(7e56fc9990eb99512078e2b1e2874fb33b0aa05c) )
784   ROM_LOAD( "f52.bin",      0x3800, 0x0800, CRC(33f3af63) SHA1(f2e2ebdec205360a6fa8ce4bc8cdf15b82b02728) )
785
786   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
787   ROM_LOAD( "ic23.3d",      0x0000, 0x0800, CRC(3c7e623f) SHA1(e7ff5fc371664af44785c079e92eeb2d8530187b) )
788   ROM_LOAD( "ic24.4d",      0x0800, 0x0800, CRC(59916d3b) SHA1(71aec70a8e096ed1f0c2297b3ae7dca1b8ecc38d) )
789
790   ROM_REGION( 0x1000, REGION_GFX2, ROMREGION_DISPOSE )
791   ROM_LOAD( "f39.bin",      0x0000, 0x0800, CRC(53c52eb0) SHA1(19624ca359996b77d3c65ef78a7af90eeb092377) )
792   ROM_LOAD( "f40.bin",      0x0800, 0x0800, CRC(eba42f0f) SHA1(378282cb2c4e10c23179ae3c605ae7bf691150f6) )
793
794   ROM_REGION( 0x0200, REGION_PROMS, 0 )
795   ROM_LOAD( "mmi6301.ic40",   0x0000, 0x0100, CRC(79350b25) SHA1(57411be4c1d89677f7919ae295446da90612c8a8) )  /* palette low bits */
796   ROM_LOAD( "mmi6301.ic41",   0x0100, 0x0100, CRC(e176b768) SHA1(e2184dd495ed579f10b6da0b78379e02d7a6229f) )  /* palette high bits */
797ROM_END
798
799ROM_START( vautourz )
800   ROM_REGION( 0x10000, REGION_CPU1, 0 )
754801   ROM_LOAD( "vautour1.bin", 0x0000, 0x0800, CRC(a600f6a4) SHA1(f1aea5ec71da0d0664fb90b87602fe4c4eed2dbe) )
755802   ROM_LOAD( "vautour2.bin", 0x0800, 0x0800, CRC(3699b11a) SHA1(7122685cbfcd75898eaa68f8c5bf87c11df59a3b) )
756803   ROM_LOAD( "vautour3.bin", 0x1000, 0x0800, CRC(750b059b) SHA1(6fbaa2ef4c7eef6f731a73b2d33a02fff21b318a) )
r2375r2376
821868   ROM_LOAD( "mmi6301.ic41",   0x0100, 0x0100, CRC(e176b768) SHA1(e2184dd495ed579f10b6da0b78379e02d7a6229f) )  /* palette high bits */
822869ROM_END
823870
824ROM_START( falcona )
825   ROM_REGION( 0x10000, REGION_CPU1, 0 )
826   ROM_LOAD( "f45.bin",      0x0000, 0x0800, CRC(9158b43b) SHA1(222cbcfb3f95d09bb90148813541c2613d8b7e1c) )
827   ROM_LOAD( "f46.bin",      0x0800, 0x0800, CRC(22ddb600) SHA1(9606d11722261990c34b788baae5dc7516ba52d6) )
828   ROM_LOAD( "f47.bin",      0x1000, 0x0800, CRC(cb2838d9) SHA1(332e339475b17d17eeb43a524c5cb3bf9818837a) )
829   ROM_LOAD( "f48.bin",      0x1800, 0x0800, CRC(552cf57a) SHA1(d9d36495f0cb25c1648e0807c8d37daf49bbf0d4) )
830   ROM_LOAD( "f49.bin",      0x2000, 0x0800, CRC(1ff3a982) SHA1(66fb39e7abdf7a9c6e2eb01d41cfe9429781d6aa) )
831   ROM_LOAD( "f50.bin",      0x2800, 0x0800, CRC(8c83bff7) SHA1(3dfb090d7e3a9ae8da882b06e166c48555eaf77c) )
832   ROM_LOAD( "f51.bin",      0x3000, 0x0800, CRC(805ec2e8) SHA1(7e56fc9990eb99512078e2b1e2874fb33b0aa05c) )
833   ROM_LOAD( "f52.bin",      0x3800, 0x0800, CRC(33f3af63) SHA1(f2e2ebdec205360a6fa8ce4bc8cdf15b82b02728) )
834
835   ROM_REGION( 0x1000, REGION_GFX1, ROMREGION_DISPOSE )
836   ROM_LOAD( "ic23.3d",      0x0000, 0x0800, CRC(3c7e623f) SHA1(e7ff5fc371664af44785c079e92eeb2d8530187b) )
837   ROM_LOAD( "ic24.4d",      0x0800, 0x0800, CRC(59916d3b) SHA1(71aec70a8e096ed1f0c2297b3ae7dca1b8ecc38d) )
838
839   ROM_REGION( 0x1000, REGION_GFX2, ROMREGION_DISPOSE )
840   ROM_LOAD( "f39.bin",      0x0000, 0x0800, CRC(53c52eb0) SHA1(19624ca359996b77d3c65ef78a7af90eeb092377) )
841   ROM_LOAD( "f40.bin",      0x0800, 0x0800, CRC(eba42f0f) SHA1(378282cb2c4e10c23179ae3c605ae7bf691150f6) )
842
843   ROM_REGION( 0x0200, REGION_PROMS, 0 )
844   ROM_LOAD( "mmi6301.ic40",   0x0000, 0x0100, CRC(79350b25) SHA1(57411be4c1d89677f7919ae295446da90612c8a8) )  /* palette low bits */
845   ROM_LOAD( "mmi6301.ic41",   0x0100, 0x0100, CRC(e176b768) SHA1(e2184dd495ed579f10b6da0b78379e02d7a6229f) )  /* palette high bits */
846ROM_END
847
848871ROM_START( nextfase )
849872   ROM_REGION( 0x10000, REGION_CPU1, 0 )
850873   ROM_LOAD( "nf01.bin",   0x0000, 0x0800, CRC(b31ce820) SHA1(dfdb17995a14b66d2571c2c8de481d2792f9ce6a) )
r2375r2376
9951018static DRIVER_INIT( condor )
9961019{
9971020   /* additional inputs for coinage */
998   memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x5000, 0x5000, 0, 0, input_port_4_r );
1021   memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x5000, 0x5000, 0, 0, port_tag_to_handler8("DSW1") );
9991022}
10001023
10011024static DRIVER_INIT( survival )
r2375r2376
10081031
10091032
10101033
1011GAME( 1980, phoenix,  0,       phoenix,  phoenix,  0,        ROT90, "Amstar", "Phoenix (Amstar)", GAME_SUPPORTS_SAVE )
1012GAME( 1980, phoenixa, phoenix, phoenix,  phoenixa, 0,        ROT90, "Amstar (Centuri license)", "Phoenix (Centuri), Set 1", GAME_SUPPORTS_SAVE )
1013GAME( 1980, phoenixb, phoenix, phoenix,  phoenixa, 0,        ROT90, "Amstar (Centuri license)", "Phoenix (Centuri), Set 2", GAME_SUPPORTS_SAVE )
1014GAME( 1980, phoenixt, phoenix, phoenix,  phoenixt, 0,        ROT90, "Taito", "Phoenix (Taito)", GAME_SUPPORTS_SAVE )
1015GAME( 1980, phoenix3, phoenix, phoenix,  phoenix3, 0,        ROT90, "bootleg", "Phoenix (T.P.N.)", GAME_SUPPORTS_SAVE )
1016GAME( 1981, phoenixc, phoenix, phoenix,  phoenixt, 0,        ROT90, "bootleg?", "Phoenix (IRECSA, G.G.I Corp)", GAME_SUPPORTS_SAVE )
1017
1018
1019GAME( 1981, condor,   phoenix, condor,   condor,   condor,   ROT90, "Sidam (bootleg)",      "Condor (bootleg of Phoenix)", GAME_SUPPORTS_SAVE )
1034GAME( 1980, phoenix,  0,        phoenix,  phoenix,  0,        ROT90, "Amstar", "Phoenix (Amstar)", GAME_SUPPORTS_SAVE )
1035GAME( 1980, phoenixa, phoenix,  phoenix,  phoenixa, 0,        ROT90, "Amstar (Centuri license)", "Phoenix (Centuri, set 1)", GAME_SUPPORTS_SAVE )
1036GAME( 1980, phoenixb, phoenix,  phoenix,  phoenixa, 0,        ROT90, "Amstar (Centuri license)", "Phoenix (Centuri, set 2)", GAME_SUPPORTS_SAVE )
1037GAME( 1980, phoenixt, phoenix,  phoenix,  phoenixt, 0,        ROT90, "Taito", "Phoenix (Taito)", GAME_SUPPORTS_SAVE )
1038GAME( 1980, phoenix3, phoenix,  phoenix,  phoenix3, 0,        ROT90, "bootleg", "Phoenix (T.P.N.)", GAME_SUPPORTS_SAVE )
1039GAME( 1981, phoenixc, phoenix,  phoenix,  phoenixt, 0,        ROT90, "bootleg?", "Phoenix (IRECSA, G.G.I Corp)", GAME_SUPPORTS_SAVE )
1040GAME( 1981, condor,   phoenix,  condor,   condor,   condor,   ROT90, "Sidam (bootleg)",       "Condor (bootleg of Phoenix)", GAME_SUPPORTS_SAVE )
10201041// the following 2 were common bootlegs in england & france respectively
1021GAME( 1980, falcon,   phoenix, phoenix,  phoenixt, 0,        ROT90, "bootleg",              "Falcon (bootleg of Phoenix) (set 1)", GAME_SUPPORTS_SAVE )
1022GAME( 1980, vautour,  phoenix, phoenix,  phoenixt, 0,        ROT90, "Jeutel (bootleg)",     "Vautour (bootleg of Phoenix) (set 1)", GAME_SUPPORTS_SAVE )
1023GAME( 1980, vautour2, phoenix, condor,   condor,   condor,   ROT90, "bootleg",              "Vautour (bootleg of Phoenix) (set 2)", GAME_SUPPORTS_SAVE )
1024// fenix is an italian bootleg based on vautour
1025GAME( 1980, fenix,    phoenix, condor,   condor,   condor,   ROT90, "bootleg",              "Fenix (bootleg of Phoenix)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
1026GAME( 1980, griffon,  phoenix, condor,   condor,   condor,   ROT90, "Videotron (bootleg)",  "Griffon (bootleg of Phoenix)", GAME_SUPPORTS_SAVE )
1027GAME( 1980, falcona,  phoenix, condor,   falcona,  0,        ROT90, "bootleg",              "Falcon (bootleg of Phoenix) (set 2)", GAME_SUPPORTS_SAVE )
1042GAME( 1980, falcon,   phoenix,  phoenix,  phoenixt, 0,        ROT90, "bootleg",               "Falcon (bootleg of Phoenix) (8085A CPU)", GAME_SUPPORTS_SAVE )
1043GAME( 1980, vautour,  phoenix,  phoenix,  phoenixt, 0,        ROT90, "Jeutel (bootleg)",      "Vautour (bootleg of Phoenix) (8085A CPU)", GAME_SUPPORTS_SAVE )
1044GAME( 1980, falconz,  phoenix,  condor,   falconz,  0,        ROT90, "bootleg",               "Falcon (bootleg of Phoenix) (Z80 CPU)", GAME_SUPPORTS_SAVE )
1045GAME( 1980, vautourz, phoenix,  condor,   condor,   condor,   ROT90, "bootleg",               "Vautour (bootleg of Phoenix) (Z80 CPU)", GAME_SUPPORTS_SAVE )
1046// fenix is an italian bootleg based on vautourz
1047GAME( 1980, fenix,    phoenix,  condor,   condor,   condor,   ROT90, "bootleg",               "Fenix (bootleg of Phoenix)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
1048GAME( 1980, griffon,  phoenix,  condor,   condor,   condor,   ROT90, "Videotron (bootleg)",   "Griffon (bootleg of Phoenix)", GAME_SUPPORTS_SAVE )
10281049// nextfase is a spanish bootleg
1029GAME( 1981, nextfase, phoenix, phoenix,  nextfase, 0,        ROT90, "Petaco S.A. (bootleg)","Next Fase (bootleg of Phoenix)", GAME_SUPPORTS_SAVE )
1050GAME( 1981, nextfase, phoenix, phoenix,  nextfase, 0,        ROT90, "Petaco S.A. (bootleg)", "Next Fase (bootleg of Phoenix)", GAME_SUPPORTS_SAVE )
10301051
1031GAME( 1981, pleiads,  0,       pleiads,  pleiads,  0,        ROT90, "Tehkan", "Pleiads (Tehkan)", GAME_IMPERFECT_COLORS )
1032GAME( 1981, pleiadbl, pleiads, pleiads,  pleiads,  0,        ROT90, "bootleg", "Pleiads (bootleg)", GAME_IMPERFECT_COLORS )
1033GAME( 1981, pleiadce, pleiads, pleiads,  pleiadce, 0,        ROT90, "Tehkan (Centuri license)", "Pleiads (Centuri)", GAME_IMPERFECT_COLORS )
1034GAME( 1981, capitol,  pleiads, phoenix,  capitol,  0,        ROT90, "Universal Video Spiel", "Capitol", GAME_IMPERFECT_COLORS )
1035GAME( 1982, survival, 0,       survival, survival, survival, ROT90, "Rock-ola", "Survival", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
1052GAME( 1981, pleiads,  0,        pleiads,  pleiads,  0,        ROT90, "Tehkan", "Pleiads (Tehkan)", GAME_IMPERFECT_COLORS )
1053GAME( 1981, pleiadbl, pleiads,  pleiads,  pleiads,  0,        ROT90, "bootleg", "Pleiads (bootleg)", GAME_IMPERFECT_COLORS )
1054GAME( 1981, pleiadce, pleiads,  pleiads,  pleiadce, 0,        ROT90, "Tehkan (Centuri license)", "Pleiads (Centuri)", GAME_IMPERFECT_COLORS )
1055GAME( 1981, capitol,  pleiads,  phoenix,  capitol,  0,        ROT90, "Universal Video Spiel", "Capitol", GAME_IMPERFECT_COLORS )
1056
1057GAME( 1982, survival, 0,        survival, survival, survival, ROT90, "Rock-ola", "Survival", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
src/mame/drivers/lastfght.c
r2375r2376
306306{
307307   // high byte:
308308   // mask 0x1c: from sound?
309   return (mame_rand(Machine) & 0x1c00) | readinputport(0);
309   return (mame_rand(Machine) & 0x1c00) | input_port_read_indexed(machine, 0);
310310}
311311
312312static READ16_HANDLER( lastfght_c00004_r )
313313{
314   return readinputport(1);
314   return input_port_read_indexed(machine, 1);
315315}
316316
317317static READ16_HANDLER( lastfght_c00006_r )
r2375r2376
319319   // low byte:
320320   // bit 7 = protection?
321321   // bit 5 = blitter?
322   return readinputport(2);
322   return input_port_read_indexed(machine, 2);
323323}
324324
325325static WRITE16_HANDLER( lastfght_c00006_w )
src/mame/drivers/embargo.c
r2375r2376
5858
5959static READ8_HANDLER( input_port_bit_r )
6060{
61   return (readinputport(1) << (7 - input_select)) & 0x80;
61   return (input_port_read_indexed(machine, 1) << (7 - input_select)) & 0x80;
6262}
6363
6464
r2375r2376
8282
8383   if (dial_enable_1 && !dial_enable_2)
8484   {
85      lo = readinputport(3);
86      hi = readinputport(4);
85      lo = input_port_read_indexed(machine, 3);
86      hi = input_port_read_indexed(machine, 4);
8787   }
8888
8989   if (dial_enable_2 && !dial_enable_1)
9090   {
91      lo = readinputport(5);
92      hi = readinputport(6);
91      lo = input_port_read_indexed(machine, 5);
92      hi = input_port_read_indexed(machine, 6);
9393   }
9494
9595   lo = 12 * lo / 256;
src/mame/drivers/msisaac.c
r2375r2376
159159          //6-down
160160          //7-leftdwn
161161
162          UINT8 val= (readinputport(4)>>2) & 0x0f;
162          UINT8 val= (input_port_read_indexed(machine, 4)>>2) & 0x0f;
163163          /* bit0 = left
164164               bit1 = right
165165               bit2 = down
src/mame/drivers/superqix.c
r2375r2376
195195static READ8_HANDLER( in4_mcu_r )
196196{
197197//  logerror("%04x: in4_mcu_r\n",activecpu_get_pc());
198   return readinputport(4) | (from_mcu_pending << 6) | (from_z80_pending << 7);
198   return input_port_read_indexed(machine, 4) | (from_mcu_pending << 6) | (from_z80_pending << 7);
199199}
200200
201201static READ8_HANDLER( sqix_from_mcu_r )
r2375r2376
268268{
269269   if ((port1 & 0x10) == 0)
270270   {
271      return readinputport(0);
271      return input_port_read_indexed(machine, 0);
272272   }
273273   else if ((port1 & 0x20) == 0)
274274   {
275      return readinputport(2) | (from_mcu_pending << 6) | (from_z80_pending << 7);
275      return input_port_read_indexed(machine, 2) | (from_mcu_pending << 6) | (from_z80_pending << 7);
276276   }
277277   else if ((port1 & 0x40) == 0)
278278   {
r2375r2376
297297
298298static READ8_HANDLER( bootleg_in0_r )
299299{
300   return BITSWAP8(readinputport(0), 0,1,2,3,4,5,6,7);
300   return BITSWAP8(input_port_read_indexed(machine, 0), 0,1,2,3,4,5,6,7);
301301}
302302
303303static WRITE8_HANDLER( bootleg_flipscreen_w )
r2375r2376
318318 * connected to the 68705 which acts as a counter.
319319 */
320320
321static int read_dial(int player)
321static int read_dial(running_machine *machine, int player)
322322{
323323   int newpos;
324324   static int oldpos[2];
325325   static int sign[2];
326326
327327   /* get the new position and adjust the result */
328   newpos = readinputport(3 + player);
328   newpos = input_port_read_indexed(machine, 3 + player);
329329   if (newpos != oldpos[player])
330330   {
331331      sign[player] = ((newpos - oldpos[player]) & 0x80) >> 7;
r2375r2376
401401      switch (data & 0x07)
402402      {
403403         case 0x0:   // dsw A
404            portA_in = readinputport(0);
404            portA_in = input_port_read_indexed(machine, 0);
405405            break;
406406
407407         case 0x1:   // dsw B
408            portA_in = readinputport(1);
408            portA_in = input_port_read_indexed(machine, 1);
409409            break;
410410
411411         case 0x2:
r2375r2376
424424            break;
425425
426426         case 0x6:
427            portA_in = read_dial(0);
427            portA_in = read_dial(machine, 0);
428428            break;
429429
430430         case 0x7:
431            portA_in = read_dial(1);
431            portA_in = read_dial(machine, 1);
432432            break;
433433      }
434434   }
r2375r2376
449449static READ8_HANDLER(hotsmash_ay_port_a_r)
450450{
451451//logerror("%04x: ay_port_a_r and mcu_pending is %d\n",activecpu_get_pc(),from_mcu_pending);
452   return readinputport(2) | ((from_mcu_pending^1) << 7);
452   return input_port_read_indexed(machine, 2) | ((from_mcu_pending^1) << 7);
453453}
454454
455455/**************************************************************************
r2375r2376
469469
470470   switch (from_z80)
471471   {
472      case 0x01: return readinputport(4 + 2 * curr_player);
473      case 0x02: return readinputport(5 + 2 * curr_player);
474      case 0x04: return readinputport(0);
475      case 0x08: return readinputport(1);
472      case 0x01: return input_port_read_indexed(machine, 4 + 2 * curr_player);
473      case 0x02: return input_port_read_indexed(machine, 5 + 2 * curr_player);
474      case 0x04: return input_port_read_indexed(machine, 0);
475      case 0x08: return input_port_read_indexed(machine, 1);
476476      case 0x80: curr_player = 0; return 0;
477477      case 0x81: curr_player = 1; return 0;
478478   }
r2375r2376
485485{
486486//  logerror("%04x: ay_port_a_r\n",activecpu_get_pc());
487487    /* bits 76------  MCU status bits */
488   return (mame_rand(Machine)&0xc0)|readinputport(3);
488   return (mame_rand(Machine)&0xc0)|input_port_read_indexed(machine, 3);
489489}
490490
491491
src/mame/drivers/cojag.c
r2375r2376
368368
369369static READ32_HANDLER( jamma_r )
370370{
371   return readinputport(0) | (readinputport(1) << 16);
371   return input_port_read_indexed(machine, 0) | (input_port_read_indexed(machine, 1) << 16);
372372}
373373
374374
r2375r2376
381381   // D5     = /VOLUMEUP
382382   // D4     = /VOLUMEDOWN
383383   // D3-D0  = ACTC4-1
384   return readinputport(2) | (readinputport(2) << 16);
384   return input_port_read_indexed(machine, 2) | (input_port_read_indexed(machine, 2) << 16);
385385}
386386
387387
src/mame/drivers/cyberbal.c
r2375r2376
105105
106106static READ16_HANDLER( special_port0_r )
107107{
108   int temp = readinputport(0);
108   int temp = input_port_read_indexed(machine, 0);
109109   if (atarigen_cpu_to_sound_ready) temp ^= 0x0080;
110110   return temp;
111111}
r2375r2376
113113
114114static READ16_HANDLER( special_port2_r )
115115{
116   int temp = readinputport(2);
116   int temp = input_port_read_indexed(machine, 2);
117117   if (atarigen_cpu_to_sound_ready) temp ^= 0x2000;
118118   return temp;
119119}
src/mame/drivers/lockon.c
r2375r2376
359359{
360360   switch (offset)
361361   {
362      case 0:  return readinputportbytag("ADC_BANK");
363      case 1:  return readinputportbytag("ADC_PITCH");
364      case 2:  return readinputportbytag("ADC_MISSILE");
365      case 3:  return readinputportbytag("ADC_HOVER");
362      case 0:  return input_port_read(machine, "ADC_BANK");
363      case 1:  return input_port_read(machine, "ADC_PITCH");
364      case 2:  return input_port_read(machine, "ADC_MISSILE");
365      case 3:  return input_port_read(machine, "ADC_HOVER");
366366      default: return 0;
367367   }
368368}
src/mame/drivers/mappy.c
r2375r2376
604604***************************************************************************/
605605
606606static int mux;
607static READ8_HANDLER( in0_l )   { return readinputportbytag("IN0"); }      // P1 joystick
608static READ8_HANDLER( in0_h )   { return readinputportbytag("IN0") >> 4; }   // P2 joystick
609static READ8_HANDLER( in1_l )   { return readinputportbytag("IN1"); }      // fire and start buttons
610static READ8_HANDLER( in1_h )   { return readinputportbytag("IN1") >> 4; }   // coins
611static READ8_HANDLER( in2 )      { return readinputportbytag("DSW0"); }      // test, cocktail, optional buttons
612static READ8_HANDLER( dipA_l )   { return readinputportbytag("DSW1"); }      // dips A
613static READ8_HANDLER( dipA_h )   { return readinputportbytag("DSW1") >> 4; }   // dips A
614static READ8_HANDLER( dipB_mux )   { return readinputportbytag("DSW2") >> (4*mux); }   // dips B
607static READ8_HANDLER( in0_l )   { return input_port_read(machine, "IN0"); }      // P1 joystick
608static READ8_HANDLER( in0_h )   { return input_port_read(machine, "IN0") >> 4; }   // P2 joystick
609static READ8_HANDLER( in1_l )   { return input_port_read(machine, "IN1"); }      // fire and start buttons
610static READ8_HANDLER( in1_h )   { return input_port_read(machine, "IN1") >> 4; }   // coins
611static READ8_HANDLER( in2 )      { return input_port_read(machine, "DSW0"); }      // test, cocktail, optional buttons
612static READ8_HANDLER( dipA_l )   { return input_port_read(machine, "DSW1"); }      // dips A
613static READ8_HANDLER( dipA_h )   { return input_port_read(machine, "DSW1") >> 4; }   // dips A
614static READ8_HANDLER( dipB_mux )   { return input_port_read(machine, "DSW2") >> (4*mux); }   // dips B
615615static READ8_HANDLER( dipB_muxi )   // dips B
616616{
617617   // bits are interleaved in Phozon
618   return BITSWAP8(readinputport(4),6,4,2,0,7,5,3,1) >> (4*mux);
618   return BITSWAP8(input_port_read_indexed(machine, 4),6,4,2,0,7,5,3,1) >> (4*mux);
619619}
620620static WRITE8_HANDLER( out_mux )   { mux = data & 1; }
621621static WRITE8_HANDLER( out_lamps )
src/mame/drivers/pntnpuzl.c
r2375r2376
162162static READ16_HANDLER( pntnpuzl_eeprom_r )
163163{
164164   /* bit 11 is EEPROM data */
165   return (pntnpuzl_eeprom & 0xf4ff) | (EEPROM_read_bit()<<11) | (readinputport(3) & 0x0300);
165   return (pntnpuzl_eeprom & 0xf4ff) | (EEPROM_read_bit()<<11) | (input_port_read_indexed(machine, 3) & 0x0300);
166166}
167167
168168static WRITE16_HANDLER( pntnpuzl_eeprom_w )
r2375r2376
293293
294294static READ16_HANDLER( pntnpuzl_vblank_r )
295295{
296   return (readinputport(0) & 1) << 11;
296   return (input_port_read_indexed(machine, 0) & 1) << 11;
297297}
298298
299299
r2375r2376
351351   if (serial_out == 0x11)
352352   {
353353      static int touchscr[5];
354      if (readinputport(0) & 0x10)
354      if (input_port_read_indexed(machine, 0) & 0x10)
355355      {
356356         touchscr[0] = 0x1b;
357         touchscr[2] = BITSWAP8(readinputport(1),0,1,2,3,4,5,6,7);
358         touchscr[4] = BITSWAP8(readinputport(2),0,1,2,3,4,5,6,7);
357         touchscr[2] = BITSWAP8(input_port_read_indexed(machine, 1),0,1,2,3,4,5,6,7);
358         touchscr[4] = BITSWAP8(input_port_read_indexed(machine, 2),0,1,2,3,4,5,6,7);
359359      }
360360      else
361361         touchscr[0] = 0;
r2375r2376
412412
413413static INTERRUPT_GEN( pntnpuzl_irq )
414414{
415   if (readinputport(0) & 0x02)   /* coin */
415   if (input_port_read_indexed(machine, 0) & 0x02)   /* coin */
416416      cpunum_set_input_line(machine, 0, 1, PULSE_LINE);
417   else if (readinputport(0) & 0x04)   /* service */
417   else if (input_port_read_indexed(machine, 0) & 0x04)   /* service */
418418      cpunum_set_input_line(machine, 0, 2, PULSE_LINE);
419   else if (readinputport(0) & 0x08)   /* coin */
419   else if (input_port_read_indexed(machine, 0) & 0x08)   /* coin */
420420      cpunum_set_input_line(machine, 0, 4, PULSE_LINE);
421421}
422422
src/mame/drivers/uapce.c
r2375r2376
5858{
5959   UINT8 dsw_val;
6060
61   dsw_val = readinputportbytag( "DSW" );
61   dsw_val = input_port_read(machine, "DSW" );
6262
6363   if ( BIT( offset, 7 ) == 0 )
6464   {
r2375r2376
100100{
101101   if ( jamma_if_control_latch & 0x10 )
102102   {
103      return readinputportbytag( "IN" );
103      return input_port_read(Machine, "IN" );
104104   }
105105   else
106106   {
107      return readinputportbytag( "IN" ) | 0x08;
107      return input_port_read(Machine, "IN" ) | 0x08;
108108   }
109109}
110110
src/mame/drivers/wilytowr.c
r2375r2376
255255}
256256
257257
258static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 )
259   AM_RANGE(0x0000, 0xbfff) AM_READ(SMH_ROM)
260   AM_RANGE(0xd000, 0xdfff) AM_READ(SMH_RAM)
261   AM_RANGE(0xe000, 0xefff) AM_READ(SMH_RAM)
262   AM_RANGE(0xf800, 0xf800) AM_READ(input_port_0_r)
263   AM_RANGE(0xf801, 0xf801) AM_READ(input_port_1_r)
264   AM_RANGE(0xf802, 0xf802) AM_READ(input_port_2_r)
265   AM_RANGE(0xf806, 0xf806) AM_READ(input_port_3_r)
266ADDRESS_MAP_END
267
268static ADDRESS_MAP_START( writemem, ADDRESS_SPACE_PROGRAM, 8 )
269   AM_RANGE(0x0000, 0xbfff) AM_WRITE(SMH_ROM)
270   AM_RANGE(0xd000, 0xdfff) AM_WRITE(SMH_RAM)
271   AM_RANGE(0xe000, 0xe1ff) AM_WRITE(SMH_RAM)
272   AM_RANGE(0xe200, 0xe2ff) AM_WRITE(SMH_RAM) AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
273   AM_RANGE(0xe300, 0xe3ff) AM_WRITE(SMH_RAM) AM_BASE(&wilytowr_scrollram)
274   AM_RANGE(0xe400, 0xe7ff) AM_WRITE(wilytowr_videoram2_w) AM_BASE(&wilytowr_videoram2)
275   AM_RANGE(0xe800, 0xebff) AM_WRITE(wilytowr_videoram_w) AM_BASE(&videoram)
276   AM_RANGE(0xec00, 0xefff) AM_WRITE(wilytowr_colorram_w) AM_BASE(&colorram)
258static ADDRESS_MAP_START( wilytowr_map, ADDRESS_SPACE_PROGRAM, 8 )
259   AM_RANGE(0x0000, 0xbfff) AM_ROM
260   AM_RANGE(0xd000, 0xdfff) AM_RAM
261   AM_RANGE(0xe000, 0xe1ff) AM_RAM
262   AM_RANGE(0xe200, 0xe2ff) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size)
263   AM_RANGE(0xe300, 0xe3ff) AM_RAM AM_BASE(&wilytowr_scrollram)
264   AM_RANGE(0xe400, 0xe7ff) AM_RAM AM_WRITE(wilytowr_videoram2_w) AM_BASE(&wilytowr_videoram2)
265   AM_RANGE(0xe800, 0xebff) AM_RAM AM_WRITE(wilytowr_videoram_w) AM_BASE(&videoram)
266   AM_RANGE(0xec00, 0xefff) AM_RAM AM_WRITE(wilytowr_colorram_w) AM_BASE(&colorram)
277267   AM_RANGE(0xf000, 0xf000) AM_WRITE(interrupt_enable_w)   /* NMI enable */
278268   AM_RANGE(0xf002, 0xf002) AM_WRITE(wilytwr_flipscreen_w)
279269   AM_RANGE(0xf003, 0xf003) AM_WRITE(wilytwr_palbank_w)
280270   AM_RANGE(0xf006, 0xf007) AM_WRITE(coin_w)
281   AM_RANGE(0xf800, 0xf800) AM_WRITE(soundlatch_w)
282   AM_RANGE(0xf801, 0xf801) AM_WRITE(SMH_NOP)   /* continues game when in stop mode (cleared by NMI handler) */
271   AM_RANGE(0xf800, 0xf800) AM_READWRITE(input_port_0_r, soundlatch_w)
272   AM_RANGE(0xf801, 0xf801) AM_READWRITE(input_port_1_r, SMH_NOP)   /* continues game when in stop mode (cleared by NMI handler) */
273   AM_RANGE(0xf802, 0xf802) AM_READ(input_port_2_r)
283274   AM_RANGE(0xf803, 0xf803) AM_WRITE(snd_irq_w)
275   AM_RANGE(0xf806, 0xf806) AM_READ(input_port_3_r)
284276ADDRESS_MAP_END
285277
286278static ADDRESS_MAP_START( fghtbskt_map, ADDRESS_SPACE_PROGRAM, 8 )
r2375r2376
310302   AM_RANGE(0xf807, 0xf807) AM_WRITE(fghtbskt_samples_w)
311303ADDRESS_MAP_END
312304
313static ADDRESS_MAP_START( i8039_readmem, ADDRESS_SPACE_PROGRAM, 8 )
314   AM_RANGE(0x0000, 0x0fff) AM_READ(SMH_ROM)
305static ADDRESS_MAP_START( i8039_map, ADDRESS_SPACE_PROGRAM, 8 )
306   AM_RANGE(0x0000, 0x0fff) AM_ROM
315307ADDRESS_MAP_END
316308
317static ADDRESS_MAP_START( i8039_writemem, ADDRESS_SPACE_PROGRAM, 8 )
318   AM_RANGE(0x0000, 0x0fff) AM_WRITE(SMH_ROM)
319ADDRESS_MAP_END
320309
321static ADDRESS_MAP_START( i8039_readport, ADDRESS_SPACE_IO, 8 )
322//  AM_RANGE(0x00, 0xff)
310static ADDRESS_MAP_START( i8039_port_map, ADDRESS_SPACE_IO, 8 )
323311//  AM_RANGE(I8039_t1, I8039_t1)
324ADDRESS_MAP_END
325
326static ADDRESS_MAP_START( i8039_writeport, ADDRESS_SPACE_IO, 8 )
327312   AM_RANGE(0x00, 0xff) AM_WRITE(snddata_w)
328313   AM_RANGE(I8039_p1, I8039_p1) AM_WRITE(p1_w)
329314   AM_RANGE(I8039_p2, I8039_p2) AM_WRITE(p2_w)
r2375r2376
523508
524509   /* basic machine hardware */
525510   MDRV_CPU_ADD(Z80,4000000)   /* 4 MHz ???? */
526   MDRV_CPU_PROGRAM_MAP(readmem,writemem)
511   MDRV_CPU_PROGRAM_MAP(wilytowr_map,0)
527512   MDRV_CPU_VBLANK_INT("main", nmi_line_pulse)
528513
529   MDRV_CPU_ADD(I8039,8000000)   /* ????? */
530514   /* audio CPU */
531   MDRV_CPU_PROGRAM_MAP(i8039_readmem,i8039_writemem)
532   MDRV_CPU_IO_MAP(i8039_readport,i8039_writeport)
515   MDRV_CPU_ADD(I8039,8000000)   /* ????? */
516   MDRV_CPU_PROGRAM_MAP(i8039_map,0)
517   MDRV_CPU_IO_MAP(i8039_port_map,0)
533518
534519   /* video hardware */
535520   MDRV_SCREEN_ADD("main", RASTER)
r2375r2376
563548   MDRV_CPU_PROGRAM_MAP(fghtbskt_map,0)
564549   MDRV_CPU_VBLANK_INT("main", nmi_line_pulse)
565550
566   MDRV_CPU_ADD(I8039,12000000/4)   /* ????? */
567551   /* audio CPU */
568   MDRV_CPU_PROGRAM_MAP(i8039_readmem,i8039_writemem)
569   MDRV_CPU_IO_MAP(i8039_readport,i8039_writeport)
552   MDRV_CPU_ADD(I8039,12000000/4)   /* ????? */
553   MDRV_CPU_PROGRAM_MAP(i8039_map,0)
554   MDRV_CPU_IO_MAP(i8039_port_map,0)
570555
571556   /* video hardware */
572557   MDRV_SCREEN_ADD("main", RASTER)
src/mame/drivers/segas32.c
r2375r2376
591591}
592592
593593
594static UINT16 common_io_chip_r(int which, offs_t offset, UINT16 mem_mask)
594static UINT16 common_io_chip_r(running_machine *machine, int which, offs_t offset, UINT16 mem_mask)
595595{
596596   offset &= 0x1f/2;
597597
r2375r2376
611611            return misc_io_data[which][offset];
612612
613613         /* otherwise, return an input port */
614         return readinputport(which*8 + offset);
614         return input_port_read_indexed(machine, which*8 + offset);
615615
616616      /* 'SEGA' protection */
617617      case 0x10/2:
r2375r2376
700700
701701static READ16_HANDLER( io_chip_r )
702702{
703   return common_io_chip_r(0, offset, mem_mask);
703   return common_io_chip_r(machine, 0, offset, mem_mask);
704704}
705705
706706
r2375r2376
712712
713713static READ32_HANDLER( io_chip_0_r )
714714{
715   return common_io_chip_r(0, offset*2+0, mem_mask) |
716         (common_io_chip_r(0, offset*2+1, mem_mask >> 16) << 16);
715   return common_io_chip_r(machine, 0, offset*2+0, mem_mask) |
716         (common_io_chip_r(machine, 0, offset*2+1, mem_mask >> 16) << 16);
717717}
718718
719719
r2375r2376
728728
729729static READ32_HANDLER( io_chip_1_r )
730730{
731   return common_io_chip_r(1, offset*2+0, mem_mask) |
732         (common_io_chip_r(1, offset*2+1, mem_mask >> 16) << 16);
731   return common_io_chip_r(machine, 1, offset*2+0, mem_mask) |
732         (common_io_chip_r(machine, 1, offset*2+1, mem_mask >> 16) << 16);
733733}
734734
735735
r2375r2376
868868      case 0x12/2:
869869      case 0x14/2:
870870      case 0x16/2:
871         analog_value[offset & 3] = readinputportbytag_safe(names[offset & 3], 0);
871         analog_value[offset & 3] = input_port_read_safe(machine, names[offset & 3], 0);
872872         return;
873873   }
874874   logerror("%06X:unknown analog_custom_io_w(%X) = %04X & %04X\n", activecpu_get_pc(), offset*2, data, mem_mask ^ 0xffff);
r2375r2376
884884      case 0x22/2:
885885      case 0x24/2:
886886      case 0x26/2:
887         return readinputportbytag_safe(names[offset & 3], 0xffff);
887         return input_port_read_safe(machine, names[offset & 3], 0xffff);
888888   }
889889
890890   logerror("%06X:unknown extra_custom_io_r(%X) & %04X\n", activecpu_get_pc(), offset*2, mem_mask ^ 0xffff);
r2375r2376
901901      case 0x12/2:
902902      case 0x14/2:
903903      case 0x16/2:
904         analog_value[offset & 3] = readinputportbytag_safe(names[analog_bank * 4 + (offset & 3)], 0);
904         analog_value[offset & 3] = input_port_read_safe(machine, names[analog_bank * 4 + (offset & 3)], 0);
905905         return;
906906
907907      case 0x20/2:
r2375r2376
924924      case 0x0c/2:
925925      case 0x10/2:
926926      case 0x14/2:
927         return (UINT8)(readinputportbytag(names[offset/2]) - sonic_last[offset/2]);
927         return (UINT8)(input_port_read(machine, names[offset/2]) - sonic_last[offset/2]);
928928   }
929929
930930   logerror("%06X:unknown sonic_custom_io_r(%X) & %04X\n", activecpu_get_pc(), offset*2, mem_mask ^ 0xffff);
r2375r2376
941941      case 0x00/2:
942942      case 0x08/2:
943943      case 0x10/2:
944         sonic_last[offset/2 + 0] = readinputportbytag(names[offset/2 + 0]);
945         sonic_last[offset/2 + 1] = readinputportbytag(names[offset/2 + 1]);
944         sonic_last[offset/2 + 0] = input_port_read(machine, names[offset/2 + 0]);
945         sonic_last[offset/2 + 1] = input_port_read(machine, names[offset/2 + 1]);
946946         return;
947947   }
948948
src/mame/drivers/badlands.c
r2375r2376
139139   /* sound IRQ is on 32V */
140140   if (scanline & 32)
141141      atarigen_6502_irq_ack_r(screen->machine, 0);
142   else if (!(readinputport(0) & 0x40))
142   else if (!(input_port_read_indexed(screen->machine, 0) & 0x40))
143143      atarigen_6502_irq_gen(screen->machine, 0);
144144}
145145
r2375r2376
240240                0x02 = coin 2
241241                0x01 = coin 1
242242            */
243         result = readinputport(3);
244         if (!(readinputport(0) & 0x0080)) result ^= 0x90;
243         result = input_port_read_indexed(machine, 3);
244         if (!(input_port_read_indexed(machine, 0) & 0x0080)) result ^= 0x90;
245245         if (atarigen_cpu_to_sound_ready) result ^= 0x40;
246246         if (atarigen_sound_to_cpu_ready) result ^= 0x20;
247247         result ^= 0x10;
r2375r2376
633633   /* sound IRQ is on 32V */
634634//  if (scanline & 32)
635635//      atarigen_6502_irq_ack_r(screen->machine, 0);
636//  else if (!(readinputport(0) & 0x40))
636//  else if (!(input_port_read_indexed(machine, 0) & 0x40))
637637//      atarigen_6502_irq_gen(screen->machine, 0);
638638}
639639
src/mame/drivers/astinvad.c
r2375r2376
272272   if (bits_gone_hi & 0x08) sample_start(5, SND_FLEET4, 0);
273273   if (bits_gone_hi & 0x10) sample_start(4, SND_UFOHIT, 0);
274274
275   screen_flip = (readinputport(3) & data & 0x20) ? 0xff : 0x00;
275   screen_flip = (input_port_read_indexed(machine, 3) & data & 0x20) ? 0xff : 0x00;
276276}
277277
278278
r2375r2376
303303
304304   if (bits_gone_hi & 0x04) sample_start(3, SND_INVADERHIT, 0);
305305
306   screen_flip = (readinputport(3) & data & 0x80) ? 0xff : 0x00;
306   screen_flip = (input_port_read_indexed(machine, 3) & data & 0x80) ? 0xff : 0x00;
307307}
308308
309309
src/mame/drivers/psikyosh.c
r2375r2376
404404{
405405   if (ACCESSING_BITS_24_31)
406406   {
407      return ((EEPROM_read_bit() << 28) | (readinputport(4) << 24)); /* EEPROM | Region */
407      return ((EEPROM_read_bit() << 28) | (input_port_read_indexed(machine, 4) << 24)); /* EEPROM | Region */
408408   }
409409
410410   logerror("Unk EEPROM read mask %x\n", mem_mask);
r2375r2376
419419
420420static READ32_HANDLER(io32_r)
421421{
422   return ((readinputport(0) << 24) | (readinputport(1) << 16) | (readinputport(2) << 8) | (readinputport(3) << 0));
422   return ((input_port_read_indexed(machine, 0) << 24) | (input_port_read_indexed(machine, 1) << 16) | (input_port_read_indexed(machine, 2) << 8) | (input_port_read_indexed(machine, 3) << 0));
423423}
424424
425425static WRITE32_HANDLER( paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w )
src/mame/drivers/darkhors.c
r2375r2376
234234static READ32_HANDLER( darkhors_eeprom_r )
235235{
236236   // bit 31?
237   return readinputport(4) | ((EEPROM_read_bit() & 1) << (7+16));
237   return input_port_read_indexed(machine, 4) | ((EEPROM_read_bit() & 1) << (7+16));
238238}
239239
240240static WRITE32_HANDLER( darkhors_eeprom_w )
r2375r2376
302302   int bit_p1 = mask_to_bit((input_sel & 0x00ff0000) >> 16);
303303   int bit_p2 = mask_to_bit((input_sel & 0xff000000) >> 24);
304304
305   return   (readinputport(5 + bit_p1) & 0x00ffffff) |
306         (readinputport(5 + bit_p2) & 0xff000000) ;
305   return   (input_port_read_indexed(machine, 5 + bit_p1) & 0x00ffffff) |
306         (input_port_read_indexed(machine, 5 + bit_p2) & 0xff000000) ;
307307}
308308
309309static WRITE32_HANDLER( darkhors_unk1_w )
src/mame/drivers/bishjan.c
r2375r2376
224224
225225   for (i = 0; i < 5; i++)
226226      if (bishjan_input & (1 << i))
227         res = readinputport(4+i);
227         res = input_port_read_indexed(machine, 4+i);
228228
229229   return   (res << 8) |
230         readinputport(3) |
230         input_port_read_indexed(machine, 3) |
231231         ((bishjan_hopper && !(video_screen_get_frame_number(machine->primary_screen)%10)) ? 0x00 : 0x04)   // bit 2: hopper sensor
232232   ;
233233}
src/mame/drivers/offtwall.c
r2375r2376
9090
9191static READ16_HANDLER( special_port3_r )
9292{
93   int result = readinputport(3);
93   int result = input_port_read_indexed(machine, 3);
9494   if (atarigen_cpu_to_sound_ready) result ^= 0x0020;
9595   return result;
9696}
src/mame/drivers/upscope.c
r2375r2376
2424**********************************************************************************/
2525
2626#include "driver.h"
27#include "deprecat.h"
2728#include "includes/amiga.h"
2829
2930
r2375r2376
209210      if (data & 4)
210211      {
211212         if (LOG_IO) logerror("Internal register (%d) read\n", nvram_address_latch);
212         nvram_data_latch = (nvram_address_latch == 0) ? readinputportbytag("IO0") : 0xff;
213         nvram_data_latch = (nvram_address_latch == 0) ? input_port_read(Machine, "IO0") : 0xff;
213214      }
214215
215216      /* if SEL == 0, we read NVRAM */
src/mame/drivers/equites.c
r2375r2376
412412
413413static TIMER_CALLBACK( equites_frq_adjuster_callback )
414414{
415   UINT8 frq = readinputportbytag(FRQ_ADJUSTER_TAG);
415   UINT8 frq = input_port_read(machine, FRQ_ADJUSTER_TAG);
416416
417417   msm5232_set_clock(sndti_token(SOUND_MSM5232, 0), MSM5232_MIN_CLOCK + frq * (MSM5232_MAX_CLOCK - MSM5232_MIN_CLOCK) / 100);
418418//popmessage("8155: C %02x A %02x  AY: A %02x B %02x Unk:%x", eq8155_port_c,eq8155_port_a,ay_port_a,ay_port_b,eq_cymbal_ctrl&15);
r2375r2376
643643#if HVOLTAGE_DEBUG
644644static READ16_HANDLER(hvoltage_debug_r)
645645{
646   return(readinputport(2));
646   return(input_port_read_indexed(machine, 2));
647647}
648648#endif
649649
src/mame/drivers/neodrvr.c
r2375r2376
70387038
70397039static TIMER_CALLBACK( svcpcb_bios_timer_callback )
70407040{
7041   int harddip3 = readinputportbytag("HARDDIP") & 1;
7041   int harddip3 = input_port_read(machine, "HARDDIP") & 1;
70427042   memory_set_bankptr(NEOGEO_BANK_BIOS, memory_region(NEOGEO_REGION_MAIN_CPU_BIOS)+0x20000+harddip3*0x20000);
70437043}
70447044
src/mame/drivers/omegrace.c
r2375r2376
293293
294294static READ8_HANDLER( omegrace_spinner1_r )
295295{
296   return (spinnerTable[readinputport(4) & 0x3f]);
296   return (spinnerTable[input_port_read_indexed(machine, 4) & 0x3f]);
297297}
298298
299299
src/mame/drivers/decocass.c
r2375r2376
11181118      decrypted[A] = swap_bits_5_6(rom[A]);
11191119
11201120   /* Call the state save setup code in machine/decocass.c */
1121   decocass_machine_state_save_init();
1121   decocass_machine_state_save_init(machine);
11221122   /* and in video/decocass.c, too */
11231123   decocass_video_state_save_init();
11241124}
src/mame/drivers/mystwarr.c
r2375r2376
119119{
120120   if (ACCESSING_BITS_0_7)
121121   {
122      int res = readinputport(1) | EEPROM_read_bit();
122      int res = input_port_read_indexed(machine, 1) | EEPROM_read_bit();
123123
124124      if (init_eeprom_count)
125125      {
r2375r2376
139139{
140140   if (ACCESSING_BITS_0_7)
141141   {
142      int res = readinputport(1) | EEPROM_read_bit();
142      int res = input_port_read_indexed(machine, 1) | EEPROM_read_bit();
143143
144144      if (init_eeprom_count)
145145      {
r2375r2376
173173{
174174   if (ACCESSING_BITS_8_15)
175175   {
176      return (readinputport(1) | EEPROM_read_bit())<<8;
176      return (input_port_read_indexed(machine, 1) | EEPROM_read_bit())<<8;
177177   }
178178
179   return readinputport(3);
179   return input_port_read_indexed(machine, 3);
180180}
181181
182182static WRITE16_HANDLER( mmeeprom_w )
r2375r2376
316316
317317static READ16_HANDLER( player1_r )
318318{
319   return readinputport(2) | (readinputport(3)<<8);
319   return input_port_read_indexed(machine, 2) | (input_port_read_indexed(machine, 3)<<8);
320320}
321321
322322static READ16_HANDLER( player2_r )
323323{
324   return readinputport(4) | (readinputport(5)<<8);
324   return input_port_read_indexed(machine, 4) | (input_port_read_indexed(machine, 5)<<8);
325325}
326326
327327static READ16_HANDLER( mmplayer1_r )
328328{
329   return readinputport(2) | (readinputport(4)<<8);
329   return input_port_read_indexed(machine, 2) | (input_port_read_indexed(machine, 4)<<8);
330330}
331331
332332static READ16_HANDLER( mmplayer2_r )
333333{
334   return readinputport(3) | (readinputport(5)<<8);
334   return input_port_read_indexed(machine, 3) | (input_port_read_indexed(machine, 5)<<8);
335335}
336336
337337static READ16_HANDLER( mmcoins_r )
338338{
339   int res = readinputport(0);
339   int res = input_port_read_indexed(machine, 0);
340340
341341   if (init_eeprom_count)
342342   {
r2375r2376
349349
350350static READ16_HANDLER( dddcoins_r )
351351{
352   int res = (readinputport(0)<<8) | readinputport(2);
352   int res = (input_port_read_indexed(machine, 0)<<8) | input_port_read_indexed(machine, 2);
353353
354354   if (init_eeprom_count)
355355   {
r2375r2376
850850   GFXDECODE_ENTRY( REGION_GFX3, 0, bglayout_8bpp, 0x0000, 8 )
851851GFXDECODE_END
852852
853static STATE_POSTLOAD( mystwarr_postload )
854{
855   reset_sound_region();
856}
857
853858static MACHINE_START( mystwarr )
854859{
855860   /* set default bankswitch */
r2375r2376
860865
861866   state_save_register_global(mw_irq_control);
862867   state_save_register_global(cur_sound_region);
863   state_save_register_func_postload(reset_sound_region);
868   state_save_register_postload(machine, mystwarr_postload, NULL);
864869}
865870
866871static MACHINE_RESET(mystwarr)
src/mame/drivers/fromance.c
r2375r2376
203203   int ret = 0xff;
204204
205205   if (fromance_portselect & 0x01)
206      ret &= readinputport(4);
206      ret &= input_port_read_indexed(machine, 4);
207207   if (fromance_portselect & 0x02)
208      ret &= readinputport(5);
208      ret &= input_port_read_indexed(machine, 5);
209209   if (fromance_portselect & 0x04)
210      ret &= readinputport(6);
210      ret &= input_port_read_indexed(machine, 6);
211211   if (fromance_portselect & 0x08)
212      ret &= readinputport(7);
212      ret &= input_port_read_indexed(machine, 7);
213213   if (fromance_portselect & 0x10)
214      ret &= readinputport(8);
214      ret &= input_port_read_indexed(machine, 8);
215215
216216   return ret;
217217}
src/mame/drivers/dlair.c
r2375r2376
295295   if (laserdisc_type & LASERDISC_TYPE_VARIABLE)
296296   {
297297      laserdisc_type &= ~LASERDISC_TYPE_MASK;
298      laserdisc_type |= (readinputportbytag("DSW2") & 0x08) ? LASERDISC_TYPE_LDV1000 : LASERDISC_TYPE_PR7820;
298      laserdisc_type |= (input_port_read(machine, "DSW2") & 0x08) ? LASERDISC_TYPE_LDV1000 : LASERDISC_TYPE_PR7820;
299299   }
300300   laserdisc_reset(discinfo, laserdisc_type & LASERDISC_TYPE_MASK);
301301}
src/mame/drivers/skykid.c
r2375r2376
5353   switch (inputport_selected)
5454   {
5555      case 0x00:   /* DSW B (bits 0-4) */
56         return (readinputport(1) & 0xf8) >> 3; break;
56         return (input_port_read_indexed(machine, 1) & 0xf8) >> 3; break;
5757      case 0x01:   /* DSW B (bits 5-7), DSW A (bits 0-1) */
58         return ((readinputport(1) & 0x07) << 2) | ((readinputport(0) & 0xc0) >> 6); break;
58         return ((input_port_read_indexed(machine, 1) & 0x07) << 2) | ((input_port_read_indexed(machine, 0) & 0xc0) >> 6); break;
5959      case 0x02:   /* DSW A (bits 2-6) */
60         return (readinputport(0) & 0x3e) >> 1; break;
60         return (input_port_read_indexed(machine, 0) & 0x3e) >> 1; break;
6161      case 0x03:   /* DSW A (bit 7), DSW C (bits 0-3) */
62         return ((readinputport(0) & 0x01) << 4) | (readinputport(2) & 0x0f); break;
62         return ((input_port_read_indexed(machine, 0) & 0x01) << 4) | (input_port_read_indexed(machine, 2) & 0x0f); break;
6363      case 0x04:   /* coins, start */
64         return readinputport(3); break;
64         return input_port_read_indexed(machine, 3); break;
6565      case 0x05:   /* 2P controls */
66         return readinputport(5); break;
66         return input_port_read_indexed(machine, 5); break;
6767      case 0x06:   /* 1P controls */
68         return readinputport(4); break;
68         return input_port_read_indexed(machine, 4); break;
6969      default:
7070         return 0xff;
7171   }
src/mame/drivers/klax.c
r2375r2376
4747static void scanline_update(const device_config *screen, int scanline)
4848{
4949   /* generate 32V signals */
50   if ((scanline & 32) == 0 && !(readinputport(0) & 0x800))
50   if ((scanline & 32) == 0 && !(input_port_read_indexed(screen->machine, 0) & 0x800))
5151      atarigen_scanline_int_gen(screen->machine, 0);
5252}
5353
src/mame/drivers/halleys.c
r2375r2376
14301430   else
14311431      fillbitmap(bitmap, bgcolor, cliprect);
14321432
1433   if (readinputportbytag("FAKE")) copy_scroll_xp(bitmap, render_layer[3], *scrollx0, *scrolly0); // not used???
1433   if (input_port_read(screen->machine, "FAKE")) copy_scroll_xp(bitmap, render_layer[3], *scrollx0, *scrolly0); // not used???
14341434   copy_scroll_xp(bitmap, render_layer[2], *scrollx1, *scrolly1);
14351435   copy_fixed_2b (bitmap, render_layer[1]);
14361436   copy_fixed_xp (bitmap, render_layer[0]);
r2375r2376
15931593{
15941594   // This is a hack, but it lets you coin up when COIN1 or COIN2 are signaled.
15951595   // See NMI for the twisted logic that is involved in handling coin input.
1596   int inp = readinputportbytag("IN0");
1596   int inp = input_port_read(machine, "IN0");
15971597   int result = 0x01; // dual coin slots
15981598
15991599   if (inp & 0x80) result |= 0x02;
r2375r2376
16051605
16061606static READ8_HANDLER( io_mirror_r )
16071607{
1608   return(readinputport(offset + 3));
1608   return(input_port_read_indexed(machine, offset + 3));
16091609}
16101610
16111611
src/mame/drivers/gomoku.c
r2375r2376
5252
5353   res = 0;
5454   for (i = 0; i < 8; i++)
55      res |= ((readinputport(i) >> offset) & 1) << i;
55      res |= ((input_port_read_indexed(machine, i) >> offset) & 1) << i;
5656
5757   return res;
5858}
src/mame/drivers/djmain.c
r2375r2376
257257
258258static READ32_HANDLER( inp1_r )
259259{
260   UINT32 result = (readinputport(5)<<24) | (readinputport(2)<<16) | (readinputport(1)<<8) | readinputport(0);
260   UINT32 result = (input_port_read_indexed(machine, 5)<<24) | (input_port_read_indexed(machine, 2)<<16) | (input_port_read_indexed(machine, 1)<<8) | input_port_read_indexed(machine, 0);
261261
262262   return result;
263263}
264264
265265static READ32_HANDLER( inp2_r )
266266{
267   return (readinputport(3)<<24) | (readinputport(4)<<16) | 0xffff;
267   return (input_port_read_indexed(machine, 3)<<24) | (input_port_read_indexed(machine, 4)<<16) | 0xffff;
268268}
269269
270270static READ32_HANDLER( turntable_r )
r2375r2376
276276      UINT8 pos;
277277      int delta;
278278
279      pos = readinputport(6 + turntable_select);
279      pos = input_port_read_indexed(machine, 6 + turntable_select);
280280      delta = pos - turntable_last_pos[turntable_select];
281281      if (delta < -128)
282282         delta += 256;
r2375r2376
11831183 *
11841184 *************************************/
11851185
1186static STATE_POSTLOAD( djmain_postload )
1187{
1188   sndram_set_bank();
1189}
1190
11861191static MACHINE_START( djmain )
11871192{
11881193   UINT8 *region = memory_region(REGION_SOUND1);
r2375r2376
11931198   state_save_register_global(v_ctrl);
11941199   state_save_register_global_array(obj_regs);
11951200
1196   state_save_register_func_postload(sndram_set_bank);
1201   state_save_register_postload(machine, djmain_postload, NULL);
11971202}
11981203
11991204
src/mame/drivers/ssfindo.c
r2375r2376
335335         return (PS7500_IO[IRQSTA]&PS7500_IO[IRQMSKA])|0x80;
336336
337337      case IOCR: //TODO: nINT1, OD[n] p.81
338         return (input_port_0_r(machine,0)&0x80)|0x34|3;
338         return (input_port_read_indexed(machine, 0)&0x80)|0x34|3;
339339
340340      case VIDCR:
341341         return (PS7500_IO[offset]|0x50)&0xfffffff0;
src/mame/drivers/firetrk.c
r2375r2376
169169
170170static READ8_HANDLER( firetrk_dip_r )
171171{
172   UINT8 val0 = readinputportbytag("DIP_0");
173   UINT8 val1 = readinputportbytag("DIP_1");
172   UINT8 val0 = input_port_read(machine, "DIP_0");
173   UINT8 val1 = input_port_read(machine, "DIP_1");
174174
175175   if (val1 & (1 << (2 * offset + 0))) val0 |= 1;
176176   if (val1 & (1 << (2 * offset + 1))) val0 |= 2;
r2375r2376
181181
182182static READ8_HANDLER( montecar_dip_r )
183183{
184   UINT8 val0 = readinputportbytag("DIP_0");
185   UINT8 val1 = readinputportbytag("DIP_1");
184   UINT8 val0 = input_port_read(machine, "DIP_0");
185   UINT8 val1 = input_port_read(machine, "DIP_1");
186186
187187   if (val1 & (1 << (3 - offset))) val0 |= 1;
188188   if (val1 & (1 << (7 - offset))) val0 |= 2;
r2375r2376
244244   /* update steering wheels */
245245   for (i = 0; i < 2; i++)
246246   {
247      UINT32 new_dial = readinputportbytag_safe((i ? "STEER_2" : "STEER_1"), 0);
247      UINT32 new_dial = input_port_read_safe(machine, (i ? "STEER_2" : "STEER_1"), 0);
248248      INT32 delta = new_dial - dial[i];
249249
250250      if (delta != 0)
r2375r2376
256256      }
257257   }
258258
259   return ((readinputportbytag_safe("BIT_0", 0) & (1 << offset)) ? 0x01 : 0) |
260         ((readinputportbytag_safe("BIT_6", 0) & (1 << offset)) ? 0x40 : 0) |
261         ((readinputportbytag_safe("BIT_7", 0) & (1 << offset)) ? 0x80 : 0);
259   return ((input_port_read_safe(machine, "BIT_0", 0) & (1 << offset)) ? 0x01 : 0) |
260         ((input_port_read_safe(machine, "BIT_6", 0) & (1 << offset)) ? 0x40 : 0) |
261         ((input_port_read_safe(machine, "BIT_7", 0) & (1 << offset)) ? 0x80 : 0);
262262}
263263
264264
src/mame/drivers/peplus.c
r2375r2376
419419static READ8_HANDLER( peplus_crtc_lpen2_r )
420420{
421421    UINT8 ret_val = 0x00;
422    UINT8 x_val = readinputportbytag_safe("TOUCH_X",0x00);
423    UINT8 y_val = (0x19 - readinputportbytag_safe("TOUCH_Y",0x00));
422    UINT8 x_val = input_port_read_safe(machine, "TOUCH_X",0x00);
423    UINT8 y_val = (0x19 - input_port_read_safe(machine, "TOUCH_Y",0x00));
424424    UINT16 t_val = y_val * 0x28 + (x_val+1);
425425
426426   switch(vid_register) {
r2375r2376
530530      sda = i2cmem_read(0, I2CMEM_SDA);
531531   }
532532
533   if ((readinputportbytag_safe("SENSOR",0x00) & 0x01) == 0x01 && coin_state == 0) {
533   if ((input_port_read_safe(machine, "SENSOR",0x00) & 0x01) == 0x01 && coin_state == 0) {
534534      coin_state = 1; // Start Coin Cycle
535535      last_cycles = activecpu_gettotalcycles();
536536   } else {
r2375r2376
566566   }
567567
568568   if (curr_cycles - last_door > 6000) { // Guessing with 6000
569      if ((readinputportbytag_safe("DOOR",0xff) & 0x01) == 0x01) {
569      if ((input_port_read_safe(machine, "DOOR",0xff) & 0x01) == 0x01) {
570570         door_open = (!door_open & 0x01);
571571      } else {
572572         door_open = 1;
r2375r2376
963963    autohold_addr = 0x5e7e; // AutoHold Address
964964
965965    if (autohold_addr)
966        program_ram[autohold_addr] = readinputportbytag_safe("AUTOHOLD",0x00) & 0x01;
966        program_ram[autohold_addr] = input_port_read_safe(machine, "AUTOHOLD",0x00) & 0x01;
967967*/
968968}
969969
src/mame/drivers/segas24.c
r2375r2376
510510{
511511   switch(port) {
512512   case 0:
513      return readinputport(0);
513      return input_port_read_indexed(machine, 0);
514514   case 1:
515      return readinputport(1);
515      return input_port_read_indexed(machine, 1);
516516   case 2:
517517      return 0xff;
518518   case 3:
519519      return 0xff;
520520   case 4:
521      return readinputport(2);
521      return input_port_read_indexed(machine, 2);
522522   case 5: // Dip switches
523      return readinputport(3);
523      return input_port_read_indexed(machine, 3);
524524   case 6:
525      return readinputport(4);
525      return input_port_read_indexed(machine, 4);
526526   case 7: // DAC
527527      return 0xff;
528528   }
r2375r2376
534534   switch(port) {
535535   case 0: {
536536      static const UINT8 pos[16] = { 0, 1, 3, 2, 6, 4, 12, 8, 9 };
537      return (readinputport(0) & 0xf) | ((~pos[readinputport(5)>>4]<<4) & 0xf0);
537      return (input_port_read_indexed(machine, 0) & 0xf) | ((~pos[input_port_read_indexed(machine, 5)>>4]<<4) & 0xf0);
538538   }
539539   case 1:
540      return readinputport(1);
540      return input_port_read_indexed(machine, 1);
541541   case 2:
542542      return 0xff;
543543   case 3:
544544      return 0xff;
545545   case 4:
546      return readinputport(2);
546      return input_port_read_indexed(machine, 2);
547547   case 5: // Dip switches
548      return readinputport(3);
548      return input_port_read_indexed(machine, 3);
549549   case 6:
550      return readinputport(4);
550      return input_port_read_indexed(machine, 4);
551551   case 7: // DAC
552552      return 0xff;
553553   }
r2375r2376
564564   case 1:
565565      return 0xff;
566566   case 2:
567      return readinputport(cur_input_line);
567      return input_port_read_indexed(machine, cur_input_line);
568568   case 3:
569569      return 0xff;
570570   case 4:
571      return readinputport(8);
571      return input_port_read_indexed(machine, 8);
572572   case 5: // Dip switches
573      return readinputport(9);
573      return input_port_read_indexed(machine, 9);
574574   case 6:
575      return readinputport(10);
575      return input_port_read_indexed(machine, 10);
576576   case 7: // DAC
577577      return 0xff;
578578   }
r2375r2376
583583{
584584   switch(port) {
585585   case 0:
586      return readinputport(0);
586      return input_port_read_indexed(machine, 0);
587587   case 1:
588      return readinputport(1);
588      return input_port_read_indexed(machine, 1);
589589   case 2: // P3 inputs
590      return readinputport(2);
590      return input_port_read_indexed(machine, 2);
591591   case 3:
592592      return 0xff;
593593   case 4:
594      return readinputport(3);
594      return input_port_read_indexed(machine, 3);
595595   case 5: // Dip switches
596      return readinputport(4);
596      return input_port_read_indexed(machine, 4);
597597   case 6:
598      return readinputport(5);
598      return input_port_read_indexed(machine, 5);
599599   case 7: // DAC
600600      return 0xff;
601601   }
r2375r2376
636636{
637637   if(ACCESSING_BITS_0_7) {
638638      data &= 3;
639      hotrod_ctrl_cur = readinputport(9+data);
639      hotrod_ctrl_cur = input_port_read_indexed(machine, 9+data);
640640   }
641641}
642642
r2375r2376
646646      switch(offset) {
647647         // Steering dials
648648      case 0:
649         return readinputport(5) & 0xff;
649         return input_port_read_indexed(machine, 5) & 0xff;
650650      case 1:
651         return readinputport(5) >> 8;
651         return input_port_read_indexed(machine, 5) >> 8;
652652      case 2:
653         return readinputport(6) & 0xff;
653         return input_port_read_indexed(machine, 6) & 0xff;
654654      case 3:
655         return readinputport(6) >> 8;
655         return input_port_read_indexed(machine, 6) >> 8;
656656      case 4:
657         return readinputport(7) & 0xff;
657         return input_port_read_indexed(machine, 7) & 0xff;
658658      case 5:
659         return readinputport(7) >> 8;
659         return input_port_read_indexed(machine, 7) >> 8;
660660      case 6:
661         return readinputport(8) & 0xff;
661         return input_port_read_indexed(machine, 8) & 0xff;
662662      case 7:
663         return readinputport(8) >> 8;
663         return input_port_read_indexed(machine, 8) >> 8;
664664
665665      case 8: { // Serial ADCs for the accel
666666         int v = hotrod_ctrl_cur & 0x80;
src/mame/drivers/namcoic.c
r2375r2376
16011601   }
16021602}
16031603
1604static void
1605RoadMarkAllDirty(void)
1604static STATE_POSTLOAD( RoadMarkAllDirty )
16061605{
16071606   memset( mpRoadDirty,0x01,ROAD_TILE_COUNT_MAX );
16081607   mbRoadSomethingIsDirty = 1;
r2375r2376
16321631
16331632               state_save_register_global_pointer(mpRoadDirty, ROAD_TILE_COUNT_MAX);
16341633               state_save_register_global_pointer(mpRoadRAM,   0x20000 / 2);
1635               state_save_register_func_postload(RoadMarkAllDirty);
1634               state_save_register_postload(machine, RoadMarkAllDirty, NULL);
16361635
16371636      }
16381637   }
src/mame/drivers/ddayjlc.c
r2375r2376
114114
115115static READ8_HANDLER(prot_r)
116116{
117   return (input_port_1_r(machine,0)&0x1f)|protData[protAdr];
117   return (input_port_read_indexed(machine, 1)&0x1f)|protData[protAdr];
118118}
119119
120120static WRITE8_HANDLER(prot_w)
src/mame/drivers/segas16a.c
r2375r2376
279279         return ppi8255_0_r(machine, offset & 3);
280280
281281      case 0x1000/2:
282         return readinputport(offset & 3);
282         return input_port_read_indexed(machine, offset & 3);
283283
284284      case 0x2000/2:
285         return readinputport(4 + (offset & 1));
285         return input_port_read_indexed(machine, 4 + (offset & 1));
286286   }
287287   logerror("%06X:standard_io_r - unknown read access to address %04X\n", activecpu_get_pc(), offset * 2);
288288   return 0xffff;
r2375r2376
580580            {
581581               switch (video_control & 0xf)
582582               {
583                  case 0x00: return readinputportbytag("P1");
584                  case 0x04: return readinputportbytag("ANALOGX1");
585                  case 0x08: return readinputportbytag("ANALOGY1");
586                  case 0x0c: return readinputportbytag("UNUSED");
583                  case 0x00: return input_port_read(machine, "P1");
584                  case 0x04: return input_port_read(machine, "ANALOGX1");
585                  case 0x08: return input_port_read(machine, "ANALOGY1");
586                  case 0x0c: return input_port_read(machine, "UNUSED");
587587               }
588588               break;
589589            }
590590
591591            case 0x02:
592               return readinputportbytag("DIAL1") | (readinputportbytag("DIAL2") << 4);
592               return input_port_read(machine, "DIAL1") | (input_port_read(machine, "DIAL2") << 4);
593593
594594            case 0x03:
595595            {
596596               switch (video_control & 0xf)
597597               {
598                  case 0x00: return readinputportbytag("P2");
599                  case 0x04: return readinputportbytag("ANALOGX2");
600                  case 0x08: return readinputportbytag("ANALOGY2");
601                  case 0x0c: return readinputportbytag("POW2");
598                  case 0x00: return input_port_read(machine, "P2");
599                  case 0x04: return input_port_read(machine, "ANALOGX2");
600                  case 0x08: return input_port_read(machine, "ANALOGY2");
601                  case 0x0c: return input_port_read(machine, "POW2");
602602               }
603603               break;
604604            }
r2375r2376
628628            /* upper bit of the trackball controls */
629629            case 0:
630630            {
631               UINT8 buttons = readinputportbytag("SERVICE");
632               UINT8 analog1 = readinputportbytag((video_control & 4) ? "ANALOGY1" : "ANALOGX1");
633               UINT8 analog2 = readinputportbytag((video_control & 4) ? "ANALOGY2" : "ANALOGX2");
631               UINT8 buttons = input_port_read(machine, "SERVICE");
632               UINT8 analog1 = input_port_read(machine, (video_control & 4) ? "ANALOGY1" : "ANALOGX1");
633               UINT8 analog2 = input_port_read(machine, (video_control & 4) ? "ANALOGY2" : "ANALOGX2");
634634               buttons |= (analog1 & 0x80) >> 1;
635635               buttons |= (analog2 & 0x80);
636636               return buttons;
r2375r2376
640640            /* player 1 select switch mapped to bit 7 */
641641            case 1:
642642            {
643               UINT8 buttons = readinputportbytag("BUTTONS1");
644               UINT8 analog = readinputportbytag((video_control & 4) ? "ANALOGY1" : "ANALOGX1");
643               UINT8 buttons = input_port_read(machine, "BUTTONS1");
644               UINT8 analog = input_port_read(machine, (video_control & 4) ? "ANALOGY1" : "ANALOGX1");
645645               return (buttons & 0x80) | (analog & 0x7f);
646646            }
647647
r2375r2376
649649            case 2:
650650            {
651651               if (video_control & 4)
652                  return (readinputportbytag("ANALOGZ1") >> 4) | (readinputportbytag("ANALOGZ2") & 0xf0);
652                  return (input_port_read(machine, "ANALOGZ1") >> 4) | (input_port_read(machine, "ANALOGZ2") & 0xf0);
653653               else
654654               {
655655                  static UINT8 last_buttons1 = 0;
656656                  static UINT8 last_buttons2 = 0;
657                  UINT8 buttons1 = readinputportbytag("BUTTONS1");
658                  UINT8 buttons2 = readinputportbytag("BUTTONS2");
657                  UINT8 buttons1 = input_port_read(machine, "BUTTONS1");
658                  UINT8 buttons2 = input_port_read(machine, "BUTTONS2");
659659
660660                  if (!(buttons1 & 0x01))
661661                     last_buttons1 = 0;
r2375r2376
683683            /* player 2 select switch mapped to bit 7 */
684684            case 3:
685685            {
686               UINT8 buttons = readinputportbytag("BUTTONS2");
687               UINT8 analog = readinputportbytag((video_control & 4) ? "ANALOGY2" : "ANALOGX2");
686               UINT8 buttons = input_port_read(machine, "BUTTONS2");
687               UINT8 analog = input_port_read(machine, (video_control & 4) ? "ANALOGY2" : "ANALOGX2");
688688               return (buttons & 0x80) | (analog & 0x7f);
689689            }
690690         }
r2375r2376
714714            case 1:
715715               switch ((read_port++)&3)
716716               {
717                  case 0: return readinputportbytag("P1");
718                  case 1: return readinputportbytag("P2");
719                  case 2: return readinputportbytag("P3");
720                  case 3: return readinputportbytag("P4");
717                  case 0: return input_port_read(machine, "P1");
718                  case 1: return input_port_read(machine, "P2");
719                  case 2: return input_port_read(machine, "P3");
720                  case 3: return input_port_read(machine, "P4");
721721               }
722722
723723               break;
r2375r2376
740740      case 0x1000/2:
741741         switch (offset & 3)
742742         {
743            case 1:   return readinputportbytag((video_control & 4) ? "ANALOGY1" : "ANALOGX1");
744            case 3:   return readinputportbytag((video_control & 4) ? "ANALOGY2" : "ANALOGX2");
743            case 1:   return input_port_read(machine, (video_control & 4) ? "ANALOGY1" : "ANALOGX1");
744            case 3:   return input_port_read(machine, (video_control & 4) ? "ANALOGY2" : "ANALOGX2");
745745         }
746746         break;
747747   }
r2375r2376
765765         switch (offset & 3)
766766         {
767767            case 1:
768               if (readinputportbytag_safe(portname[mj_input_num], 0xff) != 0xff)
768               if (input_port_read_safe(machine, portname[mj_input_num], 0xff) != 0xff)
769769                  return 0xff & ~(1 << mj_input_num);
770770               return 0xff;
771771
772772            case 2:
773               return readinputportbytag_safe(portname[mj_input_num], 0xff);
773               return input_port_read_safe(machine, portname[mj_input_num], 0xff);
774774         }
775775         break;
776776   }
src/mame/drivers/neogeo.c
r2375r2376
332332
333333   sprintf(tag, "IN%s-%d", (const char *)param, controller_select & 0x01);
334334
335   return readinputportbytag(tag);
335   return input_port_read(machine, tag);
336336}
337337
338338
r2375r2376
351351   {
352352   default:
353353   case 0x00: ret = 0x0000; break; /* nothing? */
354   case 0x09: ret = readinputportbytag("MAHJONG1"); break;
355   case 0x12: ret = readinputportbytag("MAHJONG2"); break;
356   case 0x1b: ret = readinputportbytag("MAHJONG3"); break; /* player 1 normal inputs? */
357   case 0x24: ret = readinputportbytag("MAHJONG4"); break;
354   case 0x09: ret = input_port_read(machine, "MAHJONG1"); break;
355   case 0x12: ret = input_port_read(machine, "MAHJONG2"); break;
356   case 0x1b: ret = input_port_read(machine, "MAHJONG3"); break; /* player 1 normal inputs? */
357   case 0x24: ret = input_port_read(machine, "MAHJONG4"); break;
358358   }
359359
360360   return ret;
r2375r2376
817817      switch (offset & 0x07)
818818      {
819819      default:
820      case 0x00: neogeo_set_screen_dark(bit); break;
820      case 0x00: neogeo_set_screen_dark(machine, bit); break;
821821      case 0x01: set_main_cpu_vector_table_source(bit);
822822               set_audio_cpu_rom_source(bit); /* this is a guess */
823823               break;
824824      case 0x05: neogeo_set_fixed_layer_source(bit); break;
825825      case 0x06: set_save_ram_unlock(bit); break;
826      case 0x07: neogeo_set_palette_bank(bit); break;
826      case 0x07: neogeo_set_palette_bank(machine, bit); break;
827827
828828      case 0x02: /* unknown - HC32 middle pin 1 */
829829      case 0x03: /* unknown - uPD4990 pin ? */
r2375r2376
944944 *
945945 *************************************/
946946
947static STATE_POSTLOAD( neogeo_postload )
948{
949   _set_main_cpu_bank_address();
950   _set_main_cpu_vector_table_source();
951   set_audio_cpu_banking();
952   _set_audio_cpu_rom_source();
953   set_outputs();
954}
955
947956static MACHINE_START( neogeo )
948957{
949958   /* set the BIOS bank */
r2375r2376
987996   state_save_register_global(led1_value);
988997   state_save_register_global(led2_value);
989998
990   state_save_register_func_postload(_set_main_cpu_bank_address);
991   state_save_register_func_postload(_set_main_cpu_vector_table_source);
992   state_save_register_func_postload(set_audio_cpu_banking);
993   state_save_register_func_postload(_set_audio_cpu_rom_source);
994   state_save_register_func_postload(set_outputs);
999   state_save_register_postload(machine, neogeo_postload, NULL);
9951000}
9961001
9971002
src/mame/drivers/konamigx.c
r2375r2376
489489   //      excpuint stat, objdma stat, eeprom do
490490
491491   // note: racin' force expects bit 1 of the eeprom port to toggle
492   return(readinputport(6)<<24 | readinputport(7)<<16 | readinputport(0)<<8 | EEPROM_read_bit() | gx_rdport1_3);
492   return(input_port_read_indexed(machine, 6)<<24 | input_port_read_indexed(machine, 7)<<16 | input_port_read_indexed(machine, 0)<<8 | EEPROM_read_bit() | gx_rdport1_3);
493493}
494494
495495static WRITE32_HANDLER( eeprom_w )
r2375r2376
870870   switch( input )
871871   {
872872   case ADC083X_CH0:
873      return ( (double)5 * readinputport( 9 ) ) / 255; // steer
873      return ( (double)5 * input_port_read_indexed(Machine, 9 ) ) / 255; // steer
874874   case ADC083X_CH1:
875      return ( (double)5 * readinputport( 10 ) ) / 255; // gas
875      return ( (double)5 * input_port_read_indexed(Machine, 10 ) ) / 255; // gas
876876   case ADC083X_VREF:
877877      return 5;
878878   }
r2375r2376
881881
882882static READ32_HANDLER( le2_gun_H_r )
883883{
884   int p1x = readinputport(9)*287/0xff+22;
885   int p2x = readinputport(11)*287/0xff+22;
884   int p1x = input_port_read_indexed(machine, 9)*287/0xff+22;
885   int p2x = input_port_read_indexed(machine, 11)*287/0xff+22;
886886
887887   return (p1x<<16)|p2x;
888888}
889889
890890static READ32_HANDLER( le2_gun_V_r )
891891{
892   int p1y = readinputport(10)*223/0xff+1;
893   int p2y = readinputport(12)*223/0xff+1;
892   int p1y = input_port_read_indexed(machine, 10)*223/0xff+1;
893   int p2y = input_port_read_indexed(machine, 12)*223/0xff+1;
894894
895895   return (p1y<<16)|p2y;
896896}
897897
898898static READ32_HANDLER( service_r )
899899{
900   int res = (readinputport(1)<<24) | (readinputport(8)<<8);
900   int res = (input_port_read_indexed(machine, 1)<<24) | (input_port_read_indexed(machine, 8)<<8);
901901
902902   if (init_eeprom_count)
903903   {
r2375r2376
910910
911911static READ32_HANDLER( players_r )
912912{
913   return (readinputport(2)<<24) | (readinputport(3)<<16) | (readinputport(4)<<8) | (readinputport(5));
913   return (input_port_read_indexed(machine, 2)<<24) | (input_port_read_indexed(machine, 3)<<16) | (input_port_read_indexed(machine, 4)<<8) | (input_port_read_indexed(machine, 5));
914914}
915915
916916
src/mame/drivers/segahang.c
r2375r2376
3939
4040static UINT8 adc_select;
4141
42static void (*i8751_vblank_hook)(void);
42static void (*i8751_vblank_hook)(running_machine *machine);
4343
4444
4545
r2375r2376
150150         return ppi8255_0_r(machine, offset & 3);
151151
152152      case 0x1000/2: /* Input ports and DIP switches */
153         return readinputport(offset & 3);
153         return input_port_read_indexed(machine, offset & 3);
154154
155155      case 0x3000/2: /* PPI @ 4C */
156156         return ppi8255_1_r(machine, offset & 3);
157157
158158      case 0x3020/2: /* ADC0804 data output */
159         return readinputport(4 + adc_select);
159         return input_port_read_indexed(machine, 4 + adc_select);
160160   }
161161
162162   logerror("%06X:hangon_io_r - unknown read access to address %04X\n", activecpu_get_pc(), offset * 2);
r2375r2376
195195         return ppi8255_0_r(machine, offset & 3);
196196
197197      case 0x0010/2: /* Input ports and DIP switches */
198         return readinputport(offset & 3);
198         return input_port_read_indexed(machine, offset & 3);
199199
200200      case 0x0020/2: /* PPI @ 4C */
201201         if (offset == 2) return 0;
202202         return ppi8255_1_r(machine, offset & 3);
203203
204204      case 0x0030/2: /* ADC0804 data output */
205         return readinputport(4 + adc_select);
205         return input_port_read_indexed(machine, 4 + adc_select);
206206   }
207207
208208   logerror("%06X:sharrier_io_r - unknown read access to address %04X\n", activecpu_get_pc(), offset * 2);
r2375r2376
312312{
313313   /* if we have a fake 8751 handler, call it on VBLANK */
314314   if (i8751_vblank_hook != NULL)
315      (*i8751_vblank_hook)();
315      (*i8751_vblank_hook)(machine);
316316   irq4_line_hold(machine, cpunum);
317317}
318318
r2375r2376
324324 *
325325 *************************************/
326326
327static void sharrier_i8751_sim(void)
327static void sharrier_i8751_sim(running_machine *machine)
328328{
329   workram[0x492/2] = (readinputport(4) << 8) | readinputport(5);
329   workram[0x492/2] = (input_port_read_indexed(machine, 4) << 8) | input_port_read_indexed(machine, 5);
330330}
331331
332332
src/mame/drivers/thunderj.c
r2375r2376
7878
7979static READ16_HANDLER( special_port2_r )
8080{
81   int result = readinputport(2);
81   int result = input_port_read_indexed(machine, 2);
8282
8383   if (atarigen_sound_to_cpu_ready) result ^= 0x0004;
8484   if (atarigen_cpu_to_sound_ready) result ^= 0x0008;
src/mame/drivers/ultraman.c
r2375r2376
110110
111111
112112
113static ADDRESS_MAP_START( ultraman_readmem, ADDRESS_SPACE_PROGRAM, 16 )
114   AM_RANGE(0x000000, 0x03ffff) AM_READ(SMH_ROM)            /* ROM */
115   AM_RANGE(0x080000, 0x08ffff) AM_READ(SMH_RAM)            /* RAM */
116   AM_RANGE(0x180000, 0x183fff) AM_READ(SMH_RAM)            /* Palette */
113static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 )
114   AM_RANGE(0x000000, 0x03ffff) AM_ROM
115   AM_RANGE(0x080000, 0x08ffff) AM_RAM
116   AM_RANGE(0x180000, 0x183fff) AM_RAM AM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE(&paletteram16)/* Palette */
117117   AM_RANGE(0x1c0000, 0x1c0001) AM_READ(input_port_0_word_r)   /* Coins + Service */
118118   AM_RANGE(0x1c0002, 0x1c0003) AM_READ(input_port_1_word_r)   /* 1P controls */
119119   AM_RANGE(0x1c0004, 0x1c0005) AM_READ(input_port_2_word_r)   /* 2P controls */
120120   AM_RANGE(0x1c0006, 0x1c0007) AM_READ(input_port_3_word_r)   /* DIPSW #1 */
121121   AM_RANGE(0x1c0008, 0x1c0009) AM_READ(input_port_4_word_r)   /* DIPSW #2 */
122   AM_RANGE(0x204000, 0x204fff) AM_READ(ultraman_K051316_0_r)   /* K051316 #0 RAM */
123   AM_RANGE(0x205000, 0x205fff) AM_READ(ultraman_K051316_1_r)   /* K051316 #1 RAM */
124   AM_RANGE(0x206000, 0x206fff) AM_READ(ultraman_K051316_2_r)   /* K051316 #2 RAM */
125   AM_RANGE(0x304000, 0x30400f) AM_READ(ultraman_K051937_r)      /* Sprite control */
126   AM_RANGE(0x304800, 0x304fff) AM_READ(ultraman_K051960_r)      /* Sprite RAM */
127ADDRESS_MAP_END
128
129static ADDRESS_MAP_START( ultraman_writemem, ADDRESS_SPACE_PROGRAM, 16 )
130   AM_RANGE(0x000000, 0x03ffff) AM_WRITE(SMH_ROM)               /* ROM */
131   AM_RANGE(0x080000, 0x08ffff) AM_WRITE(SMH_RAM)               /* RAM */
132   AM_RANGE(0x180000, 0x183fff) AM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE(&paletteram16)/* Palette */
133122   AM_RANGE(0x1c0018, 0x1c0019) AM_WRITE(ultraman_gfxctrl_w)   /* counters + gfx ctrl */
134123   AM_RANGE(0x1c0020, 0x1c0021) AM_WRITE(sound_cmd_w)
135124   AM_RANGE(0x1c0028, 0x1c0029) AM_WRITE(sound_irq_trigger_w)
136125   AM_RANGE(0x1c0030, 0x1c0031) AM_WRITE(watchdog_reset16_w)
137   AM_RANGE(0x204000, 0x204fff) AM_WRITE(ultraman_K051316_0_w)      /* K051316 #0 RAM */
138   AM_RANGE(0x205000, 0x205fff) AM_WRITE(ultraman_K051316_1_w)      /* K051316 #1 RAM */
139   AM_RANGE(0x206000, 0x206fff) AM_WRITE(ultraman_K051316_2_w)      /* K051316 #2 RAM */
140   AM_RANGE(0x207f80, 0x207f9f) AM_WRITE(ultraman_K051316_ctrl_0_w   )   /* K051316 #0 registers  */
126   AM_RANGE(0x204000, 0x204fff) AM_READWRITE(ultraman_K051316_0_r, ultraman_K051316_0_w)   /* K051316 #0 RAM */
127   AM_RANGE(0x205000, 0x205fff) AM_READWRITE(ultraman_K051316_1_r, ultraman_K051316_1_w)   /* K051316 #1 RAM */
128   AM_RANGE(0x206000, 0x206fff) AM_READWRITE(ultraman_K051316_2_r, ultraman_K051316_2_w)   /* K051316 #2 RAM */
129   AM_RANGE(0x207f80, 0x207f9f) AM_WRITE(ultraman_K051316_ctrl_0_w   )   /* K051316 #0 registers */
141130   AM_RANGE(0x207fa0, 0x207fbf) AM_WRITE(ultraman_K051316_ctrl_1_w   )   /* K051316 #1 registers */
142131   AM_RANGE(0x207fc0, 0x207fdf) AM_WRITE(ultraman_K051316_ctrl_2_w   )   /* K051316 #2 registers */
143   AM_RANGE(0x304000, 0x30400f) AM_WRITE(ultraman_K051937_w)         /* Sprite control */
144   AM_RANGE(0x304800, 0x304fff) AM_WRITE(ultraman_K051960_w)         /* Sprite RAM */
132   AM_RANGE(0x304000, 0x30400f) AM_READWRITE(ultraman_K051937_r, ultraman_K051937_w)      /* Sprite control */
133   AM_RANGE(0x304800, 0x304fff) AM_READWRITE(ultraman_K051960_r, ultraman_K051960_w)      /* Sprite RAM */
145134ADDRESS_MAP_END
146135
147static ADDRESS_MAP_START( ultraman_readmem_sound, ADDRESS_SPACE_PROGRAM, 8 )
148   AM_RANGE(0x0000, 0x7fff) AM_READ(SMH_ROM)               /* ROM */
149   AM_RANGE(0x8000, 0xbfff) AM_READ(SMH_RAM)               /* RAM */
150   AM_RANGE(0xc000, 0xc000) AM_READ(soundlatch_r)            /* Sound latch read */
151   AM_RANGE(0xe000, 0xe000) AM_READ(OKIM6295_status_0_r)      /* M6295 */
152   AM_RANGE(0xf001, 0xf001) AM_READ(YM2151_status_port_0_r)      /* YM2151 */
136static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
137   AM_RANGE(0x0000, 0x7fff) AM_ROM
138   AM_RANGE(0x8000, 0xbfff) AM_RAM
139   AM_RANGE(0xc000, 0xc000) AM_READ(soundlatch_r)   /* Sound latch read */
140//  AM_RANGE(0xd000, 0xd000) AM_WRITE(SMH_NOP)      /* ??? */
141   AM_RANGE(0xe000, 0xe000) AM_READWRITE(OKIM6295_status_0_r, OKIM6295_data_0_w)      /* M6295 */
142   AM_RANGE(0xf000, 0xf000) AM_WRITE(YM2151_register_port_0_w)                     /* YM2151 */
143   AM_RANGE(0xf001, 0xf001) AM_READWRITE(YM2151_status_port_0_r, YM2151_data_port_0_w)   /* YM2151 */
153144ADDRESS_MAP_END
154145
155static ADDRESS_MAP_START( ultraman_writemem_sound, ADDRESS_SPACE_PROGRAM, 8 )
156   AM_RANGE(0x0000, 0x7fff) AM_WRITE(SMH_ROM)               /* ROM */
157   AM_RANGE(0x8000, 0xbfff) AM_WRITE(SMH_RAM)               /* RAM */
158//  AM_RANGE(0xd000, 0xd000) AM_WRITE(SMH_NOP)                 /* ??? */
159   AM_RANGE(0xe000, 0xe000) AM_WRITE(OKIM6295_data_0_w)         /* M6295 */
160   AM_RANGE(0xf000, 0xf000) AM_WRITE(YM2151_register_port_0_w)   /* YM2151 */
161   AM_RANGE(0xf001, 0xf001) AM_WRITE(YM2151_data_port_0_w)      /* YM2151 */
162ADDRESS_MAP_END
163
164static ADDRESS_MAP_START( ultraman_writeport_sound, ADDRESS_SPACE_IO, 8 )
146static ADDRESS_MAP_START( sound_io_map, ADDRESS_SPACE_IO, 8 )
165147   ADDRESS_MAP_GLOBAL_MASK(0xff)
166148//  AM_RANGE(0x00, 0x00) AM_WRITE(SMH_NOP)                     /* ??? */
167149ADDRESS_MAP_END
r2375r2376
266248
267249   /* basic machine hardware */
268250   MDRV_CPU_ADD(M68000,24000000/2)      /* 12 MHz? */
269   MDRV_CPU_PROGRAM_MAP(ultraman_readmem,ultraman_writemem)
251   MDRV_CPU_PROGRAM_MAP(main_map,0)
270252   MDRV_CPU_VBLANK_INT("main", irq4_line_hold)
271253
272   MDRV_CPU_ADD(Z80,24000000/6)
273254   /* audio CPU */      /* 4 MHz? */
274   MDRV_CPU_PROGRAM_MAP(ultraman_readmem_sound,ultraman_writemem_sound)
275   MDRV_CPU_IO_MAP(0,ultraman_writeport_sound)
255   MDRV_CPU_ADD(Z80,24000000/6)
256   MDRV_CPU_PROGRAM_MAP(sound_map,0)
257   MDRV_CPU_IO_MAP(sound_io_map,0)
276258
277259   MDRV_INTERLEAVE(10)
278260
src/mame/drivers/ladybug.c
r2375r2376
154154
155155static CUSTOM_INPUT( ladybug_p1_control_r )
156156{
157   return readinputportbytag(LADYBUG_P1_CONTROL_PORT_TAG);
157   return input_port_read(machine, LADYBUG_P1_CONTROL_PORT_TAG);
158158}
159159
160160static CUSTOM_INPUT( ladybug_p2_control_r )
r2375r2376
162162   UINT32 ret;
163163
164164   /* upright cabinet only uses a single set of controls */
165   if (readinputportbytag("DSW0") & 0x20)
166      ret = readinputportbytag(LADYBUG_P2_CONTROL_PORT_TAG);
165   if (input_port_read(machine, "DSW0") & 0x20)
166      ret = input_port_read(machine, LADYBUG_P2_CONTROL_PORT_TAG);
167167   else
168      ret = readinputportbytag(LADYBUG_P1_CONTROL_PORT_TAG);
168      ret = input_port_read(machine, LADYBUG_P1_CONTROL_PORT_TAG);
169169
170170   return ret;
171171}
src/mame/drivers/quantum.c
r2375r2376
6060
6161static READ16_HANDLER( switches_r )
6262{
63   return (readinputport(0) | (avgdvg_done() ? 1 : 0));
63   return (input_port_read_indexed(machine, 0) | (avgdvg_done() ? 1 : 0));
6464}
6565
6666
6767static READ16_HANDLER( trackball_r )
6868{
69   return (readinputport(4) << 4) | readinputport(3);
69   return (input_port_read_indexed(machine, 4) << 4) | input_port_read_indexed(machine, 3);
7070}
7171
7272
7373static READ8_HANDLER( input_1_r )
7474{
75   return (readinputport(1) << (7 - (offset - POT0_C))) & 0x80;
75   return (input_port_read_indexed(machine, 1) << (7 - (offset - POT0_C))) & 0x80;
7676}
7777
7878
7979static READ8_HANDLER( input_2_r )
8080{
81   return (readinputport(2) << (7 - (offset - POT0_C))) & 0x80;
81   return (input_port_read_indexed(machine, 2) << (7 - (offset - POT0_C))) & 0x80;
8282}
8383
8484
src/mame/drivers/combatsc.c
r2375r2376
169169      {
170170         UINT8 curr;
171171
172         curr = readinputport(4 + i);
172         curr = input_port_read_indexed(machine, 4 + i);
173173
174174         dir[i] = curr - pos[i];
175175         sign[i] = dir[i] & 0x80;
src/mame/drivers/segac2.c
r2375r2376
372372
373373         /* otherwise, return an input port */
374374         if (offset == 0x04/2 && sound_banks)
375            return (readinputport(offset) & 0xbf) | (upd7759_0_busy_r(machine,0) << 6);
376         return readinputport(offset);
375            return (input_port_read_indexed(machine, offset) & 0xbf) | (upd7759_0_busy_r(machine,0) << 6);
376         return input_port_read_indexed(machine, offset);
377377
378378      /* 'SEGA' protection */
379379      case 0x10/2:
src/mame/drivers/starshp1.c
r2375r2376
1717
1818static INTERRUPT_GEN( starshp1_interrupt )
1919{
20   if ((readinputport(0) & 0x90) != 0x90)
20   if ((input_port_read_indexed(machine, 0) & 0x90) != 0x90)
2121      cpunum_set_input_line(machine, 0, 0, PULSE_LINE);
2222}
2323
r2375r2376
6969   switch (starshp1_analog_in_select)
7070   {
7171   case 0:
72      val = readinputport(4);
72      val = input_port_read_indexed(machine, 4);
7373      break;
7474   case 1:
75      val = readinputport(5);
75      val = input_port_read_indexed(machine, 5);
7676      break;
7777   case 2:
7878      val = 0x20; /* DAC feedback, not used */
7979      break;
8080   case 3:
81      val = readinputport(3);
81      val = input_port_read_indexed(machine, 3);
8282      break;
8383   }
8484
85   return (val & 0x3f) | readinputport(1);
85   return (val & 0x3f) | input_port_read_indexed(machine, 1);
8686}
8787
8888
8989static READ8_HANDLER( starshp1_port_2_r )
9090{
91   return readinputport(2) | (starshp1_collision_latch & 0x0f);
91   return input_port_read_indexed(machine, 2) | (starshp1_collision_latch & 0x0f);
9292}
9393
9494
src/mame/drivers/taito_f2.c
r2375r2376
38513851                      MACHINE DRIVERS
38523852***********************************************************/
38533853
3854static STATE_POSTLOAD( f2_postload )
3855{
3856   reset_sound_region();
3857}
3858
38543859static MACHINE_START( f2 )
38553860{
38563861   state_save_register_global(banknum);
3857   state_save_register_func_postload(reset_sound_region);
3862   state_save_register_postload(machine, f2_postload, NULL);
38583863}
38593864
38603865static MACHINE_RESET( qcrayon )
r2375r2376
59015906   state_save_register_global(yesnoj_dsw);
59025907}
59035908
5909static STATE_POSTLOAD( driveout_postload )
5910{
5911   reset_driveout_sound_region();
5912}
5913
59045914static DRIVER_INIT( driveout )
59055915{
59065916   state_save_register_global(driveout_sound_latch);
59075917   state_save_register_global(oki_bank);
5908   state_save_register_func_postload(reset_driveout_sound_region);
5918   state_save_register_postload(machine, driveout_postload, NULL);
59095919}
59105920
59115921
src/mame/drivers/gottlieb.c
r2375r2376
222222   {
223223      case 0:
224224      default:
225         joy = ((readinputportbytag("IN4") >> 0) & 0x0f);   /* joystick 1 */
225         joy = ((input_port_read(machine, "IN4") >> 0) & 0x0f);   /* joystick 1 */
226226         break;
227227      case 1:
228         joy = ((readinputportbytag("IN5") >> 0) & 0x0f);   /* joystick 2 */
228         joy = ((input_port_read(machine, "IN5") >> 0) & 0x0f);   /* joystick 2 */
229229         break;
230230      case 2:
231         joy = ((readinputportbytag("IN5") >> 4) & 0x0f);   /* joystick 3 */
231         joy = ((input_port_read(machine, "IN5") >> 4) & 0x0f);   /* joystick 3 */
232232         break;
233233   }
234234
235   return joy | (readinputportbytag("IN4") & 0xf0);
235   return joy | (input_port_read(machine, "IN4") & 0xf0);
236236}
237237
238238static WRITE8_HANDLER( reactor_output_w )
src/mame/drivers/homedata.c
r2375r2376
264264      {
265265         if (keyb & (1 << i))
266266         {
267            res = readinputport(3+i) & 0x3f;
267            res = input_port_read_indexed(machine, 3+i) & 0x3f;
268268            break;
269269         }
270270      }
r2375r2376
398398
399399static READ8_HANDLER( reikaids_io_r )
400400{
401   int res = readinputport(2);   // bit 4 = coin, bit 5 = service
401   int res = input_port_read_indexed(machine, 2);   // bit 4 = coin, bit 5 = service
402402
403403   res |= BIT(upd7807_portc,2) * 0x01;      // bit 0 = upd7807 status
404404   res |= BIT(upd7807_portc,6) * 0x02;      // bit 1 = upd7807 data
r2375r2376
468468
469469static READ8_HANDLER( pteacher_keyboard_r )
470470{
471   int dips = readinputport(0);
471   int dips = input_port_read_indexed(machine, 0);
472472
473473//  logerror("%04x: keyboard_r with port A = %02x\n",activecpu_get_pc(),upd7807_porta);
474474
r2375r2376
476476   {
477477      /* player 1 + dip switches */
478478      int row = (upd7807_porta & 0x07);
479      return readinputport(2 + row) | (((dips >> row) & 1) << 5);   // 0-5
479      return input_port_read_indexed(machine, 2 + row) | (((dips >> row) & 1) << 5);   // 0-5
480480   }
481481   if (upd7807_porta & 0x08)
482482   {
src/mame/drivers/exidy.c
r2375r2376
145145static CUSTOM_INPUT( teetert_input_direction_r )
146146{
147147   int result = 0;
148   UINT8 dial = readinputportbytag("DIAL");
148   UINT8 dial = input_port_read(machine, "DIAL");
149149
150150   if (dial != last_dial)
151151   {
r2375r2376
164164
165165static CUSTOM_INPUT( teetert_input_movement_r )
166166{
167   UINT8 dial = readinputportbytag("DIAL");
167   UINT8 dial = input_port_read(machine, "DIAL");
168168
169169   return (dial != last_dial) ? 1 : 0;
170170}
src/mame/drivers/xxmissio.c
r2375r2376
3838
3939static READ8_HANDLER( xxmissio_status_r )
4040{
41   xxmissio_status = (xxmissio_status | 2) & ( readinputportbytag("IN2") | 0xfd );
41   xxmissio_status = (xxmissio_status | 2) & ( input_port_read(machine, "IN2") | 0xfd );
4242   return xxmissio_status;
4343}
4444
src/mame/drivers/mugsmash.c
r2375r2376
161161   switch (offset)
162162   {
163163      case 0 :
164         data = (readinputport(0) & 0xff) | ((readinputport(3) & 0xc0) << 6) | ((readinputport(2) & 0x03) << 8);
164         data = (input_port_read_indexed(machine, 0) & 0xff) | ((input_port_read_indexed(machine, 3) & 0xc0) << 6) | ((input_port_read_indexed(machine, 2) & 0x03) << 8);
165165         break;
166166      case 1 :
167         data = (readinputport(1) & 0xff) | ((readinputport(3) & 0x3f) << 8);
167         data = (input_port_read_indexed(machine, 1) & 0xff) | ((input_port_read_indexed(machine, 3) & 0x3f) << 8);
168168         break;
169169      case 2 :
170         data = ((readinputport(4) & 0x3f) << 8);
170         data = ((input_port_read_indexed(machine, 4) & 0x3f) << 8);
171171         break;
172172      case 3 :
173         data = ((readinputport(4) & 0xc0) << 2);
173         data = ((input_port_read_indexed(machine, 4) & 0xc0) << 2);
174174         break;
175175   }
176176
src/mame/drivers/hng64.c
r2375r2376
729729      //SamSho64
730730//      case 0x00:  toggi^=1; if (toggi==1) {return 0x00000400;} else {return 0x00000300;};
731731      //RoadsEdge
732//      case 0x00:  return readinputportbytag("IPT_TEST");
732//      case 0x00:  return input_port_read(machine, "IPT_TEST");
733733
734734      //Fatfurwa
735735      case 0x00:  return 0x00000400;
736      case 0x04:  return readinputportbytag("IPT_NONE")       | (readinputportbytag("FATFURWA_TST_ETC")<<16);
737      case 0x08:  return readinputportbytag("FATFURWA_PLR_2") | (readinputportbytag("FATFURWA_PLR_1")<<16);
736      case 0x04:  return input_port_read(machine, "IPT_NONE")       | (input_port_read(machine, "FATFURWA_TST_ETC")<<16);
737      case 0x08:  return input_port_read(machine, "FATFURWA_PLR_2") | (input_port_read(machine, "FATFURWA_PLR_1")<<16);
738738
739739      // This takes care of the 'machine' error code
740740      case 0x600: return no_machine_error_code;
src/mame/drivers/macrossp.c
r2375r2376
236236
237237static READ32_HANDLER ( macrossp_ports1_r )
238238{
239   return ((readinputport(0) << 16) |  (readinputport(1) << 0));
239   return ((input_port_read_indexed(machine, 0) << 16) |  (input_port_read_indexed(machine, 1) << 0));
240240}
241241
242242static READ32_HANDLER ( macrossp_ports2_r )
243243{
244   return ((readinputport(2) << 16) |  (readinputport(3) << 0));
244   return ((input_port_read_indexed(machine, 2) << 16) |  (input_port_read_indexed(machine, 3) << 0));
245245}
246246
247247static WRITE32_HANDLER( paletteram32_macrossp_w )
src/mame/drivers/gladiatr.c
r2375r2376
216216
217217static READ8_HANDLER( gladiator_dsw1_r )
218218{
219   int orig = readinputportbytag("DSW1")^0xff;
219   int orig = input_port_read(machine, "DSW1")^0xff;
220220
221221   return BITSWAP8(orig, 0,1,2,3,4,5,6,7);
222222}
223223
224224static READ8_HANDLER( gladiator_dsw2_r )
225225{
226   int orig = readinputportbytag("DSW2")^0xff;
226   int orig = input_port_read(machine, "DSW2")^0xff;
227227
228228   return BITSWAP8(orig, 2,3,4,5,6,7,1,0);
229229}
r2375r2376
232232{
233233   int coins = 0;
234234
235   if( readinputportbytag("COINS") & 0xc0 ) coins = 0x80;
235   if( input_port_read(machine, "COINS") & 0xc0 ) coins = 0x80;
236236   switch(offset)
237237   {
238238   case 0x01: /* start button , coins */
239      return readinputportbytag("IN0") | coins;
239      return input_port_read(machine, "IN0") | coins;
240240   case 0x02: /* Player 1 Controller , coins */
241      return readinputportbytag("IN1") | coins;
241      return input_port_read(machine, "IN1") | coins;
242242   case 0x04: /* Player 2 Controller , coins */
243      return readinputportbytag("IN2") | coins;
243      return input_port_read(machine, "IN2") | coins;
244244   }
245245   /* unknown */
246246   return 0;
r2375r2376
251251   switch(offset)
252252   {
253253   case 0x01: /* button 3 */
254      return readinputportbytag("IN3");
254      return input_port_read(machine, "IN3");
255255   }
256256   /* unknown */
257257   return 0;
r2375r2376
278278/* YM2203 port A handler (input) */
279279static READ8_HANDLER( gladiator_dsw3_r )
280280{
281   return readinputportbytag("DSW3");
281   return input_port_read(machine, "DSW3");
282282}
283283/* YM2203 port B handler (output) */
284284static WRITE8_HANDLER( gladiator_int_control_w )
src/mame/drivers/imolagp.c
r2375r2376
371371   else
372372   {
373373      static int oldsteer;
374      int newsteer = readinputport(3)&0xf;
374      int newsteer = input_port_read_indexed(machine, 3)&0xf;
375375      if( newsteer!=oldsteer )
376376      {
377377         if( imola_steerlatch==0 )
src/mame/drivers/kinstb.c
r2375r2376
4646   static INT32 oldinput=0;
4747   INT32 coincnt;
4848#ifdef MAME_DEBUG
49   INT32   input=readinputport(13);
49   INT32   input=input_port_read_indexed(machine, 13);
5050#else
51   INT32   input=readinputport(10);
51   INT32   input=input_port_read_indexed(machine, 10);
5252#endif
5353
5454   if(input&3)
src/mame/drivers/moo.c
r2375r2376
9898   /* bit 1 is EEPROM ready */
9999   /* bit 3 is service button */
100100   /* bits 4-7 are DIP switches */
101   res = EEPROM_read_bit() | input_port_1_r(machine,0);
101   res = EEPROM_read_bit() | input_port_read_indexed(machine, 1);
102102
103103   if (init_eeprom_count)
104104   {
r2375r2376
261261
262262static READ16_HANDLER( player1_r )    // players 1 and 3
263263{
264   return input_port_2_r(machine,0) | (input_port_4_r(machine,0)<<8);
264   return input_port_read_indexed(machine, 2) | (input_port_read_indexed(machine, 4)<<8);
265265}
266266
267267static READ16_HANDLER( player2_r )   // players 2 and 4
268268{
269   return input_port_3_r(machine,0) | (input_port_5_r(machine,0)<<8);
269   return input_port_read_indexed(machine, 3) | (input_port_read_indexed(machine, 5)<<8);
270270}
271271
272272static WRITE16_HANDLER( moo_prot_w )
src/mame/drivers/eolith16.c
r2375r2376
4545static READ16_HANDLER( eolith16_custom_r )
4646{
4747   eolith_speedup_read();
48   return (readinputport(0) & ~0x10) | (EEPROM_read_bit() << 4);
48   return (input_port_read_indexed(machine, 0) & ~0x10) | (EEPROM_read_bit() << 4);
4949}
5050
5151
src/mame/drivers/taito_l.c
r2375r2376
533533   switch(mux_ctrl)
534534   {
535535   case 0:
536      return input_port_0_r(machine,0);
536      return input_port_read_indexed(machine, 0);
537537   case 1:
538      return input_port_1_r(machine,0);
538      return input_port_read_indexed(machine, 1);
539539   case 2:
540      return input_port_2_r(machine,0);
540      return input_port_read_indexed(machine, 2);
541541   case 3:
542      return input_port_3_r(machine,0);
542      return input_port_read_indexed(machine, 3);
543543   case 7:
544      return input_port_4_r(machine,0);
544      return input_port_read_indexed(machine, 4);
545545   default:
546546      logerror("Mux read from unknown port %d (%04x)\n", mux_ctrl, activecpu_get_pc());
547547      return 0xff;
r2375r2376
620620static READ8_HANDLER( horshoes_tracky_reset_r )
621621{
622622   /* reset the trackball counter */
623   tracky = readinputportbytag("AN0");
623   tracky = input_port_read(machine, "AN0");
624624   return 0;
625625}
626626
627627static READ8_HANDLER( horshoes_trackx_reset_r )
628628{
629629   /* reset the trackball counter */
630   trackx = readinputportbytag("AN1");
630   trackx = input_port_read(machine, "AN1");
631631   return 0;
632632}
633633
634634static READ8_HANDLER( horshoes_tracky_lo_r )
635635{
636   return (readinputportbytag("AN0") - tracky) & 0xff;
636   return (input_port_read(machine, "AN0") - tracky) & 0xff;
637637}
638638
639639static READ8_HANDLER( horshoes_tracky_hi_r )
640640{
641   return (readinputportbytag("AN0") - tracky) >> 8;
641   return (input_port_read(machine, "AN0") - tracky) >> 8;
642642}
643643
644644static READ8_HANDLER( horshoes_trackx_lo_r )
645645{
646   return (readinputportbytag("AN1") - trackx) & 0xff;
646   return (input_port_read(machine, "AN1") - trackx) & 0xff;
647647}
648648
649649static READ8_HANDLER( horshoes_trackx_hi_r )
650650{
651   return (readinputportbytag("AN1") - trackx) >> 8;
651   return (input_port_read(machine, "AN1") - trackx) >> 8;
652652}
653653
654654
src/mame/drivers/gamecstl.c
r2375r2376
428428
429429static const struct dma8237_interface dma8237_2_config =
430430{
431   0,
432   1.0e-6, // 1us
431   0,
432   1.0e-6, // 1us
433433
434434   NULL,
435435   NULL,
r2375r2376
650650   pic8259_set_irq_line(1, 6, state);
651651}
652652
653static int gamecstl_get_out2(running_machine *machine) {
654   return pit8253_get_output((device_config*)device_list_find_by_tag( machine->config->devicelist, PIT8254, "pit8254" ), 2 );
655}
656
653657static const struct kbdc8042_interface at8042 =
654658{
655   KBDC8042_AT386, set_gate_a20, keyboard_interrupt
659   KBDC8042_AT386, set_gate_a20, keyboard_interrupt, gamecstl_get_out2
656660};
657661
658662static const struct ide_interface ide_intf =
src/mame/drivers/cabal.c
r2375r2376
8787   int i;
8888
8989   for (i = 0;i < 4;i++)
90      last[i] = readinputport(3+i);
90      last[i] = input_port_read_indexed(machine, 3+i);
9191}
9292
9393static READ16_HANDLER( track_r )
r2375r2376
9595   switch (offset)
9696   {
9797      default:
98      case 0:   return (( readinputport(3) - last[0]) & 0x00ff)        | (((readinputport(5) - last[2]) & 0x00ff) << 8);   /* X lo */
99      case 1:   return (((readinputport(3) - last[0]) & 0xff00) >> 8) | (( readinputport(5) - last[2]) & 0xff00);      /* X hi */
100      case 2:   return (( readinputport(4) - last[1]) & 0x00ff)        | (((readinputport(6) - last[3]) & 0x00ff) << 8);   /* Y lo */
101      case 3:   return (((readinputport(4) - last[1]) & 0xff00) >> 8) | (( readinputport(6) - last[3]) & 0xff00);      /* Y hi */
98      case 0:   return (( input_port_read_indexed(machine, 3) - last[0]) & 0x00ff)        | (((input_port_read_indexed(machine, 5) - last[2]) & 0x00ff) << 8);   /* X lo */
99      case 1:   return (((input_port_read_indexed(machine, 3) - last[0]) & 0xff00) >> 8) | (( input_port_read_indexed(machine, 5) - last[2]) & 0xff00);      /* X hi */
100      case 2:   return (( input_port_read_indexed(machine, 4) - last[1]) & 0x00ff)        | (((input_port_read_indexed(machine, 6) - last[3]) & 0x00ff) << 8);   /* Y lo */
101      case 3:   return (((input_port_read_indexed(machine, 4) - last[1]) & 0xff00) >> 8) | (( input_port_read_indexed(machine, 6) - last[3]) & 0xff00);      /* Y hi */
102102   }
103103}
104104
src/mame/drivers/cidelsa.c
r2375r2376
3636        EF4     Coin 1
3737    */
3838
39   return readinputportbytag("EF");
39   return input_port_read(Machine, "EF");
4040}
4141
4242static void cidelsa_q_w(int q)
src/mame/drivers/tickee.c
r2375r2376
4343{
4444   const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen);
4545
46   *x = (((readinputport(4 + player * 2) & 0xff) * (visarea->max_x - visarea->min_x)) >> 8) + visarea->min_x;
47   *y = (((readinputport(5 + player * 2) & 0xff) * (visarea->max_y - visarea->min_y)) >> 8) + visarea->min_y;
46   *x = (((input_port_read_indexed(machine, 4 + player * 2) & 0xff) * (visarea->max_x - visarea->min_x)) >> 8) + visarea->min_x;
47   *y = (((input_port_read_indexed(machine, 5 + player * 2) & 0xff) * (visarea->max_y - visarea->min_y)) >> 8) + visarea->min_y;
4848}
4949
5050
src/mame/drivers/m92.c
r2375r2376
220220   memory_set_bankptr(1,&RAM[bankaddress]);
221221}
222222
223static STATE_POSTLOAD( m92_postload )
224{
225   set_m92_bank();
226}
227
223228static MACHINE_START( m92 )
224229{
225230   state_save_register_global(irqvector);
226231   state_save_register_global(sound_status);
227232   state_save_register_global(bankaddress);
228   state_save_register_func_postload(set_m92_bank);
233   state_save_register_postload(machine, m92_postload, NULL);
229234
230235   scanline_timer = timer_alloc(m92_scanline_interrupt, NULL);
231236}
src/mame/drivers/hal21.c
r2375r2376
551551
552552static READ8_HANDLER( CPUC_ready_r ) { snk_sound_busy_bit = 0; return 0; }
553553
554static READ8_HANDLER( hal21_input_port_0_r ) { return input_port_0_r(machine,0) | snk_sound_busy_bit; }
554static READ8_HANDLER( hal21_input_port_0_r ) { return input_port_read_indexed(machine, 0) | snk_sound_busy_bit; }
555555
556556static WRITE8_HANDLER( hal21_soundcommand_w ) { hal21_sound_scheduler(machine, 1, data); }
557557static WRITE8_HANDLER( hal21_soundack_w ) { hal21_sound_scheduler(machine,2, data); }
src/mame/drivers/vendetta.c
r2375r2376
150150
151151   res |= 0x02;//konami_eeprom_ack() << 5; /* add the ack */
152152
153   res |= readinputport( 3 ) & 0x0c; /* test switch */
153   res |= input_port_read_indexed(machine, 3 ) & 0x0c; /* test switch */
154154
155155   if (init_eeprom_count)
156156   {
src/mame/drivers/destroyr.c
r2375r2376
5050
5151   /* PCB supports two dials, but cab has only got one */
5252
53   timer_set(video_screen_get_time_until_pos(machine->primary_screen, readinputport(3), 0), NULL, 0, destroyr_dial_callback);
53   timer_set(video_screen_get_time_until_pos(machine->primary_screen, input_port_read_indexed(machine, 3), 0), NULL, 0, destroyr_dial_callback);
5454   timer_set(video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, destroyr_frame_callback);
5555}
5656
r2375r2376
137137
138138   if (offset == 0)
139139   {
140      UINT8 ret = readinputport(0);
140      UINT8 ret = input_port_read_indexed(machine, 0);
141141
142142      if (destroyr_potsense[0] && destroyr_potmask[0])
143143         ret |= 4;
r2375r2376
149149
150150   if (offset == 1)
151151   {
152      return readinputport(1);
152      return input_port_read_indexed(machine, 1);
153153   }
154154
155155   logerror("unmapped input port %d\n", offset);
src/mame/drivers/segas16b.c
r2375r2376
11201120   switch (offset & (0x3000/2))
11211121   {
11221122      case 0x1000/2:
1123         return readinputport(offset & 3);
1123         return input_port_read_indexed(machine, offset & 3);
11241124
11251125      case 0x2000/2:
1126         return readinputport(4 + (offset & 1));
1126         return input_port_read_indexed(machine, 4 + (offset & 1));
11271127   }
11281128   logerror("%06X:standard_io_r - unknown read access to address %04X\n", activecpu_get_pc(), offset * 2);
11291129   return segaic16_open_bus_r(machine,0,0);
r2375r2376
13791379   }
13801380
13811381   /* read inputs */
1382   workram[inputoffs] = ~readinputport(0) << 8;
1382   workram[inputoffs] = ~input_port_read_indexed(machine, 0) << 8;
13831383}
13841384
13851385static void altbeasj_i8751_sim(running_machine *machine)
r2375r2376
14581458   }
14591459
14601460   /* read inputs */
1461   workram[0x2cd0/2] = (readinputport(1) << 8) | readinputport(3);
1462   workram[0x2c96/2] = readinputport(0) << 8;
1461   workram[0x2cd0/2] = (input_port_read_indexed(machine, 1) << 8) | input_port_read_indexed(machine, 3);
1462   workram[0x2c96/2] = input_port_read_indexed(machine, 0) << 8;
14631463}
14641464
14651465
r2375r2376
14791479   }
14801480
14811481   /* read inputs */
1482   workram[0x01e6/2] = readinputport(0) << 8;
1483   workram[0x01e8/2] = readinputport(1) << 8;
1484   workram[0x01ea/2] = readinputport(3) << 8;
1482   workram[0x01e6/2] = input_port_read_indexed(machine, 0) << 8;
1483   workram[0x01e8/2] = input_port_read_indexed(machine, 1) << 8;
1484   workram[0x01ea/2] = input_port_read_indexed(machine, 3) << 8;
14851485}
14861486
14871487
r2375r2376
15181518   }
15191519
15201520   /* read inputs */
1521   workram[0x2082/2] = readinputport(0);
1521   workram[0x2082/2] = input_port_read_indexed(machine, 0);
15221522}
15231523
15241524
r2375r2376
15541554      case 0x3000/2:
15551555         switch ((offset/2) & 7)
15561556         {
1557            case 0:   return (readinputportbytag("ANALOGX1") << 4) >> (8 * (offset & 1));
1558            case 1:   return (readinputportbytag("ANALOGY1") << 4) >> (8 * (offset & 1));
1559            case 2:   return (readinputportbytag("ANALOGX2") << 4) >> (8 * (offset & 1));
1560            case 3:   return (readinputportbytag("ANALOGY2") << 4) >> (8 * (offset & 1));
1561            case 4:   return (readinputportbytag("ANALOGX3") << 4) >> (8 * (offset & 1));
1562            case 5:   return (readinputportbytag("ANALOGY3") << 4) >> (8 * (offset & 1));
1563            case 6:   return (readinputportbytag("ANALOGX4") << 4) >> (8 * (offset & 1));
1564            case 7:   return (readinputportbytag("ANALOGY4") << 4) >> (8 * (offset & 1));
1557            case 0:   return (input_port_read(machine, "ANALOGX1") << 4) >> (8 * (offset & 1));
1558            case 1:   return (input_port_read(machine, "ANALOGY1") << 4) >> (8 * (offset & 1));
1559            case 2:   return (input_port_read(machine, "ANALOGX2") << 4) >> (8 * (offset & 1));
1560            case 3:   return (input_port_read(machine, "ANALOGY2") << 4) >> (8 * (offset & 1));
1561            case 4:   return (input_port_read(machine, "ANALOGX3") << 4) >> (8 * (offset & 1));
1562            case 5:   return (input_port_read(machine, "ANALOGY3") << 4) >> (8 * (offset & 1));
1563            case 6:   return (input_port_read(machine, "ANALOGX4") << 4) >> (8 * (offset & 1));
1564            case 7:   return (input_port_read(machine, "ANALOGY4") << 4) >> (8 * (offset & 1));
15651565         }
15661566         break;
15671567   }
r2375r2376
16051605         switch (offset & 0x30/2)
16061606         {
16071607            case 0x20/2:
1608               hwc_input_value = readinputportbytag_safe(portname[offset & 3], 0xff);
1608               hwc_input_value = input_port_read_safe(machine, portname[offset & 3], 0xff);
16091609               break;
16101610
16111611            case 0x30/2:
r2375r2376
16371637      case 0x3000/2:
16381638         switch (offset & 3)
16391639         {
1640            case 0:   return readinputportbytag("P1");
1641            case 1:   return readinputportbytag("P2");
1642            case 2:   return readinputportbytag("P3");
1643            case 3:   return readinputportbytag("P4");
1640            case 0:   return input_port_read(machine, "P1");
1641            case 1:   return input_port_read(machine, "P2");
1642            case 2:   return input_port_read(machine, "P3");
1643            case 3:   return input_port_read(machine, "P4");
16441644         }
16451645         break;
16461646   }
r2375r2376
16621662      case 0x3000/2:
16631663         switch ((offset/2) & 3)
16641664         {
1665            case 0:   return readinputportbytag("ANALOGX1");
1666            case 1:   return readinputportbytag("ANALOGY1");
1667            case 2:   return readinputportbytag("ANALOGX2");
1668            case 3:   return readinputportbytag("ANALOGY2");
1665            case 0:   return input_port_read(machine, "ANALOGX1");
1666            case 1:   return input_port_read(machine, "ANALOGY1");
1667            case 2:   return input_port_read(machine, "ANALOGX2");
1668            case 3:   return input_port_read(machine, "ANALOGY2");
16691669         }
16701670         break;
16711671   }
r2375r2376
16891689         switch (offset & 3)
16901690         {
16911691            case 1:
1692               if (readinputportbytag_safe(portname[mj_input_num], 0xff) != 0xff)
1692               if (input_port_read_safe(machine, portname[mj_input_num], 0xff) != 0xff)
16931693                  return 0xff & ~(1 << mj_input_num);
16941694               return 0xff;
16951695
16961696            case 2:
1697               return readinputportbytag_safe(portname[mj_input_num], 0xff);
1697               return input_port_read_safe(machine, portname[mj_input_num], 0xff);
16981698         }
16991699         break;
17001700   }
src/mame/drivers/wwfwfest.c
r2375r2376
149149   switch (offset)
150150   {
151151   case 0x00:
152   tmp = readinputport(0) | readinputport(4) << 8;
152   tmp = input_port_read_indexed(machine, 0) | input_port_read_indexed(machine, 4) << 8;
153153   tmp &= 0xcfff;
154   tmp |= ((readinputport(7) & 0xc0) << 6);
154   tmp |= ((input_port_read_indexed(machine, 7) & 0xc0) << 6);
155155   break;
156156   case 0x01:
157   tmp = readinputport(1);
157   tmp = input_port_read_indexed(machine, 1);
158158   tmp &= 0xc0ff;
159   tmp |= ((readinputport(7) & 0x3f)<<8);
159   tmp |= ((input_port_read_indexed(machine, 7) & 0x3f)<<8);
160160   break;
161161   case 0x02:
162   tmp = readinputport(2);
162   tmp = input_port_read_indexed(machine, 2);
163163   tmp &= 0xc0ff;
164   tmp |= ((readinputport(6) & 0x3f)<<8);
164   tmp |= ((input_port_read_indexed(machine, 6) & 0x3f)<<8);
165165   break;
166166   case 0x03:
167   tmp = (readinputport(3) | readinputport(5) << 8) ;
167   tmp = (input_port_read_indexed(machine, 3) | input_port_read_indexed(machine, 5) << 8) ;
168168   tmp &= 0xfcff;
169   tmp |= ((readinputport(6) & 0xc0) << 2);
169   tmp |= ((input_port_read_indexed(machine, 6) & 0xc0) << 2);
170170   break;
171171   }
172172
src/mame/drivers/marineb.c
r2375r2376
833833   ROM_RELOAD(               0x3000, 0x1000 )
834834
835835   ROM_REGION( 0x4000, REGION_GFX2, ROMREGION_DISPOSE )
836   ROM_LOAD( "hopper08.6f",   0x0000, 0x2000, CRC(06d37e64) SHA1(c0923a1a40dca43b66e14d755dacf7767d62ab8b) )
837   ROM_LOAD( "hopper09.6k",   0x2000, 0x2000, CRC(047921c7) SHA1(8ef4722a98be540e4b5c67965599c400511b4a52) )
836   ROM_LOAD( "hopper09.6k",   0x0000, 0x2000, CRC(047921c7) SHA1(8ef4722a98be540e4b5c67965599c400511b4a52) )
837   ROM_LOAD( "hopper08.6f",   0x2000, 0x2000, CRC(06d37e64) SHA1(c0923a1a40dca43b66e14d755dacf7767d62ab8b) )
838838
839839   ROM_REGION( 0x0200, REGION_PROMS, 0 )
840840   ROM_LOAD( "7052hop.1b",    0x0000, 0x0100, CRC(94450775) SHA1(e15fcf6d1cd7cfc0d98e82bd0559b6d342aac9ed) ) /* palette low 4 bits */
src/mame/drivers/multigam.c
r2375r2376
100100   in_0_shift = 0;
101101   in_1_shift = 0;
102102
103   in_0 = readinputport(0);
104   in_1 = readinputport(1);
103   in_0 = input_port_read_indexed(machine, 0);
104   in_1 = input_port_read_indexed(machine, 1);
105105
106106   multigam_in_dsw_shift = 0;
107   multigam_in_dsw = readinputport(3);
107   multigam_in_dsw = input_port_read_indexed(machine, 3);
108108}
109109
110110static READ8_HANDLER( multigam_IN1_r )
r2375r2376
117117   /* bit 0: serial input (dsw)
118118       bit 1: coin */
119119   return ((multigam_in_dsw >> multigam_in_dsw_shift++) & 0x01) |
120         readinputport(2);
120         input_port_read_indexed(machine, 2);
121121}
122122
123123
src/mame/drivers/atarigx2.c
r2375r2376
8181
8282static READ32_HANDLER( special_port2_r )
8383{
84   int temp = readinputport(2);
84   int temp = input_port_read_indexed(machine, 2);
8585   if (atarigen_cpu_to_sound_ready) temp ^= 0x0020;
8686   if (atarigen_sound_to_cpu_ready) temp ^= 0x0010;
8787   temp ^= 0x0008;      /* A2D.EOC always high for now */
r2375r2376
9191
9292static READ32_HANDLER( special_port3_r )
9393{
94   int temp = readinputport(3);
94   int temp = input_port_read_indexed(machine, 3);
9595   return (temp << 16) | temp;
9696}
9797
r2375r2376
111111   switch (offset)
112112   {
113113      case 0:
114         return (readinputport(5) << 24) | (readinputport(6) << 8);
114         return (input_port_read_indexed(machine, 5) << 24) | (input_port_read_indexed(machine, 6) << 8);
115115      case 1:
116         return (readinputport(7) << 24) | (readinputport(8) << 8);
116         return (input_port_read_indexed(machine, 7) << 24) | (input_port_read_indexed(machine, 8) << 8);
117117   }
118118
119119   return 0;
r2375r2376
11691169
11701170static READ32_HANDLER( inputs_01_r )
11711171{
1172   return (readinputport(0) << 16) | readinputport(1);
1172   return (input_port_read_indexed(machine, 0) << 16) | input_port_read_indexed(machine, 1);
11731173}
11741174
11751175
src/mame/drivers/nwk-tr.c
r2375r2376
556556   int value = 0;
557557   switch (input)
558558   {
559      case 0:      value = readinputport(4) - 0x800; break;
560      case 1:      value = readinputport(5); break;
561      case 2:      value = readinputport(6); break;
562      case 3:      value = readinputport(7); break;
563      case 4:      value = readinputport(8); break;
559      case 0:      value = input_port_read_indexed(Machine, 4) - 0x800; break;
560      case 1:      value = input_port_read_indexed(Machine, 5); break;
561      case 2:      value = input_port_read_indexed(Machine, 6); break;
562      case 3:      value = input_port_read_indexed(Machine, 7); break;
563      case 4:      value = input_port_read_indexed(Machine, 8); break;
564564   }
565565
566566   return (double)(value) / 2047.0;
r2375r2376
573573   {
574574      if (ACCESSING_BITS_24_31)
575575      {
576         r |= readinputport(0) << 24;
576         r |= input_port_read_indexed(machine, 0) << 24;
577577      }
578578      if (ACCESSING_BITS_16_23)
579579      {
580         r |= readinputport(1) << 16;
580         r |= input_port_read_indexed(machine, 1) << 16;
581581      }
582582      if (ACCESSING_BITS_8_15)
583583      {
584         r |= readinputport(2) << 8;
584         r |= input_port_read_indexed(machine, 2) << 8;
585585      }
586586      if (ACCESSING_BITS_0_7)
587587      {
r2375r2376
592592   {
593593      if (ACCESSING_BITS_24_31)
594594      {
595         r |= readinputport(3) << 24;
595         r |= input_port_read_indexed(machine, 3) << 24;
596596      }
597597   }
598598   return r;
src/mame/drivers/sderby.c
r2375r2376
9393   switch (offset)
9494   {
9595      case 0x00 >> 1:
96         return readinputport(0);
96         return input_port_read_indexed(machine, 0);
9797      case 0x02 >> 1:
9898         return 0xffff;         // to avoid game to reset (needs more work)
9999   }
r2375r2376
108108   switch (offset)
109109   {
110110   case 0x00 >>1:
111      return readinputport(0);
111      return input_port_read_indexed(machine, 0);
112112   case 0x02 >>1:
113      return readinputport(1);
113      return input_port_read_indexed(machine, 1);
114114   case 0x04 >>1:
115      return readinputport(2);
115      return input_port_read_indexed(machine, 2);
116116   }
117117   return 0xffff;
118118
src/mame/drivers/vastar.c
r2375r2376
114114
115115
116116
117static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 )
118   AM_RANGE(0x0000, 0x7fff) AM_READ(SMH_ROM)
119   AM_RANGE(0x8000, 0x8fff) AM_READ(vastar_bg2videoram_r)
120   AM_RANGE(0x9000, 0x9fff) AM_READ(vastar_bg1videoram_r)
121   AM_RANGE(0xa000, 0xafff) AM_READ(vastar_bg2videoram_r)   /* mirror address */
122   AM_RANGE(0xb000, 0xbfff) AM_READ(vastar_bg1videoram_r)   /* mirror address */
123   AM_RANGE(0xc400, 0xcfff) AM_READ(SMH_RAM)
124   AM_RANGE(0xe000, 0xe000) AM_READ(watchdog_reset_r)
125   AM_RANGE(0xf000, 0xf0ff) AM_READ(vastar_sharedram_r)
126   AM_RANGE(0xf100, 0xf7ff) AM_READ(SMH_RAM)
127ADDRESS_MAP_END
128
129static ADDRESS_MAP_START( writemem, ADDRESS_SPACE_PROGRAM, 8 )
130   AM_RANGE(0x0000, 0x7fff) AM_WRITE(SMH_ROM)
131   AM_RANGE(0x8000, 0x8fff) AM_WRITE(vastar_bg2videoram_w) AM_BASE(&vastar_bg2videoram)
132   AM_RANGE(0x9000, 0x9fff) AM_WRITE(vastar_bg1videoram_w) AM_BASE(&vastar_bg1videoram)
133   AM_RANGE(0xa000, 0xafff) AM_WRITE(vastar_bg2videoram_w)            /* mirror address */
134   AM_RANGE(0xb000, 0xbfff) AM_WRITE(vastar_bg1videoram_w)              /* mirror address */
117static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
118   AM_RANGE(0x0000, 0x7fff) AM_ROM
119   AM_RANGE(0x8000, 0x8fff) AM_READWRITE(vastar_bg2videoram_r, vastar_bg2videoram_w) AM_BASE(&vastar_bg2videoram)
120   AM_RANGE(0x9000, 0x9fff) AM_READWRITE(vastar_bg1videoram_r, vastar_bg1videoram_w) AM_BASE(&vastar_bg1videoram)
121   AM_RANGE(0xa000, 0xafff) AM_READWRITE(vastar_bg2videoram_r, vastar_bg2videoram_w)   /* mirror address */
122   AM_RANGE(0xb000, 0xbfff) AM_READWRITE(vastar_bg1videoram_r, vastar_bg1videoram_w)   /* mirror address */
135123   AM_RANGE(0xc000, 0xc000) AM_WRITE(SMH_RAM) AM_BASE(&vastar_sprite_priority)   /* sprite/BG priority */
136   AM_RANGE(0xc400, 0xcfff) AM_WRITE(vastar_fgvideoram_w) AM_BASE(&vastar_fgvideoram)
137   AM_RANGE(0xe000, 0xe000) AM_WRITE(watchdog_reset_w)
138   AM_RANGE(0xf000, 0xf0ff) AM_WRITE(vastar_sharedram_w) AM_BASE(&vastar_sharedram)
139   AM_RANGE(0xf100, 0xf7ff) AM_WRITE(SMH_RAM)
124   AM_RANGE(0xc400, 0xcfff) AM_RAM AM_WRITE(vastar_fgvideoram_w) AM_BASE(&vastar_fgvideoram)
125   AM_RANGE(0xe000, 0xe000) AM_READWRITE(watchdog_reset_r, watchdog_reset_w)
126   AM_RANGE(0xf000, 0xf0ff) AM_READWRITE(vastar_sharedram_r, vastar_sharedram_w) AM_BASE(&vastar_sharedram)
127   AM_RANGE(0xf100, 0xf7ff) AM_RAM
140128
141   /* in hidden portions of video RAM: */
129   /* in hidden portions of video RAM: (fallthrough) */
142130   AM_RANGE(0xc400, 0xc43f) AM_WRITE(SMH_RAM) AM_BASE(&spriteram) AM_SIZE(&spriteram_size)   /* actually c410-c41f and c430-c43f */
143131   AM_RANGE(0xc7c0, 0xc7df) AM_WRITE(SMH_RAM) AM_BASE(&vastar_bg1_scroll)
144132   AM_RANGE(0xc7e0, 0xc7ff) AM_WRITE(SMH_RAM) AM_BASE(&vastar_bg2_scroll)
r2375r2376
146134   AM_RANGE(0xcc00, 0xcc3f) AM_WRITE(SMH_RAM) AM_BASE(&spriteram_3)   /* actually cc10-cc1f and cc30-cc3f */
147135ADDRESS_MAP_END
148136
149static ADDRESS_MAP_START( writeport, ADDRESS_SPACE_IO, 8 )
137static ADDRESS_MAP_START( main_port_map, ADDRESS_SPACE_IO, 8 )
150138   ADDRESS_MAP_GLOBAL_MASK(0xff)
151139   AM_RANGE(0x00, 0x00) AM_WRITE(interrupt_enable_w)
152140   AM_RANGE(0x01, 0x01) AM_WRITE(flip_screen_w)
153141   AM_RANGE(0x02, 0x02) AM_WRITE(vastar_hold_cpu2_w)
154142ADDRESS_MAP_END
155143
156static ADDRESS_MAP_START( cpu2_readmem, ADDRESS_SPACE_PROGRAM, 8 )
157   AM_RANGE(0x0000, 0x1fff) AM_READ(SMH_ROM)
158   AM_RANGE(0x4000, 0x40ff) AM_READ(vastar_sharedram_r)
144
145static ADDRESS_MAP_START( cpu2_map, ADDRESS_SPACE_PROGRAM, 8 )
146   AM_RANGE(0x0000, 0x1fff) AM_ROM
147   AM_RANGE(0x4000, 0x40ff) AM_READWRITE(vastar_sharedram_r, vastar_sharedram_w)
159148   AM_RANGE(0x8000, 0x8000) AM_READ(input_port_1_r)
160149   AM_RANGE(0x8040, 0x8040) AM_READ(input_port_0_r)
161150   AM_RANGE(0x8080, 0x8080) AM_READ(input_port_2_r)
162151ADDRESS_MAP_END
163152
164static ADDRESS_MAP_START( cpu2_writemem, ADDRESS_SPACE_PROGRAM, 8 )
165   AM_RANGE(0x0000, 0x1fff) AM_WRITE(SMH_ROM)
166   AM_RANGE(0x4000, 0x40ff) AM_WRITE(vastar_sharedram_w)
167ADDRESS_MAP_END
168
169static ADDRESS_MAP_START( cpu2_readport, ADDRESS_SPACE_IO, 8 )
153static ADDRESS_MAP_START( cpu2_port_map, ADDRESS_SPACE_IO, 8 )
170154   ADDRESS_MAP_GLOBAL_MASK(0xff)
171   AM_RANGE(0x02, 0x02) AM_READ(AY8910_read_port_0_r)
172ADDRESS_MAP_END
173
174static ADDRESS_MAP_START( cpu2_writeport, ADDRESS_SPACE_IO, 8 )
175   ADDRESS_MAP_GLOBAL_MASK(0xff)
176155   AM_RANGE(0x00, 0x00) AM_WRITE(AY8910_control_port_0_w)
177156   AM_RANGE(0x01, 0x01) AM_WRITE(AY8910_write_port_0_w)
157   AM_RANGE(0x02, 0x02) AM_READ(AY8910_read_port_0_r)
178158ADDRESS_MAP_END
179159
180160
181
182161static INPUT_PORTS_START( vastar )
183162   PORT_START_TAG("IN0")
184163   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY
r2375r2376
325304
326305   /* basic machine hardware */
327306   MDRV_CPU_ADD(Z80, 3072000)   /* 3.072 MHz ???? */
328   MDRV_CPU_PROGRAM_MAP(readmem,writemem)
329   MDRV_CPU_IO_MAP(0,writeport)
307   MDRV_CPU_PROGRAM_MAP(main_map,0)
308   MDRV_CPU_IO_MAP(main_port_map,0)
330309   MDRV_CPU_VBLANK_INT("main", nmi_line_pulse)
331310
332311   MDRV_CPU_ADD(Z80, 3072000)   /* 3.072 MHz ???? */
333   MDRV_CPU_PROGRAM_MAP(cpu2_readmem,cpu2_writemem)
334   MDRV_CPU_IO_MAP(cpu2_readport,cpu2_writeport)
312   MDRV_CPU_PROGRAM_MAP(cpu2_map,0)
313   MDRV_CPU_IO_MAP(cpu2_port_map,0)
335314   MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold,4)   /* ??? */
336315
337316   MDRV_INTERLEAVE(10)   /* 10 CPU slices per frame - seems enough to ensure proper */
src/mame/drivers/relief.c
r2375r2376
104104
105105static READ16_HANDLER( special_port2_r )
106106{
107   int result = readinputport(2);
107   int result = input_port_read_indexed(machine, 2);
108108   if (atarigen_cpu_to_sound_ready) result ^= 0x0020;
109109   if (!(result & 0x0080) || atarigen_get_hblank(machine->primary_screen)) result ^= 0x0001;
110110   return result;
src/mame/drivers/taito_f3.c
r2375r2376
5858      case 0x0: /* MSW: Test switch, coins, eeprom access, LSW: Player Buttons, Start, Tilt, Service */
5959         e=EEPROM_read_bit();
6060         e=e|(e<<8);
61         return ((e | readinputport(2) | (readinputport(2)<<8))<<16) /* top byte may be mirror of bottom byte??  see bubblem */
62               | readinputport(1);
61         return ((e | input_port_read_indexed(machine, 2) | (input_port_read_indexed(machine, 2)<<8))<<16) /* top byte may be mirror of bottom byte??  see bubblem */
62               | input_port_read_indexed(machine, 1);
6363
6464      case 0x1: /* MSW: Coin counters/lockouts are readable, LSW: Joysticks (Player 1 & 2) */
65         return (coin_word[0]<<16) | readinputport(0) | 0xff00;
65         return (coin_word[0]<<16) | input_port_read_indexed(machine, 0) | 0xff00;
6666
6767      case 0x2: /* Analog control 1 */
68         return ((readinputport(3)&0xf)<<12) | ((readinputport(3)&0xff0)>>4);
68         return ((input_port_read_indexed(machine, 3)&0xf)<<12) | ((input_port_read_indexed(machine, 3)&0xff0)>>4);
6969
7070      case 0x3: /* Analog control 2 */
71         return ((readinputport(4)&0xf)<<12) | ((readinputport(4)&0xff0)>>4);
71         return ((input_port_read_indexed(machine, 4)&0xf)<<12) | ((input_port_read_indexed(machine, 4)&0xff0)>>4);
7272
7373      case 0x4: /* Player 3 & 4 fire buttons (Player 2 top fire buttons in Kaiser Knuckle) */
74         return readinputport(5)<<8;
74         return input_port_read_indexed(machine, 5)<<8;
7575
7676      case 0x5: /* Player 3 & 4 joysticks (Player 1 top fire buttons in Kaiser Knuckle) */
77         return (coin_word[1]<<16) | readinputport(6);
77         return (coin_word[1]<<16) | input_port_read_indexed(machine, 6);
7878   }
7979
8080   logerror("CPU #0 PC %06x: warning - read unmapped control address %06x\n",activecpu_get_pc(),offset);
src/mame/drivers/gaelco2.c
r2375r2376
269269   }
270270}
271271
272static READ16_HANDLER(p1_gun_x) {return (readinputport(3)*320/0x100)+1;}
273static READ16_HANDLER(p1_gun_y) {return (readinputport(5)*240/0x100)-4;}
274static READ16_HANDLER(p2_gun_x) {return (readinputport(4)*320/0x100)+1;}
275static READ16_HANDLER(p2_gun_y) {return (readinputport(6)*240/0x100)-4;}
272static READ16_HANDLER(p1_gun_x) {return (input_port_read_indexed(machine, 3)*320/0x100)+1;}
273static READ16_HANDLER(p1_gun_y) {return (input_port_read_indexed(machine, 5)*240/0x100)-4;}
274static READ16_HANDLER(p2_gun_x) {return (input_port_read_indexed(machine, 4)*320/0x100)+1;}
275static READ16_HANDLER(p2_gun_y) {return (input_port_read_indexed(machine, 6)*240/0x100)-4;}
276276
277277static ADDRESS_MAP_START( bang_readmem, ADDRESS_SPACE_PROGRAM, 16 )
278278    AM_RANGE(0x000000, 0x0fffff) AM_READ(SMH_ROM) /* ROM */
src/mame/drivers/homerun.c
r2375r2376
9292static READ8_HANDLER(homerun_40_r)
9393{
9494   if(video_screen_get_vpos(machine->primary_screen)>116)
95      return readinputport(0)|0x40;
95      return input_port_read_indexed(machine, 0)|0x40;
9696   else
97      return readinputport(0);
97      return input_port_read_indexed(machine, 0);
9898}
9999
100100static ADDRESS_MAP_START( homerun_iomap, ADDRESS_SPACE_IO, 8 )
src/mame/drivers/guab.c
r2375r2376
552552      case 0x01:
553553      case 0x02:
554554      {
555         return readinputport(offset);
555         return input_port_read_indexed(machine, offset);
556556      }
557557      case 0x30:
558558      {
src/mame/drivers/baraduke.c
r2375r2376
144144   switch (inputport_selected)
145145   {
146146      case 0x00:   /* DSW A (bits 0-4) */
147         return (readinputport(0) & 0xf8) >> 3; break;
147         return (input_port_read_indexed(machine, 0) & 0xf8) >> 3; break;
148148      case 0x01:   /* DSW A (bits 5-7), DSW B (bits 0-1) */
149         return ((readinputport(0) & 0x07) << 2) | ((readinputport(1) & 0xc0) >> 6); break;
149         return ((input_port_read_indexed(machine, 0) & 0x07) << 2) | ((input_port_read_indexed(machine, 1) & 0xc0) >> 6); break;
150150      case 0x02:   /* DSW B (bits 2-6) */
151         return (readinputport(1) & 0x3e) >> 1; break;
151         return (input_port_read_indexed(machine, 1) & 0x3e) >> 1; break;
152152      case 0x03:   /* DSW B (bit 7), DSW C (bits 0-3) */
153         return ((readinputport(1) & 0x01) << 4) | (readinputport(2) & 0x0f); break;
153         return ((input_port_read_indexed(machine, 1) & 0x01) << 4) | (input_port_read_indexed(machine, 2) & 0x0f); break;
154154      case 0x04:   /* coins, start */
155         return readinputport(3); break;
155         return input_port_read_indexed(machine, 3); break;
156156      case 0x05:   /* 2P controls */
157         return readinputport(5); break;
157         return input_port_read_indexed(machine, 5); break;
158158      case 0x06:   /* 1P controls */
159         return readinputport(4); break;
159         return input_port_read_indexed(machine, 4); break;
160160      default:
161161         return 0xff;
162162   }
src/mame/drivers/ssozumo.c
r2375r2376
3434{
3535   static int coin;
3636
37   if ((readinputport(0) & 0xc0) != 0xc0)
37   if ((input_port_read_indexed(machine, 0) & 0xc0) != 0xc0)
3838   {
3939      if (coin == 0)
4040      {
src/mame/drivers/mcr.c
r2375r2376
319319   /* game in cocktail mode, they don't work at all. So we fake-mux   */
320320   /* the controls through player 1's ports */
321321   if (mcr_cocktail_flip)
322      return readinputportbytag("SSIO.IP0") | 0x08;
322      return input_port_read(machine, "SSIO.IP0") | 0x08;
323323   else
324      return ((readinputportbytag("SSIO.IP0") & ~0x14) | 0x08) | ((readinputportbytag("SSIO.IP0") & 0x08) >> 1) | ((readinputportbytag("SSIO.IP2") & 0x01) << 4);
324      return ((input_port_read(machine, "SSIO.IP0") & ~0x14) | 0x08) | ((input_port_read(machine, "SSIO.IP0") & 0x08) >> 1) | ((input_port_read(machine, "SSIO.IP2") & 0x01) << 4);
325325}
326326
327327
r2375r2376
329329{
330330   /*  same deal as above */
331331   if (mcr_cocktail_flip)
332      return readinputportbytag("SSIO.IP1") | 0xf0;
332      return input_port_read(machine, "SSIO.IP1") | 0xf0;
333333   else
334      return (readinputportbytag("SSIO.IP1") >> 4) | 0xf0;
334      return (input_port_read(machine, "SSIO.IP1") >> 4) | 0xf0;
335335}
336336
337337
r2375r2376
344344
345345static READ8_HANDLER( kick_ip1_r )
346346{
347   return (readinputportbytag("DIAL2") << 4) & 0xf0;
347   return (input_port_read(machine, "DIAL2") << 4) & 0xf0;
348348}
349349
350350
r2375r2376
364364static READ8_HANDLER( wacko_ip1_r )
365365{
366366   if (!input_mux)
367      return readinputportbytag("SSIO.IP1");
367      return input_port_read(machine, "SSIO.IP1");
368368   else
369      return readinputportbytag("SSIO.IP1.ALT");
369      return input_port_read(machine, "SSIO.IP1.ALT");
370370}
371371
372372
373373static READ8_HANDLER( wacko_ip2_r )
374374{
375375   if (!input_mux)
376      return readinputportbytag("SSIO.IP2");
376      return input_port_read(machine, "SSIO.IP2");
377377   else
378      return readinputportbytag("SSIO.IP2.ALT");
378      return input_port_read(machine, "SSIO.IP2.ALT");
379379}
380380
381381
r2375r2376
388388
389389static READ8_HANDLER( kroozr_ip1_r )
390390{
391   int dial = readinputportbytag("DIAL");
391   int dial = input_port_read(machine, "DIAL");
392392   return ((dial & 0x80) >> 1) | ((dial & 0x70) >> 4);
393393}
394394
r2375r2376
581581
582582static READ8_HANDLER( demoderb_ip1_r )
583583{
584   return readinputportbytag(input_mux ? "SSIO.IP1.ALT" : "SSIO.IP1");
584   return input_port_read(machine, input_mux ? "SSIO.IP1.ALT" : "SSIO.IP1");
585585}
586586
587587
588588static READ8_HANDLER( demoderb_ip2_r )
589589{
590   return readinputportbytag(input_mux ? "SSIO.IP2.ALT" : "SSIO.IP2");
590   return input_port_read(machine, input_mux ? "SSIO.IP2.ALT" : "SSIO.IP2");
591591}
592592
593593
src/mame/drivers/beaminv.c
r2375r2376
192192
193193static READ8_HANDLER( controller_r )
194194{
195   return readinputportbytag((controller_select == 1) ? P1_CONTROL_PORT_TAG : P2_CONTROL_PORT_TAG);
195   return input_port_read(machine, (controller_select == 1) ? P1_CONTROL_PORT_TAG : P2_CONTROL_PORT_TAG);
196196}
197197
198198
src/mame/drivers/ninjaw.c
r2375r2376
927927   ROM_LOAD( "c07-12.107", 0x00000, 0x80000, CRC(e0b71258) SHA1(0258e308b643d723475824752ebffc4ea29d1ac4) )
928928ROM_END
929929
930static STATE_POSTLOAD( ninjaw_postload )
931{
932   parse_control();
933   reset_sound_region();
934}
930935
931936static MACHINE_START( ninjaw )
932937{
933938   cpua_ctrl = 0xff;
934939   state_save_register_global(cpua_ctrl);
935   state_save_register_func_postload(parse_control);
936
937940   state_save_register_global(banknum);
938   state_save_register_func_postload(reset_sound_region);
941   state_save_register_postload(machine, ninjaw_postload, NULL);
939942}
940943
941944static MACHINE_RESET( ninjaw )
src/mame/drivers/matmania.c
r2375r2376
18182600-27ff Background attribute RAM #2
19194000-ffff ROM
2020
21
222008.04.04: Small note regarding DipSwitches. Locations and values have been
23verified with the manual for both Mat Mania and Mania Challenge.
24Exciting Hour DIPs confirmed with crazykong diplist, no manual available ATM.
25Notice that the manual for Mat Mania lists DSW2:3,4 as Unused, but they
26correctly affect the timer speed during the game. Also, default difficulty
27in Mat Mania is Normal, while manual for Mania Challenge reports Easy.
28The driver has been updated accordingly.
29
2130***************************************************************************/
2231
2332#include "driver.h"
r2375r2376
8291   AM_RANGE(0x0000, 0x077f) AM_READ(SMH_RAM)
8392   AM_RANGE(0x1000, 0x17ff) AM_READ(SMH_RAM)
8493   AM_RANGE(0x2000, 0x27ff) AM_READ(SMH_RAM)
85   AM_RANGE(0x3000, 0x3000) AM_READ(input_port_0_r)
86   AM_RANGE(0x3010, 0x3010) AM_READ(input_port_1_r)
87   AM_RANGE(0x3020, 0x3020) AM_READ(input_port_2_r)
88   AM_RANGE(0x3030, 0x3030) AM_READ(input_port_3_r)
94   AM_RANGE(0x3000, 0x3000) AM_READ_PORT("IN0")
95   AM_RANGE(0x3010, 0x3010) AM_READ_PORT("IN1")
96   AM_RANGE(0x3020, 0x3020) AM_READ_PORT("DSW2")
97   AM_RANGE(0x3030, 0x3030) AM_READ_PORT("DSW1")
8998   AM_RANGE(0x4000, 0xffff) AM_READ(SMH_ROM)
9099ADDRESS_MAP_END
91100
r2375r2376
110119   AM_RANGE(0x0000, 0x077f) AM_READ(SMH_RAM)
111120   AM_RANGE(0x1000, 0x17ff) AM_READ(SMH_RAM)
112121   AM_RANGE(0x2000, 0x27ff) AM_READ(SMH_RAM)
113   AM_RANGE(0x3000, 0x3000) AM_READ(input_port_0_r)
114   AM_RANGE(0x3010, 0x3010) AM_READ(input_port_1_r)
115   AM_RANGE(0x3020, 0x3020) AM_READ(input_port_2_r)
116   AM_RANGE(0x3030, 0x3030) AM_READ(input_port_3_r)
122   AM_RANGE(0x3000, 0x3000) AM_READ_PORT("IN0")
123   AM_RANGE(0x3010, 0x3010) AM_READ_PORT("IN1")
124   AM_RANGE(0x3020, 0x3020) AM_READ_PORT("DSW2")
125   AM_RANGE(0x3030, 0x3030) AM_READ_PORT("DSW1")
117126   AM_RANGE(0x3040, 0x3040) AM_READ(maniach_mcu_r)
118127   AM_RANGE(0x3041, 0x3041) AM_READ(maniach_mcu_status_r)
119128   AM_RANGE(0x4000, 0xffff) AM_READ(SMH_ROM)
r2375r2376
191200
192201
193202static INPUT_PORTS_START( matmania )
194   PORT_START   /* IN0 */
203   PORT_START_TAG("IN0")
195204   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
196205   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
197206   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
r2375r2376
201210   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(1)
202211   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(1)
203212
204   PORT_START   /* IN1 */
213   PORT_START_TAG("IN1")
205214   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
206215   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
207216   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
r2375r2376
211220   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
212221   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
213222
214   PORT_START   /* DSW1 */
215   PORT_DIPNAME(0x03, 0x03, DEF_STR( Difficulty ) )
216   PORT_DIPSETTING(   0x03, DEF_STR( Easy ) )
217   PORT_DIPSETTING(   0x02, DEF_STR( Medium ) )
218   PORT_DIPSETTING(   0x01, DEF_STR( Hard ) )
219   PORT_DIPSETTING(   0x00, DEF_STR( Hardest ) )
220   PORT_DIPNAME(0x0c, 0x0c, "Tournament Time" )    // Tournament time is always 3:00, but time per 1 second is shorter.
221   PORT_DIPSETTING(   0x00, "2:12" )
222   PORT_DIPSETTING(   0x04, "2:24" )
223   PORT_DIPSETTING(   0x08, "2:30" )
224   PORT_DIPSETTING(   0x0c, "2:36" )
225   PORT_DIPNAME(0x10, 0x10, DEF_STR( Unused ) )
226   PORT_DIPSETTING(   0x10, DEF_STR( Off ) )
227   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
228   PORT_DIPNAME(0x20, 0x20, DEF_STR( Unused ) )
229   PORT_DIPSETTING(   0x20, DEF_STR( Off ) )
230   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
231   PORT_DIPNAME(0x40, 0x40, DEF_STR( Unused ) )
232   PORT_DIPSETTING(   0x40, DEF_STR( Off ) )
233   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
234   PORT_DIPNAME(0x80, 0x80, DEF_STR( Unused ) )
235   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
236   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
237
238   PORT_START   /* DSW2 */
239   PORT_DIPNAME(0x03, 0x03, DEF_STR( Coin_A ) )
223   PORT_START_TAG("DSW1")
224   PORT_DIPNAME(0x03, 0x03, DEF_STR( Coin_A ) )      PORT_DIPLOCATION("SW1:1,2")
240225   PORT_DIPSETTING(   0x00, DEF_STR( 2C_1C ) )
241226   PORT_DIPSETTING(   0x03, DEF_STR( 1C_1C ) )
242227   PORT_DIPSETTING(   0x02, DEF_STR( 1C_2C ) )
243228   PORT_DIPSETTING(   0x01, DEF_STR( 1C_3C ) )
244   PORT_DIPNAME(0x0c, 0x0c, DEF_STR( Coin_B ) )
229   PORT_DIPNAME(0x0c, 0x0c, DEF_STR( Coin_B ) )      PORT_DIPLOCATION("SW1:3,4")
245230   PORT_DIPSETTING(   0x00, DEF_STR( 2C_1C ) )
246231   PORT_DIPSETTING(   0x0c, DEF_STR( 1C_1C ) )
247232   PORT_DIPSETTING(   0x08, DEF_STR( 1C_2C ) )
248233   PORT_DIPSETTING(   0x04, DEF_STR( 1C_3C ) )
249   PORT_DIPNAME(0x10, 0x10, DEF_STR( Demo_Sounds ) )
234   PORT_DIPNAME(0x10, 0x10, DEF_STR( Demo_Sounds ) )   PORT_DIPLOCATION("SW1:5")
250235   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
251236   PORT_DIPSETTING(   0x10, DEF_STR( On ) )
252   PORT_DIPNAME(0x20, 0x00, DEF_STR( Cabinet ) )    // The default setting should be cocktail.
253   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )
237   PORT_DIPNAME(0x20, 0x00, DEF_STR( Cabinet ) )      PORT_DIPLOCATION("SW1:6")
238   PORT_DIPSETTING(   0x00, DEF_STR( Upright ) )      /* The default setting should be cocktail. */
254239   PORT_DIPSETTING(   0x20, DEF_STR( Cocktail ) )
255   PORT_SERVICE( 0x40, IP_ACTIVE_LOW )
256   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )
240   PORT_SERVICE_DIPLOC( 0x40, IP_ACTIVE_LOW, "SW1:7" )
241   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )      /* Listed as always ON among DIPs in the manual */
242
243   PORT_START_TAG("DSW2")
244   PORT_DIPNAME(0x03, 0x02, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("SW2:1,2")
245   PORT_DIPSETTING(   0x03, DEF_STR( Easy ) )
246   PORT_DIPSETTING(   0x02, DEF_STR( Medium ) )      /* According to the manual, default is Medium */
247   PORT_DIPSETTING(   0x01, DEF_STR( Hard ) )
248   PORT_DIPSETTING(   0x00, DEF_STR( Hardest ) )
249   PORT_DIPNAME(0x0c, 0x0c, "Tournament Time" )      PORT_DIPLOCATION("SW2:3,4")
250   PORT_DIPSETTING(   0x00, "2:12" )               /* Tournament time is always 3:00, but time per 1 second is shorter. */
251   PORT_DIPSETTING(   0x04, "2:24" )
252   PORT_DIPSETTING(   0x08, "2:30" )
253   PORT_DIPSETTING(   0x0c, "2:36" )
254   PORT_DIPUNUSED_DIPLOC(0x10, IP_ACTIVE_LOW, "SW2:5")   /* Listed as Unused */
255   PORT_DIPUNUSED_DIPLOC(0x20, IP_ACTIVE_LOW, "SW2:6")   /* Listed as Unused */
256   PORT_DIPUNUSED_DIPLOC(0x40, IP_ACTIVE_LOW, "SW2:7")   /* Listed as Unused */
257   PORT_DIPUNUSED_DIPLOC(0x80, IP_ACTIVE_LOW, "SW2:8")   /* Listed as Unused */
257258INPUT_PORTS_END
258259
260static INPUT_PORTS_START( maniach )
261   PORT_INCLUDE( matmania )
262
263   PORT_MODIFY("DSW2")
264   PORT_DIPNAME(0x03, 0x03, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("SW2:1,2")
265   PORT_DIPSETTING(   0x03, DEF_STR( Easy ) )         /* According to the manual, default for this game is Easy */
266   PORT_DIPSETTING(   0x02, DEF_STR( Medium ) )
267   PORT_DIPSETTING(   0x01, DEF_STR( Hard ) )
268   PORT_DIPSETTING(   0x00, DEF_STR( Hardest ) )
269INPUT_PORTS_END
270
271
259272static const gfx_layout charlayout =
260273{
261274   8,8,   /* 8*8 characters */
r2375r2376
660673
661674
662675GAME( 1985, matmania, 0,        matmania, matmania, 0, ROT270, "Technos (Taito America license)", "Mat Mania", 0 )
663GAME( 1985, excthour, matmania, matmania, matmania, 0, ROT270, "Technos (Taito license)", "Exciting Hour", 0 )
664GAME( 1986, maniach,  0,        maniach,  matmania, 0, ROT270, "Technos (Taito America license)", "Mania Challenge (set 1)", 0 )
665GAME( 1986, maniach2, maniach,  maniach,  matmania, 0, ROT270, "Technos (Taito America license)", "Mania Challenge (set 2)" , 0)   /* earlier version? */
676GAME( 1985, excthour, matmania, matmania, maniach,  0, ROT270, "Technos (Taito license)", "Exciting Hour", 0 )
677GAME( 1986, maniach,  0,        maniach,  maniach,  0, ROT270, "Technos (Taito America license)", "Mania Challenge (set 1)", 0 )
678GAME( 1986, maniach2, maniach,  maniach,  maniach,  0, ROT270, "Technos (Taito America license)", "Mania Challenge (set 2)" , 0)   /* earlier version? */
src/mame/drivers/twin16.c
r2375r2376
7171extern VIDEO_EOF( twin16 );
7272extern VIDEO_UPDATE( vulcan );
7373
74
7475extern void twin16_spriteram_process( void );
7576
7677UINT16 twin16_custom_video;
r2375r2376
218219{
219220   switch( offset )
220221   {
221      case 0x00: return readinputport(0); // coin
222      case 0x01: return readinputport(1); // p1
223      case 0x02: return readinputport(2); // p2
224      case 0x03: return readinputport(3); // p3 (Dark Adventure)
225      case 0x08: return readinputport(5); // DSW1
226      case 0x09: return readinputport(4); // DSW2
227      case 0x0c: return readinputport(6); // DSW3
222      case 0x00: return input_port_read_indexed(machine, 0); // coin
223      case 0x01: return input_port_read_indexed(machine, 1); // p1
224      case 0x02: return input_port_read_indexed(machine, 2); // p2
225      case 0x03: return input_port_read_indexed(machine, 3); // p3 (Dark Adventure)
226      case 0x08: return input_port_read_indexed(machine, 5); // DSW1
227      case 0x09: return input_port_read_indexed(machine, 4); // DSW2
228      case 0x0c: return input_port_read_indexed(machine, 6); // DSW3
228229   }
229230   return 0;
230231}
r2375r2376
958959   /* audio CPU */
959960   MDRV_CPU_PROGRAM_MAP(readmem_sound,writemem_sound)
960961
961   MDRV_CPU_ADD(M68000, 10000000)
962   MDRV_CPU_ADD(M68000, XTAL_18_432MHz/2)
962963   MDRV_CPU_PROGRAM_MAP(readmem_sub,writemem_sub)
963964   MDRV_CPU_VBLANK_INT("main", CPUB_interrupt)
964965
965   MDRV_CPU_ADD(M68000, 10000000)
966   MDRV_CPU_ADD(M68000, XTAL_18_432MHz/2)
966967   MDRV_CPU_PROGRAM_MAP(readmem,writemem)
967968   MDRV_CPU_VBLANK_INT("main", CPUA_interrupt)
968969
r2375r2376
972973   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
973974
974975   MDRV_SCREEN_ADD("main", RASTER)
975   MDRV_SCREEN_REFRESH_RATE(60)
976   MDRV_SCREEN_REFRESH_RATE(((double)XTAL_18_432MHz / 2) / (576 * 264))
976977   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
977978   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
978979   MDRV_SCREEN_SIZE(40*8, 32*8)
r2375r2376
10691070   MDRV_SCREEN_MODIFY("main")
10701071   MDRV_SCREEN_VISIBLE_AREA(1*8, 39*8-1, 2*8, 30*8-1)
10711072   MDRV_VIDEO_START(fround)
1073
10721074MACHINE_DRIVER_END
10731075
10741076static MACHINE_DRIVER_START( vulcan )
src/mame/drivers/megasys1.c
r2375r2376
175175                        [ Main CPU - System A / Z ]
176176***************************************************************************/
177177
178static READ16_HANDLER( coins_r )   {return readinputport(0);}   // < 00 | Coins >
179static READ16_HANDLER( player1_r )   {return readinputport(1);}   // < 00 | Player 1 >
180static READ16_HANDLER( player2_r )   {return readinputport(2) * 256 +
181                                   readinputport(3);}      // < Reserve | Player 2 >
182static READ16_HANDLER( dsw1_r )      {return readinputport(4);}                     //   DSW 1
183static READ16_HANDLER( dsw2_r )      {return readinputport(5);}                     //   DSW 2
184static READ16_HANDLER( dsw_r )      {return readinputport(4) * 256 +
185                                   readinputport(5);}      // < DSW 1 | DSW 2 >
178static READ16_HANDLER( coins_r )   {return input_port_read_indexed(machine, 0);}   // < 00 | Coins >
179static READ16_HANDLER( player1_r )   {return input_port_read_indexed(machine, 1);}   // < 00 | Player 1 >
180static READ16_HANDLER( player2_r )   {return input_port_read_indexed(machine, 2) * 256 +
181                                   input_port_read_indexed(machine, 3);}      // < Reserve | Player 2 >
182static READ16_HANDLER( dsw1_r )      {return input_port_read_indexed(machine, 4);}                     //   DSW 1
183static READ16_HANDLER( dsw2_r )      {return input_port_read_indexed(machine, 5);}                     //   DSW 2
184static READ16_HANDLER( dsw_r )      {return input_port_read_indexed(machine, 4) * 256 +
185                                   input_port_read_indexed(machine, 5);}      // < DSW 1 | DSW 2 >
186186
187187
188188#define INTERRUPT_NUM_A      3
src/mame/drivers/crshrace.c
r2375r2376
173173
174174static READ16_HANDLER( country_sndpending_r )
175175{
176   return readinputport(5) | (pending_command ? 0x8000 : 0);
176   return input_port_read_indexed(machine, 5) | (pending_command ? 0x8000 : 0);
177177}
178178
179179static WRITE8_HANDLER( pending_command_clear_w )
src/mame/drivers/clshroad.c
r2375r2376
5656
5757static READ8_HANDLER( clshroad_input_r )
5858{
59   return   ((~readinputportbytag("IN0") & (1 << offset)) ? 1 : 0) |
60         ((~readinputportbytag("IN1") & (1 << offset)) ? 2 : 0) |
61         ((~readinputportbytag("DSW1") & (1 << offset)) ? 4 : 0) |
62         ((~readinputportbytag("DSW2") & (1 << offset)) ? 8 : 0) ;
59   return   ((~input_port_read(machine, "IN0") & (1 << offset)) ? 1 : 0) |
60         ((~input_port_read(machine, "IN1") & (1 << offset)) ? 2 : 0) |
61         ((~input_port_read(machine, "DSW1") & (1 << offset)) ? 4 : 0) |
62         ((~input_port_read(machine, "DSW2") & (1 << offset)) ? 8 : 0) ;
6363}
6464
6565
src/mame/drivers/pacman.c
r2375r2376
368368static MACHINE_RESET( mschamp )
369369{
370370   UINT8 *rom = memory_region(REGION_CPU1) + 0x10000;
371   int whichbank = readinputportbytag("GAME") & 1;
371   int whichbank = input_port_read(machine, "GAME") & 1;
372372
373373   memory_configure_bank(1, 0, 2, &rom[0x0000], 0x8000);
374374   memory_configure_bank(2, 0, 2, &rom[0x4000], 0x8000);
r2375r2376
405405      int portnum = port_tag_to_index("FAKE");
406406      if (portnum != -1)
407407      {
408         UINT8 value = readinputport(portnum);
408         UINT8 value = input_port_read_indexed(machine, portnum);
409409         if ((value & 7) == 5 || (value & 6) == 2)
410410            irq0_line_hold(machine, cpunum);
411411      }
src/mame/drivers/dcheese.c
r2375r2376
128128
129129static READ16_HANDLER( port_0_r )
130130{
131   return (readinputport(0) & 0xff7f) | (EEPROM_read_bit() << 7);
131   return (input_port_read_indexed(machine, 0) & 0xff7f) | (EEPROM_read_bit() << 7);
132132}
133133
134134
135135static READ16_HANDLER( port_2_r )
136136{
137   return (readinputport(2) & 0xff1f) | (!soundlatch_full << 7) | (ticket_dispenser_r(machine, 0) >> 2);
137   return (input_port_read_indexed(machine, 2) & 0xff1f) | (!soundlatch_full << 7) | (ticket_dispenser_r(machine, 0) >> 2);
138138}
139139
140140
src/mame/drivers/chqflag.c
r2375r2376
125125   static int accel, wheel;
126126
127127   switch (analog_ctrl & 0x03){
128      case 0x00: return (accel = readinputport(5));   /* accelerator */
129      case 0x01: return (wheel = readinputport(6));   /* steering */
128      case 0x00: return (accel = input_port_read_indexed(machine, 5));   /* accelerator */
129      case 0x01: return (wheel = input_port_read_indexed(machine, 6));   /* steering */
130130      case 0x02: return accel;                  /* accelerator (previous?) */
131131      case 0x03: return wheel;                  /* steering (previous?) */
132132   }
src/mame/drivers/bwing.c
r2375r2376
7878      break;
7979
8080      case 1:
81         if (~readinputport(4) & 0x03)
81         if (~input_port_read_indexed(machine, 4) & 0x03)
8282            { if (!coin) { coin = 1; cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, ASSERT_LINE); } }
8383         else
8484            coin = 0;
8585      break;
8686
8787      case 2:
88         if (readinputport(5)) cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, ASSERT_LINE);
88         if (input_port_read_indexed(machine, 5)) cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, ASSERT_LINE);
8989      break;
9090   }
9191}
r2375r2376
104104
105105static READ8_HANDLER( bwp1_io_r )
106106{
107   if (offset == 0) return(readinputport(0));
108   if (offset == 1) return(readinputport(1));
109   if (offset == 2) return(readinputport(2));
110   if (offset == 3) return(readinputport(3));
111   if (offset == 4) return(readinputport(4));
107   if (offset == 0) return(input_port_read_indexed(machine, 0));
108   if (offset == 1) return(input_port_read_indexed(machine, 1));
109   if (offset == 2) return(input_port_read_indexed(machine, 2));
110   if (offset == 3) return(input_port_read_indexed(machine, 3));
111   if (offset == 4) return(input_port_read_indexed(machine, 4));
112112
113113   return((bwp123_membase[0])[0x1b00 + offset]);
114114}
src/mame/drivers/srmp6.c
r2375r2376
348348static READ16_HANDLER( srmp6_inputs_r )
349349{
350350   if (offset == 0)         // DSW
351      return readinputport(4);
351      return input_port_read_indexed(machine, 4);
352352
353353   switch(srmp6_input_select)   // inputs
354354   {
355      case 1<<0: return readinputport(0);
356      case 1<<1: return readinputport(1);
357      case 1<<2: return readinputport(2);
358      case 1<<3: return readinputport(3);
355      case 1<<0: return input_port_read_indexed(machine, 0);
356      case 1<<1: return input_port_read_indexed(machine, 1);
357      case 1<<2: return input_port_read_indexed(machine, 2);
358      case 1<<3: return input_port_read_indexed(machine, 3);
359359   }
360360
361361   return 0;
src/mame/drivers/sf.c
r2375r2376
124124         program_write_word(0xffc00e, 0);
125125
126126         sf_fg_scroll_w(machine, 0, d1, 0);
127         sf_fg_scroll_w(machine, 0, d2, 0);
127         sf_bg_scroll_w(machine, 0, d2, 0);
128128         break;
129129      }
130130   case 4:
r2375r2376
144144            }
145145            program_write_word(0xffc682, d1);
146146            program_write_word(0xffc00e, off);
147            sf_fg_scroll_w(machine, 0, d1, 0);
147            sf_bg_scroll_w(machine, 0, d1, 0);
148148         }
149149         break;
150150      }
r2375r2376
166166
167167static READ16_HANDLER( button1_r )
168168{
169   return (scale[input_port_7_r(machine,0)]<<8)|scale[input_port_5_r(machine,0)];
169   return (scale[input_port_read_indexed(machine, 7)]<<8)|scale[input_port_read_indexed(machine, 5)];
170170}
171171
172172static READ16_HANDLER( button2_r )
173173{
174   return (scale[input_port_8_r(machine,0)]<<8)|scale[input_port_6_r(machine,0)];
174   return (scale[input_port_read_indexed(machine, 8)]<<8)|scale[input_port_read_indexed(machine, 6)];
175175}
176176
177177
src/mame/drivers/sengokmj.c
r2375r2376
6767{
6868   switch(sengokumj_mux_data)
6969   {
70      case 1:    return readinputport(2);
71      case 2:    return readinputport(3);
72      case 4:    return readinputport(4);
73      case 8:    return readinputport(5);
74      case 0x10: return readinputport(6);
75      case 0x20: return readinputport(7);
70      case 1:    return input_port_read_indexed(machine, 2);
71      case 2:    return input_port_read_indexed(machine, 3);
72      case 4:    return input_port_read_indexed(machine, 4);
73      case 8:    return input_port_read_indexed(machine, 5);
74      case 0x10: return input_port_read_indexed(machine, 6);
75      case 0x20: return input_port_read_indexed(machine, 7);
7676   }
7777
7878   return 0xffff;
src/mame/drivers/cham24.c
r2375r2376
106106   in_0_shift = 0;
107107   in_1_shift = 0;
108108
109   in_0 = readinputport(0);
110   in_1 = readinputport(1);
109   in_0 = input_port_read_indexed(machine, 0);
110   in_1 = input_port_read_indexed(machine, 1);
111111
112112}
113113
src/mame/drivers/cave.c
r2375r2376
311311
312312static READ16_HANDLER( cave_input1_r )
313313{
314   return readinputport(1) | ((EEPROM_read_bit() & 0x01) << 11);
314   return input_port_read_indexed(machine, 1) | ((EEPROM_read_bit() & 0x01) << 11);
315315}
316316
317317static READ16_HANDLER( guwange_input1_r )
318318{
319   return readinputport(1) | ((EEPROM_read_bit() & 0x01) << 7);
319   return input_port_read_indexed(machine, 1) | ((EEPROM_read_bit() & 0x01) << 7);
320320}
321321
322322static READ16_HANDLER( gaia_dsw_r )
323323{
324   return readinputport(2) | (readinputport(3) << 8);
324   return input_port_read_indexed(machine, 2) | (input_port_read_indexed(machine, 3) << 8);
325325}
326326
327327static WRITE16_HANDLER( cave_eeprom_msb_w )
r2375r2376
870870
871871static READ16_HANDLER( korokoro_input0_r )
872872{
873   return readinputport(0) | (hopper ? 0 : 0x8000);
873   return input_port_read_indexed(machine, 0) | (hopper ? 0 : 0x8000);
874874}
875875
876876static READ16_HANDLER( korokoro_input1_r )
877877{
878   return readinputport(1) | ((EEPROM_read_bit() & 0x01) << 12);
878   return input_port_read_indexed(machine, 1) | ((EEPROM_read_bit() & 0x01) << 12);
879879}
880880
881881static ADDRESS_MAP_START( korokoro_readmem, ADDRESS_SPACE_PROGRAM, 16 )
r2375r2376
10771077static READ16_HANDLER( sailormn_input0_r )
10781078{
10791079//  watchdog_reset16_r(0,0);    // written too rarely for mame.
1080   return readinputport(0);
1080   return input_port_read_indexed(machine, 0);
10811081}
10821082
10831083static READ16_HANDLER( agallet_irq_cause_r )
r2375r2376
19841984   /* modify the eeprom on a reset with the desired region for the games that have the
19851985       region factory set in eeprom */
19861986   if (cave_region_byte >= 0)
1987      EEPROM_get_data_pointer(0)[cave_region_byte] =  readinputport(2);
1987      EEPROM_get_data_pointer(0)[cave_region_byte] =  input_port_read_indexed(machine, 2);
19881988}
19891989
19901990static const struct YMZ280Binterface ymz280b_intf =
src/mame/drivers/fuukifg3.c
r2375r2376
224224\
225225static READ32_HANDLER( io32_##_N_##_r ) \
226226{ \
227   return (readinputport( _N_ ) << 16) | readinputport( _N_ ); \
227   return (input_port_read_indexed(machine, _N_ ) << 16) | input_port_read_indexed(machine, _N_ ); \
228228}
229229
230230FUUKI32_INPUT( 0 ) /* $800000.l Coins Inputs */
src/mame/drivers/dec8.c
r2375r2376
119119{
120120   switch (offset) {
121121      case 0: /* Rotary low byte */
122         return ~((1 << (readinputport(5) * 12 / 256))&0xff);
122         return ~((1 << (input_port_read_indexed(machine, 5) * 12 / 256))&0xff);
123123      case 1: /* Joystick = bottom 4 bits, rotary = top 4 */
124         return ((~((1 << (readinputport(5) * 12 / 256))>>4))&0xf0) | (readinputport(0)&0xf);
124         return ((~((1 << (input_port_read_indexed(machine, 5) * 12 / 256))>>4))&0xf0) | (input_port_read_indexed(machine, 0)&0xf);
125125   }
126126   return 0xff;
127127}
r2375r2376
130130{
131131   switch (offset) {
132132      case 0: /* Rotary low byte */
133         return ~((1 << (readinputport(6) * 12 / 256))&0xff);
133         return ~((1 << (input_port_read_indexed(machine, 6) * 12 / 256))&0xff);
134134      case 1: /* Joystick = bottom 4 bits, rotary = top 4 */
135         return ((~((1 << (readinputport(6) * 12 / 256))>>4))&0xf0) | (readinputport(1)&0xf);
135         return ((~((1 << (input_port_read_indexed(machine, 6) * 12 / 256))>>4))&0xf0) | (input_port_read_indexed(machine, 1)&0xf);
136136   }
137137   return 0xff;
138138}
r2375r2376
178178    if (i8751_value==0x5000) i8751_return=((coins / 10) << 4) | (coins % 10); /* Coin request */
179179    if (i8751_value==0x6000) {i8751_value=-1; coins--; } /* Coin clear */
180180   /* Nb:  Command 0x4000 for setting coinage options is not supported */
181    if ((readinputport(4)&1)==1) latch=1;
182    if ((readinputport(4)&1)!=1 && latch) {coins++; latch=0;}
181    if ((input_port_read_indexed(machine, 4)&1)==1) latch=1;
182    if ((input_port_read_indexed(machine, 4)&1)!=1 && latch) {coins++; latch=0;}
183183
184184   /* This next value is the index to a series of tables,
185185    each table controls the end of level bad guy, wrong values crash the
r2375r2376
246246   }
247247
248248   /* Coins are controlled by the i8751 */
249    if ((readinputport(4)&3)==3) latch=1;
250    if ((readinputport(4)&1)!=1 && latch) {coin1++; snd=1; latch=0;}
251    if ((readinputport(4)&2)!=2 && latch) {coin2++; snd=1; latch=0;}
249    if ((input_port_read_indexed(machine, 4)&3)==3) latch=1;
250    if ((input_port_read_indexed(machine, 4)&1)!=1 && latch) {coin1++; snd=1; latch=0;}
251    if ((input_port_read_indexed(machine, 4)&2)!=2 && latch) {coin2++; snd=1; latch=0;}
252252
253253   /* Work out return values */
254254   if (i8751_value==0x0000) {i8751_return=0; coin1=coin2=snd=0;}
r2375r2376
279279   }
280280
281281   /* Coins are controlled by the i8751 */
282    if (/*(readinputport(2)&3)==3*/!latch) {latch=1;coin1=coin2=0;}
283    if ((readinputport(2)&1)!=1 && latch) {coin1=1; latch=0;}
284    if ((readinputport(2)&2)!=2 && latch) {coin2=1; latch=0;}
282    if (/*(input_port_read_indexed(machine, 2)&3)==3*/!latch) {latch=1;coin1=coin2=0;}
283    if ((input_port_read_indexed(machine, 2)&1)!=1 && latch) {coin1=1; latch=0;}
284    if ((input_port_read_indexed(machine, 2)&2)!=2 && latch) {coin2=1; latch=0;}
285285
286286   if (i8751_value==0x0050) i8751_return=0; /* Breywood ID */
287287   if (i8751_value==0x0051) i8751_return=0; /* Shackled ID */
r2375r2376
309309   if(offset==0)
310310   {
311311      /* Coins are controlled by the i8751 */
312       if ((readinputport(2)&3)==3 && !latch) latch=1;
313       if ((readinputport(2)&3)!=3 && latch) {coin++; latch=0;snd=0x400;i8751_return=0x400;return;}
312       if ((input_port_read_indexed(machine, 2)&3)==3 && !latch) latch=1;
313       if ((input_port_read_indexed(machine, 2)&3)!=3 && latch) {coin++; latch=0;snd=0x400;i8751_return=0x400;return;}
314314      if (i8751_value==0x007a) i8751_return=0x0185; /* Japan ID code */
315315      if (i8751_value==0x007b) i8751_return=0x0184; /* USA ID code */
316316      if (i8751_value==0x0001) {coin=snd=0;}//???
r2375r2376
340340   if(offset==0)
341341   {
342342      /* Coins are controlled by the i8751 */
343       if ((readinputport(2)&3)==3 && !latch) latch=1;
344       if ((readinputport(2)&3)!=3 && latch) {coin++; latch=0;snd=0x1200; i8751_return=0x1200;return;}
343       if ((input_port_read_indexed(machine, 2)&3)==3 && !latch) latch=1;
344       if ((input_port_read_indexed(machine, 2)&3)!=3 && latch) {coin++; latch=0;snd=0x1200; i8751_return=0x1200;return;}
345345
346346      if (i8751_value==0x054a) {i8751_return=~(0x4a); coin=0; snd=0;} /* Captain Silver (Japan) ID */
347347      if (i8751_value==0x054c) {i8751_return=~(0x4c); coin=0; snd=0;} /* Captain Silver (World) ID */
r2375r2376
366366   }
367367
368368   /* Coins are controlled by the i8751 */
369    if ((readinputport(2)&3)==3) latch=1;
370    if ((readinputport(2)&1)!=1 && latch) {coin1++; latch=0;}
371    if ((readinputport(2)&2)!=2 && latch) {coin2++; latch=0;}
369    if ((input_port_read_indexed(machine, 2)&3)==3) latch=1;
370    if ((input_port_read_indexed(machine, 2)&1)!=1 && latch) {coin1++; latch=0;}
371    if ((input_port_read_indexed(machine, 2)&2)!=2 && latch) {coin2++; latch=0;}
372372
373373   /* Work out return values */
374374   if ((i8751_value>>8)==0x00) {i8751_return=0; coin1=coin2=0;}
r2375r2376
20462046static INTERRUPT_GEN( ghostb_interrupt )
20472047{
20482048   static int latch[4];
2049   int i8751_out=readinputport(4);
2049   int i8751_out=input_port_read_indexed(machine, 4);
20502050
20512051   /* Ghostbusters coins are controlled by the i8751 */
20522052   if ((i8751_out & 0x8) == 0x8) latch[0]=1;
r2375r2376
20732073{
20742074   static int latch=1;
20752075
2076   if ((readinputport(2) & 0x7) == 0x7) latch=1;
2077   if (latch && (readinputport(2) & 0x7) != 0x7) {
2076   if ((input_port_read_indexed(machine, 2) & 0x7) == 0x7) latch=1;
2077   if (latch && (input_port_read_indexed(machine, 2) & 0x7) != 0x7) {
20782078      latch=0;
20792079       cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE);
20802080    }
src/mame/drivers/atarigt.c
r2375r2376
106106
107107static READ32_HANDLER( inputs_01_r )
108108{
109   return (readinputportbytag("IN0") << 16) | readinputportbytag("IN1");
109   return (input_port_read(machine, "IN0") << 16) | input_port_read(machine, "IN1");
110110}
111111
112112
113113static READ32_HANDLER( special_port2_r )
114114{
115   int temp = readinputportbytag("IN2");
115   int temp = input_port_read(machine, "IN2");
116116   temp ^= 0x0001;      /* /A2DRDY always high for now */
117117   temp ^= 0x0008;      /* A2D.EOC always high for now */
118118   return (temp << 16) | temp;
r2375r2376
121121
122122static READ32_HANDLER( special_port3_r )
123123{
124   int temp = readinputportbytag("IN3");
124   int temp = input_port_read(machine, "IN3");
125125   if (atarigen_video_int_state) temp ^= 0x0001;
126126   if (atarigen_scanline_int_state) temp ^= 0x0002;
127127   return (temp << 16) | temp;
r2375r2376
131131#if (HACK_TMEK_CONTROLS)
132132INLINE void compute_fake_pots(int *pots)
133133{
134   int fake = readinputportbytag("FAKE");
134   int fake = input_port_read(machine, "FAKE");
135135
136136   pots[0] = pots[1] = pots[2] = pots[3] = 0x80;
137137
r2375r2376
168168   compute_fake_pots(pots);
169169   return (pots[0] << 24) | (pots[3] << 8);
170170#else
171   return (readinputportbytag("IN4") << 24) | (readinputportbytag("IN5") << 8);
171   return (input_port_read(machine, "IN4") << 24) | (input_port_read(machine, "IN5") << 8);
172172#endif
173173}
174174
r2375r2376
180180   compute_fake_pots(pots);
181181   return (pots[2] << 24) | (pots[1] << 8);
182182#else
183   return (readinputportbytag("IN6") << 24) | (readinputportbytag("IN7") << 8);
183   return (input_port_read(machine, "IN6") << 24) | (input_port_read(machine, "IN7") << 8);
184184#endif
185185}
186186
src/mame/drivers/tourtabl.c
r2375r2376
5454
5555static READ16_HANDLER( tourtabl_read_input_port )
5656{
57   return readinputport(offset);
57   return input_port_read_indexed(machine, offset);
5858}
5959
6060static READ8_HANDLER( tourtabl_get_databus_contents )
src/mame/drivers/genesis.c
r2375r2376
320320   {
321321      offset &=0x1fff;
322322//      if(offset == 0)
323//          return (readinputport(8) << 8) ^ 0xff00;
323//          return (input_port_read_indexed(machine, 8) << 8) ^ 0xff00;
324324      return (ic36_ram[offset] << 8) + ic36_ram[offset+1];
325325   }
326326
r2375r2376
471471
472472         if (genesis_io_ram[offset] & 0x40)
473473         {
474            int iport = readinputport(9);
474            int iport = input_port_read_indexed(machine, 9);
475475            return_value = iport & 0x3f;
476476         }
477477         else
478478         {
479            int iport1 = readinputport(12);
480            int iport2 = readinputport(7) >> 1;
479            int iport1 = input_port_read_indexed(machine, 12);
480            int iport2 = input_port_read_indexed(machine, 7) >> 1;
481481            return_value = (iport1 & 0x10) + (iport2 & 0x20);
482482            if(iport1 & 0x10 || iport2 & 0x20)
483483               return_value+=1;
r2375r2376
492492
493493         if (genesis_io_ram[offset] & 0x40)
494494         {
495            int iport1 = (readinputport(9) & 0xc0) >> 6;
496            int iport2 = (readinputport(8) & 0x0f) << 2;
495            int iport1 = (input_port_read_indexed(machine, 9) & 0xc0) >> 6;
496            int iport2 = (input_port_read_indexed(machine, 8) & 0x0f) << 2;
497497            return_value = (iport1 + iport2) & 0x3f;
498498         }
499499         else
500500         {
501            int iport1 = readinputport(12) << 2;
502            int iport2 = readinputport(7) >> 2;
501            int iport1 = input_port_read_indexed(machine, 12) << 2;
502            int iport2 = input_port_read_indexed(machine, 7) >> 2;
503503            return_value = (iport1 & 0x10) + (iport2 & 0x20);
504504            if(iport1 & 0x10 || iport2 & 0x20)
505505               return_value+=1;
r2375r2376
541541      case 1: /* port A data (joypad 1) */
542542
543543         if (genesis_io_ram[offset] & 0x40)
544            return_value = readinputport(1) & (genesis_io_ram[4]^0xff);
544            return_value = input_port_read_indexed(machine, 1) & (genesis_io_ram[4]^0xff);
545545         else
546546         {
547            return_value = readinputport(2) & (genesis_io_ram[4]^0xff);
548            return_value |= readinputport(1) & 0x03;
547            return_value = input_port_read_indexed(machine, 2) & (genesis_io_ram[4]^0xff);
548            return_value |= input_port_read_indexed(machine, 1) & 0x03;
549549         }
550550         return_value = (genesis_io_ram[offset] & 0x80) | return_value;
551551//          logerror ("reading joypad 1 , type %02x %02x\n",genesis_io_ram[offset] & 0xb0, return_value &0x7f);
r2375r2376
554554      case 2: /* port B data (joypad 2) */
555555
556556         if (genesis_io_ram[offset] & 0x40)
557            return_value = readinputport(3) & (genesis_io_ram[5]^0xff);
557            return_value = input_port_read_indexed(machine, 3) & (genesis_io_ram[5]^0xff);
558558         else
559559         {
560            return_value = readinputport(4) & (genesis_io_ram[5]^0xff);
561            return_value |= readinputport(3) & 0x03;
560            return_value = input_port_read_indexed(machine, 4) & (genesis_io_ram[5]^0xff);
561            return_value |= input_port_read_indexed(machine, 3) & 0x03;
562562         }
563563         return_value = (genesis_io_ram[offset] & 0x80) | return_value;
564564//          logerror ("reading joypad 2 , type %02x %02x\n",genesis_io_ram[offset] & 0xb0, return_value &0x7f);
src/mame/drivers/cloud9.c
r2375r2376
248248
249249static READ8_HANDLER( leta_r )
250250{
251   return readinputport(3 + offset);
251   return input_port_read_indexed(machine, 3 + offset);
252252}
253253
254254
src/mame/drivers/rpunch.c
r2375r2376
165165
166166static READ16_HANDLER( common_port_r )
167167{
168   return readinputport(offset) | readinputport(2);
168   return input_port_read_indexed(machine, offset) | input_port_read_indexed(machine, 2);
169169}
170170
171171
src/mame/drivers/changela.c
r2375r2376
9595
9696static READ8_HANDLER( changela_68705_portB_r )
9797{
98   return (portB_out & ddrB) | (readinputport(4) & ~ddrB);
98   return (portB_out & ddrB) | (input_port_read_indexed(machine, 4) & ~ddrB);
9999}
100100
101101static WRITE8_HANDLER( changela_68705_portB_w )
r2375r2376
177177
178178static READ8_HANDLER( changela_30_r )
179179{
180   return readinputport(7) & 0x0f;   //wheel control (clocked input) signal on bits 3,2,1,0
180   return input_port_read_indexed(machine, 7) & 0x0f;   //wheel control (clocked input) signal on bits 3,2,1,0
181181}
182182
183183static READ8_HANDLER( changela_31_r )
r2375r2376
186186       or if the new value is greater than the old value, and it did wrap around,
187187       then we are moving LEFT. */
188188   static UINT8 prev_value = 0;
189   UINT8 curr_value = readinputport(7);
189   UINT8 curr_value = input_port_read_indexed(machine, 7);
190190   static int dir = 0;
191191
192192   if( (curr_value < prev_value && (prev_value - curr_value) < 0x80)
r2375r2376
204204
205205static READ8_HANDLER( changela_2c_r )
206206{
207   int val = readinputport(5);
207   int val = input_port_read_indexed(machine, 5);
208208
209209    val = (val&0x30) | ((val&1)<<7) | (((val&1)^1)<<6);
210210
r2375r2376
221221      v8 = 1;
222222
223223   /* Gas pedal is made up of 2 switches, 1 active low, 1 active high */
224   switch(readinputport(6) & 0x03)
224   switch(input_port_read_indexed(machine, 6) & 0x03)
225225   {
226226      case 0x02:
227227         gas = 0x80;
r2375r2376
234234         break;
235235   }
236236
237   return (readinputport(6) & 0x20) | gas | (v8<<4);
237   return (input_port_read_indexed(machine, 6) & 0x20) | gas | (v8<<4);
238238}
239239
240240static WRITE8_HANDLER( mcu_PC0_w )
src/mame/drivers/rabbit.c
r2375r2376
448448{
449449   int rv;
450450
451   rv = (readinputport(1)<<16)|(readinputport(0));
451   rv = (input_port_read_indexed(machine, 1)<<16)|(input_port_read_indexed(machine, 0));
452452   rv &= ~1;
453453   rv |= EEPROM_read_bit();   // as per code at 4d932
454454   return rv;
r2375r2376
458458{
459459   int rv;
460460
461   rv = (readinputport(1)<<16)|(readinputport(0));
461   rv = (input_port_read_indexed(machine, 1)<<16)|(input_port_read_indexed(machine, 0));
462462   rv &= ~0x80;
463463   rv |= (EEPROM_read_bit()<<7);   // as per code at 778
464464   return rv;
src/mame/drivers/triplhnt.c
r2375r2376
7676   discrete_sound_w(machine, TRIPLHNT_LAMP_EN, triplhnt_misc_flags & 0x02);   // Lamp is used to reset noise
7777   discrete_sound_w(machine, TRIPLHNT_BEAR_EN, triplhnt_misc_flags & 0x80);   // bear
7878
79   is_witch_hunt = readinputport(2) == 0x40;
79   is_witch_hunt = input_port_read_indexed(machine, 2) == 0x40;
8080   bit = ~triplhnt_misc_flags & 0x40;
8181
8282   /* if we're not playing the sample yet, start it */
r2375r2376
108108static READ8_HANDLER( triplhnt_input_port_4_r )
109109{
110110   watchdog_reset_w(machine, 0, 0);
111   return readinputport(4);
111   return input_port_read_indexed(machine, 4);
112112}
113113
114114
115115static READ8_HANDLER( triplhnt_misc_r )
116116{
117117   triplhnt_update_misc(machine, offset);
118   return readinputport(7) | triplhnt_hit_code;
118   return input_port_read_indexed(machine, 7) | triplhnt_hit_code;
119119}
120120
121121
122122static READ8_HANDLER( triplhnt_da_latch_r )
123123{
124   int cross_x = readinputport(8);
125   int cross_y = readinputport(9);
124   int cross_x = input_port_read_indexed(machine, 8);
125   int cross_y = input_port_read_indexed(machine, 9);
126126
127127   triplhnt_da_latch = offset;
128128
src/mame/drivers/backfire.c
r2375r2376
231231{
232232   /* some kind of screen indicator?  checked by backfira set before it will boot */
233233   int backfire_screen = mame_rand(Machine)&1;
234   return ((EEPROM_read_bit()<<24) | readinputport(0) | (readinputport(3)<<16)) ^  (backfire_screen << 26) ;
234   return ((EEPROM_read_bit()<<24) | input_port_read_indexed(machine, 0) | (input_port_read_indexed(machine, 3)<<16)) ^  (backfire_screen << 26) ;
235235}
236236
237237static READ32_HANDLER(backfire_control2_r)
238238{
239239//  logerror("%08x:Read eprom %08x (%08x)\n",activecpu_get_pc(),offset<<1,mem_mask);
240   return (EEPROM_read_bit()<<24) | readinputport(1) | (readinputport(1)<<16);
240   return (EEPROM_read_bit()<<24) | input_port_read_indexed(machine, 1) | (input_port_read_indexed(machine, 1)<<16);
241241}
242242
243243#ifdef UNUSED_FUNCTION
244244static READ32_HANDLER(backfire_control3_r)
245245{
246246//  logerror("%08x:Read eprom %08x (%08x)\n",activecpu_get_pc(),offset<<1,mem_mask);
247   return (EEPROM_read_bit()<<24) | readinputport(2) | (readinputport(2)<<16);
247   return (EEPROM_read_bit()<<24) | input_port_read_indexed(machine, 2) | (input_port_read_indexed(machine, 2)<<16);
248248}
249249#endif
250250
r2375r2376
306306#ifdef UNUSED_FUNCTION
307307READ32_HANDLER( backfire_unknown_wheel_r )
308308{
309   return readinputport(4);
309   return input_port_read_indexed(machine, 4);
310310}
311311
312312READ32_HANDLER( backfire_wheel1_r )
src/mame/drivers/wolfpack.c
r2375r2376
5858
5959static READ8_HANDLER( wolfpack_input_r )
6060{
61   UINT8 val = readinputport(0);
61   UINT8 val = input_port_read_indexed(machine, 0);
6262
63   if (((readinputport(2) + 0) / 2) & 1)
63   if (((input_port_read_indexed(machine, 2) + 0) / 2) & 1)
6464   {
6565      val |= 1;
6666   }
67   if (((readinputport(2) + 1) / 2) & 1)
67   if (((input_port_read_indexed(machine, 2) + 1) / 2) & 1)
6868   {
6969      val |= 2;
7070   }
src/mame/drivers/tankbatt.c
r2375r2376
8181{
8282   int val;
8383
84   val = readinputport(0);
84   val = input_port_read_indexed(machine, 0);
8585   return ((val << (7-offset)) & 0x80);
8686}
8787
r2375r2376
8989{
9090   int val;
9191
92   val = readinputport(1);
92   val = input_port_read_indexed(machine, 1);
9393   return ((val << (7-offset)) & 0x80);
9494}
9595
r2375r2376
9797{
9898   int val;
9999
100   val = readinputport(2);
100   val = input_port_read_indexed(machine, 2);
101101   return ((val << (7-offset)) & 0x80);
102102}
103103
r2375r2376
177177
178178static INTERRUPT_GEN( tankbatt_interrupt )
179179{
180   if ((readinputport (0) & 0x60) == 0) cpunum_set_input_line(machine, 0,0,HOLD_LINE);
180   if ((input_port_read_indexed(machine, 0) & 0x60) == 0) cpunum_set_input_line(machine, 0,0,HOLD_LINE);
181181   else if (tankbatt_nmi_enable) cpunum_set_input_line(machine, 0,INPUT_LINE_NMI,PULSE_LINE);
182182}
183183
src/mame/drivers/segas18.c
r2375r2376
236236            return misc_io_data[offset];
237237
238238         /* otherwise, return an input port */
239         return readinputport(offset);
239         return input_port_read_indexed(machine, offset);
240240
241241      /* 'SEGA' protection */
242242      case 0x10/2:
r2375r2376
330330
331331      /* video control latch */
332332      case 0x2000/2:
333         return readinputport(4 + (offset & 1));
333         return input_port_read_indexed(machine, 4 + (offset & 1));
334334   }
335335   if (custom_io_r)
336336      return custom_io_r(machine, offset, mem_mask);
r2375r2376
419419   switch (offset)
420420   {
421421      case 0x3020/2:
422         return readinputportbytag("P3");
422         return input_port_read(machine, "P3");
423423
424424      case 0x3022/2:
425         return readinputportbytag("P4");
425         return input_port_read(machine, "P4");
426426
427427      case 0x3024/2:
428         return readinputportbytag("P34START");
428         return input_port_read(machine, "P34START");
429429   }
430430   return segaic16_open_bus_r(machine,0,0);
431431}
r2375r2376
460460   switch (offset)
461461   {
462462      case 0x3010/2:
463         lghost_value = 255 - readinputportbytag("GUNY1");
463         lghost_value = 255 - input_port_read(machine, "GUNY1");
464464         break;
465465
466466      case 0x3012/2:
467         lghost_value = readinputportbytag("GUNX1");
467         lghost_value = input_port_read(machine, "GUNX1");
468468         break;
469469
470470      case 0x3014/2:
471         lghost_value = 255 - readinputportbytag(lghost_select ? "GUNY3" : "GUNY2");
471         lghost_value = 255 - input_port_read(machine, lghost_select ? "GUNY3" : "GUNY2");
472472         break;
473473
474474      case 0x3016/2:
475         lghost_value = readinputportbytag(lghost_select ? "GUNX3" : "GUNX2");
475         lghost_value = input_port_read(machine, lghost_select ? "GUNX3" : "GUNX2");
476476         break;
477477
478478      case 0x3020/2:
r2375r2376
494494   switch (offset)
495495   {
496496      case 0x3000/2:
497         return (readinputportbytag("TRACKX1") - wwally_last_x[0]) & 0xff;
497         return (input_port_read(machine, "TRACKX1") - wwally_last_x[0]) & 0xff;
498498
499499      case 0x3004/2:
500         return (readinputportbytag("TRACKY1") - wwally_last_y[0]) & 0xff;
500         return (input_port_read(machine, "TRACKY1") - wwally_last_y[0]) & 0xff;
501501
502502      case 0x3008/2:
503         return (readinputportbytag("TRACKX2") - wwally_last_x[1]) & 0xff;
503         return (input_port_read(machine, "TRACKX2") - wwally_last_x[1]) & 0xff;
504504
505505      case 0x300c/2:
506         return (readinputportbytag("TRACKY2") - wwally_last_y[1]) & 0xff;
506         return (input_port_read(machine, "TRACKY2") - wwally_last_y[1]) & 0xff;
507507
508508      case 0x3010/2:
509         return (readinputportbytag("TRACKX3") - wwally_last_x[2]) & 0xff;
509         return (input_port_read(machine, "TRACKX3") - wwally_last_x[2]) & 0xff;
510510
511511      case 0x3014/2:
512         return (readinputportbytag("TRACKY3") - wwally_last_y[2]) & 0xff;
512         return (input_port_read(machine, "TRACKY3") - wwally_last_y[2]) & 0xff;
513513   }
514514   return segaic16_open_bus_r(machine,0,0);
515515}
r2375r2376
521521   {
522522      case 0x3000/2:
523523      case 0x3004/2:
524         wwally_last_x[0] = readinputportbytag("TRACKX1");
525         wwally_last_y[0] = readinputportbytag("TRACKY1");
524         wwally_last_x[0] = input_port_read(machine, "TRACKX1");
525         wwally_last_y[0] = input_port_read(machine, "TRACKY1");
526526         break;
527527
528528      case 0x3008/2:
529529      case 0x300c/2:
530         wwally_last_x[1] = readinputportbytag("TRACKX2");
531         wwally_last_y[1] = readinputportbytag("TRACKY2");
530         wwally_last_x[1] = input_port_read(machine, "TRACKX2");
531         wwally_last_y[1] = input_port_read(machine, "TRACKY2");
532532         break;
533533
534534      case 0x3010/2:
535535      case 0x3014/2:
536         wwally_last_x[2] = readinputportbytag("TRACKX3");
537         wwally_last_y[2] = readinputportbytag("TRACKY3");
536         wwally_last_x[2] = input_port_read(machine, "TRACKX3");
537         wwally_last_y[2] = input_port_read(machine, "TRACKY3");
538538         break;
539539   }
540540}
r2375r2376
10401040   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(3)
10411041
10421042   PORT_MODIFY("P2")
1043   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN)
1044   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN)
1045   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN)
1046   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN)
1047   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED) /* P2 joystick inputs, unused in lghost */
1048   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED)
1049   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED)
1050   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED)
1043   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
1044   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1045   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1046   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1047   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) /* P2 joystick inputs, unused in lghost */
1048   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED )
1049   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
1050   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
10511051
10521052   PORT_MODIFY("SERVICE")
10531053   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
r2375r2376
10641064   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
10651065   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
10661066   PORT_DIPNAME( 0x1c, 0x1c, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SWB:3,4,5")
1067   PORT_DIPSETTING(    0x04, DEF_STR( Harder ) )
1068   PORT_DIPSETTING(    0x08, DEF_STR( Hardest ) )
10691067   PORT_DIPSETTING(    0x0c, DEF_STR( Easiest ) )
1068   PORT_DIPSETTING(    0x14, DEF_STR( Easier ) )
1069    PORT_DIPSETTING(    0x18, DEF_STR( Easy ) )
10701070    PORT_DIPSETTING(    0x1c, DEF_STR( Normal ) )
10711071   PORT_DIPSETTING(    0x10, DEF_STR( Hard ) )
1072   PORT_DIPSETTING(    0x14, DEF_STR( Easier ) )
1073    PORT_DIPSETTING(    0x18, DEF_STR( Easy ) )
1072   PORT_DIPSETTING(    0x04, DEF_STR( Harder ) )
1073   PORT_DIPSETTING(    0x08, DEF_STR( Hardest ) )
10741074   PORT_DIPSETTING(    0x00, "Extra Hardest" )
1075   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Allow_Continue ) ) PORT_DIPLOCATION("SWB:6")
1076   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
1077   PORT_DIPSETTING(    0x20, DEF_STR( Yes ) )
10751078   PORT_DIPNAME( 0x40, 0x40, "Coin Chute" ) PORT_DIPLOCATION("SWB:7")
10761079   PORT_DIPSETTING(    0x00, "Common" )
10771080   PORT_DIPSETTING(    0x40, "Individual" )
src/mame/drivers/meijinsn.c
r2375r2376
8484   switch (offset)
8585   {
8686      case 0: /* Dipswitch 2 */
87         shared_ram[0] = (source&0xff00)|readinputportbytag("IN2");
87         shared_ram[0] = (source&0xff00)|input_port_read(machine, "IN2");
8888         return 0;
8989
9090      case 0x22: /* Coin value */
r2375r2376
9595
9696         credits=0;
9797
98         if ((readinputportbytag("IN3")&0x3)==3) latch=0;
98         if ((input_port_read(machine, "IN3")&0x3)==3) latch=0;
9999
100         if ((readinputportbytag("IN3")&0x1)==0 && !latch)
100         if ((input_port_read(machine, "IN3")&0x1)==0 && !latch)
101101         {
102102            shared_ram[0x29] = (source&0xff00)|(0x22);   // coinA
103103            shared_ram[0x22] = (source&0xff00)|0x0;
104104            latch=1;
105105
106            coinvalue = (~readinputportbytag("IN2")>>3) & 1;
106            coinvalue = (~input_port_read(machine, "IN2")>>3) & 1;
107107
108108            deposits1++;
109109            if (deposits1 == coinage1[coinvalue][0])
r2375r2376
114114            else
115115               credits = 0;
116116         }
117         else if ((readinputportbytag("IN3")&0x2)==0 && !latch)
117         else if ((input_port_read(machine, "IN3")&0x2)==0 && !latch)
118118         {
119119            shared_ram[0x29] = (source&0xff00)|(0x22);   // coinA
120120            shared_ram[0x22] = (source&0xff00)|0x0;
121121            latch=1;
122122
123            coinvalue = (~readinputportbytag("IN2")>>3) & 1;
123            coinvalue = (~input_port_read(machine, "IN2")>>3) & 1;
124124
125125            deposits2++;
126126            if (deposits2 == coinage2[coinvalue][0])
src/mame/drivers/royalmah.c
r2375r2376
251251{
252252   switch (dsw_select)
253253   {
254      case 0x00: return readinputport(13);   /* DSW3 */
255      case 0x20: return readinputport(14);   /* DSW4 */
256      case 0x40: return readinputport(12);   /* DSW2 */
254      case 0x00: return input_port_read_indexed(machine, 13);   /* DSW3 */
255      case 0x20: return input_port_read_indexed(machine, 14);   /* DSW4 */
256      case 0x40: return input_port_read_indexed(machine, 12);   /* DSW2 */
257257   }
258258   return 0;
259259}
r2375r2376
271271   {
272272      switch (suzume_bank)
273273      {
274         case 0x08: return readinputport(14);   /* DSW4 */
275         case 0x10: return readinputport(13);   /* DSW3 */
276         case 0x18: return readinputport(12);   /* DSW2 */
274         case 0x08: return input_port_read_indexed(machine, 14);   /* DSW4 */
275         case 0x10: return input_port_read_indexed(machine, 13);   /* DSW3 */
276         case 0x18: return input_port_read_indexed(machine, 12);   /* DSW2 */
277277      }
278278      return 0;
279279   }
r2375r2376
312312
313313static READ8_HANDLER( mjapinky_dsw_r )
314314{
315   if (rombank == 0x0e)   return readinputport(13);
315   if (rombank == 0x0e)   return input_port_read_indexed(machine, 13);
316316   else               return *(memory_region(REGION_CPU1) + 0x10000 + 0x8000 * rombank);
317317}
318318
r2375r2376
502502
503503static READ8_HANDLER( janptr96_dsw_r )
504504{
505   if (~dsw_select & 0x01) return readinputportbytag("DSW4");
506   if (~dsw_select & 0x02) return readinputportbytag("DSW3");
507   if (~dsw_select & 0x04) return readinputportbytag("DSW2");
508   if (~dsw_select & 0x08) return readinputportbytag("DSW1");
509   if (~dsw_select & 0x10) return readinputportbytag("DSWTOP");
505   if (~dsw_select & 0x01) return input_port_read(machine, "DSW4");
506   if (~dsw_select & 0x02) return input_port_read(machine, "DSW3");
507   if (~dsw_select & 0x04) return input_port_read(machine, "DSW2");
508   if (~dsw_select & 0x08) return input_port_read(machine, "DSW1");
509   if (~dsw_select & 0x10) return input_port_read(machine, "DSWTOP");
510510   return 0xff;
511511}
512512
r2375r2376
572572
573573   switch(offset)
574574   {
575      case 0x8000:   return readinputport(14);      // dsw 4
576      case 0x8200:   return readinputport(13);      // dsw 3
575      case 0x8000:   return input_port_read_indexed(machine, 14);      // dsw 4
576      case 0x8200:   return input_port_read_indexed(machine, 13);      // dsw 3
577577      case 0x9001:   return AY8910_read_port_0_r(machine,0);   // inputs
578      case 0x9011:   return readinputport(10);
578      case 0x9011:   return input_port_read_indexed(machine, 10);
579579   }
580580
581581   logerror("%04X: unmapped input read at %04X\n", activecpu_get_pc(), offset);
r2375r2376
624624
625625static READ8_HANDLER( mjifb_p3_r )
626626{
627   return readinputport(11) >> 6;
627   return input_port_read_indexed(machine, 11) >> 6;
628628}
629629static READ8_HANDLER( mjifb_p5_r )
630630{
631   return readinputport(11);
631   return input_port_read_indexed(machine, 11);
632632}
633633static READ8_HANDLER( mjifb_p6_r )
634634{
635   return readinputport(12);
635   return input_port_read_indexed(machine, 12);
636636}
637637static READ8_HANDLER( mjifb_p7_r )
638638{
639   return readinputport(12) >> 4;
639   return input_port_read_indexed(machine, 12) >> 4;
640640}
641641static READ8_HANDLER( mjifb_p8_r )
642642{
r2375r2376
679679
680680   switch(offset)
681681   {
682      case 0x8000:   return readinputport(14);      // dsw 2
683      case 0x8001:   return readinputport(13);      // dsw 1
682      case 0x8000:   return input_port_read_indexed(machine, 14);      // dsw 2
683      case 0x8001:   return input_port_read_indexed(machine, 13);      // dsw 1
684684      case 0x9001:   return AY8910_read_port_0_r(machine,0);   // inputs
685      case 0x9011:   return readinputport(10);
685      case 0x9011:   return input_port_read_indexed(machine, 10);
686686   }
687687
688688   logerror("%04X: unmapped input read at %04X\n", activecpu_get_pc(), offset);
r2375r2376
795795{
796796   switch( dsw_select )
797797   {
798      case 0x00: return readinputportbytag("DSW1");
799      case 0x01: return readinputportbytag("DSW2");
800      case 0x02: return readinputportbytag("DSW3");
801      case 0x03: return readinputportbytag("DSW4");
802      case 0x04: return readinputportbytag("DSWTOP");
798      case 0x00: return input_port_read(machine, "DSW1");
799      case 0x01: return input_port_read(machine, "DSW2");
800      case 0x02: return input_port_read(machine, "DSW3");
801      case 0x03: return input_port_read(machine, "DSW4");
802      case 0x04: return input_port_read(machine, "DSWTOP");
803803   }
804804   logerror("%04X: unmapped dsw read %02X\n", activecpu_get_pc(), dsw_select);
805805   return 0xff;
src/mame/drivers/mquake.c
r2375r2376
88
99
1010#include "driver.h"
11#include "deprecat.h"
1112#include "includes/amiga.h"
1213#include "sound/es5503.h"
1314
r2375r2376
3031
3132static UINT8 mquake_cia_0_porta_r(void)
3233{
33   return readinputportbytag("CIA0PORTA");
34   return input_port_read(Machine, "CIA0PORTA");
3435}
3536
3637static void mquake_cia_0_porta_w(UINT8 data)
r2375r2376
124125static READ16_HANDLER( coin_chip_r )
125126{
126127   if (offset == 1)
127      return readinputportbytag("COINCHIP");
128      return input_port_read(machine, "COINCHIP");
128129   logerror("%06x:coin_chip_r(%02x) & %04x\n", activecpu_get_pc(), offset, mem_mask ^ 0xffff);
129130   return 0xffff;
130131}
src/mame/drivers/m10.c
r2375r2376
181181   /* I have NO IDEA if this is correct or not */
182182   state->bottomline = ~data & 0x20;
183183
184   if (readinputportbytag("CAB") & 0x01)
184   if (input_port_read(machine, "CAB") & 0x01)
185185      state->flip = ~data & 0x10;
186186
187   if (!(readinputportbytag("CAB") & 0x02))
187   if (!(input_port_read(machine, "CAB") & 0x02))
188188      sound_global_enable(~data & 0x80);
189189
190190   /* sound command in lower 4 bytes */
r2375r2376
257257
258258   state->bottomline = ~data & 0x20;
259259
260   if (readinputportbytag("CAB") & 0x01)
260   if (input_port_read(machine, "CAB") & 0x01)
261261      state->flip = ~data & 0x10;
262262
263   if (!(readinputportbytag("CAB") & 0x02))
263   if (!(input_port_read(machine, "CAB") & 0x02))
264264      sound_global_enable(~data & 0x80);
265265}
266266
r2375r2376
287287   if (data & 0xF0)
288288      popmessage("M15 ctrl: %02x",data);
289289#endif
290   if (readinputportbytag("CAB") & 0x01)
290   if (input_port_read(machine, "CAB") & 0x01)
291291      state->flip = ~data & 0x04;
292   if (!(readinputportbytag("CAB") & 0x02))
292   if (!(input_port_read(machine, "CAB") & 0x02))
293293      sound_global_enable(~data & 0x08);
294294}
295295
src/osd/windows/input.c
r2375r2376
12301230      return utf8_from_tstring(namestring);
12311231
12321232   // otherwise, allocate space to add the suffix
1233   combined = malloc_or_die(_tcslen(namestring) + 1 + _tcslen(suffix) + 1);
1233   combined = malloc_or_die(sizeof(TCHAR) * (_tcslen(namestring) + 1 + _tcslen(suffix) + 1));
12341234   _tcscpy(combined, namestring);
12351235   _tcscat(combined, TEXT(" "));
12361236   _tcscat(combined, suffix);
src/osd/winui/winui.c
r2375r2376
55915591         // read playback header
55925592         mame_fread(pPlayBack, &input_header, sizeof(inp_header));
55935593
5594         if (!isalnum(input_header.name[0])) // If first byte is not alpha-numeric
5594         if (!isalnum(input_header.gamename[0])) // If first byte is not alpha-numeric
55955595            mame_fseek(pPlayBack, 0, SEEK_SET); // old .inp file - no header
55965596         else
55975597         {
55985598            int i;
55995599            for (i = 0; drivers[i] != 0; i++) // find game and play it
56005600            {
5601               if (strcmp(drivers[i]->name, input_header.name) == 0)
5601               if (strcmp(drivers[i]->name, input_header.gamename) == 0)
56025602               {
56035603                  nGame = i;
56045604                  break;
src/emu/cpu/m6805/m6805.h
r2375r2376
6161/****************************************************************************/
6262/* Read a byte from given memory location                                   */
6363/****************************************************************************/
64#define M6805_RDMEM(Addr) ((unsigned)program_read_byte_8(Addr))
64#define M6805_RDMEM(Addr) ((unsigned)program_read_byte_8be(Addr))
6565
6666/****************************************************************************/
6767/* Write a byte to given memory location                                    */
6868/****************************************************************************/
69#define M6805_WRMEM(Addr,Value) (program_write_byte_8(Addr,Value))
69#define M6805_WRMEM(Addr,Value) (program_write_byte_8be(Addr,Value))
7070
7171/****************************************************************************/
7272/* M6805_RDOP() is identical to M6805_RDMEM() except it is used for reading */
src/emu/cpu/v30mz/v30mz.h
r2375r2376
7070
7171#define DefaultBase(Seg) ((seg_prefix && (Seg==DS || Seg==SS)) ? prefix_base : I.sregs[Seg] << 4)
7272
73#define GetMemB(Seg,Off) ((UINT8)program_read_byte_8((DefaultBase(Seg)+(Off))))
74#define GetMemW(Seg,Off) ((UINT16) program_read_byte_8((DefaultBase(Seg)+(Off))) + (program_read_byte_8((DefaultBase(Seg)+((Off)+1)))<<8) )
73#define GetMemB(Seg,Off) ((UINT8)program_read_byte_8le((DefaultBase(Seg)+(Off))))
74#define GetMemW(Seg,Off) ((UINT16) program_read_byte_8le((DefaultBase(Seg)+(Off))) + (program_read_byte_8le((DefaultBase(Seg)+((Off)+1)))<<8) )
7575
76#define PutMemB(Seg,Off,x) { program_write_byte_8((DefaultBase(Seg)+(Off)),(x)); }
76#define PutMemB(Seg,Off,x) { program_write_byte_8le((DefaultBase(Seg)+(Off)),(x)); }
7777#define PutMemW(Seg,Off,x) { PutMemB(Seg,Off,(x)&0xff); PutMemB(Seg,(Off)+1,(BYTE)((x)>>8)); }
7878
7979/* Todo:  Remove these later - plus readword could overflow */
80#define ReadByte(ea) ((BYTE)program_read_byte_8((ea)))
81#define ReadWord(ea) (program_read_byte_8((ea))+(program_read_byte_8(((ea)+1))<<8))
82#define WriteByte(ea,val) { program_write_byte_8((ea),val); }
83#define WriteWord(ea,val) { program_write_byte_8((ea),(BYTE)(val)); program_write_byte_8(((ea)+1),(val)>>8); }
80#define ReadByte(ea) ((BYTE)program_read_byte_8le((ea)))
81#define ReadWord(ea) (program_read_byte_8le((ea))+(program_read_byte_8le(((ea)+1))<<8))
82#define WriteByte(ea,val) { program_write_byte_8le((ea),val); }
83#define WriteWord(ea,val) { program_write_byte_8le((ea),(BYTE)(val)); program_write_byte_8le(((ea)+1),(val)>>8); }
8484
85#define read_port(port) io_read_byte_8(port)
86#define write_port(port,val) io_write_byte_8(port,val)
85#define read_port(port) io_read_byte_8le(port)
86#define write_port(port,val) io_write_byte_8le(port,val)
8787
8888#define FETCH (cpu_readop_arg((I.sregs[CS]<<4)+I.ip++))
8989#define FETCHOP (cpu_readop((I.sregs[CS]<<4)+I.ip++))
src/emu/cpu/m6809/m6809.h
r2375r2376
1919/* Read a byte from given memory location                                   */
2020/****************************************************************************/
2121/* ASG 971005 -- changed to program_read_byte_8/cpu_writemem16 */
22#define M6809_RDMEM(Addr) ((unsigned)program_read_byte_8(Addr))
22#define M6809_RDMEM(Addr) ((unsigned)program_read_byte_8be(Addr))
2323
2424/****************************************************************************/
2525/* Write a byte to given memory location                                    */
2626/****************************************************************************/
27#define M6809_WRMEM(Addr,Value) (program_write_byte_8(Addr,Value))
27#define M6809_WRMEM(Addr,Value) (program_write_byte_8be(Addr,Value))
2828
2929/****************************************************************************/
3030/* Z80_RDOP() is identical to Z80_RDMEM() except it is used for reading     */
src/emu/cpu/h83002/h83002.c
r2375r2376
316316   h8.regs[reg] = data;
317317}
318318
319static void h8_onstateload(void)
319static STATE_POSTLOAD( h8_onstateload )
320320{
321321   h8_set_ccr(h8.ccr);
322322}
r2375r2376
344344   state_save_register_item("H8/3002", index, h8.h8TCNT3);
345345   state_save_register_item("H8/3002", index, h8.h8TCNT4);
346346
347   state_save_register_func_postload(h8_onstateload);
347   state_save_register_postload(Machine, h8_onstateload, NULL);
348348
349349   h8_itu_init();
350350}
src/emu/cpu/h83002/h8periph.c
r2375r2376
400400         val = io_read_byte(H8_SERIAL_B);
401401         break;
402402      case 0xe0:
403         val = io_read_byte_8(H8_ADC_0_H);
403         val = io_read_byte(H8_ADC_0_H);
404404         break;
405405      case 0xe1:
406         val = io_read_byte_8(H8_ADC_0_L);
406         val = io_read_byte(H8_ADC_0_L);
407407         break;
408408      case 0xe2:
409         val = io_read_byte_8(H8_ADC_1_H);
409         val = io_read_byte(H8_ADC_1_H);
410410         break;
411411      case 0xe3:
412         val = io_read_byte_8(H8_ADC_1_L);
412         val = io_read_byte(H8_ADC_1_L);
413413         break;
414414      case 0xe4:
415         val = io_read_byte_8(H8_ADC_2_H);
415         val = io_read_byte(H8_ADC_2_H);
416416         break;
417417      case 0xe5:
418         val = io_read_byte_8(H8_ADC_2_L);
418         val = io_read_byte(H8_ADC_2_L);
419419         break;
420420      case 0xe6:
421         val = io_read_byte_8(H8_ADC_3_H);
421         val = io_read_byte(H8_ADC_3_H);
422422         break;
423423      case 0xe7:
424         val = io_read_byte_8(H8_ADC_3_L);
424         val = io_read_byte(H8_ADC_3_L);
425425         break;
426426      case 0xe8:      // adc status
427427         val = 0x80;
428428         break;
429429      case 0xc7:          // port 4 data
430         val = io_read_byte_8(H8_PORT4);
430         val = io_read_byte(H8_PORT4);
431431         break;
432432      case 0xcb:          // port 6 data
433         val = io_read_byte_8(H8_PORT6);
433         val = io_read_byte(H8_PORT6);
434434         break;
435435      case 0xce:      // port 7 data
436         val = io_read_byte_8(H8_PORT7);
436         val = io_read_byte(H8_PORT7);
437437         break;
438438      case 0xcf:      // port 8 data
439         val = io_read_byte_8(H8_PORT8);
439         val = io_read_byte(H8_PORT8);
440440         break;
441441      case 0xd2:      // port 9 data
442         val = io_read_byte_8(H8_PORT9);
442         val = io_read_byte(H8_PORT9);
443443         break;
444444      case 0xd3:      // port a data
445         val = io_read_byte_8(H8_PORTA);
445         val = io_read_byte(H8_PORTA);
446446         break;
447447      case 0xd6:      // port b data
448         val = io_read_byte_8(H8_PORTB);
448         val = io_read_byte(H8_PORTB);
449449         break;
450450      case 0xf6:
451451         val = h8_ISR_r();
r2375r2376
482482         io_write_byte(H8_SERIAL_B, val);
483483         break;
484484      case 0xc7:
485         io_write_byte_8(H8_PORT4, val);
485         io_write_byte(H8_PORT4, val);
486486         break;
487487      case 0xcb:          // port 6 data
488         io_write_byte_8(H8_PORT6, val);
488         io_write_byte(H8_PORT6, val);
489489         break;
490490      case 0xce:      // port 7 data
491         io_write_byte_8(H8_PORT7, val);
491         io_write_byte(H8_PORT7, val);
492492         break;
493493      case 0xcf:      // port 8 data
494         io_write_byte_8(H8_PORT8, val);
494         io_write_byte(H8_PORT8, val);
495495         break;
496496      case 0xd2:      // port 9 data
497         io_write_byte_8(H8_PORT9, val);
497         io_write_byte(H8_PORT9, val);
498498         break;
499499      case 0xd3:      // port a data
500         io_write_byte_8(H8_PORTA, val);
500         io_write_byte(H8_PORTA, val);
501501         break;
502502      case 0xd6:      // port b data
503         io_write_byte_8(H8_PORTB, val);
503         io_write_byte(H8_PORTB, val);
504504         break;
505505      case 0xf6:
506506         h8_ISR_w(val);
r2375r2376
684684         val = io_read_byte(H8_SERIAL_B);
685685         break;
686686      case 0xe0:
687         val = io_read_byte_8(H8_ADC_0_H);
687         val = io_read_byte(H8_ADC_0_H);
688688         break;
689689      case 0xe1:
690         val = io_read_byte_8(H8_ADC_0_L);
690         val = io_read_byte(H8_ADC_0_L);
691691         break;
692692      case 0xe2:
693         val = io_read_byte_8(H8_ADC_1_H);
693         val = io_read_byte(H8_ADC_1_H);
694694         break;
695695      case 0xe3:
696         val = io_read_byte_8(H8_ADC_1_L);
696         val = io_read_byte(H8_ADC_1_L);
697697         break;
698698      case 0xe4:
699         val = io_read_byte_8(H8_ADC_2_H);
699         val = io_read_byte(H8_ADC_2_H);
700700         break;
701701      case 0xe5:
702         val = io_read_byte_8(H8_ADC_2_L);
702         val = io_read_byte(H8_ADC_2_L);
703703         break;
704704      case 0xe6:
705         val = io_read_byte_8(H8_ADC_3_H);
705         val = io_read_byte(H8_ADC_3_H);
706706         break;
707707      case 0xe7:
708         val = io_read_byte_8(H8_ADC_3_L);
708         val = io_read_byte(H8_ADC_3_L);
709709         break;
710710      case 0xe8:      // adc status
711711         val = 0x80;
712712         break;
713713
714714      case 0xd3:          // port 4 data
715         val = io_read_byte_8(H8_PORT4);
715         val = io_read_byte(H8_PORT4);
716716         break;
717717      case 0xd5:          // port 6 data
718         val = io_read_byte_8(H8_PORT6);
718         val = io_read_byte(H8_PORT6);
719719         break;
720720      case 0xd6:      // port 7 data
721         val = io_read_byte_8(H8_PORT7);
721         val = io_read_byte(H8_PORT7);
722722         break;
723723      case 0xd7:      // port 8 data
724         val = io_read_byte_8(H8_PORT8);
724         val = io_read_byte(H8_PORT8);
725725         break;
726726      case 0xd8:      // port 9 data
727         val = io_read_byte_8(H8_PORT9);
727         val = io_read_byte(H8_PORT9);
728728         break;
729729      case 0xd9:      // port a data
730         val = io_read_byte_8(H8_PORTA);
730         val = io_read_byte(H8_PORTA);
731731         break;
732732      case 0xda:      // port b data
733         val = io_read_byte_8(H8_PORTB);
733         val = io_read_byte(H8_PORTB);
734734         break;
735735      default:
736736         val = h8.per_regs[reg];
r2375r2376
766766            io_write_byte(H8_SERIAL_B, val);
767767            break;
768768         case 0xd3:
769            io_write_byte_8(H8_PORT4, val);
769            io_write_byte(H8_PORT4, val);
770770            break;
771771         case 0xd5:      // port 6 data
772            io_write_byte_8(H8_PORT6, val);
772            io_write_byte(H8_PORT6, val);
773773            break;
774774         case 0xd6:      // port 7 data
775            io_write_byte_8(H8_PORT7, val);
775            io_write_byte(H8_PORT7, val);
776776            break;
777777         case 0xd7:      // port 8 data
778            io_write_byte_8(H8_PORT8, val);
778            io_write_byte(H8_PORT8, val);
779779            break;
780780         case 0xd8:      // port 9 data
781            io_write_byte_8(H8_PORT9, val);
781            io_write_byte(H8_PORT9, val);
782782            break;
783783         case 0xd9:      // port a data
784            io_write_byte_8(H8_PORTA, val);
784            io_write_byte(H8_PORTA, val);
785785            break;
786786         case 0xda:      // port b data
787            io_write_byte_8(H8_PORTB, val);
787            io_write_byte(H8_PORTB, val);
788788            break;
789789      }
790790   }
src/emu/cpu/m68000/m68kmame.c
r2375r2376
2626   return (cpu_readop(addr) << 8) | (cpu_readop(addr + 1));
2727}
2828
29static UINT16 readword_d8(offs_t address)
30{
31   UINT16 result = program_read_byte_8(address) << 8;
32   return result | program_read_byte_8(address + 1);
33}
34
35static void writeword_d8(offs_t address, UINT16 data)
36{
37   program_write_byte_8(address, data >> 8);
38   program_write_byte_8(address + 1, data);
39}
40
41static UINT32 readlong_d8(offs_t address)
42{
43   UINT32 result = program_read_byte_8(address) << 24;
44   result |= program_read_byte_8(address + 1) << 16;
45   result |= program_read_byte_8(address + 2) << 8;
46   return result | program_read_byte_8(address + 3);
47}
48
49static void writelong_d8(offs_t address, UINT32 data)
50{
51   program_write_byte_8(address, data >> 24);
52   program_write_byte_8(address + 1, data >> 16);
53   program_write_byte_8(address + 2, data >> 8);
54   program_write_byte_8(address + 3, data);
55}
56
5729/* interface for 20/22-bit address bus, 8-bit data bus (68008) */
5830static const struct m68k_memory_interface interface_d8 =
5931{
6032   0,
6133   m68008_read_immediate_16,
62   program_read_byte_8,
63   readword_d8,
64   readlong_d8,
65   program_write_byte_8,
66   writeword_d8,
67   writelong_d8
34   program_read_byte_8be,
35   program_read_word_8be,
36   program_read_dword_8be,
37   program_write_byte_8be,
38   program_write_word_8be,
39   program_write_dword_8be
6840};
6941
7042/****************************************************************************
r2375r2376
7648   return cpu_readop16((address) ^ m68k_memory_intf.opcode_xor);
7749}
7850
79static UINT32 readlong_d16(offs_t address)
80{
81   UINT32 result = program_read_word_16be(address) << 16;
82   return result | program_read_word_16be(address + 2);
83}
84
85static void writelong_d16(offs_t address, UINT32 data)
86{
87   program_write_word_16be(address, data >> 16);
88   program_write_word_16be(address + 2, data);
89}
90
9151/* interface for 24-bit address bus, 16-bit data bus (68000, 68010) */
9252static const struct m68k_memory_interface interface_d16 =
9353{
r2375r2376
9555   read_immediate_16,
9656   program_read_byte_16be,
9757   program_read_word_16be,
98   readlong_d16,
58   program_read_dword_16be,
9959   program_write_byte_16be,
10060   program_write_word_16be,
101   writelong_d16
61   program_write_dword_16be
10262};
10363
10464/****************************************************************************
r2375r2376
281241
282242static void m68008_set_context(void *src)
283243{
284   if (m68k_memory_intf.read8 != program_read_byte_8)
244   if (m68k_memory_intf.read8 != program_read_byte_8be)
285245      m68k_memory_intf = interface_d8;
286246   m68k_set_context(src);
287247}
src/emu/cpu/m68000/m68kcpu.c
r2375r2376
978978   UINT8 halted;
979979} m68k_substate;
980980
981static void m68k_prepare_substate(void)
981static void m68k_prepare_substate(running_machine *machine, void *param)
982982{
983983   m68k_substate.sr = m68ki_get_sr();
984984   m68k_substate.stopped = (CPU_STOPPED & STOP_LEVEL_STOP) != 0;
985985   m68k_substate.halted  = (CPU_STOPPED & STOP_LEVEL_HALT) != 0;
986986}
987987
988static void m68k_post_load(void)
988static void m68k_post_load(running_machine *machine, void *param)
989989{
990990   m68ki_set_sr_noint_nosp(m68k_substate.sr);
991991   CPU_STOPPED = m68k_substate.stopped ? STOP_LEVEL_STOP : 0
r2375r2376
10141014   state_save_register_item(type, index, m68k_substate.halted);
10151015   state_save_register_item(type, index, CPU_PREF_ADDR);
10161016   state_save_register_item(type, index, CPU_PREF_DATA);
1017   state_save_register_func_presave(m68k_prepare_substate);
1018   state_save_register_func_postload(m68k_post_load);
1017   state_save_register_presave(Machine, m68k_prepare_substate, NULL);
1018   state_save_register_postload(Machine, m68k_post_load, NULL);
10191019}
10201020
10211021#endif /* M68K_COMPILE_FOR_MAME */
src/emu/cpu/ccpu/ccpu.c
r2375r2376
6161#define RDMEM(a)         (data_read_word_16be((a) * 2) & 0xfff)
6262#define WRMEM(a,v)         (data_write_word_16be((a) * 2, (v)))
6363
64#define READPORT(a)         (io_read_byte_8(a))
65#define WRITEPORT(a,v)      (io_write_byte_8((a), (v)))
64#define READPORT(a)         (io_read_byte_8be(a))
65#define WRITEPORT(a,v)      (io_write_byte_8be((a), (v)))
6666
6767#define SET_A0()         do { ccpu.a0flag = ccpu.A; } while (0)
6868#define SET_CMP_VAL(x)      do { ccpu.cmpacc = *ccpu.acc; ccpu.cmpval = (x) & 0xfff; } while (0)
src/emu/cpu/z80gb/z80gb.c
r2375r2376
119119/* Memory functions                                                         */
120120/****************************************************************************/
121121
122#define mem_ReadByte(A)      ((UINT8)program_read_byte_8(A))
123#define mem_WriteByte(A,V)   (program_write_byte_8(A,V))
122#define mem_ReadByte(A)      ((UINT8)program_read_byte_8le(A))
123#define mem_WriteByte(A,V)   (program_write_byte_8le(A,V))
124124
125125INLINE UINT16 mem_ReadWord (UINT32 address)
126126{
src/emu/cpu/tms34010/tms34010.c
r2375r2376
102102
103103static void check_interrupt(void);
104104static TIMER_CALLBACK( scanline_callback );
105static void tms34010_state_postload(void);
105static STATE_POSTLOAD( tms34010_state_postload );
106106
107107
108108/***************************************************************************
r2375r2376
672672   state_save_register_item("tms34010", index, state.pixelshift);
673673   state_save_register_item("tms34010", index, state.gfxcycles);
674674   state_save_register_item_pointer("tms34010", index, (&state.regs[0].reg), ARRAY_LENGTH(state.regs));
675   state_save_register_func_postload(tms34010_state_postload);
675   state_save_register_postload(Machine, tms34010_state_postload, NULL);
676676}
677677
678678static void tms34010_reset(void)
r2375r2376
16221622    SAVE STATE
16231623***************************************************************************/
16241624
1625static void tms34010_state_postload(void)
1625static STATE_POSTLOAD( tms34010_state_postload )
16261626{
16271627   change_pc(TOBYTE(PC));
16281628   set_raster_op();
src/emu/cpu/cpu.mak
r2375r2376
13771377#-------------------------------------------------
13781378
13791379CPUDEFS += -DHAS_PSXCPU=$(if $(filter PSXCPU,$(CPUS)),1,0)
1380CPUDEFS += -DHAS_CXD8661R=$(if $(filter CXD8661R,$(CPUS)),1,0)
13801381
1381ifneq ($(filter PSXCPU,$(CPUS)),)
1382ifneq ($(filter PSXCPU CXD8661R,$(CPUS)),)
13821383OBJDIRS += $(CPUOBJ)/mips
13831384CPUOBJS += $(CPUOBJ)/mips/psx.o
13841385DBGOBJS += $(CPUOBJ)/mips/mipsdasm.o
src/emu/cpu/m37710/m37710.c
r2375r2376
504504   switch (offset)
505505   {
506506      case 2: // p0
507         return io_read_byte_8(M37710_PORT0);
507         return io_read_byte_8le(M37710_PORT0);
508508         break;
509509      case 3: // p1
510         return io_read_byte_8(M37710_PORT1);
510         return io_read_byte_8le(M37710_PORT1);
511511         break;
512512      case 6: // p2
513         return io_read_byte_8(M37710_PORT2);
513         return io_read_byte_8le(M37710_PORT2);
514514         break;
515515      case 7: // p3
516         return io_read_byte_8(M37710_PORT3);
516         return io_read_byte_8le(M37710_PORT3);
517517         break;
518518      case 0xa: // p4
519         return io_read_byte_8(M37710_PORT4);
519         return io_read_byte_8le(M37710_PORT4);
520520         break;
521521      case 0xb: // p5
522         return io_read_byte_8(M37710_PORT5);
522         return io_read_byte_8le(M37710_PORT5);
523523         break;
524524      case 0xe: // p6
525         return io_read_byte_8(M37710_PORT6);
525         return io_read_byte_8le(M37710_PORT6);
526526         break;
527527      case 0xf: // p7
528         return io_read_byte_8(M37710_PORT7);
528         return io_read_byte_8le(M37710_PORT7);
529529         break;
530530      case 0x12: // p8
531         return io_read_byte_8(M37710_PORT8);
531         return io_read_byte_8le(M37710_PORT8);
532532         break;
533533
534534      case 0x20:
535         return io_read_byte_8(M37710_ADC0_L);
535         return io_read_byte_8le(M37710_ADC0_L);
536536         break;
537537      case 0x21:
538         return io_read_byte_8(M37710_ADC0_H);
538         return io_read_byte_8le(M37710_ADC0_H);
539539         break;
540540      case 0x22:
541         return io_read_byte_8(M37710_ADC1_L);
541         return io_read_byte_8le(M37710_ADC1_L);
542542         break;
543543      case 0x23:
544         return io_read_byte_8(M37710_ADC1_H);
544         return io_read_byte_8le(M37710_ADC1_H);
545545         break;
546546      case 0x24:
547         return io_read_byte_8(M37710_ADC2_L);
547         return io_read_byte_8le(M37710_ADC2_L);
548548         break;
549549      case 0x25:
550         return io_read_byte_8(M37710_ADC2_H);
550         return io_read_byte_8le(M37710_ADC2_H);
551551         break;
552552      case 0x26:
553         return io_read_byte_8(M37710_ADC3_L);
553         return io_read_byte_8le(M37710_ADC3_L);
554554         break;
555555      case 0x27:
556         return io_read_byte_8(M37710_ADC3_H);
556         return io_read_byte_8le(M37710_ADC3_H);
557557         break;
558558      case 0x28:
559         return io_read_byte_8(M37710_ADC4_L);
559         return io_read_byte_8le(M37710_ADC4_L);
560560         break;
561561      case 0x29:
562         return io_read_byte_8(M37710_ADC4_H);
562         return io_read_byte_8le(M37710_ADC4_H);
563563         break;
564564      case 0x2a:
565         return io_read_byte_8(M37710_ADC5_L);
565         return io_read_byte_8le(M37710_ADC5_L);
566566         break;
567567      case 0x2b:
568         return io_read_byte_8(M37710_ADC5_H);
568         return io_read_byte_8le(M37710_ADC5_H);
569569         break;
570570      case 0x2c:
571         return io_read_byte_8(M37710_ADC6_L);
571         return io_read_byte_8le(M37710_ADC6_L);
572572         break;
573573      case 0x2d:
574         return io_read_byte_8(M37710_ADC6_H);
574         return io_read_byte_8le(M37710_ADC6_H);
575575         break;
576576      case 0x2e:
577         return io_read_byte_8(M37710_ADC7_L);
577         return io_read_byte_8le(M37710_ADC7_L);
578578         break;
579579      case 0x2f:
580         return io_read_byte_8(M37710_ADC7_H);
580         return io_read_byte_8le(M37710_ADC7_H);
581581         break;
582582      case 0x35:
583583         return 0xff;   // UART control
r2375r2376
598598   switch(offset)
599599   {
600600      case 2: // p0
601         io_write_byte_8(M37710_PORT0, data);
601         io_write_byte_8le(M37710_PORT0, data);
602602         return;
603603         break;
604604      case 3: // p1
605         io_write_byte_8(M37710_PORT1, data);
605         io_write_byte_8le(M37710_PORT1, data);
606606         return;
607607         break;
608608      case 6: // p2
609         io_write_byte_8(M37710_PORT2, data);
609         io_write_byte_8le(M37710_PORT2, data);
610610         return;
611611         break;
612612      case 7: // p3
613         io_write_byte_8(M37710_PORT3, data);
613         io_write_byte_8le(M37710_PORT3, data);
614614         return;
615615         break;
616616      case 0xa: // p4
617         io_write_byte_8(M37710_PORT4, data);
617         io_write_byte_8le(M37710_PORT4, data);
618618         return;
619619         break;
620620      case 0xb: // p5
621         io_write_byte_8(M37710_PORT5, data);
621         io_write_byte_8le(M37710_PORT5, data);
622622         return;
623623         break;
624624      case 0xe: // p6
625         io_write_byte_8(M37710_PORT6, data);
625         io_write_byte_8le(M37710_PORT6, data);
626626         return;
627627         break;
628628      case 0xf: // p7
629         io_write_byte_8(M37710_PORT7, data);
629         io_write_byte_8le(M37710_PORT7, data);
630630         return;
631631         break;
632632      case 0x12: // p8
633         io_write_byte_8(M37710_PORT8, data);
633         io_write_byte_8le(M37710_PORT8, data);
634634         return;
635635         break;
636636
r2375r2376
10411041}
10421042#endif /* ENABLE_DEBUGGER */
10431043
1044static void m37710_restore_state(void)
1044static STATE_POSTLOAD( m37710_restore_state )
10451045{
10461046   // restore proper function pointers
10471047   m37710i_set_execution_mode((FLAG_M>>4) | (FLAG_X>>4));
r2375r2376
11121112   state_save_register_item("M377xx", index, m37710i_cpu.reload[7].seconds);
11131113   state_save_register_item("M377xx", index, m37710i_cpu.reload[7].attoseconds);
11141114
1115   state_save_register_func_postload(m37710_restore_state);
1115   state_save_register_postload(Machine, m37710_restore_state, NULL);
11161116}
11171117
11181118/**************************************************************************
src/emu/cpu/z180/z180.c
r2375r2376
811811static UINT8 z180_readcontrol(offs_t port)
812812{
813813   /* normal external readport */
814   UINT8 data = io_read_byte_8(port);
814   UINT8 data = io_read_byte_8le(port);
815815
816816   /* remap internal I/O registers */
817817   if((port & (IO_IOCR & 0xc0)) == (IO_IOCR & 0xc0))
r2375r2376
12391239static void z180_writecontrol(offs_t port, UINT8 data)
12401240{
12411241   /* normal external write port */
1242   io_write_byte_8(port, data);
1242   io_write_byte_8le(port, data);
12431243
12441244   /* remap internal I/O registers */
12451245   if((port & (IO_IOCR & 0xc0)) == (IO_IOCR & 0xc0))
r2375r2376
16041604      switch( IO_DMODE & (Z180_DMODE_SM | Z180_DMODE_DM) )
16051605      {
16061606      case 0x00:   /* memory SAR0+1 to memory DAR0+1 */
1607         program_write_byte_8(dar0++, program_read_byte_8(sar0++));
1607         program_write_byte_8le(dar0++, program_read_byte_8le(sar0++));
16081608         break;
16091609      case 0x04:   /* memory SAR0-1 to memory DAR0+1 */
1610         program_write_byte_8(dar0++, program_read_byte_8(sar0--));
1610         program_write_byte_8le(dar0++, program_read_byte_8le(sar0--));
16111611         break;
16121612      case 0x08:   /* memory SAR0 fixed to memory DAR0+1 */
1613         program_write_byte_8(dar0++, program_read_byte_8(sar0));
1613         program_write_byte_8le(dar0++, program_read_byte_8le(sar0));
16141614         break;
16151615      case 0x0c:   /* I/O SAR0 fixed to memory DAR0+1 */
16161616         if (Z180.iol & Z180_DREQ0)
16171617         {
1618            program_write_byte_8(dar0++, IN(sar0));
1618            program_write_byte_8le(dar0++, IN(sar0));
16191619            /* edge sensitive DREQ0 ? */
16201620            if (IO_DCNTL & Z180_DCNTL_DIM0)
16211621            {
r2375r2376
16251625         }
16261626         break;
16271627      case 0x10:   /* memory SAR0+1 to memory DAR0-1 */
1628         program_write_byte_8(dar0--, program_read_byte_8(sar0++));
1628         program_write_byte_8le(dar0--, program_read_byte_8le(sar0++));
16291629         break;
16301630      case 0x14:   /* memory SAR0-1 to memory DAR0-1 */
1631         program_write_byte_8(dar0--, program_read_byte_8(sar0--));
1631         program_write_byte_8le(dar0--, program_read_byte_8le(sar0--));
16321632         break;
16331633      case 0x18:   /* memory SAR0 fixed to memory DAR0-1 */
1634         program_write_byte_8(dar0--, program_read_byte_8(sar0));
1634         program_write_byte_8le(dar0--, program_read_byte_8le(sar0));
16351635         break;
16361636      case 0x1c:   /* I/O SAR0 fixed to memory DAR0-1 */
16371637         if (Z180.iol & Z180_DREQ0)
16381638            {
1639            program_write_byte_8(dar0--, IN(sar0));
1639            program_write_byte_8le(dar0--, IN(sar0));
16401640            /* edge sensitive DREQ0 ? */
16411641            if (IO_DCNTL & Z180_DCNTL_DIM0)
16421642            {
r2375r2376
16461646         }
16471647         break;
16481648      case 0x20:   /* memory SAR0+1 to memory DAR0 fixed */
1649         program_write_byte_8(dar0, program_read_byte_8(sar0++));
1649         program_write_byte_8le(dar0, program_read_byte_8le(sar0++));
16501650         break;
16511651      case 0x24:   /* memory SAR0-1 to memory DAR0 fixed */
1652         program_write_byte_8(dar0, program_read_byte_8(sar0--));
1652         program_write_byte_8le(dar0, program_read_byte_8le(sar0--));
16531653         break;
16541654      case 0x28:   /* reserved */
16551655         break;
r2375r2376
16581658      case 0x30:   /* memory SAR0+1 to I/O DAR0 fixed */
16591659         if (Z180.iol & Z180_DREQ0)
16601660            {
1661            OUT(dar0, program_read_byte_8(sar0++));
1661            OUT(dar0, program_read_byte_8le(sar0++));
16621662            /* edge sensitive DREQ0 ? */
16631663            if (IO_DCNTL & Z180_DCNTL_DIM0)
16641664            {
r2375r2376
16701670      case 0x34:   /* memory SAR0-1 to I/O DAR0 fixed */
16711671         if (Z180.iol & Z180_DREQ0)
16721672            {
1673            OUT(dar0, program_read_byte_8(sar0--));
1673            OUT(dar0, program_read_byte_8le(sar0--));
16741674            /* edge sensitive DREQ0 ? */
16751675            if (IO_DCNTL & Z180_DCNTL_DIM0)
16761676            {
r2375r2376
17351735   switch (IO_DCNTL & (Z180_DCNTL_DIM1 | Z180_DCNTL_DIM0))
17361736   {
17371737   case 0x00:   /* memory MAR1+1 to I/O IAR1 fixed */
1738      io_write_byte_8(iar1, program_read_byte_8(mar1++));
1738      io_write_byte_8le(iar1, program_read_byte_8le(mar1++));
17391739      break;
17401740   case 0x01:   /* memory MAR1-1 to I/O IAR1 fixed */
1741      io_write_byte_8(iar1, program_read_byte_8(mar1--));
1741      io_write_byte_8le(iar1, program_read_byte_8le(mar1--));
17421742      break;
17431743   case 0x02:   /* I/O IAR1 fixed to memory MAR1+1 */
1744      program_write_byte_8(mar1++, io_read_byte_8(iar1));
1744      program_write_byte_8le(mar1++, io_read_byte_8le(iar1));
17451745      break;
17461746   case 0x03:   /* I/O IAR1 fixed to memory MAR1-1 */
1747      program_write_byte_8(mar1--, io_read_byte_8(iar1));
1747      program_write_byte_8le(mar1--, io_read_byte_8le(iar1));
17481748      break;
17491749   }
17501750
src/emu/cpu/z180/z180ops.h
r2375r2376
2424 ***************************************************************/
2525#define IN(port)                                    \
2626   (((port ^ IO_IOCR) & 0xffc0) == 0) ?                  \
27      z180_readcontrol(port) : io_read_byte_8(port)
27      z180_readcontrol(port) : io_read_byte_8le(port)
2828
2929/***************************************************************
3030 * Output a byte to given I/O port
r2375r2376
3232#define OUT(port,value)                               \
3333   if (((port ^ IO_IOCR) & 0xffc0) == 0)                  \
3434      z180_writecontrol(port,value);                     \
35   else io_write_byte_8(port,value)
35   else io_write_byte_8le(port,value)
3636
3737/***************************************************************
3838 * MMU calculate the memory managemant lookup table
r2375r2376
6868/***************************************************************
6969 * Read a byte from given memory location
7070 ***************************************************************/
71#define RM(addr)   program_read_byte_8(MMU_REMAP_ADDR(addr))
71#define RM(addr)   program_read_byte_8le(MMU_REMAP_ADDR(addr))
7272UINT8 z180_readmem(offs_t offset)
7373{
7474   return RM(offset);
r2375r2376
7777/***************************************************************
7878 * Write a byte to given memory location
7979 ***************************************************************/
80#define WM(addr,value) program_write_byte_8(MMU_REMAP_ADDR(addr),value)
80#define WM(addr,value) program_write_byte_8le(MMU_REMAP_ADDR(addr),value)
8181void z180_writemem(offs_t offset, UINT8 data)
8282{
8383   WM(offset, data);
src/emu/cpu/i86/i86mem.c
r2375r2376
44
55#ifdef I8086
66#if (HAS_I8088||HAS_I80188)
7static UINT16 read_word_8(offs_t addr)
8{
9   UINT16 result = program_read_byte_8(addr);
10   return result | (program_read_byte_8(addr + 1) << 8);
11}
12
13static void write_word_8(offs_t addr, UINT16 data)
14{
15   program_write_byte_8(addr, data);
16   program_write_byte_8(addr + 1, data >> 8);
17}
18
19static UINT16 read_port_word_8(offs_t addr)
20{
21   UINT16 result = io_read_byte_8(addr);
22   return result | (io_read_byte_8(addr + 1) << 8);
23}
24
25static void write_port_word_8(offs_t addr, UINT16 data)
26{
27   io_write_byte_8(addr, data);
28   io_write_byte_8(addr + 1, data >> 8);
29}
30
317static void configure_memory_8bit(void)
328{
339   I.mem.fetch_xor = 0;
3410
35   I.mem.rbyte = program_read_byte_8;
36   I.mem.rword = read_word_8;
37   I.mem.wbyte = program_write_byte_8;
38   I.mem.wword = write_word_8;
11   I.mem.rbyte = program_read_byte_8le;
12   I.mem.rword = program_read_word_8le;
13   I.mem.wbyte = program_write_byte_8le;
14   I.mem.wword = program_write_word_8le;
3915
40   I.mem.rbyte_port = io_read_byte_8;
41   I.mem.rword_port = read_port_word_8;
42   I.mem.wbyte_port = io_write_byte_8;
43   I.mem.wword_port = write_port_word_8;
16   I.mem.rbyte_port = io_read_byte_8le;
17   I.mem.rword_port = io_read_word_8le;
18   I.mem.wbyte_port = io_write_byte_8le;
19   I.mem.wword_port = io_write_word_8le;
4420}
4521#endif
4622#endif
src/emu/cpu/i86/i286.h
r2375r2376
1414#undef PutMemW
1515
1616/* ASG 971005 -- changed to program_read_byte_8/program_write_byte_8 */
17#define GetMemB(Seg,Off) ( (BYTE)program_read_byte_8((DefaultBase(Seg)+(Off))&AMASK))
17#define GetMemB(Seg,Off) ( (BYTE)program_read_byte_8le((DefaultBase(Seg)+(Off))&AMASK))
1818#define GetMemW(Seg,Off) ( (WORD)GetMemB(Seg,Off)+(WORD)(GetMemB(Seg,(Off)+1)<<8))
19#define PutMemB(Seg,Off,x) { program_write_byte_8((DefaultBase(Seg)+(Off))&AMASK,(x)); }
19#define PutMemB(Seg,Off,x) { program_write_byte_8le((DefaultBase(Seg)+(Off))&AMASK,(x)); }
2020#define PutMemW(Seg,Off,x) { PutMemB(Seg,Off,(BYTE)(x)); PutMemB(Seg,(Off)+1,(BYTE)((x)>>8)); }
2121
2222#undef PEEKBYTE
23#define PEEKBYTE(ea) ((BYTE)program_read_byte_8((ea)&AMASK))
23#define PEEKBYTE(ea) ((BYTE)program_read_byte_8le((ea)&AMASK))
2424
2525#undef ReadByte
2626#undef ReadWord
2727#undef WriteByte
2828#undef WriteWord
2929
30#define ReadByte(ea) ((BYTE)program_read_byte_8((ea)&AMASK))
31#define ReadWord(ea) (program_read_byte_8((ea)&AMASK)+(program_read_byte_8(((ea)+1)&AMASK)<<8))
32#define WriteByte(ea,val) { program_write_byte_8((ea)&AMASK,val); }
33#define WriteWord(ea,val) { program_write_byte_8((ea)&AMASK,(BYTE)(val)); program_write_byte_8(((ea)+1)&AMASK,(val)>>8); }
30#define ReadByte(ea) ((BYTE)program_read_byte_8le((ea)&AMASK))
31#define ReadWord(ea) (program_read_byte_8le((ea)&AMASK)+(program_read_byte_8le(((ea)+1)&AMASK)<<8))
32#define WriteByte(ea,val) { program_write_byte_8le((ea)&AMASK,val); }
33#define WriteWord(ea,val) { program_write_byte_8le((ea)&AMASK,(BYTE)(val)); program_write_byte_8le(((ea)+1)&AMASK,(val)>>8); }
3434
3535#undef CHANGE_PC
3636#define CHANGE_PC(addr) change_pc(addr)
src/emu/cpu/upd7810/upd7810.c
r2375r2376
539539
540540#define RDOP(O)    O = cpu_readop(PCD); PC++
541541#define RDOPARG(A)   A = cpu_readop_arg(PCD); PC++
542#define RM(A)      program_read_byte_8(A)
543#define WM(A,V)    program_write_byte_8(A,V)
542#define RM(A)      program_read_byte_8le(A)
543#define WM(A,V)    program_write_byte_8le(A,V)
544544
545545#define ZHC_ADD(after,before,carry)    \
546546   if (after == 0) PSW |= Z; else PSW &= ~Z; \
r2375r2376
581581   {
582582   case UPD7810_PORTA:
583583      if (upd7810.ma)   // NS20031301 no need to read if the port is set as output
584         upd7810.pa_in = io_read_byte_8(port);
584         upd7810.pa_in = io_read_byte_8le(port);
585585      data = (upd7810.pa_in & upd7810.ma) | (upd7810.pa_out & ~upd7810.ma);
586586      break;
587587   case UPD7810_PORTB:
588588      if (upd7810.mb)   // NS20031301 no need to read if the port is set as output
589         upd7810.pb_in = io_read_byte_8(port);
589         upd7810.pb_in = io_read_byte_8le(port);
590590      data = (upd7810.pb_in & upd7810.mb) | (upd7810.pb_out & ~upd7810.mb);
591591      break;
592592   case UPD7810_PORTC:
593593      if (upd7810.mc)   // NS20031301 no need to read if the port is set as output
594         upd7810.pc_in = io_read_byte_8(port);
594         upd7810.pc_in = io_read_byte_8le(port);
595595      data = (upd7810.pc_in & upd7810.mc) | (upd7810.pc_out & ~upd7810.mc);
596596      if (upd7810.mcc & 0x01)    /* PC0 = TxD output */
597597         data = (data & ~0x01) | (upd7810.txd & 1 ? 0x01 : 0x00);
r2375r2376
611611         data = (data & ~0x80) | (upd7810.co1 & 1 ? 0x80 : 0x00);
612612      break;
613613   case UPD7810_PORTD:
614      upd7810.pd_in = io_read_byte_8(port);
614      upd7810.pd_in = io_read_byte_8le(port);
615615      switch (upd7810.mm & 0x07)
616616      {
617617      case 0x00:         /* PD input mode, PF port mode */
r2375r2376
626626      }
627627      break;
628628   case UPD7810_PORTF:
629      upd7810.pf_in = io_read_byte_8(port);
629      upd7810.pf_in = io_read_byte_8le(port);
630630      switch (upd7810.mm & 0x06)
631631      {
632632      case 0x00:         /* PD input/output mode, PF port mode */
r2375r2376
646646      }
647647      break;
648648   case UPD7807_PORTT:   // NS20031301 partial implementation
649      data = io_read_byte_8(port);
649      data = io_read_byte_8le(port);
650650      break;
651651   default:
652652      logerror("uPD7810 internal error: RP() called with invalid port number\n");
r2375r2376
662662      upd7810.pa_out = data;
663663//      data = (data & ~upd7810.ma) | (upd7810.pa_in & upd7810.ma);
664664      data = (data & ~upd7810.ma) | (upd7810.ma);   // NS20031401
665      io_write_byte_8(port, data);
665      io_write_byte_8le(port, data);
666666      break;
667667   case UPD7810_PORTB:
668668      upd7810.pb_out = data;
669669//      data = (data & ~upd7810.mb) | (upd7810.pb_in & upd7810.mb);
670670      data = (data & ~upd7810.mb) | (upd7810.mb);   // NS20031401
671      io_write_byte_8(port, data);
671      io_write_byte_8le(port, data);
672672      break;
673673   case UPD7810_PORTC:
674674      upd7810.pc_out = data;
r2375r2376
690690         data = (data & ~0x40) | (upd7810.co0 & 1 ? 0x40 : 0x00);
691691      if (upd7810.mcc & 0x80)    /* PC7 = CO1 output */
692692         data = (data & ~0x80) | (upd7810.co1 & 1 ? 0x80 : 0x00);
693      io_write_byte_8(port, data);
693      io_write_byte_8le(port, data);
694694      break;
695695   case UPD7810_PORTD:
696696      upd7810.pd_out = data;
r2375r2376
705705      default:         /* PD extension mode, PF port/extension mode */
706706         return;
707707      }
708      io_write_byte_8(port, data);
708      io_write_byte_8le(port, data);
709709      break;
710710   case UPD7810_PORTF:
711711      upd7810.pf_out = data;
r2375r2376
724724         data |= 0xff;   /* what would come out for the lower bits here? */
725725         break;
726726      }
727      io_write_byte_8(port, data);
727      io_write_byte_8le(port, data);
728728      break;
729729   default:
730730      logerror("uPD7810 internal error: RP() called with invalid port number\n");
src/emu/cpu/minx/minx.c
r2375r2376
9090static minx_regs regs;
9191static int minx_icount;
9292
93#define rd(offset)   program_read_byte_8( offset )
94#define wr(offset,data)   program_write_byte_8( offset, data )
93#define rd(offset)   program_read_byte_8be( offset )
94#define wr(offset,data)   program_write_byte_8be( offset, data )
9595#define minx_PC      ( ( regs.PC & 0x8000 ) ? ( regs.V << 15 ) | (regs.PC & 0x7FFF ) : regs.PC )
9696
9797INLINE UINT16 rd16( UINT32 offset ) {
src/emu/cpu/spc700/spc700.h
r2375r2376
130130
131131extern void spc700_get_info(UINT32 state, cpuinfo *info);
132132
133#define spc700_read_8(addr) program_read_byte_8(addr)
134#define spc700_write_8(addr,data) program_write_byte_8(addr,data)
133#define spc700_read_8(addr) program_read_byte_8le(addr)
134#define spc700_write_8(addr,data) program_write_byte_8le(addr,data)
135135
136136#define spc700_read_8_direct(A)     spc700_read_8(A)
137137#define spc700_write_8_direct(A, V) spc700_write_8(A, V)
138138//#define spc700_read_instruction(A)    cpu_readop(A)
139139//#define spc700_read_8_immediate(A)    cpu_readop_arg(A)
140#define spc700_read_instruction(A)    program_read_byte_8(A)
141#define spc700_read_8_immediate(A)    program_read_byte_8(A)
140#define spc700_read_instruction(A)    program_read_byte_8le(A)
141#define spc700_read_8_immediate(A)    program_read_byte_8le(A)
142142#define spc700_jumping(A)             change_pc(A)
143143#define spc700_branching(A)         change_pc(A)
144144
src/emu/cpu/i8039/i8039.h
r2375r2376
205205/*
206206 *   Input a UINT8 from given I/O port
207207 */
208#define I8039_In(Port) ((UINT8)io_read_byte_8(Port))
208#define I8039_In(Port) ((UINT8)io_read_byte_8le(Port))
209209
210210
211211/*
212212 *   Output a UINT8 to given I/O port
213213 */
214#define I8039_Out(Port,Value) (io_write_byte_8(Port,Value))
214#define I8039_Out(Port,Value) (io_write_byte_8le(Port,Value))
215215
216216
217217/*
218218 *   Read a UINT8 from given memory location
219219 */
220#define I8039_RDMEM(A) ((unsigned)program_read_byte_8(A))
220#define I8039_RDMEM(A) ((unsigned)program_read_byte_8le(A))
221221
222222
223223/*
224224 *   Write a UINT8 to given memory location
225225 */
226#define I8039_WRMEM(A,V) (program_write_byte_8(A,V))
226#define I8039_WRMEM(A,V) (program_write_byte_8le(A,V))
227227
228228
229229/*
src/emu/cpu/hd6309/hd6309.h
r2375r2376
2020/* Read a byte from given memory location                                   */
2121/****************************************************************************/
2222/* ASG 971005 -- changed to program_read_byte_8/cpu_writemem16 */
23#define HD6309_RDMEM(Addr) ((unsigned)program_read_byte_8(Addr))
23#define HD6309_RDMEM(Addr) ((unsigned)program_read_byte_8be(Addr))
2424
2525/****************************************************************************/
2626/* Write a byte to given memory location                                    */
2727/****************************************************************************/
28#define HD6309_WRMEM(Addr,Value) (program_write_byte_8(Addr,Value))
28#define HD6309_WRMEM(Addr,Value) (program_write_byte_8be(Addr,Value))
2929
3030/****************************************************************************/
3131/* Z80_RDOP() is identical to Z80_RDMEM() except it is used for reading     */
src/emu/cpu/hd6309/hd6309.c
r2375r2376
387387   WM( (mAddr+3)&0xffff, p->b.l );
388388}
389389
390static void UpdateState( void )
390static void UpdateState(void)
391391{
392392   if ( hd6309.md & MD_EM )
393393   {
r2375r2376
511511   UpdateState();
512512}
513513
514static STATE_POSTLOAD( hd6309_postload )
515{
516   UpdateState();
517}
514518
515519static void hd6309_init(int index, int clock, const void *config, int (*irqcallback)(int))
516520{
r2375r2376
525529   state_save_register_item("hd6309", index, DP);
526530   state_save_register_item("hd6309", index, CC);
527531   state_save_register_item("hd6309", index, MD);
528   state_save_register_func_postload( UpdateState );
532   state_save_register_postload(Machine, hd6309_postload, NULL);
529533   state_save_register_item("hd6309", index, hd6309.int_state);
530534   state_save_register_item("hd6309", index, hd6309.nmi_state);
531535   state_save_register_item("hd6309", index, hd6309.irq_state[0]);
src/emu/cpu/tlcs90/tlcs90.c
r2375r2376
159159#define R16D8( N,R,I )      mode##N = MODE_R16D8;   r##N = R;   r##N##b = I;
160160#define R16R8( N,R,g )      mode##N = MODE_R16R8;   r##N = R;   r##N##b = g;
161161
162INLINE UINT8  RM8 (UINT32 a)   { return program_read_byte_8( a ); }
162INLINE UINT8  RM8 (UINT32 a)   { return program_read_byte_8le( a ); }
163163INLINE UINT16 RM16(UINT32 a)   { return RM8(a) | (RM8( (a+1) & 0xffff ) << 8); }
164164
165INLINE void WM8 (UINT32 a, UINT8  v)   { program_write_byte_8( a, v ); }
165INLINE void WM8 (UINT32 a, UINT8  v)   { program_write_byte_8le( a, v ); }
166166INLINE void WM16(UINT32 a, UINT16 v)   { WM8(a,v);   WM8( (a+1) & 0xffff, v >> 8); }
167167
168INLINE UINT8  RX8 (UINT32 a, UINT32 base)   { return program_read_byte_8( base | a ); }
168INLINE UINT8  RX8 (UINT32 a, UINT32 base)   { return program_read_byte_8le( base | a ); }
169169INLINE UINT16 RX16(UINT32 a, UINT32 base)   { return RX8(a,base) | (RX8( (a+1) & 0xffff, base ) << 8); }
170170
171INLINE void WX8 (UINT32 a, UINT8  v, UINT32 base)   { program_write_byte_8( base | a, v ); }
171INLINE void WX8 (UINT32 a, UINT8  v, UINT32 base)   { program_write_byte_8le( base | a, v ); }
172172INLINE void WX16(UINT32 a, UINT16 v, UINT32 base)   { WX8(a,v,base);   WX8( (a+1) & 0xffff, v >> 8, base); }
173173
174174INLINE UINT8  READ8(void)   { UINT8 b0 = RM8( addr++ ); addr &= 0xffff; return b0; }
r2375r2376
22762276
22772277static READ8_HANDLER( t90_internal_registers_r )
22782278{
2279   #define RIO      io_read_byte_8( T90_IOBASE+offset )
2279   #define RIO      io_read_byte_8le( T90_IOBASE+offset )
22802280
22812281   UINT8 data = T90.internal_registers[offset];
22822282   switch ( T90_IOBASE + offset )
r2375r2376
24842484
24852485static WRITE8_HANDLER( t90_internal_registers_w )
24862486{
2487   #define WIO      io_write_byte_8( T90_IOBASE+offset, data )
2487   #define WIO      io_write_byte_8le( T90_IOBASE+offset, data )
24882488
24892489   UINT8 out_mask;
24902490   UINT8 old = T90.internal_registers[offset];
src/emu/cpu/s2650/s2650.c
r2375r2376
191191 * RDMEM
192192 * read memory byte from addr
193193 ***************************************************************/
194#define RDMEM(addr) program_read_byte_8(addr)
194#define RDMEM(addr) program_read_byte_8le(addr)
195195
196196/***************************************************************
197197 * handy table to build PC relative offsets
r2375r2376
508508 * Store source register to memory addr (CC unchanged)
509509 ***************************************************************/
510510#define M_STR(address,source)                           \
511   program_write_byte_8(address, source)
511   program_write_byte_8le(address, source)
512512
513513/***************************************************************
514514 * M_AND
r2375r2376
653653 ***************************************************************/
654654#define M_SPSU()                                    \
655655{                                                \
656   R0 = ((S.psu & ~PSU34) | (io_read_byte_8(S2650_SENSE_PORT) & SI)); \
656   R0 = ((S.psu & ~PSU34) | (io_read_byte_8le(S2650_SENSE_PORT) & SI)); \
657657   SET_CC(R0);                                     \
658658}
659659
r2375r2376
723723#define M_TPSU()                                    \
724724{                                                \
725725   UINT8 tpsu = ARG();                               \
726    UINT8 rpsu = (S.psu | (io_read_byte_8(S2650_SENSE_PORT) & SI)); \
726    UINT8 rpsu = (S.psu | (io_read_byte_8le(S2650_SENSE_PORT) & SI)); \
727727   S.psl &= ~CC;                                    \
728728   if( (rpsu & tpsu) != tpsu )                           \
729729      S.psl |= 0x80;                                 \
r2375r2376
855855{
856856   /* OR'd with Input to allow for external connections */
857857
858    return (((S.psu & SI) ? 1 : 0) | ((io_read_byte_8(S2650_SENSE_PORT) & SI) ? 1 : 0));
858    return (((S.psu & SI) ? 1 : 0) | ((io_read_byte_8le(S2650_SENSE_PORT) & SI) ? 1 : 0));
859859}
860860
861861static int s2650_execute(int cycles)
r2375r2376
989989         case 0x32:      /* REDC,2 */
990990         case 0x33:      /* REDC,3 */
991991            s2650_ICount -= 6;
992            S.reg[S.r] = io_read_byte_8(S2650_CTRL_PORT);
992            S.reg[S.r] = io_read_byte_8le(S2650_CTRL_PORT);
993993            SET_CC( S.reg[S.r] );
994994            break;
995995
r2375r2376
10791079         case 0x56:      /* REDE,2 v */
10801080         case 0x57:      /* REDE,3 v */
10811081            s2650_ICount -= 9;
1082            S.reg[S.r] = io_read_byte_8( ARG() );
1082            S.reg[S.r] = io_read_byte_8le( ARG() );
10831083            SET_CC(S.reg[S.r]);
10841084            break;
10851085
r2375r2376
11381138         case 0x72:      /* REDD,2 */
11391139         case 0x73:      /* REDD,3 */
11401140            s2650_ICount -= 6;
1141            S.reg[S.r] = io_read_byte_8(S2650_DATA_PORT);
1141            S.reg[S.r] = io_read_byte_8le(S2650_DATA_PORT);
11421142            SET_CC(S.reg[S.r]);
11431143            break;
11441144
r2375r2376
12941294         case 0xb2:      /* WRTC,2 */
12951295         case 0xb3:      /* WRTC,3 */
12961296            s2650_ICount -= 6;
1297            io_write_byte_8(S2650_CTRL_PORT,S.reg[S.r]);
1297            io_write_byte_8le(S2650_CTRL_PORT,S.reg[S.r]);
12981298            break;
12991299
13001300         case 0xb4:      /* TPSU */
r2375r2376
13801380         case 0xd6:      /* WRTE,2 v */
13811381         case 0xd7:      /* WRTE,3 v */
13821382            s2650_ICount -= 9;
1383            io_write_byte_8( ARG(), S.reg[S.r] );
1383            io_write_byte_8le( ARG(), S.reg[S.r] );
13841384            break;
13851385
13861386         case 0xd8:      /* BIRR,0 (*)a */
r2375r2376
14381438         case 0xf2:      /* WRTD,2 */
14391439         case 0xf3:      /* WRTD,3 */
14401440            s2650_ICount -= 6;
1441            io_write_byte_8(S2650_DATA_PORT, S.reg[S.r]);
1441            io_write_byte_8le(S2650_DATA_PORT, S.reg[S.r]);
14421442            break;
14431443
14441444         case 0xf4:      /* TMI,0  v */
src/emu/cpu/e132xs/e132xs.c
r2375r2376
385385#define SAME_SRCF_DST  (decode)->same_srcf_dst
386386
387387#if (HAS_E116T || HAS_E116XT || HAS_E116XS || HAS_E116XSR || HAS_GMS30C2116 || HAS_GMS30C2216)
388static UINT32 program_read_dword_16be(offs_t address)
388static UINT32 internal_program_read_dword_16be(offs_t address)
389389{
390390   return (program_read_word_16be(address & ~1) << 16) | program_read_word_16be((address & ~1) + 2);
391391}
392392
393static void program_write_dword_16be(offs_t address, UINT32 data)
393static void internal_program_write_dword_16be(offs_t address, UINT32 data)
394394{
395395   program_write_word_16be(address & ~1, (data & 0xffff0000)>>16);
396396   program_write_word_16be((address & ~1)+2, data & 0xffff);
397397}
398398
399static UINT32 io_read_dword_16be(offs_t address)
399static UINT32 internal_io_read_dword_16be(offs_t address)
400400{
401401   return (io_read_word_16be(address & ~1)<< 16) | io_read_word_16be((address & ~1) + 2);
402402}
403403
404static void io_write_dword_16be(offs_t address, UINT32 data)
404static void internal_io_write_dword_16be(offs_t address, UINT32 data)
405405{
406406   io_write_word_16be(address & ~1, (data & 0xffff0000)>>16);
407407   io_write_word_16be((address & ~1)+2, data & 0xffff);
r2375r2376
15861586{
15871587   hyp_cpu_read_byte      = program_read_byte_16be;
15881588   hyp_cpu_read_half_word = program_read_word_16be;
1589   hyp_cpu_read_word      = program_read_dword_16be;
1590   hyp_cpu_read_io_word   = io_read_dword_16be;
1589   hyp_cpu_read_word      = internal_program_read_dword_16be;
1590   hyp_cpu_read_io_word   = internal_io_read_dword_16be;
15911591
15921592   hyp_cpu_write_byte      = program_write_byte_16be;
15931593   hyp_cpu_write_half_word = program_write_word_16be;
1594   hyp_cpu_write_word      = program_write_dword_16be;
1595   hyp_cpu_write_io_word   = io_write_dword_16be;
1594   hyp_cpu_write_word      = internal_program_write_dword_16be;
1595   hyp_cpu_write_io_word   = internal_io_write_dword_16be;
15961596
15971597   hyp_type_16bit = 1;
15981598
src/emu/cpu/i386/i386.c
r2375r2376
489489
490490/*************************************************************************/
491491
492static void i386_postload(void)
492static STATE_POSTLOAD( i386_postload )
493493{
494494   int i;
495495   for (i = 0; i < 6; i++)
r2375r2376
581581   state_save_register_item(state_type, index, I.ldtr.flags);
582582   state_save_register_item(state_type, index,  I.irq_state);
583583   state_save_register_item(state_type, index, I.performed_intersegment_jump);
584   state_save_register_func_postload(i386_postload);
584   state_save_register_postload(Machine, i386_postload, NULL);
585585}
586586
587587static void build_opcode_table(UINT32 features)
src/emu/cpu/cop400/410ops.c
r2375r2376
1212#define INSTRUCTION(mnemonic) INLINE void (mnemonic)(UINT8 opcode)
1313
1414#define ROM(addr)         cpu_readop(addr)
15#define RAM_W(addr, value)   (data_write_byte_8(addr, value))
16#define RAM_R(addr)         (data_read_byte_8(addr))
15#define RAM_W(addr, value)   (data_write_byte_8le(addr, value))
16#define RAM_R(addr)         (data_read_byte_8le(addr))
1717
18#define IN(addr)         io_read_byte_8(addr)
19#define OUT(addr, value)   io_write_byte_8(addr, value)
18#define IN(addr)         io_read_byte_8le(addr)
19#define OUT(addr, value)   io_write_byte_8le(addr, value)
2020
2121#define A            R.A
2222#define B            R.B
src/emu/cpu/m6502/mincce02.h
r2375r2376
6666
6767#define PEEK_OP()   cpu_readop(PCW)
6868
69#define RDMEM(addr)         program_read_byte_8(addr); m65ce02_ICount -= 1
70#define WRMEM(addr,data)   program_write_byte_8(addr,data); m65ce02_ICount -= 1
69#define RDMEM(addr)         program_read_byte_8le(addr); m65ce02_ICount -= 1
70#define WRMEM(addr,data)   program_write_byte_8le(addr,data); m65ce02_ICount -= 1
7171
src/emu/cpu/m6502/minc4510.h
r2375r2376
5555
5656#define PEEK_OP()   cpu_readop(M4510_MEM(PCD))
5757
58#define RDMEM(addr)         program_read_byte_8(addr); m4510_ICount -= 1
59#define WRMEM(addr,data)   program_write_byte_8(addr,data); m4510_ICount -= 1
58#define RDMEM(addr)         program_read_byte_8le(addr); m4510_ICount -= 1
59#define WRMEM(addr,data)   program_write_byte_8le(addr,data); m4510_ICount -= 1
6060
6161/***************************************************************
6262 *  RDOP    read an opcode
src/emu/cpu/m6502/tdeco16.c
r2375r2376
189189OP(47) { RD_DUM; ILL; }                           /* 2 ILL / 5 RMB4 ZPG ?? */
190190OP(67) {
191191   int tmp; RD_IMM;
192   m6502.a=io_read_byte_8(0);
192   m6502.a=io_read_byte_8le(0);
193193
194194//  logerror("%04x: VBL (0x67)\n",activecpu_get_pc());
195195
r2375r2376
275275OP(4b) { int tmp; m6502_ICount -= 1; RD_IMM;
276276   logerror("%04x: OP4B %02x\n",activecpu_get_pc(),tmp);
277277
278//  m6502.a=io_read_byte_8(0);
278//  m6502.a=io_read_byte_8le(0);
279279
280280//tilt??
281281
r2375r2376
367367OP(8f) { int tmp; m6502_ICount -= 1; RD_IMM;
368368   logerror("%04x: BANK (8F) %02x\n",activecpu_get_pc(),tmp);
369369
370   io_write_byte_8(0,tmp);
370   io_write_byte_8le(0,tmp);
371371
372372//swap bank in/out
373373
src/emu/cpu/m6502/m4510.c
r2375r2376
173173#define M4510
174174#include "t65ce02.c"
175175
176static READ8_HANDLER( default_rdmem_id ) { return program_read_byte_8(offset); }
177static WRITE8_HANDLER( default_wrmem_id ) { program_write_byte_8(offset, data); }
176static READ8_HANDLER( default_rdmem_id ) { return program_read_byte_8le(offset); }
177static WRITE8_HANDLER( default_wrmem_id ) { program_write_byte_8le(offset, data); }
178178
179179static void m4510_init(int index, int clock, const void *config, int (*irqcallback)(int))
180180{
src/emu/cpu/m6502/ops02.h
r2375r2376
8181/***************************************************************
8282 *  RDMEM   read memory
8383 ***************************************************************/
84#define RDMEM(addr) program_read_byte_8(addr); m6502_ICount -= 1
84#define RDMEM(addr) program_read_byte_8le(addr); m6502_ICount -= 1
8585
8686/***************************************************************
8787 *  WRMEM   write memory
8888 ***************************************************************/
89#define WRMEM(addr,data) program_write_byte_8(addr,data); m6502_ICount -= 1
89#define WRMEM(addr,data) program_write_byte_8le(addr,data); m6502_ICount -= 1
9090
9191/***************************************************************
9292 *  BRA  branch relative
src/emu/cpu/m6502/m6502.c
r2375r2376
8989
9090static m6502_Regs m6502;
9191
92static READ8_HANDLER( default_rdmem_id ) { return program_read_byte_8(offset); }
93static WRITE8_HANDLER( default_wdmem_id ) { program_write_byte_8(offset, data); }
92static READ8_HANDLER( default_rdmem_id ) { return program_read_byte_8le(offset); }
93static WRITE8_HANDLER( default_wdmem_id ) { program_write_byte_8le(offset, data); }
9494
9595/***************************************************************
9696 * include the opcode macros, functions and tables
src/emu/cpu/m6502/ops09.h
r2375r2376
5252 *  RDMEM   read memory
5353 ***************************************************************/
5454#undef RDMEM
55#define RDMEM(addr) program_read_byte_8(addr); m6502_ICount -= 1
55#define RDMEM(addr) program_read_byte_8le(addr); m6502_ICount -= 1
5656
5757/***************************************************************
5858 *  WRMEM   write memory
5959 ***************************************************************/
6060#undef WRMEM
61#define WRMEM(addr,data) program_write_byte_8(addr,data); m6502_ICount -= 1
61#define WRMEM(addr,data) program_write_byte_8le(addr,data); m6502_ICount -= 1
6262
6363/***************************************************************
6464 * push a register onto the stack
src/emu/cpu/m6502/m6509.c
r2375r2376
119119   AM_RANGE(0x00001, 0x00001) AM_MIRROR(0xF0000) AM_READWRITE(m6509_read_00001, m6509_write_00001)
120120ADDRESS_MAP_END
121121
122static READ8_HANDLER( default_rdmem_id ) { return program_read_byte_8(offset); }
123static WRITE8_HANDLER( default_wdmem_id ) { program_write_byte_8(offset, data); }
122static READ8_HANDLER( default_rdmem_id ) { return program_read_byte_8le(offset); }
123static WRITE8_HANDLER( default_wdmem_id ) { program_write_byte_8le(offset, data); }
124124
125125static void m6509_init(int index, int clock, const void *config, int (*irqcallback)(int))
126126{
src/emu/cpu/m6502/m65ce02.c
r2375r2376
9191
9292static void m65ce02_init(int index, int clock, const void *config, int (*irqcallback)(int))
9393{
94   m65ce02.rdmem_id = program_read_byte_8;
95   m65ce02.wrmem_id = program_write_byte_8;
94   m65ce02.rdmem_id = program_read_byte_8le;
95   m65ce02.wrmem_id = program_write_byte_8le;
9696   m65ce02.irq_callback = irqcallback;
9797}
9898
src/emu/cpu/jaguar/jaguar.c
r2375r2376
415415         }
416416}
417417
418static STATE_POSTLOAD( jaguar_postload )
419{
420   update_register_banks();
421   check_irqs();
422}
423
418424static void jaguar_state_register(int index, const char *type)
419425{
420426   state_save_register_item_array(type, index, jaguar.r);
421427   state_save_register_item_array(type, index, jaguar.a);
422428   state_save_register_item_array(type, index, jaguar.ctrl);
423429   state_save_register_item(type, index, jaguar.ppc);
424   state_save_register_func_postload(update_register_banks);
425   state_save_register_func_postload(check_irqs);
430   state_save_register_postload(Machine, jaguar_postload, NULL);
426431}
427432
428433static void jaguargpu_init(int index, int clock, const void *_config, int (*irqcallback)(int))
src/emu/cpu/i8085/i8085cpu.h
r2375r2376
107107
108108#define M_IN                                       \
109109   I.XX.d=ARG();                                    \
110   I.AF.b.h=io_read_byte_8(I.XX.d);
110   I.AF.b.h=io_read_byte_8le(I.XX.d);
111111
112112#define M_OUT                                       \
113113   I.XX.d=ARG();                                    \
114   io_write_byte_8(I.XX.d,I.AF.b.h)
114   io_write_byte_8le(I.XX.d,I.AF.b.h)
115115
116116#define M_DAD(R) {                                              \
117117   int q = I.HL.d + I.R.d;                            \
src/emu/cpu/i8085/i8085.c
r2375r2376
176176
177177static UINT8 RM(UINT32 a)
178178{
179   return program_read_byte_8(a);
179   return program_read_byte_8le(a);
180180}
181181
182182static void WM(UINT32 a, UINT8 v)
183183{
184   program_write_byte_8(a, v);
184   program_write_byte_8le(a, v);
185185}
186186
187187INLINE void execute_one(int opcode)
src/emu/cpu/z8000/z8000.c
r2375r2376
233233{
234234   if( mode == 0 )
235235   {
236      return io_read_byte_8(addr);
236      return io_read_byte_8le(addr);
237237   }
238238   else
239239   {
r2375r2376
246246{
247247   if( mode == 0 )
248248   {
249      return io_read_byte_8((UINT16)(addr)) +
250           (io_read_byte_8((UINT16)(addr+1)) << 8);
249      return io_read_byte_8le((UINT16)(addr)) +
250           (io_read_byte_8le((UINT16)(addr+1)) << 8);
251251   }
252252   else
253253   {
r2375r2376
261261{
262262   if( mode == 0 )
263263   {
264      return   io_read_byte_8((UINT16)(addr)) +
265            (io_read_byte_8((UINT16)(addr+1)) <<  8) +
266            (io_read_byte_8((UINT16)(addr+2)) << 16) +
267            (io_read_byte_8((UINT16)(addr+3)) << 24);
264      return   io_read_byte_8le((UINT16)(addr)) +
265            (io_read_byte_8le((UINT16)(addr+1)) <<  8) +
266            (io_read_byte_8le((UINT16)(addr+2)) << 16) +
267            (io_read_byte_8le((UINT16)(addr+3)) << 24);
268268   }
269269   else
270270   {
r2375r2376
278278{
279279   if( mode == 0 )
280280   {
281        io_write_byte_8(addr,value);
281        io_write_byte_8le(addr,value);
282282   }
283283   else
284284   {
r2375r2376
290290{
291291   if( mode == 0 )
292292   {
293      io_write_byte_8((UINT16)(addr),value & 0xff);
294      io_write_byte_8((UINT16)(addr+1),(value >> 8) & 0xff);
293      io_write_byte_8le((UINT16)(addr),value & 0xff);
294      io_write_byte_8le((UINT16)(addr+1),(value >> 8) & 0xff);
295295   }
296296   else
297297   {
r2375r2376
304304{
305305   if( mode == 0 )
306306   {
307      io_write_byte_8((UINT16)(addr),value & 0xff);
308      io_write_byte_8((UINT16)(addr+1),(value >> 8) & 0xff);
309      io_write_byte_8((UINT16)(addr+2),(value >> 16) & 0xff);
310      io_write_byte_8((UINT16)(addr+3),(value >> 24) & 0xff);
307      io_write_byte_8le((UINT16)(addr),value & 0xff);
308      io_write_byte_8le((UINT16)(addr+1),(value >> 8) & 0xff);
309      io_write_byte_8le((UINT16)(addr+2),(value >> 16) & 0xff);
310      io_write_byte_8le((UINT16)(addr+3),(value >> 24) & 0xff);
311311   }
312312   else
313313   {
src/emu/cpu/sm8500/sm8500.c
r2375r2376
6161};
6262
6363UINT8 sm85cpu_mem_readbyte( UINT32 offset ) {
64   return ( offset < 0x10 ) ? regs.register_base[offset] : program_read_byte_8( offset );
64   return ( offset < 0x10 ) ? regs.register_base[offset] : program_read_byte_8be( offset );
6565}
6666
6767void sm85cpu_mem_writebyte( UINT32 offset, UINT8 data ) {
6868   if ( offset < 0x10 ) {
6969      regs.register_base[offset] = data;
7070   } else {
71      program_write_byte_8( offset, data );
71      program_write_byte_8be( offset, data );
7272   }
7373}
7474
src/emu/cpu/mb88xx/mb88xx.c
r2375r2376
6868
6969#define READOP(a)          (cpu_readop(a))
7070
71#define RDMEM(a)         (data_read_byte_8(a))
72#define WRMEM(a,v)         (data_write_byte_8((a), (v)))
71#define RDMEM(a)         (data_read_byte_8be(a))
72#define WRMEM(a,v)         (data_write_byte_8be((a), (v)))
7373
74#define READPORT(a)         (io_read_byte_8(a))
75#define WRITEPORT(a,v)      (io_write_byte_8((a), (v)))
74#define READPORT(a)         (io_read_byte_8be(a))
75#define WRITEPORT(a,v)      (io_write_byte_8be((a), (v)))
7676
7777#define TEST_ST()         (mb88.st & 1)
7878#define TEST_ZF()         (mb88.zf & 1)
src/emu/cpu/alph8201/alph8201.h
r2375r2376
4444/*
4545 *   Read a UINT8 from given memory location
4646 */
47#define ALPHA8201_RDMEM(A) ((unsigned)program_read_byte_8(A))
47#define ALPHA8201_RDMEM(A) ((unsigned)program_read_byte_8le(A))
4848
4949/*
5050 *   Write a UINT8 to given memory location
5151 */
52#define ALPHA8201_WRMEM(A,V) (program_write_byte_8(A,V))
52#define ALPHA8201_WRMEM(A,V) (program_write_byte_8le(A,V))
5353
5454/*
5555 *   ALPHA8201_RDOP() is identical to ALPHA8201_RDMEM() except it is used for reading
src/emu/cpu/apexc/apexc.c
r2375r2376
448448
449449static int papertape_read(void)
450450{
451   return io_read_byte_8(0) & 0x1f;
451   return io_read_byte_8be(0) & 0x1f;
452452}
453453
454454static void papertape_punch(int data)
455455{
456   io_write_byte_8(0, data);
456   io_write_byte_8be(0, data);
457457}
458458
459459/*
src/emu/cpu/g65816/g65816.h
r2375r2376
9191#undef G65816_CALL_DEBUGGER
9292#define G65816_CALL_DEBUGGER CALL_DEBUGGER
9393
94#define g65816_read_8(addr)          program_read_byte_8(addr)
95#define g65816_write_8(addr,data)      program_write_byte_8(addr,data)
96#define g65816_read_8_immediate(A)      program_read_byte_8(A)
94#define g65816_read_8(addr)          program_read_byte_8be(addr)
95#define g65816_write_8(addr,data)      program_write_byte_8be(addr,data)
96#define g65816_read_8_immediate(A)      program_read_byte_8be(A)
9797#define g65816_jumping(A)            change_pc(A)
9898#define g65816_branching(A)
9999
src/emu/cpu/nec/nec.c
r2375r2376
121121   NULL
122122};
123123
124extern int necv_dasm_one(char *buffer, UINT32 eip, const UINT8 *oprom);
124extern int necv_dasm_one(char *buffer, UINT32 eip, const UINT8 *oprom, const nec_config *config);
125125
126126/* NEC registers */
127127typedef union
r2375r2376
320320
321321#define OP(num,func_name) static void func_name(void)
322322
323OP( 0x00, i_add_br8  ) { DEF_br8;   ADDB;   PutbackRMByte(ModRM,dst);   CLKM(2,2,2,16,13,7);       }
323OP( 0x00, i_add_br8  ) { DEF_br8;   ADDB;   PutbackRMByte(ModRM,dst);   CLKM(2,2,2,16,16,7);       }
324324OP( 0x01, i_add_wr16 ) { DEF_wr16;   ADDW;   PutbackRMWord(ModRM,dst);   CLKR(24,24,11,24,16,7,2,EA);}
325OP( 0x02, i_add_r8b  ) { DEF_r8b;   ADDB;   RegByte(ModRM)=dst;         CLKM(2,2,2,11,10,6);      }
325OP( 0x02, i_add_r8b  ) { DEF_r8b;   ADDB;   RegByte(ModRM)=dst;         CLKM(2,2,2,11,11,6);      }
326326OP( 0x03, i_add_r16w ) { DEF_r16w;   ADDW;   RegWord(ModRM)=dst;         CLKR(15,15,8,15,11,6,2,EA);   }
327327OP( 0x04, i_add_ald8 ) { DEF_ald8;   ADDB;   I.regs.b[AL]=dst;         CLKS(4,4,2);            }
328328OP( 0x05, i_add_axd16) { DEF_axd16;   ADDW;   I.regs.w[AW]=dst;         CLKS(4,4,2);            }
329329OP( 0x06, i_push_es  ) { PUSH(I.sregs[DS1]);   CLKS(12,8,3);    }
330330OP( 0x07, i_pop_es   ) { POP(I.sregs[DS1]);   CLKS(12,8,5);   }
331331
332OP( 0x08, i_or_br8   ) { DEF_br8;   ORB;   PutbackRMByte(ModRM,dst);   CLKM(2,2,2,16,13,7);      }
332OP( 0x08, i_or_br8   ) { DEF_br8;   ORB;   PutbackRMByte(ModRM,dst);   CLKM(2,2,2,16,16,7);      }
333333OP( 0x09, i_or_wr16  ) { DEF_wr16;   ORW;   PutbackRMWord(ModRM,dst);   CLKR(24,24,11,24,16,7,2,EA);}
334OP( 0x0a, i_or_r8b   ) { DEF_r8b;   ORB;   RegByte(ModRM)=dst;         CLKM(2,2,2,11,10,6);      }
334OP( 0x0a, i_or_r8b   ) { DEF_r8b;   ORB;   RegByte(ModRM)=dst;         CLKM(2,2,2,11,11,6);      }
335335OP( 0x0b, i_or_r16w  ) { DEF_r16w;   ORW;   RegWord(ModRM)=dst;         CLKR(15,15,8,15,11,6,2,EA);   }
336336OP( 0x0c, i_or_ald8  ) { DEF_ald8;   ORB;   I.regs.b[AL]=dst;         CLKS(4,4,2);            }
337337OP( 0x0d, i_or_axd16 ) { DEF_axd16;   ORW;   I.regs.w[AW]=dst;         CLKS(4,4,2);            }
338OP( 0x0e, i_push_cs  ) { PUSH(I.sregs[PS]);   CLKS(12,8,5);   }
338OP( 0x0e, i_push_cs  ) { PUSH(I.sregs[PS]);   CLKS(12,8,3);   }
339339OP( 0x0f, i_pre_nec  ) { UINT32 ModRM, tmp, tmp2;
340340   switch (FETCH) {
341341      case 0x10 : BITOP_BYTE;   CLKS(3,3,4); tmp2 = I.regs.b[CL] & 0x7;   I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0;   I.CarryVal=I.OverVal=0; break; /* Test */
r2375r2376
371371   }
372372}
373373
374OP( 0x10, i_adc_br8  ) { DEF_br8;   src+=CF;   ADDB;   PutbackRMByte(ModRM,dst);   CLKM(2,2,2,16,13,7);       }
374OP( 0x10, i_adc_br8  ) { DEF_br8;   src+=CF;   ADDB;   PutbackRMByte(ModRM,dst);   CLKM(2,2,2,16,16,7);       }
375375OP( 0x11, i_adc_wr16 ) { DEF_wr16;   src+=CF;   ADDW;   PutbackRMWord(ModRM,dst);   CLKR(24,24,11,24,16,7,2,EA);}
376OP( 0x12, i_adc_r8b  ) { DEF_r8b;   src+=CF;   ADDB;   RegByte(ModRM)=dst;         CLKM(2,2,2,11,10,6);       }
376OP( 0x12, i_adc_r8b  ) { DEF_r8b;   src+=CF;   ADDB;   RegByte(ModRM)=dst;         CLKM(2,2,2,11,11,6);       }
377377OP( 0x13, i_adc_r16w ) { DEF_r16w;   src+=CF;   ADDW;   RegWord(ModRM)=dst;         CLKR(15,15,8,15,11,6,2,EA);   }
378378OP( 0x14, i_adc_ald8 ) { DEF_ald8;   src+=CF;   ADDB;   I.regs.b[AL]=dst;         CLKS(4,4,2);            }
379379OP( 0x15, i_adc_axd16) { DEF_axd16;   src+=CF;   ADDW;   I.regs.w[AW]=dst;         CLKS(4,4,2);            }
380380OP( 0x16, i_push_ss  ) { PUSH(I.sregs[SS]);      CLKS(12,8,3);   }
381381OP( 0x17, i_pop_ss   ) { POP(I.sregs[SS]);      CLKS(12,8,5);   I.no_interrupt=1; }
382382
383OP( 0x18, i_sbb_br8  ) { DEF_br8;   src+=CF;   SUBB;   PutbackRMByte(ModRM,dst);   CLKM(2,2,2,16,13,7);       }
383OP( 0x18, i_sbb_br8  ) { DEF_br8;   src+=CF;   SUBB;   PutbackRMByte(ModRM,dst);   CLKM(2,2,2,16,16,7);       }
384384OP( 0x19, i_sbb_wr16 ) { DEF_wr16;   src+=CF;   SUBW;   PutbackRMWord(ModRM,dst);   CLKR(24,24,11,24,16,7,2,EA);}
385OP( 0x1a, i_sbb_r8b  ) { DEF_r8b;   src+=CF;   SUBB;   RegByte(ModRM)=dst;         CLKM(2,2,2,11,10,6);       }
385OP( 0x1a, i_sbb_r8b  ) { DEF_r8b;   src+=CF;   SUBB;   RegByte(ModRM)=dst;         CLKM(2,2,2,11,11,6);       }
386386OP( 0x1b, i_sbb_r16w ) { DEF_r16w;   src+=CF;   SUBW;   RegWord(ModRM)=dst;         CLKR(15,15,8,15,11,6,2,EA);   }
387387OP( 0x1c, i_sbb_ald8 ) { DEF_ald8;   src+=CF;   SUBB;   I.regs.b[AL]=dst;         CLKS(4,4,2);             }
388388OP( 0x1d, i_sbb_axd16) { DEF_axd16;   src+=CF;   SUBW;   I.regs.w[AW]=dst;         CLKS(4,4,2);   }
389389OP( 0x1e, i_push_ds  ) { PUSH(I.sregs[DS0]);      CLKS(12,8,3);   }
390390OP( 0x1f, i_pop_ds   ) { POP(I.sregs[DS0]);      CLKS(12,8,5);   }
391391
392OP( 0x20, i_and_br8  ) { DEF_br8;   ANDB;   PutbackRMByte(ModRM,dst);   CLKM(2,2,2,16,13,7);       }
392OP( 0x20, i_and_br8  ) { DEF_br8;   ANDB;   PutbackRMByte(ModRM,dst);   CLKM(2,2,2,16,16,7);       }
393393OP( 0x21, i_and_wr16 ) { DEF_wr16;   ANDW;   PutbackRMWord(ModRM,dst);   CLKR(24,24,11,24,16,7,2,EA);}
394OP( 0x22, i_and_r8b  ) { DEF_r8b;   ANDB;   RegByte(ModRM)=dst;         CLKM(2,2,2,11,10,6);      }
394OP( 0x22, i_and_r8b  ) { DEF_r8b;   ANDB;   RegByte(ModRM)=dst;         CLKM(2,2,2,11,11,6);      }
395395OP( 0x23, i_and_r16w ) { DEF_r16w;   ANDW;   RegWord(ModRM)=dst;         CLKR(15,15,8,15,11,6,2,EA);   }
396396OP( 0x24, i_and_ald8 ) { DEF_ald8;   ANDB;   I.regs.b[AL]=dst;         CLKS(4,4,2);            }
397397OP( 0x25, i_and_axd16) { DEF_axd16;   ANDW;   I.regs.w[AW]=dst;         CLKS(4,4,2);   }
398398OP( 0x26, i_es       ) { seg_prefix=TRUE;   prefix_base=I.sregs[DS1]<<4;   CLK(2);      nec_instruction[fetchop()]();   seg_prefix=FALSE; }
399399OP( 0x27, i_daa      ) { ADJ4(6,0x60);                           CLKS(3,3,2);   }
400400
401OP( 0x28, i_sub_br8  ) { DEF_br8;   SUBB;   PutbackRMByte(ModRM,dst);   CLKM(2,2,2,16,13,7);       }
401OP( 0x28, i_sub_br8  ) { DEF_br8;   SUBB;   PutbackRMByte(ModRM,dst);   CLKM(2,2,2,16,16,7);       }
402402OP( 0x29, i_sub_wr16 ) { DEF_wr16;   SUBW;   PutbackRMWord(ModRM,dst);   CLKR(24,24,11,24,16,7,2,EA);}
403OP( 0x2a, i_sub_r8b  ) { DEF_r8b;   SUBB;   RegByte(ModRM)=dst;         CLKM(2,2,2,11,10,6);       }
403OP( 0x2a, i_sub_r8b  ) { DEF_r8b;   SUBB;   RegByte(ModRM)=dst;         CLKM(2,2,2,11,11,6);       }
404404OP( 0x2b, i_sub_r16w ) { DEF_r16w;   SUBW;   RegWord(ModRM)=dst;         CLKR(15,15,8,15,11,6,2,EA);   }
405405OP( 0x2c, i_sub_ald8 ) { DEF_ald8;   SUBB;   I.regs.b[AL]=dst;         CLKS(4,4,2);             }
406406OP( 0x2d, i_sub_axd16) { DEF_axd16;   SUBW;   I.regs.w[AW]=dst;         CLKS(4,4,2);   }
407407OP( 0x2e, i_cs       ) { seg_prefix=TRUE;   prefix_base=I.sregs[PS]<<4;   CLK(2);      nec_instruction[fetchop()]();   seg_prefix=FALSE; }
408408OP( 0x2f, i_das      ) { ADJ4(-6,-0x60);                        CLKS(3,3,2);   }
409409
410OP( 0x30, i_xor_br8  ) { DEF_br8;   XORB;   PutbackRMByte(ModRM,dst);   CLKM(2,2,2,16,13,7);      }
410OP( 0x30, i_xor_br8  ) { DEF_br8;   XORB;   PutbackRMByte(ModRM,dst);   CLKM(2,2,2,16,16,7);      }
411411OP( 0x31, i_xor_wr16 ) { DEF_wr16;   XORW;   PutbackRMWord(ModRM,dst);   CLKR(24,24,11,24,16,7,2,EA);}
412OP( 0x32, i_xor_r8b  ) { DEF_r8b;   XORB;   RegByte(ModRM)=dst;         CLKM(2,2,2,11,10,6);       }
412OP( 0x32, i_xor_r8b  ) { DEF_r8b;   XORB;   RegByte(ModRM)=dst;         CLKM(2,2,2,11,11,6);       }
413413OP( 0x33, i_xor_r16w ) { DEF_r16w;   XORW;   RegWord(ModRM)=dst;         CLKR(15,15,8,15,11,6,2,EA);   }
414414OP( 0x34, i_xor_ald8 ) { DEF_ald8;   XORB;   I.regs.b[AL]=dst;         CLKS(4,4,2);             }
415415OP( 0x35, i_xor_axd16) { DEF_axd16;   XORW;   I.regs.w[AW]=dst;         CLKS(4,4,2);   }
416416OP( 0x36, i_ss       ) { seg_prefix=TRUE;   prefix_base=I.sregs[SS]<<4;   CLK(2);      nec_instruction[fetchop()]();   seg_prefix=FALSE; }
417417OP( 0x37, i_aaa      ) { ADJB(6, (I.regs.b[AL] > 0xf9) ? 2 : 1);      CLKS(7,7,4);    }
418418
419OP( 0x38, i_cmp_br8  ) { DEF_br8;   SUBB;               CLKM(2,2,2,11,10,6); }
419OP( 0x38, i_cmp_br8  ) { DEF_br8;   SUBB;               CLKM(2,2,2,11,11,6); }
420420OP( 0x39, i_cmp_wr16 ) { DEF_wr16;   SUBW;               CLKR(15,15,8,15,11,6,2,EA);}
421OP( 0x3a, i_cmp_r8b  ) { DEF_r8b;   SUBB;               CLKM(2,2,2,11,10,6); }
421OP( 0x3a, i_cmp_r8b  ) { DEF_r8b;   SUBB;               CLKM(2,2,2,11,11,6); }
422422OP( 0x3b, i_cmp_r16w ) { DEF_r16w;   SUBW;               CLKR(15,15,8,15,11,6,2,EA);   }
423423OP( 0x3c, i_cmp_ald8 ) { DEF_ald8;   SUBB;               CLKS(4,4,2); }
424424OP( 0x3d, i_cmp_axd16) { DEF_axd16;   SUBW;               CLKS(4,4,2);   }
r2375r2376
10431043#ifdef ENABLE_DEBUGGER
10441044static offs_t nec_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram)
10451045{
1046   return necv_dasm_one(buffer, pc, oprom);
1046   return necv_dasm_one(buffer, pc, oprom, I.config);
10471047}
10481048#endif /* ENABLE_DEBUGGER */
10491049
r2375r2376
10861086 *****************************************************************************/
10871087
10881088#if (HAS_V20||HAS_V25)
1089static UINT16 read_word_8(offs_t addr)
1090{
1091   UINT16 result = program_read_byte_8(addr);
1092   return result | (program_read_byte_8(addr + 1) << 8);
1093}
1094
1095static void write_word_8(offs_t addr, UINT16 data)
1096{
1097   program_write_byte_8(addr, data);
1098   program_write_byte_8(addr + 1, data >> 8);
1099}
1100
1101static UINT16 read_port_word_8(offs_t addr)
1102{
1103   UINT16 result = io_read_byte_8(addr);
1104   return result | (io_read_byte_8(addr + 1) << 8);
1105}
1106
1107static void write_port_word_8(offs_t addr, UINT16 data)
1108{
1109   io_write_byte_8(addr, data);
1110   io_write_byte_8(addr + 1, data >> 8);
1111}
1112
11131089static void configure_memory_8bit(void)
11141090{
11151091   I.mem.fetch_xor = 0;
11161092
1117   I.mem.rbyte = program_read_byte_8;
1118   I.mem.rword = read_word_8;
1119   I.mem.wbyte = program_write_byte_8;
1120   I.mem.wword = write_word_8;
1093   I.mem.rbyte = program_read_byte_8le;
1094   I.mem.rword = program_read_word_8le;
1095   I.mem.wbyte = program_write_byte_8le;
1096   I.mem.wword = program_write_word_8le;
11211097
1122   I.mem.rbyte_port = io_read_byte_8;
1123   I.mem.rword_port = read_port_word_8;
1124   I.mem.wbyte_port = io_write_byte_8;
1125   I.mem.wword_port = write_port_word_8;
1098   I.mem.rbyte_port = io_read_byte_8le;
1099   I.mem.rword_port = io_read_word_8le;
1100   I.mem.wbyte_port = io_write_byte_8le;
1101   I.mem.wword_port = io_write_word_8le;
11261102}
11271103#endif
11281104
src/emu/cpu/nec/necdasm.c
r2375r2376
77
88#include "cpuintrf.h"
99
10typedef struct _nec_config nec_config;
11struct _nec_config
12{
13   const UINT8*   v25v35_decryptiontable; // internal decryption table
14};
15
16/* default configuration */
17static const nec_config default_config =
18{
19   NULL
20};
21
22static const nec_config *Iconfig;
23
1024enum {
1125   PARAM_REG8 = 1,      /* 8-bit register */
1226   PARAM_REG16,      /* 16-bit register */
r2375r2376
14371451   }
14381452}
14391453
1440static void decode_opcode(char *s, const I386_OPCODE *op, UINT8 op1)
1454static void decode_opcode(char *s, const I386_OPCODE *op, UINT8 op1 )
14411455{
14421456   int i;
14431457   UINT8 op2;
r2375r2376
14551469      case SEG_SS:
14561470         segment = op->flags;
14571471         op2 = FETCH();
1472         if (Iconfig->v25v35_decryptiontable) op2 = Iconfig->v25v35_decryptiontable[op2];
14581473         decode_opcode( s, &necv_opcode_table1[op2], op1 );
14591474         return;
14601475
14611476      case PREFIX:
14621477         s += sprintf( s, "%-8s", op->mnemonic );
14631478         op2 = FETCH();
1479         if (Iconfig->v25v35_decryptiontable) op2 = Iconfig->v25v35_decryptiontable[op2];
14641480         decode_opcode( s, &necv_opcode_table1[op2], op1 );
14651481         return;
14661482
14671483      case GROUP:
14681484         handle_modrm( modrm_string );
14691485         for( i=0; i < ARRAY_LENGTH(group_op_table); i++ ) {
1470            if( mame_stricmp(op->mnemonic, group_op_table[i].mnemonic) == 0 ) {
1486            if( mame_stricmp(op->mnemonic, group_op_table[i].mnemonic) == 0 )
1487            {
14711488               decode_opcode( s, &group_op_table[i].opcode[MODRM_REG1], op1 );
14721489               return;
14731490            }
r2375r2376
15061523   sprintf(s, "???");
15071524}
15081525
1509int necv_dasm_one(char *buffer, UINT32 eip, const UINT8 *oprom)
1526int necv_dasm_one(char *buffer, UINT32 eip, const UINT8 *oprom, const nec_config *_config)
15101527{
15111528   UINT8 op;
1529   const nec_config *config = _config ? _config : &default_config;
1530   Iconfig = config;
15121531
15131532   opcode_ptr = opcode_ptr_base = oprom;
15141533   pc = eip;
r2375r2376
15171536
15181537   op = FETCH();
15191538
1539   if (Iconfig->v25v35_decryptiontable) op = Iconfig->v25v35_decryptiontable[op];
1540
15201541   decode_opcode( buffer, &necv_opcode_table1[op], op );
15211542   return (pc-eip) | dasm_flags | DASMFLAG_SUPPORTED;
15221543}
src/emu/cpu/i8051/i8051.c
r2375r2376
191191 * Read a byte from External Code Memory (Usually Program Rom(s) Space)
192192 *****************************************************************************
193193 This area is mapped from 0-FFFF internally (64K) */
194#define CODEMEM_R(a)   (UINT8)program_read_byte_8(a)
194#define CODEMEM_R(a)   (UINT8)program_read_byte_8le(a)
195195/*****************************************************************************
196196 * Read/Write a byte from/to External Data Memory (Usually RAM or other I/O)
197197 *****************************************************************************
r2375r2376
202202 addresses, w/o any contention.
203203 As far as the 8051 program code which is executing knows data memory still lives
204204 in the 0-FFFF range.*/
205#define DATAMEM_R(a)   (UINT8)data_read_byte_8(a)
206#define DATAMEM_W(a,v)   data_write_byte_8(a,v)
205#define DATAMEM_R(a)   (UINT8)data_read_byte_8le(a)
206#define DATAMEM_W(a,v)   data_write_byte_8le(a,v)
207207
208208/***************************************************************
209209 * Read/Write a byte from/to the Internal RAM
src/emu/cpu/mips/dismips.mak
r2375r2376
11..\..\..\..\dismips.exe: dismips.c mipsdasm.c r3kdasm.c mips3dsm.c ../../../lib/util/corestr.c
2   gcc -O3 -Wall -I../../../emu -I../../../lib/util -I../../../osd -DINLINE="static __inline__" -DSTANDALONE -DMAME_DEBUG -DLSB_FIRST dismips.c mipsdasm.c r3kdasm.c mips3dsm.c ../../../lib/util/corestr.c -o../../../../dismips
2   gcc -O3 -Wall -I../../../emu -I../../../osd -I../../../lib/util -DINLINE="static __inline__" -DSTANDALONE -DENABLE_DEBUGGER -DLSB_FIRST dismips.c mipsdasm.c r3kdasm.c mips3dsm.c ../../../lib/util/corestr.c -o../../../../dismips
src/emu/cpu/mips/mips3com.h
r2375r2376
109109#define EXCEPTION_BADCOP   11
110110#define EXCEPTION_OVERFLOW   12
111111#define EXCEPTION_TRAP      13
112#define EXCEPTION_COUNT      16
112113
113114
114115
src/emu/cpu/mips/mips3fe.c
r2375r2376
291291      case 0x08:   /* JR */
292292         desc->gpr.used |= REGFLAG_R(RSREG);
293293         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
294         desc->targetpc = BRANCH_TARGET_DYNAMIC;
294295         desc->delayslots = 1;
295296         return TRUE;
296297
r2375r2376
298299         desc->gpr.used |= REGFLAG_R(RSREG);
299300         desc->gpr.modified |= REGFLAG_R(RDREG);
300301         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
302         desc->targetpc = BRANCH_TARGET_DYNAMIC;
301303         desc->delayslots = 1;
302304         return TRUE;
303305
src/emu/cpu/mips/dismips.c
r2375r2376
4242
4343static UINT8 *filebuf;
4444static UINT32 offset;
45static const UINT8 order[] = { 0, 1, 2, 3 };
45static UINT8 order[] = { 0, 1, 2, 3 };
4646
4747static const char *const Options[]=
4848{
r2375r2376
308308         break;
309309      }
310310
311      i &= DASMFLAG_LENGTHMASK;
312
311313      printf( "%08x: ", pc + offset );
312314      for( j = 0; j < i; j++ )
313315      {
src/emu/cpu/mips/psx.c
r2375r2376
11/*
2 * Sony CXD8530AQ/CXD8530BQ/CXD8530CQ/CXD8661R
2 * PlayStation CPU emulator by smf
33 *
4 * PSX CPU emulator for the MAME project written by smf
5 * Thanks to Farfetch'd for information on the delay slot bug
4 * Licensed to the MAME Team for distribution under the MAME license.
65 *
7 * The PSX CPU is a custom r3000a with a built in
8 * geometry transform engine, no mmu & no data cache.
6 * Known chip id's
7 *   CXD8530AQ
8 *   CXD8530BQ
9 *   CXD8530CQ
10 *   CXD8661R
11 *   CXD8606BQ
12 *   CXD8606CQ
913 *
10 * There is a stall circuit for load delays, but
11 * it doesn't work if the load occurs in a branch
12 * delay slot.
14 * The PlayStation CPU is based on the LSI LR33300.
1315 *
16 * Differences from the LR33300:
17 *
18 *  There is only 1k of data cache ram ( the LR33300 has 2k )
19 *
20 *  There is no data cache tag ram, so the data cache ram can only be used as a fast area
21 *  of ram ( which is a standard LR33300 feature ).
22 *
23 *  If COP0 is disabled in user mode you get a coprocessor unusable exception, while
24 *  the LR33300 is documented to generate a reserved instruction exception.
25 *
26 * Known limitations of the emulation:
27 *
28 *  Only read & write break points are emulated, trace and program counter breakpoints are not.
29 *
30 *  Load/Store timings are based on load scheduling turned off & no write cache. This affects when
31 *  bus error exceptions occur and also when the read & write handlers are called. A scheduled
32 *  load will complete if a load breakpoint fires, but an unscheduled load will not.
33 *
34 *  Reading from the data and instruction cache at the same time causes a bus conflict that
35 *  corrupts the data in a reliable but strange way, which is not emulated.
36 *
37 *  Values written to COP1 & COP3 can be read back by the next instruction, which is not emulated.
38 *  Because of loadscheduling the value loaded with LWC1/LWC3 can be read by more than the next
39 *  instruction.
40 *
41 *  SWC0 writes stale data from a previous operation, this is only partially emulated as the timing
42 *  is complicated. Left over instruction fetches are currently emulated as they are the most
43 *  'interesting' and have no impact on the rest of the emulation.
44 *
45 *  MTC0 timing is not emulated, switching to user mode while in kernel space continues
46 *  execution for another two instructions before taking an exception. Using RFE to do the same
47 *  thing causes the exception straight away, unless the RFE is the first instructio that follows
48 *  an MTC0 instruction.
49 *
50 *  The PRId register should be 1 on some revisions of the CPU ( there might be other values too ).
51 *
52 *  Moving to the HI/LO register after a multiply or divide, but before reading the results will
53 *  always abort the operation as if you did it immediately. In reality it should complete on it's
54 *  own, and aborting before it completes would result in returning the working results.
55 *
56 *  Running code in cached address space does not use or update the instruction cache.
57 *
58 *  Wait states are not emulated.
59 *
60 *  Bus errors caused by instruction fetches are not supported.
61 *
1462 */
1563
1664#include "debugger.h"
r2375r2376
2371#define EXC_INT ( 0 )
2472#define EXC_ADEL ( 4 )
2573#define EXC_ADES ( 5 )
74#define EXC_DBE ( 7 )
2675#define EXC_SYS ( 8 )
2776#define EXC_BP ( 9 )
2877#define EXC_RI ( 10 )
2978#define EXC_CPU ( 11 )
3079#define EXC_OVF ( 12 )
3180
81#define CP0_INDEX ( 0 )
3282#define CP0_RANDOM ( 1 )
33#define CP0_BADVADDR ( 8 )
83#define CP0_ENTRYLO ( 2 )
84#define CP0_CONTEXT ( 4 )
85#define CP0_ENTRYHI ( 10 )
86
87#define CP0_BPC ( 3 )
88#define CP0_BDA ( 5 )
89#define CP0_TAR ( 6 )
90#define CP0_DCIC ( 7 )
91#define CP0_BADA ( 8 )
92#define CP0_BDAM ( 9 )
93#define CP0_BPCM ( 11 )
3494#define CP0_SR ( 12 )
3595#define CP0_CAUSE ( 13 )
3696#define CP0_EPC ( 14 )
3797#define CP0_PRID ( 15 )
3898
99#define DCIC_STATUS ( 0x3f )
100#define DCIC_DB ( 1L << 0 )
101#define DCIC_DA ( 1L << 2 )
102#define DCIC_R ( 1L << 3 )
103#define DCIC_W ( 1L << 4 )
104#define DCIC_DE ( 1L << 23 )
105#define DCIC_DAE ( 1L << 25 )
106#define DCIC_DR ( 1L << 26 )
107#define DCIC_DW ( 1L << 27 )
108#define DCIC_KD ( 1L << 29 )
109#define DCIC_UD ( 1L << 30 )
110#define DCIC_TR ( 1L << 31 )
111
39112#define SR_IEC ( 1L << 0 )
40113#define SR_KUC ( 1L << 1 )
41114#define SR_ISC ( 1L << 16 )
42115#define SR_SWC ( 1L << 17 )
43#define SR_TS  ( 1L << 21 )
44116#define SR_BEV ( 1L << 22 )
45#define SR_RE ( 1L << 25 )
46117#define SR_CU0 ( 1L << 28 )
47118#define SR_CU1 ( 1L << 29 )
48119#define SR_CU2 ( 1L << 30 )
r2375r2376
57128#define CAUSE_IP6 ( 1L << 14 )
58129#define CAUSE_IP7 ( 1L << 15 )
59130#define CAUSE_CE ( 3L << 28 )
60#define CAUSE_CE0 ( 0L << 28 )
61#define CAUSE_CE1 ( 1L << 28 )
62#define CAUSE_CE2 ( 2L << 28 )
131#define CAUSE_BT ( 1L << 30 )
63132#define CAUSE_BD ( 1L << 31 )
64133
134#define BIU_LOCK ( 0x00000001 )
135#define BIU_INV  ( 0x00000002 )
136#define BIU_TAG  ( 0x00000004 )
137#define BIU_RAM  ( 0x00000008 )
138#define BIU_DS   ( 0x00000080 )
139#define BIU_IS1  ( 0x00000800 )
140
141#define ICACHE_ENTRIES ( 0x400 )
142#define DCACHE_ENTRIES ( 0x100 )
143
144#define TAG_MATCH_MASK ( 0 - ( ICACHE_ENTRIES * 4 ) )
145#define TAG_MATCH ( 0x10 )
146#define TAG_VALID ( 0x0f )
147
148#define MULTIPLIER_OPERATION_IDLE ( 0 )
149#define MULTIPLIER_OPERATION_MULT ( 1 )
150#define MULTIPLIER_OPERATION_MULTU ( 2 )
151#define MULTIPLIER_OPERATION_DIV ( 3 )
152#define MULTIPLIER_OPERATION_DIVU ( 4 )
153
65154static const char *const delayn[] =
66155{
67   "pc", "at", "v0", "v1", "a0", "a1", "a2", "a3",
156   "",  "at", "v0", "v1", "a0", "a1", "a2", "a3",
68157   "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
69158   "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
70159   "t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra",
71   "pc"
160   "pc", "!pc"
72161};
73162
74#define REGPC ( 32 )
75
76163typedef struct
77164{
78165   UINT32 op;
r2375r2376
81168   UINT32 delayr;
82169   UINT32 hi;
83170   UINT32 lo;
171   UINT32 biu;
172   UINT32 berr;
84173   UINT32 r[ 32 ];
85   UINT32 cp0r[ 32 ];
174   UINT32 cp0r[ 16 ];
86175   PAIR cp2cr[ 32 ];
87176   PAIR cp2dr[ 32 ];
177   UINT32 icacheTag[ ICACHE_ENTRIES / 4 ];
178   UINT32 icache[ ICACHE_ENTRIES ];
179   UINT32 dcache[ DCACHE_ENTRIES ];
180   int multiplier_operation;
181   UINT32 multiplier_operand1;
182   UINT32 multiplier_operand2;
88183   int (*irq_callback)(int irqline);
184   UINT8 (*readbyte)( UINT32 );
185   UINT16 (*readhalf)( UINT32 );
186   UINT32 (*readword)( UINT32 );
187   UINT32 (*readword_masked)( UINT32, UINT32 );
188   void (*writeword)( UINT32, UINT32 );
189   void (*writeword_masked)( UINT32, UINT32, UINT32 );
190   UINT32 bad_byte_address_mask;
191   UINT32 bad_half_address_mask;
192   UINT32 bad_word_address_mask;
89193} mips_cpu_context;
90194
91195static mips_cpu_context mipscpu;
r2375r2376
94198
95199static const UINT32 mips_mtc0_writemask[]=
96200{
97   0xffffffff, /* INDEX */
98   0x00000000, /* RANDOM */
99   0xffffff00, /* ENTRYLO */
100   0x00000000,
101   0xffe00000, /* CONTEXT */
102   0x00000000,
103   0x00000000,
104   0x00000000,
105   0x00000000, /* BADVADDR */
106   0x00000000,
107   0xffffffc0, /* ENTRYHI */
108   0x00000000,
109   0xf27fff3f, /* SR */
201   0x00000000, /* !INDEX */
202   0x00000000, /* !RANDOM */
203   0x00000000, /* !ENTRYLO */
204   0xffffffff, /* BPC */
205   0x00000000, /* !CONTEXT */
206   0xffffffff, /* BDA */
207   0x00000000, /* TAR */
208   0xff80f03f, /* DCIC */
209   0x00000000, /* BADA */
210   0xffffffff, /* BDAM */
211   0x00000000, /* !ENTRYHI */
212   0xffffffff, /* BPCM */
213   0xf04fff3f, /* SR */
110214   0x00000300, /* CAUSE */
111215   0x00000000, /* EPC */
112   0x00000000, /* PRID */
113   0x00000000,
114   0x00000000,
115   0x00000000,
116   0x00000000,
117   0x00000000,
118   0x00000000,
119   0x00000000,
120   0x00000000,
121   0x00000000,
122   0x00000000,
123   0x00000000,
124   0x00000000,
125   0x00000000,
126   0x00000000,
127   0x00000000,
128   0x00000000
216   0x00000000  /* PRID */
129217};
130218
131219#if 0
r2375r2376
142230INLINE void ATTR_PRINTF(1,2) GTELOG(const char *a, ...) {}
143231#endif
144232
145static UINT32 getcp2dr( int n_reg );
146static void setcp2dr( int n_reg, UINT32 n_value );
147static UINT32 getcp2cr( int n_reg );
148static void setcp2cr( int n_reg, UINT32 n_value );
149static void docop2( int gteop );
233static UINT32 getcp1dr( int reg );
234static void setcp1dr( int reg, UINT32 value );
235static UINT32 getcp1cr( int reg );
236static void setcp1cr( int reg, UINT32 value );
237//static void docop1( int op );
238
239
240static UINT32 getcp2dr( int reg );
241static void setcp2dr( int reg, UINT32 value );
242static UINT32 getcp2cr( int reg );
243static void setcp2cr( int reg, UINT32 value );
244static void docop2( int op );
245
246
247static UINT32 getcp3dr( int reg );
248static void setcp3dr( int reg, UINT32 value );
249static UINT32 getcp3cr( int reg );
250static void setcp3cr( int reg, UINT32 value );
251//static void docop3( int op );
252
253
150254static void mips_exception( int exception );
255static void mips_load_bad_address( UINT32 address );
151256
152257static void mips_stop( void )
153258{
154259   DEBUGGER_BREAK;
155   CALL_DEBUGGER(mipscpu.pc);
260   CALL_DEBUGGER( mipscpu.pc );
156261}
157262
158263#if LOG_BIOSCALL
r2375r2376
481586   }
482587   else
483588   {
484      return program_read_dword_32le( activecpu_get_reg( MIPS_R29 ) + ( parm * 4 ) );
589      return mipscpu.readword( activecpu_get_reg( MIPS_R29 ) + ( parm * 4 ) );
485590   }
486591}
487592
r2375r2376
502607
503608   for( ;; )
504609   {
505      UINT8 c = program_read_byte_32le( address );
610      UINT8 c = mipscpu.readbyte( address );
506611      if( c == 0 )
507612      {
508613         break;
r2375r2376
592697         int fd = log_bioscall_parameter( 0 );
593698         int buf = log_bioscall_parameter( 1 );
594699         int nbytes = log_bioscall_parameter( 2 );
700
595701         if( fd == 1 )
596702         {
597703            while( nbytes > 0 )
598704            {
599               UINT8 c = program_read_byte_32le( buf );
705               UINT8 c = mipscpu.readbyte( buf );
600706               putchar( c );
601707               nbytes--;
602708               buf++;
r2375r2376
623729         while( *( prototype ) != 0 )
624730         {
625731            int ch = *( prototype );
732
626733            switch( ch )
627734            {
628735            case '(':
r2375r2376
634741                  parmstart = prototype;
635742               }
636743               break;
744
637745            case ')':
638746               if( brackets == 1 )
639747               {
r2375r2376
642750               prototype++;
643751               brackets--;
644752               break;
753
645754            case ',':
646755               if( brackets == 1 )
647756               {
r2375r2376
649758               }
650759               prototype++;
651760               break;
761
652762            default:
653763               if( brackets == 0 )
654764               {
r2375r2376
682792                     UINT32 format = log_bioscall_parameter( parm - 1 );
683793                     const char *parmstr = NULL;
684794                     int percent = 0;
795
685796                     for( ;; )
686797                     {
687                        UINT8 c = program_read_byte_32le( format );
798                        UINT8 c = mipscpu.readbyte( format );
688799                        if( c == 0 )
689800                        {
690801                           break;
r2375r2376
805916{
806917   char buf[ 1024 ];
807918   int operation = activecpu_get_reg( MIPS_R4 );
919
808920   switch( operation )
809921   {
810922   case 0:
811923      strcpy( buf, "void Exception()" );
812924      break;
925
813926   case 1:
814927      strcpy( buf, "void EnterCriticalSection()" );
815928      break;
929
816930   case 2:
817931      strcpy( buf, "void ExitCriticalSection()" );
818932      break;
933
819934   default:
820935      sprintf( buf, "unknown_%02x", operation );
821936      break;
r2375r2376
825940
826941#endif
827942
943static UINT32 mips_cache_readword( UINT32 offset )
944{
945   UINT32 data = 0;
946
947   if( ( mipscpu.biu & BIU_TAG ) != 0 )
948   {
949      if( ( mipscpu.biu & BIU_IS1 ) != 0 )
950      {
951         UINT32 tag = mipscpu.icacheTag[ ( offset / 16 ) % ( ICACHE_ENTRIES / 4 ) ];
952         data |= tag & TAG_VALID;
953
954         if( ( ( tag ^ offset ) & TAG_MATCH_MASK ) == 0 )
955         {
956            data |= TAG_MATCH;
957         }
958      }
959   }
960   else if( ( mipscpu.biu & ( BIU_LOCK | BIU_INV ) ) != 0 )
961   {
962   }
963   else
964   {
965      if( ( mipscpu.biu & BIU_IS1 ) == BIU_IS1 )
966      {
967         data |= mipscpu.icache[ ( offset / 4 ) % ICACHE_ENTRIES ];
968      }
969
970      if( ( mipscpu.biu & BIU_DS ) == BIU_DS )
971      {
972         data |= mipscpu.dcache[ ( offset / 4 ) % DCACHE_ENTRIES ];
973      }
974   }
975
976   return data;
977}
978
979static UINT8 mips_cache_readbyte( UINT32 offset )
980{
981   return mips_cache_readword( offset ) >> ( ( offset & 3 ) * 8 );
982}
983
984static UINT16 mips_cache_readhalf( UINT32 offset )
985{
986   return mips_cache_readword( offset ) >> ( ( offset & 2 ) * 8 );
987}
988
989static UINT32 mips_cache_readword_masked( UINT32 offset, UINT32 mask )
990{
991   return mips_cache_readword( offset );
992}
993
994static void mips_cache_writeword( UINT32 offset, UINT32 data )
995{
996   if( ( mipscpu.biu & BIU_TAG ) != 0 )
997   {
998      if( ( mipscpu.biu & BIU_IS1 ) != 0 )
999      {
1000         mipscpu.icacheTag[ ( offset / 16 ) % ( ICACHE_ENTRIES / 4 ) ] = ( data & TAG_VALID ) | ( offset & TAG_MATCH_MASK );
1001      }
1002   }
1003   else if( ( mipscpu.biu & ( BIU_LOCK | BIU_INV ) ) != 0 )
1004   {
1005      if( ( mipscpu.biu & BIU_IS1 ) != 0 )
1006      {
1007         mipscpu.icacheTag[ ( offset / 16 ) % ( ICACHE_ENTRIES / 4 ) ] = ( offset & TAG_MATCH_MASK );
1008      }
1009   }
1010   else
1011   {
1012      if( ( mipscpu.biu & BIU_IS1 ) != 0 )
1013      {
1014         mipscpu.icache[ ( offset / 4 ) % ICACHE_ENTRIES ] = data;
1015      }
1016
1017      if( ( mipscpu.biu & BIU_DS ) != 0 )
1018      {
1019         mipscpu.dcache[ ( offset / 4 ) % DCACHE_ENTRIES ] = data;
1020      }
1021   }
1022}
1023
1024static void mips_cache_writeword_masked( UINT32 offset, UINT32 data, UINT32 mask )
1025{
1026   mips_cache_writeword( offset, data );
1027}
1028
1029static void mips_update_memory_handlers( void )
1030{
1031   if( ( mipscpu.cp0r[ CP0_SR ] & SR_ISC ) != 0 )
1032   {
1033      mipscpu.readbyte = mips_cache_readbyte;
1034      mipscpu.readhalf = mips_cache_readhalf;
1035      mipscpu.readword = mips_cache_readword;
1036      mipscpu.readword_masked = mips_cache_readword_masked;
1037      mipscpu.writeword = mips_cache_writeword;
1038      mipscpu.writeword_masked = mips_cache_writeword_masked;
1039   }
1040   else
1041   {
1042      mipscpu.readbyte = program_read_byte_32le;
1043      mipscpu.readhalf = program_read_word_32le;
1044      mipscpu.readword = program_read_dword_32le;
1045      mipscpu.readword_masked = program_read_dword_masked_32le;
1046      mipscpu.writeword = program_write_dword_32le;
1047      mipscpu.writeword_masked = program_write_dword_masked_32le;
1048   }
1049}
1050
1051INLINE void funct_mthi( void )
1052{
1053   mipscpu.multiplier_operation = MULTIPLIER_OPERATION_IDLE;
1054   mipscpu.hi = mipscpu.r[ INS_RS( mipscpu.op ) ];
1055}
1056
1057INLINE void funct_mtlo( void )
1058{
1059   mipscpu.multiplier_operation = MULTIPLIER_OPERATION_IDLE;
1060   mipscpu.lo = mipscpu.r[ INS_RS( mipscpu.op ) ];
1061}
1062
1063INLINE void funct_mult( void )
1064{
1065   mipscpu.multiplier_operation = MULTIPLIER_OPERATION_MULT;
1066   mipscpu.multiplier_operand1 = mipscpu.r[ INS_RS( mipscpu.op ) ];
1067   mipscpu.multiplier_operand2 = mipscpu.r[ INS_RT( mipscpu.op ) ];
1068   mipscpu.lo = mipscpu.multiplier_operand1;
1069}
1070
1071INLINE void funct_multu( void )
1072{
1073   mipscpu.multiplier_operation = MULTIPLIER_OPERATION_MULTU;
1074   mipscpu.multiplier_operand1 = mipscpu.r[ INS_RS( mipscpu.op ) ];
1075   mipscpu.multiplier_operand2 = mipscpu.r[ INS_RT( mipscpu.op ) ];
1076   mipscpu.lo = mipscpu.multiplier_operand1;
1077}
1078
1079INLINE void funct_div( void )
1080{
1081   mipscpu.multiplier_operation = MULTIPLIER_OPERATION_DIV;
1082   mipscpu.multiplier_operand1 = mipscpu.r[ INS_RS( mipscpu.op ) ];
1083   mipscpu.multiplier_operand2 = mipscpu.r[ INS_RT( mipscpu.op ) ];
1084   mipscpu.lo = mipscpu.multiplier_operand1;
1085   mipscpu.hi = 0;
1086}
1087
1088INLINE void funct_divu( void )
1089{
1090   mipscpu.multiplier_operation = MULTIPLIER_OPERATION_DIVU;
1091   mipscpu.multiplier_operand1 = mipscpu.r[ INS_RS( mipscpu.op ) ];
1092   mipscpu.multiplier_operand2 = mipscpu.r[ INS_RT( mipscpu.op ) ];
1093   mipscpu.lo = mipscpu.multiplier_operand1;
1094   mipscpu.hi = 0;
1095}
1096
1097static void multiplier_update( void )
1098{
1099   switch( mipscpu.multiplier_operation )
1100   {
1101   case MULTIPLIER_OPERATION_MULT:
1102      {
1103         INT64 result = MUL_64_32_32( (INT32)mipscpu.multiplier_operand1, (INT32)mipscpu.multiplier_operand2 );
1104         mipscpu.lo = LO32_32_64( result );
1105         mipscpu.hi = HI32_32_64( result );
1106      }
1107      break;
1108
1109   case MULTIPLIER_OPERATION_MULTU:
1110      {
1111         UINT64 result = MUL_U64_U32_U32( mipscpu.multiplier_operand1, mipscpu.multiplier_operand2 );
1112         mipscpu.lo = LO32_U32_U64( result );
1113         mipscpu.hi = HI32_U32_U64( result );
1114      }
1115      break;
1116
1117   case MULTIPLIER_OPERATION_DIV:
1118      if( mipscpu.multiplier_operand2 != 0 )
1119      {
1120         mipscpu.lo = (INT32)mipscpu.multiplier_operand1 / (INT32)mipscpu.multiplier_operand2;
1121         mipscpu.hi = (INT32)mipscpu.multiplier_operand1 % (INT32)mipscpu.multiplier_operand2;
1122      }
1123      else
1124      {
1125         if( (INT32)mipscpu.multiplier_operand1 < 0 )
1126         {
1127            mipscpu.lo = 1;
1128         }
1129         else
1130         {
1131            mipscpu.lo = 0xffffffff;
1132         }
1133
1134         mipscpu.hi = mipscpu.multiplier_operand1;
1135      }
1136      break;
1137
1138   case MULTIPLIER_OPERATION_DIVU:
1139      if( mipscpu.multiplier_operand2 != 0 )
1140      {
1141         mipscpu.lo = mipscpu.multiplier_operand1 / mipscpu.multiplier_operand2;
1142         mipscpu.hi = mipscpu.multiplier_operand1 % mipscpu.multiplier_operand2;
1143      }
1144      else
1145      {
1146         mipscpu.lo = 0xffffffff;
1147         mipscpu.hi = mipscpu.multiplier_operand1;
1148      }
1149      break;
1150   }
1151
1152   mipscpu.multiplier_operation = MULTIPLIER_OPERATION_IDLE;
1153}
1154
1155static UINT32 mips_get_hi( void )
1156{
1157   if( mipscpu.multiplier_operation != MULTIPLIER_OPERATION_IDLE )
1158   {
1159      multiplier_update();
1160   }
1161
1162   return mipscpu.hi;
1163}
1164
1165static UINT32 mips_get_lo( void )
1166{
1167   if( mipscpu.multiplier_operation != MULTIPLIER_OPERATION_IDLE )
1168   {
1169      multiplier_update();
1170   }
1171   return mipscpu.lo;
1172}
1173
1174static int mips_execute_unstoppable_instructions( int executeCop2 )
1175{
1176   switch( INS_OP( mipscpu.op ) )
1177   {
1178   case OP_SPECIAL:
1179      switch( INS_FUNCT( mipscpu.op ) )
1180      {
1181      case FUNCT_MTHI:
1182         funct_mthi();
1183         break;
1184
1185      case FUNCT_MTLO:
1186         funct_mtlo();
1187         break;
1188
1189      case FUNCT_MULT:
1190         funct_mult();
1191         break;
1192
1193      case FUNCT_MULTU:
1194         funct_multu();
1195         break;
1196
1197      case FUNCT_DIV:
1198         funct_div();
1199         break;
1200
1201      case FUNCT_DIVU:
1202         funct_divu();
1203         break;
1204      }
1205      break;
1206
1207   case OP_COP2:
1208      if( executeCop2 )
1209      {
1210         switch( INS_CO( mipscpu.op ) )
1211         {
1212         case 1:
1213            if( ( mipscpu.cp0r[ CP0_SR ] & SR_CU2 ) == 0 )
1214            {
1215               return 0;
1216            }
1217
1218            docop2( INS_COFUN( mipscpu.op ) );
1219            break;
1220         }
1221      }
1222   }
1223
1224   return 1;
1225}
1226
1227static void mips_update_address_masks( void )
1228{
1229   if( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) != 0 )
1230   {
1231      mipscpu.bad_byte_address_mask = 0x80000000;
1232      mipscpu.bad_half_address_mask = 0x80000001;
1233      mipscpu.bad_word_address_mask = 0x80000003;
1234   }
1235   else
1236   {
1237      mipscpu.bad_byte_address_mask = 0;
1238      mipscpu.bad_half_address_mask = 1;
1239      mipscpu.bad_word_address_mask = 3;
1240   }
1241}
1242
1243static READ32_HANDLER( psx_berr_r )
1244{
1245   mipscpu.berr = 1;
1246
1247   return 0;
1248}
1249
1250static WRITE32_HANDLER( psx_berr_w )
1251{
1252   mipscpu.berr = 1;
1253}
1254
1255static void mips_update_scratchpad( void )
1256{
1257   int cpu = cpu_getactivecpu();
1258
1259   if( ( mipscpu.biu & BIU_RAM ) == 0 )
1260   {
1261      memory_install_read32_handler ( cpu, ADDRESS_SPACE_PROGRAM, 0x1f800000, 0x1f8003ff, 0, 0, psx_berr_r );
1262      memory_install_write32_handler( cpu, ADDRESS_SPACE_PROGRAM, 0x1f800000, 0x1f8003ff, 0, 0, psx_berr_w );
1263   }
1264   else if( ( mipscpu.biu & BIU_DS ) == 0 )
1265   {
1266      memory_install_read32_handler ( cpu, ADDRESS_SPACE_PROGRAM, 0x1f800000, 0x1f8003ff, 0, 0, psx_berr_r );
1267      memory_install_write32_handler( cpu, ADDRESS_SPACE_PROGRAM, 0x1f800000, 0x1f8003ff, 0, 0, SMH_NOP );
1268   }
1269   else
1270   {
1271      memory_install_read32_handler ( cpu, ADDRESS_SPACE_PROGRAM, 0x1f800000, 0x1f8003ff, 0, 0, SMH_BANK32 );
1272      memory_install_write32_handler( cpu, ADDRESS_SPACE_PROGRAM, 0x1f800000, 0x1f8003ff, 0, 0, SMH_BANK32 );
1273
1274      memory_set_bankptr( 32, mipscpu.dcache );
1275   }
1276}
1277
8281278INLINE void mips_set_cp0r( int reg, UINT32 value )
8291279{
1280   UINT32 old = mipscpu.cp0r[ reg ];
1281
8301282   mipscpu.cp0r[ reg ] = value;
831   if( reg == CP0_SR || reg == CP0_CAUSE )
1283
1284   if( reg == CP0_SR )
8321285   {
833      if( ( mipscpu.cp0r[ CP0_SR ] & SR_IEC ) != 0 && ( mipscpu.cp0r[ CP0_SR ] & mipscpu.cp0r[ CP0_CAUSE ] & CAUSE_IP ) != 0 )
1286      if( ( old & SR_ISC ) != ( value & SR_ISC ) )
8341287      {
835         mips_exception( EXC_INT );
1288         mips_update_memory_handlers();
8361289      }
837      else if( mipscpu.delayr != REGPC && ( mipscpu.pc & ( ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) | 3 ) ) != 0 )
1290
1291      if( ( old & SR_KUC ) != ( value & SR_KUC ) )
8381292      {
839         mips_exception( EXC_ADEL );
840         mips_set_cp0r( CP0_BADVADDR, mipscpu.pc );
1293         mips_update_address_masks();
8411294      }
8421295   }
1296
1297   if( ( reg == CP0_SR || reg == CP0_CAUSE ) &&
1298      ( mipscpu.cp0r[ CP0_SR ] & SR_IEC ) != 0 &&
1299      ( mipscpu.cp0r[ CP0_SR ] & mipscpu.cp0r[ CP0_CAUSE ] & CAUSE_IP ) != 0 )
1300   {
1301      mipscpu.op = cpu_readop32( mipscpu.pc );
1302      mips_execute_unstoppable_instructions( 1 );
1303      mips_exception( EXC_INT );
1304   }
1305   else if( reg == CP0_SR &&
1306      mipscpu.delayr != MIPS_DELAYR_PC &&
1307      ( mipscpu.pc & mipscpu.bad_word_address_mask ) != 0 )
1308   {
1309      mips_load_bad_address( mipscpu.pc );
1310   }
8431311}
8441312
8451313INLINE void mips_commit_delayed_load( void )
r2375r2376
8521320   }
8531321}
8541322
855INLINE void mips_delayed_branch( UINT32 n_adr )
1323static void mips_set_pc( unsigned val )
8561324{
857   if( ( n_adr & ( ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) | 3 ) ) != 0 )
1325   mipscpu.pc = val;
1326   change_pc( val );
1327}
1328
1329static void mips_fetch_next_op( void )
1330{
1331   if( mipscpu.delayr == MIPS_DELAYR_PC )
8581332   {
859      mips_exception( EXC_ADEL );
860      mips_set_cp0r( CP0_BADVADDR, n_adr );
1333      UINT32 safepc = mipscpu.delayv & ~mipscpu.bad_word_address_mask;
1334
1335      change_pc( safepc );
1336      mipscpu.op = cpu_readop32( safepc );
1337      change_pc( mipscpu.pc );
8611338   }
862   else if( mipscpu.delayr == REGPC )
1339   else
8631340   {
1341      mipscpu.op = cpu_readop32( mipscpu.pc + 4 );
1342   }
1343}
1344
1345INLINE int mips_advance_pc( void )
1346{
1347   if( mipscpu.delayr == MIPS_DELAYR_PC )
1348   {
8641349      mipscpu.pc = mipscpu.delayv;
865      change_pc( mipscpu.delayv );
866      mipscpu.delayv = n_adr;
1350      mipscpu.delayr = 0;
1351      mipscpu.delayv = 0;
1352
1353      if( ( mipscpu.pc & mipscpu.bad_word_address_mask ) != 0 )
1354      {
1355         mips_load_bad_address( mipscpu.pc );
1356         return 0;
1357      }
1358      else
1359      {
1360         change_pc( mipscpu.pc );
1361      }
8671362   }
1363   else if( mipscpu.delayr == MIPS_DELAYR_NOTPC )
1364   {
1365      mipscpu.delayr = 0;
1366      mipscpu.delayv = 0;
1367      mipscpu.pc += 4;
1368   }
8681369   else
8691370   {
8701371      mips_commit_delayed_load();
871      mipscpu.delayr = REGPC;
872      mipscpu.delayv = n_adr;
8731372      mipscpu.pc += 4;
8741373   }
1374
1375   return 1;
8751376}
8761377
877INLINE void mips_set_pc( unsigned val )
1378INLINE void mips_load( UINT32 reg, UINT32 value )
8781379{
879   mipscpu.pc = val;
1380   mips_advance_pc();
8801381
881   change_pc( val );
882   mipscpu.delayr = 0;
883   mipscpu.delayv = 0;
1382   if( reg != 0 )
1383   {
1384      mipscpu.r[ reg ] = value;
1385   }
8841386}
8851387
886INLINE void mips_advance_pc( void )
1388INLINE void mips_delayed_load( UINT32 reg, UINT32 value )
8871389{
888   if( mipscpu.delayr == REGPC )
1390   mips_advance_pc();
1391
1392   mipscpu.delayr = reg;
1393   mipscpu.delayv = value;
1394}
1395
1396INLINE void mips_branch( UINT32 address )
1397{
1398   mips_advance_pc();
1399
1400   mipscpu.delayr = MIPS_DELAYR_PC;
1401   mipscpu.delayv = address;
1402}
1403
1404INLINE void mips_conditional_branch( int takeBranch )
1405{
1406   mips_advance_pc();
1407
1408   if( takeBranch )
8891409   {
890      mips_set_pc( mipscpu.delayv );
1410      mipscpu.delayr = MIPS_DELAYR_PC;
1411      mipscpu.delayv = mipscpu.pc + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) ) << 2 );
8911412   }
8921413   else
8931414   {
894      mips_commit_delayed_load();
895      mipscpu.pc += 4;
1415      mipscpu.delayr = MIPS_DELAYR_NOTPC;
1416      mipscpu.delayv = 0;
8961417   }
8971418}
8981419
899INLINE void mips_load( UINT32 n_r, UINT32 n_v )
1420INLINE void mips_unconditional_branch( void )
9001421{
9011422   mips_advance_pc();
902   if( n_r != 0 )
903   {
904      mipscpu.r[ n_r ] = n_v;
905   }
1423
1424   mipscpu.delayr = MIPS_DELAYR_PC;
1425   mipscpu.delayv = ( mipscpu.pc & 0xf0000000 ) + ( INS_TARGET( mipscpu.op ) << 2 );
9061426}
9071427
908INLINE void mips_delayed_load( UINT32 n_r, UINT32 n_v )
1428static void mips_common_exception( int exception, UINT32 romOffset, UINT32 ramOffset )
9091429{
910   if( mipscpu.delayr == REGPC )
1430   int cause = ( exception << 2 ) | ( ( ( mipscpu.op >> 26 ) & 3 ) << 28 );
1431
1432   if( mipscpu.delayr == MIPS_DELAYR_PC )
9111433   {
912      mips_set_pc( mipscpu.delayv );
913      mipscpu.delayr = n_r;
914      mipscpu.delayv = n_v;
1434      cause |= CAUSE_BT;
1435      mips_set_cp0r( CP0_TAR, mipscpu.delayv );
9151436   }
1437   else if( mipscpu.delayr == MIPS_DELAYR_NOTPC )
1438   {
1439      mips_set_cp0r( CP0_TAR, mipscpu.pc + 4 );
1440   }
9161441   else
9171442   {
9181443      mips_commit_delayed_load();
919      mipscpu.pc += 4;
920      if( n_r != 0 )
921      {
922         mipscpu.r[ n_r ] = n_v;
923      }
9241444   }
925}
9261445
927static void mips_exception( int exception )
928{
929   mips_set_cp0r( CP0_SR, ( mipscpu.cp0r[ CP0_SR ] & ~0x3f ) | ( ( mipscpu.cp0r[ CP0_SR ] << 2 ) & 0x3f ) );
930   if( mipscpu.delayr == REGPC )
1446   if( mipscpu.delayr == MIPS_DELAYR_PC || mipscpu.delayr == MIPS_DELAYR_NOTPC )
9311447   {
1448      cause |= CAUSE_BD;
9321449      mips_set_cp0r( CP0_EPC, mipscpu.pc - 4 );
933      mips_set_cp0r( CP0_CAUSE, ( mipscpu.cp0r[ CP0_CAUSE ] & ~CAUSE_EXC ) | CAUSE_BD | ( exception << 2 ) );
9341450   }
9351451   else
9361452   {
937      mips_commit_delayed_load();
9381453      mips_set_cp0r( CP0_EPC, mipscpu.pc );
939      mips_set_cp0r( CP0_CAUSE, ( mipscpu.cp0r[ CP0_CAUSE ] & ~( CAUSE_EXC | CAUSE_BD ) ) | ( exception << 2 ) );
9401454   }
1455
1456#if LOG_BIOSCALL
1457   if( exception != EXC_INT )
1458   {
1459      logerror( "%08x: Exception %d\n", mipscpu.pc, exception );
1460   }
1461#endif
1462
1463   mipscpu.delayr = 0;
1464   mipscpu.delayv = 0;
1465   mipscpu.berr = 0;
1466
9411467   if( mipscpu.cp0r[ CP0_SR ] & SR_BEV )
9421468   {
943      mips_set_pc( 0xbfc00180 );
1469      mips_set_pc( romOffset );
9441470   }
9451471   else
9461472   {
947      mips_set_pc( 0x80000080 );
1473      mips_set_pc( ramOffset );
9481474   }
1475
1476   mips_set_cp0r( CP0_SR, ( mipscpu.cp0r[ CP0_SR ] & ~0x3f ) | ( ( mipscpu.cp0r[ CP0_SR ] << 2 ) & 0x3f ) );
1477   mips_set_cp0r( CP0_CAUSE, ( mipscpu.cp0r[ CP0_CAUSE ] & ~( CAUSE_EXC | CAUSE_BD | CAUSE_BT | CAUSE_CE ) ) | cause );
9491478}
9501479
1480static void mips_exception( int exception )
1481{
1482   mips_common_exception( exception, 0xbfc00180, 0x80000080 );
1483}
1484
1485static void mips_breakpoint_exception( void )
1486{
1487   mips_fetch_next_op();
1488   mips_execute_unstoppable_instructions( 1 );
1489   mips_common_exception( EXC_BP, 0xbfc00140, 0x80000040 );
1490}
1491
1492static void mips_load_bus_error_exception( void )
1493{
1494   mips_fetch_next_op();
1495   mips_execute_unstoppable_instructions( 0 );
1496   mips_common_exception( EXC_DBE, 0xbfc00180, 0x80000080 );
1497}
1498
1499static void mips_store_bus_error_exception( void )
1500{
1501   mips_fetch_next_op();
1502
1503   if( mips_execute_unstoppable_instructions( 1 ) )
1504   {
1505      if( !mips_advance_pc() )
1506      {
1507         return;
1508      }
1509
1510      mips_fetch_next_op();
1511      mips_execute_unstoppable_instructions( 0 );
1512   }
1513
1514   mips_common_exception( EXC_DBE, 0xbfc00180, 0x80000080 );
1515}
1516
1517static void mips_load_bad_address( UINT32 address )
1518{
1519   mips_set_cp0r( CP0_BADA, address );
1520   mips_exception( EXC_ADEL );
1521}
1522
1523static void mips_store_bad_address( UINT32 address )
1524{
1525   mips_set_cp0r( CP0_BADA, address );
1526   mips_exception( EXC_ADES );
1527}
1528
1529INLINE int mips_data_address_breakpoint( int dcic_rw, int dcic_status, UINT32 address )
1530{
1531   if( address < 0x1f000000 || address > 0x1fffffff )
1532   {
1533      if( ( mipscpu.cp0r[ CP0_DCIC ] & DCIC_DE ) != 0 &&
1534         ( ( ( mipscpu.cp0r[ CP0_DCIC ] & DCIC_KD ) != 0 && ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) == 0 ) ||
1535         ( ( mipscpu.cp0r[ CP0_DCIC ] & DCIC_UD ) != 0 && ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) != 0 ) ) )
1536      {
1537         if( ( mipscpu.cp0r[ CP0_DCIC ] & dcic_rw ) == dcic_rw &&
1538            ( address & mipscpu.cp0r[ CP0_BDAM ] ) == ( mipscpu.cp0r[ CP0_BDA ] & mipscpu.cp0r[ CP0_BDAM ] ) )
1539         {
1540            mipscpu.cp0r[ CP0_DCIC ] = ( mipscpu.cp0r[ CP0_DCIC ] & ~DCIC_STATUS ) | dcic_status;
1541
1542            if( ( mipscpu.cp0r[ CP0_DCIC ] & DCIC_TR ) != 0 )
1543            {
1544               return 1;
1545            }
1546         }
1547      }
1548   }
1549
1550   return 0;
1551}
1552
1553INLINE int mips_load_data_address_breakpoint( UINT32 address )
1554{
1555   return mips_data_address_breakpoint( DCIC_DR | DCIC_DAE, DCIC_DB | DCIC_DA | DCIC_R, address );
1556}
1557
1558INLINE int mips_store_data_address_breakpoint( UINT32 address )
1559{
1560   return mips_data_address_breakpoint( DCIC_DW | DCIC_DAE, DCIC_DB | DCIC_DA | DCIC_W, address );
1561}
1562
1563static STATE_POSTLOAD( mips_postload )
1564{
1565   mips_update_memory_handlers();
1566   mips_update_address_masks();
1567   mips_update_scratchpad();
1568}
1569
1570static void mips_state_register( const char *type, int index )
1571{
1572   state_save_register_item( type, index, mipscpu.op );
1573   state_save_register_item( type, index, mipscpu.pc );
1574   state_save_register_item( type, index, mipscpu.delayv );
1575   state_save_register_item( type, index, mipscpu.delayr );
1576   state_save_register_item( type, index, mipscpu.hi );
1577   state_save_register_item( type, index, mipscpu.lo );
1578   state_save_register_item( type, index, mipscpu.biu );
1579   state_save_register_item_array( type, index, mipscpu.r );
1580   state_save_register_item_array( type, index, mipscpu.cp0r );
1581   state_save_register_item_array( type, index, mipscpu.cp2cr );
1582   state_save_register_item_array( type, index, mipscpu.cp2dr );
1583   state_save_register_item_array( type, index, mipscpu.icacheTag );
1584   state_save_register_item_array( type, index, mipscpu.icache );
1585   state_save_register_item_array( type, index, mipscpu.dcache );
1586   state_save_register_item( type, index, mipscpu.multiplier_operation );
1587   state_save_register_item( type, index, mipscpu.multiplier_operand1 );
1588   state_save_register_item( type, index, mipscpu.multiplier_operand2 );
1589   state_save_register_postload( Machine, mips_postload, NULL );
1590}
1591
9511592static void mips_init( int index, int clock, const void *config, int (*irqcallback)(int) )
9521593{
9531594   mipscpu.irq_callback = irqcallback;
9541595
955   state_save_register_item( "psxcpu", index, mipscpu.op );
956   state_save_register_item( "psxcpu", index, mipscpu.pc );
957   state_save_register_item( "psxcpu", index, mipscpu.delayv );
958   state_save_register_item( "psxcpu", index, mipscpu.delayr );
959   state_save_register_item( "psxcpu", index, mipscpu.hi );
960   state_save_register_item( "psxcpu", index, mipscpu.lo );
961   state_save_register_item_array( "psxcpu", index, mipscpu.r );
962   state_save_register_item_array( "psxcpu", index, mipscpu.cp0r );
963   state_save_register_item_array( "psxcpu", index, mipscpu.cp2cr );
964   state_save_register_item_array( "psxcpu", index, mipscpu.cp2dr );
1596   mips_state_register( "psxcpu", index );
9651597}
9661598
9671599static void mips_reset( void )
9681600{
969   mips_set_cp0r( CP0_SR, ( mipscpu.cp0r[ CP0_SR ] & ~( SR_TS | SR_SWC | SR_KUC | SR_IEC ) ) | SR_BEV );
970   mips_set_cp0r( CP0_RANDOM, 63 ); /* todo: */
971   mips_set_cp0r( CP0_PRID, 0x00000200 ); /* todo: */
1601   mipscpu.delayr = 0;
1602   mipscpu.delayv = 0;
1603
1604   mipscpu.multiplier_operation = MULTIPLIER_OPERATION_IDLE;
1605
1606   mips_update_memory_handlers();
1607   mips_update_address_masks();
1608   mips_update_scratchpad();
1609
1610   mips_set_cp0r( CP0_SR, SR_BEV );
1611   mips_set_cp0r( CP0_CAUSE, 0x00000000 );
1612   mips_set_cp0r( CP0_PRID, 0x00000002 );
1613   mips_set_cp0r( CP0_DCIC, 0x00000000 );
1614   mips_set_cp0r( CP0_BPCM, 0xffffffff );
1615   mips_set_cp0r( CP0_BDAM, 0xffffffff );
9721616   mips_set_pc( 0xbfc00000 );
9731617}
9741618
r2375r2376
9761620{
9771621}
9781622
1623static UINT32 mips_get_register_from_pipeline( int reg )
1624{
1625   if( mipscpu.delayr == reg )
1626   {
1627      UINT32 data = mipscpu.delayv;
1628
1629      mipscpu.delayr = 0;
1630      mipscpu.delayv = 0;
1631
1632      return data;
1633   }
1634
1635   return mipscpu.r[ reg ];
1636}
1637
1638static int mips_cop0_usable( void )
1639{
1640   if( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) != 0 && ( mipscpu.cp0r[ CP0_SR ] & SR_CU0 ) == 0 )
1641   {
1642      mips_exception( EXC_CPU );
1643
1644      return 0;
1645   }
1646
1647   return 1;
1648}
1649
1650static void mips_lwc( int cop, int sr_cu )
1651{
1652   UINT32 address = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1653   int breakpoint = mips_load_data_address_breakpoint( address );
1654
1655   if( ( mipscpu.cp0r[ CP0_SR ] & sr_cu ) == 0 )
1656   {
1657      mips_exception( EXC_CPU );
1658   }
1659   else if( ( address & mipscpu.bad_word_address_mask ) != 0 )
1660   {
1661      mips_load_bad_address( address );
1662   }
1663   else if( breakpoint )
1664   {
1665      mips_breakpoint_exception();
1666   }
1667   else
1668   {
1669      UINT32 data = mipscpu.readword( address );
1670
1671      if( mipscpu.berr )
1672      {
1673         mips_load_bus_error_exception();
1674      }
1675      else
1676      {
1677         int reg = INS_RT( mipscpu.op );
1678
1679         mips_advance_pc();
1680
1681         switch( cop )
1682         {
1683         case 0:
1684            /* lwc0 doesn't update any cop0 registers */
1685            break;
1686
1687         case 1:
1688            setcp1dr( reg, data );
1689            break;
1690
1691         case 2:
1692            setcp2dr( reg, data );
1693            break;
1694
1695         case 3:
1696            setcp3dr( reg, data );
1697            break;
1698         }
1699      }
1700   }
1701}
1702
1703static void mips_swc( int cop, int sr_cu )
1704{
1705   UINT32 address = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1706   int breakpoint = mips_store_data_address_breakpoint( address );
1707
1708   if( ( mipscpu.cp0r[ CP0_SR ] & sr_cu ) == 0 )
1709   {
1710      mips_exception( EXC_CPU );
1711   }
1712   else if( ( address & mipscpu.bad_word_address_mask ) != 0 )
1713   {
1714      mips_store_bad_address( address );
1715   }
1716   else
1717   {
1718      UINT32 data = 0;
1719
1720      switch( cop )
1721      {
1722      case 0:
1723         {
1724            int address;
1725
1726            if( mipscpu.delayr == MIPS_DELAYR_PC )
1727            {
1728               switch( mipscpu.delayv & 0x0c )
1729               {
1730               case 0x0c:
1731                  address = mipscpu.delayv;
1732                  break;
1733
1734               default:
1735                  address = mipscpu.delayv + 4;
1736                  break;
1737               }
1738            }
1739            else
1740            {
1741               switch( mipscpu.pc & 0x0c )
1742               {
1743               case 0x0:
1744               case 0xc:
1745                  address = mipscpu.pc + 0x08;
1746                  break;
1747
1748               default:
1749                  address = mipscpu.pc | 0x0c;
1750                  break;
1751               }
1752            }
1753
1754            data = program_read_dword_32le( address );
1755         }
1756         break;
1757
1758      case 1:
1759         data = getcp1dr( INS_RT( mipscpu.op ) );
1760         break;
1761
1762      case 2:
1763         data = getcp2dr( INS_RT( mipscpu.op ) );
1764         break;
1765
1766      case 3:
1767         data = getcp3dr( INS_RT( mipscpu.op ) );
1768         break;
1769      }
1770
1771      mipscpu.writeword( address, data );
1772
1773      if( breakpoint )
1774      {
1775         mips_breakpoint_exception();
1776      }
1777      else if( mipscpu.berr )
1778      {
1779         mips_store_bus_error_exception();
1780      }
1781      else
1782      {
1783         mips_advance_pc();
1784      }
1785   }
1786}
1787
1788static void mips_bc( int cop, int sr_cu, int condition )
1789{
1790   if( ( mipscpu.cp0r[ CP0_SR ] & sr_cu ) == 0 )
1791   {
1792      mips_exception( EXC_CPU );
1793   }
1794   else
1795   {
1796      mips_conditional_branch( !condition );
1797   }
1798}
1799
9791800static int mips_execute( int cycles )
9801801{
981   UINT32 n_res;
982
9831802   mips_ICount = cycles;
9841803   do
9851804   {
r2375r2376
9871806      log_bioscall();
9881807#endif
9891808
990      CALL_DEBUGGER(mipscpu.pc);
1809      CALL_DEBUGGER( mipscpu.pc );
9911810
9921811      mipscpu.op = cpu_readop32( mipscpu.pc );
9931812      switch( INS_OP( mipscpu.op ) )
r2375r2376
9981817         case FUNCT_SLL:
9991818            mips_load( INS_RD( mipscpu.op ), mipscpu.r[ INS_RT( mipscpu.op ) ] << INS_SHAMT( mipscpu.op ) );
10001819            break;
1820
10011821         case FUNCT_SRL:
10021822            mips_load( INS_RD( mipscpu.op ), mipscpu.r[ INS_RT( mipscpu.op ) ] >> INS_SHAMT( mipscpu.op ) );
10031823            break;
1824
10041825         case FUNCT_SRA:
10051826            mips_load( INS_RD( mipscpu.op ), (INT32)mipscpu.r[ INS_RT( mipscpu.op ) ] >> INS_SHAMT( mipscpu.op ) );
10061827            break;
1828
10071829         case FUNCT_SLLV:
10081830            mips_load( INS_RD( mipscpu.op ), mipscpu.r[ INS_RT( mipscpu.op ) ] << ( mipscpu.r[ INS_RS( mipscpu.op ) ] & 31 ) );
10091831            break;
1832
10101833         case FUNCT_SRLV:
10111834            mips_load( INS_RD( mipscpu.op ), mipscpu.r[ INS_RT( mipscpu.op ) ] >> ( mipscpu.r[ INS_RS( mipscpu.op ) ] & 31 ) );
10121835            break;
1836
10131837         case FUNCT_SRAV:
10141838            mips_load( INS_RD( mipscpu.op ), (INT32)mipscpu.r[ INS_RT( mipscpu.op ) ] >> ( mipscpu.r[ INS_RS( mipscpu.op ) ] & 31 ) );
10151839            break;
1840
10161841         case FUNCT_JR:
1017            if( INS_RD( mipscpu.op ) != 0 )
1018            {
1019               mips_exception( EXC_RI );
1020            }
1021            else
1022            {
1023               mips_delayed_branch( mipscpu.r[ INS_RS( mipscpu.op ) ] );
1024            }
1842            mips_branch( mipscpu.r[ INS_RS( mipscpu.op ) ] );
10251843            break;
1844
10261845         case FUNCT_JALR:
1027            n_res = mipscpu.pc + 8;
1028            mips_delayed_branch( mipscpu.r[ INS_RS( mipscpu.op ) ] );
1846            mips_branch( mipscpu.r[ INS_RS( mipscpu.op ) ] );
10291847            if( INS_RD( mipscpu.op ) != 0 )
10301848            {
1031               mipscpu.r[ INS_RD( mipscpu.op ) ] = n_res;
1849               mipscpu.r[ INS_RD( mipscpu.op ) ] = mipscpu.pc + 4;
10321850            }
10331851            break;
1852
10341853         case FUNCT_SYSCALL:
10351854#if LOG_BIOSCALL
10361855            log_syscall();
10371856#endif
10381857            mips_exception( EXC_SYS );
10391858            break;
1859
10401860         case FUNCT_BREAK:
10411861            mips_exception( EXC_BP );
10421862            break;
1863
10431864         case FUNCT_MFHI:
1044            mips_load( INS_RD( mipscpu.op ), mipscpu.hi );
1865            mips_load( INS_RD( mipscpu.op ), mips_get_hi() );
10451866            break;
1867
10461868         case FUNCT_MTHI:
1047            if( INS_RD( mipscpu.op ) != 0 )
1048            {
1049               mips_exception( EXC_RI );
1050            }
1051            else
1052            {
1053               mips_advance_pc();
1054               mipscpu.hi = mipscpu.r[ INS_RS( mipscpu.op ) ];
1055            }
1869            funct_mthi();
1870            mips_advance_pc();
10561871            break;
1872
10571873         case FUNCT_MFLO:
1058            mips_load( INS_RD( mipscpu.op ), mipscpu.lo );
1874            mips_load( INS_RD( mipscpu.op ), mips_get_lo() );
10591875            break;
1876
10601877         case FUNCT_MTLO:
1061            if( INS_RD( mipscpu.op ) != 0 )
1062            {
1063               mips_exception( EXC_RI );
1064            }
1065            else
1066            {
1067               mips_advance_pc();
1068               mipscpu.lo = mipscpu.r[ INS_RS( mipscpu.op ) ];
1069            }
1878            funct_mtlo();
1879            mips_advance_pc();
10701880            break;
1881
10711882         case FUNCT_MULT:
1072            if( INS_RD( mipscpu.op ) != 0 )
1073            {
1074               mips_exception( EXC_RI );
1075            }
1076            else
1077            {
1078               INT64 n_res64;
1079               n_res64 = MUL_64_32_32( (INT32)mipscpu.r[ INS_RS( mipscpu.op ) ], (INT32)mipscpu.r[ INS_RT( mipscpu.op ) ] );
1080               mips_advance_pc();
1081               mipscpu.lo = LO32_32_64( n_res64 );
1082               mipscpu.hi = HI32_32_64( n_res64 );
1083            }
1883            funct_mult();
1884            mips_advance_pc();
10841885            break;
1886
10851887         case FUNCT_MULTU:
1086            if( INS_RD( mipscpu.op ) != 0 )
1087            {
1088               mips_exception( EXC_RI );
1089            }
1090            else
1091            {
1092               UINT64 n_res64;
1093               n_res64 = MUL_U64_U32_U32( mipscpu.r[ INS_RS( mipscpu.op ) ], mipscpu.r[ INS_RT( mipscpu.op ) ] );
1094               mips_advance_pc();
1095               mipscpu.lo = LO32_U32_U64( n_res64 );
1096               mipscpu.hi = HI32_U32_U64( n_res64 );
1097            }
1888            funct_multu();
1889            mips_advance_pc();
10981890            break;
1891
10991892         case FUNCT_DIV:
1100            if( INS_RD( mipscpu.op ) != 0 )
1101            {
1102               mips_exception( EXC_RI );
1103            }
1104            else
1105            {
1106               UINT32 n_div;
1107               UINT32 n_mod;
1108               if( mipscpu.r[ INS_RT( mipscpu.op ) ] != 0 )
1109               {
1110                  n_div = (INT32)mipscpu.r[ INS_RS( mipscpu.op ) ] / (INT32)mipscpu.r[ INS_RT( mipscpu.op ) ];
1111                  n_mod = (INT32)mipscpu.r[ INS_RS( mipscpu.op ) ] % (INT32)mipscpu.r[ INS_RT( mipscpu.op ) ];
1112                  mips_advance_pc();
1113                  mipscpu.lo = n_div;
1114                  mipscpu.hi = n_mod;
1115               }
1116               else
1117               {
1118                  mips_advance_pc();
1119               }
1120            }
1893            funct_div();
1894            mips_advance_pc();
11211895            break;
1896
11221897         case FUNCT_DIVU:
1123            if( INS_RD( mipscpu.op ) != 0 )
1124            {
1125               mips_exception( EXC_RI );
1126            }
1127            else
1128            {
1129               UINT32 n_div;
1130               UINT32 n_mod;
1131               if( mipscpu.r[ INS_RT( mipscpu.op ) ] != 0 )
1132               {
1133                  n_div = mipscpu.r[ INS_RS( mipscpu.op ) ] / mipscpu.r[ INS_RT( mipscpu.op ) ];
1134                  n_mod = mipscpu.r[ INS_RS( mipscpu.op ) ] % mipscpu.r[ INS_RT( mipscpu.op ) ];
1135                  mips_advance_pc();
1136                  mipscpu.lo = n_div;
1137                  mipscpu.hi = n_mod;
1138               }
1139               else
1140               {
1141                  mips_advance_pc();
1142               }
1143            }
1898            funct_divu();
1899            mips_advance_pc();
11441900            break;
1901
11451902         case FUNCT_ADD:
11461903            {
1147               n_res = mipscpu.r[ INS_RS( mipscpu.op ) ] + mipscpu.r[ INS_RT( mipscpu.op ) ];
1148               if( (INT32)( ~( mipscpu.r[ INS_RS( mipscpu.op ) ] ^ mipscpu.r[ INS_RT( mipscpu.op ) ] ) & ( mipscpu.r[ INS_RS( mipscpu.op ) ] ^ n_res ) ) < 0 )
1904               UINT32 result = mipscpu.r[ INS_RS( mipscpu.op ) ] + mipscpu.r[ INS_RT( mipscpu.op ) ];
1905               if( (INT32)( ~( mipscpu.r[ INS_RS( mipscpu.op ) ] ^ mipscpu.r[ INS_RT( mipscpu.op ) ] ) & ( mipscpu.r[ INS_RS( mipscpu.op ) ] ^ result ) ) < 0 )
11491906               {
11501907                  mips_exception( EXC_OVF );
11511908               }
11521909               else
11531910               {
1154                  mips_load( INS_RD( mipscpu.op ), n_res );
1911                  mips_load( INS_RD( mipscpu.op ), result );
11551912               }
11561913            }
11571914            break;
1915
11581916         case FUNCT_ADDU:
11591917            mips_load( INS_RD( mipscpu.op ), mipscpu.r[ INS_RS( mipscpu.op ) ] + mipscpu.r[ INS_RT( mipscpu.op ) ] );
11601918            break;
1919
11611920         case FUNCT_SUB:
1162            n_res = mipscpu.r[ INS_RS( mipscpu.op ) ] - mipscpu.r[ INS_RT( mipscpu.op ) ];
1163            if( (INT32)( ( mipscpu.r[ INS_RS( mipscpu.op ) ] ^ mipscpu.r[ INS_RT( mipscpu.op ) ] ) & ( mipscpu.r[ INS_RS( mipscpu.op ) ] ^ n_res ) ) < 0 )
11641921            {
1165               mips_exception( EXC_OVF );
1922               UINT32 result = mipscpu.r[ INS_RS( mipscpu.op ) ] - mipscpu.r[ INS_RT( mipscpu.op ) ];
1923               if( (INT32)( ( mipscpu.r[ INS_RS( mipscpu.op ) ] ^ mipscpu.r[ INS_RT( mipscpu.op ) ] ) & ( mipscpu.r[ INS_RS( mipscpu.op ) ] ^ result ) ) < 0 )
1924               {
1925                  mips_exception( EXC_OVF );
1926               }
1927               else
1928               {
1929                  mips_load( INS_RD( mipscpu.op ), result );
1930               }
11661931            }
1167            else
1168            {
1169               mips_load( INS_RD( mipscpu.op ), n_res );
1170            }
11711932            break;
1933
11721934         case FUNCT_SUBU:
11731935            mips_load( INS_RD( mipscpu.op ), mipscpu.r[ INS_RS( mipscpu.op ) ] - mipscpu.r[ INS_RT( mipscpu.op ) ] );
11741936            break;
1937
11751938         case FUNCT_AND:
11761939            mips_load( INS_RD( mipscpu.op ), mipscpu.r[ INS_RS( mipscpu.op ) ] & mipscpu.r[ INS_RT( mipscpu.op ) ] );
11771940            break;
1941
11781942         case FUNCT_OR:
11791943            mips_load( INS_RD( mipscpu.op ), mipscpu.r[ INS_RS( mipscpu.op ) ] | mipscpu.r[ INS_RT( mipscpu.op ) ] );
11801944            break;
1945
11811946         case FUNCT_XOR:
11821947            mips_load( INS_RD( mipscpu.op ), mipscpu.r[ INS_RS( mipscpu.op ) ] ^ mipscpu.r[ INS_RT( mipscpu.op ) ] );
11831948            break;
1949
11841950         case FUNCT_NOR:
11851951            mips_load( INS_RD( mipscpu.op ), ~( mipscpu.r[ INS_RS( mipscpu.op ) ] | mipscpu.r[ INS_RT( mipscpu.op ) ] ) );
11861952            break;
1953
11871954         case FUNCT_SLT:
11881955            mips_load( INS_RD( mipscpu.op ), (INT32)mipscpu.r[ INS_RS( mipscpu.op ) ] < (INT32)mipscpu.r[ INS_RT( mipscpu.op ) ] );
11891956            break;
1957
11901958         case FUNCT_SLTU:
11911959            mips_load( INS_RD( mipscpu.op ), mipscpu.r[ INS_RS( mipscpu.op ) ] < mipscpu.r[ INS_RT( mipscpu.op ) ] );
11921960            break;
1961
11931962         default:
11941963            mips_exception( EXC_RI );
11951964            break;
11961965         }
11971966         break;
1967
11981968      case OP_REGIMM:
1199         switch( INS_RT( mipscpu.op ) )
1969         switch( INS_RT_REGIMM( mipscpu.op ) )
12001970         {
12011971         case RT_BLTZ:
1202            if( (INT32)mipscpu.r[ INS_RS( mipscpu.op ) ] < 0 )
1972            mips_conditional_branch( (INT32)mipscpu.r[ INS_RS( mipscpu.op ) ] < 0 );
1973
1974            if( INS_RT( mipscpu.op ) == RT_BLTZAL )
12031975            {
1204               mips_delayed_branch( mipscpu.pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) ) << 2 ) );
1976               mipscpu.r[ 31 ] = mipscpu.pc + 4;
12051977            }
1206            else
1207            {
1208               mips_advance_pc();
1209            }
12101978            break;
1979
12111980         case RT_BGEZ:
1212            if( (INT32)mipscpu.r[ INS_RS( mipscpu.op ) ] >= 0 )
1981            mips_conditional_branch( (INT32)mipscpu.r[ INS_RS( mipscpu.op ) ] >= 0 );
1982
1983            if( INS_RT( mipscpu.op ) == RT_BGEZAL )
12131984            {
1214               mips_delayed_branch( mipscpu.pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) ) << 2 ) );
1985               mipscpu.r[ 31 ] = mipscpu.pc + 4;
12151986            }
1216            else
1217            {
1218               mips_advance_pc();
1219            }
12201987            break;
1221         case RT_BLTZAL:
1222            n_res = mipscpu.pc + 8;
1223            if( (INT32)mipscpu.r[ INS_RS( mipscpu.op ) ] < 0 )
1224            {
1225               mips_delayed_branch( mipscpu.pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) ) << 2 ) );
1226            }
1227            else
1228            {
1229               mips_advance_pc();
1230            }
1231            mipscpu.r[ 31 ] = n_res;
1232            break;
1233         case RT_BGEZAL:
1234            n_res = mipscpu.pc + 8;
1235            if( (INT32)mipscpu.r[ INS_RS( mipscpu.op ) ] >= 0 )
1236            {
1237               mips_delayed_branch( mipscpu.pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) ) << 2 ) );
1238            }
1239            else
1240            {
1241               mips_advance_pc();
1242            }
1243            mipscpu.r[ 31 ] = n_res;
1244            break;
12451988         }
12461989         break;
1990
12471991      case OP_J:
1248         mips_delayed_branch( ( ( mipscpu.pc + 4 ) & 0xf0000000 ) + ( INS_TARGET( mipscpu.op ) << 2 ) );
1992         mips_unconditional_branch();
12491993         break;
1994
12501995      case OP_JAL:
1251         n_res = mipscpu.pc + 8;
1252         mips_delayed_branch( ( ( mipscpu.pc + 4 ) & 0xf0000000 ) + ( INS_TARGET( mipscpu.op ) << 2 ) );
1253         mipscpu.r[ 31 ] = n_res;
1996         mips_unconditional_branch();
1997         mipscpu.r[ 31 ] = mipscpu.pc + 4;
12541998         break;
1999
12552000      case OP_BEQ:
1256         if( mipscpu.r[ INS_RS( mipscpu.op ) ] == mipscpu.r[ INS_RT( mipscpu.op ) ] )
1257         {
1258            mips_delayed_branch( mipscpu.pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) ) << 2 ) );
1259         }
1260         else
1261         {
1262            mips_advance_pc();
1263         }
2001         mips_conditional_branch( mipscpu.r[ INS_RS( mipscpu.op ) ] == mipscpu.r[ INS_RT( mipscpu.op ) ] );
12642002         break;
2003
12652004      case OP_BNE:
1266         if( mipscpu.r[ INS_RS( mipscpu.op ) ] != mipscpu.r[ INS_RT( mipscpu.op ) ] )
1267         {
1268            mips_delayed_branch( mipscpu.pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) ) << 2 ) );
1269         }
1270         else
1271         {
1272            mips_advance_pc();
1273         }
2005         mips_conditional_branch( mipscpu.r[ INS_RS( mipscpu.op ) ] != mipscpu.r[ INS_RT( mipscpu.op ) ] );
12742006         break;
2007
12752008      case OP_BLEZ:
1276         if( INS_RT( mipscpu.op ) != 0 )
1277         {
1278            mips_exception( EXC_RI );
1279         }
1280         else if( (INT32)mipscpu.r[ INS_RS( mipscpu.op ) ] <= 0 )
1281         {
1282            mips_delayed_branch( mipscpu.pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) ) << 2 ) );
1283         }
1284         else
1285         {
1286            mips_advance_pc();
1287         }
2009         mips_conditional_branch( (INT32)mipscpu.r[ INS_RS( mipscpu.op ) ] < 0 || mipscpu.r[ INS_RS( mipscpu.op ) ] == mipscpu.r[ INS_RT( mipscpu.op ) ] );
12882010         break;
2011
12892012      case OP_BGTZ:
1290         if( INS_RT( mipscpu.op ) != 0 )
1291         {
1292            mips_exception( EXC_RI );
1293         }
1294         else if( (INT32)mipscpu.r[ INS_RS( mipscpu.op ) ] > 0 )
1295         {
1296            mips_delayed_branch( mipscpu.pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) ) << 2 ) );
1297         }
1298         else
1299         {
1300            mips_advance_pc();
1301         }
2013         mips_conditional_branch( (INT32)mipscpu.r[ INS_RS( mipscpu.op ) ] >= 0 && mipscpu.r[ INS_RS( mipscpu.op ) ] != mipscpu.r[ INS_RT( mipscpu.op ) ] );
13022014         break;
2015
13032016      case OP_ADDI:
13042017         {
1305            UINT32 n_imm;
1306            n_imm = MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1307            n_res = mipscpu.r[ INS_RS( mipscpu.op ) ] + n_imm;
1308            if( (INT32)( ~( mipscpu.r[ INS_RS( mipscpu.op ) ] ^ n_imm ) & ( mipscpu.r[ INS_RS( mipscpu.op ) ] ^ n_res ) ) < 0 )
2018            UINT32 immediate = MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2019            UINT32 result = mipscpu.r[ INS_RS( mipscpu.op ) ] + immediate;
2020            if( (INT32)( ~( mipscpu.r[ INS_RS( mipscpu.op ) ] ^ immediate ) & ( mipscpu.r[ INS_RS( mipscpu.op ) ] ^ result ) ) < 0 )
13092021            {
13102022               mips_exception( EXC_OVF );
13112023            }
13122024            else
13132025            {
1314               mips_load( INS_RT( mipscpu.op ), n_res );
2026               mips_load( INS_RT( mipscpu.op ), result );
13152027            }
13162028         }
13172029         break;
2030
13182031      case OP_ADDIU:
13192032         mips_load( INS_RT( mipscpu.op ), mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) ) );
13202033         break;
2034
13212035      case OP_SLTI:
13222036         mips_load( INS_RT( mipscpu.op ), (INT32)mipscpu.r[ INS_RS( mipscpu.op ) ] < MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) ) );
13232037         break;
2038
13242039      case OP_SLTIU:
13252040         mips_load( INS_RT( mipscpu.op ), mipscpu.r[ INS_RS( mipscpu.op ) ] < (UINT32)MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) ) );
13262041         break;
2042
13272043      case OP_ANDI:
13282044         mips_load( INS_RT( mipscpu.op ), mipscpu.r[ INS_RS( mipscpu.op ) ] & INS_IMMEDIATE( mipscpu.op ) );
13292045         break;
2046
13302047      case OP_ORI:
13312048         mips_load( INS_RT( mipscpu.op ), mipscpu.r[ INS_RS( mipscpu.op ) ] | INS_IMMEDIATE( mipscpu.op ) );
13322049         break;
2050
13332051      case OP_XORI:
13342052         mips_load( INS_RT( mipscpu.op ), mipscpu.r[ INS_RS( mipscpu.op ) ] ^ INS_IMMEDIATE( mipscpu.op ) );
13352053         break;
2054
13362055      case OP_LUI:
13372056         mips_load( INS_RT( mipscpu.op ), INS_IMMEDIATE( mipscpu.op ) << 16 );
13382057         break;
2058
13392059      case OP_COP0:
1340         if( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) != 0 && ( mipscpu.cp0r[ CP0_SR ] & SR_CU0 ) == 0 )
2060         switch( INS_RS( mipscpu.op ) )
13412061         {
1342            mips_exception( EXC_CPU );
1343            mips_set_cp0r( CP0_CAUSE, ( mipscpu.cp0r[ CP0_CAUSE ] & ~CAUSE_CE ) | CAUSE_CE0 );
1344         }
1345         else
1346         {
1347            switch( INS_RS( mipscpu.op ) )
2062         case RS_MFC:
13482063            {
1349            case RS_MFC:
1350               mips_delayed_load( INS_RT( mipscpu.op ), mipscpu.cp0r[ INS_RD( mipscpu.op ) ] );
1351               break;
1352            case RS_CFC:
1353               /* todo: */
1354               logerror( "%08x: COP0 CFC not supported\n", mipscpu.pc );
1355               mips_stop();
1356               mips_advance_pc();
1357               break;
1358            case RS_MTC:
1359               n_res = ( mipscpu.cp0r[ INS_RD( mipscpu.op ) ] & ~mips_mtc0_writemask[ INS_RD( mipscpu.op ) ] ) |
1360                  ( mipscpu.r[ INS_RT( mipscpu.op ) ] & mips_mtc0_writemask[ INS_RD( mipscpu.op ) ] );
1361               mips_advance_pc();
1362               mips_set_cp0r( INS_RD( mipscpu.op ), n_res );
1363               break;
1364            case RS_CTC:
1365               /* todo: */
1366               logerror( "%08x: COP0 CTC not supported\n", mipscpu.pc );
1367               mips_stop();
1368               mips_advance_pc();
1369               break;
1370            case RS_BC:
1371               switch( INS_RT( mipscpu.op ) )
2064               int reg = INS_RD( mipscpu.op );
2065
2066               if( reg == CP0_INDEX ||
2067                  reg == CP0_RANDOM ||
2068                  reg == CP0_ENTRYLO ||
2069                  reg == CP0_CONTEXT ||
2070                  reg == CP0_ENTRYHI )
13722071               {
1373               case RT_BCF:
1374                  /* todo: */
1375                  logerror( "%08x: COP0 BCF not supported\n", mipscpu.pc );
1376                  mips_stop();
2072                  mips_exception( EXC_RI );
2073               }
2074               else if( reg < 16 )
2075               {
2076                  if( mips_cop0_usable() )
2077                  {
2078                     mips_delayed_load( INS_RT( mipscpu.op ), mipscpu.cp0r[ reg ] );
2079                  }
2080               }
2081               else
2082               {
13772083                  mips_advance_pc();
1378                  break;
1379               case RT_BCT:
1380                  /* todo: */
1381                  logerror( "%08x: COP0 BCT not supported\n", mipscpu.pc );
1382                  mips_stop();
2084               }
2085            }
2086            break;
2087
2088         case RS_CFC:
2089            mips_exception( EXC_RI );
2090            break;
2091
2092         case RS_MTC:
2093            {
2094               int reg = INS_RD( mipscpu.op );
2095
2096               if( reg == CP0_INDEX ||
2097                  reg == CP0_RANDOM ||
2098                  reg == CP0_ENTRYLO ||
2099                  reg == CP0_CONTEXT ||
2100                  reg == CP0_ENTRYHI )
2101               {
2102                  mips_exception( EXC_RI );
2103               }
2104               else if( reg < 16 )
2105               {
2106                  if( mips_cop0_usable() )
2107                  {
2108                     UINT32 data = ( mipscpu.cp0r[ reg ] & ~mips_mtc0_writemask[ reg ] ) |
2109                        ( mipscpu.r[ INS_RT( mipscpu.op ) ] & mips_mtc0_writemask[ reg ] );
2110                     mips_advance_pc();
2111
2112                     mips_set_cp0r( reg, data );
2113                  }
2114               }
2115               else
2116               {
13832117                  mips_advance_pc();
1384                  break;
1385               default:
1386                  /* todo: */
1387                  logerror( "%08x: COP0 unknown command %08x\n", mipscpu.pc, mipscpu.op );
1388                  mips_stop();
1389                  mips_advance_pc();
1390                  break;
13912118               }
2119            }
2120            break;
2121
2122         case RS_CTC:
2123            mips_exception( EXC_RI );
2124            break;
2125
2126         case RS_BC:
2127         case RS_BC_ALT:
2128            switch( INS_BC( mipscpu.op ) )
2129            {
2130            case BC_BCF:
2131               mips_bc( 0, SR_CU0, 0 );
13922132               break;
1393            default:
1394               switch( INS_CO( mipscpu.op ) )
2133
2134            case BC_BCT:
2135               mips_bc( 0, SR_CU0, 1 );
2136               break;
2137            }
2138            break;
2139
2140         default:
2141            switch( INS_CO( mipscpu.op ) )
2142            {
2143            case 1:
2144               switch( INS_CF( mipscpu.op ) )
13952145               {
1396               case 1:
1397                  switch( INS_CF( mipscpu.op ) )
2146               case CF_TLBR:
2147               case CF_TLBWI:
2148               case CF_TLBWR:
2149               case CF_TLBP:
2150                  mips_exception( EXC_RI );
2151                  break;
2152
2153               case CF_RFE:
2154                  if( mips_cop0_usable() )
13982155                  {
1399                  case CF_RFE:
14002156                     mips_advance_pc();
14012157                     mips_set_cp0r( CP0_SR, ( mipscpu.cp0r[ CP0_SR ] & ~0xf ) | ( ( mipscpu.cp0r[ CP0_SR ] >> 2 ) & 0xf ) );
1402                     break;
1403                  default:
1404                     /* todo: */
1405                     logerror( "%08x: COP0 unknown command %08x\n", mipscpu.pc, mipscpu.op );
1406                     mips_stop();
1407                     mips_advance_pc();
1408                     break;
14092158                  }
14102159                  break;
2160
14112161               default:
1412                  /* todo: */
1413                  logerror( "%08x: COP0 unknown command %08x\n", mipscpu.pc, mipscpu.op );
1414                  mips_stop();
14152162                  mips_advance_pc();
14162163                  break;
14172164               }
14182165               break;
2166
2167            default:
2168               mips_advance_pc();
2169               break;
14192170            }
2171            break;
14202172         }
14212173         break;
2174
14222175      case OP_COP1:
14232176         if( ( mipscpu.cp0r[ CP0_SR ] & SR_CU1 ) == 0 )
14242177         {
14252178            mips_exception( EXC_CPU );
1426            mips_set_cp0r( CP0_CAUSE, ( mipscpu.cp0r[ CP0_CAUSE ] & ~CAUSE_CE ) | CAUSE_CE1 );
14272179         }
14282180         else
14292181         {
14302182            switch( INS_RS( mipscpu.op ) )
14312183            {
14322184            case RS_MFC:
1433               /* todo: */
1434               logerror( "%08x: COP1 BCT not supported\n", mipscpu.pc );
1435               mips_stop();
1436               mips_advance_pc();
2185               mips_delayed_load( INS_RT( mipscpu.op ), getcp1dr( INS_RD( mipscpu.op ) ) );
14372186               break;
2187
14382188            case RS_CFC:
1439               /* todo: */
1440               logerror( "%08x: COP1 CFC not supported\n", mipscpu.pc );
1441               mips_stop();
1442               mips_advance_pc();
2189               mips_delayed_load( INS_RT( mipscpu.op ), getcp1cr( INS_RD( mipscpu.op ) ) );
14432190               break;
2191
14442192            case RS_MTC:
1445               /* todo: */
1446               logerror( "%08x: COP1 MTC not supported\n", mipscpu.pc );
1447               mips_stop();
2193               setcp1dr( INS_RD( mipscpu.op ), mipscpu.r[ INS_RT( mipscpu.op ) ] );
14482194               mips_advance_pc();
14492195               break;
2196
14502197            case RS_CTC:
1451               /* todo: */
1452               logerror( "%08x: COP1 CTC not supported\n", mipscpu.pc );
1453               mips_stop();
2198               setcp1cr( INS_RD( mipscpu.op ), mipscpu.r[ INS_RT( mipscpu.op ) ] );
14542199               mips_advance_pc();
14552200               break;
2201
14562202            case RS_BC:
1457               switch( INS_RT( mipscpu.op ) )
2203            case RS_BC_ALT:
2204               switch( INS_BC( mipscpu.op ) )
14582205               {
1459               case RT_BCF:
1460                  /* todo: */
1461                  logerror( "%08x: COP1 BCF not supported\n", mipscpu.pc );
1462                  mips_stop();
1463                  mips_advance_pc();
2206               case BC_BCF:
2207                  mips_bc( 1, SR_CU1, 0 );
14642208                  break;
1465               case RT_BCT:
1466                  /* todo: */
1467                  logerror( "%08x: COP1 BCT not supported\n", mipscpu.pc );
1468                  mips_stop();
1469                  mips_advance_pc();
2209
2210               case BC_BCT:
2211                  mips_bc( 1, SR_CU1, 1 );
14702212                  break;
1471               default:
1472                  /* todo: */
1473                  logerror( "%08x: COP1 unknown command %08x\n", mipscpu.pc, mipscpu.op );
1474                  mips_stop();
1475                  mips_advance_pc();
1476                  break;
14772213               }
14782214               break;
2215
14792216            default:
1480               switch( INS_CO( mipscpu.op ) )
1481               {
1482               case 1:
1483                  /* todo: */
1484                  logerror( "%08x: COP1 unknown command %08x\n", mipscpu.pc, mipscpu.op );
1485                  mips_stop();
1486                  mips_advance_pc();
1487                  break;
1488               default:
1489                  /* todo: */
1490                  logerror( "%08x: COP1 unknown command %08x\n", mipscpu.pc, mipscpu.op );
1491                  mips_stop();
1492                  mips_advance_pc();
1493                  break;
1494               }
2217               mips_advance_pc();
14952218               break;
14962219            }
14972220         }
14982221         break;
2222
14992223      case OP_COP2:
15002224         if( ( mipscpu.cp0r[ CP0_SR ] & SR_CU2 ) == 0 )
15012225         {
15022226            mips_exception( EXC_CPU );
1503            mips_set_cp0r( CP0_CAUSE, ( mipscpu.cp0r[ CP0_CAUSE ] & ~CAUSE_CE ) | CAUSE_CE2 );
15042227         }
15052228         else
15062229         {
r2375r2376
15092232            case RS_MFC:
15102233               mips_delayed_load( INS_RT( mipscpu.op ), getcp2dr( INS_RD( mipscpu.op ) ) );
15112234               break;
2235
15122236            case RS_CFC:
15132237               mips_delayed_load( INS_RT( mipscpu.op ), getcp2cr( INS_RD( mipscpu.op ) ) );
15142238               break;
2239
15152240            case RS_MTC:
15162241               setcp2dr( INS_RD( mipscpu.op ), mipscpu.r[ INS_RT( mipscpu.op ) ] );
15172242               mips_advance_pc();
15182243               break;
2244
15192245            case RS_CTC:
15202246               setcp2cr( INS_RD( mipscpu.op ), mipscpu.r[ INS_RT( mipscpu.op ) ] );
15212247               mips_advance_pc();
15222248               break;
2249
15232250            case RS_BC:
1524               switch( INS_RT( mipscpu.op ) )
2251            case RS_BC_ALT:
2252               switch( INS_BC( mipscpu.op ) )
15252253               {
1526               case RT_BCF:
1527                  /* todo: */
1528                  logerror( "%08x: COP2 BCF not supported\n", mipscpu.pc );
1529                  mips_stop();
1530                  mips_advance_pc();
2254               case BC_BCF:
2255                  mips_bc( 2, SR_CU2, 0 );
15312256                  break;
1532               case RT_BCT:
1533                  /* todo: */
1534                  logerror( "%08x: COP2 BCT not supported\n", mipscpu.pc );
1535                  mips_stop();
1536                  mips_advance_pc();
2257
2258               case BC_BCT:
2259                  mips_bc( 2, SR_CU2, 1 );
15372260                  break;
1538               default:
1539                  /* todo: */
1540                  logerror( "%08x: COP2 unknown command %08x\n", mipscpu.pc, mipscpu.op );
1541                  mips_stop();
1542                  mips_advance_pc();
1543                  break;
15442261               }
15452262               break;
2263
15462264            default:
15472265               switch( INS_CO( mipscpu.op ) )
15482266               {
r2375r2376
15502268                  docop2( INS_COFUN( mipscpu.op ) );
15512269                  mips_advance_pc();
15522270                  break;
2271
15532272               default:
1554                  /* todo: */
1555                  logerror( "%08x: COP2 unknown command %08x\n", mipscpu.pc, mipscpu.op );
1556                  mips_stop();
15572273                  mips_advance_pc();
15582274                  break;
15592275               }
r2375r2376
15612277            }
15622278         }
15632279         break;
1564      case OP_LB:
1565         if( ( mipscpu.cp0r[ CP0_SR ] & SR_ISC ) != 0 )
2280
2281      case OP_COP3:
2282         if( ( mipscpu.cp0r[ CP0_SR ] & SR_CU3 ) == 0 )
15662283         {
1567            /* todo: */
1568            logerror( "%08x: LB SR_ISC not supported\n", mipscpu.pc );
1569            mips_stop();
1570            mips_advance_pc();
2284            mips_exception( EXC_CPU );
15712285         }
1572         else if( ( mipscpu.cp0r[ CP0_SR ] & ( SR_RE | SR_KUC ) ) == ( SR_RE | SR_KUC ) )
2286         else
15732287         {
1574            UINT32 n_adr;
1575            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1576            if( ( n_adr & ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) ) != 0 )
2288            switch( INS_RS( mipscpu.op ) )
15772289            {
1578               mips_exception( EXC_ADEL );
1579               mips_set_cp0r( CP0_BADVADDR, n_adr );
2290            case RS_MFC:
2291               mips_delayed_load( INS_RT( mipscpu.op ), getcp3dr( INS_RD( mipscpu.op ) ) );
2292               break;
2293
2294            case RS_CFC:
2295               mips_delayed_load( INS_RT( mipscpu.op ), getcp3cr( INS_RD( mipscpu.op ) ) );
2296               break;
2297
2298            case RS_MTC:
2299               setcp3dr( INS_RD( mipscpu.op ), mipscpu.r[ INS_RT( mipscpu.op ) ] );
2300               mips_advance_pc();
2301               break;
2302
2303            case RS_CTC:
2304               setcp3cr( INS_RD( mipscpu.op ), mipscpu.r[ INS_RT( mipscpu.op ) ] );
2305               mips_advance_pc();
2306               break;
2307
2308            case RS_BC:
2309            case RS_BC_ALT:
2310               switch( INS_BC( mipscpu.op ) )
2311               {
2312               case BC_BCF:
2313                  mips_bc( 3, SR_CU3, 0 );
2314                  break;
2315
2316               case BC_BCT:
2317                  mips_bc( 3, SR_CU3, 1 );
2318                  break;
2319               }
2320               break;
2321
2322            default:
2323               mips_advance_pc();
2324               break;
15802325            }
1581            else
1582            {
1583               mips_delayed_load( INS_RT( mipscpu.op ), MIPS_BYTE_EXTEND( program_read_byte_32le( n_adr ^ 3 ) ) );
1584            }
15852326         }
1586         else
2327         break;
2328
2329      case OP_LB:
15872330         {
1588            UINT32 n_adr;
1589            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1590            if( ( n_adr & ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) ) != 0 )
2331            UINT32 address = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2332            int breakpoint = mips_load_data_address_breakpoint( address );
2333
2334            if( ( address & mipscpu.bad_byte_address_mask ) != 0 )
15912335            {
1592               mips_exception( EXC_ADEL );
1593               mips_set_cp0r( CP0_BADVADDR, n_adr );
2336               mips_load_bad_address( address );
15942337            }
2338            else if( breakpoint )
2339            {
2340               mips_breakpoint_exception();
2341            }
15952342            else
15962343            {
1597               mips_delayed_load( INS_RT( mipscpu.op ), MIPS_BYTE_EXTEND( program_read_byte_32le( n_adr ) ) );
2344               UINT32 data = MIPS_BYTE_EXTEND( mipscpu.readbyte( address ) );
2345
2346               if( mipscpu.berr )
2347               {
2348                  mips_load_bus_error_exception();
2349               }
2350               else
2351               {
2352                  mips_delayed_load( INS_RT( mipscpu.op ), data );
2353               }
15982354            }
15992355         }
16002356         break;
2357
16012358      case OP_LH:
1602         if( ( mipscpu.cp0r[ CP0_SR ] & SR_ISC ) != 0 )
16032359         {
1604            /* todo: */
1605            logerror( "%08x: LH SR_ISC not supported\n", mipscpu.pc );
1606            mips_stop();
1607            mips_advance_pc();
1608         }
1609         else if( ( mipscpu.cp0r[ CP0_SR ] & ( SR_RE | SR_KUC ) ) == ( SR_RE | SR_KUC ) )
1610         {
1611            UINT32 n_adr;
1612            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1613            if( ( n_adr & ( ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) | 1 ) ) != 0 )
2360            UINT32 address = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2361            int breakpoint = mips_load_data_address_breakpoint( address );
2362
2363            if( ( address & mipscpu.bad_half_address_mask ) != 0 )
16142364            {
1615               mips_exception( EXC_ADEL );
1616               mips_set_cp0r( CP0_BADVADDR, n_adr );
2365               mips_load_bad_address( address );
16172366            }
1618            else
2367            else if( breakpoint )
16192368            {
1620               mips_delayed_load( INS_RT( mipscpu.op ), MIPS_WORD_EXTEND( program_read_word_32le( n_adr ^ 2 ) ) );
2369               mips_breakpoint_exception();
16212370            }
1622         }
1623         else
1624         {
1625            UINT32 n_adr;
1626            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1627            if( ( n_adr & ( ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) | 1 ) ) != 0 )
1628            {
1629               mips_exception( EXC_ADEL );
1630               mips_set_cp0r( CP0_BADVADDR, n_adr );
1631            }
16322371            else
16332372            {
1634               mips_delayed_load( INS_RT( mipscpu.op ), MIPS_WORD_EXTEND( program_read_word_32le( n_adr ) ) );
2373               UINT32 data = MIPS_WORD_EXTEND( mipscpu.readhalf( address ) );
2374
2375               if( mipscpu.berr )
2376               {
2377                  mips_load_bus_error_exception();
2378               }
2379               else
2380               {
2381                  mips_delayed_load( INS_RT( mipscpu.op ), data );
2382               }
16352383            }
16362384         }
16372385         break;
2386
16382387      case OP_LWL:
1639         if( ( mipscpu.cp0r[ CP0_SR ] & SR_ISC ) != 0 )
16402388         {
1641            /* todo: */
1642            logerror( "%08x: LWL SR_ISC not supported\n", mipscpu.pc );
1643            mips_stop();
1644            mips_advance_pc();
1645         }
1646         else if( ( mipscpu.cp0r[ CP0_SR ] & ( SR_RE | SR_KUC ) ) == ( SR_RE | SR_KUC ) )
1647         {
1648            UINT32 n_adr;
1649            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1650            if( ( n_adr & ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) ) != 0 )
2389            UINT32 address = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2390            int load_type = address & 3;
2391            int breakpoint;
2392
2393            address &= ~3;
2394            breakpoint = mips_load_data_address_breakpoint( address );
2395
2396            if( ( address & mipscpu.bad_byte_address_mask ) != 0 )
16512397            {
1652               mips_exception( EXC_ADEL );
1653               mips_set_cp0r( CP0_BADVADDR, n_adr );
2398               mips_load_bad_address( address );
16542399            }
1655            else
2400            else if( breakpoint )
16562401            {
1657               switch( n_adr & 3 )
1658               {
1659               case 0:
1660                  n_res = ( mipscpu.r[ INS_RT( mipscpu.op ) ] & 0x00ffffff ) | ( (UINT32)program_read_byte_32le( n_adr + 3 ) << 24 );
1661                  break;
1662               case 1:
1663                  n_res = ( mipscpu.r[ INS_RT( mipscpu.op ) ] & 0x0000ffff ) | ( (UINT32)program_read_word_32le( n_adr + 1 ) << 16 );
1664                  break;
1665               case 2:
1666                  n_res = ( mipscpu.r[ INS_RT( mipscpu.op ) ] & 0x000000ff ) | ( (UINT32)program_read_byte_32le( n_adr - 1 ) << 8 ) | ( (UINT32)program_read_word_32le( n_adr ) << 16 );
1667                  break;
1668               default:
1669                  n_res = program_read_dword_32le( n_adr - 3 );
1670                  break;
1671               }
1672               mips_delayed_load( INS_RT( mipscpu.op ), n_res );
2402               mips_breakpoint_exception();
16732403            }
1674         }
1675         else
1676         {
1677            UINT32 n_adr;
1678            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1679            if( ( n_adr & ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) ) != 0 )
1680            {
1681               mips_exception( EXC_ADEL );
1682               mips_set_cp0r( CP0_BADVADDR, n_adr );
1683            }
16842404            else
16852405            {
1686               switch( n_adr & 3 )
2406               UINT32 data = mips_get_register_from_pipeline( INS_RT( mipscpu.op ) );
2407
2408               switch( load_type )
16872409               {
16882410               case 0:
1689                  n_res = ( mipscpu.r[ INS_RT( mipscpu.op ) ] & 0x00ffffff ) | ( (UINT32)program_read_byte_32le( n_adr ) << 24 );
2411                  data = ( data & 0x00ffffff ) | ( mipscpu.readword_masked( address, 0xff000000 ) << 24 );
16902412                  break;
2413
16912414               case 1:
1692                  n_res = ( mipscpu.r[ INS_RT( mipscpu.op ) ] & 0x0000ffff ) | ( (UINT32)program_read_word_32le( n_adr - 1 ) << 16 );
2415                  data = ( data & 0x0000ffff ) | ( mipscpu.readword_masked( address, 0xffff0000 ) << 16 );
16932416                  break;
2417
16942418               case 2:
1695                  n_res = ( mipscpu.r[ INS_RT( mipscpu.op ) ] & 0x000000ff ) | ( (UINT32)program_read_word_32le( n_adr - 2 ) << 8 ) | ( (UINT32)program_read_byte_32le( n_adr ) << 24 );
2419                  data = ( data & 0x000000ff ) | ( mipscpu.readword_masked( address, 0xffffff00 ) << 8 );
16962420                  break;
1697               default:
1698                  n_res = program_read_dword_32le( n_adr - 3 );
2421
2422               case 3:
2423                  data = mipscpu.readword( address );
16992424                  break;
17002425               }
1701               mips_delayed_load( INS_RT( mipscpu.op ), n_res );
2426
2427               if( mipscpu.berr )
2428               {
2429                  mips_load_bus_error_exception();
2430               }
2431               else
2432               {
2433                  mips_delayed_load( INS_RT( mipscpu.op ), data );
2434               }
17022435            }
17032436         }
17042437         break;
2438
17052439      case OP_LW:
1706         if( ( mipscpu.cp0r[ CP0_SR ] & SR_ISC ) != 0 )
17072440         {
1708            /* todo: */
1709            logerror( "%08x: LW SR_ISC not supported\n", mipscpu.pc );
1710            mips_stop();
1711            mips_advance_pc();
1712         }
1713         else
1714         {
1715            UINT32 n_adr;
1716            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1717            if( ( n_adr & ( ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) | 3 ) ) != 0 )
2441            UINT32 address = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2442            int breakpoint = mips_load_data_address_breakpoint( address );
2443
2444            if( ( address & mipscpu.bad_word_address_mask ) != 0 )
17182445            {
1719               mips_exception( EXC_ADEL );
1720               mips_set_cp0r( CP0_BADVADDR, n_adr );
2446               mips_load_bad_address( address );
17212447            }
2448            else if( breakpoint )
2449            {
2450               mips_breakpoint_exception();
2451            }
17222452            else
17232453            {
1724               mips_delayed_load( INS_RT( mipscpu.op ), program_read_dword_32le( n_adr ) );
2454               UINT32 data = mipscpu.readword( address );
2455
2456               if( mipscpu.berr )
2457               {
2458                  mips_load_bus_error_exception();
2459               }
2460               else
2461               {
2462                  mips_delayed_load( INS_RT( mipscpu.op ), data );
2463               }
17252464            }
17262465         }
17272466         break;
2467
17282468      case OP_LBU:
1729         if( ( mipscpu.cp0r[ CP0_SR ] & SR_ISC ) != 0 )
17302469         {
1731            /* todo: */
1732            logerror( "%08x: LBU SR_ISC not supported\n", mipscpu.pc );
1733            mips_stop();
1734            mips_advance_pc();
1735         }
1736         else if( ( mipscpu.cp0r[ CP0_SR ] & ( SR_RE | SR_KUC ) ) == ( SR_RE | SR_KUC ) )
1737         {
1738            UINT32 n_adr;
1739            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1740            if( ( n_adr & ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) ) != 0 )
2470            UINT32 address = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2471            int breakpoint = mips_load_data_address_breakpoint( address );
2472
2473            if( ( address & mipscpu.bad_byte_address_mask ) != 0 )
17412474            {
1742               mips_exception( EXC_ADEL );
1743               mips_set_cp0r( CP0_BADVADDR, n_adr );
2475               mips_load_bad_address( address );
17442476            }
1745            else
2477            else if( breakpoint )
17462478            {
1747               mips_delayed_load( INS_RT( mipscpu.op ), program_read_byte_32le( n_adr ^ 3 ) );
2479               mips_breakpoint_exception();
17482480            }
1749         }
1750         else
1751         {
1752            UINT32 n_adr;
1753            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1754            if( ( n_adr & ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) ) != 0 )
1755            {
1756               mips_exception( EXC_ADEL );
1757               mips_set_cp0r( CP0_BADVADDR, n_adr );
1758            }
17592481            else
17602482            {
1761               mips_delayed_load( INS_RT( mipscpu.op ), program_read_byte_32le( n_adr ) );
2483               UINT32 data = mipscpu.readbyte( address );
2484
2485               if( mipscpu.berr )
2486               {
2487                  mips_load_bus_error_exception();
2488               }
2489               else
2490               {
2491                  mips_delayed_load( INS_RT( mipscpu.op ), data );
2492               }
17622493            }
17632494         }
17642495         break;
2496
17652497      case OP_LHU:
1766         if( ( mipscpu.cp0r[ CP0_SR ] & SR_ISC ) != 0 )
17672498         {
1768            /* todo: */
1769            logerror( "%08x: LHU SR_ISC not supported\n", mipscpu.pc );
1770            mips_stop();
1771            mips_advance_pc();
1772         }
1773         else if( ( mipscpu.cp0r[ CP0_SR ] & ( SR_RE | SR_KUC ) ) == ( SR_RE | SR_KUC ) )
1774         {
1775            UINT32 n_adr;
1776            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1777            if( ( n_adr & ( ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) | 1 ) ) != 0 )
2499            UINT32 address = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2500            int breakpoint = mips_load_data_address_breakpoint( address );
2501
2502            if( ( address & mipscpu.bad_half_address_mask ) != 0 )
17782503            {
1779               mips_exception( EXC_ADEL );
1780               mips_set_cp0r( CP0_BADVADDR, n_adr );
2504               mips_load_bad_address( address );
17812505            }
1782            else
2506            else if( breakpoint )
17832507            {
1784               mips_delayed_load( INS_RT( mipscpu.op ), program_read_word_32le( n_adr ^ 2 ) );
2508               mips_breakpoint_exception();
17852509            }
1786         }
1787         else
1788         {
1789            UINT32 n_adr;
1790            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1791            if( ( n_adr & ( ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) | 1 ) ) != 0 )
1792            {
1793               mips_exception( EXC_ADEL );
1794               mips_set_cp0r( CP0_BADVADDR, n_adr );
1795            }
17962510            else
17972511            {
1798               mips_delayed_load( INS_RT( mipscpu.op ), program_read_word_32le( n_adr ) );
2512               UINT32 data = mipscpu.readhalf( address );
2513
2514               if( mipscpu.berr )
2515               {
2516                  mips_load_bus_error_exception();
2517               }
2518               else
2519               {
2520                  mips_delayed_load( INS_RT( mipscpu.op ), data );
2521               }
17992522            }
18002523         }
18012524         break;
2525
18022526      case OP_LWR:
1803         if( ( mipscpu.cp0r[ CP0_SR ] & SR_ISC ) != 0 )
18042527         {
1805            /* todo: */
1806            logerror( "%08x: LWR SR_ISC not supported\n", mipscpu.pc );
1807            mips_stop();
1808            mips_advance_pc();
1809         }
1810         else if( ( mipscpu.cp0r[ CP0_SR ] & ( SR_RE | SR_KUC ) ) == ( SR_RE | SR_KUC ) )
1811         {
1812            UINT32 n_adr;
1813            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1814            if( ( n_adr & ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) ) != 0 )
2528            UINT32 address = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2529            int breakpoint = mips_load_data_address_breakpoint( address );
2530
2531            if( ( address & mipscpu.bad_byte_address_mask ) != 0 )
18152532            {
1816               mips_exception( EXC_ADEL );
1817               mips_set_cp0r( CP0_BADVADDR, n_adr );
2533               mips_load_bad_address( address );
18182534            }
2535            else if( breakpoint )
2536            {
2537               mips_breakpoint_exception();
2538            }
18192539            else
18202540            {
1821               switch( n_adr & 3 )
2541               UINT32 data = mips_get_register_from_pipeline( INS_RT( mipscpu.op ) );
2542
2543               switch( address & 3 )
18222544               {
1823               case 3:
1824                  n_res = ( mipscpu.r[ INS_RT( mipscpu.op ) ] & 0xffffff00 ) | program_read_byte_32le( n_adr - 3 );
2545               case 0:
2546                  data = mipscpu.readword( address );
18252547                  break;
1826               case 2:
1827                  n_res = ( mipscpu.r[ INS_RT( mipscpu.op ) ] & 0xffff0000 ) | program_read_word_32le( n_adr - 2 );
1828                  break;
2548
18292549               case 1:
1830                  n_res = ( mipscpu.r[ INS_RT( mipscpu.op ) ] & 0xff000000 ) | program_read_word_32le( n_adr - 1 ) | ( (UINT32)program_read_byte_32le( n_adr + 1 ) << 16 );
2550                  data = ( data & 0xff000000 ) | ( mipscpu.readword_masked( address, 0x00ffffff ) >> 8 );
18312551                  break;
1832               default:
1833                  n_res = program_read_dword_32le( n_adr );
2552
2553               case 2:
2554                  data = ( data & 0xffff0000 ) | ( mipscpu.readword_masked( address, 0x0000ffff ) >> 16 );
18342555                  break;
1835               }
1836               mips_delayed_load( INS_RT( mipscpu.op ), n_res );
1837            }
1838         }
1839         else
1840         {
1841            UINT32 n_adr;
1842            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1843            if( ( n_adr & ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) ) != 0 )
1844            {
1845               mips_exception( EXC_ADEL );
1846               mips_set_cp0r( CP0_BADVADDR, n_adr );
1847            }
1848            else
1849            {
1850               switch( n_adr & 3 )
1851               {
2556
18522557               case 3:
1853                  n_res = ( mipscpu.r[ INS_RT( mipscpu.op ) ] & 0xffffff00 ) | program_read_byte_32le( n_adr );
2558                  data = ( data & 0xffffff00 ) | ( mipscpu.readword_masked( address, 0x000000ff ) >> 24 );
18542559                  break;
1855               case 2:
1856                  n_res = ( mipscpu.r[ INS_RT( mipscpu.op ) ] & 0xffff0000 ) | program_read_word_32le( n_adr );
1857                  break;
1858               case 1:
1859                  n_res = ( mipscpu.r[ INS_RT( mipscpu.op ) ] & 0xff000000 ) | program_read_byte_32le( n_adr ) | ( (UINT32)program_read_word_32le( n_adr + 1 ) << 8 );
1860                  break;
1861               default:
1862                  n_res = program_read_dword_32le( n_adr );
1863                  break;
18642560               }
1865               mips_delayed_load( INS_RT( mipscpu.op ), n_res );
2561
2562               if( mipscpu.berr )
2563               {
2564                  mips_load_bus_error_exception();
2565               }
2566               else
2567               {
2568                  mips_delayed_load( INS_RT( mipscpu.op ), data );
2569               }
18662570            }
18672571         }
18682572         break;
2573
18692574      case OP_SB:
1870         if( ( mipscpu.cp0r[ CP0_SR ] & SR_ISC ) != 0 )
18712575         {
1872            /* todo: */
1873            logerror( "%08x: SB SR_ISC not supported\n", mipscpu.pc );
1874            mips_stop();
1875            mips_advance_pc();
1876         }
1877         else if( ( mipscpu.cp0r[ CP0_SR ] & ( SR_RE | SR_KUC ) ) == ( SR_RE | SR_KUC ) )
1878         {
1879            UINT32 n_adr;
1880            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1881            if( ( n_adr & ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) ) != 0 )
2576            UINT32 address = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2577            int breakpoint = mips_store_data_address_breakpoint( address );
2578
2579            if( ( address & mipscpu.bad_byte_address_mask ) != 0 )
18822580            {
1883               mips_exception( EXC_ADES );
1884               mips_set_cp0r( CP0_BADVADDR, n_adr );
2581               mips_store_bad_address( address );
18852582            }
18862583            else
18872584            {
1888               program_write_byte_32le( n_adr ^ 3, mipscpu.r[ INS_RT( mipscpu.op ) ] );
1889               mips_advance_pc();
2585               int shift = 8 * ( address & 3 );
2586               mipscpu.writeword_masked( address, mipscpu.r[ INS_RT( mipscpu.op ) ] << shift, ~( 0xff << shift ) );
2587
2588               if( breakpoint )
2589               {
2590                  mips_breakpoint_exception();
2591               }
2592               else if( mipscpu.berr )
2593               {
2594                  mips_store_bus_error_exception();
2595               }
2596               else
2597               {
2598                  mips_advance_pc();
2599               }
18902600            }
18912601         }
1892         else
1893         {
1894            UINT32 n_adr;
1895            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1896            if( ( n_adr & ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) ) != 0 )
1897            {
1898               mips_exception( EXC_ADES );
1899               mips_set_cp0r( CP0_BADVADDR, n_adr );
1900            }
1901            else
1902            {
1903               program_write_byte_32le( n_adr, mipscpu.r[ INS_RT( mipscpu.op ) ] );
1904               mips_advance_pc();
1905            }
1906         }
19072602         break;
2603
19082604      case OP_SH:
1909         if( ( mipscpu.cp0r[ CP0_SR ] & SR_ISC ) != 0 )
19102605         {
1911            /* todo: */
1912            logerror( "%08x: SH SR_ISC not supported\n", mipscpu.pc );
1913            mips_stop();
1914            mips_advance_pc();
1915         }
1916         else if( ( mipscpu.cp0r[ CP0_SR ] & ( SR_RE | SR_KUC ) ) == ( SR_RE | SR_KUC ) )
1917         {
1918            UINT32 n_adr;
1919            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1920            if( ( n_adr & ( ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) | 1 ) ) != 0 )
2606            UINT32 address = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2607            int breakpoint = mips_store_data_address_breakpoint( address );
2608
2609            if( ( address & mipscpu.bad_half_address_mask ) != 0 )
19212610            {
1922               mips_exception( EXC_ADES );
1923               mips_set_cp0r( CP0_BADVADDR, n_adr );
2611               mips_store_bad_address( address );
19242612            }
19252613            else
19262614            {
1927               program_write_word_32le( n_adr ^ 2, mipscpu.r[ INS_RT( mipscpu.op ) ] );
1928               mips_advance_pc();
2615               int shift = 8 * ( address & 2 );
2616               mipscpu.writeword_masked( address, mipscpu.r[ INS_RT( mipscpu.op ) ] << shift, ~( 0xffff << shift ) );
2617
2618               if( breakpoint )
2619               {
2620                  mips_breakpoint_exception();
2621               }
2622               else if( mipscpu.berr )
2623               {
2624                  mips_store_bus_error_exception();
2625               }
2626               else
2627               {
2628                  mips_advance_pc();
2629               }
19292630            }
19302631         }
1931         else
1932         {
1933            UINT32 n_adr;
1934            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1935            if( ( n_adr & ( ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) | 1 ) ) != 0 )
1936            {
1937               mips_exception( EXC_ADES );
1938               mips_set_cp0r( CP0_BADVADDR, n_adr );
1939            }
1940            else
1941            {
1942               program_write_word_32le( n_adr, mipscpu.r[ INS_RT( mipscpu.op ) ] );
1943               mips_advance_pc();
1944            }
1945         }
19462632         break;
2633
19472634      case OP_SWL:
1948         if( ( mipscpu.cp0r[ CP0_SR ] & SR_ISC ) != 0 )
19492635         {
1950            /* todo: */
1951            logerror( "%08x: SWL SR_ISC not supported\n", mipscpu.pc );
1952            mips_stop();
1953            mips_advance_pc();
1954         }
1955         else if( ( mipscpu.cp0r[ CP0_SR ] & ( SR_RE | SR_KUC ) ) == ( SR_RE | SR_KUC ) )
1956         {
1957            UINT32 n_adr;
1958            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1959            if( ( n_adr & ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) ) != 0 )
2636            UINT32 address = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2637            int save_type = address & 3;
2638            int breakpoint;
2639
2640            address &= ~3;
2641            breakpoint = mips_store_data_address_breakpoint( address );
2642
2643            if( ( address & mipscpu.bad_byte_address_mask ) != 0 )
19602644            {
1961               mips_exception( EXC_ADES );
1962               mips_set_cp0r( CP0_BADVADDR, n_adr );
2645               mips_store_bad_address( address );
19632646            }
19642647            else
19652648            {
1966               switch( n_adr & 3 )
2649               switch( save_type )
19672650               {
19682651               case 0:
1969                  program_write_byte_32le( n_adr + 3, mipscpu.r[ INS_RT( mipscpu.op ) ] >> 24 );
2652                  mipscpu.writeword_masked( address, mipscpu.r[ INS_RT( mipscpu.op ) ] >> 24, 0xffffff00 );
19702653                  break;
2654
19712655               case 1:
1972                  program_write_word_32le( n_adr + 1, mipscpu.r[ INS_RT( mipscpu.op ) ] >> 16 );
2656                  mipscpu.writeword_masked( address, mipscpu.r[ INS_RT( mipscpu.op ) ] >> 16, 0xffff0000 );
19732657                  break;
2658
19742659               case 2:
1975                  program_write_byte_32le( n_adr - 1, mipscpu.r[ INS_RT( mipscpu.op ) ] >> 8 );
1976                  program_write_word_32le( n_adr, mipscpu.r[ INS_RT( mipscpu.op ) ] >> 16 );
2660                  mipscpu.writeword_masked( address, mipscpu.r[ INS_RT( mipscpu.op ) ] >> 8, 0xff000000 );
19772661                  break;
2662
19782663               case 3:
1979                  program_write_dword_32le( n_adr - 3, mipscpu.r[ INS_RT( mipscpu.op ) ] );
2664                  mipscpu.writeword( address, mipscpu.r[ INS_RT( mipscpu.op ) ] );
19802665                  break;
19812666               }
1982               mips_advance_pc();
1983            }
1984         }
1985         else
1986         {
1987            UINT32 n_adr;
1988            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
1989            if( ( n_adr & ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) ) != 0 )
1990            {
1991               mips_exception( EXC_ADES );
1992               mips_set_cp0r( CP0_BADVADDR, n_adr );
1993            }
1994            else
1995            {
1996               switch( n_adr & 3 )
2667
2668               if( breakpoint )
19972669               {
1998               case 0:
1999                  program_write_byte_32le( n_adr, mipscpu.r[ INS_RT( mipscpu.op ) ] >> 24 );
2000                  break;
2001               case 1:
2002                  program_write_word_32le( n_adr - 1, mipscpu.r[ INS_RT( mipscpu.op ) ] >> 16 );
2003                  break;
2004               case 2:
2005                  program_write_word_32le( n_adr - 2, mipscpu.r[ INS_RT( mipscpu.op ) ] >> 8 );
2006                  program_write_byte_32le( n_adr, mipscpu.r[ INS_RT( mipscpu.op ) ] >> 24 );
2007                  break;
2008               case 3:
2009                  program_write_dword_32le( n_adr - 3, mipscpu.r[ INS_RT( mipscpu.op ) ] );
2010                  break;
2670                  mips_breakpoint_exception();
20112671               }
2012               mips_advance_pc();
2672               else if( mipscpu.berr )
2673               {
2674                  mips_store_bus_error_exception();
2675               }
2676               else
2677               {
2678                  mips_advance_pc();
2679               }
20132680            }
20142681         }
20152682         break;
2683
20162684      case OP_SW:
2017         if( ( mipscpu.cp0r[ CP0_SR ] & SR_ISC ) != 0 )
20182685         {
2019            /* todo: */
2020/* used by bootstrap
2021                logerror( "%08x: SW SR_ISC not supported\n", mipscpu.pc );
2022                mips_stop();
2023*/
2024            mips_advance_pc();
2025         }
2026         else
2027         {
2028            UINT32 n_adr;
2029            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2030            if( ( n_adr & ( ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) | 3 ) ) != 0 )
2686            UINT32 address = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2687            int breakpoint = mips_store_data_address_breakpoint( address );
2688
2689            if( ( address & mipscpu.bad_word_address_mask ) != 0 )
20312690            {
2032               mips_exception( EXC_ADES );
2033               mips_set_cp0r( CP0_BADVADDR, n_adr );
2691               mips_store_bad_address( address );
20342692            }
20352693            else
20362694            {
2037               program_write_dword_32le( n_adr, mipscpu.r[ INS_RT( mipscpu.op ) ] );
2038               mips_advance_pc();
2695               mipscpu.writeword( address, mipscpu.r[ INS_RT( mipscpu.op ) ] );
2696
2697               if( breakpoint )
2698               {
2699                  mips_breakpoint_exception();
2700               }
2701               else if( mipscpu.berr )
2702               {
2703                  mips_store_bus_error_exception();
2704               }
2705               else
2706               {
2707                  mips_advance_pc();
2708               }
20392709            }
20402710         }
20412711         break;
2712
20422713      case OP_SWR:
2043         if( ( mipscpu.cp0r[ CP0_SR ] & SR_ISC ) != 0 )
20442714         {
2045            /* todo: */
2046            logerror( "%08x: SWR SR_ISC not supported\n", mipscpu.pc );
2047            mips_stop();
2048            mips_advance_pc();
2049         }
2050         else if( ( mipscpu.cp0r[ CP0_SR ] & ( SR_RE | SR_KUC ) ) == ( SR_RE | SR_KUC ) )
2051         {
2052            UINT32 n_adr;
2053            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2054            if( ( n_adr & ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) ) != 0 )
2715            UINT32 address = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2716            int breakpoint = mips_store_data_address_breakpoint( address );
2717
2718            if( ( address & mipscpu.bad_byte_address_mask ) != 0 )
20552719            {
2056               mips_exception( EXC_ADES );
2057               mips_set_cp0r( CP0_BADVADDR, n_adr );
2720               mips_store_bad_address( address );
20582721            }
20592722            else
20602723            {
2061               switch( n_adr & 3 )
2724               switch( address & 3 )
20622725               {
20632726               case 0:
2064                  program_write_dword_32le( n_adr, mipscpu.r[ INS_RT( mipscpu.op ) ] );
2727                  mipscpu.writeword( address, mipscpu.r[ INS_RT( mipscpu.op ) ] );
20652728                  break;
2729
20662730               case 1:
2067                  program_write_word_32le( n_adr - 1, mipscpu.r[ INS_RT( mipscpu.op ) ] );
2068                  program_write_byte_32le( n_adr + 1, mipscpu.r[ INS_RT( mipscpu.op ) ] >> 16 );
2731                  mipscpu.writeword_masked( address, mipscpu.r[ INS_RT( mipscpu.op ) ] << 8, 0x000000ff );
20692732                  break;
2733
20702734               case 2:
2071                  program_write_word_32le( n_adr - 2, mipscpu.r[ INS_RT( mipscpu.op ) ] );
2735                  mipscpu.writeword_masked( address, mipscpu.r[ INS_RT( mipscpu.op ) ] << 16, 0x0000ffff );
20722736                  break;
2737
20732738               case 3:
2074                  program_write_byte_32le( n_adr - 3, mipscpu.r[ INS_RT( mipscpu.op ) ] );
2739                  mipscpu.writeword_masked( address, mipscpu.r[ INS_RT( mipscpu.op ) ] << 24, 0x00ffffff );
20752740                  break;
20762741               }
2077               mips_advance_pc();
2078            }
2079         }
2080         else
2081         {
2082            UINT32 n_adr;
2083            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2084            if( ( n_adr & ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) ) != 0 )
2085            {
2086               mips_exception( EXC_ADES );
2087               mips_set_cp0r( CP0_BADVADDR, n_adr );
2088            }
2089            else
2090            {
2091               switch( n_adr & 3 )
2742
2743               if( breakpoint )
20922744               {
2093               case 0:
2094                  program_write_dword_32le( n_adr, mipscpu.r[ INS_RT( mipscpu.op ) ] );
2095                  break;
2096               case 1:
2097                  program_write_byte_32le( n_adr, mipscpu.r[ INS_RT( mipscpu.op ) ] );
2098                  program_write_word_32le( n_adr + 1, mipscpu.r[ INS_RT( mipscpu.op ) ] >> 8 );
2099                  break;
2100               case 2:
2101                  program_write_word_32le( n_adr, mipscpu.r[ INS_RT( mipscpu.op ) ] );
2102                  break;
2103               case 3:
2104                  program_write_byte_32le( n_adr, mipscpu.r[ INS_RT( mipscpu.op ) ] );
2105                  break;
2745                  mips_breakpoint_exception();
21062746               }
2107               mips_advance_pc();
2747               else if( mipscpu.berr )
2748               {
2749                  mips_store_bus_error_exception();
2750               }
2751               else
2752               {
2753                  mips_advance_pc();
2754               }
21082755            }
21092756         }
21102757         break;
2758
2759      case OP_LWC0:
2760         mips_lwc( 0, SR_CU0 );
2761         break;
2762
21112763      case OP_LWC1:
2112         /* todo: */
2113         logerror( "%08x: COP1 LWC not supported\n", mipscpu.pc );
2114         mips_stop();
2115         mips_advance_pc();
2764         mips_lwc( 1, SR_CU1 );
21162765         break;
2766
21172767      case OP_LWC2:
2118         if( ( mipscpu.cp0r[ CP0_SR ] & SR_CU2 ) == 0 )
2119         {
2120            mips_exception( EXC_CPU );
2121            mips_set_cp0r( CP0_CAUSE, ( mipscpu.cp0r[ CP0_CAUSE ] & ~CAUSE_CE ) | CAUSE_CE2 );
2122         }
2123         else if( ( mipscpu.cp0r[ CP0_SR ] & SR_ISC ) != 0 )
2124         {
2125            /* todo: */
2126            logerror( "%08x: LWC2 SR_ISC not supported\n", mipscpu.pc );
2127            mips_stop();
2128            mips_advance_pc();
2129         }
2130         else
2131         {
2132            UINT32 n_adr;
2133            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2134            if( ( n_adr & ( ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) | 3 ) ) != 0 )
2135            {
2136               mips_exception( EXC_ADEL );
2137               mips_set_cp0r( CP0_BADVADDR, n_adr );
2138            }
2139            else
2140            {
2141               /* todo: delay? */
2142               setcp2dr( INS_RT( mipscpu.op ), program_read_dword_32le( n_adr ) );
2143               mips_advance_pc();
2144            }
2145         }
2768         mips_lwc( 2, SR_CU2 );
21462769         break;
2770
2771      case OP_LWC3:
2772         mips_lwc( 3, SR_CU3 );
2773         break;
2774
2775      case OP_SWC0:
2776         mips_swc( 0, SR_CU0 );
2777         break;
2778
21472779      case OP_SWC1:
2148         /* todo: */
2149         logerror( "%08x: COP1 SWC not supported\n", mipscpu.pc );
2150         mips_stop();
2151         mips_advance_pc();
2780         mips_swc( 1, SR_CU1 );
21522781         break;
2782
21532783      case OP_SWC2:
2154         if( ( mipscpu.cp0r[ CP0_SR ] & SR_CU2 ) == 0 )
2155         {
2156            mips_exception( EXC_CPU );
2157            mips_set_cp0r( CP0_CAUSE, ( mipscpu.cp0r[ CP0_CAUSE ] & ~CAUSE_CE ) | CAUSE_CE2 );
2158         }
2159         else if( ( mipscpu.cp0r[ CP0_SR ] & SR_ISC ) != 0 )
2160         {
2161            /* todo: */
2162            logerror( "%08x: SWC2 SR_ISC not supported\n", mipscpu.pc );
2163            mips_stop();
2164            mips_advance_pc();
2165         }
2166         else
2167         {
2168            UINT32 n_adr;
2169            n_adr = mipscpu.r[ INS_RS( mipscpu.op ) ] + MIPS_WORD_EXTEND( INS_IMMEDIATE( mipscpu.op ) );
2170            if( ( n_adr & ( ( ( mipscpu.cp0r[ CP0_SR ] & SR_KUC ) << 30 ) | 3 ) ) != 0 )
2171            {
2172               mips_exception( EXC_ADES );
2173               mips_set_cp0r( CP0_BADVADDR, n_adr );
2174            }
2175            else
2176            {
2177               program_write_dword_32le( n_adr, getcp2dr( INS_RT( mipscpu.op ) ) );
2178               mips_advance_pc();
2179            }
2180         }
2784         mips_swc( 2, SR_CU2 );
21812785         break;
2786
2787      case OP_SWC3:
2788         mips_swc( 3, SR_CU3 );
2789         break;
2790
21822791      default:
21832792         logerror( "%08x: unknown opcode %08x\n", mipscpu.pc, mipscpu.op );
21842793         mips_stop();
r2375r2376
22172826   case MIPS_IRQ0:
22182827      ip = CAUSE_IP2;
22192828      break;
2829
22202830   case MIPS_IRQ1:
22212831      ip = CAUSE_IP3;
22222832      break;
2833
22232834   case MIPS_IRQ2:
22242835      ip = CAUSE_IP4;
22252836      break;
2837
22262838   case MIPS_IRQ3:
22272839      ip = CAUSE_IP5;
22282840      break;
2841
22292842   case MIPS_IRQ4:
22302843      ip = CAUSE_IP6;
22312844      break;
2845
22322846   case MIPS_IRQ5:
22332847      ip = CAUSE_IP7;
22342848      break;
2849
22352850   default:
22362851      return;
22372852   }
r2375r2376
22412856   case CLEAR_LINE:
22422857      mips_set_cp0r( CP0_CAUSE, mipscpu.cp0r[ CP0_CAUSE ] & ~ip );
22432858      break;
2859
22442860   case ASSERT_LINE:
22452861      mips_set_cp0r( CP0_CAUSE, mipscpu.cp0r[ CP0_CAUSE ] |= ip );
2862
22462863      if( mipscpu.irq_callback )
22472864      {
22482865         /* HOLD_LINE interrupts are not supported by the architecture.
r2375r2376
22572874   }
22582875}
22592876
2877static READ32_HANDLER( psx_biu_r )
2878{
2879   return mipscpu.biu;
2880}
2881
2882static WRITE32_HANDLER( psx_biu_w )
2883{
2884   UINT32 old = mipscpu.biu;
2885
2886   COMBINE_DATA( &mipscpu.biu );
2887
2888   if( ( old & ( BIU_RAM | BIU_DS ) ) != ( mipscpu.biu & ( BIU_RAM | BIU_DS ) ) )
2889   {
2890      mips_update_scratchpad();
2891   }
2892}
2893
2894// On-board RAM and peripherals
2895static ADDRESS_MAP_START( psxcpu_internal_map, ADDRESS_SPACE_PROGRAM, 32 )
2896   AM_RANGE(0x00800000, 0x1effffff) AM_READWRITE(psx_berr_r, psx_berr_w)
2897   AM_RANGE(0x1f800400, 0x1f800fff) AM_READWRITE(psx_berr_r, psx_berr_w)
2898   AM_RANGE(0x20000000, 0x7fffffff) AM_READWRITE(psx_berr_r, psx_berr_w)
2899   AM_RANGE(0x80800000, 0x9effffff) AM_READWRITE(psx_berr_r, psx_berr_w)
2900   AM_RANGE(0xa0800000, 0xbeffffff) AM_READWRITE(psx_berr_r, psx_berr_w)
2901   AM_RANGE(0xc0000000, 0xfffdffff) AM_READWRITE(psx_berr_r, psx_berr_w)
2902   AM_RANGE(0xfffe0130, 0xfffe0133) AM_READWRITE(psx_biu_r, psx_biu_w)
2903ADDRESS_MAP_END
2904
2905static ADDRESS_MAP_START( cxd8661r_internal_map, ADDRESS_SPACE_PROGRAM, 32 )
2906   AM_RANGE(0x01000000, 0x1effffff) AM_READWRITE(psx_berr_r, psx_berr_w)
2907   AM_RANGE(0x1f800400, 0x1f800fff) AM_READWRITE(psx_berr_r, psx_berr_w)
2908   AM_RANGE(0x20000000, 0x7fffffff) AM_READWRITE(psx_berr_r, psx_berr_w)
2909   AM_RANGE(0x81000000, 0x9effffff) AM_READWRITE(psx_berr_r, psx_berr_w)
2910   AM_RANGE(0xa1000000, 0xbeffffff) AM_READWRITE(psx_berr_r, psx_berr_w)
2911   AM_RANGE(0xc0000000, 0xfffdffff) AM_READWRITE(psx_berr_r, psx_berr_w)
2912   AM_RANGE(0xfffe0130, 0xfffe0133) AM_READWRITE(psx_biu_r, psx_biu_w)
2913ADDRESS_MAP_END
2914
22602915/****************************************************************************
22612916 * Return a formatted string for a register
22622917 ****************************************************************************/
r2375r2376
22682923}
22692924#endif /* ENABLE_DEBUGGER */
22702925
2926
2927static UINT32 getcp1dr( int reg )
2928{
2929   /* if a mtc/ctc precedes then this will get the value moved (which cop1 register is irrelevant). */
2930   /* if a mfc/cfc follows then it will get the same value as this one. */
2931   return program_read_dword_32le( mipscpu.pc + 4 );
2932}
2933
2934static void setcp1dr( int reg, UINT32 value )
2935{
2936}
2937
2938static UINT32 getcp1cr( int reg )
2939{
2940   /* if a mtc/ctc precedes then this will get the value moved (which cop1 register is irrelevant). */
2941   /* if a mfc/cfc follows then it will get the same value as this one. */
2942   return program_read_dword_32le( mipscpu.pc + 4 );
2943}
2944
2945static void setcp1cr( int reg, UINT32 value )
2946{
2947}
2948
2949
2950static UINT32 getcp3dr( int reg )
2951{
2952   /* if you have mtc/ctc with an mfc/cfc directly afterwards then you get the value that was moved. */
2953   /* if you have an lwc with an mfc/cfc somewhere after it then you get the value that is loaded */
2954   /* otherwise you get the next opcode. which register you transfer to or from is irrelevant. */
2955   return program_read_dword_32le( mipscpu.pc + 4 );
2956}
2957
2958static void setcp3dr( int reg, UINT32 value )
2959{
2960}
2961
2962static UINT32 getcp3cr( int reg )
2963{
2964   /* if you have mtc/ctc with an mfc/cfc directly afterwards then you get the value that was moved. */
2965   /* if you have an lwc with an mfc/cfc somewhere after it then you get the value that is loaded */
2966   /* otherwise you get the next opcode. which register you transfer to or from is irrelevant. */
2967   return program_read_dword_32le( mipscpu.pc + 4 );
2968}
2969
2970static void setcp3cr( int reg, UINT32 value )
2971{
2972}
2973
2974
22712975/* preliminary gte code */
22722976
22732977#define VXY0 ( mipscpu.cp2dr[ 0 ].d )
r2375r2376
23813085#define ZSF4 ( mipscpu.cp2cr[ 30 ].w.l )
23823086#define FLAG ( mipscpu.cp2cr[ 31 ].d )
23833087
2384static UINT32 getcp2dr( int n_reg )
3088INLINE INT32 LIM( INT32 value, INT32 max, INT32 min, UINT32 flag )
23853089{
2386   if( n_reg == 1 || n_reg == 3 || n_reg == 5 || n_reg == 8 || n_reg == 9 || n_reg == 10 || n_reg == 11 )
3090   if( value > max )
23873091   {
2388      mipscpu.cp2dr[ n_reg ].d = (INT32)(INT16)mipscpu.cp2dr[ n_reg ].d;
3092      FLAG |= flag;
3093      return max;
23893094   }
2390   else if( n_reg == 17 || n_reg == 18 || n_reg == 19 )
3095   else if( value < min )
23913096   {
2392      mipscpu.cp2dr[ n_reg ].d = (UINT32)(UINT16)mipscpu.cp2dr[ n_reg ].d;
3097      FLAG |= flag;
3098      return min;
23933099   }
2394   else if( n_reg == 29 )
3100   return value;
3101}
3102
3103static UINT32 getcp2dr( int reg )
3104{
3105   switch( reg )
23953106   {
2396      ORGB = ( ( IR1 >> 7 ) & 0x1f ) | ( ( IR2 >> 2 ) & 0x3e0 ) | ( ( IR3 << 3 ) & 0x7c00 );
3107   case 1:
3108   case 3:
3109   case 5:
3110   case 8:
3111   case 9:
3112   case 10:
3113   case 11:
3114      mipscpu.cp2dr[ reg ].d = (INT32)(INT16)mipscpu.cp2dr[ reg ].d;
3115      break;
3116
3117   case 7:
3118   case 16:
3119   case 17:
3120   case 18:
3121   case 19:
3122      mipscpu.cp2dr[ reg ].d = (UINT32)(UINT16)mipscpu.cp2dr[ reg ].d;
3123      break;
3124
3125   case 15:
3126      mipscpu.cp2dr[ reg ].d = SXY2;
3127      break;
3128
3129   case 28:
3130   case 29:
3131      mipscpu.cp2dr[ reg ].d = LIM( (INT16)IR1 >> 7, 0x1f, 0, 0 ) | ( LIM( (INT16)IR2 >> 7, 0x1f, 0, 0 ) << 5 ) | ( LIM( (INT16)IR3 >> 7, 0x1f, 0, 0 ) << 10 );
3132      break;
23973133   }
2398   GTELOG( "get CP2DR%u=%08x", n_reg, mipscpu.cp2dr[ n_reg ].d );
2399   return mipscpu.cp2dr[ n_reg ].d;
3134
3135   GTELOG( "get CP2DR%u=%08x", reg, mipscpu.cp2dr[ reg ].d );
3136   return mipscpu.cp2dr[ reg ].d;
24003137}
24013138
2402static void setcp2dr( int n_reg, UINT32 n_value )
3139static void setcp2dr( int reg, UINT32 value )
24033140{
2404   GTELOG( "set CP2DR%u=%08x", n_reg, n_value );
2405   mipscpu.cp2dr[ n_reg ].d = n_value;
3141   GTELOG( "set CP2DR%u=%08x", reg, value );
24063142
2407   if( n_reg == 15 )
3143   switch( reg )
24083144   {
3145   case 15:
24093146      SXY0 = SXY1;
24103147      SXY1 = SXY2;
2411      SXY2 = SXYP;
2412   }
2413   else if( n_reg == 28 )
3148      SXY2 = value;
3149      break;
3150
3151   case 28:
3152      IR1 = ( value & 0x1f ) << 7;
3153      IR2 = ( value & 0x3e0 ) << 2;
3154      IR3 = ( value & 0x7c00 ) >> 3;
3155      break;
3156
3157   case 30:
24143158   {
2415      IR1 = ( IRGB & 0x1f ) << 4;
2416      IR2 = ( IRGB & 0x3e0 ) >> 1;
2417      IR3 = ( IRGB & 0x7c00 ) >> 6;
2418   }
2419   else if( n_reg == 30 )
2420   {
2421      UINT32 n_lzcs = LZCS;
2422      UINT32 n_lzcr = 0;
3159      UINT32 lzcs = value;
3160      UINT32 lzcr = 0;
24233161
2424      if( ( n_lzcs & 0x80000000 ) == 0 )
3162      if( ( lzcs & 0x80000000 ) == 0 )
24253163      {
2426         n_lzcs = ~n_lzcs;
3164         lzcs = ~lzcs;
24273165      }
2428      while( ( n_lzcs & 0x80000000 ) != 0 )
3166      while( ( lzcs & 0x80000000 ) != 0 )
24293167      {
2430         n_lzcr++;
2431         n_lzcs <<= 1;
3168         lzcr++;
3169         lzcs <<= 1;
24323170      }
2433      LZCR = n_lzcr;
3171      LZCR = lzcr;
3172      break;
24343173   }
3174
3175   case 31:
3176      value = mipscpu.cp2dr[ reg ].d;
3177      break;
3178   }
3179
3180   mipscpu.cp2dr[ reg ].d = value;
24353181}
24363182
2437static UINT32 getcp2cr( int n_reg )
3183static UINT32 getcp2cr( int reg )
24383184{
2439   GTELOG( "get CP2CR%u=%08x", n_reg, mipscpu.cp2cr[ n_reg ].d );
2440   return mipscpu.cp2cr[ n_reg ].d;
3185   GTELOG( "get CP2CR%u=%08x", reg, mipscpu.cp2cr[ reg ].d );
3186
3187   return mipscpu.cp2cr[ reg ].d;
24413188}
24423189
2443static void setcp2cr( int n_reg, UINT32 n_value )
3190static void setcp2cr( int reg, UINT32 value )
24443191{
2445   GTELOG( "set CP2CR%u=%08x", n_reg, n_value );
2446   mipscpu.cp2cr[ n_reg ].d = n_value;
2447}
3192   GTELOG( "set CP2CR%u=%08x", reg, value );
24483193
2449INLINE INT32 LIM( INT32 n_value, INT32 n_max, INT32 n_min, UINT32 n_flag )
2450{
2451   if( n_value > n_max )
3194   switch( reg )
24523195   {
2453      FLAG |= n_flag;
2454      return n_max;
3196   case 4:
3197   case 12:
3198   case 20:
3199   case 26:
3200   case 27:
3201   case 29:
3202   case 30:
3203      value = (INT32)(INT16) value;
3204      break;
3205
3206   case 31:
3207      value = ( mipscpu.cp2cr[ reg ].d & 0x80000fff ) | ( value & ~0x80000fff );
3208      break;
24553209   }
2456   else if( n_value < n_min )
2457   {
2458      FLAG |= n_flag;
2459      return n_min;
2460   }
2461   return n_value;
3210
3211   mipscpu.cp2cr[ reg ].d = value;
24623212}
24633213
24643214INLINE INT64 BOUNDS( INT64 n_value, INT64 n_max, int n_maxflag, INT64 n_min, int n_minflag )
24653215{
24663216   if( n_value > n_max )
24673217   {
2468      FLAG |= 1 << n_maxflag;
3218      FLAG |= n_maxflag;
24693219   }
24703220   else if( n_value < n_min )
24713221   {
2472      FLAG |= 1 << n_minflag;
3222      FLAG |= n_minflag;
24733223   }
24743224   return n_value;
24753225}
24763226
2477#define A1( a ) BOUNDS( ( a ), 0x7fffffff, 30, -(INT64)0x80000000, 27 )
2478#define A2( a ) BOUNDS( ( a ), 0x7fffffff, 29, -(INT64)0x80000000, 26 )
2479#define A3( a ) BOUNDS( ( a ), 0x7fffffff, 28, -(INT64)0x80000000, 25 )
3227#define A1( a ) BOUNDS( ( a ), 0x7fffffff, ( 1 << 30 ), -(INT64)0x80000000, ( 1 << 27 ) )
3228#define A2( a ) BOUNDS( ( a ), 0x7fffffff, ( 1 << 29 ), -(INT64)0x80000000, ( 1 << 26 ) )
3229#define A3( a ) BOUNDS( ( a ), 0x7fffffff, ( 1 << 28 ), -(INT64)0x80000000, ( 1 << 25 ) )
24803230#define Lm_B1( a, l ) LIM( ( a ), 0x7fff, -0x8000 * !l, ( 1 << 31 ) | ( 1 << 24 ) )
24813231#define Lm_B2( a, l ) LIM( ( a ), 0x7fff, -0x8000 * !l, ( 1 << 31 ) | ( 1 << 23 ) )
24823232#define Lm_B3( a, l ) LIM( ( a ), 0x7fff, -0x8000 * !l, ( 1 << 31 ) | ( 1 << 22 ) )
r2375r2376
25303280   static const UINT32 *const p_n_fc[] = { &RFC, &GFC, &BFC };
25313281   static const UINT32 *const p_n_zc[] = { &n_zc, &n_zc, &n_zc };
25323282   static const UINT32 *const *const p_p_n_cv[] = { p_n_tr, p_n_bk, p_n_fc, p_n_zc };
3283   INT64 mac0;
25333284
25343285   switch( GTE_FUNCT( gteop ) )
25353286   {
r2375r2376
29753726         return;
29763727      }
29773728      break;
3729
29783730   case 0x2d:
2979      if( gteop == 0x158002d )
2980      {
2981         GTELOG( "AVSZ3" );
2982         FLAG = 0;
3731      GTELOG( "AVSZ3" );
3732      FLAG = 0;
29833733
2984         MAC0 = F( ( (INT64)(INT16)ZSF3 * SZ1 ) + ( (INT16)ZSF3 * SZ2 ) + ( (INT16)ZSF3 * SZ3 ) );
2985         OTZ = Lm_D( (INT32)MAC0 >> 12 );
2986         return;
2987      }
2988      break;
3734      mac0 = F( (INT64)( ZSF3 * SZ1 ) + ( ZSF3 * SZ2 ) + ( ZSF3 * SZ3 ) );
3735      OTZ = Lm_D( mac0 >> 12 );
3736
3737      MAC0 = mac0;
3738      return;
3739
29893740   case 0x2e:
2990      if( gteop == 0x168002e )
2991      {
2992         GTELOG( "AVSZ4" );
2993         FLAG = 0;
3741      GTELOG( "AVSZ4" );
3742      FLAG = 0;
29943743
2995         MAC0 = F( ( (INT64)(INT16)ZSF4 * SZ0 ) + ( (INT16)ZSF4 * SZ1 ) + ( (INT16)ZSF4 * SZ2 ) + ( (INT16)ZSF4 * SZ3 ) );
2996         OTZ = Lm_D( (INT32)MAC0 >> 12 );
2997         return;
2998      }
2999      break;
3744      mac0 = F( (INT64)( ZSF4 * SZ0 ) + ( ZSF4 * SZ1 ) + ( ZSF4 * SZ2 ) + ( ZSF4 * SZ3 ) );
3745      OTZ = Lm_D( mac0 >> 12 );
3746
3747      MAC0 = mac0;
3748      return;
3749
30003750   case 0x30:
30013751      if( gteop == 0x0280030 )
30023752      {
r2375r2376
31513901      case CPUINFO_INT_REGISTER + MIPS_PC:         mips_set_pc( info->i );               break;
31523902      case CPUINFO_INT_SP:                     /* no stack */                     break;
31533903      case CPUINFO_INT_REGISTER + MIPS_DELAYV:      mipscpu.delayv = info->i;            break;
3154      case CPUINFO_INT_REGISTER + MIPS_DELAYR:      if( info->i <= REGPC ) mipscpu.delayr = info->i; break;
3904      case CPUINFO_INT_REGISTER + MIPS_DELAYR:      if( info->i <= MIPS_DELAYR_NOTPC ) mipscpu.delayr = info->i; break;
31553905      case CPUINFO_INT_REGISTER + MIPS_HI:         mipscpu.hi = info->i;               break;
31563906      case CPUINFO_INT_REGISTER + MIPS_LO:         mipscpu.lo = info->i;               break;
3907      case CPUINFO_INT_REGISTER + MIPS_BIU:         mipscpu.biu = info->i;               break;
31573908      case CPUINFO_INT_REGISTER + MIPS_R0:         mipscpu.r[ 0 ] = info->i;            break;
31583909      case CPUINFO_INT_REGISTER + MIPS_R1:         mipscpu.r[ 1 ] = info->i;            break;
31593910      case CPUINFO_INT_REGISTER + MIPS_R2:         mipscpu.r[ 2 ] = info->i;            break;
r2375r2376
32023953      case CPUINFO_INT_REGISTER + MIPS_CP0R13:      mips_set_cp0r( 13, info->i );         break;
32033954      case CPUINFO_INT_REGISTER + MIPS_CP0R14:      mips_set_cp0r( 14, info->i );         break;
32043955      case CPUINFO_INT_REGISTER + MIPS_CP0R15:      mips_set_cp0r( 15, info->i );         break;
3205      case CPUINFO_INT_REGISTER + MIPS_CP0R16:      mips_set_cp0r( 16, info->i );         break;
3206      case CPUINFO_INT_REGISTER + MIPS_CP0R17:      mips_set_cp0r( 17, info->i );         break;
3207      case CPUINFO_INT_REGISTER + MIPS_CP0R18:      mips_set_cp0r( 18, info->i );         break;
3208      case CPUINFO_INT_REGISTER + MIPS_CP0R19:      mips_set_cp0r( 19, info->i );         break;
3209      case CPUINFO_INT_REGISTER + MIPS_CP0R20:      mips_set_cp0r( 20, info->i );         break;
3210      case CPUINFO_INT_REGISTER + MIPS_CP0R21:      mips_set_cp0r( 21, info->i );         break;
3211      case CPUINFO_INT_REGISTER + MIPS_CP0R22:      mips_set_cp0r( 22, info->i );         break;
3212      case CPUINFO_INT_REGISTER + MIPS_CP0R23:      mips_set_cp0r( 23, info->i );         break;
3213      case CPUINFO_INT_REGISTER + MIPS_CP0R24:      mips_set_cp0r( 24, info->i );         break;
3214      case CPUINFO_INT_REGISTER + MIPS_CP0R25:      mips_set_cp0r( 25, info->i );         break;
3215      case CPUINFO_INT_REGISTER + MIPS_CP0R26:      mips_set_cp0r( 26, info->i );         break;
3216      case CPUINFO_INT_REGISTER + MIPS_CP0R27:      mips_set_cp0r( 27, info->i );         break;
3217      case CPUINFO_INT_REGISTER + MIPS_CP0R28:      mips_set_cp0r( 28, info->i );         break;
3218      case CPUINFO_INT_REGISTER + MIPS_CP0R29:      mips_set_cp0r( 29, info->i );         break;
3219      case CPUINFO_INT_REGISTER + MIPS_CP0R30:      mips_set_cp0r( 30, info->i );         break;
3220      case CPUINFO_INT_REGISTER + MIPS_CP0R31:      mips_set_cp0r( 31, info->i );         break;
32213956      case CPUINFO_INT_REGISTER + MIPS_CP2DR0:      mipscpu.cp2dr[ 0 ].d = info->i;         break;
32223957      case CPUINFO_INT_REGISTER + MIPS_CP2DR1:      mipscpu.cp2dr[ 1 ].d = info->i;         break;
32233958      case CPUINFO_INT_REGISTER + MIPS_CP2DR2:      mipscpu.cp2dr[ 2 ].d = info->i;         break;
r2375r2376
33374072      case CPUINFO_INT_REGISTER + MIPS_DELAYR:      info->i = mipscpu.delayr;            break;
33384073      case CPUINFO_INT_REGISTER + MIPS_HI:         info->i = mipscpu.hi;               break;
33394074      case CPUINFO_INT_REGISTER + MIPS_LO:         info->i = mipscpu.lo;               break;
4075      case CPUINFO_INT_REGISTER + MIPS_BIU:         info->i = mipscpu.biu;               break;
33404076      case CPUINFO_INT_REGISTER + MIPS_R0:         info->i = mipscpu.r[ 0 ];            break;
33414077      case CPUINFO_INT_REGISTER + MIPS_R1:         info->i = mipscpu.r[ 1 ];            break;
33424078      case CPUINFO_INT_REGISTER + MIPS_R2:         info->i = mipscpu.r[ 2 ];            break;
r2375r2376
33854121      case CPUINFO_INT_REGISTER + MIPS_CP0R13:      info->i = mipscpu.cp0r[ 13 ];         break;
33864122      case CPUINFO_INT_REGISTER + MIPS_CP0R14:      info->i = mipscpu.cp0r[ 14 ];         break;
33874123      case CPUINFO_INT_REGISTER + MIPS_CP0R15:      info->i = mipscpu.cp0r[ 15 ];         break;
3388      case CPUINFO_INT_REGISTER + MIPS_CP0R16:      info->i = mipscpu.cp0r[ 16 ];         break;
3389      case CPUINFO_INT_REGISTER + MIPS_CP0R17:      info->i = mipscpu.cp0r[ 17 ];         break;
3390      case CPUINFO_INT_REGISTER + MIPS_CP0R18:      info->i = mipscpu.cp0r[ 18 ];         break;
3391      case CPUINFO_INT_REGISTER + MIPS_CP0R19:      info->i = mipscpu.cp0r[ 19 ];         break;
3392      case CPUINFO_INT_REGISTER + MIPS_CP0R20:      info->i = mipscpu.cp0r[ 20 ];         break;
3393      case CPUINFO_INT_REGISTER + MIPS_CP0R21:      info->i = mipscpu.cp0r[ 21 ];         break;
3394      case CPUINFO_INT_REGISTER + MIPS_CP0R22:      info->i = mipscpu.cp0r[ 22 ];         break;
3395      case CPUINFO_INT_REGISTER + MIPS_CP0R23:      info->i = mipscpu.cp0r[ 23 ];         break;
3396      case CPUINFO_INT_REGISTER + MIPS_CP0R24:      info->i = mipscpu.cp0r[ 24 ];         break;
3397      case CPUINFO_INT_REGISTER + MIPS_CP0R25:      info->i = mipscpu.cp0r[ 25 ];         break;
3398      case CPUINFO_INT_REGISTER + MIPS_CP0R26:      info->i = mipscpu.cp0r[ 26 ];         break;
3399      case CPUINFO_INT_REGISTER + MIPS_CP0R27:      info->i = mipscpu.cp0r[ 27 ];         break;
3400      case CPUINFO_INT_REGISTER + MIPS_CP0R28:      info->i = mipscpu.cp0r[ 28 ];         break;
3401      case CPUINFO_INT_REGISTER + MIPS_CP0R29:      info->i = mipscpu.cp0r[ 29 ];         break;
3402      case CPUINFO_INT_REGISTER + MIPS_CP0R30:      info->i = mipscpu.cp0r[ 30 ];         break;
3403      case CPUINFO_INT_REGISTER + MIPS_CP0R31:      info->i = mipscpu.cp0r[ 31 ];         break;
34044124      case CPUINFO_INT_REGISTER + MIPS_CP2DR0:      info->i = mipscpu.cp2dr[ 0 ].d;         break;
34054125      case CPUINFO_INT_REGISTER + MIPS_CP2DR1:      info->i = mipscpu.cp2dr[ 1 ].d;         break;
34064126      case CPUINFO_INT_REGISTER + MIPS_CP2DR2:      info->i = mipscpu.cp2dr[ 2 ].d;         break;
r2375r2376
34804200#endif /* ENABLE_DEBUGGER */
34814201      case CPUINFO_PTR_INSTRUCTION_COUNTER:         info->icount = &mips_ICount;         break;
34824202
4203      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map32 = address_map_psxcpu_internal_map; break;
4204      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA:    info->internal_map32 = 0; break;
4205      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_IO:      info->internal_map32 = 0; break;
4206
34834207      /* --- the following bits of info are returned as NULL-terminated strings --- */
3484      case CPUINFO_STR_NAME:                     strcpy(info->s, "PSX CPU");            break;
3485      case CPUINFO_STR_CORE_FAMILY:               strcpy(info->s, "mipscpu");            break;
3486      case CPUINFO_STR_CORE_VERSION:               strcpy(info->s, "1.5");               break;
3487      case CPUINFO_STR_CORE_FILE:                  strcpy(info->s, __FILE__);            break;
3488      case CPUINFO_STR_CORE_CREDITS:               strcpy(info->s, "Copyright smf");      break;
4208      case CPUINFO_STR_NAME:                     strcpy(info->s, "PSX CPU"); break;
4209      case CPUINFO_STR_CORE_FAMILY:               strcpy(info->s, "MIPS"); break;
4210      case CPUINFO_STR_CORE_VERSION:               strcpy(info->s, "2.0"); break;
4211      case CPUINFO_STR_CORE_FILE:                  strcpy(info->s, __FILE__); break;
4212      case CPUINFO_STR_CORE_CREDITS:               strcpy(info->s, "Copyright 2008 smf"); break;
34894213
3490      case CPUINFO_STR_FLAGS:                     strcpy(info->s, " ");               break;
4214      case CPUINFO_STR_FLAGS:                     strcpy(info->s, " "); break;
34914215
34924216      case CPUINFO_STR_REGISTER + MIPS_PC:         sprintf( info->s, "pc      :%08x", mipscpu.pc ); break;
3493      case CPUINFO_STR_REGISTER + MIPS_DELAYV:      sprintf( info->s, "delay   :%08x", mipscpu.delayv ); break;
3494      case CPUINFO_STR_REGISTER + MIPS_DELAYR:      sprintf( info->s, "delay %s:%02x", delayn[ mipscpu.delayr ], mipscpu.delayr ); break;
4217      case CPUINFO_STR_REGISTER + MIPS_DELAYV:      sprintf( info->s, "delayv  :%08x", mipscpu.delayv ); break;
4218      case CPUINFO_STR_REGISTER + MIPS_DELAYR:      sprintf( info->s, "delayr  :%02x %s", mipscpu.delayr, delayn[ mipscpu.delayr ] ); break;
34954219      case CPUINFO_STR_REGISTER + MIPS_HI:         sprintf( info->s, "hi      :%08x", mipscpu.hi ); break;
34964220      case CPUINFO_STR_REGISTER + MIPS_LO:         sprintf( info->s, "lo      :%08x", mipscpu.lo ); break;
4221      case CPUINFO_STR_REGISTER + MIPS_BIU:         sprintf( info->s, "biu     :%08x", mipscpu.biu ); break;
34974222      case CPUINFO_STR_REGISTER + MIPS_R0:         sprintf( info->s, "zero    :%08x", mipscpu.r[ 0 ] ); break;
34984223      case CPUINFO_STR_REGISTER + MIPS_R1:         sprintf( info->s, "at      :%08x", mipscpu.r[ 1 ] ); break;
34994224      case CPUINFO_STR_REGISTER + MIPS_R2:         sprintf( info->s, "v0      :%08x", mipscpu.r[ 2 ] ); break;
r2375r2376
35264251      case CPUINFO_STR_REGISTER + MIPS_R29:         sprintf( info->s, "sp      :%08x", mipscpu.r[ 29 ] ); break;
35274252      case CPUINFO_STR_REGISTER + MIPS_R30:         sprintf( info->s, "fp      :%08x", mipscpu.r[ 30 ] ); break;
35284253      case CPUINFO_STR_REGISTER + MIPS_R31:         sprintf( info->s, "ra      :%08x", mipscpu.r[ 31 ] ); break;
3529      case CPUINFO_STR_REGISTER + MIPS_CP0R0:         sprintf( info->s, "Index   :%08x", mipscpu.cp0r[ 0 ] ); break;
3530      case CPUINFO_STR_REGISTER + MIPS_CP0R1:         sprintf( info->s, "Random  :%08x", mipscpu.cp0r[ 1 ] ); break;
3531      case CPUINFO_STR_REGISTER + MIPS_CP0R2:         sprintf( info->s, "EntryLo :%08x", mipscpu.cp0r[ 2 ] ); break;
3532      case CPUINFO_STR_REGISTER + MIPS_CP0R3:         sprintf( info->s, "cp0r3   :%08x", mipscpu.cp0r[ 3 ] ); break;
3533      case CPUINFO_STR_REGISTER + MIPS_CP0R4:         sprintf( info->s, "Context :%08x", mipscpu.cp0r[ 4 ] ); break;
3534      case CPUINFO_STR_REGISTER + MIPS_CP0R5:         sprintf( info->s, "cp0r5   :%08x", mipscpu.cp0r[ 5 ] ); break;
3535      case CPUINFO_STR_REGISTER + MIPS_CP0R6:         sprintf( info->s, "cp0r6   :%08x", mipscpu.cp0r[ 6 ] ); break;
3536      case CPUINFO_STR_REGISTER + MIPS_CP0R7:         sprintf( info->s, "cp0r7   :%08x", mipscpu.cp0r[ 7 ] ); break;
3537      case CPUINFO_STR_REGISTER + MIPS_CP0R8:         sprintf( info->s, "BadVAddr:%08x", mipscpu.cp0r[ 8 ] ); break;
3538      case CPUINFO_STR_REGISTER + MIPS_CP0R9:         sprintf( info->s, "cp0r9   :%08x", mipscpu.cp0r[ 9 ] ); break;
3539      case CPUINFO_STR_REGISTER + MIPS_CP0R10:      sprintf( info->s, "EntryHi :%08x", mipscpu.cp0r[ 10 ] ); break;
3540      case CPUINFO_STR_REGISTER + MIPS_CP0R11:      sprintf( info->s, "cp0r11  :%08x", mipscpu.cp0r[ 11 ] ); break;
4254      case CPUINFO_STR_REGISTER + MIPS_CP0R0:         sprintf( info->s, "!Index  :%08x", mipscpu.cp0r[ 0 ] ); break;
4255      case CPUINFO_STR_REGISTER + MIPS_CP0R1:         sprintf( info->s, "!Random :%08x", mipscpu.cp0r[ 1 ] ); break;
4256      case CPUINFO_STR_REGISTER + MIPS_CP0R2:         sprintf( info->s, "!EntryLo:%08x", mipscpu.cp0r[ 2 ] ); break;
4257      case CPUINFO_STR_REGISTER + MIPS_CP0R3:         sprintf( info->s, "BPC     :%08x", mipscpu.cp0r[ 3 ] ); break;
4258      case CPUINFO_STR_REGISTER + MIPS_CP0R4:         sprintf( info->s, "!Context:%08x", mipscpu.cp0r[ 4 ] ); break;
4259      case CPUINFO_STR_REGISTER + MIPS_CP0R5:         sprintf( info->s, "BDA     :%08x", mipscpu.cp0r[ 5 ] ); break;
4260      case CPUINFO_STR_REGISTER + MIPS_CP0R6:         sprintf( info->s, "TAR     :%08x", mipscpu.cp0r[ 6 ] ); break;
4261      case CPUINFO_STR_REGISTER + MIPS_CP0R7:         sprintf( info->s, "DCIC    :%08x", mipscpu.cp0r[ 7 ] ); break;
4262      case CPUINFO_STR_REGISTER + MIPS_CP0R8:         sprintf( info->s, "BadA    :%08x", mipscpu.cp0r[ 8 ] ); break;
4263      case CPUINFO_STR_REGISTER + MIPS_CP0R9:         sprintf( info->s, "BDAM    :%08x", mipscpu.cp0r[ 9 ] ); break;
4264      case CPUINFO_STR_REGISTER + MIPS_CP0R10:      sprintf( info->s, "!EntryHi:%08x", mipscpu.cp0r[ 10 ] ); break;
4265      case CPUINFO_STR_REGISTER + MIPS_CP0R11:      sprintf( info->s, "BPCM    :%08x", mipscpu.cp0r[ 11 ] ); break;
35414266      case CPUINFO_STR_REGISTER + MIPS_CP0R12:      sprintf( info->s, "SR      :%08x", mipscpu.cp0r[ 12 ] ); break;
35424267      case CPUINFO_STR_REGISTER + MIPS_CP0R13:      sprintf( info->s, "Cause   :%08x", mipscpu.cp0r[ 13 ] ); break;
35434268      case CPUINFO_STR_REGISTER + MIPS_CP0R14:      sprintf( info->s, "EPC     :%08x", mipscpu.cp0r[ 14 ] ); break;
35444269      case CPUINFO_STR_REGISTER + MIPS_CP0R15:      sprintf( info->s, "PRId    :%08x", mipscpu.cp0r[ 15 ] ); break;
3545      case CPUINFO_STR_REGISTER + MIPS_CP0R16:      sprintf( info->s, "cp0r16  :%08x", mipscpu.cp0r[ 16 ] ); break;
3546      case CPUINFO_STR_REGISTER + MIPS_CP0R17:      sprintf( info->s, "cp0r17  :%08x", mipscpu.cp0r[ 17 ] ); break;
3547      case CPUINFO_STR_REGISTER + MIPS_CP0R18:      sprintf( info->s, "cp0r18  :%08x", mipscpu.cp0r[ 18 ] ); break;
3548      case CPUINFO_STR_REGISTER + MIPS_CP0R19:      sprintf( info->s, "cp0r19  :%08x", mipscpu.cp0r[ 19 ] ); break;
3549      case CPUINFO_STR_REGISTER + MIPS_CP0R20:      sprintf( info->s, "cp0r20  :%08x", mipscpu.cp0r[ 20 ] ); break;
3550      case CPUINFO_STR_REGISTER + MIPS_CP0R21:      sprintf( info->s, "cp0r21  :%08x", mipscpu.cp0r[ 21 ] ); break;
3551      case CPUINFO_STR_REGISTER + MIPS_CP0R22:      sprintf( info->s, "cp0r22  :%08x", mipscpu.cp0r[ 22 ] ); break;
3552      case CPUINFO_STR_REGISTER + MIPS_CP0R23:      sprintf( info->s, "cp0r23  :%08x", mipscpu.cp0r[ 23 ] ); break;
3553      case CPUINFO_STR_REGISTER + MIPS_CP0R24:      sprintf( info->s, "cp0r24  :%08x", mipscpu.cp0r[ 24 ] ); break;
3554      case CPUINFO_STR_REGISTER + MIPS_CP0R25:      sprintf( info->s, "cp0r25  :%08x", mipscpu.cp0r[ 25 ] ); break;
3555      case CPUINFO_STR_REGISTER + MIPS_CP0R26:      sprintf( info->s, "cp0r26  :%08x", mipscpu.cp0r[ 26 ] ); break;
3556      case CPUINFO_STR_REGISTER + MIPS_CP0R27:      sprintf( info->s, "cp0r27  :%08x", mipscpu.cp0r[ 27 ] ); break;
3557      case CPUINFO_STR_REGISTER + MIPS_CP0R28:      sprintf( info->s, "cp0r28  :%08x", mipscpu.cp0r[ 28 ] ); break;
3558      case CPUINFO_STR_REGISTER + MIPS_CP0R29:      sprintf( info->s, "cp0r29  :%08x", mipscpu.cp0r[ 29 ] ); break;
3559      case CPUINFO_STR_REGISTER + MIPS_CP0R30:      sprintf( info->s, "cp0r30  :%08x", mipscpu.cp0r[ 30 ] ); break;
3560      case CPUINFO_STR_REGISTER + MIPS_CP0R31:      sprintf( info->s, "cp0r31  :%08x", mipscpu.cp0r[ 31 ] ); break;
35614270      case CPUINFO_STR_REGISTER + MIPS_CP2DR0:      sprintf( info->s, "vxy0    :%08x", mipscpu.cp2dr[ 0 ].d ); break;
35624271      case CPUINFO_STR_REGISTER + MIPS_CP2DR1:      sprintf( info->s, "vz0     :%08x", mipscpu.cp2dr[ 1 ].d ); break;
35634272      case CPUINFO_STR_REGISTER + MIPS_CP2DR2:      sprintf( info->s, "vxy1    :%08x", mipscpu.cp2dr[ 2 ].d ); break;
r2375r2376
36444353   }
36454354}
36464355#endif
4356
4357#if (HAS_CXD8661R)
4358
4359void cxd8661r_get_info(UINT32 state, cpuinfo *info)
4360{
4361   switch (state)
4362   {
4363      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map32 = address_map_cxd8661r_internal_map; break;
4364
4365         /* --- the following bits of info are returned as NULL-terminated strings --- */
4366      case CPUINFO_STR_NAME:                     strcpy(info->s, "CXD8661R"); break;
4367
4368      default:
4369         mips_get_info(state, info);
4370         break;
4371   }
4372}
4373
4374#endif
src/emu/cpu/mips/mipsdasm.c
r2375r2376
3131
3232static const char *const s_cp0genreg[] =
3333{
34   "Index", "Random", "EntryLo", "cp0r3", "Context", "cp0r5", "cp0r6", "cp0r7",
35   "BadVAddr", "cp0r9", "EntryHi", "cp0r11", "SR", "Cause", "EPC", "PRId",
34   "!Index", "!Random", "!EntryLo", "BPC", "!Context", "BDA", "TAR", "DCIC",
35   "BadA", "BDAM", "!EntryHi", "BPCM", "SR", "Cause", "EPC", "PRId",
3636   "cp0r16", "cp0r17", "cp0r18", "cp0r19", "cp0r20", "cp0r21", "cp0r22", "cp0r23",
3737   "cp0r24", "cp0r25", "cp0r26", "cp0r27", "cp0r28", "cp0r29", "cp0r30", "cp0r31"
3838};
3939
40static const char *const s_cp0ctlreg[] =
41{
42   "cp0cr0", "cp0cr1", "cp0cr2", "cp0cr3", "cp0cr4", "cp0cr5", "cp0cr6", "cp0cr7",
43   "cp0cr8", "cp0cr9", "cp0cr10", "cp0cr11", "cp0cr12", "cp0cr13", "cp0cr14", "cp0cr15",
44   "cp0cr16", "cp0cr17", "cp0cr18", "cp0cr19", "cp0cr20", "cp0cr21", "cp0cr22", "cp0cr23",
45   "cp0cr24", "cp0cr25", "cp0cr26", "cp0cr27", "cp0cr28", "cp0cr29", "cp0cr30", "cp0cr31"
46};
47
4048static const char *const s_cp1genreg[] =
4149{
4250   "cp1r0", "cp1r1", "cp1r2", "cp1r3", "cp1r4", "cp1r5", "cp1r6", "cp1r7",
r2375r2376
6977   "ofx", "ofy", "h", "dqa", "dqb", "zsf3", "zsf4", "flag"
7078};
7179
80static const char *const s_cp3genreg[] =
81{
82   "cp3r0", "cp3r1", "cp3r2", "cp3r3", "cp3r4", "cp3r5", "cp3r6", "cp3r7",
83   "cp3r8", "cp3r9", "cp3r10", "cp3r11", "cp3r12", "cp3r13", "cp3r14", "cp3r15",
84   "cp3r16", "cp3r17", "cp3r18", "cp3r19", "cp3r20", "cp3r21", "cp3r22", "cp3r22",
85   "cp3r23", "cp3r24", "cp3r25", "cp3r26", "cp3r27", "cp3r28", "cp3r29", "cp3r30"
86};
87
88static const char *const s_cp3ctlreg[] =
89{
90   "cp3cr0", "cp3cr1", "cp3cr2", "cp3cr3", "cp3cr4", "cp3cr5", "cp3cr6", "cp3cr7",
91   "cp3cr8", "cp3cr9", "cp3cr10", "cp3cr11", "cp3cr12", "cp3cr13", "cp3cr14", "cp3cr15",
92   "cp3cr16", "cp3cr17", "cp3cr18", "cp3cr19", "cp3cr20", "cp3cr21", "cp3cr22", "cp3cr23",
93   "cp3cr24", "cp3cr25", "cp3cr26", "cp3cr27", "cp3cr28", "cp3cr29", "cp3cr30", "cp3cr31"
94};
95
7296static const char *const s_gtesf[] =
7397{
7498   "0", "12"
r2375r2376
94118   "0", "1"
95119};
96120
97static char *make_address( UINT32 pc, UINT32 op )
121static char *effective_address( UINT32 pc, UINT32 op )
98122{
99123   static char s_address[ 20 ];
100124#ifndef STANDALONE
r2375r2376
109133   return s_address;
110134}
111135
136static UINT32 relative_address( UINT32 pc, UINT32 op )
137{
138   UINT32 nextpc = pc + 4;
139#ifndef STANDALONE
140   if( pc == activecpu_get_pc() && activecpu_get_reg( MIPS_DELAYR ) == 32 )
141   {
142      nextpc = activecpu_get_reg( MIPS_DELAYV );
143   }
144#endif
145   return nextpc + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( op ) ) << 2 );
146}
147
148static UINT32 jump_address( UINT32 pc, UINT32 op )
149{
150   UINT32 nextpc = pc + 4;
151#ifndef STANDALONE
152   if( pc == activecpu_get_pc() && activecpu_get_reg( MIPS_DELAYR ) == 32 )
153   {
154      nextpc = activecpu_get_reg( MIPS_DELAYV );
155   }
156#endif
157   return ( nextpc & 0xf0000000 ) + ( INS_TARGET( op ) << 2 );
158}
159
160static UINT32 fetch_op( const UINT8 *opram )
161{
162   return ( opram[ 3 ] << 24 ) | ( opram[ 2 ] << 16 ) | ( opram[ 1 ] << 8 ) | ( opram[ 0 ] << 0 );
163}
164
165static char *upper_address( UINT32 op, const UINT8 *opram )
166{
167   static char s_address[ 20 ];
168   UINT32 nextop = fetch_op( opram );
169
170   if( INS_OP( nextop ) == OP_ORI && INS_RT( op ) == INS_RS( nextop ) )
171   {
172      sprintf( s_address, "$%04x ; 0x%08x", INS_IMMEDIATE( op ), ( INS_IMMEDIATE( op ) << 16 ) | INS_IMMEDIATE( nextop ) );
173   }
174   else if( INS_OP( nextop ) == OP_ADDIU && INS_RT( op ) == INS_RS( nextop ) )
175   {
176      sprintf( s_address, "$%04x ; 0x%08x", INS_IMMEDIATE( op ), ( INS_IMMEDIATE( op ) << 16 ) + (INT16) INS_IMMEDIATE( nextop ) );
177   }
178   else
179   {
180      sprintf( s_address, "$%04x", INS_IMMEDIATE( op ) );
181   }
182
183   return s_address;
184}
185
112186unsigned DasmMIPS( char *buffer, UINT32 pc, const UINT8 *opram )
113187{
114188   UINT32 op;
115189   const UINT8 *oldopram;
190   UINT32 flags = 0;
116191
117192   oldopram = opram;
118   op = ( opram[ 3 ] << 24 ) | ( opram[ 2 ] << 16 ) | ( opram[ 1 ] << 8 ) | ( opram[ 0 ] << 0 );
193   op = fetch_op( opram );
119194   opram += 4;
120195
121196   sprintf( buffer, "dw      $%08x", op );
r2375r2376
152227         sprintf( buffer, "srav    %s,%s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RT( op ) ], s_cpugenreg[ INS_RS( op ) ] );
153228         break;
154229      case FUNCT_JR:
155         if( INS_RD( op ) == 0 )
230         sprintf( buffer, "jr      %s", s_cpugenreg[ INS_RS( op ) ] );
231         if( INS_RS( op ) == 31 )
156232         {
157            sprintf( buffer, "jr      %s", s_cpugenreg[ INS_RS( op ) ] );
233            flags = DASMFLAG_STEP_OUT;
158234         }
159235         break;
160236      case FUNCT_JALR:
161237         sprintf( buffer, "jalr    %s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RS( op ) ] );
238         flags = DASMFLAG_STEP_OVER | DASMFLAG_STEP_OVER_EXTRA( 1 );
162239         break;
163240      case FUNCT_SYSCALL:
164241         sprintf( buffer, "syscall $%05x", INS_CODE( op ) );
242         flags = DASMFLAG_STEP_OVER;
165243         break;
166244      case FUNCT_BREAK:
167245         sprintf( buffer, "break   $%05x", INS_CODE( op ) );
246         flags = DASMFLAG_STEP_OVER;
168247         break;
169248      case FUNCT_MFHI:
170249         sprintf( buffer, "mfhi    %s", s_cpugenreg[ INS_RD( op ) ] );
171250         break;
172251      case FUNCT_MTHI:
173         if( INS_RD( op ) == 0 )
174         {
175            sprintf( buffer, "mthi    %s", s_cpugenreg[ INS_RS( op ) ] );
176         }
252         sprintf( buffer, "mthi    %s", s_cpugenreg[ INS_RS( op ) ] );
177253         break;
178254      case FUNCT_MFLO:
179255         sprintf( buffer, "mflo    %s", s_cpugenreg[ INS_RD( op ) ] );
180256         break;
181257      case FUNCT_MTLO:
182         if( INS_RD( op ) == 0 )
183         {
184            sprintf( buffer, "mtlo    %s", s_cpugenreg[ INS_RS( op ) ] );
185         }
258         sprintf( buffer, "mtlo    %s", s_cpugenreg[ INS_RS( op ) ] );
186259         break;
187260      case FUNCT_MULT:
188         if( INS_RD( op ) == 0 )
189         {
190            sprintf( buffer, "mult    %s,%s", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
191         }
261         sprintf( buffer, "mult    %s,%s", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
192262         break;
193263      case FUNCT_MULTU:
194         if( INS_RD( op ) == 0 )
195         {
196            sprintf( buffer, "multu   %s,%s", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
197         }
264         sprintf( buffer, "multu   %s,%s", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
198265         break;
199266      case FUNCT_DIV:
200         if( INS_RD( op ) == 0 )
201         {
202            sprintf( buffer, "div     %s,%s", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
203         }
267         sprintf( buffer, "div     %s,%s", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
204268         break;
205269      case FUNCT_DIVU:
206         if( INS_RD( op ) == 0 )
207         {
208            sprintf( buffer, "divu    %s,%s", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
209         }
270         sprintf( buffer, "divu    %s,%s", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
210271         break;
211272      case FUNCT_ADD:
212273         sprintf( buffer, "add     %s,%s,%s", s_cpugenreg[ INS_RD( op ) ], s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ] );
r2375r2376
241302      }
242303      break;
243304   case OP_REGIMM:
244      switch( INS_RT( op ) )
305      switch( INS_RT_REGIMM( op ) )
245306      {
246307      case RT_BLTZ:
247         sprintf( buffer, "bltz    %s,$%08x", s_cpugenreg[ INS_RS( op ) ], pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( op ) ) << 2 ) );
308         if( INS_RT( op ) == RT_BLTZAL )
309         {
310            sprintf( buffer, "bltzal  %s,$%08x", s_cpugenreg[ INS_RS( op ) ], relative_address( pc, op ) );
311            flags = DASMFLAG_STEP_OVER | DASMFLAG_STEP_OVER_EXTRA( 1 );
312         }
313         else
314         {
315            sprintf( buffer, "bltz    %s,$%08x", s_cpugenreg[ INS_RS( op ) ], relative_address( pc, op ) );
316         }
248317         break;
249318      case RT_BGEZ:
250         sprintf( buffer, "bgez    %s,$%08x", s_cpugenreg[ INS_RS( op ) ], pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( op ) ) << 2 ) );
319         if( INS_RT( op ) == RT_BGEZAL )
320         {
321            sprintf( buffer, "bgezal  %s,$%08x", s_cpugenreg[ INS_RS( op ) ], relative_address( pc, op ) );
322            flags = DASMFLAG_STEP_OVER | DASMFLAG_STEP_OVER_EXTRA( 1 );
323         }
324         else
325         {
326            sprintf( buffer, "bgez    %s,$%08x", s_cpugenreg[ INS_RS( op ) ], relative_address( pc, op ) );
327         }
251328         break;
252      case RT_BLTZAL:
253         sprintf( buffer, "bltzal  %s,$%08x", s_cpugenreg[ INS_RS( op ) ], pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( op ) ) << 2 ) );
254         break;
255      case RT_BGEZAL:
256         sprintf( buffer, "bgezal  %s,$%08x", s_cpugenreg[ INS_RS( op ) ], pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( op ) ) << 2 ) );
257         break;
258329      }
259330      break;
260331   case OP_J:
261      sprintf( buffer, "j       $%08x", ( ( pc + 4 ) & 0xF0000000 ) + ( INS_TARGET( op ) << 2 ) );
332      sprintf( buffer, "j       $%08x", jump_address( pc, op ) );
262333      break;
263334   case OP_JAL:
264      sprintf( buffer, "jal     $%08x", ( ( pc + 4 ) & 0xF0000000 ) + ( INS_TARGET( op ) << 2 ) );
335      sprintf( buffer, "jal     $%08x", jump_address( pc, op ) );
336      flags = DASMFLAG_STEP_OVER | DASMFLAG_STEP_OVER_EXTRA( 1 );
265337      break;
266338   case OP_BEQ:
267      sprintf( buffer, "beq     %s,%s,$%08x", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ], pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( op ) ) << 2 ) );
339      sprintf( buffer, "beq     %s,%s,$%08x", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ], relative_address( pc, op ) );
268340      break;
269341   case OP_BNE:
270      sprintf( buffer, "bne     %s,%s,$%08x", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ], pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( op ) ) << 2 ) );
342      sprintf( buffer, "bne     %s,%s,$%08x", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ], relative_address( pc, op ) );
271343      break;
272344   case OP_BLEZ:
273      if( INS_RT( op ) == 0 )
274      {
275         sprintf( buffer, "blez    %s,$%08x", s_cpugenreg[ INS_RS( op ) ], pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( op ) ) << 2 ) );
276      }
345      sprintf( buffer, "blez    %s,%s,$%08x", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ], relative_address( pc, op ) );
277346      break;
278347   case OP_BGTZ:
279      if( INS_RT( op ) == 0 )
280      {
281         sprintf( buffer, "bgtz    %s,$%08x", s_cpugenreg[ INS_RS( op ) ], pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( op ) ) << 2 ) );
282      }
348      sprintf( buffer, "bgtz    %s,%s,$%08x", s_cpugenreg[ INS_RS( op ) ], s_cpugenreg[ INS_RT( op ) ], relative_address( pc, op ) );
283349      break;
284350   case OP_ADDI:
285351      sprintf( buffer, "addi    %s,%s,%s", s_cpugenreg[ INS_RT( op ) ], s_cpugenreg[ INS_RS( op ) ], make_signed_hex_str_16( INS_IMMEDIATE( op ) ) );
r2375r2376
303369      sprintf( buffer, "xori    %s,%s,$%04x", s_cpugenreg[ INS_RT( op ) ], s_cpugenreg[ INS_RS( op ) ], INS_IMMEDIATE( op ) );
304370      break;
305371   case OP_LUI:
306      sprintf( buffer, "lui     %s,$%04x", s_cpugenreg[ INS_RT( op ) ], INS_IMMEDIATE( op ) );
372      sprintf( buffer, "lui     %s,%s", s_cpugenreg[ INS_RT( op ) ], upper_address( op, opram ) );
307373      break;
308374   case OP_COP0:
309375      switch( INS_RS( op ) )
r2375r2376
311377      case RS_MFC:
312378         sprintf( buffer, "mfc0    %s,%s",  s_cpugenreg[ INS_RT( op ) ], s_cp0genreg[ INS_RD( op ) ] );
313379         break;
380      case RS_CFC:
381         sprintf( buffer, "!cfc0    %s,%s",  s_cpugenreg[ INS_RT( op ) ], s_cp0ctlreg[ INS_RD( op ) ] );
382         break;
314383      case RS_MTC:
315384         sprintf( buffer, "mtc0    %s,%s",  s_cpugenreg[ INS_RT( op ) ], s_cp0genreg[ INS_RD( op ) ] );
316385         break;
386      case RS_CTC:
387         sprintf( buffer, "!ctc0    %s,%s",  s_cpugenreg[ INS_RT( op ) ], s_cp0ctlreg[ INS_RD( op ) ] );
388         break;
317389      case RS_BC:
318         switch( INS_RT( op ) )
390      case RS_BC_ALT:
391         switch( INS_BC( op ) )
319392         {
320         case RT_BCF:
321            sprintf( buffer, "bc0f    $%08x", pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( op ) ) << 2 ) );
393         case BC_BCF:
394            sprintf( buffer, "bc0f    $%08x", relative_address( pc, op ) );
322395            break;
323         case RT_BCT:
324            sprintf( buffer, "bc0t    $%08x", pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( op ) ) << 2 ) );
396         case BC_BCT:
397            sprintf( buffer, "bc0t    $%08x", relative_address( pc, op ) );
325398            break;
326399         }
327400         break;
r2375r2376
333406
334407            switch( INS_CF( op ) )
335408            {
336            case 1:
337               sprintf( buffer, "tlbr" );
409            case CF_TLBR:
410               sprintf( buffer, "!tlbr" );
338411               break;
339            case 4:
340               sprintf( buffer, "tlbwi" );
412            case CF_TLBWI:
413               sprintf( buffer, "!tlbwi" );
341414               break;
342            case 6:
343               sprintf( buffer, "tlbwr" );
415            case CF_TLBWR:
416               sprintf( buffer, "!tlbwr" );
344417               break;
345            case 8:
346               sprintf( buffer, "tlbp" );
418            case CF_TLBP:
419               sprintf( buffer, "!tlbp" );
347420               break;
348            case 16:
421            case CF_RFE:
349422               sprintf( buffer, "rfe" );
350423               break;
351424            }
r2375r2376
370443         sprintf( buffer, "ctc1    %s,%s",  s_cpugenreg[ INS_RT( op ) ], s_cp1ctlreg[ INS_RD( op ) ] );
371444         break;
372445      case RS_BC:
373         switch( INS_RT( op ) )
446      case RS_BC_ALT:
447         switch( INS_BC( op ) )
374448         {
375         case RT_BCF:
376            sprintf( buffer, "bc1f    $%08x", pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( op ) ) << 2 ) );
449         case BC_BCF:
450            sprintf( buffer, "bc1f    $%08x", relative_address( pc, op ) );
377451            break;
378         case RT_BCT:
379            sprintf( buffer, "bc1t    $%08x", pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( op ) ) << 2 ) );
452         case BC_BCT:
453            sprintf( buffer, "bc1t    $%08x", relative_address( pc, op ) );
380454            break;
381455         }
382456         break;
r2375r2376
406480         sprintf( buffer, "ctc2    %s,%s",  s_cpugenreg[ INS_RT( op ) ], s_cp2ctlreg[ INS_RD( op ) ] );
407481         break;
408482      case RS_BC:
409         switch( INS_RT( op ) )
483      case RS_BC_ALT:
484         switch( INS_BC( op ) )
410485         {
411         case RT_BCF:
412            sprintf( buffer, "bc2f    $%08x", pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( op ) ) << 2 ) );
486         case BC_BCF:
487            sprintf( buffer, "bc2f    $%08x", relative_address( pc, op ) );
413488            break;
414         case RT_BCT:
415            sprintf( buffer, "bc2t    $%08x", pc + 4 + ( MIPS_WORD_EXTEND( INS_IMMEDIATE( op ) ) << 2 ) );
489         case BC_BCT:
490            sprintf( buffer, "bc2t    $%08x", relative_address( pc, op ) );
416491            break;
417492         }
418493         break;
r2375r2376
567642         break;
568643      }
569644      break;
645   case OP_COP3:
646      switch( INS_RS( op ) )
647      {
648      case RS_MFC:
649         sprintf( buffer, "mfc3    %s,%s",  s_cpugenreg[ INS_RT( op ) ], s_cp3genreg[ INS_RD( op ) ] );
650         break;
651      case RS_CFC:
652         sprintf( buffer, "cfc3    %s,%s",  s_cpugenreg[ INS_RT( op ) ], s_cp3ctlreg[ INS_RD( op ) ] );
653         break;
654      case RS_MTC:
655         sprintf( buffer, "mtc3    %s,%s",  s_cpugenreg[ INS_RT( op ) ], s_cp3genreg[ INS_RD( op ) ] );
656         break;
657      case RS_CTC:
658         sprintf( buffer, "ctc3    %s,%s",  s_cpugenreg[ INS_RT( op ) ], s_cp3ctlreg[ INS_RD( op ) ] );
659         break;
660      case RS_BC:
661      case RS_BC_ALT:
662         switch( INS_BC( op ) )
663         {
664         case BC_BCF:
665            sprintf( buffer, "bc3f    $%08x", relative_address( pc, op ) );
666            break;
667         case BC_BCT:
668            sprintf( buffer, "bc3t    $%08x", relative_address( pc, op ) );
669            break;
670         }
671         break;
672      default:
673         switch( INS_CO( op ) )
674         {
675         case 1:
676            sprintf( buffer, "cop3    $%07x", INS_COFUN( op ) );
677            break;
678         }
679         break;
680      }
681      break;
570682   case OP_LB:
571      sprintf( buffer, "lb      %s,%s", s_cpugenreg[ INS_RT( op ) ], make_address( pc, op ) );
683      sprintf( buffer, "lb      %s,%s", s_cpugenreg[ INS_RT( op ) ], effective_address( pc, op ) );
572684      break;
573685   case OP_LH:
574      sprintf( buffer, "lh      %s,%s", s_cpugenreg[ INS_RT( op ) ], make_address( pc, op ) );
686      sprintf( buffer, "lh      %s,%s", s_cpugenreg[ INS_RT( op ) ], effective_address( pc, op ) );
575687      break;
576688   case OP_LWL:
577      sprintf( buffer, "lwl     %s,%s", s_cpugenreg[ INS_RT( op ) ], make_address( pc, op ) );
689      sprintf( buffer, "lwl     %s,%s", s_cpugenreg[ INS_RT( op ) ], effective_address( pc, op ) );
578690      break;
579691   case OP_LW:
580      sprintf( buffer, "lw      %s,%s", s_cpugenreg[ INS_RT( op ) ], make_address( pc, op ) );
692      sprintf( buffer, "lw      %s,%s", s_cpugenreg[ INS_RT( op ) ], effective_address( pc, op ) );
581693      break;
582694   case OP_LBU:
583      sprintf( buffer, "lbu     %s,%s", s_cpugenreg[ INS_RT( op ) ], make_address( pc, op ) );
695      sprintf( buffer, "lbu     %s,%s", s_cpugenreg[ INS_RT( op ) ], effective_address( pc, op ) );
584696      break;
585697   case OP_LHU:
586      sprintf( buffer, "lhu     %s,%s", s_cpugenreg[ INS_RT( op ) ], make_address( pc, op ) );
698      sprintf( buffer, "lhu     %s,%s", s_cpugenreg[ INS_RT( op ) ], effective_address( pc, op ) );
587699      break;
588700   case OP_LWR:
589      sprintf( buffer, "lwr     %s,%s", s_cpugenreg[ INS_RT( op ) ], make_address( pc, op ) );
701      sprintf( buffer, "lwr     %s,%s", s_cpugenreg[ INS_RT( op ) ], effective_address( pc, op ) );
590702      break;
591703   case OP_SB:
592      sprintf( buffer, "sb      %s,%s", s_cpugenreg[ INS_RT( op ) ], make_address( pc, op ) );
704      sprintf( buffer, "sb      %s,%s", s_cpugenreg[ INS_RT( op ) ], effective_address( pc, op ) );
593705      break;
594706   case OP_SH:
595      sprintf( buffer, "sh      %s,%s", s_cpugenreg[ INS_RT( op ) ], make_address( pc, op ) );
707      sprintf( buffer, "sh      %s,%s", s_cpugenreg[ INS_RT( op ) ], effective_address( pc, op ) );
596708      break;
597709   case OP_SWL:
598      sprintf( buffer, "swl     %s,%s", s_cpugenreg[ INS_RT( op ) ], make_address( pc, op ) );
710      sprintf( buffer, "swl     %s,%s", s_cpugenreg[ INS_RT( op ) ], effective_address( pc, op ) );
599711      break;
600712   case OP_SW:
601      sprintf( buffer, "sw      %s,%s", s_cpugenreg[ INS_RT( op ) ], make_address( pc, op ) );
713      sprintf( buffer, "sw      %s,%s", s_cpugenreg[ INS_RT( op ) ], effective_address( pc, op ) );
602714      break;
603715   case OP_SWR:
604      sprintf( buffer, "swr     %s,%s", s_cpugenreg[ INS_RT( op ) ], make_address( pc, op ) );
716      sprintf( buffer, "swr     %s,%s", s_cpugenreg[ INS_RT( op ) ], effective_address( pc, op ) );
605717      break;
718   case OP_LWC0:
719      sprintf( buffer, "lwc0    %s,%s", s_cp0genreg[ INS_RT( op ) ], effective_address( pc, op ) );
720      break;
606721   case OP_LWC1:
607      sprintf( buffer, "lwc1    %s,%s", s_cp1genreg[ INS_RT( op ) ], make_address( pc, op ) );
722      sprintf( buffer, "lwc1    %s,%s", s_cp1genreg[ INS_RT( op ) ], effective_address( pc, op ) );
608723      break;
609724   case OP_LWC2:
610      sprintf( buffer, "lwc2    %s,%s", s_cp2genreg[ INS_RT( op ) ], make_address( pc, op ) );
725      sprintf( buffer, "lwc2    %s,%s", s_cp2genreg[ INS_RT( op ) ], effective_address( pc, op ) );
611726      break;
727   case OP_LWC3:
728      sprintf( buffer, "lwc3    %s,%s", s_cp2genreg[ INS_RT( op ) ], effective_address( pc, op ) );
729      break;
730   case OP_SWC0:
731      sprintf( buffer, "swc0    %s,%s", s_cp0genreg[ INS_RT( op ) ], effective_address( pc, op ) );
732      break;
612733   case OP_SWC1:
613      sprintf( buffer, "swc1    %s,%s", s_cp1genreg[ INS_RT( op ) ], make_address( pc, op ) );
734      sprintf( buffer, "swc1    %s,%s", s_cp1genreg[ INS_RT( op ) ], effective_address( pc, op ) );
614735      break;
615736   case OP_SWC2:
616      sprintf( buffer, "swc2    %s,%s", s_cp2genreg[ INS_RT( op ) ], make_address( pc, op ) );
737      sprintf( buffer, "swc2    %s,%s", s_cp2genreg[ INS_RT( op ) ], effective_address( pc, op ) );
617738      break;
739   case OP_SWC3:
740      sprintf( buffer, "swc3    %s,%s", s_cp2genreg[ INS_RT( op ) ], effective_address( pc, op ) );
741      break;
618742   }
619   return ( opram - oldopram ) | DASMFLAG_SUPPORTED;
743   return ( opram - oldopram ) | flags | DASMFLAG_SUPPORTED;
620744}
src/emu/cpu/mips/psx.h
r2375r2376
33
44#include "cpuintrf.h"
55
6#define MIPS_DELAYR_PC ( 32 )
7#define MIPS_DELAYR_NOTPC ( 33 )
8
69enum
710{
811   MIPS_PC = 1,
912   MIPS_DELAYV, MIPS_DELAYR,
1013   MIPS_HI, MIPS_LO,
14   MIPS_BIU,
1115   MIPS_R0, MIPS_R1,
1216   MIPS_R2, MIPS_R3,
1317   MIPS_R4, MIPS_R5,
r2375r2376
3236   MIPS_CP0R10, MIPS_CP0R11,
3337   MIPS_CP0R12, MIPS_CP0R13,
3438   MIPS_CP0R14, MIPS_CP0R15,
35   MIPS_CP0R16, MIPS_CP0R17,
36   MIPS_CP0R18, MIPS_CP0R19,
37   MIPS_CP0R20, MIPS_CP0R21,
38   MIPS_CP0R22, MIPS_CP0R23,
39   MIPS_CP0R24, MIPS_CP0R25,
40   MIPS_CP0R26, MIPS_CP0R27,
41   MIPS_CP0R28, MIPS_CP0R29,
42   MIPS_CP0R30, MIPS_CP0R31,
4339   MIPS_CP2DR0, MIPS_CP2DR1,
4440   MIPS_CP2DR2, MIPS_CP2DR3,
4541   MIPS_CP2DR4, MIPS_CP2DR5,
r2375r2376
9793#define INS_CODE( op ) ( ( op >> 6 ) & 0xfffff )
9894#define INS_CO( op ) ( ( op >> 25 ) & 1 )
9995#define INS_COFUN( op ) ( op & 0x1ffffff )
100#define INS_CF( op ) ( op & 63 )
96#define INS_CF( op ) ( op & 31 )
97#define INS_BC( op ) ( ( op >> 16 ) & 1 )
98#define INS_RT_REGIMM( op ) ( ( op >> 16 ) & 1 )
10199
102100#define GTE_OP( op ) ( ( op >> 20 ) & 31 )
103101#define GTE_SF( op ) ( ( op >> 19 ) & 1 )
r2375r2376
128126#define OP_COP0 ( 16 )
129127#define OP_COP1 ( 17 )
130128#define OP_COP2 ( 18 )
129#define OP_COP3 ( 19 )
131130#define OP_LB ( 32 )
132131#define OP_LH ( 33 )
133132#define OP_LWL ( 34 )
r2375r2376
140139#define OP_SWL ( 42 )
141140#define OP_SW ( 43 )
142141#define OP_SWR ( 46 )
142#define OP_LWC0 ( 48 )
143143#define OP_LWC1 ( 49 )
144144#define OP_LWC2 ( 50 )
145#define OP_LWC3 ( 51 )
146#define OP_SWC0 ( 56 )
145147#define OP_SWC1 ( 57 )
146148#define OP_SWC2 ( 58 )
149#define OP_SWC3 ( 59 )
147150
148151/* OP_SPECIAL */
149152#define FUNCT_SLL ( 0 )
r2375r2376
187190#define RS_MTC ( 4 )
188191#define RS_CTC ( 6 )
189192#define RS_BC ( 8 )
193#define RS_BC_ALT ( 12 )
190194
191/* RS_BC */
192#define RT_BCF ( 0 )
193#define RT_BCT ( 1 )
195/* BC_BC */
196#define BC_BCF ( 0 )
197#define BC_BCT ( 1 )
194198
195199/* OP_COP0 */
200#define CF_TLBR ( 1 )
201#define CF_TLBWI ( 2 )
202#define CF_TLBWR ( 6 )
203#define CF_TLBP ( 8 )
196204#define CF_RFE ( 16 )
197205
198206#ifdef ENABLE_DEBUGGER
src/emu/cpu/mips/mips3com.c
r2375r2376
2929static void tlb_write_common(mips3_state *mips, int index);
3030static void tlb_entry_log_half(mips3_tlb_entry *tlbent, int index, int which);
3131
32static UINT64 program_read_qword_32be(offs_t offset);
3332static UINT64 program_read_qword_masked_32be(offs_t offset, UINT64 mem_mask);
34
35static void program_write_qword_32be(offs_t offset, UINT64 data);
3633static void program_write_qword_masked_32be(offs_t offset, UINT64 data, UINT64 mem_mask);
37
38static UINT64 program_read_qword_32le(offs_t offset);
3934static UINT64 program_read_qword_masked_32le(offs_t offset, UINT64 mem_mask);
40
41static void program_write_qword_32le(offs_t offset, UINT64 data);
4235static void program_write_qword_masked_32le(offs_t offset, UINT64 data, UINT64 mem_mask);
4336
4437
r2375r2376
5245   program_read_byte_32be,
5346   program_read_word_32be,
5447   program_read_dword_32be,
55   program_read_masked_32be,
48   program_read_dword_masked_32be,
5649   program_read_qword_32be,
5750   program_read_qword_masked_32be,
5851
5952   program_write_byte_32be,
6053   program_write_word_32be,
6154   program_write_dword_32be,
62   program_write_masked_32be,
55   program_write_dword_masked_32be,
6356   program_write_qword_32be,
6457   program_write_qword_masked_32be
6558};
r2375r2376
6962   program_read_byte_32le,
7063   program_read_word_32le,
7164   program_read_dword_32le,
72   program_read_masked_32le,
65   program_read_dword_masked_32le,
7366   program_read_qword_32le,
7467   program_read_qword_masked_32le,
7568
7669   program_write_byte_32le,
7770   program_write_word_32le,
7871   program_write_dword_32le,
79   program_write_masked_32le,
72   program_write_dword_masked_32le,
8073   program_write_qword_32le,
8174   program_write_qword_masked_32le
8275};
r2375r2376
875868***************************************************************************/
876869
877870/*-------------------------------------------------
878    program_read_qword_32be - read a 64-bit
879    big-endian value
880-------------------------------------------------*/
881
882static UINT64 program_read_qword_32be(offs_t offset)
883{
884   UINT64 result = (UINT64)program_read_dword_32be(offset) << 32;
885   return result | program_read_dword_32be(offset + 4);
886}
887
888
889/*-------------------------------------------------
890871    program_read_qword_masked_32be - read a 64-bit
891872    big-endian value with explicit masking
892873-------------------------------------------------*/
r2375r2376
895876{
896877   UINT64 result = 0;
897878   if (ACCESSING_BITS_32_63)
898      result |= (UINT64)program_read_masked_32be(offset, mem_mask >> 32) << 32;
879      result |= (UINT64)program_read_dword_masked_32be(offset, mem_mask >> 32) << 32;
899880   if (ACCESSING_BITS_0_31)
900      result |= program_read_masked_32be(offset + 4, mem_mask);
881      result |= program_read_dword_masked_32be(offset + 4, mem_mask);
901882   return result;
902883}
903884
904885
905886/*-------------------------------------------------
906    program_read_qword_32le - read a 64-bit
907    little-endian value
908-------------------------------------------------*/
909
910static UINT64 program_read_qword_32le(offs_t offset)
911{
912   UINT64 result = program_read_dword_32le(offset);
913   return result | ((UINT64)program_read_dword_32le(offset + 4) << 32);
914}
915
916
917/*-------------------------------------------------
918887    program_read_qword_masked_32le - read a 64-bit
919888    little-endian value with explicit masking
920889-------------------------------------------------*/
r2375r2376
923892{
924893   UINT64 result = 0;
925894   if (ACCESSING_BITS_0_31)
926      result |= program_read_masked_32le(offset, mem_mask);
895      result |= program_read_dword_masked_32le(offset, mem_mask);
927896   if (ACCESSING_BITS_32_63)
928      result |= (UINT64)program_read_masked_32le(offset + 4, mem_mask >> 32) << 32;
897      result |= (UINT64)program_read_dword_masked_32le(offset + 4, mem_mask >> 32) << 32;
929898   return result;
930899}
931900
932901
933902/*-------------------------------------------------
934    program_write_qword_32be - write a 64-bit
935    big-endian value
936-------------------------------------------------*/
937
938static void program_write_qword_32be(offs_t offset, UINT64 data)
939{
940   program_write_dword_32be(offset, data >> 32);
941   program_write_dword_32be(offset + 4, data);
942}
943
944
945/*-------------------------------------------------
946903    program_write_qword_masked_32be - write a
947904    64-bit big-endian value with explicit masking
948905-------------------------------------------------*/
r2375r2376
950907static void program_write_qword_masked_32be(offs_t offset, UINT64 data, UINT64 mem_mask)
951908{
952909   if (ACCESSING_BITS_32_63)
953      program_write_masked_32be(offset, data >> 32, mem_mask >> 32);
910      program_write_dword_masked_32be(offset, data >> 32, mem_mask >> 32);
954911   if (ACCESSING_BITS_0_31)
955      program_write_masked_32be(offset + 4, data, mem_mask);
912      program_write_dword_masked_32be(offset + 4, data, mem_mask);
956913}
957914
958915
959916/*-------------------------------------------------
960    program_write_qword_32le - write a 64-bit
961    little-endian value
962-------------------------------------------------*/
963
964static void program_write_qword_32le(offs_t offset, UINT64 data)
965{
966   program_write_dword_32le(offset, data);
967   program_write_dword_32le(offset + 4, data >> 32);
968}
969
970
971/*-------------------------------------------------
972917    program_write_qword_masked_32le - write a
973918    64-bit little-endian value with explicit masking
974919-------------------------------------------------*/
r2375r2376
976921static void program_write_qword_masked_32le(offs_t offset, UINT64 data, UINT64 mem_mask)
977922{
978923   if (ACCESSING_BITS_0_31)
979      program_write_masked_32le(offset, data, mem_mask);
924      program_write_dword_masked_32le(offset, data, mem_mask);
980925   if (ACCESSING_BITS_32_63)
981      program_write_masked_32le(offset + 4, data >> 32, mem_mask >> 32);
926      program_write_dword_masked_32le(offset + 4, data >> 32, mem_mask >> 32);
982927}
src/emu/cpu/tms7000/tms7000.c
r2375r2376
5757static int tms7000_div_by_16_trigger;
5858static int tms7000_cycles_per_INT2;
5959
60#define RM(Addr) ((unsigned)program_read_byte_8(Addr))
61#define WM(Addr,Value) (program_write_byte_8(Addr,Value))
60#define RM(Addr) ((unsigned)program_read_byte_8be(Addr))
61#define WM(Addr,Value) (program_write_byte_8be(Addr,Value))
6262
6363INLINE UINT16 RM16( UINT32 mAddr )   /* Read memory (16-bit) */
6464{
r2375r2376
619619         break;
620620
621621      case 0x06: /* Port B write */
622         io_write_byte_8( TMS7000_PORTB, data );
622         io_write_byte_8be( TMS7000_PORTB, data );
623623         tms7000.pf[ 0x06 ] = data;
624624         break;
625625
626626      case 0x08: /* Port C write */
627627         temp1 = data & tms7000.pf[ 0x09 ];   /* Mask off input bits */
628         io_write_byte_8( TMS7000_PORTC, temp1 );
628         io_write_byte_8be( TMS7000_PORTC, temp1 );
629629         tms7000.pf[ 0x08 ] = temp1;
630630         break;
631631
632632      case 0x0a: /* Port D write */
633633         temp1 = data & tms7000.pf[ 0x0b ];   /* Mask off input bits */
634         io_write_byte_8( TMS7000_PORTD, temp1 );
634         io_write_byte_8be( TMS7000_PORTD, temp1 );
635635         tms7000.pf[ 0x0a ] = temp1;
636636         break;
637637
r2375r2376
666666         break;
667667
668668      case 0x04: /* Port A read */
669         result = io_read_byte_8( TMS7000_PORTA );
669         result = io_read_byte_8be( TMS7000_PORTA );
670670         break;
671671
672672
r2375r2376
677677
678678      case 0x08: /* Port C read */
679679         temp1 = tms7000.pf[ 0x08 ] & tms7000.pf[ 0x09 ];   /* Get previous output bits */
680         temp2 = io_read_byte_8( TMS7000_PORTC );         /* Read port */
680         temp2 = io_read_byte_8be( TMS7000_PORTC );         /* Read port */
681681         temp3 = temp2 & (~tms7000.pf[ 0x09 ]);            /* Mask off output bits */
682682         result = temp1 | temp3;                        /* OR together */
683683         break;
684684
685685      case 0x0a: /* Port D read */
686686         temp1 = tms7000.pf[ 0x0a ] & tms7000.pf[ 0x0b ];   /* Get previous output bits */
687         temp2 = io_read_byte_8( TMS7000_PORTD );         /* Read port */
687         temp2 = io_read_byte_8be( TMS7000_PORTD );         /* Read port */
688688         temp3 = temp2 & (~tms7000.pf[ 0x0b ]);            /* Mask off output bits */
689689         result = temp1 | temp3;                        /* OR together */
690690         break;
src/emu/cpu/f8/f8.c
r2375r2376
136136     * the memory location addressed by DC0; then all devices increment
137137     * DC0.
138138     */
139    f8.dbus = program_read_byte_8(f8.dc0);
139    f8.dbus = program_read_byte_8be(f8.dc0);
140140    f8.dc0 += 1;
141141    f8_icount -= cL;
142142}
r2375r2376
167167     * Store the data bus contents into the memory location pointed
168168     * to by DC0; increment DC0.
169169     */
170    program_write_byte_8(f8.dc0, f8.dbus);
170    program_write_byte_8be(f8.dc0, f8.dbus);
171171    f8.dc0 += 1;
172172    f8_icount -= cL;
173173}
r2375r2376
403403     * register was addressed; the device containing the addressed port
404404     * must place the contents of the data bus into the address port.
405405     */
406    io_write_byte_8(f8.io, f8.dbus);
406    io_write_byte_8be(f8.io, f8.dbus);
407407    f8_icount -= cL;
408408}
409409
r2375r2376
416416     * contents of timer and interrupt control registers cannot be read
417417     * back onto the data bus).
418418     */
419   f8.dbus = io_read_byte_8(f8.io);
419   f8.dbus = io_read_byte_8be(f8.io);
420420    f8_icount -= cL;
421421}
422422
r2375r2376
12581258{
12591259    ROMC_1C(cS);
12601260    CLR_OZCS;
1261    f8.a = io_read_byte_8(n);
1261    f8.a = io_read_byte_8be(n);
12621262    SET_SZ(f8.a);
12631263}
12641264
r2375r2376
12831283static void f8_outs_0(int n)
12841284{
12851285    ROMC_1C(cS);
1286    io_write_byte_8(n, f8.a);
1286    io_write_byte_8be(n, f8.a);
12871287}
12881288
12891289/***************************************************
src/emu/cpu/z80/z80.c
r2375r2376
565565/***************************************************************
566566 * Input a byte from given I/O port
567567 ***************************************************************/
568#define IN(port)   ((UINT8)io_read_byte_8(port))
568#define IN(port)   ((UINT8)io_read_byte_8le(port))
569569
570570/***************************************************************
571571 * Output a byte to given I/O port
572572 ***************************************************************/
573#define OUT(port,value) io_write_byte_8(port,value)
573#define OUT(port,value) io_write_byte_8le(port,value)
574574
575575/***************************************************************
576576 * Read a byte from given memory location
577577 ***************************************************************/
578#define RM(addr) (UINT8)program_read_byte_8(addr)
578#define RM(addr) (UINT8)program_read_byte_8le(addr)
579579
580580/***************************************************************
581581 * Read a word from given memory location
r2375r2376
589589/***************************************************************
590590 * Write a byte to given memory location
591591 ***************************************************************/
592#define WM(addr,value) program_write_byte_8(addr,value)
592#define WM(addr,value) program_write_byte_8le(addr,value)
593593
594594/***************************************************************
595595 * Write a word to given memory location
src/emu/cpu/tms9900/99xxcore.h
r2375r2376
777777      int val;
778778
779779      TMS99XX_ICOUNT -= 2;
780      val = program_read_byte_8(addr);
781      return (val << 8) | program_read_byte_8(addr+1);
780      val = program_read_byte_8be(addr);
781      return (val << 8) | program_read_byte_8be(addr+1);
782782   }
783   #define writeword(addr,data)  { TMS99XX_ICOUNT -= 2; program_write_byte_8((addr), (data) >> 8); program_write_byte_8((addr) + 1, (data) & 0xff); }
783   #define writeword(addr,data)  { TMS99XX_ICOUNT -= 2; program_write_byte_8be((addr), (data) >> 8); program_write_byte_8be((addr) + 1, (data) & 0xff); }
784784
785785#if 0
786   #define readbyte(addr)        (TMS99XX_ICOUNT -= 2, program_read_byte_8(addr))
787   #define writebyte(addr,data)  { TMS99XX_ICOUNT -= 2; program_write_byte_8((addr),(data)); }
786   #define readbyte(addr)        (TMS99XX_ICOUNT -= 2, program_read_byte_8be(addr))
787   #define writebyte(addr,data)  { TMS99XX_ICOUNT -= 2; program_write_byte_8be((addr),(data)); }
788788#else
789789   /*This is how it really works*/
790790   /*Note that every writebyte must match a readbyte (which is indeed the case)*/
r2375r2376
795795      TMS99XX_ICOUNT -= 2;
796796      if (addr & 1)
797797      {
798         extra_byte = program_read_byte_8(addr-1);
799         return program_read_byte_8(addr);
798         extra_byte = program_read_byte_8be(addr-1);
799         return program_read_byte_8be(addr);
800800      }
801801      else
802802      {
803         int val = program_read_byte_8(addr);
804         extra_byte = program_read_byte_8(addr+1);
803         int val = program_read_byte_8be(addr);
804         extra_byte = program_read_byte_8be(addr+1);
805805         return val;
806806      }
807807   }
r2375r2376
810810      TMS99XX_ICOUNT -= 2;
811811      if (addr & 1)
812812      {
813         program_write_byte_8(addr-1, extra_byte);
814         program_write_byte_8(addr, data);
813         program_write_byte_8be(addr-1, extra_byte);
814         program_write_byte_8be(addr, data);
815815      }
816816      else
817817      {
818         program_write_byte_8(addr, data);
819         program_write_byte_8(addr+1, extra_byte);
818         program_write_byte_8be(addr, data);
819         program_write_byte_8be(addr+1, extra_byte);
820820      }
821821   }
822822#endif
r2375r2376
836836      else
837837      {
838838         TMS99XX_ICOUNT -= 2;
839         return (program_read_byte_8(addr) << 8) + program_read_byte_8(addr + 1);
839         return (program_read_byte_8be(addr) << 8) + program_read_byte_8be(addr + 1);
840840      }
841841   }
842842   static void writeword(int addr, int data)
r2375r2376
847847      else if (!(addr < 0x2000))
848848      {
849849         TMS99XX_ICOUNT -= 2;
850         program_write_byte_8(addr, data >> 8);
851         program_write_byte_8(addr + 1, data & 0xff);
850         program_write_byte_8be(addr, data >> 8);
851         program_write_byte_8be(addr + 1, data & 0xff);
852852      }
853853   }
854854
r2375r2376
865865         TMS99XX_ICOUNT -= 2;
866866         if (addr & 1)
867867         {
868            extra_byte = program_read_byte_8(addr-1);
869            return program_read_byte_8(addr);
868            extra_byte = program_read_byte_8be(addr-1);
869            return program_read_byte_8be(addr);
870870         }
871871         else
872872         {
873            int val = program_read_byte_8(addr);
874            extra_byte = program_read_byte_8(addr+1);
873            int val = program_read_byte_8be(addr);
874            extra_byte = program_read_byte_8be(addr+1);
875875            return val;
876876         }
877877      }
r2375r2376
886886         TMS99XX_ICOUNT -= 2;
887887         if (addr & 1)
888888         {
889            program_write_byte_8(addr-1, extra_byte);
890            program_write_byte_8(addr, data);
889            program_write_byte_8be(addr-1, extra_byte);
890            program_write_byte_8be(addr, data);
891891         }
892892         else
893893         {
894            program_write_byte_8(addr, data);
895            program_write_byte_8(addr+1, extra_byte);
894            program_write_byte_8be(addr, data);
895            program_write_byte_8be(addr+1, extra_byte);
896896      }
897897   }
898898   }
r2375r2376
909909      {
910910         int reply;
911911         TMS99XX_ICOUNT -= I.memory_wait_states_word;
912         reply = program_read_byte_8(addr);
913         return (reply << 8) | program_read_byte_8(addr + 1);
912         reply = program_read_byte_8be(addr);
913         return (reply << 8) | program_read_byte_8be(addr + 1);
914914      }
915915      else if (addr < 0xf0fc)
916916      {
r2375r2376
920920      {
921921         int reply;
922922         TMS99XX_ICOUNT -= I.memory_wait_states_word;
923         reply = program_read_byte_8(addr);
924         return (reply << 8) | program_read_byte_8(addr + 1);
923         reply = program_read_byte_8be(addr);
924         return (reply << 8) | program_read_byte_8be(addr + 1);
925925      }
926926      else if (addr < 0xfffc)
927927      {
r2375r2376
944944      if ((addr < 0xf000) || (I.is_mp9537))
945945      {
946946         TMS99XX_ICOUNT -= I.memory_wait_states_word;
947         program_write_byte_8(addr, data >> 8);
948         program_write_byte_8(addr + 1, data & 0xff);
947         program_write_byte_8be(addr, data >> 8);
948         program_write_byte_8be(addr + 1, data & 0xff);
949949      }
950950      else if (addr < 0xf0fc)
951951      {
r2375r2376
954954      else if (addr < 0xfffa)
955955      {
956956         TMS99XX_ICOUNT -= I.memory_wait_states_word;
957         program_write_byte_8(addr, data >> 8);
958         program_write_byte_8(addr + 1, data & 0xff);
957         program_write_byte_8be(addr, data >> 8);
958         program_write_byte_8be(addr + 1, data & 0xff);
959959      }
960960      else if (addr < 0xfffc)
961961      {
r2375r2376
974974      if ((addr < 0xf000) || (I.is_mp9537))
975975      {
976976         TMS99XX_ICOUNT -= I.memory_wait_states_byte;
977         return program_read_byte_8(addr);
977         return program_read_byte_8be(addr);
978978      }
979979      else if (addr < 0xf0fc)
980980      {
r2375r2376
983983      else if (addr < 0xfffa)
984984      {
985985         TMS99XX_ICOUNT -= I.memory_wait_states_byte;
986         return program_read_byte_8(addr);
986         return program_read_byte_8be(addr);
987987      }
988988      else if (addr < 0xfffc)
989989      {
r2375r2376
10131013      if ((addr < 0xf000) || (I.is_mp9537))
10141014      {
10151015         TMS99XX_ICOUNT -= I.memory_wait_states_byte;
1016         program_write_byte_8(addr, data);
1016         program_write_byte_8be(addr, data);
10171017      }
10181018      else if (addr < 0xf0fc)
10191019      {
r2375r2376
10221022      else if (addr < 0xfffa)
10231023      {
10241024         TMS99XX_ICOUNT -= I.memory_wait_states_byte;
1025         program_write_byte_8(addr, data);
1025         program_write_byte_8be(addr, data);
10261026      }
10271027      else if (addr < 0xfffc)
10281028      {
r2375r2376
20492049   CRU_PRIVILEGE_VIOLATION = -1
20502050} cru_error_code;
20512051
2052#define WRITEPORT(port, data) io_write_byte_8(port, data)
2052#define WRITEPORT(port, data) io_write_byte_8be(port, data)
20532053
20542054#if (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID)
20552055/* on tms9940, we have to handle internal CRU ports */
r2375r2376
22682268    read at the same address.  This seems to be impossible to emulate efficiently, so, if you need
22692269    to emulate this, you're in trouble.
22702270*/
2271#define READPORT(port) io_read_byte_8(port)
2271#define READPORT(port) io_read_byte_8be(port)
22722272
22732273
22742274#if (TMS99XX_MODEL == TMS9940_ID) || (TMS99XX_MODEL == TMS9985_ID)
src/emu/cpu/pic16c5x/pic16c5x.h
r2375r2376
4747 */
4848
4949#define PIC16C5x_T0      0x10
50#define PIC16C5x_T0_In (io_read_byte_8(PIC16C5x_T0))
50#define PIC16C5x_T0_In (io_read_byte_8le(PIC16C5x_T0))
5151
5252
5353/****************************************************************************
5454 *  Input a word from given I/O port
5555 */
5656
57#define PIC16C5x_In(Port) ((UINT8)io_read_byte_8((Port)))
57#define PIC16C5x_In(Port) ((UINT8)io_read_byte_8le((Port)))
5858
5959
6060/****************************************************************************
6161 *  Output a word to given I/O port
6262 */
6363
64#define PIC16C5x_Out(Port,Value) (io_write_byte_8((Port),Value))
64#define PIC16C5x_Out(Port,Value) (io_write_byte_8le((Port),Value))
6565
6666
6767
r2375r2376
6969 *  Read a word from given RAM memory location
7070 */
7171
72#define PIC16C5x_RAM_RDMEM(A) ((UINT8)data_read_byte_8(A))
72#define PIC16C5x_RAM_RDMEM(A) ((UINT8)data_read_byte_8le(A))
7373
7474
7575/****************************************************************************
7676 *  Write a word to given RAM memory location
7777 */
7878
79#define PIC16C5x_RAM_WRMEM(A,V) (data_write_byte_8(A,V))
79#define PIC16C5x_RAM_WRMEM(A,V) (data_write_byte_8le(A,V))
8080
8181
8282
src/emu/cpu/h6280/h6280ops.h
r2375r2376
127127 ***************************************************************/
128128INLINE UINT8 RDMEM(offs_t addr) {
129129   CHECK_VDC_VCE_PENALTY(addr);
130   return program_read_byte_8(TRANSLATED(addr));
130   return program_read_byte_8le(TRANSLATED(addr));
131131}
132132
133133/***************************************************************
r2375r2376
135135 ***************************************************************/
136136INLINE void WRMEM(offs_t addr, UINT8 data) {
137137   CHECK_VDC_VCE_PENALTY(addr);
138   program_write_byte_8(TRANSLATED(addr),data);
138   program_write_byte_8le(TRANSLATED(addr),data);
139139}
140140
141141/***************************************************************
142142 *  RDMEMZ   read memory - zero page
143143 ***************************************************************/
144144#define RDMEMZ(addr)                                  \
145   program_read_byte_8( (h6280.mmr[1] << 13) | ((addr)&0x1fff));
145   program_read_byte_8le( (h6280.mmr[1] << 13) | ((addr)&0x1fff));
146146
147147/***************************************************************
148148 *  WRMEMZ   write memory - zero page
149149 ***************************************************************/
150150#define WRMEMZ(addr,data)                               \
151   program_write_byte_8( (h6280.mmr[1] << 13) | ((addr)&0x1fff),data);
151   program_write_byte_8le( (h6280.mmr[1] << 13) | ((addr)&0x1fff),data);
152152
153153/***************************************************************
154154 *  RDMEMW   read word from memory
155155 ***************************************************************/
156156#define RDMEMW(addr)                                 \
157   program_read_byte_8(TRANSLATED(addr)) \
158| ( program_read_byte_8(TRANSLATED(addr+1)) << 8 )
157   program_read_byte_8le(TRANSLATED(addr)) \
158| ( program_read_byte_8le(TRANSLATED(addr+1)) << 8 )
159159
160160/***************************************************************
161161 *  RDZPWORD    read a word from a zero page address
162162 ***************************************************************/
163163#define RDZPWORD(addr)                                 \
164164   ((addr&0xff)==0xff) ?                              \
165      program_read_byte_8( (h6280.mmr[1] << 13) | ((addr)&0x1fff))            \
166      +(program_read_byte_8( (h6280.mmr[1] << 13) | ((addr-0xff)&0x1fff))<<8) : \
167      program_read_byte_8( (h6280.mmr[1] << 13) | ((addr)&0x1fff))            \
168      +(program_read_byte_8( (h6280.mmr[1] << 13) | ((addr+1)&0x1fff))<<8)
165      program_read_byte_8le( (h6280.mmr[1] << 13) | ((addr)&0x1fff))            \
166      +(program_read_byte_8le( (h6280.mmr[1] << 13) | ((addr-0xff)&0x1fff))<<8) : \
167      program_read_byte_8le( (h6280.mmr[1] << 13) | ((addr)&0x1fff))            \
168      +(program_read_byte_8le( (h6280.mmr[1] << 13) | ((addr+1)&0x1fff))<<8)
169169
170170
171171/***************************************************************
172172 * push a register onto the stack
173173 ***************************************************************/
174#define PUSH(Rg) program_write_byte_8( (h6280.mmr[1] << 13) | h6280.sp.d,Rg); S--
174#define PUSH(Rg) program_write_byte_8le( (h6280.mmr[1] << 13) | h6280.sp.d,Rg); S--
175175
176176/***************************************************************
177177 * pull a register from the stack
178178 ***************************************************************/
179#define PULL(Rg) S++; Rg = program_read_byte_8( (h6280.mmr[1] << 13) | h6280.sp.d)
179#define PULL(Rg) S++; Rg = program_read_byte_8le( (h6280.mmr[1] << 13) | h6280.sp.d)
180180
181181/***************************************************************
182182 *  RDOP    read an opcode
r2375r2376
11171117 ***************************************************************/
11181118#define ST0                                                     \
11191119   CLEAR_T;                                       \
1120    io_write_byte_8(0x0000,tmp)
1120    io_write_byte_8le(0x0000,tmp)
11211121
11221122/* 6280 ********************************************************
11231123 *  ST1 Store at hardware address 2
11241124 ***************************************************************/
11251125#define ST1                                                     \
11261126   CLEAR_T;                                       \
1127    io_write_byte_8(0x0002,tmp)
1127    io_write_byte_8le(0x0002,tmp)
11281128
11291129/* 6280 ********************************************************
11301130 *  ST2 Store at hardware address 3
11311131 ***************************************************************/
11321132#define ST2                                                     \
11331133   CLEAR_T;                                       \
1134    io_write_byte_8(0x0003,tmp)
1134    io_write_byte_8le(0x0003,tmp)
11351135
11361136/* 6280 ********************************************************
11371137 *  STA Store accumulator
src/emu/cpu/m6800/m6800.h
r2375r2376
182182/* Read a byte from given memory location                                   */
183183/****************************************************************************/
184184/* ASG 971005 -- changed to program_read_byte_8/program_write_byte_8 */
185#define M6800_RDMEM(Addr) ((unsigned)program_read_byte_8(Addr))
185#define M6800_RDMEM(Addr) ((unsigned)program_read_byte_8be(Addr))
186186
187187/****************************************************************************/
188188/* Write a byte to given memory location                                    */
189189/****************************************************************************/
190#define M6800_WRMEM(Addr,Value) (program_write_byte_8(Addr,Value))
190#define M6800_WRMEM(Addr,Value) (program_write_byte_8be(Addr,Value))
191191
192192/****************************************************************************/
193193/* M6800_RDOP() is identical to M6800_RDMEM() except it is used for reading */
src/emu/cpu/m6800/m6800.c
r2375r2376
613613   m6800.port2_data = (m6800.port2_data & 0xef) | (value << 4);
614614
615615   if(m6800.port2_ddr == 0xff)
616      io_write_byte_8(M6803_PORT2,m6800.port2_data);
616      io_write_byte_8be(M6803_PORT2,m6800.port2_data);
617617   else
618      io_write_byte_8(M6803_PORT2,(m6800.port2_data & m6800.port2_ddr)
619         | (io_read_byte_8(M6803_PORT2) & (m6800.port2_ddr ^ 0xff)));
618      io_write_byte_8be(M6803_PORT2,(m6800.port2_data & m6800.port2_ddr)
619         | (io_read_byte_8be(M6803_PORT2) & (m6800.port2_ddr ^ 0xff)));
620620}
621621
622622static int m6800_rx(void)
623623{
624   return (io_read_byte_8(M6803_PORT2) & M6800_PORT2_IO3) >> 3;
624   return (io_read_byte_8be(M6803_PORT2) & M6800_PORT2_IO3) >> 3;
625625}
626626
627627static TIMER_CALLBACK(m6800_tx_tick)
r2375r2376
22932293      case 0x01:
22942294         return m6800.port2_ddr;
22952295      case 0x02:
2296         return (io_read_byte_8(M6803_PORT1) & (m6800.port1_ddr ^ 0xff))
2296         return (io_read_byte_8be(M6803_PORT1) & (m6800.port1_ddr ^ 0xff))
22972297               | (m6800.port1_data & m6800.port1_ddr);
22982298      case 0x03:
2299         return (io_read_byte_8(M6803_PORT2) & (m6800.port2_ddr ^ 0xff))
2299         return (io_read_byte_8be(M6803_PORT2) & (m6800.port2_ddr ^ 0xff))
23002300               | (m6800.port2_data & m6800.port2_ddr);
23012301      case 0x04:
23022302         return m6800.port3_ddr;
23032303      case 0x05:
23042304         return m6800.port4_ddr;
23052305      case 0x06:
2306         return (io_read_byte_8(M6803_PORT3) & (m6800.port3_ddr ^ 0xff))
2306         return (io_read_byte_8be(M6803_PORT3) & (m6800.port3_ddr ^ 0xff))
23072307               | (m6800.port3_data & m6800.port3_ddr);
23082308      case 0x07:
2309         return (io_read_byte_8(M6803_PORT4) & (m6800.port4_ddr ^ 0xff))
2309         return (io_read_byte_8be(M6803_PORT4) & (m6800.port4_ddr ^ 0xff))
23102310               | (m6800.port4_data & m6800.port4_ddr);
23112311      case 0x08:
23122312         m6800.pending_tcsr = 0;
r2375r2376
23912391         {
23922392            m6800.port1_ddr = data;
23932393            if(m6800.port1_ddr == 0xff)
2394               io_write_byte_8(M6803_PORT1,m6800.port1_data);
2394               io_write_byte_8be(M6803_PORT1,m6800.port1_data);
23952395            else
2396               io_write_byte_8(M6803_PORT1,(m6800.port1_data & m6800.port1_ddr)
2397                  | (io_read_byte_8(M6803_PORT1) & (m6800.port1_ddr ^ 0xff)));
2396               io_write_byte_8be(M6803_PORT1,(m6800.port1_data & m6800.port1_ddr)
2397                  | (io_read_byte_8be(M6803_PORT1) & (m6800.port1_ddr ^ 0xff)));
23982398         }
23992399         break;
24002400      case 0x01:
r2375r2376
24022402         {
24032403            m6800.port2_ddr = data;
24042404            if(m6800.port2_ddr == 0xff)
2405               io_write_byte_8(M6803_PORT2,m6800.port2_data);
2405               io_write_byte_8be(M6803_PORT2,m6800.port2_data);
24062406            else
2407               io_write_byte_8(M6803_PORT2,(m6800.port2_data & m6800.port2_ddr)
2408                  | (io_read_byte_8(M6803_PORT2) & (m6800.port2_ddr ^ 0xff)));
2407               io_write_byte_8be(M6803_PORT2,(m6800.port2_data & m6800.port2_ddr)
2408                  | (io_read_byte_8be(M6803_PORT2) & (m6800.port2_ddr ^ 0xff)));
24092409
24102410            if (m6800.port2_ddr & 2)
24112411               logerror("CPU #%d PC %04x: warning - port 2 bit 1 set as output (OLVL) - not supported\n",cpu_getactivecpu(),activecpu_get_pc());
r2375r2376
24142414      case 0x02:
24152415         m6800.port1_data = data;
24162416         if(m6800.port1_ddr == 0xff)
2417            io_write_byte_8(M6803_PORT1,m6800.port1_data);
2417            io_write_byte_8be(M6803_PORT1,m6800.port1_data);
24182418         else
2419            io_write_byte_8(M6803_PORT1,(m6800.port1_data & m6800.port1_ddr)
2420               | (io_read_byte_8(M6803_PORT1) & (m6800.port1_ddr ^ 0xff)));
2419            io_write_byte_8be(M6803_PORT1,(m6800.port1_data & m6800.port1_ddr)
2420               | (io_read_byte_8be(M6803_PORT1) & (m6800.port1_ddr ^ 0xff)));
24212421         break;
24222422      case 0x03:
24232423         if (m6800.trcsr & M6800_TRCSR_TE)
r2375r2376
24292429            m6800.port2_data = data;
24302430         }
24312431         if(m6800.port2_ddr == 0xff)
2432            io_write_byte_8(M6803_PORT2,m6800.port2_data);
2432            io_write_byte_8be(M6803_PORT2,m6800.port2_data);
24332433         else
2434            io_write_byte_8(M6803_PORT2,(m6800.port2_data & m6800.port2_ddr)
2435               | (io_read_byte_8(M6803_PORT2) & (m6800.port2_ddr ^ 0xff)));
2434            io_write_byte_8be(M6803_PORT2,(m6800.port2_data & m6800.port2_ddr)
2435               | (io_read_byte_8be(M6803_PORT2) & (m6800.port2_ddr ^ 0xff)));
24362436         break;
24372437      case 0x04:
24382438         if (m6800.port3_ddr != data)
24392439         {
24402440            m6800.port3_ddr = data;
24412441            if(m6800.port3_ddr == 0xff)
2442               io_write_byte_8(M6803_PORT3,m6800.port3_data);
2442               io_write_byte_8be(M6803_PORT3,m6800.port3_data);
24432443            else
2444               io_write_byte_8(M6803_PORT3,(m6800.port3_data & m6800.port3_ddr)
2445                  | (io_read_byte_8(M6803_PORT3) & (m6800.port3_ddr ^ 0xff)));
2444               io_write_byte_8be(M6803_PORT3,(m6800.port3_data & m6800.port3_ddr)
2445                  | (io_read_byte_8be(M6803_PORT3) & (m6800.port3_ddr ^ 0xff)));
24462446         }
24472447         break;
24482448      case 0x05:
r2375r2376
24502450         {
24512451            m6800.port4_ddr = data;
24522452            if(m6800.port4_ddr == 0xff)
2453               io_write_byte_8(M6803_PORT4,m6800.port4_data);
2453               io_write_byte_8be(M6803_PORT4,m6800.port4_data);
24542454            else
2455               io_write_byte_8(M6803_PORT4,(m6800.port4_data & m6800.port4_ddr)
2456                  | (io_read_byte_8(M6803_PORT4) & (m6800.port4_ddr ^ 0xff)));
2455               io_write_byte_8be(M6803_PORT4,(m6800.port4_data & m6800.port4_ddr)
2456                  | (io_read_byte_8be(M6803_PORT4) & (m6800.port4_ddr ^ 0xff)));
24572457         }
24582458         break;
24592459      case 0x06:
24602460         m6800.port3_data = data;
24612461         if(m6800.port3_ddr == 0xff)
2462            io_write_byte_8(M6803_PORT3,m6800.port3_data);
2462            io_write_byte_8be(M6803_PORT3,m6800.port3_data);
24632463         else
2464            io_write_byte_8(M6803_PORT3,(m6800.port3_data & m6800.port3_ddr)
2465               | (io_read_byte_8(M6803_PORT3) & (m6800.port3_ddr ^ 0xff)));
2464            io_write_byte_8be(M6803_PORT3,(m6800.port3_data & m6800.port3_ddr)
2465               | (io_read_byte_8be(M6803_PORT3) & (m6800.port3_ddr ^ 0xff)));
24662466         break;
24672467      case 0x07:
24682468         m6800.port4_data = data;
24692469         if(m6800.port4_ddr == 0xff)
2470            io_write_byte_8(M6803_PORT4,m6800.port4_data);
2470            io_write_byte_8be(M6803_PORT4,m6800.port4_data);
24712471         else
2472            io_write_byte_8(M6803_PORT4,(m6800.port4_data & m6800.port4_ddr)
2473               | (io_read_byte_8(M6803_PORT4) & (m6800.port4_ddr ^ 0xff)));
2472            io_write_byte_8be(M6803_PORT4,(m6800.port4_data & m6800.port4_ddr)
2473               | (io_read_byte_8be(M6803_PORT4) & (m6800.port4_ddr ^ 0xff)));
24742474         break;
24752475      case 0x08:
24762476         m6800.tcsr = data;
src/emu/cpu/i8x41/i8x41.c
r2375r2376
114114
115115static I8X41 i8x41;
116116
117#define RM(a)   program_read_byte_8(a)
118#define WM(a,v) program_write_byte_8(a,v)
119#define RP(a)   io_read_byte_8(a)
120#define WP(a,v) io_write_byte_8(a,v)
117#define RM(a)   program_read_byte_8le(a)
118#define WM(a,v) program_write_byte_8le(a,v)
119#define RP(a)   io_read_byte_8le(a)
120#define WP(a,v) io_write_byte_8le(a,v)
121121#define ROP(pc) cpu_readop(pc)
122122#define ROP_ARG(pc) cpu_readop_arg(pc)
123123
src/emu/cpu/konami/konami.h
r2375r2376
2323/****************************************************************************/
2424/* Read a byte from given memory location                                   */
2525/****************************************************************************/
26#define KONAMI_RDMEM(Addr) ((unsigned)program_read_byte_8(Addr))
26#define KONAMI_RDMEM(Addr) ((unsigned)program_read_byte_8be(Addr))
2727
2828/****************************************************************************/
2929/* Write a byte to given memory location                                    */
3030/****************************************************************************/
31#define KONAMI_WRMEM(Addr,Value) (program_write_byte_8(Addr,Value))
31#define KONAMI_WRMEM(Addr,Value) (program_write_byte_8be(Addr,Value))
3232
3333/****************************************************************************/
3434/* Z80_RDOP() is identical to Z80_RDMEM() except it is used for reading     */
src/emu/streams.c
r2375r2376
166166    FUNCTION PROTOTYPES
167167***************************************************************************/
168168
169static void stream_postload(void *param);
169static STATE_POSTLOAD( stream_postload );
170170static void allocate_resample_buffers(streams_private *strdata, sound_stream *stream);
171171static void allocate_output_buffers(streams_private *strdata, sound_stream *stream);
172172static void recompute_sample_rate_data(streams_private *strdata, sound_stream *stream);
r2375r2376
374374   /* create a unique tag for saving */
375375   sprintf(statetag, "stream.%d", stream->index);
376376   state_save_register_item(statetag, 0, stream->sample_rate);
377   state_save_register_func_postload_ptr(stream_postload, stream);
377   state_save_register_postload(Machine, stream_postload, stream);
378378
379379   /* allocate space for the inputs */
380380   if (inputs > 0)
r2375r2376
633633    stream_postload - save/restore callback
634634-------------------------------------------------*/
635635
636static void stream_postload(void *param)
636static STATE_POSTLOAD( stream_postload )
637637{
638   streams_private *strdata = Machine->streams_data;
638   streams_private *strdata = machine->streams_data;
639639   sound_stream *stream = param;
640640   int outputnum;
641641
src/emu/video/cdp1869.c
r2375r2376
144144
145145/* State Save Postload */
146146
147static void cdp1869_state_save_postload(void *param)
147static STATE_POSTLOAD( cdp1869_state_save_postload )
148148{
149149   update_prd_changed_timer(param);
150150}
r2375r2376
804804   // register for state saving
805805
806806   state_save_combine_module_and_tag(unique_tag, "CDP1869", device->tag);
807   state_save_register_func_postload_ptr(cdp1869_state_save_postload, cdp1869);
807   state_save_register_postload(device->machine, cdp1869_state_save_postload, cdp1869);
808808
809809   state_save_register_item(unique_tag, 0, cdp1869->dispoff);
810810   state_save_register_item(unique_tag, 0, cdp1869->fresvert);
src/emu/video/poly.c
r2375r2376
77***************************************************************************/
88
99#include "poly.h"
10#include "deprecat.h"
1011#include "eminline.h"
1112#include "mame.h"
1213#include "state.h"
r2375r2376
206207static void **allocate_array(size_t *itemsize, UINT32 itemcount);
207208static void free_array(void **array);
208209static void *poly_item_callback(void *param, int threadid);
209static void poly_state_presave(void *param);
210static STATE_PRESAVE( poly_state_presave );
210211
211212
212213
r2375r2376
360361      poly->queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_MULTI | WORK_QUEUE_FLAG_HIGH_FREQ);
361362
362363   /* request a pre-save callback for synchronization */
363   state_save_register_func_presave_ptr(poly_state_presave, poly);
364   state_save_register_presave(Machine, poly_state_presave, poly);
364365   return poly;
365366}
366367
r2375r2376
14201421    ensure everything is synced before saving
14211422-------------------------------------------------*/
14221423
1423static void poly_state_presave(void *param)
1424static STATE_PRESAVE( poly_state_presave )
14241425{
14251426   poly_manager *poly = param;
14261427   poly_wait(poly, "pre-save");
src/emu/video/mc6845.c
r2375r2376
108108};
109109
110110
111static void mc6845_state_save_postload(void *param);
111static STATE_POSTLOAD( mc6845_state_save_postload );
112112static void recompute_parameters(mc6845_t *mc6845, int postload);
113113static void update_de_changed_timer(mc6845_t *mc6845);
114114static void update_hsync_changed_timers(mc6845_t *mc6845);
r2375r2376
132132}
133133
134134
135static void mc6845_state_save_postload(void *param)
135static STATE_POSTLOAD( mc6845_state_save_postload )
136136{
137137   recompute_parameters(param, TRUE);
138138}
r2375r2376
723723   /* register for state saving */
724724   state_save_combine_module_and_tag(unique_tag, device_tags[device_type], device->tag);
725725
726   state_save_register_func_postload_ptr(mc6845_state_save_postload, mc6845);
726   state_save_register_postload(device->machine, mc6845_state_save_postload, mc6845);
727727
728728   state_save_register_item(unique_tag, 0, mc6845->clock);
729729   state_save_register_item(unique_tag, 0, mc6845->hpixels_per_column);
src/emu/info.c
r2375r2376
869869   begin_resource_tracking();
870870   config = machine_config_alloc(game->machine_config);
871871#ifdef MESS
872   /* temporary hook until MESS device transition is complete */
872873   mess_devices_setup(config, game);
873874#endif /* MESS */
874875   input = input_port_allocate(game->ipt, NULL);
src/emu/tilemap.c
r2375r2376
138138
139139/* system management helpers */
140140static void tilemap_exit(running_machine *machine);
141static void tilemap_postload(void *param);
141static STATE_POSTLOAD( tilemap_postload );
142142static void tilemap_dispose(tilemap *tmap);
143143
144144/* logical <-> memory index mapping */
r2375r2376
355355   tilemap_instance++;
356356
357357   /* reset everything after a load */
358   state_save_register_func_postload_ptr(tilemap_postload, tmap);
358   state_save_register_postload(Machine, tilemap_postload, tmap);
359359   return tmap;
360360}
361361
r2375r2376
379379
380380void tilemap_set_palette_offset(tilemap *tmap, UINT32 offset)
381381{
382   if (tmap->palette_offset != offset)
383   {
384      tmap->palette_offset = offset;
385      tilemap_mark_all_tiles_dirty(tmap);
386   }
382   tmap->palette_offset = offset;
387383}
388384
389385
r2375r2376
10541050    invalidate everything
10551051-------------------------------------------------*/
10561052
1057static void tilemap_postload(void *param)
1053static STATE_POSTLOAD( tilemap_postload )
10581054{
10591055   /* recompute the mappings for this tilemap */
10601056   tilemap *tmap = param;
src/emu/tilemap.h
r2375r2376
432432/* specify a parameter to be passed into the tile_get_info callback */
433433void tilemap_set_user_data(tilemap *tmap, void *user_data);
434434
435/* specify an offset to be added to each pixel before looking up the palette */
435/* specify an offset to be added to each pixel before looking up the palette
436 * The offset only applies at final rendering time (e.g., tilemap_draw())
437 * It does not apply to the cached pixmap, which is provided by tilemap_get_pixmap().
438 */
436439void tilemap_set_palette_offset(tilemap *tmap, UINT32 offset);
437440
438441/* set an enable flag for the tilemap; if 0, requests to draw the tilemap are ignored */
src/emu/video.c
r2375r2376
181181static osd_ticks_t throttle_until_ticks(running_machine *machine, osd_ticks_t target_ticks);
182182static void update_frameskip(running_machine *machine);
183183static void recompute_speed(running_machine *machine, attotime emutime);
184static void update_refresh_speed(running_machine *machine);
184185
185186/* screen snapshots */
186187static void create_snapshot_bitmap(const device_config *screen);
r2375r2376
305306
306307   /* extract initial execution state from global configuration settings */
307308   global.speed = original_speed_setting();
309   update_refresh_speed(machine);
308310   global.throttle = options_get_bool(mame_options(), OPTION_THROTTLE);
309311   global.auto_frameskip = options_get_bool(mame_options(), OPTION_AUTOFRAMESKIP);
310312   global.frameskip_level = options_get_int(mame_options(), OPTION_FRAMESKIP);
r2375r2376
699701   else
700702      state->vblank_period = config->vblank;
701703
702   /* adjust speed if necessary */
703   if (options_get_bool(mame_options(), OPTION_REFRESHSPEED))
704   {
705      float minrefresh = render_get_max_update_rate();
706      if (minrefresh != 0)
707      {
708         UINT32 target_speed = floor(minrefresh * 100.0 / ATTOSECONDS_TO_HZ(frame_period));
709         UINT32 original_speed = original_speed_setting();
710         target_speed = MIN(target_speed, original_speed);
711         if (target_speed != global.speed)
712         {
713            mame_printf_verbose("Adjusting target speed to %d%%\n", target_speed);
714            global.speed = target_speed;
715         }
716      }
717   }
718
719704   /* if we are on scanline 0 already, reset the update timer immediately */
720705   /* otherwise, defer until the next scanline 0 */
721706   if (video_screen_get_vpos(screen) == 0)
r2375r2376
725710
726711   /* start the VBLANK timer */
727712   timer_adjust_oneshot(state->vblank_begin_timer, video_screen_get_time_until_vblank_start(screen), 0);
713
714   /* adjust speed if necessary */
715   update_refresh_speed(screen->machine);
728716}
729717
730718
r2375r2376
16201608
16211609
16221610/*-------------------------------------------------
1611    video_get_speed_percent - return the current
1612    effective speed percentage
1613-------------------------------------------------*/
1614
1615double video_get_speed_percent(running_machine *machine)
1616{
1617   return global.speed_percent;
1618}
1619
1620
1621/*-------------------------------------------------
16231622    video_get_frameskip - return the current
16241623    actual frameskip (-1 means autoframeskip)
16251624-------------------------------------------------*/
r2375r2376
19731972
19741973
19751974/*-------------------------------------------------
1975    update_refresh_speed - update the global.speed
1976    based on the maximum refresh rate supported
1977-------------------------------------------------*/
1978
1979static void update_refresh_speed(running_machine *machine)
1980{
1981   /* only do this if the refreshspeed option is used */
1982   if (options_get_bool(mame_options(), OPTION_REFRESHSPEED))
1983   {
1984      float minrefresh = render_get_max_update_rate();
1985      if (minrefresh != 0)
1986      {
1987         attoseconds_t min_frame_period = ATTOSECONDS_PER_SECOND;
1988         UINT32 original_speed = original_speed_setting();
1989         const device_config *screen;
1990         UINT32 target_speed;
1991
1992         /* find the screen with the shortest frame period (max refresh rate) */
1993         for (screen = video_screen_first(machine->config); screen != NULL; screen = video_screen_next(screen))
1994         {
1995            screen_state *state = get_safe_token(screen);
1996            min_frame_period = MIN(min_frame_period, state->frame_period);
1997         }
1998
1999         /* compute a target speed as an integral percentage */
2000         target_speed = floor(minrefresh * 100.0 / ATTOSECONDS_TO_HZ(min_frame_period));
2001         target_speed = MIN(target_speed, original_speed);
2002
2003         /* if we changed, log that verbosely */
2004         if (target_speed != global.speed)
2005         {
2006            mame_printf_verbose("Adjusting target speed to %d%%\n", target_speed);
2007            global.speed = target_speed;
2008         }
2009      }
2010   }
2011}
2012
2013
2014/*-------------------------------------------------
19762015    recompute_speed - recompute the current
19772016    overall speed; we assume this is called only
19782017    if we did not skip a frame
src/emu/memory.c
r2375r2376
341341   /* program accessors */
342342   {
343343      {
344         { memory_set_opbase, program_read_byte_8, NULL, NULL, NULL, NULL, NULL, program_write_byte_8, NULL, NULL, NULL, NULL, NULL },
345         { memory_set_opbase, program_read_byte_8, NULL, NULL, NULL, NULL, NULL, program_write_byte_8, NULL, NULL, NULL, NULL, NULL }
344         { memory_set_opbase, program_read_byte_8le, program_read_word_8le, program_read_dword_8le, NULL, program_read_qword_8le, NULL, program_write_byte_8le, program_write_word_8le, program_write_dword_8le, NULL, program_write_qword_8le, NULL },
345         { memory_set_opbase, program_read_byte_8be, program_read_word_8be, program_read_dword_8be, NULL, program_read_qword_8be, NULL, program_write_byte_8be, program_write_word_8be, program_write_dword_8be, NULL, program_write_qword_8be, NULL }
346346      },
347347      {
348         { memory_set_opbase, program_read_byte_16le, program_read_word_16le, NULL, NULL, NULL, NULL, program_write_byte_16le, program_write_word_16le, NULL, NULL, NULL, NULL },
349         { memory_set_opbase, program_read_byte_16be, program_read_word_16be, NULL, NULL, NULL, NULL, program_write_byte_16be, program_write_word_16be, NULL, NULL, NULL, NULL }
348         { memory_set_opbase, program_read_byte_16le, program_read_word_16le, program_read_dword_16le, NULL, program_read_qword_16le, NULL, program_write_byte_16le, program_write_word_16le, program_write_dword_16le, NULL, program_write_qword_16le, NULL },
349         { memory_set_opbase, program_read_byte_16be, program_read_word_16be, program_read_dword_16be, NULL, program_read_qword_16be, NULL, program_write_byte_16be, program_write_word_16be, program_write_dword_16be, NULL, program_write_qword_16be, NULL }
350350      },
351351      {
352         { memory_set_opbase, program_read_byte_32le, program_read_word_32le, program_read_dword_32le, program_read_masked_32le, NULL, NULL, program_write_byte_32le, program_write_word_32le, program_write_dword_32le, program_write_masked_32le, NULL, NULL },
353         { memory_set_opbase, program_read_byte_32be, program_read_word_32be, program_read_dword_32be, program_read_masked_32be, NULL, NULL, program_write_byte_32be, program_write_word_32be, program_write_dword_32be, program_write_masked_32be, NULL, NULL }
352         { memory_set_opbase, program_read_byte_32le, program_read_word_32le, program_read_dword_32le, program_read_dword_masked_32le, program_read_qword_32le, NULL, program_write_byte_32le, program_write_word_32le, program_write_dword_32le, program_write_dword_masked_32le, program_write_qword_32le, NULL },
353         { memory_set_opbase, program_read_byte_32be, program_read_word_32be, program_read_dword_32be, program_read_dword_masked_32be, program_read_qword_32be, NULL, program_write_byte_32be, program_write_word_32be, program_write_dword_32be, program_write_dword_masked_32be, program_write_qword_32be, NULL }
354354      },
355355      {
356         { memory_set_opbase, program_read_byte_64le, program_read_word_64le, program_read_dword_64le, NULL, program_read_qword_64le, program_read_masked_64le, program_write_byte_64le, program_write_word_64le, program_write_dword_64le, NULL, program_write_qword_64le, program_write_masked_64le },
357         { memory_set_opbase, program_read_byte_64be, program_read_word_64be, program_read_dword_64be, NULL, program_read_qword_64be, program_read_masked_64be, program_write_byte_64be, program_write_word_64be, program_write_dword_64be, NULL, program_write_qword_64be, program_write_masked_64be }
356         { memory_set_opbase, program_read_byte_64le, program_read_word_64le, program_read_dword_64le, NULL, program_read_qword_64le, program_read_qword_masked_64le, program_write_byte_64le, program_write_word_64le, program_write_dword_64le, NULL, program_write_qword_64le, program_write_qword_masked_64le },
357         { memory_set_opbase, program_read_byte_64be, program_read_word_64be, program_read_dword_64be, NULL, program_read_qword_64be, program_read_qword_masked_64be, program_write_byte_64be, program_write_word_64be, program_write_dword_64be, NULL, program_write_qword_64be, program_write_qword_masked_64be }
358358      }
359359   },
360360
361361   /* data accessors */
362362   {
363363      {
364         { memory_set_opbase, data_read_byte_8, NULL, NULL, NULL, NULL, NULL, data_write_byte_8, NULL, NULL, NULL, NULL, NULL },
365         { memory_set_opbase, data_read_byte_8, NULL, NULL, NULL, NULL, NULL, data_write_byte_8, NULL, NULL, NULL, NULL, NULL }
364         { memory_set_opbase, data_read_byte_8le, data_read_word_8le, data_read_dword_8le, NULL, data_read_qword_8le, NULL, data_write_byte_8le, data_write_word_8le, data_write_dword_8le, NULL, data_write_qword_8le, NULL },
365         { memory_set_opbase, data_read_byte_8be, data_read_word_8be, data_read_dword_8be, NULL, data_read_qword_8be, NULL, data_write_byte_8be, data_write_word_8be, data_write_dword_8be, NULL, data_write_qword_8be, NULL }
366366      },
367367      {
368         { memory_set_opbase, data_read_byte_16le, data_read_word_16le, NULL, NULL, NULL, NULL, data_write_byte_16le, data_write_word_16le, NULL, NULL, NULL, NULL },
369         { memory_set_opbase, data_read_byte_16be, data_read_word_16be, NULL, NULL, NULL, NULL, data_write_byte_16be, data_write_word_16be, NULL, NULL, NULL, NULL }
368         { memory_set_opbase, data_read_byte_16le, data_read_word_16le, data_read_dword_16le, NULL, data_read_qword_16le, NULL, data_write_byte_16le, data_write_word_16le, data_write_dword_16le, NULL, data_write_qword_16le, NULL },
369         { memory_set_opbase, data_read_byte_16be, data_read_word_16be, data_read_dword_16be, NULL, data_read_qword_16be, NULL, data_write_byte_16be, data_write_word_16be, data_write_dword_16be, NULL, data_write_qword_16be, NULL }
370370      },
371371      {
372         { memory_set_opbase, data_read_byte_32le, data_read_word_32le, data_read_dword_32le, data_read_masked_32le, NULL, NULL, data_write_byte_32le, data_write_word_32le, data_write_dword_32le, data_write_masked_32le, NULL, NULL },
373         { memory_set_opbase, data_read_byte_32be, data_read_word_32be, data_read_dword_32be, data_read_masked_32be, NULL, NULL, data_write_byte_32be, data_write_word_32be, data_write_dword_32be, data_write_masked_32be, NULL, NULL }
372         { memory_set_opbase, data_read_byte_32le, data_read_word_32le, data_read_dword_32le, data_read_dword_masked_32le, data_read_qword_32le, NULL, data_write_byte_32le, data_write_word_32le, data_write_dword_32le, data_write_dword_masked_32le, data_write_qword_32le, NULL },
373         { memory_set_opbase, data_read_byte_32be, data_read_word_32be, data_read_dword_32be, data_read_dword_masked_32be, data_read_qword_32be, NULL, data_write_byte_32be, data_write_word_32be, data_write_dword_32be, data_write_dword_masked_32be, data_write_qword_32be, NULL }
374374      },
375375      {
376         { memory_set_opbase, data_read_byte_64le, data_read_word_64le, data_read_dword_64le, NULL, data_read_qword_64le, data_read_masked_64le, data_write_byte_64le, data_write_word_64le, data_write_dword_64le, NULL, data_write_qword_64le, data_write_masked_64le },
377         { memory_set_opbase, data_read_byte_64be, data_read_word_64be, data_read_dword_64be, NULL, data_read_qword_64be, data_read_masked_64be, data_write_byte_64be, data_write_word_64be, data_write_dword_64be, NULL, data_write_qword_64be, data_write_masked_64be }
376         { memory_set_opbase, data_read_byte_64le, data_read_word_64le, data_read_dword_64le, NULL, data_read_qword_64le, data_read_qword_masked_64le, data_write_byte_64le, data_write_word_64le, data_write_dword_64le, NULL, data_write_qword_64le, data_write_qword_masked_64le },
377         { memory_set_opbase, data_read_byte_64be, data_read_word_64be, data_read_dword_64be, NULL, data_read_qword_64be, data_read_qword_masked_64be, data_write_byte_64be, data_write_word_64be, data_write_dword_64be, NULL, data_write_qword_64be, data_write_qword_masked_64be }
378378      }
379379   },
380380
381381   /* I/O accessors */
382382   {
383383      {
384         { memory_set_opbase, io_read_byte_8, NULL, NULL, NULL, NULL, NULL, io_write_byte_8, NULL, NULL, NULL, NULL, NULL },
385         { memory_set_opbase, io_read_byte_8, NULL, NULL, NULL, NULL, NULL, io_write_byte_8, NULL, NULL, NULL, NULL, NULL }
384         { memory_set_opbase, io_read_byte_8le, io_read_word_8le, io_read_dword_8le, NULL, io_read_qword_8le, NULL, io_write_byte_8le, io_write_word_8le, io_write_dword_8le, NULL, io_write_qword_8le, NULL },
385         { memory_set_opbase, io_read_byte_8be, io_read_word_8be, io_read_dword_8be, NULL, io_read_qword_8be, NULL, io_write_byte_8be, io_write_word_8be, io_write_dword_8be, NULL, io_write_qword_8be, NULL }
386386      },
387387      {
388         { memory_set_opbase, io_read_byte_16le, io_read_word_16le, NULL, NULL, NULL, NULL, io_write_byte_16le, io_write_word_16le, NULL, NULL, NULL, NULL },
389         { memory_set_opbase, io_read_byte_16be, io_read_word_16be, NULL, NULL, NULL, NULL, io_write_byte_16be, io_write_word_16be, NULL, NULL, NULL, NULL }
388         { memory_set_opbase, io_read_byte_16le, io_read_word_16le, io_read_dword_16le, NULL, io_read_qword_16le, NULL, io_write_byte_16le, io_write_word_16le, io_write_dword_16le, NULL, io_write_qword_16le, NULL },
389         { memory_set_opbase, io_read_byte_16be, io_read_word_16be, io_read_dword_16be, NULL, io_read_qword_16be, NULL, io_write_byte_16be, io_write_word_16be, io_write_dword_16be, NULL, io_write_qword_16be, NULL }
390390      },
391391      {
392         { memory_set_opbase, io_read_byte_32le, io_read_word_32le, io_read_dword_32le, io_read_masked_32le, NULL, NULL, io_write_byte_32le, io_write_word_32le, io_write_dword_32le, io_write_masked_32le, NULL, NULL },
393         { memory_set_opbase, io_read_byte_32be, io_read_word_32be, io_read_dword_32be, io_read_masked_32be, NULL, NULL, io_write_byte_32be, io_write_word_32be, io_write_dword_32be, io_write_masked_32be, NULL, NULL }
392         { memory_set_opbase, io_read_byte_32le, io_read_word_32le, io_read_dword_32le, io_read_dword_masked_32le, io_read_qword_32le, NULL, io_write_byte_32le, io_write_word_32le, io_write_dword_32le, io_write_dword_masked_32le, io_write_qword_32le, NULL },
393         { memory_set_opbase, io_read_byte_32be, io_read_word_32be, io_read_dword_32be, io_read_dword_masked_32be, io_read_qword_32be, NULL, io_write_byte_32be, io_write_word_32be, io_write_dword_32be, io_write_dword_masked_32be, io_write_qword_32be, NULL }
394394      },
395395      {
396         { memory_set_opbase, io_read_byte_64le, io_read_word_64le, io_read_dword_64le, NULL, io_read_qword_64le, io_read_masked_64le, io_write_byte_64le, io_write_word_64le, io_write_dword_64le, NULL, io_write_qword_64le, io_write_masked_64le },
397         { memory_set_opbase, io_read_byte_64be, io_read_word_64be, io_read_dword_64be, NULL, io_read_qword_64be, io_read_masked_64be, io_write_byte_64be, io_write_word_64be, io_write_dword_64be, NULL, io_write_qword_64be, io_write_masked_64be }
396         { memory_set_opbase, io_read_byte_64le, io_read_word_64le, io_read_dword_64le, NULL, io_read_qword_64le, io_read_qword_masked_64le, io_write_byte_64le, io_write_word_64le, io_write_dword_64le, NULL, io_write_qword_64le, io_write_qword_masked_64le },
397         { memory_set_opbase, io_read_byte_64be, io_read_word_64be, io_read_dword_64be, NULL, io_read_qword_64be, io_read_qword_masked_64be, io_write_byte_64be, io_write_word_64be, io_write_dword_64be, NULL, io_write_qword_64be, io_write_qword_masked_64be }
398398      }
399399   },
400400};
r2375r2376
428428static void *allocate_memory_block(int cpunum, int spacenum, offs_t bytestart, offs_t byteend, void *memory);
429429static void register_for_save(int cpunum, int spacenum, offs_t bytestart, void *base, size_t numbytes);
430430static address_map_entry *assign_intersecting_blocks(addrspace_data *space, offs_t bytestart, offs_t byteend, UINT8 *base);
431static void memory_init_locate(void);
431static void memory_init_locate(running_machine *machine);
432432static void *memory_find_base(int cpunum, int spacenum, offs_t byteaddress);
433433static genf *get_static_handler(int databits, int readorwrite, int spacenum, int which);
434434static void memory_exit(running_machine *machine);
r2375r2376
513513   memory_init_allocate(machine->config);
514514
515515   /* find all the allocated pointers */
516   memory_init_locate();
516   memory_init_locate(machine);
517517
518518   /* dump the final memory configuration */
519519   mem_dump();
r2375r2376
23842384    reattach_banks - reconnect banks after a load
23852385-------------------------------------------------*/
23862386
2387static void reattach_banks(void)
2387static STATE_POSTLOAD( reattach_banks )
23882388{
23892389   int banknum;
23902390
r2375r2376
24042404    into the final allocated memory
24052405-------------------------------------------------*/
24062406
2407static void memory_init_locate(void)
2407static void memory_init_locate(running_machine *machine)
24082408{
24092409   int cpunum, spacenum, banknum;
24102410
r2375r2376
24522452      }
24532453
24542454   /* request a callback to fix up the banks when done */
2455   state_save_register_func_postload(reattach_banks);
2455   state_save_register_postload(machine, reattach_banks, NULL);
24562456}
24572457
24582458
r2375r2376
24942494}
24952495
24962496
2497/*-------------------------------------------------
2498    PERFORM_LOOKUP - common lookup procedure
2499-------------------------------------------------*/
25002497
2501#define PERFORM_LOOKUP(lookup,handlers,spacenum,extraand)                        \
2502   /* perform lookup */                                                \
2503   address &= active_address_space[spacenum].bytemask & extraand;                  \
2504   entry = active_address_space[spacenum].lookup[LEVEL1_INDEX(address)];            \
2505   if (entry >= SUBTABLE_BASE)                                             \
2506      entry = active_address_space[spacenum].lookup[LEVEL2_INDEX(entry,address)];      \
2507   handler = &active_address_space[spacenum].handlers[entry];                     \
2508
2509
25102498/*-------------------------------------------------
2511    READBYTE - generic byte-sized read handler
2512-------------------------------------------------*/
2513
2514#define READBYTE8(name,spacenum)                                          \
2515UINT8 name(offs_t original_address)                                          \
2516{                                                                  \
2517   offs_t address = original_address;                                       \
2518   const handler_data *handler;                                          \
2519   UINT32 entry;                                                      \
2520   MEMREADSTART();                                                      \
2521   PERFORM_LOOKUP(readlookup,readhandlers,spacenum,~0);                        \
2522   DEBUG_HOOK_READ(spacenum, address, 0xff);                                 \
2523                                                                  \
2524   /* handle banks inline */                                             \
2525   address = (address - handler->bytestart) & handler->bytemask;                  \
2526   if (entry < STATIC_RAM)                                              \
2527      MEMREADEND(bank_ptr[entry][address]);                                 \
2528                                                                  \
2529   /* fall back to the handler */                                          \
2530   else                                                            \
2531      MEMREADEND((*handler->handler.read.mhandler8)(handler->object, address));      \
2532}                                                                  \
2533
2534#define READBYTE(name,spacenum,xormacro,handlertype,ignorebits,shiftbytes,masktype)      \
2535UINT8 name(offs_t original_address)                                          \
2536{                                                                  \
2537   offs_t address = original_address;                                       \
2538   const handler_data *handler;                                          \
2539   UINT32 entry;                                                      \
2540   MEMREADSTART();                                                      \
2541   PERFORM_LOOKUP(readlookup,readhandlers,spacenum,~0);                        \
2542   DEBUG_HOOK_READ(spacenum, address - xormacro(shiftbytes), (masktype)0xff << (8 * (shiftbytes)));   \
2543                                                                  \
2544   /* handle banks inline */                                             \
2545   address = (address - handler->bytestart) & handler->bytemask;                  \
2546   if (entry < STATIC_RAM)                                                \
2547      MEMREADEND(bank_ptr[entry][xormacro(address)]);                           \
2548                                                                  \
2549   /* fall back to the handler */                                          \
2550   else                                                            \
2551   {                                                               \
2552      int shift = 8 * (shiftbytes);                                       \
2553      MEMREADEND((*handler->handler.read.handlertype)(handler->object, address >> (ignorebits), ~((masktype)0xff << shift)) >> shift);\
2554   }                                                               \
2555}                                                                  \
2556
2557#define READBYTE16BE(name,space)   READBYTE(name,space,BYTE_XOR_BE, mhandler16,1,~address & 1,UINT16)
2558#define READBYTE16LE(name,space)   READBYTE(name,space,BYTE_XOR_LE, mhandler16,1, address & 1,UINT16)
2559#define READBYTE32BE(name,space)   READBYTE(name,space,BYTE4_XOR_BE,mhandler32,2,~address & 3,UINT32)
2560#define READBYTE32LE(name,space)   READBYTE(name,space,BYTE4_XOR_LE,mhandler32,2, address & 3,UINT32)
2561#define READBYTE64BE(name,space)   READBYTE(name,space,BYTE8_XOR_BE,mhandler64,3,~address & 7,UINT64)
2562#define READBYTE64LE(name,space)   READBYTE(name,space,BYTE8_XOR_LE,mhandler64,3, address & 7,UINT64)
2563
2564
2565/*-------------------------------------------------
2566    READWORD - generic word-sized read handler
2567    (16-bit, 32-bit and 64-bit aligned only!)
2568-------------------------------------------------*/
2569
2570#define READWORD16(name,spacenum)                                          \
2571UINT16 name(offs_t original_address)                                       \
2572{                                                                  \
2573   offs_t address = original_address;                                       \
2574   const handler_data *handler;                                          \
2575   UINT32 entry;                                                      \
2576   MEMREADSTART();                                                      \
2577   PERFORM_LOOKUP(readlookup,readhandlers,spacenum,~1);                        \
2578   DEBUG_HOOK_READ(spacenum, address, 0xffff);                                 \
2579                                                                  \
2580   /* handle banks inline */                                             \
2581   address = (address - handler->bytestart) & handler->bytemask;                  \
2582   if (entry < STATIC_RAM)                                                \
2583      MEMREADEND(*(UINT16 *)&bank_ptr[entry][address]);                        \
2584                                                                  \
2585   /* fall back to the handler */                                          \
2586   else                                                            \
2587      MEMREADEND((*handler->handler.read.mhandler16)(handler->object, address >> 1, 0));\
2588}                                                                  \
2589
2590#define READWORD(name,spacenum,xormacro,handlertype,ignorebits,shiftbytes,masktype)      \
2591UINT16 name(offs_t original_address)                                       \
2592{                                                                  \
2593   offs_t address = original_address;                                       \
2594   const handler_data *handler;                                          \
2595   UINT32 entry;                                                      \
2596   MEMREADSTART();                                                      \
2597   PERFORM_LOOKUP(readlookup,readhandlers,spacenum,~1);                        \
2598   DEBUG_HOOK_READ(spacenum, address - xormacro(shiftbytes), (masktype)0xffff << (8 * (shiftbytes)));   \
2599                                                                  \
2600   /* handle banks inline */                                             \
2601   address = (address - handler->bytestart) & handler->bytemask;                  \
2602   if (entry < STATIC_RAM)                                                \
2603      MEMREADEND(*(UINT16 *)&bank_ptr[entry][xormacro(address)]);                  \
2604                                                                  \
2605   /* fall back to the handler */                                          \
2606   else                                                            \
2607   {                                                               \
2608      int shift = 8 * (shiftbytes);                                       \
2609      MEMREADEND((*handler->handler.read.handlertype)(handler->object, address >> (ignorebits), ~((masktype)0xffff << shift)) >> shift);\
2610   }                                                               \
2611}                                                                  \
2612
2613#define READWORD32BE(name,space)   READWORD(name,space,WORD_XOR_BE, mhandler32,2,~address & 2,UINT32)
2614#define READWORD32LE(name,space)   READWORD(name,space,WORD_XOR_LE, mhandler32,2, address & 2,UINT32)
2615#define READWORD64BE(name,space)   READWORD(name,space,WORD2_XOR_BE,mhandler64,3,~address & 6,UINT64)
2616#define READWORD64LE(name,space)   READWORD(name,space,WORD2_XOR_LE,mhandler64,3, address & 6,UINT64)
2617
2618
2619/*-------------------------------------------------
2620    READDWORD - generic dword-sized read handler
2621    (32-bit and 64-bit aligned only!)
2622-------------------------------------------------*/
2623
2624#define READDWORD32(name,spacenum)                                          \
2625UINT32 name(offs_t original_address)                                       \
2626{                                                                  \
2627   offs_t address = original_address;                                       \
2628   const handler_data *handler;                                          \
2629   UINT32 entry;                                                      \
2630   MEMREADSTART();                                                      \
2631   PERFORM_LOOKUP(readlookup,readhandlers,spacenum,~3);                        \
2632   DEBUG_HOOK_READ(spacenum, address, 0xffffffff);                              \
2633                                                                  \
2634   /* handle banks inline */                                             \
2635   address = (address - handler->bytestart) & handler->bytemask;                  \
2636   if (entry < STATIC_RAM)                                                \
2637      MEMREADEND(*(UINT32 *)&bank_ptr[entry][address]);                        \
2638                                                                  \
2639   /* fall back to the handler */                                          \
2640   else                                                            \
2641      MEMREADEND((*handler->handler.read.mhandler32)(handler->object, address >> 2, 0));\
2642}                                                                  \
2643
2644#define READMASKED32(name,spacenum)                                          \
2645UINT32 name(offs_t original_address, UINT32 mem_mask)                           \
2646{                                                                  \
2647   offs_t address = original_address;                                       \
2648   const handler_data *handler;                                          \
2649   UINT32 entry;                                                      \
2650   MEMREADSTART();                                                      \
2651   PERFORM_LOOKUP(readlookup,readhandlers,spacenum,~3);                        \
2652   DEBUG_HOOK_READ(spacenum, address, ~mem_mask);                              \
2653                                                                  \
2654   /* handle banks inline */                                             \
2655   address = (address - handler->bytestart) & handler->bytemask;                  \
2656   if (entry < STATIC_RAM)                                                \
2657      MEMREADEND(*(UINT32 *)&bank_ptr[entry][address]);                        \
2658                                                                  \
2659   /* fall back to the handler */                                          \
2660   else                                                            \
2661      MEMREADEND((*handler->handler.read.mhandler32)(handler->object, address >> 2, mem_mask));\
2662}                                                                  \
2663
2664#define READDWORD(name,spacenum,xormacro,handlertype,ignorebits,shiftbytes,masktype)   \
2665UINT32 name(offs_t original_address)                                       \
2666{                                                                  \
2667   offs_t address = original_address;                                       \
2668   const handler_data *handler;                                          \
2669   UINT32 entry;                                                      \
2670   MEMREADSTART();                                                      \
2671   PERFORM_LOOKUP(readlookup,readhandlers,spacenum,~3);                        \
2672   DEBUG_HOOK_READ(spacenum, address - xormacro(shiftbytes), (masktype)0xffffffff << (8 * (shiftbytes)));   \
2673                                                                  \
2674   /* handle banks inline */                                             \
2675   address = (address - handler->bytestart) & handler->bytemask;                  \
2676   if (entry < STATIC_RAM)                                                \
2677      MEMREADEND(*(UINT32 *)&bank_ptr[entry][xormacro(address)]);                  \
2678                                                                  \
2679   /* fall back to the handler */                                          \
2680   else                                                            \
2681   {                                                               \
2682      int shift = 8 * (shiftbytes);                                       \
2683      MEMREADEND((*handler->handler.read.handlertype)(handler->object, address >> (ignorebits), ~((masktype)0xffffffff << shift)) >> shift);\
2684   }                                                               \
2685}                                                                  \
2686
2687#define READDWORD64BE(name,space)   READDWORD(name,space,DWORD_XOR_BE,mhandler64,3,~address & 4,UINT64)
2688#define READDWORD64LE(name,space)   READDWORD(name,space,DWORD_XOR_LE,mhandler64,3, address & 4,UINT64)
2689
2690
2691/*-------------------------------------------------
2692    READQWORD - generic qword-sized read handler
2693    (64-bit aligned only!)
2694-------------------------------------------------*/
2695
2696#define READQWORD64(name,spacenum)                                          \
2697UINT64 name(offs_t original_address)                                       \
2698{                                                                  \
2699   offs_t address = original_address;                                       \
2700   const handler_data *handler;                                          \
2701   UINT32 entry;                                                      \
2702   MEMREADSTART();                                                      \
2703   PERFORM_LOOKUP(readlookup,readhandlers,spacenum,~7);                        \
2704   DEBUG_HOOK_READ(spacenum, address, ~(UINT64)0);                              \
2705                                                                  \
2706   /* handle banks inline */                                             \
2707   address = (address - handler->bytestart) & handler->bytemask;                  \
2708   if (entry < STATIC_RAM)                                                \
2709      MEMREADEND(*(UINT64 *)&bank_ptr[entry][address]);                        \
2710                                                                  \
2711   /* fall back to the handler */                                          \
2712   else                                                            \
2713      MEMREADEND((*handler->handler.read.mhandler64)(handler->object, address >> 3, 0));\
2714}                                                                  \
2715
2716#define READMASKED64(name,spacenum)                                          \
2717UINT64 name(offs_t original_address, UINT64 mem_mask)                           \
2718{                                                                  \
2719   offs_t address = original_address;                                       \
2720   const handler_data *handler;                                          \
2721   UINT32 entry;                                                      \
2722   MEMREADSTART();                                                      \
2723   PERFORM_LOOKUP(readlookup,readhandlers,spacenum,~7);                        \
2724   DEBUG_HOOK_READ(spacenum, address, ~mem_mask);                              \
2725                                                                  \
2726   /* handle banks inline */                                             \
2727   address = (address - handler->bytestart) & handler->bytemask;                  \
2728   if (entry < STATIC_RAM)                                                \
2729      MEMREADEND(*(UINT64 *)&bank_ptr[entry][address]);                        \
2730                                                                  \
2731   /* fall back to the handler */                                          \
2732   else                                                            \
2733      MEMREADEND((*handler->handler.read.mhandler64)(handler->object, address >> 3, mem_mask));\
2734}                                                                  \
2735
2736
2737/*-------------------------------------------------
2738    WRITEBYTE - generic byte-sized write handler
2739-------------------------------------------------*/
2740
2741#define WRITEBYTE8(name,spacenum)                                          \
2742void name(offs_t original_address, UINT8 data)                                 \
2743{                                                                  \
2744   offs_t address = original_address;                                       \
2745   const handler_data *handler;                                          \
2746   UINT32 entry;                                                      \
2747   MEMWRITESTART();                                                   \
2748   PERFORM_LOOKUP(writelookup,writehandlers,spacenum,~0);                        \
2749   DEBUG_HOOK_WRITE(spacenum, address, data, 0xff);                           \
2750                                                                  \
2751   /* handle banks inline */                                             \
2752   address = (address - handler->bytestart) & handler->bytemask;                  \
2753   if (entry < STATIC_RAM)                                                \
2754      MEMWRITEEND(bank_ptr[entry][address] = data);                           \
2755                                                                  \
2756   /* fall back to the handler */                                          \
2757   else                                                            \
2758      MEMWRITEEND((*handler->handler.write.mhandler8)(handler->object, address, data));\
2759}                                                                  \
2760
2761#define WRITEBYTE(name,spacenum,xormacro,handlertype,ignorebits,shiftbytes,masktype)   \
2762void name(offs_t original_address, UINT8 data)                                 \
2763{                                                                  \
2764   offs_t address = original_address;                                       \
2765   const handler_data *handler;                                          \
2766   UINT32 entry;                                                      \
2767   MEMWRITESTART();                                                   \
2768   PERFORM_LOOKUP(writelookup,writehandlers,spacenum,~0);                        \
2769   DEBUG_HOOK_WRITE(spacenum, address - xormacro(shiftbytes), (masktype)data << (8 * (shiftbytes)), (masktype)0xff << (8 * (shiftbytes)));   \
2770                                                                  \
2771   /* handle banks inline */                                             \
2772   address = (address - handler->bytestart) & handler->bytemask;                  \
2773   if (entry < STATIC_RAM)                                                \
2774      MEMWRITEEND(bank_ptr[entry][xormacro(address)] = data);                     \
2775                                                                  \
2776   /* fall back to the handler */                                          \
2777   else                                                            \
2778   {                                                               \
2779      int shift = 8 * (shiftbytes);                                       \
2780      MEMWRITEEND((*handler->handler.write.handlertype)(handler->object, address >> (ignorebits), (masktype)data << shift, ~((masktype)0xff << shift)));\
2781   }                                                               \
2782}                                                                  \
2783
2784#define WRITEBYTE16BE(name,space)   WRITEBYTE(name,space,BYTE_XOR_BE, mhandler16,1,~address & 1,UINT16)
2785#define WRITEBYTE16LE(name,space)   WRITEBYTE(name,space,BYTE_XOR_LE, mhandler16,1, address & 1,UINT16)
2786#define WRITEBYTE32BE(name,space)   WRITEBYTE(name,space,BYTE4_XOR_BE,mhandler32,2,~address & 3,UINT32)
2787#define WRITEBYTE32LE(name,space)   WRITEBYTE(name,space,BYTE4_XOR_LE,mhandler32,2, address & 3,UINT32)
2788#define WRITEBYTE64BE(name,space)   WRITEBYTE(name,space,BYTE8_XOR_BE,mhandler64,3,~address & 7,UINT64)
2789#define WRITEBYTE64LE(name,space)   WRITEBYTE(name,space,BYTE8_XOR_LE,mhandler64,3, address & 7,UINT64)
2790
2791
2792/*-------------------------------------------------
2793    WRITEWORD - generic word-sized write handler
2794    (16-bit, 32-bit and 64-bit aligned only!)
2795-------------------------------------------------*/
2796
2797#define WRITEWORD16(name,spacenum)                                          \
2798void name(offs_t original_address, UINT16 data)                                 \
2799{                                                                  \
2800   offs_t address = original_address;                                       \
2801   const handler_data *handler;                                          \
2802   UINT32 entry;                                                      \
2803   MEMWRITESTART();                                                   \
2804   PERFORM_LOOKUP(writelookup,writehandlers,spacenum,~1);                        \
2805   DEBUG_HOOK_WRITE(spacenum, address, data, 0xffff);                           \
2806                                                                  \
2807   /* handle banks inline */                                             \
2808   address = (address - handler->bytestart) & handler->bytemask;                  \
2809   if (entry < STATIC_RAM)                                                \
2810      MEMWRITEEND(*(UINT16 *)&bank_ptr[entry][address] = data);                  \
2811                                                                  \
2812   /* fall back to the handler */                                          \
2813   else                                                            \
2814      MEMWRITEEND((*handler->handler.write.mhandler16)(handler->object, address >> 1, data, 0));\
2815}                                                                  \
2816
2817#define WRITEWORD(name,spacenum,xormacro,handlertype,ignorebits,shiftbytes,masktype)   \
2818void name(offs_t original_address, UINT16 data)                                 \
2819{                                                                  \
2820   offs_t address = original_address;                                       \
2821   const handler_data *handler;                                          \
2822   UINT32 entry;                                                      \
2823   MEMWRITESTART();                                                   \
2824   PERFORM_LOOKUP(writelookup,writehandlers,spacenum,~1);                        \
2825   DEBUG_HOOK_WRITE(spacenum, address - xormacro(shiftbytes), (masktype)data << (8 * (shiftbytes)), (masktype)0xffff << (8 * (shiftbytes)));   \
2826                                                                  \
2827   /* handle banks inline */                                             \
2828   address = (address - handler->bytestart) & handler->bytemask;                  \
2829   if (entry < STATIC_RAM)                                                \
2830      MEMWRITEEND(*(UINT16 *)&bank_ptr[entry][xormacro(address)] = data);            \
2831                                                                  \
2832   /* fall back to the handler */                                          \
2833   else                                                            \
2834   {                                                               \
2835      int shift = 8 * (shiftbytes);                                       \
2836      MEMWRITEEND((*handler->handler.write.handlertype)(handler->object, address >> (ignorebits), (masktype)data << shift, ~((masktype)0xffff << shift)));\
2837   }                                                               \
2838}                                                                  \
2839
2840#define WRITEWORD32BE(name,space)   WRITEWORD(name,space,WORD_XOR_BE, mhandler32,2,~address & 2,UINT32)
2841#define WRITEWORD32LE(name,space)   WRITEWORD(name,space,WORD_XOR_LE, mhandler32,2, address & 2,UINT32)
2842#define WRITEWORD64BE(name,space)   WRITEWORD(name,space,WORD2_XOR_BE,mhandler64,3,~address & 6,UINT64)
2843#define WRITEWORD64LE(name,space)   WRITEWORD(name,space,WORD2_XOR_LE,mhandler64,3, address & 6,UINT64)
2844
2845
2846/*-------------------------------------------------
2847    WRITEDWORD - dword-sized write handler
2848    (32-bit and 64-bit aligned only!)
2849-------------------------------------------------*/
2850
2851#define WRITEDWORD32(name,spacenum)                                          \
2852void name(offs_t original_address, UINT32 data)                                 \
2853{                                                                  \
2854   offs_t address = original_address;                                       \
2855   const handler_data *handler;                                          \
2856   UINT32 entry;                                                      \
2857   MEMWRITESTART();                                                   \
2858   PERFORM_LOOKUP(writelookup,writehandlers,spacenum,~3);                        \
2859   DEBUG_HOOK_WRITE(spacenum, address, data, 0xffffffff);                        \
2860                                                                  \
2861   /* handle banks inline */                                             \
2862   address = (address - handler->bytestart) & handler->bytemask;                  \
2863   if (entry < STATIC_RAM)                                                \
2864      MEMWRITEEND(*(UINT32 *)&bank_ptr[entry][address] = data);                  \
2865                                                                  \
2866   /* fall back to the handler */                                          \
2867   else                                                            \
2868      MEMWRITEEND((*handler->handler.write.mhandler32)(handler->object, address >> 2, data, 0));\
2869}                                                                  \
2870
2871#define WRITEMASKED32(name,spacenum)                                       \
2872void name(offs_t original_address, UINT32 data, UINT32 mem_mask)                  \
2873{                                                                  \
2874   offs_t address = original_address;                                       \
2875   const handler_data *handler;                                          \
2876   UINT32 entry;                                                      \
2877   MEMWRITESTART();                                                   \
2878   PERFORM_LOOKUP(writelookup,writehandlers,spacenum,~3);                        \
2879   DEBUG_HOOK_WRITE(spacenum, address, data, ~mem_mask);                        \
2880                                                                  \
2881   /* handle banks inline */                                             \
2882   address = (address - handler->bytestart) & handler->bytemask;                  \
2883   if (entry < STATIC_RAM)                                                \
2884   {                                                               \
2885      UINT32 *dest = (UINT32 *)&bank_ptr[entry][address];                        \
2886      MEMWRITEEND(*dest = (*dest & mem_mask) | (data & ~mem_mask));               \
2887   }                                                               \
2888                                                                  \
2889   /* fall back to the handler */                                          \
2890   else                                                            \
2891      MEMWRITEEND((*handler->handler.write.mhandler32)(handler->object, address >> 2, data, mem_mask));\
2892}                                                                  \
2893
2894#define WRITEDWORD(name,spacenum,xormacro,handlertype,ignorebits,shiftbytes,masktype)   \
2895void name(offs_t original_address, UINT32 data)                                 \
2896{                                                                  \
2897   offs_t address = original_address;                                       \
2898   const handler_data *handler;                                          \
2899   UINT32 entry;                                                      \
2900   MEMWRITESTART();                                                   \
2901   PERFORM_LOOKUP(writelookup,writehandlers,spacenum,~3);                        \
2902   DEBUG_HOOK_WRITE(spacenum, address - xormacro(shiftbytes), (masktype)data << (8 * (shiftbytes)), (masktype)0xffffffff << (8 * (shiftbytes)));   \
2903                                                                  \
2904   /* handle banks inline */                                             \
2905   address = (address - handler->bytestart) & handler->bytemask;                  \
2906   if (entry < STATIC_RAM)                                                \
2907      MEMWRITEEND(*(UINT32 *)&bank_ptr[entry][xormacro(address)] = data);            \
2908                                                                  \
2909   /* fall back to the handler */                                          \
2910   else                                                            \
2911   {                                                               \
2912      int shift = 8 * (shiftbytes);                                       \
2913      MEMWRITEEND((*handler->handler.write.handlertype)(handler->object, address >> (ignorebits), (masktype)data << shift, ~((masktype)0xffffffff << shift)));\
2914   }                                                               \
2915}                                                                  \
2916
2917#define WRITEDWORD64BE(name,space)   WRITEDWORD(name,space,DWORD_XOR_BE,mhandler64,3,~address & 4,UINT64)
2918#define WRITEDWORD64LE(name,space)   WRITEDWORD(name,space,DWORD_XOR_LE,mhandler64,3, address & 4,UINT64)
2919
2920
2921/*-------------------------------------------------
2922    WRITEQWORD - qword-sized write handler
2923    (64-bit aligned only!)
2924-------------------------------------------------*/
2925
2926#define WRITEQWORD64(name,spacenum)                                          \
2927void name(offs_t original_address, UINT64 data)                                 \
2928{                                                                  \
2929   offs_t address = original_address;                                       \
2930   const handler_data *handler;                                          \
2931   UINT32 entry;                                                      \
2932   MEMWRITESTART();                                                   \
2933   PERFORM_LOOKUP(writelookup,writehandlers,spacenum,~7);                        \
2934   DEBUG_HOOK_WRITE(spacenum, address, data, ~(UINT64)0);                        \
2935                                                                  \
2936   /* handle banks inline */                                             \
2937   address = (address - handler->bytestart) & handler->bytemask;                  \
2938   if (entry < STATIC_RAM)                                                \
2939      MEMWRITEEND(*(UINT64 *)&bank_ptr[entry][address] = data);                  \
2940                                                                  \
2941   /* fall back to the handler */                                          \
2942   else                                                            \
2943      MEMWRITEEND((*handler->handler.write.mhandler64)(handler->object, address >> 3, data, 0));\
2944}                                                                  \
2945
2946#define WRITEMASKED64(name,spacenum)                                       \
2947void name(offs_t original_address, UINT64 data, UINT64 mem_mask)                  \
2948{                                                                  \
2949   offs_t address = original_address;                                       \
2950   const handler_data *handler;                                          \
2951   UINT32 entry;                                                      \
2952   MEMWRITESTART();                                                   \
2953   PERFORM_LOOKUP(writelookup,writehandlers,spacenum,~7);                        \
2954   DEBUG_HOOK_WRITE(spacenum, address, data, ~mem_mask);                        \
2955                                                                  \
2956   /* handle banks inline */                                             \
2957   address = (address - handler->bytestart) & handler->bytemask;                  \
2958   if (entry < STATIC_RAM)                                                \
2959   {                                                               \
2960      UINT64 *dest = (UINT64 *)&bank_ptr[entry][address];                        \
2961      MEMWRITEEND(*dest = (*dest & mem_mask) | (data & ~mem_mask));               \
2962   }                                                               \
2963                                                                  \
2964   /* fall back to the handler */                                          \
2965   else                                                            \
2966      MEMWRITEEND((*handler->handler.write.mhandler64)(handler->object, address >> 3, data, mem_mask));\
2967}                                                                  \
2968
2969
2970/*-------------------------------------------------
2971    Program memory handlers
2972-------------------------------------------------*/
2973
2974     READBYTE8(program_read_byte_8,      ADDRESS_SPACE_PROGRAM)
2975    WRITEBYTE8(program_write_byte_8,     ADDRESS_SPACE_PROGRAM)
2976
2977  READBYTE16BE(program_read_byte_16be,   ADDRESS_SPACE_PROGRAM)
2978    READWORD16(program_read_word_16be,   ADDRESS_SPACE_PROGRAM)
2979 WRITEBYTE16BE(program_write_byte_16be,  ADDRESS_SPACE_PROGRAM)
2980   WRITEWORD16(program_write_word_16be,  ADDRESS_SPACE_PROGRAM)
2981
2982  READBYTE16LE(program_read_byte_16le,   ADDRESS_SPACE_PROGRAM)
2983    READWORD16(program_read_word_16le,   ADDRESS_SPACE_PROGRAM)
2984 WRITEBYTE16LE(program_write_byte_16le,  ADDRESS_SPACE_PROGRAM)
2985   WRITEWORD16(program_write_word_16le,  ADDRESS_SPACE_PROGRAM)
2986
2987  READBYTE32BE(program_read_byte_32be,   ADDRESS_SPACE_PROGRAM)
2988  READWORD32BE(program_read_word_32be,   ADDRESS_SPACE_PROGRAM)
2989   READDWORD32(program_read_dword_32be,  ADDRESS_SPACE_PROGRAM)
2990  READMASKED32(program_read_masked_32be, ADDRESS_SPACE_PROGRAM)
2991 WRITEBYTE32BE(program_write_byte_32be,  ADDRESS_SPACE_PROGRAM)
2992 WRITEWORD32BE(program_write_word_32be,  ADDRESS_SPACE_PROGRAM)
2993  WRITEDWORD32(program_write_dword_32be, ADDRESS_SPACE_PROGRAM)
2994 WRITEMASKED32(program_write_masked_32be,ADDRESS_SPACE_PROGRAM)
2995
2996  READBYTE32LE(program_read_byte_32le,   ADDRESS_SPACE_PROGRAM)
2997  READWORD32LE(program_read_word_32le,   ADDRESS_SPACE_PROGRAM)
2998   READDWORD32(program_read_dword_32le,  ADDRESS_SPACE_PROGRAM)
2999  READMASKED32(program_read_masked_32le, ADDRESS_SPACE_PROGRAM)
3000 WRITEBYTE32LE(program_write_byte_32le,  ADDRESS_SPACE_PROGRAM)
3001 WRITEWORD32LE(program_write_word_32le,  ADDRESS_SPACE_PROGRAM)
3002  WRITEDWORD32(program_write_dword_32le, ADDRESS_SPACE_PROGRAM)
3003 WRITEMASKED32(program_write_masked_32le,ADDRESS_SPACE_PROGRAM)
3004
3005  READBYTE64BE(program_read_byte_64be,   ADDRESS_SPACE_PROGRAM)
3006  READWORD64BE(program_read_word_64be,   ADDRESS_SPACE_PROGRAM)
3007 READDWORD64BE(program_read_dword_64be,  ADDRESS_SPACE_PROGRAM)
3008   READQWORD64(program_read_qword_64be,  ADDRESS_SPACE_PROGRAM)
3009  READMASKED64(program_read_masked_64be, ADDRESS_SPACE_PROGRAM)
3010 WRITEBYTE64BE(program_write_byte_64be,  ADDRESS_SPACE_PROGRAM)
3011 WRITEWORD64BE(program_write_word_64be,  ADDRESS_SPACE_PROGRAM)
3012WRITEDWORD64BE(program_write_dword_64be, ADDRESS_SPACE_PROGRAM)
3013  WRITEQWORD64(program_write_qword_64be, ADDRESS_SPACE_PROGRAM)
3014 WRITEMASKED64(program_write_masked_64be,ADDRESS_SPACE_PROGRAM)
3015
3016  READBYTE64LE(program_read_byte_64le,   ADDRESS_SPACE_PROGRAM)
3017  READWORD64LE(program_read_word_64le,   ADDRESS_SPACE_PROGRAM)
3018 READDWORD64LE(program_read_dword_64le,  ADDRESS_SPACE_PROGRAM)
3019   READQWORD64(program_read_qword_64le,  ADDRESS_SPACE_PROGRAM)
3020  READMASKED64(program_read_masked_64le, ADDRESS_SPACE_PROGRAM)
3021 WRITEBYTE64LE(program_write_byte_64le,  ADDRESS_SPACE_PROGRAM)
3022 WRITEWORD64LE(program_write_word_64le,  ADDRESS_SPACE_PROGRAM)
3023WRITEDWORD64LE(program_write_dword_64le, ADDRESS_SPACE_PROGRAM)
3024  WRITEQWORD64(program_write_qword_64le, ADDRESS_SPACE_PROGRAM)
3025 WRITEMASKED64(program_write_masked_64le,ADDRESS_SPACE_PROGRAM)
3026
3027
3028/*-------------------------------------------------
3029    Data memory handlers
3030-------------------------------------------------*/
3031
3032     READBYTE8(data_read_byte_8,      ADDRESS_SPACE_DATA)
3033    WRITEBYTE8(data_write_byte_8,     ADDRESS_SPACE_DATA)
3034
3035  READBYTE16BE(data_read_byte_16be,   ADDRESS_SPACE_DATA)
3036    READWORD16(data_read_word_16be,   ADDRESS_SPACE_DATA)
3037 WRITEBYTE16BE(data_write_byte_16be,  ADDRESS_SPACE_DATA)
3038   WRITEWORD16(data_write_word_16be,  ADDRESS_SPACE_DATA)
3039
3040  READBYTE16LE(data_read_byte_16le,   ADDRESS_SPACE_DATA)
3041    READWORD16(data_read_word_16le,   ADDRESS_SPACE_DATA)
3042 WRITEBYTE16LE(data_write_byte_16le,  ADDRESS_SPACE_DATA)
3043   WRITEWORD16(data_write_word_16le,  ADDRESS_SPACE_DATA)
3044
3045  READBYTE32BE(data_read_byte_32be,   ADDRESS_SPACE_DATA)
3046  READWORD32BE(data_read_word_32be,   ADDRESS_SPACE_DATA)
3047   READDWORD32(data_read_dword_32be,  ADDRESS_SPACE_DATA)
3048  READMASKED32(data_read_masked_32be, ADDRESS_SPACE_DATA)
3049 WRITEBYTE32BE(data_write_byte_32be,  ADDRESS_SPACE_DATA)
3050 WRITEWORD32BE(data_write_word_32be,  ADDRESS_SPACE_DATA)
3051  WRITEDWORD32(data_write_dword_32be, ADDRESS_SPACE_DATA)
3052 WRITEMASKED32(data_write_masked_32be,ADDRESS_SPACE_DATA)
3053
3054  READBYTE32LE(data_read_byte_32le,   ADDRESS_SPACE_DATA)
3055  READWORD32LE(data_read_word_32le,   ADDRESS_SPACE_DATA)
3056   READDWORD32(data_read_dword_32le,  ADDRESS_SPACE_DATA)
3057  READMASKED32(data_read_masked_32le, ADDRESS_SPACE_DATA)
3058 WRITEBYTE32LE(data_write_byte_32le,  ADDRESS_SPACE_DATA)
3059 WRITEWORD32LE(data_write_word_32le,  ADDRESS_SPACE_DATA)
3060  WRITEDWORD32(data_write_dword_32le, ADDRESS_SPACE_DATA)
3061 WRITEMASKED32(data_write_masked_32le,ADDRESS_SPACE_DATA)
3062
3063  READBYTE64BE(data_read_byte_64be,   ADDRESS_SPACE_DATA)
3064  READWORD64BE(data_read_word_64be,   ADDRESS_SPACE_DATA)
3065 READDWORD64BE(data_read_dword_64be,  ADDRESS_SPACE_DATA)
3066   READQWORD64(data_read_qword_64be,  ADDRESS_SPACE_DATA)
3067  READMASKED64(data_read_masked_64be, ADDRESS_SPACE_DATA)
3068 WRITEBYTE64BE(data_write_byte_64be,  ADDRESS_SPACE_DATA)
3069 WRITEWORD64BE(data_write_word_64be,  ADDRESS_SPACE_DATA)
3070WRITEDWORD64BE(data_write_dword_64be, ADDRESS_SPACE_DATA)
3071  WRITEQWORD64(data_write_qword_64be, ADDRESS_SPACE_DATA)
3072 WRITEMASKED64(data_write_masked_64be,ADDRESS_SPACE_DATA)
3073
3074  READBYTE64LE(data_read_byte_64le,   ADDRESS_SPACE_DATA)
3075  READWORD64LE(data_read_word_64le,   ADDRESS_SPACE_DATA)
3076 READDWORD64LE(data_read_dword_64le,  ADDRESS_SPACE_DATA)
3077   READQWORD64(data_read_qword_64le,  ADDRESS_SPACE_DATA)
3078  READMASKED64(data_read_masked_64le, ADDRESS_SPACE_DATA)
3079 WRITEBYTE64LE(data_write_byte_64le,  ADDRESS_SPACE_DATA)
3080 WRITEWORD64LE(data_write_word_64le,  ADDRESS_SPACE_DATA)
3081WRITEDWORD64LE(data_write_dword_64le, ADDRESS_SPACE_DATA)
3082  WRITEQWORD64(data_write_qword_64le, ADDRESS_SPACE_DATA)
3083 WRITEMASKED64(data_write_masked_64le,ADDRESS_SPACE_DATA)
3084
3085
3086/*-------------------------------------------------
3087    I/O memory handlers
3088-------------------------------------------------*/
3089
3090     READBYTE8(io_read_byte_8,      ADDRESS_SPACE_IO)
3091    WRITEBYTE8(io_write_byte_8,     ADDRESS_SPACE_IO)
3092
3093  READBYTE16BE(io_read_byte_16be,   ADDRESS_SPACE_IO)
3094    READWORD16(io_read_word_16be,   ADDRESS_SPACE_IO)
3095 WRITEBYTE16BE(io_write_byte_16be,  ADDRESS_SPACE_IO)
3096   WRITEWORD16(io_write_word_16be,  ADDRESS_SPACE_IO)
3097
3098  READBYTE16LE(io_read_byte_16le,   ADDRESS_SPACE_IO)
3099    READWORD16(io_read_word_16le,   ADDRESS_SPACE_IO)
3100 WRITEBYTE16LE(io_write_byte_16le,  ADDRESS_SPACE_IO)
3101   WRITEWORD16(io_write_word_16le,  ADDRESS_SPACE_IO)
3102
3103  READBYTE32BE(io_read_byte_32be,   ADDRESS_SPACE_IO)
3104  READWORD32BE(io_read_word_32be,   ADDRESS_SPACE_IO)
3105   READDWORD32(io_read_dword_32be,  ADDRESS_SPACE_IO)
3106  READMASKED32(io_read_masked_32be, ADDRESS_SPACE_IO)
3107 WRITEBYTE32BE(io_write_byte_32be,  ADDRESS_SPACE_IO)
3108 WRITEWORD32BE(io_write_word_32be,  ADDRESS_SPACE_IO)
3109  WRITEDWORD32(io_write_dword_32be, ADDRESS_SPACE_IO)
3110 WRITEMASKED32(io_write_masked_32be,ADDRESS_SPACE_IO)
3111
3112  READBYTE32LE(io_read_byte_32le,   ADDRESS_SPACE_IO)
3113  READWORD32LE(io_read_word_32le,   ADDRESS_SPACE_IO)
3114   READDWORD32(io_read_dword_32le,  ADDRESS_SPACE_IO)
3115  READMASKED32(io_read_masked_32le, ADDRESS_SPACE_IO)
3116 WRITEBYTE32LE(io_write_byte_32le,  ADDRESS_SPACE_IO)
3117 WRITEWORD32LE(io_write_word_32le,  ADDRESS_SPACE_IO)
3118  WRITEDWORD32(io_write_dword_32le, ADDRESS_SPACE_IO)
3119 WRITEMASKED32(io_write_masked_32le,ADDRESS_SPACE_IO)
3120
3121  READBYTE64BE(io_read_byte_64be,   ADDRESS_SPACE_IO)
3122  READWORD64BE(io_read_word_64be,   ADDRESS_SPACE_IO)
3123 READDWORD64BE(io_read_dword_64be,  ADDRESS_SPACE_IO)
3124   READQWORD64(io_read_qword_64be,  ADDRESS_SPACE_IO)
3125  READMASKED64(io_read_masked_64be, ADDRESS_SPACE_IO)
3126 WRITEBYTE64BE(io_write_byte_64be,  ADDRESS_SPACE_IO)
3127 WRITEWORD64BE(io_write_word_64be,  ADDRESS_SPACE_IO)
3128WRITEDWORD64BE(io_write_dword_64be, ADDRESS_SPACE_IO)
3129  WRITEQWORD64(io_write_qword_64be, ADDRESS_SPACE_IO)
3130 WRITEMASKED64(io_write_masked_64be,ADDRESS_SPACE_IO)
3131
3132  READBYTE64LE(io_read_byte_64le,   ADDRESS_SPACE_IO)
3133  READWORD64LE(io_read_word_64le,   ADDRESS_SPACE_IO)
3134 READDWORD64LE(io_read_dword_64le,  ADDRESS_SPACE_IO)
3135   READQWORD64(io_read_qword_64le,  ADDRESS_SPACE_IO)
3136  READMASKED64(io_read_masked_64le, ADDRESS_SPACE_IO)
3137 WRITEBYTE64LE(io_write_byte_64le,  ADDRESS_SPACE_IO)
3138 WRITEWORD64LE(io_write_word_64le,  ADDRESS_SPACE_IO)
3139WRITEDWORD64LE(io_write_dword_64le, ADDRESS_SPACE_IO)
3140  WRITEQWORD64(io_write_qword_64le, ADDRESS_SPACE_IO)
3141 WRITEMASKED64(io_write_masked_64le,ADDRESS_SPACE_IO)
3142
3143
3144/*-------------------------------------------------
31452499    safe opcode reading
31462500-------------------------------------------------*/
31472501
r2375r2376
35872941      }
35882942   }
35892943}
2944
2945
2946
2947
2948
2949
2950
2951/***************************************************************************
2952    MEMORY HANDLER LOOKUP HELPERS
2953***************************************************************************/
2954
2955/*-------------------------------------------------
2956    Program memory handlers
2957-------------------------------------------------*/
2958
2959INLINE UINT32 lookup_read_entry(const address_space *space, offs_t address)
2960{
2961   UINT32 entry = space->readlookup[LEVEL1_INDEX(address)];
2962   if (entry >= SUBTABLE_BASE)
2963      entry = space->readlookup[LEVEL2_INDEX(entry, address)];
2964   return entry;
2965}
2966
2967
2968INLINE UINT32 lookup_write_entry(const address_space *space, offs_t address)
2969{
2970   UINT32 entry = space->writelookup[LEVEL1_INDEX(address)];
2971   if (entry >= SUBTABLE_BASE)
2972      entry = space->writelookup[LEVEL2_INDEX(entry, address)];
2973   return entry;
2974}
2975
2976
2977/***************************************************************************
2978    8-BIT READ HANDLERS
2979***************************************************************************/
2980
2981/*-------------------------------------------------
2982    read_byte_generic - read a byte from an
2983    arbitrary address space
2984-------------------------------------------------*/
2985
2986INLINE UINT8 read_byte_generic(UINT8 spacenum, offs_t address)
2987{
2988   const address_space *space = &active_address_space[spacenum];
2989   const handler_data *handler;
2990   offs_t offset;
2991   UINT32 entry;
2992   UINT8 result;
2993
2994   profiler_mark(PROFILER_MEMREAD);
2995
2996   address &= space->bytemask;
2997   entry = lookup_read_entry(space, address);
2998   handler = &space->readhandlers[entry];
2999
3000   DEBUG_HOOK_READ(spacenum, address, 0xff);
3001
3002   offset = (address - handler->bytestart) & handler->bytemask;
3003   if (entry < STATIC_RAM)
3004      result = bank_ptr[entry][offset];
3005   else
3006      result = (*handler->handler.read.mhandler8)(handler->object, offset);
3007
3008   profiler_mark(PROFILER_END);
3009
3010   return result;
3011}
3012
3013
3014/*-------------------------------------------------
3015    ADDRESS_SPACE_PROGRAM
3016-------------------------------------------------*/
3017
3018UINT8 program_read_byte_8le(offs_t address)
3019{
3020   return read_byte_generic(ADDRESS_SPACE_PROGRAM, address);
3021}
3022
3023UINT8 program_read_byte_8be(offs_t address)
3024{
3025   return read_byte_generic(ADDRESS_SPACE_PROGRAM, address);
3026}
3027
3028UINT16 program_read_word_8le(offs_t address)
3029{
3030   UINT16 result = program_read_byte_8le(address + 0) << 0;
3031   return result | (program_read_byte_8le(address + 1) << 8);
3032}
3033
3034UINT16 program_read_word_8be(offs_t address)
3035{
3036   UINT16 result = program_read_byte_8be(address + 0) << 8;
3037   return result | (program_read_byte_8be(address + 1) << 0);
3038}
3039
3040UINT32 program_read_dword_8le(offs_t address)
3041{
3042   UINT32 result = program_read_word_8le(address + 0) << 0;
3043   return result | (program_read_word_8le(address + 2) << 16);
3044}
3045
3046UINT32 program_read_dword_8be(offs_t address)
3047{
3048   UINT32 result = program_read_word_8be(address + 0) << 16;
3049   return result | (program_read_word_8be(address + 2) << 0);
3050}
3051
3052UINT64 program_read_qword_8le(offs_t address)
3053{
3054   UINT64 result = (UINT64)program_read_dword_8le(address + 0) << 0;
3055   return result | ((UINT64)program_read_dword_8le(address + 4) << 32);
3056}
3057
3058UINT64 program_read_qword_8be(offs_t address)
3059{
3060   UINT64 result = (UINT64)program_read_dword_8le(address + 0) << 32;
3061   return result | ((UINT64)program_read_dword_8le(address + 4) << 0);
3062}
3063
3064
3065/*-------------------------------------------------
3066    ADDRESS_SPACE_DATA
3067-------------------------------------------------*/
3068
3069UINT8 data_read_byte_8le(offs_t address)
3070{
3071   return read_byte_generic(ADDRESS_SPACE_DATA, address);
3072}
3073
3074UINT8 data_read_byte_8be(offs_t address)
3075{
3076   return read_byte_generic(ADDRESS_SPACE_DATA, address);
3077}
3078
3079UINT16 data_read_word_8le(offs_t address)
3080{
3081   UINT16 result = data_read_byte_8le(address + 0) << 0;
3082   return result | (data_read_byte_8le(address + 1) << 8);
3083}
3084
3085UINT16 data_read_word_8be(offs_t address)
3086{
3087   UINT16 result = data_read_byte_8be(address + 0) << 8;
3088   return result | (data_read_byte_8be(address + 1) << 0);
3089}
3090
3091UINT32 data_read_dword_8le(offs_t address)
3092{
3093   UINT32 result = data_read_word_8le(address + 0) << 0;
3094   return result | (data_read_word_8le(address + 2) << 16);
3095}
3096
3097UINT32 data_read_dword_8be(offs_t address)
3098{
3099   UINT32 result = data_read_word_8be(address + 0) << 16;
3100   return result | (data_read_word_8be(address + 2) << 0);
3101}
3102
3103UINT64 data_read_qword_8le(offs_t address)
3104{
3105   UINT64 result = (UINT64)data_read_dword_8le(address + 0) << 0;
3106   return result | ((UINT64)data_read_dword_8le(address + 4) << 32);
3107}
3108
3109UINT64 data_read_qword_8be(offs_t address)
3110{
3111   UINT64 result = (UINT64)data_read_dword_8le(address + 0) << 32;
3112   return result | ((UINT64)data_read_dword_8le(address + 4) << 0);
3113}
3114
3115
3116/*-------------------------------------------------
3117    ADDRESS_SPACE_IO
3118-------------------------------------------------*/
3119
3120UINT8 io_read_byte_8le(offs_t address)
3121{
3122   return read_byte_generic(ADDRESS_SPACE_IO, address);
3123}
3124
3125UINT8 io_read_byte_8be(offs_t address)
3126{
3127   return read_byte_generic(ADDRESS_SPACE_IO, address);
3128}
3129
3130UINT16 io_read_word_8le(offs_t address)
3131{
3132   UINT16 result = io_read_byte_8le(address + 0) << 0;
3133   return result | (io_read_byte_8le(address + 1) << 8);
3134}
3135
3136UINT16 io_read_word_8be(offs_t address)
3137{
3138   UINT16 result = io_read_byte_8be(address + 0) << 8;
3139   return result | (io_read_byte_8be(address + 1) << 0);
3140}
3141
3142UINT32 io_read_dword_8le(offs_t address)
3143{
3144   UINT32 result = io_read_word_8le(address + 0) << 0;
3145   return result | (io_read_word_8le(address + 2) << 16);
3146}
3147
3148UINT32 io_read_dword_8be(offs_t address)
3149{
3150   UINT32 result = io_read_word_8be(address + 0) << 16;
3151   return result | (io_read_word_8be(address + 2) << 0);
3152}
3153
3154UINT64 io_read_qword_8le(offs_t address)
3155{
3156   UINT64 result = (UINT64)io_read_dword_8le(address + 0) << 0;
3157   return result | ((UINT64)io_read_dword_8le(address + 4) << 32);
3158}
3159
3160UINT64 io_read_qword_8be(offs_t address)
3161{
3162   UINT64 result = (UINT64)io_read_dword_8le(address + 0) << 32;
3163   return result | ((UINT64)io_read_dword_8le(address + 4) << 0);
3164}
3165
3166
3167
3168/***************************************************************************
3169    8-BIT WRITE HANDLERS
3170***************************************************************************/
3171
3172/*-------------------------------------------------
3173    write_byte_generic - write a byte to an
3174    arbitrary address space
3175-------------------------------------------------*/
3176
3177INLINE void write_byte_generic(UINT8 spacenum, offs_t address, UINT8 data)
3178{
3179   const address_space *space = &active_address_space[spacenum];
3180   const handler_data *handler;
3181   offs_t offset;
3182   UINT32 entry;
3183
3184   profiler_mark(PROFILER_MEMWRITE);
3185
3186   address &= space->bytemask;
3187   entry = lookup_write_entry(space, address);
3188   handler = &space->writehandlers[entry];
3189
3190   DEBUG_HOOK_WRITE(spacenum, address, data, 0xff);
3191
3192   offset = (address - handler->bytestart) & handler->bytemask;
3193   if (entry < STATIC_RAM)
3194      bank_ptr[entry][offset] = data;
3195   else
3196      (*handler->handler.write.mhandler8)(handler->object, offset, data);
3197
3198   profiler_mark(PROFILER_END);
3199}
3200
3201
3202/*-------------------------------------------------
3203    ADDRESS_SPACE_PROGRAM
3204-------------------------------------------------*/
3205
3206void program_write_byte_8le(offs_t address, UINT8 data)
3207{
3208   write_byte_generic(ADDRESS_SPACE_PROGRAM, address, data);
3209}
3210
3211void program_write_byte_8be(offs_t address, UINT8 data)
3212{
3213   write_byte_generic(ADDRESS_SPACE_PROGRAM, address, data);
3214}
3215
3216void program_write_word_8le(offs_t address, UINT16 data)
3217{
3218   program_write_byte_8le(address + 0, data >> 0);
3219   program_write_byte_8le(address + 1, data >> 8);
3220}
3221
3222void program_write_word_8be(offs_t address, UINT16 data)
3223{
3224   program_write_byte_8be(address + 0, data >> 8);
3225   program_write_byte_8be(address + 1, data >> 0);
3226}
3227
3228void program_write_dword_8le(offs_t address, UINT32 data)
3229{
3230   program_write_word_8le(address + 0, data >> 0);
3231   program_write_word_8le(address + 2, data >> 16);
3232}
3233
3234void program_write_dword_8be(offs_t address, UINT32 data)
3235{
3236   program_write_word_8be(address + 0, data >> 16);
3237   program_write_word_8be(address + 2, data >> 0);
3238}
3239
3240void program_write_qword_8le(offs_t address, UINT64 data)
3241{
3242   program_write_dword_8le(address + 0, data >> 0);
3243   program_write_dword_8le(address + 4, data >> 32);
3244}
3245
3246void program_write_qword_8be(offs_t address, UINT64 data)
3247{
3248   program_write_dword_8be(address + 0, data >> 32);
3249   program_write_dword_8be(address + 4, data >> 0);
3250}
3251
3252
3253/*-------------------------------------------------
3254    ADDRESS_SPACE_DATA
3255-------------------------------------------------*/
3256
3257void data_write_byte_8le(offs_t address, UINT8 data)
3258{
3259   write_byte_generic(ADDRESS_SPACE_DATA, address, data);
3260}
3261
3262void data_write_byte_8be(offs_t address, UINT8 data)
3263{
3264   write_byte_generic(ADDRESS_SPACE_DATA, address, data);
3265}
3266
3267void data_write_word_8le(offs_t address, UINT16 data)
3268{
3269   data_write_byte_8le(address + 0, data >> 0);
3270   data_write_byte_8le(address + 1, data >> 8);
3271}
3272
3273void data_write_word_8be(offs_t address, UINT16 data)
3274{
3275   data_write_byte_8be(address + 0, data >> 8);
3276   data_write_byte_8be(address + 1, data >> 0);
3277}
3278
3279void data_write_dword_8le(offs_t address, UINT32 data)
3280{
3281   data_write_word_8le(address + 0, data >> 0);
3282   data_write_word_8le(address + 2, data >> 16);
3283}
3284
3285void data_write_dword_8be(offs_t address, UINT32 data)
3286{
3287   data_write_word_8be(address + 0, data >> 16);
3288   data_write_word_8be(address + 2, data >> 0);
3289}
3290
3291void data_write_qword_8le(offs_t address, UINT64 data)
3292{
3293   data_write_dword_8le(address + 0, data >> 0);
3294   data_write_dword_8le(address + 4, data >> 32);
3295}
3296
3297void data_write_qword_8be(offs_t address, UINT64 data)
3298{
3299   data_write_dword_8be(address + 0, data >> 32);
3300   data_write_dword_8be(address + 4, data >> 0);
3301}
3302
3303
3304/*-------------------------------------------------
3305    ADDRESS_SPACE_IO
3306-------------------------------------------------*/
3307
3308void io_write_byte_8le(offs_t address, UINT8 data)
3309{
3310   write_byte_generic(ADDRESS_SPACE_IO, address, data);
3311}
3312
3313void io_write_byte_8be(offs_t address, UINT8 data)
3314{
3315   write_byte_generic(ADDRESS_SPACE_IO, address, data);
3316}
3317
3318void io_write_word_8le(offs_t address, UINT16 data)
3319{
3320   io_write_byte_8le(address + 0, data >> 0);
3321   io_write_byte_8le(address + 1, data >> 8);
3322}
3323
3324void io_write_word_8be(offs_t address, UINT16 data)
3325{
3326   io_write_byte_8be(address + 0, data >> 8);
3327   io_write_byte_8be(address + 1, data >> 0);
3328}
3329
3330void io_write_dword_8le(offs_t address, UINT32 data)
3331{
3332   io_write_word_8le(address + 0, data >> 0);
3333   io_write_word_8le(address + 2, data >> 16);
3334}
3335
3336void io_write_dword_8be(offs_t address, UINT32 data)
3337{
3338   io_write_word_8be(address + 0, data >> 16);
3339   io_write_word_8be(address + 2, data >> 0);
3340}
3341
3342void io_write_qword_8le(offs_t address, UINT64 data)
3343{
3344   io_write_dword_8le(address + 0, data >> 0);
3345   io_write_dword_8le(address + 4, data >> 32);
3346}
3347
3348void io_write_qword_8be(offs_t address, UINT64 data)
3349{
3350   io_write_dword_8be(address + 0, data >> 32);
3351   io_write_dword_8be(address + 4, data >> 0);
3352}
3353
3354
3355
3356/***************************************************************************
3357    16-BIT READ HANDLERS
3358***************************************************************************/
3359
3360/*-------------------------------------------------
3361    read_word_masked_generic - read a word from
3362    an arbitrary address space
3363-------------------------------------------------*/
3364
3365INLINE UINT16 read_word_masked_generic(UINT8 spacenum, offs_t address, UINT16 mem_mask)
3366{
3367   const address_space *space = &active_address_space[spacenum];
3368   const handler_data *handler;
3369   offs_t offset;
3370   UINT32 entry;
3371   UINT16 result;
3372
3373   profiler_mark(PROFILER_MEMREAD);
3374
3375   address &= space->bytemask;
3376   entry = lookup_read_entry(space, address);
3377   handler = &space->readhandlers[entry];
3378
3379   DEBUG_HOOK_READ(spacenum, address & ~1, (UINT16)~mem_mask);
3380
3381   offset = (address - handler->bytestart) & handler->bytemask;
3382   if (entry < STATIC_RAM)
3383      result = *(UINT16 *)&bank_ptr[entry][offset & ~1];
3384   else
3385      result = (*handler->handler.read.mhandler16)(handler->object, offset >> 1, mem_mask);
3386
3387   profiler_mark(PROFILER_END);
3388
3389   return result;
3390}
3391
3392
3393/*-------------------------------------------------
3394    ADDRESS_SPACE_PROGRAM
3395-------------------------------------------------*/
3396
3397UINT8 program_read_byte_16le(offs_t address)
3398{
3399   UINT32 shift = (address & 1) * 8;
3400   return read_word_masked_generic(ADDRESS_SPACE_PROGRAM, address, ~(0xff << shift)) >> shift;
3401}
3402
3403UINT8 program_read_byte_16be(offs_t address)
3404{
3405   UINT32 shift = (~address & 1) * 8;
3406   return read_word_masked_generic(ADDRESS_SPACE_PROGRAM, address, ~(0xff << shift)) >> shift;
3407}
3408
3409UINT16 program_read_word_16le(offs_t address)
3410{
3411   return read_word_masked_generic(ADDRESS_SPACE_PROGRAM, address, 0);
3412}
3413
3414UINT16 program_read_word_16be(offs_t address)
3415{
3416   return read_word_masked_generic(ADDRESS_SPACE_PROGRAM, address, 0);
3417}
3418
3419UINT32 program_read_dword_16le(offs_t address)
3420{
3421   UINT32 result = program_read_word_16le(address + 0) << 0;
3422   return result | (program_read_word_16le(address + 2) << 16);
3423}
3424
3425UINT32 program_read_dword_16be(offs_t address)
3426{
3427   UINT32 result = program_read_word_16be(address + 0) << 16;
3428   return result | (program_read_word_16be(address + 2) << 0);
3429}
3430
3431UINT64 program_read_qword_16le(offs_t address)
3432{
3433   UINT64 result = (UINT64)program_read_dword_16le(address + 0) << 0;
3434   return result | ((UINT64)program_read_dword_16le(address + 4) << 32);
3435}
3436
3437UINT64 program_read_qword_16be(offs_t address)
3438{
3439   UINT64 result = (UINT64)program_read_dword_16le(address + 0) << 32;
3440   return result | ((UINT64)program_read_dword_16le(address + 4) << 0);
3441}
3442
3443
3444/*-------------------------------------------------
3445    ADDRESS_SPACE_DATA
3446-------------------------------------------------*/
3447
3448UINT8 data_read_byte_16le(offs_t address)
3449{
3450   UINT32 shift = (address & 1) * 8;
3451   return read_word_masked_generic(ADDRESS_SPACE_DATA, address, ~(0xff << shift)) >> shift;
3452}
3453
3454UINT8 data_read_byte_16be(offs_t address)
3455{
3456   UINT32 shift = (~address & 1) * 8;
3457   return read_word_masked_generic(ADDRESS_SPACE_DATA, address, ~(0xff << shift)) >> shift;
3458}
3459
3460UINT16 data_read_word_16le(offs_t address)
3461{
3462   return read_word_masked_generic(ADDRESS_SPACE_DATA, address, 0);
3463}
3464
3465UINT16 data_read_word_16be(offs_t address)
3466{
3467   return read_word_masked_generic(ADDRESS_SPACE_DATA, address, 0);
3468}
3469
3470UINT32 data_read_dword_16le(offs_t address)
3471{
3472   UINT32 result = data_read_word_16le(address + 0) << 0;
3473   return result | (data_read_word_16le(address + 2) << 16);
3474}
3475
3476UINT32 data_read_dword_16be(offs_t address)
3477{
3478   UINT32 result = data_read_word_16be(address + 0) << 16;
3479   return result | (data_read_word_16be(address + 2) << 0);
3480}
3481
3482UINT64 data_read_qword_16le(offs_t address)
3483{
3484   UINT64 result = (UINT64)data_read_dword_16le(address + 0) << 0;
3485   return result | ((UINT64)data_read_dword_16le(address + 4) << 32);
3486}
3487
3488UINT64 data_read_qword_16be(offs_t address)
3489{
3490   UINT64 result = (UINT64)data_read_dword_16le(address + 0) << 32;
3491   return result | ((UINT64)data_read_dword_16le(address + 4) << 0);
3492}
3493
3494
3495/*-------------------------------------------------
3496    ADDRESS_SPACE_IO
3497-------------------------------------------------*/
3498
3499UINT8 io_read_byte_16le(offs_t address)
3500{
3501   UINT32 shift = (address & 1) * 8;
3502   return read_word_masked_generic(ADDRESS_SPACE_IO, address, ~(0xff << shift)) >> shift;
3503}
3504
3505UINT8 io_read_byte_16be(offs_t address)
3506{
3507   UINT32 shift = (~address & 1) * 8;
3508   return read_word_masked_generic(ADDRESS_SPACE_IO, address, ~(0xff << shift)) >> shift;
3509}
3510
3511UINT16 io_read_word_16le(offs_t address)
3512{
3513   return read_word_masked_generic(ADDRESS_SPACE_IO, address, 0);
3514}
3515
3516UINT16 io_read_word_16be(offs_t address)
3517{
3518   return read_word_masked_generic(ADDRESS_SPACE_IO, address, 0);
3519}
3520
3521UINT32 io_read_dword_16le(offs_t address)
3522{
3523   UINT32 result = io_read_word_16le(address + 0) << 0;
3524   return result | (io_read_word_16le(address + 2) << 16);
3525}
3526
3527UINT32 io_read_dword_16be(offs_t address)
3528{
3529   UINT32 result = io_read_word_16be(address + 0) << 16;
3530   return result | (io_read_word_16be(address + 2) << 0);
3531}
3532
3533UINT64 io_read_qword_16le(offs_t address)
3534{
3535   UINT64 result = (UINT64)io_read_dword_16le(address + 0) << 0;
3536   return result | ((UINT64)io_read_dword_16le(address + 4) << 32);
3537}
3538
3539UINT64 io_read_qword_16be(offs_t address)
3540{
3541   UINT64 result = (UINT64)io_read_dword_16le(address + 0) << 32;
3542   return result | ((UINT64)io_read_dword_16le(address + 4) << 0);
3543}
3544
3545
3546
3547/***************************************************************************
3548    16-BIT WRITE HANDLERS
3549***************************************************************************/
3550
3551/*-------------------------------------------------
3552    write_word_masked_generic - write a masked
3553    word to an arbitrary address space
3554-------------------------------------------------*/
3555
3556INLINE void write_word_masked_generic(UINT8 spacenum, offs_t address, UINT16 data, UINT16 mem_mask)
3557{
3558   const address_space *space = &active_address_space[spacenum];
3559   const handler_data *handler;
3560   offs_t offset;
3561   UINT32 entry;
3562
3563   profiler_mark(PROFILER_MEMWRITE);
3564
3565   address &= space->bytemask;
3566   entry = lookup_write_entry(space, address);
3567   handler = &space->writehandlers[entry];
3568
3569   DEBUG_HOOK_WRITE(spacenum, address & ~1, data, (UINT16)~mem_mask);
3570
3571   offset = (address - handler->bytestart) & handler->bytemask;
3572   if (entry < STATIC_RAM)
3573   {
3574      UINT16 *dest = (UINT16 *)&bank_ptr[entry][offset & ~1];
3575      *dest = (*dest & mem_mask) | (data & ~mem_mask);
3576   }
3577   else
3578      (*handler->handler.write.mhandler16)(handler->object, offset >> 1, data, mem_mask);
3579
3580   profiler_mark(PROFILER_END);
3581}
3582
3583
3584/*-------------------------------------------------
3585    ADDRESS_SPACE_PROGRAM
3586-------------------------------------------------*/
3587
3588void program_write_byte_16le(offs_t address, UINT8 data)
3589{
3590   UINT32 shift = (address & 1) * 8;
3591   write_word_masked_generic(ADDRESS_SPACE_PROGRAM, address, data << shift, ~(0xff << shift));
3592}
3593
3594void program_write_byte_16be(offs_t address, UINT8 data)
3595{
3596   UINT32 shift = (~address & 1) * 8;
3597   write_word_masked_generic(ADDRESS_SPACE_PROGRAM, address, data << shift, ~(0xff << shift));
3598}
3599
3600void program_write_word_16le(offs_t address, UINT16 data)
3601{
3602   write_word_masked_generic(ADDRESS_SPACE_PROGRAM, address, data, 0);
3603}
3604
3605void program_write_word_16be(offs_t address, UINT16 data)
3606{
3607   write_word_masked_generic(ADDRESS_SPACE_PROGRAM, address, data, 0);
3608}
3609
3610void program_write_dword_16le(offs_t address, UINT32 data)
3611{
3612   program_write_word_16le(address + 0, data >> 0);
3613   program_write_word_16le(address + 2, data >> 16);
3614}
3615
3616void program_write_dword_16be(offs_t address, UINT32 data)
3617{
3618   program_write_word_16be(address + 0, data >> 16);
3619   program_write_word_16be(address + 2, data >> 0);
3620}
3621
3622void program_write_qword_16le(offs_t address, UINT64 data)
3623{
3624   program_write_dword_16le(address + 0, data >> 0);
3625   program_write_dword_16le(address + 4, data >> 32);
3626}
3627
3628void program_write_qword_16be(offs_t address, UINT64 data)
3629{
3630   program_write_dword_16be(address + 0, data >> 32);
3631   program_write_dword_16be(address + 4, data >> 0);
3632}
3633
3634
3635/*-------------------------------------------------
3636    ADDRESS_SPACE_DATA
3637-------------------------------------------------*/
3638
3639void data_write_byte_16le(offs_t address, UINT8 data)
3640{
3641   UINT32 shift = (address & 1) * 8;
3642   write_word_masked_generic(ADDRESS_SPACE_DATA, address, data << shift, ~(0xff << shift));
3643}
3644
3645void data_write_byte_16be(offs_t address, UINT8 data)
3646{
3647   UINT32 shift = (~address & 1) * 8;
3648   write_word_masked_generic(ADDRESS_SPACE_DATA, address, data << shift, ~(0xff << shift));
3649}
3650
3651void data_write_word_16le(offs_t address, UINT16 data)
3652{
3653   write_word_masked_generic(ADDRESS_SPACE_DATA, address, data, 0);
3654}
3655
3656void data_write_word_16be(offs_t address, UINT16 data)
3657{
3658   write_word_masked_generic(ADDRESS_SPACE_DATA, address, data, 0);
3659}
3660
3661void data_write_dword_16le(offs_t address, UINT32 data)
3662{
3663   data_write_word_16le(address + 0, data >> 0);
3664   data_write_word_16le(address + 2, data >> 16);
3665}
3666
3667void data_write_dword_16be(offs_t address, UINT32 data)
3668{
3669   data_write_word_16be(address + 0, data >> 16);
3670   data_write_word_16be(address + 2, data >> 0);
3671}
3672
3673void data_write_qword_16le(offs_t address, UINT64 data)
3674{
3675   data_write_dword_16le(address + 0, data >> 0);
3676   data_write_dword_16le(address + 4, data >> 32);
3677}
3678
3679void data_write_qword_16be(offs_t address, UINT64 data)
3680{
3681   data_write_dword_16be(address + 0, data >> 32);
3682   data_write_dword_16be(address + 4, data >> 0);
3683}
3684
3685
3686/*-------------------------------------------------
3687    ADDRESS_SPACE_IO
3688-------------------------------------------------*/
3689
3690void io_write_byte_16le(offs_t address, UINT8 data)
3691{
3692   UINT32 shift = (address & 1) * 8;
3693   write_word_masked_generic(ADDRESS_SPACE_IO, address, data << shift, ~(0xff << shift));
3694}
3695
3696void io_write_byte_16be(offs_t address, UINT8 data)
3697{
3698   UINT32 shift = (~address & 1) * 8;
3699   write_word_masked_generic(ADDRESS_SPACE_IO, address, data << shift, ~(0xff << shift));
3700}
3701
3702void io_write_word_16le(offs_t address, UINT16 data)
3703{
3704   write_word_masked_generic(ADDRESS_SPACE_IO, address, data, 0);
3705}
3706
3707void io_write_word_16be(offs_t address, UINT16 data)
3708{
3709   write_word_masked_generic(ADDRESS_SPACE_IO, address, data, 0);
3710}
3711
3712void io_write_dword_16le(offs_t address, UINT32 data)
3713{
3714   io_write_word_16le(address + 0, data >> 0);
3715   io_write_word_16le(address + 2, data >> 16);
3716}
3717
3718void io_write_dword_16be(offs_t address, UINT32 data)
3719{
3720   io_write_word_16be(address + 0, data >> 16);
3721   io_write_word_16be(address + 2, data >> 0);
3722}
3723
3724void io_write_qword_16le(offs_t address, UINT64 data)
3725{
3726   io_write_dword_16le(address + 0, data >> 0);
3727   io_write_dword_16le(address + 4, data >> 32);
3728}
3729
3730void io_write_qword_16be(offs_t address, UINT64 data)
3731{
3732   io_write_dword_16be(address + 0, data >> 32);
3733   io_write_dword_16be(address + 4, data >> 0);
3734}
3735
3736
3737
3738/***************************************************************************
3739    32-BIT READ HANDLERS
3740***************************************************************************/
3741
3742/*-------------------------------------------------
3743    read_dword_masked_generic - read a dword from
3744    an arbitrary address space
3745-------------------------------------------------*/
3746
3747INLINE UINT32 read_dword_masked_generic(UINT8 spacenum, offs_t address, UINT32 mem_mask)
3748{
3749   const address_space *space = &active_address_space[spacenum];
3750   const handler_data *handler;
3751   offs_t offset;
3752   UINT32 entry;
3753   UINT32 result;
3754
3755   profiler_mark(PROFILER_MEMREAD);
3756
3757   address &= space->bytemask;
3758   entry = lookup_read_entry(space, address);
3759   handler = &space->readhandlers[entry];
3760
3761   DEBUG_HOOK_READ(spacenum, address & ~3, (UINT32)~mem_mask);
3762
3763   offset = (address - handler->bytestart) & handler->bytemask;
3764   if (entry < STATIC_RAM)
3765      result = *(UINT32 *)&bank_ptr[entry][offset & ~3];
3766   else
3767      result = (*handler->handler.read.mhandler32)(handler->object, offset >> 2, mem_mask);
3768
3769   profiler_mark(PROFILER_END);
3770
3771   return result;
3772}
3773
3774
3775/*-------------------------------------------------
3776    ADDRESS_SPACE_PROGRAM
3777-------------------------------------------------*/
3778
3779UINT8 program_read_byte_32le(offs_t address)
3780{
3781   UINT32 shift = (address & 3) * 8;
3782   return read_dword_masked_generic(ADDRESS_SPACE_PROGRAM, address, ~(0xff << shift)) >> shift;
3783}
3784
3785UINT8 program_read_byte_32be(offs_t address)
3786{
3787   UINT32 shift = (~address & 3) * 8;
3788   return read_dword_masked_generic(ADDRESS_SPACE_PROGRAM, address, ~(0xff << shift)) >> shift;
3789}
3790
3791UINT16 program_read_word_32le(offs_t address)
3792{
3793   UINT32 shift = (address & 2) * 8;
3794   return read_dword_masked_generic(ADDRESS_SPACE_PROGRAM, address, ~(0xffff << shift)) >> shift;
3795}
3796
3797UINT16 program_read_word_32be(offs_t address)
3798{
3799   UINT32 shift = (~address & 2) * 8;
3800   return read_dword_masked_generic(ADDRESS_SPACE_PROGRAM, address, ~(0xffff << shift)) >> shift;
3801}
3802
3803UINT32 program_read_dword_32le(offs_t address)
3804{
3805   return read_dword_masked_generic(ADDRESS_SPACE_PROGRAM, address, 0);
3806}
3807
3808UINT32 program_read_dword_32be(offs_t address)
3809{
3810   return read_dword_masked_generic(ADDRESS_SPACE_PROGRAM, address, 0);
3811}
3812
3813UINT32 program_read_dword_masked_32le(offs_t address, UINT32 mem_mask)
3814{
3815   return read_dword_masked_generic(ADDRESS_SPACE_PROGRAM, address, mem_mask);
3816}
3817
3818UINT32 program_read_dword_masked_32be(offs_t address, UINT32 mem_mask)
3819{
3820   return read_dword_masked_generic(ADDRESS_SPACE_PROGRAM, address, mem_mask);
3821}
3822
3823UINT64 program_read_qword_32le(offs_t address)
3824{
3825   UINT64 result = (UINT64)program_read_dword_32le(address + 0) << 0;
3826   return result | ((UINT64)program_read_dword_32le(address + 4) << 32);
3827}
3828
3829UINT64 program_read_qword_32be(offs_t address)
3830{
3831   UINT64 result = (UINT64)program_read_dword_32le(address + 0) << 32;
3832   return result | ((UINT64)program_read_dword_32le(address + 4) << 0);
3833}
3834
3835
3836/*-------------------------------------------------
3837    ADDRESS_SPACE_DATA
3838-------------------------------------------------*/
3839
3840UINT8 data_read_byte_32le(offs_t address)
3841{
3842   UINT32 shift = (address & 3) * 8;
3843   return read_dword_masked_generic(ADDRESS_SPACE_DATA, address, ~(0xff << shift)) >> shift;
3844}
3845
3846UINT8 data_read_byte_32be(offs_t address)
3847{
3848   UINT32 shift = (~address & 3) * 8;
3849   return read_dword_masked_generic(ADDRESS_SPACE_DATA, address, ~(0xff << shift)) >> shift;
3850}
3851
3852UINT16 data_read_word_32le(offs_t address)
3853{
3854   UINT32 shift = (address & 2) * 8;
3855   return read_dword_masked_generic(ADDRESS_SPACE_DATA, address, ~(0xffff << shift)) >> shift;
3856}
3857
3858UINT16 data_read_word_32be(offs_t address)
3859{
3860   UINT32 shift = (~address & 2) * 8;
3861   return read_dword_masked_generic(ADDRESS_SPACE_DATA, address, ~(0xffff << shift)) >> shift;
3862}
3863
3864UINT32 data_read_dword_32le(offs_t address)
3865{
3866   return read_dword_masked_generic(ADDRESS_SPACE_DATA, address, 0);
3867}
3868
3869UINT32 data_read_dword_32be(offs_t address)
3870{
3871   return read_dword_masked_generic(ADDRESS_SPACE_DATA, address, 0);
3872}
3873
3874UINT32 data_read_dword_masked_32le(offs_t address, UINT32 mem_mask)
3875{
3876   return read_dword_masked_generic(ADDRESS_SPACE_DATA, address, mem_mask);
3877}
3878
3879UINT32 data_read_dword_masked_32be(offs_t address, UINT32 mem_mask)
3880{
3881   return read_dword_masked_generic(ADDRESS_SPACE_DATA, address, mem_mask);
3882}
3883
3884UINT64 data_read_qword_32le(offs_t address)
3885{
3886   UINT64 result = (UINT64)data_read_dword_32le(address + 0) << 0;
3887   return result | ((UINT64)data_read_dword_32le(address + 4) << 32);
3888}
3889
3890UINT64 data_read_qword_32be(offs_t address)
3891{
3892   UINT64 result = (UINT64)data_read_dword_32le(address + 0) << 32;
3893   return result | ((UINT64)data_read_dword_32le(address + 4) << 0);
3894}
3895
3896
3897/*-------------------------------------------------
3898    ADDRESS_SPACE_IO
3899-------------------------------------------------*/
3900
3901UINT8 io_read_byte_32le(offs_t address)
3902{
3903   UINT32 shift = (address & 3) * 8;
3904   return read_dword_masked_generic(ADDRESS_SPACE_IO, address, ~(0xff << shift)) >> shift;
3905}
3906
3907UINT8 io_read_byte_32be(offs_t address)
3908{
3909   UINT32 shift = (~address & 3) * 8;
3910   return read_dword_masked_generic(ADDRESS_SPACE_IO, address, ~(0xff << shift)) >> shift;
3911}
3912
3913UINT16 io_read_word_32le(offs_t address)
3914{
3915   UINT32 shift = (address & 2) * 8;
3916   return read_dword_masked_generic(ADDRESS_SPACE_IO, address, ~(0xffff << shift)) >> shift;
3917}
3918
3919UINT16 io_read_word_32be(offs_t address)
3920{
3921   UINT32 shift = (~address & 2) * 8;
3922   return read_dword_masked_generic(ADDRESS_SPACE_IO, address, ~(0xffff << shift)) >> shift;
3923}
3924
3925UINT32 io_read_dword_32le(offs_t address)
3926{
3927   return read_dword_masked_generic(ADDRESS_SPACE_IO, address, 0);
3928}
3929
3930UINT32 io_read_dword_32be(offs_t address)
3931{
3932   return read_dword_masked_generic(ADDRESS_SPACE_IO, address, 0);
3933}
3934
3935UINT32 io_read_dword_masked_32le(offs_t address, UINT32 mem_mask)
3936{
3937   return read_dword_masked_generic(ADDRESS_SPACE_IO, address, mem_mask);
3938}
3939
3940UINT32 io_read_dword_masked_32be(offs_t address, UINT32 mem_mask)
3941{
3942   return read_dword_masked_generic(ADDRESS_SPACE_IO, address, mem_mask);
3943}
3944
3945UINT64 io_read_qword_32le(offs_t address)
3946{
3947   UINT64 result = (UINT64)io_read_dword_32le(address + 0) << 0;
3948   return result | ((UINT64)io_read_dword_32le(address + 4) << 32);
3949}
3950
3951UINT64 io_read_qword_32be(offs_t address)
3952{
3953   UINT64 result = (UINT64)io_read_dword_32le(address + 0) << 32;
3954   return result | ((UINT64)io_read_dword_32le(address + 4) << 0);
3955}
3956
3957
3958
3959/***************************************************************************
3960    32-BIT WRITE HANDLERS
3961***************************************************************************/
3962
3963/*-------------------------------------------------
3964    write_dword_masked_generic - write a masked
3965    dword to an arbitrary address space
3966-------------------------------------------------*/
3967
3968INLINE void write_dword_masked_generic(UINT8 spacenum, offs_t address, UINT32 data, UINT32 mem_mask)
3969{
3970   const address_space *space = &active_address_space[spacenum];
3971   const handler_data *handler;
3972   offs_t offset;
3973   UINT32 entry;
3974
3975   profiler_mark(PROFILER_MEMWRITE);
3976
3977   address &= space->bytemask;
3978   entry = lookup_write_entry(space, address);
3979   handler = &space->writehandlers[entry];
3980
3981   DEBUG_HOOK_WRITE(spacenum, address & ~3, data, (UINT32)~mem_mask);
3982
3983   offset = (address - handler->bytestart) & handler->bytemask;
3984   if (entry < STATIC_RAM)
3985   {
3986      UINT32 *dest = (UINT32 *)&bank_ptr[entry][offset & ~3];
3987      *dest = (*dest & mem_mask) | (data & ~mem_mask);
3988   }
3989   else
3990      (*handler->handler.write.mhandler32)(handler->object, offset >> 2, data, mem_mask);
3991
3992   profiler_mark(PROFILER_END);
3993}
3994
3995
3996/*-------------------------------------------------
3997    ADDRESS_SPACE_PROGRAM
3998-------------------------------------------------*/
3999
4000void program_write_byte_32le(offs_t address, UINT8 data)
4001{
4002   UINT32 shift = (address & 3) * 8;
4003   write_dword_masked_generic(ADDRESS_SPACE_PROGRAM, address, data << shift, ~(0xff << shift));
4004}
4005
4006void program_write_byte_32be(offs_t address, UINT8 data)
4007{
4008   UINT32 shift = (~address & 3) * 8;
4009   write_dword_masked_generic(ADDRESS_SPACE_PROGRAM, address, data << shift, ~(0xff << shift));
4010}
4011
4012void program_write_word_32le(offs_t address, UINT16 data)
4013{
4014   UINT32 shift = (address & 2) * 8;
4015   write_dword_masked_generic(ADDRESS_SPACE_PROGRAM, address, data << shift, ~(0xffff << shift));
4016}
4017
4018void program_write_word_32be(offs_t address, UINT16 data)
4019{
4020   UINT32 shift = (~address & 2) * 8;
4021   write_dword_masked_generic(ADDRESS_SPACE_PROGRAM, address, data << shift, ~(0xffff << shift));
4022}
4023
4024void program_write_dword_32le(offs_t address, UINT32 data)
4025{
4026   write_dword_masked_generic(ADDRESS_SPACE_PROGRAM, address, data, 0);
4027}
4028
4029void program_write_dword_32be(offs_t address, UINT32 data)
4030{
4031   write_dword_masked_generic(ADDRESS_SPACE_PROGRAM, address, data, 0);
4032}
4033
4034void program_write_dword_masked_32le(offs_t address, UINT32 data, UINT32 mem_mask)
4035{
4036   write_dword_masked_generic(ADDRESS_SPACE_PROGRAM, address, data, mem_mask);
4037}
4038
4039void program_write_dword_masked_32be(offs_t address, UINT32 data, UINT32 mem_mask)
4040{
4041   write_dword_masked_generic(ADDRESS_SPACE_PROGRAM, address, data, mem_mask);
4042}
4043
4044void program_write_qword_32le(offs_t address, UINT64 data)
4045{
4046   program_write_dword_32le(address + 0, data >> 0);
4047   program_write_dword_32le(address + 4, data >> 32);
4048}
4049
4050void program_write_qword_32be(offs_t address, UINT64 data)
4051{
4052   program_write_dword_32be(address + 0, data >> 32);
4053   program_write_dword_32be(address + 4, data >> 0);
4054}
4055
4056
4057/*-------------------------------------------------
4058    ADDRESS_SPACE_DATA
4059-------------------------------------------------*/
4060
4061void data_write_byte_32le(offs_t address, UINT8 data)
4062{
4063   UINT32 shift = (address & 3) * 8;
4064   write_dword_masked_generic(ADDRESS_SPACE_DATA, address, data << shift, ~(0xff << shift));
4065}
4066
4067void data_write_byte_32be(offs_t address, UINT8 data)
4068{
4069   UINT32 shift = (~address & 3) * 8;
4070   write_dword_masked_generic(ADDRESS_SPACE_DATA, address, data << shift, ~(0xff << shift));
4071}
4072
4073void data_write_word_32le(offs_t address, UINT16 data)
4074{
4075   UINT32 shift = (address & 2) * 8;
4076   write_dword_masked_generic(ADDRESS_SPACE_DATA, address, data << shift, ~(0xffff << shift));
4077}
4078
4079void data_write_word_32be(offs_t address, UINT16 data)
4080{
4081   UINT32 shift = (~address & 2) * 8;
4082   write_dword_masked_generic(ADDRESS_SPACE_DATA, address, data << shift, ~(0xffff << shift));
4083}
4084
4085void data_write_dword_32le(offs_t address, UINT32 data)
4086{
4087   write_dword_masked_generic(ADDRESS_SPACE_DATA, address, data, 0);
4088}
4089
4090void data_write_dword_32be(offs_t address, UINT32 data)
4091{
4092   write_dword_masked_generic(ADDRESS_SPACE_DATA, address, data, 0);
4093}
4094
4095void data_write_dword_masked_32le(offs_t address, UINT32 data, UINT32 mem_mask)
4096{
4097   write_dword_masked_generic(ADDRESS_SPACE_DATA, address, data, mem_mask);
4098}
4099
4100void data_write_dword_masked_32be(offs_t address, UINT32 data, UINT32 mem_mask)
4101{
4102   write_dword_masked_generic(ADDRESS_SPACE_DATA, address, data, mem_mask);
4103}
4104
4105void data_write_qword_32le(offs_t address, UINT64 data)
4106{
4107   data_write_dword_32le(address + 0, data >> 0);
4108   data_write_dword_32le(address + 4, data >> 32);
4109}
4110
4111void data_write_qword_32be(offs_t address, UINT64 data)
4112{
4113   data_write_dword_32be(address + 0, data >> 32);
4114   data_write_dword_32be(address + 4, data >> 0);
4115}
4116
4117
4118/*-------------------------------------------------
4119    ADDRESS_SPACE_IO
4120-------------------------------------------------*/
4121
4122void io_write_byte_32le(offs_t address, UINT8 data)
4123{
4124   UINT32 shift = (address & 3) * 8;
4125   write_dword_masked_generic(ADDRESS_SPACE_IO, address, data << shift, ~(0xff << shift));
4126}
4127
4128void io_write_byte_32be(offs_t address, UINT8 data)
4129{
4130   UINT32 shift = (~address & 3) * 8;
4131   write_dword_masked_generic(ADDRESS_SPACE_IO, address, data << shift, ~(0xff << shift));
4132}
4133
4134void io_write_word_32le(offs_t address, UINT16 data)
4135{
4136   UINT32 shift = (address & 2) * 8;
4137   write_dword_masked_generic(ADDRESS_SPACE_IO, address, data << shift, ~(0xffff << shift));
4138}
4139
4140void io_write_word_32be(offs_t address, UINT16 data)
4141{
4142   UINT32 shift = (~address & 2) * 8;
4143   write_dword_masked_generic(ADDRESS_SPACE_IO, address, data << shift, ~(0xffff << shift));
4144}
4145
4146void io_write_dword_32le(offs_t address, UINT32 data)
4147{
4148   write_dword_masked_generic(ADDRESS_SPACE_IO, address, data, 0);
4149}
4150
4151void io_write_dword_32be(offs_t address, UINT32 data)
4152{
4153   write_dword_masked_generic(ADDRESS_SPACE_IO, address, data, 0);
4154}
4155
4156void io_write_dword_masked_32le(offs_t address, UINT32 data, UINT32 mem_mask)
4157{
4158   write_dword_masked_generic(ADDRESS_SPACE_IO, address, data, mem_mask);
4159}
4160
4161void io_write_dword_masked_32be(offs_t address, UINT32 data, UINT32 mem_mask)
4162{
4163   write_dword_masked_generic(ADDRESS_SPACE_IO, address, data, mem_mask);
4164}
4165
4166void io_write_qword_32le(offs_t address, UINT64 data)
4167{
4168   io_write_dword_32le(address + 0, data >> 0);
4169   io_write_dword_32le(address + 4, data >> 32);
4170}
4171
4172void io_write_qword_32be(offs_t address, UINT64 data)
4173{
4174   io_write_dword_32be(address + 0, data >> 32);
4175   io_write_dword_32be(address + 4, data >> 0);
4176}
4177
4178
4179
4180/***************************************************************************
4181    64-BIT READ HANDLERS
4182***************************************************************************/
4183
4184/*-------------------------------------------------
4185    read_qword_masked_generic - read a qword from
4186    an arbitrary address space
4187-------------------------------------------------*/
4188
4189INLINE UINT64 read_qword_masked_generic(UINT8 spacenum, offs_t address, UINT64 mem_mask)
4190{
4191   const address_space *space = &active_address_space[spacenum];
4192   const handler_data *handler;
4193   offs_t offset;
4194   UINT32 entry;
4195   UINT64 result;
4196
4197   profiler_mark(PROFILER_MEMREAD);
4198
4199   address &= space->bytemask;
4200   entry = lookup_read_entry(space, address);
4201   handler = &space->readhandlers[entry];
4202
4203   DEBUG_HOOK_READ(spacenum, address & ~7, ~mem_mask);
4204
4205   offset = (address - handler->bytestart) & handler->bytemask;
4206   if (entry < STATIC_RAM)
4207      result = *(UINT64 *)&bank_ptr[entry][offset & ~7];
4208   else
4209      result = (*handler->handler.read.mhandler64)(handler->object, offset >> 3, mem_mask);
4210
4211   profiler_mark(PROFILER_END);
4212
4213   return result;
4214}
4215
4216
4217/*-------------------------------------------------
4218    ADDRESS_SPACE_PROGRAM
4219-------------------------------------------------*/
4220
4221UINT8 program_read_byte_64le(offs_t address)
4222{
4223   UINT32 shift = (address & 7) * 8;
4224   return read_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, ~((UINT64)0xff << shift)) >> shift;
4225}
4226
4227UINT8 program_read_byte_64be(offs_t address)
4228{
4229   UINT32 shift = (~address & 7) * 8;
4230   return read_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, ~((UINT64)0xff << shift)) >> shift;
4231}
4232
4233UINT16 program_read_word_64le(offs_t address)
4234{
4235   UINT32 shift = (address & 6) * 8;
4236   return read_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, ~((UINT64)0xffff << shift)) >> shift;
4237}
4238
4239UINT16 program_read_word_64be(offs_t address)
4240{
4241   UINT32 shift = (~address & 6) * 8;
4242   return read_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, ~((UINT64)0xffff << shift)) >> shift;
4243}
4244
4245UINT32 program_read_dword_64le(offs_t address)
4246{
4247   UINT32 shift = (address & 4) * 8;
4248   return read_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, ~((UINT64)0xffffffff << shift)) >> shift;
4249}
4250
4251UINT32 program_read_dword_64be(offs_t address)
4252{
4253   UINT32 shift = (~address & 4) * 8;
4254   return read_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, ~((UINT64)0xffffffff << shift)) >> shift;
4255}
4256
4257UINT64 program_read_qword_64le(offs_t address)
4258{
4259   return read_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, 0);
4260}
4261
4262UINT64 program_read_qword_64be(offs_t address)
4263{
4264   return read_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, 0);
4265}
4266
4267UINT64 program_read_qword_masked_64le(offs_t address, UINT64 mem_mask)
4268{
4269   return read_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, mem_mask);
4270}
4271
4272UINT64 program_read_qword_masked_64be(offs_t address, UINT64 mem_mask)
4273{
4274   return read_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, mem_mask);
4275}
4276
4277
4278/*-------------------------------------------------
4279    ADDRESS_SPACE_DATA
4280-------------------------------------------------*/
4281
4282UINT8 data_read_byte_64le(offs_t address)
4283{
4284   UINT32 shift = (address & 7) * 8;
4285   return read_qword_masked_generic(ADDRESS_SPACE_DATA, address, ~((UINT64)0xff << shift)) >> shift;
4286}
4287
4288UINT8 data_read_byte_64be(offs_t address)
4289{
4290   UINT32 shift = (~address & 7) * 8;
4291   return read_qword_masked_generic(ADDRESS_SPACE_DATA, address, ~((UINT64)0xff << shift)) >> shift;
4292}
4293
4294UINT16 data_read_word_64le(offs_t address)
4295{
4296   UINT32 shift = (address & 6) * 8;
4297   return read_qword_masked_generic(ADDRESS_SPACE_DATA, address, ~((UINT64)0xffff << shift)) >> shift;
4298}
4299
4300UINT16 data_read_word_64be(offs_t address)
4301{
4302   UINT32 shift = (~address & 6) * 8;
4303   return read_qword_masked_generic(ADDRESS_SPACE_DATA, address, ~((UINT64)0xffff << shift)) >> shift;
4304}
4305
4306UINT32 data_read_dword_64le(offs_t address)
4307{
4308   UINT32 shift = (address & 4) * 8;
4309   return read_qword_masked_generic(ADDRESS_SPACE_DATA, address, ~((UINT64)0xffffffff << shift)) >> shift;
4310}
4311
4312UINT32 data_read_dword_64be(offs_t address)
4313{
4314   UINT32 shift = (~address & 4) * 8;
4315   return read_qword_masked_generic(ADDRESS_SPACE_DATA, address, ~((UINT64)0xffffffff << shift)) >> shift;
4316}
4317
4318UINT64 data_read_qword_64le(offs_t address)
4319{
4320   return read_qword_masked_generic(ADDRESS_SPACE_DATA, address, 0);
4321}
4322
4323UINT64 data_read_qword_64be(offs_t address)
4324{
4325   return read_qword_masked_generic(ADDRESS_SPACE_DATA, address, 0);
4326}
4327
4328UINT64 data_read_qword_masked_64le(offs_t address, UINT64 mem_mask)
4329{
4330   return read_qword_masked_generic(ADDRESS_SPACE_DATA, address, mem_mask);
4331}
4332
4333UINT64 data_read_qword_masked_64be(offs_t address, UINT64 mem_mask)
4334{
4335   return read_qword_masked_generic(ADDRESS_SPACE_DATA, address, mem_mask);
4336}
4337
4338
4339/*-------------------------------------------------
4340    ADDRESS_SPACE_IO
4341-------------------------------------------------*/
4342
4343UINT8 io_read_byte_64le(offs_t address)
4344{
4345   UINT32 shift = (address & 7) * 8;
4346   return read_qword_masked_generic(ADDRESS_SPACE_IO, address, ~((UINT64)0xff << shift)) >> shift;
4347}
4348
4349UINT8 io_read_byte_64be(offs_t address)
4350{
4351   UINT32 shift = (~address & 7) * 8;
4352   return read_qword_masked_generic(ADDRESS_SPACE_IO, address, ~((UINT64)0xff << shift)) >> shift;
4353}
4354
4355UINT16 io_read_word_64le(offs_t address)
4356{
4357   UINT32 shift = (address & 6) * 8;
4358   return read_qword_masked_generic(ADDRESS_SPACE_IO, address, ~((UINT64)0xffff << shift)) >> shift;
4359}
4360
4361UINT16 io_read_word_64be(offs_t address)
4362{
4363   UINT32 shift = (~address & 6) * 8;
4364   return read_qword_masked_generic(ADDRESS_SPACE_IO, address, ~((UINT64)0xffff << shift)) >> shift;
4365}
4366
4367UINT32 io_read_dword_64le(offs_t address)
4368{
4369   UINT32 shift = (address & 4) * 8;
4370   return read_qword_masked_generic(ADDRESS_SPACE_IO, address, ~((UINT64)0xffffffff << shift)) >> shift;
4371}
4372
4373UINT32 io_read_dword_64be(offs_t address)
4374{
4375   UINT32 shift = (~address & 4) * 8;
4376   return read_qword_masked_generic(ADDRESS_SPACE_IO, address, ~((UINT64)0xffffffff << shift)) >> shift;
4377}
4378
4379UINT64 io_read_qword_64le(offs_t address)
4380{
4381   return read_qword_masked_generic(ADDRESS_SPACE_IO, address, 0);
4382}
4383
4384UINT64 io_read_qword_64be(offs_t address)
4385{
4386   return read_qword_masked_generic(ADDRESS_SPACE_IO, address, 0);
4387}
4388
4389UINT64 io_read_qword_masked_64le(offs_t address, UINT64 mem_mask)
4390{
4391   return read_qword_masked_generic(ADDRESS_SPACE_IO, address, mem_mask);
4392}
4393
4394UINT64 io_read_qword_masked_64be(offs_t address, UINT64 mem_mask)
4395{
4396   return read_qword_masked_generic(ADDRESS_SPACE_IO, address, mem_mask);
4397}
4398
4399
4400
4401/***************************************************************************
4402    64-BIT WRITE HANDLERS
4403***************************************************************************/
4404
4405/*-------------------------------------------------
4406    write_qword_masked_generic - write a masked
4407    dword to an arbitrary address space
4408-------------------------------------------------*/
4409
4410INLINE void write_qword_masked_generic(UINT8 spacenum, offs_t address, UINT64 data, UINT64 mem_mask)
4411{
4412   const address_space *space = &active_address_space[spacenum];
4413   const handler_data *handler;
4414   offs_t offset;
4415   UINT32 entry;
4416
4417   profiler_mark(PROFILER_MEMWRITE);
4418
4419   address &= space->bytemask;
4420   entry = lookup_write_entry(space, address);
4421   handler = &space->writehandlers[entry];
4422
4423   DEBUG_HOOK_WRITE(spacenum, address & ~7, data, ~mem_mask);
4424
4425   offset = (address - handler->bytestart) & handler->bytemask;
4426   if (entry < STATIC_RAM)
4427   {
4428      UINT64 *dest = (UINT64 *)&bank_ptr[entry][offset & ~7];
4429      *dest = (*dest & mem_mask) | (data & ~mem_mask);
4430   }
4431   else
4432      (*handler->handler.write.mhandler64)(handler->object, offset >> 3, data, mem_mask);
4433
4434   profiler_mark(PROFILER_END);
4435}
4436
4437
4438/*-------------------------------------------------
4439    ADDRESS_SPACE_PROGRAM
4440-------------------------------------------------*/
4441
4442void program_write_byte_64le(offs_t address, UINT8 data)
4443{
4444   UINT32 shift = (address & 7) * 8;
4445   write_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, (UINT64)data << shift, ~((UINT64)0xff << shift));
4446}
4447
4448void program_write_byte_64be(offs_t address, UINT8 data)
4449{
4450   UINT32 shift = (~address & 7) * 8;
4451   write_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, (UINT64)data << shift, ~((UINT64)0xff << shift));
4452}
4453
4454void program_write_word_64le(offs_t address, UINT16 data)
4455{
4456   UINT32 shift = (address & 6) * 8;
4457   write_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, (UINT64)data << shift, ~((UINT64)0xffff << shift));
4458}
4459
4460void program_write_word_64be(offs_t address, UINT16 data)
4461{
4462   UINT32 shift = (~address & 6) * 8;
4463   write_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, (UINT64)data << shift, ~((UINT64)0xffff << shift));
4464}
4465
4466void program_write_dword_64le(offs_t address, UINT32 data)
4467{
4468   UINT32 shift = (address & 4) * 8;
4469   write_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, (UINT64)data << shift, ~((UINT64)0xffffffff << shift));
4470}
4471
4472void program_write_dword_64be(offs_t address, UINT32 data)
4473{
4474   UINT32 shift = (~address & 4) * 8;
4475   write_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, (UINT64)data << shift, ~((UINT64)0xffffffff << shift));
4476}
4477
4478void program_write_qword_64le(offs_t address, UINT64 data)
4479{
4480   write_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, data, 0);
4481}
4482
4483void program_write_qword_64be(offs_t address, UINT64 data)
4484{
4485   write_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, data, 0);
4486}
4487
4488void program_write_qword_masked_64le(offs_t address, UINT64 data, UINT64 mem_mask)
4489{
4490   write_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, data, mem_mask);
4491}
4492
4493void program_write_qword_masked_64be(offs_t address, UINT64 data, UINT64 mem_mask)
4494{
4495   write_qword_masked_generic(ADDRESS_SPACE_PROGRAM, address, data, mem_mask);
4496}
4497
4498
4499/*-------------------------------------------------
4500    ADDRESS_SPACE_DATA
4501-------------------------------------------------*/
4502
4503void data_write_byte_64le(offs_t address, UINT8 data)
4504{
4505   UINT32 shift = (address & 7) * 8;
4506   write_qword_masked_generic(ADDRESS_SPACE_DATA, address, (UINT64)data << shift, ~((UINT64)0xff << shift));
4507}
4508
4509void data_write_byte_64be(offs_t address, UINT8 data)
4510{
4511   UINT32 shift = (~address & 7) * 8;
4512   write_qword_masked_generic(ADDRESS_SPACE_DATA, address, (UINT64)data << shift, ~((UINT64)0xff << shift));
4513}
4514
4515void data_write_word_64le(offs_t address, UINT16 data)
4516{
4517   UINT32 shift = (address & 6) * 8;
4518   write_qword_masked_generic(ADDRESS_SPACE_DATA, address, (UINT64)data << shift, ~((UINT64)0xffff << shift));
4519}
4520
4521void data_write_word_64be(offs_t address, UINT16 data)
4522{
4523   UINT32 shift = (~address & 6) * 8;
4524   write_qword_masked_generic(ADDRESS_SPACE_DATA, address, (UINT64)data << shift, ~((UINT64)0xffff << shift));
4525}
4526
4527void data_write_dword_64le(offs_t address, UINT32 data)
4528{
4529   UINT32 shift = (address & 4) * 8;
4530   write_qword_masked_generic(ADDRESS_SPACE_DATA, address, (UINT64)data << shift, ~((UINT64)0xffffffff << shift));
4531}
4532
4533void data_write_dword_64be(offs_t address, UINT32 data)
4534{
4535   UINT32 shift = (~address & 4) * 8;
4536   write_qword_masked_generic(ADDRESS_SPACE_DATA, address, (UINT64)data << shift, ~((UINT64)0xffffffff << shift));
4537}
4538
4539void data_write_qword_64le(offs_t address, UINT64 data)
4540{
4541   write_qword_masked_generic(ADDRESS_SPACE_DATA, address, data, 0);
4542}
4543
4544void data_write_qword_64be(offs_t address, UINT64 data)
4545{
4546   write_qword_masked_generic(ADDRESS_SPACE_DATA, address, data, 0);
4547}
4548
4549void data_write_qword_masked_64le(offs_t address, UINT64 data, UINT64 mem_mask)
4550{
4551   write_qword_masked_generic(ADDRESS_SPACE_DATA, address, data, mem_mask);
4552}
4553
4554void data_write_qword_masked_64be(offs_t address, UINT64 data, UINT64 mem_mask)
4555{
4556   write_qword_masked_generic(ADDRESS_SPACE_DATA, address, data, mem_mask);
4557}
4558
4559
4560/*-------------------------------------------------
4561    ADDRESS_SPACE_IO
4562-------------------------------------------------*/
4563
4564void io_write_byte_64le(offs_t address, UINT8 data)
4565{
4566   UINT32 shift = (address & 7) * 8;
4567   write_qword_masked_generic(ADDRESS_SPACE_IO, address, (UINT64)data << shift, ~((UINT64)0xff << shift));
4568}
4569
4570void io_write_byte_64be(offs_t address, UINT8 data)
4571{
4572   UINT32 shift = (~address & 7) * 8;
4573   write_qword_masked_generic(ADDRESS_SPACE_IO, address, (UINT64)data << shift, ~((UINT64)0xff << shift));
4574}
4575
4576void io_write_word_64le(offs_t address, UINT16 data)
4577{
4578   UINT32 shift = (address & 6) * 8;
4579   write_qword_masked_generic(ADDRESS_SPACE_IO, address, (UINT64)data << shift, ~((UINT64)0xffff << shift));
4580}
4581
4582void io_write_word_64be(offs_t address, UINT16 data)
4583{
4584   UINT32 shift = (~address & 6) * 8;
4585   write_qword_masked_generic(ADDRESS_SPACE_IO, address, (UINT64)data << shift, ~((UINT64)0xffff << shift));
4586}
4587
4588void io_write_dword_64le(offs_t address, UINT32 data)
4589{
4590   UINT32 shift = (address & 4) * 8;
4591   write_qword_masked_generic(ADDRESS_SPACE_IO, address, (UINT64)data << shift, ~((UINT64)0xffffffff << shift));
4592}
4593
4594void io_write_dword_64be(offs_t address, UINT32 data)
4595{
4596   UINT32 shift = (~address & 4) * 8;
4597   write_qword_masked_generic(ADDRESS_SPACE_IO, address, (UINT64)data << shift, ~((UINT64)0xffffffff << shift));
4598}
4599
4600void io_write_qword_64le(offs_t address, UINT64 data)
4601{
4602   write_qword_masked_generic(ADDRESS_SPACE_IO, address, data, 0);
4603}
4604
4605void io_write_qword_64be(offs_t address, UINT64 data)
4606{
4607   write_qword_masked_generic(ADDRESS_SPACE_IO, address, data, 0);
4608}
4609
4610void io_write_qword_masked_64le(offs_t address, UINT64 data, UINT64 mem_mask)
4611{
4612   write_qword_masked_generic(ADDRESS_SPACE_IO, address, data, mem_mask);
4613}
4614
4615void io_write_qword_masked_64be(offs_t address, UINT64 data, UINT64 mem_mask)
4616{
4617   write_qword_masked_generic(ADDRESS_SPACE_IO, address, data, mem_mask);
4618}
src/emu/video.h
r2375r2376
236236/* return text to display about the current speed */
237237const char *video_get_speed_text(running_machine *machine);
238238
239/* return the current effective speed percentage */
240double video_get_speed_percent(running_machine *machine);
241
239242/* get/set the current frameskip (-1 means auto) */
240243int video_get_frameskip(void);
241244void video_set_frameskip(int frameskip);
src/emu/memory.h
r2375r2376
801801***************************************************************************/
802802
803803/* declare program address space handlers */
804UINT8 program_read_byte_8(offs_t address);
805void program_write_byte_8(offs_t address, UINT8 data);
804UINT8 program_read_byte_8le(offs_t address);
805UINT16 program_read_word_8le(offs_t address);
806UINT32 program_read_dword_8le(offs_t address);
807UINT64 program_read_qword_8le(offs_t address);
808void program_write_byte_8le(offs_t address, UINT8 data);
809void program_write_word_8le(offs_t address, UINT16 data);
810void program_write_dword_8le(offs_t address, UINT32 data);
811void program_write_qword_8le(offs_t address, UINT64 data);
806812
807UINT8 program_read_byte_16be(offs_t address);
808UINT16 program_read_word_16be(offs_t address);
809void program_write_byte_16be(offs_t address, UINT8 data);
810void program_write_word_16be(offs_t address, UINT16 data);
813UINT8 program_read_byte_8be(offs_t address);
814UINT16 program_read_word_8be(offs_t address);
815UINT32 program_read_dword_8be(offs_t address);
816UINT64 program_read_qword_8be(offs_t address);
817void program_write_byte_8be(offs_t address, UINT8 data);
818void program_write_word_8be(offs_t address, UINT16 data);
819void program_write_dword_8be(offs_t address, UINT32 data);
820void program_write_qword_8be(offs_t address, UINT64 data);
811821
812822UINT8 program_read_byte_16le(offs_t address);
813823UINT16 program_read_word_16le(offs_t address);
824UINT32 program_read_dword_16le(offs_t address);
825UINT64 program_read_qword_16le(offs_t address);
814826void program_write_byte_16le(offs_t address, UINT8 data);
815827void program_write_word_16le(offs_t address, UINT16 data);
828void program_write_dword_16le(offs_t address, UINT32 data);
829void program_write_qword_16le(offs_t address, UINT64 data);
816830
817UINT8 program_read_byte_32be(offs_t address);
818UINT16 program_read_word_32be(offs_t address);
819UINT32 program_read_dword_32be(offs_t address);
820UINT32 program_read_masked_32be(offs_t address, UINT32 mem_mask);
821void program_write_byte_32be(offs_t address, UINT8 data);
822void program_write_word_32be(offs_t address, UINT16 data);
823void program_write_dword_32be(offs_t address, UINT32 data);
824void program_write_masked_32be(offs_t address, UINT32 data, UINT32 mem_mask);
831UINT8 program_read_byte_16be(offs_t address);
832UINT16 program_read_word_16be(offs_t address);
833UINT32 program_read_dword_16be(offs_t address);
834UINT64 program_read_qword_16be(offs_t address);
835void program_write_byte_16be(offs_t address, UINT8 data);
836void program_write_word_16be(offs_t address, UINT16 data);
837void program_write_dword_16be(offs_t address, UINT32 data);
838void program_write_qword_16be(offs_t address, UINT64 data);
825839
826840UINT8 program_read_byte_32le(offs_t address);
827841UINT16 program_read_word_32le(offs_t address);
828842UINT32 program_read_dword_32le(offs_t address);
829UINT32 program_read_masked_32le(offs_t address, UINT32 mem_mask);
843UINT32 program_read_dword_masked_32le(offs_t address, UINT32 mem_mask);
844UINT64 program_read_qword_32le(offs_t address);
830845void program_write_byte_32le(offs_t address, UINT8 data);
831846void program_write_word_32le(offs_t address, UINT16 data);
832847void program_write_dword_32le(offs_t address, UINT32 data);
833void program_write_masked_32le(offs_t address, UINT32 data, UINT32 mem_mask);
848void program_write_dword_masked_32le(offs_t address, UINT32 data, UINT32 mem_mask);
849void program_write_qword_32le(offs_t address, UINT64 data);
834850
835UINT8 program_read_byte_64be(offs_t address);
836UINT16 program_read_word_64be(offs_t address);
837UINT32 program_read_dword_64be(offs_t address);
838UINT64 program_read_qword_64be(offs_t address);
839UINT64 program_read_masked_64be(offs_t address, UINT64 mem_mask);
840void program_write_byte_64be(offs_t address, UINT8 data);
841void program_write_word_64be(offs_t address, UINT16 data);
842void program_write_dword_64be(offs_t address, UINT32 data);
843void program_write_qword_64be(offs_t address, UINT64 data);
844void program_write_masked_64be(offs_t address, UINT64 data, UINT64 mem_mask);
851UINT8 program_read_byte_32be(offs_t address);
852UINT16 program_read_word_32be(offs_t address);
853UINT32 program_read_dword_32be(offs_t address);
854UINT32 program_read_dword_masked_32be(offs_t address, UINT32 mem_mask);
855UINT64 program_read_qword_32be(offs_t address);
856void program_write_byte_32be(offs_t address, UINT8 data);
857void program_write_word_32be(offs_t address, UINT16 data);
858void program_write_dword_32be(offs_t address, UINT32 data);
859void program_write_dword_masked_32be(offs_t address, UINT32 data, UINT32 mem_mask);
860void program_write_qword_32be(offs_t address, UINT64 data);
845861
846862UINT8 program_read_byte_64le(offs_t address);
847863UINT16 program_read_word_64le(offs_t address);
848864UINT32 program_read_dword_64le(offs_t address);
849865UINT64 program_read_qword_64le(offs_t address);
850UINT64 program_read_masked_64le(offs_t address, UINT64 mem_mask);
866UINT64 program_read_qword_masked_64le(offs_t address, UINT64 mem_mask);
851867void program_write_byte_64le(offs_t address, UINT8 data);
852868void program_write_word_64le(offs_t address, UINT16 data);
853869void program_write_dword_64le(offs_t address, UINT32 data);
854870void program_write_qword_64le(offs_t address, UINT64 data);
855void program_write_masked_64le(offs_t address, UINT64 data, UINT64 mem_mask);
871void program_write_qword_masked_64le(offs_t address, UINT64 data, UINT64 mem_mask);
856872
873UINT8 program_read_byte_64be(offs_t address);
874UINT16 program_read_word_64be(offs_t address);
875UINT32 program_read_dword_64be(offs_t address);
876UINT64 program_read_qword_64be(offs_t address);
877UINT64 program_read_qword_masked_64be(offs_t address, UINT64 mem_mask);
878void program_write_byte_64be(offs_t address, UINT8 data);
879void program_write_word_64be(offs_t address, UINT16 data);
880void program_write_dword_64be(offs_t address, UINT32 data);
881void program_write_qword_64be(offs_t address, UINT64 data);
882void program_write_qword_masked_64be(offs_t address, UINT64 data, UINT64 mem_mask);
883
884
857885/* declare data address space handlers */
858UINT8 data_read_byte_8(offs_t address);
859void data_write_byte_8(offs_t address, UINT8 data);
886UINT8 data_read_byte_8le(offs_t address);
887UINT16 data_read_word_8le(offs_t address);
888UINT32 data_read_dword_8le(offs_t address);
889UINT64 data_read_qword_8le(offs_t address);
890void data_write_byte_8le(offs_t address, UINT8 data);
891void data_write_word_8le(offs_t address, UINT16 data);
892void data_write_dword_8le(offs_t address, UINT32 data);
893void data_write_qword_8le(offs_t address, UINT64 data);
860894
861UINT8 data_read_byte_16be(offs_t address);
862UINT16 data_read_word_16be(offs_t address);
863void data_write_byte_16be(offs_t address, UINT8 data);
864void data_write_word_16be(offs_t address, UINT16 data);
895UINT8 data_read_byte_8be(offs_t address);
896UINT16 data_read_word_8be(offs_t address);
897UINT32 data_read_dword_8be(offs_t address);
898UINT64 data_read_qword_8be(offs_t address);
899void data_write_byte_8be(offs_t address, UINT8 data);
900void data_write_word_8be(offs_t address, UINT16 data);
901void data_write_dword_8be(offs_t address, UINT32 data);
902void data_write_qword_8be(offs_t address, UINT64 data);
865903
866904UINT8 data_read_byte_16le(offs_t address);
867905UINT16 data_read_word_16le(offs_t address);
906UINT32 data_read_dword_16le(offs_t address);
907UINT64 data_read_qword_16le(offs_t address);
868908void data_write_byte_16le(offs_t address, UINT8 data);
869909void data_write_word_16le(offs_t address, UINT16 data);
910void data_write_dword_16le(offs_t address, UINT32 data);
911void data_write_qword_16le(offs_t address, UINT64 data);
870912
871UINT8 data_read_byte_32be(offs_t address);
872UINT16 data_read_word_32be(offs_t address);
873UINT32 data_read_dword_32be(offs_t address);
874UINT32 data_read_masked_32be(offs_t address, UINT32 mem_mask);
875void data_write_byte_32be(offs_t address, UINT8 data);
876void data_write_word_32be(offs_t address, UINT16 data);
877void data_write_dword_32be(offs_t address, UINT32 data);
878void data_write_masked_32be(offs_t address, UINT32 data, UINT32 mem_mask);
913UINT8 data_read_byte_16be(offs_t address);
914UINT16 data_read_word_16be(offs_t address);
915UINT32 data_read_dword_16be(offs_t address);
916UINT64 data_read_qword_16be(offs_t address);
917void data_write_byte_16be(offs_t address, UINT8 data);
918void data_write_word_16be(offs_t address, UINT16 data);
919void data_write_dword_16be(offs_t address, UINT32 data);
920void data_write_qword_16be(offs_t address, UINT64 data);
879921
880922UINT8 data_read_byte_32le(offs_t address);
881923UINT16 data_read_word_32le(offs_t address);
882924UINT32 data_read_dword_32le(offs_t address);
883UINT32 data_read_masked_32le(offs_t address, UINT32 mem_mask);
925UINT32 data_read_dword_masked_32le(offs_t address, UINT32 mem_mask);
926UINT64 data_read_qword_32le(offs_t address);
884927void data_write_byte_32le(offs_t address, UINT8 data);
885928void data_write_word_32le(offs_t address, UINT16 data);
886929void data_write_dword_32le(offs_t address, UINT32 data);
887void data_write_masked_32le(offs_t address, UINT32 data, UINT32 mem_mask);
930void data_write_dword_masked_32le(offs_t address, UINT32 data, UINT32 mem_mask);
931void data_write_qword_32le(offs_t address, UINT64 data);
888932
889UINT8 data_read_byte_64be(offs_t address);
890UINT16 data_read_word_64be(offs_t address);
891UINT32 data_read_dword_64be(offs_t address);
892UINT64 data_read_qword_64be(offs_t address);
893UINT64 data_read_masked_64be(offs_t address, UINT64 mem_mask);
894void data_write_byte_64be(offs_t address, UINT8 data);
895void data_write_word_64be(offs_t address, UINT16 data);
896void data_write_dword_64be(offs_t address, UINT32 data);
897void data_write_qword_64be(offs_t address, UINT64 data);
898void data_write_masked_64be(offs_t address, UINT64 data, UINT64 mem_mask);
933UINT8 data_read_byte_32be(offs_t address);
934UINT16 data_read_word_32be(offs_t address);
935UINT32 data_read_dword_32be(offs_t address);
936UINT32 data_read_dword_masked_32be(offs_t address, UINT32 mem_mask);
937UINT64 data_read_qword_32be(offs_t address);
938void data_write_byte_32be(offs_t address, UINT8 data);
939void data_write_word_32be(offs_t address, UINT16 data);
940void data_write_dword_32be(offs_t address, UINT32 data);
941void data_write_dword_masked_32be(offs_t address, UINT32 data, UINT32 mem_mask);
942void data_write_qword_32be(offs_t address, UINT64 data);
899943
900944UINT8 data_read_byte_64le(offs_t address);
901945UINT16 data_read_word_64le(offs_t address);
902946UINT32 data_read_dword_64le(offs_t address);
903947UINT64 data_read_qword_64le(offs_t address);
904UINT64 data_read_masked_64le(offs_t address, UINT64 mem_mask);
948UINT64 data_read_qword_masked_64le(offs_t address, UINT64 mem_mask);
905949void data_write_byte_64le(offs_t address, UINT8 data);
906950void data_write_word_64le(offs_t address, UINT16 data);
907951void data_write_dword_64le(offs_t address, UINT32 data);
908952void data_write_qword_64le(offs_t address, UINT64 data);
909void data_write_masked_64le(offs_t address, UINT64 data, UINT64 mem_mask);
953void data_write_qword_masked_64le(offs_t address, UINT64 data, UINT64 mem_mask);
910954
911/* declare I/O address space handlers */
912UINT8 io_read_byte_8(offs_t address);
913void io_write_byte_8(offs_t address, UINT8 data);
955UINT8 data_read_byte_64be(offs_t address);
956UINT16 data_read_word_64be(offs_t address);
957UINT32 data_read_dword_64be(offs_t address);
958UINT64 data_read_qword_64be(offs_t address);
959UINT64 data_read_qword_masked_64be(offs_t address, UINT64 mem_mask);
960void data_write_byte_64be(offs_t address, UINT8 data);
961void data_write_word_64be(offs_t address, UINT16 data);
962void data_write_dword_64be(offs_t address, UINT32 data);
963void data_write_qword_64be(offs_t address, UINT64 data);
964void data_write_qword_masked_64be(offs_t address, UINT64 data, UINT64 mem_mask);
914965
915UINT8 io_read_byte_16be(offs_t address);
916UINT16 io_read_word_16be(offs_t address);
917void io_write_byte_16be(offs_t address, UINT8 data);
918void io_write_word_16be(offs_t address, UINT16 data);
919966
967/* declare io address space handlers */
968UINT8 io_read_byte_8le(offs_t address);
969UINT16 io_read_word_8le(offs_t address);
970UINT32 io_read_dword_8le(offs_t address);
971UINT64 io_read_qword_8le(offs_t address);
972void io_write_byte_8le(offs_t address, UINT8 data);
973void io_write_word_8le(offs_t address, UINT16 data);
974void io_write_dword_8le(offs_t address, UINT32 data);
975void io_write_qword_8le(offs_t address, UINT64 data);
976
977UINT8 io_read_byte_8be(offs_t address);
978UINT16 io_read_word_8be(offs_t address);
979UINT32 io_read_dword_8be(offs_t address);
980UINT64 io_read_qword_8be(offs_t address);
981void io_write_byte_8be(offs_t address, UINT8 data);
982void io_write_word_8be(offs_t address, UINT16 data);
983void io_write_dword_8be(offs_t address, UINT32 data);
984void io_write_qword_8be(offs_t address, UINT64 data);
985
920986UINT8 io_read_byte_16le(offs_t address);
921987UINT16 io_read_word_16le(offs_t address);
988UINT32 io_read_dword_16le(offs_t address);
989UINT64 io_read_qword_16le(offs_t address);
922990void io_write_byte_16le(offs_t address, UINT8 data);
923991void io_write_word_16le(offs_t address, UINT16 data);
992void io_write_dword_16le(offs_t address, UINT32 data);
993void io_write_qword_16le(offs_t address, UINT64 data);
924994
925UINT8 io_read_byte_32be(offs_t address);
926UINT16 io_read_word_32be(offs_t address);
927UINT32 io_read_dword_32be(offs_t address);
928UINT32 io_read_masked_32be(offs_t address, UINT32 mem_mask);
929void io_write_byte_32be(offs_t address, UINT8 data);
930void io_write_word_32be(offs_t address, UINT16 data);
931void io_write_dword_32be(offs_t address, UINT32 data);
932void io_write_masked_32be(offs_t address, UINT32 data, UINT32 mem_mask);
995UINT8 io_read_byte_16be(offs_t address);
996UINT16 io_read_word_16be(offs_t address);
997UINT32 io_read_dword_16be(offs_t address);
998UINT64 io_read_qword_16be(offs_t address);
999void io_write_byte_16be(offs_t address, UINT8 data);
1000void io_write_word_16be(offs_t address, UINT16 data);
1001void io_write_dword_16be(offs_t address, UINT32 data);
1002void io_write_qword_16be(offs_t address, UINT64 data);
9331003
9341004UINT8 io_read_byte_32le(offs_t address);
9351005UINT16 io_read_word_32le(offs_t address);
9361006UINT32 io_read_dword_32le(offs_t address);
937UINT32 io_read_masked_32le(offs_t address, UINT32 mem_mask);
1007UINT32 io_read_dword_masked_32le(offs_t address, UINT32 mem_mask);
1008UINT64 io_read_qword_32le(offs_t address);
9381009void io_write_byte_32le(offs_t address, UINT8 data);
9391010void io_write_word_32le(offs_t address, UINT16 data);
9401011void io_write_dword_32le(offs_t address, UINT32 data);
941void io_write_masked_32le(offs_t address, UINT32 data, UINT32 mem_mask);
1012void io_write_dword_masked_32le(offs_t address, UINT32 data, UINT32 mem_mask);
1013void io_write_qword_32le(offs_t address, UINT64 data);
9421014
943UINT8 io_read_byte_64be(offs_t address);
944UINT16 io_read_word_64be(offs_t address);
945UINT32 io_read_dword_64be(offs_t address);
946UINT64 io_read_qword_64be(offs_t address);
947UINT64 io_read_masked_64be(offs_t address, UINT64 mem_mask);
948void io_write_byte_64be(offs_t address, UINT8 data);
949void io_write_word_64be(offs_t address, UINT16 data);
950void io_write_dword_64be(offs_t address, UINT32 data);
951void io_write_qword_64be(offs_t address, UINT64 data);
952void io_write_masked_64be(offs_t address, UINT64 data, UINT64 mem_mask);
1015UINT8 io_read_byte_32be(offs_t address);
1016UINT16 io_read_word_32be(offs_t address);
1017UINT32 io_read_dword_32be(offs_t address);
1018UINT32 io_read_dword_masked_32be(offs_t address, UINT32 mem_mask);
1019UINT64 io_read_qword_32be(offs_t address);
1020void io_write_byte_32be(offs_t address, UINT8 data);
1021void io_write_word_32be(offs_t address, UINT16 data);
1022void io_write_dword_32be(offs_t address, UINT32 data);
1023void io_write_dword_masked_32be(offs_t address, UINT32 data, UINT32 mem_mask);
1024void io_write_qword_32be(offs_t address, UINT64 data);
9531025
9541026UINT8 io_read_byte_64le(offs_t address);
9551027UINT16 io_read_word_64le(offs_t address);
9561028UINT32 io_read_dword_64le(offs_t address);
9571029UINT64 io_read_qword_64le(offs_t address);
958UINT64 io_read_masked_64le(offs_t address, UINT64 mem_mask);
1030UINT64 io_read_qword_masked_64le(offs_t address, UINT64 mem_mask);
9591031void io_write_byte_64le(offs_t address, UINT8 data);
9601032void io_write_word_64le(offs_t address, UINT16 data);
9611033void io_write_dword_64le(offs_t address, UINT32 data);
9621034void io_write_qword_64le(offs_t address, UINT64 data);
963void io_write_masked_64le(offs_t address, UINT64 data, UINT64 mem_mask);
1035void io_write_qword_masked_64le(offs_t address, UINT64 data, UINT64 mem_mask);
9641036
1037UINT8 io_read_byte_64be(offs_t address);
1038UINT16 io_read_word_64be(offs_t address);
1039UINT32 io_read_dword_64be(offs_t address);
1040UINT64 io_read_qword_64be(offs_t address);
1041UINT64 io_read_qword_masked_64be(offs_t address, UINT64 mem_mask);
1042void io_write_byte_64be(offs_t address, UINT8 data);
1043void io_write_word_64be(offs_t address, UINT16 data);
1044void io_write_dword_64be(offs_t address, UINT32 data);
1045void io_write_qword_64be(offs_t address, UINT64 data);
1046void io_write_qword_masked_64be(offs_t address, UINT64 data, UINT64 mem_mask);
9651047
1048
9661049#endif   /* __MEMORY_H__ */
src/emu/mame.c
r2375r2376
15171517static void init_machine(running_machine *machine)
15181518{
15191519   mame_private *mame = machine->mame_data;
1520   time_t newbase;
15201521   int num;
15211522
15221523   /* initialize basic can't-fail systems here */
r2375r2376
15451546   /* init the osd layer */
15461547   osd_init(machine);
15471548
1549   /* initialize the base time (needed for doing record/playback) */
1550   time(&mame->base_time);
1551
15481552   /* initialize the input system and input ports for the game */
15491553   /* this must be done before memory_init in order to allow specifying */
15501554   /* callbacks based on input port tags */
1551   input_port_init(machine, machine->gamedrv->ipt);
1555   newbase = input_port_init(machine, machine->gamedrv->ipt);
1556   if (newbase != 0)
1557      mame->base_time = newbase;
15521558
1553   /* initialize the base time (if not doing record/playback) */
1554   if (machine->record_file == NULL && machine->playback_file == NULL)
1555      time(&mame->base_time);
1556   else
1557      mame->base_time = 0;
1558
15591559   /* first load ROMs, then populate memory, and finally initialize CPUs */
15601560   /* these operations must proceed in this order */
15611561   rom_init(machine, machine->gamedrv->rom);
src/emu/inptport.c
r2375r2376
133133typedef struct _analog_port_info analog_port_info;
134134struct _analog_port_info
135135{
136   analog_port_info *   next;         /* linked list */
137   input_port_entry *   port;         /* pointer to the input port referenced */
138   double            accum;         /* accumulated value (including relative adjustments) */
139   double            previous;      /* previous adjusted value */
140   INT32            previousanalog;   /* previous analog value */
141   INT32            minimum;      /* minimum adjusted value */
142   INT32            maximum;      /* maximum adjusted value */
143   INT32            center;         /* center adjusted value for autocentering */
144   INT32            reverse_val;   /* value where we subtract from to reverse directions */
145   double            scalepos;      /* scale factor to apply to positive adjusted values */
146   double            scaleneg;      /* scale factor to apply to negative adjusted values */
147   double            keyscalepos;   /* scale factor to apply to the key delta field when pos */
148   double            keyscaleneg;   /* scale factor to apply to the key delta field when neg */
149   double            positionalscale;/* scale factor to divide a joystick into positions */
150   UINT8            shift;         /* left shift to apply to the final result */
151   UINT8            bits;         /* how many bits of resolution are expected? */
152   UINT8            absolute;      /* is this an absolute or relative input? */
153   UINT8            wraps;         /* does the control wrap around? */
154   UINT8            one_of_x;      /* is this a 1 of X positional input? */
155   UINT8            autocenter;      /* autocenter this input? */
156   UINT8            single_scale;   /* scale joystick differently if default is between min/max */
157   UINT8            interpolate;   /* should we do linear interpolation for mid-frame reads? */
158   UINT8            lastdigital;   /* was the last modification caused by a digital form? */
159   UINT32            crosshair_pos;   /* position of fake crosshair */
136   analog_port_info *   next;            /* linked list */
137   input_port_entry *   portentry;         /* pointer to the input port entry referenced */
138   INT32            accum;            /* accumulated value (including relative adjustments) */
139   INT32            previous;         /* previous adjusted value */
140   INT32            previousanalog;      /* previous analog value */
141   INT32            minimum;         /* minimum adjusted value */
142   INT32            maximum;         /* maximum adjusted value */
143   INT32            center;            /* center adjusted value for autocentering */
144   INT32            reverse_val;      /* value where we subtract from to reverse directions */
145   INT64            scalepos;         /* scale factor to apply to positive adjusted values */
146   INT64            scaleneg;         /* scale factor to apply to negative adjusted values */
147   INT64            keyscalepos;      /* scale factor to apply to the key delta field when pos */
148   INT64            keyscaleneg;      /* scale factor to apply to the key delta field when neg */
149   INT64            positionalscale;   /* scale factor to divide a joystick into positions */
150   UINT8            shift;            /* left shift to apply to the final result */
151   UINT8            bits;            /* how many bits of resolution are expected? */
152   UINT8            absolute;         /* is this an absolute or relative input? */
153   UINT8            wraps;            /* does the control wrap around? */
154   UINT8            one_of_x;         /* is this a 1 of X positional input? */
155   UINT8            autocenter;         /* autocenter this input? */
156   UINT8            single_scale;      /* scale joystick differently if default is between min/max */
157   UINT8            interpolate;      /* should we do linear interpolation for mid-frame reads? */
158   UINT8            lastdigital;      /* was the last modification caused by a digital form? */
159   UINT32            crosshair_pos;      /* position of fake crosshair */
160160};
161161
162162
163163typedef struct _custom_port_info custom_port_info;
164164struct _custom_port_info
165165{
166   custom_port_info *   next;      /* linked list */
167   input_port_entry *   port;      /* pointer to the input port referenced */
168   UINT8            shift;      /* left shift to apply to the final result */
166   custom_port_info *   next;            /* linked list */
167   input_port_entry *   portentry;         /* pointer to the input port entry referenced */
168   UINT8            shift;            /* left shift to apply to the final result */
169169};
170170
171171
172172typedef struct _changed_port_info changed_port_info;
173173struct _changed_port_info
174174{
175   changed_port_info *   next;      /* linked list */
176   input_port_entry *   port;      /* pointer to the input port referenced */
177   UINT8            shift;      /* right shift to apply before calling callback */
175   changed_port_info *   next;            /* linked list */
176   input_port_entry *   portentry;         /* pointer to the input port entry referenced */
177   UINT8            shift;            /* right shift to apply before calling callback */
178178};
179179
180180
181181typedef struct _input_bit_info input_bit_info;
182182struct _input_bit_info
183183{
184   input_port_entry *   port;      /* port for this input */
185   UINT8            impulse;   /* counter for impulse controls */
186   UINT8            last;      /* were we pressed last time? */
184   input_port_entry *   portentry;         /* port entry for this input */
185   UINT8            impulse;         /* counter for impulse controls */
186   UINT8            last;            /* were we pressed last time? */
187187};
188188
189189
190190typedef struct _input_port_info input_port_info;
191191struct _input_port_info
192192{
193   const char *      tag;      /* tag for this port */
194   UINT32            defvalue;   /* default value of all the bits */
195   UINT32            analog;      /* value from analog inputs */
196   UINT32            analogmask;   /* mask of all analog inputs */
197   UINT32            digital;   /* value from digital inputs */
198   UINT32            vblank;      /* value of all IPT_VBLANK bits */
199   UINT32            playback;   /* current playback override */
200   UINT8            has_custom;   /* do we have any custom ports? */
193   const char *      tag;            /* tag for this port */
194   UINT32            defvalue;         /* default value of all the bits */
195   UINT32            digital;         /* value from digital inputs */
196   UINT32            vblank;            /* value of all IPT_VBLANK bits */
201197   input_bit_info       bit[MAX_BITS_PER_PORT]; /* info about each bit in the port */
202   analog_port_info *   analoginfo;   /* pointer to linked list of analog port info */
203   custom_port_info *   custominfo;   /* pointer to linked list of custom port info */
204   changed_port_info *   changedinfo;/* pointer to linked list of changed port info */
198   analog_port_info *   analoginfo;         /* pointer to linked list of analog port info */
199   custom_port_info *   custominfo;         /* pointer to linked list of custom port info */
200   changed_port_info *   changedinfo;      /* pointer to linked list of changed port info */
205201};
206202
207203
208204typedef struct _digital_joystick_info digital_joystick_info;
209205struct _digital_joystick_info
210206{
211   input_port_entry *   port[4];   /* port for up,down,left,right respectively */
212   UINT8            inuse;      /* is this joystick used? */
213   UINT8            current;   /* current value */
214   UINT8            current4way;/* current 4-way value */
215   UINT8            previous;   /* previous value */
207   input_port_entry *   portentry[4];      /* port entry for up,down,left,right respectively */
208   UINT8            inuse;            /* is this joystick used? */
209   UINT8            current;         /* current value */
210   UINT8            current4way;      /* current 4-way value */
211   UINT8            previous;         /* previous value */
216212};
217213
218214
219215struct _input_port_init_params
220216{
221   input_port_entry *   ports;      /* base of the port array */
222   int               max_ports;   /* maximum number of ports we can support */
223   int               current_port;/* current port index */
217   input_port_entry *   ports;            /* base of the port array */
218   int               max_ports;         /* maximum number of ports we can support */
219   int               current_port;      /* current port index */
224220};
225221
226222
r2375r2376
234230#define JOYSTICK_INFO_FOR_PORT(in)   (&joystick_info[(in)->player][((in)->type - __ipt_digital_joystick_start) / 4])
235231#define JOYSTICK_DIR_FOR_PORT(in)   (((in)->type - __ipt_digital_joystick_start) % 4)
236232
237#define APPLY_SENSITIVITY(x,s)      (((double)(x) * (s)) / 100)
238#define APPLY_INVERSE_SENSITIVITY(x,s) (((double)(x) * 100) / (s))
233#define APPLY_SENSITIVITY(x,s)      (((INT64)(x) * (s)) / 100)
234#define APPLY_INVERSE_SENSITIVITY(x,s) (((INT64)(x) * 100) / (s))
239235
236#define COMPUTE_SCALE(num,den)      (((INT64)(num) << 24) / (den))
237#define RECIP_SCALE(s)            (((INT64)1 << 48) / (s))
238#define APPLY_SCALE(x,s)         (((INT64)(x) * (s)) >> 24)
240239
241240
241
242242/***************************************************************************
243243    GLOBAL VARIABLES
244244***************************************************************************/
r2375r2376
258258/* original input_ports without modifications */
259259static input_port_entry *input_ports_default;
260260
261/* recorded speed read from an INP file */
262static double rec_speed;
263
264/* set to TRUE if INP file being played is an extended INP file */
265static int extended_inp;
266
267/* for average speed calculations */
261/* for scaling analog ports */
268262static attotime last_update;
269263static attoseconds_t last_delta;
270static int framecount;
271static double totalspeed;
272264
265/* playback information */
266static UINT64 playback_accumulated_speed;
267static UINT32 playback_accumulated_frames;
273268
274269
270
275271/***************************************************************************
276272    PORT HANDLER TABLES
277273***************************************************************************/
r2375r2376
10341030    FUNCTION PROTOTYPES
10351031***************************************************************************/
10361032
1037static void setup_playback(running_machine *machine);
1038static void setup_record(running_machine *machine);
10391033static void input_port_exit(running_machine *machine);
10401034static void input_port_frame(running_machine *machine);
1035static void input_port_frame_update(running_machine *machine);
10411036static void input_port_load(int config_type, xml_data_node *parentnode);
10421037static void input_port_save(int config_type, xml_data_node *parentnode);
1043static void update_digital_joysticks(void);
1038static void update_digital_joysticks(running_machine *machine);
10441039static void update_analog_port(int port);
1045static void interpolate_analog_port(int port);
10461040static void autoselect_device(const input_port_entry *ipt, int type1, int type2, int type3, const char *option, const char *ananame);
10471041
1042/* playback and record */
1043static time_t playback_init(running_machine *machine);
1044static void record_init(running_machine *machine);
1045static void playback_end(running_machine *machine, const char *message);
1046static void record_end(running_machine *machine, const char *message);
1047static void playback_frame(running_machine *machine, attotime curtime);
1048static void record_frame(running_machine *machine, attotime curtime);
1049static void playback_port(running_machine *machine, input_port_info *portinfo);
1050static void record_port(running_machine *machine, input_port_info *portinfo);
10481051
10491052
1053
10501054/***************************************************************************
10511055    CORE IMPLEMENTATION
10521056***************************************************************************/
r2375r2376
10571061 *
10581062 *************************************/
10591063
1060void input_port_init(running_machine *machine, const input_port_token *ipt)
1064time_t input_port_init(running_machine *machine, const input_port_token *ipt)
10611065{
10621066   int ipnum, player;
1067   time_t basetime;
10631068
10641069   /* add an exit callback */
10651070   add_exit_callback(machine, input_port_exit);
r2375r2376
10891094   if (ipt != NULL)
10901095   {
10911096      const char *joystick_map_default = options_get_string(mame_options(), OPTION_JOYSTICK_MAP);
1092      input_port_entry *port;
1097      input_port_entry *portentry;
10931098      int portnum;
10941099
10951100      /* allocate input ports */
r2375r2376
11101115
11111116      /* look for 4-way joysticks and change the default map if we find any */
11121117      if (joystick_map_default[0] == 0 || strcmp(joystick_map_default, "auto") == 0)
1113         for (port = machine->input_ports; port->type != IPT_END; port++)
1114            if (IS_DIGITAL_JOYSTICK(port) && port->way == 4)
1118         for (portentry = machine->input_ports; portentry->type != IPT_END; portentry++)
1119            if (IS_DIGITAL_JOYSTICK(portentry) && portentry->way == 4)
11151120            {
1116               input_device_set_joystick_map(-1, port->rotated ? joystick_map_4way_diagonal : joystick_map_4way_sticky);
1121               input_device_set_joystick_map(-1, portentry->rotated ? joystick_map_4way_diagonal : joystick_map_4way_sticky);
11171122               break;
11181123            }
11191124
11201125      /* identify all the tagged ports up front so the memory system can access them */
11211126      portnum = 0;
1122      for (port = machine->input_ports; port->type != IPT_END; port++)
1123         if (port->type == IPT_PORT)
1124            port_info[portnum++].tag = port->start.tag;
1127      for (portentry = machine->input_ports; portentry->type != IPT_END; portentry++)
1128         if (portentry->type == IPT_PORT)
1129            port_info[portnum++].tag = portentry->start.tag;
11251130
11261131      /* look up all the tags referenced in conditions */
1127      for (port = machine->input_ports; port->type != IPT_END; port++)
1128         if (port->condition.tag)
1132      for (portentry = machine->input_ports; portentry->type != IPT_END; portentry++)
1133         if (portentry->condition.tag)
11291134         {
1130            int tag = port_tag_to_index(port->condition.tag);
1135            int tag = port_tag_to_index(portentry->condition.tag);
11311136            if (tag == -1)
1132               fatalerror("Conditional port references invalid tag '%s'", port->condition.tag);
1133            port->condition.portnum = tag;
1137               fatalerror("Conditional port references invalid tag '%s'", portentry->condition.tag);
1138            portentry->condition.portnum = tag;
11341139         }
11351140   }
11361141
r2375r2376
11381143   config_register("input", input_port_load, input_port_save);
11391144
11401145   /* open playback and record files if specified */
1141   setup_playback(machine);
1142   setup_record(machine);
1143}
1146   basetime = playback_init(machine);
1147   record_init(machine);
11441148
1145
1146
1147/*************************************
1148 *
1149 *  Set up for playback
1150 *
1151 *************************************/
1152
1153static void setup_playback(running_machine *machine)
1154{
1155   const char *filename = options_get_string(mame_options(), OPTION_PLAYBACK);
1156   ext_inp_header extinpheader;
1157   inp_header inpheader;
1158   file_error filerr;
1159   time_t started_time;
1160   char check[7];
1161
1162   /* if no file, nothing to do */
1163   if (filename[0] == 0)
1164      return;
1165
1166   /* open the playback file */
1167   filerr = mame_fopen(SEARCHPATH_INPUTLOG, filename, OPEN_FLAG_READ, &machine->playback_file);
1168   assert_always(filerr == FILERR_NONE, "Failed to open file for playback");
1169
1170   /* read first four bytes to check INP type */
1171   mame_fread(machine->playback_file, check, 7);
1172   mame_fseek(machine->playback_file, 0, SEEK_SET);
1173
1174   /* Check if input file is an eXtended INP file */
1175   extended_inp = (memcmp(check, "XINP\0\0\0", 7) == 0);
1176   if (!extended_inp)
1177   {
1178      /* read playback header */
1179      mame_fread(machine->playback_file, &inpheader, sizeof(inpheader));
1180
1181      /* if the first byte is not alphanumeric, it's an old INP file with no header */
1182      if (!isalnum(inpheader.name[0]))
1183         mame_fseek(machine->playback_file, 0, SEEK_SET);
1184
1185      /* else verify the header against the current game */
1186      else if (strcmp(machine->gamedrv->name, inpheader.name) != 0)
1187         fatalerror("Input file is for " GAMENOUN " '%s', not for current " GAMENOUN " '%s'\n", inpheader.name, machine->gamedrv->name);
1188
1189      /* otherwise, print a message indicating what's happening */
1190      else
1191         mame_printf_info("Playing back previously recorded " GAMENOUN " %s\n", machine->gamedrv->name);
1192   }
1193    else
1194   {
1195      /* read playback header */
1196      mame_fread(machine->playback_file, &extinpheader, sizeof(extinpheader));
1197
1198      /* output info to console */
1199      mame_printf_info("Extended INP file info:\n");
1200      mame_printf_info("Version string: %s\n", extinpheader.version);
1201      started_time = (time_t)extinpheader.starttime;
1202      mame_printf_info("Start time: %s\n", ctime(&started_time));
1203
1204      /* verify header against current game */
1205      if (strcmp(machine->gamedrv->name, extinpheader.shortname) != 0)
1206         fatalerror("Input file is for " GAMENOUN " '%s', not for current " GAMENOUN " '%s'\n", extinpheader.shortname, machine->gamedrv->name);
1207      else
1208         mame_printf_info("Playing back previously recorded " GAMENOUN " %s\n", machine->gamedrv->name);
1209   }
1149   return basetime;
12101150}
12111151
12121152
1213/*************************************
1214 *
1215 *  Set up for recording
1216 *
1217 *************************************/
12181153
1219static void setup_record(running_machine *machine)
1220{
1221   const char *filename = options_get_string(mame_options(), OPTION_RECORD);
1222   inp_header inpheader;
1223   file_error filerr;
1224
1225   /* if no file, nothing to do */
1226   if (filename[0] == 0)
1227      return;
1228
1229   /* open the record file  */
1230   filerr = mame_fopen(SEARCHPATH_INPUTLOG, filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &machine->record_file);
1231   assert_always(filerr == FILERR_NONE, "Failed to open file for recording");
1232
1233   /* create a header */
1234   memset(&inpheader, 0, sizeof(inpheader));
1235   strcpy(inpheader.name, machine->gamedrv->name);
1236   mame_fwrite(machine->record_file, &inpheader, sizeof(inpheader));
1237}
1238
1239
1240
12411154/*************************************
12421155 *
12431156 *  Input port exit
r2375r2376
12471160void input_port_exit(running_machine *machine)
12481161{
12491162   /* close any playback or recording files */
1250   if (machine->playback_file != NULL)
1251      mame_fclose(machine->playback_file);
1252   if (machine->record_file != NULL)
1253      mame_fclose(machine->record_file);
1163   playback_end(machine, NULL);
1164   record_end(machine, NULL);
12541165}
12551166
12561167
r2375r2376
12631174
12641175static void input_port_postload(void)
12651176{
1266   input_port_entry *port;
1177   input_port_entry *portentry;
12671178   int portnum, bitnum;
12681179   UINT32 mask;
12691180
12701181   /* loop over the ports and identify all the analog inputs */
12711182   portnum = -1;
12721183   bitnum = 0;
1273   for (port = Machine->input_ports; port->type != IPT_END; port++)
1184   for (portentry = Machine->input_ports; portentry->type != IPT_END; portentry++)
12741185   {
12751186      /* if this is IPT_PORT, increment the port number */
1276      if (port->type == IPT_PORT)
1187      if (portentry->type == IPT_PORT)
12771188      {
12781189         portnum++;
12791190         bitnum = 0;
12801191      }
12811192
12821193      /* if this is not a DIP setting or config setting, add it to the list */
1283      else if (port->type != IPT_DIPSWITCH_SETTING && port->type != IPT_CONFIG_SETTING)
1194      else if (portentry->type != IPT_DIPSWITCH_SETTING && portentry->type != IPT_CONFIG_SETTING)
12841195      {
12851196         /* fatal error if we didn't hit an IPT_PORT */
12861197         if (portnum < 0)
r2375r2376
12911202            fatalerror("Error in InputPort definition: too many bits for a port (%d max)", MAX_BITS_PER_PORT);
12921203
12931204         /* fill in the bit info */
1294         port_info[portnum].bit[bitnum].port = port;
1205         port_info[portnum].bit[bitnum].portentry = portentry;
12951206         port_info[portnum].bit[bitnum].impulse = 0;
12961207         port_info[portnum].bit[bitnum++].last = 0;
12971208
12981209         /* if this is a custom input, add it to the list */
1299         if (port->custom != NULL)
1210         if (portentry->custom != NULL)
13001211         {
13011212            custom_port_info *info;
13021213
r2375r2376
13051216            memset(info, 0, sizeof(*info));
13061217
13071218            /* fill in the data */
1308            info->port = port;
1309            for (mask = port->mask; !(mask & 1); mask >>= 1)
1219            info->portentry = portentry;
1220            for (mask = portentry->mask; !(mask & 1); mask >>= 1)
13101221               info->shift++;
13111222
13121223            /* hook in the list */
r2375r2376
13151226         }
13161227
13171228         /* if this is a changed input, add it to the list */
1318         else if (port->changed != NULL)
1229         else if (portentry->changed != NULL)
13191230         {
13201231            changed_port_info *info;
13211232
r2375r2376
13241235            memset(info, 0, sizeof(*info));
13251236
13261237            /* fill in the data */
1327            info->port = port;
1328            for (mask = port->mask; !(mask & 1); mask >>= 1)
1238            info->portentry = portentry;
1239            for (mask = portentry->mask; !(mask & 1); mask >>= 1)
13291240               info->shift++;
13301241
13311242            /* hook in the list */
r2375r2376
13341245         }
13351246
13361247         /* if this is an analog port, create an info struct for it */
1337         else if (IS_ANALOG(port))
1248         else if (IS_ANALOG(portentry))
13381249         {
13391250            analog_port_info *info;
13401251
r2375r2376
13431254            memset(info, 0, sizeof(*info));
13441255
13451256            /* fill in the data */
1346            info->port = port;
1347            for (mask = port->mask; !(mask & 1); mask >>= 1)
1257            info->portentry = portentry;
1258            for (mask = portentry->mask; !(mask & 1); mask >>= 1)
13481259               info->shift++;
13491260            for ( ; mask & 1; mask >>= 1)
13501261               info->bits++;
r2375r2376
13551266            info->interpolate = 1;
13561267
13571268            /* adjust default, min, and max so they fall in the bitmask range */
1358            port->default_value = (port->default_value & port->mask) >> info->shift;
1359            if (port->type != IPT_POSITIONAL && port->type != IPT_POSITIONAL_V)
1269            portentry->default_value = (portentry->default_value & portentry->mask) >> info->shift;
1270            if (portentry->type != IPT_POSITIONAL && portentry->type != IPT_POSITIONAL_V)
13601271            {
1361               port->analog.min = (port->analog.min & port->mask) >> info->shift;
1362               port->analog.max = (port->analog.max & port->mask) >> info->shift;
1272               portentry->analog.min = (portentry->analog.min & portentry->mask) >> info->shift;
1273               portentry->analog.max = (portentry->analog.max & portentry->mask) >> info->shift;
13631274            }
13641275
1365            switch (port->type)
1276            switch (portentry->type)
13661277            {
13671278               /* pedals start at and autocenter to the min range*/
13681279               case IPT_PEDAL:
r2375r2376
13701281               case IPT_PEDAL3:
13711282                  info->center = INPUT_ABSOLUTE_MIN;
13721283                  /* force pedals to start at their scaled minimum */
1373                  info->accum = APPLY_INVERSE_SENSITIVITY(info->center, port->analog.sensitivity);
1284                  info->accum = APPLY_INVERSE_SENSITIVITY(info->center, portentry->analog.sensitivity);
13741285                  /* fall through to complete setup */
13751286
13761287               /* pedals, paddles and analog joysticks are absolute and autocenter */
r2375r2376
14081319               /* set each position to be 512 units */
14091320               case IPT_POSITIONAL:
14101321               case IPT_POSITIONAL_V:
1411                  info->positionalscale = (double)(port->analog.max) / (INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN);
1322                  info->positionalscale = COMPUTE_SCALE(portentry->analog.max, INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN);
14121323                  /* force to only use PORT_POSITIONS data */
1413                  port->analog.min = 0;
1414                  port->analog.max--;
1415                  info->autocenter = !port->analog.wraps;
1416                  info->wraps = port->analog.wraps;
1324                  portentry->analog.min = 0;
1325                  portentry->analog.max--;
1326                  info->autocenter = !portentry->analog.wraps;
1327                  info->wraps = portentry->analog.wraps;
14171328                  break;
14181329
14191330               default:
r2375r2376
14281339                     * and the default port value is between min/max,
14291340                     * we need to scale differently for the +/- directions.
14301341                     * All other absolute types use a 1:1 scale */
1431               info->single_scale = (port->default_value == port->analog.min) || (port->default_value == port->analog.max);
1342               info->single_scale = (portentry->default_value == portentry->analog.min) || (portentry->default_value == portentry->analog.max);
14321343
14331344               if (!info->single_scale)
14341345               {
14351346                  /* axis moves in both directions from the default value */
14361347
14371348                  /* unsigned */
1438                  info->scalepos = ((double)port->analog.max - (double)port->default_value) / (double)(INPUT_ABSOLUTE_MAX - 0);
1439                  info->scaleneg = ((double)port->default_value - (double)port->analog.min) / (double)(0 - INPUT_ABSOLUTE_MIN);
1349                  info->scalepos = COMPUTE_SCALE(portentry->analog.max - portentry->default_value, INPUT_ABSOLUTE_MAX - 0);
1350                  info->scaleneg = COMPUTE_SCALE(portentry->default_value - portentry->analog.min, 0 - INPUT_ABSOLUTE_MIN);
14401351
1441                  if (port->analog.min > port->analog.max)
1352                  if (portentry->analog.min > portentry->analog.max)
14421353                  {
14431354                     /* signed */
14441355                     info->scaleneg *= -1;
r2375r2376
14501361               else
14511362               {
14521363                  /* single axis that increases from default */
1453                  info->scalepos = (double)(port->analog.max - port->analog.min) / (double)(INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN);
1364                  info->scalepos = COMPUTE_SCALE(portentry->analog.max - portentry->analog.min, INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN);
14541365
14551366                  /* move from default */
1456                  if (port->default_value == port->analog.max)
1367                  if (portentry->default_value == portentry->analog.max)
14571368                     info->scalepos *= -1;
14581369
14591370                  /* make the scaling the same for easier coding when we need to scale */
r2375r2376
14711382               /* The validity checks are purposely set up to not allow you to use anything other */
14721383               /* a default of 0 and PORT_MINMAX(0,mask).  This is in case the need arises to use */
14731384               /* this feature in the future.  Keeping the code in does not hurt anything. */
1474               if (port->analog.min > port->analog.max)
1385               if (portentry->analog.min > portentry->analog.max)
14751386                  /* adjust for signed */
1476                  port->analog.min *= -1;
1387                  portentry->analog.min *= -1;
14771388
1478               info->minimum = (port->analog.min - port->default_value) * 512;
1479               info->maximum = (port->analog.max - port->default_value) * 512;
1389               info->minimum = (portentry->analog.min - portentry->default_value) * 512;
1390               info->maximum = (portentry->analog.max - portentry->default_value) * 512;
14801391
14811392               /* make the scaling the same for easier coding when we need to scale */
1482               info->scaleneg = info->scalepos = 1.0 / 512.0;
1393               info->scaleneg = info->scalepos = COMPUTE_SCALE(1, 512);
14831394
1484               if (port->analog.reset)
1395               if (portentry->analog.reset)
14851396                  /* delta values reverse from center */
14861397                  info->reverse_val = 0;
14871398               else
r2375r2376
14901401                  info->reverse_val = info->maximum + info->minimum;
14911402
14921403                  /* relative controls reverse from 1 past their max range */
1493                  if (info->positionalscale == 0) info->reverse_val += 512;
1404                  if (info->positionalscale == 0)
1405                     info->reverse_val += 512;
14941406               }
14951407            }
14961408
14971409            /* compute scale for keypresses */
1498            info->keyscalepos = 1.0 / info->scalepos;
1499            info->keyscaleneg = 1.0 / info->scaleneg;
1410            info->keyscalepos = RECIP_SCALE(info->scalepos);
1411            info->keyscaleneg = RECIP_SCALE(info->scaleneg);
15001412
15011413            /* hook in the list */
15021414            info->next = port_info[portnum].analoginfo;
r2375r2376
15041416         }
15051417
15061418         /* if this is a digital joystick port, update info on it */
1507         else if (IS_DIGITAL_JOYSTICK(port))
1419         else if (IS_DIGITAL_JOYSTICK(portentry))
15081420         {
1509            digital_joystick_info *info = JOYSTICK_INFO_FOR_PORT(port);
1510            info->port[JOYSTICK_DIR_FOR_PORT(port)] = port;
1421            digital_joystick_info *info = JOYSTICK_INFO_FOR_PORT(portentry);
1422            info->portentry[JOYSTICK_DIR_FOR_PORT(portentry)] = portentry;
15111423            info->inuse = 1;
15121424         }
15131425      }
15141426   }
15151427
15161428   /* run an initial update */
1517   input_port_frame(Machine);
1429   input_port_frame_update(Machine);
15181430}
15191431
15201432
r2375r2376
19511863static void input_port_detokenize(input_port_init_params *param, const input_port_token *ipt)
19521864{
19531865   UINT32 entrytype = INPUT_TOKEN_INVALID;
1954   input_port_entry *port = NULL;
1866   input_port_entry *portentry = NULL;
19551867   const char *modify_tag = NULL;
19561868   int seq_index[3] = {0};
19571869
r2375r2376
19821894         case INPUT_TOKEN_START:
19831895         case INPUT_TOKEN_START_TAG:
19841896            modify_tag = NULL;
1985            port = input_port_initialize(param, IPT_PORT, NULL, 0, 0);
1897            portentry = input_port_initialize(param, IPT_PORT, NULL, 0, 0);
19861898            if (entrytype == INPUT_TOKEN_START_TAG)
1987               port->start.tag = TOKEN_GET_STRING(ipt);
1899               portentry->start.tag = TOKEN_GET_STRING(ipt);
19881900            break;
19891901
19901902         /* modify an existing port */
r2375r2376
19971909            TOKEN_UNGET_UINT32(ipt);
19981910            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, type, 24);
19991911            TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32);
2000            port = input_port_initialize(param, type, modify_tag, mask, defval);
1912            portentry = input_port_initialize(param, type, modify_tag, mask, defval);
20011913            seq_index[0] = seq_index[1] = seq_index[2] = 0;
20021914            break;
20031915
r2375r2376
20061918            TOKEN_GET_UINT32_UNPACK3(ipt, entrytype, 8, hasdiploc, 1, strindex, 23);
20071919            TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32);
20081920
2009            port = input_port_initialize(param, IPT_DIPSWITCH_NAME, modify_tag, mask, mask & defval);
1921            portentry = input_port_initialize(param, IPT_DIPSWITCH_NAME, modify_tag, mask, mask & defval);
20101922            temptoken.i = strindex;
2011            port->name = input_port_string_from_token(temptoken);
1923            portentry->name = input_port_string_from_token(temptoken);
20121924            if (strindex == INPUT_STRING_Service_Mode)
20131925            {
2014               port->toggle = TRUE;
2015               port->seq.code[0] = KEYCODE_F2;
1926               portentry->toggle = TRUE;
1927               portentry->seq.code[0] = KEYCODE_F2;
20161928            }
20171929            if (hasdiploc)
2018               input_port_parse_diplocation(port, TOKEN_GET_STRING(ipt));
1930               input_port_parse_diplocation(portentry, TOKEN_GET_STRING(ipt));
20191931
2020            port = input_port_initialize(param, IPT_DIPSWITCH_SETTING, modify_tag, 0, mask & defval);
1932            portentry = input_port_initialize(param, IPT_DIPSWITCH_SETTING, modify_tag, 0, mask & defval);
20211933            temptoken.i = INPUT_STRING_Off;
2022            port->name = input_port_string_from_token(temptoken);
1934            portentry->name = input_port_string_from_token(temptoken);
20231935
2024            port = input_port_initialize(param, IPT_DIPSWITCH_SETTING, modify_tag, 0, mask & ~defval);
1936            portentry = input_port_initialize(param, IPT_DIPSWITCH_SETTING, modify_tag, 0, mask & ~defval);
20251937            temptoken.i = INPUT_STRING_On;
2026            port->name = input_port_string_from_token(temptoken);
1938            portentry->name = input_port_string_from_token(temptoken);
20271939            break;
20281940
20291941         /* append a code */
r2375r2376
20311943            TOKEN_UNGET_UINT32(ipt);
20321944            TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32);
20331945            if (seq_index[0] > 0)
2034               port->seq.code[seq_index[0]++] = SEQCODE_OR;
2035            port->seq.code[seq_index[0]++] = val;
1946               portentry->seq.code[seq_index[0]++] = SEQCODE_OR;
1947            portentry->seq.code[seq_index[0]++] = val;
20361948            break;
20371949
20381950         case INPUT_TOKEN_CODE_DEC:
20391951            TOKEN_UNGET_UINT32(ipt);
20401952            TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32);
20411953            if (seq_index[1] > 0)
2042               port->analog.decseq.code[seq_index[1]++] = SEQCODE_OR;
2043            port->analog.decseq.code[seq_index[1]++] = val;
1954               portentry->analog.decseq.code[seq_index[1]++] = SEQCODE_OR;
1955            portentry->analog.decseq.code[seq_index[1]++] = val;
20441956            break;
20451957
20461958         case INPUT_TOKEN_CODE_INC:
20471959            TOKEN_UNGET_UINT32(ipt);
20481960            TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32);
20491961            if (seq_index[2] > 0)
2050               port->analog.incseq.code[seq_index[2]++] = SEQCODE_OR;
2051            port->analog.incseq.code[seq_index[2]++] = val;
1962               portentry->analog.incseq.code[seq_index[2]++] = SEQCODE_OR;
1963            portentry->analog.incseq.code[seq_index[2]++] = val;
20521964            break;
20531965
20541966         /* joystick flags */
r2375r2376
20561968         case INPUT_TOKEN_4WAY:
20571969         case INPUT_TOKEN_8WAY:
20581970         case INPUT_TOKEN_16WAY:
2059            port->way = 2 << (entrytype - INPUT_TOKEN_2WAY);
1971            portentry->way = 2 << (entrytype - INPUT_TOKEN_2WAY);
20601972            break;
20611973
20621974         case INPUT_TOKEN_ROTATED:
2063            port->rotated = TRUE;
1975            portentry->rotated = TRUE;
20641976            break;
20651977
20661978         /* general flags */
20671979         case INPUT_TOKEN_NAME:
2068            port->name = input_port_string_from_token(*ipt++);
1980            portentry->name = input_port_string_from_token(*ipt++);
20691981            break;
20701982
20711983         case INPUT_TOKEN_PLAYER1:
r2375r2376
20761988         case INPUT_TOKEN_PLAYER6:
20771989         case INPUT_TOKEN_PLAYER7:
20781990         case INPUT_TOKEN_PLAYER8:
2079            port->player = entrytype - INPUT_TOKEN_PLAYER1;
1991            portentry->player = entrytype - INPUT_TOKEN_PLAYER1;
20801992            break;
20811993
20821994         case INPUT_TOKEN_COCKTAIL:
2083            port->cocktail = TRUE;
2084            port->player = 1;
1995            portentry->cocktail = TRUE;
1996            portentry->player = 1;
20851997            break;
20861998
20871999         case INPUT_TOKEN_TOGGLE:
2088            port->toggle = TRUE;
2000            portentry->toggle = TRUE;
20892001            break;
20902002
20912003         case INPUT_TOKEN_IMPULSE:
20922004            TOKEN_UNGET_UINT32(ipt);
2093            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, port->impulse, 24);
2005            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->impulse, 24);
20942006            break;
20952007
20962008         case INPUT_TOKEN_REVERSE:
2097            port->analog.reverse = TRUE;
2009            portentry->analog.reverse = TRUE;
20982010            break;
20992011
21002012         case INPUT_TOKEN_RESET:
2101            port->analog.reset = TRUE;
2013            portentry->analog.reset = TRUE;
21022014            break;
21032015
21042016         case INPUT_TOKEN_UNUSED:
2105            port->unused = TRUE;
2017            portentry->unused = TRUE;
21062018            break;
21072019
21082020         /* analog settings */
21092021         case INPUT_TOKEN_MINMAX:
2110            TOKEN_GET_UINT64_UNPACK2(ipt, port->analog.min, 32, port->analog.max, 32);
2022            TOKEN_GET_UINT64_UNPACK2(ipt, portentry->analog.min, 32, portentry->analog.max, 32);
21112023            break;
21122024
21132025         case INPUT_TOKEN_SENSITIVITY:
21142026            TOKEN_UNGET_UINT32(ipt);
2115            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, port->analog.sensitivity, 24);
2027            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->analog.sensitivity, 24);
21162028            break;
21172029
21182030         case INPUT_TOKEN_KEYDELTA:
21192031            TOKEN_UNGET_UINT32(ipt);
2120            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, port->analog.delta, -24);
2121            port->analog.centerdelta = port->analog.delta;
2032            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->analog.delta, -24);
2033            portentry->analog.centerdelta = portentry->analog.delta;
21222034            break;
21232035
21242036         case INPUT_TOKEN_CENTERDELTA:
21252037            TOKEN_UNGET_UINT32(ipt);
2126            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, port->analog.centerdelta, -24);
2038            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->analog.centerdelta, -24);
21272039            break;
21282040
21292041         case INPUT_TOKEN_CROSSHAIR:
21302042            TOKEN_UNGET_UINT32(ipt);
2131            TOKEN_GET_UINT32_UNPACK3(ipt, entrytype, 8, port->analog.crossaxis, 4, port->analog.crossaltaxis, -20);
2132            TOKEN_GET_UINT64_UNPACK2(ipt, port->analog.crossscale, -32, port->analog.crossoffset, -32);
2133            port->analog.crossaltaxis *= 1.0f / 65536.0f;
2134            port->analog.crossscale *= 1.0f / 65536.0f;
2135            port->analog.crossoffset *= 1.0f / 65536.0f;
2043            TOKEN_GET_UINT32_UNPACK3(ipt, entrytype, 8, portentry->analog.crossaxis, 4, portentry->analog.crossaltaxis, -20);
2044            TOKEN_GET_UINT64_UNPACK2(ipt, portentry->analog.crossscale, -32, portentry->analog.crossoffset, -32);
2045            portentry->analog.crossaltaxis *= 1.0f / 65536.0f;
2046            portentry->analog.crossscale *= 1.0f / 65536.0f;
2047            portentry->analog.crossoffset *= 1.0f / 65536.0f;
21362048            break;
21372049
21382050         case INPUT_TOKEN_FULL_TURN_COUNT:
21392051            TOKEN_UNGET_UINT32(ipt);
2140            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, port->analog.full_turn_count, 24);
2052            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->analog.full_turn_count, 24);
21412053            break;
21422054
21432055         case INPUT_TOKEN_POSITIONS:
21442056            TOKEN_UNGET_UINT32(ipt);
2145            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, port->analog.max, 24);
2057            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->analog.max, 24);
21462058            break;
21472059
21482060         case INPUT_TOKEN_WRAPS:
2149            port->analog.wraps = TRUE;
2061            portentry->analog.wraps = TRUE;
21502062            break;
21512063
21522064         case INPUT_TOKEN_REMAP_TABLE:
2153            port->analog.remap_table = TOKEN_GET_PTR(ipt, ui32ptr);
2065            portentry->analog.remap_table = TOKEN_GET_PTR(ipt, ui32ptr);
21542066            break;
21552067
21562068         case INPUT_TOKEN_INVERT:
2157            port->analog.invert = TRUE;
2069            portentry->analog.invert = TRUE;
21582070            break;
21592071
21602072         /* custom callbacks */
21612073         case INPUT_TOKEN_CUSTOM:
2162            port->custom = TOKEN_GET_PTR(ipt, customptr);
2163            port->custom_param = (void *)TOKEN_GET_PTR(ipt, voidptr);
2074            portentry->custom = TOKEN_GET_PTR(ipt, customptr);
2075            portentry->custom_param = (void *)TOKEN_GET_PTR(ipt, voidptr);
21642076            break;
21652077
21662078         /* changed callbacks */
21672079         case INPUT_TOKEN_CHANGED:
2168            port->changed = TOKEN_GET_PTR(ipt, changedptr);
2169            port->changed_param = (void *)TOKEN_GET_PTR(ipt, voidptr);
2080            portentry->changed = TOKEN_GET_PTR(ipt, changedptr);
2081            portentry->changed_param = (void *)TOKEN_GET_PTR(ipt, voidptr);
21702082            break;
21712083
21722084         /* dip switch definition */
21732085         case INPUT_TOKEN_DIPNAME:
21742086            TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32);
2175            port = input_port_initialize(param, IPT_DIPSWITCH_NAME, modify_tag, mask, defval);
2087            portentry = input_port_initialize(param, IPT_DIPSWITCH_NAME, modify_tag, mask, defval);
21762088            seq_index[0] = seq_index[1] = seq_index[2] = 0;
2177            port->name = input_port_string_from_token(*ipt++);
2089            portentry->name = input_port_string_from_token(*ipt++);
21782090            break;
21792091
21802092         case INPUT_TOKEN_DIPSETTING:
21812093            TOKEN_UNGET_UINT32(ipt);
21822094            TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32);
2183            port = input_port_initialize(param, IPT_DIPSWITCH_SETTING, modify_tag, 0, defval);
2095            portentry = input_port_initialize(param, IPT_DIPSWITCH_SETTING, modify_tag, 0, defval);
21842096            seq_index[0] = seq_index[1] = seq_index[2] = 0;
2185            port->name = input_port_string_from_token(*ipt++);
2097            portentry->name = input_port_string_from_token(*ipt++);
21862098            break;
21872099
21882100         /* physical location */
21892101         case INPUT_TOKEN_DIPLOCATION:
2190            input_port_parse_diplocation(port, TOKEN_GET_STRING(ipt));
2102            input_port_parse_diplocation(portentry, TOKEN_GET_STRING(ipt));
21912103            break;
21922104
21932105         /* conditionals for dip switch settings */
21942106         case INPUT_TOKEN_CONDITION:
21952107            TOKEN_UNGET_UINT32(ipt);
2196            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, port->condition.condition, 24);
2197            TOKEN_GET_UINT64_UNPACK2(ipt, port->condition.mask, 32, port->condition.value, 32);
2198            port->condition.tag = TOKEN_GET_STRING(ipt);
2108            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->condition.condition, 24);
2109            TOKEN_GET_UINT64_UNPACK2(ipt, portentry->condition.mask, 32, portentry->condition.value, 32);
2110            portentry->condition.tag = TOKEN_GET_STRING(ipt);
21992111            break;
22002112
22012113         /* analog adjuster definition */
22022114         case INPUT_TOKEN_ADJUSTER:
22032115            TOKEN_UNGET_UINT32(ipt);
22042116            TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32);
2205            port = input_port_initialize(param, IPT_ADJUSTER, modify_tag, 0xff, defval | (defval << 8));
2117            portentry = input_port_initialize(param, IPT_ADJUSTER, modify_tag, 0xff, defval | (defval << 8));
22062118            seq_index[0] = seq_index[1] = seq_index[2] = 0;
2207            port->name = TOKEN_GET_STRING(ipt);
2119            portentry->name = TOKEN_GET_STRING(ipt);
22082120            break;
22092121
22102122         /* configuration definition */
22112123         case INPUT_TOKEN_CONFNAME:
22122124            TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32);
2213            port = input_port_initialize(param, IPT_CONFIG_NAME, modify_tag, mask, defval);
2125            portentry = input_port_initialize(param, IPT_CONFIG_NAME, modify_tag, mask, defval);
22142126            seq_index[0] = seq_index[1] = seq_index[2] = 0;
2215            port->name = input_port_string_from_token(*ipt++);
2127            portentry->name = input_port_string_from_token(*ipt++);
22162128            break;
22172129
22182130         case INPUT_TOKEN_CONFSETTING:
22192131            TOKEN_UNGET_UINT32(ipt);
22202132            TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32);
2221            port = input_port_initialize(param, IPT_CONFIG_SETTING, modify_tag, 0, defval);
2133            portentry = input_port_initialize(param, IPT_CONFIG_SETTING, modify_tag, 0, defval);
22222134            seq_index[0] = seq_index[1] = seq_index[2] = 0;
2223            port->name = input_port_string_from_token(*ipt++);
2135            portentry->name = input_port_string_from_token(*ipt++);
22242136            break;
22252137
22262138#ifdef MESS
r2375r2376
22292141            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, val, 24);
22302142            {
22312143               int ch;
2232               for (ch = 0; port->keyboard.chars[ch] != 0; ch++)
2144               for (ch = 0; portentry->keyboard.chars[ch] != 0; ch++)
22332145                  ;
2234               port->keyboard.chars[ch] = (unicode_char) val;
2146               portentry->keyboard.chars[ch] = (unicode_char) val;
22352147            }
22362148            break;
22372149
22382150         /* category definition */
22392151         case INPUT_TOKEN_CATEGORY:
22402152            TOKEN_UNGET_UINT32(ipt);
2241            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, port->category, 24);
2153            TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->category, 24);
22422154            break;
22432155
22442156         case INPUT_TOKEN_CATEGORY_NAME:
22452157            TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32);
2246            port = input_port_initialize(param, IPT_CATEGORY_NAME, modify_tag, mask, defval);
2158            portentry = input_port_initialize(param, IPT_CATEGORY_NAME, modify_tag, mask, defval);
22472159            seq_index[0] = seq_index[1] = seq_index[2] = 0;
2248            port->name = input_port_string_from_token(*ipt++);
2160            portentry->name = input_port_string_from_token(*ipt++);
22492161            break;
22502162
22512163         case INPUT_TOKEN_CATEGORY_SETTING:
22522164            TOKEN_UNGET_UINT32(ipt);
22532165            TOKEN_GET_UINT64_UNPACK3(ipt, entrytype, 8, defval, 32, category, 16);
2254            port = input_port_initialize(param, IPT_CATEGORY_SETTING, modify_tag, 0, defval);
2166            portentry = input_port_initialize(param, IPT_CATEGORY_SETTING, modify_tag, 0, defval);
22552167            seq_index[0] = seq_index[1] = seq_index[2] = 0;
2256            port->name = input_port_string_from_token(*ipt++);
2257            port->category = category;
2168            portentry->name = input_port_string_from_token(*ipt++);
2169            portentry->category = category;
22582170            break;
22592171#endif /* MESS */
22602172
r2375r2376
22762188input_port_entry *input_port_initialize(input_port_init_params *iip, UINT32 type, const char *tag, UINT32 mask, UINT32 defval)
22772189{
22782190   /* this function is used within an INPUT_PORT callback to set up a single port */
2279   input_port_entry *port;
2191   input_port_entry *portentry;
22802192   input_code code;
22812193
22822194   /* are we modifying an existing port? */
r2375r2376
23102222      {
23112223         memmove(&iip->ports[portnum + 1], &iip->ports[portnum], (iip->current_port - portnum) * sizeof(iip->ports[0]));
23122224         iip->current_port++;
2313         port = &iip->ports[portnum];
2225         portentry = &iip->ports[portnum];
23142226      }
23152227      else
2316         port = &iip->ports[iip->current_port++];
2228         portentry = &iip->ports[iip->current_port++];
23172229   }
23182230
23192231   /* otherwise, just allocate a new one from the end */
r2375r2376
23212233   {
23222234      if (iip->current_port >= iip->max_ports)
23232235         fatalerror("Too many input ports");
2324      port = &iip->ports[iip->current_port++];
2236      portentry = &iip->ports[iip->current_port++];
23252237   }
23262238
23272239   /* set up defaults */
2328   memset(port, 0, sizeof(*port));
2329   port->name = IP_NAME_DEFAULT;
2330   port->type = type;
2331   port->mask = mask;
2332   port->default_value = defval;
2240   memset(portentry, 0, sizeof(*portentry));
2241   portentry->name = IP_NAME_DEFAULT;
2242   portentry->type = type;
2243   portentry->mask = mask;
2244   portentry->default_value = defval;
23332245
23342246   /* default min to 0 and max to the mask value */
23352247   /* they can be overwritten by PORT_MINMAX */
2336   if (port_type_is_analog(port->type) && !port->analog.min && !port->analog.max)
2337      port->analog.max = port->mask;
2248   if (port_type_is_analog(portentry->type) && !portentry->analog.min && !portentry->analog.max)
2249      portentry->analog.max = portentry->mask;
23382250
23392251   /* sets up default port codes */
2340   switch (port->type)
2252   switch (portentry->type)
23412253   {
23422254      case IPT_DIPSWITCH_NAME:
23432255      case IPT_DIPSWITCH_SETTING:
r2375r2376
23522264   }
23532265
23542266   /* set the default codes */
2355   input_seq_set_1(&port->seq, code);
2356   input_seq_set_1(&port->analog.incseq, code);
2357   input_seq_set_1(&port->analog.decseq, code);
2358   return port;
2267   input_seq_set_1(&portentry->seq, code);
2268   input_seq_set_1(&portentry->analog.incseq, code);
2269   input_seq_set_1(&portentry->analog.decseq, code);
2270   return portentry;
23592271}
23602272
23612273
r2375r2376
25322444 *
25332445 *************************************/
25342446
2535int input_port_active(const input_port_entry *port)
2447int input_port_active(const input_port_entry *portentry)
25362448{
2537   return (input_port_name(port) != NULL && !port->unused);
2449   return (input_port_name(portentry) != NULL && !portentry->unused);
25382450}
25392451
25402452
r2375r2376
25522464
25532465int port_type_in_use(int type)
25542466{
2555   input_port_entry *port;
2556   for (port = Machine->input_ports; port->type != IPT_END; port++)
2557      if (port->type == type)
2467   input_port_entry *portentry;
2468   for (portentry = Machine->input_ports; portentry->type != IPT_END; portentry++)
2469      if (portentry->type == type)
25582470         return 1;
25592471   return 0;
25602472}
r2375r2376
25712483
25722484int port_tag_to_index(const char *tag)
25732485{
2574   int port;
2486   int portnum;
25752487
25762488   /* find the matching tag */
2577   for (port = 0; port < MAX_INPUT_PORTS; port++)
2578      if (port_info[port].tag != NULL && !strcmp(port_info[port].tag, tag))
2579         return port;
2489   for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++)
2490      if (port_info[portnum].tag != NULL && !strcmp(port_info[portnum].tag, tag))
2491         return portnum;
25802492   return -1;
25812493}
25822494
25832495
25842496read8_machine_func port_tag_to_handler8(const char *tag)
25852497{
2586   int port = port_tag_to_index(tag);
2587   return (port == -1) ? SMH_NOP : port_handler8[port];
2498   int portnum = port_tag_to_index(tag);
2499   return (portnum == -1) ? SMH_NOP : port_handler8[portnum];
25882500}
25892501
25902502
25912503read16_machine_func port_tag_to_handler16(const char *tag)
25922504{
2593   int port = port_tag_to_index(tag);
2594   return (port == -1) ? SMH_NOP : port_handler16[port];
2505   int portnum = port_tag_to_index(tag);
2506   return (portnum == -1) ? SMH_NOP : port_handler16[portnum];
25952507}
25962508
25972509
25982510read32_machine_func port_tag_to_handler32(const char *tag)
25992511{
2600   int port = port_tag_to_index(tag);
2601   return (port == -1) ? SMH_NOP : port_handler32[port];
2512   int portnum = port_tag_to_index(tag);
2513   return (portnum == -1) ? SMH_NOP : port_handler32[portnum];
26022514}
26032515
26042516
r2375r2376
26082520}
26092521
26102522
2611const char *input_port_name(const input_port_entry *port)
2523const char *input_port_name(const input_port_entry *portentry)
26122524{
26132525   int defindex;
26142526
26152527   /* if we have a non-default name, use that */
2616   if (port->name != IP_NAME_DEFAULT)
2617      return port->name;
2528   if (portentry->name != IP_NAME_DEFAULT)
2529      return portentry->name;
26182530
26192531   /* if the port exists, return the default name */
2620   defindex = default_ports_lookup[port->type][port->player];
2532   defindex = default_ports_lookup[portentry->type][portentry->player];
26212533   if (defindex != -1)
26222534      return default_ports[defindex].name;
26232535
r2375r2376
26262538}
26272539
26282540
2629const input_seq *input_port_seq(input_port_entry *port, input_seq_type seqtype)
2541const input_seq *input_port_seq(input_port_entry *portentry, input_seq_type seqtype)
26302542{
26312543   static const input_seq ip_none = SEQ_DEF_0;
26322544   input_seq *portseq;
26332545
26342546   /* if port is disabled, return no key */
2635   if (port->unused)
2547   if (portentry->unused)
26362548      return &ip_none;
26372549
26382550   /* handle the various seq types */
26392551   switch (seqtype)
26402552   {
26412553      case SEQ_TYPE_STANDARD:
2642         portseq = &port->seq;
2554         portseq = &portentry->seq;
26432555         break;
26442556
26452557      case SEQ_TYPE_INCREMENT:
2646         if (!IS_ANALOG(port))
2558         if (!IS_ANALOG(portentry))
26472559            return &ip_none;
2648         portseq = &port->analog.incseq;
2560         portseq = &portentry->analog.incseq;
26492561         break;
26502562
26512563      case SEQ_TYPE_DECREMENT:
2652         if (!IS_ANALOG(port))
2564         if (!IS_ANALOG(portentry))
26532565            return &ip_none;
2654         portseq = &port->analog.decseq;
2566         portseq = &portentry->analog.decseq;
26552567         break;
26562568
26572569      default:
r2375r2376
26632575      return portseq;
26642576
26652577   /* otherwise find the default setting */
2666   return input_port_default_seq(port->type, port->player, seqtype);
2578   return input_port_default_seq(portentry->type, portentry->player, seqtype);
26672579}
26682580
26692581
r2375r2376
26942606   switch (in->condition.condition)
26952607   {
26962608      case PORTCOND_EQUALS:
2697         return ((readinputport(in->condition.portnum) & in->condition.mask) == in->condition.value);
2609         return ((input_port_read_indexed(Machine, in->condition.portnum) & in->condition.mask) == in->condition.value);
26982610      case PORTCOND_NOTEQUALS:
2699         return ((readinputport(in->condition.portnum) & in->condition.mask) != in->condition.value);
2611         return ((input_port_read_indexed(Machine, in->condition.portnum) & in->condition.mask) != in->condition.value);
27002612   }
27012613   return 1;
27022614}
r2375r2376
27972709
27982710/*************************************
27992711 *
2800 *  Playback/record helper
2801 *
2802 *************************************/
2803
2804static void update_playback_record(running_machine *machine, int portnum, UINT32 portvalue)
2805{
2806   /* handle playback */
2807   if (machine->playback_file != NULL)
2808   {
2809      UINT32 result;
2810
2811      /* a successful read goes into the playback field which overrides everything else */
2812      if (mame_fread(machine->playback_file, &result, sizeof(result)) == sizeof(result))
2813         portvalue = port_info[portnum].playback = BIG_ENDIANIZE_INT32(result);
2814
2815      /* a failure causes us to close the playback file and stop playback */
2816      else
2817      {
2818         mame_fclose(machine->playback_file);
2819         machine->playback_file = NULL;
2820         if (!extended_inp)
2821            popmessage("End of playback");
2822         else
2823         {
2824            popmessage("End of playback - %i frames - Average speed %f%%", framecount, (double)totalspeed/framecount);
2825            printf("End of playback - %i frames - Average speed %f%%\n", framecount, (double)totalspeed/framecount);
2826         }
2827      }
2828   }
2829
2830   /* handle recording */
2831   if (machine->record_file != NULL)
2832   {
2833      UINT32 result = BIG_ENDIANIZE_INT32(portvalue);
2834
2835      /* a successful write just works */
2836      if (mame_fwrite(machine->record_file, &result, sizeof(result)) == sizeof(result))
2837         ;
2838
2839      /* a failure causes us to close the record file and stop recording */
2840      else
2841      {
2842         mame_fclose(machine->record_file);
2843         machine->record_file = NULL;
2844      }
2845   }
2846}
2847
2848
2849
2850/*************************************
2851 *
28522712 *  Update default ports
28532713 *
28542714 *************************************/
r2375r2376
28722732            portinfo->defvalue = 0;
28732733
28742734         /* first compute the default value for the entire port */
2875         for (bitnum = 0, info = &portinfo->bit[0]; bitnum < MAX_BITS_PER_PORT && info->port; bitnum++, info++)
2876            if (input_port_condition(info->port))
2877               portinfo->defvalue = (portinfo->defvalue & ~info->port->mask) | (info->port->default_value & info->port->mask);
2735         for (bitnum = 0, info = &portinfo->bit[0]; bitnum < MAX_BITS_PER_PORT && info->portentry; bitnum++, info++)
2736            if (input_port_condition(info->portentry))
2737               portinfo->defvalue = (portinfo->defvalue & ~info->portentry->mask) | (info->portentry->default_value & info->portentry->mask);
28782738      }
28792739}
28802740
r2375r2376
28882748
28892749static void input_port_frame(running_machine *machine)
28902750{
2751   /* if we're paused, don't do anything */
2752   if (mame_is_paused(machine))
2753      return;
2754
2755   /* otherwise, use the common code */
2756   input_port_frame_update(machine);
2757}
2758
2759
2760static void input_port_frame_update(running_machine *machine)
2761{
28912762   int ui_visible = ui_is_menu_active() || ui_is_slider_active();
28922763   attotime curtime = timer_get_time();
28932764   int portnum, bitnum;
28942765
28952766profiler_mark(PROFILER_INPUT);
28962767
2768   /* record/playback information about the current frame */
2769   playback_frame(machine, curtime);
2770   record_frame(machine, curtime);
2771
28972772   /* track the duration of the previous frame */
28982773   last_delta = attotime_to_attoseconds(attotime_sub(curtime, last_update)) / ATTOSECONDS_PER_SECOND_SQRT;
28992774   last_update = curtime;
r2375r2376
29042779         update_analog_port(portnum);
29052780
29062781   /* update the digital joysticks first */
2907   update_digital_joysticks();
2782   update_digital_joysticks(machine);
29082783
29092784   /* compute default values for all the ports */
29102785   input_port_update_defaults();
r2375r2376
29182793
29192794      /* compute the VBLANK mask */
29202795      portinfo->vblank = 0;
2921      for (bitnum = 0, info = &portinfo->bit[0]; bitnum < MAX_BITS_PER_PORT && info->port; bitnum++, info++)
2922         if (info->port->type == IPT_VBLANK)
2923            portinfo->vblank ^= info->port->mask;
2796      for (bitnum = 0, info = &portinfo->bit[0]; bitnum < MAX_BITS_PER_PORT && info->portentry; bitnum++, info++)
2797         if (input_port_condition(info->portentry) && info->portentry->type == IPT_VBLANK)
2798            portinfo->vblank ^= info->portentry->mask;
29242799
29252800      /* now loop back and modify based on the inputs */
29262801      portinfo->digital = 0;
2927      for (bitnum = 0, info = &portinfo->bit[0]; bitnum < MAX_BITS_PER_PORT && info->port; bitnum++, info++)
2928         if (input_port_condition(info->port))
2802      for (bitnum = 0, info = &portinfo->bit[0]; bitnum < MAX_BITS_PER_PORT && info->portentry; bitnum++, info++)
2803         if (input_port_condition(info->portentry))
29292804         {
2930            input_port_entry *port = info->port;
2805            input_port_entry *portentry = info->portentry;
29312806
29322807            /* handle non-analog types, but only when the UI isn't visible */
2933            if (port->type != IPT_VBLANK && !IS_ANALOG(port) && !ui_visible)
2808            if (portentry->type != IPT_VBLANK && !IS_ANALOG(portentry) && !ui_visible)
29342809            {
29352810               /* if the sequence for this port is currently pressed.... */
2936               if (input_seq_pressed(input_port_seq(port, SEQ_TYPE_STANDARD)))
2811               if (input_seq_pressed(input_port_seq(portentry, SEQ_TYPE_STANDARD)))
29372812               {
29382813#ifdef MESS
29392814                  /* (MESS-specific) check for disabled keyboard */
2940                  if (port->type == IPT_KEYBOARD && osd_keyboard_disabled())
2815                  if (portentry->type == IPT_KEYBOARD && osd_keyboard_disabled())
29412816                     continue;
29422817#endif
29432818                  /* skip locked-out coin inputs */
2944                  if (port->type >= IPT_COIN1 && port->type <= IPT_COIN8 && coinlockedout[port->type - IPT_COIN1])
2819                  if (portentry->type >= IPT_COIN1 && portentry->type <= IPT_COIN8 && coinlockedout[portentry->type - IPT_COIN1])
2820                  {
2821                     ui_popup_time(3, "Coinlock disabled %s.", input_port_name(portentry));
29452822                     continue;
2946                  if (port->type >= IPT_SERVICE1 && port->type <= IPT_SERVICE4 && servicecoinlockedout[port->type - IPT_SERVICE1])
2823                  }
2824                  if (portentry->type >= IPT_SERVICE1 && portentry->type <= IPT_SERVICE4 && servicecoinlockedout[portentry->type - IPT_SERVICE1])
2825                  {
2826                     ui_popup_time(3, "Coinlock disabled %s.", input_port_name(portentry));
29472827                     continue;
2948
2828                  }
29492829                  /* if this is a downward press and we're an impulse control, reset the count */
2950                  if (port->impulse)
2830                  if (portentry->impulse)
29512831                  {
29522832                     if (info->last == 0)
2953                        info->impulse = port->impulse;
2833                        info->impulse = portentry->impulse;
29542834                  }
29552835
29562836                  /* if this is a downward press and we're a toggle control, toggle the value */
2957                  else if (port->toggle)
2837                  else if (portentry->toggle)
29582838                  {
29592839                     if (info->last == 0)
29602840                     {
2961                        port->default_value ^= port->mask;
2962                        portinfo->digital ^= port->mask;
2841                        portentry->default_value ^= portentry->mask;
2842                        portinfo->digital ^= portentry->mask;
29632843                     }
29642844                  }
29652845
29662846                  /* if this is a digital joystick type, apply either standard or 4-way rules */
2967                  else if (IS_DIGITAL_JOYSTICK(port))
2847                  else if (IS_DIGITAL_JOYSTICK(portentry))
29682848                  {
2969                     digital_joystick_info *joyinfo = JOYSTICK_INFO_FOR_PORT(port);
2849                     digital_joystick_info *joyinfo = JOYSTICK_INFO_FOR_PORT(portentry);
29702850                     UINT8 mask;
2971                     switch( port->way )
2851                     switch( portentry->way )
29722852                     {
29732853                        case 4:
29742854                           mask = joyinfo->current4way;
r2375r2376
29802860                           mask = joyinfo->current;
29812861                           break;
29822862                     }
2983                     if ((mask >> JOYSTICK_DIR_FOR_PORT(port)) & 1)
2984                        portinfo->digital ^= port->mask;
2863                     if ((mask >> JOYSTICK_DIR_FOR_PORT(portentry)) & 1)
2864                        portinfo->digital ^= portentry->mask;
29852865                  }
29862866
29872867                  /* otherwise, just set it raw */
29882868                  else
2989                     portinfo->digital ^= port->mask;
2869                     portinfo->digital ^= portentry->mask;
29902870
29912871                  /* track the last value */
29922872                  info->last = 1;
r2375r2376
29952875                  info->last = 0;
29962876
29972877               /* handle the impulse countdown */
2998               if (port->impulse && info->impulse > 0)
2878               if (portentry->impulse && info->impulse > 0)
29992879               {
30002880                  info->impulse--;
30012881                  info->last = 1;
3002                  portinfo->digital ^= port->mask;
2882                  portinfo->digital ^= portentry->mask;
30032883               }
30042884            }
30052885
r2375r2376
30082888
30092889      /* call changed handlers */
30102890      for (changed = portinfo->changedinfo; changed; changed = changed->next)
3011         if (input_port_condition(changed->port))
2891         if (input_port_condition(changed->portentry))
30122892         {
3013            input_port_entry *port = changed->port;
2893            input_port_entry *portentry = changed->portentry;
30142894
3015            UINT32 new_unmasked_value = readinputport(portnum);
3016            UINT32 newval = (new_unmasked_value       & port->mask) >> changed->shift;
3017            UINT32 oldval = (port->changed_last_value & port->mask) >> changed->shift;
2895            UINT32 new_unmasked_value = input_port_read_indexed(machine, portnum);
2896            UINT32 newval = (new_unmasked_value       & portentry->mask) >> changed->shift;
2897            UINT32 oldval = (portentry->changed_last_value & portentry->mask) >> changed->shift;
30182898
30192899            if (newval != oldval)
3020               (*port->changed)(machine, port->changed_param, oldval, newval);
2900               (*portentry->changed)(machine, portentry->changed_param, oldval, newval);
30212901
3022            port->changed_last_value = new_unmasked_value;
2902            portentry->changed_last_value = new_unmasked_value;
30232903         }
30242904   }
30252905
30262906#ifdef MESS
30272907   /* less MESS to MESSy things */
3028   inputx_update();
2908   inputx_update(machine);
30292909#endif
30302910
30312911   /* handle playback/record */
30322912   for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++)
30332913   {
3034      /* analog ports automatically update on every read */
3035      if (port_info[portnum].analoginfo)
3036         readinputport(portnum);
3037
3038      /* non-analog ports must be manually updated */
3039      else
3040         update_playback_record(machine, portnum, readinputport(portnum));
2914      playback_port(machine, &port_info[portnum]);
2915      record_port(machine, &port_info[portnum]);
30412916   }
30422917
3043   /* store speed read from INP file, if extended INP */
3044   if (machine->playback_file != NULL && extended_inp)
3045   {
3046      UINT32 dummy;
3047      mame_fread(machine->playback_file, &rec_speed, sizeof(rec_speed));
3048      mame_fread(machine->playback_file, &dummy, sizeof(dummy));
3049      framecount++;
3050      rec_speed *= 100;
3051      totalspeed += rec_speed;
3052   }
3053
30542918profiler_mark(PROFILER_END);
30552919}
30562920
r2375r2376
30622926 *
30632927 *************************************/
30642928
3065static void update_digital_joysticks(void)
2929static void update_digital_joysticks(running_machine *machine)
30662930{
30672931   int player, joyindex;
30682932
r2375r2376
30772941            info->current = 0;
30782942
30792943            /* read all the associated ports */
3080            if (info->port[JOYDIR_UP] != NULL && input_seq_pressed(input_port_seq(info->port[JOYDIR_UP], SEQ_TYPE_STANDARD)))
2944            if (info->portentry[JOYDIR_UP] != NULL && input_seq_pressed(input_port_seq(info->portentry[JOYDIR_UP], SEQ_TYPE_STANDARD)))
30812945               info->current |= JOYDIR_UP_BIT;
3082            if (info->port[JOYDIR_DOWN] != NULL && input_seq_pressed(input_port_seq(info->port[JOYDIR_DOWN], SEQ_TYPE_STANDARD)))
2946            if (info->portentry[JOYDIR_DOWN] != NULL && input_seq_pressed(input_port_seq(info->portentry[JOYDIR_DOWN], SEQ_TYPE_STANDARD)))
30832947               info->current |= JOYDIR_DOWN_BIT;
3084            if (info->port[JOYDIR_LEFT] != NULL && input_seq_pressed(input_port_seq(info->port[JOYDIR_LEFT], SEQ_TYPE_STANDARD)))
2948            if (info->portentry[JOYDIR_LEFT] != NULL && input_seq_pressed(input_port_seq(info->portentry[JOYDIR_LEFT], SEQ_TYPE_STANDARD)))
30852949               info->current |= JOYDIR_LEFT_BIT;
3086            if (info->port[JOYDIR_RIGHT] != NULL && input_seq_pressed(input_port_seq(info->port[JOYDIR_RIGHT], SEQ_TYPE_STANDARD)))
2950            if (info->portentry[JOYDIR_RIGHT] != NULL && input_seq_pressed(input_port_seq(info->portentry[JOYDIR_RIGHT], SEQ_TYPE_STANDARD)))
30872951               info->current |= JOYDIR_RIGHT_BIT;
30882952
30892953            /* lock out opposing directions (left + right or up + down) */
r2375r2376
31282992               if ((info->current4way & (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) &&
31292993                  (info->current4way & (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT)))
31302994               {
3131                  if (mame_rand(Machine) & 1)
2995                  if (mame_rand(machine) & 1)
31322996                     info->current4way &= ~(JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT);
31332997                  else
31342998                     info->current4way &= ~(JOYDIR_UP_BIT | JOYDIR_DOWN_BIT);
r2375r2376
31463010 *
31473011 *************************************/
31483012
3149INLINE INT32 apply_analog_min_max(const analog_port_info *info, double value)
3013INLINE INT32 apply_analog_min_max(const analog_port_info *info, INT32 value)
31503014{
3151   const input_port_entry *port = info->port;
3152   double adjmax, adjmin, adj1, adjdif;
3015   const input_port_entry *portentry = info->portentry;
3016   INT32 adjmax, adjmin, adj1, adjdif;
31533017
31543018   /* take the analog minimum and maximum values and apply the inverse of the */
31553019   /* sensitivity so that we can clamp against them before applying sensitivity */
3156   adjmin = APPLY_INVERSE_SENSITIVITY(info->minimum, port->analog.sensitivity);
3157   adjmax = APPLY_INVERSE_SENSITIVITY(info->maximum, port->analog.sensitivity);
3158   adj1   = APPLY_INVERSE_SENSITIVITY(512, port->analog.sensitivity);
3020   adjmin = APPLY_INVERSE_SENSITIVITY(info->minimum, portentry->analog.sensitivity);
3021   adjmax = APPLY_INVERSE_SENSITIVITY(info->maximum, portentry->analog.sensitivity);
3022   adj1   = APPLY_INVERSE_SENSITIVITY(512, portentry->analog.sensitivity);
31593023
31603024   /* for absolute devices, clamp to the bounds absolutely */
31613025   if (!info->wraps)
r2375r2376
31703034   else
31713035   {
31723036      adjdif = adjmax - adjmin + adj1;
3173      if (port->analog.reverse)
3037      if (portentry->analog.reverse)
31743038      {
31753039         while (value <= adjmin - adj1)
31763040            value += adjdif;
r2375r2376
32043068   /* loop over all analog ports in this port number */
32053069   for (info = port_info[portnum].analoginfo; info != NULL; info = info->next)
32063070   {
3207      input_port_entry *port = info->port;
3071      input_port_entry *portentry = info->portentry;
32083072      INT32 rawvalue;
3209      double delta = 0, keyscale;
3210      int keypressed = 0;
3073      INT32 delta = 0;
3074      INT64 keyscale;
3075      int keypressed = FALSE;
32113076      input_item_class itemclass;
32123077
32133078      /* clamp the previous value to the min/max range and remember it */
32143079      info->previous = info->accum = apply_analog_min_max(info, info->accum);
32153080
32163081      /* get the new raw analog value and its type */
3217      rawvalue = input_seq_axis_value(input_port_seq(port, SEQ_TYPE_STANDARD), &itemclass);
3082      rawvalue = input_seq_axis_value(input_port_seq(portentry, SEQ_TYPE_STANDARD), &itemclass);
32183083
32193084      /* if we got an absolute input, it overrides everything else */
32203085      if (itemclass == ITEM_CLASS_ABSOLUTE)
r2375r2376
32273092            /* apply the inverse of the sensitivity to the raw value so that */
32283093            /* it will still cover the full min->max range requested after */
32293094            /* we apply the sensitivity adjustment */
3230            if (info->absolute || port->analog.reset)
3095            if (info->absolute || portentry->analog.reset)
32313096            {
32323097               /* if port is absolute, then just return the absolute data supplied */
3233               info->accum = APPLY_INVERSE_SENSITIVITY(rawvalue, port->analog.sensitivity);
3098               info->accum = APPLY_INVERSE_SENSITIVITY(rawvalue, portentry->analog.sensitivity);
32343099            }
32353100            else if (info->positionalscale != 0)
32363101            {
32373102               /* if port is positional, we will take the full analog control and divide it */
32383103               /* into positions, that way as the control is moved full scale, */
32393104               /* it moves through all the positions */
3240               rawvalue = info->positionalscale * (rawvalue - INPUT_ABSOLUTE_MIN) * 512 + info->minimum;
3105               rawvalue = APPLY_SCALE(rawvalue - INPUT_ABSOLUTE_MIN, info->positionalscale) * 512 + info->minimum;
32413106
32423107               /* clamp the high value so it does not roll over */
3243               if (rawvalue > info->maximum) rawvalue = info->maximum;
3244               info->accum = APPLY_INVERSE_SENSITIVITY(rawvalue, port->analog.sensitivity);
3108               rawvalue = MIN(rawvalue, info->maximum);
3109               info->accum = APPLY_INVERSE_SENSITIVITY(rawvalue, portentry->analog.sensitivity);
32453110            }
32463111            else
32473112               /* if port is relative, we use the value to simulate the speed of relative movement */
32483113               /* sensitivity adjustment is allowed for this mode */
32493114               info->accum += rawvalue;
32503115
3251            info->lastdigital = 0;
3116            info->lastdigital = FALSE;
32523117            /* do not bother with other control types if the analog data is changing */
3253            return;
3118            continue;
32543119         }
32553120         else
32563121         {
32573122            /* we still have to update fake relative from joystick control */
3258            if (!info->absolute && info->positionalscale == 0) info->accum += rawvalue;
3123            if (!info->absolute && info->positionalscale == 0)
3124               info->accum += rawvalue;
32593125         }
32603126      }
32613127
r2375r2376
32713137
32723138      /* if the decrement code sequence is pressed, add the key delta to */
32733139      /* the accumulated delta; also note that the last input was a digital one */
3274      if (input_seq_pressed(input_port_seq(info->port, SEQ_TYPE_DECREMENT)))
3140      if (input_seq_pressed(input_port_seq(info->portentry, SEQ_TYPE_DECREMENT)))
32753141      {
3276         keypressed = 1;
3277         if (port->analog.delta)
3278            delta -= (double)(port->analog.delta) * keyscale;
3142         keypressed = TRUE;
3143         if (portentry->analog.delta)
3144            delta -= APPLY_SCALE(portentry->analog.delta, keyscale);
32793145         else if (info->lastdigital != 1)
32803146            /* decrement only once when first pressed */
3281            delta -= keyscale;
3147            delta -= APPLY_SCALE(1, keyscale);
32823148         info->lastdigital = 1;
32833149      }
32843150
32853151      /* same for the increment code sequence */
3286      if (input_seq_pressed(input_port_seq(info->port, SEQ_TYPE_INCREMENT)))
3152      if (input_seq_pressed(input_port_seq(info->portentry, SEQ_TYPE_INCREMENT)))
32873153      {
3288         keypressed = 1;
3289         if (port->analog.delta)
3290            delta += (double)(port->analog.delta) * keyscale;
3154         keypressed = TRUE;
3155         if (portentry->analog.delta)
3156            delta += APPLY_SCALE(portentry->analog.delta, keyscale);
32913157         else if (info->lastdigital != 2)
32923158            /* increment only once when first pressed */
3293            delta += keyscale;
3159            delta += APPLY_SCALE(1, keyscale);
32943160         info->lastdigital = 2;
32953161      }
32963162
r2375r2376
32983164      /* applying the deltas so that we only return this frame's delta */
32993165      /* note that centering only works for relative controls */
33003166      /* no need to check if absolute here because it is checked by the validity tests */
3301      if (port->analog.reset)
3167      if (portentry->analog.reset)
33023168         info->accum = 0;
33033169
33043170      /* apply the delta to the accumulated value */
r2375r2376
33093175      /* was pressed, apply autocentering */
33103176      if (info->autocenter)
33113177      {
3312         double center = APPLY_INVERSE_SENSITIVITY(info->center, port->analog.sensitivity);
3178         INT32 center = APPLY_INVERSE_SENSITIVITY(info->center, portentry->analog.sensitivity);
33133179         if (info->lastdigital && !keypressed)
33143180         {
33153181            /* autocenter from positive values */
33163182            if (info->accum >= center)
33173183            {
3318               info->accum -= (double)(port->analog.centerdelta) * info->keyscalepos;
3184               info->accum -= APPLY_SCALE(portentry->analog.centerdelta, info->keyscalepos);
33193185               if (info->accum < center)
33203186               {
33213187                  info->accum = center;
r2375r2376
33263192            /* autocenter from negative values */
33273193            else
33283194            {
3329               info->accum += (double)(port->analog.centerdelta) * info->keyscaleneg;
3195               info->accum += APPLY_SCALE(portentry->analog.centerdelta, info->keyscaleneg);
33303196               if (info->accum > center)
33313197               {
33323198                  info->accum = center;
r2375r2376
33483214 *
33493215 *************************************/
33503216
3351static void interpolate_analog_port(int portnum)
3217static UINT32 merge_interpolated_analog_data(int portnum, UINT32 digital)
33523218{
33533219   analog_port_info *info;
3220   UINT32 result = digital;
33543221
33553222profiler_mark(PROFILER_INPUT);
33563223
3357   /* set the default mask and value */
3358   port_info[portnum].analogmask = 0;
3359   port_info[portnum].analog = 0;
3360
33613224   /* loop over all analog ports in this port number */
33623225   for (info = port_info[portnum].analoginfo; info != NULL; info = info->next)
33633226   {
3364      input_port_entry *port = info->port;
3227      input_port_entry *portentry = info->portentry;
33653228
3366      if (input_port_condition(info->port))
3229      if (input_port_condition(portentry))
33673230      {
3368         double current;
3231         INT32 current;
33693232         INT32 value;
33703233
33713234         /* interpolate or not */
3372         if (info->interpolate && !port->analog.reset && last_delta != 0)
3235         if (info->interpolate && !portentry->analog.reset && last_delta != 0)
33733236         {
33743237            attoseconds_t time_since_last = attotime_to_attoseconds(attotime_sub(timer_get_time(), last_update)) / ATTOSECONDS_PER_SECOND_SQRT;
33753238            current = info->previous + ((INT64)(info->accum - info->previous) * time_since_last / last_delta);
r2375r2376
33793242
33803243         /* apply the min/max and then the sensitivity */
33813244         current = apply_analog_min_max(info, current);
3382         current = APPLY_SENSITIVITY(current, port->analog.sensitivity);
3245         current = APPLY_SENSITIVITY(current, portentry->analog.sensitivity);
33833246
33843247         /* apply reversal if needed */
3385         if (port->analog.reverse)
3386               current = info->reverse_val - current;
3387         else
3388         if (info->single_scale)
3248         if (portentry->analog.reverse)
3249            current = info->reverse_val - current;
3250         else if (info->single_scale)
33893251            /* it's a pedal or the default value is equal to min/max */
33903252            /* so we need to adjust the center to the minimum */
33913253            current -= INPUT_ABSOLUTE_MIN;
33923254
33933255         /* map differently for positive and negative values */
3394         if (current >= 0 )
3395            value = (INT32)(current * info->scalepos);
3256         if (current >= 0)
3257            value = APPLY_SCALE(current, info->scalepos);
33963258         else
3397            value = (INT32)(current * info->scaleneg);
3398         value += port->default_value;
3259            value = APPLY_SCALE(current, info->scaleneg);
3260         value += portentry->default_value;
33993261
3400         /* store croshair position before any remapping */
3401         info->crosshair_pos = (INT32)value & (port->mask >> info->shift);
3262         /* store crosshair position before any remapping */
3263         info->crosshair_pos = (INT32)value & (portentry->mask >> info->shift);
34023264
34033265         /* remap the value if needed */
3404         if (port->analog.remap_table)
3405            value = info->port->analog.remap_table[value];
3266         if (portentry->analog.remap_table)
3267            value = info->portentry->analog.remap_table[value];
34063268
34073269         /* invert bits if needed */
3408         if (port->analog.invert)
3270         if (portentry->analog.invert)
34093271            value = ~value;
34103272
34113273         /* insert into the port */
3412         port_info[portnum].analogmask |= info->port->mask;
3413         port_info[portnum].analog = (port_info[portnum].analog & ~port->mask) | ((value << info->shift) & port->mask);
3274         result = (result & ~portentry->mask) | ((value << info->shift) & portentry->mask);
34143275      }
34153276   }
34163277
34173278profiler_mark(PROFILER_END);
3279   return result;
34183280}
34193281
34203282
r2375r2376
34253287 *
34263288 *************************************/
34273289
3428UINT32 readinputport(int port)
3290UINT32 input_port_read_indexed(running_machine *machine, int portnum)
34293291{
3430   input_port_info *portinfo = &port_info[port];
3292   input_port_info *portinfo = &port_info[portnum];
34313293   custom_port_info *custom;
34323294   UINT32 result;
34333295
3434   /* interpolate analog values */
3435   interpolate_analog_port(port);
3296   /* start with the digital */
3297   result = portinfo->defvalue ^ portinfo->digital;
34363298
3299   /* merge in analog portions */
3300   result = merge_interpolated_analog_data(portnum, result);
3301
34373302   /* update custom values */
34383303   for (custom = portinfo->custominfo; custom; custom = custom->next)
3439      if (input_port_condition(custom->port))
3304      if (input_port_condition(custom->portentry))
34403305      {
34413306         /* replace the bits with bits from the custom routine */
3442         input_port_entry *port = custom->port;
3443         portinfo->digital &= ~port->mask;
3444         portinfo->digital |= ((*port->custom)(Machine, port->custom_param) << custom->shift) & port->mask;
3307         input_port_entry *portentry = custom->portentry;
3308         result &= ~portentry->mask;
3309         result |= ((*portentry->custom)(machine, portentry->custom_param) << custom->shift) & portentry->mask;
34453310      }
34463311
3447   /* compute the current result: default value XOR the digital, merged with the analog */
3448   result = ((portinfo->defvalue ^ portinfo->digital) & ~portinfo->analogmask) | portinfo->analog;
3449
3450   /* if we have analog data, update the recording state */
3451   if (port_info[port].analoginfo)
3452      update_playback_record(Machine, port, result);
3453
3454   /* if we're playing back, use the recorded value for inputs instead */
3455   if (Machine->playback_file != NULL)
3456      result = portinfo->playback;
3457
3458   /* handle VBLANK bits after inputs */
3312   /* handle VBLANK bits */
34593313   if (portinfo->vblank)
34603314   {
34613315      /* reset the VBLANK bits to their default value, regardless of inputs */
34623316      result = (result & ~portinfo->vblank) | (portinfo->defvalue & portinfo->vblank);
34633317
34643318      /* toggle VBLANK if we're in a VBLANK state */
3465      if (video_screen_get_vblank(Machine->primary_screen))
3319      if (video_screen_get_vblank(machine->primary_screen))
34663320         result ^= portinfo->vblank;
34673321   }
34683322   return result;
34693323}
34703324
34713325
3472UINT32 readinputportbytag(const char *tag)
3326UINT32 input_port_read(running_machine *machine, const char *tag)
34733327{
3474   int port = port_tag_to_index(tag);
3475   if (port != -1)
3476      return readinputport(port);
3328   int portnum = port_tag_to_index(tag);
3329   if (portnum != -1)
3330      return input_port_read_indexed(machine, portnum);
34773331
34783332   /* otherwise fail horribly */
34793333   fatalerror("Unable to locate input port '%s'", tag);
r2375r2376
34813335}
34823336
34833337
3484UINT32 readinputportbytag_safe(const char *tag, UINT32 defvalue)
3338UINT32 input_port_read_safe(running_machine *machine, const char *tag, UINT32 defvalue)
34853339{
3486   int port = port_tag_to_index(tag);
3487   if (port != -1)
3488      return readinputport(port);
3340   int portnum = port_tag_to_index(tag);
3341   if (portnum != -1)
3342      return input_port_read_indexed(machine, portnum);
34893343   return defvalue;
34903344}
34913345
34923346
34933347
3494UINT32 input_port_read_indexed(running_machine *machine, int port) { return readinputport(port); }
3495UINT32 input_port_read(running_machine *machine, const char *tag) { return readinputportbytag(tag); }
3496UINT32 input_port_read_safe(running_machine *machine, const char *tag, UINT32 defvalue) { return readinputportbytag_safe(tag, defvalue); }
3497
3498
3499
35003348/*************************************
35013349 *
35023350 *  Input port writing
35033351 *
35043352 *************************************/
35053353
3506void input_port_set_digital_value(int portnum, UINT32 value, UINT32 mask)
3354void input_port_set_digital_value(running_machine *machine, int port_num, UINT32 value, UINT32 mask)
35073355{
3508   input_port_info *portinfo = &port_info[portnum];
3356   /* used by MESS for natural keyboard input */
3357   input_port_info *portinfo = &port_info[port_num];
35093358   portinfo->digital &= ~mask;
35103359   portinfo->digital |= value;
35113360}
r2375r2376
35223371{
35233372   input_port_info *portinfo = &port_info[port_num];
35243373   analog_port_info *info;
3525   input_port_entry *port;
3374   input_port_entry *portentry;
35263375   UINT32 result = 0;
35273376
35283377   for (info = portinfo->analoginfo; info; info = info->next)
35293378   {
3530      port = info->port;
3531      if (port->player == player && port->analog.crossaxis == axis)
3379      portentry = info->portentry;
3380      if (portentry->player == player && portentry->analog.crossaxis == axis)
35323381      {
35333382         result = info->crosshair_pos;
35343383         break;
r2375r2376
35933442            break;
35943443         }
35953444}
3445
3446
3447
3448/***************************************************************************
3449    PLAYBACK AND RECORD
3450***************************************************************************/
3451
3452/*-------------------------------------------------
3453    playback_read_uint8 - read an 8-bit value
3454    from the playback file
3455-------------------------------------------------*/
3456
3457static UINT8 playback_read_uint8(running_machine *machine)
3458{
3459   UINT8 result;
3460
3461   /* protect against NULL handles if previous reads fail */
3462   if (machine->playback_file == NULL)
3463      return 0;
3464
3465   /* read the value; if we fail, end playback */
3466   if (mame_fread(machine->playback_file, &result, sizeof(result)) != sizeof(result))
3467   {
3468      playback_end(machine, "End of file");
3469      return 0;
3470   }
3471
3472   /* return the appropriate value */
3473   return result;
3474}
3475
3476
3477/*-------------------------------------------------
3478    record_write_uint8 - write an 8-bit value
3479    to the record file
3480-------------------------------------------------*/
3481
3482static void record_write_uint8(running_machine *machine, UINT8 data)
3483{
3484   UINT8 result = data;
3485
3486   /* protect against NULL handles if previous reads fail */
3487   if (machine->record_file == NULL)
3488      return;
3489
3490   /* read the value; if we fail, end playback */
3491   if (mame_fwrite(machine->record_file, &result, sizeof(result)) != sizeof(result))
3492      record_end(machine, "Out of space");
3493}
3494
3495
3496/*-------------------------------------------------
3497    playback_read_uint32 - read a 32-bit value
3498    from the playback file
3499-------------------------------------------------*/
3500
3501static UINT32 playback_read_uint32(running_machine *machine)
3502{
3503   UINT32 result;
3504
3505   /* protect against NULL handles if previous reads fail */
3506   if (machine->playback_file == NULL)
3507      return 0;
3508
3509   /* read the value; if we fail, end playback */
3510   if (mame_fread(machine->playback_file, &result, sizeof(result)) != sizeof(result))
3511   {
3512      playback_end(machine, "End of file");
3513      return 0;
3514   }
3515
3516   /* return the appropriate value */
3517   return LITTLE_ENDIANIZE_INT32(result);
3518}
3519
3520
3521/*-------------------------------------------------
3522    record_write_uint32 - write a 32-bit value
3523    to the record file
3524-------------------------------------------------*/
3525
3526static void record_write_uint32(running_machine *machine, UINT32 data)
3527{
3528   UINT32 result = LITTLE_ENDIANIZE_INT32(data);
3529
3530   /* protect against NULL handles if previous reads fail */
3531   if (machine->record_file == NULL)
3532      return;
3533
3534   /* read the value; if we fail, end playback */
3535   if (mame_fwrite(machine->record_file, &result, sizeof(result)) != sizeof(result))
3536      record_end(machine, "Out of space");
3537}
3538
3539
3540/*-------------------------------------------------
3541    playback_read_uint64 - read a 64-bit value
3542    from the playback file
3543-------------------------------------------------*/
3544
3545static UINT64 playback_read_uint64(running_machine *machine)
3546{
3547   UINT64 result;
3548
3549   /* protect against NULL handles if previous reads fail */
3550   if (machine->playback_file == NULL)
3551      return 0;
3552
3553   /* read the value; if we fail, end playback */
3554   if (mame_fread(machine->playback_file, &result, sizeof(result)) != sizeof(result))
3555   {
3556      playback_end(machine, "End of file");
3557      return 0;
3558   }
3559
3560   /* return the appropriate value */
3561   return LITTLE_ENDIANIZE_INT64(result);
3562}
3563
3564
3565/*-------------------------------------------------
3566    record_write_uint64 - write a 64-bit value
3567    to the record file
3568-------------------------------------------------*/
3569
3570static void record_write_uint64(running_machine *machine, UINT64 data)
3571{
3572   UINT64 result = LITTLE_ENDIANIZE_INT64(data);
3573
3574   /* protect against NULL handles if previous reads fail */
3575   if (machine->record_file == NULL)
3576      return;
3577
3578   /* read the value; if we fail, end playback */
3579   if (mame_fwrite(machine->record_file, &result, sizeof(result)) != sizeof(result))
3580      record_end(machine, "Out of space");
3581}
3582
3583
3584/*-------------------------------------------------
3585    playback_init - initialize INP playback
3586-------------------------------------------------*/
3587
3588static time_t playback_init(running_machine *machine)
3589{
3590   const char *filename = options_get_string(mame_options(), OPTION_PLAYBACK);
3591   UINT8 header[INP_HEADER_SIZE];
3592   file_error filerr;
3593   time_t basetime;
3594
3595   /* if no file, nothing to do */
3596   if (filename[0] == 0)
3597      return 0;
3598
3599   /* open the playback file */
3600   filerr = mame_fopen(SEARCHPATH_INPUTLOG, filename, OPEN_FLAG_READ, &machine->playback_file);
3601   assert_always(filerr == FILERR_NONE, "Failed to open file for playback");
3602
3603   /* read the header and verify that it is a modern version; if not, print an error */
3604   if (mame_fread(machine->playback_file, header, sizeof(header)) != sizeof(header))
3605      fatalerror("Input file is corrupt or invalid (missing header)");
3606   if (memcmp(header, "MAMEINP\0", 8) != 0)
3607      fatalerror("Input file invalid or in an older, unsupported format");
3608   if (header[0x10] != INP_HEADER_MAJVERSION)
3609      fatalerror("Input file format version mismatch");
3610
3611   /* output info to console */
3612   mame_printf_info("Input file: %s\n", filename);
3613   mame_printf_info("INP version %d.%d\n", header[0x10], header[0x11]);
3614   basetime = header[0x08] | (header[0x09] << 8) | (header[0x0a] << 16) | (header[0x0b] << 24) |
3615            ((UINT64)header[0x0c] << 32) | ((UINT64)header[0x0d] << 40) | ((UINT64)header[0x0e] << 48) | ((UINT64)header[0x0f] << 56);
3616   mame_printf_info("Created %s", ctime(&basetime));
3617   mame_printf_info("Recorded using %s\n", header + 0x20);
3618
3619   /* verify the header against the current game */
3620   if (memcmp(machine->gamedrv->name, header + 0x14, strlen(machine->gamedrv->name) + 1) != 0)
3621      fatalerror("Input file is for " GAMENOUN " '%s', not for current " GAMENOUN " '%s'\n", header + 0x14, machine->gamedrv->name);
3622
3623   return basetime;
3624}
3625
3626
3627/*-------------------------------------------------
3628    record_init - initialize INP recording
3629-------------------------------------------------*/
3630
3631static void record_init(running_machine *machine)
3632{
3633   const char *filename = options_get_string(mame_options(), OPTION_RECORD);
3634   UINT8 header[INP_HEADER_SIZE];
3635   mame_system_time systime;
3636   file_error filerr;
3637
3638   /* if no file, nothing to do */
3639   if (filename[0] == 0)
3640      return;
3641
3642   /* open the record file  */
3643   filerr = mame_fopen(SEARCHPATH_INPUTLOG, filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &machine->record_file);
3644   assert_always(filerr == FILERR_NONE, "Failed to open file for recording");
3645
3646   /* get the base time */
3647   mame_get_base_datetime(machine, &systime);
3648
3649   /* fill in the header */
3650   memset(header, 0, sizeof(header));
3651   memcpy(header, "MAMEINP\0", 8);
3652   header[0x08] = systime.time >> 0;
3653   header[0x09] = systime.time >> 8;
3654   header[0x0a] = systime.time >> 16;
3655   header[0x0b] = systime.time >> 24;
3656   header[0x0c] = systime.time >> 32;
3657   header[0x0d] = systime.time >> 40;
3658   header[0x0e] = systime.time >> 48;
3659   header[0x0f] = systime.time >> 56;
3660   header[0x10] = INP_HEADER_MAJVERSION;
3661   header[0x11] = INP_HEADER_MINVERSION;
3662   strcpy((char *)header + 0x14, machine->gamedrv->name);
3663   sprintf((char *)header + 0x20, APPNAME " %s", build_version);
3664
3665   /* write it */
3666   mame_fwrite(machine->record_file, header, sizeof(header));
3667}
3668
3669
3670/*-------------------------------------------------
3671    playback_end - end INP playback
3672-------------------------------------------------*/
3673
3674static void playback_end(running_machine *machine, const char *message)
3675{
3676   /* only applies if we have a live file */
3677   if (machine->playback_file != NULL)
3678   {
3679      /* close the file */
3680      mame_fclose(machine->playback_file);
3681      machine->playback_file = NULL;
3682
3683      /* pop a message */
3684      if (message != NULL)
3685         popmessage("Playback Ended\nReason: %s", message);
3686
3687      /* display speed stats */
3688      playback_accumulated_speed /= playback_accumulated_frames;
3689      mame_printf_info("Total playback frames: %d\n", (UINT32)playback_accumulated_frames);
3690      mame_printf_info("Average recorded speed: %d%%\n", (UINT32)((playback_accumulated_speed * 200 + 1) >> 21));
3691   }
3692}
3693
3694
3695/*-------------------------------------------------
3696    record_end - end INP recording
3697-------------------------------------------------*/
3698
3699static void record_end(running_machine *machine, const char *message)
3700{
3701   /* only applies if we have a live file */
3702   if (machine->record_file != NULL)
3703   {
3704      /* close the file */
3705      mame_fclose(machine->record_file);
3706      machine->record_file = NULL;
3707
3708      /* pop a message */
3709      if (message != NULL)
3710         popmessage("Recording Ended\nReason: %s", message);
3711   }
3712}
3713
3714
3715/*-------------------------------------------------
3716    playback_frame - start of frame callback for
3717    playback
3718-------------------------------------------------*/
3719
3720static void playback_frame(running_machine *machine, attotime curtime)
3721{
3722   /* if playing back, fetch the information and verify */
3723   if (machine->playback_file != NULL)
3724   {
3725      attotime readtime;
3726
3727      /* first the absolute time */
3728      readtime.seconds = playback_read_uint32(machine);
3729      readtime.attoseconds = playback_read_uint64(machine);
3730      if (attotime_compare(readtime, curtime) != 0)
3731         playback_end(machine, "Out of sync");
3732
3733      /* then the speed */
3734      playback_accumulated_speed += playback_read_uint32(machine);
3735      playback_accumulated_frames++;
3736   }
3737}
3738
3739
3740/*-------------------------------------------------
3741    record_frame - start of frame callback for
3742    recording
3743-------------------------------------------------*/
3744
3745static void record_frame(running_machine *machine, attotime curtime)
3746{
3747   /* if recording, record information about the current frame */
3748   if (machine->record_file != NULL)
3749   {
3750      /* first the absolute time */
3751      record_write_uint32(machine, curtime.seconds);
3752      record_write_uint64(machine, curtime.attoseconds);
3753
3754      /* then the current speed */
3755      record_write_uint32(machine, video_get_speed_percent(machine) * (double)(1 << 20));
3756   }
3757}
3758
3759
3760/*-------------------------------------------------
3761    playback_port - per-port callback for playback
3762-------------------------------------------------*/
3763
3764static void playback_port(running_machine *machine, input_port_info *portinfo)
3765{
3766   /* if playing back, fetch information about this port */
3767   if (machine->playback_file != NULL)
3768   {
3769      analog_port_info *analog;
3770
3771      /* read the digital value */
3772      portinfo->digital = playback_read_uint32(machine);
3773
3774      /* loop over analog ports and save their data */
3775      for (analog = portinfo->analoginfo; analog != NULL; analog = analog->next)
3776      {
3777         /* read current and previous values */
3778         analog->accum = playback_read_uint32(machine);
3779         analog->previous = playback_read_uint32(machine);
3780
3781         /* read configuration information */
3782         analog->portentry->analog.sensitivity = playback_read_uint32(machine);
3783         analog->portentry->analog.reverse = playback_read_uint8(machine);
3784      }
3785   }
3786}
3787
3788
3789/*-------------------------------------------------
3790    record_port - per-port callback for record
3791-------------------------------------------------*/
3792
3793static void record_port(running_machine *machine, input_port_info *portinfo)
3794{
3795   /* if recording, store information about this port */
3796   if (machine->record_file != NULL)
3797   {
3798      analog_port_info *analog;
3799
3800      /* store the digital value */
3801      record_write_uint32(machine, portinfo->digital);
3802
3803      /* loop over analog ports and save their data */
3804      for (analog = portinfo->analoginfo; analog != NULL; analog = analog->next)
3805      {
3806         /* store current and previous values */
3807         record_write_uint32(machine, analog->accum);
3808         record_write_uint32(machine, analog->previous);
3809
3810         /* store configuration information */
3811         record_write_uint32(machine, analog->portentry->analog.sensitivity);
3812         record_write_uint8(machine, analog->portentry->analog.reverse);
3813      }
3814   }
3815}
src/emu/machine/scsicd.c
r2375r2376
741741         return 0;
742742
743743      case SCSIOP_ALLOC_INSTANCE:
744         SCSIBase( &SCSIClassCDROM, operation, file, intparm + SCSI_DEVICE_CDROM_STATE_BASE, ptrparm );
745         scsicd_alloc_instance( *((SCSIInstance **) ptrparm), intparm + SCSI_DEVICE_CDROM_STATE_BASE );
744         SCSIBase( &SCSIClassCDROM, operation, file, intparm, ptrparm );
745         scsicd_alloc_instance( *((SCSIInstance **) ptrparm), intparm );
746746         return 0;
747747
748748      case SCSIOP_DELETE_INSTANCE:
src/emu/machine/scsicd.h
r2375r2376
1313extern const SCSIClass SCSIClassCDROM;
1414#define SCSI_DEVICE_CDROM &SCSIClassCDROM
1515
16// we pass in the disk ID for each SCSI device, but that's not unique across device types.
17// to avoid collisions, each non-HDD SCSI device type should have it's own BASE to prevent
18// this problem.
19#define SCSI_DEVICE_CDROM_STATE_BASE   (32)
20
2116#endif
2217
src/emu/machine/generic.c
r2375r2376
713713    8-bit read handlers
714714-------------------------------------------------*/
715715
716READ8_HANDLER( input_port_0_r ) { return readinputport(0); }
717READ8_HANDLER( input_port_1_r ) { return readinputport(1); }
718READ8_HANDLER( input_port_2_r ) { return readinputport(2); }
719READ8_HANDLER( input_port_3_r ) { return readinputport(3); }
720READ8_HANDLER( input_port_4_r ) { return readinputport(4); }
721READ8_HANDLER( input_port_5_r ) { return readinputport(5); }
722READ8_HANDLER( input_port_6_r ) { return readinputport(6); }
723READ8_HANDLER( input_port_7_r ) { return readinputport(7); }
724READ8_HANDLER( input_port_8_r ) { return readinputport(8); }
725READ8_HANDLER( input_port_9_r ) { return readinputport(9); }
726READ8_HANDLER( input_port_10_r ) { return readinputport(10); }
727READ8_HANDLER( input_port_11_r ) { return readinputport(11); }
728READ8_HANDLER( input_port_12_r ) { return readinputport(12); }
729READ8_HANDLER( input_port_13_r ) { return readinputport(13); }
730READ8_HANDLER( input_port_14_r ) { return readinputport(14); }
731READ8_HANDLER( input_port_15_r ) { return readinputport(15); }
732READ8_HANDLER( input_port_16_r ) { return readinputport(16); }
733READ8_HANDLER( input_port_17_r ) { return readinputport(17); }
734READ8_HANDLER( input_port_18_r ) { return readinputport(18); }
735READ8_HANDLER( input_port_19_r ) { return readinputport(19); }
736READ8_HANDLER( input_port_20_r ) { return readinputport(20); }
737READ8_HANDLER( input_port_21_r ) { return readinputport(21); }
738READ8_HANDLER( input_port_22_r ) { return readinputport(22); }
739READ8_HANDLER( input_port_23_r ) { return readinputport(23); }
740READ8_HANDLER( input_port_24_r ) { return readinputport(24); }
741READ8_HANDLER( input_port_25_r ) { return readinputport(25); }
742READ8_HANDLER( input_port_26_r ) { return readinputport(26); }
743READ8_HANDLER( input_port_27_r ) { return readinputport(27); }
744READ8_HANDLER( input_port_28_r ) { return readinputport(28); }
745READ8_HANDLER( input_port_29_r ) { return readinputport(29); }
746READ8_HANDLER( input_port_30_r ) { return readinputport(30); }
747READ8_HANDLER( input_port_31_r ) { return readinputport(31); }
716READ8_HANDLER( input_port_0_r ) { return input_port_read_indexed(machine, 0); }
717READ8_HANDLER( input_port_1_r ) { return input_port_read_indexed(machine, 1); }
718READ8_HANDLER( input_port_2_r ) { return input_port_read_indexed(machine, 2); }
719READ8_HANDLER( input_port_3_r ) { return input_port_read_indexed(machine, 3); }
720READ8_HANDLER( input_port_4_r ) { return input_port_read_indexed(machine, 4); }
721READ8_HANDLER( input_port_5_r ) { return input_port_read_indexed(machine, 5); }
722READ8_HANDLER( input_port_6_r ) { return input_port_read_indexed(machine, 6); }
723READ8_HANDLER( input_port_7_r ) { return input_port_read_indexed(machine, 7); }
724READ8_HANDLER( input_port_8_r ) { return input_port_read_indexed(machine, 8); }
725READ8_HANDLER( input_port_9_r ) { return input_port_read_indexed(machine, 9); }
726READ8_HANDLER( input_port_10_r ) { return input_port_read_indexed(machine, 10); }
727READ8_HANDLER( input_port_11_r ) { return input_port_read_indexed(machine, 11); }
728READ8_HANDLER( input_port_12_r ) { return input_port_read_indexed(machine, 12); }
729READ8_HANDLER( input_port_13_r ) { return input_port_read_indexed(machine, 13); }
730READ8_HANDLER( input_port_14_r ) { return input_port_read_indexed(machine, 14); }
731READ8_HANDLER( input_port_15_r ) { return input_port_read_indexed(machine, 15); }
732READ8_HANDLER( input_port_16_r ) { return input_port_read_indexed(machine, 16); }
733READ8_HANDLER( input_port_17_r ) { return input_port_read_indexed(machine, 17); }
734READ8_HANDLER( input_port_18_r ) { return input_port_read_indexed(machine, 18); }
735READ8_HANDLER( input_port_19_r ) { return input_port_read_indexed(machine, 19); }
736READ8_HANDLER( input_port_20_r ) { return input_port_read_indexed(machine, 20); }
737READ8_HANDLER( input_port_21_r ) { return input_port_read_indexed(machine, 21); }
738READ8_HANDLER( input_port_22_r ) { return input_port_read_indexed(machine, 22); }
739READ8_HANDLER( input_port_23_r ) { return input_port_read_indexed(machine, 23); }
740READ8_HANDLER( input_port_24_r ) { return input_port_read_indexed(machine, 24); }
741READ8_HANDLER( input_port_25_r ) { return input_port_read_indexed(machine, 25); }
742READ8_HANDLER( input_port_26_r ) { return input_port_read_indexed(machine, 26); }
743READ8_HANDLER( input_port_27_r ) { return input_port_read_indexed(machine, 27); }
744READ8_HANDLER( input_port_28_r ) { return input_port_read_indexed(machine, 28); }
745READ8_HANDLER( input_port_29_r ) { return input_port_read_indexed(machine, 29); }
746READ8_HANDLER( input_port_30_r ) { return input_port_read_indexed(machine, 30); }
747READ8_HANDLER( input_port_31_r ) { return input_port_read_indexed(machine, 31); }
748748
749749
750750/*-------------------------------------------------
751751    16-bit read handlers
752752-------------------------------------------------*/
753753
754READ16_HANDLER( input_port_0_word_r ) { return readinputport(0); }
755READ16_HANDLER( input_port_1_word_r ) { return readinputport(1); }
756READ16_HANDLER( input_port_2_word_r ) { return readinputport(2); }
757READ16_HANDLER( input_port_3_word_r ) { return readinputport(3); }
758READ16_HANDLER( input_port_4_word_r ) { return readinputport(4); }
759READ16_HANDLER( input_port_5_word_r ) { return readinputport(5); }
760READ16_HANDLER( input_port_6_word_r ) { return readinputport(6); }
761READ16_HANDLER( input_port_7_word_r ) { return readinputport(7); }
762READ16_HANDLER( input_port_8_word_r ) { return readinputport(8); }
763READ16_HANDLER( input_port_9_word_r ) { return readinputport(9); }
764READ16_HANDLER( input_port_10_word_r ) { return readinputport(10); }
765READ16_HANDLER( input_port_11_word_r ) { return readinputport(11); }
766READ16_HANDLER( input_port_12_word_r ) { return readinputport(12); }
767READ16_HANDLER( input_port_13_word_r ) { return readinputport(13); }
768READ16_HANDLER( input_port_14_word_r ) { return readinputport(14); }
769READ16_HANDLER( input_port_15_word_r ) { return readinputport(15); }
770READ16_HANDLER( input_port_16_word_r ) { return readinputport(16); }
771READ16_HANDLER( input_port_17_word_r ) { return readinputport(17); }
772READ16_HANDLER( input_port_18_word_r ) { return readinputport(18); }
773READ16_HANDLER( input_port_19_word_r ) { return readinputport(19); }
774READ16_HANDLER( input_port_20_word_r ) { return readinputport(20); }
775READ16_HANDLER( input_port_21_word_r ) { return readinputport(21); }
776READ16_HANDLER( input_port_22_word_r ) { return readinputport(22); }
777READ16_HANDLER( input_port_23_word_r ) { return readinputport(23); }
778READ16_HANDLER( input_port_24_word_r ) { return readinputport(24); }
779READ16_HANDLER( input_port_25_word_r ) { return readinputport(25); }
780READ16_HANDLER( input_port_26_word_r ) { return readinputport(26); }
781READ16_HANDLER( input_port_27_word_r ) { return readinputport(27); }
782READ16_HANDLER( input_port_28_word_r ) { return readinputport(28); }
783READ16_HANDLER( input_port_29_word_r ) { return readinputport(29); }
784READ16_HANDLER( input_port_30_word_r ) { return readinputport(30); }
785READ16_HANDLER( input_port_31_word_r ) { return readinputport(31); }
754READ16_HANDLER( input_port_0_word_r ) { return input_port_read_indexed(machine, 0); }
755READ16_HANDLER( input_port_1_word_r ) { return input_port_read_indexed(machine, 1); }
756READ16_HANDLER( input_port_2_word_r ) { return input_port_read_indexed(machine, 2); }
757READ16_HANDLER( input_port_3_word_r ) { return input_port_read_indexed(machine, 3); }
758READ16_HANDLER( input_port_4_word_r ) { return input_port_read_indexed(machine, 4); }
759READ16_HANDLER( input_port_5_word_r ) { return input_port_read_indexed(machine, 5); }
760READ16_HANDLER( input_port_6_word_r ) { return input_port_read_indexed(machine, 6); }
761READ16_HANDLER( input_port_7_word_r ) { return input_port_read_indexed(machine, 7); }
762READ16_HANDLER( input_port_8_word_r ) { return input_port_read_indexed(machine, 8); }
763READ16_HANDLER( input_port_9_word_r ) { return input_port_read_indexed(machine, 9); }
764READ16_HANDLER( input_port_10_word_r ) { return input_port_read_indexed(machine, 10); }
765READ16_HANDLER( input_port_11_word_r ) { return input_port_read_indexed(machine, 11); }
766READ16_HANDLER( input_port_12_word_r ) { return input_port_read_indexed(machine, 12); }
767READ16_HANDLER( input_port_13_word_r ) { return input_port_read_indexed(machine, 13); }
768READ16_HANDLER( input_port_14_word_r ) { return input_port_read_indexed(machine, 14); }
769READ16_HANDLER( input_port_15_word_r ) { return input_port_read_indexed(machine, 15); }
770READ16_HANDLER( input_port_16_word_r ) { return input_port_read_indexed(machine, 16); }
771READ16_HANDLER( input_port_17_word_r ) { return input_port_read_indexed(machine, 17); }
772READ16_HANDLER( input_port_18_word_r ) { return input_port_read_indexed(machine, 18); }
773READ16_HANDLER( input_port_19_word_r ) { return input_port_read_indexed(machine, 19); }
774READ16_HANDLER( input_port_20_word_r ) { return input_port_read_indexed(machine, 20); }
775READ16_HANDLER( input_port_21_word_r ) { return input_port_read_indexed(machine, 21); }
776READ16_HANDLER( input_port_22_word_r ) { return input_port_read_indexed(machine, 22); }
777READ16_HANDLER( input_port_23_word_r ) { return input_port_read_indexed(machine, 23); }
778READ16_HANDLER( input_port_24_word_r ) { return input_port_read_indexed(machine, 24); }
779READ16_HANDLER( input_port_25_word_r ) { return input_port_read_indexed(machine, 25); }
780READ16_HANDLER( input_port_26_word_r ) { return input_port_read_indexed(machine, 26); }
781READ16_HANDLER( input_port_27_word_r ) { return input_port_read_indexed(machine, 27); }
782READ16_HANDLER( input_port_28_word_r ) { return input_port_read_indexed(machine, 28); }
783READ16_HANDLER( input_port_29_word_r ) { return input_port_read_indexed(machine, 29); }
784READ16_HANDLER( input_port_30_word_r ) { return input_port_read_indexed(machine, 30); }
785READ16_HANDLER( input_port_31_word_r ) { return input_port_read_indexed(machine, 31); }
786786
787787
788788/*-------------------------------------------------
789789    32-bit read handlers
790790-------------------------------------------------*/
791791
792READ32_HANDLER( input_port_0_dword_r ) { return readinputport(0); }
793READ32_HANDLER( input_port_1_dword_r ) { return readinputport(1); }
794READ32_HANDLER( input_port_2_dword_r ) { return readinputport(2); }
795READ32_HANDLER( input_port_3_dword_r ) { return readinputport(3); }
796READ32_HANDLER( input_port_4_dword_r ) { return readinputport(4); }
797READ32_HANDLER( input_port_5_dword_r ) { return readinputport(5); }
798READ32_HANDLER( input_port_6_dword_r ) { return readinputport(6); }
799READ32_HANDLER( input_port_7_dword_r ) { return readinputport(7); }
800READ32_HANDLER( input_port_8_dword_r ) { return readinputport(8); }
801READ32_HANDLER( input_port_9_dword_r ) { return readinputport(9); }
802READ32_HANDLER( input_port_10_dword_r ) { return readinputport(10); }
803READ32_HANDLER( input_port_11_dword_r ) { return readinputport(11); }
804READ32_HANDLER( input_port_12_dword_r ) { return readinputport(12); }
805READ32_HANDLER( input_port_13_dword_r ) { return readinputport(13); }
806READ32_HANDLER( input_port_14_dword_r ) { return readinputport(14); }
807READ32_HANDLER( input_port_15_dword_r ) { return readinputport(15); }
808READ32_HANDLER( input_port_16_dword_r ) { return readinputport(16); }
809READ32_HANDLER( input_port_17_dword_r ) { return readinputport(17); }
810READ32_HANDLER( input_port_18_dword_r ) { return readinputport(18); }
811READ32_HANDLER( input_port_19_dword_r ) { return readinputport(19); }
812READ32_HANDLER( input_port_20_dword_r ) { return readinputport(20); }
813READ32_HANDLER( input_port_21_dword_r ) { return readinputport(21); }
814READ32_HANDLER( input_port_22_dword_r ) { return readinputport(22); }
815READ32_HANDLER( input_port_23_dword_r ) { return readinputport(23); }
816READ32_HANDLER( input_port_24_dword_r ) { return readinputport(24); }
817READ32_HANDLER( input_port_25_dword_r ) { return readinputport(25); }
818READ32_HANDLER( input_port_26_dword_r ) { return readinputport(26); }
819READ32_HANDLER( input_port_27_dword_r ) { return readinputport(27); }
820READ32_HANDLER( input_port_28_dword_r ) { return readinputport(28); }
821READ32_HANDLER( input_port_29_dword_r ) { return readinputport(29); }
822READ32_HANDLER( input_port_30_dword_r ) { return readinputport(30); }
823READ32_HANDLER( input_port_31_dword_r ) { return readinputport(31); }
792READ32_HANDLER( input_port_0_dword_r ) { return input_port_read_indexed(machine, 0); }
793READ32_HANDLER( input_port_1_dword_r ) { return input_port_read_indexed(machine, 1); }
794READ32_HANDLER( input_port_2_dword_r ) { return input_port_read_indexed(machine, 2); }
795READ32_HANDLER( input_port_3_dword_r ) { return input_port_read_indexed(machine, 3); }
796READ32_HANDLER( input_port_4_dword_r ) { return input_port_read_indexed(machine, 4); }
797READ32_HANDLER( input_port_5_dword_r ) { return input_port_read_indexed(machine, 5); }
798READ32_HANDLER( input_port_6_dword_r ) { return input_port_read_indexed(machine, 6); }
799READ32_HANDLER( input_port_7_dword_r ) { return input_port_read_indexed(machine, 7); }
800READ32_HANDLER( input_port_8_dword_r ) { return input_port_read_indexed(machine, 8); }
801READ32_HANDLER( input_port_9_dword_r ) { return input_port_read_indexed(machine, 9); }
802READ32_HANDLER( input_port_10_dword_r ) { return input_port_read_indexed(machine, 10); }
803READ32_HANDLER( input_port_11_dword_r ) { return input_port_read_indexed(machine, 11); }
804READ32_HANDLER( input_port_12_dword_r ) { return input_port_read_indexed(machine, 12); }
805READ32_HANDLER( input_port_13_dword_r ) { return input_port_read_indexed(machine, 13); }
806READ32_HANDLER( input_port_14_dword_r ) { return input_port_read_indexed(machine, 14); }
807READ32_HANDLER( input_port_15_dword_r ) { return input_port_read_indexed(machine, 15); }
808READ32_HANDLER( input_port_16_dword_r ) { return input_port_read_indexed(machine, 16); }
809READ32_HANDLER( input_port_17_dword_r ) { return input_port_read_indexed(machine, 17); }
810READ32_HANDLER( input_port_18_dword_r ) { return input_port_read_indexed(machine, 18); }
811READ32_HANDLER( input_port_19_dword_r ) { return input_port_read_indexed(machine, 19); }
812READ32_HANDLER( input_port_20_dword_r ) { return input_port_read_indexed(machine, 20); }
813READ32_HANDLER( input_port_21_dword_r ) { return input_port_read_indexed(machine, 21); }
814READ32_HANDLER( input_port_22_dword_r ) { return input_port_read_indexed(machine, 22); }
815READ32_HANDLER( input_port_23_dword_r ) { return input_port_read_indexed(machine, 23); }
816READ32_HANDLER( input_port_24_dword_r ) { return input_port_read_indexed(machine, 24); }
817READ32_HANDLER( input_port_25_dword_r ) { return input_port_read_indexed(machine, 25); }
818READ32_HANDLER( input_port_26_dword_r ) { return input_port_read_indexed(machine, 26); }
819READ32_HANDLER( input_port_27_dword_r ) { return input_port_read_indexed(machine, 27); }
820READ32_HANDLER( input_port_28_dword_r ) { return input_port_read_indexed(machine, 28); }
821READ32_HANDLER( input_port_29_dword_r ) { return input_port_read_indexed(machine, 29); }
822READ32_HANDLER( input_port_30_dword_r ) { return input_port_read_indexed(machine, 30); }
823READ32_HANDLER( input_port_31_dword_r ) { return input_port_read_indexed(machine, 31); }
824824
src/emu/machine/pit8253.c
r2375r2376
11701170   {
11711171      struct pit8253_timer *timer = get_timer(pit,i);
11721172      /* According to Intel's 8254 docs, the state of a timer is undefined
1173         until the first mode control word is written. Here we define this
1174         undefined behaviour */
1173           until the first mode control word is written. Here we define this
1174           undefined behaviour */
11751175      timer->control = timer->status = 0x30;
11761176      timer->rmsb = timer->wmsb = 0;
11771177      timer->count = timer->value = timer->latch = 0;
r2375r2376
12011201   switch ( state ) {
12021202      /* --- the following bits of info are returned as 64-bit signed integers --- */
12031203      case DEVINFO_INT_TOKEN_BYTES:            info->i = sizeof(pit8253_t);            break;
1204      case DEVINFO_INT_INLINE_CONFIG_BYTES:      info->i = 256; /* FIX ME Judge! */         break;
1204      case DEVINFO_INT_INLINE_CONFIG_BYTES:      info->i = 0;                        break;
12051205      case DEVINFO_INT_CLASS:                  info->i = DEVICE_CLASS_PERIPHERAL;         break;
12061206
12071207      /* --- the following bits of info are returned as pointers to data or functions --- */
r2375r2376
12311231      default:                           DEVICE_GET_INFO_CALL(pit8253);            break;
12321232   }
12331233}
1234
src/emu/machine/pit8253.h
r2375r2376
2929      pit8253_output_changed_func         output_changed;
3030
3131      /* If specified, this gets called whenever the frequency of the output for this
32         timer changes. */
33      pit8253_frequency_changed_func      frequency_changed;     
32           timer changes. */
33      pit8253_frequency_changed_func      frequency_changed;
3434   } timer[3];
3535};
3636
src/emu/inptport.h
r2375r2376
3939#define INPUT_PORT_PAIR_TOKENS   (2 * sizeof(UINT32) / sizeof(FPTR))
4040
4141
42#define INP_HEADER_SIZE         64
43#define INP_HEADER_MAJVERSION   2
44#define INP_HEADER_MINVERSION   0
45
46
4247/* macro for a custom callback functions (PORT_CUSTOM) */
4348#define CUSTOM_INPUT(name)   UINT32 name(running_machine *machine, void *param)
4449
r2375r2376
630635typedef struct _inp_header inp_header;
631636struct _inp_header
632637{
633   char    name[9];            /* 8 bytes for game->name + NUL */
634   char    version[3];         /* byte[0] = 0, byte[1] = version byte[2] = beta_version */
635   char    reserved[20];       /* for future use, possible store game options? */
638   char   header[8];         /* +00: 8 byte header - must be "MAMEINP\0" */
639   UINT64   basetime;         /* +08: base time of recording */
640   UINT8   majversion;         /* +10: major INP version */
641   UINT8   minversion;         /* +11: minor INP version */
642   UINT8   reserved[2];      /* +12: must be zero */
643   char   gamename[12];      /* +14: game name string, NULL-terminated */
644   char   version[32];      /* +20: system version string, NULL-terminated */
636645};
637646
638647
639typedef struct _ext_inp_header ext_inp_header;
640struct _ext_inp_header
641{
642   char    header[7];         /* must be "XINP" followed by NULLs */
643   char    shortname[9];      /* game shortname */
644   char    version[32];      /* MAME version string */
645   UINT32 starttime;         /* approximate INP start time */
646   char    dummy[32];         /* for possible future expansion */
647};
648648
649
650
651649/***************************************************************************
652650    MACROS FOR BUILDING INPUT PORTS
653651***************************************************************************/
r2375r2376
904902    FUNCTION PROTOTYPES
905903***************************************************************************/
906904
907void input_port_init(running_machine *machine, const input_port_token *ipt);
905time_t input_port_init(running_machine *machine, const input_port_token *ipt);
908906const char *input_port_string_from_token(const input_port_token token);
909907
910908input_port_entry *input_port_initialize(input_port_init_params *params, UINT32 type, const char *tag, UINT32 mask, UINT32 defval);
r2375r2376
938936
939937void input_port_update_defaults(void);
940938
941void input_port_set_digital_value(int port, UINT32 value, UINT32 mask);
939void input_port_set_digital_value(running_machine *machine, int port_num, UINT32 value, UINT32 mask);
942940
943941UINT32 get_crosshair_pos(int port_num, UINT8 player, UINT8 axis);
944942
945/* leaving these in temporarily until 0.124u2 */
946UINT32 readinputport(int port);
947UINT32 readinputportbytag(const char *tag);
948UINT32 readinputportbytag_safe(const char *tag, UINT32 defvalue);
949
950943UINT32 input_port_read_indexed(running_machine *machine, int port);
951944UINT32 input_port_read(running_machine *machine, const char *tag);
952945UINT32 input_port_read_safe(running_machine *machine, const char *tag, UINT32 defvalue);
src/emu/cpuintrf.c
r2375r2376
213213void mb86233_get_info(UINT32 state, cpuinfo *info);
214214void ssp1601_get_info(UINT32 state, cpuinfo *info);
215215void minx_get_info(UINT32 state, cpuinfo *info);
216void cxd8661r_get_info(UINT32 state, cpuinfo *info);
216217
217218
218219
r2375r2376
824825#if (HAS_MINX)
825826   { CPU_MINX, minx_get_info },
826827#endif
828#if (HAS_CXD8661R)
829   { CPU_CXD8661R, cxd8661r_get_info },
830#endif
827831};
828832
829833
src/emu/cpuexec.h
r2375r2376
241241   CPU_MB86233,
242242   CPU_SSP1601,
243243   CPU_MINX,
244   CPU_CXD8661R,
244245    CPU_COUNT
245246};
246247typedef enum _cpu_type cpu_type;
src/emu/sound/2612intf.c
r2375r2376
1212***************************************************************************/
1313
1414#include "sndintrf.h"
15#include "deprecat.h"
1516#include "streams.h"
1617#include "sound/fm.h"
1718#include "sound/2612intf.h"
r2375r2376
7980}
8081
8182
82static void ym2612_postload(void *param)
83static STATE_POSTLOAD( ym2612_postload )
8384{
8485   struct ym2612_info *info = param;
8586   YM2612Postload(info->chip);
r2375r2376
108109   /**** initialize YM2612 ****/
109110   info->chip = YM2612Init(info,sndindex,clock,rate,timer_handler,IRQHandler);
110111
111   state_save_register_func_postload_ptr(ym2612_postload, info);
112   state_save_register_postload(Machine, ym2612_postload, info);
112113
113114   if (info->chip)
114115      return info;
src/emu/sound/k054539.c
r2375r2376
1818*********************************************************/
1919
2020#include "sndintrf.h"
21#include "deprecat.h"
2122#include "streams.h"
2223#include "k054539.h"
2324#include <math.h>
r2375r2376
592593   regbase[offset] = data;
593594}
594595
595static void reset_zones(void *param)
596static STATE_POSTLOAD( reset_zones )
596597{
597598   struct k054539_info *info = param;
598599   int data = info->regs[0x22e];
r2375r2376
662663
663664   K054539_init_chip(info, clock, sndindex);
664665
665   state_save_register_func_postload_ptr(reset_zones, info);
666   state_save_register_postload(Machine, reset_zones, info);
666667   return info;
667668}
668669
src/emu/sound/disc_inp.c
r2375r2376
122122   if (DSS_ADJUSTMENT__ENABLE)
123123   {
124124      struct dss_adjustment_context *context = node->context;
125      INT32 rawportval = readinputport(context->port);
125      INT32 rawportval = input_port_read_indexed(Machine, context->port);
126126
127127      /* only recompute if the value changed from last time */
128128      if (rawportval != context->lastpval)
src/emu/sound/ymz280b.c
r2375r2376
191191}
192192
193193
194static void YMZ280B_state_save_update_step(void *param)
194static STATE_POSTLOAD( YMZ280B_state_save_update_step )
195195{
196196   struct YMZ280BChip *chip = param;
197197   int j;
r2375r2376
690690      }
691691   }
692692
693   state_save_register_func_postload_ptr(YMZ280B_state_save_update_step, chip);
693   state_save_register_postload(Machine, YMZ280B_state_save_update_step, chip);
694694
695695#if MAKE_WAVS
696696   chip->wavresample = wav_open("resamp.wav", INTERNAL_SAMPLE_RATE, 2);
src/emu/sound/upd7759.c
r2375r2376
100100#include <math.h>
101101
102102#include "sndintrf.h"
103#include "deprecat.h"
103104#include "streams.h"
104105#include "upd7759.h"
105106
r2375r2376
579580}
580581
581582
582static void upd7759_postload(void *param)
583static STATE_POSTLOAD( upd7759_postload )
583584{
584585   struct upd7759_chip *chip = (struct upd7759_chip *)param;
585586   chip->rom = chip->rombase + chip->romoffset;
r2375r2376
615616   state_save_register_item("upd7759", index, chip->sample);
616617
617618   state_save_register_item("upd7759", index, chip->romoffset);
618   state_save_register_func_postload_ptr(upd7759_postload, chip);
619   state_save_register_postload(Machine, upd7759_postload, chip);
619620}
620621
621622
src/emu/sound/ym2151.c
r2375r2376
13861386/*
13871387*   state save support for MAME
13881388*/
1389void YM2151Postload(void *chip)
1389STATE_POSTLOAD( YM2151Postload )
13901390{
1391   YM2151 *YM2151_chip = (YM2151 *)chip;
1391   YM2151 *YM2151_chip = (YM2151 *)param;
13921392   int j;
13931393
13941394   for (j=0; j<8; j++)
r2375r2376
14941494
14951495   state_save_register_item_array(buf1, sndindex, chip->connect);
14961496
1497   state_save_register_func_postload_ptr(YM2151Postload, chip);
1497   state_save_register_postload(Machine, YM2151Postload, chip);
14981498}
14991499#else
1500void YM2151Postload(void *chip)
1500STATE_POSTLOAD( YM2151Postload )
15011501{
15021502}
15031503
src/emu/sound/ym2151.h
r2375r2376
8282void YM2151SetPortWriteHandler(void *chip, write8_machine_func handler);
8383
8484/* refresh chip when load state */
85void YM2151Postload(void *chip);
85STATE_POSTLOAD( YM2151Postload );
8686#endif /*_H_YM2151_*/
src/emu/sound/samples.c
r2375r2376
494494}
495495
496496
497static void samples_postload(void *param)
497static STATE_POSTLOAD( samples_postload )
498498{
499499   struct samples_info *info = param;
500500   int i;
r2375r2376
566566        state_save_register_item("samples", sndindex * MAX_CHANNELS + i, info->channel[i].loop);
567567        state_save_register_item("samples", sndindex * MAX_CHANNELS + i, info->channel[i].paused);
568568   }
569   state_save_register_func_postload_ptr(samples_postload, info);
569   state_save_register_postload(Machine, samples_postload, info);
570570
571571   /* initialize any custom handlers */
572572   if (intf->start)
src/emu/sound/2610intf.c
r2375r2376
1212***************************************************************************/
1313
1414#include "sndintrf.h"
15#include "deprecat.h"
1516#include "streams.h"
1617#include "ay8910.h"
1718#include "2610intf.h"
r2375r2376
112113}
113114
114115
115static void ym2610_postload(void *param)
116static STATE_POSTLOAD( ym2610_postload )
116117{
117118   struct ym2610_info *info = param;
118119   YM2610Postload(info->chip);
r2375r2376
154155                 pcmbufa,pcmsizea,pcmbufb,pcmsizeb,
155156                 timer_handler,IRQHandler,&psgintf);
156157
157   state_save_register_func_postload_ptr(ym2610_postload, info);
158   state_save_register_postload(Machine, ym2610_postload, info);
158159
159160   if (info->chip)
160161      return info;
src/emu/sound/fmopl.c
r2375r2376
7070#include <math.h>
7171
7272#include "sndintrf.h"      /* use M.A.M.E. */
73#include "deprecat.h"      /* use M.A.M.E. */
7374
7475#include "ymdeltat.h"
7576
r2375r2376
18201821}
18211822
18221823
1823static void OPL_postload(void *param)
1824static STATE_POSTLOAD( OPL_postload )
18241825{
18251826   FM_OPL *OPL = (FM_OPL *)param;
18261827   int slot, ch;
r2375r2376
19701971   state_save_register_item(statename, index, OPL->statusmask);
19711972   state_save_register_item(statename, index, OPL->mode);
19721973
1973   state_save_register_func_postload_ptr(OPL_postload, OPL);
1974   state_save_register_postload(Machine, OPL_postload, OPL);
19741975}
19751976
19761977
src/emu/sound/2608intf.c
r2375r2376
1212***************************************************************************/
1313
1414#include "sndintrf.h"
15#include "deprecat.h"
1516#include "streams.h"
1617#include "ay8910.h"
1718#include "2608intf.h"
r2375r2376
110111}
111112
112113
113static void ym2608_postload(void *param)
114static STATE_POSTLOAD( ym2608_postload )
114115{
115116   struct ym2608_info *info = param;
116117   YM2608Postload(info->chip);
r2375r2376
149150                 pcmbufa,pcmsizea,
150151                 timer_handler,IRQHandler,&psgintf);
151152
152   state_save_register_func_postload_ptr(ym2608_postload, info);
153   state_save_register_postload(Machine, ym2608_postload, info);
153154
154155   if (info->chip)
155156      return info;
src/emu/sound/2151intf.c
r2375r2376
88
99#include "sndintrf.h"
1010#include "streams.h"
11#include "deprecat.h"
1112#include "fm.h"
1213#include "2151intf.h"
1314#include "ym2151.h"
r2375r2376
2930}
3031
3132
32static void ym2151_postload(void *param)
33static STATE_POSTLOAD( ym2151_postload )
3334{
3435   struct ym2151_info *info = param;
35   YM2151Postload(info->chip);
36   YM2151Postload(machine, info->chip);
3637}
3738
3839
r2375r2376
5455
5556   info->chip = YM2151Init(sndindex,clock,rate);
5657
57   state_save_register_func_postload_ptr(ym2151_postload, info);
58   state_save_register_postload(Machine, ym2151_postload, info);
5859
5960   if (info->chip != 0)
6061   {
src/emu/sound/multipcm.c
r2375r2376
2929
3030#include <math.h>
3131#include "sndintrf.h"
32#include "deprecat.h"
3233#include "streams.h"
3334#include "multipcm.h"
3435
r2375r2376
101102
102103} MultiPCMT;
103104
104static void MultiPCM_postload(void *param)
105static STATE_POSTLOAD( MultiPCM_postload )
105106{
106107   MultiPCMT *mpcm = param;
107108   int j;
r2375r2376
329330      state_save_register_item(mname, sndindex, mpcm->curvoice);
330331   }
331332
332   state_save_register_func_postload_ptr(MultiPCM_postload, mpcm);
333   state_save_register_postload(Machine, MultiPCM_postload, mpcm);
333334
334335   return mpcm;
335336}
src/emu/sound/vlm5030.c
r2375r2376
476476}
477477
478478
479static void VLM5030_restore_state(void *param)
479static STATE_POSTLOAD( VLM5030_restore_state )
480480{
481481   struct vlm5030_info *chip = param;
482482   int i;
r2375r2376
680680   state_save_register_item(VLM_NAME,sndindex,chip->target_pitch);
681681   state_save_register_item_array(VLM_NAME,sndindex,chip->target_k);
682682   state_save_register_item_array(VLM_NAME,sndindex,chip->x);
683   state_save_register_func_postload_ptr(VLM5030_restore_state, chip);
683   state_save_register_postload(Machine, VLM5030_restore_state, chip);
684684
685685   return chip;
686686}
src/emu/sound/2203intf.c
r2375r2376
11#include <math.h>
22#include "sndintrf.h"
3#include "deprecat.h"
34#include "streams.h"
45#include "2203intf.h"
56#include "fm.h"
r2375r2376
9798}
9899
99100
100static void ym2203_postload(void *param)
101static STATE_POSTLOAD( ym2203_postload )
101102{
102103   struct ym2203_info *info = param;
103104   YM2203Postload(info->chip);
r2375r2376
128129   /* Initialize FM emurator */
129130   info->chip = YM2203Init(info,sndindex,clock,rate,timer_handler,IRQHandler,&psgintf);
130131
131   state_save_register_func_postload_ptr(ym2203_postload, info);
132   state_save_register_postload(Machine, ym2203_postload, info);
132133
133134   if (info->chip)
134135      return info;
src/emu/input.c
r2375r2376
759759void input_device_item_add(input_device *device, const char *name, void *internal, input_item_id itemid, item_get_state_func getstate)
760760{
761761   input_device_item *item;
762   input_item_id itemid_std = itemid;
762763
763764   assert_always(mame_get_phase(Machine) == MAME_PHASE_INIT, "Can only call input_device_item_add at init time!");
764765   assert(name != NULL);
r2375r2376
787788   item->name = astring_cpyc(auto_astring_alloc(), name);
788789   item->token = NULL;
789790   item->internal = internal;
790   item->itemclass = input_item_standard_class(device->devclass, itemid);
791   item->itemclass = input_item_standard_class(device->devclass, itemid_std);
791792   item->itemid = itemid;
792793   item->getstate = getstate;
793794
src/emu/state.c
r2375r2376
5151   SS_MSB_FIRST = 0x02
5252};
5353
54enum
55{
56   FUNC_NOPARAM,
57   FUNC_INTPARAM,
58   FUNC_PTRPARAM
59};
6054
6155
62
6356/***************************************************************************
6457    TYPE DEFINITIONS
6558***************************************************************************/
r2375r2376
8174struct _ss_func
8275{
8376   ss_func *      next;            /* pointer to next entry */
84   int            type;            /* type of callback */
8577   union
8678   {
87      void (*voidf)(void);
88      void (*intf)(int param);
89      void (*ptrf)(void *param);
79      state_presave_func presave;      /* presave callback */
80      state_postload_func postload;   /* postload callback */
9081   } func;                        /* function pointers */
91   union
92   {
93      int intp;
94      void *ptrp;
95   } param;                     /* parameters */
82   void *         param;            /* function parameter */
9683   int            tag;            /* saving tag */
9784};
9885
r2375r2376
305292***************************************************************************/
306293
307294/*-------------------------------------------------
308    register_func_void - register a function
309    callback that takes no parameters
295    state_save_register_presave -
296    register a pre-save function callback
310297-------------------------------------------------*/
311298
312static void register_func_void(ss_func **root, void (*func)(void))
299void state_save_register_presave(running_machine *machine, state_presave_func func, void *param)
313300{
314301   ss_func **cur;
315302
316303   /* check for invalid timing */
317304   if (!ss_registration_allowed)
318   {
319      logerror("Attempt to register callback function after state registration is closed!");
320      if (Machine->gamedrv->flags & GAME_SUPPORTS_SAVE)
321         fatalerror("Attempt to register callback function after state registration is closed!");
322      ss_illegal_regs++;
323      return;
324   }
325
326   /* scan for duplicates and push through to the end */
327   for (cur = root; *cur; cur = &(*cur)->next)
328      if ((*cur)->func.voidf == func && (*cur)->tag == ss_current_tag)
329         fatalerror("Duplicate save state function (%d, 0x%p)", ss_current_tag, func);
330
331   /* allocate a new entry */
332   *cur = malloc_or_die(sizeof(ss_func));
333
334   /* fill it in */
335   (*cur)->next       = NULL;
336   (*cur)->type       = FUNC_NOPARAM;
337   (*cur)->func.voidf = func;
338   (*cur)->tag        = ss_current_tag;
339   restrack_register_object(OBJTYPE_STATEREG, *cur, (root == &ss_prefunc_reg) ? 1 : 2, __FILE__, __LINE__);
340}
341
342void state_save_register_func_presave(void (*func)(void))
343{
344   register_func_void(&ss_prefunc_reg, func);
345}
346
347void state_save_register_func_postload(void (*func)(void))
348{
349   register_func_void(&ss_postfunc_reg, func);
350}
351
352
353/*-------------------------------------------------
354    register_func_int - register a function
355    callback that takes an integer parameter
356-------------------------------------------------*/
357
358static void register_func_int(ss_func **root, void (*func)(int), int param)
359{
360   ss_func **cur;
361
362   /* check for invalid timing */
363   if (!ss_registration_allowed)
364305      fatalerror("Attempt to register callback function after state registration is closed!");
365306
366307   /* scan for duplicates and push through to the end */
367   for (cur = root; *cur; cur = &(*cur)->next)
368      if ((*cur)->func.intf == func && (*cur)->param.intp == param && (*cur)->tag == ss_current_tag)
369         fatalerror("Duplicate save state function (%d, %d, %p)", ss_current_tag, param, func);
308   for (cur = &ss_prefunc_reg; *cur; cur = &(*cur)->next)
309      if ((*cur)->func.presave == func && (*cur)->param == param && (*cur)->tag == ss_current_tag)
310         fatalerror("Duplicate save state function (%d, %p, %p)", ss_current_tag, param, func);
370311
371312   /* allocate a new entry */
372313   *cur = malloc_or_die(sizeof(ss_func));
373314
374315   /* fill it in */
375   (*cur)->next       = NULL;
376   (*cur)->type       = FUNC_INTPARAM;
377   (*cur)->func.intf  = func;
378   (*cur)->param.intp = param;
379   (*cur)->tag        = ss_current_tag;
380   restrack_register_object(OBJTYPE_STATEREG, *cur, (root == &ss_prefunc_reg) ? 1 : 2, __FILE__, __LINE__);
316   (*cur)->next         = NULL;
317   (*cur)->func.presave = func;
318   (*cur)->param        = param;
319   (*cur)->tag          = ss_current_tag;
320   restrack_register_object(OBJTYPE_STATEREG, *cur, 1, __FILE__, __LINE__);
381321}
382322
383void state_save_register_func_presave_int(void (*func)(int), int param)
384{
385   register_func_int(&ss_prefunc_reg, func, param);
386}
387323
388void state_save_register_func_postload_int(void (*func)(int), int param)
389{
390   register_func_int(&ss_postfunc_reg, func, param);
391}
392
393
394324/*-------------------------------------------------
395    register_func_ptr - register a function
396    callback that takes a void * parameter
325    state_save_register_postload -
326    register a post-load function callback
397327-------------------------------------------------*/
398328
399static void register_func_ptr(ss_func **root, void (*func)(void *), void *param)
329void state_save_register_postload(running_machine *machine, state_postload_func func, void *param)
400330{
401331   ss_func **cur;
402332
r2375r2376
405335      fatalerror("Attempt to register callback function after state registration is closed!");
406336
407337   /* scan for duplicates and push through to the end */
408   for (cur = root; *cur; cur = &(*cur)->next)
409      if ((*cur)->func.ptrf == func && (*cur)->param.ptrp == param && (*cur)->tag == ss_current_tag)
338   for (cur = &ss_postfunc_reg; *cur; cur = &(*cur)->next)
339      if ((*cur)->func.postload == func && (*cur)->param == param && (*cur)->tag == ss_current_tag)
410340         fatalerror("Duplicate save state function (%d, %p, %p)", ss_current_tag, param, func);
411341
412342   /* allocate a new entry */
413343   *cur = malloc_or_die(sizeof(ss_func));
414344
415345   /* fill it in */
416   (*cur)->next       = NULL;
417   (*cur)->type       = FUNC_PTRPARAM;
418   (*cur)->func.ptrf  = func;
419   (*cur)->param.ptrp = param;
420   (*cur)->tag        = ss_current_tag;
421   restrack_register_object(OBJTYPE_STATEREG, *cur, (root == &ss_prefunc_reg) ? 1 : 2, __FILE__, __LINE__);
346   (*cur)->next          = NULL;
347   (*cur)->func.postload = func;
348   (*cur)->param         = param;
349   (*cur)->tag           = ss_current_tag;
350   restrack_register_object(OBJTYPE_STATEREG, *cur, 2, __FILE__, __LINE__);
422351}
423352
424void state_save_register_func_presave_ptr(void (*func)(void *), void * param)
425{
426   register_func_ptr(&ss_prefunc_reg, func, param);
427}
428353
429void state_save_register_func_postload_ptr(void (*func)(void *), void * param)
430{
431   register_func_ptr(&ss_postfunc_reg, func, param);
432}
433354
434
435
436355/***************************************************************************
437356    REGISTRATION FREEING
438357***************************************************************************/
r2375r2376
594513
595514
596515/*-------------------------------------------------
597    call_hook_functions - loop through all the
598    hook functions and call them
599-------------------------------------------------*/
600
601static int call_hook_functions(ss_func *funclist)
602{
603   ss_func *func;
604   int count = 0;
605
606   /* iterate over the list of functions */
607   for (func = funclist; func; func = func->next)
608      if (func->tag == ss_current_tag)
609      {
610         count++;
611
612         /* call with the appropriate parameters */
613         switch (func->type)
614         {
615            case FUNC_NOPARAM:   (func->func.voidf)();               break;
616            case FUNC_INTPARAM:   (func->func.intf)(func->param.intp);   break;
617            case FUNC_PTRPARAM:   (func->func.ptrf)(func->param.ptrp);   break;
618         }
619      }
620
621   return count;
622}
623
624
625/*-------------------------------------------------
626516    get_signature - compute the signature, which
627517    is a CRC over the structure of the data
628518-------------------------------------------------*/
r2375r2376
768658void state_save_save_continue(void)
769659{
770660   ss_entry *entry;
771   int count;
661   ss_func *func;
662   int count = 0;
772663
773664   LOG(("Saving tag %d\n", ss_current_tag));
774665
775666   /* call the pre-save functions */
776667   LOG(("  calling pre-save functions\n"));
777   count = call_hook_functions(ss_prefunc_reg);
668
669   /* iterate over the list of functions */
670   for (func = ss_prefunc_reg; func; func = func->next)
671      if (func->tag == ss_current_tag)
672      {
673         count++;
674         (*func->func.presave)(Machine, func->param);
675      }
778676   LOG(("    %d functions called\n", count));
779677
780678   /* then copy in all the data */
r2375r2376
873771void state_save_load_continue(void)
874772{
875773   ss_entry *entry;
774   ss_func *func;
876775   int need_convert;
877   int count;
776   int count = 0;
878777
879778   /* first determine whether or not we need to convert the endianness of the data */
880779#ifdef LSB_FIRST
r2375r2376
898797
899798   /* call the post-load functions */
900799   LOG(("  calling post-load functions\n"));
901   count = call_hook_functions(ss_postfunc_reg);
800   for (func = ss_postfunc_reg; func; func = func->next)
801      if (func->tag == ss_current_tag)
802      {
803         count++;
804         (*func->func.postload)(Machine, func->param);
805      }
902806   LOG(("    %d functions called\n", count));
903807}
904808
src/emu/timer.c
r2375r2376
104104    FUNCTION PROTOTYPES
105105***************************************************************************/
106106
107static void timer_postload(void);
107static STATE_POSTLOAD( timer_postload );
108108static void timer_logtimers(void);
109109static void timer_remove(emu_timer *which);
110110
r2375r2376
280280   state_save_push_tag(0);
281281   state_save_register_item("timer", 0, global_basetime.seconds);
282282   state_save_register_item("timer", 0, global_basetime.attoseconds);
283   state_save_register_func_postload(timer_postload);
283   state_save_register_postload(machine, timer_postload, NULL);
284284   state_save_pop_tag();
285285
286286   /* reset the timers */
r2375r2376
427427    timer_postload - after loading a save state
428428-------------------------------------------------*/
429429
430static void timer_postload(void)
430static STATE_POSTLOAD( timer_postload )
431431{
432432   emu_timer *privlist = NULL;
433433   emu_timer *t;
src/emu/emupal.c
r2375r2376
7575    FUNCTION PROTOTYPES
7676***************************************************************************/
7777
78static void palette_presave(void);
79static void palette_postload(void);
78static void palette_presave(running_machine *machine, void *param);
79static void palette_postload(running_machine *machine, void *param);
8080static void palette_exit(running_machine *machine);
8181static void allocate_palette(running_machine *machine, palette_private *palette);
8282static void allocate_color_tables(running_machine *machine, palette_private *palette);
r2375r2376
151151      palette->save_bright = auto_malloc(sizeof(*palette->save_bright) * numcolors);
152152      state_save_register_global_pointer(palette->save_pen, numcolors);
153153      state_save_register_global_pointer(palette->save_bright, numcolors);
154      state_save_register_func_presave(palette_presave);
155      state_save_register_func_postload(palette_postload);
154      state_save_register_presave(machine, palette_presave, palette);
155      state_save_register_postload(machine, palette_postload, palette);
156156   }
157157}
158158
r2375r2376
534534    for saving
535535-------------------------------------------------*/
536536
537static void palette_presave(void)
537static void palette_presave(running_machine *machine, void *param)
538538{
539   int numcolors = palette_get_num_colors(Machine->palette);
540   palette_private *palette = Machine->palette_data;
539   int numcolors = palette_get_num_colors(machine->palette);
540   palette_private *palette = param;
541541   int index;
542542
543543   /* fill the save arrays with updated pen and brightness information */
544544   for (index = 0; index < numcolors; index++)
545545   {
546      palette->save_pen[index] = palette_entry_get_color(Machine->palette, index);
547      palette->save_bright[index] = palette_entry_get_contrast(Machine->palette, index);
546      palette->save_pen[index] = palette_entry_get_color(machine->palette, index);
547      palette->save_bright[index] = palette_entry_get_contrast(machine->palette, index);
548548   }
549549}
550550
r2375r2376
554554    actually update the palette
555555-------------------------------------------------*/
556556
557static void palette_postload(void)
557static void palette_postload(running_machine *machine, void *param)
558558{
559   int numcolors = palette_get_num_colors(Machine->palette);
560   palette_private *palette = Machine->palette_data;
559   int numcolors = palette_get_num_colors(machine->palette);
560   palette_private *palette = param;
561561   int index;
562562
563563   /* reset the pen and brightness for each entry */
564564   for (index = 0; index < numcolors; index++)
565565   {
566      palette_entry_set_color(Machine->palette, index, palette->save_pen[index]);
567      palette_entry_set_contrast(Machine->palette, index, palette->save_bright[index]);
566      palette_entry_set_color(machine->palette, index, palette->save_pen[index]);
567      palette_entry_set_contrast(machine->palette, index, palette->save_bright[index]);
568568   }
569569}
570570
src/emu/state.h
r2375r2376
1919
2020
2121/***************************************************************************
22    TYPE DEFINTIONS
23***************************************************************************/
24
25typedef void (*state_presave_func)(running_machine *machine, void *param);
26typedef void (*state_postload_func)(running_machine *machine, void *param);
27
28
29
30/***************************************************************************
2231    MACROS
2332***************************************************************************/
2433
34#define STATE_PRESAVE(name) void name(running_machine *machine, void *param)
35#define STATE_POSTLOAD(name) void name(running_machine *machine, void *param)
36
37
2538#define IS_COMPATIBLE_TYPE(_valtype, _checktype)                              \
2639   (sizeof(_valtype) == sizeof(_checktype) && TYPES_COMPATIBLE(typeof(_valtype), _checktype))
2740
r2375r2376
88101void state_save_register_memory(const char *module, UINT32 instance, const char *name, void *val, UINT32 valsize, UINT32 valcount);
89102void state_save_register_bitmap(const char *module, UINT32 instance, const char *name, bitmap_t *val);
90103
91void state_save_register_func_presave(void (*func)(void));
92void state_save_register_func_postload(void (*func)(void));
104void state_save_register_presave(running_machine *machine, state_presave_func func, void *param);
105void state_save_register_postload(running_machine *machine, state_postload_func func, void *param);
93106
94void state_save_register_func_presave_int(void (*func)(int), int param);
95void state_save_register_func_postload_int(void (*func)(int), int param);
96
97void state_save_register_func_presave_ptr(void (*func)(void *), void *param);
98void state_save_register_func_postload_ptr(void (*func)(void *), void *param);
99
100107/* Save and load functions */
101108/* The tags are a hack around the current cpu structures */
102109int  state_save_save_begin(mame_file *file);
src/emu/mconfig.h
r2375r2376
229229
230230#define MDRV_DEVICE_CONFIG_DATAFP32(_struct, _field, _val, _fixbits) \
231231   TOKEN_UINT32_PACK4(MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP32, 8, sizeof(((_struct *)NULL)->_field), 6, _fixbits, 6, offsetof(_struct, _field), 12), \
232   TOKEN_UINT32((UINT32)((float)(_val) * (float)(1 << (_fixbits)))),
232   TOKEN_UINT32((INT32)((float)(_val) * (float)(1 << (_fixbits)))),
233233
234234#define MDRV_DEVICE_CONFIG_DATAFP64(_struct, _field, _val, _fixbits) \
235235   TOKEN_UINT32_PACK4(MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP64, 8, sizeof(((_struct *)NULL)->_field), 6, _fixbits, 6, offsetof(_struct, _field), 12), \
236   TOKEN_UINT64((UINT64)((float)(_val) * (float)((UINT64)1 << (_fixbits)))),
236   TOKEN_UINT64((INT64)((float)(_val) * (float)((UINT64)1 << (_fixbits)))),
237237
238238#ifdef PTR64
239239#define MDRV_DEVICE_CONFIG_DATAPTR(_struct, _field, _val) MDRV_DEVICE_CONFIG_DATA64(_struct, _field, _val)
src/emu/drivers/xtal.h
r2375r2376
9292   XTAL_17_73447MHz   = 17734470,      /* 4 times the PAL subcarrier */
9393   XTAL_18MHz         = 18000000,      /* S.A.R, Ikari Warriors 3 */
9494   XTAL_18_432MHz     = 18432000,      /* Extremely common, used on 100's of PCBs */
95   XTAL_19_6608MHz      = 19660800,      /* Euro League (bootleg), labeled as "UKI 19.6608 20PF" */
9596   XTAL_19_923MHz      = 19923000,      /* Cinematronics vectors */
9697   XTAL_19_968MHz     = 19968000,      /* Used mostly by some Taito games */
9798   XTAL_20MHz         = 20000000,
src/lib/util/xmlfile.c
r2375r2376
515515            case '<'  : d += sprintf(d, "&lt;"); break;
516516            case '>'  : d += sprintf(d, "&gt;"); break;
517517            default:
518               if (*string >= ' ' && *string <= '~')
519                  *d++ = *string;
520               else
521                  d += sprintf(d, "&#%d;", (unsigned)(unsigned char)*string);
518               *d++ = *string;
522519         }
523520         ++string;
524521      }
src/mess/devices/coco_fdc.c
r2375r2376
379379
380380static rtc_type_t real_time_clock(void)
381381{
382   return (rtc_type_t) (int) readinputportbytag_safe("real_time_clock", 0x00);
382   return (rtc_type_t) (int) input_port_read_safe(Machine, "real_time_clock", 0x00);
383383}
384384
385385
src/mess/devices/thomflop.c
r2375r2376
17161716   if ( offset == 8 )
17171717   {
17181718      /* network ID of the computer */
1719      UINT8 id = readinputport( THOM_INPUT_FCONFIG ) >> 3;
1719      UINT8 id = input_port_read_indexed(machine, THOM_INPUT_FCONFIG ) >> 3;
17201720      VLOG(( "%f $%04x to7_network_r: read id $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), id ));
17211721      return id;
17221722   }
r2375r2376
17741774
17751775void to7_floppy_reset ( running_machine *machine )
17761776{
1777   to7_controller_type = (readinputport( THOM_INPUT_FCONFIG ) ) & 7;
1777   to7_controller_type = (input_port_read_indexed(machine, THOM_INPUT_FCONFIG ) ) & 7;
17781778
17791779   switch ( to7_controller_type )
17801780   {
src/mess/video/gb.c
r2375r2376
13071307   dst = ((UINT16)(HDMA3 & 0x1F) << 8) | (HDMA4 & 0xF0);
13081308   dst |= 0x8000;
13091309   while( length > 0 ) {
1310      program_write_byte_8( dst++, program_read_byte_8( src++ ) );
1310      program_write_byte( dst++, program_read_byte( src++ ) );
13111311      length--;
13121312   }
13131313   HDMA1 = src >> 8;
r2375r2376
19421942         UINT8 *P = gb_oam;
19431943         offset = (UINT16) data << 8;
19441944         for (data = 0; data < 0xA0; data++)
1945            *P++ = program_read_byte_8 (offset++);
1945            *P++ = program_read_byte (offset++);
19461946      }
19471947      return;
19481948   case 0x07:                  /* BGP - Background Palette */
src/mess/video/m6847.c
r2375r2376
18041804
18051805
18061806
1807static STATE_POSTLOAD( m6847_postload )
1808{
1809   set_field_sync();
1810   set_horizontal_sync();
1811   set_dirty();
1812}
1813
1814
1815
18071816void m6847_init(running_machine *machine, const m6847_config *cfg)
18081817{
18091818   const m6847_variant *v;
r2375r2376
18901899   timer_adjust_periodic(m6847->fs_rise_timer, attotime_zero, 0, attotime_make(0, frame_period));
18911900
18921901   /* setup save states */
1893   state_save_register_func_postload(set_field_sync);
1894   state_save_register_func_postload(set_horizontal_sync);
1895   state_save_register_func_postload(set_dirty);
1902   state_save_register_postload(machine, m6847_postload, NULL);
18961903
18971904   /* build font */
18981905   build_fontdata(v);
src/mess/video/pc_video.c
r2375r2376
3030
3131/**************************************************************************/
3232
33static void pc_video_postload(void)
33static STATE_POSTLOAD( pc_video_postload )
3434{
3535   pc_anythingdirty = 1;
3636   pc_current_height = -1;
r2375r2376
6464      video_start_generic_bitmapped(machine);
6565   }
6666
67   state_save_register_func_postload(pc_video_postload);
67   state_save_register_postload(machine, pc_video_postload, NULL);
6868   return pc_crtc;
6969}
7070
src/mess/video/oric.c
r2375r2376
298298         }
299299
300300         /* fetch data */
301         c = RAM ? RAM[read_addr] : program_read_byte_8(read_addr);
301         c = RAM ? RAM[read_addr] : program_read_byte(read_addr);
302302
303303         /* if bits 6 and 5 are zero, the byte contains a serial attribute */
304304         if ((c & ((1<<6) | (1<<5)))==0)
src/mess/video/coco3.c
r2375r2376
784784
785785
786786
787static STATE_POSTLOAD( coco3_video_postload )
788{
789   coco3_set_dirty();
790}
791
792
793
787794static void internal_video_start_coco3(running_machine *machine, m6847_type type)
788795{
789796   int i;
r2375r2376
840847   state_save_register_global(video->legacy_video);
841848   state_save_register_global(video->top_border_scanlines);
842849   state_save_register_global(video->display_scanlines);
843   state_save_register_func_postload(coco3_set_dirty);
850   state_save_register_postload(machine, coco3_video_postload, NULL);
844851}
845852
846853
src/mess/inputx.c
r2375r2376
923923
924924
925925
926void inputx_update(void)
926void inputx_update(running_machine *machine)
927927{
928928   const key_buffer *keybuf;
929929   const mess_input_code *code;
r2375r2376
948948            for (i = 0; i < ARRAY_LENGTH(code->ipt) && code->ipt[i]; i++)
949949            {
950950               value = code->ipt[i]->mask;
951               input_port_set_digital_value(code->port[i], value, value);
951               input_port_set_digital_value(machine, code->port[i], value, value);
952952            }
953953         }
954954      }
src/mess/inputx.h
r2375r2376
6161
6262/* these are called by the core; they should not be called from FEs */
6363void inputx_init(running_machine *machine);
64void inputx_update(void);
64void inputx_update(running_machine *machine);
6565void inputx_handle_mess_extensions(input_port_entry *ipt);
6666
6767/* called by drivers to setup natural keyboard support */
src/mess/machine/wswan.c
r2375r2376
669669            dst = ws_portram[0x44] + (ws_portram[0x45] << 8) + (ws_portram[0x43] << 16);
670670            length = ws_portram[0x46] + (ws_portram[0x47] << 8);
671671            for( ; length > 0; length-- ) {
672               program_write_byte_8( dst, program_read_byte_8( src ) );
672               program_write_byte( dst, program_read_byte( src ) );
673673               src++;
674674               dst++;
675675            }
r2375r2376
13751375   /* Handle Sound DMA */
13761376   if ( ( sound_dma.enable & 0x88 ) == 0x80 ) {
13771377      /* TODO: Output sound DMA byte */
1378      wswan_port_w( machine, 0x89, program_read_byte_8( sound_dma.source ) );
1378      wswan_port_w( machine, 0x89, program_read_byte( sound_dma.source ) );
13791379      sound_dma.size--;
13801380      sound_dma.source = ( sound_dma.source + 1 ) & 0x0FFFFF;
13811381      if ( sound_dma.size == 0 ) {
src/mess/machine/pdp1.c
r2375r2376
160160{
161161   int config;
162162
163   config = readinputport(pdp1_config);
163   config = input_port_read_indexed(machine, pdp1_config);
164164   pdp1_reset_param.extend_support = (config >> pdp1_config_extend_bit) & pdp1_config_extend_mask;
165165   pdp1_reset_param.hw_mul_div = (config >> pdp1_config_hw_mul_div_bit) & pdp1_config_hw_mul_div_mask;
166166   pdp1_reset_param.type_20_sbs = (config >> pdp1_config_type_20_sbs_bit) & pdp1_config_type_20_sbs_mask;
r2375r2376
11751175*/
11761176void iot_011(int op2, int nac, int mb, int *io, int ac)
11771177{
1178   int key_state = readinputport(pdp1_spacewar_controllers);
1178   int key_state = input_port_read_indexed(Machine, pdp1_spacewar_controllers);
11791179   int reply;
11801180
11811181
r2375r2376
12601260
12611261
12621262   for (i=0; i<4; i++)
1263      typewriter_keys[i] = readinputport(pdp1_typewriter + i);
1263      typewriter_keys[i] = input_port_read_indexed(machine, pdp1_typewriter + i);
12641264
12651265   for (i=0; i<4; i++)
12661266   {
r2375r2376
12861286
12871287static void pdp1_lightpen(void)
12881288{
1289   running_machine *machine = Machine;
12891290   int x_delta, y_delta;
12901291   int current_state;
12911292   static int previous_state;
12921293
1293   lightpen.active = (readinputport(pdp1_config) >> pdp1_config_lightpen_bit) & pdp1_config_lightpen_mask;
1294   lightpen.active = (input_port_read_indexed(machine, pdp1_config) >> pdp1_config_lightpen_bit) & pdp1_config_lightpen_mask;
12941295
1295   current_state = readinputport(pdp1_lightpen_state);
1296   current_state = input_port_read_indexed(machine, pdp1_lightpen_state);
12961297
12971298   /* update pen down state */
12981299   lightpen.down = lightpen.active && (current_state & pdp1_lightpen_down);
r2375r2376
13141315   previous_state = current_state;
13151316
13161317   /* update pen position */
1317   x_delta = readinputport(pdp1_lightpen_x);
1318   y_delta = readinputport(pdp1_lightpen_y);
1318   x_delta = input_port_read_indexed(machine, pdp1_lightpen_x);
1319   y_delta = input_port_read_indexed(machine, pdp1_lightpen_y);
13191320
13201321   if (x_delta >= 0x80)
13211322      x_delta -= 0x100;
r2375r2376
13551356   int ta_transitions;
13561357
13571358
1358   cpunum_set_reg(0, PDP1_SS, readinputport(pdp1_sense_switches));
1359   cpunum_set_reg(0, PDP1_SS, input_port_read_indexed(machine, pdp1_sense_switches));
13591360
13601361   /* read new state of control keys */
1361   control_keys = readinputport(pdp1_control_switches);
1362   control_keys = input_port_read_indexed(machine, pdp1_control_switches);
13621363
13631364   if (control_keys & pdp1_control)
13641365   {
r2375r2376
14501451
14511452
14521453      /* handle test word keys */
1453      tw_keys = (readinputport(pdp1_tw_switches_MSB) << 16) | readinputport(pdp1_tw_switches_LSB);
1454      tw_keys = (input_port_read_indexed(machine, pdp1_tw_switches_MSB) << 16) | input_port_read_indexed(machine, pdp1_tw_switches_LSB);
14541455
14551456      /* compute transitions */
14561457      tw_transitions = tw_keys & (~ old_tw_keys);
r2375r2376
14631464
14641465
14651466      /* handle address keys */
1466      ta_keys = readinputport(pdp1_ta_switches);
1467      ta_keys = input_port_read_indexed(machine, pdp1_ta_switches);
14671468
14681469      /* compute transitions */
14691470      ta_transitions = ta_keys & (~ old_ta_keys);
src/mess/machine/mac.c
r2375r2376
13341334
13351335
13361336
1337static void mac_state_load(void)
1337static STATE_POSTLOAD( mac_state_load )
13381338{
13391339   int overlay = mac_overlay;
13401340   mac_overlay = -1;
r2375r2376
13701370
13711371   /* save state stuff */
13721372   state_save_register_global(mac_overlay);
1373   state_save_register_func_postload(mac_state_load);
1373   state_save_register_postload(Machine, mac_state_load, NULL);
13741374}
13751375
13761376
src/mess/machine/pokemini.c
r2375r2376
687687            UINT8 tile = pokemini_ram[ 0x360 + ( y * vdp.map_size_x ) + x ];
688688            int i;
689689            for( i = 0; i < 8; i++ ) {
690               pokemini_ram[ ( y * 96 ) + ( x * 8 ) + i ] = program_read_byte_8( vdp.bg_tiles + ( tile * 8 ) + i );
690               pokemini_ram[ ( y * 96 ) + ( x * 8 ) + i ] = program_read_byte( vdp.bg_tiles + ( tile * 8 ) + i );
691691            }
692692         }
693693      }
src/mess/machine/coco.c
r2375r2376
965965{
966966   coco_input_device result = INPUTDEVICE_NA;
967967
968   switch(readinputportbytag_safe("joystick_mode", 0x00))
968   switch(input_port_read_safe(Machine, "joystick_mode", 0x00))
969969   {
970970      case 0x00:
971971         /* "Normal" */
r2375r2376
10411041{
10421042   double val;
10431043
1044   val = readinputportbytag_safe(inputport, 0) / 255.0;
1044   val = input_port_read_safe(Machine, inputport, 0) / 255.0;
10451045
10461046   if (get_input_device(INPUTPORT_RIGHT_JOYSTICK) == INPUTDEVICE_HIRES_CC3MAX_INTERFACE)
10471047   {
r2375r2376
12921292   joystick = mux_sel2;
12931293
12941294   /* poll keyoard keys */
1295   if ((readinputport(0) | pia0_pb) != 0xff) porta &= ~0x01;
1296   if ((readinputport(1) | pia0_pb) != 0xff) porta &= ~0x02;
1297   if ((readinputport(2) | pia0_pb) != 0xff) porta &= ~0x04;
1298   if ((readinputport(3) | pia0_pb) != 0xff) porta &= ~0x08;
1299   if ((readinputport(4) | pia0_pb) != 0xff) porta &= ~0x10;
1300   if ((readinputport(5) | pia0_pb) != 0xff) porta &= ~0x20;
1301   if ((readinputport(6) | pia0_pb) != 0xff) porta &= ~0x40;
1295   if ((input_port_read_indexed(machine, 0) | pia0_pb) != 0xff) porta &= ~0x01;
1296   if ((input_port_read_indexed(machine, 1) | pia0_pb) != 0xff) porta &= ~0x02;
1297   if ((input_port_read_indexed(machine, 2) | pia0_pb) != 0xff) porta &= ~0x04;
1298   if ((input_port_read_indexed(machine, 3) | pia0_pb) != 0xff) porta &= ~0x08;
1299   if ((input_port_read_indexed(machine, 4) | pia0_pb) != 0xff) porta &= ~0x10;
1300   if ((input_port_read_indexed(machine, 5) | pia0_pb) != 0xff) porta &= ~0x20;
1301   if ((input_port_read_indexed(machine, 6) | pia0_pb) != 0xff) porta &= ~0x40;
13021302
1303   if ((readinputport(0) | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x01;
1304   if ((readinputport(1) | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x02;
1305   if ((readinputport(2) | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x04;
1306   if ((readinputport(3) | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x08;
1307   if ((readinputport(4) | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x10;
1308   if ((readinputport(5) | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x20;
1309   if ((readinputport(6) | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x40;
1303   if ((input_port_read_indexed(machine, 0) | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x01;
1304   if ((input_port_read_indexed(machine, 1) | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x02;
1305   if ((input_port_read_indexed(machine, 2) | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x04;
1306   if ((input_port_read_indexed(machine, 3) | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x08;
1307   if ((input_port_read_indexed(machine, 4) | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x10;
1308   if ((input_port_read_indexed(machine, 5) | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x20;
1309   if ((input_port_read_indexed(machine, 6) | pia_get_port_b_z_mask(0)) != 0xff) port_za &= ~0x40;
13101310
13111311   switch(get_input_device(joystick ? INPUTPORT_LEFT_JOYSTICK : INPUTPORT_RIGHT_JOYSTICK))
13121312   {
13131313      case INPUTDEVICE_RIGHT_JOYSTICK:
1314         joyval = readinputportbytag_safe(joystick_axis ? "joystick_right_y" : "joystick_right_x", 0x00);
1314         joyval = input_port_read_safe(machine, joystick_axis ? "joystick_right_y" : "joystick_right_x", 0x00);
13151315         if (dac <= joyval)
13161316            porta |= 0x80;
13171317         break;
13181318
13191319      case INPUTDEVICE_LEFT_JOYSTICK:
1320         joyval = readinputportbytag_safe(joystick_axis ? "joystick_left_y" : "joystick_left_x", 0x00);
1320         joyval = input_port_read_safe(machine, joystick_axis ? "joystick_left_y" : "joystick_left_x", 0x00);
13211321         if (dac <= joyval)
13221322            porta |= 0x80;
13231323         break;
r2375r2376
13291329         break;
13301330
13311331      case INPUTDEVICE_RAT:
1332         joyval = readinputportbytag_safe(joystick_axis ? "rat_mouse_y" : "rat_mouse_x", 0x00);
1332         joyval = input_port_read_safe(machine, joystick_axis ? "rat_mouse_y" : "rat_mouse_x", 0x00);
13331333         if ((dac >> 2) <= joy_rat_table[joyval])
13341334            porta |= 0x80;
13351335         break;
13361336
13371337      case INPUTDEVICE_DIECOM_LIGHTGUN:
1338         if( (video_screen_get_vpos(machine->primary_screen) == readinputportbytag_safe("dclg_y", 0)) )
1338         if( (video_screen_get_vpos(machine->primary_screen) == input_port_read_safe(machine, "dclg_y", 0)) )
13391339         {
13401340            /* If gun is pointing at the current scan line, set hit bit and cache horizontal timer value */
13411341            dclg_output_h |= 0x02;
1342            dclg_timer = readinputportbytag_safe("dclg_x", 0) << 1;
1342            dclg_timer = input_port_read_safe(machine, "dclg_x", 0) << 1;
13431343         }
13441344
13451345         if ( (dac >> 2) <= dclg_table[ (joystick_axis ? dclg_output_h : dclg_output_v) & 0x03 ])
r2375r2376
13481348         if( (dclg_state == 7) )
13491349         {
13501350            /* While in state 7, prepare to chech next video frame for a hit */
1351            dclg_time = video_screen_get_time_until_pos(machine->primary_screen, readinputportbytag_safe("dclg_y", 0), 0);
1351            dclg_time = video_screen_get_time_until_pos(machine->primary_screen, input_port_read_safe(machine, "dclg_y", 0), 0);
13521352         }
13531353
13541354         break;
r2375r2376
13741374   }
13751375
13761376   /* sample joystick buttons */
1377   porta &= ~readinputportbytag_safe("joystick_buttons", 0);
1378   port_za &= ~readinputportbytag_safe("joystick_buttons", 0);
1377   porta &= ~input_port_read_safe(machine, "joystick_buttons", 0);
1378   port_za &= ~input_port_read_safe(machine, "joystick_buttons", 0);
13791379
13801380   pia_set_input_a(0, porta, port_za);
13811381   return porta;
r2375r2376
30523052   coco3_mmu_update(0, 8);
30533053}
30543054
3055static void coco3_state_postload(void)
3055static STATE_POSTLOAD( coco3_state_postload )
30563056{
30573057   coco3_mmu_update(0, 8);
30583058}
30593059
30603060static void update_lightgun(running_machine *machine)
30613061{
3062   int is_lightgun = readinputportbytag_safe("joystick_mode", 0x00) == 0x40;
3062   int is_lightgun = input_port_read_safe(machine, "joystick_mode", 0x00) == 0x40;
30633063   crosshair_set_screen(machine, 0, is_lightgun ? CROSSHAIR_SCREEN_ALL : CROSSHAIR_SCREEN_NONE);
30643064}
30653065
r2375r2376
31053105   state_save_register_global(coco3_interupt_line);
31063106   state_save_register_global(gime_irq);
31073107   state_save_register_global(gime_firq);
3108   state_save_register_func_postload(coco3_state_postload);
3108   state_save_register_postload(machine, coco3_state_postload, NULL);
31093109
31103110   /* need to specify lightgun crosshairs */
31113111   timer_set(attotime_zero, NULL, 0, update_lightgun_timer_callback);
src/mess/machine/nes_mmc.c
r2375r2376
42484248   if(0==(offset&0x7FFF))
42494249      return;
42504250
4251   data = data|(program_read_byte_8(offset)&1);
4251   data = data|(program_read_byte(offset)&1);
42524252
42534253   /* Switch 8k VROM bank */
42544254   chr8 (data >> 4);
src/mess/machine/thomson.c
r2375r2376
322322
323323
324324
325static STATE_POSTLOAD( to7_update_cart_bank_postload )
326{
327   to7_update_cart_bank();
328}
329
330
331
325332/* write signal to 0000-1fff generates a bank switch */
326333WRITE8_HANDLER ( to7_cartridge_w )
327334{
r2375r2376
13271334   state_save_register_global( to7_lightpen );
13281335   state_save_register_global( to7_lightpen_step );
13291336   state_save_register_global_pointer( (mem + 0x10000), 0x10000 );
1330   state_save_register_func_postload( to7_update_cart_bank );
1337   state_save_register_postload(machine, to7_update_cart_bank_postload, NULL );
13311338}
13321339
13331340
r2375r2376
13951402
13961403
13971404
1405static STATE_POSTLOAD ( to770_update_ram_bank_postload )
1406{
1407   to770_update_ram_bank();
1408}
1409
1410
1411
13981412static WRITE8_HANDLER ( to770_sys_portb_out )
13991413{
14001414   to770_update_ram_bank();
r2375r2376
15451559   state_save_register_global( to7_lightpen );
15461560   state_save_register_global( to7_lightpen_step );
15471561   state_save_register_global_pointer( (mem + 0x10000), 0x10000 );
1548   state_save_register_func_postload( to770_update_ram_bank );
1549   state_save_register_func_postload( to7_update_cart_bank );
1562   state_save_register_postload(machine,  to770_update_ram_bank_postload, NULL );
1563   state_save_register_postload(machine,  to7_update_cart_bank_postload, NULL );
15501564}
15511565
15521566
r2375r2376
17881802
17891803
17901804
1805static STATE_POSTLOAD( mo5_update_cart_bank_postload )
1806{
1807   mo5_update_cart_bank();
1808}
1809
1810
1811
17911812/* write signal to b000-cfff generates a bank switch */
17921813WRITE8_HANDLER ( mo5_cartridge_w )
17931814{
r2375r2376
18951916   state_save_register_global( to7_lightpen_step );
18961917   state_save_register_global( mo5_reg_cart );
18971918   state_save_register_global_pointer( (mem + 0x10000), 0x10000 );
1898   state_save_register_func_postload( mo5_update_cart_bank );
1919   state_save_register_postload(machine, mo5_update_cart_bank_postload, NULL );
18991920}
19001921
19011922
r2375r2376
21472168
21482169
21492170
2171static STATE_POSTLOAD( to9_update_cart_bank_postload )
2172{
2173   to9_update_cart_bank();
2174}
2175
2176
2177
21502178/* write signal to 0000-1fff generates a bank switch */
21512179WRITE8_HANDLER ( to9_cartridge_w )
21522180{
r2375r2376
22172245
22182246
22192247
2248static STATE_POSTLOAD( to9_update_ram_bank_postload )
2249{
2250   to9_update_ram_bank();
2251}
2252
2253
2254
22202255/* ------------ keyboard (6850 ACIA + 6805 CPU) ------------ */
22212256
22222257/* The 6805 chip scans the keyboard and sends ASCII codes to the 6909.
r2375r2376
28352870   state_save_register_global( to7_lightpen_step );
28362871   state_save_register_global( to9_soft_bank );
28372872   state_save_register_global_pointer( (mem + 0x10000), 0x10000 );
2838   state_save_register_func_postload( to9_update_ram_bank );
2839   state_save_register_func_postload( to9_update_cart_bank );
2873   state_save_register_postload(machine,  to9_update_ram_bank_postload, NULL );
2874   state_save_register_postload(machine,  to9_update_cart_bank_postload, NULL );
28402875}
28412876
28422877
r2375r2376
32013236
32023237
32033238
3239static STATE_POSTLOAD( to8_update_floppy_bank_postload )
3240{
3241   to8_update_floppy_bank();
3242}
3243
3244
3245
32043246static void to8_update_ram_bank ( void )
32053247{
32063248   UINT8 bank = 0;
r2375r2376
32573299
32583300
32593301
3302static STATE_POSTLOAD( to8_update_ram_bank_postload )
3303{
3304   to8_update_ram_bank();
3305}
3306
3307
3308
32603309static void to8_update_cart_bank ( void )
32613310{
32623311   static int old_bank = -1;
r2375r2376
33093358
33103359
33113360
3361static STATE_POSTLOAD( to8_update_cart_bank_postload )
3362{
3363   to8_update_cart_bank();
3364}
3365
3366
3367
33123368/* ROM bank switch */
33133369WRITE8_HANDLER ( to8_cartridge_w )
33143370{
r2375r2376
37853841   state_save_register_global( to8_data_vpage );
37863842   state_save_register_global( to8_cart_vpage );
37873843   state_save_register_global_pointer( (mem + 0x10000), 0x10000 );
3788   state_save_register_func_postload( to8_update_ram_bank );
3789   state_save_register_func_postload( to8_update_cart_bank );
3790   state_save_register_func_postload( to8_update_floppy_bank );
3844   state_save_register_postload(machine,  to8_update_ram_bank_postload, NULL );
3845   state_save_register_postload(machine,  to8_update_cart_bank_postload, NULL );
3846   state_save_register_postload(machine,  to8_update_floppy_bank_postload, NULL );
37913847}
37923848
37933849
r2375r2376
39474003   state_save_register_global( to8_data_vpage );
39484004   state_save_register_global( to8_cart_vpage );
39494005   state_save_register_global_pointer( (mem + 0x10000), 0x10000 );
3950   state_save_register_func_postload( to8_update_ram_bank );
3951   state_save_register_func_postload( to8_update_cart_bank );
3952   state_save_register_func_postload( to8_update_floppy_bank );
4006   state_save_register_postload(machine,  to8_update_ram_bank_postload, NULL );
4007   state_save_register_postload(machine,  to8_update_cart_bank_postload, NULL );
4008   state_save_register_postload(machine,  to8_update_floppy_bank_postload, NULL );
39534009}
39544010
39554011
r2375r2376
39794035
39804036
39814037
4038static STATE_POSTLOAD( mo6_update_ram_bank_postload )
4039{
4040   mo6_update_ram_bank();
4041}
4042
4043
4044
39824045static void mo6_update_cart_bank ( void )
39834046{
39844047   int b = (pia_get_output_a( THOM_PIA_SYS ) >> 5) & 1;
r2375r2376
40564119
40574120
40584121
4122static STATE_POSTLOAD( mo6_update_cart_bank_postload )
4123{
4124   mo6_update_cart_bank();
4125}
4126
4127
4128
40594129/* write signal generates a bank switch */
40604130WRITE8_HANDLER ( mo6_cartridge_w )
40614131{
r2375r2376
45154585   state_save_register_global( to8_cart_vpage );
45164586   state_save_register_global( mo5_reg_cart );
45174587   state_save_register_global_pointer( (mem + 0x10000), 0x10000 );
4518   state_save_register_func_postload( mo6_update_ram_bank );
4519   state_save_register_func_postload( mo6_update_cart_bank );
4588   state_save_register_postload(machine,  mo6_update_ram_bank_postload, NULL );
4589   state_save_register_postload(machine,  mo6_update_cart_bank_postload, NULL );
45204590}
45214591
45224592
r2375r2376
47824852   state_save_register_global( to8_cart_vpage );
47834853   state_save_register_global( mo5_reg_cart );
47844854   state_save_register_global_pointer( (mem + 0x10000), 0x10000 );
4785   state_save_register_func_postload( mo6_update_ram_bank );
4786   state_save_register_func_postload( mo6_update_cart_bank );
4855   state_save_register_postload(machine,  mo6_update_ram_bank_postload, NULL );
4856   state_save_register_postload(machine,  mo6_update_cart_bank_postload, NULL );
47874857}
src/mess/machine/lynx.c
r2375r2376
12061206#endif
12071207}
12081208
1209static void lynx_postload(void)
1209static STATE_POSTLOAD( lynx_postload )
12101210{
12111211   lynx_memory_config_w(Machine, 0, lynx_memory_config);
12121212}
r2375r2376
12151215{
12161216   state_save_register_global(lynx_memory_config);
12171217   state_save_register_global_pointer(lynx_mem_fe00, lynx_mem_fe00_size);
1218   state_save_register_func_postload(lynx_postload);
1218   state_save_register_postload(machine, lynx_postload, NULL);
12191219
12201220   memory_configure_bank(3, 0, 1, memory_region(REGION_CPU1) + 0x0000, 0);
12211221   memory_configure_bank(3, 1, 1, lynx_mem_fe00, 0);
src/mess/machine/spectrum.c
r2375r2376
305305   {
306306      sp_reg = cpunum_get_reg(0, Z80_SP);
307307      return_addr =
308         ((UINT16) program_read_byte_8(sp_reg + 0) ) >> 8 |
309         ((UINT16) program_read_byte_8(sp_reg + 1) ) >> 0;
308         ((UINT16) program_read_byte(sp_reg + 0) ) >> 8 |
309         ((UINT16) program_read_byte(sp_reg + 1) ) >> 0;
310310
311311      sp_reg += 2;
312312      cpunum_set_reg(0, Z80_SP, (sp_reg & 0x0ffff));
r2375r2376
618618      addr = cpunum_get_reg(0, Z80_SP) & 0xFFFF;
619619
620620      cpunum_set_reg(0, Z80_PC,
621         ((UINT16) program_read_byte_8(addr + 0) ) >> 8 |
622         ((UINT16) program_read_byte_8(addr + 1) ) >> 0);
621         ((UINT16) program_read_byte(addr + 0) ) >> 8 |
622         ((UINT16) program_read_byte(addr + 1) ) >> 0);
623623
624624      addr += 2;
625625      cpunum_set_reg(0, Z80_SP, (addr & 0x0ffff));
src/mess/machine/6883sam.c
r2375r2376
119119
120120
121121
122static STATE_POSTLOAD( update_sam_postload )
123{
124   update_sam();
125}
126
127
128
122129void sam_init(running_machine *machine, const sam6883_interface *intf)
123130{
124131   sam.state = 0;
r2375r2376
130137   /* save state registration */
131138   state_save_register_item("6883sam", 0, sam.state);
132139   state_save_register_item("6883sam", 0, sam.video_position);
133   state_save_register_func_postload(update_sam);
140   state_save_register_postload(machine, update_sam_postload, NULL);
134141}
135142
136143
src/mess/machine/tx0.c
r2375r2376
11201120
11211121
11221122   for (i=0; i<4; i++)
1123      typewriter_keys[i] = readinputport(tx0_typewriter + i);
1123      typewriter_keys[i] = input_port_read_indexed(machine, tx0_typewriter + i);
11241124
11251125   for (i=0; i<4; i++)
11261126   {
r2375r2376
11621162
11631163
11641164   /* read new state of control keys */
1165   control_keys = readinputport(tx0_control_switches);
1165   control_keys = input_port_read_indexed(machine, tx0_control_switches);
11661166
11671167   if (control_keys & tx0_control)
11681168   {
r2375r2376
12311231
12321232
12331233      /* handle toggle switch register keys */
1234      tsr_keys = (readinputport(tx0_tsr_switches_MSW) << 16) | readinputport(tx0_tsr_switches_LSW);
1234      tsr_keys = (input_port_read_indexed(machine, tx0_tsr_switches_MSW) << 16) | input_port_read_indexed(machine, tx0_tsr_switches_LSW);
12351235
12361236      /* compute transitions */
12371237      tsr_transitions = tsr_keys & (~ old_tsr_keys);
src/mess/machine/nascom1.c
r2375r2376
248248      if (sscanf((char *)line, "%x %x %x %x %x %x %x %x %x %x\010\010\n",
249249         &addr, &b0, &b1, &b2, &b3, &b4, &b5, &b6, &b7, &dummy) == 10)
250250      {
251         program_write_byte_8(addr++, b0);
252         program_write_byte_8(addr++, b1);
253         program_write_byte_8(addr++, b2);
254         program_write_byte_8(addr++, b3);
255         program_write_byte_8(addr++, b4);
256         program_write_byte_8(addr++, b5);
257         program_write_byte_8(addr++, b6);
258         program_write_byte_8(addr++, b7);
251         program_write_byte(addr++, b0);
252         program_write_byte(addr++, b1);
253         program_write_byte(addr++, b2);
254         program_write_byte(addr++, b3);
255         program_write_byte(addr++, b4);
256         program_write_byte(addr++, b5);
257         program_write_byte(addr++, b6);
258         program_write_byte(addr++, b7);
259259      }
260260   }
261261
src/mess/machine/vtech1.c
r2375r2376
208208   switch (header[21])
209209   {
210210   case VZ_BASIC:      /* 0xF0 */
211      program_write_byte_8(0x78a4, start % 256); /* start of basic program */
212      program_write_byte_8(0x78a5, start / 256);
213      program_write_byte_8(0x78f9, end % 256); /* end of basic program */
214      program_write_byte_8(0x78fa, end / 256);
215      program_write_byte_8(0x78fb, end % 256); /* start variable table */
216      program_write_byte_8(0x78fc, end / 256);
217      program_write_byte_8(0x78fd, end % 256); /* start free mem, end variable table */
218      program_write_byte_8(0x78fe, end / 256);
211      program_write_byte(0x78a4, start % 256); /* start of basic program */
212      program_write_byte(0x78a5, start / 256);
213      program_write_byte(0x78f9, end % 256); /* end of basic program */
214      program_write_byte(0x78fa, end / 256);
215      program_write_byte(0x78fb, end % 256); /* start variable table */
216      program_write_byte(0x78fc, end / 256);
217      program_write_byte(0x78fd, end % 256); /* start free mem, end variable table */
218      program_write_byte(0x78fe, end / 256);
219219      popmessage("%s (B)\nsize=%04X : start=%04X : end=%04X",pgmname,size,start,end);
220220      free(pgmname);
221221      break;
222222
223223   case VZ_MCODE:      /* 0xF1 */
224      program_write_byte_8(0x788e, start % 256); /* usr subroutine address */
225      program_write_byte_8(0x788f, start / 256);
224      program_write_byte(0x788e, start % 256); /* usr subroutine address */
225      program_write_byte(0x788f, start / 256);
226226      popmessage("%s (M)\nsize=%04X : start=%04X : end=%04X",pgmname,size,start,end);
227227      free(pgmname);
228228      cpunum_set_reg(0, REG_PC, start);            /* start program */
src/mess/machine/cpm_bios.c
r2375r2376
295295 *****************************************************************************/
296296static void cpm_conout_chr(int data)
297297{
298   io_write_byte_8(BIOS_CONOUT, data);
298   io_write_byte(BIOS_CONOUT, data);
299299}
300300
301301/*****************************************************************************
r2375r2376
650650      break;
651651
652652   case 0x02: /* CSTAT */
653      tmp = io_read_byte_8(BIOS_CONST) & 0xff;
653      tmp = io_read_byte(BIOS_CONST) & 0xff;
654654      af = (af & 0xff) | (tmp << 8);
655655
656656      if (VERBOSE_CONIO)
r2375r2376
658658      break;
659659
660660   case 0x03: /* CONIN */
661      if ( io_read_byte_8(BIOS_CONST) == 0 )
661      if ( io_read_byte(BIOS_CONST) == 0 )
662662      {
663663         activecpu_set_reg( Z80_PC, activecpu_get_reg(Z80_PC) - 2 );
664664         break;
665665      }
666      tmp = io_read_byte_8(BIOS_CONIN) & 0xff;
666      tmp = io_read_byte(BIOS_CONIN) & 0xff;
667667      af = (af & 0xff) | (tmp << 8);
668668      if (VERBOSE_CONIO)
669669         logerror("BIOS 03 console input       A:%02X\n", tmp);
src/mess/machine/trs80.c
r2375r2376
9898         LOG(("cas_copy_callback block ($%02X) %d at $%04X\n", data, block_len, block_ofs));
9999         while( block_len && cas_size )
100100         {
101            program_write_byte_8(block_ofs, cas_buff[offs]);
101            program_write_byte(block_ofs, cas_buff[offs]);
102102            offs++;
103103            block_ofs++;
104104            block_len--;
r2375r2376
178178         LOG(("trs80_cmd_load block ($%02X) %d at $%04X\n", data, block_len, block_ofs));
179179         while( block_len && quickload_size )
180180         {
181            program_write_byte_8(block_ofs, cmd_buff[offs]);
181            program_write_byte(block_ofs, cmd_buff[offs]);
182182            offs++;
183183            block_ofs++;
184184            block_len--;
src/mess/machine/apple2.c
r2375r2376
293293
294294
295295
296static STATE_POSTLOAD( apple2_update_memory_postload )
297{
298   apple2_update_memory();
299}
300
301
302
296303/* -----------------------------------------------------------------------
297304 * Apple II memory map
298305 * ----------------------------------------------------------------------- */
r2375r2376
10631070
10641071   if (offset == 0)
10651072   {
1066      joystick_x1_time = attotime_to_double(timer_get_time()) + x_calibration * readinputportbytag("joystick_1_x");
1067      joystick_y1_time = attotime_to_double(timer_get_time()) + y_calibration * readinputportbytag("joystick_1_y");
1068      joystick_x2_time = attotime_to_double(timer_get_time()) + x_calibration * readinputportbytag("joystick_2_x");
1069      joystick_y2_time = attotime_to_double(timer_get_time()) + y_calibration * readinputportbytag("joystick_2_y");
1073      joystick_x1_time = attotime_to_double(timer_get_time()) + x_calibration * input_port_read(machine, "joystick_1_x");
1074      joystick_y1_time = attotime_to_double(timer_get_time()) + y_calibration * input_port_read(machine, "joystick_1_y");
1075      joystick_x2_time = attotime_to_double(timer_get_time()) + x_calibration * input_port_read(machine, "joystick_2_x");
1076      joystick_y2_time = attotime_to_double(timer_get_time()) + y_calibration * input_port_read(machine, "joystick_2_y");
10701077   }
10711078   return 0;
10721079}
r2375r2376
15321539
15331540   /* state save registers */
15341541   state_save_register_global(a2);
1535   state_save_register_func_postload(apple2_update_memory);
1542   state_save_register_postload(machine, apple2_update_memory_postload, NULL);
15361543
15371544   /* apple2 behaves much better when the default memory is zero */
15381545   memset(mess_ram, 0, mess_ram_size);
src/mess/machine/c64.c
r2375r2376
749749   }
750750   else if (!ultimax)
751751      c64_bankswitch (0);
752   c64_memory[0x000] = program_read_byte_8( 0 );
753   c64_memory[0x001] = program_read_byte_8( 1 );
752   c64_memory[0x000] = program_read_byte( 0 );
753   c64_memory[0x001] = program_read_byte( 1 );
754754}
755755
756756UINT8 c64_m6510_port_read(UINT8 direction)
src/mess/mess.mak
r2375r2376
210210CPUS += TMS7000_EXL
211211CPUS += SM8500
212212CPUS += V30MZ
213#CPUS += CXD8661R
213214#CPUS += SSP1610
214215CPUS += UPD7801
215216CPUS += M68008
src/mess/drivers/cpschngr.c
r2375r2376
130130***************************************************************************/
131131
132132/*    YEAR  NAME      PARENT    COMPAT  MACHINE   INPUT     INIT    CONFIG  COMPANY     FULLNAME */
133CONS( 1995, sfzch,    0,        0,      cps1,     sfzch,    cps1,   NULL,   "Capcom", "CPS Changer (Street Fighter ZERO)" , 0)
133CONS( 1995, sfzch,    0,        0,      cps1_10MHz,     sfzch,    cps1,   NULL,   "Capcom", "CPS Changer (Street Fighter ZERO)" , 0)
134134
src/mess/drivers/apexc.c
r2375r2376
335335
336336
337337   /* read new state of edit keys */
338   edit_keys = (readinputportbytag("data1") << 16) | readinputportbytag("data2");
338   edit_keys = (input_port_read(machine, "data1") << 16) | input_port_read(machine, "data2");
339339
340340   /* toggle data reg according to transitions */
341341   panel_data_reg ^= edit_keys & (~ old_edit_keys);
r2375r2376
345345
346346
347347   /* read new state of control keys */
348   control_keys = readinputportbytag("panel");
348   control_keys = input_port_read(machine, "panel");
349349
350350   /* compute transitions */
351351   control_transitions = control_keys & (~ old_control_keys);
src/mess/drivers/a2600.c
r2375r2376
10451045static READ8_HANDLER(modeFE_switch_r)
10461046{
10471047   modeFE_switch(offset, 0 );
1048   return program_read_byte_8( 0xFE );
1048   return program_read_byte( 0xFE );
10491049}
10501050
10511051static WRITE8_HANDLER(modeFE_switch_w)
10521052{
1053   program_write_byte_8( 0xFE, data );
1053   program_write_byte( 0xFE, data );
10541054   modeFE_switch(offset, 0 );
10551055}
10561056
r2375r2376
13421342   if ( ! ( last_address & 0x1080 ) ) {
13431343      return offset;
13441344   }
1345   last_byte = program_read_byte_8( last_address );
1345   last_byte = program_read_byte( last_address );
13461346   if ( last_byte < 0x80 || last_byte == 0xFF ) {
13471347      return last_byte;
13481348   }
r2375r2376
13501350   if ( ! ( prev_address & 0x1080 ) ) {
13511351      return last_byte;
13521352   }
1353   prev_byte = program_read_byte_8( prev_address );
1353   prev_byte = program_read_byte( prev_address );
13541354   if ( prev_byte == 0xB1 ) {   /* LDA (XX),Y */
1355      return program_read_byte_8( last_byte + 1 );
1355      return program_read_byte( last_byte + 1 );
13561356   }
13571357   return last_byte;
13581358}
src/mess/drivers/bw2.c
r2375r2376
346346   PC3     Not connected
347347   */
348348
349   if (readinputportbytag("RAMCARD") & 0x01)
349   if (input_port_read(machine, "RAMCARD") & 0x01)
350350   {
351351      ramcard_set_banks(data & 0x07);
352352   }
r2375r2376
500500   wd17xx_init(machine, WD_TYPE_2793, bw2_wd17xx_callback, NULL);
501501   wd17xx_set_density(DEN_MFM_LO);
502502
503   if (readinputportbytag("RAMCARD") & 0x01)
503   if (input_port_read(machine, "RAMCARD") & 0x01)
504504   {
505505      // RAMCARD installed
506506     
src/mess/drivers/psx.c
r2375r2376
721721
722722static DRIVER_INIT( psx )
723723{
724   psx_driver_init();
724   psx_driver_init(machine);
725725}
726726
727727static INPUT_PORTS_START( psx )
src/mess/drivers/coupe.c
r2375r2376
144144   UINT8 data = 0xe0;
145145   UINT8 row = ~(offset >> 8);
146146
147   if (row & 0x80) data &= readinputportbytag("keyboard_row_7f") & 0xe0;
148   if (row & 0x40) data &= readinputportbytag("keyboard_row_bf") & 0xe0;
149   if (row & 0x20) data &= readinputportbytag("keyboard_row_df") & 0xe0;
150   if (row & 0x10) data &= readinputportbytag("keyboard_row_ef") & 0xe0;
151   if (row & 0x08) data &= readinputportbytag("keyboard_row_f7") & 0xe0;
152   if (row & 0x04) data &= readinputportbytag("keyboard_row_fb") & 0xe0;
153   if (row & 0x02) data &= readinputportbytag("keyboard_row_fd") & 0xe0;
154   if (row & 0x01) data &= readinputportbytag("keyboard_row_fe") & 0xe0;
147   if (row & 0x80) data &= input_port_read(machine, "keyboard_row_7f") & 0xe0;
148   if (row & 0x40) data &= input_port_read(machine, "keyboard_row_bf") & 0xe0;
149   if (row & 0x20) data &= input_port_read(machine, "keyboard_row_df") & 0xe0;
150   if (row & 0x10) data &= input_port_read(machine, "keyboard_row_ef") & 0xe0;
151   if (row & 0x08) data &= input_port_read(machine, "keyboard_row_f7") & 0xe0;
152   if (row & 0x04) data &= input_port_read(machine, "keyboard_row_fb") & 0xe0;
153   if (row & 0x02) data &= input_port_read(machine, "keyboard_row_fd") & 0xe0;
154   if (row & 0x01) data &= input_port_read(machine, "keyboard_row_fe") & 0xe0;
155155
156156   return data | coupe_regs.status;
157157}
r2375r2376
222222
223223   if (row == 0)
224224   {
225      data &= readinputportbytag("keyboard_row_ff") & 0x1f;
225      data &= input_port_read(machine, "keyboard_row_ff") & 0x1f;
226226   }
227227   else
228228   {
229      if (row & 0x80) data &= readinputportbytag("keyboard_row_7f") & 0x1f;
230      if (row & 0x40) data &= readinputportbytag("keyboard_row_bf") & 0x1f;
231      if (row & 0x20) data &= readinputportbytag("keyboard_row_df") & 0x1f;
232      if (row & 0x10) data &= readinputportbytag("keyboard_row_ef") & 0x1f;
233      if (row & 0x08) data &= readinputportbytag("keyboard_row_f7") & 0x1f;
234      if (row & 0x04) data &= readinputportbytag("keyboard_row_fb") & 0x1f;
235      if (row & 0x02) data &= readinputportbytag("keyboard_row_fd") & 0x1f;
236      if (row & 0x01) data &= readinputportbytag("keyboard_row_fe") & 0x1f;
229      if (row & 0x80) data &= input_port_read(machine, "keyboard_row_7f") & 0x1f;
230      if (row & 0x40) data &= input_port_read(machine, "keyboard_row_bf") & 0x1f;
231      if (row & 0x20) data &= input_port_read(machine, "keyboard_row_df") & 0x1f;
232      if (row & 0x10) data &= input_port_read(machine, "keyboard_row_ef") & 0x1f;
233      if (row & 0x08) data &= input_port_read(machine, "keyboard_row_f7") & 0x1f;
234      if (row & 0x04) data &= input_port_read(machine, "keyboard_row_fb") & 0x1f;
235      if (row & 0x02) data &= input_port_read(machine, "keyboard_row_fd") & 0x1f;
236      if (row & 0x01) data &= input_port_read(machine, "keyboard_row_fe") & 0x1f;
237237   }
238238
239239   return data | 0xe0;
docs/messnew.txt
r2375r2376
7373
7474Source Changes:
7575----------------
76- The core is based on MAME 0.124u1.  This incorporates all features of the
76- The core is based on MAME 0.124u2.  This incorporates all features of the
7777  update to this core.  [MAME team]
7878
7979- Major changes to transition MESS's device system onto MAME's device system.

Previous 15994 Revisions Next


© 1998-2018 The MESS Team