Previous 15994 Revisions Next

r6741 Friday 25th December, 2009 at 04:22:44 UTC by Nathan Woods
Updated to MAME 0.135u4 core
[ROOT]makefile
[docs]messnew.txt
[src/emu]clifront.c clifront.h deprecat.h drawgfx.c drawgfx.h emu.mak inptport.c inptport.h mame.c mame.h memory.c profiler.c profiler.h restrack.c restrack.h romload.c state.c state.h tilemap.c tilemap.h timer.c video.c
[src/emu/cpu]cpu.mak drcbec.c drcbex64.c drcbex86.c drcuml.c drcuml.h drcumlsh.h x86emit.h
[src/emu/cpu/i386]i386op16.c
[src/emu/cpu/mips]mips3drc.c
[src/emu/cpu/pic16c62x]16c62xdsm.c* dis16c62x.c* pic16c62x.c* pic16c62x.h*
[src/emu/cpu/powerpc]ppcdrc.c
[src/emu/cpu/rsp]rspdrc.c rspfe.c
[src/emu/cpu/sh2]sh2drc.c
[src/emu/cpu/v810]v810.c
[src/emu/cpu/z180]z180.c
[src/emu/debug]debugvw.c
[src/emu/machine]68681.c 74148.c 74148.h 74153.c 74153.h 7474.c 7474.h 8237dma.c ds2404.c ds2404.h eepromdev.c intelfsh.c mb14241.c* mb14241.h* rtc65271.c rtc65271.h tmp68301.c tmp68301.h
[src/emu/sound]cdp1864.c disc_inp.c discrete.h fm.c fm2612.c ics2115.c k056800.c* k056800.h* sound.mak tms5110.c
[src/emu/video]generic.c mc6845.c s2636.c saa5050.c v9938.c
[src/lib/util]pool.c
[src/mame]mame.mak mamedriv.c
[src/mame/audio]8080bw.c atarifb.c avalnche.c aztarac.c bsktball.c bzone.c cage.c canyon.c cchasm.c cinemat.c circus.c crbaloon.c dcs.c dkong.c dragrace.c exidy.c exidy440.c firetrk.c galaga.c grchamp.c gridlee.c harddriv.c hitme.c jaguar.c jedi.c leland.c llander.c m72.c m72.h m79amb.c madalien.c meadows.c mw8080bw.c n8080.c nitedrvr.c norautp.c orbit.c phoenix.c polepos.c poolshrk.c qix.c redalert.c redbaron.c scramble.c segag80r.c segag80v.c segasnd.c skydiver.c skyraid.c snk6502.c sprint2.c sprint4.c sprint8.c starshp1.c subs.c taito_en.c taito_en.h tank8.c targ.c triplhnt.c turbo.c vicdual.c videopin.c
[src/mame/drivers]1942.c 1943.c 20pacgal.c 4roses.c 8080bw.c 88games.c acefruit.c actfancr.c aeroboto.c airbustr.c ajax.c aleck64.c aliens.c amaticmg.c ambush.c angelkds.c appoooh.c arabian.c arcadecl.c arkanoid.c artmagic.c ashnojoe.c asterix.c asteroid.c astrof.c asuka.c atarifb.c atarig1.c atarig42.c atarigt.c atarigx2.c atarisy1.c atarisy2.c ataxx.c atetris.c avalnche.c aztarac.c backfire.c badlands.c bagman.c balsente.c bankp.c batman.c battlane.c battlex.c battlnts.c beathead.c berzerk.c bfcobra.c bionicc.c bishi.c bishjan.c bladestl.c blktiger.c blmbycar.c blockhl.c blockout.c bloodbro.c blstroid.c blueprnt.c bmcbowl.c bogeyman.c bombjack.c boogwing.c bottom9.c brkthru.c bsktball.c btoads.c bwing.c bzone.c calomega.c canyon.c capbowl.c cardline.c carjmbre.c carpolo.c carrera.c cave.c cb2001.c cbasebal.c cbuster.c ccastles.c cchasm.c centiped.c champbas.c cheekyms.c chihiro.c chinagat.c chinsan.c chqflag.c cidelsa.c cinemat.c circus.c circusc.c cischeat.c citycon.c cloud9.c cninja.c cojag.c combatsc.c commando.c compgolf.c contra.c coolpool.c coolridr.c cop01.c copsnrob.c cosmic.c cowrace.c cps1.c cps2.c crbaloon.c crgolf.c crimfght.c crospang.c crshrace.c cvs.c cyberbal.c dambustr.c darkhors.c dassault.c dblewing.c dbz.c dcheese.c dday.c ddragon.c ddragon3.c dec0.c deco156.c deco32.c deco_mlc.c deniam.c dietgo.c djboy.c djmain.c dogfgt.c dragrace.c dribling.c drmicro.c eolith.c eolith16.c epos.c eprom.c equites.c esd16.c espial.c esripsys.c exedexes.c exerion.c exidy.c exidy440.c exprraid.c exterm.c exzisus.c f1gp.c fantland.c fastfred.c fastlane.c fcombat.c fcrash.c fgoal.c finalizr.c firebeat.c firetrap.c firetrk.c flkatck.c foodf.c freekick.c funkybee.c funkyjet.c funworld.c funybubl.c fuukifg2.c fuukifg3.c gaelco3d.c gaiden.c gal3.c galaga.c galastrm.c galaxia.c galaxian.c galaxold.c galpani2.c galpani3.c gameplan.c gauntlet.c gbusters.c gei.c ggconnie.c gijoe.c goldnpkr.c goldstar.c gomoku.c gottlieb.c gradius3.c grchamp.c gridlee.c groundfx.c gstriker.c gticlub.c gunbustr.c halleys.c harddriv.c hcastle.c hexa.c hexion.c hitpoker.c hng64.c homedata.c hornet.c hvyunit.c hyhoo.c iqblock.c irobot.c itech32.c itech8.c janshi.c jchan.c jedi.c jokrwild.c jpmimpct.c jrpacman.c klax.c koftball.c koikoi.c konamigq.c konamigv.c konamigx.c labyrunr.c laserbat.c leland.c lethal.c lethalj.c liberate.c liberatr.c lockon.c lordgun.c luckgrln.c lvcards.c m10.c m107.c m52.c m57.c m58.c m62.c m72.c m79amb.c m90.c m92.c macs.c madalien.c magicfly.c mainevt.c mainsnk.c malzak.c mario.c matmania.c maxaflex.c mcr.c mcr3.c mcr68.c meadows.c mediagx.c megadriv.c megadriv.h megasys1.c megazone.c merit.c mermaid.c metro.c mhavoc.c midtunit.c midvunit.c midwunit.c midxunit.c midyunit.c midzeus.c mikie.c miniboy7.c mirage.c mirax.c mitchell.c model1.c model2.c mogura.c moo.c mouser.c mrjong.c mw8080bw.c mystston.c mystwarr.c namcofl.c namcoic.c namcona1.c namconb1.c namcond1.c namcos2.c namcos21.c namcos22.c naomi.c nbmj8688.c nbmj8891.c nbmj8900.c nbmj8991.c nbmj9195.c nemesis.c neodrvr.c neogeo.c news.c ninjakd2.c ninjaw.c nitedrvr.c niyanpai.c norautp.c nova2001.c nwk-tr.c offtwall.c olibochu.c opwolf.c orbit.c othunder.c overdriv.c pacman.c pandoras.c paradise.c parodius.c pastelg.c pbaction.c pengo.c pgm.c phoenix.c pingpong.c pirates.c pkscram.c pktgaldx.c plygonet.c polepos.c policetr.c polyplay.c poolshrk.c popeye.c popper.c psikyo.c psikyo4.c psikyosh.c qix.c quasar.c rainbow.c rampart.c rastan.c realbrk.c redalert.c relief.c rmhaihai.c rockrage.c rohga.c rollerg.c rollrace.c rungun.c sbowling.c scobra.c scotrsht.c scramble.c segac2.c segag80r.c segag80v.c segahang.c segamsys.c segaorun.c segas16a.c segas16b.c segas18.c segas24.c segas32.c segaxbd.c segaybd.c seibuspi.c seicross.c seta.c seta2.c sf.c shaolins.c shisen.c shuuz.c sidearms.c sidepckt.c simpl156.c simpsons.c skullxbo.c skyarmy.c skydiver.c skyraid.c slapfght.c sliver.c sms.c snk.c snk6502.c snookr10.c solomon.c spacefb.c spcforce.c speedatk.c speglsht.c spiders.c spool99.c sprint2.c sprint8.c spy.c srmp5.c ssozumo.c sspeedr.c ssv.c st0016.c stactics.c starwars.c stv.c subs.c subsino.c suna8.c supbtime.c superchs.c suprnova.c suprridr.c suprslam.c surpratk.c system16.c tagteam.c tail2nos.c taito_b.c taito_f2.c taito_f3.c taito_h.c taito_l.c taito_x.c taito_z.c taitoair.c taitojc.c tank8.c tankbust.c tatsumi.c tattack.c taxidrvr.c tceptor.c tecmosys.c tehkanwc.c thedeep.c thunderj.c thunderx.c tickee.c tmnt.c tnzs.c toaplan1.c toaplan2.c toobin.c topspeed.c toratora.c tourtabl.c tp84.c triforce.c triplhnt.c trucocl.c trvmadns.c trvquest.c tsamurai.c tubep.c tumbleb.c tumblep.c turbo.c twin16.c twincobr.c twinkle.c tx1.c ultraman.c ultratnk.c ultrsprt.c undrfire.c unico.c vaportra.c vegaeo.c vendetta.c vertigo.c vicdual.c victory.c videopin.c videopkr.c vigilant.c vindictr.c volfied.c vroulet.c wardner.c warpwarp.c warriorb.c wecleman.c wgp.c wheelfir.c williams.c wiping.c wiz.c wwfwfest.c xexex.c xmen.c xtheball.c xybots.c yunsun16.c zerozone.c zr107.c
[src/mame/includes]88games.h* airbustr.h* atarisy1.h bagman.h balsente.h battlnts.h* beathead.h bladestl.h* carpolo.h cbasebal.h* combatsc.h* contra.h* cps1.h crshrace.h cvs.h djboy.h* f1gp.h fastlane.h* fgoal.h flkatck.h* foodf.h galaga.h galaxold.h gameplan.h harddriv.h hcastle.h* hng64.h irobot.h jaguar.h labyrunr.h* malzak.h* matmania.h mhavoc.h mitchell.h* model1.h mw8080bw.h neogeo.h nitedrvr.h pacman.h pgm.h psikyo.h* psikyo4.h* psikyosh.h rockrage.h* sf.h* simpsons.h slapfght.h snk6502.h suprslam.h* timeplt.h tmnt.h vertigo.h williams.h wiping.h xmen.h xybots.h
[src/mame/machine]acitya.c ajax.c arkanoid.c asteroid.c atarifb.c atarigen.c atarigen.h balsente.c bsktball.c carpolo.c cchasm.c copsnrob.c cps2crpt.c dc.c dec0.c deco102.c decocrpt.c decoprot.c galaxold.c harddriv.c irobot.c konamigx.c leland.c mcr.c mhavoc.c midtunit.c midwunit.c midyunit.c model1.c mw8080bw.c n64.c namcond1.c naomibd.c nb1413m3.c neoboot.c neocrypt.c neoprot.c nitedrvr.c pgmprot.c qix.c segag80.c segas24.c segas32.c simpsons.c slapstic.c slikshot.c snes.c starwars.c stvcd.c stvcd.h subs.c system16.c tatsumi.c tecmosys.c theglobp.c ticket.c ticket.h twincobr.c tx1.c vertigo.c williams.c wrally.c xevious.c
[src/mame/video]1942.c 1943.c 20pacgal.c 8080bw.c 88games.c actfancr.c aeroboto.c airbustr.c ajax.c aliens.c ambush.c angelkds.c appoooh.c arabian.c arcadecl.c artmagic.c ashnojoe.c asterix.c atarig1.c atarig42.c atarigt.c atarigx2.c atarimo.c atarisy1.c atarisy2.c atetris.c aztarac.c badlands.c bagman.c balsente.c bankp.c batman.c battlane.c battlex.c battlnts.c beathead.c bionicc.c bishi.c bladestl.c blktiger.c blmbycar.c blockhl.c blockout.c blstroid.c blueprnt.c bogeyman.c bombjack.c boogwing.c bottom9.c brkthru.c bsktball.c btoads.c bwing.c calomega.c capbowl.c carjmbre.c carpolo.c cave.c cbasebal.c cbuster.c ccastles.c cchasm.c centiped.c champbas.c cheekyms.c chqflag.c cidelsa.c cinemat.c circus.c circusc.c cischeat.c citycon.c cloak.c cloud9.c cninja.c combatsc.c commando.c compgolf.c contra.c cop01.c copsnrob.c cosmic.c cps1.c crgolf.c crimfght.c crospang.c crshrace.c cvs.c cyberbal.c dassault.c dbz.c dc.c dcheese.c dday.c ddragon.c ddragon3.c deco16ic.c deco32.c deniam.c dietgo.c djboy.c djmain.c dogfgt.c dribling.c drmicro.c epos.c eprom.c equites.c esd16.c esripsys.c exedexes.c exerion.c exidy.c exidy440.c exprraid.c exterm.c f1gp.c fastfred.c fastlane.c fcombat.c finalizr.c firetrap.c firetrk.c flkatck.c foodf.c freekick.c funkybee.c funkyjet.c funworld.c funybubl.c fuukifg2.c fuukifg3.c gaelco.c gaelco3d.c gaiden.c galpani2.c gameplan.c gauntlet.c gbusters.c genesis.c gijoe.c goldstar.c gottlieb.c gradius3.c gstriker.c harddriv.c hcastle.c hexa.c hng64.c homedata.c hyhoo.c iqblock.c irobot.c itech32.c itech8.c jedi.c jpmimpct.c kaneko16.c klax.c konamigx.c konicdev.c* konicdev.h* labyrunr.c leland.c lethal.c lethalj.c liberate.c liberatr.c lockon.c lordgun.c lvcards.c m10.c m107.c m72.c madalien.c mainevt.c malzak.c matmania.c mcr.c mcr3.c mcr68.c meadows.c megasys1.c megazone.c mermaid.c metro.c midtunit.c midvunit.c midyunit.c mikie.c mitchell.c moo.c mouser.c mrjong.c mw8080bw.c mystston.c mystwarr.c n64.c namcofl.c namcona1.c namconb1.c namcos2.c namcos21.c namcos22.c nbmj8688.c nbmj8891.c nbmj8900.c nbmj8991.c neogeo.c news.c ninjakd2.c nova2001.c offtwall.c overdriv.c pacman.c pandoras.c paradise.c parodius.c pastelg.c pbaction.c pgm.c phoenix.c pingpong.c pktgaldx.c plygonet.c policetr.c popeye.c popper.c psikyo.c psikyo4.c psikyosh.c psx.c qix.c quasar.c rallyx.c rampart.c rdpupd16.c realbrk.c redalert.c relief.c rockrage.c rohga.c rollerg.c rollrace.c rungun.c scotrsht.c segag80r.c segas32.c seicross.c seta.c seta2.c sf.c shaolins.c shuuz.c sidearms.c sidepckt.c simpl156.c simpsons.c skydiver.c slapfght.c snes.c snk.c snk6502.c snookr10.c solomon.c spacefb.c spcforce.c speedatk.c spy.c ssozumo.c ssv.c st0016.c stactics.c starfire.c stvvdp2.c subs.c supbtime.c suprridr.c suprslam.c surpratk.c system16.c tagteam.c tail2nos.c taito_f3.c tank8.c tankbust.c tatsumi.c taxidrvr.c tceptor.c tehkanwc.c thedeep.c thunderx.c tmnt.c toaplan1.c toobin.c triplhnt.c trucocl.c tsamurai.c tumblep.c turbo.c twincobr.c tx1.c ultraman.c ultratnk.c unico.c vaportra.c vendetta.c vertigo.c victory.c vindictr.c warpwarp.c wecleman.c williams.c wiping.c xexex.c xmen.c ygv608.c yunsun16.c zerozone.c
[src/mess]mess.mak
[src/mess/drivers]aquarius.c cgenie.c geneve.c jaguar.c ng_aes.c ti99_4p.c ti99_4x.c ti99_8.c x1.c
[src/mess/includes]aquarius.h cgenie.h geneve.h mz700.h
[src/mess/machine]99_ide.c cgenie.c geneve.c mz700.c super80.c ti99_4x.c ti99_4x.h
[src/mess/video]aquarius.c cgenie.c mbee.c mz700.c super80.c
[src/osd/windows]winmain.c winmain.h winwork.c
[src/tools]src2html.c srcclean.c unidasm.c

src/mame/audio/cchasm.c
r6740r6741
88#include "streams.h"
99#include "cpu/z80/z80.h"
1010#include "machine/z80ctc.h"
11#include "cchasm.h"
11#include "includes/cchasm.h"
1212#include "sound/ay8910.h"
1313#include "sound/dac.h"
1414
src/mame/audio/skydiver.c
r6740r6741
44
55*************************************************************************/
66#include "driver.h"
7#include "skydiver.h"
7#include "includes/skydiver.h"
88#include "sound/discrete.h"
99
1010
r6740r6741
123123   /* frequency, then decays at the rate set by    */
124124   /* a 68k resistor and 22uf capacitor.           */
125125   /************************************************/
126   DISCRETE_ADJUSTMENT_TAG(NODE_30, 250000, 50000, DISC_LINADJ, "WHISTLE1")   /* R66 */
126   DISCRETE_ADJUSTMENT(NODE_30, 250000, 50000, DISC_LINADJ, "WHISTLE1")   /* R66 */
127127   DISCRETE_MULTADD(NODE_31, SKYDIVER_WHISTLE1_EN, 3.05-0.33, 0.33)
128128   DISCRETE_RCDISC2(NODE_32, SKYDIVER_WHISTLE1_EN, NODE_31, 1.0, NODE_31, 68000.0, 2.2e-5)   /* CV */
129129   DISCRETE_SWITCH(NODE_33, 1, SKYDIVER_OCT1_EN, 1e-8, 1e-8 + 3.3e-9)   /* Cap C73 & C58 */
130130   DISCRETE_555_ASTABLE_CV(NODE_34, SKYDIVER_WHISTLE1_EN, 100000, NODE_30, NODE_33, NODE_32, &skydiverWhistl555)
131131   DISCRETE_MULTIPLY(SKYDIVER_WHISTLE1_SND, NODE_34, 228.5/3.3)
132132
133   DISCRETE_ADJUSTMENT_TAG(NODE_35, 250000, 50000, DISC_LINADJ, "WHISTLE2")   /* R65 */
133   DISCRETE_ADJUSTMENT(NODE_35, 250000, 50000, DISC_LINADJ, "WHISTLE2")   /* R65 */
134134   DISCRETE_MULTADD(NODE_36, SKYDIVER_WHISTLE2_EN, 3.05-0.33, 0.33)
135135   DISCRETE_RCDISC2(NODE_37, SKYDIVER_WHISTLE2_EN, NODE_36, 1.0, NODE_36, 68000.0, 2.2e-5)   /* CV */
136136   DISCRETE_SWITCH(NODE_38, 1, SKYDIVER_OCT2_EN, 1e-8, 1e-8 + 3.3e-9)   /* Cap C72 & C59 */
src/mame/audio/qix.c
r6740r6741
77#include "driver.h"
88#include "cpu/m6800/m6800.h"
99#include "cpu/m6809/m6809.h"
10#include "qix.h"
10#include "includes/qix.h"
1111#include "sound/sn76496.h"
1212#include "sound/discrete.h"
1313
src/mame/audio/jaguar.c
r6740r6741
166166static UINT16 dsp_regs[DSP_REGS];
167167
168168static UINT16 serial_frequency;
169static emu_timer *serial_timer;
170169
171170static UINT8 gpu_irq_state;
172171
173172#if ENABLE_SPEEDUP_HACKS
174
175static TIMER_CALLBACK( serial_chunky_callback );
176173static WRITE32_HANDLER( dsp_flags_w );
177
178#else
179
180static TIMER_CALLBACK( serial_callback );
181
182174#endif
183175
184176
r6740r6741
278270
279271/*************************************
280272 *
281 *  Sound reset
282 *
283 *************************************/
284
285void cojag_sound_reset(running_machine *machine)
286{
287#if ENABLE_SPEEDUP_HACKS
288   serial_timer = timer_alloc(machine, serial_chunky_callback, NULL);
289#else
290   serial_timer = timer_alloc(machine, serial_callback, NULL);
291#endif
292}
293
294
295
296/*************************************
297 *
298273 *  Jerry 16-bit register access
299274 *
300275 *************************************/
r6740r6741
390365
391366#if ENABLE_SPEEDUP_HACKS
392367
393static TIMER_CALLBACK( serial_chunky_callback )
368TIMER_DEVICE_CALLBACK( jaguar_serial_callback )
394369{
395370   /* assert the A2S IRQ on CPU #2 (DSP) */
396   cputag_set_input_line(machine, "audiocpu", 1, ASSERT_LINE);
397   jaguar_dsp_resume(machine);
371   cputag_set_input_line(timer->machine, "audiocpu", 1, ASSERT_LINE);
372   jaguar_dsp_resume(timer->machine);
398373
399374   /* fix flaky code in interrupt handler which thwarts our speedup */
400375   if ((jaguar_dsp_ram[0x3e/4] & 0xffff) == 0xbfbc &&
r6740r6741
409384
410385#else
411386
412static TIMER_CALLBACK( serial_callback )
387TIMER_DEVICE_CALLBACK( jaguar_serial_callback )
413388{
414389   /* assert the A2S IRQ on CPU #2 (DSP) */
415   cputag_set_input_line(machine, "audiocpu", 1, ASSERT_LINE);
416   jaguar_dsp_resume(machine);
390   cputag_set_input_line(timer->machine, "audiocpu", 1, ASSERT_LINE);
391   jaguar_dsp_resume(timer->machine);
417392}
418393
419394#endif
r6740r6741
459434         if ((data & 0x3f) == 0x15)
460435         {
461436            attotime rate = attotime_mul(ATTOTIME_IN_HZ(26000000), 32 * 2 * (serial_frequency + 1));
462            timer_adjust_periodic(serial_timer, rate, 0, rate);
437            timer_device_adjust_periodic(devtag_get_device(space->machine, "serial_timer"), rate, 0, rate);
463438         }
464439         break;
465440
src/mame/audio/phoenix.c
r6740r6741
1111#include "driver.h"
1212#include "streams.h"
1313#include "sound/tms36xx.h"
14#include "phoenix.h"
14#include "includes/phoenix.h"
1515
1616/****************************************************************************
1717 * 4006
src/mame/audio/n8080.c
r6740r6741
435435}
436436
437437
438static TIMER_CALLBACK( spacefev_vco_voltage_timer )
438static TIMER_DEVICE_CALLBACK( spacefev_vco_voltage_timer )
439439{
440   const device_config *sn = devtag_get_device(machine, "snsnd");
441   n8080_state *state = (n8080_state *)machine->driver_data;
440   const device_config *sn = devtag_get_device(timer->machine, "snsnd");
441   n8080_state *state = (n8080_state *)timer->machine->driver_data;
442442   double voltage = 0;
443443
444444   if (state->mono_flop[2])
r6740r6741
450450}
451451
452452
453static TIMER_CALLBACK( helifire_dac_volume_timer )
453static TIMER_DEVICE_CALLBACK( helifire_dac_volume_timer )
454454{
455   n8080_state *state = (n8080_state *)machine->driver_data;
456   double t = state->helifire_dac_timing - attotime_to_double(timer_get_time(machine));
455   n8080_state *state = (n8080_state *)timer->machine->driver_data;
456   double t = state->helifire_dac_timing - attotime_to_double(timer_get_time(timer->machine));
457457
458458   if (state->helifire_dac_phase)
459459   {
r6740r6741
486486   n8080_state *state = (n8080_state *)machine->driver_data;
487487   state->n8080_hardware = 1;
488488
489   timer_pulse(machine, ATTOTIME_IN_HZ(1000), NULL, 0, spacefev_vco_voltage_timer);
490
491489   state->mono_flop[0] = 0;
492490   state->mono_flop[1] = 0;
493491   state->mono_flop[2] = 0;
r6740r6741
548546   n8080_state *state = (n8080_state *)machine->driver_data;
549547   state->n8080_hardware = 3;
550548
551   timer_pulse(machine, ATTOTIME_IN_HZ(1000), NULL, 0, helifire_dac_volume_timer);
552
553549   state->helifire_dac_volume = 1;
554550   state->helifire_dac_timing = 0;
555551   state->helifire_dac_phase = 0;
r6740r6741
596592   MDRV_CPU_PROGRAM_MAP(n8080_sound_cpu_map)
597593   MDRV_CPU_IO_MAP(n8080_sound_io_map)
598594
595   MDRV_TIMER_ADD_PERIODIC("vco_timer", spacefev_vco_voltage_timer, HZ(1000))
596
599597   /* sound hardware */
600598   MDRV_SPEAKER_STANDARD_MONO("mono")
601599
r6740r6741
634632   MDRV_CPU_PROGRAM_MAP(n8080_sound_cpu_map)
635633   MDRV_CPU_IO_MAP(helifire_sound_io_map)
636634
635   MDRV_TIMER_ADD_PERIODIC("helifire_dac", helifire_dac_volume_timer, HZ(1000) )
636
637637   /* sound hardware */
638638   MDRV_SPEAKER_STANDARD_MONO("mono")
639639
src/mame/audio/cinemat.c
r6740r6741
2121#include "cpu/ccpu/ccpu.h"
2222#include "cpu/z80/z80daisy.h"
2323#include "machine/z80ctc.h"
24#include "cinemat.h"
24#include "includes/cinemat.h"
2525#include "sound/samples.h"
2626#include "sound/ay8910.h"
2727
r6740r6741
9696 *
9797 *************************************/
9898
99static MACHINE_START( generic )
100{
101    /* register for save states */
102    state_save_register_global(machine, sound_control);
103    state_save_register_global(machine, current_shift);
104    state_save_register_global(machine, last_shift);
105    state_save_register_global(machine, last_shift2);
106    state_save_register_global(machine, current_pitch);
107    state_save_register_global(machine, last_frame);
108    state_save_register_global_array(machine, sound_fifo);
109    state_save_register_global(machine, sound_fifo_in);
110    state_save_register_global(machine, sound_fifo_out);
111    state_save_register_global(machine, last_portb_write);
112}
113
114
99115static void generic_init(running_machine *machine, void (*callback)(running_machine *,UINT8, UINT8))
100116{
101117   /* call the standard init */
r6740r6741
117133
118134   /* reset Star Castle pitch */
119135    current_pitch = 0x10000;
120
121    /* register for save states */
122    state_save_register_global(machine, sound_control);
123    state_save_register_global(machine, current_shift);
124    state_save_register_global(machine, last_shift);
125    state_save_register_global(machine, last_shift2);
126    state_save_register_global(machine, current_pitch);
127    state_save_register_global(machine, last_frame);
128    state_save_register_global_array(machine, sound_fifo);
129    state_save_register_global(machine, sound_fifo_in);
130    state_save_register_global(machine, sound_fifo_out);
131    state_save_register_global(machine, last_portb_write);
132136}
133137
134138
r6740r6741
206210}
207211
208212MACHINE_DRIVER_START( spacewar_sound )
213   MDRV_MACHINE_START(generic)
209214   MDRV_MACHINE_RESET(spacewar)
210215
211216   MDRV_SPEAKER_STANDARD_MONO("mono")
r6740r6741
261266}
262267
263268MACHINE_DRIVER_START( barrier_sound )
269   MDRV_MACHINE_START(generic)
264270   MDRV_MACHINE_RESET(barrier)
265271
266272   MDRV_SPEAKER_STANDARD_MONO("mono")
r6740r6741
321327}
322328
323329MACHINE_DRIVER_START( speedfrk_sound )
330   MDRV_MACHINE_START(generic)
324331   MDRV_MACHINE_RESET(speedfrk)
325332
326333   MDRV_SPEAKER_STANDARD_MONO("mono")
r6740r6741
397404}
398405
399406MACHINE_DRIVER_START( starhawk_sound )
407   MDRV_MACHINE_START(generic)
400408   MDRV_MACHINE_RESET(starhawk)
401409
402410   MDRV_SPEAKER_STANDARD_MONO("mono")
r6740r6741
467475}
468476
469477MACHINE_DRIVER_START( sundance_sound )
478   MDRV_MACHINE_START(generic)
470479   MDRV_MACHINE_RESET(sundance)
471480
472481   MDRV_SPEAKER_STANDARD_MONO("mono")
r6740r6741
556565}
557566
558567MACHINE_DRIVER_START( tailg_sound )
568   MDRV_MACHINE_START(generic)
559569   MDRV_MACHINE_RESET(tailg)
560570
561571   MDRV_SPEAKER_STANDARD_MONO("mono")
r6740r6741
625635}
626636
627637MACHINE_DRIVER_START( warrior_sound )
638   MDRV_MACHINE_START(generic)
628639   MDRV_MACHINE_RESET(warrior)
629640
630641   MDRV_SPEAKER_STANDARD_MONO("mono")
r6740r6741
720731}
721732
722733MACHINE_DRIVER_START( armora_sound )
734   MDRV_MACHINE_START(generic)
723735   MDRV_MACHINE_RESET(armora)
724736
725737   MDRV_SPEAKER_STANDARD_MONO("mono")
r6740r6741
812824}
813825
814826MACHINE_DRIVER_START( ripoff_sound )
827   MDRV_MACHINE_START(generic)
815828   MDRV_MACHINE_RESET(ripoff)
816829
817830   MDRV_SPEAKER_STANDARD_MONO("mono")
r6740r6741
925938}
926939
927940MACHINE_DRIVER_START( starcas_sound )
941   MDRV_MACHINE_START(generic)
928942   MDRV_MACHINE_RESET(starcas)
929943
930944   MDRV_SPEAKER_STANDARD_MONO("mono")
r6740r6741
10611075}
10621076
10631077MACHINE_DRIVER_START( solarq_sound )
1078   MDRV_MACHINE_START(generic)
10641079   MDRV_MACHINE_RESET(solarq)
10651080
10661081   MDRV_SPEAKER_STANDARD_MONO("mono")
r6740r6741
11961211}
11971212
11981213MACHINE_DRIVER_START( boxingb_sound )
1214   MDRV_MACHINE_START(generic)
11991215   MDRV_MACHINE_RESET(boxingb)
12001216
12011217   MDRV_SPEAKER_STANDARD_MONO("mono")
r6740r6741
13091325}
13101326
13111327MACHINE_DRIVER_START( wotw_sound )
1328   MDRV_MACHINE_START(generic)
13121329   MDRV_MACHINE_RESET(wotw)
13131330
13141331   MDRV_SPEAKER_STANDARD_MONO("mono")
r6740r6741
14221439}
14231440
14241441MACHINE_DRIVER_START( wotwc_sound )
1442   MDRV_MACHINE_START(generic)
14251443   MDRV_MACHINE_RESET(wotwc)
14261444
14271445   MDRV_SPEAKER_STANDARD_MONO("mono")
r6740r6741
15771595
15781596   MDRV_Z80CTC_ADD("ctc", 3579545 /* same as "audiocpu" */, demon_z80ctc_interface)
15791597
1598   MDRV_MACHINE_START(generic)
15801599   MDRV_MACHINE_RESET(demon_sound)
15811600
15821601   /* sound hardware */
src/mame/audio/llander.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "asteroid.h"
8#include "includes/asteroid.h"
99#include "sound/discrete.h"
1010
1111/************************************************************************/
src/mame/audio/grchamp.c
r6740r6741
44
55*************************************************************************/
66#include "driver.h"
7#include "grchamp.h"
7#include "includes/grchamp.h"
88
99
1010/************************************************************************/
src/mame/audio/avalnche.c
r6740r6741
44
55*************************************************************************/
66#include "driver.h"
7#include "avalnche.h"
7#include "includes/avalnche.h"
88#include "sound/discrete.h"
99
1010
src/mame/audio/canyon.c
r6740r6741
44
55*************************************************************************/
66#include "driver.h"
7#include "canyon.h"
7#include "includes/canyon.h"
88#include "sound/discrete.h"
99
1010
r6740r6741
123123   /* 0k = 214Hz.   250k = 4416Hz                  */
124124   /************************************************/
125125   DISCRETE_RCFILTER(NODE_20, CANYON_MOTOR1_DATA, 123000, 1e-6)
126   DISCRETE_ADJUSTMENT_TAG(NODE_21, (214.0-27.0)/12/15, (4416.0-27.0)/12/15, DISC_LOGADJ, "MOTOR1")
126   DISCRETE_ADJUSTMENT(NODE_21, (214.0-27.0)/12/15, (4416.0-27.0)/12/15, DISC_LOGADJ, "MOTOR1")
127127   DISCRETE_MULTIPLY(NODE_22, NODE_20, NODE_21)
128128
129129   DISCRETE_MULTADD(NODE_23, NODE_22, 2, 27.0/6)   /* F1 = /12*2 = /6 */
r6740r6741
146146   /* it to sound different from motor 1.          */
147147   /************************************************/
148148   DISCRETE_RCFILTER(NODE_40, CANYON_MOTOR2_DATA, 123000, 1e-6)
149   DISCRETE_ADJUSTMENT_TAG(NODE_41, (214.0-27.0)/12/15, (4416.0-27.0)/12/15, DISC_LOGADJ, "MOTOR2")
149   DISCRETE_ADJUSTMENT(NODE_41, (214.0-27.0)/12/15, (4416.0-27.0)/12/15, DISC_LOGADJ, "MOTOR2")
150150   DISCRETE_MULTIPLY(NODE_42, NODE_40, NODE_41)
151151
152152   DISCRETE_MULTADD(NODE_43, NODE_42, 2, 27.0/6)   /* F1 = /12*2 = /6 */
r6740r6741
187187   /* frequency, then decays at the rate set by    */
188188   /* a 68k resistor and 22uf capacitor.           */
189189   /************************************************/
190   DISCRETE_ADJUSTMENT_TAG(NODE_70, 50000, 100000, DISC_LINADJ, "WHISTLE1")   /* R59 */
190   DISCRETE_ADJUSTMENT(NODE_70, 50000, 100000, DISC_LINADJ, "WHISTLE1")   /* R59 */
191191   DISCRETE_MULTADD(NODE_71, CANYON_WHISTLE1_EN, 3.05-0.33, 0.33)
192192   DISCRETE_RCDISC2(NODE_72, CANYON_WHISTLE1_EN, NODE_71, 1.0, NODE_71, 68000.0, 2.2e-5)   /* CV */
193193   DISCRETE_555_ASTABLE_CV(NODE_73, CANYON_WHISTLE1_EN, 33000, NODE_70, 1e-8, NODE_72, &canyonWhistl555)
194194   DISCRETE_MULTIPLY(CANYON_WHISTLESND1, NODE_73, 519.4/3.3)
195195
196   DISCRETE_ADJUSTMENT_TAG(NODE_75, 50000, 100000, DISC_LINADJ, "WHISTLE2")   /* R69 */
196   DISCRETE_ADJUSTMENT(NODE_75, 50000, 100000, DISC_LINADJ, "WHISTLE2")   /* R69 */
197197   DISCRETE_MULTADD(NODE_76, CANYON_WHISTLE2_EN, 3.05-0.33, 0.33)
198198   DISCRETE_RCDISC2(NODE_77, CANYON_WHISTLE2_EN, NODE_76, 1.0, NODE_76, 68000.0, 2.2e-5)   /* CV */
199199   DISCRETE_555_ASTABLE_CV(NODE_78, CANYON_WHISTLE2_EN, 33000, NODE_75, 1e-8, NODE_77, &canyonWhistl555)
src/mame/audio/circus.c
r6740r6741
11#include "driver.h"
22#include "sound/samples.h"
3#include "circus.h"
3#include "includes/circus.h"
44
55static const char *const circus_sample_names[] =
66{
r6740r6741
122122   DISCRETE_INPUT_LOGIC(CRASH_MUSIC_BIT)
123123   DISCRETE_INPUT_PULSE(CRASH_BEEPER_EN, 1)
124124
125   DISCRETE_ADJUSTMENT_TAG(CRASH_R63, 0, 5.0*RES_K(100)/(RES_K(47+100))-0.5, DISC_LINADJ, "R63")
126   DISCRETE_ADJUSTMENT_TAG(CRASH_R39, 0, 1, DISC_LINADJ, "R39")
125   DISCRETE_ADJUSTMENT(CRASH_R63, 0, 5.0*RES_K(100)/(RES_K(47+100))-0.5, DISC_LINADJ, "R63")
126   DISCRETE_ADJUSTMENT(CRASH_R39, 0, 1, DISC_LINADJ, "R39")
127127
128128   /************************************************/
129129   /* Music is just a 1 bit DAC                    */
src/mame/audio/norautp.c
r6740r6741
44 ************************************************************************/
55
66#include "driver.h"
7#include "norautp.h"
7#include "includes/norautp.h"
88
99
1010/* Discrete Sound Input Nodes */
src/mame/audio/turbo.c
r6740r6741
55*************************************************************************/
66
77#include "driver.h"
8#include "turbo.h"
8#include "includes/turbo.h"
99#include "sound/samples.h"
1010
1111
src/mame/audio/redbaron.c
r6740r6741
1717#include <math.h>
1818#include "driver.h"
1919#include "streams.h"
20#include "bzone.h"
20#include "includes/bzone.h"
2121#include "sound/pokey.h"
2222
2323#define OUTPUT_RATE      (48000)
src/mame/audio/crbaloon.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "crbaloon.h"
10#include "includes/crbaloon.h"
1111#include "sound/sn76477.h"
1212#include "sound/discrete.h"
1313
r6740r6741
9797   DISCRETE_INPUT_LOGIC(CRBALOON_MUSIC_EN)
9898   DISCRETE_INPUT_DATA (CRBALOON_MUSIC_DATA)
9999
100   DISCRETE_ADJUSTMENT_TAG(CRBALOON_VR2, 0, 0.5, DISC_LINADJ, "VR2")
101   DISCRETE_ADJUSTMENT_TAG(CRBALOON_VR3, 0, 1,   DISC_LINADJ, "VR3")
100   DISCRETE_ADJUSTMENT(CRBALOON_VR2, 0, 0.5, DISC_LINADJ, "VR2")
101   DISCRETE_ADJUSTMENT(CRBALOON_VR3, 0, 1,   DISC_LINADJ, "VR3")
102102
103103   /************************************************
104104    * Laugh is a VCO modulated by a constant
src/mame/audio/cage.c
r6740r6741
4545
4646static UINT8 dma_enabled;
4747static UINT8 dma_timer_enabled;
48static emu_timer *dma_timer;
48static const device_config *dma_timer;
4949
5050static UINT8 cage_timer_enabled[2];
51static emu_timer *timer[2];
51static const device_config *timer[2];
5252
5353static UINT32 *tms32031_io_regs;
5454
r6740r6741
140140 *
141141 *************************************/
142142
143static TIMER_CALLBACK( dma_timer_callback );
144static TIMER_CALLBACK( cage_timer_callback );
143static TIMER_DEVICE_CALLBACK( dma_timer_callback );
144static TIMER_DEVICE_CALLBACK( cage_timer_callback );
145145static void update_timer(int which);
146146static WRITE32_HANDLER( speedup_w );
147147
r6740r6741
167167   cage_cpu_clock_period = ATTOTIME_IN_HZ(cpu_get_clock(cage_cpu));
168168   cage_cpu_h1_clock_period = attotime_mul(cage_cpu_clock_period, 2);
169169
170   dma_timer = timer_alloc(machine, dma_timer_callback, NULL);
171   timer[0] = timer_alloc(machine, cage_timer_callback, NULL);
172   timer[1] = timer_alloc(machine, cage_timer_callback, NULL);
170   dma_timer = devtag_get_device(machine, "cage_dma_timer");
171   timer[0] = devtag_get_device(machine, "cage_timer0");
172   timer[1] = devtag_get_device(machine, "cage_timer1");
173173
174174   if (speedup)
175175      speedup_ram = memory_install_write32_handler(cpu_get_address_space(cage_cpu, ADDRESS_SPACE_PROGRAM), speedup, speedup, 0, 0, speedup_w);
r6740r6741
214214 *
215215 *************************************/
216216
217static TIMER_CALLBACK( dma_timer_callback )
217static TIMER_DEVICE_CALLBACK( dma_timer_callback )
218218{
219219   /* if we weren't enabled, don't do anything, just shut ourself off */
220220   if (!dma_enabled)
221221   {
222222      if (dma_timer_enabled)
223223      {
224         timer_adjust_oneshot(dma_timer, attotime_never, 0);
224         timer_device_adjust_oneshot(timer, attotime_never, 0);
225225         dma_timer_enabled = 0;
226226      }
227227      return;
r6740r6741
272272      if (!dma_timer_enabled)
273273      {
274274         attotime period = attotime_mul(serial_period_per_word, tms32031_io_regs[DMA_TRANSFER_COUNT]);
275         timer_adjust_periodic(dma_timer, period, addr, period);
275         timer_device_adjust_periodic(dma_timer, period, addr, period);
276276         dma_timer_enabled = 1;
277277      }
278278   }
r6740r6741
280280   /* see if we turned off */
281281   else if (!enabled && dma_enabled)
282282   {
283      timer_adjust_oneshot(dma_timer, attotime_never, 0);
283      timer_device_adjust_oneshot(dma_timer, attotime_never, 0);
284284      dma_timer_enabled = 0;
285285   }
286286
r6740r6741
296296 *
297297 *************************************/
298298
299static TIMER_CALLBACK( cage_timer_callback )
299static TIMER_DEVICE_CALLBACK( cage_timer_callback )
300300{
301301   int which = param;
302302
r6740r6741
322322      if (tms32031_io_regs[base + TIMER0_GLOBAL_CTL] != 0x2c1)
323323         logerror("CAGE TIMER%d: unexpected timer config %08X!\n", which, tms32031_io_regs[base + TIMER0_GLOBAL_CTL]);
324324
325      timer_adjust_oneshot(timer[which], period, which);
325      timer_device_adjust_oneshot(timer[which], period, which);
326326   }
327327
328328   /* see if we turned off */
329329   else if (!enabled && cage_timer_enabled[which])
330330   {
331      timer_adjust_oneshot(timer[which], attotime_never, which);
331      timer_device_adjust_oneshot(timer[which], attotime_never, which);
332332   }
333333
334334   /* set the new state */
r6740r6741
569569
570570      dma_enabled = 0;
571571      dma_timer_enabled = 0;
572      timer_adjust_oneshot(dma_timer, attotime_never, 0);
572      timer_device_adjust_oneshot(dma_timer, attotime_never, 0);
573573
574574      cage_timer_enabled[0] = 0;
575575      cage_timer_enabled[1] = 0;
576      timer_adjust_oneshot(timer[0], attotime_never, 0);
577      timer_adjust_oneshot(timer[1], attotime_never, 0);
576      timer_device_adjust_oneshot(timer[0], attotime_never, 0);
577      timer_device_adjust_oneshot(timer[1], attotime_never, 0);
578578
579579      memset(tms32031_io_regs, 0, 0x60 * 4);
580580
r6740r6741
654654   MDRV_CPU_CONFIG(cage_config)
655655   MDRV_CPU_PROGRAM_MAP(cage_map)
656656
657   MDRV_TIMER_ADD("cage_dma_timer", dma_timer_callback)
658   MDRV_TIMER_ADD("cage_timer0", cage_timer_callback)
659   MDRV_TIMER_ADD("cage_timer1", cage_timer_callback)
660
657661   /* sound hardware */
658662   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
659663
src/mame/audio/hitme.c
r6740r6741
44
55*************************************************************************/
66#include "driver.h"
7#include "hitme.h"
7#include "includes/hitme.h"
88#include "sound/discrete.h"
99
1010
r6740r6741
4242   DISCRETE_INPUT_PULSE(HITME_OUT1, 0)
4343
4444    /* This represents the resistor at R3, which controls the speed of the sound effects */
45   DISCRETE_ADJUSTMENT_TAG(HITME_GAME_SPEED,0.0,25000.0,DISC_LINADJ,"R3")
45   DISCRETE_ADJUSTMENT(HITME_GAME_SPEED,0.0,25000.0,DISC_LINADJ,"R3")
4646
4747   /* The clock for the main downcounter is a "404", or LS123 retriggerable multivibrator.
4848     * It is clocked by IPH2 (8.945MHz/16 = 559kHz), then triggers a pulse which is adjustable
src/mame/audio/snk6502.c
r6740r6741
1414#include "streams.h"
1515#include "sound/sn76477.h"
1616#include "sound/samples.h"
17#include "snk6502.h"
17#include "includes/snk6502.h"
1818#include "sound/discrete.h"
1919
2020
src/mame/audio/exidy440.c
r6740r6741
1010#include "driver.h"
1111#include "cpu/m6809/m6809.h"
1212#include "streams.h"
13#include "exidy440.h"
13#include "includes/exidy440.h"
1414
1515
1616#define   SOUND_LOG      0
src/mame/audio/bzone.c
r6740r6741
2020#include <math.h>
2121#include "driver.h"
2222#include "streams.h"
23#include "bzone.h"
23#include "includes/bzone.h"
2424
2525#include "sound/discrete.h"
2626#include "sound/pokey.h"
r6740r6741
292292   DISCRETE_BITS_DECODE(NODE_10, BZ_INPUT, 0, 7, 1)             /* IC M2, bits 0 - 7 */
293293
294294   /* the pot is 250K, but we will use a smaller range to get a better adjustment range */
295   DISCRETE_ADJUSTMENT_TAG(BZ_R11_POT, RES_K(75), RES_K(10), DISC_LINADJ, "R11")
295   DISCRETE_ADJUSTMENT(BZ_R11_POT, RES_K(75), RES_K(10), DISC_LINADJ, "R11")
296296
297297
298298   /************************************************/
src/mame/audio/segasnd.c
r6740r6741
1111
1212#include "driver.h"
1313#include "streams.h"
14#include "segag80v.h"
14#include "includes/segag80v.h"
1515#include "cpu/mcs48/mcs48.h"
1616#include "sound/sp0250.h"
1717#include "segasnd.h"
r6740r6741
302302 *
303303 *************************************/
304304
305static TIMER_CALLBACK( increment_t1_clock )
305static TIMER_DEVICE_CALLBACK( increment_t1_clock )
306306{
307307   /* only increment if it is not being forced clear */
308308   if (!(usb.last_p2_value & 0x80))
r6740r6741
316316   cpu_set_input_line(usb.cpu, INPUT_LINE_RESET, ASSERT_LINE);
317317
318318   /* start the clock timer */
319   timer_pulse(machine, attotime_mul(ATTOTIME_IN_HZ(USB_2MHZ_CLOCK), 256), NULL, 0, increment_t1_clock);
320319   usb.t1_clock_mask = t1_clock_mask;
321320}
322321
r6740r6741
923922   MDRV_CPU_PROGRAM_MAP(usb_map)
924923   MDRV_CPU_IO_MAP(usb_portmap)
925924
925   MDRV_TIMER_ADD_PERIODIC("usb_timer", increment_t1_clock, HZ(USB_2MHZ_CLOCK / 256))
926
926927   /* sound hardware */
927928   MDRV_SOUND_ADD("usbsnd", USB, 0)
928929   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
src/mame/audio/aztarac.c
r6740r6741
66
77#include "driver.h"
88#include "cpu/z80/z80.h"
9#include "aztarac.h"
9#include "includes/aztarac.h"
1010
1111static int sound_status;
1212
src/mame/audio/vicdual.c
r6740r6741
55*************************************************************************/
66
77#include "driver.h"
8#include "vicdual.h"
8#include "includes/vicdual.h"
99#include "sound/discrete.h"
1010#include "sound/samples.h"
1111
r6740r6741
7373   DISCRETE_INPUT_NOT(FROGS_CAPTURE_EN)
7474   DISCRETE_INPUT_NOT(FROGS_SPLASH_EN)
7575
76   DISCRETE_ADJUSTMENT_TAG(FROGS_R93, RES_M(1), RES_K(10), DISC_LOGADJ, "R93")
76   DISCRETE_ADJUSTMENT(FROGS_R93, RES_M(1), RES_K(10), DISC_LOGADJ, "R93")
7777
7878   DISCRETE_555_MSTABLE(NODE_30, 1, FROGS_TONGUE_EN, RES_K(100), CAP_U(1), &frogsZip555m)
7979
src/mame/audio/bsktball.c
r6740r6741
44
55*************************************************************************/
66#include "driver.h"
7#include "bsktball.h"
7#include "includes/bsktball.h"
88#include "sound/discrete.h"
99
1010/***************************************************************************
src/mame/audio/meadows.c
r6740r6741
88
99#include "driver.h"
1010#include "cpu/s2650/s2650.h"
11#include "meadows.h"
11#include "includes/meadows.h"
1212#include "sound/samples.h"
1313#include "sound/dac.h"
1414
src/mame/audio/leland.c
r6740r6741
8181#include "streams.h"
8282#include "cpu/i86/i86.h"
8383#include "cpu/z80/z80.h"
84#include "leland.h"
84#include "includes/leland.h"
8585#include "sound/2151intf.h"
8686
8787
src/mame/audio/poolshrk.c
r6740r6741
44
55*************************************************************************/
66#include "driver.h"
7#include "poolshrk.h"
7#include "includes/poolshrk.h"
88#include "sound/discrete.h"
99
1010/************************************************************************/
src/mame/audio/sprint2.c
r6740r6741
44
55*************************************************************************/
66#include "driver.h"
7#include "sprint2.h"
7#include "includes/sprint2.h"
88
99
1010/************************************************************************/
r6740r6741
121121   /* and are output thru a DAC                    */
122122   /************************************************/
123123
124   DISCRETE_ADJUSTMENT_TAG(NODE_20,
124   DISCRETE_ADJUSTMENT(NODE_20,
125125            RES_K(260),   // R21 + R23 @ max
126126            RES_K(10),   // R21 + R23 @ min
127127            DISC_LOGADJ, "MOTOR1")
r6740r6741
159159   /************************************************/
160160   /* Car2 motor sound                             */
161161   /************************************************/
162   DISCRETE_ADJUSTMENT_TAG(NODE_40,
162   DISCRETE_ADJUSTMENT(NODE_40,
163163            RES_K(260),   // R21 + R23 @ max
164164            RES_K(10),   // R21 + R23 @ min
165165            DISC_LOGADJ, "MOTOR2")
r6740r6741
244244   /* and are output thru a DAC                    */
245245   /************************************************/
246246
247   DISCRETE_ADJUSTMENT_TAG(NODE_20,
247   DISCRETE_ADJUSTMENT(NODE_20,
248248            RES_K(260),   // R21 + R23 @ max
249249            RES_K(10),   // R21 + R23 @ min
250250            DISC_LOGADJ, "MOTOR")
r6740r6741
368368   DISCRETE_INPUT_DATA (DOMINOS_AMP_DATA)               // IC C4
369369   DISCRETE_INPUT_LOGIC(DOMINOS_ATTRACT_EN)
370370
371   DISCRETE_ADJUSTMENT_TAG(DOMINOS_R23,
371   DISCRETE_ADJUSTMENT(DOMINOS_R23,
372372            RES_K(60),   // R21 + R23 @ max
373373            RES_K(10),   // R21 + R23 @ min
374374            DISC_LINADJ, "R23")
src/mame/audio/dkong.c
r6740r6741
451451
452452   DISCRETE_TASK_START(1)
453453   /* Mixing - DAC */
454   DISCRETE_ADJUSTMENT_TAG(DS_ADJ_DAC, 0, 1, DISC_LINADJ, "VR2")
454   DISCRETE_ADJUSTMENT(DS_ADJ_DAC, 0, 1, DISC_LINADJ, "VR2")
455455
456456   /* Buffer DAC first to input stream 0 */
457457   DISCRETE_INPUT_BUFFER(DS_DAC, 0)
r6740r6741
647647   //DISCRETE_INPUT_DATA(DS_DAC)
648648
649649   /* Mixing - DAC */
650   DISCRETE_ADJUSTMENT_TAG(DS_ADJ_DAC, 0, 1, DISC_LINADJ, "VR2")
650   DISCRETE_ADJUSTMENT(DS_ADJ_DAC, 0, 1, DISC_LINADJ, "VR2")
651651
652652   /************************************************/
653653   /* SIGNALS                                      */
src/mame/audio/taito_en.c
r6740r6741
77static UINT16 es5510_dsp_ram[0x200];
88static UINT32   es5510_gpr[0xc0];
99static UINT32   es5510_gpr_latch;
10static emu_timer *timer_68681=NULL;
1110static int timer_mode,m68681_imr;
1211
1312//static int es_tmp=1;
r6740r6741
1716
1817enum { TIMER_SINGLESHOT, TIMER_PULSE };
1918
19
20
2021static READ16_HANDLER(f3_68000_share_r)
2122{
2223   if ((offset&3)==0) return (f3_shared_ram[offset/4]&0xff000000)>>16;
r6740r6741
6869   /* Channels 0, 1, 2, 3 - Unused */
6970}
7071
71static TIMER_CALLBACK( taito_en_timer_callback )
72static TIMER_DEVICE_CALLBACK( taito_en_timer_callback )
7273{
7374   /* Only cause IRQ if the mask is set to allow it */
7475   if (m68681_imr & 0x08)
7576   {
76      cpu_set_input_line_vector(cputag_get_cpu(machine, "audiocpu"), 6, vector_reg);
77      cputag_set_input_line(machine, "audiocpu", 6, ASSERT_LINE);
77      cpu_set_input_line_vector(cputag_get_cpu(timer->machine, "audiocpu"), 6, vector_reg);
78      cputag_set_input_line(timer->machine, "audiocpu", 6, ASSERT_LINE);
7879      imr_status |= 0x08;
7980   }
8081}
8182
82void f3_68681_reset(running_machine *machine)
83{
84   timer_68681 = timer_alloc(machine, taito_en_timer_callback, NULL);
85}
86
8783static READ16_HANDLER(f3_68681_r)
8884{
8985   if (offset == 0x05)
r6740r6741
123119            case 3:
124120               logerror("Counter:  X1/Clk - divided by 16, counter is %04x, so interrupt every %d cycles\n",counter,(M68000_CLOCK/M68681_CLOCK)*counter*16);
125121               timer_mode=TIMER_SINGLESHOT;
126               timer_adjust_oneshot(timer_68681, cpu_clocks_to_attotime(space->cpu, (M68000_CLOCK/M68681_CLOCK)*counter*16), 0);
122               timer_device_adjust_oneshot(devtag_get_device(space->machine, "timer_68681"), cpu_clocks_to_attotime(space->cpu, (M68000_CLOCK/M68681_CLOCK)*counter*16), 0);
127123               break;
128124            case 4:
129125               logerror("Timer:  Unimplemented external IP2\n");
r6740r6741
134130            case 6:
135131               logerror("Timer:  X1/Clk, counter is %04x, so interrupt every %d cycles\n",counter,(M68000_CLOCK/M68681_CLOCK)*counter);
136132               timer_mode=TIMER_PULSE;
137               timer_adjust_periodic(timer_68681, cpu_clocks_to_attotime(space->cpu, (M68000_CLOCK/M68681_CLOCK)*counter), 0, cpu_clocks_to_attotime(space->cpu, (M68000_CLOCK/M68681_CLOCK)*counter));
133               timer_device_adjust_periodic(devtag_get_device(space->machine, "timer_68681"), cpu_clocks_to_attotime(space->cpu, (M68000_CLOCK/M68681_CLOCK)*counter), 0, cpu_clocks_to_attotime(space->cpu, (M68000_CLOCK/M68681_CLOCK)*counter));
138134               break;
139135            case 7:
140136               logerror("Timer:  Unimplemented X1/Clk - divided by 16\n");
r6740r6741
247243   AM_RANGE(0xff0000, 0xffffff) AM_RAM AM_SHARE("share1")   // mirror
248244ADDRESS_MAP_END
249245
250void taito_f3_soundsystem_reset(running_machine *machine)
246static SOUND_RESET( taito_f3_soundsystem_reset )
251247{
252248   /* Sound cpu program loads to 0xc00000 so we use a bank */
253249   UINT16 *ROM = (UINT16 *)memory_region(machine, "audiocpu");
r6740r6741
265261   //cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, ASSERT_LINE);
266262}
267263
268const es5505_interface es5505_taito_f3_config =
264static const es5505_interface es5505_taito_f3_config =
269265{
270266   "ensoniq.0",   /* Bank 0: Unused by F3 games? */
271267   "ensoniq.0",   /* Bank 1: All games seem to use this */
272268   NULL /* irq */
273269};
270
271MACHINE_DRIVER_START( taito_f3_sound )
272   MDRV_TIMER_ADD("timer_68681", taito_en_timer_callback)
273
274   MDRV_SOUND_RESET( taito_f3_soundsystem_reset )
275
276   MDRV_CPU_ADD("audiocpu",  M68000, 16000000)
277   MDRV_CPU_PROGRAM_MAP(f3_sound_map)
278
279   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
280   MDRV_SOUND_ADD("ensoniq", ES5505, 30476100/2)
281   MDRV_SOUND_CONFIG(es5505_taito_f3_config)
282   MDRV_SOUND_ROUTE(0, "lspeaker", 1.0)
283   MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)
284MACHINE_DRIVER_END
src/mame/audio/harddriv.c
r6740r6741
88#include "cpu/tms32010/tms32010.h"
99#include "sound/dac.h"
1010#include "machine/atarigen.h"
11#include "harddriv.h"
11#include "includes/harddriv.h"
1212
1313
1414#define BIO_FREQUENCY      (1000000 / 50)
src/mame/audio/sprint4.c
r6740r6741
172172               SPRINT4_MOTOR_DATA_##_plr,               /* DATA */                          \
173173               DEFAULT_TTL_V_LOGIC_1,                  /* VDATA */                         \
174174               &sprint4_motor_freq_DAC)               /* LADDER */                        \
175   DISCRETE_ADJUSTMENT_TAG(SPRINT4_PLAYER_MOTOR_NODE(2, _plr),                                     \
175   DISCRETE_ADJUSTMENT(SPRINT4_PLAYER_MOTOR_NODE(2, _plr),                                     \
176176               RES_K(10) + RES_K(250),                  /* MIN */                           \
177177               RES_K(10),                           /* MAX */                           \
178178               DISC_LOGADJ,                        /* LOGLIN */                        \
src/mame/audio/m72.c
r6740r6741
104104      cputag_set_input_line_and_vector(machine, "soundcpu",0,ASSERT_LINE, irqvector);
105105}
106106
107MACHINE_RESET( m72_sound )
107SOUND_START( m72 )
108108{
109   setvector_callback(machine, NULL, VECTOR_INIT);
110
111109   state_save_register_global(machine, irqvector);
112110   state_save_register_global(machine, sample_addr);
113111}
114112
113SOUND_RESET( m72 )
114{
115   setvector_callback(machine, NULL, VECTOR_INIT);
116}
117
115118void m72_ym2151_irq_handler(const device_config *device, int irq)
116119{
117120   if (irq)
src/mame/audio/firetrk.c
r6740r6741
55*************************************************************************/
66
77#include "driver.h"
8#include "firetrk.h"
8#include "includes/firetrk.h"
99#include "sound/discrete.h"
1010
1111
r6740r6741
206206   /* drive a modulo 12 counter, with div6 & div12 */
207207   /* summed as the output of the circuit.         */
208208   /************************************************/
209   DISCRETE_ADJUSTMENT_TAG(NODE_20,
209   DISCRETE_ADJUSTMENT(NODE_20,
210210            RES_K(260),   // R26 + R27 @ max
211211            RES_K(10),   // R26 + R27 @ min
212212            DISC_LOGADJ, "R27")
r6740r6741
409409   /* latch (4 bit). This freqency is then used to */
410410   /* drive a modulo 12 counter.                   */
411411   /************************************************/
412   DISCRETE_ADJUSTMENT_TAG(NODE_20,
412   DISCRETE_ADJUSTMENT(NODE_20,
413413            RES_K(260),   // R12 + R62 @ max
414414            RES_K(10),   // R12 + R62 @ min
415415            DISC_LOGADJ, "R62")
r6740r6741
593593   /* driver a modulo 12 counter, with div6, 4 & 3 */
594594   /* summed as the output of the circuit.         */
595595   /************************************************/
596   DISCRETE_ADJUSTMENT_TAG(NODE_20,
596   DISCRETE_ADJUSTMENT(NODE_20,
597597            RES_K(260),   // R87 + R89 @ max
598598            RES_K(10),   // R87 + R89 @ min
599599            DISC_LOGADJ, "R89")
r6740r6741
628628   /************************************************/
629629   DISCRETE_COMP_ADDER(NODE_30, MONTECAR_DRONE_LOUD_DATA, &montecar_drone_vol_res)   // make sure to change the node value in the mixer table if you change this node number
630630
631   DISCRETE_ADJUSTMENT_TAG(NODE_40,
631   DISCRETE_ADJUSTMENT(NODE_40,
632632            RES_K(260),   // R85 + R88 @ max
633633            RES_K(10),   // R85 + R88 @ min
634634            DISC_LOGADJ, "R88")
src/mame/audio/skyraid.c
r6740r6741
44 ************************************************************************/
55
66#include "driver.h"
7#include "skyraid.h"
7#include "includes/skyraid.h"
88
99
1010/* Discrete Sound Input Nodes */
src/mame/audio/sprint8.c
r6740r6741
44 ************************************************************************/
55
66#include "driver.h"
7#include "sprint8.h"
7#include "includes/sprint8.h"
88
99
1010/* Discrete Sound Input Nodes */
r6740r6741
182182   DISCRETE_INPUTX_LOGIC(SPRINT8_MOTOR8_EN, DEFAULT_TTL_V_LOGIC_1, 0, 0)
183183
184184   DISCRETE_TASK_START(0)
185   DISCRETE_ADJUSTMENT_TAG(SPRINT8_R132_POT, 0, SPRINT8_R132, DISC_LINADJ, "R132")
185   DISCRETE_ADJUSTMENT(SPRINT8_R132_POT, 0, SPRINT8_R132, DISC_LINADJ, "R132")
186186
187187   /************************************************
188188     * Noise Generator, Crash, Screech
src/mame/audio/taito_en.h
r6740r6741
11#include "cpu/m68000/m68000.h"
22#include "sound/es5506.h"
33
4void f3_68681_reset(running_machine *machine);
5
6void taito_f3_soundsystem_reset(running_machine *machine);
7
8#define TAITO_F3_SOUND_SYSTEM_CPU(freq)                        \
9   MDRV_CPU_ADD("audiocpu",  M68000, freq)                     \
10   MDRV_CPU_PROGRAM_MAP(f3_sound_map)                     \
11
12
13#define TAITO_F3_SOUND_SYSTEM_ES5505(freq)                     \
14   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")               \
15   MDRV_SOUND_ADD("ensoniq", ES5505, freq)                     \
16   MDRV_SOUND_CONFIG(es5505_taito_f3_config)                  \
17   MDRV_SOUND_ROUTE(0, "lspeaker", 1.0)                        \
18   MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)                        \
19
20ADDRESS_MAP_EXTERN(f3_sound_map, 16);
21
22extern const es5505_interface es5505_taito_f3_config;
4MACHINE_DRIVER_EXTERN( taito_f3_sound );
src/mame/audio/dragrace.c
r6740r6741
44
55*************************************************************************/
66#include "driver.h"
7#include "dragrace.h"
7#include "includes/dragrace.h"
88#include "sound/discrete.h"
99
1010/************************************************************************/
r6740r6741
9292   /* NOTE: freqs are ripped from Sprint for now.  */
9393   /************************************************/
9494   DISCRETE_RCFILTER(NODE_20, DRAGRACE_MOTOR1_DATA, 119898, 2.2e-6)
95   DISCRETE_ADJUSTMENT_TAG(NODE_21, (214.0-27.0)/12/31, (4416.0-27.0)/12/31, DISC_LOGADJ, "MOTOR1")
95   DISCRETE_ADJUSTMENT(NODE_21, (214.0-27.0)/12/31, (4416.0-27.0)/12/31, DISC_LOGADJ, "MOTOR1")
9696   DISCRETE_MULTIPLY(NODE_22, NODE_20, NODE_21)
9797
9898   DISCRETE_MULTADD(NODE_23, NODE_22, 2, 27.0/6)   /* F1 = /12*2 = /6 */
r6740r6741
115115   /* it to sound different from car1.             */
116116   /************************************************/
117117   DISCRETE_RCFILTER(NODE_40, DRAGRACE_MOTOR2_DATA, 119898, 2.2e-6)
118   DISCRETE_ADJUSTMENT_TAG(NODE_41, (214.0-27.0)/12/31, (4416.0-27.0)/12/31, DISC_LOGADJ, "MOTOR2")
118   DISCRETE_ADJUSTMENT(NODE_41, (214.0-27.0)/12/31, (4416.0-27.0)/12/31, DISC_LOGADJ, "MOTOR2")
119119   DISCRETE_MULTIPLY(NODE_42, NODE_40, NODE_41)
120120
121121   DISCRETE_MULTADD(NODE_43, NODE_42, 2, 27.0/6)   /* F1 = /12*2 = /6 */
src/mame/audio/madalien.c
r6740r6741
44 ************************************************************************/
55
66#include "driver.h"
7#include "madalien.h"
7#include "includes/madalien.h"
88#include "sound/discrete.h"
99
1010
src/mame/audio/m72.h
r6740r6741
44
55****************************************************************************/
66
7MACHINE_RESET( m72_sound );
7SOUND_START( m72 );
8SOUND_RESET( m72 );
89void m72_ym2151_irq_handler(const device_config *device, int irq);
910WRITE8_HANDLER( m72_sound_command_byte_w );
1011WRITE16_HANDLER( m72_sound_command_w );
src/mame/audio/gridlee.c
r6740r6741
66
77#include "driver.h"
88#include "streams.h"
9#include "gridlee.h"
9#include "includes/gridlee.h"
1010#include "sound/samples.h"
1111
1212
src/mame/audio/orbit.c
r6740r6741
44
55*************************************************************************/
66#include "driver.h"
7#include "orbit.h"
7#include "includes/orbit.h"
88#include "sound/discrete.h"
99
1010/*************************************
src/mame/audio/segag80r.c
r6740r6741
1010#include "driver.h"
1111#include "streams.h"
1212#include "cpu/mcs48/mcs48.h"
13#include "segag80r.h"
13#include "includes/segag80r.h"
1414#include "machine/8255ppi.h"
1515#include "machine/i8243.h"
1616#include "sound/samples.h"
src/mame/audio/segag80v.c
r6740r6741
55*************************************************************************/
66
77#include "driver.h"
8#include "segag80v.h"
8#include "includes/segag80v.h"
99#include "sound/samples.h"
1010
1111/* History:
src/mame/audio/scramble.c
r6740r6741
7979
8080WRITE8_DEVICE_HANDLER( scramble_sh_irqtrigger_w )
8181{
82   const device_config *target = devtag_get_device(device->machine, "konami_7474");
83
8284   /* the complement of bit 3 is connected to the flip-flop's clock */
83   TTL7474_clock_w(2, ~data & 0x08);
84   TTL7474_update(device->machine, 2);
85   ttl7474_clock_w(target, ~data & 0x08);
86   ttl7474_update(target);
8587
8688   /* bit 4 is sound disable */
8789   sound_global_enable(device->machine, ~data & 0x10);
r6740r6741
8991
9092WRITE8_DEVICE_HANDLER( mrkougar_sh_irqtrigger_w )
9193{
94   const device_config *target = devtag_get_device(device->machine, "konami_7474");
95
9296   /* the complement of bit 3 is connected to the flip-flop's clock */
93   TTL7474_clock_w(2, ~data & 0x08);
94   TTL7474_update(device->machine, 2);
97   ttl7474_clock_w(target, ~data & 0x08);
98   ttl7474_update(target);
9599}
96100
97#ifdef UNUSED_FUNCTION
98WRITE8_HANDLER( froggrmc_sh_irqtrigger_w )
99{
100   /* the complement of bit 0 is connected to the flip-flop's clock */
101   TTL7474_clock_w(2, ~data & 0x01);
102   TTL7474_update(space->machine, 2);
103}
104#endif
105
106101static IRQ_CALLBACK(scramble_sh_irq_callback)
107102{
103   const device_config *target = devtag_get_device(device->machine, "konami_7474");
104
108105   /* interrupt acknowledge clears the flip-flop --
109106       we need to pulse the CLR line because MAME's core never clears this
110107       line, only asserts it */
111   TTL7474_clear_w(2, 0);
112   TTL7474_update(device->machine, 2);
108   ttl7474_clear_w(target, 0);
109   ttl7474_update(target);
113110
114   TTL7474_clear_w(2, 1);
115   TTL7474_update(device->machine, 2);
111   ttl7474_clear_w(target, 1);
112   ttl7474_update(target);
116113
117114   return 0xff;
118115}
119116
120static void scramble_sh_7474_callback(running_machine *machine)
117void scramble_sh_7474_callback(const device_config *device)
121118{
122119   /* the Q bar is connected to the Z80's INT line.  But since INT is complemented, */
123120   /* we need to complement Q bar */
124   cputag_set_input_line(machine, "audiocpu", 0, !TTL7474_output_comp_r(2) ? ASSERT_LINE : CLEAR_LINE);
121   cputag_set_input_line(device->machine, "audiocpu", 0, !ttl7474_output_comp_r(device) ? ASSERT_LINE : CLEAR_LINE);
125122}
126123
127124WRITE8_HANDLER( hotshock_sh_irqtrigger_w )
r6740r6741
166163   filter_w(devtag_get_device(space->machine, "filter.0.2"), (offset >> 10) & 3);
167164}
168165
169static const struct TTL7474_interface scramble_sh_7474_intf =
170{
171   scramble_sh_7474_callback
172};
173
174166void scramble_sh_init(running_machine *machine)
175167{
176168   cpu_set_irq_callback(cputag_get_cpu(machine, "audiocpu"), scramble_sh_irq_callback);
177169
178   TTL7474_config(machine, 2, &scramble_sh_7474_intf);
179
180170   /* PR is always 0, D is always 1 */
181   TTL7474_d_w(2, 1);
171   ttl7474_d_w(devtag_get_device(machine, "konami_7474"), 1);
182172}
183173
184174
src/mame/audio/redalert.c
r6740r6741
1515#include "machine/6821pia.h"
1616#include "sound/ay8910.h"
1717#include "sound/hc55516.h"
18#include "redalert.h"
18#include "includes/redalert.h"
1919
2020
2121
src/mame/audio/triplhnt.c
r6740r6741
44
55*************************************************************************/
66#include "driver.h"
7#include "triplhnt.h"
7#include "includes/triplhnt.h"
88#include "sound/discrete.h"
99
1010
r6740r6741
130130   /************************************************/
131131   /* Bear Roar is a VCO with noise mixed in.      */
132132   /************************************************/
133   DISCRETE_ADJUSTMENT_TAG(NODE_20,
133   DISCRETE_ADJUSTMENT(NODE_20,
134134            10000,   // R86 + R88 @ 0
135135            260000,   // R86 + R88 @ max
136136            DISC_LOGADJ, "BEAR")
src/mame/audio/starshp1.c
r6740r6741
44 ************************************************************************/
55
66#include "driver.h"
7#include "starshp1.h"
7#include "includes/starshp1.h"
88#include "sound/discrete.h"
99
1010
src/mame/audio/atarifb.c
r6740r6741
55*************************************************************************/
66
77#include "driver.h"
8#include "atarifb.h"
8#include "includes/atarifb.h"
99#include "sound/discrete.h"
1010
1111
src/mame/audio/dcs.c
r6740r6741
296296   UINT16      size;
297297   UINT16      incs;
298298   const device_config *dmadac[6];
299   emu_timer *   reg_timer;
300   emu_timer *   sport_timer;
301   emu_timer *   internal_timer;
299   const device_config *reg_timer;
300   const device_config *sport_timer;
301   const device_config *internal_timer;
302302   INT32      ireg;
303303   UINT16      ireg_base;
304304   UINT16      control_regs[32];
r6740r6741
350350   INT32      writes_left;
351351   UINT16      sum;
352352   INT32      fifo_entries;
353   emu_timer *   watchdog;
353   const device_config *watchdog;
354354};
355355
356356
r6740r6741
410410static WRITE16_HANDLER( output_control_w );
411411
412412static void timer_enable_callback(const device_config *device, int enable);
413static TIMER_CALLBACK( internal_timer_callback );
414static TIMER_CALLBACK( dcs_irq );
415static TIMER_CALLBACK( sport0_irq );
413static TIMER_DEVICE_CALLBACK( internal_timer_callback );
414static TIMER_DEVICE_CALLBACK( dcs_irq );
415static TIMER_DEVICE_CALLBACK( sport0_irq );
416416static void recompute_sample_rate(running_machine *machine);
417417static void sound_tx_callback(const device_config *device, int port, INT32 data);
418418
419419static READ16_HANDLER( dcs_polling_r );
420420static WRITE16_HANDLER( dcs_polling_w );
421421
422static TIMER_CALLBACK( transfer_watchdog_callback );
422static TIMER_DEVICE_CALLBACK( transfer_watchdog_callback );
423423static int preprocess_write(running_machine *machine, UINT16 data);
424424
425425
r6740r6741
614614   MDRV_CPU_PROGRAM_MAP(dcs_2k_program_map)
615615   MDRV_CPU_DATA_MAP(dcs_2k_data_map)
616616
617   MDRV_TIMER_ADD("dcs_reg_timer", dcs_irq)
618   MDRV_TIMER_ADD("dcs_int_timer", internal_timer_callback)
619
617620   MDRV_SPEAKER_STANDARD_MONO("mono")
618621
619622   MDRV_SOUND_ADD("dac", DMADAC, 0)
r6740r6741
653656   MDRV_CPU_PROGRAM_MAP(dcs2_2115_program_map)
654657   MDRV_CPU_DATA_MAP(dcs2_2115_data_map)
655658
659   MDRV_TIMER_ADD("dcs_reg_timer", dcs_irq)
660   MDRV_TIMER_ADD("dcs_sport_timer", sport0_irq)
661   MDRV_TIMER_ADD("dcs_int_timer", internal_timer_callback)
662   MDRV_TIMER_ADD("dcs_hle_timer", transfer_watchdog_callback)
663
656664   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
657665
658666   MDRV_SOUND_ADD("dac1", DMADAC, 0)
r6740r6741
855863   /* reset timers */
856864   dcs.timer_enable = 0;
857865   dcs.timer_scale = 1;
858   timer_adjust_oneshot(dcs.internal_timer, attotime_never, 0);
866   timer_device_adjust_oneshot(dcs.internal_timer, attotime_never, 0);
859867
860868   /* start the SPORT0 timer */
861   if (dcs.sport_timer)
862      timer_adjust_periodic(dcs.sport_timer, ATTOTIME_IN_HZ(1000), 0, ATTOTIME_IN_HZ(1000));
869   if (dcs.sport_timer != NULL)
870      timer_device_adjust_periodic(dcs.sport_timer, ATTOTIME_IN_HZ(1000), 0, ATTOTIME_IN_HZ(1000));
863871
864872   /* reset the HLE transfer states */
865873   transfer.dcs_state = transfer.state = 0;
r6740r6741
948956   memory_configure_bank(machine, "databank", 0, dcs.sounddata_banks, dcs.sounddata, 0x1000*2);
949957
950958   /* create the timers */
951   dcs.internal_timer = timer_alloc(machine, internal_timer_callback, NULL);
952   dcs.reg_timer = timer_alloc(machine, dcs_irq, NULL);
959   dcs.internal_timer = devtag_get_device(machine, "dcs_int_timer");
960   dcs.reg_timer = devtag_get_device(machine, "dcs_reg_timer");
953961
954962   /* non-RAM based automatically acks */
955963   dcs.auto_ack = TRUE;
r6740r6741
10131021   dcs_sram = auto_alloc_array(machine, UINT16, 0x8000*4/2);
10141022
10151023   /* create the timers */
1016   dcs.internal_timer = timer_alloc(machine, internal_timer_callback, NULL);
1017   dcs.reg_timer = timer_alloc(machine, dcs_irq, NULL);
1018   dcs.sport_timer = timer_alloc(machine, sport0_irq, NULL);
1024   dcs.internal_timer = devtag_get_device(machine, "dcs_int_timer");
1025   dcs.reg_timer = devtag_get_device(machine, "dcs_reg_timer");
1026   dcs.sport_timer = devtag_get_device(machine, "dcs_sport_timer");
10191027
10201028   /* we don't do auto-ack by default */
10211029   dcs.auto_ack = FALSE;
r6740r6741
10281036   /* allocate a watchdog timer for HLE transfers */
10291037   transfer.hle_enabled = (ENABLE_HLE_TRANSFERS && dram_in_mb != 0);
10301038   if (transfer.hle_enabled)
1031      transfer.watchdog = timer_alloc(machine, transfer_watchdog_callback, NULL);
1039      transfer.watchdog = devtag_get_device(machine, "dcs_hle_timer");
10321040
10331041   /* register for save states */
10341042   dcs_register_state(machine);
r6740r6741
15821590      return;
15831591
15841592   /* if we are DCS1, set a timer to latch the data */
1585   if (!dcs.sport_timer)
1593   if (dcs.sport_timer == NULL)
15861594      timer_call_after_resynch(dcs.cpu->machine, NULL, data, dcs_delayed_data_w_callback);
15871595   else
15881596       dcs_delayed_data_w(dcs.cpu->machine, data);
r6740r6741
17331741}
17341742
17351743
1736static TIMER_CALLBACK( internal_timer_callback )
1744static TIMER_DEVICE_CALLBACK( internal_timer_callback )
17371745{
17381746   INT64 target_cycles;
17391747
r6740r6741
17451753
17461754   /* set the next timer, but only if it's for a reasonable number */
17471755   if (!dcs.timer_ignore && (dcs.timer_period > 10 || dcs.timer_scale > 1))
1748      timer_adjust_oneshot(dcs.internal_timer, cpu_clocks_to_attotime(dcs.cpu, target_cycles), 0);
1756      timer_device_adjust_oneshot(timer, cpu_clocks_to_attotime(dcs.cpu, target_cycles), 0);
17491757
17501758   /* the IRQ line is edge triggered */
17511759   cpu_set_input_line(dcs.cpu, ADSP2105_TIMER, ASSERT_LINE);
r6740r6741
17811789
17821790   /* adjust the timer if not optimized */
17831791   if (!dcs.timer_ignore)
1784      timer_adjust_oneshot(dcs.internal_timer, cpu_clocks_to_attotime(dcs.cpu, dcs.timer_scale * (dcs.timer_start_count + 1)), 0);
1792      timer_device_adjust_oneshot(dcs.internal_timer, cpu_clocks_to_attotime(dcs.cpu, dcs.timer_scale * (dcs.timer_start_count + 1)), 0);
17851793}
17861794
17871795
r6740r6741
17971805   else
17981806   {
17991807//      mame_printf_debug("Timer disabled\n");
1800      timer_adjust_oneshot(dcs.internal_timer, attotime_never, 0);
1808      timer_device_adjust_oneshot(dcs.internal_timer, attotime_never, 0);
18011809   }
18021810}
18031811
r6740r6741
18751883         if ((data & 0x0800) == 0)
18761884         {
18771885            dmadac_enable(&dcs.dmadac[0], dcs.channels, 0);
1878            timer_adjust_oneshot(dcs.reg_timer, attotime_never, 0);
1886            timer_device_adjust_oneshot(dcs.reg_timer, attotime_never, 0);
18791887         }
18801888         break;
18811889
r6740r6741
18841892         if ((data & 0x0002) == 0)
18851893         {
18861894            dmadac_enable(&dcs.dmadac[0], dcs.channels, 0);
1887            timer_adjust_oneshot(dcs.reg_timer, attotime_never, 0);
1895            timer_device_adjust_oneshot(dcs.reg_timer, attotime_never, 0);
18881896         }
18891897         break;
18901898
r6740r6741
19301938    DCS IRQ GENERATION CALLBACKS
19311939****************************************************************************/
19321940
1933static TIMER_CALLBACK( dcs_irq )
1941static TIMER_DEVICE_CALLBACK( dcs_irq )
19341942{
19351943   /* get the index register */
19361944   int reg = cpu_get_reg(dcs.cpu, ADSP2100_I0 + dcs.ireg);
r6740r6741
19661974}
19671975
19681976
1969static TIMER_CALLBACK( sport0_irq )
1977static TIMER_DEVICE_CALLBACK( sport0_irq )
19701978{
19711979   /* this latches internally, so we just pulse */
19721980   /* note that there is non-interrupt code that reads/modifies/writes the output_control */
r6740r6741
19962004   if (dcs.incs)
19972005   {
19982006      attotime period = attotime_div(attotime_mul(sample_period, dcs.size), (2 * dcs.channels * dcs.incs));
1999      timer_adjust_periodic(dcs.reg_timer, period, 0, period);
2007      timer_device_adjust_periodic(dcs.reg_timer, period, 0, period);
20002008   }
20012009}
20022010
r6740r6741
20492057   dmadac_enable(&dcs.dmadac[0], dcs.channels, 0);
20502058
20512059   /* remove timer */
2052   timer_adjust_oneshot(dcs.reg_timer, attotime_never, 0);
2060   timer_device_adjust_oneshot(dcs.reg_timer, attotime_never, 0);
20532061}
20542062
20552063
r6740r6741
20972105}
20982106
20992107
2100static TIMER_CALLBACK( transfer_watchdog_callback )
2108static TIMER_DEVICE_CALLBACK( transfer_watchdog_callback )
21012109{
21022110   int starting_writes_left = param;
21032111
21042112   if (transfer.fifo_entries && starting_writes_left == transfer.writes_left)
21052113   {
21062114      for ( ; transfer.fifo_entries; transfer.fifo_entries--)
2107         preprocess_write(machine, (*dcs.fifo_data_r)(dcs.cpu));
2115         preprocess_write(timer->machine, (*dcs.fifo_data_r)(dcs.cpu));
21082116   }
2109   timer_adjust_oneshot(transfer.watchdog, ATTOTIME_IN_MSEC(1), transfer.writes_left);
2117   timer_device_adjust_oneshot(transfer.watchdog, ATTOTIME_IN_MSEC(1), transfer.writes_left);
21102118}
21112119
21122120
r6740r6741
23362344         transfer.sum = 0;
23372345         if (transfer.hle_enabled)
23382346         {
2339            timer_adjust_oneshot(transfer.watchdog, ATTOTIME_IN_MSEC(1), transfer.writes_left);
2347            timer_device_adjust_oneshot(transfer.watchdog, ATTOTIME_IN_MSEC(1), transfer.writes_left);
23402348            return 1;
23412349         }
23422350         break;
r6740r6741
23632371            if (transfer.state == 0)
23642372            {
23652373               timer_set(machine, ATTOTIME_IN_USEC(1), NULL, transfer.sum, s2_ack_callback);
2366               timer_adjust_oneshot(transfer.watchdog, attotime_never, 0);
2374               timer_device_adjust_oneshot(transfer.watchdog, attotime_never, 0);
23672375            }
23682376            return 1;
23692377         }
r6740r6741
23782386   int result;
23792387
23802388   /* if we're not DCS2, skip */
2381   if (!dcs.sport_timer)
2389   if (dcs.sport_timer == NULL)
23822390      return 0;
23832391
23842392   /* state 0 - initialization phase */
src/mame/audio/jedi.c
r6740r6741
1010#include "cpu/m6502/m6502.h"
1111#include "sound/tms5220.h"
1212#include "sound/pokey.h"
13#include "jedi.h"
13#include "includes/jedi.h"
1414
1515
1616
src/mame/audio/galaga.c
r6740r6741
66#include "driver.h"
77#include "namco52.h"
88#include "namco54.h"
9#include "galaga.h"
9#include "includes/galaga.h"
1010
1111
1212/*************************************
src/mame/audio/subs.c
r6740r6741
44
55*************************************************************************/
66#include "driver.h"
7#include "subs.h"
7#include "includes/subs.h"
88#include "sound/discrete.h"
99
1010
src/mame/audio/videopin.c
r6740r6741
44
55*************************************************************************/
66#include "driver.h"
7#include "videopin.h"
7#include "includes/videopin.h"
88#include "sound/discrete.h"
99
1010
src/mame/audio/polepos.c
r6740r6741
88#include "machine/rescap.h"
99#include "namco52.h"
1010#include "namco54.h"
11#include "polepos.h"
11#include "includes/polepos.h"
1212
1313static int sample_msb = 0;
1414static int sample_lsb = 0;
src/mame/audio/exidy.c
r6740r6741
1313#include "machine/6532riot.h"
1414#include "sound/hc55516.h"
1515#include "sound/tms5220.h"
16#include "exidy.h"
16#include "includes/exidy.h"
1717
1818
1919
src/mame/audio/tank8.c
r6740r6741
44
55*************************************************************************/
66#include "driver.h"
7#include "tank8.h"
7#include "includes/tank8.h"
88#include "sound/discrete.h"
99
1010
r6740r6741
247247   DISCRETE_ADDER2(NODE_125, 1 , NODE_122, NODE_124 )
248248   DISCRETE_MULTIPLY(NODE_126, NODE_120, NODE_125 )
249249   DISCRETE_RCFILTER(NODE_127, NODE_126, RES_K(47), CAP_U(0.1))
250   DISCRETE_ADJUSTMENT_TAG(NODE_128,
250   DISCRETE_ADJUSTMENT(NODE_128,
251251            1.0,            // min gain of E5
252252            1.0 + 100.0/22,      // max gain of E5 = 1 + r132/r101
253253            DISC_LINADJ, "CRASH")
src/mame/audio/8080bw.c
r6740r6741
1/* 8080bw.c *********************************
2 */
1/* 8080bw.c *******************************************/
2
33#include "driver.h"
4#include "8080bw.h"
5#include "mw8080bw.h"
64#include "sound/samples.h"
75#include "sound/sn76477.h"
86#include "sound/discrete.h"
97#include "sound/speaker.h"
8#include "includes/mw8080bw.h"
109
1110
12static emu_timer *schaser_effect_555_timer;
13static attotime schaser_effect_555_time_remain;
14static INT32 schaser_effect_555_time_remain_savable;
15static int schaser_effect_555_is_low;
16static int schaser_explosion;
17static UINT8 port_1_last_extra = 0;
18static UINT8 port_2_last_extra = 0;
19static UINT8 port_3_last_extra = 0;
20
2111/*******************************************************/
2212/*                                                     */
2313/* Global state registration                           */
r6740r6741
2616
2717MACHINE_START( extra_8080bw_sh )
2818{
29    state_save_register_global(machine, port_1_last_extra);
30    state_save_register_global(machine, port_2_last_extra);
31    state_save_register_global(machine, port_3_last_extra);
19   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
20
21   state_save_register_global(machine, state->port_1_last_extra);
22   state_save_register_global(machine, state->port_2_last_extra);
23   state_save_register_global(machine, state->port_3_last_extra);
3224}
3325
3426/*******************************************************/
r6740r6741
3931
4032WRITE8_HANDLER( invadpt2_sh_port_1_w )
4133{
42   const device_config *samples = devtag_get_device(space->machine, "samples");
43   const device_config *sn = devtag_get_device(space->machine, "snsnd");
44   UINT8 rising_bits = data & ~port_1_last_extra;
34   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
35   UINT8 rising_bits = data & ~state->port_1_last_extra;
4536
46   sn76477_enable_w(sn, !(data & 0x01));         /* SAUCER SOUND */
37   sn76477_enable_w(state->sn, !(data & 0x01));         /* SAUCER SOUND */
4738
48   if (rising_bits & 0x02) sample_start(samples, 0, 0, 0);      /* MISSLE SOUND */
49   if (rising_bits & 0x04) sample_start(samples, 1, 1, 0);      /* EXPLOSION */
50   if (rising_bits & 0x08) sample_start(samples, 2, 2, 0);      /* INVADER HIT */
51   if (rising_bits & 0x10) sample_start(samples, 5, 8, 0);      /* BONUS MISSILE BASE */
39   if (rising_bits & 0x02) sample_start(state->samples, 0, 0, 0);      /* MISSLE SOUND */
40   if (rising_bits & 0x04) sample_start(state->samples, 1, 1, 0);      /* EXPLOSION */
41   if (rising_bits & 0x08) sample_start(state->samples, 2, 2, 0);      /* INVADER HIT */
42   if (rising_bits & 0x10) sample_start(state->samples, 5, 8, 0);      /* BONUS MISSILE BASE */
5243
53    c8080bw_screen_red_w(data & 0x04);
44   state->screen_red = data & 0x04;
5445
5546   sound_global_enable(space->machine, data & 0x20);
5647
57   port_1_last_extra = data;
48   state->port_1_last_extra = data;
5849
5950}
6051
r6740r6741
6758       D2 = 82K
6859       D3 = 100K */
6960
70   const device_config *samples = devtag_get_device(space->machine, "samples");
71   UINT8 rising_bits = data & ~port_2_last_extra;
61   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
62   UINT8 rising_bits = data & ~state->port_2_last_extra;
7263
73   if (rising_bits & 0x01) sample_start(samples, 4, 3, 0);      /* FLEET */
74   if (rising_bits & 0x02) sample_start(samples, 4, 4, 0);      /* FLEET */
75   if (rising_bits & 0x04) sample_start(samples, 4, 5, 0);      /* FLEET */
76   if (rising_bits & 0x08) sample_start(samples, 4, 6, 0);      /* FLEET */
77   if (rising_bits & 0x10) sample_start(samples, 3, 7, 0);      /* SAUCER HIT */
64   if (rising_bits & 0x01) sample_start(state->samples, 4, 3, 0);      /* FLEET */
65   if (rising_bits & 0x02) sample_start(state->samples, 4, 4, 0);      /* FLEET */
66   if (rising_bits & 0x04) sample_start(state->samples, 4, 5, 0);      /* FLEET */
67   if (rising_bits & 0x08) sample_start(state->samples, 4, 6, 0);      /* FLEET */
68   if (rising_bits & 0x10) sample_start(state->samples, 3, 7, 0);      /* SAUCER HIT */
7869
79    c8080bw_flip_screen_w(space, data & 0x20);
70   state->c8080bw_flip_screen = data & 0x20;
8071
81   port_2_last_extra = data;
72   state->port_2_last_extra = data;
8273}
8374
8475
r6740r6741
9081
9182WRITE8_HANDLER( spcewars_sh_port_w )
9283{
93   const device_config *samples = devtag_get_device(space->machine, "samples");
94   const device_config *speaker = devtag_get_device(space->machine, "speaker");
95   const device_config *sn = devtag_get_device(space->machine, "snsnd");
96   UINT8 rising_bits = data & ~port_1_last_extra;
84   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
85   UINT8 rising_bits = data & ~state->port_1_last_extra;
9786
98   sn76477_enable_w(sn, !(data & 0x01));         /* Saucer Sound */
87   sn76477_enable_w(state->sn, !(data & 0x01));         /* Saucer Sound */
9988
100   if (rising_bits & 0x02) sample_start(samples, 0, 0, 0);      /* Shot Sound */
101   if (rising_bits & 0x04) sample_start(samples, 1, 1, 0);      /* Base Hit */
102   if (rising_bits & 0x08) sample_start(samples, 2, 2, 0);      /* Invader Hit */
89   if (rising_bits & 0x02) sample_start(state->samples, 0, 0, 0);      /* Shot Sound */
90   if (rising_bits & 0x04) sample_start(state->samples, 1, 1, 0);      /* Base Hit */
91   if (rising_bits & 0x08) sample_start(state->samples, 2, 2, 0);      /* Invader Hit */
10392
104   speaker_level_w(speaker, (data & 0x10) ? 1 : 0);      /* Various bitstream tunes */
93   speaker_level_w(state->speaker, (data & 0x10) ? 1 : 0);      /* Various bitstream tunes */
10594
106   port_1_last_extra = data;
95   state->port_1_last_extra = data;
10796}
10897
10998
r6740r6741
136125
137126WRITE8_HANDLER( lrescue_sh_port_1_w )
138127{
139   const device_config *samples = devtag_get_device(space->machine, "samples");
140   UINT8 rising_bits = data & ~port_1_last_extra;
128   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
129   UINT8 rising_bits = data & ~state->port_1_last_extra;
141130
142   if (rising_bits & 0x01) sample_start(samples, 0, 3, 0);      /* Thrust */
143   if (rising_bits & 0x02) sample_start(samples, 1, 2, 0);      /* Shot Sound */
144   if (rising_bits & 0x04) sample_start(samples, 0, 1, 0);      /* Death */
145   if (rising_bits & 0x08) sample_start(samples, 1, 0, 0);      /* Alien Hit */
146   if (rising_bits & 0x10) sample_start(samples, 2, 5, 0);      /* Bonus Ship (not confirmed) */
131   if (rising_bits & 0x01) sample_start(state->samples, 0, 3, 0);      /* Thrust */
132   if (rising_bits & 0x02) sample_start(state->samples, 1, 2, 0);      /* Shot Sound */
133   if (rising_bits & 0x04) sample_start(state->samples, 0, 1, 0);      /* Death */
134   if (rising_bits & 0x08) sample_start(state->samples, 1, 0, 0);      /* Alien Hit */
135   if (rising_bits & 0x10) sample_start(state->samples, 2, 5, 0);      /* Bonus Ship (not confirmed) */
147136
148137   sound_global_enable(space->machine, data & 0x20);
149138
150   c8080bw_screen_red_w(data & 0x04);
139   state->screen_red = data & 0x04;
151140
152   port_1_last_extra = data;
141   state->port_1_last_extra = data;
153142}
154143
155144WRITE8_HANDLER( lrescue_sh_port_2_w )
156145{
157   const device_config *samples = devtag_get_device(space->machine, "samples");
158   const device_config *speaker = devtag_get_device(space->machine, "speaker");
159   UINT8 rising_bits = data & ~port_2_last_extra;
146   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
147   UINT8 rising_bits = data & ~state->port_2_last_extra;
160148
161   if (rising_bits & 0x01) sample_start(samples, 1, 8, 0);      /* Footstep high tone */
162   if (rising_bits & 0x02) sample_start(samples, 1, 7, 0);      /* Footstep low tone */
163   if (rising_bits & 0x04) sample_start(samples, 1, 4, 0);      /* Bonus when counting men saved */
149   if (rising_bits & 0x01) sample_start(state->samples, 1, 8, 0);      /* Footstep high tone */
150   if (rising_bits & 0x02) sample_start(state->samples, 1, 7, 0);      /* Footstep low tone */
151   if (rising_bits & 0x04) sample_start(state->samples, 1, 4, 0);      /* Bonus when counting men saved */
164152
165   speaker_level_w(speaker, (data & 0x08) ? 1 : 0);      /* Bitstream tunes - endlevel and bonus1 */
153   speaker_level_w(state->speaker, (data & 0x08) ? 1 : 0);      /* Bitstream tunes - endlevel and bonus1 */
166154
167   if (rising_bits & 0x10) sample_start(samples, 3, 6, 0);      /* Shooting Star and Rescue Ship sounds */
168   if (~data & 0x10 && port_2_last_extra & 0x10) sample_stop (samples, 3);   /* This makes the rescue ship sound beep on and off */
155   if (rising_bits & 0x10) sample_start(state->samples, 3, 6, 0);      /* Shooting Star and Rescue Ship sounds */
156   if (~data & 0x10 && state->port_2_last_extra & 0x10) sample_stop (state->samples, 3);   /* This makes the rescue ship sound beep on and off */
169157
170   c8080bw_flip_screen_w(space, data & 0x20);
158   state->c8080bw_flip_screen = data & 0x20;
171159
172   port_2_last_extra = data;
160   state->port_2_last_extra = data;
173161}
174162
175163
r6740r6741
195183
196184WRITE8_HANDLER( ballbomb_sh_port_1_w )
197185{
198   const device_config *samples = devtag_get_device(space->machine, "samples");
199   UINT8 rising_bits = data & ~port_1_last_extra;
186   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
187   UINT8 rising_bits = data & ~state->port_1_last_extra;
200188
201   if (rising_bits & 0x01) sample_start(samples, 1, 2, 0);      /* Hit a balloon */
202   if (rising_bits & 0x02) sample_start(samples, 2, 0, 0);      /* Shot Sound */
203   if (rising_bits & 0x04) sample_start(samples, 2, 1, 0);      /* Base Hit */
204   if (rising_bits & 0x08) sample_start(samples, 1, 7, 0);      /* Hit a Bomb */
205   if (rising_bits & 0x10) sample_start(samples, 3, 8, 0);      /* Bonus Base at 1500 points */
189   if (rising_bits & 0x01) sample_start(state->samples, 1, 2, 0);      /* Hit a balloon */
190   if (rising_bits & 0x02) sample_start(state->samples, 2, 0, 0);      /* Shot Sound */
191   if (rising_bits & 0x04) sample_start(state->samples, 2, 1, 0);      /* Base Hit */
192   if (rising_bits & 0x08) sample_start(state->samples, 1, 7, 0);      /* Hit a Bomb */
193   if (rising_bits & 0x10) sample_start(state->samples, 3, 8, 0);      /* Bonus Base at 1500 points */
206194
207195   sound_global_enable(space->machine, data & 0x20);
208196
209   c8080bw_screen_red_w(data & 0x04);
197   state->screen_red = data & 0x04;
210198
211   port_1_last_extra = data;
199   state->port_1_last_extra = data;
212200}
213201
214202WRITE8_HANDLER( ballbomb_sh_port_2_w )
215203{
216   const device_config *samples = devtag_get_device(space->machine, "samples");
217   UINT8 rising_bits = data & ~port_2_last_extra;
204   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
205   UINT8 rising_bits = data & ~state->port_2_last_extra;
218206
219   if (data & 0x01) sample_start(samples, 0, 7, 0);      /* Indicates plane will drop bombs */
220   if (data & 0x04) sample_start(samples, 0, 4, 0);      /* Plane is dropping new balloons at start of level */
221   if (rising_bits & 0x10) sample_start(samples, 2, 2, 0);      /* Balloon hit and bomb drops */
207   if (data & 0x01) sample_start(state->samples, 0, 7, 0);      /* Indicates plane will drop bombs */
208   if (data & 0x04) sample_start(state->samples, 0, 4, 0);      /* Plane is dropping new balloons at start of level */
209   if (rising_bits & 0x10) sample_start(state->samples, 2, 2, 0);      /* Balloon hit and bomb drops */
222210
223   c8080bw_flip_screen_w(space, data & 0x20);
211   state->c8080bw_flip_screen = data & 0x20;
224212
225   port_2_last_extra = data;
213   state->port_2_last_extra = data;
226214}
227215
228216
r6740r6741
272260WRITE8_HANDLER( indianbt_sh_port_1_w )
273261{
274262   /* bit 4 occurs every 5.25 seconds during gameplay */
263   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
264   UINT8 rising_bits = data & ~state->port_1_last_extra;
275265
276   const device_config *samples = devtag_get_device(space->machine, "samples");
277   UINT8 rising_bits = data & ~port_1_last_extra;
266   if (rising_bits & 0x01) sample_start(state->samples, 1, 7, 0);      /* Death */
267   if (rising_bits & 0x02) sample_start(state->samples, 0, 1, 0);      /* Shot Sound */
268   if (rising_bits & 0x04) sample_start(state->samples, 2, 3, 0);      /* Move */
269   if (rising_bits & 0x08) sample_start(state->samples, 3, 2, 0);      /* Hit */
278270
279   if (rising_bits & 0x01) sample_start(samples, 1, 7, 0);   /* Death */
280   if (rising_bits & 0x02) sample_start(samples, 0, 1, 0);      /* Shot Sound */
281   if (rising_bits & 0x04) sample_start(samples, 2, 3, 0);      /* Move */
282   if (rising_bits & 0x08) sample_start(samples, 3, 2, 0);      /* Hit */
283
284271   sound_global_enable(space->machine, data & 0x20);
285272
286   c8080bw_screen_red_w(data & 0x01);
273   state->screen_red = data & 0x01;
287274
288   port_1_last_extra = data;
275   state->port_1_last_extra = data;
289276}
290277
291278WRITE8_HANDLER( indianbt_sh_port_2_w )
292279{
293   const device_config *samples = devtag_get_device(space->machine, "samples");
294   UINT8 rising_bits = data & ~port_2_last_extra;
280   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
281   UINT8 rising_bits = data & ~state->port_2_last_extra;
295282
296   if (rising_bits & 0x01) sample_start(samples, 4, 0, 0);      /* Bird dropped an egg, Lasso used */
297   if (rising_bits & 0x02) sample_start(samples, 4, 2, 0);   /* Egg hatches, egg shot */
298   if (rising_bits & 0x08) sample_start(samples, 5, 0, 0);      /* Grabber, Lasso caught something */
299   if (rising_bits & 0x10) sample_start(samples, 3, 7, 0);      /* Lasso sound */
283   if (rising_bits & 0x01) sample_start(state->samples, 4, 0, 0);      /* Bird dropped an egg, Lasso used */
284   if (rising_bits & 0x02) sample_start(state->samples, 4, 2, 0);      /* Egg hatches, egg shot */
285   if (rising_bits & 0x08) sample_start(state->samples, 5, 0, 0);      /* Grabber, Lasso caught something */
286   if (rising_bits & 0x10) sample_start(state->samples, 3, 7, 0);      /* Lasso sound */
300287
301   port_2_last_extra = data;
288   state->port_2_last_extra = data;
302289}
303290
304291WRITE8_DEVICE_HANDLER( indianbt_sh_port_3_w )
r6740r6741
455442
456443   /* We will cheat and just use the controls to scale the amplitude. */
457444   /* It is the same as taking the (0 to 50k)/50k */
458   DISCRETE_ADJUSTMENT_TAG(POLARIS_ADJ_VR1, 0, 1, DISC_LINADJ, "VR1")
459   DISCRETE_ADJUSTMENT_TAG(POLARIS_ADJ_VR2, 0, 1, DISC_LINADJ, "VR2")
445   DISCRETE_ADJUSTMENT(POLARIS_ADJ_VR1, 0, 1, DISC_LINADJ, "VR1")
446   DISCRETE_ADJUSTMENT(POLARIS_ADJ_VR2, 0, 1, DISC_LINADJ, "VR2")
460447   /* Extra cheating for VR3.  We will include the resistor scaling. */
461   DISCRETE_ADJUSTMENT_TAG(POLARIS_ADJ_VR3, 0, 0.5376, DISC_LINADJ, "VR3")
448   DISCRETE_ADJUSTMENT(POLARIS_ADJ_VR3, 0, 0.5376, DISC_LINADJ, "VR3")
462449
463450/******************************************************************************
464451 *
r6740r6741
646633
647634WRITE8_DEVICE_HANDLER( polaris_sh_port_3_w )
648635{
636   mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data;
649637
650638   coin_lockout_global_w(device->machine, data & 0x04);  /* SX8 */
651639
652   c8080bw_flip_screen_w(cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM), data & 0x20);  /* SX11 */
640   state->c8080bw_flip_screen = data & 0x20;      /* SX11 */
653641
654642   /* 0x01 - SX6 - Plane Down */
655643   discrete_sound_w(device, POLARIS_SX6_EN, data & 0x01);
r6740r6741
749737   /* We will set them to adjust the realitive     */
750738   /* gains.                                       */
751739   /************************************************/
752   DISCRETE_ADJUSTMENT_TAG(SCHASER_VR1, 0, RES_K(50)/(RES_K(50) + RES_K(470)), DISC_LINADJ, "VR1")
753   DISCRETE_ADJUSTMENT_TAG(SCHASER_VR2, 0, RES_K(50)/(RES_K(50) + 560 + RES_K(6.8) + RES_K(2)), DISC_LINADJ, "VR2")
754   DISCRETE_ADJUSTMENT_TAG(SCHASER_VR3, 0, RES_K(50)/(RES_K(50) + 560 + RES_K(6.8) + RES_K(10)), DISC_LINADJ, "VR3")
740   DISCRETE_ADJUSTMENT(SCHASER_VR1, 0, RES_K(50)/(RES_K(50) + RES_K(470)), DISC_LINADJ, "VR1")
741   DISCRETE_ADJUSTMENT(SCHASER_VR2, 0, RES_K(50)/(RES_K(50) + 560 + RES_K(6.8) + RES_K(2)), DISC_LINADJ, "VR2")
742   DISCRETE_ADJUSTMENT(SCHASER_VR3, 0, RES_K(50)/(RES_K(50) + 560 + RES_K(6.8) + RES_K(10)), DISC_LINADJ, "VR3")
755743
756744   /************************************************/
757745   /* Dot selection just selects between 4V and 8V */
r6740r6741
799787
800788WRITE8_HANDLER( schaser_sh_port_1_w )
801789{
802   const device_config *discrete = devtag_get_device(space->machine, "discrete");
803   const device_config *sn = devtag_get_device(space->machine, "snsnd");
804   static int last_effect = 0;
790   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
805791   int effect;
806792
807793   /* bit 0 - Dot Sound Enable (SX0)
r6740r6741
812798       bit 5 - Explosion (SX5) */
813799
814800    //printf( "schaser_sh_port_1_w: %02x\n", data );
815   discrete_sound_w(discrete, SCHASER_DOT_EN, data & 0x01);
816   discrete_sound_w(discrete, SCHASER_DOT_SEL, data & 0x02);
801   discrete_sound_w(state->discrete, SCHASER_DOT_EN, data & 0x01);
802   discrete_sound_w(state->discrete, SCHASER_DOT_SEL, data & 0x02);
817803
818804   /* The effect is a variable rate 555 timer.  A diode/resistor array is used to
819805     * select the frequency.  Because of the diode voltage drop, we can not use the
r6740r6741
822808     * but the bleed time is so long, that we can just cheat and put the time on hold
823809     * when effect = 0. */
824810   effect = (data >> 2) & 0x07;
825   if (last_effect != effect)
811   if (state->schaser_last_effect != effect)
826812   {
827813      if (effect)
828814      {
829         if (attotime_compare(schaser_effect_555_time_remain, attotime_zero) != 0)
815         if (attotime_compare(state->schaser_effect_555_time_remain, attotime_zero) != 0)
830816         {
831817            /* timer re-enabled, use up remaining 555 high time */
832            timer_adjust_oneshot(schaser_effect_555_timer, schaser_effect_555_time_remain, effect);
818            timer_adjust_oneshot(state->schaser_effect_555_timer, state->schaser_effect_555_time_remain, effect);
833819         }
834         else if (!schaser_effect_555_is_low)
820         else if (!state->schaser_effect_555_is_low)
835821         {
836822            /* set 555 high time */
837823            attotime new_time = attotime_make(0, ATTOSECONDS_PER_SECOND * .8873 * schaser_effect_rc[effect]);
838            timer_adjust_oneshot(schaser_effect_555_timer, new_time, effect);
824            timer_adjust_oneshot(state->schaser_effect_555_timer, new_time, effect);
839825         }
840826      }
841827      else
842828      {
843829         /* disable effect - stops at end of low cycle */
844         if (!schaser_effect_555_is_low)
830         if (!state->schaser_effect_555_is_low)
845831         {
846            schaser_effect_555_time_remain = timer_timeleft(schaser_effect_555_timer);
847                schaser_effect_555_time_remain_savable = attotime_to_double(schaser_effect_555_time_remain);
848            timer_adjust_oneshot(schaser_effect_555_timer, attotime_never, 0);
832            state->schaser_effect_555_time_remain = timer_timeleft(state->schaser_effect_555_timer);
833                  state->schaser_effect_555_time_remain_savable = attotime_to_double(state->schaser_effect_555_time_remain);
834            timer_adjust_oneshot(state->schaser_effect_555_timer, attotime_never, 0);
849835         }
850836      }
851      last_effect = effect;
837      state->schaser_last_effect = effect;
852838   }
853839
854   schaser_explosion = (data >> 5) & 0x01;
855   if (schaser_explosion)
840   state->schaser_explosion = (data >> 5) & 0x01;
841   if (state->schaser_explosion)
856842   {
857      sn76477_amplitude_res_w(sn, 1.0 / (1.0/RES_K(200) + 1.0/RES_K(68)));
843      sn76477_amplitude_res_w(state->sn, 1.0 / (1.0/RES_K(200) + 1.0/RES_K(68)));
858844   }
859845   else
860846   {
861      sn76477_amplitude_res_w(sn, RES_K(200));
847      sn76477_amplitude_res_w(state->sn, RES_K(200));
862848   }
863   sn76477_enable_w(sn, !(schaser_effect_555_is_low || schaser_explosion));
864   sn76477_one_shot_cap_voltage_w(sn, !(schaser_effect_555_is_low || schaser_explosion) ? 0 : SN76477_EXTERNAL_VOLTAGE_DISCONNECT);
865   sn76477_mixer_b_w(sn, schaser_explosion);
849   sn76477_enable_w(state->sn, !(state->schaser_effect_555_is_low || state->schaser_explosion));
850   sn76477_one_shot_cap_voltage_w(state->sn, !(state->schaser_effect_555_is_low || state->schaser_explosion) ? 0 : SN76477_EXTERNAL_VOLTAGE_DISCONNECT);
851   sn76477_mixer_b_w(state->sn, state->schaser_explosion);
866852}
867853
868854WRITE8_HANDLER( schaser_sh_port_2_w )
r6740r6741
874860       bit 4 - Field Control B (SX10)
875861       bit 5 - Flip Screen */
876862
877   const device_config *discrete = devtag_get_device(space->machine, "discrete");
863   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
878864
879    //printf( "schaser_sh_port_2_w: %02x\n", data );
865   //printf( "schaser_sh_port_2_w: %02x\n", data );
880866
881   discrete_sound_w(discrete, SCHASER_MUSIC_BIT, data & 0x01);
867   discrete_sound_w(state->discrete, SCHASER_MUSIC_BIT, data & 0x01);
882868
883   discrete_sound_w(discrete, SCHASER_SND_EN, data & 0x02);
869   discrete_sound_w(state->discrete, SCHASER_SND_EN, data & 0x02);
884870   sound_global_enable(space->machine, data & 0x02);
885871
886872   coin_lockout_global_w(space->machine, data & 0x04);
887873
888   schaser_background_control_w(data & 0x18);
874   state->schaser_background_disable = (data >> 3) & 0x01;
875   state->schaser_background_select = (data >> 4) & 0x01;
889876
890   c8080bw_flip_screen_w(space, data & 0x20);
877   state->c8080bw_flip_screen = data & 0x20;
891878
892    port_2_last_extra = data;
879   state->port_2_last_extra = data;
893880}
894881
895882
896883static TIMER_CALLBACK( schaser_effect_555_cb )
897884{
898   const device_config *sn = devtag_get_device(machine, "snsnd");
885   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
899886   int effect = param;
900887   attotime new_time;
901888   /* Toggle 555 output */
902   schaser_effect_555_is_low = !schaser_effect_555_is_low;
903   schaser_effect_555_time_remain = attotime_zero;
904    schaser_effect_555_time_remain_savable = attotime_to_double(schaser_effect_555_time_remain);
889   state->schaser_effect_555_is_low = !state->schaser_effect_555_is_low;
890   state->schaser_effect_555_time_remain = attotime_zero;
891   state->schaser_effect_555_time_remain_savable = attotime_to_double(state->schaser_effect_555_time_remain);
905892
906   if (schaser_effect_555_is_low)
893   if (state->schaser_effect_555_is_low)
907894      new_time = attotime_div(PERIOD_OF_555_ASTABLE(0, RES_K(20), CAP_U(1)), 2);
908895   else
909896   {
r6740r6741
912899      else
913900         new_time = attotime_never;
914901   }
915   timer_adjust_oneshot(schaser_effect_555_timer, new_time, effect);
916   sn76477_enable_w(sn, !(schaser_effect_555_is_low || schaser_explosion));
917   sn76477_one_shot_cap_voltage_w(sn, !(schaser_effect_555_is_low || schaser_explosion) ? 0 : SN76477_EXTERNAL_VOLTAGE_DISCONNECT);
902   timer_adjust_oneshot(state->schaser_effect_555_timer, new_time, effect);
903   sn76477_enable_w(state->sn, !(state->schaser_effect_555_is_low || state->schaser_explosion));
904   sn76477_one_shot_cap_voltage_w(state->sn, !(state->schaser_effect_555_is_low || state->schaser_explosion) ? 0 : SN76477_EXTERNAL_VOLTAGE_DISCONNECT);
918905}
919906
920907
921908static STATE_POSTLOAD( schaser_reinit_555_time_remain )
922909{
923    const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
924    schaser_effect_555_time_remain = double_to_attotime(schaser_effect_555_time_remain_savable);
925    schaser_sh_port_2_w(space, 0, port_2_last_extra);
910   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
911   const address_space *space = cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM);
912   state->schaser_effect_555_time_remain = double_to_attotime(state->schaser_effect_555_time_remain_savable);
913   schaser_sh_port_2_w(space, 0, state->port_2_last_extra);
926914}
927915
928916
929MACHINE_START( schaser )
917MACHINE_START( schaser_sh )
930918{
931   schaser_effect_555_timer = timer_alloc(machine, schaser_effect_555_cb, NULL);
919   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
932920
933    state_save_register_global(machine, schaser_explosion);
934    state_save_register_global(machine, schaser_effect_555_is_low);
935    state_save_register_global(machine, schaser_effect_555_time_remain_savable);
936    state_save_register_global(machine, port_2_last_extra);
937    state_save_register_postload(machine, schaser_reinit_555_time_remain, NULL);
921   state->schaser_effect_555_timer = timer_alloc(machine, schaser_effect_555_cb, NULL);
938922
939    MACHINE_START_CALL(extra_8080bw_vh);
940   MACHINE_START_CALL(mw8080bw);
923   state_save_register_global(machine, state->schaser_explosion);
924   state_save_register_global(machine, state->schaser_effect_555_is_low);
925   state_save_register_global(machine, state->schaser_effect_555_time_remain_savable);
926   state_save_register_global(machine, state->port_2_last_extra);
927   state_save_register_postload(machine, schaser_reinit_555_time_remain, NULL);
941928}
942929
943930
944MACHINE_RESET( schaser )
931MACHINE_RESET( schaser_sh )
945932{
933   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
946934   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
947   schaser_effect_555_is_low = 0;
948   timer_adjust_oneshot(schaser_effect_555_timer, attotime_never, 0);
935
936   state->schaser_effect_555_is_low = 0;
937   timer_adjust_oneshot(state->schaser_effect_555_timer, attotime_never, 0);
949938   schaser_sh_port_1_w(space, 0, 0);
950939   schaser_sh_port_2_w(space, 0, 0);
951   schaser_effect_555_time_remain = attotime_zero;
952    schaser_effect_555_time_remain_savable = attotime_to_double(schaser_effect_555_time_remain);
953
954   MACHINE_RESET_CALL(mw8080bw);
940   state->schaser_effect_555_time_remain = attotime_zero;
941   state->schaser_effect_555_time_remain_savable = attotime_to_double(state->schaser_effect_555_time_remain);
955942}
956943
957944
r6740r6741
963950
964951WRITE8_HANDLER( rollingc_sh_port_w )
965952{
966   const device_config *samples = devtag_get_device(space->machine, "samples");
967   UINT8 rising_bits = data & ~port_3_last_extra;
953   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
954   UINT8 rising_bits = data & ~state->port_3_last_extra;
968955
969   if (rising_bits & 0x02) sample_start(samples, 4, 0, 0);   /* Steering */
970   if (rising_bits & 0x04) sample_start(samples, 0, 1, 0);   /* Collision */
971   if (rising_bits & 0x10) sample_start(samples, 1, 8, 0);   /* Computer car is starting to move */
956   if (rising_bits & 0x02) sample_start(state->samples, 4, 0, 0);   /* Steering */
957   if (rising_bits & 0x04) sample_start(state->samples, 0, 1, 0);   /* Collision */
958   if (rising_bits & 0x10) sample_start(state->samples, 1, 8, 0);   /* Computer car is starting to move */
972959
973   port_3_last_extra = data;
960   state->port_3_last_extra = data;
974961}
975962
976963
r6740r6741
987974
988975WRITE8_HANDLER( invrvnge_sh_port_w )
989976{
990   const device_config *samples = devtag_get_device(space->machine, "samples");
977   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
978
991979   switch (data)
992980   {
993981      case 0x06:
994         sample_start(samples, 1, 0, 0);            /* Shoot */
982         sample_start(state->samples, 1, 0, 0);            /* Shoot */
995983         break;
996984
997985      case 0x14:
998         sample_start(samples, 2, 2, 0);            /* Hit Alien */
986         sample_start(state->samples, 2, 2, 0);            /* Hit Alien */
999987         break;
1000988
1001989      case 0x16:
1002         sample_start(samples, 2, 5, 0);            /* Hit Asteroid */
990         sample_start(state->samples, 2, 5, 0);            /* Hit Asteroid */
1003991         break;
1004992
1005993      case 0x1e:
1006         sample_start(samples, 3, 1, 0);            /* Death (followed by 0x0a byte), also bit 4 of port 5 */
994         sample_start(state->samples, 3, 1, 0);            /* Death (followed by 0x0a byte), also bit 4 of port 5 */
1007995         break;
1008996
1009997      case 0x18:                  /* Fuel Low */
1010998      case 0x30:                  /* Fuel bar filling up */
1011         sample_start(samples, 4, 7, 0);
999         sample_start(state->samples, 4, 7, 0);
10121000         break;
10131001
10141002      case 0x02:                  /* Coin */
r6740r6741
10181006         break;
10191007
10201008      case 0x3a:                  /* Thrust, Docking, extra ship? */
1021         sample_start(samples, 0, 8, 0);
1009         sample_start(state->samples, 0, 8, 0);
10221010         break;
10231011   }
10241012}
r6740r6741
10311019
10321020WRITE8_HANDLER( lupin3_sh_port_1_w )
10331021{
1034   const device_config *samples = devtag_get_device(space->machine, "samples");
1035   const device_config *sn = devtag_get_device(space->machine, "snsnd");
1036   UINT8 rising_bits = data & ~port_1_last_extra;
1022   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
1023   UINT8 rising_bits = data & ~state->port_1_last_extra;
10371024
1038   if (rising_bits & 0x01) sample_start(samples, 0, 6, 0);      /* Walking, get money */
1025   if (rising_bits & 0x01) sample_start(state->samples, 0, 6, 0);      /* Walking, get money */
10391026
1040   sn76477_enable_w(sn, data & 0x02 ? 0:1);         /* Helicopter */
1027   sn76477_enable_w(state->sn, data & 0x02 ? 0:1);         /* Helicopter */
10411028
1042   if (rising_bits & 0x04) sample_start(samples, 0, 7, 0);      /* Translocate */
1043   if (rising_bits & 0x08) sample_start(samples, 0, 1, 0);      /* Jail */
1044   if (rising_bits & 0x10) sample_start(samples, 3, 8, 0);      /* Bonus Man */
1029   if (rising_bits & 0x04) sample_start(state->samples, 0, 7, 0);      /* Translocate */
1030   if (rising_bits & 0x08) sample_start(state->samples, 0, 1, 0);      /* Jail */
1031   if (rising_bits & 0x10) sample_start(state->samples, 3, 8, 0);      /* Bonus Man */
10451032
1046   port_1_last_extra = data;
1033   state->port_1_last_extra = data;
10471034}
10481035
10491036WRITE8_HANDLER( lupin3_sh_port_2_w )
10501037{
1051   const device_config *samples = devtag_get_device(space->machine, "samples");
1052   UINT8 rising_bits = data & ~port_2_last_extra;
1038   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
1039   UINT8 rising_bits = data & ~state->port_2_last_extra;
10531040
1054   if (rising_bits & 0x01) sample_start(samples, 0, 3, 0);      /* Lands on top of building, wife kicks man */
1055   if (rising_bits & 0x02) sample_start(samples, 1, 2, 0);      /* deposit money, start intermission, end game */
1056   if (rising_bits & 0x04) sample_start(samples, 2, 5, 0);      /* deposit money, start intermission, Slides down rope */
1057   if (rising_bits & 0x08) sample_start(samples, 3, 0, 0);      /* start intermission, end game */
1058   //if (rising_bits & 0x10) sample_start(samples, 3, 9, 0);        /* Dog barking */
1041   if (rising_bits & 0x01) sample_start(state->samples, 0, 3, 0);      /* Lands on top of building, wife kicks man */
1042   if (rising_bits & 0x02) sample_start(state->samples, 1, 2, 0);      /* deposit money, start intermission, end game */
1043   if (rising_bits & 0x04) sample_start(state->samples, 2, 5, 0);      /* deposit money, start intermission, Slides down rope */
1044   if (rising_bits & 0x08) sample_start(state->samples, 3, 0, 0);      /* start intermission, end game */
1045   //if (rising_bits & 0x10) sample_start(state->samples, 3, 9, 0);        /* Dog barking */
10591046
1060   lupin3_flip_screen_w(space, data & 0x60);
1047   state->color_map = data & 0x40;
10611048
1062   port_2_last_extra = data;
1049   state->c8080bw_flip_screen = (data & 0x20) && (input_port_read(space->machine, "IN2") & 0x04);
1050
1051   state->port_2_last_extra = data;
10631052}
10641053
10651054
r6740r6741
10751064       bit 3 = 1st speedup
10761065       Death is a stream of ff's with some fe's thrown in */
10771066
1078   const device_config *samples = devtag_get_device(space->machine, "samples");
1079   UINT8 rising_bits = data & ~port_1_last_extra;
1067   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
1068   UINT8 rising_bits = data & ~state->port_1_last_extra;
10801069
1081   if (rising_bits & 0x02) sample_start(samples, 1, 6, 0);      /* Ran over a dot */
1082   if (rising_bits & 0x10) sample_start(samples, 0, 1, 0);      /* Death */
1070   if (rising_bits & 0x02) sample_start(state->samples, 1, 6, 0);      /* Ran over a dot */
1071   if (rising_bits & 0x10) sample_start(state->samples, 0, 1, 0);      /* Death */
10831072
1084   port_1_last_extra = data;
1073   state->port_1_last_extra = data;
10851074}
10861075
10871076WRITE8_HANDLER( schasrcv_sh_port_2_w )
10881077{
1089   const device_config *speaker = devtag_get_device(space->machine, "speaker");
1078   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
10901079
1091   speaker_level_w(speaker, (data & 0x01) ? 1 : 0);      /* End-of-Level */
1080   speaker_level_w(state->speaker, (data & 0x01) ? 1 : 0);      /* End-of-Level */
10921081
10931082   sound_global_enable(space->machine, data & 0x10);
10941083
1095   c8080bw_flip_screen_w(space, data & 0x20);
1084   state->c8080bw_flip_screen = data & 0x20;
10961085}
10971086
10981087
r6740r6741
11031092
11041093WRITE8_HANDLER( yosakdon_sh_port_1_w )
11051094{
1106   const device_config *samples = devtag_get_device(space->machine, "samples");
1107   UINT8 rising_bits = data & ~port_1_last_extra;
1095   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
1096   UINT8 rising_bits = data & ~state->port_1_last_extra;
11081097
1109   if (rising_bits & 0x01) sample_start(samples, 0, 3, 0);         /* Game Over */
1110   if (rising_bits & 0x02) sample_start(samples, 2, 0, 0);         /* Bird dead */
1111   if (rising_bits & 0x04) sample_start(samples, 0, 1, 0);         /* Rifle being fired */
1112   if (rising_bits & 0x08) sample_start(samples, 1, 2, 0);         /* Man dead */
1113   if (rising_bits & 0x10) sample_start(samples, 5, 8, 0);         /* Bonus Man? */
1098   if (rising_bits & 0x01) sample_start(state->samples, 0, 3, 0);         /* Game Over */
1099   if (rising_bits & 0x02) sample_start(state->samples, 2, 0, 0);         /* Bird dead */
1100   if (rising_bits & 0x04) sample_start(state->samples, 0, 1, 0);         /* Rifle being fired */
1101   if (rising_bits & 0x08) sample_start(state->samples, 1, 2, 0);         /* Man dead */
1102   if (rising_bits & 0x10) sample_start(state->samples, 5, 8, 0);         /* Bonus Man? */
11141103
11151104   sound_global_enable(space->machine, data & 0x20);
11161105
1117   port_1_last_extra = data;
1106   state->port_1_last_extra = data;
11181107}
11191108
11201109WRITE8_HANDLER( yosakdon_sh_port_2_w )
11211110{
1122   const device_config *samples = devtag_get_device(space->machine, "samples");
1123   const device_config *sn = devtag_get_device(space->machine, "snsnd");
1124   UINT8 rising_bits = data & ~port_2_last_extra;
1111   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
1112   UINT8 rising_bits = data & ~state->port_2_last_extra;
11251113
1126   if (rising_bits & 0x01) sample_start(samples, 1, 6, 0);         /* Ready? , Game Over */
1127   if (rising_bits & 0x04) sample_start(samples, 3, 7, 0);         /* Big bird dead */
1114   if (rising_bits & 0x01) sample_start(state->samples, 1, 6, 0);         /* Ready? , Game Over */
1115   if (rising_bits & 0x04) sample_start(state->samples, 3, 7, 0);         /* Big bird dead */
11281116
1129   sn76477_enable_w(sn, data & 0x08 ? 0:1);            /* Big bird */
1117   sn76477_enable_w(state->sn, data & 0x08 ? 0:1);            /* Big bird */
11301118
1131   if (rising_bits & 0x10) sample_start(samples, 2, 7, 0);         /* Game Over */
1119   if (rising_bits & 0x10) sample_start(state->samples, 2, 7, 0);         /* Game Over */
11321120
1133   c8080bw_flip_screen_w(space, data & 0x20);
1121   state->c8080bw_flip_screen = data & 0x20;
11341122
1135   port_2_last_extra = data;
1123   state->port_2_last_extra = data;
11361124}
11371125
11381126
r6740r6741
11441132WRITE8_HANDLER( shuttlei_sh_port_1_w )
11451133{
11461134   /* bit 3 is high while you are alive and playing */
1135   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
1136   UINT8 rising_bits = data & ~state->port_1_last_extra;
11471137
1148   const device_config *samples = devtag_get_device(space->machine, "samples");
1149   const device_config *sn = devtag_get_device(space->machine, "snsnd");
1150   UINT8 rising_bits = data & ~port_1_last_extra;
1138   if (rising_bits & 0x01) sample_start(state->samples, 4, 4, 0);         /* Fleet move */
1139   if (rising_bits & 0x02) sample_start(state->samples, 5, 8, 0);         /* Extra Tank */
11511140
1152   if (rising_bits & 0x01) sample_start(samples, 4, 4, 0);         /* Fleet move */
1153   if (rising_bits & 0x02) sample_start(samples, 5, 8, 0);         /* Extra Tank */
1141   sn76477_enable_w(state->sn, data & 0x04 ? 0:1);            /* UFO */
11541142
1155   sn76477_enable_w(sn, data & 0x04 ? 0:1);            /* UFO */
1156
1157   port_1_last_extra = data;
1143   state->port_1_last_extra = data;
11581144}
11591145
11601146WRITE8_HANDLER( shuttlei_sh_port_2_w )
11611147{
1162   const device_config *samples = devtag_get_device(space->machine, "samples");
1148   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
1149
11631150   switch (data)
11641151   {
11651152      case 0x23:
1166         sample_start(samples, 2, 2, 0);            /* Hit */
1153         sample_start(state->samples, 2, 2, 0);            /* Hit */
11671154         break;
11681155
11691156      case 0x2b:
1170         sample_start(samples, 0, 0, 0);            /* Shoot */
1157         sample_start(state->samples, 0, 0, 0);            /* Shoot */
11711158         break;
11721159
11731160      case 0xa3:
1174         sample_start(samples, 3, 7, 0);            /* Hit UFO */
1161         sample_start(state->samples, 3, 7, 0);            /* Hit UFO */
11751162         break;
11761163
11771164      case 0xab:
1178         sample_start(samples, 1, 1, 0);            /* Death */
1165         sample_start(state->samples, 1, 1, 0);            /* Death */
11791166         break;
11801167   }
11811168}
src/mame/audio/mw8080bw.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "mw8080bw.h"
98#include "sound/samples.h"
109#include "sound/sn76477.h"
1110#include "sound/discrete.h"
11#include "includes/mw8080bw.h"
1212
1313
14
1514/*************************************
1615 *
17 *  Globals
18 *
19 *************************************/
20
21static UINT8 port_1_last;
22static UINT8 port_2_last;
23
24
25
26/*************************************
27 *
2816 *  Audio setup
2917 *
3018 *************************************/
3119
3220static SOUND_START( samples )
3321{
22   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
23
3424   /* setup for save states */
35   state_save_register_global(machine, port_1_last);
36   state_save_register_global(machine, port_2_last);
25   state_save_register_global(machine, state->port_1_last);
26   state_save_register_global(machine, state->port_2_last);
3727}
3828
3929
40
4130/*************************************
4231 *
4332 *  Implementation of tone generator used
r6740r6741
4534 *
4635 *************************************/
4736
48#define MIDWAY_TONE_EN            NODE_100
49#define MIDWAY_TONE_DATA_L         NODE_101
50#define MIDWAY_TONE_DATA_H         NODE_102
51#define MIDWAY_TONE_SND            NODE_103
52#define MIDWAY_TONE_TRASFORM_OUT   NODE_104
53#define MIDWAY_TONE_BEFORE_AMP_SND   NODE_105
37#define MIDWAY_TONE_EN              NODE_100
38#define MIDWAY_TONE_DATA_L          NODE_101
39#define MIDWAY_TONE_DATA_H          NODE_102
40#define MIDWAY_TONE_SND             NODE_103
41#define MIDWAY_TONE_TRASFORM_OUT    NODE_104
42#define MIDWAY_TONE_BEFORE_AMP_SND  NODE_105
5443
5544
5645#define MIDWAY_TONE_GENERATOR(discrete_op_amp_tvca_info) \
r6740r6741
176165
177166WRITE8_HANDLER( seawolf_audio_w )
178167{
179   const device_config *samples = devtag_get_device(space->machine, "samples");
180   UINT8 rising_bits = data & ~port_1_last;
168   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
169   UINT8 rising_bits = data & ~state->port_1_last;
181170
182171   /* if (data & 0x01)  enable SHIP HIT sound */
183   if (rising_bits & 0x01) sample_start(samples, 0, 0, 0);
172   if (rising_bits & 0x01) sample_start(state->samples, 0, 0, 0);
184173
185174   /* if (data & 0x02)  enable TORPEDO sound */
186   if (rising_bits & 0x02) sample_start(samples, 1, 1, 0);
175   if (rising_bits & 0x02) sample_start(state->samples, 1, 1, 0);
187176
188177   /* if (data & 0x04)  enable DIVE sound */
189   if (rising_bits & 0x04) sample_start(samples, 2, 2, 0);
178   if (rising_bits & 0x04) sample_start(state->samples, 2, 2, 0);
190179
191180   /* if (data & 0x08)  enable SONAR sound */
192   if (rising_bits & 0x08) sample_start(samples, 3, 3, 0);
181   if (rising_bits & 0x08) sample_start(state->samples, 3, 3, 0);
193182
194183   /* if (data & 0x10)  enable MINE HIT sound */
195   if (rising_bits & 0x10) sample_start(samples, 4, 4, 0);
184   if (rising_bits & 0x10) sample_start(state->samples, 4, 4, 0);
196185
197186   coin_counter_w(space->machine, 0, (data >> 5) & 0x01);
198187
199188   /* D6 and D7 are not connected */
200189
201   port_1_last = data;
190   state->port_1_last = data;
202191}
203192
204193
r6740r6741
242231
243232WRITE8_HANDLER( gunfight_audio_w )
244233{
245   const device_config *samples0 = devtag_get_device(space->machine, "samples1");
246   const device_config *samples1 = devtag_get_device(space->machine, "samples2");
234   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
247235
248236   /* D0 and D1 are just tied to 1k resistors */
249237
r6740r6741
257245
258246   case 0x01:
259247      /* enable LEFT SHOOT sound (left speaker) */
260      sample_start(samples0, 0, 0, 0);
248      sample_start(state->samples1, 0, 0, 0);
261249      break;
262250
263251   case 0x02:
264252      /* enable RIGHT SHOOT sound (right speaker) */
265      sample_start(samples1, 0, 0, 0);
253      sample_start(state->samples2, 0, 0, 0);
266254      break;
267255
268256   case 0x03:
269257      /* enable LEFT HIT sound (left speaker) */
270      sample_start(samples0, 0, 1, 0);
258      sample_start(state->samples1, 0, 1, 0);
271259      break;
272260
273261   case 0x04:
274262      /* enable RIGHT HIT sound (right speaker) */
275      sample_start(samples1, 0, 1, 0);
263      sample_start(state->samples2, 0, 1, 0);
276264      break;
277265
278266   default:
279      logerror("%04x:  Unknown sh port write %02x\n",cpu_get_pc(space->cpu),data);
267      logerror("%04x:  Unknown sh port write %02x\n", cpu_get_pc(space->cpu), data);
280268      break;
281269   }
282270}
r6740r6741
289277 *
290278 *************************************/
291279
292#define TORNBASE_SQUAREW_240      NODE_01
293#define TORNBASE_SQUAREW_960      NODE_02
294#define TORNBASE_SQUAREW_120      NODE_03
280#define TORNBASE_SQUAREW_240        NODE_01
281#define TORNBASE_SQUAREW_960        NODE_02
282#define TORNBASE_SQUAREW_120        NODE_03
295283
296#define TORNBASE_TONE_240_EN      NODE_04
297#define TORNBASE_TONE_960_EN      NODE_05
298#define TORNBASE_TONE_120_EN      NODE_06
284#define TORNBASE_TONE_240_EN        NODE_04
285#define TORNBASE_TONE_960_EN        NODE_05
286#define TORNBASE_TONE_120_EN        NODE_06
299287
300#define TORNBASE_TONE_240_SND      NODE_07
301#define TORNBASE_TONE_960_SND      NODE_08
302#define TORNBASE_TONE_120_SND      NODE_09
303#define TORNBASE_TONE_SND         NODE_10
304#define TORNBASE_TONE_SND_FILT      NODE_11
288#define TORNBASE_TONE_240_SND       NODE_07
289#define TORNBASE_TONE_960_SND       NODE_08
290#define TORNBASE_TONE_120_SND       NODE_09
291#define TORNBASE_TONE_SND           NODE_10
292#define TORNBASE_TONE_SND_FILT      NODE_11
305293
306294
307295static DISCRETE_SOUND_START(tornbase)
r6740r6741
425413 *************************************/
426414
427415/* nodes - inputs */
428#define MAZE_P1_DATA         NODE_01
429#define MAZE_P2_DATA         NODE_02
430#define MAZE_TONE_TIMING      NODE_03
431#define MAZE_COIN            NODE_04
416#define MAZE_P1_DATA             NODE_01
417#define MAZE_P2_DATA             NODE_02
418#define MAZE_TONE_TIMING         NODE_03
419#define MAZE_COIN                NODE_04
432420
433421/* nodes - other */
434#define MAZE_JOYSTICK_IN_USE   NODE_11
435#define MAZE_AUDIO_ENABLE      NODE_12
436#define MAZE_TONE_ENABLE      NODE_13
437#define MAZE_GAME_OVER         NODE_14
438#define MAZE_R305_306_308      NODE_15
439#define MAZE_R303_309         NODE_16
440#define MAZE_PLAYER_SEL         NODE_17
422#define MAZE_JOYSTICK_IN_USE     NODE_11
423#define MAZE_AUDIO_ENABLE        NODE_12
424#define MAZE_TONE_ENABLE         NODE_13
425#define MAZE_GAME_OVER           NODE_14
426#define MAZE_R305_306_308        NODE_15
427#define MAZE_R303_309            NODE_16
428#define MAZE_PLAYER_SEL          NODE_17
441429
442430/* nodes - sounds */
443#define MAZE_SND            NODE_18
431#define MAZE_SND                 NODE_18
444432
445433
446434static const discrete_555_desc maze_555_F2 =
r6740r6741
618606 *************************************/
619607
620608/* nodes - inputs */
621#define BOOTHILL_GAME_ON_EN         NODE_01
622#define BOOTHILL_LEFT_SHOT_EN      NODE_02
623#define BOOTHILL_RIGHT_SHOT_EN      NODE_03
624#define BOOTHILL_LEFT_HIT_EN      NODE_04
625#define BOOTHILL_RIGHT_HIT_EN      NODE_05
609#define BOOTHILL_GAME_ON_EN         NODE_01
610#define BOOTHILL_LEFT_SHOT_EN       NODE_02
611#define BOOTHILL_RIGHT_SHOT_EN      NODE_03
612#define BOOTHILL_LEFT_HIT_EN        NODE_04
613#define BOOTHILL_RIGHT_HIT_EN       NODE_05
626614
627615/* nodes - sounds */
628#define BOOTHILL_NOISE            NODE_06
629#define BOOTHILL_L_SHOT_SND         NODE_07
630#define BOOTHILL_R_SHOT_SND         NODE_08
631#define BOOTHILL_L_HIT_SND         NODE_09
632#define BOOTHILL_R_HIT_SND         NODE_10
616#define BOOTHILL_NOISE              NODE_06
617#define BOOTHILL_L_SHOT_SND         NODE_07
618#define BOOTHILL_R_SHOT_SND         NODE_08
619#define BOOTHILL_L_HIT_SND          NODE_09
620#define BOOTHILL_R_HIT_SND          NODE_10
633621
634622/* nodes - adjusters */
635#define BOOTHILL_MUSIC_ADJ         NODE_11
623#define BOOTHILL_MUSIC_ADJ          NODE_11
636624
637625
638626static const discrete_op_amp_tvca_info boothill_tone_tvca_info =
r6740r6741
771759   /* The low value of the pot is set to 75000.  A real 1M pot will never go to 0 anyways.
772760       This will give the control more apparent volume range.
773761       The music way overpowers the rest of the sounds anyways. */
774   DISCRETE_ADJUSTMENT_TAG(BOOTHILL_MUSIC_ADJ, RES_M(1), 75000, DISC_LOGADJ, "MUSIC_ADJ")
762   DISCRETE_ADJUSTMENT(BOOTHILL_MUSIC_ADJ, RES_M(1), 75000, DISC_LOGADJ, "MUSIC_ADJ")
775763
776764   /************************************************
777765     * Tone generator
r6740r6741
862850 *************************************/
863851
864852/* nodes - inputs */
865#define CHECKMAT_BOOM_EN         NODE_01
866#define CHECKMAT_TONE_EN         NODE_02
867#define CHECKMAT_TONE_DATA_45      NODE_03
868#define CHECKMAT_TONE_DATA_67      NODE_04
853#define CHECKMAT_BOOM_EN            NODE_01
854#define CHECKMAT_TONE_EN            NODE_02
855#define CHECKMAT_TONE_DATA_45       NODE_03
856#define CHECKMAT_TONE_DATA_67       NODE_04
869857
870858/* nodes - other */
871#define CHECKMAT_R401_402_400      NODE_06
872#define CHECKMAT_R407_406_410      NODE_07
859#define CHECKMAT_R401_402_400       NODE_06
860#define CHECKMAT_R407_406_410       NODE_07
873861
874862/* nodes - sounds */
875#define CHECKMAT_BOOM_SND         NODE_10
876#define CHECKMAT_TONE_SND         NODE_11
877#define CHECKMAT_FINAL_SND         NODE_12
863#define CHECKMAT_BOOM_SND           NODE_10
864#define CHECKMAT_TONE_SND           NODE_11
865#define CHECKMAT_FINAL_SND          NODE_12
878866
879867/* nodes - adjusters */
880#define CHECKMAT_R309            NODE_15
881#define CHECKMAT_R411            NODE_16
868#define CHECKMAT_R309               NODE_15
869#define CHECKMAT_R411               NODE_16
882870
883871
884872static const discrete_comp_adder_table checkmat_r401_402_400 =
r6740r6741
975963   /* This is needed because the original controls are infinite, but the UI only gives 100 steps. */
976964   /* Also real variable resistors never hit 0 ohms.  There is always some resistance. */
977965   /* R309 mostly just increases the Boom clipping, making it sound bassier. */
978   DISCRETE_ADJUSTMENT_TAG(CHECKMAT_R309, RES_K(100), 1000, DISC_LOGADJ, "R309")
979   DISCRETE_ADJUSTMENT_TAG(CHECKMAT_R411, RES_M(1), 1000, DISC_LOGADJ, "R411")
966   DISCRETE_ADJUSTMENT(CHECKMAT_R309, RES_K(100), 1000, DISC_LOGADJ, "R309")
967   DISCRETE_ADJUSTMENT(CHECKMAT_R411, RES_M(1), 1000, DISC_LOGADJ, "R411")
980968
981969   /************************************************
982970     * Boom Sound
r6740r6741
10901078 *************************************/
10911079
10921080/* nodes - inputs */
1093#define DESERTGU_GAME_ON_EN               NODE_01
1094#define DESERTGU_RIFLE_SHOT_EN            NODE_02
1095#define DESERTGU_BOTTLE_HIT_EN            NODE_03
1096#define DESERTGU_ROAD_RUNNER_HIT_EN         NODE_04
1097#define DESERTGU_CREATURE_HIT_EN         NODE_05
1098#define DESERTGU_ROADRUNNER_BEEP_BEEP_EN   NODE_06
1099#define DESERTGU_TRIGGER_CLICK_EN         NODE_07
1081#define DESERTGU_GAME_ON_EN                   NODE_01
1082#define DESERTGU_RIFLE_SHOT_EN                NODE_02
1083#define DESERTGU_BOTTLE_HIT_EN                NODE_03
1084#define DESERTGU_ROAD_RUNNER_HIT_EN           NODE_04
1085#define DESERTGU_CREATURE_HIT_EN              NODE_05
1086#define DESERTGU_ROADRUNNER_BEEP_BEEP_EN      NODE_06
1087#define DESERTGU_TRIGGER_CLICK_EN             NODE_07
11001088
11011089/* nodes - sounds */
1102#define DESERTGU_NOISE                  NODE_08
1103#define DESERTGU_RIFLE_SHOT_SND            NODE_09
1104#define DESERTGU_BOTTLE_HIT_SND            NODE_10
1105#define DESERTGU_ROAD_RUNNER_HIT_SND      NODE_11
1106#define DESERTGU_CREATURE_HIT_SND         NODE_12
1107#define DESERTGU_ROADRUNNER_BEEP_BEEP_SND   NODE_13
1108#define DESERTGU_TRIGGER_CLICK_SND         DESERTGU_TRIGGER_CLICK_EN
1090#define DESERTGU_NOISE                        NODE_08
1091#define DESERTGU_RIFLE_SHOT_SND               NODE_09
1092#define DESERTGU_BOTTLE_HIT_SND               NODE_10
1093#define DESERTGU_ROAD_RUNNER_HIT_SND          NODE_11
1094#define DESERTGU_CREATURE_HIT_SND             NODE_12
1095#define DESERTGU_ROADRUNNER_BEEP_BEEP_SND     NODE_13
1096#define DESERTGU_TRIGGER_CLICK_SND            DESERTGU_TRIGGER_CLICK_EN
11091097
11101098/* nodes - adjusters */
1111#define DESERTGU_MUSIC_ADJ               NODE_15
1099#define DESERTGU_MUSIC_ADJ                    NODE_15
11121100
11131101
11141102static const discrete_op_amp_tvca_info desertgu_rifle_shot_tvca_info =
r6740r6741
12161204   /* The low value of the pot is set to 75000.  A real 1M pot will never go to 0 anyways. */
12171205   /* This will give the control more apparent volume range. */
12181206   /* The music way overpowers the rest of the sounds anyways. */
1219   DISCRETE_ADJUSTMENT_TAG(DESERTGU_MUSIC_ADJ, RES_M(1), 75000, DISC_LOGADJ, "MUSIC_ADJ")
1207   DISCRETE_ADJUSTMENT(DESERTGU_MUSIC_ADJ, RES_M(1), 75000, DISC_LOGADJ, "MUSIC_ADJ")
12201208
12211209   /************************************************
12221210     * Tone generator
r6740r6741
12961284
12971285WRITE8_DEVICE_HANDLER( desertgu_audio_2_w )
12981286{
1287   mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data;
1288
12991289   discrete_sound_w(device, DESERTGU_ROADRUNNER_BEEP_BEEP_EN, (data >> 0) & 0x01);
13001290
13011291   discrete_sound_w(device, DESERTGU_TRIGGER_CLICK_EN, (data >> 1) & 0x01);
13021292
13031293   output_set_value("KICKER", (data >> 2) & 0x01);
13041294
1305   desertgun_set_controller_select((data >> 3) & 0x01);
1295   state->desertgun_controller_select = (data >> 3) & 0x01;
13061296
13071297   /* D4-D7 are not connected */
13081298}
r6740r6741
13181308 *************************************/
13191309
13201310/* nodes - inputs */
1321#define DPLAY_GAME_ON_EN   NODE_01
1322#define DPLAY_TONE_ON_EN   NODE_02
1323#define DPLAY_SIREN_EN      NODE_03
1324#define DPLAY_WHISTLE_EN   NODE_04
1325#define DPLAY_CHEER_EN      NODE_05
1311#define DPLAY_GAME_ON_EN      NODE_01
1312#define DPLAY_TONE_ON_EN      NODE_02
1313#define DPLAY_SIREN_EN        NODE_03
1314#define DPLAY_WHISTLE_EN      NODE_04
1315#define DPLAY_CHEER_EN        NODE_05
13261316
13271317/* nodes - sounds */
1328#define DPLAY_NOISE         NODE_06
1329#define DPLAY_TONE_SND      NODE_07
1330#define DPLAY_SIREN_SND      NODE_08
1331#define DPLAY_WHISTLE_SND   NODE_09
1332#define DPLAY_CHEER_SND      NODE_10
1318#define DPLAY_NOISE           NODE_06
1319#define DPLAY_TONE_SND        NODE_07
1320#define DPLAY_SIREN_SND       NODE_08
1321#define DPLAY_WHISTLE_SND     NODE_09
1322#define DPLAY_CHEER_SND       NODE_10
13331323
13341324/* nodes - adjusters */
1335#define DPLAY_MUSIC_ADJ      NODE_11
1325#define DPLAY_MUSIC_ADJ       NODE_11
13361326
13371327
13381328static const discrete_lfsr_desc dplay_lfsr =
r6740r6741
14821472   /* The low value of the pot is set to 1000.  A real 1M pot will never go to 0 anyways. */
14831473   /* This will give the control more apparent volume range. */
14841474   /* The music way overpowers the rest of the sounds anyways. */
1485   DISCRETE_ADJUSTMENT_TAG(DPLAY_MUSIC_ADJ, RES_M(1), 1000, DISC_LOGADJ, "MUSIC_ADJ")
1475   DISCRETE_ADJUSTMENT(DPLAY_MUSIC_ADJ, RES_M(1), 1000, DISC_LOGADJ, "MUSIC_ADJ")
14861476
14871477   /************************************************
14881478     * Music and Tone Generator
r6740r6741
16031593       reversed (D5=R, D7=L), but the software confirms that
16041594       ours is right */
16051595
1606   const device_config *samples0 = devtag_get_device(space->machine, "samples1");
1607   const device_config *samples1 = devtag_get_device(space->machine, "samples2");
1608   UINT8 rising_bits = data & ~port_1_last;
1596   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
1597   UINT8 rising_bits = data & ~state->port_1_last;
16091598
16101599   /* D0 and D1 are not connected */
16111600
r6740r6741
16141603   sound_global_enable(space->machine, (data >> 3) & 0x01);
16151604
16161605   /* if (data & 0x10)  enable RIGHT MISSILE sound (goes to right speaker) */
1617   if (rising_bits & 0x10) sample_start(samples1, 0, 0, 0);
1606   if (rising_bits & 0x10) sample_start(state->samples2, 0, 0, 0);
16181607
16191608   /* if (data & 0x20)  enable LEFT EXPLOSION sound (goes to left speaker) */
16201609   output_set_value("L_EXP_LIGHT", (data >> 5) & 0x01);
1621   if (rising_bits & 0x20) sample_start(samples0, 0, 1, 0);
1610   if (rising_bits & 0x20) sample_start(state->samples1, 0, 1, 0);
16221611
16231612   /* if (data & 0x40)  enable LEFT MISSILE sound (goes to left speaker) */
1624   if (rising_bits & 0x40) sample_start(samples0, 0, 0, 0);
1613   if (rising_bits & 0x40) sample_start(state->samples1, 0, 0, 0);
16251614
16261615   /* if (data & 0x80)  enable RIGHT EXPLOSION sound (goes to right speaker) */
16271616   output_set_value("R_EXP_LIGHT", (data >> 7) & 0x01);
1628   if (rising_bits & 0x80) sample_start(samples1, 0, 1, 0);
1617   if (rising_bits & 0x80) sample_start(state->samples2, 0, 1, 0);
16291618
1630   port_1_last = data;
1619   state->port_1_last = data;
16311620}
16321621
16331622
r6740r6741
16991688
17001689WRITE8_HANDLER( m4_audio_1_w )
17011690{
1702   const device_config *samples0 = devtag_get_device(space->machine, "samples1");
1703   const device_config *samples1 = devtag_get_device(space->machine, "samples2");
1704   UINT8 rising_bits = data & ~port_1_last;
1691   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
1692   UINT8 rising_bits = data & ~state->port_1_last;
17051693
17061694   /* D0 and D1 are not connected */
17071695
r6740r6741
17101698   sound_global_enable(space->machine, (data >> 3) & 0x01);
17111699
17121700   /* if (data & 0x10)  enable LEFT PLAYER SHOT sound (goes to left speaker) */
1713   if (rising_bits & 0x10) sample_start(samples0, 0, 0, 0);
1701   if (rising_bits & 0x10) sample_start(state->samples1, 0, 0, 0);
17141702
17151703   /* if (data & 0x20)  enable RIGHT PLAYER SHOT sound (goes to right speaker) */
1716   if (rising_bits & 0x20) sample_start(samples1, 0, 0, 0);
1704   if (rising_bits & 0x20) sample_start(state->samples2, 0, 0, 0);
17171705
17181706   /* if (data & 0x40)  enable LEFT PLAYER EXPLOSION sound via 300K res (goes to left speaker) */
1719   if (rising_bits & 0x40) sample_start(samples0, 1, 1, 0);
1707   if (rising_bits & 0x40) sample_start(state->samples1, 1, 1, 0);
17201708
17211709   /* if (data & 0x80)  enable RIGHT PLAYER EXPLOSION sound via 300K res (goes to right speaker) */
1722   if (rising_bits & 0x80) sample_start(samples1, 1, 1, 0);
1710   if (rising_bits & 0x80) sample_start(state->samples2, 1, 1, 0);
17231711
1724   port_1_last = data;
1712   state->port_1_last = data;
17251713}
17261714
17271715
17281716WRITE8_HANDLER( m4_audio_2_w )
17291717{
1730   const device_config *samples0 = devtag_get_device(space->machine, "samples1");
1731   const device_config *samples1 = devtag_get_device(space->machine, "samples2");
1732   UINT8 rising_bits = data & ~port_2_last;
1718   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
1719   UINT8 rising_bits = data & ~state->port_2_last;
17331720
17341721   /* if (data & 0x01)  enable LEFT PLAYER EXPLOSION sound via 510K res (goes to left speaker) */
1735   if (rising_bits & 0x01) sample_start(samples0, 1, 1, 0);
1722   if (rising_bits & 0x01) sample_start(state->samples1, 1, 1, 0);
17361723
17371724   /* if (data & 0x02)  enable RIGHT PLAYER EXPLOSION sound via 510K res (goes to right speaker) */
1738   if (rising_bits & 0x02) sample_start(samples1, 1, 1, 0);
1725   if (rising_bits & 0x02) sample_start(state->samples2, 1, 1, 0);
17391726
17401727   /* if (data & 0x04)  enable LEFT TANK MOTOR sound (goes to left speaker) */
17411728
r6740r6741
17491736
17501737   /* D6 and D7 are not connected */
17511738
1752   port_2_last = data;
1739   state->port_2_last = data;
17531740}
17541741
17551742
r6740r6741
17631750 *************************************/
17641751
17651752/* nodes - inputs */
1766#define CLOWNS_POP_BOTTOM_EN      NODE_01
1767#define CLOWNS_POP_MIDDLE_EN      NODE_02
1768#define CLOWNS_POP_TOP_EN         NODE_03
1769#define CLOWNS_SPRINGBOARD_HIT_EN   NODE_04
1770#define CLOWNS_SPRINGBOARD_MISS_EN   NODE_05
1753#define CLOWNS_POP_BOTTOM_EN        NODE_01
1754#define CLOWNS_POP_MIDDLE_EN        NODE_02
1755#define CLOWNS_POP_TOP_EN           NODE_03
1756#define CLOWNS_SPRINGBOARD_HIT_EN   NODE_04
1757#define CLOWNS_SPRINGBOARD_MISS_EN  NODE_05
17711758
17721759/* nodes - sounds */
1773#define CLOWNS_NOISE            NODE_06
1774#define CLOWNS_POP_SND            NODE_07
1775#define CLOWNS_SB_HIT_SND         NODE_08
1776#define CLOWNS_SB_MISS_SND         NODE_09
1760#define CLOWNS_NOISE                NODE_06
1761#define CLOWNS_POP_SND              NODE_07
1762#define CLOWNS_SB_HIT_SND           NODE_08
1763#define CLOWNS_SB_MISS_SND          NODE_09
17771764
17781765/* nodes - adjusters */
1779#define CLOWNS_R507_POT            NODE_11
1766#define CLOWNS_R507_POT             NODE_11
17801767
17811768
17821769static const discrete_op_amp_tvca_info clowns_pop_tvca_info =
r6740r6741
18891876   /* The low value of the pot is set to 7000.  A real 1M pot will never go to 0 anyways. */
18901877   /* This will give the control more apparent volume range. */
18911878   /* The music way overpowers the rest of the sounds anyways. */
1892   DISCRETE_ADJUSTMENT_TAG(CLOWNS_R507_POT, RES_M(1), 7000, DISC_LOGADJ, "R507")
1879   DISCRETE_ADJUSTMENT(CLOWNS_R507_POT, RES_M(1), 7000, DISC_LOGADJ, "R507")
18931880
18941881   /************************************************
18951882     * Tone generator
r6740r6741
19631950
19641951WRITE8_HANDLER( clowns_audio_1_w )
19651952{
1953   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
19661954   coin_counter_w(space->machine, 0, (data >> 0) & 0x01);
19671955
1968   clowns_set_controller_select((data >> 1) & 0x01);
1956   state->clowns_controller_select = (data >> 1) & 0x01;
19691957
19701958   /* D2-D7 are not connected */
19711959}
r6740r6741
19731961
19741962WRITE8_DEVICE_HANDLER( clowns_audio_2_w )
19751963{
1976   const device_config *samples = devtag_get_device(device->machine, "samples");
1977   UINT8 rising_bits = data & ~port_2_last;
1964   mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data;
1965   UINT8 rising_bits = data & ~state->port_2_last;
19781966
19791967   discrete_sound_w(device, CLOWNS_POP_BOTTOM_EN, (data >> 0) & 0x01);
19801968
r6740r6741
19861974
19871975   discrete_sound_w(device, CLOWNS_SPRINGBOARD_HIT_EN, (data >> 4) & 0x01);
19881976
1989   if (rising_bits & 0x20) sample_start(samples, 0, 0, 0);  /* springboard miss */
1977   if (rising_bits & 0x20) sample_start(state->samples, 0, 0, 0);  /* springboard miss */
19901978
19911979   /* D6 and D7 are not connected */
19921980
1993   port_2_last = data;
1981   state->port_2_last = data;
19941982}
19951983
19961984
r6740r6741
20041992 *************************************/
20051993
20061994 /* Discrete Sound Input Nodes */
2007#define SPACWALK_TARGET_HIT_BOTTOM_EN      NODE_01
2008#define SPACWALK_TARGET_HIT_MIDDLE_EN      NODE_02
2009#define SPACWALK_TARGET_HIT_TOP_EN         NODE_03
2010#define SPACWALK_SPRINGBOARD_HIT1_EN      NODE_04
2011#define SPACWALK_SPRINGBOARD_HIT2_EN      NODE_05
2012#define SPACWALK_SPRINGBOARD_MISS_EN      NODE_06
2013#define SPACWALK_SPACE_SHIP_EN            NODE_07
1995#define SPACWALK_TARGET_HIT_BOTTOM_EN         NODE_01
1996#define SPACWALK_TARGET_HIT_MIDDLE_EN         NODE_02
1997#define SPACWALK_TARGET_HIT_TOP_EN            NODE_03
1998#define SPACWALK_SPRINGBOARD_HIT1_EN          NODE_04
1999#define SPACWALK_SPRINGBOARD_HIT2_EN          NODE_05
2000#define SPACWALK_SPRINGBOARD_MISS_EN          NODE_06
2001#define SPACWALK_SPACE_SHIP_EN                NODE_07
20142002
20152003/* Discrete Sound Output Nodes */
2016#define SPACWALK_NOISE                  NODE_10
2017#define SPACWALK_TARGET_HIT_SND            NODE_11
2018#define SPACWALK_SPRINGBOARD_HIT1_SND      NODE_12
2019#define SPACWALK_SPRINGBOARD_HIT2_SND      NODE_13
2020#define SPACWALK_SPRINGBOARD_MISS_SND      NODE_14
2021#define SPACWALK_SPACE_SHIP_SND            NODE_15
2004#define SPACWALK_NOISE                        NODE_10
2005#define SPACWALK_TARGET_HIT_SND               NODE_11
2006#define SPACWALK_SPRINGBOARD_HIT1_SND         NODE_12
2007#define SPACWALK_SPRINGBOARD_HIT2_SND         NODE_13
2008#define SPACWALK_SPRINGBOARD_MISS_SND         NODE_14
2009#define SPACWALK_SPACE_SHIP_SND               NODE_15
20222010
20232011/* Adjusters */
2024#define SPACWALK_R507_POT         NODE_19
2012#define SPACWALK_R507_POT                     NODE_19
20252013
20262014/* Parts List - Resistors */
20272015#define SPACWALK_R200      RES_K(820)
r6740r6741
22252213   /* The low value of the pot is set to 7000.  A real 1M pot will never go to 0 anyways. */
22262214   /* This will give the control more apparent volume range. */
22272215   /* The music way overpowers the rest of the sounds anyways. */
2228   DISCRETE_ADJUSTMENT_TAG(SPACWALK_R507_POT, SPACWALK_R507, 7000, DISC_LOGADJ, "R507")
2216   DISCRETE_ADJUSTMENT(SPACWALK_R507_POT, SPACWALK_R507, 7000, DISC_LOGADJ, "R507")
22292217
22302218   /************************************************
22312219     * Tone generator
r6740r6741
23292317
23302318WRITE8_DEVICE_HANDLER( spacwalk_audio_1_w )
23312319{
2320   mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data;
2321
23322322   coin_counter_w(device->machine, 0, (data >> 0) & 0x01);
23332323
2334   clowns_set_controller_select((data >> 1) & 0x01);
2324   state->clowns_controller_select = (data >> 1) & 0x01;
23352325
23362326   sound_global_enable(device->machine, (data >> 2) & 0x01);
23372327
r6740r6741
23642354 *************************************/
23652355
23662356 /* Discrete Sound Input Nodes */
2367#define SHUFFLE_ROLLING_1_EN      NODE_01
2368#define SHUFFLE_ROLLING_2_EN      NODE_02
2369#define SHUFFLE_ROLLING_3_EN      NODE_03
2370#define SHUFFLE_FOUL_EN            NODE_04
2371#define SHUFFLE_ROLLOVER_EN         NODE_05
2372#define SHUFFLE_CLICK_EN         NODE_06
2357#define SHUFFLE_ROLLING_1_EN        NODE_01
2358#define SHUFFLE_ROLLING_2_EN        NODE_02
2359#define SHUFFLE_ROLLING_3_EN        NODE_03
2360#define SHUFFLE_FOUL_EN             NODE_04
2361#define SHUFFLE_ROLLOVER_EN         NODE_05
2362#define SHUFFLE_CLICK_EN            NODE_06
23732363
23742364/* Discrete Sound Output Nodes */
2375#define SHUFFLE_NOISE            NODE_10
2376#define SHUFFLE_ROLLING_SND         NODE_11
2377#define SHUFFLE_FOUL_SND         NODE_12
2378#define SHUFFLE_ROLLOVER_SND      NODE_13
2379#define SHUFFLE_CLICK_SND         NODE_14
2365#define SHUFFLE_NOISE               NODE_10
2366#define SHUFFLE_ROLLING_SND         NODE_11
2367#define SHUFFLE_FOUL_SND            NODE_12
2368#define SHUFFLE_ROLLOVER_SND        NODE_13
2369#define SHUFFLE_CLICK_SND           NODE_14
23802370
23812371/* Parts List - Resistors */
23822372#define SHUFFLE_R300   RES_K(33)
r6740r6741
26772667
26782668
26792669/* nodes - inputs */
2680#define SPCENCTR_ENEMY_SHIP_SHOT_EN      NODE_01
2681#define SPCENCTR_PLAYER_SHOT_EN         NODE_02
2682#define SPCENCTR_SCREECH_EN            NODE_03
2683#define SPCENCTR_CRASH_EN            NODE_04
2684#define SPCENCTR_EXPLOSION_EN         NODE_05
2685#define SPCENCTR_BONUS_EN            NODE_06
2686#define SPCENCTR_WIND_DATA            NODE_07
2670#define SPCENCTR_ENEMY_SHIP_SHOT_EN       NODE_01
2671#define SPCENCTR_PLAYER_SHOT_EN           NODE_02
2672#define SPCENCTR_SCREECH_EN               NODE_03
2673#define SPCENCTR_CRASH_EN                 NODE_04
2674#define SPCENCTR_EXPLOSION_EN             NODE_05
2675#define SPCENCTR_BONUS_EN                 NODE_06
2676#define SPCENCTR_WIND_DATA                NODE_07
26872677
26882678/* nodes - sounds */
2689#define SPCENCTR_NOISE               NODE_10
2690#define SPCENCTR_ENEMY_SHIP_SHOT_SND   NODE_11
2691#define SPCENCTR_PLAYER_SHOT_SND      NODE_12
2692#define SPCENCTR_SCREECH_SND         NODE_13
2693#define SPCENCTR_CRASH_SND            NODE_14
2694#define SPCENCTR_EXPLOSION_SND         NODE_15
2695#define SPCENCTR_BONUS_SND            NODE_16
2696#define SPCENCTR_WIND_SND            NODE_17
2679#define SPCENCTR_NOISE                    NODE_10
2680#define SPCENCTR_ENEMY_SHIP_SHOT_SND      NODE_11
2681#define SPCENCTR_PLAYER_SHOT_SND          NODE_12
2682#define SPCENCTR_SCREECH_SND              NODE_13
2683#define SPCENCTR_CRASH_SND                NODE_14
2684#define SPCENCTR_EXPLOSION_SND            NODE_15
2685#define SPCENCTR_BONUS_SND                NODE_16
2686#define SPCENCTR_WIND_SND                 NODE_17
26972687
26982688
26992689static const discrete_op_amp_info spcenctr_enemy_ship_shot_op_amp_E1 =
r6740r6741
31753165
31763166WRITE8_DEVICE_HANDLER( spcenctr_audio_2_w )
31773167{
3168   mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data;
3169
31783170   /* set WIND SOUND FREQ(data & 0x0f)  0, if no wind */
31793171
31803172   discrete_sound_w(device, SPCENCTR_EXPLOSION_EN, (data >> 4) & 0x01);
r6740r6741
31833175
31843176   /* D6 and D7 are not connected */
31853177
3186   port_2_last = data;
3178   state->port_2_last = data;
31873179}
31883180
31893181
31903182WRITE8_DEVICE_HANDLER( spcenctr_audio_3_w )
31913183{
3192   const device_config *sn = devtag_get_device(device->machine, "snsnd");
3184   mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data;
31933185
31943186   /* if (data & 0x01)  enable SCREECH (hit the sides) sound */
31953187
31963188   discrete_sound_w(device, SPCENCTR_ENEMY_SHIP_SHOT_EN, (data >> 1) & 0x01);
31973189
3198   spcenctr_set_strobe_state((data >> 2) & 0x01);
3190   state->spcenctr_strobe_state = (data >> 2) & 0x01;
31993191
32003192   output_set_value("LAMP", (data >> 3) & 0x01);
32013193
32023194   discrete_sound_w(device, SPCENCTR_BONUS_EN, (data >> 4) & 0x01);
32033195
3204   sn76477_enable_w(sn, (data >> 5) & 0x01);   /* saucer sound */
3196   sn76477_enable_w(state->sn, (data >> 5) & 0x01);   /* saucer sound */
32053197
32063198   /* D6 and D7 are not connected */
32073199}
r6740r6741
32423234
32433235WRITE8_HANDLER( phantom2_audio_1_w )
32443236{
3245   const device_config *samples = devtag_get_device(space->machine, "samples");
3246   UINT8 rising_bits = data & ~port_1_last;
3237   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
3238   UINT8 rising_bits = data & ~state->port_1_last;
32473239
32483240   /* if (data & 0x01)  enable PLAYER SHOT sound */
3249   if (rising_bits & 0x01) sample_start(samples, 0, 0, 0);
3241   if (rising_bits & 0x01) sample_start(state->samples, 0, 0, 0);
32503242
32513243   /* if (data & 0x02)  enable ENEMY SHOT sound */
32523244
r6740r6741
32583250
32593251   /* D5-D7 are not connected */
32603252
3261   port_1_last = data;
3253   state->port_1_last = data;
32623254}
32633255
32643256
32653257WRITE8_HANDLER( phantom2_audio_2_w )
32663258{
3267   const device_config *samples = devtag_get_device(space->machine, "samples");
3268   UINT8 rising_bits = data & ~port_2_last;
3259   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
3260   UINT8 rising_bits = data & ~state->port_2_last;
32693261
32703262   /* D0-D2 are not connected */
32713263
32723264   /* if (data & 0x08)  enable EXPLOSION sound */
3273   if (rising_bits & 0x08) sample_start(samples, 1, 1, 0);
3265   if (rising_bits & 0x08) sample_start(state->samples, 1, 1, 0);
32743266
32753267   output_set_value("EXPLAMP", (data >> 4) & 0x01);
32763268
32773269   /* set JET SOUND FREQ((data >> 5) & 0x07)  0, if no jet sound */
32783270
3279   port_2_last = data;
3271   state->port_2_last = data;
32803272}
32813273
32823274
r6740r6741
32913283 *************************************/
32923284
32933285/* nodes - inputs */
3294#define BOWLER_FOWL_EN         NODE_01
3286#define BOWLER_FOWL_EN            NODE_01
32953287
32963288/* nodes - sounds */
3297#define BOWLER_FOWL_SND         NODE_10
3289#define BOWLER_FOWL_SND           NODE_10
32983290
32993291
33003292static const discrete_op_amp_tvca_info bowler_fowl_tvca =
r6740r6741
35273519
35283520
35293521/* nodes - inputs */
3530#define INVADERS_SAUCER_HIT_EN            01
3531#define INVADERS_FLEET_DATA               02
3532#define INVADERS_BONUS_MISSLE_BASE_EN      03
3533#define INVADERS_INVADER_HIT_EN            04
3534#define INVADERS_EXPLOSION_EN            05
3535#define INVADERS_MISSILE_EN               06
3522#define INVADERS_SAUCER_HIT_EN                01
3523#define INVADERS_FLEET_DATA                   02
3524#define INVADERS_BONUS_MISSLE_BASE_EN         03
3525#define INVADERS_INVADER_HIT_EN               04
3526#define INVADERS_EXPLOSION_EN                 05
3527#define INVADERS_MISSILE_EN                   06
35363528
35373529/* nodes - sounds */
3538#define INVADERS_NOISE                  NODE_10
3539#define INVADERS_SAUCER_HIT_SND            11
3540#define INVADERS_FLEET_SND               12
3541#define INVADERS_BONUS_MISSLE_BASE_SND      13
3542#define INVADERS_INVADER_HIT_SND         14
3543#define INVADERS_EXPLOSION_SND            15
3544#define INVADERS_MISSILE_SND            16
3530#define INVADERS_NOISE                        NODE_10
3531#define INVADERS_SAUCER_HIT_SND               11
3532#define INVADERS_FLEET_SND                    12
3533#define INVADERS_BONUS_MISSLE_BASE_SND        13
3534#define INVADERS_INVADER_HIT_SND              14
3535#define INVADERS_EXPLOSION_SND                15
3536#define INVADERS_MISSILE_SND                  16
35453537
35463538
35473539static const discrete_op_amp_info invaders_saucer_hit_op_amp_B3_9 =
r6740r6741
40954087
40964088WRITE8_DEVICE_HANDLER( invaders_audio_1_w )
40974089{
4098   const device_config *sn = devtag_get_device(device->machine, "snsnd");
4090   mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data;
40994091
4100   sn76477_enable_w(sn, (~data >> 0) & 0x01);   /* saucer sound */
4092   sn76477_enable_w(state->sn, (~data >> 0) & 0x01);   /* saucer sound */
41014093
41024094   discrete_sound_w(device, INVADERS_NODE(INVADERS_MISSILE_EN, 1), data & 0x02);
41034095   discrete_sound_w(device, INVADERS_NODE(INVADERS_EXPLOSION_EN, 1), data & 0x04);
r6740r6741
41124104
41134105WRITE8_DEVICE_HANDLER( invaders_audio_2_w )
41144106{
4107   mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data;
4108
41154109   discrete_sound_w(device, INVADERS_NODE(INVADERS_FLEET_DATA, 1), data & 0x0f);
41164110   discrete_sound_w(device, INVADERS_NODE(INVADERS_SAUCER_HIT_EN, 1), data & 0x10);
41174111
41184112   /* the flip screen line is only connected on the cocktail PCB */
41194113   if (invaders_is_cabinet_cocktail(device->machine))
41204114   {
4121      invaders_set_flip_screen((data >> 5) & 0x01);
4115      state->invaders_flip_screen = (data >> 5) & 0x01;
41224116   }
41234117
41244118   /* D6 and D7 are not connected */
r6740r6741
41374131 *************************************/
41384132
41394133/* nodes - inputs */
4140#define BLUESHRK_OCTOPUS_EN      NODE_01
4141#define BLUESHRK_HIT_EN         NODE_02
4142#define BLUESHRK_SHARK_EN      NODE_03
4143#define BLUESHRK_SHOT_EN      NODE_04
4144#define BLUESHRK_GAME_ON_EN      NODE_05
4134#define BLUESHRK_OCTOPUS_EN         NODE_01
4135#define BLUESHRK_HIT_EN             NODE_02
4136#define BLUESHRK_SHARK_EN           NODE_03
4137#define BLUESHRK_SHOT_EN            NODE_04
4138#define BLUESHRK_GAME_ON_EN         NODE_05
41454139
41464140/* nodes - sounds */
4147#define BLUESHRK_NOISE_1      NODE_11
4148#define BLUESHRK_NOISE_2      NODE_12
4149#define BLUESHRK_OCTOPUS_SND   NODE_13
4150#define BLUESHRK_HIT_SND      NODE_14
4151#define BLUESHRK_SHARK_SND      NODE_15
4152#define BLUESHRK_SHOT_SND      NODE_16
4141#define BLUESHRK_NOISE_1            NODE_11
4142#define BLUESHRK_NOISE_2            NODE_12
4143#define BLUESHRK_OCTOPUS_SND        NODE_13
4144#define BLUESHRK_HIT_SND            NODE_14
4145#define BLUESHRK_SHARK_SND          NODE_15
4146#define BLUESHRK_SHOT_SND           NODE_16
41534147
41544148/* Parts List - Resistors */
41554149#define BLUESHRK_R300   RES_M(1)
r6740r6741
47264720
47274721WRITE8_DEVICE_HANDLER( invad2ct_audio_1_w )
47284722{
4729   const device_config *sn = devtag_get_device(device->machine, "sn1");
4723   mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data;
47304724
4731   sn76477_enable_w(sn, (~data >> 0) & 0x01);   /* saucer sound */
4725   sn76477_enable_w(state->sn1, (~data >> 0) & 0x01);   /* saucer sound */
47324726
47334727   discrete_sound_w(device, INVADERS_NODE(INVADERS_MISSILE_EN, 1), data & 0x02);
47344728   discrete_sound_w(device, INVADERS_NODE(INVADERS_EXPLOSION_EN, 1), data & 0x04);
r6740r6741
47524746
47534747WRITE8_DEVICE_HANDLER( invad2ct_audio_3_w )
47544748{
4755   const device_config *sn = devtag_get_device(device->machine, "sn2");
4749   mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data;
47564750
4757   sn76477_enable_w(sn, (~data >> 0) & 0x01);   /* saucer sound */
4751   sn76477_enable_w(state->sn2, (~data >> 0) & 0x01);   /* saucer sound */
47584752
47594753   discrete_sound_w(device, INVADERS_NODE(INVADERS_MISSILE_EN, 2), data & 0x02);
47604754   discrete_sound_w(device, INVADERS_NODE(INVADERS_EXPLOSION_EN, 2), data & 0x04);
src/mame/audio/m79amb.c
r6740r6741
44 ************************************************************************/
55
66#include "driver.h"
7#include "m79amb.h"
7#include "includes/m79amb.h"
88#include "sound/discrete.h"
99
1010#define   TIME_OF_9602(r, c)            (0.34 * (r) * (c) * (1.0 + 1.0 / (r)))
src/mame/audio/nitedrvr.c
r6740r6741
44
55*************************************************************************/
66#include "driver.h"
7#include "nitedrvr.h"
7#include "includes/nitedrvr.h"
88#include "sound/discrete.h"
99
1010
r6740r6741
8080   /* 0k = 214Hz.   250k = 4416Hz                  */
8181   /************************************************/
8282   DISCRETE_RCFILTER(NODE_20, NITEDRVR_MOTOR_DATA, 123037, 2.2e-6)
83   DISCRETE_ADJUSTMENT_TAG(NODE_21, (214.0-27.0)/12/31, (4416.0-27.0)/12/31, DISC_LOGADJ, "MOTOR")
83   DISCRETE_ADJUSTMENT(NODE_21, (214.0-27.0)/12/31, (4416.0-27.0)/12/31, DISC_LOGADJ, "MOTOR")
8484   DISCRETE_MULTIPLY(NODE_22, NODE_20, NODE_21)
8585
8686   DISCRETE_MULTADD(NODE_23, NODE_22, 2, 27.0/6)   /* F1 = /12*2 = /6 */
src/mame/audio/targ.c
r6740r6741
1414#include "driver.h"
1515#include "sound/samples.h"
1616#include "sound/dac.h"
17#include "targ.h"
17#include "includes/targ.h"
1818
1919
2020
src/mame/machine/xevious.c
r6740r6741
1717
1818***************************************************************************/
1919
20static emu_timer *nmi_timer;
21
2220static UINT8 customio[16];
2321static char battles_customio_command;
2422static char battles_customio_prev_command;
r6740r6741
2624static char battles_customio_data;
2725static char battles_sound_played;
2826
29static TIMER_CALLBACK( battles_nmi_generate );
3027
31
3228void battles_customio_init(running_machine *machine)
3329{
3430   battles_customio_command = 0;
r6740r6741
3632   battles_customio_command_count = 0;
3733   battles_customio_data = 0;
3834   battles_sound_played = 0;
39   nmi_timer = timer_alloc(machine, battles_nmi_generate, NULL);
4035}
4136
4237
43static TIMER_CALLBACK( battles_nmi_generate )
38TIMER_DEVICE_CALLBACK( battles_nmi_generate )
4439{
4540
4641   battles_customio_prev_command = battles_customio_command;
r6740r6741
4944   {
5045      if( battles_customio_command_count == 0 )
5146      {
52         cputag_set_input_line(machine, "sub3", INPUT_LINE_NMI, PULSE_LINE);
47         cputag_set_input_line(timer->machine, "sub3", INPUT_LINE_NMI, PULSE_LINE);
5348      }
5449      else
5550      {
56         cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
57         cputag_set_input_line(machine, "sub3", INPUT_LINE_NMI, PULSE_LINE);
51         cputag_set_input_line(timer->machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
52         cputag_set_input_line(timer->machine, "sub3", INPUT_LINE_NMI, PULSE_LINE);
5853      }
5954   }
6055   else
6156   {
62      cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
63      cputag_set_input_line(machine, "sub3", INPUT_LINE_NMI, PULSE_LINE);
57      cputag_set_input_line(timer->machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
58      cputag_set_input_line(timer->machine, "sub3", INPUT_LINE_NMI, PULSE_LINE);
6459   }
6560   battles_customio_command_count++;
6661}
r6740r6741
9489
9590WRITE8_HANDLER( battles_customio0_w )
9691{
92   const device_config *timer = devtag_get_device(space->machine, "battles_nmi");
93
9794   logerror("CPU0 %04x: custom I/O Write = %02x\n",cpu_get_pc(space->cpu),data);
9895
9996   battles_customio_command = data;
r6740r6741
10299   switch (data)
103100   {
104101      case 0x10:
105         timer_adjust_oneshot(nmi_timer, attotime_never, 0);
102         timer_device_adjust_oneshot(timer, attotime_never, 0);
106103         return; /* nop */
107104   }
108   timer_adjust_periodic(nmi_timer, ATTOTIME_IN_USEC(166), 0, ATTOTIME_IN_USEC(166));
105   timer_device_adjust_periodic(timer, ATTOTIME_IN_USEC(166), 0, ATTOTIME_IN_USEC(166));
109106
110107}
111108
src/mame/machine/midyunit.c
r6740r6741
88#include "cpu/tms34010/tms34010.h"
99#include "cpu/m6809/m6809.h"
1010#include "audio/williams.h"
11#include "midyunit.h"
11#include "includes/midyunit.h"
1212
1313
1414/* constant definitions */
src/mame/machine/segas32.c
r6740r6741
11/* Sega System 32 Protection related functions */
22
33#include "driver.h"
4#include "segas32.h"
4#include "includes/segas32.h"
55
66
77/******************************************************************************
src/mame/machine/acitya.c
r6740r6741
184184}
185185
186186
187MACHINE_RESET( acitya )
187MACHINE_START( acitya )
188188{
189189   UINT8 *RAM = memory_region(machine, "maincpu");
190190
r6740r6741
196196   acitya_decrypt_rom_A(machine);
197197   acitya_decrypt_rom_B(machine);
198198
199   /* The initial state of the counter is 0x0B */
200   counter = 0x0B;
201199   memory_configure_bank(machine, "bank1", 0, 4, &RAM[0x10000], 0x4000);
202   memory_set_bank(machine, "bank1", 3);
203200
204201   state_save_register_global(machine, counter);
205202}
203
204
205MACHINE_RESET( acitya )
206{
207   /* The initial state of the counter is 0x0B */
208   counter = 0x0B;
209   memory_set_bank(machine, "bank1", 3);
210}
src/mame/machine/asteroid.c
r6740r6741
1010#include "driver.h"
1111#include "machine/atari_vg.h"
1212#include "video/avgdvg.h"
13#include "asteroid.h"
13#include "includes/asteroid.h"
1414
1515UINT8 *asteroid_ram1, *asteroid_ram2;
1616
src/mame/machine/mhavoc.c
r6740r6741
88#include "video/avgdvg.h"
99#include "sound/tms5220.h"
1010#include "cpu/m6502/m6502.h"
11#include "mhavoc.h"
11#include "includes/mhavoc.h"
1212
1313UINT8 *mhavoc_zram0, *mhavoc_zram1;
1414
r6740r6741
3636 *
3737 *************************************/
3838
39static TIMER_CALLBACK( cpu_irq_clock )
39TIMER_DEVICE_CALLBACK( mhavoc_cpu_irq_clock )
4040{
4141   /* clock the LS161 driving the alpha CPU IRQ */
4242   if (alpha_irq_clock_enable)
r6740r6741
4444      alpha_irq_clock++;
4545      if ((alpha_irq_clock & 0x0c) == 0x0c)
4646      {
47         cputag_set_input_line(machine, "alpha", 0, ASSERT_LINE);
47         cputag_set_input_line(timer->machine, "alpha", 0, ASSERT_LINE);
4848         alpha_irq_clock_enable = 0;
4949      }
5050   }
r6740r6741
5353   if (has_gamma_cpu)
5454   {
5555      gamma_irq_clock++;
56      cputag_set_input_line(machine, "gamma", 0, (gamma_irq_clock & 0x08) ? ASSERT_LINE : CLEAR_LINE);
56      cputag_set_input_line(timer->machine, "gamma", 0, (gamma_irq_clock & 0x08) ? ASSERT_LINE : CLEAR_LINE);
5757   }
5858}
5959
r6740r6741
8282 *
8383 *************************************/
8484
85MACHINE_START( mhavoc )
86{
87   state_save_register_item(machine, "misc", NULL, 0, alpha_data);
88   state_save_register_item(machine, "misc", NULL, 0, alpha_rcvd);
89   state_save_register_item(machine, "misc", NULL, 0, alpha_xmtd);
90   state_save_register_item(machine, "misc", NULL, 0, gamma_data);
91   state_save_register_item(machine, "misc", NULL, 0, gamma_rcvd);
92   state_save_register_item(machine, "misc", NULL, 0, gamma_xmtd);
93   state_save_register_item(machine, "misc", NULL, 0, player_1);
94   state_save_register_item(machine, "misc", NULL, 0, alpha_irq_clock);
95   state_save_register_item(machine, "misc", NULL, 0, alpha_irq_clock_enable);
96   state_save_register_item(machine, "misc", NULL, 0, gamma_irq_clock);
97
98   state_save_register_item(machine, "misc", NULL, 0, speech_write_buffer);
99}
100
101
85102MACHINE_RESET( mhavoc )
86103{
87104   const address_space *space = cputag_get_address_space(machine, "alpha", ADDRESS_SPACE_PROGRAM);
r6740r6741
112129   alpha_irq_clock = 0;
113130   alpha_irq_clock_enable = 1;
114131   gamma_irq_clock = 0;
115
116   /* set a timer going for the CPU interrupt generators */
117   timer_pulse(machine, ATTOTIME_IN_HZ(MHAVOC_CLOCK_5K), NULL, 0, cpu_irq_clock);
118
119   state_save_register_item(machine, "misc", NULL, 0, alpha_data);
120   state_save_register_item(machine, "misc", NULL, 0, alpha_rcvd);
121   state_save_register_item(machine, "misc", NULL, 0, alpha_xmtd);
122   state_save_register_item(machine, "misc", NULL, 0, gamma_data);
123   state_save_register_item(machine, "misc", NULL, 0, gamma_rcvd);
124   state_save_register_item(machine, "misc", NULL, 0, gamma_xmtd);
125   state_save_register_item(machine, "misc", NULL, 0, player_1);
126   state_save_register_item(machine, "misc", NULL, 0, alpha_irq_clock);
127   state_save_register_item(machine, "misc", NULL, 0, alpha_irq_clock_enable);
128   state_save_register_item(machine, "misc", NULL, 0, gamma_irq_clock);
129
130   state_save_register_item(machine, "misc", NULL, 0, speech_write_buffer);
131132}
132133
133134
src/mame/machine/copsnrob.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "copsnrob.h"
8#include "includes/copsnrob.h"
99
1010static const int gun_mask[] = {0x7e, 0x7d, 0x7b, 0x77, 0x6f, 0x5f, 0x3f};
1111
src/mame/machine/twincobr.c
r6740r6741
66#include "driver.h"
77#include "cpu/m68000/m68000.h"
88#include "cpu/tms32010/tms32010.h"
9#include "twincobr.h"
9#include "includes/twincobr.h"
1010
1111
1212#define LOG_DSP_CALLS 0
src/mame/machine/irobot.c
r6740r6741
77#include "driver.h"
88#include "profiler.h"
99#include "cpu/m6809/m6809.h"
10#include "irobot.h"
10#include "includes/irobot.h"
1111
1212/* Note:
1313 * There's probably something wrong with the way the Mathbox gets started.
r6740r6741
3535static UINT8 irmb_running;
3636
3737#if IR_TIMING
38static emu_timer *irvg_timer;
39static emu_timer *irmb_timer;
38static const device_config *irvg_timer;
39static const device_config *irmb_timer;
4040#endif
4141
4242static UINT8 *comRAM[2], *mbRAM, *mbROM;
r6740r6741
8484      irobot_combase[BYTE_XOR_BE(offset & 0xFFF)] = data;
8585}
8686
87static TIMER_CALLBACK( irvg_done_callback )
87TIMER_DEVICE_CALLBACK( irobot_irvg_done_callback )
8888{
8989   logerror("vg done. ");
9090   irvg_running = 0;
r6740r6741
112112      else
113113         logerror("vg start [busy!] ");
114114      IR_CPU_STATE(space->machine);
115      timer_adjust_oneshot(irvg_timer, ATTOTIME_IN_MSEC(10), 0);
115      timer_device_adjust_oneshot(irvg_timer, ATTOTIME_IN_MSEC(10), 0);
116116#endif
117117      irvg_running=1;
118118   }
r6740r6741
188188    timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), NULL, scanline, scanline_callback);
189189}
190190
191static TIMER_CALLBACK( irmb_done_callback );
192191MACHINE_RESET( irobot )
193192{
194193   UINT8 *MB = memory_region(machine, "mathbox");
r6740r6741
201200
202201   irvg_vblank=0;
203202   irvg_running = 0;
204   irvg_timer = timer_alloc(machine, irvg_done_callback, NULL);
203   irvg_timer = devtag_get_device(machine, "irvg_timer");
205204   irmb_running = 0;
206   irmb_timer = timer_alloc(machine, irmb_done_callback, NULL);
205   irmb_timer = devtag_get_device(machine, "irmb_timer");
207206
208207   /* set an initial timer to go off on scanline 0 */
209208   timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, scanline_callback);
r6740r6741
453452   load_oproms(machine);
454453}
455454
456static TIMER_CALLBACK( irmb_done_callback )
455TIMER_DEVICE_CALLBACK( irobot_irmb_done_callback )
457456{
458457    logerror("mb done. ");
459458   irmb_running = 0;
460   cputag_set_input_line(machine, "maincpu", M6809_FIRQ_LINE, ASSERT_LINE);
459   cputag_set_input_line(timer->machine, "maincpu", M6809_FIRQ_LINE, ASSERT_LINE);
461460}
462461
463462
r6740r6741
850849#if IR_TIMING
851850   if (irmb_running == 0)
852851   {
853      timer_adjust_oneshot(irmb_timer, attotime_mul(ATTOTIME_IN_HZ(12000000), icount), 0);
852      timer_device_adjust_oneshot(irmb_timer, attotime_mul(ATTOTIME_IN_HZ(12000000), icount), 0);
854853      logerror("mb start ");
855854      IR_CPU_STATE(machine);
856855   }
r6740r6741
858857   {
859858      logerror("mb start [busy!] ");
860859      IR_CPU_STATE(machine);
861      timer_adjust_oneshot(irmb_timer, attotime_mul(ATTOTIME_IN_NSEC(200), icount), 0);
860      timer_device_adjust_oneshot(irmb_timer, attotime_mul(ATTOTIME_IN_NSEC(200), icount), 0);
862861   }
863862#else
864863   cputag_set_input_line(machine, "maincpu", M6809_FIRQ_LINE, ASSERT_LINE);
src/mame/machine/leland.c
r6740r6741
1010#include "cpu/i86/i86.h"
1111#include "machine/eeprom.h"
1212#include "cpu/z80/z80.h"
13#include "leland.h"
13#include "includes/leland.h"
1414#include "sound/ay8910.h"
1515
1616
src/mame/machine/neoboot.c
r6740r6741
1313***************************************************************************/
1414
1515#include "driver.h"
16#include "neogeo.h"
16#include "includes/neogeo.h"
1717
1818
1919/* General Bootleg Functions - used by more than 1 game */
src/mame/machine/segas24.c
r6740r6741
11#include "driver.h"
2#include "system16.h"
2#include "includes/system16.h"
33#include "includes/segas24.h"
44
55/* system24temp_ functions / variables are from shared rewrite files,
src/mame/machine/konamigx.c
r6740r6741
66
77#include "driver.h"
88#include "video/konamiic.h"
9#include "konamigx.h"
9#include "includes/konamigx.h"
1010
1111/***************************************************************************/
1212/*                                                                         */
src/mame/machine/ticket.c
r6740r6741
1616#define DEBUG_TICKET 0
1717#define LOG(x) do { if (DEBUG_TICKET) logerror x; } while (0)
1818
19#define MAX_DISPENSERS   2
2019
21struct ticket_state
20typedef struct _ticket_state ticket_state;
21struct _ticket_state
2222{
23   int active_bit;
24   int time_msec;
25   int motoron;
26   int ticketdispensed;
27   int ticketnotdispensed;
28
2329   UINT8 status;
2430   UINT8 power;
2531   emu_timer *timer;
2632};
2733
28static int active_bit = 0x80;
29static int time_msec;
30static int motoron;
31static int ticketdispensed;
32static int ticketnotdispensed;
34INLINE ticket_state *get_safe_token(const device_config *device)
35{
36   assert(device != NULL);
37   assert(device->token != NULL);
38   assert(device->type == TICKET_DISPENSER);
3339
34static struct ticket_state dispenser[MAX_DISPENSERS];
40   return (ticket_state *)device->token;
41}
3542
36static TIMER_CALLBACK( ticket_dispenser_toggle );
3743
38
39/***************************************************************************
40  ticket_dispenser_init
41
42***************************************************************************/
43void ticket_dispenser_init(running_machine *machine, int msec, int motoronhigh, int statusactivehigh)
44static TIMER_CALLBACK( ticket_dispenser_toggle )
4445{
45   int i;
46   ticket_state *state = get_safe_token((const device_config *)ptr);
4647
47   time_msec         = msec;
48   motoron            = motoronhigh  ? active_bit : 0;
49   ticketdispensed      = statusactivehigh ? active_bit : 0;
50   ticketnotdispensed   = ticketdispensed ^ active_bit;
48   /* If we still have power, keep toggling ticket states. */
49   if (state->power)
50   {
51      state->status ^= state->active_bit;
52      LOG(("Ticket Status Changed to %02X\n", state->status));
53      timer_adjust_oneshot(state->timer, ATTOTIME_IN_MSEC(state->time_msec), 0);
54   }
5155
52   for (i = 0; i < MAX_DISPENSERS; i++)
56   if (state->status == state->ticketdispensed)
5357   {
54      dispenser[i].status   = ticketnotdispensed;
55      dispenser[i].power    = 0x00;
56      dispenser[i].timer    = timer_alloc(machine, ticket_dispenser_toggle, &dispenser[i]);
58      set_led_status(machine, 2,1);
59      increment_dispensed_tickets(machine, 1);
5760
58      state_save_register_item(machine, "ticket", NULL, i, dispenser[i].status);
59      state_save_register_item(machine, "ticket", NULL, i, dispenser[i].power);
61      LOG(("Ticket Dispensed\n"));
6062   }
63   else
64   {
65      set_led_status(machine, 2,0);
66   }
6167}
6268
63/***************************************************************************
64  ticket_dispenser_r
65***************************************************************************/
66READ8_HANDLER( ticket_dispenser_r )
67{
68   return ticket_dispenser_0_r(space, offset);
69}
7069
71READ8_HANDLER( ticket_dispenser_0_r )
70READ8_DEVICE_HANDLER( ticket_dispenser_r )
7271{
73   LOG(("PC: %04X  Ticket Status Read = %02X\n", cpu_get_pc(space->cpu), dispenser[0].status));
74   return dispenser[0].status;
72   ticket_state *state = get_safe_token(device);
73   LOG(("%s: Ticket Status Read = %02X\n", cpuexec_describe_context(device->machine), state->status));
74   return state->status;
7575}
7676
77READ8_HANDLER( ticket_dispenser_1_r )
78{
79   LOG(("PC: %04X  Ticket Status Read = %02X\n", cpu_get_pc(space->cpu), dispenser[1].status));
80   return dispenser[1].status;
81}
8277
83CUSTOM_INPUT( ticket_dispenser_0_port_r )
78READ_LINE_DEVICE_HANDLER( ticket_dispenser_line_r )
8479{
85   return dispenser[0].status ? 1 : 0;
80   ticket_state *state = get_safe_token(device);
81   return state->status ? 1 : 0;
8682}
8783
88CUSTOM_INPUT( ticket_dispenser_1_port_r )
89{
90   return dispenser[1].status ? 1 : 0;
91}
9284
93/***************************************************************************
94  ticket_dispenser_w
95***************************************************************************/
96WRITE8_HANDLER( ticket_dispenser_w )
85WRITE8_DEVICE_HANDLER( ticket_dispenser_w )
9786{
98   ticket_dispenser_0_w(space, offset, data);
99}
87   ticket_state *state = get_safe_token(device);
10088
101WRITE8_HANDLER( ticket_dispenser_0_w )
102{
10389   /* On an activate signal, start dispensing! */
104   if ((data & active_bit) == motoron)
90   if ((data & state->active_bit) == state->motoron)
10591   {
106      if (!dispenser[0].power)
92      if (!state->power)
10793      {
108         LOG(("PC: %04X  Ticket Power On\n", cpu_get_pc(space->cpu)));
109         timer_adjust_oneshot(dispenser[0].timer, ATTOTIME_IN_MSEC(time_msec), 0);
110         dispenser[0].power = 1;
94         LOG(("%s: Ticket Power On\n", cpuexec_describe_context(device->machine)));
95         timer_adjust_oneshot(state->timer, ATTOTIME_IN_MSEC(state->time_msec), 0);
96         state->power = 1;
11197
112         dispenser[0].status = ticketnotdispensed;
98         state->status = state->ticketnotdispensed;
11399      }
114100   }
115101   else
116102   {
117      if (dispenser[0].power)
103      if (state->power)
118104      {
119         LOG(("PC: %04X  Ticket Power Off\n", cpu_get_pc(space->cpu)));
120         timer_adjust_oneshot(dispenser[0].timer, attotime_never, 0);
121         set_led_status(space->machine, 2,0);
122         dispenser[0].power = 0;
105         LOG(("%s: Ticket Power Off\n", cpuexec_describe_context(device->machine)));
106         timer_adjust_oneshot(state->timer, attotime_never, 0);
107         set_led_status(device->machine, 2,0);
108         state->power = 0;
123109      }
124110   }
125111}
126112
127WRITE8_HANDLER( ticket_dispenser_1_w )
113
114
115/***************************************************************************
116    DEVICE INTERFACE
117***************************************************************************/
118
119/*-------------------------------------------------
120    device start callback
121-------------------------------------------------*/
122
123static DEVICE_START( ticket )
128124{
129   /* On an activate signal, start dispensing! */
130   if ((data & active_bit) == motoron)
131   {
132      if (!dispenser[1].power)
133      {
134         LOG(("PC: %04X  Ticket Power On\n", cpu_get_pc(space->cpu)));
135         timer_adjust_oneshot(dispenser[1].timer, ATTOTIME_IN_MSEC(time_msec), 0);
136         dispenser[1].power = 1;
125   const ticket_config *config = (const ticket_config *)device->inline_config;
126   ticket_state *state = get_safe_token(device);
137127
138         dispenser[1].status = ticketnotdispensed;
139      }
140   }
141   else
142   {
143      if (dispenser[1].power)
144      {
145         LOG(("PC: %04X  Ticket Power Off\n", cpu_get_pc(space->cpu)));
146         timer_adjust_oneshot(dispenser[1].timer, attotime_never, 0);
147         set_led_status(space->machine, 2,0);
148         dispenser[1].power = 0;
149      }
150   }
128   assert(config != NULL);
129
130   /* initialize the state */
131   state->active_bit          = 0x80;
132   state->time_msec         = device->clock;
133   state->motoron            = config->motorhigh  ? state->active_bit : 0;
134   state->ticketdispensed      = config->statushigh ? state->active_bit : 0;
135   state->ticketnotdispensed   = state->ticketdispensed ^ state->active_bit;
136
137   state->timer             = timer_alloc(device->machine, ticket_dispenser_toggle, (void *)device);
138
139   state_save_register_device_item(device, 0, state->status);
140   state_save_register_device_item(device, 0, state->power);
151141}
152142
153143
154/***************************************************************************
155  ticket_dispenser_toggle
144/*-------------------------------------------------
145    device reset callback
146-------------------------------------------------*/
156147
157  How I think this works:
158  When a ticket dispenses, there is N milliseconds of status = high,
159  and N milliseconds of status = low (a wait cycle?).
160***************************************************************************/
161static TIMER_CALLBACK( ticket_dispenser_toggle )
148static DEVICE_RESET( ticket )
162149{
163   struct ticket_state *dispenser = (struct ticket_state *)ptr;
150   ticket_state *state = get_safe_token(device);
151   state->status            = state->ticketnotdispensed;
152   state->power             = 0x00;
153}
164154
165   /* If we still have power, keep toggling ticket states. */
166   if (dispenser->power)
167   {
168      dispenser->status ^= active_bit;
169      LOG(("Ticket Status Changed to %02X\n", dispenser->status));
170      timer_adjust_oneshot(dispenser->timer, ATTOTIME_IN_MSEC(time_msec), 0);
171   }
172155
173   if (dispenser->status == ticketdispensed)
174   {
175      set_led_status(machine, 2,1);
176      increment_dispensed_tickets(machine, 1);
156/*-------------------------------------------------
157    device definition
158-------------------------------------------------*/
177159
178      LOG(("Ticket Dispensed\n"));
179   }
180   else
181   {
182      set_led_status(machine, 2,0);
183   }
184}
160static const char DEVTEMPLATE_SOURCE[] = __FILE__;
161
162#define DEVTEMPLATE_ID(p,s)      p##ticket##s
163#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET | DT_HAS_INLINE_CONFIG
164#define DEVTEMPLATE_NAME      "Ticket Dispenser"
165#define DEVTEMPLATE_FAMILY      "Generic"
166#include "devtempl.h"
src/mame/machine/stvcd.c
r6740r6741
106106} trans32T;
107107
108108// local variables
109static emu_timer *sector_timer;
109static const device_config *sector_timer;
110110static partitionT partitions[MAX_FILTERS];
111111static partitionT *transpart;
112112
r6740r6741
182182#define CD_STAT_WAIT     0x8000      // waiting for command if set, else executed immediately
183183#define CD_STAT_REJECT   0xff00      // ultra-fatal error.
184184
185static TIMER_CALLBACK( sector_cb )
185TIMER_DEVICE_CALLBACK( stv_sector_cb )
186186{
187187   if (fadstoplay)
188188   {
r6740r6741
199199   cr3 = (cd_curfad>>16)&0xff;
200200   cr4 = cd_curfad;
201201
202   timer_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0);
202   timer_device_adjust_oneshot(timer, ATTOTIME_IN_HZ(150), 0);
203203}
204204
205205// global functions
r6740r6741
274274      cd_stat = CD_STAT_OPEN;
275275   }
276276
277   sector_timer = timer_alloc(machine, sector_cb, NULL);
278   timer_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0);   // 150 sectors / second = 300kBytes/second
277   sector_timer = devtag_get_device(machine, "sector_timer");
278   timer_device_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0);   // 150 sectors / second = 300kBytes/second
279279}
280280
281281static blockT *cd_alloc_block(UINT8 *blknum)
r6740r6741
766766
767767         // and do the disc I/O
768768         // make sure it doesn't come in too early
769         timer_adjust_oneshot(sector_timer, attotime_never, 0);
770         timer_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0);   // 150 sectors / second = 300kBytes/second
769         timer_device_adjust_oneshot(sector_timer, attotime_never, 0);
770         timer_device_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0);   // 150 sectors / second = 300kBytes/second
771771         break;
772772
773773      case 0x1100: // disk seek
r6740r6741
12751275         playtype = 1;
12761276
12771277         // and do the disc I/O
1278//          timer_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0);  // 150 sectors / second = 300kBytes/second
1278//          timer_device_adjust_oneshot(sector_timer, ATTOTIME_IN_HZ(150), 0);  // 150 sectors / second = 300kBytes/second
12791279         break;
12801280
12811281      case 0x7500:
src/mame/machine/dc.c
r6740r6741
66
77#include "driver.h"
88#include "debugger.h"
9#include "dc.h"
9#include "includes/dc.h"
1010#include "cpu/sh4/sh4.h"
1111#include "sound/aica.h"
12#include "naomibd.h"
13#include "naomi.h"
12#include "includes/naomibd.h"
13#include "includes/naomi.h"
1414
1515#define DEBUG_REGISTERS   (1)
1616
r6740r6741
13361336
13371337MACHINE_START( dc )
13381338{
1339   dc_rtc_timer = timer_alloc(machine, dc_rtc_increment, 0);
13391340}
13401341
13411342MACHINE_RESET( dc )
r6740r6741
13481349   memset(dc_rtcregister, 0, sizeof(dc_rtcregister));
13491350   memset(dc_coin_counts, 0, sizeof(dc_coin_counts));
13501351
1351   dc_rtc_timer = timer_alloc(machine, dc_rtc_increment, 0);
13521352   timer_adjust_periodic(dc_rtc_timer, attotime_zero, 0, ATTOTIME_IN_SEC(1));
13531353
13541354   dc_sysctrl_regs[SB_SBREV] = 0x0b;
src/mame/machine/ticket.h
r6740r6741
44
55***************************************************************************/
66
7
87#define TICKET_MOTOR_ACTIVE_LOW    0    /* Ticket motor is triggered by D7=0 */
98#define TICKET_MOTOR_ACTIVE_HIGH   1    /* Ticket motor is triggered by D7=1 */
109
1110#define TICKET_STATUS_ACTIVE_LOW   0    /* Ticket is done dispensing when D7=0 */
1211#define TICKET_STATUS_ACTIVE_HIGH  1    /* Ticket is done dispensing when D7=1 */
1312
14/***************************************************************************
15  ticket_dispenser_init
1613
17  msec       = how many milliseconds it takes to dispense a ticket
18  activehigh = see constants above
1914
20***************************************************************************/
21void ticket_dispenser_init(running_machine *machine, int msec, int motoractivehigh, int statusactivehigh);
15typedef struct _ticket_config ticket_config;
16struct _ticket_config
17{
18   UINT8   motorhigh;
19   UINT8   statushigh;
20};
2221
2322
24/***************************************************************************
25  ticket_dispenser_r
26***************************************************************************/
27READ8_HANDLER( ticket_dispenser_r );
28READ8_HANDLER( ticket_dispenser_0_r );
29READ8_HANDLER( ticket_dispenser_1_r );
23#define MDRV_TICKET_DISPENSER_ADD(_tag, _clock, _motorhigh, _statushigh) \
24   MDRV_DEVICE_ADD(_tag, TICKET_DISPENSER, _clock) \
25   MDRV_DEVICE_CONFIG_DATA32(ticket_config, motorhigh, _motorhigh) \
26   MDRV_DEVICE_CONFIG_DATA32(ticket_config, statushigh, _statushigh)
3027
31CUSTOM_INPUT( ticket_dispenser_0_port_r );
32CUSTOM_INPUT( ticket_dispenser_1_port_r );
3328
29READ8_DEVICE_HANDLER( ticket_dispenser_r );
30WRITE8_DEVICE_HANDLER( ticket_dispenser_w );
3431
35/***************************************************************************
36  ticket_dispenser_w
37***************************************************************************/
38WRITE8_HANDLER( ticket_dispenser_w );
39WRITE8_HANDLER( ticket_dispenser_0_w );
40WRITE8_HANDLER( ticket_dispenser_1_w );
32READ_LINE_DEVICE_HANDLER( ticket_dispenser_line_r );
4133
34/* device interface */
35#define TICKET_DISPENSER DEVICE_GET_INFO_NAME(ticket)
36DEVICE_GET_INFO( ticket );
src/mame/machine/stvcd.h
r6740r6741
1212void stvcd_reset(running_machine* machine);
1313void stvcd_exit(running_machine* machine);
1414
15TIMER_DEVICE_CALLBACK( stv_sector_cb );
16
1517READ32_HANDLER( stvcd_r );
1618WRITE32_HANDLER( stvcd_w );
1719
src/mame/machine/midtunit.c
r6740r6741
99#include "cpu/m6809/m6809.h"
1010#include "audio/williams.h"
1111#include "audio/dcs.h"
12#include "midtunit.h"
12#include "includes/midtunit.h"
1313
1414
1515/* compile-time constants */
src/mame/machine/carpolo.c
r6740r6741
5858#define CAR_BORDER_EXTRA_BITS      0x50
5959
6060
61#define TTL74148_3S               0
6261
63#define TTL74153_1K               0
64
65#define TTL7474_2S_1            0
66#define TTL7474_2S_2            1
67#define TTL7474_2U_1            2
68#define TTL7474_2U_2            3
69#define TTL7474_1F_1            4
70#define TTL7474_1F_2            5
71#define TTL7474_1D_1            6
72#define TTL7474_1D_2            7
73#define TTL7474_1C_1            8
74#define TTL7474_1C_2            9
75#define TTL7474_1A_1            10
76#define TTL7474_1A_2            11
77
78
7962static UINT8 ball_screen_collision_cause;
8063static UINT8 car_ball_collision_x;
8164static UINT8 car_ball_collision_y;
r6740r6741
8669static UINT8 priority_0_extension;
8770static UINT8 last_wheel_value[4];
8871
72static const device_config *ttl74148_3s;
8973
90static void TTL74148_3S_cb(running_machine *machine)
74static const device_config *ttl74153_1k;
75
76static const device_config *ttl7474_2s_1;
77static const device_config *ttl7474_2s_2;
78static const device_config *ttl7474_2u_1;
79static const device_config *ttl7474_2u_2;
80static const device_config *ttl7474_1f_1;
81static const device_config *ttl7474_1f_2;
82static const device_config *ttl7474_1d_1;
83static const device_config *ttl7474_1d_2;
84static const device_config *ttl7474_1c_1;
85static const device_config *ttl7474_1c_2;
86static const device_config *ttl7474_1a_1;
87static const device_config *ttl7474_1a_2;
88
89
90void carpolo_74148_3s_cb(const device_config *device)
9191{
92   cputag_set_input_line(machine, "maincpu", M6502_IRQ_LINE, TTL74148_output_valid_r(TTL74148_3S) ? CLEAR_LINE : ASSERT_LINE);
92   cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, ttl74148_output_valid_r(device) ? CLEAR_LINE : ASSERT_LINE);
9393}
9494
9595
9696/* the outputs of the flip-flops are connected to the priority encoder */
97static void TTL7474_2S_1_cb(running_machine *machine)
97void carpolo_7474_2s_1_cb(const device_config *device)
9898{
99   TTL74148_input_line_w(TTL74148_3S, COIN1_PRIORITY_LINE, TTL7474_output_comp_r(TTL7474_2S_1));
100   TTL74148_update(machine, TTL74148_3S);
99   ttl74148_input_line_w(ttl74148_3s, COIN1_PRIORITY_LINE, ttl7474_output_comp_r(device));
100   ttl74148_update(ttl74148_3s);
101101}
102102
103static void TTL7474_2S_2_cb(running_machine *machine)
103void carpolo_7474_2s_2_cb(const device_config *device)
104104{
105   TTL74148_input_line_w(TTL74148_3S, COIN2_PRIORITY_LINE, TTL7474_output_comp_r(TTL7474_2S_2));
106   TTL74148_update(machine, TTL74148_3S);
105   ttl74148_input_line_w(ttl74148_3s, COIN2_PRIORITY_LINE, ttl7474_output_comp_r(device));
106   ttl74148_update(ttl74148_3s);
107107}
108108
109static void TTL7474_2U_1_cb(running_machine *machine)
109void carpolo_7474_2u_1_cb(const device_config *device)
110110{
111   TTL74148_input_line_w(TTL74148_3S, COIN3_PRIORITY_LINE, TTL7474_output_comp_r(TTL7474_2U_1));
112   TTL74148_update(machine, TTL74148_3S);
111   ttl74148_input_line_w(ttl74148_3s, COIN3_PRIORITY_LINE, ttl7474_output_comp_r(device));
112   ttl74148_update(ttl74148_3s);
113113}
114114
115static void TTL7474_2U_2_cb(running_machine *machine)
115void carpolo_7474_2u_2_cb(const device_config *device)
116116{
117   TTL74148_input_line_w(TTL74148_3S, COIN4_PRIORITY_LINE, TTL7474_output_comp_r(TTL7474_2U_2));
118   TTL74148_update(machine, TTL74148_3S);
117   ttl74148_input_line_w(ttl74148_3s, COIN4_PRIORITY_LINE, ttl7474_output_comp_r(device));
118   ttl74148_update(ttl74148_3s);
119119}
120120
121121
r6740r6741
123123{
124124   ball_screen_collision_cause = cause;
125125
126   TTL74148_input_line_w(TTL74148_3S, BALL_SCREEN_PRIORITY_LINE, 0);
127   TTL74148_update(machine, TTL74148_3S);
126   ttl74148_input_line_w(ttl74148_3s, BALL_SCREEN_PRIORITY_LINE, 0);
127   ttl74148_update(ttl74148_3s);
128128}
129129
130130void carpolo_generate_car_car_interrupt(running_machine *machine, int car1, int car2)
131131{
132132   car_car_collision_cause = ~((1 << (3 - car1)) | (1 << (3 - car2)));
133133
134   TTL74148_input_line_w(TTL74148_3S, CAR_CAR_PRIORITY_LINE, 0);
135   TTL74148_update(machine, TTL74148_3S);
134   ttl74148_input_line_w(ttl74148_3s, CAR_CAR_PRIORITY_LINE, 0);
135   ttl74148_update(ttl74148_3s);
136136}
137137
138138void carpolo_generate_car_goal_interrupt(running_machine *machine, int car, int right_goal)
139139{
140140   car_goal_collision_cause = car | (right_goal ? 0x08 : 0x00);
141141
142   TTL74148_input_line_w(TTL74148_3S, CAR_GOAL_PRIORITY_LINE, 0);
143   TTL74148_update(machine, TTL74148_3S);
142   ttl74148_input_line_w(ttl74148_3s, CAR_GOAL_PRIORITY_LINE, 0);
143   ttl74148_update(ttl74148_3s);
144144}
145145
146146void carpolo_generate_car_ball_interrupt(running_machine *machine, int car, int car_x, int car_y)
r6740r6741
151151
152152   priority_0_extension = CAR_BALL_EXTRA_BITS;
153153
154   TTL74148_input_line_w(TTL74148_3S, PRI0_PRIORTITY_LINE, 0);
155   TTL74148_update(machine, TTL74148_3S);
154   ttl74148_input_line_w(ttl74148_3s, PRI0_PRIORTITY_LINE, 0);
155   ttl74148_update(ttl74148_3s);
156156}
157157
158158void carpolo_generate_car_border_interrupt(running_machine *machine, int car, int horizontal_border)
r6740r6741
161161
162162   priority_0_extension = CAR_BORDER_EXTRA_BITS;
163163
164   TTL74148_input_line_w(TTL74148_3S, PRI0_PRIORTITY_LINE, 0);
165   TTL74148_update(machine, TTL74148_3S);
164   ttl74148_input_line_w(ttl74148_3s, PRI0_PRIORTITY_LINE, 0);
165   ttl74148_update(ttl74148_3s);
166166}
167167
168168
r6740r6741
222222READ8_HANDLER( carpolo_interrupt_cause_r )
223223{
224224   /* the output of the 148 goes to bits 1-3 (which is priority ^ 7) */
225   return (TTL74148_output_r(TTL74148_3S) << 1) | priority_0_extension;
225   return (ttl74148_output_r(ttl74148_3s) << 1) | priority_0_extension;
226226}
227227
228228
r6740r6741
233233
234234
235235   /* cause the timer interrupt */
236   TTL74148_input_line_w(TTL74148_3S, PRI0_PRIORTITY_LINE, 0);
236   ttl74148_input_line_w(ttl74148_3s, PRI0_PRIORTITY_LINE, 0);
237237   priority_0_extension = TIMER_EXTRA_BITS;
238238
239   TTL74148_update(device->machine, TTL74148_3S);
239   ttl74148_update(ttl74148_3s);
240240
241241
242242   /* check the coins here as well - they drive the clock of the flip-flops */
243243   port_value = input_port_read(device->machine, "IN0");
244244
245   TTL7474_clock_w(TTL7474_2S_1, port_value & 0x01);
246   TTL7474_clock_w(TTL7474_2S_2, port_value & 0x02);
247   TTL7474_clock_w(TTL7474_2U_1, port_value & 0x04);
248   TTL7474_clock_w(TTL7474_2U_2, port_value & 0x08);
245   ttl7474_clock_w(ttl7474_2s_1, port_value & 0x01);
246   ttl7474_clock_w(ttl7474_2s_2, port_value & 0x02);
247   ttl7474_clock_w(ttl7474_2u_1, port_value & 0x04);
248   ttl7474_clock_w(ttl7474_2u_2, port_value & 0x08);
249249
250   TTL7474_update(device->machine, TTL7474_2S_1);
251   TTL7474_update(device->machine, TTL7474_2S_2);
252   TTL7474_update(device->machine, TTL7474_2U_1);
253   TTL7474_update(device->machine, TTL7474_2U_2);
250   ttl7474_update(ttl7474_2s_1);
251   ttl7474_update(ttl7474_2s_2);
252   ttl7474_update(ttl7474_2u_1);
253   ttl7474_update(ttl7474_2u_2);
254254
255255
256256   /* read the steering controls */
257257   for (player = 0; player < 4; player++)
258258   {
259      int movement_flip_flop = TTL7474_1F_1 + (2 * player);
260      int dir_flip_flop      = movement_flip_flop + 1;
261259      static const char *const portnames[] = { "DIAL0", "DIAL1", "DIAL2", "DIAL3" };
260      const device_config *movement_flip_flop;
261      const device_config *dir_flip_flop;
262262
263      switch (player)
264      {
265         default:
266         case 0:   movement_flip_flop = ttl7474_1f_1;   dir_flip_flop = ttl7474_1f_2;   break;
267         case 1:   movement_flip_flop = ttl7474_1d_1;   dir_flip_flop = ttl7474_1d_2;   break;
268         case 2:   movement_flip_flop = ttl7474_1c_1;   dir_flip_flop = ttl7474_1c_2;   break;
269         case 3:   movement_flip_flop = ttl7474_1a_1;   dir_flip_flop = ttl7474_1a_2;   break;
270      }
271
263272      port_value = input_port_read(device->machine, portnames[player]);
264273
265274      if (port_value != last_wheel_value[player])
266275      {
267276         /* set the movement direction */
268         TTL7474_d_w(dir_flip_flop, ((port_value - last_wheel_value[player]) & 0x80) ? 1 : 0);
277         ttl7474_d_w(dir_flip_flop, ((port_value - last_wheel_value[player]) & 0x80) ? 1 : 0);
269278
270279         last_wheel_value[player] = port_value;
271280      }
272281
273282      /* as the wheel moves, both flip-flops are clocked */
274      TTL7474_clock_w(movement_flip_flop, port_value & 0x01);
275      TTL7474_clock_w(dir_flip_flop,      port_value & 0x01);
283      ttl7474_clock_w(movement_flip_flop, port_value & 0x01);
284      ttl7474_clock_w(dir_flip_flop,      port_value & 0x01);
276285
277      TTL7474_update(device->machine, movement_flip_flop);
278      TTL7474_update(device->machine, dir_flip_flop);
286      ttl7474_update(movement_flip_flop);
287      ttl7474_update(dir_flip_flop);
279288   }
280289
281290
r6740r6741
289298           how much, resulting in only two different possible levels */
290299      if (port_value & 0x01)
291300      {
292         TTL74153_input_line_w(TTL74153_1K, 0, player, 1);
293         TTL74153_input_line_w(TTL74153_1K, 1, player, 0);
301         ttl74153_input_line_w(ttl74153_1k, 0, player, 1);
302         ttl74153_input_line_w(ttl74153_1k, 1, player, 0);
294303      }
295304      else if (port_value & 0x02)
296305      {
297         TTL74153_input_line_w(TTL74153_1K, 0, player, 1);
298         TTL74153_input_line_w(TTL74153_1K, 1, player, 1);
306         ttl74153_input_line_w(ttl74153_1k, 0, player, 1);
307         ttl74153_input_line_w(ttl74153_1k, 1, player, 1);
299308      }
300309      else
301310      {
302         TTL74153_input_line_w(TTL74153_1K, 0, player, 0);
311         ttl74153_input_line_w(ttl74153_1k, 0, player, 0);
303312         /* the other line is irrelevant */
304313      }
305314
306315      port_value >>= 2;
307316   }
308317
309   TTL74153_update(TTL74153_1K);
318   ttl74153_update(ttl74153_1k);
310319}
311320
312321
313322static WRITE_LINE_DEVICE_HANDLER( coin1_interrupt_clear_w )
314323{
315   TTL7474_clear_w(TTL7474_2S_1, state);
316   TTL7474_update(device->machine, TTL7474_2S_1);
324   ttl7474_clear_w(ttl7474_2s_1, state);
325   ttl7474_update(ttl7474_2s_1);
317326}
318327
319328static WRITE_LINE_DEVICE_HANDLER( coin2_interrupt_clear_w )
320329{
321   TTL7474_clear_w(TTL7474_2S_2, state);
322   TTL7474_update(device->machine, TTL7474_2S_2);
330   ttl7474_clear_w(ttl7474_2s_2, state);
331   ttl7474_update(ttl7474_2s_2);
323332}
324333
325334static WRITE_LINE_DEVICE_HANDLER( coin3_interrupt_clear_w )
326335{
327   TTL7474_clear_w(TTL7474_2U_1, state);
328   TTL7474_update(device->machine, TTL7474_2U_1);
336   ttl7474_clear_w(ttl7474_2u_1, state);
337   ttl7474_update(ttl7474_2u_1);
329338}
330339
331340static WRITE_LINE_DEVICE_HANDLER( coin4_interrupt_clear_w )
332341{
333   TTL7474_clear_w(TTL7474_2U_2, state);
334   TTL7474_update(device->machine, TTL7474_2U_2);
342   ttl7474_clear_w(ttl7474_2u_2, state);
343   ttl7474_update(ttl7474_2u_2);
335344}
336345
337346WRITE8_HANDLER( carpolo_ball_screen_interrupt_clear_w )
338347{
339   TTL74148_input_line_w(TTL74148_3S, BALL_SCREEN_PRIORITY_LINE, 1);
340   TTL74148_update(space->machine, TTL74148_3S);
348   ttl74148_input_line_w(ttl74148_3s, BALL_SCREEN_PRIORITY_LINE, 1);
349   ttl74148_update(ttl74148_3s);
341350}
342351
343352WRITE8_HANDLER( carpolo_car_car_interrupt_clear_w )
344353{
345   TTL74148_input_line_w(TTL74148_3S, CAR_CAR_PRIORITY_LINE, 1);
346   TTL74148_update(space->machine, TTL74148_3S);
354   ttl74148_input_line_w(ttl74148_3s, CAR_CAR_PRIORITY_LINE, 1);
355   ttl74148_update(ttl74148_3s);
347356}
348357
349358WRITE8_HANDLER( carpolo_car_goal_interrupt_clear_w )
350359{
351   TTL74148_input_line_w(TTL74148_3S, CAR_GOAL_PRIORITY_LINE, 1);
352   TTL74148_update(space->machine, TTL74148_3S);
360   ttl74148_input_line_w(ttl74148_3s, CAR_GOAL_PRIORITY_LINE, 1);
361   ttl74148_update(ttl74148_3s);
353362}
354363
355364WRITE8_HANDLER( carpolo_car_ball_interrupt_clear_w )
356365{
357   TTL74148_input_line_w(TTL74148_3S, PRI0_PRIORTITY_LINE, 1);
358   TTL74148_update(space->machine, TTL74148_3S);
366   ttl74148_input_line_w(ttl74148_3s, PRI0_PRIORTITY_LINE, 1);
367   ttl74148_update(ttl74148_3s);
359368}
360369
361370WRITE8_HANDLER( carpolo_car_border_interrupt_clear_w )
362371{
363   TTL74148_input_line_w(TTL74148_3S, PRI0_PRIORTITY_LINE, 1);
364   TTL74148_update(space->machine, TTL74148_3S);
372   ttl74148_input_line_w(ttl74148_3s, PRI0_PRIORTITY_LINE, 1);
373   ttl74148_update(ttl74148_3s);
365374}
366375
367376WRITE8_HANDLER( carpolo_timer_interrupt_clear_w )
368377{
369   TTL74148_input_line_w(TTL74148_3S, PRI0_PRIORTITY_LINE, 1);
370   TTL74148_update(space->machine, TTL74148_3S);
378   ttl74148_input_line_w(ttl74148_3s, PRI0_PRIORTITY_LINE, 1);
379   ttl74148_update(ttl74148_3s);
371380}
372381
373382
r6740r6741
391400   coin_counter_w(device->machine, 0, data & 0x01);
392401
393402
394   TTL7474_clear_w(TTL7474_1F_1, data & 0x08);
395   TTL7474_clear_w(TTL7474_1D_1, data & 0x08);
396   TTL7474_clear_w(TTL7474_1C_1, data & 0x08);
397   TTL7474_clear_w(TTL7474_1A_1, data & 0x08);
403   ttl7474_clear_w(ttl7474_1f_1, data & 0x08);
404   ttl7474_clear_w(ttl7474_1d_1, data & 0x08);
405   ttl7474_clear_w(ttl7474_1c_1, data & 0x08);
406   ttl7474_clear_w(ttl7474_1a_1, data & 0x08);
398407
399   TTL7474_update(device->machine, TTL7474_1F_1);
400   TTL7474_update(device->machine, TTL7474_1D_1);
401   TTL7474_update(device->machine, TTL7474_1C_1);
402   TTL7474_update(device->machine, TTL7474_1A_1);
408   ttl7474_update(ttl7474_1f_1);
409   ttl7474_update(ttl7474_1d_1);
410   ttl7474_update(ttl7474_1c_1);
411   ttl7474_update(ttl7474_1a_1);
403412}
404413
405414
r6740r6741
412421       bit 6 - Select pedal 0
413422       bit 7 - Select pdeal 1 */
414423
415   TTL74153_a_w(TTL74153_1K, data & 0x40);
416   TTL74153_b_w(TTL74153_1K, data & 0x80);
424   ttl74153_a_w(ttl74153_1k, data & 0x40);
425   ttl74153_b_w(ttl74153_1k, data & 0x80);
417426
418   TTL74153_update(TTL74153_1K);
427   ttl74153_update(ttl74153_1k);
419428}
420429
421430static READ8_DEVICE_HANDLER( pia_0_port_b_r )
r6740r6741
423432   /* bit 4 - Pedal bit 0
424433       bit 5 - Pedal bit 1 */
425434
426   return (TTL74153_output_r(TTL74153_1K, 0) << 5) |
427         (TTL74153_output_r(TTL74153_1K, 1) << 4);
435   return (ttl74153_output_r(ttl74153_1k, 0) << 5) |
436         (ttl74153_output_r(ttl74153_1k, 1) << 4);
428437}
429438
430439
r6740r6741
441450       bit 6 - Player 2 forward/reverse input
442451       bit 7 - Player 1 forward/reverse input */
443452
444   ret = (TTL7474_output_r(TTL7474_1A_2) ? 0x01 : 0x00) |
445        (TTL7474_output_r(TTL7474_1C_2) ? 0x02 : 0x00) |
446        (TTL7474_output_r(TTL7474_1D_2) ? 0x04 : 0x00) |
447        (TTL7474_output_r(TTL7474_1F_2) ? 0x08 : 0x00) |
453   ret = (ttl7474_output_r(ttl7474_1a_2) ? 0x01 : 0x00) |
454        (ttl7474_output_r(ttl7474_1c_2) ? 0x02 : 0x00) |
455        (ttl7474_output_r(ttl7474_1d_2) ? 0x04 : 0x00) |
456        (ttl7474_output_r(ttl7474_1f_2) ? 0x08 : 0x00) |
448457        (input_port_read(device->machine, "IN2") & 0xf0);
449458
450459   return ret;
r6740r6741
460469       bit 6 - Player 2 steering input (wheel moving or stopped)
461470       bit 7 - Player 1 steering input (wheel moving or stopped) */
462471
463   ret = (TTL7474_output_r(TTL7474_1A_1) ? 0x10 : 0x00) |
464        (TTL7474_output_r(TTL7474_1C_1) ? 0x20 : 0x00) |
465        (TTL7474_output_r(TTL7474_1D_1) ? 0x40 : 0x00) |
466        (TTL7474_output_r(TTL7474_1F_1) ? 0x80 : 0x00);
472   ret = (ttl7474_output_r(ttl7474_1a_1) ? 0x10 : 0x00) |
473        (ttl7474_output_r(ttl7474_1c_1) ? 0x20 : 0x00) |
474        (ttl7474_output_r(ttl7474_1d_1) ? 0x40 : 0x00) |
475        (ttl7474_output_r(ttl7474_1f_1) ? 0x80 : 0x00);
467476
468477   return ret;
469478}
r6740r6741
502511   DEVCB_NULL      /* IRQB */
503512};
504513
505static const struct TTL74148_interface TTL74148_3S_intf =
514MACHINE_START( carpolo )
506515{
507   TTL74148_3S_cb
508};
516   /* find flip-flops */
517   ttl7474_2s_1 = devtag_get_device(machine, "7474_2s_1");
518   ttl7474_2s_2 = devtag_get_device(machine, "7474_2s_2");
519   ttl7474_2u_1 = devtag_get_device(machine, "7474_2u_1");
520   ttl7474_2u_2 = devtag_get_device(machine, "7474_2u_2");
521   ttl7474_1f_1 = devtag_get_device(machine, "7474_1f_1");
522   ttl7474_1f_2 = devtag_get_device(machine, "7474_1f_2");
523   ttl7474_1d_1 = devtag_get_device(machine, "7474_1d_1");
524   ttl7474_1d_2 = devtag_get_device(machine, "7474_1d_2");
525   ttl7474_1c_1 = devtag_get_device(machine, "7474_1c_1");
526   ttl7474_1c_2 = devtag_get_device(machine, "7474_1c_2");
527   ttl7474_1a_1 = devtag_get_device(machine, "7474_1a_1");
528   ttl7474_1a_2 = devtag_get_device(machine, "7474_1a_2");
509529
510static const struct TTL7474_interface TTL7474_2S_1_intf =
511{
512   TTL7474_2S_1_cb
513};
530   ttl74148_3s = devtag_get_device(machine, "74148_3s");
531   ttl74153_1k = devtag_get_device(machine, "74153_1k");
514532
515static const struct TTL7474_interface TTL7474_2S_2_intf =
516{
517   TTL7474_2S_2_cb
518};
519
520static const struct TTL7474_interface TTL7474_2U_1_intf =
521{
522   TTL7474_2U_1_cb
523};
524
525static const struct TTL7474_interface TTL7474_2U_2_intf =
526{
527   TTL7474_2U_2_cb
528};
529
530
531MACHINE_START( carpolo )
532{
533533    state_save_register_global(machine, ball_screen_collision_cause);
534534    state_save_register_global(machine, car_ball_collision_x);
535535    state_save_register_global(machine, car_ball_collision_y);
r6740r6741
544544MACHINE_RESET( carpolo )
545545{
546546   /* set up the priority encoder */
547   TTL74148_config(machine, TTL74148_3S, &TTL74148_3S_intf);
548   TTL74148_enable_input_w(TTL74148_3S, 0);   /* always enabled */
547   ttl74148_enable_input_w(ttl74148_3s, 0);   /* always enabled */
549548
550
551549   /* set up the coin handling flip-flops */
552   TTL7474_config(machine, TTL7474_2S_1, &TTL7474_2S_1_intf);
553   TTL7474_config(machine, TTL7474_2S_2, &TTL7474_2S_2_intf);
554   TTL7474_config(machine, TTL7474_2U_1, &TTL7474_2U_1_intf);
555   TTL7474_config(machine, TTL7474_2U_2, &TTL7474_2U_2_intf);
550   ttl7474_d_w     (ttl7474_2s_1, 1);
551   ttl7474_preset_w(ttl7474_2s_1, 1);
556552
557   TTL7474_d_w     (TTL7474_2S_1, 1);
558   TTL7474_preset_w(TTL7474_2S_1, 1);
553   ttl7474_d_w     (ttl7474_2s_2, 1);
554   ttl7474_preset_w(ttl7474_2s_2, 1);
559555
560   TTL7474_d_w     (TTL7474_2S_2, 1);
561   TTL7474_preset_w(TTL7474_2S_2, 1);
556   ttl7474_d_w     (ttl7474_2u_1, 1);
557   ttl7474_preset_w(ttl7474_2u_1, 1);
562558
563   TTL7474_d_w     (TTL7474_2U_1, 1);
564   TTL7474_preset_w(TTL7474_2U_1, 1);
559   ttl7474_d_w     (ttl7474_2u_2, 1);
560   ttl7474_preset_w(ttl7474_2u_2, 1);
565561
566   TTL7474_d_w     (TTL7474_2U_2, 1);
567   TTL7474_preset_w(TTL7474_2U_2, 1);
568562
569
570563   /* set up the steering handling flip-flops */
571   TTL7474_config(machine, TTL7474_1F_1, 0);
572   TTL7474_config(machine, TTL7474_1F_2, 0);
573   TTL7474_config(machine, TTL7474_1D_1, 0);
574   TTL7474_config(machine, TTL7474_1D_2, 0);
575   TTL7474_config(machine, TTL7474_1C_1, 0);
576   TTL7474_config(machine, TTL7474_1C_2, 0);
577   TTL7474_config(machine, TTL7474_1A_1, 0);
578   TTL7474_config(machine, TTL7474_1A_2, 0);
564   ttl7474_d_w     (ttl7474_1f_1, 1);
565   ttl7474_preset_w(ttl7474_1f_1, 1);
579566
580   TTL7474_d_w     (TTL7474_1F_1, 1);
581   TTL7474_preset_w(TTL7474_1F_1, 1);
567   ttl7474_clear_w (ttl7474_1f_2, 1);
568   ttl7474_preset_w(ttl7474_1f_2, 1);
582569
583   TTL7474_clear_w (TTL7474_1F_2, 1);
584   TTL7474_preset_w(TTL7474_1F_2, 1);
570   ttl7474_d_w     (ttl7474_1d_1, 1);
571   ttl7474_preset_w(ttl7474_1d_1, 1);
585572
586   TTL7474_d_w     (TTL7474_1D_1, 1);
587   TTL7474_preset_w(TTL7474_1D_1, 1);
573   ttl7474_clear_w (ttl7474_1d_2, 1);
574   ttl7474_preset_w(ttl7474_1d_2, 1);
588575
589   TTL7474_clear_w (TTL7474_1D_2, 1);
590   TTL7474_preset_w(TTL7474_1D_2, 1);
576   ttl7474_d_w     (ttl7474_1c_1, 1);
577   ttl7474_preset_w(ttl7474_1c_1, 1);
591578
592   TTL7474_d_w     (TTL7474_1C_1, 1);
593   TTL7474_preset_w(TTL7474_1C_1, 1);
579   ttl7474_clear_w (ttl7474_1c_2, 1);
580   ttl7474_preset_w(ttl7474_1c_2, 1);
594581
595   TTL7474_clear_w (TTL7474_1C_2, 1);
596   TTL7474_preset_w(TTL7474_1C_2, 1);
582   ttl7474_d_w     (ttl7474_1a_1, 1);
583   ttl7474_preset_w(ttl7474_1a_1, 1);
597584
598   TTL7474_d_w     (TTL7474_1A_1, 1);
599   TTL7474_preset_w(TTL7474_1A_1, 1);
585   ttl7474_clear_w (ttl7474_1a_2, 1);
586   ttl7474_preset_w(ttl7474_1a_2, 1);
600587
601   TTL7474_clear_w (TTL7474_1A_2, 1);
602   TTL7474_preset_w(TTL7474_1A_2, 1);
603588
604
605589   /* set up the pedal handling chips */
606   TTL74153_config(machine, TTL74153_1K, 0);
607
608   TTL74153_enable_w(TTL74153_1K, 0, 0);
609   TTL74153_enable_w(TTL74153_1K, 1, 0);
590   ttl74153_enable_w(ttl74153_1k, 0, 0);
591   ttl74153_enable_w(ttl74153_1k, 1, 0);
610592}
src/mame/machine/n64.c
r6740r6741
20012001   rspdrc_add_imem(cputag_get_cpu(machine, "rsp"), rsp_imem);
20022002   rspdrc_add_dmem(cputag_get_cpu(machine, "rsp"), rsp_dmem);
20032003   rspdrc_flush_drc_cache(cputag_get_cpu(machine, "rsp"));
2004
2005   audio_timer = timer_alloc(machine, audio_timer_callback, NULL);
20042006}
20052007
20062008MACHINE_RESET( n64 )
r6740r6741
20602062
20612063   cic_status = 0;
20622064
2063   audio_timer = timer_alloc(machine, audio_timer_callback, NULL);
20642065   timer_adjust_oneshot(audio_timer, attotime_never, 0);
20652066
20662067   cputag_set_input_line(machine, "rsp", INPUT_LINE_HALT, ASSERT_LINE);
src/mame/machine/deco102.c
r6740r6741
99
1010#include "driver.h"
1111#include "cpu/m68000/m68000.h"
12#include "decocrpt.h"
12#include "includes/decocrpt.h"
1313
1414static UINT16 decrypt(UINT16 data, int address, int select_xor)
1515{
src/mame/machine/balsente.c
r6740r6741
88
99#include "driver.h"
1010#include "cpu/m6809/m6809.h"
11#include "balsente.h"
11#include "includes/balsente.h"
1212#include "sound/cem3394.h"
1313
1414
r6740r6741
1818/* local prototypes */
1919static void poly17_init(running_machine *machine);
2020static void counter_set_out(running_machine *machine, int which, int gate);
21static TIMER_CALLBACK( counter_callback );
22static TIMER_CALLBACK( clock_counter_0_ff );
2321static void update_grudge_steering(running_machine *machine);
2422
25/* global data */
26UINT8 balsente_shooter;
27static UINT8 balsente_shooter_x;
28static UINT8 balsente_shooter_y;
29UINT8 balsente_adc_shift;
30UINT16 *shrike_shared;
31UINT16 *shrike_io;
3223
3324
34/* 8253 counter state */
35struct counter_state
36{
37   emu_timer *timer;
38   UINT8 timer_active;
39   INT32 initial;
40   INT32 count;
41   UINT8 gate;
42   UINT8 out;
43   UINT8 mode;
44   UINT8 readbyte;
45   UINT8 writebyte;
46};
4725
48static struct counter_state counter[3];
49
50static emu_timer *scanline_timer;
51
52/* manually clocked counter 0 states */
53static UINT8 counter_control;
54static UINT8 counter_0_ff;
55static emu_timer *counter_0_timer;
56static UINT8 counter_0_timer_active;
57
58/* random number generator states */
59static UINT8 *poly17 = NULL;
60static UINT8 *rand17 = NULL;
61
62/* ADC I/O states */
63static INT8 analog_input_data[4];
64static UINT8 adc_value;
65
66/* CEM3394 DAC control states */
67static UINT16 dac_value;
68static UINT8 dac_register;
69static UINT8 chip_select;
70
71/* main CPU 6850 states */
72static UINT8 m6850_status;
73static UINT8 m6850_control;
74static UINT8 m6850_input;
75static UINT8 m6850_output;
76static UINT8 m6850_data_ready;
77
78/* sound CPU 6850 states */
79static UINT8 m6850_sound_status;
80static UINT8 m6850_sound_control;
81static UINT8 m6850_sound_input;
82static UINT8 m6850_sound_output;
83
84/* noise generator states */
85static UINT32 noise_position[6];
86static const device_config *cem_device[6];
87
88/* game-specific states */
89static UINT8 nstocker_bits;
90static UINT8 spiker_expand_color;
91static UINT8 spiker_expand_bgcolor;
92static UINT8 spiker_expand_bits;
93static UINT8 grudge_steering_result;
94static UINT8 grudge_last_steering[3];
95
96
97
9826/*************************************
9927 *
10028 *  Interrupt handling
r6740r6741
10735}
10836
10937
110static TIMER_CALLBACK( interrupt_timer )
38TIMER_DEVICE_CALLBACK( balsente_interrupt_timer )
11139{
40   balsente_state *state = (balsente_state *)timer->machine->driver_data;
41
11242   /* next interrupt after scanline 256 is scanline 64 */
11343   if (param == 256)
114      timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 64, 0), 64);
44      timer_device_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, 64, 0), 64);
11545   else
116      timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, param + 64, 0), param + 64);
46      timer_device_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, param + 64, 0), param + 64);
11747
11848   /* IRQ starts on scanline 0, 64, 128, etc. */
119   cputag_set_input_line(machine, "maincpu", M6809_IRQ_LINE, ASSERT_LINE);
49   cputag_set_input_line(timer->machine, "maincpu", M6809_IRQ_LINE, ASSERT_LINE);
12050
12151   /* it will turn off on the next HBLANK */
122   timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, param, BALSENTE_HBSTART), NULL, 0, irq_off);
52   timer_set(timer->machine, video_screen_get_time_until_pos(timer->machine->primary_screen, param, BALSENTE_HBSTART), NULL, 0, irq_off);
12353
12454   /* if this is Grudge Match, update the steering */
125   if (grudge_steering_result & 0x80)
126      update_grudge_steering(machine);
55   if (state->grudge_steering_result & 0x80)
56      update_grudge_steering(timer->machine);
12757
12858   /* if we're a shooter, we do a little more work */
129   if (balsente_shooter)
59   if (state->shooter)
13060   {
13161      UINT8 tempx, tempy;
13262
13363      /* we latch the beam values on the first interrupt after VBLANK */
134      if (param == 64 && balsente_shooter)
64      if (param == 64)
13565      {
136         balsente_shooter_x = input_port_read(machine, "FAKEX");
137         balsente_shooter_y = input_port_read(machine, "FAKEY");
66         state->shooter_x = input_port_read(timer->machine, "FAKEX");
67         state->shooter_y = input_port_read(timer->machine, "FAKEY");
13868      }
13969
14070      /* which bits get returned depends on which scanline we're at */
141      tempx = balsente_shooter_x << ((param - 64) / 64);
142      tempy = balsente_shooter_y << ((param - 64) / 64);
143      nstocker_bits = ((tempx >> 4) & 0x08) | ((tempx >> 1) & 0x04) |
144                  ((tempy >> 6) & 0x02) | ((tempy >> 3) & 0x01);
71      tempx = state->shooter_x << ((param - 64) / 64);
72      tempy = state->shooter_y << ((param - 64) / 64);
73      state->nstocker_bits = ((tempx >> 4) & 0x08) | ((tempx >> 1) & 0x04) |
74                        ((tempy >> 6) & 0x02) | ((tempy >> 3) & 0x01);
14575   }
14676}
14777
14878
149MACHINE_RESET( balsente )
79MACHINE_START( balsente )
15080{
151   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
152   int numbanks, i;
81   balsente_state *state = (balsente_state *)machine->driver_data;
82   int i;
15383
15484   /* create the polynomial tables */
15585   poly17_init(machine);
15686
87   /* register for saving */
88   for (i = 0; i < 3; i++)
89   {
90      state_save_register_item(machine, "8253counter", NULL, i, state->counter[i].timer_active);
91      state_save_register_item(machine, "8253counter", NULL, i, state->counter[i].initial);
92      state_save_register_item(machine, "8253counter", NULL, i, state->counter[i].count);
93      state_save_register_item(machine, "8253counter", NULL, i, state->counter[i].gate);
94      state_save_register_item(machine, "8253counter", NULL, i, state->counter[i].out);
95      state_save_register_item(machine, "8253counter", NULL, i, state->counter[i].mode);
96      state_save_register_item(machine, "8253counter", NULL, i, state->counter[i].readbyte);
97      state_save_register_item(machine, "8253counter", NULL, i, state->counter[i].writebyte);
98   }
99
100   state_save_register_global(machine, state->counter_control);
101   state_save_register_global(machine, state->counter_0_ff);
102   state_save_register_global(machine, state->counter_0_timer_active);
103
104   state_save_register_global_array(machine, state->analog_input_data);
105   state_save_register_global(machine, state->adc_value);
106
107   state_save_register_global(machine, state->dac_value);
108   state_save_register_global(machine, state->dac_register);
109   state_save_register_global(machine, state->chip_select);
110
111   state_save_register_global(machine, state->m6850_status);
112   state_save_register_global(machine, state->m6850_control);
113   state_save_register_global(machine, state->m6850_input);
114   state_save_register_global(machine, state->m6850_output);
115   state_save_register_global(machine, state->m6850_data_ready);
116
117   state_save_register_global(machine, state->m6850_sound_status);
118   state_save_register_global(machine, state->m6850_sound_control);
119   state_save_register_global(machine, state->m6850_sound_input);
120   state_save_register_global(machine, state->m6850_sound_output);
121
122   state_save_register_global_array(machine, state->noise_position);
123
124   state_save_register_global(machine, state->nstocker_bits);
125   state_save_register_global(machine, state->spiker_expand_color);
126   state_save_register_global(machine, state->spiker_expand_bgcolor);
127   state_save_register_global(machine, state->spiker_expand_bits);
128   state_save_register_global(machine, state->grudge_steering_result);
129   state_save_register_global_array(machine, state->grudge_last_steering);
130}
131
132
133MACHINE_RESET( balsente )
134{
135   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
136   balsente_state *state = (balsente_state *)machine->driver_data;
137   int numbanks, i;
138
157139   /* reset counters; counter 2's gate is tied high */
158   memset(counter, 0, sizeof(counter));
159   counter[1].timer = timer_alloc(machine, counter_callback, NULL);
160   counter[2].timer = timer_alloc(machine, counter_callback, NULL);
161   counter[2].gate = 1;
140   memset(state->counter, 0, sizeof(state->counter));
141   state->counter[1].timer = devtag_get_device(machine, "8253_1_timer");
142   state->counter[2].timer = devtag_get_device(machine, "8253_2_timer");
143   state->counter[2].gate = 1;
162144
163145   /* reset the manual counter 0 clock */
164   counter_control = 0x00;
165   counter_0_ff = 0;
166   counter_0_timer = timer_alloc(machine, clock_counter_0_ff, NULL);
167   counter_0_timer_active = 0;
146   state->counter_0_timer = devtag_get_device(machine, "8253_0_timer");
147   state->counter_control = 0x00;
148   state->counter_0_ff = 0;
149   state->counter_0_timer_active = 0;
168150
169151   /* reset the ADC states */
170   adc_value = 0;
152   state->adc_value = 0;
171153
172154   /* reset the CEM3394 I/O states */
173   dac_value = 0;
174   dac_register = 0;
175   chip_select = 0x3f;
155   state->dac_value = 0;
156   state->dac_register = 0;
157   state->chip_select = 0x3f;
176158
177159   /* reset game-specific states */
178   grudge_steering_result = 0;
160   state->grudge_steering_result = 0;
179161
180162   /* reset the 6850 chips */
181163   balsente_m6850_w(space, 0, 3);
182164   balsente_m6850_sound_w(space, 0, 3);
183165
184166   /* reset the noise generator */
185   memset(noise_position, 0, sizeof(noise_position));
167   memset(state->noise_position, 0, sizeof(state->noise_position));
186168
187169   /* find the CEM devices */
188   for (i = 0; i < ARRAY_LENGTH(cem_device); i++)
170   for (i = 0; i < ARRAY_LENGTH(state->cem_device); i++)
189171   {
190172      char name[10];
191173      sprintf(name, "cem%d", i+1);
192      cem_device[i] = devtag_get_device(machine, name);
193      assert(cem_device[i] != NULL);
174      state->cem_device[i] = devtag_get_device(machine, name);
175      assert(state->cem_device[i] != NULL);
194176   }
195177
196178   /* point the banks to bank 0 */
r6740r6741
202184   device_reset(cputag_get_cpu(machine, "maincpu"));
203185
204186   /* start a timer to generate interrupts */
205   scanline_timer = timer_alloc(machine, interrupt_timer, NULL);
206   timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
207
208   /* register for saving */
209   for (i = 0; i < 3; i++)
210   {
211      state_save_register_item(machine, "8253counter", NULL, i, counter[i].timer_active);
212      state_save_register_item(machine, "8253counter", NULL, i, counter[i].initial);
213      state_save_register_item(machine, "8253counter", NULL, i, counter[i].count);
214      state_save_register_item(machine, "8253counter", NULL, i, counter[i].gate);
215      state_save_register_item(machine, "8253counter", NULL, i, counter[i].out);
216      state_save_register_item(machine, "8253counter", NULL, i, counter[i].mode);
217      state_save_register_item(machine, "8253counter", NULL, i, counter[i].readbyte);
218      state_save_register_item(machine, "8253counter", NULL, i, counter[i].writebyte);
219   }
220
221   state_save_register_global(machine, counter_control);
222   state_save_register_global(machine, counter_0_ff);
223   state_save_register_global(machine, counter_0_timer_active);
224
225   state_save_register_global_array(machine, analog_input_data);
226   state_save_register_global(machine, adc_value);
227
228   state_save_register_global(machine, dac_value);
229   state_save_register_global(machine, dac_register);
230   state_save_register_global(machine, chip_select);
231
232   state_save_register_global(machine, m6850_status);
233   state_save_register_global(machine, m6850_control);
234   state_save_register_global(machine, m6850_input);
235   state_save_register_global(machine, m6850_output);
236   state_save_register_global(machine, m6850_data_ready);
237
238   state_save_register_global(machine, m6850_sound_status);
239   state_save_register_global(machine, m6850_sound_control);
240   state_save_register_global(machine, m6850_sound_input);
241   state_save_register_global(machine, m6850_sound_output);
242
243   state_save_register_global_array(machine, noise_position);
244
245   state_save_register_global(machine, nstocker_bits);
246   state_save_register_global(machine, spiker_expand_color);
247   state_save_register_global(machine, spiker_expand_bgcolor);
248   state_save_register_global(machine, spiker_expand_bits);
249   state_save_register_global(machine, grudge_steering_result);
250   state_save_register_global_array(machine, grudge_last_steering);
187   state->scanline_timer = devtag_get_device(machine, "scan_timer");
188   timer_device_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
251189}
252190
253191
r6740r6741
261199 *
262200 *************************************/
263201
264#define POLY17_BITS 17
265#define POLY17_SIZE ((1 << POLY17_BITS) - 1)
266#define POLY17_SHL   7
267#define POLY17_SHR   10
268#define POLY17_ADD   0x18000
269
270202static void poly17_init(running_machine *machine)
271203{
204   balsente_state *state = (balsente_state *)machine->driver_data;
272205   UINT32 i, x = 0;
273206   UINT8 *p, *r;
274207
275208   /* allocate memory */
276   p = poly17 = auto_alloc_array(machine, UINT8, POLY17_SIZE + 1);
277   r = rand17 = auto_alloc_array(machine, UINT8, POLY17_SIZE + 1);
209   p = state->poly17;
210   r = state->rand17;
278211
279212   /* generate the polynomial */
280213   for (i = 0; i < POLY17_SIZE; i++)
r6740r6741
291224
292225void balsente_noise_gen(const device_config *device, int count, short *buffer)
293226{
227   balsente_state *state = (balsente_state *)device->machine->driver_data;
294228   int chip;
295229   UINT32 step, noise_counter;
296230
297231   /* find the chip we are referring to */
298   for (chip = 0; chip < ARRAY_LENGTH(cem_device); chip++)
232   for (chip = 0; chip < ARRAY_LENGTH(state->cem_device); chip++)
299233   {
300      if (device == cem_device[chip])
234      if (device == state->cem_device[chip])
301235         break;
302      else if (cem_device[chip] == NULL)
236      else if (state->cem_device[chip] == NULL)
303237      {
304         cem_device[chip] = device;
238         state->cem_device[chip] = device;
305239         break;
306240      }
307241   }
308   assert(chip < ARRAY_LENGTH(cem_device));
242   assert(chip < ARRAY_LENGTH(state->cem_device));
309243
310244   /* noise generator runs at 100kHz */
311245   step = (100000 << 14) / CEM3394_SAMPLE_RATE;
312   noise_counter = noise_position[chip];
246   noise_counter = state->noise_position[chip];
313247
314248   while (count--)
315249   {
316      *buffer++ = poly17[(noise_counter >> 14) & POLY17_SIZE] << 12;
250      *buffer++ = state->poly17[(noise_counter >> 14) & POLY17_SIZE] << 12;
317251      noise_counter += step;
318252   }
319253
320254   /* remember the noise position */
321   noise_position[chip] = noise_counter;
255   state->noise_position[chip] = noise_counter;
322256}
323257
324258
r6740r6741
337271
338272READ8_HANDLER( balsente_random_num_r )
339273{
274   balsente_state *state = (balsente_state *)space->machine->driver_data;
340275   UINT32 cc;
341276
342277   /* CPU runs at 1.25MHz, noise source at 100kHz --> multiply by 12.5 */
r6740r6741
344279
345280   /* 12.5 = 8 + 4 + 0.5 */
346281   cc = (cc << 3) + (cc << 2) + (cc >> 1);
347   return rand17[cc & POLY17_SIZE];
282   return state->rand17[cc & POLY17_SIZE];
348283}
349284
350285
r6740r6741
421356
422357static void m6850_update_io(running_machine *machine)
423358{
359   balsente_state *state = (balsente_state *)machine->driver_data;
424360   UINT8 new_state;
425361
426362   /* sound -> main CPU communications */
427   if (!(m6850_sound_status & 0x02))
363   if (!(state->m6850_sound_status & 0x02))
428364   {
429365      /* set the overrun bit if the data in the destination hasn't been read yet */
430      if (m6850_status & 0x01)
431         m6850_status |= 0x20;
366      if (state->m6850_status & 0x01)
367         state->m6850_status |= 0x20;
432368
433369      /* copy the sound's output to our input */
434      m6850_input = m6850_sound_output;
370      state->m6850_input = state->m6850_sound_output;
435371
436372      /* set the receive register full bit */
437      m6850_status |= 0x01;
373      state->m6850_status |= 0x01;
438374
439375      /* set the sound's trasmitter register empty bit */
440      m6850_sound_status |= 0x02;
376      state->m6850_sound_status |= 0x02;
441377   }
442378
443379   /* main -> sound CPU communications */
444   if (m6850_data_ready)
380   if (state->m6850_data_ready)
445381   {
446382      /* set the overrun bit if the data in the destination hasn't been read yet */
447      if (m6850_sound_status & 0x01)
448         m6850_sound_status |= 0x20;
383      if (state->m6850_sound_status & 0x01)
384         state->m6850_sound_status |= 0x20;
449385
450386      /* copy the main CPU's output to our input */
451      m6850_sound_input = m6850_output;
387      state->m6850_sound_input = state->m6850_output;
452388
453389      /* set the receive register full bit */
454      m6850_sound_status |= 0x01;
390      state->m6850_sound_status |= 0x01;
455391
456392      /* set the main CPU's trasmitter register empty bit */
457      m6850_status |= 0x02;
458      m6850_data_ready = 0;
393      state->m6850_status |= 0x02;
394      state->m6850_data_ready = 0;
459395   }
460396
461397   /* check for reset states */
462   if ((m6850_control & 3) == 3)
398   if ((state->m6850_control & 3) == 3)
463399   {
464      m6850_status = 0x02;
465      m6850_data_ready = 0;
400      state->m6850_status = 0x02;
401      state->m6850_data_ready = 0;
466402   }
467   if ((m6850_sound_control & 3) == 3)
468      m6850_sound_status = 0x02;
403   if ((state->m6850_sound_control & 3) == 3)
404      state->m6850_sound_status = 0x02;
469405
470406   /* check for transmit/receive IRQs on the main CPU */
471407   new_state = 0;
472   if ((m6850_control & 0x80) && (m6850_status & 0x21)) new_state = 1;
473   if ((m6850_control & 0x60) == 0x20 && (m6850_status & 0x02)) new_state = 1;
408   if ((state->m6850_control & 0x80) && (state->m6850_status & 0x21)) new_state = 1;
409   if ((state->m6850_control & 0x60) == 0x20 && (state->m6850_status & 0x02)) new_state = 1;
474410
475411   /* apply the change */
476   if (new_state && !(m6850_status & 0x80))
412   if (new_state && !(state->m6850_status & 0x80))
477413   {
478414      cputag_set_input_line(machine, "maincpu", M6809_FIRQ_LINE, ASSERT_LINE);
479      m6850_status |= 0x80;
415      state->m6850_status |= 0x80;
480416   }
481   else if (!new_state && (m6850_status & 0x80))
417   else if (!new_state && (state->m6850_status & 0x80))
482418   {
483419      cputag_set_input_line(machine, "maincpu", M6809_FIRQ_LINE, CLEAR_LINE);
484      m6850_status &= ~0x80;
420      state->m6850_status &= ~0x80;
485421   }
486422
487423   /* check for transmit/receive IRQs on the sound CPU */
488424   new_state = 0;
489   if ((m6850_sound_control & 0x80) && (m6850_sound_status & 0x21)) new_state = 1;
490   if ((m6850_sound_control & 0x60) == 0x20 && (m6850_sound_status & 0x02)) new_state = 1;
491   if (!(counter_control & 0x20)) new_state = 0;
425   if ((state->m6850_sound_control & 0x80) && (state->m6850_sound_status & 0x21)) new_state = 1;
426   if ((state->m6850_sound_control & 0x60) == 0x20 && (state->m6850_sound_status & 0x02)) new_state = 1;
427   if (!(state->counter_control & 0x20)) new_state = 0;
492428
493429   /* apply the change */
494   if (new_state && !(m6850_sound_status & 0x80))
430   if (new_state && !(state->m6850_sound_status & 0x80))
495431   {
496432      cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, ASSERT_LINE);
497      m6850_sound_status |= 0x80;
433      state->m6850_sound_status |= 0x80;
498434   }
499   else if (!new_state && (m6850_sound_status & 0x80))
435   else if (!new_state && (state->m6850_sound_status & 0x80))
500436   {
501437      cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, CLEAR_LINE);
502      m6850_sound_status &= ~0x80;
438      state->m6850_sound_status &= ~0x80;
503439   }
504440}
505441
r6740r6741
513449
514450READ8_HANDLER( balsente_m6850_r )
515451{
452   balsente_state *state = (balsente_state *)space->machine->driver_data;
516453   int result;
517454
518455   /* status register is at offset 0 */
519456   if (offset == 0)
520457   {
521      result = m6850_status;
458      result = state->m6850_status;
522459   }
523460
524461   /* input register is at offset 1 */
525462   else
526463   {
527      result = m6850_input;
464      result = state->m6850_input;
528465
529466      /* clear the overrun and receive buffer full bits */
530      m6850_status &= ~0x21;
467      state->m6850_status &= ~0x21;
531468      m6850_update_io(space->machine);
532469   }
533470
r6740r6741
537474
538475static TIMER_CALLBACK( m6850_data_ready_callback )
539476{
477   balsente_state *state = (balsente_state *)machine->driver_data;
478
540479   /* set the output data byte and indicate that we're ready to go */
541   m6850_output = param;
542   m6850_data_ready = 1;
480   state->m6850_output = param;
481   state->m6850_data_ready = 1;
543482   m6850_update_io(machine);
544483}
545484
546485
547486static TIMER_CALLBACK( m6850_w_callback )
548487{
488   balsente_state *state = (balsente_state *)machine->driver_data;
489
549490   /* indicate that the transmit buffer is no longer empty and update the I/O state */
550   m6850_status &= ~0x02;
491   state->m6850_status &= ~0x02;
551492   m6850_update_io(machine);
552493
553494   /* set a timer for 500usec later to actually transmit the data */
r6740r6741
558499
559500WRITE8_HANDLER( balsente_m6850_w )
560501{
502   balsente_state *state = (balsente_state *)space->machine->driver_data;
503
561504   /* control register is at offset 0 */
562505   if (offset == 0)
563506   {
564      m6850_control = data;
507      state->m6850_control = data;
565508
566509      /* re-update since interrupt enables could have been modified */
567510      m6850_update_io(space->machine);
r6740r6741
582525
583526READ8_HANDLER( balsente_m6850_sound_r )
584527{
528   balsente_state *state = (balsente_state *)space->machine->driver_data;
585529   int result;
586530
587531   /* status register is at offset 0 */
588532   if (offset == 0)
589533   {
590      result = m6850_sound_status;
534      result = state->m6850_sound_status;
591535   }
592536
593537   /* input register is at offset 1 */
594538   else
595539   {
596      result = m6850_sound_input;
540      result = state->m6850_sound_input;
597541
598542      /* clear the overrun and receive buffer full bits */
599      m6850_sound_status &= ~0x21;
543      state->m6850_sound_status &= ~0x21;
600544      m6850_update_io(space->machine);
601545   }
602546
r6740r6741
606550
607551WRITE8_HANDLER( balsente_m6850_sound_w )
608552{
553   balsente_state *state = (balsente_state *)space->machine->driver_data;
554
609555   /* control register is at offset 0 */
610556   if (offset == 0)
611      m6850_sound_control = data;
557      state->m6850_sound_control = data;
612558
613559   /* output register is at offset 1 */
614560   else
615561   {
616      m6850_sound_output = data;
617      m6850_sound_status &= ~0x02;
562      state->m6850_sound_output = data;
563      state->m6850_sound_status &= ~0x02;
618564   }
619565
620566   /* re-update since interrupt enables could have been modified */
r6740r6741
631577
632578INTERRUPT_GEN( balsente_update_analog_inputs )
633579{
580   balsente_state *state = (balsente_state *)device->machine->driver_data;
634581   int i;
635582   static const char *const analog[] = { "AN0", "AN1", "AN2", "AN3" };
636583
r6740r6741
639586   /* ports are read once a frame, just at varying intervals. To get around this, we */
640587   /* read all the analog inputs at VBLANK time and just return the cached values. */
641588   for (i = 0; i < 4; i++)
642      analog_input_data[i] = input_port_read(device->machine, analog[i]);
589      state->analog_input_data[i] = input_port_read(device->machine, analog[i]);
643590}
644591
645592
646593static TIMER_CALLBACK( adc_finished )
647594{
595   balsente_state *state = (balsente_state *)machine->driver_data;
648596   int which = param;
649597
650598   /* analog controls are read in two pieces; the lower port returns the sign */
651599   /* and the upper port returns the absolute value of the magnitude */
652   int val = analog_input_data[which / 2] << balsente_adc_shift;
600   int val = state->analog_input_data[which / 2] << state->adc_shift;
653601
654602   /* special case for Stompin'/Shrike Avenger */
655   if (balsente_adc_shift == 32)
603   if (state->adc_shift == 32)
656604   {
657      adc_value = analog_input_data[which];
605      state->adc_value = state->analog_input_data[which];
658606      return;
659607   }
660608
r6740r6741
669617
670618   /* return the sign */
671619   if (!(which & 1))
672      adc_value = (val < 0) ? 0xff : 0x00;
620      state->adc_value = (val < 0) ? 0xff : 0x00;
673621
674622   /* return the magnitude */
675623   else
676      adc_value = (val < 0) ? -val : val;
624      state->adc_value = (val < 0) ? -val : val;
677625}
678626
679627
680628READ8_HANDLER( balsente_adc_data_r )
681629{
630   balsente_state *state = (balsente_state *)space->machine->driver_data;
631
682632   /* just return the last value read */
683   return adc_value;
633   return state->adc_value;
684634}
685635
686636
r6740r6741
702652 *
703653 *************************************/
704654
705INLINE void counter_start(int which)
655INLINE void counter_start(balsente_state *state, int which)
706656{
707657   /* don't start a timer for channel 0; it is clocked manually */
708658   if (which != 0)
709659   {
710660      /* only start a timer if we're gated and there is none already */
711      if (counter[which].gate && !counter[which].timer_active)
661      if (state->counter[which].gate && !state->counter[which].timer_active)
712662      {
713         counter[which].timer_active = 1;
714         timer_adjust_oneshot(counter[which].timer, attotime_mul(ATTOTIME_IN_HZ(2000000), counter[which].count), which);
663         state->counter[which].timer_active = 1;
664         timer_device_adjust_oneshot(state->counter[which].timer, attotime_mul(ATTOTIME_IN_HZ(2000000), state->counter[which].count), which);
715665      }
716666   }
717667}
718668
719669
720INLINE void counter_stop(int which)
670INLINE void counter_stop(balsente_state *state, int which)
721671{
722672   /* only stop the timer if it exists */
723   if (counter[which].timer_active)
724      timer_adjust_oneshot(counter[which].timer, attotime_never, 0);
725   counter[which].timer_active = 0;
673   if (state->counter[which].timer_active)
674      timer_device_adjust_oneshot(state->counter[which].timer, attotime_never, 0);
675   state->counter[which].timer_active = 0;
726676}
727677
728678
729INLINE void counter_update_count(int which)
679INLINE void counter_update_count(balsente_state *state, int which)
730680{
731681   /* only update if the timer is running */
732   if (counter[which].timer_active)
682   if (state->counter[which].timer_active)
733683   {
734684      /* determine how many 2MHz cycles are remaining */
735      int count = attotime_to_double(attotime_mul(timer_timeleft(counter[which].timer), 2000000));
736      counter[which].count = (count < 0) ? 0 : count;
685      int count = attotime_to_double(attotime_mul(timer_device_timeleft(state->counter[which].timer), 2000000));
686      state->counter[which].count = (count < 0) ? 0 : count;
737687   }
738688}
739689
r6740r6741
749699
750700static void counter_set_gate(running_machine *machine, int which, int gate)
751701{
752   int oldgate = counter[which].gate;
702   balsente_state *state = (balsente_state *)machine->driver_data;
703   int oldgate = state->counter[which].gate;
753704
754705   /* remember the gate state */
755   counter[which].gate = gate;
706   state->counter[which].gate = gate;
756707
757708   /* if the counter is being halted, update the count and remove the system timer */
758709   if (!gate && oldgate)
759710   {
760      counter_update_count(which);
761      counter_stop(which);
711      counter_update_count(state, which);
712      counter_stop(state, which);
762713   }
763714
764715   /* if the counter is being started, create the timer */
765716   else if (gate && !oldgate)
766717   {
767718      /* mode 1 waits for the gate to trigger the counter */
768      if (counter[which].mode == 1)
719      if (state->counter[which].mode == 1)
769720      {
770721         counter_set_out(machine, which, 0);
771722
772723         /* add one to the count; technically, OUT goes low on the next clock pulse */
773724         /* and then starts counting down; it's important that we don't count the first one */
774         counter[which].count = counter[which].initial + 1;
725         state->counter[which].count = state->counter[which].initial + 1;
775726      }
776727
777728      /* start the counter */
778      counter_start(which);
729      counter_start(state, which);
779730   }
780731}
781732
782733
783734static void counter_set_out(running_machine *machine, int which, int out)
784735{
736   balsente_state *state = (balsente_state *)machine->driver_data;
737
785738   /* OUT on counter 2 is hooked to the /INT line on the Z80 */
786739   if (which == 2)
787740      cputag_set_input_line(machine, "audiocpu", 0, out ? ASSERT_LINE : CLEAR_LINE);
r6740r6741
791744      counter_set_gate(machine, 1, !out);
792745
793746   /* remember the out state */
794   counter[which].out = out;
747   state->counter[which].out = out;
795748}
796749
797750
798static TIMER_CALLBACK( counter_callback )
751TIMER_DEVICE_CALLBACK( balsente_counter_callback )
799752{
753   balsente_state *state = (balsente_state *)timer->machine->driver_data;
754
800755   /* reset the counter and the count */
801   counter[param].timer_active = 0;
802   counter[param].count = 0;
756   state->counter[param].timer_active = 0;
757   state->counter[param].count = 0;
803758
804759   /* set the state of the OUT line */
805760   /* mode 0 and 1: when firing, transition OUT to high */
806   if (counter[param].mode == 0 || counter[param].mode == 1)
807      counter_set_out(machine, param, 1);
761   if (state->counter[param].mode == 0 || state->counter[param].mode == 1)
762      counter_set_out(timer->machine, param, 1);
808763
809764   /* no other modes handled currently */
810765}
r6740r6741
821776
822777READ8_HANDLER( balsente_counter_8253_r )
823778{
779   balsente_state *state = (balsente_state *)space->machine->driver_data;
824780   int which;
825781
826782   switch (offset & 3)
r6740r6741
832788         which = offset & 3;
833789
834790         /* update the count */
835         counter_update_count(which);
791         counter_update_count(state, which);
836792
837793         /* return the LSB */
838         if (counter[which].readbyte == 0)
794         if (state->counter[which].readbyte == 0)
839795         {
840            counter[which].readbyte = 1;
841            return counter[which].count & 0xff;
796            state->counter[which].readbyte = 1;
797            return state->counter[which].count & 0xff;
842798         }
843799
844800         /* write the MSB and reset the counter */
845801         else
846802         {
847            counter[which].readbyte = 0;
848            return (counter[which].count >> 8) & 0xff;
803            state->counter[which].readbyte = 0;
804            return (state->counter[which].count >> 8) & 0xff;
849805         }
850806         break;
851807   }
r6740r6741
855811
856812WRITE8_HANDLER( balsente_counter_8253_w )
857813{
814   balsente_state *state = (balsente_state *)space->machine->driver_data;
858815   int which;
859816
860817   switch (offset & 3)
r6740r6741
866823         which = offset & 3;
867824
868825         /* if the counter is in mode 0, a write here will reset the OUT state */
869         if (counter[which].mode == 0)
826         if (state->counter[which].mode == 0)
870827            counter_set_out(space->machine, which, 0);
871828
872829         /* write the LSB */
873         if (counter[which].writebyte == 0)
830         if (state->counter[which].writebyte == 0)
874831         {
875            counter[which].count = (counter[which].count & 0xff00) | (data & 0x00ff);
876            counter[which].initial = (counter[which].initial & 0xff00) | (data & 0x00ff);
877            counter[which].writebyte = 1;
832            state->counter[which].count = (state->counter[which].count & 0xff00) | (data & 0x00ff);
833            state->counter[which].initial = (state->counter[which].initial & 0xff00) | (data & 0x00ff);
834            state->counter[which].writebyte = 1;
878835         }
879836
880837         /* write the MSB and reset the counter */
881838         else
882839         {
883            counter[which].count = (counter[which].count & 0x00ff) | ((data << 8) & 0xff00);
884            counter[which].initial = (counter[which].initial & 0x00ff) | ((data << 8) & 0xff00);
885            counter[which].writebyte = 0;
840            state->counter[which].count = (state->counter[which].count & 0x00ff) | ((data << 8) & 0xff00);
841            state->counter[which].initial = (state->counter[which].initial & 0x00ff) | ((data << 8) & 0xff00);
842            state->counter[which].writebyte = 0;
886843
887844            /* treat 0 as $10000 */
888            if (counter[which].count == 0) counter[which].count = counter[which].initial = 0x10000;
845            if (state->counter[which].count == 0) state->counter[which].count = state->counter[which].initial = 0x10000;
889846
890847            /* remove any old timer and set a new one */
891            counter_stop(which);
848            counter_stop(state, which);
892849
893850            /* note that in mode 1, we have to wait for a rising edge of a gate */
894            if (counter[which].mode == 0)
895               counter_start(which);
851            if (state->counter[which].mode == 0)
852               counter_start(state, which);
896853
897854            /* if the counter is in mode 1, a write here will set the OUT state */
898            if (counter[which].mode == 1)
855            if (state->counter[which].mode == 1)
899856               counter_set_out(space->machine, which, 1);
900857         }
901858         break;
r6740r6741
906863         if (which == 3) break;
907864
908865         /* if the counter was in mode 0, a write here will reset the OUT state */
909         if (((counter[which].mode >> 1) & 7) == 0)
866         if (((state->counter[which].mode >> 1) & 7) == 0)
910867            counter_set_out(space->machine, which, 0);
911868
912869         /* set the mode */
913         counter[which].mode = (data >> 1) & 7;
870         state->counter[which].mode = (data >> 1) & 7;
914871
915872         /* if the counter is in mode 0, a write here will reset the OUT state */
916         if (counter[which].mode == 0)
873         if (state->counter[which].mode == 0)
917874            counter_set_out(space->machine, which, 0);
918875         break;
919876   }
r6740r6741
927884 *
928885 *************************************/
929886
930static void set_counter_0_ff(running_machine *machine, int newstate)
887static void set_counter_0_ff(const device_config *timer, int newstate)
931888{
889   balsente_state *state = (balsente_state *)timer->machine->driver_data;
890
932891   /* the flip/flop output is inverted, so if we went high to low, that's a clock */
933   if (counter_0_ff && !newstate)
892   if (state->counter_0_ff && !newstate)
934893   {
935894      /* only count if gated and non-zero */
936      if (counter[0].count > 0 && counter[0].gate)
895      if (state->counter[0].count > 0 && state->counter[0].gate)
937896      {
938         counter[0].count--;
939         if (counter[0].count == 0)
940            counter_callback(machine, NULL, 0);
897         state->counter[0].count--;
898         if (state->counter[0].count == 0)
899            balsente_counter_callback(timer, NULL, 0);
941900      }
942901   }
943902
944903   /* remember the new state */
945   counter_0_ff = newstate;
904   state->counter_0_ff = newstate;
946905}
947906
948907
949static TIMER_CALLBACK( clock_counter_0_ff )
908TIMER_DEVICE_CALLBACK( balsente_clock_counter_0_ff )
950909{
910   balsente_state *state = (balsente_state *)timer->machine->driver_data;
911
951912   /* clock the D value through the flip-flop */
952   set_counter_0_ff(machine, (counter_control >> 3) & 1);
913   set_counter_0_ff(timer, (state->counter_control >> 3) & 1);
953914}
954915
955916
956static void update_counter_0_timer(void)
917static void update_counter_0_timer(balsente_state *state)
957918{
958919   double maxfreq = 0.0;
959920   int i;
960921
961922   /* if there's already a timer, remove it */
962   if (counter_0_timer_active)
963      timer_adjust_oneshot(counter_0_timer, attotime_never, 0);
964   counter_0_timer_active = 0;
923   if (state->counter_0_timer_active)
924      timer_device_adjust_oneshot(state->counter_0_timer, attotime_never, 0);
925   state->counter_0_timer_active = 0;
965926
966927   /* find the counter with the maximum frequency */
967928   /* this is used to calibrate the timers at startup */
968929   for (i = 0; i < 6; i++)
969      if (cem3394_get_parameter(cem_device[i], CEM3394_FINAL_GAIN) < 10.0)
930      if (cem3394_get_parameter(state->cem_device[i], CEM3394_FINAL_GAIN) < 10.0)
970931      {
971932         double tempfreq;
972933
973934         /* if the filter resonance is high, then they're calibrating the filter frequency */
974         if (cem3394_get_parameter(cem_device[i], CEM3394_FILTER_RESONANCE) > 0.9)
975            tempfreq = cem3394_get_parameter(cem_device[i], CEM3394_FILTER_FREQENCY);
935         if (cem3394_get_parameter(state->cem_device[i], CEM3394_FILTER_RESONANCE) > 0.9)
936            tempfreq = cem3394_get_parameter(state->cem_device[i], CEM3394_FILTER_FREQENCY);
976937
977938         /* otherwise, they're calibrating the VCO frequency */
978939         else
979            tempfreq = cem3394_get_parameter(cem_device[i], CEM3394_VCO_FREQUENCY);
940            tempfreq = cem3394_get_parameter(state->cem_device[i], CEM3394_VCO_FREQUENCY);
980941
981942         if (tempfreq > maxfreq) maxfreq = tempfreq;
982943      }
r6740r6741
984945   /* reprime the timer */
985946   if (maxfreq > 0.0)
986947   {
987      counter_0_timer_active = 1;
988      timer_adjust_periodic(counter_0_timer, ATTOTIME_IN_HZ(maxfreq), 0, ATTOTIME_IN_HZ(maxfreq));
948      state->counter_0_timer_active = 1;
949      timer_device_adjust_periodic(state->counter_0_timer, ATTOTIME_IN_HZ(maxfreq), 0, ATTOTIME_IN_HZ(maxfreq));
989950   }
990951}
991952
r6740r6741
999960
1000961READ8_HANDLER( balsente_counter_state_r )
1001962{
963   balsente_state *state = (balsente_state *)space->machine->driver_data;
964
1002965   /* bit D0 is the inverse of the flip-flop state */
1003   int result = !counter_0_ff;
966   int result = !state->counter_0_ff;
1004967
1005968   /* bit D1 is the OUT value from counter 0 */
1006   if (counter[0].out) result |= 0x02;
969   if (state->counter[0].out) result |= 0x02;
1007970
1008971   return result;
1009972}
r6740r6741
1011974
1012975WRITE8_HANDLER( balsente_counter_control_w )
1013976{
1014   UINT8 diff_counter_control = counter_control ^ data;
977   balsente_state *state = (balsente_state *)space->machine->driver_data;
978   UINT8 diff_counter_control = state->counter_control ^ data;
1015979
1016980   /* set the new global value */
1017   counter_control = data;
981   state->counter_control = data;
1018982
1019983   /* bit D0 enables/disables audio */
1020984   if (diff_counter_control & 0x01)
1021985   {
1022986      int ch;
1023987      for (ch = 0; ch < 6; ch++)
1024         sound_set_output_gain(cem_device[ch], 0, (data & 0x01) ? 1.0 : 0);
988         sound_set_output_gain(state->cem_device[ch], 0, (data & 0x01) ? 1.0 : 0);
1025989   }
1026990
1027991   /* bit D1 is hooked to counter 0's gate */
1028992   /* if we gate on, start a pulsing timer to clock it */
1029   if (!counter[0].gate && (data & 0x02) && !counter_0_timer_active)
993   if (!state->counter[0].gate && (data & 0x02) && !state->counter_0_timer_active)
1030994   {
1031      update_counter_0_timer();
995      update_counter_0_timer(state);
1032996   }
1033997
1034998   /* if we gate off, remove the timer */
1035   else if (counter[0].gate && !(data & 0x02) && counter_0_timer_active)
999   else if (state->counter[0].gate && !(data & 0x02) && state->counter_0_timer_active)
10361000   {
1037      timer_adjust_oneshot(counter_0_timer, attotime_never, 0);
1038      counter_0_timer_active = 0;
1001      timer_device_adjust_oneshot(state->counter_0_timer, attotime_never, 0);
1002      state->counter_0_timer_active = 0;
10391003   }
10401004
10411005   /* set the actual gate afterwards, since we need to know the old value above */
10421006   counter_set_gate(space->machine, 0, (data >> 1) & 1);
10431007
10441008   /* bits D2 and D4 control the clear/reset flags on the flip-flop that feeds counter 0 */
1045   if (!(data & 0x04)) set_counter_0_ff(space->machine, 1);
1046   if (!(data & 0x10)) set_counter_0_ff(space->machine, 0);
1009   if (!(data & 0x04)) set_counter_0_ff(state->counter_0_timer, 1);
1010   if (!(data & 0x10)) set_counter_0_ff(state->counter_0_timer, 0);
10471011
10481012   /* bit 5 clears the NMI interrupt; recompute the I/O state now */
10491013   m6850_update_io(space->machine);
r6740r6741
10711035      CEM3394_WAVE_SELECT
10721036   };
10731037
1074   double voltage = (double)dac_value * (8.0 / 4096.0) - 4.0;
1075   int diffchip = data ^ chip_select, i;
1076   int reg = register_map[dac_register];
1038   balsente_state *state = (balsente_state *)space->machine->driver_data;
1039   double voltage = (double)state->dac_value * (8.0 / 4096.0) - 4.0;
1040   int diffchip = data ^ state->chip_select, i;
1041   int reg = register_map[state->dac_register];
10771042
10781043   /* remember the new select value */
1079   chip_select = data;
1044   state->chip_select = data;
10801045
10811046   /* check all six chip enables */
10821047   for (i = 0; i < 6; i++)
r6740r6741
10881053         /* remember the previous value */
10891054         temp =
10901055#endif
1091            cem3394_get_parameter(cem_device[i], reg);
1056            cem3394_get_parameter(state->cem_device[i], reg);
10921057
10931058         /* set the voltage */
1094         cem3394_set_voltage(cem_device[i], reg, voltage);
1059         cem3394_set_voltage(state->cem_device[i], reg, voltage);
10951060
10961061         /* only log changes */
10971062#if LOG_CEM_WRITES
1098         if (temp != cem3394_get_parameter(cem_device[i], reg))
1063         if (temp != cem3394_get_parameter(state->cem_device[i], reg))
10991064         {
11001065            static const char *const names[] =
11011066            {
r6740r6741
11081073               "PULSE_WIDTH",
11091074               "WAVE_SELECT"
11101075            };
1111            logerror("s%04X:   CEM#%d:%s=%f\n", cpu_get_previouspc(space->cpu), i, names[dac_register], voltage);
1076            logerror("s%04X:   CEM#%d:%s=%f\n", cpu_get_previouspc(space->cpu), i, names[state->dac_register], voltage);
11121077         }
11131078#endif
11141079      }
11151080
11161081   /* if a timer for counter 0 is running, recompute */
1117   if (counter_0_timer_active)
1118      update_counter_0_timer();
1082   if (state->counter_0_timer_active)
1083      update_counter_0_timer(state);
11191084}
11201085
11211086
11221087
11231088WRITE8_HANDLER( balsente_dac_data_w )
11241089{
1090   balsente_state *state = (balsente_state *)space->machine->driver_data;
1091
11251092   /* LSB or MSB? */
11261093   if (offset & 1)
1127      dac_value = (dac_value & 0xfc0) | ((data >> 2) & 0x03f);
1094      state->dac_value = (state->dac_value & 0xfc0) | ((data >> 2) & 0x03f);
11281095   else
1129      dac_value = (dac_value & 0x03f) | ((data << 6) & 0xfc0);
1096      state->dac_value = (state->dac_value & 0x03f) | ((data << 6) & 0xfc0);
11301097
11311098   /* if there are open channels, force the values in */
1132   if ((chip_select & 0x3f) != 0x3f)
1099   if ((state->chip_select & 0x3f) != 0x3f)
11331100   {
1134      UINT8 temp = chip_select;
1101      UINT8 temp = state->chip_select;
11351102      balsente_chip_select_w(space, 0, 0x3f);
11361103      balsente_chip_select_w(space, 0, temp);
11371104   }
r6740r6741
11401107
11411108WRITE8_HANDLER( balsente_register_addr_w )
11421109{
1143   dac_register = data & 7;
1110   balsente_state *state = (balsente_state *)space->machine->driver_data;
1111   state->dac_register = data & 7;
11441112}
11451113
11461114
r6740r6741
11531121
11541122CUSTOM_INPUT( nstocker_bits_r )
11551123{
1156   return nstocker_bits;
1124   balsente_state *state = (balsente_state *)field->port->machine->driver_data;
1125   return state->nstocker_bits;
11571126}
11581127
11591128
11601129WRITE8_HANDLER( spiker_expand_w )
11611130{
1131   balsente_state *state = (balsente_state *)space->machine->driver_data;
1132
11621133   /* offset 0 is the bit pattern */
11631134   if (offset == 0)
1164      spiker_expand_bits = data;
1135      state->spiker_expand_bits = data;
11651136
11661137   /* offset 1 is the background color (cleared on each read) */
11671138   else if (offset == 1)
1168      spiker_expand_bgcolor = data;
1139      state->spiker_expand_bgcolor = data;
11691140
11701141   /* offset 2 is the color */
11711142   else if (offset == 2)
1172      spiker_expand_color = data;
1143      state->spiker_expand_color = data;
11731144}
11741145
11751146
11761147READ8_HANDLER( spiker_expand_r )
11771148{
1149   balsente_state *state = (balsente_state *)space->machine->driver_data;
11781150   UINT8 left, right;
11791151
11801152   /* first rotate each nibble */
1181   spiker_expand_bits = ((spiker_expand_bits << 1) & 0xee) | ((spiker_expand_bits >> 3) & 0x11);
1153   state->spiker_expand_bits = ((state->spiker_expand_bits << 1) & 0xee) | ((state->spiker_expand_bits >> 3) & 0x11);
11821154
11831155   /* compute left and right pixels */
1184   left  = (spiker_expand_bits & 0x10) ? spiker_expand_color : spiker_expand_bgcolor;
1185   right = (spiker_expand_bits & 0x01) ? spiker_expand_color : spiker_expand_bgcolor;
1156   left  = (state->spiker_expand_bits & 0x10) ? state->spiker_expand_color : state->spiker_expand_bgcolor;
1157   right = (state->spiker_expand_bits & 0x01) ? state->spiker_expand_color : state->spiker_expand_bgcolor;
11861158
11871159   /* reset the background color */
1188   spiker_expand_bgcolor = 0;
1160   state->spiker_expand_bgcolor = 0;
11891161
11901162   /* return the combined result */
11911163   return (left & 0xf0) | (right & 0x0f);
r6740r6741
11941166
11951167static void update_grudge_steering(running_machine *machine)
11961168{
1169   balsente_state *state = (balsente_state *)machine->driver_data;
11971170   UINT8 wheel[3];
11981171   INT8 diff[3];
11991172
r6740r6741
12031176   wheel[2] = input_port_read(machine, "AN2");
12041177
12051178   /* diff the values */
1206   diff[0] = wheel[0] - grudge_last_steering[0];
1207   diff[1] = wheel[1] - grudge_last_steering[1];
1208   diff[2] = wheel[2] - grudge_last_steering[2];
1179   diff[0] = wheel[0] - state->grudge_last_steering[0];
1180   diff[1] = wheel[1] - state->grudge_last_steering[1];
1181   diff[2] = wheel[2] - state->grudge_last_steering[2];
12091182
12101183   /* update the last values */
1211   grudge_last_steering[0] += diff[0];
1212   grudge_last_steering[1] += diff[1];
1213   grudge_last_steering[2] += diff[2];
1184   state->grudge_last_steering[0] += diff[0];
1185   state->grudge_last_steering[1] += diff[1];
1186   state->grudge_last_steering[2] += diff[2];
12141187
12151188   /* compute the result */
1216   grudge_steering_result = 0xff;
1189   state->grudge_steering_result = 0xff;
12171190   if (diff[0])
12181191   {
1219      grudge_steering_result ^= 0x01;
1220      if (diff[0] > 0) grudge_steering_result ^= 0x02;
1192      state->grudge_steering_result ^= 0x01;
1193      if (diff[0] > 0) state->grudge_steering_result ^= 0x02;
12211194   }
12221195   if (diff[1])
12231196   {
1224      grudge_steering_result ^= 0x04;
1225      if (diff[1] > 0) grudge_steering_result ^= 0x08;
1197      state->grudge_steering_result ^= 0x04;
1198      if (diff[1] > 0) state->grudge_steering_result ^= 0x08;
12261199   }
12271200   if (diff[2])
12281201   {
1229      grudge_steering_result ^= 0x10;
1230      if (diff[2] > 0) grudge_steering_result ^= 0x20;
1202      state->grudge_steering_result ^= 0x10;
1203      if (diff[2] > 0) state->grudge_steering_result ^= 0x20;
12311204   }
12321205   logerror("Recomputed steering\n");
12331206}
r6740r6741
12351208
12361209READ8_HANDLER( grudge_steering_r )
12371210{
1211   balsente_state *state = (balsente_state *)space->machine->driver_data;
12381212   logerror("%04X:grudge_steering_r(@%d)\n", cpu_get_pc(space->cpu), video_screen_get_vpos(space->machine->primary_screen));
1239   grudge_steering_result |= 0x80;
1240   return grudge_steering_result;
1213   state->grudge_steering_result |= 0x80;
1214   return state->grudge_steering_result;
12411215}
12421216
12431217
r6740r6741
12501224
12511225READ8_HANDLER( shrike_shared_6809_r )
12521226{
1253  UINT16 mem_mask = offset & 1 ? 0xff00 : 0x00ff;
1227   balsente_state *state = (balsente_state *)space->machine->driver_data;
1228   UINT16 mem_mask = offset & 1 ? 0xff00 : 0x00ff;
12541229
1255  switch( offset )
1256  {
1257    case 6: // return OK for 68k status register until motors hooked up
1258      return 0;
1259    default:
1260      return ( shrike_shared[offset >> 1] & ~mem_mask ) >> ( mem_mask & 8 );
1261  }
1230   switch( offset )
1231   {
1232      case 6: // return OK for 68k status register until motors hooked up
1233         return 0;
1234      default:
1235         return ( state->shrike_shared[offset >> 1] & ~mem_mask ) >> ( mem_mask & 8 );
1236   }
12621237}
12631238
12641239
12651240WRITE8_HANDLER( shrike_shared_6809_w )
12661241{
1267  UINT16 mem_mask = offset & 1 ? 0xff00 : 0x00ff;
1268  shrike_shared[offset >> 1] = ( shrike_shared[offset >> 1] & mem_mask ) | ( data << ( mem_mask & 0x8 ) );
1242   balsente_state *state = (balsente_state *)space->machine->driver_data;
1243   UINT16 mem_mask = offset & 1 ? 0xff00 : 0x00ff;
1244   state->shrike_shared[offset >> 1] = ( state->shrike_shared[offset >> 1] & mem_mask ) | ( data << ( mem_mask & 0x8 ) );
12691245}
12701246
12711247// uses movep, so writes even 8 bit addresses to odd 16 bit addresses, reads as 16 bit from odd addresses
12721248// i.e. write 0xdeadbeef to 10000, read 0xde from 10001, 0xad from 10003, 0xbe from 10005...
12731249WRITE16_HANDLER( shrike_io_68k_w )
12741250{
1275  COMBINE_DATA( &shrike_io[offset] );
1251   balsente_state *state = (balsente_state *)space->machine->driver_data;
1252   COMBINE_DATA( &state->shrike_io[offset] );
12761253}
12771254
12781255READ16_HANDLER( shrike_io_68k_r )
12791256{
1280  return ( shrike_io[offset] & mem_mask ) >> ( 8 & ~mem_mask );
1257   balsente_state *state = (balsente_state *)space->machine->driver_data;
1258   return ( state->shrike_io[offset] & mem_mask ) >> ( 8 & ~mem_mask );
12811259}
12821260
src/mame/machine/segag80.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "segag80r.h"
8#include "includes/segag80r.h"
99
1010UINT8 (*sega_decrypt)(offs_t,UINT8);
1111
src/mame/machine/cchasm.c
r6740r6741
66
77#include "driver.h"
88#include "video/vector.h"
9#include "cchasm.h"
9#include "includes/cchasm.h"
1010
1111WRITE16_HANDLER( cchasm_led_w )
1212{
src/mame/machine/qix.c
r6740r6741
1111#include "cpu/m6805/m6805.h"
1212#include "cpu/m6809/m6809.h"
1313#include "sound/sn76496.h"
14#include "qix.h"
14#include "includes/qix.h"
1515
1616
1717
src/mame/machine/theglobp.c
r6740r6741
238238}
239239
240240
241MACHINE_RESET( theglobp )
241MACHINE_START( theglobp )
242242{
243243   UINT8 *RAM = memory_region(machine, "maincpu");
244244
r6740r6741
250250   theglobp_decrypt_rom_A(machine);
251251   theglobp_decrypt_rom_B(machine);
252252
253   /* The initial state of the counter is 0x0A */
254   counter = 0x0A;
255253   memory_configure_bank(machine, "bank1", 0, 4, &RAM[0x10000], 0x4000);
256   memory_set_bank(machine, "bank1", 2);
257254
258255   state_save_register_global(machine, counter);
259256}
257
258
259MACHINE_RESET( theglobp )
260{
261   /* The initial state of the counter is 0x0A */
262   counter = 0x0A;
263   memory_set_bank(machine, "bank1", 2);
264}
src/mame/machine/snes.c
r6740r6741
19721972
19731973*************************************/
19741974
1975static void snes_init_timers(running_machine *machine)
1976{
1977   /* init timers and stop them */
1978   snes_scanline_timer = timer_alloc(machine, snes_scanline_tick, NULL);
1979   timer_adjust_oneshot(snes_scanline_timer, attotime_never, 0);
1980   snes_hblank_timer = timer_alloc(machine, snes_hblank_tick, NULL);
1981   timer_adjust_oneshot(snes_hblank_timer, attotime_never, 0);
1982   snes_nmi_timer = timer_alloc(machine, snes_nmi_tick, NULL);
1983   timer_adjust_oneshot(snes_nmi_timer, attotime_never, 0);
1984   snes_hirq_timer = timer_alloc(machine, snes_hirq_tick_callback, NULL);
1985   timer_adjust_oneshot(snes_hirq_timer, attotime_never, 0);
1986
1987   // SNES hcounter has a 0-339 range.  hblank starts at counter 260.
1988   // clayfighter sets an HIRQ at 260, apparently it wants it to be before hdma kicks off, so we'll delay 2 pixels.
1989   hblank_offset = 268;
1990   timer_adjust_oneshot(snes_hblank_timer, video_screen_get_time_until_pos(machine->primary_screen, ((snes_ram[STAT78] & 0x10) == SNES_NTSC) ? SNES_VTOTAL_NTSC-1 : SNES_VTOTAL_PAL-1, hblank_offset), 0);
1991
1992}
1993
19751994static void snes_init_ram(running_machine *machine)
19761995{
19771996   const address_space *cpu0space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
r6740r6741
20202039   snes_ram[WRIO] = 0xff;
20212040   snes_ram[VMAIN] = 0x80;
20222041
2023   /* init timers and stop them */
2024   snes_scanline_timer = timer_alloc(machine, snes_scanline_tick, NULL);
2025   timer_adjust_oneshot(snes_scanline_timer, attotime_never, 0);
2026   snes_hblank_timer = timer_alloc(machine, snes_hblank_tick, NULL);
2027   timer_adjust_oneshot(snes_hblank_timer, attotime_never, 0);
2028   snes_nmi_timer = timer_alloc(machine, snes_nmi_tick, NULL);
2029   timer_adjust_oneshot(snes_nmi_timer, attotime_never, 0);
2030   snes_hirq_timer = timer_alloc(machine, snes_hirq_tick_callback, NULL);
2031   timer_adjust_oneshot(snes_hirq_timer, attotime_never, 0);
2032
2033   // SNES hcounter has a 0-339 range.  hblank starts at counter 260.
2034   // clayfighter sets an HIRQ at 260, apparently it wants it to be before hdma kicks off, so we'll delay 2 pixels.
2035   hblank_offset = 268;
2036   timer_adjust_oneshot(snes_hblank_timer, video_screen_get_time_until_pos(machine->primary_screen, ((snes_ram[STAT78] & 0x10) == SNES_NTSC) ? SNES_VTOTAL_NTSC-1 : SNES_VTOTAL_PAL-1, hblank_offset), 0);
2037
20382042   switch (snes_has_addon_chip)
20392043   {
20402044      case HAS_DSP1:
r6740r6741
21432147         st010_init(machine);
21442148         break;
21452149   }
2150
2151   snes_init_timers(machine);
21462152}
21472153
21482154MACHINE_RESET( snes )
src/mame/machine/vertigo.c
r6740r6741
55*************************************************************************/
66
77#include "driver.h"
8#include "vertigo.h"
9#include "exidy440.h"
8#include "includes/vertigo.h"
9#include "includes/exidy440.h"
1010#include "machine/74148.h"
1111#include "machine/pit8253.h"
1212
1313
14static const device_config *ttl74148;
1415
16
17
1518/*************************************
1619 *
1720 *  Prototypes
r6740r6741
2023
2124static PIT8253_OUTPUT_CHANGED( v_irq4_w );
2225static PIT8253_OUTPUT_CHANGED( v_irq3_w );
23static void update_irq(running_machine *machine);
2426
2527
2628
r6740r6741
5961};
6062
6163
62static const struct TTL74148_interface irq_encoder =
63{
64   update_irq
65};
6664
67
68
6965/*************************************
7066 *
7167 *  IRQ handling. The priority encoder
r6740r6741
7470 *
7571 *************************************/
7672
77static void update_irq(running_machine *machine)
73void vertigo_update_irq(const device_config *device)
7874{
7975   if (irq_state < 7)
80      cputag_set_input_line(machine, "maincpu", irq_state ^ 7, CLEAR_LINE);
76      cputag_set_input_line(device->machine, "maincpu", irq_state ^ 7, CLEAR_LINE);
8177
82   irq_state = TTL74148_output_r(0);
78   irq_state = ttl74148_output_r(device);
8379
8480   if (irq_state < 7)
85      cputag_set_input_line(machine, "maincpu", irq_state ^ 7, ASSERT_LINE);
81      cputag_set_input_line(device->machine, "maincpu", irq_state ^ 7, ASSERT_LINE);
8682}
8783
8884
8985static void update_irq_encoder(running_machine *machine, int line, int state)
9086{
91   TTL74148_input_line_w(0, line, !state);
92   TTL74148_update(machine, 0);
87   ttl74148_input_line_w(ttl74148, line, !state);
88   ttl74148_update(ttl74148);
9389}
9490
9591
r6740r6741
207203 *
208204 *************************************/
209205
206MACHINE_START( vertigo )
207{
208   state_save_register_global(machine, irq_state);
209   state_save_register_global(machine, adc_result);
210   state_save_register_global(machine, irq4_time.seconds);
211   state_save_register_global(machine, irq4_time.attoseconds);
212
213   vertigo_vproc_init(machine);
214}
215
210216MACHINE_RESET( vertigo )
211217{
212218   int i;
213219
214   TTL74148_config(machine, 0, &irq_encoder);
215   TTL74148_enable_input_w(0, 0);
220   ttl74148 = devtag_get_device(machine, "74148");
221   ttl74148_enable_input_w(ttl74148, 0);
216222
217223   for (i = 0; i < 8; i++)
218      TTL74148_input_line_w(0, i, 1);
224      ttl74148_input_line_w(ttl74148, i, 1);
219225
220   TTL74148_update(machine, 0);
221   vertigo_vproc_init(machine);
226   ttl74148_update(ttl74148);
227   vertigo_vproc_reset(machine);
222228
223229   irq4_time = timer_get_time(machine);
224230   irq_state = 7;
225
226   state_save_register_global(machine, irq_state);
227   state_save_register_global(machine, adc_result);
228   state_save_register_global(machine, irq4_time.seconds);
229   state_save_register_global(machine, irq4_time.attoseconds);
230231}
231232
232233
src/mame/machine/neoprot.c
r6740r6741
1818***************************************************************************/
1919
2020#include "driver.h"
21#include "neogeo.h"
21#include "includes/neogeo.h"
2222
23
24
25static UINT32 fatfury2_prot_data;
26static UINT16 neogeo_rng;
27
28static UINT16 *pvc_cartridge_ram;
29
30
3123/************************ Fatal Fury 2 *************************/
3224
3325static READ16_HANDLER( fatfury2_protection_16_r )
3426{
35   UINT16 res = fatfury2_prot_data >> 24;
27   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
28   UINT16 res = state->fatfury2_prot_data >> 24;
3629
3730   switch (offset)
3831   {
r6740r6741
4942         return ((res & 0xf0) >> 4) | ((res & 0x0f) << 4);
5043
5144      default:
52logerror("unknown protection read at pc %06x, offset %08x\n",cpu_get_pc(space->cpu),offset<<1);
45         logerror("unknown protection read at pc %06x, offset %08x\n", cpu_get_pc(space->cpu), offset << 1);
5346         return 0;
5447   }
5548}
r6740r6741
5750
5851static WRITE16_HANDLER( fatfury2_protection_16_w )
5952{
53   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
54
6055   switch (offset)
6156   {
6257      case 0x11112/2: /* data == 0x1111; expects 0xff000000 back */
63         fatfury2_prot_data = 0xff000000;
58         state->fatfury2_prot_data = 0xff000000;
6459         break;
6560
6661      case 0x33332/2: /* data == 0x3333; expects 0x0000ffff back */
67         fatfury2_prot_data = 0x0000ffff;
62         state->fatfury2_prot_data = 0x0000ffff;
6863         break;
6964
7065      case 0x44442/2: /* data == 0x4444; expects 0x00ff0000 back */
71         fatfury2_prot_data = 0x00ff0000;
66         state->fatfury2_prot_data = 0x00ff0000;
7267         break;
7368
7469      case 0x55552/2: /* data == 0x5555; read back from 55550, ffff0, 00000, ff000 */
75         fatfury2_prot_data = 0xff00ff00;
70         state->fatfury2_prot_data = 0xff00ff00;
7671         break;
7772
7873      case 0x56782/2: /* data == 0x1234; read back from 36000 *or* 36004 */
79         fatfury2_prot_data = 0xf05a3601;
74         state->fatfury2_prot_data = 0xf05a3601;
8075         break;
8176
8277      case 0x42812/2: /* data == 0x1824; read back from 36008 *or* 3600c */
83         fatfury2_prot_data = 0x81422418;
78         state->fatfury2_prot_data = 0x81422418;
8479         break;
8580
8681      case 0x55550/2:
r6740r6741
9085      case 0x36004/2:
9186      case 0x36008/2:
9287      case 0x3600c/2:
93         fatfury2_prot_data <<= 8;
88         state->fatfury2_prot_data <<= 8;
9489         break;
9590
9691      default:
97         logerror("unknown protection write at pc %06x, offset %08x, data %02x\n",cpu_get_pc(space->cpu),offset,data);
92         logerror("unknown protection write at pc %06x, offset %08x, data %02x\n", cpu_get_pc(space->cpu), offset, data);
9893         break;
9994   }
10095}
10196
10297
103void fatfury2_install_protection(running_machine *machine)
98void fatfury2_install_protection( running_machine *machine )
10499{
100   neogeo_state *state = (neogeo_state *)machine->driver_data;
101
105102   /* the protection involves reading and writing addresses in the */
106103   /* 0x2xxxxx range. There are several checks all around the code. */
107104   memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x200000, 0x2fffff, 0, 0, fatfury2_protection_16_r, fatfury2_protection_16_w);
108105
109   state_save_register_global(machine, fatfury2_prot_data);
106   state->fatfury2_prot_data = 0;
107
108   state_save_register_global(machine, state->fatfury2_prot_data);
110109}
111110
112111
r6740r6741
124123
125124   switch (data)
126125   {
127      case 0x0090:
128      logerror ("%06x kof98 - protection 0x0090 old %04x %04x\n",cpu_get_pc(space->cpu), mem16[0x100/2], mem16[0x102/2]);
129      mem16[0x100/2] = 0x00c2; mem16[0x102/2] = 0x00fd;
126   case 0x0090:
127      logerror ("%06x kof98 - protection 0x0090 old %04x %04x\n", cpu_get_pc(space->cpu), mem16[0x100/2], mem16[0x102/2]);
128      mem16[0x100/2] = 0x00c2;
129      mem16[0x102/2] = 0x00fd;
130130      break;
131131
132      case 0x00f0:
133      logerror ("%06x kof98 - protection 0x00f0 old %04x %04x\n",cpu_get_pc(space->cpu), mem16[0x100/2], mem16[0x102/2]);
134      mem16[0x100/2] = 0x4e45; mem16[0x102/2] = 0x4f2d;
132   case 0x00f0:
133      logerror ("%06x kof98 - protection 0x00f0 old %04x %04x\n", cpu_get_pc(space->cpu), mem16[0x100/2], mem16[0x102/2]);
134      mem16[0x100/2] = 0x4e45;
135      mem16[0x102/2] = 0x4f2d;
135136      break;
136137
137      default: // 00aa is written, but not needed?
138      logerror ("%06x kof98 - unknown protection write %04x\n",cpu_get_pc(space->cpu), data);
138   default: // 00aa is written, but not needed?
139      logerror ("%06x kof98 - unknown protection write %04x\n", cpu_get_pc(space->cpu), data);
139140      break;
140141   }
141142}
142143
143144
144void install_kof98_protection(running_machine *machine)
145void install_kof98_protection( running_machine *machine )
145146{
146   /* when 0x20aaaa contains 0x0090 (word) then 0x100 (normally the neogeo header) should return 0x00c200fd
147   worked out using real hw */
147   /* when 0x20aaaa contains 0x0090 (word) then 0x100 (normally the neogeo header) should return 0x00c200fd worked out using real hw */
148148
149149   memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x20aaaa, 0x20aaab, 0, 0, kof98_prot_w);
150150}
r6740r6741
157157  Also found on this special board is a QFP144 labeled with 0103
158158***************************************************************/
159159
160void mslugx_install_protection(running_machine *machine)
160void mslugx_install_protection( running_machine *machine )
161161{
162162   int i;
163163   UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu");
164164
165165   for (i = 0;i < (0x100000/2) - 4;i++)
166166   {
167      if (mem16[i+0] == 0x0243 &&
168         mem16[i+1] == 0x0001 &&    /* andi.w  #$1, D3 */
169         mem16[i+2] == 0x6600)      /* bne xxxx */
167      if (mem16[i + 0] == 0x0243 &&
168         mem16[i + 1] == 0x0001 &&    /* andi.w  #$1, D3 */
169         mem16[i + 2] == 0x6600)      /* bne xxxx */
170170      {
171         mem16[i+2] = 0x4e71;
172         mem16[i+3] = 0x4e71;
171         mem16[i + 2] = 0x4e71;
172         mem16[i + 3] = 0x4e71;
173173      }
174174   }
175175   mem16[0x3bdc/2] = 0x4e71;
r6740r6741
375375
376376static READ16_HANDLER( sma_random_r )
377377{
378   UINT16 old = neogeo_rng;
378   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
379   UINT16 old = state->neogeo_rng;
379380
380   UINT16 newbit = ((neogeo_rng >> 2) ^
381                (neogeo_rng >> 3) ^
382                (neogeo_rng >> 5) ^
383                (neogeo_rng >> 6) ^
384                (neogeo_rng >> 7) ^
385                (neogeo_rng >>11) ^
386                (neogeo_rng >>12) ^
387                (neogeo_rng >>15)) & 1;
381   UINT16 newbit = ((state->neogeo_rng >> 2) ^
382                (state->neogeo_rng >> 3) ^
383                (state->neogeo_rng >> 5) ^
384                (state->neogeo_rng >> 6) ^
385                (state->neogeo_rng >> 7) ^
386                (state->neogeo_rng >>11) ^
387                (state->neogeo_rng >>12) ^
388                (state->neogeo_rng >>15)) & 1;
388389
389   neogeo_rng = (neogeo_rng << 1) | newbit;
390   state->neogeo_rng = (state->neogeo_rng << 1) | newbit;
390391
391392   return old;
392393}
393394
394395
395void neogeo_reset_rng(void)
396void neogeo_reset_rng( running_machine *machine )
396397{
397   neogeo_rng = 0x2345;
398   neogeo_state *state = (neogeo_state *)machine->driver_data;
399   state->neogeo_rng = 0x2345;
398400}
399401
400402
401static void sma_install_random_read_handler(running_machine *machine, int addr1, int addr2)
403static void sma_install_random_read_handler( running_machine *machine, int addr1, int addr2 )
402404{
403   state_save_register_global(machine, neogeo_rng);
405   neogeo_state *state = (neogeo_state *)machine->driver_data;
406   state_save_register_global(machine, state->neogeo_rng);
404407
405408   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), addr1, addr1 + 1, 0, 0, sma_random_r);
406409   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), addr2, addr2 + 1, 0, 0, sma_random_r);
407410}
408411
409412
410void kof99_install_protection(running_machine *machine)
413void kof99_install_protection( running_machine *machine )
411414{
412415   memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x2ffff0, 0x2ffff1, 0, 0, kof99_bankswitch_w);
413416   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x2fe446, 0x2fe447, 0, 0, prot_9a37_r);
r6740r6741
416419}
417420
418421
419void garou_install_protection(running_machine *machine)
422void garou_install_protection( running_machine *machine )
420423{
421424   memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x2fffc0, 0x2fffc1, 0, 0, garou_bankswitch_w);
422425   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x2fe446, 0x2fe447, 0, 0, prot_9a37_r);
r6740r6741
425428}
426429
427430
428void garouo_install_protection(running_machine *machine)
431void garouo_install_protection( running_machine *machine )
429432{
430433   memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x2fffc0, 0x2fffc1, 0, 0, garouo_bankswitch_w);
431434   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x2fe446, 0x2fe447, 0, 0, prot_9a37_r);
r6740r6741
434437}
435438
436439
437void mslug3_install_protection(running_machine *machine)
440void mslug3_install_protection( running_machine *machine )
438441{
439442   memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x2fffe4, 0x2fffe5, 0, 0, mslug3_bankswitch_w);
440443   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x2fe446, 0x2fe447, 0, 0, prot_9a37_r);
r6740r6741
443446}
444447
445448
446void kof2000_install_protection(running_machine *machine)
449void kof2000_install_protection( running_machine *machine )
447450{
448451   memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x2fffec, 0x2fffed, 0, 0, kof2000_bankswitch_w);
449452   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x2fe446, 0x2fe447, 0, 0, prot_9a37_r);
r6740r6741
457460  mslug5, svcchaos, kof2003
458461***************************************************************/
459462
460static void pvc_w8(offs_t offset, UINT8 data)
463static void pvc_w8( running_machine *machine, offs_t offset, UINT8 data )
461464{
462   *(((UINT8*)pvc_cartridge_ram)+BYTE_XOR_LE(offset))=data;
465   neogeo_state *state = (neogeo_state *)machine->driver_data;
466   *(((UINT8*)state->pvc_cartridge_ram) + BYTE_XOR_LE(offset)) = data;
463467}
464468
465469
466static UINT8 pvc_r8(offs_t offset)
470static UINT8 pvc_r8( running_machine *machine, offs_t offset )
467471{
468   return *(((UINT8*)pvc_cartridge_ram)+BYTE_XOR_LE(offset));
472   neogeo_state *state = (neogeo_state *)machine->driver_data;
473   return *(((UINT8*)state->pvc_cartridge_ram) + BYTE_XOR_LE(offset));
469474}
470475
471476
472static void pvc_prot1( void )
477static void pvc_prot1( running_machine *machine )
473478{
474479   UINT8 b1, b2;
475   b1 = pvc_r8(0x1fe1);
476   b2 = pvc_r8(0x1fe0);
477   pvc_w8(0x1fe2,(((b2>>0)&0xf)<<1)|((b1>>4)&1));
478   pvc_w8(0x1fe3,(((b2>>4)&0xf)<<1)|((b1>>5)&1));
479   pvc_w8(0x1fe4,(((b1>>0)&0xf)<<1)|((b1>>6)&1));
480   pvc_w8(0x1fe5, (b1>>7));
480
481   b1 = pvc_r8(machine, 0x1fe1);
482   b2 = pvc_r8(machine, 0x1fe0);
483   pvc_w8(machine, 0x1fe2, (((b2 >> 0) & 0xf) << 1) | ((b1 >> 4) & 1));
484   pvc_w8(machine, 0x1fe3, (((b2 >> 4) & 0xf) << 1) | ((b1 >> 5) & 1));
485   pvc_w8(machine, 0x1fe4, (((b1 >> 0) & 0xf) << 1) | ((b1 >> 6) & 1));
486   pvc_w8(machine, 0x1fe5, (b1 >> 7));
481487}
482488
483489
484static void pvc_prot2( void ) // on writes to e8/e9/ea/eb
490static void pvc_prot2( running_machine *machine ) // on writes to e8/e9/ea/eb
485491{
486492   UINT8 b1, b2, b3, b4;
487   b1 = pvc_r8(0x1fe9);
488   b2 = pvc_r8(0x1fe8);
489   b3 = pvc_r8(0x1feb);
490   b4 = pvc_r8(0x1fea);
491   pvc_w8(0x1fec,(b2>>1)|((b1>>1)<<4));
492   pvc_w8(0x1fed,(b4>>1)|((b2&1)<<4)|((b1&1)<<5)|((b4&1)<<6)|((b3&1)<<7));
493
494   b1 = pvc_r8(machine, 0x1fe9);
495   b2 = pvc_r8(machine, 0x1fe8);
496   b3 = pvc_r8(machine, 0x1feb);
497   b4 = pvc_r8(machine, 0x1fea);
498   pvc_w8(machine, 0x1fec, (b2 >> 1) | ((b1 >> 1) << 4));
499   pvc_w8(machine, 0x1fed, (b4 >> 1) | ((b2 & 1) << 4) | ((b1 & 1) << 5) | ((b4 & 1) << 6) | ((b3 & 1) << 7));
493500}
494501
495502
496503static void pvc_write_bankswitch( const address_space *space )
497504{
505   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
498506   UINT32 bankaddress;
499   bankaddress = ((pvc_cartridge_ram[0xff8]>>8)|(pvc_cartridge_ram[0xff9]<<8));
500   *(((UINT8 *)pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff0)) = 0xa0;
501   *(((UINT8 *)pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff1)) &= 0xfe;
502   *(((UINT8 *)pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff3)) &= 0x7f;
503   neogeo_set_main_cpu_bank_address(space, bankaddress+0x100000);
507
508   bankaddress = ((state->pvc_cartridge_ram[0xff8] >> 8)|(state->pvc_cartridge_ram[0xff9] << 8));
509   *(((UINT8 *)state->pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff0)) = 0xa0;
510   *(((UINT8 *)state->pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff1)) &= 0xfe;
511   *(((UINT8 *)state->pvc_cartridge_ram) + BYTE_XOR_LE(0x1ff3)) &= 0x7f;
512   neogeo_set_main_cpu_bank_address(space, bankaddress + 0x100000);
504513}
505514
506515
507516static READ16_HANDLER( pvc_prot_r )
508517{
509   return pvc_cartridge_ram[ offset ];
518   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
519   return state->pvc_cartridge_ram[offset];
510520}
511521
512522
513523static WRITE16_HANDLER( pvc_prot_w )
514524{
515   COMBINE_DATA( &pvc_cartridge_ram[ offset ] );
516   if (offset == 0xff0)pvc_prot1();
517   else if(offset >= 0xff4 && offset <= 0xff5)pvc_prot2();
518   else if(offset >= 0xff8)pvc_write_bankswitch(space);
525   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
526
527   COMBINE_DATA(&state->pvc_cartridge_ram[offset] );
528   if (offset == 0xff0)
529      pvc_prot1(space->machine);
530   else if(offset >= 0xff4 && offset <= 0xff5)
531      pvc_prot2(space->machine);
532   else if(offset >= 0xff8)
533      pvc_write_bankswitch(space);
519534}
520535
521536
522537void install_pvc_protection( running_machine *machine )
523538{
524   pvc_cartridge_ram = auto_alloc_array(machine, UINT16, 0x2000/2);
525   state_save_register_global_pointer(machine, pvc_cartridge_ram, 0x2000 / 2);
539   neogeo_state *state = (neogeo_state *)machine->driver_data;
540   state->pvc_cartridge_ram = auto_alloc_array(machine, UINT16, 0x2000 / 2);
541   state_save_register_global_pointer(machine, state->pvc_cartridge_ram, 0x2000 / 2);
526542
527543   memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x2fe000, 0x2fffff, 0, 0, pvc_prot_r, pvc_prot_w);
528544}
src/mame/machine/atarigen.c
r6740r6741
1414#include "sound/tms5220.h"
1515#include "sound/okim6295.h"
1616#include "sound/pokey.h"
17#include "slapstic.h"
17#include "includes/slapstic.h"
1818#include "atarigen.h"
1919
2020
r6740r6741
3232    STATIC FUNCTION DECLARATIONS
3333***************************************************************************/
3434
35static STATE_POSTLOAD( slapstic_postload );
36
3537static TIMER_CALLBACK( scanline_interrupt_callback );
3638
3739static void decompress_eeprom_word(UINT16 *dest, const UINT16 *data);
r6740r6741
5557
5658
5759/***************************************************************************
60    INLINE FUNCTIONS
61***************************************************************************/
62
63INLINE const atarigen_screen_timer *get_screen_timer(const device_config *screen)
64{
65   atarigen_state *state = (atarigen_state *)screen->machine->driver_data;
66   int i;
67
68   /* find the index of the timer that matches the screen */
69   for (i = 0; i < ARRAY_LENGTH(state->screen_timer); i++)
70      if (state->screen_timer[i].screen == screen)
71         return &state->screen_timer[i];
72
73   fatalerror("Unexpected: no atarivc_eof_update_timer for screen '%s'\n", screen->tag);
74   return NULL;
75}
76
77
78
79/***************************************************************************
80    OVERALL INIT
81***************************************************************************/
82
83void atarigen_init(running_machine *machine)
84{
85   atarigen_state *state = (atarigen_state *)machine->driver_data;
86   const device_config *screen;
87   int i;
88
89   /* allocate timers for all screens */
90   assert(video_screen_count(machine->config) <= ARRAY_LENGTH(state->screen_timer));
91   for (i = 0, screen = video_screen_first(machine->config); screen != NULL; i++, screen = video_screen_next(screen))
92   {
93      state->screen_timer[i].screen = screen;
94      state->screen_timer[i].scanline_interrupt_timer = timer_alloc(machine, scanline_interrupt_callback, (void *)screen);
95      state->screen_timer[i].scanline_timer = timer_alloc(machine, scanline_timer_callback, (void *)screen);
96      state->screen_timer[i].atarivc_eof_update_timer = timer_alloc(machine, atarivc_eof_update, (void *)screen);
97   }
98
99   state_save_register_global(machine, state->scanline_int_state);
100   state_save_register_global(machine, state->sound_int_state);
101   state_save_register_global(machine, state->video_int_state);
102
103   state_save_register_global(machine, state->cpu_to_sound_ready);
104   state_save_register_global(machine, state->sound_to_cpu_ready);
105
106   state_save_register_global(machine, state->atarivc_state.latch1);            /* latch #1 value (-1 means disabled) */
107   state_save_register_global(machine, state->atarivc_state.latch2);            /* latch #2 value (-1 means disabled) */
108   state_save_register_global(machine, state->atarivc_state.rowscroll_enable);      /* true if row-scrolling is enabled */
109   state_save_register_global(machine, state->atarivc_state.palette_bank);         /* which palette bank is enabled */
110   state_save_register_global(machine, state->atarivc_state.pf0_xscroll);         /* playfield 1 xscroll */
111   state_save_register_global(machine, state->atarivc_state.pf0_xscroll_raw);      /* playfield 1 xscroll raw value */
112   state_save_register_global(machine, state->atarivc_state.pf0_yscroll);         /* playfield 1 yscroll */
113   state_save_register_global(machine, state->atarivc_state.pf1_xscroll);         /* playfield 2 xscroll */
114   state_save_register_global(machine, state->atarivc_state.pf1_xscroll_raw);      /* playfield 2 xscroll raw value */
115   state_save_register_global(machine, state->atarivc_state.pf1_yscroll);         /* playfield 2 yscroll */
116   state_save_register_global(machine, state->atarivc_state.mo_xscroll);         /* sprite xscroll */
117   state_save_register_global(machine, state->atarivc_state.mo_yscroll);         /* sprite xscroll */
118
119   state_save_register_global(machine, state->eeprom_unlocked);
120
121   state_save_register_global(machine, state->slapstic_num);
122   state_save_register_global(machine, state->slapstic_bank);
123   state_save_register_global(machine, state->slapstic_last_pc);
124   state_save_register_global(machine, state->slapstic_last_address);
125
126   state_save_register_global(machine, state->cpu_to_sound);
127   state_save_register_global(machine, state->sound_to_cpu);
128   state_save_register_global(machine, state->timed_int);
129   state_save_register_global(machine, state->ym2151_int);
130
131   state_save_register_global(machine, state->scanlines_per_callback);
132
133   state_save_register_global(machine, state->actual_vc_latch0);
134   state_save_register_global(machine, state->actual_vc_latch1);
135
136   state_save_register_global(machine, state->playfield_latch);
137   state_save_register_global(machine, state->playfield2_latch);
138
139   /* need a postload to reset the state */
140   state_save_register_postload(machine, slapstic_postload, NULL);
141}
142
143
144
145/***************************************************************************
58146    INTERRUPT HANDLING
59147***************************************************************************/
60148
r6740r6741
65153
66154void atarigen_interrupt_reset(atarigen_state *state, atarigen_int_func update_int)
67155{
68   int i;
69
70156   /* set the callback */
71157   state->update_int_callback = update_int;
72158
73159   /* reset the interrupt states */
74160   state->video_int_state = state->sound_int_state = state->scanline_int_state = 0;
75
76   /* clear the timers */
77   for (i = 0; i < ATARIMO_MAX; i++)
78   {
79      state->scanline_interrupt_timer_screens[i] = NULL;
80      state->scanline_interrupt_timers[i] = NULL;
81      state->scanline_timer_screens[i] = NULL;
82      state->scanline_timers[i] = NULL;
83   }
84161}
85162
86163
r6740r6741
98175
99176
100177/*---------------------------------------------------------------
101    get_scanline_interrupt_timer_for_screen: Retrieves or
102    creates a scanline interrupt timer.
103---------------------------------------------------------------*/
104
105static emu_timer *get_scanline_interrupt_timer_for_screen(const device_config *screen)
106{
107   atarigen_state *state = (atarigen_state *)screen->machine->driver_data;
108   int i;
109
110   /* find the index of the timer that matches the screen */
111   for (i = 0; i < ATARIMO_MAX; i++)
112   {
113      /* matching */
114      if (state->scanline_interrupt_timer_screens[i] == screen)
115         break;
116
117      /* no more */
118      if (state->scanline_interrupt_timer_screens[i] == NULL)
119         break;
120   }
121
122   /* check that we still have room */
123   assert(i != ATARIMO_MAX);
124
125   /* need to create? */
126   if (state->scanline_interrupt_timer_screens[i] == NULL)
127   {
128      state->scanline_interrupt_timer_screens[i] = screen;
129      state->scanline_interrupt_timers[i] = timer_alloc(screen->machine, scanline_interrupt_callback, (void *)screen);
130   }
131
132   /* found it */
133   return state->scanline_interrupt_timers[i];
134}
135
136
137/*---------------------------------------------------------------
138178    atarigen_scanline_int_set: Sets the scanline when the next
139179    scanline interrupt should be generated.
140180---------------------------------------------------------------*/
141181
142182void atarigen_scanline_int_set(const device_config *screen, int scanline)
143183{
144   emu_timer *timer = get_scanline_interrupt_timer_for_screen(screen);
184   emu_timer *timer = get_screen_timer(screen)->scanline_interrupt_timer;
145185   timer_adjust_oneshot(timer, video_screen_get_time_until_pos(screen, scanline, 0), 0);
146186}
147187
r6740r6741
252292static TIMER_CALLBACK( scanline_interrupt_callback )
253293{
254294   const device_config *screen = (const device_config *)ptr;
255   emu_timer *timer = get_scanline_interrupt_timer_for_screen(screen);
295   emu_timer *timer = get_screen_timer(screen)->scanline_interrupt_timer;
256296
257297   /* generate the interrupt */
258298   atarigen_scanline_int_gen(cputag_get_cpu(machine, "maincpu"));
r6740r6741
880920***************************************************************************/
881921
882922/*---------------------------------------------------------------
883    get_scanline_timer_for_screen: Retrieves or
884    creates the the scanline timer.
885---------------------------------------------------------------*/
886
887static emu_timer *get_scanline_timer_for_screen(const device_config *screen)
888{
889   atarigen_state *state = (atarigen_state *)screen->machine->driver_data;
890   int i;
891
892   /* find the index of the timer that matches the screen */
893   for (i = 0; i < ATARIMO_MAX; i++)
894   {
895      /* matching */
896      if (state->scanline_timer_screens[i] == screen)
897         break;
898
899      /* no more */
900      if (state->scanline_timer_screens[i] == NULL)
901         break;
902   }
903
904   /* check that we still have room */
905   assert(i != ATARIMO_MAX);
906
907   /* need to create? */
908   if (state->scanline_timer_screens[i] == NULL)
909   {
910      state->scanline_timer_screens[i] = screen;
911      state->scanline_timers[i] = timer_alloc(screen->machine, scanline_timer_callback, (void *)screen);
912   }
913
914   /* found it */
915   return state->scanline_timers[i];
916}
917
918
919/*---------------------------------------------------------------
920923    atarigen_scanline_timer_reset: Sets up the scanline timer.
921924---------------------------------------------------------------*/
922925
r6740r6741
931934   /* set a timer to go off at scanline 0 */
932935   if (state->scanline_callback != NULL)
933936   {
934      emu_timer *timer = get_scanline_timer_for_screen(screen);
937      emu_timer *timer = get_screen_timer(screen)->scanline_timer;
935938      timer_adjust_oneshot(timer, video_screen_get_time_until_pos(screen, 0, 0), 0);
936939   }
937
938   /* implicitly allocate a scanline interrupt timer */
939   get_scanline_interrupt_timer_for_screen(screen);
940
941940}
942941
943942
r6740r6741
961960      scanline += state->scanlines_per_callback;
962961      if (scanline >= video_screen_get_height(screen))
963962         scanline = 0;
964      timer_adjust_oneshot(get_scanline_timer_for_screen(screen), video_screen_get_time_until_pos(screen, scanline, 0), scanline);
963      timer_adjust_oneshot(get_screen_timer(screen)->scanline_timer, video_screen_get_time_until_pos(screen, scanline, 0), scanline);
965964   }
966965}
967966
r6740r6741
972971***************************************************************************/
973972
974973/*---------------------------------------------------------------
975    get_scanline_timer_for_screen: Retrieves or
976    creates the the scanline timer.
977---------------------------------------------------------------*/
978
979static emu_timer *get_atarivc_eof_update_timer_for_screen(const device_config *screen)
980{
981   atarigen_state *state = (atarigen_state *)screen->machine->driver_data;
982   int i;
983
984   /* find the index of the timer that matches the screen */
985   for (i = 0; i < ATARIMO_MAX; i++)
986   {
987      /* matching */
988      if (state->atarivc_eof_update_timer_screens[i] == screen)
989         break;
990
991      /* no more */
992      if (state->atarivc_eof_update_timer_screens[i] == NULL)
993         break;
994   }
995
996   /* check that we still have room */
997   assert(i != ATARIMO_MAX);
998
999   /* need to create? */
1000   if (state->atarivc_eof_update_timer_screens[i] == NULL)
1001   {
1002      state->atarivc_eof_update_timer_screens[i] = screen;
1003      state->atarivc_eof_update_timers[i] = timer_alloc(screen->machine, atarivc_eof_update, (void *)screen);
1004   }
1005
1006   /* found it */
1007   return state->atarivc_eof_update_timers[i];
1008}
1009
1010
1011/*---------------------------------------------------------------
1012974    atarivc_eof_update: Callback that slurps up data and feeds
1013975    it into the video controller registers every refresh.
1014976---------------------------------------------------------------*/
r6740r6741
1017979{
1018980   atarigen_state *state = (atarigen_state *)machine->driver_data;
1019981   const device_config *screen = (const device_config *)ptr;
1020   emu_timer *timer = get_atarivc_eof_update_timer_for_screen(screen);
982   emu_timer *timer = get_screen_timer(screen)->atarivc_eof_update_timer;
1021983   int i;
1022984
1023985   /* echo all the commands to the video controller */
r6740r6741
10631025void atarivc_reset(const device_config *screen, UINT16 *eof_data, int playfields)
10641026{
10651027   atarigen_state *state = (atarigen_state *)screen->machine->driver_data;
1066   int i;
10671028
10681029   /* this allows us to manually reset eof_data to NULL if it's not used */
10691030   state->atarivc_eof_data = eof_data;
r6740r6741
10771038   state->atarivc_state.latch1 = state->atarivc_state.latch2 = -1;
10781039   state->actual_vc_latch0 = state->actual_vc_latch1 = -1;
10791040
1080   /* clear the timers */
1081   for (i = 0; i < ATARIMO_MAX; i++)
1082   {
1083      state->atarivc_eof_update_timer_screens[i] = NULL;
1084      state->atarivc_eof_update_timers[i] = NULL;
1085   }
1086
10871041   /* start a timer to go off a little before scanline 0 */
10881042   if (state->atarivc_eof_data)
10891043   {
1090      emu_timer *timer = get_atarivc_eof_update_timer_for_screen(screen);
1044      emu_timer *timer = get_screen_timer(screen)->atarivc_eof_update_timer;
10911045      timer_adjust_oneshot(timer, video_screen_get_time_until_pos(screen, 0, 0), 0);
10921046   }
10931047}
r6740r6741
16371591   /* make the assembled data our new source data */
16381592   gfx_element_set_source(gx0, srcdata);
16391593}
1640
1641
1642/***************************************************************************
1643    SAVE STATE
1644***************************************************************************/
1645
1646void atarigen_init_save_state(running_machine *machine)
1647{
1648   atarigen_state *state = (atarigen_state *)machine->driver_data;
1649
1650   state_save_register_global(machine, state->scanline_int_state);
1651   state_save_register_global(machine, state->sound_int_state);
1652   state_save_register_global(machine, state->video_int_state);
1653
1654   state_save_register_global(machine, state->cpu_to_sound_ready);
1655   state_save_register_global(machine, state->sound_to_cpu_ready);
1656
1657   state_save_register_global(machine, state->atarivc_state.latch1);            /* latch #1 value (-1 means disabled) */
1658   state_save_register_global(machine, state->atarivc_state.latch2);            /* latch #2 value (-1 means disabled) */
1659   state_save_register_global(machine, state->atarivc_state.rowscroll_enable);      /* true if row-scrolling is enabled */
1660   state_save_register_global(machine, state->atarivc_state.palette_bank);         /* which palette bank is enabled */
1661   state_save_register_global(machine, state->atarivc_state.pf0_xscroll);         /* playfield 1 xscroll */
1662   state_save_register_global(machine, state->atarivc_state.pf0_xscroll_raw);      /* playfield 1 xscroll raw value */
1663   state_save_register_global(machine, state->atarivc_state.pf0_yscroll);         /* playfield 1 yscroll */
1664   state_save_register_global(machine, state->atarivc_state.pf1_xscroll);         /* playfield 2 xscroll */
1665   state_save_register_global(machine, state->atarivc_state.pf1_xscroll_raw);      /* playfield 2 xscroll raw value */
1666   state_save_register_global(machine, state->atarivc_state.pf1_yscroll);         /* playfield 2 yscroll */
1667   state_save_register_global(machine, state->atarivc_state.mo_xscroll);         /* sprite xscroll */
1668   state_save_register_global(machine, state->atarivc_state.mo_yscroll);         /* sprite xscroll */
1669
1670   state_save_register_global(machine, state->eeprom_unlocked);
1671
1672   state_save_register_global(machine, state->slapstic_num);
1673   state_save_register_global(machine, state->slapstic_bank);
1674   state_save_register_global(machine, state->slapstic_last_pc);
1675   state_save_register_global(machine, state->slapstic_last_address);
1676
1677   state_save_register_global(machine, state->cpu_to_sound);
1678   state_save_register_global(machine, state->sound_to_cpu);
1679   state_save_register_global(machine, state->timed_int);
1680   state_save_register_global(machine, state->ym2151_int);
1681
1682   state_save_register_global(machine, state->scanlines_per_callback);
1683
1684   state_save_register_global(machine, state->actual_vc_latch0);
1685   state_save_register_global(machine, state->actual_vc_latch1);
1686
1687   state_save_register_global(machine, state->playfield_latch);
1688   state_save_register_global(machine, state->playfield2_latch);
1689
1690   /* need a postload to reset the state */
1691   state_save_register_postload(machine, slapstic_postload, NULL);
1692}
src/mame/machine/atarigen.h
r6740r6741
3232
3333typedef void (*atarigen_scanline_func)(const device_config *screen, int scanline);
3434
35struct atarivc_state_desc
35typedef struct _atarivc_state_desc atarivc_state_desc;
36struct _atarivc_state_desc
3637{
3738   UINT32 latch1;                        /* latch #1 value (-1 means disabled) */
3839   UINT32 latch2;                        /* latch #2 value (-1 means disabled) */
r6740r6741
4950};
5051
5152
53typedef struct _atarigen_screen_timer atarigen_screen_timer;
54struct _atarigen_screen_timer
55{
56   const device_config *screen;
57   emu_timer *         scanline_interrupt_timer;
58   emu_timer *         scanline_timer;
59   emu_timer *         atarivc_eof_update_timer;
60};
61
62
5263typedef struct _atarigen_state atarigen_state;
5364struct _atarigen_state
5465{
r6740r6741
8192
8293   UINT16 *         atarivc_data;
8394   UINT16 *         atarivc_eof_data;
84   struct atarivc_state_desc atarivc_state;
95   atarivc_state_desc    atarivc_state;
8596
8697   /* internal state */
8798   atarigen_int_func       update_int_callback;
r6740r6741
113124   UINT32               playfield_latch;
114125   UINT32               playfield2_latch;
115126
116   const device_config *   scanline_interrupt_timer_screens[ATARIMO_MAX];
117   emu_timer *            scanline_interrupt_timers[ATARIMO_MAX];
118
119   const device_config *   scanline_timer_screens[ATARIMO_MAX];
120   emu_timer *            scanline_timers[ATARIMO_MAX];
121
122   const device_config *   atarivc_eof_update_timer_screens[ATARIMO_MAX];
123   emu_timer *            atarivc_eof_update_timers[ATARIMO_MAX];
127   atarigen_screen_timer   screen_timer[2];
124128};
125129
126130
r6740r6741
130134***************************************************************************/
131135
132136/*---------------------------------------------------------------
137    OVERALL INIT
138---------------------------------------------------------------*/
139
140void atarigen_init(running_machine *machine);
141
142
143/*---------------------------------------------------------------
133144    INTERRUPT HANDLING
134145---------------------------------------------------------------*/
135146
r6740r6741
272283void atarigen_blend_gfx(running_machine *machine, int gfx0, int gfx1, int mask0, int mask1);
273284
274285
275/*---------------------------------------------------------------
276    STATE SAVE
277---------------------------------------------------------------*/
278286
279void atarigen_init_save_state(running_machine *machine);
280
281287/***************************************************************************
282288    GENERAL ATARI NOTES
283289**************************************************************************##
src/mame/machine/midwunit.c
r6740r6741
88#include "cpu/tms34010/tms34010.h"
99#include "cpu/m6809/m6809.h"
1010#include "audio/dcs.h"
11#include "midwunit.h"
11#include "includes/midwunit.h"
1212#include "midwayic.h"
1313
1414
src/mame/machine/neocrypt.c
r6740r6741
4747***************************************************************************/
4848
4949#include "driver.h"
50#include "neogeo.h"
50#include "includes/neogeo.h"
5151
5252
5353/***************************************************************************
src/mame/machine/tecmosys.c
r6740r6741
2929*/
3030
3131#include "driver.h"
32#include "tecmosys.h"
32#include "includes/tecmosys.h"
3333
3434enum DEV_STATUS
3535{
src/mame/machine/naomibd.c
r6740r6741
177177#include "machine/x76f100.h"
178178#include "cdrom.h"
179179#include "includes/naomi.h"
180#include "naomibd.h"
180#include "includes/naomibd.h"
181181
182182#define NAOMIBD_FLAG_AUTO_ADVANCE   (8)   // address auto-advances on read
183183#define NAOMIBD_FLAG_SPECIAL_MODE   (4)   // used to access protection registers
src/mame/machine/tx1.c
r6740r6741
66
77#include "driver.h"
88#include "debugger.h"
9#include "tx1.h"
9#include "includes/tx1.h"
1010
1111
1212/*
src/mame/machine/decoprot.c
r6740r6741
7272
7373#include "driver.h"
7474#include "machine/eeprom.h"
75#include "decoprot.h"
75#include "includes/decoprot.h"
7676
7777#define DECO_PORT(p) (prot_ram[p/2])
7878
src/mame/machine/mcr.c
r6740r6741
1414#include "cpu/m6809/m6809.h"
1515#include "cpu/z80/z80.h"
1616#include "cpu/z80/z80daisy.h"
17#include "mcr.h"
17#include "includes/mcr.h"
1818
1919#define VERBOSE 0
2020#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
src/mame/machine/tatsumi.c
r6740r6741
11#include "driver.h"
2#include "tatsumi.h"
2#include "includes/tatsumi.h"
33#include "sound/2151intf.h"
44#include "sound/okim6295.h"
55
src/mame/machine/arkanoid.c
r6740r6741
88***************************************************************************/
99
1010#include "driver.h"
11#include "arkanoid.h"
11#include "includes/arkanoid.h"
1212
1313
1414/* To log specific reads and writes of the bootlegs */
src/mame/machine/galaxold.c
r6740r6741
1212#include "includes/galaxold.h"
1313
1414static int irq_line;
15static emu_timer *int_timer;
15static const device_config *int_timer;
1616
1717static UINT8 _4in1_bank;
1818
19static void galaxold_7474_9M_2_callback(running_machine *machine)
19void galaxold_7474_9m_2_callback(const device_config *device)
2020{
2121   /* Q bar clocks the other flip-flop,
2222       Q is VBLANK (not visible to the CPU) */
23   TTL7474_clock_w(1, TTL7474_output_comp_r(0));
24   TTL7474_update(machine, 1);
23    const device_config *target = devtag_get_device(device->machine, "7474_9m_1");
24   ttl7474_clock_w(target, ttl7474_output_comp_r(device));
25   ttl7474_update(target);
2526}
2627
27static void galaxold_7474_9M_1_callback(running_machine *machine)
28void galaxold_7474_9m_1_callback(const device_config *device)
2829{
2930   /* Q goes to the NMI line */
30   cputag_set_input_line(machine, "maincpu", irq_line, TTL7474_output_r(1) ? CLEAR_LINE : ASSERT_LINE);
31   cputag_set_input_line(device->machine, "maincpu", irq_line, ttl7474_output_r(device) ? CLEAR_LINE : ASSERT_LINE);
3132}
3233
33static const struct TTL7474_interface galaxold_7474_9M_2_intf =
34{
35   galaxold_7474_9M_2_callback
36};
37
38static const struct TTL7474_interface galaxold_7474_9M_1_intf =
39{
40   galaxold_7474_9M_1_callback
41};
42
43
4434WRITE8_HANDLER( galaxold_nmi_enable_w )
4535{
46   TTL7474_preset_w(1, data);
47   TTL7474_update(space->machine, 1);
36    const device_config *target = devtag_get_device(space->machine, "7474_9m_1");
37   ttl7474_preset_w(target, data);
38   ttl7474_update(target);
4839}
4940
5041
51static TIMER_CALLBACK( interrupt_timer )
42TIMER_DEVICE_CALLBACK( galaxold_interrupt_timer )
5243{
44    const device_config *target = devtag_get_device(timer->machine, "7474_9m_2");
45
5346   /* 128V, 64V and 32V go to D */
54   TTL7474_d_w(0, (param & 0xe0) != 0xe0);
47   ttl7474_d_w(target, (param & 0xe0) != 0xe0);
5548
5649   /* 16V clocks the flip-flop */
57   TTL7474_clock_w(0, param & 0x10);
50   ttl7474_clock_w(target, param & 0x10);
5851
5952   param = (param + 0x10) & 0xff;
6053
61   timer_adjust_oneshot(int_timer, video_screen_get_time_until_pos(machine->primary_screen, param, 0), param);
54   timer_device_adjust_oneshot(int_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, param, 0), param);
6255
63   TTL7474_update(machine, 0);
56   ttl7474_update(target);
6457}
6558
6659
6760static void machine_reset_common(running_machine *machine, int line)
6861{
62    const device_config *ttl7474_9m_1 = devtag_get_device(machine, "7474_9m_1");
63    const device_config *ttl7474_9m_2 = devtag_get_device(machine, "7474_9m_2");
6964   irq_line = line;
7065
7166   /* initalize main CPU interrupt generator flip-flops */
72   TTL7474_config(machine, 0, &galaxold_7474_9M_2_intf);
73   TTL7474_preset_w(0, 1);
74   TTL7474_clear_w (0, 1);
67   ttl7474_preset_w(ttl7474_9m_2, 1);
68   ttl7474_clear_w (ttl7474_9m_2, 1);
7569
76   TTL7474_config(machine, 1, &galaxold_7474_9M_1_intf);
77   TTL7474_clear_w (1, 1);
78   TTL7474_d_w     (1, 0);
79   TTL7474_preset_w(1, 0);
70   ttl7474_clear_w (ttl7474_9m_1, 1);
71   ttl7474_d_w     (ttl7474_9m_1, 0);
72   ttl7474_preset_w(ttl7474_9m_1, 0);
8073
8174   /* start a timer to generate interrupts */
82   int_timer = timer_alloc(machine, interrupt_timer, NULL);
83   timer_adjust_oneshot(int_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
75   int_timer = devtag_get_device(machine, "int_timer");
76   timer_device_adjust_oneshot(int_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
8477}
8578
8679MACHINE_RESET( galaxold )
src/mame/machine/bsktball.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "bsktball.h"
8#include "includes/bsktball.h"
99
1010/***************************************************************************
1111    bsktball_nmion_w
src/mame/machine/slikshot.c
r6740r6741
6969
7070#include "driver.h"
7171#include "cpu/z80/z80.h"
72#include "itech8.h"
72#include "includes/itech8.h"
7373
7474
7575#define YBUFFER_COUNT   15
src/mame/machine/harddriv.c
r6740r6741
1313#include "machine/asic65.h"
1414#include "audio/atarijsa.h"
1515#include "includes/slapstic.h"
16#include "harddriv.h"
16#include "includes/harddriv.h"
1717
1818
1919/*************************************
r6740r6741
3838
3939
4040static void hd68k_update_interrupts(running_machine *machine);
41static TIMER_CALLBACK( duart_callback );
4241
4342
4443
r6740r6741
5756{
5857   harddriv_state *state = (harddriv_state *)machine->driver_data;
5958
59   atarigen_init(machine);
60
6061   /* predetermine memory regions */
6162   state->sim_memory = (UINT16 *)memory_region(machine, "user1");
6263   state->sim_memory_size = memory_region_length(machine, "user1") / 2;
6364   state->adsp_pgm_memory_word = (UINT16 *)((UINT8 *)state->adsp_pgm_memory + 1);
65
66   /* allocate timers */
67   state->duart_timer = devtag_get_device(machine, "duart_timer");
6468}
6569
6670
r6740r6741
9397   memset(state->duart_read_data, 0, sizeof(state->duart_read_data));
9498   memset(state->duart_write_data, 0, sizeof(state->duart_write_data));
9599   state->duart_output_port = 0;
96   state->duart_timer = timer_alloc(machine, duart_callback, NULL);
97100
98101   /* reset the ADSP/DSIII/DSIV boards */
99102   state->adsp_halt = 1;
r6740r6741
523526}
524527
525528
526static TIMER_CALLBACK( duart_callback )
529TIMER_DEVICE_CALLBACK( hd68k_duart_callback )
527530{
528   harddriv_state *state = (harddriv_state *)machine->driver_data;
531   harddriv_state *state = (harddriv_state *)timer->machine->driver_data;
529532   logerror("DUART timer fired\n");
530533   if (state->duart_write_data[0x05] & 0x08)
531534   {
532535      logerror("DUART interrupt generated\n");
533536      state->duart_read_data[0x05] |= 0x08;
534537      state->duart_irq_state = (state->duart_read_data[0x05] & state->duart_write_data[0x05]) != 0;
535      atarigen_update_interrupts(machine);
538      atarigen_update_interrupts(timer->machine);
536539   }
537   timer_adjust_oneshot(state->duart_timer, attotime_mul(duart_clock_period(state), 65536), 0);
540   timer_device_adjust_oneshot(timer, attotime_mul(duart_clock_period(state), 65536), 0);
538541}
539542
540543
r6740r6741
562565      case 0x0e:      /* Start-Counter Command 3 */
563566      {
564567         int reps = (state->duart_write_data[0x06] << 8) | state->duart_write_data[0x07];
565         timer_adjust_oneshot(state->duart_timer, attotime_mul(duart_clock_period(state), reps), 0);
568         timer_device_adjust_oneshot(state->duart_timer, attotime_mul(duart_clock_period(state), reps), 0);
566569         logerror("DUART timer started (period=%f)\n", attotime_to_double(attotime_mul(duart_clock_period(state), reps)));
567570         return 0x00ff;
568571      }
569572      case 0x0f:      /* Stop-Counter Command 3 */
570573         {
571            int reps = attotime_to_double(attotime_mul(timer_timeleft(state->duart_timer), duart_clock(state)));
572            timer_adjust_oneshot(state->duart_timer, attotime_never, 0);
574            int reps = attotime_to_double(attotime_mul(timer_device_timeleft(state->duart_timer), duart_clock(state)));
575            timer_device_adjust_oneshot(state->duart_timer, attotime_never, 0);
573576            state->duart_read_data[0x06] = reps >> 8;
574577            state->duart_read_data[0x07] = reps & 0xff;
575578            logerror("DUART timer stopped (final count=%04X)\n", reps);
src/mame/machine/dec0.c
r6740r6741
77*******************************************************************************/
88
99#include "driver.h"
10#include "dec0.h"
10#include "includes/dec0.h"
1111#include "cpu/h6280/h6280.h"
1212
1313static int GAME,i8751_return,slyspy_state;
src/mame/machine/williams.c
r6740r6741
1010#include "cpu/m6809/m6809.h"
1111#include "machine/6821pia.h"
1212#include "machine/ticket.h"
13#include "williams.h"
13#include "includes/williams.h"
1414#include "sound/dac.h"
1515#include "sound/hc55516.h"
1616
1717
18/* timers */
19static emu_timer *scanline_timer;
20static emu_timer *scan240_timer;
21static emu_timer *scan254_timer;
22
2318/* banking addresses set by the drivers */
2419UINT8 *mayday_protection;
2520
r6740r6741
4944static void tshoot_main_irq(const device_config *device, int state);
5045
5146/* Lotto Fun-specific code */
52static READ8_DEVICE_HANDLER( lottofun_input_port_0_r );
5347static WRITE8_DEVICE_HANDLER( lottofun_coin_lock_w );
5448
5549/* Turkey Shoot-specific code */
r6740r6741
6256static WRITE8_DEVICE_HANDLER( joust2_pia_3_cb1_w );
6357
6458
65
6659/*************************************
6760 *
68 *  Trampoline functions
69 *
70 *************************************/
71
72static READ8_DEVICE_HANDLER( input_port_0_device_r ) { return input_port_read_direct(input_port_by_index(&device->machine->portlist, 0)); }
73static READ8_DEVICE_HANDLER( input_port_1_device_r ) { return input_port_read_direct(input_port_by_index(&device->machine->portlist, 1)); }
74static READ8_DEVICE_HANDLER( input_port_2_device_r ) { return input_port_read_direct(input_port_by_index(&device->machine->portlist, 2)); }
75static READ8_DEVICE_HANDLER( input_port_3_device_r ) { return input_port_read_direct(input_port_by_index(&device->machine->portlist, 3)); }
76static READ8_DEVICE_HANDLER( input_port_4_device_r ) { return input_port_read_direct(input_port_by_index(&device->machine->portlist, 4)); }
77
78/*************************************
79 *
8061 *  Generic old-Williams PIA interfaces
8162 *
8263 *************************************/
r6740r6741
8465/* Generic PIA 0, maps to input ports 0 and 1 */
8566const pia6821_interface williams_pia_0_intf =
8667{
87   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(input_port_0_device_r), DEVCB_HANDLER(input_port_1_device_r), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
68   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_INPUT_PORT("IN0"), DEVCB_INPUT_PORT("IN1"), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
8869   /*outputs: A/B,CA/B2       */ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
8970   /*irqs   : A/B             */ DEVCB_NULL, DEVCB_NULL
9071};
r6740r6741
9475/* muxing done in williams_mux_r */
9576const pia6821_interface williams_muxed_pia_0_intf =
9677{
97   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(input_port_0_device_r), DEVCB_HANDLER(input_port_1_device_r), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
78   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_INPUT_PORT("IN0"), DEVCB_INPUT_PORT("IN1"), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
9879   /*outputs: A/B,CA/B2       */ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_HANDLER(williams_port_select_w),
9980   /*irqs   : A/B             */ DEVCB_NULL, DEVCB_NULL
10081};
r6740r6741
10283/* Generic 49-way joystick PIA 0 for Sinistar/Blaster */
10384const pia6821_interface williams_49way_pia_0_intf =
10485{
105   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(williams_49way_port_0_r), DEVCB_HANDLER(input_port_1_device_r), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
86   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(williams_49way_port_0_r), DEVCB_INPUT_PORT("IN1"), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
10687   /*outputs: A/B,CA/B2       */ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
10788   /*irqs   : A/B             */ DEVCB_NULL, DEVCB_NULL
10889};
r6740r6741
11091/* Muxing 49-way joystick PIA 0 for Blaster kit */
11192const pia6821_interface williams_49way_muxed_pia_0_intf =
11293{
113   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(williams_input_port_49way_0_5_r), DEVCB_HANDLER(input_port_1_device_r), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
94   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(williams_input_port_49way_0_5_r), DEVCB_INPUT_PORT("IN1"), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
11495   /*outputs: A/B,CA/B2       */ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_HANDLER(williams_port_select_w),
11596   /*irqs   : A/B             */ DEVCB_NULL, DEVCB_NULL
11697};
r6740r6741
11899/* Generic PIA 1, maps to input port 2, sound command out, and IRQs */
119100const pia6821_interface williams_pia_1_intf =
120101{
121   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(input_port_2_device_r), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
102   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_INPUT_PORT("IN2"), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
122103   /*outputs: A/B,CA/B2       */ DEVCB_NULL, DEVCB_HANDLER(williams_snd_cmd_w), DEVCB_NULL, DEVCB_NULL,
123104   /*irqs   : A/B             */ DEVCB_LINE(williams_main_irq), DEVCB_LINE(williams_main_irq)
124105};
r6740r6741
142123/* Special PIA 0 for Lotto Fun, to handle the controls and ticket dispenser */
143124const pia6821_interface lottofun_pia_0_intf =
144125{
145   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(lottofun_input_port_0_r), DEVCB_HANDLER(input_port_1_device_r), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
146   /*outputs: A/B,CA/B2       */ DEVCB_NULL, DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, ticket_dispenser_w), DEVCB_HANDLER(lottofun_coin_lock_w), DEVCB_NULL,
126   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_INPUT_PORT("IN0"), DEVCB_INPUT_PORT("IN1"), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
127   /*outputs: A/B,CA/B2       */ DEVCB_NULL, DEVCB_DEVICE_HANDLER("ticket", ticket_dispenser_w), DEVCB_HANDLER(lottofun_coin_lock_w), DEVCB_NULL,
147128   /*irqs   : A/B             */ DEVCB_NULL, DEVCB_NULL
148129};
149130
r6740r6741
158139/* Special PIA 1 for PlayBall, doesn't set the high bits on sound commands */
159140const pia6821_interface playball_pia_1_intf =
160141{
161   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(input_port_2_device_r), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
142   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_INPUT_PORT("IN2"), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
162143   /*outputs: A/B,CA/B2       */ DEVCB_NULL, DEVCB_HANDLER(playball_snd_cmd_w), DEVCB_NULL, DEVCB_NULL,
163144   /*irqs   : A/B             */ DEVCB_LINE(williams_main_irq), DEVCB_LINE(williams_main_irq)
164145};
r6740r6741
166147/* extra PIA 3 for Speed Ball */
167148const pia6821_interface spdball_pia_3_intf =
168149{
169   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(input_port_3_device_r), DEVCB_HANDLER(input_port_4_device_r), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
150   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_INPUT_PORT("IN3"), DEVCB_INPUT_PORT("IN4"), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
170151   /*outputs: A/B,CA/B2       */ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
171152   /*irqs   : A/B             */ DEVCB_NULL, DEVCB_NULL
172153};
r6740r6741
182163/* Generic muxing PIA 0, maps to input ports 0/3 and 1; port select is CA2 */
183164const pia6821_interface williams2_muxed_pia_0_intf =
184165{
185   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(input_port_0_device_r), DEVCB_HANDLER(input_port_1_device_r), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
166   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_INPUT_PORT("IN0"), DEVCB_INPUT_PORT("IN1"), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
186167   /*outputs: A/B,CA/B2       */ DEVCB_NULL, DEVCB_NULL, DEVCB_HANDLER(williams_port_select_w), DEVCB_NULL,
187168   /*irqs   : A/B             */ DEVCB_NULL, DEVCB_NULL
188169};
r6740r6741
190171/* Generic PIA 1, maps to input port 2, sound command out, and IRQs */
191172const pia6821_interface williams2_pia_1_intf =
192173{
193   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(input_port_2_device_r), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
174   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_INPUT_PORT("IN2"), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
194175   /*outputs: A/B,CA/B2       */ DEVCB_NULL, DEVCB_HANDLER(williams2_snd_cmd_w), DEVCB_NULL, DEVCB_DEVICE_HANDLER("pia_2", pia6821_ca1_w),
195176   /*irqs   : A/B             */ DEVCB_LINE(williams_main_irq), DEVCB_LINE(williams_main_irq)
196177};
r6740r6741
214195/* Mystic Marathon PIA 0 */
215196const pia6821_interface mysticm_pia_0_intf =
216197{
217   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(input_port_0_device_r), DEVCB_HANDLER(input_port_1_device_r), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
198   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_INPUT_PORT("IN0"), DEVCB_INPUT_PORT("IN1"), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
218199   /*outputs: A/B,CA/B2       */ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
219200   /*irqs   : A/B             */ DEVCB_LINE(williams_main_firq), DEVCB_LINE(mysticm_main_irq)
220201};
r6740r6741
222203/* Mystic Marathon PIA 1 */
223204const pia6821_interface mysticm_pia_1_intf =
224205{
225   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(input_port_2_device_r), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
206   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_INPUT_PORT("IN2"), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
226207   /*outputs: A/B,CA/B2       */ DEVCB_NULL, DEVCB_HANDLER(williams2_snd_cmd_w), DEVCB_NULL, DEVCB_DEVICE_HANDLER("pia_2", pia6821_ca1_w),
227208   /*irqs   : A/B             */ DEVCB_LINE(mysticm_main_irq), DEVCB_LINE(mysticm_main_irq)
228209};
r6740r6741
230211/* Turkey Shoot PIA 0 */
231212const pia6821_interface tshoot_pia_0_intf =
232213{
233   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(tshoot_input_port_0_3_r), DEVCB_HANDLER(input_port_1_device_r), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
214   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(tshoot_input_port_0_3_r), DEVCB_INPUT_PORT("IN1"), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
234215   /*outputs: A/B,CA/B2       */ DEVCB_NULL, DEVCB_HANDLER(tshoot_lamp_w), DEVCB_HANDLER(williams_port_select_w), DEVCB_NULL,
235216   /*irqs   : A/B             */ DEVCB_LINE(tshoot_main_irq), DEVCB_LINE(tshoot_main_irq)
236217};
r6740r6741
238219/* Turkey Shoot PIA 1 */
239220const pia6821_interface tshoot_pia_1_intf =
240221{
241   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(input_port_2_device_r), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
222   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_INPUT_PORT("IN2"), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
242223   /*outputs: A/B,CA/B2       */ DEVCB_NULL, DEVCB_HANDLER(williams2_snd_cmd_w), DEVCB_NULL, DEVCB_DEVICE_HANDLER("pia_2", pia6821_ca1_w),
243224   /*irqs   : A/B             */ DEVCB_LINE(tshoot_main_irq), DEVCB_LINE(tshoot_main_irq)
244225};
r6740r6741
254235/* Joust 2 PIA 1 */
255236const pia6821_interface joust2_pia_1_intf =
256237{
257   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_HANDLER(input_port_2_device_r), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
238   /*inputs : A/B,CA/B1,CA/B2 */ DEVCB_INPUT_PORT("IN2"), DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
258239   /*outputs: A/B,CA/B2       */ DEVCB_NULL, DEVCB_HANDLER(joust2_snd_cmd_w), DEVCB_HANDLER(joust2_pia_3_cb1_w), DEVCB_DEVICE_HANDLER("pia_2", pia6821_ca1_w),
259240   /*irqs   : A/B             */ DEVCB_LINE(williams_main_irq), DEVCB_LINE(williams_main_irq)
260241};
r6740r6741
267248 *
268249 *************************************/
269250
270static TIMER_CALLBACK( williams_va11_callback )
251TIMER_DEVICE_CALLBACK( williams_va11_callback )
271252{
272   const device_config *pia_1 = devtag_get_device(machine, "pia_1");
253   const device_config *pia_1 = devtag_get_device(timer->machine, "pia_1");
273254   int scanline = param;
274255
275256   /* the IRQ signal comes into CB1, and is set to VA11 */
r6740r6741
278259   /* set a timer for the next update */
279260   scanline += 0x20;
280261   if (scanline >= 256) scanline = 0;
281   timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline);
262   timer_device_adjust_oneshot(timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline, 0), scanline);
282263}
283264
284265
r6740r6741
291272}
292273
293274
294static TIMER_CALLBACK( williams_count240_callback )
275TIMER_DEVICE_CALLBACK( williams_count240_callback )
295276{
296   const device_config *pia_1 = devtag_get_device(machine, "pia_1");
277   const device_config *pia_1 = devtag_get_device(timer->machine, "pia_1");
297278
298279   /* the COUNT240 signal comes into CA1, and is set to the logical AND of VA10-VA13 */
299280   pia6821_ca1_w(pia_1, 0, 1);
300281
301282   /* set a timer to turn it off once the scanline counter resets */
302   timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, williams_count240_off_callback);
283   timer_set(timer->machine, video_screen_get_time_until_pos(timer->machine->primary_screen, 0, 0), NULL, 0, williams_count240_off_callback);
303284
304285   /* set a timer for next frame */
305   timer_adjust_oneshot(scan240_timer, video_screen_get_time_until_pos(machine->primary_screen, 240, 0), 0);
286   timer_device_adjust_oneshot(timer, video_screen_get_time_until_pos(timer->machine->primary_screen, 240, 0), 0);
306287}
307288
308289
r6740r6741
369350 *
370351 *************************************/
371352
372static MACHINE_RESET( williams_common )
353static MACHINE_START( williams_common )
373354{
374   /* reset the ticket dispenser (Lotto Fun) */
375   ticket_dispenser_init(machine, 70, TICKET_MOTOR_ACTIVE_LOW, TICKET_STATUS_ACTIVE_HIGH);
355   /* configure the memory bank */
356   memory_configure_bank(machine, "bank1", 0, 1, williams_videoram, 0);
357   memory_configure_bank(machine, "bank1", 1, 1, memory_region(machine, "maincpu") + 0x10000, 0);
376358
359   state_save_register_global(machine, vram_bank);
360}
361
362
363static MACHINE_RESET( williams_common )
364{
377365   /* set a timer to go off every 16 scanlines, to toggle the VA11 line and update the screen */
378   scanline_timer = timer_alloc(machine, williams_va11_callback, NULL);
379   timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
366   timer_device_adjust_oneshot(devtag_get_device(machine, "scan_timer"), video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
380367
381368   /* also set a timer to go off on scanline 240 */
382   scan240_timer = timer_alloc(machine, williams_count240_callback, NULL);
383   timer_adjust_oneshot(scan240_timer, video_screen_get_time_until_pos(machine->primary_screen, 240, 0), 0);
369   timer_device_adjust_oneshot(devtag_get_device(machine, "240_timer"), video_screen_get_time_until_pos(machine->primary_screen, 240, 0), 0);
370}
384371
385   state_save_register_global(machine, vram_bank);
372
373MACHINE_START( williams )
374{
375   MACHINE_START_CALL(williams_common);
386376}
387377
388378
389379MACHINE_RESET( williams )
390380{
391381   MACHINE_RESET_CALL(williams_common);
392
393   /* configure the memory bank */
394   memory_configure_bank(machine, "bank1", 0, 1, williams_videoram, 0);
395   memory_configure_bank(machine, "bank1", 1, 1, memory_region(machine, "maincpu") + 0x10000, 0);
396382}
397383
398384
r6740r6741
403389 *
404390 *************************************/
405391
406static TIMER_CALLBACK( williams2_va11_callback )
392TIMER_DEVICE_CALLBACK( williams2_va11_callback )
407393{
408   const device_config *pia_0 = devtag_get_device(machine, "pia_0");
409   const device_config *pia_1 = devtag_get_device(machine, "pia_1");
394   const device_config *pia_0 = devtag_get_device(timer->machine, "pia_0");
395   const device_config *pia_1 = devtag_get_device(timer->machine, "pia_1");
410396   int scanline = param;
411397
412398   /* the IRQ signal comes into CB1, and is set to VA11 */
r6740r6741
416402   /* set a timer for the next update */
417403   scanline += 0x20;
418404   if (scanline >= 256) scanline = 0;
419   timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline);
405   timer_device_adjust_oneshot(timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline, 0), scanline);
420406}
421407
422408
r6740r6741
429415}
430416
431417
432static TIMER_CALLBACK( williams2_endscreen_callback )
418TIMER_DEVICE_CALLBACK( williams2_endscreen_callback )
433419{
434   const device_config *pia_0 = devtag_get_device(machine, "pia_0");
420   const device_config *pia_0 = devtag_get_device(timer->machine, "pia_0");
435421
436422   /* the /ENDSCREEN signal comes into CA1 */
437423   pia6821_ca1_w(pia_0, 0, 0);
438424
439425   /* set a timer to turn it off once the scanline counter resets */
440   timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 8, 0), NULL, 0, williams2_endscreen_off_callback);
426   timer_set(timer->machine, video_screen_get_time_until_pos(timer->machine->primary_screen, 8, 0), NULL, 0, williams2_endscreen_off_callback);
441427
442428   /* set a timer for next frame */
443   timer_adjust_oneshot(scan254_timer, video_screen_get_time_until_pos(machine->primary_screen, 254, 0), 0);
429   timer_device_adjust_oneshot(timer, video_screen_get_time_until_pos(timer->machine->primary_screen, 254, 0), 0);
444430}
445431
446432
r6740r6741
458444}
459445
460446
461MACHINE_RESET( williams2 )
447MACHINE_START( williams2 )
462448{
463   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
464
465449   /* configure memory banks */
466450   memory_configure_bank(machine, "bank1", 0, 1, williams_videoram, 0);
467451   memory_configure_bank(machine, "bank1", 1, 4, memory_region(machine, "maincpu") + 0x10000, 0x10000);
468452
453   /* register for save states */
454   state_save_register_global(machine, vram_bank);
455   state_save_register_postload(machine, williams2_postload, NULL);
456}
457
458
459MACHINE_RESET( williams2 )
460{
461   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
462
469463   /* make sure our banking is reset */
470464   williams2_bank_select_w(space, 0, 0);
471465
472466   /* set a timer to go off every 16 scanlines, to toggle the VA11 line and update the screen */
473   scanline_timer = timer_alloc(machine, williams2_va11_callback, NULL);
474   timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
467   timer_device_adjust_oneshot(devtag_get_device(machine, "scan_timer"), video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
475468
476469   /* also set a timer to go off on scanline 254 */
477   scan254_timer = timer_alloc(machine, williams2_endscreen_callback, NULL);
478   timer_adjust_oneshot(scan254_timer, video_screen_get_time_until_pos(machine->primary_screen, 254, 0), 0);
479
480   state_save_register_global(machine, vram_bank);
481   state_save_register_postload(machine, williams2_postload, NULL);
470   timer_device_adjust_oneshot(devtag_get_device(machine, "254_timer"), video_screen_get_time_until_pos(machine->primary_screen, 254, 0), 0);
482471}
483472
484473
r6740r6741
737726}
738727
739728
729MACHINE_START( defender )
730{
731   MACHINE_START_CALL(williams_common);
732
733   /* configure the banking and make sure it is reset to 0 */
734   memory_configure_bank(machine, "bank1", 0, 9, &memory_region(machine, "maincpu")[0x10000], 0x1000);
735
736   state_save_register_postload(machine, defender_postload, NULL);
737}
738
739
740740MACHINE_RESET( defender )
741741{
742742   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
743743
744744   MACHINE_RESET_CALL(williams_common);
745745
746   /* configure the banking and make sure it is reset to 0 */
747   memory_configure_bank(machine, "bank1", 0, 9, &memory_region(machine, "maincpu")[0x10000], 0x1000);
748746   defender_bank_select_w(space, 0, 0);
749
750   state_save_register_postload(machine, defender_postload, NULL);
751747}
752748
753749
r6740r6741
834830 *
835831 *************************************/
836832
837MACHINE_RESET( blaster )
833MACHINE_START( blaster )
838834{
839   MACHINE_RESET_CALL(williams_common);
835   MACHINE_START_CALL(williams_common);
840836
841837   /* banking is different for blaster */
842838   memory_configure_bank(machine, "bank1", 0, 1, williams_videoram, 0);
r6740r6741
849845}
850846
851847
848MACHINE_RESET( blaster )
849{
850   MACHINE_RESET_CALL(williams_common);
851}
852
853
852854INLINE void update_blaster_banking(running_machine *machine)
853855{
854856   memory_set_bank(machine, "bank1", vram_bank * (blaster_bank + 1));
r6740r6741
884886 *
885887 *************************************/
886888
887static READ8_DEVICE_HANDLER( lottofun_input_port_0_r )
888{
889   const address_space *space = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
890
891   /* merge in the ticket dispenser status */
892   return input_port_read(device->machine, "IN0") | ticket_dispenser_r(space, offset);
893}
894
895889static WRITE8_DEVICE_HANDLER( lottofun_coin_lock_w )
896890{
897891   coin_lockout_global_w(device->machine, data & 1); /* bit 5 of PIC control port A */
898892}
899893
894
895
900896/*************************************
901897 *
902898 *  Turkey Shoot-specific routines
r6740r6741
957953
958954MACHINE_START( joust2 )
959955{
956   MACHINE_START_CALL(williams2);
960957   williams_cvsd_init(machine);
958   state_save_register_global(machine, joust2_current_sound_data);
961959}
962960
963961
r6740r6741
968966   /* standard init */
969967   MACHINE_RESET_CALL(williams2);
970968   pia6821_ca1_w(pia_3, 0, 1);
971   state_save_register_global(machine, joust2_current_sound_data);
972969}
973970
974971
src/mame/machine/pgmprot.c
r6740r6741
66/*** ASIC27a (Puzzle Star) -- ARM but with no external rom? behaves a bit like KOV ***/
77
88
9/*** (pstarS) ***/
910
10
11/*** (PSTARS) ***/
12static UINT16 PSTARSKEY;
13static UINT16 PSTARSINT[2];
14static UINT32 PSTARS_REGS[16];
15static UINT32 PSTARS_VAL;
16
17static UINT16 pstar_e7,pstar_b1,pstar_ce;
18static UINT16 pstar_ram[3];
19
20static const int Pstar_ba[0x1E]={
11static const int pstar_ba[0x1E]={
2112   0x02,0x00,0x00,0x01,0x00,0x03,0x00,0x00, //0
2213   0x02,0x00,0x06,0x00,0x22,0x04,0x00,0x03, //8
2314   0x00,0x00,0x06,0x00,0x20,0x07,0x00,0x03, //10
2415   0x00,0x21,0x01,0x00,0x00,0x63
2516};
2617
27static const int Pstar_b0[0x10]={
18static const int pstar_b0[0x10]={
2819   0x09,0x0A,0x0B,0x00,0x01,0x02,0x03,0x04,
2920   0x05,0x06,0x07,0x08,0x00,0x00,0x00,0x00
3021};
3122
32static const int Pstar_ae[0x10]={
23static const int pstar_ae[0x10]={
3324   0x5D,0x86,0x8C ,0x8B,0xE0,0x8B,0x62,0xAF,
3425   0xB6,0xAF,0x10A,0xAF,0x00,0x00,0x00,0x00
3526};
3627
37static const int Pstar_a0[0x10]={
28static const int pstar_a0[0x10]={
3829   0x02,0x03,0x04,0x05,0x06,0x01,0x0A,0x0B,
3930   0x0C,0x0D,0x0E,0x09,0x00,0x00,0x00,0x00,
4031};
4132
42static const int Pstar_9d[0x10]={
33static const int pstar_9d[0x10]={
4334   0x05,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
4435   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
4536};
4637
47static const int Pstar_90[0x10]={
38static const int pstar_90[0x10]={
4839   0x0C,0x10,0x0E,0x0C,0x00,0x00,0x00,0x00,
4940   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
5041};
51static const int Pstar_8c[0x23]={
42static const int pstar_8c[0x23]={
5243   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
5344   0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,
5445   0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,
r6740r6741
5647   0x03,0x03,0x03
5748};
5849
59static const int Pstar_80[0x1a3]={
50static const int pstar_80[0x1a3]={
6051   0x03,0x03,0x04,0x04,0x04,0x04,0x05,0x05,
6152   0x05,0x05,0x06,0x06,0x03,0x03,0x04,0x04,
6253   0x05,0x05,0x05,0x05,0x06,0x06,0x07,0x07,
r6740r6741
115106
116107
117108
118READ16_HANDLER (PSTARS_protram_r)
109READ16_HANDLER( pstars_protram_r )
119110{
111   pgm_state *state = (pgm_state *)space->machine->driver_data;
112
120113   if (offset == 4)      //region
121114      return input_port_read(space->machine, "Region");
122115   else if (offset >= 0x10)  //timer
123116   {
124     logerror("PSTARS ACCESS COUNTER %6X\n",pstar_ram[offset-0x10]);
125      return pstar_ram[offset-0x10]--;
117      logerror("PSTARS ACCESS COUNTER %6X\n", state->pstar_ram[offset - 0x10]);
118      return state->pstar_ram[offset - 0x10]--;
126119   }
127120   return 0x0000;
128121}
129122
130READ16_HANDLER (PSTARS_r16)
123READ16_HANDLER( pstars_r )
131124{
132   if(offset==0)
125   pgm_state *state = (pgm_state *)space->machine->driver_data;
126
127   if (offset == 0)
133128   {
134      UINT16 d=PSTARS_VAL&0xffff;
135      UINT16 realkey;
136      realkey=PSTARSKEY>>8;
137      realkey|=PSTARSKEY;
138      d^=realkey;
139//      logerror("PSTARS A27 R  %6X\n",PSTARS_VAL);
129      UINT16 d = state->pstars_val & 0xffff;
130      UINT16 realkey = state->pstars_key >> 8;
131      realkey |= state->pstars_key;
132      d ^= realkey;
133//      logerror("PSTARS A27 R  %6X\n", state->pstars_val);
140134      return d;
141135   }
142   else if(offset==1)
136   else if (offset == 1)
143137   {
144      UINT16 d=PSTARS_VAL>>16;
145      UINT16 realkey;
146      realkey=PSTARSKEY>>8;
147      realkey|=PSTARSKEY;
148      d^=realkey;
138      UINT16 d = state->pstars_val >> 16;
139      UINT16 realkey = state->pstars_key >> 8;
140      realkey |= state->pstars_key;
141      d ^= realkey;
149142      return d;
150143
151144   }
152145   return 0xff;
153146}
154147
155WRITE16_HANDLER (PSTARS_w16)
148WRITE16_HANDLER( pstars_w )
156149{
157   if(offset==0)
150   pgm_state *state = (pgm_state *)space->machine->driver_data;
151
152   if (offset == 0)
158153   {
159      PSTARSINT[0]=data;
154      state->pstars_int[0] = data;
160155      return;
161156   }
162157
163   if(offset==1)
158   if (offset == 1)
164159   {
165160      UINT16 realkey;
166      if((data>>8)==0xff)
167         PSTARSKEY=0xff00;
168      realkey=PSTARSKEY>>8;
169      realkey|=PSTARSKEY;
161      if ((data >> 8) == 0xff)
162         state->pstars_key = 0xff00;
163      realkey = state->pstars_key >> 8;
164      realkey |= state->pstars_key;
170165      {
171         PSTARSKEY+=0x100;
172         PSTARSKEY&=0xff00;
173       if(PSTARSKEY==0xff00)PSTARSKEY=0x100;
174       }
175      data^=realkey;
176      PSTARSINT[1]=data;
177      PSTARSINT[0]^=realkey;
166         state->pstars_key += 0x100;
167         state->pstars_key &= 0xff00;
168         if (state->pstars_key == 0xff00)
169            state->pstars_key = 0x100;
170      }
171      data ^= realkey;
172      state->pstars_int[1] = data;
173      state->pstars_int[0] ^= realkey;
178174
179      switch(PSTARSINT[1]&0xff)
180         {
181            case 0x99:
182            {
183               PSTARSKEY=0x100;
184               PSTARS_VAL=0x880000;
175      switch (state->pstars_int[1] & 0xff)
176      {
177      case 0x99:
178         state->pstars_key = 0x100;
179         state->pstars_val = 0x880000;
180         break;
185181
186            }
187            break;
182      case 0xe0:
183         state->pstars_val = 0xa00000 + (state->pstars_int[0] << 6);
184         break;
188185
189            case 0xE0:
190               {
191                  PSTARS_VAL=0xa00000+(PSTARSINT[0]<<6);
192               }
193               break;
194            case 0xDC:
195               {
196                  PSTARS_VAL=0xa00800+(PSTARSINT[0]<<6);
197               }
198               break;
199            case 0xD0:
200               {
201                  PSTARS_VAL=0xa01000+(PSTARSINT[0]<<5);
202               }
203               break;
186      case 0xdc:
187         state->pstars_val = 0xa00800 + (state->pstars_int[0] << 6);
188         break;
204189
205            case 0xb1:
206               {
207                  pstar_b1=PSTARSINT[0];
208                  PSTARS_VAL=0x890000;
209               }
210               break;
211            case 0xbf:
212               {
213                  PSTARS_VAL=pstar_b1*PSTARSINT[0];
214               }
215               break;
190      case 0xd0:
191         state->pstars_val = 0xa01000 + (state->pstars_int[0] << 5);
192         break;
216193
217            case 0xc1: //TODO:TIMER  0,1,2,FIX TO 0 should be OK?
218               {
219                  PSTARS_VAL=0;
220               }
221               break;
222            case 0xce: //TODO:TIMER  0,1,2
223               {
224                  pstar_ce=PSTARSINT[0];
225                  PSTARS_VAL=0x890000;
226               }
227               break;
228            case 0xcf: //TODO:TIMER  0,1,2
229               {
230                  pstar_ram[pstar_ce]=PSTARSINT[0];
231                  PSTARS_VAL=0x890000;
232               }
233               break;
194      case 0xb1:
195         state->pstar_b1 = state->pstars_int[0];
196         state->pstars_val = 0x890000;
197         break;
234198
199      case 0xbf:
200         state->pstars_val = state->pstar_b1 * state->pstars_int[0];
201         break;
235202
236            case 0xe7:
237               {
238                  pstar_e7=(PSTARSINT[0]>>12)&0xf;
239                  PSTARS_REGS[pstar_e7]&=0xffff;
240                  PSTARS_REGS[pstar_e7]|=(PSTARSINT[0]&0xff)<<16;
241                  PSTARS_VAL=0x890000;
242               }
243               break;
244            case 0xe5:
245               {
203      case 0xc1: //TODO:TIMER  0,1,2,FIX TO 0 should be OK?
204         state->pstars_val = 0;
205         break;
246206
247                  PSTARS_REGS[pstar_e7]&=0xff0000;
248                  PSTARS_REGS[pstar_e7]|=PSTARSINT[0];
249                  PSTARS_VAL=0x890000;
250               }
251               break;
252            case 0xf8: //@73C
253               {
254                PSTARS_VAL=PSTARS_REGS[PSTARSINT[0]&0xf]&0xffffff;
255               }
256               break;
207      case 0xce: //TODO:TIMER  0,1,2
208         state->pstar_ce = state->pstars_int[0];
209         state->pstars_val=0x890000;
210         break;
257211
212      case 0xcf: //TODO:TIMER  0,1,2
213         state->pstar_ram[state->pstar_ce] = state->pstars_int[0];
214         state->pstars_val = 0x890000;
215         break;
258216
259            case 0xba:
260               {
261                PSTARS_VAL=Pstar_ba[PSTARSINT[0]];
262               }
263               break;
264            case 0xb0:
265               {
266                PSTARS_VAL=Pstar_b0[PSTARSINT[0]];
267               }
268               break;
269            case 0xae:
270               {
271                PSTARS_VAL=Pstar_ae[PSTARSINT[0]];
272               }
273               break;
274            case 0xa0:
275               {
276                PSTARS_VAL=Pstar_a0[PSTARSINT[0]];
277               }
278               break;
279            case 0x9d:
280               {
281                PSTARS_VAL=Pstar_9d[PSTARSINT[0]];
282               }
283               break;
284            case 0x90:
285               {
286                PSTARS_VAL=Pstar_90[PSTARSINT[0]];
287               }
288               break;
289            case 0x8c:
290               {
291                PSTARS_VAL=Pstar_8c[PSTARSINT[0]];
292               }
293               break;
294            case 0x80:
295               {
296                PSTARS_VAL=Pstar_80[PSTARSINT[0]];
297               }
298               break;
299            default:
300                PSTARS_VAL=0x890000;
301               logerror("PSTARS PC(%06x) UNKNOWN %4X %4X\n",cpu_get_pc(space->cpu),PSTARSINT[1],PSTARSINT[0]);
217      case 0xe7:
218         state->pstar_e7 = (state->pstars_int[0] >> 12) & 0xf;
219         state->pstars_regs[state->pstar_e7] &= 0xffff;
220         state->pstars_regs[state->pstar_e7] |= (state->pstars_int[0] & 0xff) << 16;
221         state->pstars_val = 0x890000;
222         break;
302223
224      case 0xe5:
225         state->pstars_regs[state->pstar_e7] &= 0xff0000;
226         state->pstars_regs[state->pstar_e7] |= state->pstars_int[0];
227         state->pstars_val = 0x890000;
228         break;
229
230      case 0xf8: //@73C
231         state->pstars_val = state->pstars_regs[state->pstars_int[0] & 0xf] & 0xffffff;
232         break;
233
234      case 0xba:
235         state->pstars_val = pstar_ba[state->pstars_int[0]];
236         break;
237
238      case 0xb0:
239         state->pstars_val = pstar_b0[state->pstars_int[0]];
240         break;
241
242      case 0xae:
243         state->pstars_val = pstar_ae[state->pstars_int[0]];
244         break;
245
246      case 0xa0:
247         state->pstars_val = pstar_a0[state->pstars_int[0]];
248            break;
249
250      case 0x9d:
251         state->pstars_val = pstar_9d[state->pstars_int[0]];
252         break;
253
254      case 0x90:
255         state->pstars_val = pstar_90[state->pstars_int[0]];
256         break;
257
258      case 0x8c:
259         state->pstars_val = pstar_8c[state->pstars_int[0]];
260         break;
261
262      case 0x80:
263            state->pstars_val = pstar_80[state->pstars_int[0]];
264         break;
265
266      default:
267         state->pstars_val = 0x890000;
268         logerror("PSTARS PC(%06x) UNKNOWN %4X %4X\n", cpu_get_pc(space->cpu), state->pstars_int[1], state->pstars_int[0]);
269
303270      }
304271
305272   }
r6740r6741
307274
308275/*** ASIC 3 (oriental legends protection) ****************************************/
309276
310static UINT8 asic3_reg, asic3_latch[3], asic3_x, asic3_y, asic3_z, asic3_h1, asic3_h2;
311static UINT16 asic3_hold;
312
313static UINT32 bt(UINT32 v, int bit)
314{
315   return (v & (1<<bit)) != 0;
316}
317
318277static void asic3_compute_hold(running_machine *machine)
319278{
320   // The mode is dependant on the region
279   pgm_state *state = (pgm_state *)machine->driver_data;
280
281   // The mode is dependent on the region
321282   static const int modes[4] = { 1, 1, 3, 2 };
322283   int mode = modes[input_port_read(machine, "Region") & 3];
323284
324   switch(mode) {
285   switch (mode)
286   {
325287   case 1:
326      asic3_hold =
327         (asic3_hold << 1)
328         ^0x2bad
329         ^bt(asic3_hold, 15)^bt(asic3_hold, 10)^bt(asic3_hold, 8)^bt(asic3_hold, 5)
330         ^bt(asic3_z, asic3_y)
331         ^(bt(asic3_x, 0) << 1)^(bt(asic3_x, 1) << 6)^(bt(asic3_x, 2) << 10)^(bt(asic3_x, 3) << 14);
288      state->asic3_hold =
289         (state->asic3_hold << 1)
290          ^ 0x2bad
291          ^ BIT(state->asic3_hold, 15) ^ BIT(state->asic3_hold, 10) ^ BIT(state->asic3_hold, 8) ^ BIT(state->asic3_hold, 5)
292          ^ BIT(state->asic3_z, state->asic3_y)
293          ^ (BIT(state->asic3_x, 0) << 1) ^ (BIT(state->asic3_x, 1) << 6) ^ (BIT(state->asic3_x, 2) << 10) ^ (BIT(state->asic3_x, 3) << 14);
332294      break;
333295   case 2:
334      asic3_hold =
335         (asic3_hold << 1)
336         ^0x2bad
337         ^bt(asic3_hold, 15)^bt(asic3_hold, 7)^bt(asic3_hold, 6)^bt(asic3_hold, 5)
338         ^bt(asic3_z, asic3_y)
339         ^(bt(asic3_x, 0) << 4)^(bt(asic3_x, 1) << 6)^(bt(asic3_x, 2) << 10)^(bt(asic3_x, 3) << 12);
296      state->asic3_hold =
297         (state->asic3_hold << 1)
298          ^ 0x2bad
299          ^ BIT(state->asic3_hold, 15) ^ BIT(state->asic3_hold, 7) ^ BIT(state->asic3_hold, 6) ^ BIT(state->asic3_hold, 5)
300          ^ BIT(state->asic3_z, state->asic3_y)
301          ^ (BIT(state->asic3_x, 0) << 4) ^ (BIT(state->asic3_x, 1) << 6) ^ (BIT(state->asic3_x, 2) << 10) ^ (BIT(state->asic3_x, 3) << 12);
340302      break;
341303   case 3:
342      asic3_hold =
343         (asic3_hold << 1)
344         ^0x2bad
345         ^bt(asic3_hold, 15)^bt(asic3_hold, 10)^bt(asic3_hold, 8)^bt(asic3_hold, 5)
346         ^bt(asic3_z, asic3_y)
347         ^(bt(asic3_x, 0) << 4)^(bt(asic3_x, 1) << 6)^(bt(asic3_x, 2) << 10)^(bt(asic3_x, 3) << 12);
304      state->asic3_hold =
305         (state->asic3_hold << 1)
306          ^ 0x2bad
307          ^ BIT(state->asic3_hold, 15) ^ BIT(state->asic3_hold, 10) ^ BIT(state->asic3_hold, 8) ^ BIT(state->asic3_hold, 5)
308          ^ BIT(state->asic3_z, state->asic3_y)
309          ^ (BIT(state->asic3_x, 0) << 4) ^ (BIT(state->asic3_x, 1) << 6) ^ (BIT(state->asic3_x, 2) << 10) ^ (BIT(state->asic3_x, 3) << 12);
348310      break;
349311   }
350312}
351313
352314READ16_HANDLER( pgm_asic3_r )
353315{
316   pgm_state *state = (pgm_state *)space->machine->driver_data;
354317   UINT8 res = 0;
355318   /* region is supplied by the protection device */
356319
357   switch(asic3_reg) {
358   case 0x00: res = (asic3_latch[0] & 0xf7) | ((input_port_read(space->machine, "Region") << 3) & 0x08); break;
359   case 0x01: res = asic3_latch[1]; break;
360   case 0x02: res = (asic3_latch[2] & 0x7f) | ((input_port_read(space->machine, "Region") << 6) & 0x80); break;
320   switch (state->asic3_reg)
321   {
322   case 0x00: res = (state->asic3_latch[0] & 0xf7) | ((input_port_read(space->machine, "Region") << 3) & 0x08); break;
323   case 0x01: res = state->asic3_latch[1]; break;
324   case 0x02: res = (state->asic3_latch[2] & 0x7f) | ((input_port_read(space->machine, "Region") << 6) & 0x80); break;
361325   case 0x03:
362      res = (bt(asic3_hold, 15) << 0)
363         | (bt(asic3_hold, 12) << 1)
364         | (bt(asic3_hold, 13) << 2)
365         | (bt(asic3_hold, 10) << 3)
366         | (bt(asic3_hold,  7) << 4)
367         | (bt(asic3_hold,  9) << 5)
368         | (bt(asic3_hold,  2) << 6)
369         | (bt(asic3_hold,  5) << 7);
326      res = (BIT(state->asic3_hold, 15) << 0)
327         | (BIT(state->asic3_hold, 12) << 1)
328         | (BIT(state->asic3_hold, 13) << 2)
329         | (BIT(state->asic3_hold, 10) << 3)
330         | (BIT(state->asic3_hold, 7) << 4)
331         | (BIT(state->asic3_hold, 9) << 5)
332         | (BIT(state->asic3_hold, 2) << 6)
333         | (BIT(state->asic3_hold, 5) << 7);
370334      break;
371335   case 0x20: res = 0x49; break;
372336   case 0x21: res = 0x47; break;
r6740r6741
393357
394358WRITE16_HANDLER( pgm_asic3_w )
395359{
360   pgm_state *state = (pgm_state *)space->machine->driver_data;
361
396362   if(ACCESSING_BITS_0_7)
397363   {
398      if(asic3_reg < 3)
399         asic3_latch[asic3_reg] = data << 1;
400      else if(asic3_reg == 0xa0) {
401         asic3_hold = 0;
402      } else if(asic3_reg == 0x40) {
403         asic3_h2 = asic3_h1;
404         asic3_h1 = data;
405      } else if(asic3_reg == 0x48) {
406         asic3_x = 0;
407         if(!(asic3_h2 & 0x0a))
408            asic3_x |= 8;
409         if(!(asic3_h2 & 0x90))
410            asic3_x |= 4;
411         if(!(asic3_h1 & 0x06))
412            asic3_x |= 2;
413         if(!(asic3_h1 & 0x90))
414            asic3_x |= 1;
415      } else if(asic3_reg >= 0x80 && asic3_reg <= 0x87) {
416         asic3_y = asic3_reg & 7;
417         asic3_z = data;
364      if (state->asic3_reg < 3)
365         state->asic3_latch[state->asic3_reg] = data << 1;
366      else if (state->asic3_reg == 0xa0)
367         state->asic3_hold = 0;
368      else if (state->asic3_reg == 0x40)
369      {
370         state->asic3_h2 = state->asic3_h1;
371         state->asic3_h1 = data;
372      }
373      else if (state->asic3_reg == 0x48)
374      {
375         state->asic3_x = 0;
376         if (!(state->asic3_h2 & 0x0a))
377            state->asic3_x |= 8;
378         if (!(state->asic3_h2 & 0x90))
379            state->asic3_x |= 4;
380         if (!(state->asic3_h1 & 0x06))
381            state->asic3_x |= 2;
382         if (!(state->asic3_h1 & 0x90))
383            state->asic3_x |= 1;
384      }
385      else if(state->asic3_reg >= 0x80 && state->asic3_reg <= 0x87)
386      {
387         state->asic3_y = state->asic3_reg & 7;
388         state->asic3_z = data;
418389         asic3_compute_hold(space->machine);
419390      }
420391   }
r6740r6741
422393
423394WRITE16_HANDLER( pgm_asic3_reg_w )
424395{
396   pgm_state *state = (pgm_state *)space->machine->driver_data;
397
425398   if(ACCESSING_BITS_0_7)
426      asic3_reg = data & 0xff;
399      state->asic3_reg = data & 0xff;
427400}
428401
429402/*** Knights of Valour / Sango / PhotoY2k Protection (from ElSemi) (ASIC28) ***/
430403
431static UINT16 ASIC28KEY;
432static UINT16 ASIC28REGS[10];
433static UINT16 ASICPARAMS[256];
434static UINT16 ASIC28RCNT=0;
435static const UINT32 B0TABLE[16]={2,0,1,4,3}; //maps char portraits to tables
404static const UINT32 B0TABLE[16] = {2, 0, 1, 4, 3}; //maps char portraits to tables
436405
437406// photo2yk bonus stage
438407static const UINT32 AETABLE[16]={0x00,0x0a,0x14,
r6740r6741
448417     0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,
449418     0x9e,0xa3,0xd4,0xa9,0xaf,0xb5,0xbb,0xc1};
450419
451static UINT32 E0REGS[16];
452420
453421
454READ16_HANDLER (sango_protram_r)
422READ16_HANDLER( sango_protram_r )
455423{
456
457
458424   // at offset == 4 is region (supplied by device)
459425   // 0 = china
460426   // 1 = taiwan
r6740r6741
463429   // 4 = hong kong
464430   // 5 = world
465431
466   if (offset == 4)   return input_port_read(space->machine, "Region");
432   if (offset == 4)
433      return input_port_read(space->machine, "Region");
467434
468435   // otherwise it doesn't seem to use the ram for anything important, we return 0 to avoid test mode corruption
469436   // kovplus reads from offset 000e a lot ... why?
r6740r6741
486453                 (BIT(val, B0) <<  0))
487454
488455
489READ16_HANDLER (ASIC28_r16)
490//UINT16 ASIC28_r16(UINT32 addr)
456READ16_HANDLER( asic28_r )
491457{
492   UINT32 val=(ASIC28REGS[1]<<16)|(ASIC28REGS[0]);
458   pgm_state *state = (pgm_state *)space->machine->driver_data;
459   UINT32 val = (state->asic28_regs[1] << 16) | (state->asic28_regs[0]);
493460
494//logerror("Asic28 Read PC = %06x Command = %02x ??\n",cpu_get_pc(space->cpu), ASIC28REGS[1]);
461   //logerror("Asic28 Read PC = %06x Command = %02x ??\n", cpu_get_pc(space->cpu), state->asic28_regs[1]);
495462
496   switch(ASIC28REGS[1]&0xff)
463   switch (state->asic28_regs[1] & 0xff)
497464   {
498465      case 0x99:
499         val=0x880000;
466         val = 0x880000;
500467         break;
501468
502469      case 0x9d:   // spr palette
503         val=0xa00000+((ASIC28REGS[0]&0x1f)<<6);
470         val = 0xa00000 + ((state->asic28_regs[0] & 0x1f) << 6);
504471         break;
505472
506473      case 0xb0:
507         val=B0TABLE[ASIC28REGS[0]&0xf];
474         val = B0TABLE[state->asic28_regs[0] & 0xf];
508475         break;
509476
510477      case 0xb4:
511478         {
512            int v2=ASIC28REGS[0]&0x0f;
513            int v1=(ASIC28REGS[0]&0x0f00)>>8;
514//              UINT16 tmp=E0REGS[v2];
515            //E0REGS[v2]=E0REGS[v1];
516            //E0REGS[v1]=tmp;
517            if(ASIC28REGS[0]==0x102)
518               E0REGS[1]=E0REGS[0];
479            //UINT16 tmp = state->eoregs[v2];
480            int v2 = state->asic28_regs[0] & 0x0f;
481            int v1 = (state->asic28_regs[0] & 0x0f00) >> 8;
482            //state->eoregs[v2] = state->eoregs[v1];
483            //state->eoregs[v1] = tmp;
484            if (state->asic28_regs[0] == 0x102)
485               state->eoregs[1] = state->eoregs[0];
519486            else
520               E0REGS[v1]=E0REGS[v2];
487               state->eoregs[v1] = state->eoregs[v2];
521488
522            val=0x880000;
489            val = 0x880000;
523490         }
524491         break;
525492
526493      case 0xba:
527         val=BATABLE[ASIC28REGS[0]&0x3f];
528         if(ASIC28REGS[0]>0x2f)
529         {
530//              PutMessage("Unmapped BA com, report ElSemi",60);
531            popmessage   ("Unmapped BA com %02x, contact ElSemi / MameDev", ASIC28REGS[0]);
532         }
494         val = BATABLE[state->asic28_regs[0] & 0x3f];
495         if (state->asic28_regs[0] > 0x2f)
496            popmessage("Unmapped BA com %02x, contact ElSemi / MameDev", state->asic28_regs[0]);
533497         break;
534498
535499      case 0xc0:
536         val=0x880000;
500         val = 0x880000;
537501         break;
538502
539503      case 0xc3:   //TXT tile position Uses C0 to select column
540         {
541            val=0x904000+(ASICPARAMS[0xc0]+ASICPARAMS[0xc3]*64)*4;
542         }
504         val = 0x904000 + (state->asic_params[0xc0] + state->asic_params[0xc3] * 64) * 4;
543505         break;
544506
545507      case 0xcb:
546         val=0x880000;
508         val = 0x880000;
547509         break;
548510
549511      case 0xcc: //BG
550512            {
551             int y=ASICPARAMS[0xcc];
552          if(y&0x400)    //y is signed (probably x too and it also applies to TXT, but I've never seen it used)
553              y=-(0x400-(y&0x3ff));
554          val=0x900000+(((ASICPARAMS[0xcb]+(y)*64)*4)/*&0x1fff*/);
513             int y = state->asic_params[0xcc];
514         if (y & 0x400)    //y is signed (probably x too and it also applies to TXT, but I've never seen it used)
515            y =- (0x400 - (y & 0x3ff));
516         val = 0x900000 + (((state->asic_params[0xcb] + (y) * 64) * 4) /*&0x1fff*/);
555517            }
556518            break;
557519
558520      case 0xd0:   //txt palette
559         val=0xa01000+(ASIC28REGS[0]<<5);
521         val = 0xa01000 + (state->asic28_regs[0] << 5);
560522         break;
561523
562524      case 0xd6:   //???? check it
563525         {
564            int v2=ASIC28REGS[0]&0xf;
565//              int v1=(ASIC28REGS[0]&0xf0)>>4;
566            E0REGS[0]=E0REGS[v2];
567            //E0REGS[v2]=0;
568            val=0x880000;
526            int v2 = state->asic28_regs[0] & 0xf;
527            //int v1 = (state->asic28_regs[0] & 0xf0) >> 4;
528            state->eoregs[0] = state->eoregs[v2];
529            //state->eoregs[v2] = 0;
530            val = 0x880000;
569531         }
570532         break;
571533
572534      case 0xdc:   //bg palette
573         val=0xa00800+(ASIC28REGS[0]<<6);
535         val = 0xa00800 + (state->asic28_regs[0] << 6);
574536         break;
575537
576538      case 0xe0:   //spr palette
577         val=0xa00000+((ASIC28REGS[0]&0x1f)<<6);
539         val = 0xa00000 + ((state->asic28_regs[0] & 0x1f) << 6);
578540         break;
579541
580542      case 0xe5:
581         val=0x880000;
543         val = 0x880000;
582544         break;
583545
584546      case 0xe7:
585         val=0x880000;
547         val = 0x880000;
586548         break;
587549
588550      case 0xf0:
589         {
590            val=0x00C000;
591         }
551         val = 0x00C000;
592552         break;
593553
594554      case 0xf8:
595         val=E0REGS[ASIC28REGS[0]&0xf]&0xffffff;
555         val = state->eoregs[state->asic28_regs[0] & 0xf] & 0xffffff;
596556         break;
597557
598558      case 0xfc:   //Adjust damage level to char experience level
599559         {
600         val=(ASICPARAMS[0xfc]*ASICPARAMS[0xfe])>>6;
560         val = (state->asic_params[0xfc] * state->asic_params[0xfe]) >> 6;
601561         break;
602562         }
603563
604564      case 0xfe:   //todo
605         val=0x880000;
565         val = 0x880000;
606566         break;
607567
608568
609569      default:
610         {
611            val=0x880000;
612         }
570         val = 0x880000;
613571   }
614572
615//  if(addr==0x500000)
616   if(offset==0)
573   if(offset == 0)
617574   {
618      UINT16 d=val&0xffff;
619      UINT16 realkey;
620      realkey=ASIC28KEY>>8;
621      realkey|=ASIC28KEY;
622      d^=realkey;
575      UINT16 d = val & 0xffff;
576      UINT16 realkey = state->asic28_key >> 8;
577      realkey |= state->asic28_key;
578      d ^= realkey;
623579      return d;
624580   }
625//  else if(addr==0x500002)
626   else if(offset==1)
581   else if (offset == 1)
627582   {
628      UINT16 d=val>>16;
629      UINT16 realkey;
630      realkey=ASIC28KEY>>8;
631      realkey|=ASIC28KEY;
632      d^=realkey;
633      ASIC28RCNT++;
634      if(!(ASIC28RCNT&0xf))
583      UINT16 d = val >> 16;
584      UINT16 realkey = state->asic28_key >> 8;
585      realkey |= state->asic28_key;
586      d ^= realkey;
587      state->asic28_rcnt++;
588      if (!(state->asic28_rcnt & 0xf))
635589      {
636         ASIC28KEY+=0x100;
637         ASIC28KEY&=0xFF00;
590         state->asic28_key += 0x100;
591         state->asic28_key &= 0xff00;
638592      }
639593      return d;
640594   }
641595   return 0xff;
642596}
643597
644WRITE16_HANDLER (ASIC28_w16)
645//void ASIC28_w16(UINT32 addr,UINT16 data)
598WRITE16_HANDLER( asic28_w )
646599{
647//  if(addr==0x500000)
648   if(offset==0)
600   pgm_state *state = (pgm_state *)space->machine->driver_data;
601
602   if (offset == 0)
649603   {
650      UINT16 realkey;
651      realkey=ASIC28KEY>>8;
652      realkey|=ASIC28KEY;
653      data^=realkey;
654      ASIC28REGS[0]=data;
604      UINT16 realkey =state->asic28_key >> 8;
605      realkey |= state->asic28_key;
606      data ^= realkey;
607      state->asic28_regs[0] = data;
655608      return;
656609   }
657//  if(addr==0x500002)
658   if(offset==1)
610   if (offset == 1)
659611   {
660612      UINT16 realkey;
661613
662      ASIC28KEY=data&0xff00;
614      state->asic28_key = data & 0xff00;
663615
664      realkey=ASIC28KEY>>8;
665      realkey|=ASIC28KEY;
666      data^=realkey;
667      ASIC28REGS[1]=data;
668//      ErrorLogMessage("ASIC28 CMD %X  PARAM %X",ASIC28REGS[1],ASIC28REGS[0]);
669      logerror("ASIC28 CMD %04x  PARAM %04x\n",ASIC28REGS[1],ASIC28REGS[0]);
616      realkey = state->asic28_key >> 8;
617      realkey |= state->asic28_key;
618      data ^= realkey;
619      state->asic28_regs[1] = data;
620      logerror("ASIC28 CMD %04x  PARAM %04x\n", state->asic28_regs[1], state->asic28_regs[0]);
670621
671      ASICPARAMS[ASIC28REGS[1]&0xff]=ASIC28REGS[0];
672      if(ASIC28REGS[1]==0xE7)
622      state->asic_params[state->asic28_regs[1] & 0xff] = state->asic28_regs[0];
623      if (state->asic28_regs[1] == 0xE7)
673624      {
674         UINT32 E0R=(ASICPARAMS[0xE7]>>12)&0xf;
675         E0REGS[E0R]&=0xffff;
676         E0REGS[E0R]|=ASIC28REGS[0]<<16;
625         UINT32 E0R = (state->asic_params[0xe7] >> 12) & 0xf;
626         state->eoregs[E0R] &= 0xffff;
627         state->eoregs[E0R] |= state->asic28_regs[0] << 16;
677628      }
678      if(ASIC28REGS[1]==0xE5)
629      if (state->asic28_regs[1]==0xE5)
679630      {
680         UINT32 E0R=(ASICPARAMS[0xE7]>>12)&0xf;
681         E0REGS[E0R]&=0xff0000;
682         E0REGS[E0R]|=ASIC28REGS[0];
631         UINT32 E0R = (state->asic_params[0xe7] >> 12) & 0xf;
632         state->eoregs[E0R] &= 0xff0000;
633         state->eoregs[E0R] |= state->asic28_regs[0];
683634      }
684      ASIC28RCNT=0;
635      state->asic28_rcnt = 0;
685636   }
686637}
687638
r6740r6741
689640
690641#define DW2BITSWAP(s,d,bs,bd)  d=((d&(~(1<<bd)))|(((s>>bs)&1)<<bd))
691642//Use this handler for reading from 0xd80000-0xd80002
692READ16_HANDLER (dw2_d80000_r )
643READ16_HANDLER( dw2_d80000_r )
693644{
694//addr&=0xff;
645// addr&=0xff;
695646// if(dw2reg<0x20) //NOT SURE!!
696647   {
697648      //The value at 0x80EECE is computed in the routine at 0x107c18
698      UINT16 d=pgm_mainram[0xEECE/2];
699      UINT16 d2=0;
700      d=(d>>8)|(d<<8);
701      DW2BITSWAP(d,d2,7 ,0);
702      DW2BITSWAP(d,d2,4 ,1);
703      DW2BITSWAP(d,d2,5 ,2);
704      DW2BITSWAP(d,d2,2 ,3);
705      DW2BITSWAP(d,d2,15,4);
706      DW2BITSWAP(d,d2,1 ,5);
707      DW2BITSWAP(d,d2,10,6);
708      DW2BITSWAP(d,d2,13,7);
649      UINT16 d = pgm_mainram[0xEECE/2];
650      UINT16 d2 = 0;
651      d = (d >> 8) | (d << 8);
652      DW2BITSWAP(d, d2, 7,  0);
653      DW2BITSWAP(d, d2, 4,  1);
654      DW2BITSWAP(d, d2, 5,  2);
655      DW2BITSWAP(d, d2, 2,  3);
656      DW2BITSWAP(d, d2, 15, 4);
657      DW2BITSWAP(d, d2, 1,  5);
658      DW2BITSWAP(d, d2, 10, 6);
659      DW2BITSWAP(d, d2, 13, 7);
709660      // ... missing bitswaps here (8-15) there is not enough data to know them
710661      // the code only checks the lowest 8 bytes
711662      return d2;
r6740r6741
794745
795746}
796747#endif
797
798
src/mame/machine/system16.c
r6740r6741
11#include "driver.h"
2#include "system16.h"
2#include "includes/system16.h"
33#include "sound/upd7759.h"
44
55static void patch_codeX( UINT16 *mem, offs_t offset, int data )
src/mame/machine/namcond1.c
r6740r6741
1111
1212#include "driver.h"
1313#include "cpu/m6809/m6809.h"
14#include "namcond1.h"
14#include "includes/namcond1.h"
1515
1616/* Perform basic machine initialisation */
1717
src/mame/machine/cps2crpt.c
r6740r6741
943943   { "sfz3a",    { 0x990b9301,0xa4e42c7e }, 0x100000 },   // 0C80 1C62 F5A8  cmpi.l  #$1C62F5A8,D0
944944   { "sfz3ar1",  { 0x990b9301,0xa4e42c7e }, 0x100000 },   // 0C80 1C62 F5A8  cmpi.l  #$1C62F5A8,D0
945945   { "jyangoku", { 0x6ca42ae6,0x92f63f59 },  /*?*/   },   // 0C80 3652 1573  cmpi.l  #$36521573,D0
946   { "hsf2",     { 0xb8ed3630,0xaae30a3d }, 0x100000 },   // 0838 0007 2000  btst    #7,$2000
946   { "hsf2",     { 0x5a369ddd,0xfea3189c }, 0x100000 },   // 0838 0007 2000  btst    #7,$2000
947   { "hsf2a",    { 0xb8ed3630,0xaae30a3d }, 0x100000 },   // 0838 0007 2000  btst    #7,$2000
947948   { "hsf2j",    { 0x65d82fe0,0xdbb83e47 }, 0x100000 },   // 0838 0007 2000  btst    #7,$2000
948949   { "gigawing", { 0xe52de290,0x1b60d780 }, 0x100000 },   // 0C81 1972 1027  cmpi.l  #$19721027,D1
949950   { "gigawingj",{ 0x1126196a,0xbef50895 }, 0x100000 },   // 0C81 1972 1027  cmpi.l  #$19721027,D1
r6740r6741
989990      }
990991      ++k;
991992   }
992
993   DRIVER_INIT_CALL(cps2_video);
994993}
src/mame/machine/decocrpt.c
r6740r6741
4242*******************************************************************************/
4343
4444#include "driver.h"
45#include "decocrpt.h"
45#include "includes/decocrpt.h"
4646
4747static const UINT16 xor_masks[16] =
4848{
src/mame/machine/starwars.c
r6740r6741
88***************************************************************************/
99
1010#include "driver.h"
11#include "starwars.h"
11#include "includes/starwars.h"
1212#include "video/avgdvg.h"
1313
1414
src/mame/machine/nb1413m3.c
r6740r6741
1212
1313#include "driver.h"
1414#include "cpu/z80/z80.h"
15#include "nb1413m3.h"
15#include "includes/nb1413m3.h"
1616
1717
1818#define NB1413M3_DEBUG   0
src/mame/machine/atarifb.c
r6740r6741
66
77#include "driver.h"
88#include "deprecat.h"
9#include "atarifb.h"
9#include "includes/atarifb.h"
1010#include "sound/discrete.h"
1111
1212
src/mame/machine/wrally.c
r6740r6741
99
1010#include "driver.h"
1111#include "cpu/mcs51/mcs51.h"
12#include "gaelcrpt.h"
12#include "includes/gaelcrpt.h"
1313#include "includes/wrally.h"
1414
1515/***************************************************************************
src/mame/machine/simpsons.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33#include "cpu/konami/konami.h"
4#include "machine/eeprom.h"
4#include "machine/eepromdev.h"
55#include "sound/k053260.h"
66#include "includes/simpsons.h"
77
r6740r6741
1313
1414***************************************************************************/
1515
16static int init_eeprom_count;
17
18
19static const eeprom_interface eeprom_intf =
20{
21   7,            /* address bits */
22   8,            /* data bits */
23   "011000",      /*  read command */
24   "011100",      /* write command */
25   0,            /* erase command */
26   "0100000000000",/* lock command */
27   "0100110000000" /* unlock command */
28};
29
30NVRAM_HANDLER( simpsons )
31{
32   if (read_or_write)
33      eeprom_save(file);
34   else
35   {
36      eeprom_init(machine, &eeprom_intf);
37
38      if (file)
39      {
40         init_eeprom_count = 0;
41         eeprom_load(file);
42      }
43      else
44         init_eeprom_count = 10;
45   }
46}
47
48READ8_HANDLER( simpsons_eeprom_r )
49{
50   int res;
51
52   res = (eeprom_read_bit() << 4);
53
54   res |= 0x20;//konami_eeprom_ack() << 5; /* add the ack */
55
56   res |= input_port_read(space->machine, "TEST") & 1; /* test switch */
57
58   if (init_eeprom_count)
59   {
60      init_eeprom_count--;
61      res &= 0xfe;
62   }
63   return res;
64}
65
6616WRITE8_HANDLER( simpsons_eeprom_w )
6717{
68   if ( data == 0xff )
18   if (data == 0xff)
6919      return;
7020
71   eeprom_write_bit(data & 0x80);
72   eeprom_set_cs_line((data & 0x08) ? CLEAR_LINE : ASSERT_LINE);
73   eeprom_set_clock_line((data & 0x10) ? ASSERT_LINE : CLEAR_LINE);
21   input_port_write(space->machine, "EEPROMOUT", data, 0xff);
7422
75   simpsons_video_banking( space->machine, data & 3 );
23   simpsons_video_banking(space->machine, data & 3);
7624
7725   simpsons_firq_enabled = data & 0x04;
7826}
r6740r6741
8533
8634WRITE8_HANDLER( simpsons_coin_counter_w )
8735{
36   const device_config *k053246 = devtag_get_device(space->machine, "k053246");
37   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
38
8839   /* bit 0,1 coin counters */
8940   coin_counter_w(space->machine, 0,data & 0x01);
9041   coin_counter_w(space->machine, 1,data & 0x02);
9142   /* bit 2 selects mono or stereo sound */
9243   /* bit 3 = enable char ROM reading through the video RAM */
93   K052109_set_RMRD_line((data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
44   k052109_set_rmrd_line(k052109, (data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
9445   /* bit 4 = INIT (unknown) */
9546   /* bit 5 = enable sprite ROM reading */
96   K053246_set_OBJCHA_line((~data & 0x20) ? ASSERT_LINE : CLEAR_LINE);
47   k053246_set_objcha_line(k053246, (~data & 0x20) ? ASSERT_LINE : CLEAR_LINE);
9748}
9849
9950READ8_HANDLER( simpsons_sound_interrupt_r )
src/mame/machine/subs.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "subs.h"
8#include "includes/subs.h"
99
1010static int subs_steering_buf1;
1111static int subs_steering_buf2;
src/mame/machine/model1.c
r6740r6741
19201920   }
19211921}
19221922
1923MACHINE_START( model1 )
1924{
1925   ram_data = auto_alloc_array(machine, UINT32, 0x10000);
1926
1927   state_save_register_global_pointer(machine, ram_data, 0x10000);
1928   state_save_register_global(machine, ram_adr);
1929   state_save_register_global(machine, ram_scanadr);
1930   state_save_register_global_array(machine, ram_latch);
1931   state_save_register_global(machine, fifoout_rpos);
1932   state_save_register_global(machine, fifoout_wpos);
1933   state_save_register_global_array(machine, fifoout_data);
1934   state_save_register_global(machine, fifoin_rpos);
1935   state_save_register_global(machine, fifoin_wpos);
1936   state_save_register_global_array(machine, fifoin_data);
1937   state_save_register_global_array(machine, cmat);
1938   state_save_register_global_2d_array(machine, mat_stack);
1939   state_save_register_global_2d_array(machine, mat_vector);
1940   state_save_register_global(machine, mat_stack_pos);
1941   state_save_register_global(machine, acc);
1942   state_save_register_global(machine, list_length);
1943}
1944
19231945void model1_tgp_reset(running_machine *machine, int swa)
19241946{
19251947   ram_adr = 0;
1926   ram_data = auto_alloc_array(machine, UINT32, 0x10000);
19271948   memset(ram_data, 0, 0x10000*4);
19281949
19291950   fifoout_rpos = 0;
r6740r6741
19411962   model1_dump = 0;
19421963   model1_swa = swa;
19431964   next_fn();
1944
1945   state_save_register_global_pointer(machine, ram_data, 0x10000);
1946   state_save_register_global(machine, ram_adr);
1947   state_save_register_global(machine, ram_scanadr);
1948   state_save_register_global_array(machine, ram_latch);
1949   state_save_register_global(machine, fifoout_rpos);
1950   state_save_register_global(machine, fifoout_wpos);
1951   state_save_register_global_array(machine, fifoout_data);
1952   state_save_register_global(machine, fifoin_rpos);
1953   state_save_register_global(machine, fifoin_wpos);
1954   state_save_register_global_array(machine, fifoin_data);
1955   state_save_register_global_array(machine, cmat);
1956   state_save_register_global_2d_array(machine, mat_stack);
1957   state_save_register_global_2d_array(machine, mat_vector);
1958   state_save_register_global(machine, mat_stack_pos);
1959   state_save_register_global(machine, acc);
1960   state_save_register_global(machine, list_length);
19611965}
19621966
19631967/*********************************** Virtua Racing ***********************************/
r6740r6741
19721976void model1_vr_tgp_reset( running_machine *machine )
19731977{
19741978   ram_adr = 0;
1975   ram_data = auto_alloc_array(machine, UINT32, 0x8000);
19761979   memset(ram_data, 0, 0x8000*4);
19771980
19781981   copro_fifoout_rpos = 0;
src/mame/machine/slapstic.c
r6740r6741
180180
181181#include "driver.h"
182182#include "cpu/m6800/m6800.h"
183#include "slapstic.h"
183#include "includes/slapstic.h"
184184#include "cpu/m68000/m68000.h"
185185
186186
src/mame/machine/ajax.c
r6740r6741
1111#include "cpu/m6809/m6809.h"
1212#include "cpu/z80/z80.h"
1313#include "cpu/konami/konami.h"
14#include "video/konamiic.h"
14#include "video/konicdev.h"
1515#include "includes/ajax.h"
1616
1717static int firq_enable;
r6740r6741
180180
181181WRITE8_HANDLER( ajax_bankswitch_2_w )
182182{
183   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
184   const device_config *k051316 = devtag_get_device(space->machine, "k051316");
183185   UINT8 *RAM = memory_region(space->machine, "sub");
184186   int bankaddress;
185187
186188   /* enable char ROM reading through the video RAM */
187   K052109_set_RMRD_line((data & 0x40) ? ASSERT_LINE : CLEAR_LINE);
189   k052109_set_rmrd_line(k052109, (data & 0x40) ? ASSERT_LINE : CLEAR_LINE);
188190
189191   /* bit 5 enables 051316 wraparound */
190   K051316_wraparound_enable(0, data & 0x20);
192   k051316_wraparound_enable(k051316, data & 0x20);
191193
192194   /* FIRQ control */
193195   firq_enable = data & 0x10;
r6740r6741
211213
212214INTERRUPT_GEN( ajax_interrupt )
213215{
214   if (K051960_is_IRQ_enabled())
216   const device_config *k051960 = devtag_get_device(device->machine, "k051960");
217   if (k051960_is_irq_enabled(k051960))
215218      cpu_set_input_line(device, KONAMI_IRQ_LINE, HOLD_LINE);
216219}
src/mame/machine/mw8080bw.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "mw8080bw.h"
9#include "machine/mb14241.h"
8#include "includes/mw8080bw.h"
109
11
1210/*************************************
1311 *
1412 *  Interrupt generation
1513 *
1614 *************************************/
1715
18static emu_timer *interrupt_timer;
19
20
21static UINT8 vpos_to_vysnc_chain_counter(int vpos)
16static UINT8 vpos_to_vysnc_chain_counter( int vpos )
2217{
2318   /* convert from a vertical position to the actual values on the vertical sync counters */
2419   UINT8 counter;
2520   int vblank = (vpos >= MW8080BW_VBSTART);
2621
2722   if (vblank)
28   {
2923      counter = vpos - MW8080BW_VBSTART + MW8080BW_VCOUNTER_START_VBLANK;
30   }
3124   else
32   {
3325      counter = vpos + MW8080BW_VCOUNTER_START_NO_VBLANK;
34   }
3526
36
3727   return counter;
3828}
3929
4030
41static int vysnc_chain_counter_to_vpos(UINT8 counter, int vblank)
31static int vysnc_chain_counter_to_vpos( UINT8 counter, int vblank )
4232{
4333   /* convert from the vertical sync counters to an actual vertical position */
4434   int vpos;
4535
4636   if (vblank)
47   {
4837      vpos = counter - MW8080BW_VCOUNTER_START_VBLANK + MW8080BW_VBSTART;
49   }
5038   else
51   {
5239      vpos = counter - MW8080BW_VCOUNTER_START_NO_VBLANK;
53   }
5440
5541   return vpos;
5642}
r6740r6741
5844
5945static TIMER_CALLBACK( mw8080bw_interrupt_callback )
6046{
47    mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
6148   UINT8 next_counter;
6249   int next_vpos;
6350   int next_vblank;
r6740r6741
6653   int vpos = video_screen_get_vpos(machine->primary_screen);
6754   UINT8 counter = vpos_to_vysnc_chain_counter(vpos);
6855   UINT8 vector = 0xc7 | ((counter & 0x40) >> 2) | ((~counter & 0x40) >> 3);
69   cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, vector);
56   cpu_set_input_line_and_vector(state->maincpu, 0, HOLD_LINE, vector);
7057
7158   /* set up for next interrupt */
7259   if (counter == MW8080BW_INT_TRIGGER_COUNT_1)
r6740r6741
8168   }
8269
8370   next_vpos = vysnc_chain_counter_to_vpos(next_counter, next_vblank);
84   timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, next_vpos, 0), 0);
71   timer_adjust_oneshot(state->interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, next_vpos, 0), 0);
8572}
8673
8774
88static void mw8080bw_create_interrupt_timer(running_machine *machine)
75static void mw8080bw_create_interrupt_timer( running_machine *machine )
8976{
90   interrupt_timer = timer_alloc(machine, mw8080bw_interrupt_callback, NULL);
77    mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
78   state->interrupt_timer = timer_alloc(machine, mw8080bw_interrupt_callback, NULL);
9179}
9280
9381
94static void mw8080bw_start_interrupt_timer(running_machine *machine)
82static void mw8080bw_start_interrupt_timer( running_machine *machine )
9583{
84    mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
9685   int vpos = vysnc_chain_counter_to_vpos(MW8080BW_INT_TRIGGER_COUNT_1, MW8080BW_INT_TRIGGER_VBLANK_1);
97   timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, vpos, 0), 0);
86   timer_adjust_oneshot(state->interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, vpos, 0), 0);
9887}
9988
10089
r6740r6741
10796
10897MACHINE_START( mw8080bw )
10998{
99    mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
100
110101   mw8080bw_create_interrupt_timer(machine);
111   mb14241_init(machine,0);
102
103   state->maincpu = devtag_get_device(machine, "maincpu");
104   state->samples = devtag_get_device(machine, "samples");
105   state->samples1 = devtag_get_device(machine, "samples1");
106   state->samples2 = devtag_get_device(machine, "samples2");
107   state->sn = devtag_get_device(machine, "snsnd");
108   state->sn1 = devtag_get_device(machine, "sn1");
109   state->sn2 = devtag_get_device(machine, "sn2");
110   state->discrete = devtag_get_device(machine, "discrete");
111   state->speaker = devtag_get_device(machine, "speaker");
112   state->mb14241 = devtag_get_device(machine, "mb14241");
112113}
113114
114115
115
116116/*************************************
117117 *
118118 *  Machine reset
src/mame/machine/nitedrvr.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "nitedrvr.h"
8#include "includes/nitedrvr.h"
99#include "sound/discrete.h"
1010
1111static UINT8 nitedrvr_gear;
r6740r6741
250250}
251251
252252
253static TIMER_CALLBACK( nitedrvr_crash_toggle_callback )
253TIMER_DEVICE_CALLBACK( nitedrvr_crash_toggle_callback )
254254{
255255   if (nitedrvr_crash_en && nitedrvr_crash_data_en)
256256   {
257      const device_config *discrete = devtag_get_device(machine, "discrete");
257      const device_config *discrete = devtag_get_device(timer->machine, "discrete");
258258
259259      nitedrvr_crash_data--;
260260      discrete_sound_w(discrete, NITEDRVR_BANG_DATA, nitedrvr_crash_data);   // Crash Volume
r6740r6741
262262      if (nitedrvr_crash_data & 0x01)
263263      {
264264         /* Invert video */
265         palette_set_color(machine,1,MAKE_RGB(0x00,0x00,0x00)); /* BLACK */
266         palette_set_color(machine,0,MAKE_RGB(0xff,0xff,0xff)); /* WHITE */
265         palette_set_color(timer->machine,1,MAKE_RGB(0x00,0x00,0x00)); /* BLACK */
266         palette_set_color(timer->machine,0,MAKE_RGB(0xff,0xff,0xff)); /* WHITE */
267267      }
268268      else
269269      {
270270         /* Normal video */
271         palette_set_color(machine,0,MAKE_RGB(0x00,0x00,0x00)); /* BLACK */
272         palette_set_color(machine,1,MAKE_RGB(0xff,0xff,0xff)); /* WHITE */
271         palette_set_color(timer->machine,0,MAKE_RGB(0x00,0x00,0x00)); /* BLACK */
272         palette_set_color(timer->machine,1,MAKE_RGB(0xff,0xff,0xff)); /* WHITE */
273273      }
274274   }
275275}
r6740r6741
298298   nitedrvr_crash_data_en = 0;
299299   ac_line = 0;
300300   last_steering_val = 0;
301
302   timer_pulse(machine, PERIOD_OF_555_ASTABLE(RES_K(180), 330, CAP_U(1)), NULL, 0, nitedrvr_crash_toggle_callback);
303301}
src/mame/mamedriv.c
r6740r6741
22772277   DRIVER( kbash2 )   /* bootleg */
22782278   DRIVER( truxton2 )   /* TP-024 (c) 1992 Toaplan */
22792279   DRIVER( pipibibs )   /* TP-025 */
2280   DRIVER( pipibibsa )   /* TP-025 */
22802281   DRIVER( whoopee )   /* TP-025 */
22812282   DRIVER( pipibibi )   /* (c) 1991 Ryouta Kikaku (bootleg?) */
22822283   DRIVER( fixeight )   /* TP-026 (c) 1992 + Taito license */
r6740r6741
29132914   DRIVER( pzloop2 )   /* 02/03/2001 (c) 2001 Mitchell (Euro) */
29142915   DRIVER( pzloop2j )   /* 05/02/2001 (c) 2001 Mitchell (Japan) */
29152916   DRIVER( choko )      /* 20/08/2001 (c) 2001 Mitchell (Japan) */
2917   DRIVER( hsf2 )      /* 02/02/2004 (c) 2004 Hyper Street Fighter 2 (USA) */
29162918   DRIVER( hsf2j )      /* 22/12/2003 (c) 2003 Hyper Street Fighter 2 (Japan) */
2917   DRIVER( hsf2 )      /* 02/02/2004 (c) 2004 Hyper Street Fighter 2 (Asia) */
2919   DRIVER( hsf2a )      /* 02/02/2004 (c) 2004 Hyper Street Fighter 2 (Asia) */
29182920
29192921   /* CPS2 'Phoenix' bootlegs */
29202922   DRIVER( ssf2ud )
r6740r6741
50105012   DRIVER( cninja1 )   /* MAG (c) 1991 Data East Corporation (World) */
50115013   DRIVER( cninjau )   /* MAG (c) 1991 Data East Corporation (US) */
50125014   DRIVER( joemac )   /* MAG (c) 1991 Data East Corporation (Japan) */
5015   DRIVER( cninjabl )   /* bootleg */
50135016   DRIVER( stoneage )   /* bootleg */
50145017   DRIVER( robocop2 )   /* MAH (c) 1991 Data East Corporation (World) */
50155018   DRIVER( robocop2u )   /* MAH (c) 1991 Data East Corporation (US) */
r6740r6741
52885291   DRIVER( contrajb )   /* bootleg */
52895292   DRIVER( gryzor )   /* GX633 (c) 1987 */
52905293   DRIVER( gryzora )   /* GX633 (c) 1987 */
5291   DRIVER( combasc )   /* GX611 (c) 1988 */
5292   DRIVER( combasct )   /* GX611 (c) 1987 */
5293   DRIVER( combascj )   /* GX611 (c) 1987 (Japan) */
5294   DRIVER( combatsc )   /* GX611 (c) 1988 */
5295   DRIVER( combatsct )   /* GX611 (c) 1987 */
5296   DRIVER( combatscj )   /* GX611 (c) 1987 (Japan) */
52945297   DRIVER( bootcamp )   /* GX611 (c) 1987 */
5295   DRIVER( combascb )   /* bootleg */
5298   DRIVER( combatscb )   /* bootleg */
52965299   DRIVER( rockrage )   /* GX620 (c) 1986 (World?) */
52975300   DRIVER( rockragea )   /* GX620 (c) 1986 (Prototype?) */
52985301   DRIVER( rockragej )   /* GX620 (c) 1986 (Japan) */
r6740r6741
69166919   /* Midway Zeus games */
69176920   DRIVER( mk4 )      /* (c) 1997 Midway (v3.0) Latest offical release */
69186921   DRIVER( mk4a )      /* (c) 1997 Midway (v2.1) */
6922   DRIVER( mk4b )      /* (c) 1997 Midway (v1.0) */
69196923   DRIVER( invasnab )   /* (c) 1999 Midway (v5.0) Latest offical release */
69206924   DRIVER( invasnv4 )   /* (c) 1999 Midway (v4.0) */
69216925   DRIVER( crusnexo )   /* (c) 1999 Midway (v2.4) Latest offical release */
r6740r6741
71937197   DRIVER( jujub )      /* (c) 1989 Tad (Japan) */
71947198   DRIVER( bloodbro )   /* (c) 1990 Tad */
71957199   DRIVER( bloodbroa )   /* (c) 1990 Tad */
7200   DRIVER( bloodbrob )   /* (c) 1990 Tad */
71967201   DRIVER( weststry )   /* bootleg */
71977202   DRIVER( skysmash )   /* (c) 1990 Nihon System Inc. */
71987203   DRIVER( legionna )   /* (c) 1992 Tad (World) */
r6740r6741
82798284   DRIVER( kovshp )
82808285   DRIVER( oldsplus )
82818286   DRIVER( killbldp )
8287   DRIVER( happy6 )
82828288   DRIVER( svg )
82838289
82848290   /* Spirit Tech. Corp. */
src/mame/includes/nitedrvr.h
r6740r6741
2424WRITE8_HANDLER( nitedrvr_out0_w );
2525WRITE8_HANDLER( nitedrvr_out1_w );
2626
27TIMER_DEVICE_CALLBACK( nitedrvr_crash_toggle_callback );
28
2729MACHINE_RESET( nitedrvr );
2830MACHINE_START( nitedrvr );
2931
src/mame/includes/mitchell.h
r0r6741
1/*************************************************************************
2
3    Mitchell hardware
4
5*************************************************************************/
6
7typedef struct _mitchell_state mitchell_state;
8struct _mitchell_state
9{
10   /* memory pointers */
11   UINT8 *    videoram;
12   UINT8 *    colorram;
13   size_t     videoram_size;
14
15   /* video-related */
16   tilemap    *bg_tilemap;
17   UINT8      *objram;           /* Sprite RAM */
18   int        flipscreen;
19   int        video_bank;
20   int        paletteram_bank;
21
22   /* sound-related */
23   int        sample_buffer;
24   int        sample_select;
25
26   /* misc */
27   UINT8      port5_kludge;
28   int        input_type;
29   int        dial[2], dial_selected;
30   int        dir[2];
31   int        keymatrix;
32
33   /* devices */
34   const device_config *audiocpu;
35   const device_config *oki;
36};
37
38
39/*----------- defined in video/mitchell.c -----------*/
40
41WRITE8_HANDLER( mgakuen_paletteram_w );
42READ8_HANDLER( mgakuen_paletteram_r );
43WRITE8_HANDLER( mgakuen_videoram_w );
44READ8_HANDLER( mgakuen_videoram_r );
45WRITE8_HANDLER( mgakuen_objram_w );
46READ8_HANDLER( mgakuen_objram_r );
47
48WRITE8_HANDLER( pang_video_bank_w );
49WRITE8_HANDLER( pang_videoram_w );
50READ8_HANDLER( pang_videoram_r );
51WRITE8_HANDLER( pang_colorram_w );
52READ8_HANDLER( pang_colorram_r );
53WRITE8_HANDLER( pang_gfxctrl_w );
54WRITE8_HANDLER( pang_paletteram_w );
55READ8_HANDLER( pang_paletteram_r );
56
57WRITE8_HANDLER( mstworld_gfxctrl_w );
58WRITE8_HANDLER( mstworld_video_bank_w );
59
60VIDEO_START( pang );
61VIDEO_UPDATE( pang );
src/mame/includes/jaguar.h
r6740r6741
2929
3030/*----------- defined in audio/jaguar.c -----------*/
3131
32TIMER_DEVICE_CALLBACK( jaguar_serial_callback );
33
3234void jaguar_dsp_suspend(running_machine *machine);
3335void jaguar_dsp_resume(running_machine *machine);
3436
src/mame/includes/fgoal.h
r6740r6741
1414   /* misc */
1515   int        fgoal_player;
1616   UINT8      row, col;
17   unsigned   shift_data, shift_bits;
1817   int        prev_coin;
1918
2019   /* devices */
2120   const device_config *maincpu;
21   const device_config *mb14241;
2222};
2323
2424
src/mame/includes/cvs.h
r6740r6741
22
33    Century CVS System
44
5    (and Quasar)
6
57****************************************************************************/
68
79
8#define CVS_S2636_Y_OFFSET      (3)
9#define CVS_S2636_X_OFFSET      (-26)
10#define CVS_S2636_Y_OFFSET     (3)
11#define CVS_S2636_X_OFFSET     (-26)
12#define CVS_MAX_STARS          250
1013
14struct cvs_star
15{
16   int x, y, code;
17};
1118
19typedef struct _cvs_state cvs_state;
20struct _cvs_state
21{
22   /* memory pointers */
23   UINT8 *    video_ram;
24   UINT8 *    bullet_ram;
25   UINT8 *    fo_state;
26   UINT8 *    cvs_4_bit_dac_data;
27   UINT8 *    tms5110_ctl_data;
28   UINT8 *    dac3_state;
29   UINT8 *    color_ram;
30   UINT8 *    palette_ram;
31   UINT8 *    character_ram;
32   UINT8 *    effectram;   // quasar
33
34   /* video-related */
35   struct cvs_star stars[CVS_MAX_STARS];
36   bitmap_t   *collision_background;
37   bitmap_t   *background_bitmap;
38   bitmap_t   *scrolled_collision_background;
39   int        collision_register;
40   int        total_stars;
41   int        stars_on;
42   UINT8      scroll_reg;
43   UINT8      effectcontrol;   // quasar
44   int        stars_scroll;
45
46   /* misc */
47   emu_timer  *cvs_393hz_timer;
48   UINT8      cvs_393hz_clock;
49
50   UINT8      character_banking_mode;
51   UINT16     character_ram_page_start;
52   UINT16     speech_rom_bit_address;
53
54   UINT8      page, io_page;   // quasar
55
56   /* devices */
57   const device_config *maincpu;
58   const device_config *audiocpu;
59   const device_config *speech;
60   const device_config *dac3;
61   const device_config *tms;
62   const device_config *s2636_0;
63   const device_config *s2636_1;
64   const device_config *s2636_2;
65};
66
1267/*----------- defined in drivers/cvs.c -----------*/
1368
14extern UINT8 *cvs_color_ram;
15extern UINT8 *cvs_video_ram;
16extern UINT8 *cvs_bullet_ram;
17extern UINT8 *cvs_palette_ram;
18extern UINT8 *cvs_fo_state;
19
2069MACHINE_START( cvs );
70MACHINE_RESET( cvs );
2171
2272READ8_HANDLER( cvs_video_or_color_ram_r );
2373WRITE8_HANDLER( cvs_video_or_color_ram_w );
r6740r6741
3282READ8_HANDLER( cvs_s2636_2_or_character_ram_r );
3383WRITE8_HANDLER( cvs_s2636_2_or_character_ram_w );
3484
35UINT8 cvs_get_character_banking_mode(void);
85/*----------- defined in video/cvs.c -----------*/
3686
87WRITE8_HANDLER( cvs_scroll_w );
88WRITE8_HANDLER( cvs_video_fx_w );
3789
38/*----------- defined in video/cvs.c -----------*/
90READ8_HANDLER( cvs_collision_r );
91READ8_HANDLER( cvs_collision_clear );
3992
40extern bitmap_t *cvs_collision_background;
41extern int cvs_collision_register;
93void cvs_scroll_stars(running_machine *machine);
4294
4395PALETTE_INIT( cvs );
4496VIDEO_UPDATE( cvs );
4597VIDEO_START( cvs );
4698
47WRITE8_HANDLER( cvs_scroll_w );
48WRITE8_HANDLER( cvs_video_fx_w );
99/*----------- defined in video/quasar.c -----------*/
49100
50READ8_HANDLER( cvs_collision_r );
51READ8_HANDLER( cvs_collision_clear );
52
53void cvs_scroll_stars(void);
101PALETTE_INIT( quasar );
102VIDEO_UPDATE( quasar );
103VIDEO_START( quasar );
src/mame/includes/mhavoc.h
r6740r6741
1717
1818/*----------- defined in machine/mhavoc.c -----------*/
1919
20TIMER_DEVICE_CALLBACK( mhavoc_cpu_irq_clock );
21
2022WRITE8_HANDLER( mhavoc_alpha_irq_ack_w );
2123WRITE8_HANDLER( mhavoc_gamma_irq_ack_w );
2224
25MACHINE_START( mhavoc );
2326MACHINE_RESET( mhavoc );
2427DRIVER_INIT( mhavocrv );
2528
src/mame/includes/hcastle.h
r0r6741
1/*************************************************************************
2
3    Haunted Castle
4
5*************************************************************************/
6
7typedef struct _hcastle_state hcastle_state;
8struct _hcastle_state
9{
10   /* memory pointers */
11   UINT8 *    pf1_videoram;
12   UINT8 *    pf2_videoram;
13   UINT8 *    paletteram;
14//  UINT8 *    spriteram;
15//  UINT8 *    spriteram2;
16
17   /* video-related */
18   tilemap    *fg_tilemap, *bg_tilemap;
19   int        pf2_bankbase, pf1_bankbase;
20   int        old_pf1, old_pf2;
21   int        gfx_bank;
22
23   /* devices */
24   const device_config *audiocpu;
25   const device_config *k007121_1;
26   const device_config *k007121_2;
27};
28
29
30/*----------- defined in video/hcastle.c -----------*/
31
32WRITE8_HANDLER( hcastle_pf1_video_w );
33WRITE8_HANDLER( hcastle_pf2_video_w );
34READ8_HANDLER( hcastle_gfxbank_r );
35WRITE8_HANDLER( hcastle_gfxbank_w );
36WRITE8_HANDLER( hcastle_pf1_control_w );
37WRITE8_HANDLER( hcastle_pf2_control_w );
38
39PALETTE_INIT( hcastle );
40VIDEO_UPDATE( hcastle );
41VIDEO_START( hcastle );
src/mame/includes/battlnts.h
r0r6741
1/*************************************************************************
2
3    Konami Battlantis Hardware
4
5*************************************************************************/
6
7typedef struct _battlnts_state battlnts_state;
8struct _battlnts_state
9{
10   /* memory pointers */
11//  UINT8 *      paletteram;    // this currently uses generic palette handling
12
13   /* video-related */
14   int spritebank;
15   int layer_colorbase[2];
16
17
18   /* devices */
19   const device_config *audiocpu;
20   const device_config *k007342;
21   const device_config *k007420;
22};
23
24/*----------- defined in video/battlnts.c -----------*/
25
26WRITE8_HANDLER( battlnts_spritebank_w );
27
28VIDEO_UPDATE( battlnts );
29
30void battlnts_tile_callback(running_machine *machine, int layer, int bank, int *code, int *color, int *flags);
31void battlnts_sprite_callback(running_machine *machine, int *code, int *color);
src/mame/includes/labyrunr.h
r0r6741
1/*************************************************************************
2
3    Labyrinth Runner
4
5*************************************************************************/
6
7typedef struct _labyrunr_state labyrunr_state;
8struct _labyrunr_state
9{
10   /* memory pointers */
11   UINT8 *    videoram1;
12   UINT8 *    videoram2;
13   UINT8 *    scrollram;
14   UINT8 *    spriteram;
15   UINT8 *    paletteram;
16
17   /* video-related */
18   tilemap    *layer0, *layer1;
19   rectangle  clip0, clip1;
20
21   /* devices */
22   const device_config *k007121;
23};
24
25
26/*----------- defined in video/labyrunr.c -----------*/
27
28
29WRITE8_HANDLER( labyrunr_vram1_w );
30WRITE8_HANDLER( labyrunr_vram2_w );
31
32PALETTE_INIT( labyrunr );
33VIDEO_START( labyrunr );
34VIDEO_UPDATE( labyrunr );
src/mame/includes/carpolo.h
r6740r6741
1313extern const pia6821_interface carpolo_pia0_intf;
1414extern const pia6821_interface carpolo_pia1_intf;
1515
16void carpolo_74148_3s_cb(const device_config *device);
17
18void carpolo_7474_2s_1_cb(const device_config *device);
19void carpolo_7474_2s_2_cb(const device_config *device);
20void carpolo_7474_2u_1_cb(const device_config *device);
21void carpolo_7474_2u_2_cb(const device_config *device);
22
1623MACHINE_START( carpolo );
1724MACHINE_RESET( carpolo );
1825
src/mame/includes/galaga.h
r6740r6741
7070/*----------- defined in machine/xevious.c -----------*/
7171
7272void battles_customio_init(running_machine *machine);
73TIMER_DEVICE_CALLBACK( battles_nmi_generate );
7374
7475READ8_HANDLER( battles_customio0_r );
7576READ8_HANDLER( battles_customio_data0_r );
src/mame/includes/flkatck.h
r0r6741
1/*************************************************************************
2
3    Flak Attack / MX5000
4
5*************************************************************************/
6
7typedef struct _flkatck_state flkatck_state;
8struct _flkatck_state
9{
10   /* memory pointers */
11   UINT8 *    k007121_ram;
12//  UINT8 *    paletteram;  // this currently uses generic palette handling
13
14   /* video-related */
15   tilemap    *k007121_tilemap[2];
16   int        flipscreen;
17
18   /* misc */
19   int        irq_enabled;
20   int        multiply_reg[2];
21
22   /* devices */
23   const device_config *audiocpu;
24   const device_config *k007121;
25};
26
27
28//static rectangle k007121_clip[2];
29
30
31/*----------- defined in video/flkatck.c -----------*/
32
33WRITE8_HANDLER( flkatck_k007121_w );
34WRITE8_HANDLER( flkatck_k007121_regs_w );
35
36VIDEO_START( flkatck );
37VIDEO_UPDATE( flkatck );
src/mame/includes/contra.h
r0r6741
1/*************************************************************************
2
3    Contra / Gryzor
4
5*************************************************************************/
6
7typedef struct _contra_state contra_state;
8struct _contra_state
9{
10   /* memory pointers */
11   UINT8 *        spriteram;
12   UINT8 *        spriteram_2;
13   UINT8 *        paletteram;
14   UINT8 *        bg_vram;
15   UINT8 *        bg_cram;
16   UINT8 *        fg_vram;
17   UINT8 *        fg_cram;
18   UINT8 *        tx_vram;
19   UINT8 *        tx_cram;
20   // this driver also uses a large generic spriteram region...
21
22   /* video-related */
23   tilemap *bg_tilemap, *fg_tilemap, *tx_tilemap;
24   rectangle bg_clip, fg_clip, tx_clip;
25
26   /* devices */
27   const device_config *audiocpu;
28   const device_config *k007121_1;
29   const device_config *k007121_2;
30};
31
32
33/*----------- defined in video/contra.c -----------*/
34
35PALETTE_INIT( contra );
36
37WRITE8_HANDLER( contra_fg_vram_w );
38WRITE8_HANDLER( contra_fg_cram_w );
39WRITE8_HANDLER( contra_bg_vram_w );
40WRITE8_HANDLER( contra_bg_cram_w );
41WRITE8_HANDLER( contra_text_vram_w );
42WRITE8_HANDLER( contra_text_cram_w );
43
44WRITE8_HANDLER( contra_K007121_ctrl_0_w );
45WRITE8_HANDLER( contra_K007121_ctrl_1_w );
46
47VIDEO_UPDATE( contra );
48VIDEO_START( contra );
src/mame/includes/balsente.h
r6740r6741
1818#define BALSENTE_VBSTART      (0x100)
1919
2020
21#define POLY17_BITS 17
22#define POLY17_SIZE ((1 << POLY17_BITS) - 1)
23#define POLY17_SHL   7
24#define POLY17_SHR   10
25#define POLY17_ADD   0x18000
26
27
28typedef struct _balsente_state balsente_state;
29struct _balsente_state
30{
31   /* global data */
32   UINT8 shooter;
33   UINT8 shooter_x;
34   UINT8 shooter_y;
35   UINT8 adc_shift;
36   UINT16 *shrike_shared;
37   UINT16 *shrike_io;
38
39   /* 8253 counter state */
40   struct
41   {
42      const device_config *timer;
43      UINT8 timer_active;
44      INT32 initial;
45      INT32 count;
46      UINT8 gate;
47      UINT8 out;
48      UINT8 mode;
49      UINT8 readbyte;
50      UINT8 writebyte;
51   } counter[3];
52
53   const device_config *scanline_timer;
54
55   /* manually clocked counter 0 states */
56   UINT8 counter_control;
57   UINT8 counter_0_ff;
58   const device_config *counter_0_timer;
59   UINT8 counter_0_timer_active;
60
61   /* random number generator states */
62   UINT8 poly17[POLY17_SIZE + 1];
63   UINT8 rand17[POLY17_SIZE + 1];
64
65   /* ADC I/O states */
66   INT8 analog_input_data[4];
67   UINT8 adc_value;
68
69   /* CEM3394 DAC control states */
70   UINT16 dac_value;
71   UINT8 dac_register;
72   UINT8 chip_select;
73
74   /* main CPU 6850 states */
75   UINT8 m6850_status;
76   UINT8 m6850_control;
77   UINT8 m6850_input;
78   UINT8 m6850_output;
79   UINT8 m6850_data_ready;
80
81   /* sound CPU 6850 states */
82   UINT8 m6850_sound_status;
83   UINT8 m6850_sound_control;
84   UINT8 m6850_sound_input;
85   UINT8 m6850_sound_output;
86
87   /* noise generator states */
88   UINT32 noise_position[6];
89   const device_config *cem_device[6];
90
91   /* game-specific states */
92   UINT8 nstocker_bits;
93   UINT8 spiker_expand_color;
94   UINT8 spiker_expand_bgcolor;
95   UINT8 spiker_expand_bits;
96   UINT8 grudge_steering_result;
97   UINT8 grudge_last_steering[3];
98
99   /* video data */
100   UINT8 videoram[256 * 256];
101   UINT8 *sprite_data;
102   UINT32 sprite_mask;
103   UINT8 *sprite_bank[2];
104
105   UINT8 palettebank_vis;
106};
107
108
21109/*----------- defined in machine/balsente.c -----------*/
22110
23extern UINT8 balsente_shooter;
24extern UINT8 balsente_adc_shift;
25extern UINT16 *shrike_shared;
26extern UINT16 *shrike_io;
111TIMER_DEVICE_CALLBACK( balsente_interrupt_timer );
27112
113MACHINE_START( balsente );
28114MACHINE_RESET( balsente );
29115
30116void balsente_noise_gen(const device_config *device, int count, short *buffer);
r6740r6741
47133READ8_HANDLER( balsente_adc_data_r );
48134WRITE8_HANDLER( balsente_adc_select_w );
49135
136TIMER_DEVICE_CALLBACK( balsente_counter_callback );
137
50138READ8_HANDLER( balsente_counter_8253_r );
51139WRITE8_HANDLER( balsente_counter_8253_w );
52140
141TIMER_DEVICE_CALLBACK( balsente_clock_counter_0_ff );
142
53143READ8_HANDLER( balsente_counter_state_r );
54144WRITE8_HANDLER( balsente_counter_control_w );
55145
r6740r6741
68158READ16_HANDLER( shrike_io_68k_r );
69159WRITE16_HANDLER( shrike_io_68k_w );
70160
161
71162/*----------- defined in video/balsente.c -----------*/
72163
73164VIDEO_START( balsente );
src/mame/includes/psikyo4.h
r0r6741
1/*************************************************************************
2
3    Psikyo PS6807 (PS4)
4
5*************************************************************************/
6
7#define MASTER_CLOCK 57272700   // main oscillator frequency
8
9
10typedef struct _psikyo4_state psikyo4_state;
11struct _psikyo4_state
12{
13   /* memory pointers */
14   UINT32 *       vidregs;
15   UINT32 *       paletteram;
16   UINT32 *       ram;
17   UINT32 *       io_select;
18   UINT32 *       bgpen_1;
19   UINT32 *       bgpen_2;
20   UINT32 *       spriteram;
21   size_t         spriteram_size;
22
23   /* video-related */
24   double         oldbrt1, oldbrt2;
25
26   /* misc */
27   UINT32         sample_offs;   // only used if ROMTEST = 1
28
29   /* devices */
30   const device_config *maincpu;
31};
32
33
34/*----------- defined in video/psikyo4.c -----------*/
35
36VIDEO_START( psikyo4 );
37VIDEO_UPDATE( psikyo4 );
src/mame/includes/djboy.h
r0r6741
1/*************************************************************************
2
3    DJ Boy
4
5*************************************************************************/
6
7#define PROT_OUTPUT_BUFFER_SIZE 8
8
9typedef struct _djboy_state djboy_state;
10struct _djboy_state
11{
12   /* memory pointers */
13   UINT8 *    videoram;
14   UINT8 *    paletteram;
15
16   /* video-related */
17   tilemap    *background;
18   UINT8      videoreg, scrollx, scrolly;
19
20   /* Kaneko BEAST state */
21   int        prot_busy_count;
22   UINT8      prot_output_buffer[PROT_OUTPUT_BUFFER_SIZE];
23   int        prot_available_data_count;
24   int        prot_offs;       /* internal state */
25   UINT8      prot_ram[0x80];    /* internal RAM */
26   UINT8      prot_param[8];
27   int        coin;
28   int        complete;
29   int        lives[2];
30   int        addr;
31   int        bankxor;
32   int        mDjBoyState;
33   int        prot_mode;
34
35   /* devices */
36   const device_config *maincpu;
37   const device_config *cpu1;
38   const device_config *cpu2;
39   const device_config *pandora;
40};
41
42
43// mDjBoyState
44enum
45{
46   eDJBOY_ATTRACT_HIGHSCORE = 0,
47   eDJBOY_ATTRACT_TITLE,
48   eDJBOY_ATTRACT_GAMEPLAY,
49   eDJBOY_PRESS_P1_START,
50   eDJBOY_PRESS_P1_OR_P2_START,
51   eDJBOY_ACTIVE_GAMEPLAY
52};
53
54// prot_mode
55enum
56{
57   ePROT_NORMAL = 0,
58   ePROT_WRITE_BYTES,
59   ePROT_WRITE_BYTE,
60   ePROT_READ_BYTES,
61   ePROT_WAIT_DSW1_WRITEBACK,
62   ePROT_WAIT_DSW2_WRITEBACK,
63   ePROT_STORE_PARAM
64};
65
66/*----------- defined in video/djboy.c -----------*/
67
68WRITE8_HANDLER( djboy_scrollx_w );
69WRITE8_HANDLER( djboy_scrolly_w );
70WRITE8_HANDLER( djboy_videoram_w );
71WRITE8_HANDLER( djboy_paletteram_w );
72
73VIDEO_START( djboy );
74VIDEO_UPDATE( djboy );
75VIDEO_EOF( djboy );
src/mame/includes/malzak.h
r0r6741
1/*************************************************************************
2
3    Malzak
4
5*************************************************************************/
6
7
8typedef struct _malzak_state malzak_state;
9struct _malzak_state
10{
11   /* misc */
12//  int playfield_x[256];
13//  int playfield_y[256];
14   int playfield_code[256];
15   int malzak_x;
16   int malzak_y;
17   int collision_counter;
18
19   /* devices */
20   const device_config *s2636_0;
21   const device_config *s2636_1;
22   const device_config *saa5050;
23};
24
25
26/*----------- defined in video/malzak.c -----------*/
27
28WRITE8_HANDLER( malzak_playfield_w );
29
30VIDEO_UPDATE( malzak );
src/mame/includes/vertigo.h
r6740r6741
66
77/*----------- defined in machine/vertigo.c -----------*/
88
9void vertigo_update_irq(const device_config *device);
10
911extern const struct pit8253_config vertigo_pit8254_config;
1012
1113READ16_HANDLER( vertigo_io_convert );
r6740r6741
1719WRITE16_HANDLER( vertigo_wsot_w );
1820
1921INTERRUPT_GEN( vertigo_interrupt );
22MACHINE_START( vertigo );
2023MACHINE_RESET( vertigo );
2124
2225/*----------- defined in video/vertigo.c -----------*/
r6740r6741
2427extern UINT16 *vertigo_vectorram;
2528
2629void vertigo_vproc_init(running_machine *machine);
30void vertigo_vproc_reset(running_machine *machine);
2731void vertigo_vproc(int cycles, int irq4);
2832
src/mame/includes/f1gp.h
r6740r6741
1/*----------- defined in video/f1gp.c -----------*/
21
3extern UINT16 *f1gp_spr1vram,*f1gp_spr2vram,*f1gp_spr1cgram,*f1gp_spr2cgram;
4extern UINT16 *f1gp_fgvideoram,*f1gp_rozvideoram;
5extern UINT16 *f1gp2_sprcgram,*f1gp2_spritelist;
6extern UINT16 *f1gpb_rozregs, *f1gpb_fgregs;
7extern size_t f1gp_spr1cgram_size,f1gp_spr2cgram_size;
2typedef struct _f1gp_state f1gp_state;
3struct _f1gp_state
4{
5   /* memory pointers */
6   UINT16 *  sharedram;
7   UINT16 *  spr1vram;
8   UINT16 *  spr2vram;
9   UINT16 *  spr1cgram;
10   UINT16 *  spr2cgram;
11   UINT16 *  fgvideoram;
12   UINT16 *  rozvideoram;
13   UINT16 *  sprcgram;
14   UINT16 *  spritelist;
15   UINT16 *  spriteram;
16   UINT16 *  fgregs;
17   UINT16 *  rozregs;
18   UINT16 *  zoomdata;
19//      UINT16 *  paletteram;    // currently this uses generic palette handling
20   size_t    spr1cgram_size, spr2cgram_size;
21   size_t    spriteram_size;
822
23   /* video-related */
24   tilemap   *fg_tilemap, *roz_tilemap;
25   int       roz_bank, flipscreen, gfxctrl;
26   int       scroll[2];
927
10VIDEO_START( f1gp );
11VIDEO_START( f1gpb );
12VIDEO_START( f1gp2 );
13VIDEO_UPDATE( f1gp );
14VIDEO_UPDATE( f1gpb );
15VIDEO_UPDATE( f1gp2 );
28   /* misc */
29   int       pending_command;
1630
31   /* devices */
32   const device_config *audiocpu;
33   const device_config *k053936;
34};
35
36/*----------- defined in video/f1gp.c -----------*/
37
1738READ16_HANDLER( f1gp_zoomdata_r );
1839WRITE16_HANDLER( f1gp_zoomdata_w );
1940READ16_HANDLER( f1gp_rozvideoram_r );
r6740r6741
2243WRITE16_HANDLER( f1gp_fgscroll_w );
2344WRITE16_HANDLER( f1gp_gfxctrl_w );
2445WRITE16_HANDLER( f1gp2_gfxctrl_w );
46
47VIDEO_START( f1gp );
48VIDEO_START( f1gpb );
49VIDEO_START( f1gp2 );
50VIDEO_UPDATE( f1gp );
51VIDEO_UPDATE( f1gpb );
52VIDEO_UPDATE( f1gp2 );
src/mame/includes/snk6502.h
r6740r6741
4141
4242/*----------- defined in video/snk6502.c -----------*/
4343
44extern UINT8 *snk6502_videoram;
45extern UINT8 *snk6502_colorram;
4446extern UINT8 *snk6502_videoram2;
4547extern UINT8 *snk6502_charram;
4648
src/mame/includes/foodf.h
r6740r6741
1616   double         bweights[2];
1717   UINT8          playfield_flip;
1818
19   emu_timer *      scanline_timer;
2019   UINT8          whichport;
2120};
2221
src/mame/includes/harddriv.h
r6740r6741
7777   UINT8                duart_read_data[16];
7878   UINT8                duart_write_data[16];
7979   UINT8                duart_output_port;
80   emu_timer *            duart_timer;
80   const device_config *   duart_timer;
8181
8282   UINT8                last_gsp_shiftreg;
8383
r6740r6741
193193READ16_HANDLER( hd68k_zram_r );
194194WRITE16_HANDLER( hd68k_zram_w );
195195
196TIMER_DEVICE_CALLBACK( hd68k_duart_callback );
196197READ16_HANDLER( hd68k_duart_r );
197198WRITE16_HANDLER( hd68k_duart_w );
198199
src/mame/includes/88games.h
r0r6741
1/*************************************************************************
2
3    88 Games
4
5*************************************************************************/
6
7typedef struct __88games_state _88games_state;
8struct __88games_state
9{
10   /* memory pointers */
11   UINT8 *      ram;
12   UINT8 *      banked_rom;
13//  UINT8 *      paletteram_1000;   // this currently uses generic palette handling
14//  UINT8 *      nvram; // this currently uses generic nvram handling
15
16   /* video-related */
17   int          k88games_priority;
18   int          layer_colorbase[3], sprite_colorbase, zoom_colorbase;
19   int          videobank;
20   int          zoomreadroms;
21   int          speech_chip;
22
23   /* devices */
24   const device_config *audiocpu;
25   const device_config *k052109;
26   const device_config *k051960;
27   const device_config *k051316;
28   const device_config *upd_1;
29   const device_config *upd_2;
30};
31
32
33/*----------- defined in video/88games.c -----------*/
34
35void _88games_sprite_callback(running_machine *machine, int *code, int *color, int *priority, int *shadow);
36void _88games_tile_callback(running_machine *machine, int layer, int bank, int *code, int *color, int *flags, int *priority);
37void _88games_zoom_callback(running_machine *machine, int *code, int *color, int *flags);
38
39VIDEO_UPDATE( 88games );
src/mame/includes/bladestl.h
r0r6741
1/*************************************************************************
2
3    Blades of Steel
4
5*************************************************************************/
6
7typedef struct _bladestl_state bladestl_state;
8struct _bladestl_state
9{
10   /* memory pointers */
11   UINT8 *    paletteram;
12
13   /* video-related */
14   int        spritebank;
15   int        layer_colorbase[2];
16
17   /* misc */
18   int        last_track[4];
19
20   /* devices */
21   const device_config *audiocpu;
22   const device_config *k007342;
23   const device_config *k007420;
24};
25
26
27
28/*----------- defined in video/bladestl.c -----------*/
29
30PALETTE_INIT( bladestl );
31
32VIDEO_UPDATE( bladestl );
33
34void bladestl_tile_callback(running_machine *machine, int layer, int bank, int *code, int *color, int *flags);
35void bladestl_sprite_callback(running_machine *machine, int *code, int *color);
src/mame/includes/xmen.h
r6740r6741
99
1010/*----------- defined in video/xmen.c -----------*/
1111
12VIDEO_START( xmen );
12void xmen_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
13void xmen_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask);
14
1315VIDEO_START( xmen6p );
1416VIDEO_UPDATE( xmen );
1517VIDEO_UPDATE( xmen6p );
src/mame/includes/simpsons.h
r6740r6741
22
33extern int simpsons_firq_enabled;
44
5READ8_HANDLER( simpsons_eeprom_r );
65WRITE8_HANDLER( simpsons_eeprom_w );
76WRITE8_HANDLER( simpsons_coin_counter_w );
87READ8_HANDLER( simpsons_sound_interrupt_r );
98READ8_DEVICE_HANDLER( simpsons_sound_r );
109MACHINE_RESET( simpsons );
11NVRAM_HANDLER( simpsons );
1210
1311/*----------- defined in video/simpsons.c -----------*/
1412
1513extern UINT8 *simpsons_xtraram;
1614
1715void simpsons_video_banking( running_machine *machine, int select );
18VIDEO_START( simpsons );
1916VIDEO_UPDATE( simpsons );
17
18extern void simpsons_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
19extern void simpsons_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask);
src/mame/includes/model1.h
r6740r6741
1919
2020ADDRESS_MAP_EXTERN( model1_vr_tgp_map, 32 );
2121
22MACHINE_START( model1 );
23
2224void model1_vr_tgp_reset( running_machine *machine );
2325void model1_tgp_reset(running_machine *machine, int swa);
2426
src/mame/includes/mw8080bw.h
r6740r6741
44
55****************************************************************************/
66
7#include "sound/discrete.h"
8#include "sound/sn76477.h"
9#include "sound/samples.h"
710
8#define MW8080BW_MASTER_CLOCK            (19968000)
9#define MW8080BW_CPU_CLOCK               (MW8080BW_MASTER_CLOCK / 10)
10#define MW8080BW_PIXEL_CLOCK            (MW8080BW_MASTER_CLOCK / 4)
11#define MW8080BW_HTOTAL                  (0x140)
12#define MW8080BW_HBEND                  (0x000)
13#define MW8080BW_HBSTART               (0x100)
14#define MW8080BW_VTOTAL                  (0x106)
15#define MW8080BW_VBEND                  (0x000)
16#define MW8080BW_VBSTART               (0x0e0)
17#define MW8080BW_VCOUNTER_START_NO_VBLANK   (0x020)
18#define MW8080BW_VCOUNTER_START_VBLANK      (0x0da)
19#define MW8080BW_INT_TRIGGER_COUNT_1      (0x080)
20#define MW8080BW_INT_TRIGGER_VBLANK_1      (0)
21#define MW8080BW_INT_TRIGGER_COUNT_2      MW8080BW_VCOUNTER_START_VBLANK
22#define MW8080BW_INT_TRIGGER_VBLANK_2      (1)
2311
12#define MW8080BW_MASTER_CLOCK             (19968000)
13#define MW8080BW_CPU_CLOCK                (MW8080BW_MASTER_CLOCK / 10)
14#define MW8080BW_PIXEL_CLOCK              (MW8080BW_MASTER_CLOCK / 4)
15#define MW8080BW_HTOTAL                   (0x140)
16#define MW8080BW_HBEND                    (0x000)
17#define MW8080BW_HBSTART                  (0x100)
18#define MW8080BW_VTOTAL                   (0x106)
19#define MW8080BW_VBEND                    (0x000)
20#define MW8080BW_VBSTART                  (0x0e0)
21#define MW8080BW_VCOUNTER_START_NO_VBLANK (0x020)
22#define MW8080BW_VCOUNTER_START_VBLANK    (0x0da)
23#define MW8080BW_INT_TRIGGER_COUNT_1      (0x080)
24#define MW8080BW_INT_TRIGGER_VBLANK_1     (0)
25#define MW8080BW_INT_TRIGGER_COUNT_2      MW8080BW_VCOUNTER_START_VBLANK
26#define MW8080BW_INT_TRIGGER_VBLANK_2     (1)
27
2428/* +4 is added to HBSTART because the hardware displays that many pixels after
2529   setting HBLANK */
26#define MW8080BW_HPIXCOUNT      (MW8080BW_HBSTART + 4)
30#define MW8080BW_HPIXCOUNT                (MW8080BW_HBSTART + 4)
2731
2832
33typedef struct _mw8080bw_state mw8080bw_state;
34struct _mw8080bw_state
35{
36   /* memory pointers */
37   UINT8 *     main_ram;
38   UINT8 *     colorram;
39   size_t      main_ram_size;
40
41   /* sound-related */
42   UINT8       port_1_last;
43   UINT8       port_2_last;
44   UINT8       port_1_last_extra;
45   UINT8       port_2_last_extra;
46   UINT8       port_3_last_extra;
47
48   /* misc game specific */
49   emu_timer   *schaser_effect_555_timer;
50   attotime    schaser_effect_555_time_remain;
51   INT32       schaser_effect_555_time_remain_savable;
52   int         schaser_effect_555_is_low;
53   int         schaser_explosion;
54   int         schaser_last_effect;
55   UINT8       sfl_int;
56   UINT8       polaris_cloud_speed;
57   UINT8       polaris_cloud_pos;
58   UINT8       schaser_background_disable;
59   UINT8       schaser_background_select;
60   UINT8       c8080bw_flip_screen;
61   UINT8       color_map;
62   UINT8       screen_red;
63
64
65   UINT16      phantom2_cloud_counter;
66   UINT8       invaders_flip_screen;
67   UINT8       rev_shift_res;
68   UINT8       maze_tone_timing_state;   /* output of IC C1, pin 5 */
69   UINT8       desertgun_controller_select;
70   UINT8       clowns_controller_select;
71
72   UINT8       spcenctr_strobe_state;
73   UINT8       spcenctr_trench_width;
74   UINT8       spcenctr_trench_center;
75   UINT8       spcenctr_trench_slope[16];  /* 16x4 bit RAM */
76
77   /* timer */
78   emu_timer   *interrupt_timer;
79
80   /* devices */
81   const device_config *maincpu;
82   const device_config *mb14241;
83   const device_config *samples;
84   const device_config *samples1;
85   const device_config *samples2;
86   const device_config *speaker;
87   const device_config *sn1;
88   const device_config *sn2;
89   const device_config *sn;
90   const device_config *discrete;
91};
92
93
2994/*----------- defined in drivers/mw8080bw.c -----------*/
3095
31extern UINT8 *mw8080bw_ram;
32extern size_t mw8080bw_ram_size;
33
3496MACHINE_DRIVER_EXTERN( mw8080bw_root );
3597MACHINE_DRIVER_EXTERN( invaders );
3698extern const char layout_invaders[];
r6740r6741
44106
45107#define DESERTGU_GUN_X_PORT_TAG         ("GUNX")
46108#define DESERTGU_GUN_Y_PORT_TAG         ("GUNY")
47void desertgun_set_controller_select(UINT8 data);
48109
49void clowns_set_controller_select(UINT8 data);
50
51void spcenctr_set_strobe_state(UINT8 data);
52UINT8 spcenctr_get_trench_width(void);
53UINT8 spcenctr_get_trench_center(void);
54UINT8 spcenctr_get_trench_slope(UINT8 addr);
55
56UINT16 phantom2_get_cloud_counter(void);
57void phantom2_set_cloud_counter(UINT16 data);
58
59110#define INVADERS_CAB_TYPE_PORT_TAG      ("CAB")
60111#define INVADERS_P1_CONTROL_PORT_TAG   ("CONTP1")
61112#define INVADERS_P2_CONTROL_PORT_TAG   ("CONTP2")
62113
114/* for games in 8080bw.c */
115#define CABINET_PORT_TAG                  "CAB"
116
117
63118CUSTOM_INPUT( invaders_in1_control_r );
64119CUSTOM_INPUT( invaders_in2_control_r );
65UINT8 invaders_is_flip_screen(void);
66void invaders_set_flip_screen(UINT8 data);
120
67121int invaders_is_cabinet_cocktail(running_machine *machine);
68122
69123#define BLUESHRK_SPEAR_PORT_TAG         ("IN0")
r6740r6741
184238WRITE8_DEVICE_HANDLER( invad2ct_audio_3_w );
185239WRITE8_DEVICE_HANDLER( invad2ct_audio_4_w );
186240
241/*----------- defined in audio/8080bw.c -----------*/
187242
243MACHINE_START( extra_8080bw_sh );
188244
245WRITE8_HANDLER( invadpt2_sh_port_1_w );
246WRITE8_HANDLER( invadpt2_sh_port_2_w );
247
248WRITE8_HANDLER( spcewars_sh_port_w );
249
250WRITE8_HANDLER( lrescue_sh_port_1_w );
251WRITE8_HANDLER( lrescue_sh_port_2_w );
252extern const samples_interface lrescue_samples_interface;
253
254WRITE8_HANDLER( cosmo_sh_port_2_w );
255
256WRITE8_HANDLER( ballbomb_sh_port_1_w );
257WRITE8_HANDLER( ballbomb_sh_port_2_w );
258
259WRITE8_HANDLER( indianbt_sh_port_1_w );
260WRITE8_HANDLER( indianbt_sh_port_2_w );
261WRITE8_DEVICE_HANDLER( indianbt_sh_port_3_w );
262DISCRETE_SOUND_EXTERN( indianbt );
263
264WRITE8_DEVICE_HANDLER( polaris_sh_port_1_w );
265WRITE8_DEVICE_HANDLER( polaris_sh_port_2_w );
266WRITE8_DEVICE_HANDLER( polaris_sh_port_3_w );
267DISCRETE_SOUND_EXTERN( polaris );
268
269MACHINE_RESET( schaser_sh );
270MACHINE_START( schaser_sh );
271WRITE8_HANDLER( schaser_sh_port_1_w );
272WRITE8_HANDLER( schaser_sh_port_2_w );
273extern const sn76477_interface schaser_sn76477_interface;
274DISCRETE_SOUND_EXTERN( schaser );
275
276WRITE8_HANDLER( rollingc_sh_port_w );
277
278WRITE8_HANDLER( invrvnge_sh_port_w );
279
280WRITE8_HANDLER( lupin3_sh_port_1_w );
281WRITE8_HANDLER( lupin3_sh_port_2_w );
282
283WRITE8_HANDLER( schasrcv_sh_port_1_w );
284WRITE8_HANDLER( schasrcv_sh_port_2_w );
285
286WRITE8_HANDLER( yosakdon_sh_port_1_w );
287WRITE8_HANDLER( yosakdon_sh_port_2_w );
288
289WRITE8_HANDLER( shuttlei_sh_port_1_w );
290WRITE8_HANDLER( shuttlei_sh_port_2_w );
291
292
189293/*----------- defined in video/mw8080bw.c -----------*/
190294
191295VIDEO_UPDATE( mw8080bw );
r6740r6741
196300VIDEO_EOF( phantom2 );
197301
198302VIDEO_UPDATE( invaders );
303
304
305/*----------- defined in video/8080bw.c -----------*/
306
307MACHINE_START( extra_8080bw_vh );
308
309VIDEO_UPDATE( invadpt2 );
310VIDEO_UPDATE( ballbomb );
311VIDEO_UPDATE( schaser );
312VIDEO_UPDATE( schasrcv );
313VIDEO_UPDATE( rollingc );
314VIDEO_UPDATE( polaris );
315VIDEO_UPDATE( lupin3 );
316VIDEO_UPDATE( cosmo );
317VIDEO_UPDATE( indianbt );
318VIDEO_UPDATE( shuttlei );
319VIDEO_UPDATE( sflush );
320
src/mame/includes/cps1.h
r6740r6741
11#ifndef _CPS1_H_
22#define _CPS1_H_
33
4struct gfx_range
5{
6   // start and end are as passed by the game (shift adjusted to be all
7   // in the same scale a 8x8 tiles): they don't necessarily match the
8   // position in ROM.
9   int type;
10   int start;
11   int end;
12   int bank;
13};
14
15struct CPS1config
16{
17   const char *name;             /* game driver name */
18
19   /* Some games interrogate a couple of registers on bootup. */
20   /* These are CPS1 board B self test checks. They wander from game to */
21   /* game. */
22   int cpsb_addr;        /* CPS board B test register address */
23   int cpsb_value;       /* CPS board B test register expected value */
24
25   /* some games use as a protection check the ability to do 16-bit multiplies */
26   /* with a 32-bit result, by writing the factors to two ports and reading the */
27   /* result from two other ports. */
28   /* It looks like this feature was introduced with 3wonders (CPSB ID = 08xx) */
29   int mult_factor1;
30   int mult_factor2;
31   int mult_result_lo;
32   int mult_result_hi;
33
34   /* unknown registers which might be related to the multiply protection */
35   int unknown1;
36   int unknown2;
37   int unknown3;
38
39   int layer_control;
40   int priority[4];
41   int palette_control;
42
43   /* ideally, the layer enable masks should consist of only one bit, */
44   /* but in many cases it is unknown which bit is which. */
45   int layer_enable_mask[5];
46
47   /* these depend on the B-board model and PAL */
48   int bank_sizes[4];
49   const struct gfx_range *bank_mapper;
50
51   /* some C-boards have additional I/O for extra buttons/extra players */
52   int in2_addr;
53   int in3_addr;
54   int out2_addr;
55
56   int bootleg_kludge;
57};
58
59
60typedef struct _cps_state cps_state;
61struct _cps_state
62{
63   /* memory pointers */
64   // cps1
65   UINT16 *     gfxram;
66   UINT16 *     cps_a_regs;
67   UINT16 *     cps_b_regs;
68   UINT16 *     scroll1;
69   UINT16 *     scroll2;
70   UINT16 *     scroll3;
71   UINT16 *     obj;
72   UINT16 *     other;
73   UINT16 *     buffered_obj;
74   UINT8  *     qsound_sharedram1;
75   UINT8  *     qsound_sharedram2;
76   size_t       gfxram_size;
77   // cps2
78   UINT16 *     objram1;
79   UINT16 *     objram2;
80   UINT16 *     output;
81   UINT16 *     cps2_buffered_obj;
82   size_t       output_size;
83   // game-specific
84   UINT16 *     gigamn2_dummyqsound_ram;
85
86   /* video-related */
87   tilemap      *bg_tilemap[3];
88   int          scanline1;
89   int          scanline2;
90   int          scancalls;
91   int          scancount;
92
93   int          scroll1x, scroll1y;
94   int          scroll2x, scroll2y;
95   int          scroll3x, scroll3y;
96
97   int          stars_enabled[2];      /* Layer enabled [Y/N] */
98   int          stars1x, stars1y, stars2x, stars2y;
99   int          last_sprite_offset;      /* Offset of the last sprite */
100   int          cps2_last_sprite_offset;   /* Offset of the last sprite */
101   int          pri_ctrl;            /* Sprite layer priorities */
102   int          objram_bank;
103
104   /* misc */
105   int          dial[2];      // forgottn
106   int          readpaddle;   // pzloop2
107   int          cps2networkpresent;
108
109   /* fcrash sound hw */
110   int          sample_buffer1, sample_buffer2;
111   int          sample_select1, sample_select2;
112
113   /* video config (never changed after VIDEO_START) */
114   const struct CPS1config *game_config;
115   int          scroll_size;
116   int          obj_size;
117   int          cps2_obj_size;
118   int          other_size;
119   int          palette_align;
120   int          palette_size;
121   int          stars_rom_size;
122   UINT8        empty_tile8x8[8*8];
123   UINT8        empty_tile[32*32/2];
124   int          cps_version;
125
126   /* devices */
127   const device_config *maincpu;
128   const device_config *audiocpu;
129   const device_config *msm_1;   // fcrash
130   const device_config *msm_2;   // fcrash
131};
132
4133/*----------- defined in drivers/cps1.c -----------*/
5134
6ADDRESS_MAP_EXTERN(qsound_sub_map, 8);
135ADDRESS_MAP_EXTERN( qsound_sub_map, 8 );
7136
8137READ16_HANDLER( qsound_sharedram1_r );
9138WRITE16_HANDLER( qsound_sharedram1_w );
r6740r6741
15144GFXDECODE_EXTERN( cps1 );
16145
17146
147/*----------- defined in video/cps1.c -----------*/
148
149WRITE16_HANDLER( cps1_cps_a_w );
150WRITE16_HANDLER( cps1_cps_b_w );
151READ16_HANDLER( cps1_cps_b_r );
152WRITE16_HANDLER( cps1_gfxram_w );
153
154DRIVER_INIT( cps1 );
155DRIVER_INIT( cps2_video );
156
157WRITE16_HANDLER( cps2_objram_bank_w );
158READ16_HANDLER( cps2_objram1_r );
159READ16_HANDLER( cps2_objram2_r );
160WRITE16_HANDLER( cps2_objram1_w );
161WRITE16_HANDLER( cps2_objram2_w );
162
163VIDEO_START( cps1 );
164VIDEO_START( cps2 );
165VIDEO_UPDATE( cps1 );
166VIDEO_EOF( cps1 );
167
168void cps1_get_video_base(running_machine *machine);
169void cps2_set_sprite_priorities(running_machine *machine);
170void cps2_objram_latch(running_machine *machine);
171
172
173/*************************************
174 *  Encryption
175 *************************************/
176
18177/*----------- defined in machine/cps2crpt.c -----------*/
19178
20179DRIVER_INIT( cps2crpt );
r6740r6741
39198void punisher_decode(running_machine *machine);
40199void slammast_decode(running_machine *machine);
41200
42
43/*----------- defined in video/cps1.c -----------*/
44
45extern int cps1_scanline1;
46extern int cps1_scanline2;
47extern int cps1_scancalls;
48
49extern UINT16 *cps1_gfxram;     /* Video RAM */
50extern UINT16 *cps1_cps_a_regs;
51extern UINT16 *cps1_cps_b_regs;
52extern size_t cps1_gfxram_size;
53
54extern UINT16 *cps1_other;
55extern tilemap *cps1_bg_tilemap[3];
56
57extern int cps1_scroll1x, cps1_scroll1y;
58extern int cps1_scroll2x, cps1_scroll2y;
59extern int cps1_scroll3x, cps1_scroll3y;
60
61extern UINT16 *cps2_objram1,*cps2_objram2;
62extern UINT16 *cps2_output;
63extern size_t cps2_output_size;
64
65WRITE16_HANDLER( cps1_cps_a_w );
66WRITE16_HANDLER( cps1_cps_b_w );
67READ16_HANDLER( cps1_cps_b_r );
68
69DRIVER_INIT( cps1 );
70DRIVER_INIT( cps2_video );
71
72void cps1_get_video_base(void);
73
74WRITE16_HANDLER( cps1_gfxram_w );
75
76VIDEO_START( cps1 );
77VIDEO_START( cps2 );
78
79WRITE16_HANDLER( cps2_objram_bank_w );
80READ16_HANDLER( cps2_objram1_r );
81READ16_HANDLER( cps2_objram2_r );
82WRITE16_HANDLER( cps2_objram1_w );
83WRITE16_HANDLER( cps2_objram2_w );
84
85VIDEO_UPDATE( cps1 );
86VIDEO_EOF( cps1 );
87
88void cps2_set_sprite_priorities(void);
89void cps2_objram_latch(void);
90
91201#endif
src/mame/includes/suprslam.h
r0r6741
1/*************************************************************************
2
3    Super Slams
4
5*************************************************************************/
6
7typedef struct _suprslam_state suprslam_state;
8struct _suprslam_state
9{
10   /* memory pointers */
11   UINT16 *    screen_videoram;
12   UINT16 *    bg_videoram;
13   UINT16 *    sp_videoram;
14   UINT16 *    spriteram;
15//  UINT16 *    paletteram; // this currently uses generic palette handling
16
17   /* video-related */
18   tilemap     *screen_tilemap, *bg_tilemap;
19   UINT16      screen_bank, bg_bank;
20   UINT16      *spr_ctrl;
21   UINT16      *screen_vregs;
22
23   /* misc */
24   int         pending_command;
25
26   /* devices */
27   const device_config *audiocpu;
28   const device_config *k053936;
29};
30
31
32/*----------- defined in video/suprslam.c -----------*/
33
34WRITE16_HANDLER( suprslam_screen_videoram_w );
35WRITE16_HANDLER( suprslam_bg_videoram_w );
36WRITE16_HANDLER( suprslam_bank_w );
37
38VIDEO_START( suprslam );
39VIDEO_UPDATE( suprslam );
src/mame/includes/slapfght.h
r6740r6741
7272
7373extern UINT8 *slapfight_videoram;
7474extern UINT8 *slapfight_colorram;
75extern size_t slapfight_videoram_size;
75extern UINT8 *slapfight_fixvideoram;
76extern UINT8 *slapfight_fixcolorram;
7677extern UINT8 *slapfight_scrollx_lo,*slapfight_scrollx_hi,*slapfight_scrolly;
7778
7879VIDEO_UPDATE( slapfight );
src/mame/includes/psikyosh.h
r6740r6741
1/*----------- defined in drivers/psikyosh.c -----------*/
21
32#define MASTER_CLOCK 57272700   // main oscillator frequency
43
5extern UINT32 *psikyosh_bgram, *psikyosh_zoomram, *psikyosh_vidregs;
6
7/*----------- defined in video/psikyosh.c -----------*/
8
9VIDEO_START( psikyosh );
10VIDEO_UPDATE( psikyosh );
11VIDEO_EOF( psikyosh );
12
13enum { eeprom_0=0, eeprom_DEFAULT=1, eeprom_DARAKU, eeprom_S1945III, eeprom_DRAGNBLZ, eeprom_GNBARICH, eeprom_USER1, eeprom_MJGTASTE };
14
154/* Psikyo PS6406B */
16#define FLIPSCREEN (((psikyosh_vidregs[3] & 0x0000c000) == 0x0000c000) ? 1:0)
17#define DISPLAY_DISABLE (((psikyosh_vidregs[2] & 0x0000000f) == 0x00000006) ? 1:0)
18#define BG_LARGE(n) (((psikyosh_vidregs[7] << (4*n)) & 0x00001000 ) ? 1:0)
19#define BG_DEPTH_8BPP(n) (((psikyosh_vidregs[7] << (4*n)) & 0x00004000 ) ? 1:0)
20#define BG_LAYER_ENABLE(n) (((psikyosh_vidregs[7] << (4*n)) & 0x00008000 ) ? 1:0)
5#define FLIPSCREEN (((state->vidregs[3] & 0x0000c000) == 0x0000c000) ? 1:0)
6#define DISPLAY_DISABLE (((state->vidregs[2] & 0x0000000f) == 0x00000006) ? 1:0)
7#define BG_LARGE(n) (((state->vidregs[7] << (4*n)) & 0x00001000 ) ? 1:0)
8#define BG_DEPTH_8BPP(n) (((state->vidregs[7] << (4*n)) & 0x00004000 ) ? 1:0)
9#define BG_LAYER_ENABLE(n) (((state->vidregs[7] << (4*n)) & 0x00008000 ) ? 1:0)
2110
22#define BG_TYPE(n) (((psikyosh_vidregs[6] << (8*n)) & 0x7f000000 ) >> 24)
11#define BG_TYPE(n) (((state->vidregs[6] << (8*n)) & 0x7f000000 ) >> 24)
2312#define BG_NORMAL      0x0a
2413#define BG_NORMAL_ALT  0x0b /* Same as above but with different location for scroll/priority reg */
2514
r6740r6741
2716#define BG_SCROLL_0C   0x0c /* 224 v/h scroll values in bank 0x0c; Used in daraku, for text */
2817#define BG_SCROLL_0D   0x0d /* 224 v/h scroll values in bank 0x0d; Used in daraku, for alternate characters of text */
2918#define BG_SCROLL_ZOOM 0x0e /* 224 v/h scroll values in bank 0x0e-0x1f; Used in s1945ii, s1945iii */
19
20enum { eeprom_0=0, eeprom_DEFAULT=1, eeprom_DARAKU, eeprom_S1945III, eeprom_DRAGNBLZ, eeprom_GNBARICH, eeprom_USER1, eeprom_MJGTASTE };
21
22
23typedef struct _psikyosh_state psikyosh_state;
24struct _psikyosh_state
25{
26   /* memory pointers */
27   UINT32 *       bgram;
28   UINT32 *       zoomram;
29   UINT32 *       vidregs;
30   UINT32 *       ram;
31   UINT32 *       paletteram;
32//  UINT32 *       spriteram;   // currently this uses generic buffered spriteram
33//  size_t         spriteram_size;
34
35   /* video-related */
36   bitmap_t       *zoom_bitmap, *z_bitmap;
37//  UINT8          alphatable[256];
38
39   /* misc */
40   UINT32         sample_offs;   // only used if ROMTEST = 1
41
42   /* devices */
43   const device_config *maincpu;
44};
45
46/*----------- defined in video/psikyosh.c -----------*/
47
48VIDEO_START( psikyosh );
49VIDEO_UPDATE( psikyosh );
50VIDEO_EOF( psikyosh );
src/mame/includes/wiping.h
r6740r6741
1010
1111/*----------- defined in video/wiping.c -----------*/
1212
13extern UINT8 *wiping_videoram;
14extern UINT8 *wiping_colorram;
15
1316WRITE8_HANDLER( wiping_flipscreen_w );
1417PALETTE_INIT( wiping );
1518VIDEO_UPDATE( wiping );
src/mame/includes/irobot.h
r6740r6741
1414DRIVER_INIT( irobot );
1515MACHINE_RESET( irobot );
1616
17TIMER_DEVICE_CALLBACK( irobot_irvg_done_callback );
18TIMER_DEVICE_CALLBACK( irobot_irmb_done_callback );
19
1720READ8_HANDLER( irobot_status_r );
1821WRITE8_HANDLER( irobot_statwr_w );
1922WRITE8_HANDLER( irobot_out0_w );
src/mame/includes/neogeo.h
r6740r6741
55*************************************************************************/
66
77
8#define NEOGEO_MASTER_CLOCK               (24000000)
9#define NEOGEO_MAIN_CPU_CLOCK            (NEOGEO_MASTER_CLOCK / 2)
10#define NEOGEO_AUDIO_CPU_CLOCK            (NEOGEO_MASTER_CLOCK / 6)
11#define NEOGEO_YM2610_CLOCK               (NEOGEO_MASTER_CLOCK / 3)
12#define NEOGEO_PIXEL_CLOCK               (NEOGEO_MASTER_CLOCK / 4)
13#define NEOGEO_HTOTAL                  (0x180)
14#define NEOGEO_HBEND                  (0x01e)   /* this should really be 29.5 */
15#define NEOGEO_HBSTART                  (0x15e) /* this should really be 349.5 */
16#define NEOGEO_VTOTAL                  (0x108)
17#define NEOGEO_VBEND                  (0x010)
18#define NEOGEO_VBSTART                  (0x0f0)
19#define NEOGEO_VSSTART                  (0x000)
20#define NEOGEO_VBLANK_RELOAD_HPOS         (0x11f)
8#define NEOGEO_MASTER_CLOCK                     (24000000)
9#define NEOGEO_MAIN_CPU_CLOCK                   (NEOGEO_MASTER_CLOCK / 2)
10#define NEOGEO_AUDIO_CPU_CLOCK                  (NEOGEO_MASTER_CLOCK / 6)
11#define NEOGEO_YM2610_CLOCK                     (NEOGEO_MASTER_CLOCK / 3)
12#define NEOGEO_PIXEL_CLOCK                      (NEOGEO_MASTER_CLOCK / 4)
13#define NEOGEO_HTOTAL                           (0x180)
14#define NEOGEO_HBEND                            (0x01e)   /* this should really be 29.5 */
15#define NEOGEO_HBSTART                          (0x15e)   /* this should really be 349.5 */
16#define NEOGEO_VTOTAL                           (0x108)
17#define NEOGEO_VBEND                            (0x010)
18#define NEOGEO_VBSTART                          (0x0f0)
19#define NEOGEO_VSSTART                          (0x000)
20#define NEOGEO_VBLANK_RELOAD_HPOS               (0x11f)
2121
22#define NEOGEO_BANK_AUDIO_CPU_CART_BANK      "audio_cart"
22#define NEOGEO_BANK_AUDIO_CPU_CART_BANK         "audio_cart"
2323/* do not use 2, 3 and 4 */
24#define NEOGEO_BANK_CARTRIDGE            "cartridge"
25#define NEOGEO_BANK_BIOS               "bios"
26#define NEOGEO_BANK_VECTORS               "vectors"
27#define NEOGEO_BANK_AUDIO_CPU_MAIN_BANK      "audio_main"
24#define NEOGEO_BANK_CARTRIDGE                   "cartridge"
25#define NEOGEO_BANK_BIOS                        "bios"
26#define NEOGEO_BANK_VECTORS                     "vectors"
27#define NEOGEO_BANK_AUDIO_CPU_MAIN_BANK         "audio_main"
2828
2929
30
31typedef struct _neogeo_state neogeo_state;
32struct _neogeo_state
33{
34   /* memory pointers */
35//  UINT8      *memcard_data;   // this currently uses generic handlers
36//  UINT16     *save_ram;       // this currently uses generic handlers
37
38   /* video-related */
39   UINT8      *sprite_gfx;
40   UINT32     sprite_gfx_address_mask;
41   UINT16     *videoram;
42   UINT16     *palettes[2]; /* 0x100*16 2 byte palette entries */
43   pen_t      *pens;
44   UINT8      palette_bank;
45   UINT8      screen_dark;
46   UINT16     videoram_read_buffer;
47   UINT16     videoram_modulo;
48   UINT16     videoram_offset;
49
50   UINT8      fixed_layer_source;
51
52   UINT8      auto_animation_speed;
53   UINT8      auto_animation_disabled;
54   UINT8      auto_animation_counter;
55   UINT8      auto_animation_frame_counter;
56
57   const UINT8 *region_zoomy;
58
59
60   /* palette */
61   double     rgb_weights_normal[5];
62   double     rgb_weights_normal_bit15[5];
63   double     rgb_weights_dark[5];
64   double     rgb_weights_dark_bit15[5];
65
66   /* timers */
67   emu_timer  *display_position_interrupt_timer;
68   emu_timer  *display_position_vblank_timer;
69   emu_timer  *vblank_interrupt_timer;
70   emu_timer  *auto_animation_timer;
71   emu_timer  *sprite_line_timer;
72   UINT8      display_position_interrupt_control;
73   UINT32     display_counter;
74   UINT32     vblank_interrupt_pending;
75   UINT32     display_position_interrupt_pending;
76   UINT32     irq3_pending;
77
78   /* misc */
79   UINT8      controller_select;
80
81   UINT32     main_cpu_bank_address;
82   UINT8      main_cpu_vector_table_source;
83
84   UINT8      audio_result;
85   UINT8      audio_cpu_banks[4];
86   UINT8      audio_cpu_rom_source;
87   UINT8      audio_cpu_rom_source_last;
88
89   UINT8      save_ram_unlocked;
90
91   UINT8      output_data;
92   UINT8      output_latch;
93   UINT8      el_value;
94   UINT8      led1_value;
95   UINT8      led2_value;
96   UINT8      recurse;
97
98   /* protection */
99   UINT32     fatfury2_prot_data;
100   UINT16     neogeo_rng;
101   UINT16     *pvc_cartridge_ram;
102   int        fixed_layer_bank_type;
103
104   /* devices */
105   const device_config *maincpu;
106   const device_config *audiocpu;
107   const device_config *upd4990a;
108};
109
110
30111/*----------- defined in drivers/neogeo.c -----------*/
31112
32void neogeo_set_display_position_interrupt_control(UINT16 data);
113void neogeo_set_display_position_interrupt_control(running_machine *machine, UINT16 data);
33114void neogeo_set_display_counter_msb(const address_space *space, UINT16 data);
34115void neogeo_set_display_counter_lsb(const address_space *space, UINT16 data);
35116void neogeo_acknowledge_interrupt(running_machine *machine, UINT16 data);
r6740r6741
71152
72153/*----------- defined in machine/neoprot.c -----------*/
73154
74void neogeo_reset_rng(void);
155void neogeo_reset_rng(running_machine *machine);
75156void fatfury2_install_protection(running_machine *machine);
76157void mslugx_install_protection(running_machine *machine);
77158void kof99_install_protection(running_machine *machine);
r6740r6741
124205
125206/*----------- defined in video/neogeo.c -----------*/
126207
127extern int neogeo_fixed_layer_bank_type;
128
129208VIDEO_START( neogeo );
130209VIDEO_RESET( neogeo );
131210VIDEO_UPDATE( neogeo );
r6740r6741
138217READ16_HANDLER( neogeo_paletteram_r );
139218WRITE16_HANDLER( neogeo_paletteram_w );
140219
141void neogeo_set_fixed_layer_source(UINT8 data);
220void neogeo_set_fixed_layer_source(running_machine *machine, UINT8 data);
142221
143UINT8 neogeo_get_auto_animation_counter(void);
222UINT8 neogeo_get_auto_animation_counter(running_machine *machine);
src/mame/includes/tmnt.h
r6740r6741
1313WRITE16_HANDLER( tmnt_priority_w );
1414READ16_HANDLER( glfgreat_ball_r );
1515READ16_HANDLER( prmrsocr_rom_r );
16VIDEO_START( sunsetbl );
1716VIDEO_START( cuebrick );
1817VIDEO_START( mia );
1918VIDEO_START( tmnt );
20VIDEO_START( punkshot );
2119VIDEO_START( lgtnfght );
22VIDEO_START( blswhstl );
2320VIDEO_START( glfgreat );
24VIDEO_START( thndrx2 );
2521VIDEO_START( prmrsocr );
2622VIDEO_UPDATE( mia );
2723VIDEO_UPDATE( tmnt );
r6740r6741
3127VIDEO_UPDATE( tmnt2 );
3228VIDEO_UPDATE( thndrx2 );
3329VIDEO_EOF( blswhstl );
34
src/mame/includes/combatsc.h
r0r6741
1/*************************************************************************
2
3    Combat School
4
5*************************************************************************/
6
7typedef struct _combatsc_state combatsc_state;
8struct _combatsc_state
9{
10   /* memory pointers */
11   UINT8 *    videoram;
12   UINT8 *    scrollram;
13   UINT8 *    io_ram;
14   UINT8 *    paletteram;
15   UINT8 *    spriteram[2];
16
17   /* video-related */
18   tilemap *bg_tilemap[2], *textlayer;
19   UINT8 scrollram0[0x40];
20   UINT8 scrollram1[0x40];
21   int priority;
22
23   int  vreg;
24   int  bank_select; /* 0x00..0x1f */
25   int  video_circuit; /* 0 or 1 */
26   UINT8 *page[2];
27
28   /* misc */
29   UINT8 pos[4],sign[4];
30   int prot[2];
31   int boost;
32   emu_timer *interleave_timer;
33
34
35   /* devices */
36   const device_config *audiocpu;
37   const device_config *k007121_1;
38   const device_config *k007121_2;
39};
40
41
42/*----------- defined in video/combatsc.c -----------*/
43
44READ8_HANDLER( combatsc_video_r );
45WRITE8_HANDLER( combatsc_video_w );
46
47WRITE8_HANDLER( combatsc_pf_control_w );
48READ8_HANDLER( combatsc_scrollram_r );
49WRITE8_HANDLER( combatsc_scrollram_w );
50
51PALETTE_INIT( combatsc );
52PALETTE_INIT( combatscb );
53VIDEO_START( combatsc );
54VIDEO_START( combatscb );
55VIDEO_UPDATE( combatscb );
56VIDEO_UPDATE( combatsc );
src/mame/includes/rockrage.h
r0r6741
1/*************************************************************************
2
3    Rock'n Rage
4
5*************************************************************************/
6
7typedef struct _rockrage_state rockrage_state;
8struct _rockrage_state
9{
10   /* memory pointers */
11   UINT8 *    paletteram;
12
13   /* video-related */
14   int        layer_colorbase[2];
15   int        vreg;
16
17   /* devices */
18   const device_config *audiocpu;
19   const device_config *k007342;
20   const device_config *k007420;
21};
22
23
24/*----------- defined in video/rockrage.c -----------*/
25
26WRITE8_HANDLER( rockrage_vreg_w );
27
28VIDEO_UPDATE( rockrage );
29PALETTE_INIT( rockrage );
30
31void rockrage_tile_callback(running_machine *machine, int layer, int bank, int *code, int *color, int *flags);
32void rockrage_sprite_callback(running_machine *machine, int *code, int *color);
src/mame/includes/psikyo.h
r0r6741
1/*************************************************************************
2
3    Psikyo Games
4
5*************************************************************************/
6
7typedef struct _psikyo_state psikyo_state;
8struct _psikyo_state
9{
10   /* memory pointers */
11   UINT32 *       vram_0;
12   UINT32 *       vram_1;
13   UINT32 *       vregs;
14   UINT32 *       spritebuf1;
15   UINT32 *       spritebuf2;
16   UINT32 *       bootleg_spritebuffer;
17//      UINT32 *       paletteram;  // currently this uses generic palette handling
18//  UINT32 *       spriteram;   // currently this uses generic buffered spriteram
19//  size_t         spriteram_size;
20
21   /* video-related */
22   tilemap        *tilemap_0_size0, *tilemap_0_size1, *tilemap_0_size2, *tilemap_0_size3;
23   tilemap        *tilemap_1_size0, *tilemap_1_size1, *tilemap_1_size2, *tilemap_1_size3;
24   int            tilemap_0_bank, tilemap_1_bank;
25   int            ka302c_banking;
26
27   /* misc */
28   UINT8          soundlatch;
29   int            z80_nmi, mcu_status;
30
31   /* devices */
32   const device_config *audiocpu;
33
34   /* game-specific */
35   // 1945 MCU
36   UINT8          s1945_mcu_direction, s1945_mcu_latch1, s1945_mcu_latch2, s1945_mcu_inlatch, s1945_mcu_index;
37   UINT8          s1945_mcu_latching, s1945_mcu_mode, s1945_mcu_control, s1945_mcu_bctrl;
38   const UINT8    *s1945_mcu_table;
39};
40
41
42/*----------- defined in video/psikyo.c -----------*/
43
44void psikyo_switch_banks(running_machine *machine, int tmap, int bank);
45
46WRITE32_HANDLER( psikyo_vram_0_w );
47WRITE32_HANDLER( psikyo_vram_1_w );
48
49VIDEO_START( sngkace );
50VIDEO_START( psikyo );
51VIDEO_UPDATE( psikyo );
52VIDEO_UPDATE( psikyo_bootleg );
53VIDEO_EOF( psikyo );
src/mame/includes/pgm.h
r6740r6741
1/*----------- defined in drivers/pgm.c -----------*/
21
3extern UINT16 *pgm_mainram, *pgm_bg_videoram, *pgm_tx_videoram, *pgm_videoregs, *pgm_rowscrollram;
2typedef struct _pgm_state pgm_state;
3struct _pgm_state
4{
5   /* memory pointers */
6//  UINT16 *      mainram;  // currently this is also used by nvram handler
7   UINT16 *      bg_videoram;
8   UINT16 *      tx_videoram;
9   UINT16 *      videoregs;
10   UINT16 *      rowscrollram;
11   UINT16 *      videoram;
12   UINT8  *      z80_mainram;
13   UINT32 *      arm7_shareram;
14   UINT32 *      svg_shareram[2];   //for 5585G MACHINE
15   UINT16 *      sharedprotram;      // killbld & olds
16   UINT8  *      sprite_a_region;
17   size_t        sprite_a_region_size;
18   UINT16 *      spritebufferram; // buffered spriteram
19//  UINT16 *      paletteram;    // currently this uses generic palette handling
420
5extern UINT8 *pgm_sprite_a_region;
6extern size_t   pgm_sprite_a_region_allocate;
21   /* video-related */
22   tilemap       *bg_tilemap, *tx_tilemap;
23   UINT16        *sprite_temp_render;
24   bitmap_t      *tmppgmbitmap;
725
26   /* misc */
27   // kov2
28   UINT32        kov2_latchdata_68k_w;
29   UINT32        kov2_latchdata_arm_w;
30   // kovsh
31   UINT16        kovsh_highlatch_arm_w, kovsh_lowlatch_arm_w;
32   UINT16        kovsh_highlatch_68k_w, kovsh_lowlatch_68k_w;
33   UINT32        kovsh_counter;
34   // svg
35   int           svg_ram_sel;
36   // killbld & olds
37   int           kb_cmd;
38   int           kb_reg;
39   int           kb_ptr;
40   UINT32        kb_regs[0x10];
41   UINT16        olds_bs, olds_cmd3;
42   // pstars
43   UINT16        pstars_key;
44   UINT16        pstars_int[2];
45   UINT32        pstars_regs[16];
46   UINT32        pstars_val;
47   UINT16        pstar_e7, pstar_b1, pstar_ce;
48   UINT16        pstar_ram[3];
49   // ASIC 3 (oriental legends protection)
50   UINT8         asic3_reg, asic3_latch[3], asic3_x, asic3_y, asic3_z, asic3_h1, asic3_h2;
51   UINT16        asic3_hold;
52   // ASIC28
53   UINT16        asic28_key;
54   UINT16        asic28_regs[10];
55   UINT16        asic_params[256];
56   UINT16        asic28_rcnt;
57   UINT32        eoregs[16];
858
59   /* calendar */
60   UINT8        cal_val, cal_mask, cal_com, cal_cnt;
61   mame_system_time systime;
62
63   /* devices */
64   const device_config *soundcpu;
65   const device_config *prot;
66   const device_config *ics;
67};
68
69extern UINT16 *pgm_mainram;   // used by nvram handler, we cannot move it to driver data struct
70
971/*----------- defined in machine/pgmcrypt.c -----------*/
1072
11
1273void pgm_kov_decrypt(running_machine *machine);
1374void pgm_kovsh_decrypt(running_machine *machine);
1475void pgm_kov2_decrypt(running_machine *machine);
r6740r6741
3192
3293/*----------- defined in machine/pgmprot.c -----------*/
3394
34READ16_HANDLER (PSTARS_protram_r);
35READ16_HANDLER ( PSTARS_r16 );
36WRITE16_HANDLER( PSTARS_w16 );
95READ16_HANDLER( pstars_protram_r );
96READ16_HANDLER( pstars_r );
97WRITE16_HANDLER( pstars_w );
3798
3899READ16_HANDLER( pgm_asic3_r );
39100WRITE16_HANDLER( pgm_asic3_w );
40101WRITE16_HANDLER( pgm_asic3_reg_w );
41102
42READ16_HANDLER (sango_protram_r);
43READ16_HANDLER (ASIC28_r16);
44WRITE16_HANDLER (ASIC28_w16);
103READ16_HANDLER( sango_protram_r );
104READ16_HANDLER( asic28_r );
105WRITE16_HANDLER( asic28_w );
45106
46READ16_HANDLER (dw2_d80000_r );
107READ16_HANDLER( dw2_d80000_r );
47108
48109
49110/*----------- defined in video/pgm.c -----------*/
50111
51
52112WRITE16_HANDLER( pgm_tx_videoram_w );
53113WRITE16_HANDLER( pgm_bg_videoram_w );
114
54115VIDEO_START( pgm );
55116VIDEO_EOF( pgm );
56117VIDEO_UPDATE( pgm );
src/mame/includes/gameplan.h
r6740r6741
4242   const device_config *audiocpu;
4343   const device_config *riot;
4444   const device_config *via_0;
45   const device_config *via_1;
46   const device_config *via_2;
4547};
4648
4749
src/mame/includes/hng64.h
r6740r6741
77
88extern int hng64_mcu_type;
99
10void hng64_command3d(running_machine* machine, const UINT16* packet);
11
src/mame/includes/cbasebal.h
r0r6741
1/*************************************************************************
2
3    Capcom Baseball
4
5*************************************************************************/
6
7typedef struct _cbasebal_state cbasebal_state;
8struct _cbasebal_state
9{
10   /* memory pointers */
11   UINT8 *    spriteram;
12//  UINT8 *    paletteram;    // currently this uses generic palette handling
13   size_t     spriteram_size;
14
15   /* video-related */
16   tilemap    *fg_tilemap, *bg_tilemap;
17   UINT8      *textram, *scrollram;
18   UINT8      scroll_x[2], scroll_y[2];
19   int        tilebank, spritebank;
20   int        text_on, bg_on, obj_on;
21   int        flipscreen;
22
23   /* misc */
24   UINT8      rambank;
25};
26
27/*----------- defined in video/cbasebal.c -----------*/
28
29WRITE8_HANDLER( cbasebal_textram_w );
30READ8_HANDLER( cbasebal_textram_r );
31WRITE8_HANDLER( cbasebal_scrollram_w );
32READ8_HANDLER( cbasebal_scrollram_r );
33WRITE8_HANDLER( cbasebal_gfxctrl_w );
34WRITE8_HANDLER( cbasebal_scrollx_w );
35WRITE8_HANDLER( cbasebal_scrolly_w );
36
37VIDEO_START( cbasebal );
38VIDEO_UPDATE( cbasebal );
src/mame/includes/fastlane.h
r0r6741
1/*************************************************************************
2
3    Fast Lane
4
5*************************************************************************/
6
7typedef struct _fastlane_state fastlane_state;
8struct _fastlane_state
9{
10   /* memory pointers */
11   UINT8 *    videoram1;
12   UINT8 *    videoram2;
13   UINT8 *    paletteram;
14   UINT8 *    spriteram;
15   UINT8 *    k007121_regs;
16
17   /* video-related */
18   tilemap    *layer0, *layer1;
19   rectangle  clip0, clip1;
20
21   /* devices */
22   const device_config *konami2;
23   const device_config *k007121;
24};
25
26
27
28
29/*----------- defined in video/fastlane.c -----------*/
30
31WRITE8_HANDLER( fastlane_vram1_w );
32WRITE8_HANDLER( fastlane_vram2_w );
33
34PALETTE_INIT( fastlane );
35VIDEO_START( fastlane );
36VIDEO_UPDATE( fastlane );
src/mame/includes/beathead.h
r6740r6741
1313
1414   UINT32 *      vram_bulk_latch;
1515   UINT32 *      palette_select;
16
17   UINT32         finescroll;
18   offs_t         vram_latch_offset;
19
20   offs_t         hsyncram_offset;
21   offs_t         hsyncram_start;
22   UINT8         hsyncram[0x800];
1623};
1724
1825
src/mame/includes/timeplt.h
r6740r6741
1717   int x, y, color;
1818};
1919
20#define MAX_STARS 1000
20#define JUNGLER_MAX_STARS 1000
2121
2222typedef struct _timeplt_state timeplt_state;
2323struct _timeplt_state
r6740r6741
5252   int      last_bang;   // jungler
5353   int      spriteram_base, stars_enable, total_stars;   // jungler
5454   UINT8    drawmode_table[4];   // jungler
55   struct jungler_star stars[MAX_STARS];   // jungler
55   struct jungler_star stars[JUNGLER_MAX_STARS];   // jungler
5656
5757   /* devices */
5858   const device_config *maincpu;
src/mame/includes/matmania.h
r6740r6741
1616
1717/*----------- defined in video/matmania.c -----------*/
1818
19extern UINT8 *matmania_videoram,*matmania_colorram;
20extern size_t matmania_videoram_size;
1921extern UINT8 *matmania_videoram2,*matmania_colorram2;
2022extern size_t matmania_videoram2_size;
2123extern UINT8 *matmania_videoram3,*matmania_colorram3;
src/mame/includes/xybots.h
r6740r6741
1111{
1212   atarigen_state   atarigen;
1313
14   int          h256;
14   UINT16          h256;
1515};
1616
1717
src/mame/includes/crshrace.h
r6740r6741
1
2typedef struct _crshrace_state crshrace_state;
3struct _crshrace_state
4{
5   /* memory pointers */
6   UINT16 *  videoram1;
7   UINT16 *  videoram2;
8//  UINT16 *  spriteram1;   // currently this uses generic buffered spriteram
9//  UINT16 *  spriteram2;   // currently this uses generic buffered spriteram
10//      UINT16 *  paletteram;   // currently this uses generic palette handling
11
12   /* video-related */
13   tilemap   *tilemap1, *tilemap2;
14   int       roz_bank, gfxctrl, flipscreen;
15
16   /* misc */
17   int pending_command;
18
19   /* devices */
20   const device_config *audiocpu;
21   const device_config *k053936;
22};
23
124/*----------- defined in video/crshrace.c -----------*/
225
3extern UINT16 *crshrace_videoram1,*crshrace_videoram2;
4
526WRITE16_HANDLER( crshrace_videoram1_w );
627WRITE16_HANDLER( crshrace_videoram2_w );
728WRITE16_HANDLER( crshrace_roz_bank_w );
src/mame/includes/galaxold.h
r6740r6741
9898
9999/*----------- defined in machine/galaxold.c -----------*/
100100
101TIMER_DEVICE_CALLBACK( galaxold_interrupt_timer );
102
103void galaxold_7474_9m_2_callback(const device_config *device);
104void galaxold_7474_9m_1_callback(const device_config *device);
105
101106DRIVER_INIT( 4in1 );
102107DRIVER_INIT( ladybugg );
103108
r6740r6741
167172/*----------- defined in audio/scramble.c -----------*/
168173
169174void scramble_sh_init(running_machine *machine);
175void scramble_sh_7474_callback(const device_config *device);
170176
171177WRITE8_HANDLER( scramble_filter_w );
172178WRITE8_HANDLER( frogger_filter_w );
src/mame/includes/airbustr.h
r0r6741
1/*************************************************************************
2
3    Air Buster
4
5*************************************************************************/
6
7typedef struct _airbustr_state airbustr_state;
8struct _airbustr_state
9{
10   /* memory pointers */
11   UINT8 *    videoram;
12   UINT8 *    videoram2;
13   UINT8 *    colorram;
14   UINT8 *    colorram2;
15   UINT8 *    paletteram;
16   UINT8 *    devram;
17
18   /* video-related */
19   tilemap    *bg_tilemap, *fg_tilemap;
20   bitmap_t   *sprites_bitmap;
21   int        bg_scrollx, bg_scrolly, fg_scrollx, fg_scrolly, highbits;
22
23   /* misc */
24   int        soundlatch_status, soundlatch2_status;
25   int        master_addr;
26   int        slave_addr;
27
28   /* devices */
29   const device_config *master;
30   const device_config *slave;
31   const device_config *audiocpu;
32   const device_config *pandora;
33};
34
35
36/*----------- defined in video/airbustr.c -----------*/
37
38WRITE8_HANDLER( airbustr_videoram_w );
39WRITE8_HANDLER( airbustr_colorram_w );
40WRITE8_HANDLER( airbustr_videoram2_w );
41WRITE8_HANDLER( airbustr_colorram2_w );
42WRITE8_HANDLER( airbustr_scrollregs_w );
43
44VIDEO_START( airbustr );
45VIDEO_UPDATE( airbustr );
46VIDEO_EOF( airbustr );
src/mame/includes/atarisy1.h
r6740r6741
1616   UINT8          joystick_type;
1717   UINT8          trackball_type;
1818
19   emu_timer *      joystick_timer;
19   const device_config *joystick_timer;
2020   UINT8          joystick_int;
2121   UINT8          joystick_int_enable;
2222   UINT8          joystick_value;
r6740r6741
2929   UINT16          playfield_lookup[256];
3030   UINT8          playfield_tile_bank;
3131   UINT16          playfield_priority_pens;
32   emu_timer *      yscroll_reset_timer;
32   const device_config *yscroll_reset_timer;
3333
3434   /* INT3 tracking */
3535   int          next_timer_scanline;
36   emu_timer *      scanline_timer;
37   emu_timer *      int3off_timer;
36   const device_config *scanline_timer;
37   const device_config *int3off_timer;
3838
3939   /* graphics bank tracking */
4040   UINT8          bank_gfx[3][8];
r6740r6741
4444
4545/*----------- defined in video/atarisy1.c -----------*/
4646
47TIMER_DEVICE_CALLBACK( atarisy1_int3_callback );
48TIMER_DEVICE_CALLBACK( atarisy1_int3off_callback );
49TIMER_DEVICE_CALLBACK( atarisy1_reset_yscroll_callback );
50
4751READ16_HANDLER( atarisy1_int3state_r );
4852
4953WRITE16_HANDLER( atarisy1_spriteram_w );
src/mame/includes/pacman.h
r6740r6741
66
77/*----------- defined in video/pacman.c -----------*/
88
9extern UINT8 *pacman_videoram;
10extern UINT8 *pacman_colorram;
11
912PALETTE_INIT( pacman );
1013VIDEO_START( pacman );
1114VIDEO_UPDATE( pacman );
r6740r6741
5861
5962/*----------- defined in machine/theglobp.c -----------*/
6063
64MACHINE_START( theglobp );
6165MACHINE_RESET( theglobp );
6266READ8_HANDLER( theglobp_decrypt_rom );
6367
6468
6569/*----------- defined in machine/acitya.c -------------*/
6670
71MACHINE_START( acitya );
6772MACHINE_RESET( acitya );
6873READ8_HANDLER( acitya_decrypt_rom );
src/mame/includes/sf.h
r0r6741
1/*************************************************************************
2
3    Street Fighter
4
5*************************************************************************/
6
7typedef struct _sf_state sf_state;
8struct _sf_state
9{
10   /* memory pointers */
11   UINT16 *    videoram;
12   UINT16 *    objectram;
13//  UINT16 *    paletteram;    // currently this uses generic palette handling
14   size_t      videoram_size;
15
16   /* video-related */
17   tilemap     *bg_tilemap, *fg_tilemap, *tx_tilemap;
18   int         sf_active;
19   UINT16      bgscroll, fgscroll;
20
21   /* devices */
22   const device_config *maincpu;
23   const device_config *audiocpu;
24};
25
26
27/*----------- defined in video/sf.c -----------*/
28
29WRITE16_HANDLER( sf_bg_scroll_w );
30WRITE16_HANDLER( sf_fg_scroll_w );
31WRITE16_HANDLER( sf_videoram_w );
32WRITE16_HANDLER( sf_gfxctrl_w );
33
34VIDEO_START( sf );
35VIDEO_UPDATE( sf );
src/mame/includes/williams.h
r6740r6741
4141extern const pia6821_interface tshoot_snd_pia_intf;
4242extern const pia6821_interface joust2_pia_1_intf;
4343
44/* timer callbacks */
45TIMER_DEVICE_CALLBACK( williams_va11_callback );
46TIMER_DEVICE_CALLBACK( williams_count240_callback );
47TIMER_DEVICE_CALLBACK( williams2_va11_callback );
48TIMER_DEVICE_CALLBACK( williams2_endscreen_callback );
49
4450/* initialization */
51MACHINE_START( defender );
4552MACHINE_RESET( defender );
53MACHINE_START( williams );
4654MACHINE_RESET( williams );
55MACHINE_START( blaster );
4756MACHINE_RESET( blaster );
57MACHINE_START( williams2 );
4858MACHINE_RESET( williams2 );
4959MACHINE_START( joust2 );
5060MACHINE_RESET( joust2 );
src/mame/includes/bagman.h
r6740r6741
77
88/*----------- defined in video/bagman.c -----------*/
99
10extern UINT8 *bagman_videoram;
11extern UINT8 *bagman_colorram;
1012extern UINT8 *bagman_video_enable;
1113
1214WRITE8_HANDLER( bagman_videoram_w );
src/mame/mame.mak
r6740r6741
7676CPUS += SH4
7777CPUS += DSP32C
7878CPUS += PIC16C5X
79CPUS += PIC16C62X
7980CPUS += G65816
8081CPUS += SPC700
8182CPUS += E1
r6740r6741
181182SOUNDS += K051649
182183SOUNDS += K053260
183184SOUNDS += K054539
185SOUNDS += K056800
184186SOUNDS += SEGAPCM
185187SOUNDS += MULTIPCM
186188SOUNDS += SCSP
r6740r6741
326328#-------------------------------------------------
327329
328330$(MAMEOBJ)/shared.a: \
329   $(MACHINE)/mb14241.o \
330331   $(MACHINE)/nmk112.o \
331332   $(MACHINE)/pckeybrd.o \
332333   $(MACHINE)/pcshare.o \
r6740r6741
845846   $(DRIVERS)/xmen.o $(VIDEO)/xmen.o \
846847   $(DRIVERS)/yiear.o $(VIDEO)/yiear.o \
847848   $(DRIVERS)/zr107.o \
848   $(MACHINE)/konamiic.o $(VIDEO)/konamiic.o \
849   $(VIDEO)/konamiic.o $(VIDEO)/konicdev.o \
849850
850851$(MAMEOBJ)/maygay.a: \
851852   $(DRIVERS)/maygay1b.o \
src/mame/video/mitchell.c
r6740r6741
66
77#include "driver.h"
88#include "sound/okim6295.h"
9#include "includes/mitchell.h"
910
10
11/* Globals */
12size_t pang_videoram_size;
13UINT8 *pang_videoram;
14UINT8 *pang_colorram;
15
16/* Private */
17static UINT8 *pang_objram;           /* Sprite RAM */
18
19static tilemap *bg_tilemap;
20static int flipscreen;
21
22
23
2411/***************************************************************************
2512
2613  Callbacks for the TileMap code
r6740r6741
2916
3017static TILE_GET_INFO( get_tile_info )
3118{
32   UINT8 attr = pang_colorram[tile_index];
33   int code = pang_videoram[2*tile_index] + (pang_videoram[2*tile_index+1] << 8);
19   mitchell_state *state = (mitchell_state *)machine->driver_data;
20   UINT8 attr = state->colorram[tile_index];
21   int code = state->videoram[2 * tile_index] + (state->videoram[2 * tile_index + 1] << 8);
3422   SET_TILE_INFO(
3523         0,
3624         code,
r6740r6741
4836
4937VIDEO_START( pang )
5038{
51   pang_objram=NULL;
52   machine->generic.paletteram.u8=NULL;
39   mitchell_state *state = (mitchell_state *)machine->driver_data;
5340
41   state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
42   tilemap_set_transparent_pen(state->bg_tilemap, 15);
5443
55   bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,64,32);
44   /* OBJ RAM */
45   state->objram = auto_alloc_array_clear(machine, UINT8, state->videoram_size);
5646
57   tilemap_set_transparent_pen(bg_tilemap,15);
47   /* Palette RAM */
48   machine->generic.paletteram.u8 = auto_alloc_array_clear(machine, UINT8, 2 * machine->config->total_colors);
5849
59   /*
60        OBJ RAM
61    */
62   pang_objram=auto_alloc_array_clear(machine, UINT8, pang_videoram_size);
63
64   /*
65        Palette RAM
66    */
67   machine->generic.paletteram.u8 = auto_alloc_array_clear(machine, UINT8, 2*machine->config->total_colors);
50   state_save_register_global_pointer(machine, state->objram, state->videoram_size);
51   state_save_register_global_pointer(machine, machine->generic.paletteram.u8, 2 * machine->config->total_colors);
6852}
6953
7054
r6740r6741
7963  OBJ / CHAR RAM HANDLERS (BANK 0 = CHAR, BANK 1=OBJ)
8064***************************************************************************/
8165
82static int video_bank;
83
8466WRITE8_HANDLER( pang_video_bank_w )
8567{
68   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
69
8670   /* Bank handler (sets base pointers for video write) (doesn't apply to mgakuen) */
87   video_bank = data;
71   state->video_bank = data;
8872}
8973
9074WRITE8_HANDLER( mstworld_video_bank_w )
9175{
76   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
77
9278   /* Monsters World seems to freak out if more bits are used.. */
93   video_bank = data&1;
79   state->video_bank = data & 1;
9480}
9581
9682
9783WRITE8_HANDLER( mgakuen_videoram_w )
9884{
99   pang_videoram[offset] = data;
100   tilemap_mark_tile_dirty(bg_tilemap,offset/2);
85   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
86
87   state->videoram[offset] = data;
88   tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
10189}
10290
10391READ8_HANDLER( mgakuen_videoram_r )
10492{
105   return pang_videoram[offset];
93   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
94   return state->videoram[offset];
10695}
10796
10897WRITE8_HANDLER( mgakuen_objram_w )
10998{
110   pang_objram[offset]=data;
99   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
100   state->objram[offset] = data;
111101}
112102
113103READ8_HANDLER( mgakuen_objram_r )
114104{
115   return pang_objram[offset];
105   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
106   return state->objram[offset];
116107}
117108
118109WRITE8_HANDLER( pang_videoram_w )
119110{
120   if (video_bank) mgakuen_objram_w(space,offset,data);
121   else mgakuen_videoram_w(space,offset,data);
111   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
112
113   if (state->video_bank)
114      mgakuen_objram_w(space, offset, data);
115   else
116      mgakuen_videoram_w(space, offset, data);
122117}
123118
124119READ8_HANDLER( pang_videoram_r )
125120{
126   if (video_bank) return mgakuen_objram_r(space,offset);
127   else return mgakuen_videoram_r(space,offset);
121   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
122
123   if (state->video_bank)
124      return mgakuen_objram_r(space, offset);
125   else
126      return mgakuen_videoram_r(space, offset);
128127}
129128
130129/***************************************************************************
r6740r6741
133132
134133WRITE8_HANDLER( pang_colorram_w )
135134{
136   pang_colorram[offset] = data;
137   tilemap_mark_tile_dirty(bg_tilemap,offset);
135   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
136
137   state->colorram[offset] = data;
138   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
138139}
139140
140141READ8_HANDLER( pang_colorram_r )
141142{
142   return pang_colorram[offset];
143   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
144   return state->colorram[offset];
143145}
144146
145147/***************************************************************************
146148  PALETTE HANDLERS (COLOURS: BANK 0 = 0x00-0x3f BANK 1=0x40-0xff)
147149****************************************************************************/
148150
149static int paletteram_bank;
150
151151WRITE8_HANDLER( pang_gfxctrl_w )
152152{
153   const device_config *oki = devtag_get_device(space->machine, "oki");
153   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
154
154155logerror("PC %04x: pang_gfxctrl_w %02x\n",cpu_get_pc(space->cpu),data);
155156{
156157#if 0
r6740r6741
163164   /* bit 0 is unknown (used, maybe back color enable?) */
164165
165166   /* bit 1 is coin counter */
166   coin_counter_w(space->machine, 0,data & 2);
167   coin_counter_w(space->machine, 0, data & 2);
167168
168169   /* bit 2 is flip screen */
169   if (flipscreen != (data & 0x04))
170   if (state->flipscreen != (data & 0x04))
170171   {
171      flipscreen = data & 0x04;
172      tilemap_set_flip_all(space->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
172      state->flipscreen = data & 0x04;
173      tilemap_set_flip_all(space->machine, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
173174   }
174175
175176   /* bit 3 is unknown (used, e.g. marukin pulses it on the title screen) */
176177
177178   /* bit 4 selects OKI M6295 bank */
178   if (oki != NULL && sound_get_type(oki) == SOUND_OKIM6295) okim6295_set_bank_base(oki, (data & 0x10) ? 0x40000 : 0x00000);
179   if (state->oki != NULL && sound_get_type(state->oki) == SOUND_OKIM6295)
180      okim6295_set_bank_base(state->oki, (data & 0x10) ? 0x40000 : 0x00000);
179181
180182   /* bit 5 is palette RAM bank selector (doesn't apply to mgakuen) */
181   paletteram_bank = data & 0x20;
183   state->paletteram_bank = data & 0x20;
182184
183185   /* bits 6 and 7 are unknown, used in several places. At first I thought */
184186   /* they were bg and sprites enable, but this screws up spang (screen flickers */
r6740r6741
188190
189191WRITE8_HANDLER( mstworld_gfxctrl_w )
190192{
193   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
194
191195logerror("PC %04x: pang_gfxctrl_w %02x\n",cpu_get_pc(space->cpu),data);
192196{
193197   char baf[40];
r6740r6741
198202   /* bit 0 is unknown (used, maybe back color enable?) */
199203
200204   /* bit 1 is coin counter */
201   coin_counter_w(space->machine, 0,data & 2);
205   coin_counter_w(space->machine, 0, data & 2);
202206
203207   /* bit 2 is flip screen */
204   if (flipscreen != (data & 0x04))
208   if (state->flipscreen != (data & 0x04))
205209   {
206      flipscreen = data & 0x04;
207      tilemap_set_flip_all(space->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
210      state->flipscreen = data & 0x04;
211      tilemap_set_flip_all(space->machine, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
208212   }
209213
210214   /* bit 3 is unknown (used, e.g. marukin pulses it on the title screen) */
211215
212   /* bit 4 selects OKI M6295 bank */
213//  okim6295_set_bank_base(devtag_get_device(space->machine, "oki"), (data & 0x10) ? 0x40000 : 0x00000);
214   /* not here.. it has its own z80 + sound banking */
216   /* bit 4 here does not select OKI M6295 bank: mstworld has its own z80 + sound banking */
215217
216218   /* bit 5 is palette RAM bank selector (doesn't apply to mgakuen) */
217   paletteram_bank = data & 0x20;
219   state->paletteram_bank = data & 0x20;
218220
219221   /* bits 6 and 7 are unknown, used in several places. At first I thought */
220222   /* they were bg and sprites enable, but this screws up spang (screen flickers */
r6740r6741
224226
225227WRITE8_HANDLER( pang_paletteram_w )
226228{
227   if (paletteram_bank) paletteram_xxxxRRRRGGGGBBBB_le_w(space,offset + 0x800,data);
228   else paletteram_xxxxRRRRGGGGBBBB_le_w(space,offset,data);
229   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
230
231   if (state->paletteram_bank)
232      paletteram_xxxxRRRRGGGGBBBB_le_w(space, offset + 0x800, data);
233   else
234      paletteram_xxxxRRRRGGGGBBBB_le_w(space, offset, data);
229235}
230236
231237READ8_HANDLER( pang_paletteram_r )
232238{
233   if (paletteram_bank) return space->machine->generic.paletteram.u8[offset + 0x800];
239   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
240
241   if (state->paletteram_bank)
242      return space->machine->generic.paletteram.u8[offset + 0x800];
243
234244   return space->machine->generic.paletteram.u8[offset];
235245}
236246
237247WRITE8_HANDLER( mgakuen_paletteram_w )
238248{
239   paletteram_xxxxRRRRGGGGBBBB_le_w(space,offset,data);
249   paletteram_xxxxRRRRGGGGBBBB_le_w(space, offset, data);
240250}
241251
242252READ8_HANDLER( mgakuen_paletteram_r )
r6740r6741
252262
253263***************************************************************************/
254264
255static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
265static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
256266{
257   int offs,sx,sy;
267   mitchell_state *state = (mitchell_state *)machine->driver_data;
268   int offs, sx, sy;
258269
259270   /* the last entry is not a sprite, we skip it otherwise spang shows a bubble */
260271   /* moving diagonally across the screen */
261   for (offs = 0x1000-0x40;offs >= 0;offs -= 0x20)
272   for (offs = 0x1000 - 0x40; offs >= 0; offs -= 0x20)
262273   {
263      int code = pang_objram[offs];
264      int attr = pang_objram[offs+1];
274      int code = state->objram[offs];
275      int attr = state->objram[offs + 1];
265276      int color = attr & 0x0f;
266      sx = pang_objram[offs+3] + ((attr & 0x10) << 4);
267      sy = ((pang_objram[offs+2] + 8) & 0xff) - 8;
277      sx = state->objram[offs + 3] + ((attr & 0x10) << 4);
278      sy = ((state->objram[offs + 2] + 8) & 0xff) - 8;
268279      code += (attr & 0xe0) << 3;
269      if (flipscreen)
280      if (state->flipscreen)
270281      {
271282         sx = 496 - sx;
272283         sy = 240 - sy;
r6740r6741
274285      drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
275286             code,
276287             color,
277             flipscreen,flipscreen,
288             state->flipscreen, state->flipscreen,
278289             sx,sy,15);
279290   }
280291}
281292
282293VIDEO_UPDATE( pang )
283294{
284   bitmap_fill(bitmap,cliprect,0);
285   tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
286   draw_sprites(screen->machine, bitmap,cliprect);
295   mitchell_state *state = (mitchell_state *)screen->machine->driver_data;
296
297   bitmap_fill(bitmap, cliprect, 0);
298   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
299   draw_sprites(screen->machine, bitmap, cliprect);
287300   return 0;
288301}
src/mame/video/blktiger.c
r6740r6741
11#include "driver.h"
2#include "blktiger.h"
2#include "includes/blktiger.h"
33
44
55#define BGRAM_BANK_SIZE 0x1000
src/mame/video/rungun.c
r6740r6741
88*/
99
1010#include "driver.h"
11#include "video/konamiic.h"
11#include "video/konicdev.h"
1212
1313static int ttl_gfx_index;
1414static tilemap *ttl_tilemap, *rng_936_tilemap;
r6740r6741
3232   SET_TILE_INFO(ttl_gfx_index, code, attr, 0);
3333}
3434
35static void rng_sprite_callback(int *code, int *color, int *priority_mask)
35void rng_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask)
3636{
3737   *color = sprite_colorbase | (*color & 0x001f);
3838}
r6740r6741
8181      8*8*4
8282   };
8383
84   K055673_vh_start(machine, "gfx2", 1, -8, 15, rng_sprite_callback);
84//  K055673_vh_start(machine, "gfx2", 1, -8, 15, rng_sprite_callback);
8585
86   K053936_wraparound_enable(0, 0);
87   K053936_set_offset(0, 34, 9);
86//  K053936_wraparound_enable(0, 0);
87//  K053936_set_offset(0, 34, 9);
8888
8989   rng_936_tilemap = tilemap_create(machine, get_rng_936_tile_info, tilemap_scan_rows,  16, 16, 128, 128);
9090   tilemap_set_transparent_pen(rng_936_tilemap, 0);
r6740r6741
111111
112112VIDEO_UPDATE(rng)
113113{
114   const device_config *k055673 = devtag_get_device(screen->machine, "k055673");
115   const device_config *k053936 = devtag_get_device(screen->machine, "k053936");
116
114117   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
115118   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
116119
117   K053936_0_zoom_draw(bitmap, cliprect, rng_936_tilemap, 0, 0, 1);
120   k053936_zoom_draw(k053936, bitmap, cliprect, rng_936_tilemap, 0, 0, 1);
118121
119   K053247_sprites_draw(screen->machine, bitmap, cliprect);
122   k053247_sprites_draw(k055673, bitmap, cliprect);
120123
121124   tilemap_mark_all_tiles_dirty(ttl_tilemap);
122125   tilemap_draw(bitmap, cliprect, ttl_tilemap, 0, 0);
src/mame/video/eprom.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "eprom.h"
9#include "thunderj.h"
8#include "includes/eprom.h"
9#include "includes/thunderj.h"
1010
1111
1212/*************************************
r6740r6741
140140   /* initialize the alphanumerics */
141141   state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows,  8,8, 64,32);
142142   tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0);
143
144   /* save states */
145   state_save_register_global(machine, state->screen_intensity);
146   state_save_register_global(machine, state->video_disable);
143147}
144148
145149
r6740r6741
192196   /* initialize the alphanumerics */
193197   state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows,  8,8, 64,32);
194198   tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0);
199
200   /* save states */
201   state_save_register_global(machine, state->screen_intensity);
202   state_save_register_global(machine, state->video_disable);
195203}
196204
197205
src/mame/video/mystston.c
r6740r6741
1414
1515#include "driver.h"
1616#include "video/resnet.h"
17#include "mystston.h"
17#include "includes/mystston.h"
1818
1919
2020
r6740r6741
2525 *************************************/
2626
2727#define PIXEL_CLOCK      (MYSTSTON_MASTER_CLOCK / 2)
28#define HTOTAL         (0x140)
28#define HTOTAL         (0x180)
2929#define HBEND         (0x000)
3030#define HBSTART         (0x100)
3131#define VTOTAL         (0x110)    /* counts from 0x08-0xff, then from 0xe8-0xff */
src/mame/video/midyunit.c
r6740r6741
77#include "driver.h"
88#include "profiler.h"
99#include "cpu/tms34010/tms34010.h"
10#include "midyunit.h"
10#include "includes/midyunit.h"
1111
1212
1313/* compile-time options */
src/mame/video/ygv608.c
r6740r6741
3030 */
3131
3232#include "driver.h"
33#include "namcond1.h"   // only while debugging
33#include "includes/namcond1.h"   // only while debugging
3434#include "video/ygv608.h"
3535
3636#define _ENABLE_SPRITES
r6740r6741
13571357    if( i%16 == 0 )
13581358      logerror( "%04X: ", offset );
13591359    logerror( "%02X ", data );
1360    ascii[i%16] = ( data > 0x20) ? data : '.' );
1360    ascii[i%16] = (data > 0x20) ? data : '.';
13611361    if( i%16 == 15 )
13621362      logerror( "| %-16.16s\n", ascii );
13631363  }
src/mame/video/rampart.c
r6740r6741
66
77#include "driver.h"
88#include "machine/atarigen.h"
9#include "rampart.h"
9#include "includes/rampart.h"
1010
1111
1212
src/mame/video/simpl156.c
r6740r6741
33*/
44
55#include "driver.h"
6#include "deco16ic.h"
6#include "includes/deco16ic.h"
77
88/*
99
src/mame/video/hcastle.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "video/konamiic.h"
8#include "video/konicdev.h"
9#include "includes/hcastle.h"
910
10UINT8 *hcastle_pf1_videoram,*hcastle_pf2_videoram;
11static int gfx_bank;
1211
13static tilemap *fg_tilemap,*bg_tilemap;
14static int pf2_bankbase,pf1_bankbase;
15
16
1712PALETTE_INIT( hcastle )
1813{
1914   int chip;
r6740r6741
4843
4944static void set_pens(running_machine *machine)
5045{
46   hcastle_state *state = (hcastle_state *)machine->driver_data;
5147   int i;
5248
5349   for (i = 0x00; i < 0x100; i += 2)
5450   {
55      UINT16 data = machine->generic.paletteram.u8[i | 1] | (machine->generic.paletteram.u8[i] << 8);
51      UINT16 data = state->paletteram[i | 1] | (state->paletteram[i] << 8);
5652
5753      rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
5854
r6740r6741
7672
7773static TILE_GET_INFO( get_fg_tile_info )
7874{
79   int bit0 = (K007121_ctrlram[0][0x05] >> 0) & 0x03;
80   int bit1 = (K007121_ctrlram[0][0x05] >> 2) & 0x03;
81   int bit2 = (K007121_ctrlram[0][0x05] >> 4) & 0x03;
82   int bit3 = (K007121_ctrlram[0][0x05] >> 6) & 0x03;
83   int attr = hcastle_pf1_videoram[tile_index];
84   int tile = hcastle_pf1_videoram[tile_index + 0x400];
75   hcastle_state *state = (hcastle_state *)machine->driver_data;
76   UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121_1, 5);
77   UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_1, 6);
78   int bit0 = (ctrl_5 >> 0) & 0x03;
79   int bit1 = (ctrl_5 >> 2) & 0x03;
80   int bit2 = (ctrl_5 >> 4) & 0x03;
81   int bit3 = (ctrl_5 >> 6) & 0x03;
82   int attr = state->pf1_videoram[tile_index];
83   int tile = state->pf1_videoram[tile_index + 0x400];
8584   int color = attr & 0x7;
8685   int bank =  ((attr & 0x80) >> 7) |
87            ((attr >> (bit0+2)) & 0x02) |
88            ((attr >> (bit1+1)) & 0x04) |
89            ((attr >> (bit2  )) & 0x08) |
90            ((attr >> (bit3-1)) & 0x10);
86            ((attr >> (bit0 + 2)) & 0x02) |
87            ((attr >> (bit1 + 1)) & 0x04) |
88            ((attr >> (bit2    )) & 0x08) |
89            ((attr >> (bit3 - 1)) & 0x10);
9190
9291   SET_TILE_INFO(
9392         0,
94         tile + bank*0x100 + pf1_bankbase,
95         ((K007121_ctrlram[0][6]&0x30)*2+16) + color,
93         tile + bank * 0x100 + state->pf1_bankbase,
94         ((ctrl_6 & 0x30) * 2 + 16) + color,
9695         0);
9796}
9897
9998static TILE_GET_INFO( get_bg_tile_info )
10099{
101   int bit0 = (K007121_ctrlram[1][0x05] >> 0) & 0x03;
102   int bit1 = (K007121_ctrlram[1][0x05] >> 2) & 0x03;
103   int bit2 = (K007121_ctrlram[1][0x05] >> 4) & 0x03;
104   int bit3 = (K007121_ctrlram[1][0x05] >> 6) & 0x03;
105   int attr = hcastle_pf2_videoram[tile_index];
106   int tile = hcastle_pf2_videoram[tile_index + 0x400];
100   hcastle_state *state = (hcastle_state *)machine->driver_data;
101   UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121_2, 5);
102   UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_2, 6);
103   int bit0 = (ctrl_5 >> 0) & 0x03;
104   int bit1 = (ctrl_5 >> 2) & 0x03;
105   int bit2 = (ctrl_5 >> 4) & 0x03;
106   int bit3 = (ctrl_5 >> 6) & 0x03;
107   int attr = state->pf2_videoram[tile_index];
108   int tile = state->pf2_videoram[tile_index + 0x400];
107109   int color = attr & 0x7;
108110   int bank =  ((attr & 0x80) >> 7) |
109            ((attr >> (bit0+2)) & 0x02) |
110            ((attr >> (bit1+1)) & 0x04) |
111            ((attr >> (bit2  )) & 0x08) |
112            ((attr >> (bit3-1)) & 0x10);
111            ((attr >> (bit0 + 2)) & 0x02) |
112            ((attr >> (bit1 + 1)) & 0x04) |
113            ((attr >> (bit2    )) & 0x08) |
114            ((attr >> (bit3 - 1)) & 0x10);
113115
114116   SET_TILE_INFO(
115117         1,
116         tile + bank*0x100 + pf2_bankbase,
117         ((K007121_ctrlram[1][6]&0x30)*2+16) + color,
118         tile + bank * 0x100 + state->pf2_bankbase,
119         ((ctrl_6 & 0x30) * 2 + 16) + color,
118120         0);
119121}
120122
r6740r6741
128130
129131VIDEO_START( hcastle )
130132{
131   fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan,8,8,64,32);
132   bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan,     8,8,64,32);
133   hcastle_state *state = (hcastle_state *)machine->driver_data;
133134
134   tilemap_set_transparent_pen(fg_tilemap,0);
135   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan, 8, 8, 64, 32);
136   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan, 8, 8, 64, 32);
137
138   tilemap_set_transparent_pen(state->fg_tilemap, 0);
135139}
136140
137141
r6740r6741
144148
145149WRITE8_HANDLER( hcastle_pf1_video_w )
146150{
147   hcastle_pf1_videoram[offset] = data;
148   tilemap_mark_tile_dirty(fg_tilemap,offset & 0xbff);
151   hcastle_state *state = (hcastle_state *)space->machine->driver_data;
152   state->pf1_videoram[offset] = data;
153   tilemap_mark_tile_dirty(state->fg_tilemap, offset & 0xbff);
149154}
150155
151156WRITE8_HANDLER( hcastle_pf2_video_w )
152157{
153   hcastle_pf2_videoram[offset] = data;
154   tilemap_mark_tile_dirty(bg_tilemap,offset & 0xbff);
158   hcastle_state *state = (hcastle_state *)space->machine->driver_data;
159   state->pf2_videoram[offset] = data;
160   tilemap_mark_tile_dirty(state->bg_tilemap, offset & 0xbff);
155161}
156162
157163WRITE8_HANDLER( hcastle_gfxbank_w )
158164{
159   gfx_bank = data;
165   hcastle_state *state = (hcastle_state *)space->machine->driver_data;
166   state->gfx_bank = data;
160167}
161168
162169READ8_HANDLER( hcastle_gfxbank_r )
163170{
164   return gfx_bank;
171   hcastle_state *state = (hcastle_state *)space->machine->driver_data;
172   return state->gfx_bank;
165173}
166174
167175WRITE8_HANDLER( hcastle_pf1_control_w )
168176{
169   if (offset==3)
177   hcastle_state *state = (hcastle_state *)space->machine->driver_data;
178
179   if (offset == 3)
170180   {
171      if ((data&0x8)==0)
172         buffer_spriteram(space->machine, space->machine->generic.spriteram.u8+0x800,0x800);
181      if ((data & 0x8) == 0)
182         buffer_spriteram(space->machine, space->machine->generic.spriteram.u8 + 0x800, 0x800);
173183      else
174         buffer_spriteram(space->machine, space->machine->generic.spriteram.u8,0x800);
184         buffer_spriteram(space->machine, space->machine->generic.spriteram.u8, 0x800);
175185   }
176186   else if (offset == 7)
177187   {
178      tilemap_set_flip(fg_tilemap, (data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
188      tilemap_set_flip(state->fg_tilemap, (data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
179189   }
180   K007121_ctrl_0_w(space,offset,data);
190   k007121_ctrl_w(state->k007121_1, offset, data);
181191}
182192
183193WRITE8_HANDLER( hcastle_pf2_control_w )
184194{
185   if (offset==3)
195   hcastle_state *state = (hcastle_state *)space->machine->driver_data;
196
197   if (offset == 3)
186198   {
187      if ((data&0x8)==0)
188         buffer_spriteram_2(space->machine,space->machine->generic.spriteram2.u8+0x800,0x800);
199      if ((data & 0x8) == 0)
200         buffer_spriteram_2(space->machine, space->machine->generic.spriteram2.u8 + 0x800, 0x800);
189201      else
190         buffer_spriteram_2(space->machine,space->machine->generic.spriteram2.u8,0x800);
202         buffer_spriteram_2(space->machine, space->machine->generic.spriteram2.u8, 0x800);
191203   }
192204   else if (offset == 7)
193205   {
194      tilemap_set_flip(bg_tilemap, (data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
206      tilemap_set_flip(state->bg_tilemap, (data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
195207   }
196   K007121_ctrl_1_w(space,offset,data);
208   k007121_ctrl_w(state->k007121_2, offset, data);
197209}
198210
199211/*****************************************************************************/
200212
201213static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 *sbank, int bank )
202214{
203   int bank_base = (bank == 0) ? 0x4000 * (gfx_bank & 1) : 0;
204   K007121_sprites_draw(bank,bitmap,cliprect,machine->gfx,machine->colortable,sbank,(K007121_ctrlram[bank][6]&0x30)*2,0,bank_base,-1);
215   hcastle_state *state = (hcastle_state *)machine->driver_data;
216   const device_config *k007121 = bank ? state->k007121_2 : state->k007121_1;
217   int base_color = (k007121_ctrlram_r(k007121, 6) & 0x30) * 2;
218   int bank_base = (bank == 0) ? 0x4000 * (state->gfx_bank & 1) : 0;
219
220   k007121_sprites_draw(k007121, bitmap, cliprect, machine->gfx[bank], machine->colortable, sbank, base_color, 0, bank_base, -1);
205221}
206222
207223/*****************************************************************************/
208224
209225VIDEO_UPDATE( hcastle )
210226{
211   static int old_pf1,old_pf2;
227   hcastle_state *state = (hcastle_state *)screen->machine->driver_data;
212228
229   UINT8 ctrl_1_0 = k007121_ctrlram_r(state->k007121_1, 0);
230   UINT8 ctrl_1_1 = k007121_ctrlram_r(state->k007121_1, 1);
231   UINT8 ctrl_1_2 = k007121_ctrlram_r(state->k007121_1, 2);
232   UINT8 ctrl_1_3 = k007121_ctrlram_r(state->k007121_1, 3);
233   UINT8 ctrl_2_0 = k007121_ctrlram_r(state->k007121_2, 0);
234   UINT8 ctrl_2_1 = k007121_ctrlram_r(state->k007121_2, 1);
235   UINT8 ctrl_2_2 = k007121_ctrlram_r(state->k007121_2, 2);
236   UINT8 ctrl_2_3 = k007121_ctrlram_r(state->k007121_2, 3);
237
213238   set_pens(screen->machine);
214239
215   pf1_bankbase = 0x0000;
216   pf2_bankbase = 0x4000 * ((gfx_bank & 2) >> 1);
240   state->pf1_bankbase = 0x0000;
241   state->pf2_bankbase = 0x4000 * ((state->gfx_bank & 2) >> 1);
217242
218   if (K007121_ctrlram[0][3] & 0x01) pf1_bankbase += 0x2000;
219   if (K007121_ctrlram[1][3] & 0x01) pf2_bankbase += 0x2000;
243   if (ctrl_1_3 & 0x01)
244      state->pf1_bankbase += 0x2000;
245   if (ctrl_2_3 & 0x01)
246      state->pf2_bankbase += 0x2000;
220247
221   if (pf1_bankbase != old_pf1)
222      tilemap_mark_all_tiles_dirty(fg_tilemap);
248   if (state->pf1_bankbase != state->old_pf1)
249      tilemap_mark_all_tiles_dirty(state->fg_tilemap);
223250
224   if (pf2_bankbase != old_pf2)
225      tilemap_mark_all_tiles_dirty(bg_tilemap);
251   if (state->pf2_bankbase != state->old_pf2)
252      tilemap_mark_all_tiles_dirty(state->bg_tilemap);
226253
227   old_pf1 = pf1_bankbase;
228   old_pf2 = pf2_bankbase;
254   state->old_pf1 = state->pf1_bankbase;
255   state->old_pf2 = state->pf2_bankbase;
229256
230   tilemap_set_scrolly(bg_tilemap,0,K007121_ctrlram[1][2]);
231   tilemap_set_scrollx(bg_tilemap,0,((K007121_ctrlram[1][1]<<8)+K007121_ctrlram[1][0]));
232   tilemap_set_scrolly(fg_tilemap,0,K007121_ctrlram[0][2]);
233   tilemap_set_scrollx(fg_tilemap,0,((K007121_ctrlram[0][1]<<8)+K007121_ctrlram[0][0]));
257   tilemap_set_scrolly(state->bg_tilemap, 0, ctrl_2_2);
258   tilemap_set_scrollx(state->bg_tilemap, 0, ((ctrl_2_1 << 8) + ctrl_2_0));
259   tilemap_set_scrolly(state->fg_tilemap, 0, ctrl_1_2);
260   tilemap_set_scrollx(state->fg_tilemap, 0, ((ctrl_1_1 << 8) + ctrl_1_0));
234261
235262//  /* Sprite priority */
236//  if (K007121_ctrlram[0][3]&0x20)
237   if ((gfx_bank & 0x04) == 0)
263//  if (ctrl_1_3 & 0x20)
264   if ((state->gfx_bank & 0x04) == 0)
238265   {
239      tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
240      draw_sprites(screen->machine,bitmap,cliprect, screen->machine->generic.buffered_spriteram.u8, 0 );
241      draw_sprites(screen->machine,bitmap,cliprect, screen->machine->generic.buffered_spriteram2.u8, 1 );
242      tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
266      tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
267      draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram.u8, 0);
268      draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram2.u8, 1);
269      tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
243270   }
244271   else
245272   {
246      tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
247      tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
248      draw_sprites(screen->machine,bitmap,cliprect, screen->machine->generic.buffered_spriteram.u8, 0 );
249      draw_sprites(screen->machine,bitmap,cliprect, screen->machine->generic.buffered_spriteram2.u8, 1 );
273      tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
274      tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
275      draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram.u8, 0);
276      draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram2.u8, 1);
250277   }
251278   return 0;
252279}
src/mame/video/copsnrob.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "copsnrob.h"
8#include "includes/copsnrob.h"
99
1010
1111VIDEO_UPDATE( copsnrob )
src/mame/video/artmagic.c
r6740r6741
88#include "profiler.h"
99#include "cpu/tms34010/tms34010.h"
1010#include "video/tlc34076.h"
11#include "artmagic.h"
11#include "includes/artmagic.h"
1212
1313
1414#define INSTANT_BLIT      1
r6740r6741
6161   blitter_base = (UINT16 *)memory_region(machine, "gfx1");
6262   blitter_mask = memory_region_length(machine, "gfx1")/2 - 1;
6363
64   tlc34076_state_save(machine);
6465   state_save_register_global_array(machine, artmagic_xor);
6566   state_save_register_global(machine, artmagic_is_stoneball);
6667   state_save_register_global_array(machine, blitter_data);
src/mame/video/twincobr.c
r6740r6741
1414
1515#include "driver.h"
1616#include "video/mc6845.h"
17#include "twincobr.h"
17#include "includes/twincobr.h"
1818
1919
2020static STATE_POSTLOAD( twincobr_restore_screen );
src/mame/video/battlnts.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
3#include "includes/battlnts.h"
34
4static int spritebank;
5
6static int layer_colorbase[2];
7
85/***************************************************************************
96
107  Callback for the K007342
118
129***************************************************************************/
1310
14static void tile_callback(int layer, int bank, int *code, int *color, int *flags)
11void battlnts_tile_callback(running_machine *machine, int layer, int bank, int *code, int *color, int *flags)
1512{
13   battlnts_state *state = (battlnts_state *)machine->driver_data;
14
1615   *code |= ((*color & 0x0f) << 9) | ((*color & 0x40) << 2);
17   *color = layer_colorbase[layer];
16   *color = state->layer_colorbase[layer];
1817}
1918
2019/***************************************************************************
r6740r6741
2322
2423***************************************************************************/
2524
26static void sprite_callback(int *code,int *color)
25void battlnts_sprite_callback(running_machine *machine, int *code,int *color)
2726{
28   *code |= ((*color & 0xc0) << 2) | spritebank;
27   battlnts_state *state = (battlnts_state *)machine->driver_data;
28
29   *code |= ((*color & 0xc0) << 2) | state->spritebank;
2930   *code = (*code << 2) | ((*color & 0x30) >> 4);
3031   *color = 0;
3132}
3233
3334WRITE8_HANDLER( battlnts_spritebank_w )
3435{
35   spritebank = 1024 * (data & 1);
36   battlnts_state *state = (battlnts_state *)space->machine->driver_data;
37   state->spritebank = 1024 * (data & 1);
3638}
3739
3840/***************************************************************************
3941
40    Start the video hardware emulation.
42  Screen Refresh
4143
4244***************************************************************************/
4345
44VIDEO_START( battlnts )
46VIDEO_UPDATE( battlnts )
4547{
46   layer_colorbase[0] = 0;
47   layer_colorbase[1] = 0;
48   battlnts_state *state = (battlnts_state *)screen->machine->driver_data;
4849
49   K007342_vh_start(machine,0,tile_callback);
50   K007420_vh_start(machine,1,sprite_callback);
51}
50   k007342_tilemap_update(state->k007342);
5251
53/***************************************************************************
54
55  Screen Refresh
56
57***************************************************************************/
58
59VIDEO_UPDATE( battlnts ){
60
61   K007342_tilemap_update();
62
63   K007342_tilemap_draw( bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE ,0);
64   K007420_sprites_draw( bitmap, cliprect );
65   K007342_tilemap_draw( bitmap, cliprect, 0, 1 | TILEMAP_DRAW_OPAQUE ,0);
52   k007342_tilemap_draw(state->k007342, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE ,0);
53   k007420_sprites_draw(state->k007420, bitmap, cliprect, screen->machine->gfx[1]);
54   k007342_tilemap_draw(state->k007342, bitmap, cliprect, 0, 1 | TILEMAP_DRAW_OPAQUE ,0);
6655   return 0;
6756}
src/mame/video/arabian.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "arabian.h"
10#include "includes/arabian.h"
1111
1212/* Constants */
1313#define BITMAP_WIDTH      256
src/mame/video/galpani2.c
r6740r6741
88***************************************************************************/
99
1010#include "driver.h"
11#include "kaneko16.h"
11#include "includes/kaneko16.h"
1212
1313/*
1414304000:0040 0000 0100 0000-0000 0000 0000 0000      (Sprites regs)
src/mame/video/labyrunr.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
3#include "includes/labyrunr.h"
34
4UINT8 *labyrunr_videoram1,*labyrunr_videoram2,*labyrunr_scrollram;
5static tilemap *layer0, *layer1;
6static rectangle clip0, clip1;
7
8
95PALETTE_INIT( labyrunr )
106{
117   int pal;
r6740r6741
4440}
4541
4642
47static void set_pens(running_machine *machine)
43static void set_pens( running_machine *machine )
4844{
45   labyrunr_state *state = (labyrunr_state *)machine->driver_data;
4946   int i;
5047
5148   for (i = 0x00; i < 0x100; i += 2)
5249   {
53      UINT16 data = machine->generic.paletteram.u8[i | 1] | (machine->generic.paletteram.u8[i] << 8);
50      UINT16 data = state->paletteram[i | 1] | (state->paletteram[i] << 8);
5451
5552      rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
5653
r6740r6741
6865
6966static TILE_GET_INFO( get_tile_info0 )
7067{
71   int attr = labyrunr_videoram1[tile_index];
72   int code = labyrunr_videoram1[tile_index + 0x400];
73   int bit0 = (K007121_ctrlram[0][0x05] >> 0) & 0x03;
74   int bit1 = (K007121_ctrlram[0][0x05] >> 2) & 0x03;
75   int bit2 = (K007121_ctrlram[0][0x05] >> 4) & 0x03;
76   int bit3 = (K007121_ctrlram[0][0x05] >> 6) & 0x03;
68   labyrunr_state *state = (labyrunr_state *)machine->driver_data;
69   UINT8 ctrl_3 = k007121_ctrlram_r(state->k007121, 3);
70   UINT8 ctrl_4 = k007121_ctrlram_r(state->k007121, 4);
71   UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121, 5);
72   UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121, 6);
73   int attr = state->videoram1[tile_index];
74   int code = state->videoram1[tile_index + 0x400];
75   int bit0 = (ctrl_5 >> 0) & 0x03;
76   int bit1 = (ctrl_5 >> 2) & 0x03;
77   int bit2 = (ctrl_5 >> 4) & 0x03;
78   int bit3 = (ctrl_5 >> 6) & 0x03;
7779   int bank = ((attr & 0x80) >> 7) |
7880         ((attr >> (bit0+2)) & 0x02) |
7981         ((attr >> (bit1+1)) & 0x04) |
8082         ((attr >> (bit2  )) & 0x08) |
8183         ((attr >> (bit3-1)) & 0x10) |
82         ((K007121_ctrlram[0][0x03] & 0x01) << 5);
83   int mask = (K007121_ctrlram[0][0x04] & 0xf0) >> 4;
84         ((ctrl_3 & 0x01) << 5);
85   int mask = (ctrl_4 & 0xf0) >> 4;
8486
85   bank = (bank & ~(mask << 1)) | ((K007121_ctrlram[0][0x04] & mask) << 1);
87   bank = (bank & ~(mask << 1)) | ((ctrl_4 & mask) << 1);
8688
8789   SET_TILE_INFO(
8890         0,
89         code+bank*256,
90         ((K007121_ctrlram[0][6]&0x30)*2+16)+(attr&7),
91         code + bank * 256,
92         ((ctrl_6 & 0x30) * 2 + 16)+(attr & 7),
9193         0);
9294}
9395
9496static TILE_GET_INFO( get_tile_info1 )
9597{
96   int attr = labyrunr_videoram2[tile_index];
97   int code = labyrunr_videoram2[tile_index + 0x400];
98   int bit0 = (K007121_ctrlram[0][0x05] >> 0) & 0x03;
99   int bit1 = (K007121_ctrlram[0][0x05] >> 2) & 0x03;
100   int bit2 = (K007121_ctrlram[0][0x05] >> 4) & 0x03;
101   int bit3 = (K007121_ctrlram[0][0x05] >> 6) & 0x03;
98   labyrunr_state *state = (labyrunr_state *)machine->driver_data;
99   UINT8 ctrl_3 = k007121_ctrlram_r(state->k007121, 3);
100   UINT8 ctrl_4 = k007121_ctrlram_r(state->k007121, 4);
101   UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121, 5);
102   UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121, 6);
103   int attr = state->videoram2[tile_index];
104   int code = state->videoram2[tile_index + 0x400];
105   int bit0 = (ctrl_5 >> 0) & 0x03;
106   int bit1 = (ctrl_5 >> 2) & 0x03;
107   int bit2 = (ctrl_5 >> 4) & 0x03;
108   int bit3 = (ctrl_5 >> 6) & 0x03;
102109   int bank = ((attr & 0x80) >> 7) |
103110         ((attr >> (bit0+2)) & 0x02) |
104111         ((attr >> (bit1+1)) & 0x04) |
105112         ((attr >> (bit2  )) & 0x08) |
106113         ((attr >> (bit3-1)) & 0x10) |
107         ((K007121_ctrlram[0][0x03] & 0x01) << 5);
108   int mask = (K007121_ctrlram[0][0x04] & 0xf0) >> 4;
114         ((ctrl_3 & 0x01) << 5);
115   int mask = (ctrl_4 & 0xf0) >> 4;
109116
110   bank = (bank & ~(mask << 1)) | ((K007121_ctrlram[0][0x04] & mask) << 1);
117   bank = (bank & ~(mask << 1)) | ((ctrl_4 & mask) << 1);
111118
112119   SET_TILE_INFO(
113120         0,
114121         code+bank*256,
115         ((K007121_ctrlram[0][6]&0x30)*2+16)+(attr&7),
122         ((ctrl_6 & 0x30) * 2 + 16) + (attr & 7),
116123         0);
117124}
118125
r6740r6741
125132
126133VIDEO_START( labyrunr )
127134{
128   layer0 = tilemap_create(machine, get_tile_info0,tilemap_scan_rows,8,8,32,32);
129   layer1 = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,8,8,32,32);
135   labyrunr_state *state = (labyrunr_state *)machine->driver_data;
130136
131   tilemap_set_transparent_pen(layer0,0);
132   tilemap_set_transparent_pen(layer1,0);
137   state->layer0 = tilemap_create(machine, get_tile_info0, tilemap_scan_rows, 8, 8, 32, 32);
138   state->layer1 = tilemap_create(machine, get_tile_info1, tilemap_scan_rows, 8, 8, 32, 32);
133139
134   clip0 = *video_screen_get_visible_area(machine->primary_screen);
135   clip0.min_x += 40;
140   tilemap_set_transparent_pen(state->layer0, 0);
141   tilemap_set_transparent_pen(state->layer1, 0);
136142
137   clip1 = *video_screen_get_visible_area(machine->primary_screen);
138   clip1.max_x = 39;
139   clip1.min_x = 0;
143   state->clip0 = *video_screen_get_visible_area(machine->primary_screen);
144   state->clip0.min_x += 40;
140145
141   tilemap_set_scroll_cols(layer0,32);
146   state->clip1 = *video_screen_get_visible_area(machine->primary_screen);
147   state->clip1.max_x = 39;
148   state->clip1.min_x = 0;
149
150   tilemap_set_scroll_cols(state->layer0, 32);
142151}
143152
144153
r6740r6741
151160
152161WRITE8_HANDLER( labyrunr_vram1_w )
153162{
154   labyrunr_videoram1[offset] = data;
155   tilemap_mark_tile_dirty(layer0,offset & 0x3ff);
163   labyrunr_state *state = (labyrunr_state *)space->machine->driver_data;
164   state->videoram1[offset] = data;
165   tilemap_mark_tile_dirty(state->layer0, offset & 0x3ff);
156166}
157167
158168WRITE8_HANDLER( labyrunr_vram2_w )
159169{
160   labyrunr_videoram2[offset] = data;
161   tilemap_mark_tile_dirty(layer1,offset & 0x3ff);
170   labyrunr_state *state = (labyrunr_state *)space->machine->driver_data;
171   state->videoram2[offset] = data;
172   tilemap_mark_tile_dirty(state->layer1, offset & 0x3ff);
162173}
163174
164175
r6740r6741
171182
172183VIDEO_UPDATE( labyrunr )
173184{
185   labyrunr_state *state = (labyrunr_state *)screen->machine->driver_data;
186   UINT8 ctrl_0 = k007121_ctrlram_r(state->k007121, 0);
174187   rectangle finalclip0, finalclip1;
175188
176189   set_pens(screen->machine);
177190
178   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
179   bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
191   bitmap_fill(screen->machine->priority_bitmap, cliprect,0);
192   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
180193
181   if(~K007121_ctrlram[0][3] & 0x20)
194   if (~k007121_ctrlram_r(state->k007121, 3) & 0x20)
182195   {
183196      int i;
184197
185      finalclip0 = clip0;
186      finalclip1 = clip1;
198      finalclip0 = state->clip0;
199      finalclip1 = state->clip1;
187200
188201      sect_rect(&finalclip0, cliprect);
189202      sect_rect(&finalclip1, cliprect);
190203
191      tilemap_set_scrollx(layer0,0,K007121_ctrlram[0][0x00] - 40);
192      tilemap_set_scrollx(layer1,0,0);
204      tilemap_set_scrollx(state->layer0, 0, ctrl_0 - 40);
205      tilemap_set_scrollx(state->layer1, 0, 0);
193206
194207      for(i = 0; i < 32; i++)
195208      {
196209         /* enable colscroll */
197         if((K007121_ctrlram[0][1] & 6) == 6) // it's probably just one bit, but it's only used once in the game so I don't know which it's
198            tilemap_set_scrolly(layer0,(i+2) & 0x1f,K007121_ctrlram[0][0x02] + labyrunr_scrollram[i]);
210         if((k007121_ctrlram_r(state->k007121, 1) & 6) == 6) // it's probably just one bit, but it's only used once in the game so I don't know which it's
211            tilemap_set_scrolly(state->layer0, (i + 2) & 0x1f, k007121_ctrlram_r(state->k007121, 2) + state->scrollram[i]);
199212         else
200            tilemap_set_scrolly(layer0,(i+2) & 0x1f,K007121_ctrlram[0][0x02]);
213            tilemap_set_scrolly(state->layer0, (i + 2) & 0x1f, k007121_ctrlram_r(state->k007121, 2));
201214      }
202215
203      tilemap_draw(bitmap,&finalclip0,layer0,TILEMAP_DRAW_OPAQUE,0);
204      K007121_sprites_draw(0,bitmap,cliprect,screen->machine->gfx,screen->machine->colortable,screen->machine->generic.spriteram.u8,(K007121_ctrlram[0][6]&0x30)*2,40,0,(K007121_ctrlram[0][3] & 0x40) >> 5);
216      tilemap_draw(bitmap, &finalclip0, state->layer0, TILEMAP_DRAW_OPAQUE, 0);
217      k007121_sprites_draw(state->k007121, bitmap, cliprect, screen->machine->gfx[0], screen->machine->colortable, state->spriteram,(k007121_ctrlram_r(state->k007121, 6) & 0x30) * 2, 40,0,(k007121_ctrlram_r(state->k007121, 3) & 0x40) >> 5);
205218      /* we ignore the transparency because layer1 is drawn only at the top of the screen also covering sprites */
206      tilemap_draw(bitmap,&finalclip1,layer1,TILEMAP_DRAW_OPAQUE,0);
219      tilemap_draw(bitmap, &finalclip1, state->layer1, TILEMAP_DRAW_OPAQUE, 0);
207220   }
208221   else
209222   {
r6740r6741
214227      finalclip0.min_y = finalclip1.min_y = cliprect->min_y;
215228      finalclip0.max_y = finalclip1.max_y = cliprect->max_y;
216229
217      if(K007121_ctrlram[0][1] & 1)
230      if(k007121_ctrlram_r(state->k007121, 1) & 1)
218231      {
219         finalclip0.min_x = cliprect->max_x - K007121_ctrlram[0][0x00] + 8;
232         finalclip0.min_x = cliprect->max_x - ctrl_0 + 8;
220233         finalclip0.max_x = cliprect->max_x;
221234
222         if(K007121_ctrlram[0][0x00] >= 40)
235         if(ctrl_0 >= 40)
223236         {
224237            finalclip1.min_x = cliprect->min_x;
225238         }
r6740r6741
227240         {
228241            use_clip3[0] = 1;
229242
230            finalclip1.min_x = 40 - K007121_ctrlram[0][0x00];
243            finalclip1.min_x = 40 - ctrl_0;
231244         }
232245
233         finalclip1.max_x = cliprect->max_x - K007121_ctrlram[0][0x00] + 8;
246         finalclip1.max_x = cliprect->max_x - ctrl_0 + 8;
234247
235248      }
236249      else
237250      {
238         if(K007121_ctrlram[0][0x00] >= 40)
251         if(ctrl_0 >= 40)
239252         {
240253            finalclip0.min_x = cliprect->min_x;
241254         }
r6740r6741
243256         {
244257            use_clip3[1] = 1;
245258
246            finalclip0.min_x = 40 - K007121_ctrlram[0][0x00];
259            finalclip0.min_x = 40 - ctrl_0;
247260         }
248261
249         finalclip0.max_x = cliprect->max_x - K007121_ctrlram[0][0x00] + 8;
262         finalclip0.max_x = cliprect->max_x - ctrl_0 + 8;
250263
251         finalclip1.min_x = cliprect->max_x - K007121_ctrlram[0][0x00] + 8;
264         finalclip1.min_x = cliprect->max_x - ctrl_0 + 8;
252265         finalclip1.max_x = cliprect->max_x;
253266      }
254267
r6740r6741
257270         finalclip3.min_y = cliprect->min_y;
258271         finalclip3.max_y = cliprect->max_y;
259272         finalclip3.min_x = cliprect->min_x;
260         finalclip3.max_x = 40 - K007121_ctrlram[0][0x00] - 8;
273         finalclip3.max_x = 40 - ctrl_0 - 8;
261274      }
262275
263      tilemap_set_scrollx(layer0,0,K007121_ctrlram[0][0x00] - 40);
264      tilemap_set_scrollx(layer1,0,K007121_ctrlram[0][0x00] - 40);
276      tilemap_set_scrollx(state->layer0, 0, ctrl_0 - 40);
277      tilemap_set_scrollx(state->layer1, 0, ctrl_0 - 40);
265278
266      tilemap_draw(bitmap,&finalclip0,layer0,0,1);
267      if(use_clip3[0]) tilemap_draw(bitmap,&finalclip3,layer0,0,1);
279      tilemap_draw(bitmap, &finalclip0, state->layer0, 0, 1);
280      if(use_clip3[0])
281         tilemap_draw(bitmap, &finalclip3, state->layer0, 0, 1);
268282
269      tilemap_draw(bitmap,&finalclip1,layer1,0,1);
270      if(use_clip3[1]) tilemap_draw(bitmap,&finalclip3,layer1,0,1);
283      tilemap_draw(bitmap, &finalclip1, state->layer1, 0, 1);
284      if(use_clip3[1])
285         tilemap_draw(bitmap, &finalclip3, state->layer1, 0, 1);
271286
272      K007121_sprites_draw(0,bitmap,cliprect,screen->machine->gfx,screen->machine->colortable,screen->machine->generic.spriteram.u8,(K007121_ctrlram[0][6]&0x30)*2,40,0,(K007121_ctrlram[0][3] & 0x40) >> 5);
287      k007121_sprites_draw(state->k007121, bitmap, cliprect, screen->machine->gfx[0], screen->machine->colortable, state->spriteram, (k007121_ctrlram_r(state->k007121, 6) & 0x30) * 2,40,0,(k007121_ctrlram_r(state->k007121, 3) & 0x40) >> 5);
273288   }
274289   return 0;
275290}
src/mame/video/ccastles.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "ccastles.h"
8#include "includes/ccastles.h"
99#include "video/resnet.h"
1010
1111
src/mame/video/ddragon3.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "ddragon3.h"
8#include "includes/ddragon3.h"
99
1010WRITE16_HANDLER( ddragon3_scroll_w )
1111{
src/mame/video/exterm.c
r6740r6741
66
77#include "driver.h"
88#include "cpu/tms34010/tms34010.h"
9#include "exterm.h"
9#include "includes/exterm.h"
1010
1111
1212UINT16 *exterm_master_videoram, *exterm_slave_videoram;
src/mame/video/ambush.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "ambush.h"
10#include "includes/ambush.h"
1111
1212
1313/***************************************************************************
src/mame/video/policetr.c
r6740r6741
66
77#include "driver.h"
88#include "cpu/mips/r3000.h"
9#include "policetr.h"
9#include "includes/policetr.h"
1010
1111
1212/* constants */
src/mame/video/midtunit.c
r6740r6741
77#include "driver.h"
88#include "profiler.h"
99#include "cpu/tms34010/tms34010.h"
10#include "midtunit.h"
10#include "includes/midtunit.h"
1111
1212
1313/* compile-time options */
src/mame/video/drmicro.c
r6740r6741
88*******************************************************************************/
99
1010#include "driver.h"
11#include "drmicro.h"
11#include "includes/drmicro.h"
1212
1313
1414/****************************************************************************/
src/mame/video/carpolo.c
r6740r6741
77****************************************************************************/
88
99#include "driver.h"
10#include "carpolo.h"
10#include "includes/carpolo.h"
1111
1212
1313UINT8 *carpolo_alpharam;
src/mame/video/speedatk.c
r6740r6741
55*****************************************************************************************/
66#include "driver.h"
77
8UINT8 *speedatk_videoram;
9UINT8 *speedatk_colorram;
810static tilemap *bg_tilemap;
911
1012/*
r6740r6741
7577
7678WRITE8_HANDLER( speedatk_videoram_w )
7779{
78   space->machine->generic.videoram.u8[offset] = data;
80   speedatk_videoram[offset] = data;
7981   tilemap_mark_tile_dirty(bg_tilemap, offset);
8082}
8183
8284WRITE8_HANDLER( speedatk_colorram_w )
8385{
84   space->machine->generic.colorram.u8[offset] = data;
86   speedatk_colorram[offset] = data;
8587   tilemap_mark_tile_dirty(bg_tilemap, offset);
8688}
8789
r6740r6741
8991{
9092   int code, color, region;
9193
92   code = machine->generic.videoram.u8[tile_index] + ((machine->generic.colorram.u8[tile_index] & 0xe0) << 3);
93   color = machine->generic.colorram.u8[tile_index] & 0x1f;
94   region = (machine->generic.colorram.u8[tile_index] & 0x10) >> 4;
94   code = speedatk_videoram[tile_index] + ((speedatk_colorram[tile_index] & 0xe0) << 3);
95   color = speedatk_colorram[tile_index] & 0x1f;
96   region = (speedatk_colorram[tile_index] & 0x10) >> 4;
9597
9698   SET_TILE_INFO(region, code, color, 0);
9799}
src/mame/video/stvvdp2.c
r6740r6741
17531753       \----------|----------|----------|----------|----------|----------|----------|---------*/
17541754
17551755   #define STV_VDP2_LNCLEN   ((stv_vdp2_regs[0x0e8/4] >> 16)&0x0000ffff)
1756   #define STV_VDP2_SPLCEN   ((STV_VDP2_LNCLEN) & 0x0020) >> 5)
1757   #define STV_VDP2_R0LCEN   ((STV_VDP2_LNCLEN) & 0x0010) >> 4)
1758   #define STV_VDP2_N3LCEN   ((STV_VDP2_LNCLEN) & 0x0008) >> 3)
1759   #define STV_VDP2_N2LCEN   ((STV_VDP2_LNCLEN) & 0x0004) >> 2)
1760   #define STV_VDP2_N1LCEN   ((STV_VDP2_LNCLEN) & 0x0002) >> 1)
1761   #define STV_VDP2_N0LCEN   ((STV_VDP2_LNCLEN) & 0x0001) >> 0)
1756   #define STV_VDP2_SPLCEN   ((STV_VDP2_LNCLEN & 0x0020) >> 5)
1757   #define STV_VDP2_R0LCEN   ((STV_VDP2_LNCLEN & 0x0010) >> 4)
1758   #define STV_VDP2_N3LCEN   ((STV_VDP2_LNCLEN & 0x0008) >> 3)
1759   #define STV_VDP2_N2LCEN   ((STV_VDP2_LNCLEN & 0x0004) >> 2)
1760   #define STV_VDP2_N1LCEN   ((STV_VDP2_LNCLEN & 0x0002) >> 1)
1761   #define STV_VDP2_N0LCEN   ((STV_VDP2_LNCLEN & 0x0001) >> 0)
17621762
17631763/* 1800ea - Special Priority Mode
17641764 bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
src/mame/video/exedexes.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "exedexes.h"
10#include "includes/exedexes.h"
1111
1212
1313#define TileMap(offs) (memory_region(machine, "gfx5")[offs])
src/mame/video/jedi.c
r6740r6741
1515***************************************************************************/
1616
1717#include "driver.h"
18#include "jedi.h"
18#include "includes/jedi.h"
1919
2020
2121#define NUM_PENS   (0x1000)
src/mame/video/seta2.c
r6740r6741
7171***************************************************************************/
7272
7373#include "driver.h"
74#include "seta.h"
74#include "includes/seta.h"
7575
7676UINT16 *seta2_vregs;
7777
src/mame/video/flkatck.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "video/konamiic.h"
8#include "video/konicdev.h"
9#include "includes/flkatck.h"
910
10static tilemap *k007121_tilemap[2];
11static rectangle k007121_clip[2];
12
13UINT8 *k007121_ram;
14
15int flkatck_irq_enabled;
16
17static int k007121_flip_screen = 0;
18
1911/***************************************************************************
2012
2113  Callbacks for the K007121
r6740r6741
2416
2517static TILE_GET_INFO( get_tile_info_A )
2618{
27   int attr = k007121_ram[tile_index];
28   int code = k007121_ram[tile_index+0x400];
29   int bit0 = (K007121_ctrlram[0][0x05] >> 0) & 0x03;
30   int bit1 = (K007121_ctrlram[0][0x05] >> 2) & 0x03;
31   int bit2 = (K007121_ctrlram[0][0x05] >> 4) & 0x03;
32   int bit3 = (K007121_ctrlram[0][0x05] >> 6) & 0x03;
19   flkatck_state *state = (flkatck_state *)machine->driver_data;
20   UINT8 ctrl_0 = k007121_ctrlram_r(state->k007121, 0);
21   UINT8 ctrl_2 = k007121_ctrlram_r(state->k007121, 2);
22   UINT8 ctrl_3 = k007121_ctrlram_r(state->k007121, 3);
23   UINT8 ctrl_4 = k007121_ctrlram_r(state->k007121, 4);
24   UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121, 5);
25   int attr = state->k007121_ram[tile_index];
26   int code = state->k007121_ram[tile_index + 0x400];
27   int bit0 = (ctrl_5 >> 0) & 0x03;
28   int bit1 = (ctrl_5 >> 2) & 0x03;
29   int bit2 = (ctrl_5 >> 4) & 0x03;
30   int bit3 = (ctrl_5 >> 6) & 0x03;
3331   int bank = ((attr & 0x80) >> 7) |
34         ((attr >> (bit0+2)) & 0x02) |
35         ((attr >> (bit1+1)) & 0x04) |
32         ((attr >> (bit0 + 2)) & 0x02) |
33         ((attr >> (bit1 + 1)) & 0x04) |
3634         ((attr >> (bit2  )) & 0x08) |
37         ((attr >> (bit3-1)) & 0x10) |
38         ((K007121_ctrlram[0][0x03] & 0x01) << 5);
39   int mask = (K007121_ctrlram[0][0x04] & 0xf0) >> 4;
35         ((attr >> (bit3 - 1)) & 0x10) |
36         ((ctrl_3 & 0x01) << 5);
37   int mask = (ctrl_4 & 0xf0) >> 4;
4038
41   bank = (bank & ~(mask << 1)) | ((K007121_ctrlram[0][0x04] & mask) << 1);
39   bank = (bank & ~(mask << 1)) | ((ctrl_4 & mask) << 1);
4240
43   if ((attr == 0x0d) && (!(K007121_ctrlram[0][0])) && (!(K007121_ctrlram[0][2])))
41   if ((attr == 0x0d) && (!ctrl_0) && (!ctrl_2))
4442      bank = 0;   /*  this allows the game to print text
4543                    in all banks selected by the k007121 */
4644
r6740r6741
5351
5452static TILE_GET_INFO( get_tile_info_B )
5553{
56   int attr = k007121_ram[tile_index+0x800];
57   int code = k007121_ram[tile_index+0xc00];
54   flkatck_state *state = (flkatck_state *)machine->driver_data;
55   int attr = state->k007121_ram[tile_index + 0x800];
56   int code = state->k007121_ram[tile_index + 0xc00];
5857
5958   SET_TILE_INFO(
6059         0,
r6740r6741
7271
7372VIDEO_START( flkatck )
7473{
75   k007121_tilemap[0] = tilemap_create(machine, get_tile_info_A,tilemap_scan_rows,8,8,32,32);
76   k007121_tilemap[1] = tilemap_create(machine, get_tile_info_B,tilemap_scan_rows,8,8,32,32);
77
74   flkatck_state *state = (flkatck_state *)machine->driver_data;
75   state->k007121_tilemap[0] = tilemap_create(machine, get_tile_info_A, tilemap_scan_rows, 8, 8, 32, 32);
76   state->k007121_tilemap[1] = tilemap_create(machine, get_tile_info_B, tilemap_scan_rows, 8, 8, 32, 32);
7877}
7978
8079
r6740r6741
8685
8786WRITE8_HANDLER( flkatck_k007121_w )
8887{
89   k007121_ram[offset] = data;
88   flkatck_state *state = (flkatck_state *)space->machine->driver_data;
89
90   state->k007121_ram[offset] = data;
9091   if (offset < 0x1000)   /* tiles */
9192   {
9293      if (offset & 0x800)   /* score */
93         tilemap_mark_tile_dirty(k007121_tilemap[1],offset & 0x3ff);
94         tilemap_mark_tile_dirty(state->k007121_tilemap[1], offset & 0x3ff);
9495      else
95         tilemap_mark_tile_dirty(k007121_tilemap[0],offset & 0x3ff);
96         tilemap_mark_tile_dirty(state->k007121_tilemap[0], offset & 0x3ff);
9697   }
9798}
9899
99100WRITE8_HANDLER( flkatck_k007121_regs_w )
100101{
102   flkatck_state *state = (flkatck_state *)space->machine->driver_data;
103
101104   switch (offset)
102105   {
103106      case 0x04:   /* ROM bank select */
104         if (data != K007121_ctrlram[0][0x04])
107         if (data != k007121_ctrlram_r(state->k007121, 4))
105108            tilemap_mark_all_tiles_dirty_all(space->machine);
106109         break;
107110
108111      case 0x07:   /* flip screen + IRQ control */
109         k007121_flip_screen = data & 0x08;
110         tilemap_set_flip_all(space->machine, k007121_flip_screen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
111         flkatck_irq_enabled = data & 0x02;
112         state->flipscreen = data & 0x08;
113         tilemap_set_flip_all(space->machine, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
114         state->irq_enabled = data & 0x02;
112115         break;
113116   }
114117
115   K007121_ctrl_0_w(space,offset,data);
118   k007121_ctrl_w(state->k007121, offset, data);
116119}
117120
118121
r6740r6741
131134
132135VIDEO_UPDATE( flkatck )
133136{
134   rectangle final_clip[2];
137   flkatck_state *state = (flkatck_state *)screen->machine->driver_data;
138   rectangle clip[2];
135139   const rectangle *visarea = video_screen_get_visible_area(screen);
136140
137#if 0
138popmessage("%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x  %02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x",
139   K007121_ctrlram[0][0x00],K007121_ctrlram[0][0x01],K007121_ctrlram[0][0x02],K007121_ctrlram[0][0x03],K007121_ctrlram[0][0x04],K007121_ctrlram[0][0x05],K007121_ctrlram[0][0x06],K007121_ctrlram[0][0x07],
140   K007121_ctrlram[1][0x00],K007121_ctrlram[1][0x01],K007121_ctrlram[1][0x02],K007121_ctrlram[1][0x03],K007121_ctrlram[1][0x04],K007121_ctrlram[1][0x05],K007121_ctrlram[1][0x06],K007121_ctrlram[1][0x07]);
141#endif
142   if (k007121_flip_screen)
141   if (state->flipscreen)
143142   {
144      k007121_clip[0] = *visarea;
145      k007121_clip[0].max_x -= 40;
143      clip[0] = *visarea;
144      clip[0].max_x -= 40;
146145
147      k007121_clip[1] = *visarea;
148      k007121_clip[1].min_x = k007121_clip[1].max_x-40;
146      clip[1] = *visarea;
147      clip[1].min_x = clip[1].max_x - 40;
149148
150      tilemap_set_scrollx(k007121_tilemap[0],0,K007121_ctrlram[0][0x00] - 56 );
151      tilemap_set_scrolly(k007121_tilemap[0],0,K007121_ctrlram[0][0x02]);
152      tilemap_set_scrollx(k007121_tilemap[1],0,-16);
149      tilemap_set_scrollx(state->k007121_tilemap[0], 0, k007121_ctrlram_r(state->k007121, 0) - 56 );
150      tilemap_set_scrolly(state->k007121_tilemap[0], 0, k007121_ctrlram_r(state->k007121, 2));
151      tilemap_set_scrollx(state->k007121_tilemap[1], 0, -16);
153152   }
154153   else
155154   {
156      k007121_clip[0] = *visarea;
157      k007121_clip[0].min_x += 40;
155      clip[0] = *visarea;
156      clip[0].min_x += 40;
158157
159      k007121_clip[1] = *visarea;
160      k007121_clip[1].max_x = 39;
161      k007121_clip[1].min_x = 0;
158      clip[1] = *visarea;
159      clip[1].max_x = 39;
160      clip[1].min_x = 0;
162161
163      tilemap_set_scrollx(k007121_tilemap[0],0,K007121_ctrlram[0][0x00] - 40 );
164      tilemap_set_scrolly(k007121_tilemap[0],0,K007121_ctrlram[0][0x02]);
165      tilemap_set_scrollx(k007121_tilemap[1],0,0);
162      tilemap_set_scrollx(state->k007121_tilemap[0], 0, k007121_ctrlram_r(state->k007121, 0) - 40 );
163      tilemap_set_scrolly(state->k007121_tilemap[0], 0, k007121_ctrlram_r(state->k007121, 2));
164      tilemap_set_scrollx(state->k007121_tilemap[1], 0, 0);
166165   }
167166
168167   /* compute clipping */
169   final_clip[0] = k007121_clip[0];
170   final_clip[1] = k007121_clip[1];
171   sect_rect(&final_clip[0], cliprect);
172   sect_rect(&final_clip[1], cliprect);
168   sect_rect(&clip[0], cliprect);
169   sect_rect(&clip[1], cliprect);
173170
174171   /* draw the graphics */
175   tilemap_draw(bitmap,&final_clip[0],k007121_tilemap[0],0,0);
176   K007121_sprites_draw(0,bitmap,cliprect,screen->machine->gfx,NULL,&k007121_ram[0x1000],0,40,0,-1);
177   tilemap_draw(bitmap,&final_clip[1],k007121_tilemap[1],0,0);
172   tilemap_draw(bitmap, &clip[0], state->k007121_tilemap[0], 0, 0);
173   k007121_sprites_draw(state->k007121, bitmap, cliprect, screen->machine->gfx[0], NULL, &state->k007121_ram[0x1000], 0, 40, 0, -1);
174   tilemap_draw(bitmap, &clip[1], state->k007121_tilemap[1], 0, 0);
178175   return 0;
179176}
src/mame/video/namcofl.c
r6740r6741
11/* video/namcofl.c */
22
33#include "driver.h"
4#include "namconb1.h"
5#include "namcoic.h"
6#include "namcos2.h"
4#include "includes/namconb1.h"
5#include "includes/namcoic.h"
6#include "includes/namcos2.h"
77
88//UINT32 *namcofl_spritebank32;
99//UINT32 *namcofl_tilebank32;
src/mame/video/contra.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "video/konamiic.h"
8#include "video/konicdev.h"
9#include "includes/contra.h"
910
10//static int spriteram_offset;
11static UINT8 *private_spriteram_2,*private_spriteram;
1211
13UINT8 *contra_fg_vram,*contra_fg_cram;
14UINT8 *contra_text_vram,*contra_text_cram;
15UINT8 *contra_bg_vram,*contra_bg_cram;
16
17static tilemap *bg_tilemap, *fg_tilemap, *tx_tilemap;
18static rectangle bg_clip, fg_clip, tx_clip;
19
2012/***************************************************************************
2113**
2214**  Contra has palette RAM, but it also has four lookup table PROMs
r6740r6741
6052}
6153
6254
63static void set_pens(running_machine *machine)
55static void set_pens( running_machine *machine )
6456{
57   contra_state *state = (contra_state *)machine->driver_data;
6558   int i;
6659
6760   for (i = 0x00; i < 0x100; i += 2)
6861   {
69      UINT16 data = machine->generic.paletteram.u8[i] | (machine->generic.paletteram.u8[i | 1] << 8);
62      UINT16 data = state->paletteram[i] | (state->paletteram[i | 1] << 8);
7063
7164      rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
7265
r6740r6741
8477
8578static TILE_GET_INFO( get_fg_tile_info )
8679{
87   int attr = contra_fg_cram[tile_index];
88   int bit0 = (K007121_ctrlram[0][0x05] >> 0) & 0x03;
89   int bit1 = (K007121_ctrlram[0][0x05] >> 2) & 0x03;
90   int bit2 = (K007121_ctrlram[0][0x05] >> 4) & 0x03;
91   int bit3 = (K007121_ctrlram[0][0x05] >> 6) & 0x03;
80   contra_state *state = (contra_state *)machine->driver_data;
81   UINT8 ctrl_3 = k007121_ctrlram_r(state->k007121_1, 3);
82   UINT8 ctrl_4 = k007121_ctrlram_r(state->k007121_1, 4);
83   UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121_1, 5);
84   UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_1, 6);
85   int attr = state->fg_cram[tile_index];
86   int bit0 = (ctrl_5 >> 0) & 0x03;
87   int bit1 = (ctrl_5 >> 2) & 0x03;
88   int bit2 = (ctrl_5 >> 4) & 0x03;
89   int bit3 = (ctrl_5 >> 6) & 0x03;
9290   int bank = ((attr & 0x80) >> 7) |
93         ((attr >> (bit0+2)) & 0x02) |
94         ((attr >> (bit1+1)) & 0x04) |
95         ((attr >> (bit2  )) & 0x08) |
96         ((attr >> (bit3-1)) & 0x10) |
97         ((K007121_ctrlram[0][0x03] & 0x01) << 5);
98   int mask = (K007121_ctrlram[0][0x04] & 0xf0) >> 4;
91         ((attr >> (bit0 + 2)) & 0x02) |
92         ((attr >> (bit1 + 1)) & 0x04) |
93         ((attr >> (bit2    )) & 0x08) |
94         ((attr >> (bit3 - 1)) & 0x10) |
95         ((ctrl_3 & 0x01) << 5);
96   int mask = (ctrl_4 & 0xf0) >> 4;
9997
100   bank = (bank & ~(mask << 1)) | ((K007121_ctrlram[0][0x04] & mask) << 1);
98   bank = (bank & ~(mask << 1)) | ((ctrl_4 & mask) << 1);
10199
102100   SET_TILE_INFO(
103101         0,
104         contra_fg_vram[tile_index]+bank*256,
105         ((K007121_ctrlram[0][6]&0x30)*2+16)+(attr&7),
102         state->fg_vram[tile_index] + bank * 256,
103         ((ctrl_6 & 0x30) * 2 + 16) + (attr & 7),
106104         0);
107105}
108106
109107static TILE_GET_INFO( get_bg_tile_info )
110108{
111   int attr = contra_bg_cram[tile_index];
112   int bit0 = (K007121_ctrlram[1][0x05] >> 0) & 0x03;
113   int bit1 = (K007121_ctrlram[1][0x05] >> 2) & 0x03;
114   int bit2 = (K007121_ctrlram[1][0x05] >> 4) & 0x03;
115   int bit3 = (K007121_ctrlram[1][0x05] >> 6) & 0x03;
109   contra_state *state = (contra_state *)machine->driver_data;
110   UINT8 ctrl_3 = k007121_ctrlram_r(state->k007121_2, 3);
111   UINT8 ctrl_4 = k007121_ctrlram_r(state->k007121_2, 4);
112   UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121_2, 5);
113   UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_2, 6);
114   int attr = state->bg_cram[tile_index];
115   int bit0 = (ctrl_5 >> 0) & 0x03;
116   int bit1 = (ctrl_5 >> 2) & 0x03;
117   int bit2 = (ctrl_5 >> 4) & 0x03;
118   int bit3 = (ctrl_5 >> 6) & 0x03;
116119   int bank = ((attr & 0x80) >> 7) |
117         ((attr >> (bit0+2)) & 0x02) |
118         ((attr >> (bit1+1)) & 0x04) |
119         ((attr >> (bit2  )) & 0x08) |
120         ((attr >> (bit3-1)) & 0x10) |
121         ((K007121_ctrlram[1][0x03] & 0x01) << 5);
122   int mask = (K007121_ctrlram[1][0x04] & 0xf0) >> 4;
120         ((attr >> (bit0 + 2)) & 0x02) |
121         ((attr >> (bit1 + 1)) & 0x04) |
122         ((attr >> (bit2    )) & 0x08) |
123         ((attr >> (bit3 - 1)) & 0x10) |
124         ((ctrl_3 & 0x01) << 5);
125   int mask = (ctrl_4 & 0xf0) >> 4;
123126
124   bank = (bank & ~(mask << 1)) | ((K007121_ctrlram[0][0x04] & mask) << 1);
127   // 2009-12 FP: TO BE VERIFIED - old code used ctrl4 from chip 0?!?
128   bank = (bank & ~(mask << 1)) | ((ctrl_4 & mask) << 1);
125129
126130   SET_TILE_INFO(
127131         1,
128         contra_bg_vram[tile_index]+bank*256,
129         ((K007121_ctrlram[1][6]&0x30)*2+16)+(attr&7),
132         state->bg_vram[tile_index] + bank * 256,
133         ((ctrl_6 & 0x30) * 2 + 16) + (attr & 7),
130134         0);
131135}
132136
133137static TILE_GET_INFO( get_tx_tile_info )
134138{
135   int attr = contra_text_cram[tile_index];
136   int bit0 = (K007121_ctrlram[0][0x05] >> 0) & 0x03;
137   int bit1 = (K007121_ctrlram[0][0x05] >> 2) & 0x03;
138   int bit2 = (K007121_ctrlram[0][0x05] >> 4) & 0x03;
139   int bit3 = (K007121_ctrlram[0][0x05] >> 6) & 0x03;
139   contra_state *state = (contra_state *)machine->driver_data;
140   UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121_1, 5);
141   UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_1, 6);
142   int attr = state->tx_cram[tile_index];
143   int bit0 = (ctrl_5 >> 0) & 0x03;
144   int bit1 = (ctrl_5 >> 2) & 0x03;
145   int bit2 = (ctrl_5 >> 4) & 0x03;
146   int bit3 = (ctrl_5 >> 6) & 0x03;
140147   int bank = ((attr & 0x80) >> 7) |
141         ((attr >> (bit0+2)) & 0x02) |
142         ((attr >> (bit1+1)) & 0x04) |
143         ((attr >> (bit2  )) & 0x08) |
144         ((attr >> (bit3-1)) & 0x10);
148         ((attr >> (bit0 + 2)) & 0x02) |
149         ((attr >> (bit1 + 1)) & 0x04) |
150         ((attr >> (bit2    )) & 0x08) |
151         ((attr >> (bit3 - 1)) & 0x10);
152
145153   SET_TILE_INFO(
146154         0,
147         contra_text_vram[tile_index]+bank*256,
148         ((K007121_ctrlram[0][6]&0x30)*2+16)+(attr&7),
155         state->tx_vram[tile_index] + bank * 256,
156         ((ctrl_6 & 0x30) * 2 + 16) + (attr & 7),
149157         0);
150158}
151159
r6740r6741
158166
159167VIDEO_START( contra )
160168{
161   bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,     8,8,32,32);
162   fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,32,32);
163   tx_tilemap = tilemap_create(machine, get_tx_tile_info,tilemap_scan_rows,     8,8,32,32);
169   contra_state *state = (contra_state *)machine->driver_data;
164170
165   private_spriteram = auto_alloc_array(machine, UINT8, 0x800);
166   private_spriteram_2 = auto_alloc_array(machine, UINT8, 0x800);
171   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
172   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
173   state->tx_tilemap = tilemap_create(machine, get_tx_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
167174
168   bg_clip = *video_screen_get_visible_area(machine->primary_screen);
169   bg_clip.min_x += 40;
175   state->spriteram = auto_alloc_array(machine, UINT8, 0x800);
176   state->spriteram_2 = auto_alloc_array(machine, UINT8, 0x800);
170177
171   fg_clip = bg_clip;
178   state->bg_clip = *video_screen_get_visible_area(machine->primary_screen);
179   state->bg_clip.min_x += 40;
172180
173   tx_clip = *video_screen_get_visible_area(machine->primary_screen);
174   tx_clip.max_x = 39;
175   tx_clip.min_x = 0;
181   state->fg_clip = state->bg_clip;
176182
177   tilemap_set_transparent_pen(fg_tilemap,0);
183   state->tx_clip = *video_screen_get_visible_area(machine->primary_screen);
184   state->tx_clip.max_x = 39;
185   state->tx_clip.min_x = 0;
186
187   tilemap_set_transparent_pen(state->fg_tilemap, 0);
188
189   state_save_register_global_pointer(machine, state->spriteram, 0x800);
190   state_save_register_global_pointer(machine, state->spriteram_2, 0x800);
178191}
179192
180193
r6740r6741
186199
187200WRITE8_HANDLER( contra_fg_vram_w )
188201{
189   contra_fg_vram[offset] = data;
190   tilemap_mark_tile_dirty(fg_tilemap,offset);
202   contra_state *state = (contra_state *)space->machine->driver_data;
203
204   state->fg_vram[offset] = data;
205   tilemap_mark_tile_dirty(state->fg_tilemap, offset);
191206}
192207
193WRITE8_HANDLER( contra_fg_cram_w ){
194   contra_fg_cram[offset] = data;
195   tilemap_mark_tile_dirty(fg_tilemap,offset);
208WRITE8_HANDLER( contra_fg_cram_w )
209{
210   contra_state *state = (contra_state *)space->machine->driver_data;
211
212   state->fg_cram[offset] = data;
213   tilemap_mark_tile_dirty(state->fg_tilemap, offset);
196214}
197215
198216WRITE8_HANDLER( contra_bg_vram_w )
199217{
200   contra_bg_vram[offset] = data;
201   tilemap_mark_tile_dirty(bg_tilemap,offset);
218   contra_state *state = (contra_state *)space->machine->driver_data;
219
220   state->bg_vram[offset] = data;
221   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
202222}
203223
204224WRITE8_HANDLER( contra_bg_cram_w )
205225{
206   contra_bg_cram[offset] = data;
207   tilemap_mark_tile_dirty(bg_tilemap,offset);
226   contra_state *state = (contra_state *)space->machine->driver_data;
227
228   state->bg_cram[offset] = data;
229   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
208230}
209231
210232WRITE8_HANDLER( contra_text_vram_w )
211233{
212   contra_text_vram[offset] = data;
213   tilemap_mark_tile_dirty(tx_tilemap,offset);
234   contra_state *state = (contra_state *)space->machine->driver_data;
235
236   state->tx_vram[offset] = data;
237   tilemap_mark_tile_dirty(state->tx_tilemap, offset);
214238}
215239
216240WRITE8_HANDLER( contra_text_cram_w )
217241{
218   contra_text_cram[offset] = data;
219   tilemap_mark_tile_dirty(tx_tilemap,offset);
242   contra_state *state = (contra_state *)space->machine->driver_data;
243
244   state->tx_cram[offset] = data;
245   tilemap_mark_tile_dirty(state->tx_tilemap, offset);
220246}
221247
222248WRITE8_HANDLER( contra_K007121_ctrl_0_w )
223249{
250   contra_state *state = (contra_state *)space->machine->driver_data;
251   UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_1, 6);
252
224253   if (offset == 3)
225254   {
226      if ((data&0x8)==0)
227         memcpy(private_spriteram,space->machine->generic.spriteram.u8+0x800,0x800);
255      if ((data & 0x8) == 0)
256         memcpy(state->spriteram, space->machine->generic.spriteram.u8 + 0x800, 0x800);
228257      else
229         memcpy(private_spriteram,space->machine->generic.spriteram.u8,0x800);
258         memcpy(state->spriteram, space->machine->generic.spriteram.u8, 0x800);
230259   }
260
231261   if (offset == 6)
232262   {
233      if (K007121_ctrlram[0][6] != data)
234         tilemap_mark_all_tiles_dirty( fg_tilemap );
263      if (ctrl_6 != data)
264         tilemap_mark_all_tiles_dirty(state->fg_tilemap);
235265   }
266
236267   if (offset == 7)
237      tilemap_set_flip(fg_tilemap,(data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
268      tilemap_set_flip(state->fg_tilemap, (data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
238269
239   K007121_ctrl_0_w(space,offset,data);
270   k007121_ctrl_w(state->k007121_1, offset, data);
240271}
241272
242273WRITE8_HANDLER( contra_K007121_ctrl_1_w )
243274{
275   contra_state *state = (contra_state *)space->machine->driver_data;
276   UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_2, 6);
277
244278   if (offset == 3)
245279   {
246      if ((data&0x8)==0)
247         memcpy(private_spriteram_2,space->machine->generic.spriteram.u8+0x2800,0x800);
280      if ((data & 0x8) == 0)
281         memcpy(state->spriteram_2, space->machine->generic.spriteram.u8 + 0x2800, 0x800);
248282      else
249         memcpy(private_spriteram_2,space->machine->generic.spriteram.u8+0x2000,0x800);
283         memcpy(state->spriteram_2, space->machine->generic.spriteram.u8 + 0x2000, 0x800);
250284   }
251285   if (offset == 6)
252286   {
253      if (K007121_ctrlram[1][6] != data )
254         tilemap_mark_all_tiles_dirty( bg_tilemap );
287      if (ctrl_6 != data )
288         tilemap_mark_all_tiles_dirty(state->bg_tilemap);
255289   }
256290   if (offset == 7)
257      tilemap_set_flip(bg_tilemap,(data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
291      tilemap_set_flip(state->bg_tilemap, (data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
258292
259   K007121_ctrl_1_w(space,offset,data);
293   k007121_ctrl_w(state->k007121_2, offset, data);
260294}
261295
262296
r6740r6741
269303
270304static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int bank )
271305{
306   contra_state *state = (contra_state *)machine->driver_data;
307   const device_config *k007121 = bank ? state->k007121_2 : state->k007121_1;
308   int base_color = (k007121_ctrlram_r(k007121, 6) & 0x30) * 2;
272309   const UINT8 *source;
273   int base_color = (K007121_ctrlram[bank][6]&0x30)*2;
274310
275   if (bank==0) source=private_spriteram;
276   else source=private_spriteram_2;
311   if (bank == 0)
312      source = state->spriteram;
313   else
314      source = state->spriteram_2;
277315
278   K007121_sprites_draw(bank,bitmap,cliprect,machine->gfx,machine->colortable,source,base_color,40,0,-1);
316   k007121_sprites_draw(k007121, bitmap, cliprect, machine->gfx[bank], machine->colortable, source, base_color, 40, 0, -1);
279317}
280318
281319VIDEO_UPDATE( contra )
282320{
283   rectangle bg_finalclip = bg_clip;
284   rectangle fg_finalclip = fg_clip;
285   rectangle tx_finalclip = tx_clip;
321   contra_state *state = (contra_state *)screen->machine->driver_data;
322   UINT8 ctrl_1_0 = k007121_ctrlram_r(state->k007121_1, 0);
323   UINT8 ctrl_1_2 = k007121_ctrlram_r(state->k007121_1, 2);
324   UINT8 ctrl_2_0 = k007121_ctrlram_r(state->k007121_2, 0);
325   UINT8 ctrl_2_2 = k007121_ctrlram_r(state->k007121_2, 2);
326   rectangle bg_finalclip = state->bg_clip;
327   rectangle fg_finalclip = state->fg_clip;
328   rectangle tx_finalclip = state->tx_clip;
286329
287330   sect_rect(&bg_finalclip, cliprect);
288331   sect_rect(&fg_finalclip, cliprect);
r6740r6741
290333
291334   set_pens(screen->machine);
292335
293   tilemap_set_scrollx( fg_tilemap,0, K007121_ctrlram[0][0x00] - 40 );
294   tilemap_set_scrolly( fg_tilemap,0, K007121_ctrlram[0][0x02] );
295   tilemap_set_scrollx( bg_tilemap,0, K007121_ctrlram[1][0x00] - 40 );
296   tilemap_set_scrolly( bg_tilemap,0, K007121_ctrlram[1][0x02] );
336   tilemap_set_scrollx(state->fg_tilemap, 0, ctrl_1_0 - 40);
337   tilemap_set_scrolly(state->fg_tilemap, 0, ctrl_1_2);
338   tilemap_set_scrollx(state->bg_tilemap, 0, ctrl_2_0 - 40);
339   tilemap_set_scrolly(state->bg_tilemap, 0, ctrl_2_2);
297340
298   tilemap_draw( bitmap,&bg_finalclip, bg_tilemap, 0 ,0);
299   tilemap_draw( bitmap,&fg_finalclip, fg_tilemap, 0 ,0);
300   draw_sprites( screen->machine,bitmap,cliprect, 0 );
301   draw_sprites( screen->machine,bitmap,cliprect, 1 );
302   tilemap_draw( bitmap,&tx_finalclip, tx_tilemap, 0 ,0);
341   tilemap_draw(bitmap, &bg_finalclip, state->bg_tilemap, 0 ,0);
342   tilemap_draw(bitmap, &fg_finalclip, state->fg_tilemap, 0 ,0);
343   draw_sprites(screen->machine,bitmap,cliprect, 0);
344   draw_sprites(screen->machine,bitmap,cliprect, 1);
345   tilemap_draw(bitmap, &tx_finalclip, state->tx_tilemap, 0 ,0);
303346   return 0;
304347}
src/mame/video/paradise.c
r6740r6741
2626***************************************************************************/
2727
2828#include "driver.h"
29#include "paradise.h"
29#include "includes/paradise.h"
3030
3131/* Variables that driver has access to: */
3232
src/mame/video/dribling.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "dribling.h"
8#include "includes/dribling.h"
99
1010
1111/*************************************
src/mame/video/balsente.c
r6740r6741
77****************************************************************************/
88
99#include "driver.h"
10#include "balsente.h"
10#include "includes/balsente.h"
1111
1212
1313/*************************************
1414 *
15 *  Statics
16 *
17 *************************************/
18
19static UINT8 *local_videoram;
20static UINT8 *sprite_data;
21static UINT32 sprite_mask;
22static UINT8 *sprite_bank[2];
23
24static UINT8 palettebank_vis;
25
26
27
28/*************************************
29 *
3015 *  Video system start
3116 *
3217 *************************************/
3318
3419VIDEO_START( balsente )
3520{
21   balsente_state *state = (balsente_state *)machine->driver_data;
22
3623   /* reset the system */
37   palettebank_vis = 0;
38   sprite_bank[0] = memory_region(machine, "gfx1");
39   sprite_bank[1] = memory_region(machine, "gfx1") + 0x10000;
24   state->palettebank_vis = 0;
25   state->sprite_bank[0] = memory_region(machine, "gfx1");
26   state->sprite_bank[1] = memory_region(machine, "gfx1") + 0x10000;
4027
41   /* allocate a local copy of video RAM */
42   local_videoram = auto_alloc_array(machine, UINT8, 256 * 256);
43
4428   /* determine sprite size */
45   sprite_data = memory_region(machine, "gfx1");
46   sprite_mask = memory_region_length(machine, "gfx1") - 1;
29   state->sprite_data = memory_region(machine, "gfx1");
30   state->sprite_mask = memory_region_length(machine, "gfx1") - 1;
4731
4832   /* register for saving */
49   state_save_register_global_pointer(machine, local_videoram, 256 * 256);
50   state_save_register_global(machine, palettebank_vis);
33   state_save_register_global_array(machine, state->videoram);
34   state_save_register_global(machine, state->palettebank_vis);
5135}
5236
5337
r6740r6741
6044
6145WRITE8_HANDLER( balsente_videoram_w )
6246{
47   balsente_state *state = (balsente_state *)space->machine->driver_data;
48
6349   space->machine->generic.videoram.u8[offset] = data;
6450
6551   /* expand the two pixel values into two bytes */
66   local_videoram[offset * 2 + 0] = data >> 4;
67   local_videoram[offset * 2 + 1] = data & 15;
52   state->videoram[offset * 2 + 0] = data >> 4;
53   state->videoram[offset * 2 + 1] = data & 15;
6854}
6955
7056
r6740r6741
7763
7864WRITE8_HANDLER( balsente_palette_select_w )
7965{
66   balsente_state *state = (balsente_state *)space->machine->driver_data;
67
8068   /* only update if changed */
81   if (palettebank_vis != (data & 3))
69   if (state->palettebank_vis != (data & 3))
8270   {
8371      /* update the scanline palette */
8472      video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen) - 1 + BALSENTE_VBEND);
85      palettebank_vis = data & 3;
73      state->palettebank_vis = data & 3;
8674   }
8775
8876   logerror("balsente_palette_select_w(%d) scanline=%d\n", data & 3, video_screen_get_vpos(space->machine->primary_screen));
r6740r6741
119107
120108WRITE8_HANDLER( shrike_sprite_select_w )
121109{
122   if( sprite_data != sprite_bank[(data & 0x80 >> 7) ^ 1 ])
110   balsente_state *state = (balsente_state *)space->machine->driver_data;
111   if( state->sprite_data != state->sprite_bank[(data & 0x80 >> 7) ^ 1 ])
123112   {
124113      logerror( "shrike_sprite_select_w( 0x%02x )\n", data );
125114      video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen) - 1 + BALSENTE_VBEND);
126      sprite_data = sprite_bank[(data & 0x80 >> 7) ^ 1];
115      state->sprite_data = state->sprite_bank[(data & 0x80 >> 7) ^ 1];
127116   }
128117
129118   shrike_shared_6809_w( space, 1, data );
r6740r6741
139128
140129static void draw_one_sprite(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 *sprite)
141130{
131   balsente_state *state = (balsente_state *)machine->driver_data;
142132   int flags = sprite[0];
143133   int image = sprite[1] | ((flags & 7) << 8);
144134   int ypos = sprite[2] + 17 + BALSENTE_VBEND;
r6740r6741
147137   int x, y;
148138
149139   /* get a pointer to the source image */
150   src = &sprite_data[(64 * image) & sprite_mask];
140   src = &state->sprite_data[(64 * image) & state->sprite_mask];
151141   if (flags & 0x80) src += 4 * 15;
152142
153143   /* loop over y */
r6740r6741
155145   {
156146      if (ypos >= (16 + BALSENTE_VBEND) && ypos >= cliprect->min_y && ypos <= cliprect->max_y)
157147      {
158         const pen_t *pens = &machine->pens[palettebank_vis * 256];
159         UINT8 *old = &local_videoram[(ypos - BALSENTE_VBEND) * 256 + xpos];
148         const pen_t *pens = &machine->pens[state->palettebank_vis * 256];
149         UINT8 *old = &state->videoram[(ypos - BALSENTE_VBEND) * 256 + xpos];
160150         int currx = xpos;
161151
162152         /* standard case */
r6740r6741
222212
223213VIDEO_UPDATE( balsente )
224214{
225   const pen_t *pens = &screen->machine->pens[palettebank_vis * 256];
215   balsente_state *state = (balsente_state *)screen->machine->driver_data;
216   const pen_t *pens = &screen->machine->pens[state->palettebank_vis * 256];
226217   int y, i;
227218
228219   /* draw scanlines from the VRAM directly */
229220   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
230      draw_scanline8(bitmap, 0, y, 256, &local_videoram[(y - BALSENTE_VBEND) * 256], pens);
221      draw_scanline8(bitmap, 0, y, 256, &state->videoram[(y - BALSENTE_VBEND) * 256], pens);
231222
232223   /* draw the sprite images */
233224   for (i = 0; i < 40; i++)
src/mame/video/itech32.c
r6740r6741
88#include "driver.h"
99#include "profiler.h"
1010#include "cpu/m68000/m68000.h"
11#include "itech32.h"
11#include "includes/itech32.h"
1212
1313
1414/*************************************
src/mame/video/ashnojoe.c
r6740r6741
66*********************************************************************/
77
88#include "driver.h"
9#include "ashnojoe.h"
9#include "includes/ashnojoe.h"
1010
1111
1212static TILE_GET_INFO( get_joe_tile_info )
src/mame/video/mouser.c
r6740r6741
1515
1616#include "driver.h"
1717
18UINT8 *mouser_videoram;
19UINT8 *mouser_colorram;
20
1821PALETTE_INIT( mouser )
1922{
2023   int i;
r6740r6741
6164   int flipx,flipy;
6265
6366   /* for every character in the Video RAM  */
64   for (offs = screen->machine->generic.videoram_size - 1;offs >= 0;offs--)
67   for (offs = 0x3ff; offs >= 0; offs--)
6568   {
6669      int scrolled_y_position;
6770      int color_offs;
r6740r6741
8992      color_offs = offs%32 + ((256 + 8*(offs/32) - spriteram[offs%32])%256)/8*32;
9093
9194      drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0],
92            screen->machine->generic.videoram.u8[offs] | (screen->machine->generic.colorram.u8[color_offs]>>5)*256 | ((screen->machine->generic.colorram.u8[color_offs]>>4)&1)*512,
93            screen->machine->generic.colorram.u8[color_offs]%16,
95            mouser_videoram[offs] | (mouser_colorram[color_offs]>>5)*256 | ((mouser_colorram[color_offs]>>4)&1)*512,
96            mouser_colorram[color_offs]%16,
9497            flip_screen_x_get(screen->machine),flip_screen_y_get(screen->machine),
9598            8*sx,scrolled_y_position);
9699   }
src/mame/video/vertigo.c
r6740r6741
4646#include "driver.h"
4747#include "profiler.h"
4848#include "video/vector.h"
49#include "vertigo.h"
49#include "includes/vertigo.h"
5050
5151
5252/*************************************
r6740r6741
213213
214214void vertigo_vproc_init(running_machine *machine)
215215{
216   state_save_register_item_array(machine, "vector_proc", NULL, 0, vs.sram);
217   state_save_register_item(machine, "vector_proc", NULL, 0, vs.ramlatch);
218   state_save_register_item(machine, "vector_proc", NULL, 0, vs.rom_adr);
219   state_save_register_item(machine, "vector_proc", NULL, 0, vs.pc);
220   state_save_register_item(machine, "vector_proc", NULL, 0, vs.ret);
221
222   state_save_register_item_array(machine, "vector_proc", NULL, 0, bsp.ram);
223   state_save_register_item(machine, "vector_proc", NULL, 0, bsp.d);
224   state_save_register_item(machine, "vector_proc", NULL, 0, bsp.q);
225   state_save_register_item(machine, "vector_proc", NULL, 0, bsp.f);
226   state_save_register_item(machine, "vector_proc", NULL, 0, bsp.y);
227
228   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.sreg);
229   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.l1);
230   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.l2);
231   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.c_v);
232   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.c_h);
233   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.c_l);
234   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.adder_s);
235   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.adder_a);
236   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.color);
237   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.intensity);
238   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.brez);
239   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.vfin);
240   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.hud1);
241   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.hud2);
242   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.vud1);
243   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.vud2);
244   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.hc1);
245   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.ven);
246}
247
248
249void vertigo_vproc_reset(running_machine *machine)
250{
216251   int i;
217252   UINT64 *mcode;
218253
r6740r6741
244279   memset(&bsp, 0, sizeof(bsp));
245280   memset(&vgen, 0, sizeof(vgen));
246281   vgen.machine = machine;
247
248   state_save_register_item_array(machine, "vector_proc", NULL, 0, vs.sram);
249   state_save_register_item(machine, "vector_proc", NULL, 0, vs.ramlatch);
250   state_save_register_item(machine, "vector_proc", NULL, 0, vs.rom_adr);
251   state_save_register_item(machine, "vector_proc", NULL, 0, vs.pc);
252   state_save_register_item(machine, "vector_proc", NULL, 0, vs.ret);
253
254   state_save_register_item_array(machine, "vector_proc", NULL, 0, bsp.ram);
255   state_save_register_item(machine, "vector_proc", NULL, 0, bsp.d);
256   state_save_register_item(machine, "vector_proc", NULL, 0, bsp.q);
257   state_save_register_item(machine, "vector_proc", NULL, 0, bsp.f);
258   state_save_register_item(machine, "vector_proc", NULL, 0, bsp.y);
259
260   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.sreg);
261   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.l1);
262   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.l2);
263   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.c_v);
264   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.c_h);
265   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.c_l);
266   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.adder_s);
267   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.adder_a);
268   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.color);
269   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.intensity);
270   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.brez);
271   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.vfin);
272   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.hud1);
273   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.hud2);
274   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.vud1);
275   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.vud2);
276   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.hc1);
277   state_save_register_item(machine, "vector_proc", NULL, 0, vgen.ven);
278282}
279283
280284
src/mame/video/deco32.c
r6740r6741
11#include "driver.h"
2#include "deco16ic.h"
3#include "deco32.h"
2#include "includes/deco16ic.h"
3#include "includes/deco32.h"
44
55UINT32 *deco32_pf1_data,*deco32_pf2_data,*deco32_pf3_data,*deco32_pf4_data;
66UINT32 *deco32_pf12_control,*deco32_pf34_control;
src/mame/video/malzak.c
r6740r6741
1414
1515#include "driver.h"
1616#include "video/s2636.h"
17#include "video/saa5050.h"
18#include "includes/malzak.h"
1719
18static INT8 frame_count;
1920
20#define SAA5050_DBLHI   0x0001
21#define SAA5050_SEPGR   0x0002
22#define SAA5050_FLASH   0x0004
23#define SAA5050_BOX      0x0008
24#define SAA5050_GRAPH   0x0010
25#define SAA5050_CONCEAL   0x0020
26#define SAA5050_HOLDGR   0x0040
27
28#define SAA5050_BLACK   0
29#define SAA5050_WHITE   7
30
31static struct
32{
33   UINT16   saa5050_flags;
34   UINT8   saa5050_forecol;
35   UINT8   saa5050_backcol;
36   UINT8   saa5050_prvcol;
37   UINT8   saa5050_prvchr;
38} saa5050_state;
39
40
41UINT8* saa5050_vidram;  /* Video RAM for SAA 5050 */
42
43int malzak_x;
44int malzak_y;
45
46static struct playfield
47{
48   //int x;
49   //int y;
50   int code;
51} field[256];
52
5321VIDEO_UPDATE( malzak )
5422{
55   int code, colour;
23   malzak_state *state = (malzak_state *)screen->machine->driver_data;
5624   int sx, sy;
5725   int x,y;
5826   bitmap_t *s2636_0_bitmap;
5927   bitmap_t *s2636_1_bitmap;
60   const device_config *s2636_0 = devtag_get_device(screen->machine, "s2636_0");
61   const device_config *s2636_1 = devtag_get_device(screen->machine, "s2636_1");
6228
63   bitmap_fill(bitmap,0,0);
29   bitmap_fill(bitmap, 0, 0);
6430
65   // SAA 5050 - Teletext character generator
66   for (sy = 24; sy >= 0; sy--)
67   {
68      /* Set start of line state */
69      saa5050_state.saa5050_flags = 0;
70      saa5050_state.saa5050_prvchr = 32;
71      saa5050_state.saa5050_forecol = SAA5050_WHITE;
72      saa5050_state.saa5050_prvcol = SAA5050_WHITE;
73      saa5050_state.saa5050_backcol = SAA5050_BLACK;
31   saa5050_update(state->saa5050, bitmap, cliprect);
32   saa5050_frame_advance(state->saa5050);
7433
75      for (sx = 0; sx < 42; sx++)
76      {
77         int blank = 0;
78         code = saa5050_vidram[sy * 64 + sx];
79         if (code < 32)
80         {
81            switch (code) {
82            case 0x00:
83               blank = 1;  // code 0x00 should not display anything
84               break;      // unless HOLDGR is set
85            case 0x01: case 0x02: case 0x03: case 0x04:
86            case 0x05: case 0x06: case 0x07:
87               saa5050_state.saa5050_prvcol = saa5050_state.saa5050_forecol = code;
88               saa5050_state.saa5050_flags &= ~(SAA5050_GRAPH | SAA5050_CONCEAL);
89               break;
90            case 0x11: case 0x12: case 0x13: case 0x14:
91            case 0x15: case 0x16: case 0x17:
92               saa5050_state.saa5050_prvcol = (saa5050_state.saa5050_forecol =
93                  (code & 0x07));
94               saa5050_state.saa5050_flags &= ~SAA5050_CONCEAL;
95               saa5050_state.saa5050_flags |= SAA5050_GRAPH;
96               break;
97            case 0x08:
98               saa5050_state.saa5050_flags |= SAA5050_FLASH;
99               break;
100            case 0x09:
101               saa5050_state.saa5050_flags &= ~SAA5050_FLASH;
102               break;
103            case 0x0a:
104               saa5050_state.saa5050_flags |= SAA5050_BOX;
105               break;
106            case 0x0b:
107               saa5050_state.saa5050_flags &= ~SAA5050_BOX;
108               break;
109            case 0x0c:
110               saa5050_state.saa5050_flags &= ~SAA5050_DBLHI;
111               break;
112            case 0x0d:
113               saa5050_state.saa5050_flags |= SAA5050_DBLHI;
114               break;
115            case 0x18:
116               saa5050_state.saa5050_flags |= SAA5050_CONCEAL;
117               break;
118            case 0x19:
119               saa5050_state.saa5050_flags |= SAA5050_SEPGR;
120               break;
121            case 0x1a:
122               saa5050_state.saa5050_flags &= ~SAA5050_SEPGR;
123               break;
124            case 0x1c:
125               saa5050_state.saa5050_backcol = SAA5050_BLACK;
126               break;
127            case 0x1d:
128                  saa5050_state.saa5050_backcol = saa5050_state.saa5050_prvcol;
129               break;
130            case 0x1e:
131               saa5050_state.saa5050_flags |= SAA5050_HOLDGR;
132               break;
133            case 0x1f:
134               saa5050_state.saa5050_flags &= ~SAA5050_HOLDGR;
135               break;
136            }
137            if (saa5050_state.saa5050_flags & SAA5050_HOLDGR)
138                 code = saa5050_state.saa5050_prvchr;
139            else
140               code = 32;
141         }
142
143         if (code & 0x80)
144            colour = (saa5050_state.saa5050_forecol << 3) | saa5050_state.saa5050_backcol;
145         else
146            colour = saa5050_state.saa5050_forecol | (saa5050_state.saa5050_backcol << 3);
147
148         if (saa5050_state.saa5050_flags & SAA5050_CONCEAL)
149            code = 32;
150         else if ((saa5050_state.saa5050_flags & SAA5050_FLASH) && (frame_count > 38))
151            code = 32;
152         else
153         {
154            saa5050_state.saa5050_prvchr = code;
155            if ((saa5050_state.saa5050_flags & SAA5050_GRAPH) && (code & 0x20))
156            {
157               code += (code & 0x40) ? 64 : 96;
158               if (saa5050_state.saa5050_flags & SAA5050_SEPGR)
159                  code += 64;
160            }
161         }
162
163         if((blank == 0) || (saa5050_state.saa5050_flags & SAA5050_HOLDGR))
164         {
165            if (saa5050_state.saa5050_flags & SAA5050_DBLHI)
166            {
167               drawgfx_opaque (bitmap, cliprect, screen->machine->gfx[2], code, colour, 0, 0,
168                  sx * 6, sy * 10);
169               drawgfx_opaque (bitmap, cliprect, screen->machine->gfx[3], code, colour, 0, 0,
170                  sx * 6, (sy + 1) * 10);
171            }
172            else
173            {
174               drawgfx_opaque (bitmap, cliprect, screen->machine->gfx[1], code, colour, 0, 0,
175                  sx * 6, sy * 10);
176            }
177         }
178      }
179      if (saa5050_state.saa5050_flags & SAA5050_DBLHI)
180      {
181         sy--;
182         saa5050_state.saa5050_flags &= ~SAA5050_DBLHI;
183      }
184   }
185
186   frame_count++;
187   if(frame_count > 50)
188      frame_count = 0;
189
19034   // playfield - not sure exactly how this works...
191   for(x = 0;x < 16;x++)
192      for(y = 0; y < 16;y++)
35   for (x = 0; x < 16; x++)
36      for (y = 0; y < 16; y++)
19337      {
194         sx = ((x*16-48) - malzak_x);
195         sy = ((y*16) - malzak_y);
38         sx = ((x * 16 - 48) - state->malzak_x);
39         sy = ((y * 16) - state->malzak_y);
19640
197         if(sx < -271)
198            sx+=512;
199         if(sx < -15)
200            sx+=256;
41         if (sx < -271)
42            sx += 512;
43         if (sx < -15)
44            sx += 256;
20145
202         drawgfx_transpen(bitmap,cliprect, screen->machine->gfx[0],field[x*16 + y].code,7,0,0,
203            sx, sy, 0);
46         drawgfx_transpen(bitmap,cliprect, screen->machine->gfx[0], state->playfield_code[x * 16 + y], 7, 0, 0, sx, sy, 0);
20447      }
20548
206    /* update the S2636 chips */
207   s2636_0_bitmap = s2636_update(s2636_0, cliprect);
208   s2636_1_bitmap = s2636_update(s2636_1, cliprect);
49   /* update the S2636 chips */
50   s2636_0_bitmap = s2636_update(state->s2636_0, cliprect);
51   s2636_1_bitmap = s2636_update(state->s2636_1, cliprect);
20952
21053   /* copy the S2636 images into the main bitmap */
21154   {
r6740r6741
23477
23578WRITE8_HANDLER( malzak_playfield_w )
23679{
237   int tile = ((malzak_x / 16) * 16) + (offset / 16);
80   malzak_state *state = (malzak_state *)space->machine->driver_data;
81   int tile = ((state->malzak_x / 16) * 16) + (offset / 16);
23882
239//  field[tile].x = malzak_x / 16;
240//  field[tile].y = malzak_y;
241   field[tile].code = (data & 0x1f);
242   logerror("GFX: 0x16%02x write 0x%02x\n",offset,data);
83//  state->playfield_x[tile] = state->malzak_x / 16;
84//  state->playfield_y[tile] = state->malzak_y;
85   state->playfield_code[tile] = (data & 0x1f);
86   logerror("GFX: 0x16%02x write 0x%02x\n", offset, data);
24387}
src/mame/video/gaiden.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "gaiden.h"
8#include "includes/gaiden.h"
99
1010/***************************************************************************
1111
src/mame/video/fastfred.c
r6740r6741
88
99#include "driver.h"
1010#include "video/resnet.h"
11#include "fastfred.h"
11#include "includes/fastfred.h"
1212#include "includes/galaxold.h"
1313
1414UINT8 *fastfred_videoram;
src/mame/video/news.c
r6740r6741
11#include "driver.h"
2#include "news.h"
2#include "includes/news.h"
33
44
55UINT8 *news_fgram;
src/mame/video/shuuz.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "shuuz.h"
8#include "includes/shuuz.h"
99
1010
1111
src/mame/video/finalizr.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "finalizr.h"
10#include "includes/finalizr.h"
1111
1212
1313PALETTE_INIT( finalizr )
src/mame/video/hexa.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "hexa.h"
10#include "includes/hexa.h"
1111
1212WRITE8_HANDLER( hexa_videoram_w )
1313{
src/mame/video/cloak.c
r6740r6741
66
77#include "driver.h"
88#include "video/resnet.h"
9#include "cloak.h"
9#include "includes/cloak.h"
1010
1111
1212#define NUM_PENS   (0x40)
src/mame/video/namcona1.c
r6740r6741
77*/
88
99#include "driver.h"
10#include "namcona1.h"
10#include "includes/namcona1.h"
1111
1212#define NAMCONA1_NUM_TILEMAPS 4
1313
src/mame/video/foodf.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "foodf.h"
8#include "includes/foodf.h"
99#include "video/resnet.h"
1010
1111
src/mame/video/bsktball.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "bsktball.h"
8#include "includes/bsktball.h"
99
1010
1111WRITE8_HANDLER( bsktball_videoram_w )
src/mame/video/appoooh.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "appoooh.h"
10#include "includes/appoooh.h"
1111
1212/***************************************************************************
1313
src/mame/video/psx.c
r6740r6741
739739   }
740740
741741   // icky!!!
742   state_save_register_memory( machine, "globals", NULL, 0, "m_packet", (UINT8 *)&m_packet, 1, sizeof( m_packet ) );
742   state_save_register_memory( machine, "globals", NULL, 0, "m_packet", (UINT8 *)&m_packet, 1, sizeof( m_packet ), __FILE__, __LINE__ );
743743
744744   state_save_register_global_pointer(machine,  m_p_vram, m_n_vram_size );
745745   state_save_register_global(machine,  m_n_gpu_buffer_offset );
r6740r6741
11541154#define FLATTEXTUREDRECTANGLEUPDATE \
11551155   n_u += n_du;
11561156
1157#define TEXTURE_LOOP \
1158   while( n_distance > 0 ) \
1159   {
1160
1161#define TEXTURE_ENDLOOP \
1162   }
1163
11571164#define TEXTURE4BIT( TXV, TXU ) \
1158   while( n_distance > 0 ) \
1159   { \
1165   TEXTURE_LOOP \
11601166      n_bgr = p_clut[ ( *( m_p_p_vram[ n_ty + TXV ] + n_tx + ( TXU >> 2 ) ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f ];
11611167
11621168#define TEXTURE8BIT( TXV, TXU ) \
1163   while( n_distance > 0 ) \
1164   { \
1169   TEXTURE_LOOP \
11651170      n_bgr = p_clut[ ( *( m_p_p_vram[ n_ty + TXV ] + n_tx + ( TXU >> 1 ) ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff ];
11661171
11671172#define TEXTURE15BIT( TXV, TXU ) \
1168   while( n_distance > 0 ) \
1169   { \
1173   TEXTURE_LOOP \
11701174      n_bgr = *( m_p_p_vram[ n_ty + TXV ] + n_tx + TXU );
11711175
11721176#define TEXTUREWINDOW4BIT( TXV, TXU ) TEXTURE4BIT( ( TXV & m_n_twh ), ( TXU & m_n_tww ) )
r6740r6741
11741178#define TEXTUREWINDOW15BIT( TXV, TXU ) TEXTURE15BIT( ( TXV & m_n_twh ), ( TXU & m_n_tww ) )
11751179
11761180#define TEXTUREINTERLEAVED4BIT( TXV, TXU ) \
1177   while( n_distance > 0 ) \
1178   { \
1181   TEXTURE_LOOP \
11791182      int n_xi = ( ( TXU >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c ); \
11801183      int n_yi = ( TXV & ~0xf ) + ( ( TXU >> 4 ) & 0xf ); \
11811184      n_bgr = p_clut[ ( *( m_p_p_vram[ n_ty + n_yi ] + n_tx + n_xi ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f ];
11821185
11831186#define TEXTUREINTERLEAVED8BIT( TXV, TXU ) \
1184   while( n_distance > 0 ) \
1185   { \
1187   TEXTURE_LOOP \
11861188      int n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 ); \
11871189      int n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 ); \
11881190      n_bgr = p_clut[ ( *( m_p_p_vram[ n_ty + n_yi ] + n_tx + n_xi ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff ];
11891191
11901192#define TEXTUREINTERLEAVED15BIT( TXV, TXU ) \
1191   while( n_distance > 0 ) \
1192   { \
1193   TEXTURE_LOOP \
11931194      int n_xi = TXU; \
11941195      int n_yi = TXV; \
11951196      n_bgr = *( m_p_p_vram[ n_ty + n_yi ] + n_tx + n_xi );
r6740r6741
12091210      p_vram++; \
12101211      PIXELUPDATE \
12111212      n_distance--; \
1212   }
1213   TEXTURE_ENDLOOP
12131214
12141215#define TRANSPARENTPIXEL( PIXELUPDATE ) \
12151216      if( n_bgr != 0 ) \
r6740r6741
12321233      p_vram++; \
12331234      PIXELUPDATE \
12341235      n_distance--; \
1235   }
1236   TEXTURE_ENDLOOP
12361237
12371238#define TEXTUREFILL( PIXELUPDATE, TXU, TXV ) \
12381239   if( n_distance > ( (INT32)m_n_drawarea_x2 - n_x ) + 1 ) \
src/mame/video/aliens.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
44
55static int layer_colorbase[3],sprite_colorbase;
r6740r6741
1010
1111***************************************************************************/
1212
13static void tile_callback(int layer,int bank,int *code,int *color, int *flags, int *priority)
13void aliens_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color, int *flags, int *priority)
1414{
1515   *code |= ((*color & 0x3f) << 8) | (bank << 14);
1616   *color = layer_colorbase[layer] + ((*color & 0xc0) >> 6);
r6740r6741
2323
2424***************************************************************************/
2525
26static void sprite_callback(int *code,int *color,int *priority_mask,int *shadow)
26void aliens_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask,int *shadow)
2727{
2828   /* The PROM allows for mixed priorities, where sprites would have */
2929   /* priority over text but not on one or both of the other two planes. */
r6740r6741
5959   layer_colorbase[1] = 4;
6060   layer_colorbase[2] = 8;
6161   sprite_colorbase = 16;
62   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tile_callback);
63   K051960_vh_start(machine,"gfx2",NORMAL_PLANE_ORDER,sprite_callback);
6462}
6563
6664
r6740r6741
7371
7472VIDEO_UPDATE( aliens )
7573{
76   K052109_tilemap_update();
74   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
75   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
7776
77   k052109_tilemap_update(k052109);
78
7879   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
7980   bitmap_fill(bitmap,cliprect,layer_colorbase[1] * 16);
80   tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,1);
81   tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,2);
82   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,4);
8381
84   K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
82   k052109_tilemap_draw(k052109, bitmap, cliprect, 1, 0,1);
83   k052109_tilemap_draw(k052109, bitmap, cliprect, 2, 0,2);
84   k052109_tilemap_draw(k052109, bitmap, cliprect, 0, 0,4);
85
86   k051960_sprites_draw(k051960, bitmap,cliprect,-1,-1);
8587   return 0;
8688}
src/mame/video/88games.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
3#include "includes/88games.h"
34
45
5int k88games_priority;
6
7static int layer_colorbase[3],sprite_colorbase,zoom_colorbase;
8
9
10
116/***************************************************************************
127
138  Callbacks for the K052109
149
1510***************************************************************************/
1611
17static void tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
12void _88games_tile_callback( running_machine *machine, int layer, int bank, int *code, int *color, int *flags, int *priority )
1813{
14   _88games_state *state = (_88games_state *)machine->driver_data;
15
1916   *code |= ((*color & 0x0f) << 8) | (bank << 12);
20   *color = layer_colorbase[layer] + ((*color & 0xf0) >> 4);
17   *color = state->layer_colorbase[layer] + ((*color & 0xf0) >> 4);
2118}
2219
2320
r6740r6741
2724
2825***************************************************************************/
2926
30static void sprite_callback(int *code,int *color,int *priority,int *shadow)
27void _88games_sprite_callback( running_machine *machine, int *code, int *color, int *priority, int *shadow )
3128{
29   _88games_state *state = (_88games_state *)machine->driver_data;
30
3231   *priority = (*color & 0x20) >> 5;   /* ??? */
33   *color = sprite_colorbase + (*color & 0x0f);
32   *color = state->sprite_colorbase + (*color & 0x0f);
3433}
3534
3635
r6740r6741
4039
4140***************************************************************************/
4241
43static void zoom_callback(int *code,int *color,int *flags)
42void _88games_zoom_callback( running_machine *machine, int *code, int *color, int *flags )
4443{
44   _88games_state *state = (_88games_state *)machine->driver_data;
45
4546   *flags = (*color & 0x40) ? TILE_FLIPX : 0;
4647   *code |= ((*color & 0x07) << 8);
47   *color = zoom_colorbase + ((*color & 0x38) >> 3) + ((*color & 0x80) >> 4);
48   *color = state->zoom_colorbase + ((*color & 0x38) >> 3) + ((*color & 0x80) >> 4);
4849}
4950
50
5151/***************************************************************************
5252
53    Start the video hardware emulation.
54
55***************************************************************************/
56
57VIDEO_START( 88games )
58{
59   layer_colorbase[0] = 64;
60   layer_colorbase[1] = 0;
61   layer_colorbase[2] = 16;
62   sprite_colorbase = 32;
63   zoom_colorbase = 48;
64   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tile_callback);
65   K051960_vh_start(machine,"gfx2",NORMAL_PLANE_ORDER,sprite_callback);
66   K051316_vh_start_0(machine,"gfx3",4,FALSE,0,zoom_callback);
67
68    state_save_register_global_array(machine, layer_colorbase);
69    state_save_register_global(machine, k88games_priority);
70    state_save_register_global(machine, sprite_colorbase);
71    state_save_register_global(machine, zoom_colorbase);
72}
73
74
75
76/***************************************************************************
77
7853  Display refresh
7954
8055***************************************************************************/
8156
8257VIDEO_UPDATE( 88games )
8358{
84   K052109_tilemap_update();
59   _88games_state *state = (_88games_state *)screen->machine->driver_data;
8560
86   if (k88games_priority)
61   k052109_tilemap_update(state->k052109);
62
63   if (state->k88games_priority)
8764   {
88      tilemap_draw(bitmap,cliprect,K052109_tilemap[0],TILEMAP_DRAW_OPAQUE,0);
89      K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
90      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,0);
91      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
92      K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
93      K051316_zoom_draw_0(bitmap,cliprect,0,0);
65      k052109_tilemap_draw(state->k052109, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0);   // tile 0
66      k051960_sprites_draw(state->k051960, bitmap,cliprect, 1, 1);
67      k052109_tilemap_draw(state->k052109, bitmap, cliprect, 2, 0, 0);   // tile 2
68      k052109_tilemap_draw(state->k052109, bitmap, cliprect, 1, 0, 0);   // tile 1
69      k051960_sprites_draw(state->k051960, bitmap, cliprect, 0, 0);
70      k051316_zoom_draw(state->k051316, bitmap, cliprect, 0, 0);
9471   }
9572   else
9673   {
97      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],TILEMAP_DRAW_OPAQUE,0);
98      K051316_zoom_draw_0(bitmap,cliprect,0,0);
99      K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
100      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
101      K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
102      tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
74      k052109_tilemap_draw(state->k052109, bitmap, cliprect, 2, TILEMAP_DRAW_OPAQUE, 0);   // tile 2
75      k051316_zoom_draw(state->k051316, bitmap, cliprect, 0, 0);
76      k051960_sprites_draw(state->k051960, bitmap, cliprect, 0, 0);
77      k052109_tilemap_draw(state->k052109, bitmap, cliprect, 1, 0, 0);   // tile 1
78      k051960_sprites_draw(state->k051960, bitmap, cliprect, 1, 1);
79      k052109_tilemap_draw(state->k052109, bitmap, cliprect, 0, 0, 0);   // tile 0
10380   }
81
10482   return 0;
10583}
src/mame/video/kaneko16.c
r6740r6741
3232**************************************************************************/
3333
3434#include "driver.h"
35#include "kaneko16.h"
35#include "includes/kaneko16.h"
3636#include "kan_pand.h"
3737
3838static UINT16 kaneko16_disp_enable;
src/mame/video/dbz.c
r6740r6741
99
1010
1111#include "driver.h"
12#include "video/konamiic.h"
12#include "video/konicdev.h"
1313
1414static tilemap *dbz_bg1_tilemap, *dbz_bg2_tilemap;
1515UINT16 *dbz_bg1_videoram, *dbz_bg2_videoram;
1616static int sprite_colorbase, layer_colorbase[6], layer[5], layerpri[5];
1717
18static void dbz_tile_callback(int layer, int *code, int *color, int *flags)
18void dbz_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags)
1919{
2020   *color = (layer_colorbase[layer] << 1) + ((*color & 0x3c) >> 2);
2121}
2222
23static void dbz_sprite_callback(int *code, int *color, int *priority_mask)
23void dbz_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask)
2424{
2525   int pri = (*color & 0x3c0) >> 5;
2626
r6740r6741
9393
9494VIDEO_START( dbz )
9595{
96   K053251_vh_start(machine);
97   K056832_vh_start(machine, "gfx1", K056832_BPP_4, 1, NULL, dbz_tile_callback, 1);
98   K053247_vh_start(machine, "gfx2", -52, 16, NORMAL_PLANE_ORDER, dbz_sprite_callback);
96   const device_config *k056832 = devtag_get_device(machine, "k056832");
97   const device_config *k053246 = devtag_get_device(machine, "k053246");
9998
100   dbz_bg1_tilemap = tilemap_create(machine, get_dbz_bg1_tile_info,tilemap_scan_rows, 16, 16,64,32);
101   dbz_bg2_tilemap = tilemap_create(machine, get_dbz_bg2_tile_info,tilemap_scan_rows, 16, 16,64,32);
99   dbz_bg1_tilemap = tilemap_create(machine, get_dbz_bg1_tile_info, tilemap_scan_rows, 16, 16, 64, 32);
100   dbz_bg2_tilemap = tilemap_create(machine, get_dbz_bg2_tile_info, tilemap_scan_rows, 16, 16, 64, 32);
102101
103   tilemap_set_transparent_pen(dbz_bg1_tilemap,0);
104   tilemap_set_transparent_pen(dbz_bg2_tilemap,0);
102   tilemap_set_transparent_pen(dbz_bg1_tilemap, 0);
103   tilemap_set_transparent_pen(dbz_bg2_tilemap, 0);
105104
106   K053936_wraparound_enable(0, 1);
107   K053936_set_offset(0, -46, -16);
108
109   K053936_wraparound_enable(1, 1);
110   K053936_set_offset(1, -46, -16);
111
112105   if (!strcmp(machine->gamedrv->name, "dbz"))
113      K056832_set_LayerOffset(0, -34, -16);
106      k056832_set_layer_offs(k056832, 0, -34, -16);
114107   else
115      K056832_set_LayerOffset(0, -35, -16);
108      k056832_set_layer_offs(k056832, 0, -35, -16);
116109
117   K056832_set_LayerOffset(1, -31, -16);
118   K056832_set_LayerOffset(3, -31, -16); //?
110   k056832_set_layer_offs(k056832, 1, -31, -16);
111   k056832_set_layer_offs(k056832, 3, -31, -16); //?
119112
120   K053247_set_SpriteOffset(-87,32);
113   k053247_set_sprite_offs(k053246, -87, 32);
121114}
122115
123116VIDEO_UPDATE( dbz )
124117{
125118   static const int K053251_CI[6] = { K053251_CI3, K053251_CI4, K053251_CI4, K053251_CI4, K053251_CI2, K053251_CI1 };
119   const device_config *k056832 = devtag_get_device(screen->machine, "k056832");
120   const device_config *k053246 = devtag_get_device(screen->machine, "k053246");
121   const device_config *k053251 = devtag_get_device(screen->machine, "k053251");
122   const device_config *k053936_1 = devtag_get_device(screen->machine, "k053936_1");
123   const device_config *k053936_2 = devtag_get_device(screen->machine, "k053936_2");
126124   int plane, new_colorbase;
127125
128   sprite_colorbase = K053251_get_palette_index(K053251_CI0);
126   sprite_colorbase = k053251_get_palette_index(k053251, K053251_CI0);
129127
130   for (plane=0; plane<6; plane++)
128   for (plane = 0; plane < 6; plane++)
131129   {
132      new_colorbase = K053251_get_palette_index(K053251_CI[plane]);
130      new_colorbase = k053251_get_palette_index(k053251, K053251_CI[plane]);
133131      if (layer_colorbase[plane] != new_colorbase)
134132      {
135133         layer_colorbase[plane] = new_colorbase;
136         if(plane <= 3)
137            K056832_mark_plane_dirty(plane);
134         if (plane <= 3)
135            k056832_mark_plane_dirty(k056832, plane);
138136         else if(plane == 4)
139137            tilemap_mark_all_tiles_dirty(dbz_bg1_tilemap);
140138         else if(plane == 5)
r6740r6741
145143   //layers priority
146144
147145   layer[0] = 0;
148   layerpri[0] = K053251_get_priority(K053251_CI3);
146   layerpri[0] = k053251_get_priority(k053251, K053251_CI3);
149147   layer[1] = 1;
150   layerpri[1] = K053251_get_priority(K053251_CI4);
148   layerpri[1] = k053251_get_priority(k053251, K053251_CI4);
151149   layer[2] = 3;
152   layerpri[2] = K053251_get_priority(K053251_CI0);
150   layerpri[2] = k053251_get_priority(k053251, K053251_CI0);
153151   layer[3] = 4;
154   layerpri[3] = K053251_get_priority(K053251_CI2);
152   layerpri[3] = k053251_get_priority(k053251, K053251_CI2);
155153   layer[4] = 5;
156   layerpri[4] = K053251_get_priority(K053251_CI1);
154   layerpri[4] = k053251_get_priority(k053251, K053251_CI1);
157155
158156   sortlayers(layer, layerpri);
159157
160158   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
161159
162   for(plane = 0; plane < 5; plane++)
160   for (plane = 0; plane < 5; plane++)
163161   {
164162      int flag, pri;
165163
166      if(plane == 0)
164      if (plane == 0)
167165      {
168166         flag = TILEMAP_DRAW_OPAQUE;
169167         pri = 0;
r6740r6741
175173      }
176174
177175      if(layer[plane] == 4)
178         K053936_1_zoom_draw(bitmap,cliprect,dbz_bg1_tilemap,flag,pri,1);
176         k053936_zoom_draw(k053936_2, bitmap, cliprect, dbz_bg1_tilemap, flag, pri, 1);
179177      else if(layer[plane] == 5)
180         K053936_0_zoom_draw(bitmap,cliprect,dbz_bg2_tilemap,flag,pri,1);
178         k053936_zoom_draw(k053936_1, bitmap, cliprect, dbz_bg2_tilemap, flag, pri, 1);
181179      else
182         K056832_tilemap_draw(screen->machine, bitmap,cliprect,layer[plane],flag,pri);
180         k056832_tilemap_draw(k056832, bitmap, cliprect, layer[plane], flag, pri);
183181   }
184182
185   K053247_sprites_draw(screen->machine, bitmap, cliprect);
183   k053247_sprites_draw(k053246, bitmap, cliprect);
186184   return 0;
187185}
188186
src/mame/video/goldstar.c
r6740r6741
99#include "driver.h"
1010
1111UINT8 *goldstar_reel1_scroll, *goldstar_reel2_scroll, *goldstar_reel3_scroll;
12UINT8 *goldstar_fg_atrram;
13UINT8 *goldstar_fg_vidram;
1214
1315static int bgcolor;
1416
r6740r6741
5557
5658WRITE8_HANDLER( goldstar_fg_vidram_w )
5759{
58   space->machine->generic.videoram.u8[offset] = data;
60   goldstar_fg_vidram[offset] = data;
5961   tilemap_mark_tile_dirty(goldstar_fg_tilemap,offset);
6062}
6163
6264WRITE8_HANDLER( goldstar_fg_atrram_w )
6365{
64   space->machine->generic.colorram.u8[offset] = data;
66   goldstar_fg_atrram[offset] = data;
6567   tilemap_mark_tile_dirty(goldstar_fg_tilemap,offset);
6668}
6769
6870static TILE_GET_INFO( get_goldstar_fg_tile_info )
6971{
70   int code = machine->generic.videoram.u8[tile_index];
71   int attr = machine->generic.colorram.u8[tile_index];
72   int code = goldstar_fg_vidram[tile_index];
73   int attr = goldstar_fg_atrram[tile_index];
7274
7375   SET_TILE_INFO(
7476         0,
r6740r6741
8082// colour / high tile bits are swapped around
8183static TILE_GET_INFO( get_cherrym_fg_tile_info )
8284{
83   int code = machine->generic.videoram.u8[tile_index];
84   int attr = machine->generic.colorram.u8[tile_index];
85   int code = goldstar_fg_vidram[tile_index];
86   int attr = goldstar_fg_atrram[tile_index];
8587
8688   SET_TILE_INFO(
8789         0,
src/mame/video/gauntlet.c
r6740r6741
66
77#include "driver.h"
88#include "machine/atarigen.h"
9#include "gauntlet.h"
9#include "includes/gauntlet.h"
1010
1111
1212
r6740r6741
104104
105105   /* set up the base color for the playfield */
106106   state->playfield_color_bank = state->vindctr2_screen_refresh ? 0 : 1;
107
108   /* save states */
109   state_save_register_global(machine, state->playfield_tile_bank);
110   state_save_register_global(machine, state->playfield_color_bank);
107111}
108112
109113
src/mame/video/20pacgal.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "20pacgal.h"
10#include "includes/20pacgal.h"
1111
1212
1313#define SCREEN_HEIGHT   (224)
src/mame/video/seicross.c
r6740r6741
1010
1111UINT8 *seicross_row_scroll;
1212
13UINT8 *seicross_videoram;
14UINT8 *seicross_colorram;
1315static tilemap *bg_tilemap;
1416
1517/***************************************************************************
r6740r6741
5860
5961WRITE8_HANDLER( seicross_videoram_w )
6062{
61   space->machine->generic.videoram.u8[offset] = data;
63   seicross_videoram[offset] = data;
6264   tilemap_mark_tile_dirty(bg_tilemap, offset);
6365}
6466
r6740r6741
6971   /* region. */
7072   offset &= 0xffdf;
7173
72   space->machine->generic.colorram.u8[offset] = data;
73   space->machine->generic.colorram.u8[offset + 0x20] = data;
74   seicross_colorram[offset] = data;
75   seicross_colorram[offset + 0x20] = data;
7476
7577   tilemap_mark_tile_dirty(bg_tilemap, offset);
7678   tilemap_mark_tile_dirty(bg_tilemap, offset + 0x20);
r6740r6741
7880
7981static TILE_GET_INFO( get_bg_tile_info )
8082{
81   int code = machine->generic.videoram.u8[tile_index] + ((machine->generic.colorram.u8[tile_index] & 0x10) << 4);
82   int color = machine->generic.colorram.u8[tile_index] & 0x0f;
83   int flags = ((machine->generic.colorram.u8[tile_index] & 0x40) ? TILE_FLIPX : 0) | ((machine->generic.colorram.u8[tile_index] & 0x80) ? TILE_FLIPY : 0);
83   int code = seicross_videoram[tile_index] + ((seicross_colorram[tile_index] & 0x10) << 4);
84   int color = seicross_colorram[tile_index] & 0x0f;
85   int flags = ((seicross_colorram[tile_index] & 0x40) ? TILE_FLIPX : 0) | ((seicross_colorram[tile_index] & 0x80) ? TILE_FLIPY : 0);
8486
8587   SET_TILE_INFO(0, code, color, flags);
8688}
src/mame/video/system16.c
r6740r6741
2525
2626***************************************************************************/
2727#include "driver.h"
28#include "system16.h"
28#include "includes/system16.h"
2929#include "video/resnet.h"
3030#include "video/segaic16.h"
3131
src/mame/video/atarimo.c
r6740r6741
295295   state_save_register_item(machine, "atarimo", NULL, index, mo->dirtyheight);
296296#endif
297297
298   state_save_register_bitmap(machine, "atarimo", NULL, index, "bitmap", mo->bitmap);
298   state_save_register_bitmap(machine, "atarimo", NULL, index, "bitmap", mo->bitmap, __FILE__, __LINE__);
299299
300   state_save_register_memory(machine, "atarimo", NULL, index, "spriteram", mo->spriteram, sizeof(atarimo_entry), mo->spriteramsize);
300   state_save_register_memory(machine, "atarimo", NULL, index, "spriteram", mo->spriteram, sizeof(atarimo_entry), mo->spriteramsize, __FILE__, __LINE__);
301301
302302   state_save_register_item_pointer(machine, "atarimo", NULL, index, mo->codelookup, round_to_powerof2(mo->codemask.mask));
303303
src/mame/video/deniam.c
r6740r6741
11#include "driver.h"
2#include "deniam.h"
2#include "includes/deniam.h"
33
44
55static void deniam_common_init( running_machine *machine )
src/mame/video/redalert.c
r6740r6741
99
1010#include "driver.h"
1111#include "video/resnet.h"
12#include "redalert.h"
12#include "includes/redalert.h"
1313
1414
1515#define NUM_CHARMAP_PENS   0x200
src/mame/video/mcr3.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "mcr.h"
8#include "includes/mcr.h"
99
1010
1111
src/mame/video/simpsons.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33#include "includes/simpsons.h"
44
55static int bg_colorbase,sprite_colorbase,layer_colorbase[3];
r6740r6741
1313
1414***************************************************************************/
1515
16static void tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
16void simpsons_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
1717{
1818   *code |= ((*color & 0x3f) << 8) | (bank << 14);
1919   *color = layer_colorbase[layer] + ((*color & 0xc0) >> 6);
r6740r6741
2626
2727***************************************************************************/
2828
29static void sprite_callback(int *code,int *color,int *priority_mask)
29void simpsons_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask)
3030{
3131   int pri = (*color & 0x0f80) >> 6;   /* ??????? */
3232   if (pri <= layerpri[2])                        *priority_mask = 0;
r6740r6741
4040
4141/***************************************************************************
4242
43    Start the video hardware emulation.
44
45***************************************************************************/
46
47VIDEO_START( simpsons )
48{
49   K053251_vh_start(machine);
50
51   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tile_callback);
52   K053247_vh_start(machine,"gfx2",53,23,NORMAL_PLANE_ORDER,sprite_callback);
53}
54
55/***************************************************************************
56
5743  Extra video banking
5844
5945***************************************************************************/
6046
6147static READ8_HANDLER( simpsons_K052109_r )
6248{
63   return K052109_r(space,offset + 0x2000);
49   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
50   return k052109_r(k052109, offset + 0x2000);
6451}
6552
6653static WRITE8_HANDLER( simpsons_K052109_w )
6754{
68   K052109_w(space,offset + 0x2000,data);
55   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
56   k052109_w(k052109, offset + 0x2000, data);
6957}
7058
7159static READ8_HANDLER( simpsons_K053247_r )
r6740r6741
10391
10492void simpsons_video_banking(running_machine *machine, int bank)
10593{
94   const device_config *k052109 = devtag_get_device(machine, "k052109");
95   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
96
10697   if (bank & 1)
10798   {
108      memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000, 0x0fff, 0, 0, "bank5");
109      memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000, 0x0fff, 0, 0, paletteram_xBBBBBGGGGGRRRRR_be_w);
99      memory_install_read_bank(space, 0x0000, 0x0fff, 0, 0, "bank5");
100      memory_install_write8_handler(space, 0x0000, 0x0fff, 0, 0, paletteram_xBBBBBGGGGGRRRRR_be_w);
110101      memory_set_bankptr(machine, "bank5", machine->generic.paletteram.v);
111102   }
112103   else
113      memory_install_readwrite8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000, 0x0fff, 0, 0, K052109_r, K052109_w);
104      memory_install_readwrite8_device_handler(space, k052109, 0x0000, 0x0fff, 0, 0, k052109_r, k052109_w);
114105
115106   if (bank & 2)
116      memory_install_readwrite8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x2000, 0x3fff, 0, 0, simpsons_K053247_r, simpsons_K053247_w);
107      memory_install_readwrite8_handler(space, 0x2000, 0x3fff, 0, 0, simpsons_K053247_r, simpsons_K053247_w);
117108   else
118      memory_install_readwrite8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x2000, 0x3fff, 0, 0, simpsons_K052109_r, simpsons_K052109_w);
109      memory_install_readwrite8_handler(space, 0x2000, 0x3fff, 0, 0, simpsons_K052109_r, simpsons_K052109_w);
119110}
120111
121112
r6740r6741
144135
145136VIDEO_UPDATE( simpsons )
146137{
138   const device_config *k053246 = devtag_get_device(screen->machine, "k053246");
139   const device_config *k053251 = devtag_get_device(screen->machine, "k053251");
140   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
147141   int layer[3];
148142
143   bg_colorbase       = k053251_get_palette_index(k053251, K053251_CI0);
144   sprite_colorbase   = k053251_get_palette_index(k053251, K053251_CI1);
145   layer_colorbase[0] = k053251_get_palette_index(k053251, K053251_CI2);
146   layer_colorbase[1] = k053251_get_palette_index(k053251, K053251_CI3);
147   layer_colorbase[2] = k053251_get_palette_index(k053251, K053251_CI4);
149148
150   bg_colorbase       = K053251_get_palette_index(K053251_CI0);
151   sprite_colorbase   = K053251_get_palette_index(K053251_CI1);
152   layer_colorbase[0] = K053251_get_palette_index(K053251_CI2);
153   layer_colorbase[1] = K053251_get_palette_index(K053251_CI3);
154   layer_colorbase[2] = K053251_get_palette_index(K053251_CI4);
149   k052109_tilemap_update(k052109);
155150
156   K052109_tilemap_update();
157
158151   layer[0] = 0;
159   layerpri[0] = K053251_get_priority(K053251_CI2);
152   layerpri[0] = k053251_get_priority(k053251, K053251_CI2);
160153   layer[1] = 1;
161   layerpri[1] = K053251_get_priority(K053251_CI3);
154   layerpri[1] = k053251_get_priority(k053251, K053251_CI3);
162155   layer[2] = 2;
163   layerpri[2] = K053251_get_priority(K053251_CI4);
156   layerpri[2] = k053251_get_priority(k053251, K053251_CI4);
164157
165158   sortlayers(layer,layerpri);
166159
167160   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
168161   bitmap_fill(bitmap,cliprect,16 * bg_colorbase);
169   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[0]],0,1);
170   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[1]],0,2);
171   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[2]],0,4);
162   k052109_tilemap_draw(k052109, bitmap, cliprect, layer[0], 0,1);
163   k052109_tilemap_draw(k052109, bitmap, cliprect, layer[1], 0,2);
164   k052109_tilemap_draw(k052109, bitmap, cliprect, layer[2], 0,4);
172165
173   K053247_sprites_draw(screen->machine, bitmap,cliprect);
166   k053247_sprites_draw(k053246, bitmap, cliprect);
174167   return 0;
175168}
src/mame/video/actfancr.c
r6740r6741
55*******************************************************************************/
66
77#include "driver.h"
8#include "actfancr.h"
8#include "includes/actfancr.h"
99
1010
1111static TILEMAP_MAPPER( actfancr_scan )
src/mame/video/tank8.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "tank8.h"
8#include "includes/tank8.h"
99
1010
1111UINT8 *tank8_video_ram;
src/mame/video/mw8080bw.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "mw8080bw.h"
8#include "includes/mw8080bw.h"
99
1010
11
1211VIDEO_UPDATE( mw8080bw )
1312{
13    mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data;
1414   UINT8 x = 0;
1515   UINT8 y = MW8080BW_VCOUNTER_START_NO_VBLANK;
1616   UINT8 video_data = 0;
r6740r6741
5151      else if ((x & 0x07) == 0x04)
5252      {
5353         offs_t offs = ((offs_t)y << 5) | (x >> 3);
54         video_data = mw8080bw_ram[offs];
54         video_data = state->main_ram[offs];
5555      }
5656   }
5757
r6740r6741
6767 *************************************/
6868
6969
70#define PHANTOM2_BOTTOM_TRENCH_DARK_RGB32_PEN   RGB_BLACK
71#define PHANTOM2_BOTTOM_TRENCH_LIGHT_RGB32_PEN   MAKE_RGB(0x5a, 0x5a, 0x5a)
72#define PHANTOM2_TOP_TRENCH_DARK_RGB32_PEN      RGB_BLACK
73#define PHANTOM2_TOP_TRENCH_LIGHT_RGB32_PEN      RGB_WHITE
74#define PHANTOM2_SIDE_TRENCH_DARK_RGB32_PEN      RGB_BLACK
75#define PHANTOM2_SIDE_TRENCH_LIGHT_RGB32_PEN   MAKE_RGB(0x72, 0x72, 0x72)
70#define PHANTOM2_BOTTOM_TRENCH_DARK_RGB32_PEN    RGB_BLACK
71#define PHANTOM2_BOTTOM_TRENCH_LIGHT_RGB32_PEN   MAKE_RGB(0x5a, 0x5a, 0x5a)
72#define PHANTOM2_TOP_TRENCH_DARK_RGB32_PEN       RGB_BLACK
73#define PHANTOM2_TOP_TRENCH_LIGHT_RGB32_PEN      RGB_WHITE
74#define PHANTOM2_SIDE_TRENCH_DARK_RGB32_PEN      RGB_BLACK
75#define PHANTOM2_SIDE_TRENCH_LIGHT_RGB32_PEN     MAKE_RGB(0x72, 0x72, 0x72)
7676
7777
7878VIDEO_UPDATE( spcenctr )
7979{
80    mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data;
8081   UINT8 line_buf[256]; /* 256x1 bit RAM */
8182
8283   UINT8 x = 0;
r6740r6741
8586   UINT8 draw_line = 0;
8687   UINT8 draw_trench = 0;
8788   UINT8 draw_floor = 0;
88   UINT8 width = spcenctr_get_trench_width();
89   UINT8 width = state->spcenctr_trench_width;
8990   UINT8 floor_width = width;
90   UINT8 center = spcenctr_get_trench_center();
91   UINT8 center = state->spcenctr_trench_center;
9192
9293   memset(line_buf, 0, 256);
9394
r6740r6741
149150
150151         /* update the trench control for the next line */
151152         offs = ((offs_t)y << 5) | 0x1f;
152         trench_control = mw8080bw_ram[offs];
153         trench_control = state->main_ram[offs];
153154
154155         if (trench_control & 0x40)
155156            draw_trench = 1;
r6740r6741
167168
168169         /* add the lower 2 bits stored in the slope array to width */
169170         if (draw_trench)
170            width = width + (spcenctr_get_trench_slope(y) & 0x03);
171            width = width + (state->spcenctr_trench_slope[y & 0x0f] & 0x03);
171172
172173         /* add the higher 2 bits stored in the slope array to floor width */
173174         if (draw_floor)
174            floor_width = floor_width + ((spcenctr_get_trench_slope(y) & 0x0c) >> 2);
175            floor_width = floor_width + ((state->spcenctr_trench_slope[y & 0x0f] & 0x0c) >> 2);
175176
176177         /* next row, video_data is now 0, so the next line will start
177178               with 4 blank pixels */
r6740r6741
185186      else if ((x & 0x07) == 0x04)
186187      {
187188         offs_t offs = ((offs_t)y << 5) | (x >> 3);
188         video_data = mw8080bw_ram[offs];
189         video_data = state->main_ram[offs];
189190      }
190191   }
191192
r6740r6741
211212     Bits 1-7 go to address line A4-A10 of the cloud gfx prom.
212213*/
213214
214#define PHANTOM2_CLOUD_COUNTER_START   (0x0e0b)
215#define PHANTOM2_CLOUD_COUNTER_END      (0x1000)
216#define PHANTOM2_CLOUD_COUNTER_PERIOD   (PHANTOM2_CLOUD_COUNTER_END - PHANTOM2_CLOUD_COUNTER_START)
215#define PHANTOM2_CLOUD_COUNTER_START      (0x0e0b)
216#define PHANTOM2_CLOUD_COUNTER_END        (0x1000)
217#define PHANTOM2_CLOUD_COUNTER_PERIOD     (PHANTOM2_CLOUD_COUNTER_END - PHANTOM2_CLOUD_COUNTER_START)
217218
218#define PHANTOM2_RGB32_CLOUD_PEN      MAKE_RGB(0xc0, 0xc0, 0xc0)
219#define PHANTOM2_RGB32_CLOUD_PEN          MAKE_RGB(0xc0, 0xc0, 0xc0)
219220
220221
221222VIDEO_UPDATE( phantom2 )
222223{
224    mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data;
223225   UINT8 x = 0;
224226   UINT8 y = MW8080BW_VCOUNTER_START_NO_VBLANK;
225227   UINT8 video_data = 0;
226228   UINT8 cloud_data = 0;
227229
228   UINT16 cloud_counter = phantom2_get_cloud_counter();
230   UINT16 cloud_counter = state->phantom2_cloud_counter;
229231
230232   UINT8 *cloud_region = memory_region(screen->machine, "proms");
231233
r6740r6741
301303      else if ((x & 0x07) == 0x04)
302304      {
303305         offs_t offs = ((offs_t)y << 5) | (x >> 3);
304         video_data = mw8080bw_ram[offs];
306         video_data = state->main_ram[offs];
305307      }
306308   }
307309
r6740r6741
311313
312314VIDEO_EOF( phantom2 )
313315{
314   UINT16 cloud_counter = phantom2_get_cloud_counter();
316    mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
315317
316   cloud_counter = cloud_counter + MW8080BW_VTOTAL;
318   state->phantom2_cloud_counter += MW8080BW_VTOTAL;
317319
318   if (cloud_counter >= PHANTOM2_CLOUD_COUNTER_END)
319      cloud_counter = PHANTOM2_CLOUD_COUNTER_START + (cloud_counter - PHANTOM2_CLOUD_COUNTER_END);
320
321   phantom2_set_cloud_counter(cloud_counter);
320   if (state->phantom2_cloud_counter >= PHANTOM2_CLOUD_COUNTER_END)
321      state->phantom2_cloud_counter = PHANTOM2_CLOUD_COUNTER_START + (state->phantom2_cloud_counter - PHANTOM2_CLOUD_COUNTER_END);
322322}
323323
324324
325
326325/*************************************
327326 *
328327 *  Space Invaders
r6740r6741
334333
335334VIDEO_UPDATE( invaders )
336335{
336    mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data;
337337   UINT8 x = 0;
338338   UINT8 y = MW8080BW_VCOUNTER_START_NO_VBLANK;
339339   UINT8 video_data = 0;
340   UINT8 flip = invaders_is_flip_screen();
340   UINT8 flip = state->invaders_flip_screen;
341341
342342   while (1)
343343   {
r6740r6741
383383      else if ((x & 0x07) == 0x04)
384384      {
385385         offs_t offs = ((offs_t)y << 5) | (x >> 3);
386         video_data = mw8080bw_ram[offs];
386         video_data = state->main_ram[offs];
387387      }
388388   }
389389
src/mame/video/vaportra.c
r6740r6741
1010***************************************************************************/
1111
1212#include "driver.h"
13#include "deco16ic.h"
13#include "includes/deco16ic.h"
1414
1515static UINT16 vaportra_priority[2];
1616
src/mame/video/nova2001.c
r6740r6741
11#include "driver.h"
2#include "nova2001.h"
2#include "includes/nova2001.h"
33
44UINT8 *nova2001_fg_videoram, *nova2001_bg_videoram;
55
src/mame/video/cps1.c
r6740r6741
318318***************************************************************************/
319319
320320#include "driver.h"
321#include "cps1.h"
321#include "includes/cps1.h"
322322
323323#define VERBOSE 0
324324
r6740r6741
337337#define GFXTYPE_STARS     (1<<4)
338338
339339
340struct gfx_range
341{
342   // start and end are as passed by the game (shift adjusted to be all
343   // in the same scale a 8x8 tiles): they don't necessarily match the
344   // position in ROM.
345   int type;
346   int start;
347   int end;
348   int bank;
349};
350
351struct CPS1config
352{
353   const char *name;             /* game driver name */
354
355   /* Some games interrogate a couple of registers on bootup. */
356   /* These are CPS1 board B self test checks. They wander from game to */
357   /* game. */
358   int cpsb_addr;        /* CPS board B test register address */
359   int cpsb_value;       /* CPS board B test register expected value */
360
361   /* some games use as a protection check the ability to do 16-bit multiplies */
362   /* with a 32-bit result, by writing the factors to two ports and reading the */
363   /* result from two other ports. */
364   /* It looks like this feature was introduced with 3wonders (CPSB ID = 08xx) */
365   int mult_factor1;
366   int mult_factor2;
367   int mult_result_lo;
368   int mult_result_hi;
369
370   /* unknown registers which might be related to the multiply protection */
371   int unknown1;
372   int unknown2;
373   int unknown3;
374
375   int layer_control;
376   int priority[4];
377   int palette_control;
378
379   /* ideally, the layer enable masks should consist of only one bit, */
380   /* but in many cases it is unknown which bit is which. */
381   int layer_enable_mask[5];
382
383   /* these depend on the B-board model and PAL */
384   int bank_sizes[4];
385   const struct gfx_range *bank_mapper;
386
387   /* some C-boards have additional I/O for extra buttons/extra players */
388   int in2_addr;
389   int in3_addr;
390   int out2_addr;
391
392   int bootleg_kludge;
393};
394
395static const struct CPS1config *cps1_game_config;
396
397
398340#define __not_applicable__   -1,-1,-1,-1,-1,-1,-1
399341
400342/*                     CPSB ID    multiply protection      unknown      ctrl     priority masks   palctrl    layer enable masks  */
r6740r6741
12291171};
12301172
12311173
1232
12331174static const struct CPS1config cps1_config_table[]=
12341175{
12351176   /* name       CPSB         gfx mapper   in2  in3  out2   kludge */
r6740r6741
13811322
13821323
13831324
1384/* Public variables */
1385UINT16 *cps1_gfxram;
1386UINT16 *cps1_cps_a_regs;
1387UINT16 *cps1_cps_b_regs;
13881325
1389size_t cps1_gfxram_size;
1390
13911326/* Offset of each palette entry */
13921327#define cps1_palette_entries (32*6)  /* Number colour schemes in palette */
13931328
1394static const int cps1_scroll_size =0x4000;   /* scroll1, scroll2, scroll3 */
1395static const int cps1_obj_size    =0x0800;
1396static const int cps1_other_size  =0x0800;
1397static const int cps1_palette_align=0x0400;   /* minimum alignment is a single palette page (512 colors). Verified on pcb. */
1398static const int cps1_palette_size=cps1_palette_entries*32; /* Size of palette RAM */
13991329
1400static UINT16 *cps1_scroll1;
1401static UINT16 *cps1_scroll2;
1402static UINT16 *cps1_scroll3;
1403static UINT16 *cps1_obj;
1404static UINT16 *cps1_buffered_obj;
1405UINT16 *cps1_other;
1406
1407/* Working variables */
1408static int cps1_last_sprite_offset;     /* Offset of the last sprite */
1409static int cps1_stars_enabled[2];          /* Layer enabled [Y/N] */
1410
1411tilemap *cps1_bg_tilemap[3];
1412
1413
1414int cps1_scroll1x, cps1_scroll1y;
1415int cps1_scroll2x, cps1_scroll2y;
1416int cps1_scroll3x, cps1_scroll3y;
1417static int stars1x, stars1y, stars2x, stars2y;
1418
1419
14201330/* CPS-A registers */
14211331#define CPS1_OBJ_BASE           (0x00/2)    /* Base address of objects */
14221332#define CPS1_SCROLL1_BASE       (0x02/2)    /* Base address of scroll 1 */
r6740r6741
14421352CPS1 VIDEO RENDERER
14431353
14441354*/
1445/* first 0x4000 of gfx ROM are used, but 0x0000-0x1fff is == 0x2000-0x3fff */
1446static const int stars_rom_size = 0x2000;
1447
1448/* PSL: CPS2 support */
1449static const int cps2_obj_size    =0x2000;
1450UINT16 *cps2_objram1,*cps2_objram2;
1451UINT16 *cps2_output;
1452
1453size_t cps2_output_size;
1454static UINT16 *cps2_buffered_obj;
1455static int pri_ctrl;            /* Sprite layer priorities */
1456static int cps2_objram_bank;
1457static int cps2_last_sprite_offset;     /* Offset of the last sprite */
1458
14591355#define CPS2_OBJ_BASE   0x00   /* Unknown (not base address of objects). Could be bass address of bank used when object swap bit set? */
14601356#define CPS2_OBJ_UK1   0x02   /* Unknown (nearly always 0x807d, or 0x808e when screen flipped) */
14611357#define CPS2_OBJ_PRI   0x04   /* Layers priorities */
r6740r6741
14641360#define CPS2_OBJ_YOFFS   0x0a   /* Y offset (always 0x0010) */
14651361
14661362
1467static int cps_version;
1468int cps1_scanline1;
1469int cps1_scanline2;
1470int cps1_scancalls;
1471
1472
14731363static void cps1_build_palette(running_machine *machine, const UINT16* const palette_base);
14741364
14751365
14761366static MACHINE_RESET( cps )
14771367{
1368   cps_state *state = (cps_state *)machine->driver_data;
14781369   const char *gamename = machine->gamedrv->name;
1479   const struct CPS1config *pCFG=&cps1_config_table[0];
1370   const struct CPS1config *pCFG = &cps1_config_table[0];
14801371
1481   while(pCFG->name)
1372   while (pCFG->name)
14821373   {
14831374      if (strcmp(pCFG->name, gamename) == 0)
1484      {
14851375         break;
1486      }
1376
14871377      pCFG++;
14881378   }
1489   cps1_game_config=pCFG;
14901379
1491    if (!cps1_game_config->name)
1492    {
1493        gamename="cps2";
1494        pCFG=&cps1_config_table[0];
1495        while(pCFG->name)
1496        {
1497            if (strcmp(pCFG->name, gamename) == 0)
1498            {
1499                break;
1500            }
1501            pCFG++;
1502        }
1503        cps1_game_config=pCFG;
1504   }
1380   state->game_config = pCFG;
15051381
1506   if (strcmp(gamename, "sf2rb" )==0)
1382   if (!state->game_config->name)
15071383   {
1384      gamename = "cps2";
1385      pCFG = &cps1_config_table[0];
1386
1387      while(pCFG->name)
1388      {
1389         if (strcmp(pCFG->name, gamename) == 0)
1390            break;
1391
1392         pCFG++;
1393      }
1394
1395      state->game_config = pCFG;
1396   }
1397
1398   if (strcmp(gamename, "sf2rb") == 0)
1399   {
15081400      /* Patch out protection check */
15091401      UINT16 *rom = (UINT16 *)memory_region(machine, "maincpu");
1510      rom[0xe5464/2] = 0x6012;
1402      rom[0xe5464 / 2] = 0x6012;
15111403   }
1512   if (strcmp(gamename, "sf2rb2" )==0)
1404
1405   if (strcmp(gamename, "sf2rb2") == 0)
15131406   {
15141407      /* Patch out protection check */
15151408      UINT16 *rom = (UINT16 *)memory_region(machine, "maincpu");
1516      rom[0xe5332/2] = 0x6014;
1409      rom[0xe5332 / 2] = 0x6014;
15171410   }
15181411
15191412#if 0
1520   if (strcmp(gamename, "sf2accp2" )==0)
1413   if (strcmp(gamename, "sf2accp2") == 0)
15211414   {
15221415      /* Patch out a odd branch which would be incorrectly interpreted
15231416           by the cpu core as a 32-bit branch. This branch would make the
15241417           game crash (address error, since it would branch to an odd address)
15251418           if location 180ca6 (outside ROM space) isn't 0. Protection check? */
15261419      UINT16 *rom = (UINT16 *)memory_region(machine, "maincpu");
1527      rom[0x11756/2] = 0x4e71;
1420      rom[0x11756 / 2] = 0x4e71;
15281421   }
1529   else if (strcmp(gamename, "ghouls" )==0)
1422   else if (strcmp(gamename, "ghouls") == 0)
15301423   {
15311424      /* Patch out self-test... it takes forever */
15321425      UINT16 *rom = (UINT16 *)memory_region(machine, "maincpu");
1533      rom[0x61964/2] = 0x4ef9;
1534      rom[0x61966/2] = 0x0000;
1535      rom[0x61968/2] = 0x0400;
1426      rom[0x61964 / 2] = 0x4ef9;
1427      rom[0x61966 / 2] = 0x0000;
1428      rom[0x61968 / 2] = 0x0400;
15361429   }
15371430#endif
15381431}
15391432
15401433
1541INLINE UINT16 *cps1_base(int offset,int boundary)
1434INLINE UINT16 *cps1_base( running_machine *machine, int offset, int boundary )
15421435{
1543   int base = cps1_cps_a_regs[offset]*256;
1436   cps_state *state = (cps_state *)machine->driver_data;
1437   int base = state->cps_a_regs[offset] * 256;
15441438
15451439   /*
15461440    The scroll RAM must start on a 0x4000 boundary.
r6740r6741
15501444       Muscle bomber games  - will animate garbage during gameplay
15511445    Mask out the irrelevant bits.
15521446    */
1553   base &= ~(boundary-1);
1554    return &cps1_gfxram[(base&0x3ffff)/2];
1447   base &= ~(boundary - 1);
1448    return &state->gfxram[(base & 0x3ffff) / 2];
15551449}
15561450
15571451
15581452
15591453WRITE16_HANDLER( cps1_cps_a_w )
15601454{
1561   data = COMBINE_DATA(&cps1_cps_a_regs[offset]);
1455   cps_state *state = (cps_state *)space->machine->driver_data;
1456   data = COMBINE_DATA(&state->cps_a_regs[offset]);
15621457
15631458   /*
15641459    The main CPU writes the palette to gfxram, and the CPS-B custom copies it
r6740r6741
15691464    fixes glitches in the ghouls intro, but it might happen at next vblank.
15701465    */
15711466   if (offset == CPS1_PALETTE_BASE)
1572      cps1_build_palette(space->machine, cps1_base(CPS1_PALETTE_BASE,cps1_palette_align));
1467      cps1_build_palette(space->machine, cps1_base(space->machine, CPS1_PALETTE_BASE, state->palette_align));
15731468
15741469   // pzloop2 write to register 24 on startup. This is probably just a bug.
1575   if (offset == 0x24/2 && cps_version == 2)
1470   if (offset == 0x24 / 2 && state->cps_version == 2)
15761471      return;
15771472
15781473   if (offset > CPS1_VIDEOCONTROL)
1579      popmessage("write to CPS-A register %02x contact MAMEDEV", offset*2);
1474      popmessage("write to CPS-A register %02x contact MAMEDEV", offset * 2);
15801475}
15811476
15821477
15831478READ16_HANDLER( cps1_cps_b_r )
15841479{
1480   cps_state *state = (cps_state *)space->machine->driver_data;
1481
15851482   /* Some games interrogate a couple of registers on bootup. */
15861483   /* These are CPS1 board B self test checks. They wander from game to */
15871484   /* game. */
1588   if (offset == cps1_game_config->cpsb_addr/2)
1589      return cps1_game_config->cpsb_value;
1485   if (offset == state->game_config->cpsb_addr / 2)
1486      return state->game_config->cpsb_value;
15901487
15911488   /* some games use as a protection check the ability to do 16-bit multiplications */
15921489   /* with a 32-bit result, by writing the factors to two ports and reading the */
15931490   /* result from two other ports. */
1594   if (offset == cps1_game_config->mult_result_lo/2)
1595      return (cps1_cps_b_regs[cps1_game_config->mult_factor1/2] *
1596            cps1_cps_b_regs[cps1_game_config->mult_factor2/2]) & 0xffff;
1597   if (offset == cps1_game_config->mult_result_hi/2)
1598      return (cps1_cps_b_regs[cps1_game_config->mult_factor1/2] *
1599            cps1_cps_b_regs[cps1_game_config->mult_factor2/2]) >> 16;
1491   if (offset == state->game_config->mult_result_lo / 2)
1492      return (state->cps_b_regs[state->game_config->mult_factor1 / 2] *
1493            state->cps_b_regs[state->game_config->mult_factor2 / 2]) & 0xffff;
16001494
1601   if (offset == cps1_game_config->in2_addr/2)   /* Extra input ports (on C-board) */
1495   if (offset == state->game_config->mult_result_hi / 2)
1496      return (state->cps_b_regs[state->game_config->mult_factor1 / 2] *
1497            state->cps_b_regs[state->game_config->mult_factor2 / 2]) >> 16;
1498
1499   if (offset == state->game_config->in2_addr / 2)   /* Extra input ports (on C-board) */
16021500      return input_port_read(space->machine, "IN2");
16031501
1604   if (offset == cps1_game_config->in3_addr/2)   /* Player 4 controls (on C-board) ("Captain Commando") */
1502   if (offset == state->game_config->in3_addr / 2)   /* Player 4 controls (on C-board) ("Captain Commando") */
16051503      return input_port_read(space->machine, "IN3");
16061504
1607   if (cps_version == 2)
1505   if (state->cps_version == 2)
16081506   {
16091507      if (offset == 0x10/2)
16101508      {
16111509         // UNKNOWN--only mmatrix appears to read this, and I'm not sure if the result is actuallyused
1612         return cps1_cps_b_regs[0x10/2];
1510         return state->cps_b_regs[0x10 / 2];
16131511      }
16141512      if (offset == 0x12/2)
1615      {
1616         return cps1_cps_b_regs[0x12/2];
1617      }
1513         return state->cps_b_regs[0x12 / 2];
16181514   }
16191515
1620   popmessage("CPS-B read port %02x contact MAMEDEV", offset*2);
1516   popmessage("CPS-B read port %02x contact MAMEDEV", offset * 2);
16211517
16221518   return 0xffff;
16231519}
r6740r6741
16251521
16261522WRITE16_HANDLER( cps1_cps_b_w )
16271523{
1628   data = COMBINE_DATA(&cps1_cps_b_regs[offset]);
1524   cps_state *state = (cps_state *)space->machine->driver_data;
1525   data = COMBINE_DATA(&state->cps_b_regs[offset]);
16291526
1630   if (cps_version == 2)
1527   if (state->cps_version == 2)
16311528   {
16321529      /* To mark scanlines for raster effects */
16331530      if (offset == 0x0e/2)
r6740r6741
16371534      }
16381535      if (offset == 0x10/2)
16391536      {
1640         cps1_scanline1 = (data & 0x1ff);
1537         state->scanline1 = (data & 0x1ff);
16411538         return;
16421539      }
16431540      if (offset == 0x12/2)
16441541      {
1645         cps1_scanline2 = (data & 0x1ff);
1542         state->scanline2 = (data & 0x1ff);
16461543         return;
16471544      }
16481545   }
16491546
16501547
16511548   // additional outputs on C-board
1652   if (offset == cps1_game_config->out2_addr/2)
1549   if (offset == state->game_config->out2_addr / 2)
16531550   {
16541551      if (ACCESSING_BITS_0_7)
16551552      {
1656         if (cps1_game_config->cpsb_value == 0x0402)   // Mercs (CN2 connector)
1553         if (state->game_config->cpsb_value == 0x0402)   // Mercs (CN2 connector)
16571554         {
1658            coin_lockout_w(space->machine, 2,~data & 0x01);
1659            set_led_status(space->machine, 0,data & 0x02);
1660            set_led_status(space->machine, 1,data & 0x04);
1661            set_led_status(space->machine, 2,data & 0x08);
1555            coin_lockout_w(space->machine, 2, ~data & 0x01);
1556            set_led_status(space->machine, 0, data & 0x02);
1557            set_led_status(space->machine, 1, data & 0x04);
1558            set_led_status(space->machine, 2, data & 0x08);
16621559         }
16631560         else   // kod, captcomm, knights
16641561         {
1665            coin_lockout_w(space->machine, 2,~data & 0x02);
1666            coin_lockout_w(space->machine, 3,~data & 0x08);
1562            coin_lockout_w(space->machine, 2, ~data & 0x02);
1563            coin_lockout_w(space->machine, 3, ~data & 0x08);
16671564         }
16681565      }
16691566   }
16701567
16711568
1672   if (offset != cps1_game_config->cpsb_addr/2 &&   // only varth writes here
1673         offset != cps1_game_config->mult_factor1/2 &&
1674         offset != cps1_game_config->mult_factor2/2 &&
1675         offset != cps1_game_config->layer_control/2 &&
1676         offset != cps1_game_config->unknown1/2 &&
1677         offset != cps1_game_config->unknown2/2 &&
1678         offset != cps1_game_config->unknown3/2 &&
1679         offset != cps1_game_config->priority[0]/2 &&
1680         offset != cps1_game_config->priority[1]/2 &&
1681         offset != cps1_game_config->priority[2]/2 &&
1682         offset != cps1_game_config->priority[3]/2 &&
1683         offset != cps1_game_config->palette_control/2 &&
1684         offset != cps1_game_config->out2_addr/2 &&
1685         !cps1_game_config->bootleg_kludge)
1686      popmessage("CPS-B write %04x to port %02x contact MAMEDEV", data, offset*2);
1569   if (offset != state->game_config->cpsb_addr / 2 &&   // only varth writes here
1570         offset != state->game_config->mult_factor1 / 2 &&
1571         offset != state->game_config->mult_factor2 / 2 &&
1572         offset != state->game_config->layer_control / 2 &&
1573         offset != state->game_config->unknown1 / 2 &&
1574         offset != state->game_config->unknown2 / 2 &&
1575         offset != state->game_config->unknown3 / 2 &&
1576         offset != state->game_config->priority[0] / 2 &&
1577         offset != state->game_config->priority[1] / 2 &&
1578         offset != state->game_config->priority[2] / 2 &&
1579         offset != state->game_config->priority[3] / 2 &&
1580         offset != state->game_config->palette_control / 2 &&
1581         offset != state->game_config->out2_addr / 2 &&
1582         !state->game_config->bootleg_kludge)
1583      popmessage("CPS-B write %04x to port %02x contact MAMEDEV", data, offset * 2);
16871584}
16881585
16891586
16901587
1691INLINE int cps2_port(int offset)
1588INLINE int cps2_port( running_machine *machine, int offset )
16921589{
1693    return cps2_output[offset/2];
1590   cps_state *state = (cps_state *)machine->driver_data;
1591   return state->output[offset / 2];
16941592}
16951593
16961594
1697
1698
1699static void cps1_gfx_decode(running_machine *machine)
1595static void cps1_gfx_decode( running_machine *machine )
17001596{
1701   int size=memory_region_length(machine, "gfx");
1702   int i,j,gfxsize;
1597   int size = memory_region_length(machine, "gfx");
1598   int i, j, gfxsize;
17031599   UINT8 *cps1_gfx = memory_region(machine, "gfx");
17041600
1601   gfxsize = size / 4;
17051602
1706   gfxsize=size/4;
1707
1708   for (i = 0;i < gfxsize;i++)
1603   for (i = 0; i < gfxsize; i++)
17091604   {
1710      UINT32 src = cps1_gfx[4*i] + (cps1_gfx[4*i+1]<<8) + (cps1_gfx[4*i+2]<<16) + (cps1_gfx[4*i+3]<<24);
1605      UINT32 src = cps1_gfx[4 * i] + (cps1_gfx[4 * i + 1] << 8) + (cps1_gfx[4 * i + 2] << 16) + (cps1_gfx[4 * i + 3] << 24);
17111606      UINT32 dwval = 0;
17121607
1713      for (j = 0;j < 8;j++)
1608      for (j = 0; j < 8; j++)
17141609      {
17151610         int n = 0;
17161611         UINT32 mask = (0x80808080 >> j) & src;
r6740r6741
17221617
17231618         dwval |= n << (j * 4);
17241619      }
1725      cps1_gfx[4*i  ] = dwval>>0;
1726      cps1_gfx[4*i+1] = dwval>>8;
1727      cps1_gfx[4*i+2] = dwval>>16;
1728      cps1_gfx[4*i+3] = dwval>>24;
1620      cps1_gfx[4 *i    ] = dwval >> 0;
1621      cps1_gfx[4 *i + 1] = dwval >> 8;
1622      cps1_gfx[4 *i + 2] = dwval >> 16;
1623      cps1_gfx[4 *i + 3] = dwval >> 24;
17291624   }
17301625}
17311626
1732static void unshuffle(UINT64 *buf,int len)
1627static void unshuffle( UINT64 *buf, int len )
17331628{
17341629   int i;
17351630   UINT64 t;
17361631
1737   if (len == 2) return;
1632   if (len == 2)
1633      return;
17381634
17391635   assert(len % 4 == 0);   /* must not happen */
17401636
17411637   len /= 2;
17421638
1743   unshuffle(buf,len);
1744   unshuffle(buf + len,len);
1639   unshuffle(buf, len);
1640   unshuffle(buf + len, len);
17451641
1746   for (i = 0;i < len/2;i++)
1642   for (i = 0; i < len / 2; i++)
17471643   {
1748      t = buf[len/2 + i];
1749      buf[len/2 + i] = buf[len + i];
1644      t = buf[len / 2 + i];
1645      buf[len / 2 + i] = buf[len + i];
17501646      buf[len + i] = t;
17511647   }
17521648}
17531649
1754static void cps2_gfx_decode(running_machine *machine)
1650static void cps2_gfx_decode( running_machine *machine )
17551651{
1756   const int banksize=0x200000;
1757   int size=memory_region_length(machine, "gfx");
1652   const int banksize = 0x200000;
1653   int size = memory_region_length(machine, "gfx");
17581654   int i;
17591655
1760   for (i = 0;i < size;i += banksize)
1761      unshuffle((UINT64 *)(memory_region(machine, "gfx") + i),banksize/8);
1656   for (i = 0; i < size; i += banksize)
1657      unshuffle((UINT64 *)(memory_region(machine, "gfx") + i), banksize / 8);
17621658
17631659   cps1_gfx_decode(machine);
17641660}
r6740r6741
17661662
17671663DRIVER_INIT( cps1 )
17681664{
1665   cps_state *state = (cps_state *)machine->driver_data;
1666
17691667   cps1_gfx_decode(machine);
1668
1669   state->scanline1 = 0;
1670   state->scanline2 = 0;
1671   state->scancalls = 0;
1672   state->last_sprite_offset = 0;
1673   state->pri_ctrl = 0;
1674   state->objram_bank = 0;
17701675}
17711676
17721677
17731678
17741679DRIVER_INIT( cps2_video )
17751680{
1681   cps_state *state = (cps_state *)machine->driver_data;
1682
17761683   cps2_gfx_decode(machine);
17771684
1778   cps1_scanline1 = 262;
1779   cps1_scanline2 = 262;
1780   cps1_scancalls = 0;
1685   state->scanline1 = 262;
1686   state->scanline2 = 262;
1687   state->scancalls = 0;
1688   state->last_sprite_offset = 0;
1689   state->cps2_last_sprite_offset = 0;
1690   state->pri_ctrl = 0;
1691   state->objram_bank = 0;
17811692}
17821693
17831694
1784void cps1_get_video_base(void )
1695void cps1_get_video_base( running_machine *machine )
17851696{
1697   cps_state *state = (cps_state *)machine->driver_data;
17861698   int layercontrol, videocontrol, scroll1xoff, scroll2xoff, scroll3xoff;
17871699
17881700   /* Re-calculate the VIDEO RAM base */
1789   if (cps1_scroll1 != cps1_base(CPS1_SCROLL1_BASE,cps1_scroll_size))
1701   if (state->scroll1 != cps1_base(machine, CPS1_SCROLL1_BASE, state->scroll_size))
17901702   {
1791      cps1_scroll1 = cps1_base(CPS1_SCROLL1_BASE,cps1_scroll_size);
1792      tilemap_mark_all_tiles_dirty(cps1_bg_tilemap[0]);
1703      state->scroll1 = cps1_base(machine, CPS1_SCROLL1_BASE, state->scroll_size);
1704      tilemap_mark_all_tiles_dirty(state->bg_tilemap[0]);
17931705   }
1794   if (cps1_scroll2 != cps1_base(CPS1_SCROLL2_BASE,cps1_scroll_size))
1706   if (state->scroll2 != cps1_base(machine, CPS1_SCROLL2_BASE, state->scroll_size))
17951707   {
1796      cps1_scroll2 = cps1_base(CPS1_SCROLL2_BASE,cps1_scroll_size);
1797      tilemap_mark_all_tiles_dirty(cps1_bg_tilemap[1]);
1708      state->scroll2 = cps1_base(machine, CPS1_SCROLL2_BASE, state->scroll_size);
1709      tilemap_mark_all_tiles_dirty(state->bg_tilemap[1]);
17981710   }
1799   if (cps1_scroll3 != cps1_base(CPS1_SCROLL3_BASE,cps1_scroll_size))
1711   if (state->scroll3 != cps1_base(machine, CPS1_SCROLL3_BASE, state->scroll_size))
18001712   {
1801      cps1_scroll3 = cps1_base(CPS1_SCROLL3_BASE,cps1_scroll_size);
1802      tilemap_mark_all_tiles_dirty(cps1_bg_tilemap[2]);
1713      state->scroll3 = cps1_base(machine, CPS1_SCROLL3_BASE, state->scroll_size);
1714      tilemap_mark_all_tiles_dirty(state->bg_tilemap[2]);
18031715   }
18041716
18051717   /* Some of the sf2 hacks use only sprite port 0x9100 and the scroll layers are offset */
1806   if (cps1_game_config->bootleg_kludge == 1)
1718   if (state->game_config->bootleg_kludge == 1)
18071719   {
1808      cps1_cps_a_regs[CPS1_OBJ_BASE] = 0x9100;
1809      cps1_obj = cps1_base(CPS1_OBJ_BASE, cps1_obj_size);
1720      state->cps_a_regs[CPS1_OBJ_BASE] = 0x9100;
1721      state->obj = cps1_base(machine, CPS1_OBJ_BASE, state->obj_size);
18101722      scroll1xoff = -0x0c;
18111723      scroll2xoff = -0x0e;
18121724      scroll3xoff = -0x10;
18131725   }
18141726   else
18151727   {
1816      cps1_obj = cps1_base(CPS1_OBJ_BASE, cps1_obj_size);
1728      state->obj = cps1_base(machine, CPS1_OBJ_BASE, state->obj_size);
18171729      scroll1xoff = 0;
18181730      scroll2xoff = 0;
18191731      scroll3xoff = 0;
18201732   }
1821   cps1_other = cps1_base(CPS1_OTHER_BASE,cps1_other_size);
18221733
1734   state->other = cps1_base(machine, CPS1_OTHER_BASE, state->other_size);
1735
18231736   /* Get scroll values */
1824   cps1_scroll1x = cps1_cps_a_regs[CPS1_SCROLL1_SCROLLX] + scroll1xoff;
1825   cps1_scroll1y = cps1_cps_a_regs[CPS1_SCROLL1_SCROLLY];
1826   cps1_scroll2x = cps1_cps_a_regs[CPS1_SCROLL2_SCROLLX] + scroll2xoff;
1827   cps1_scroll2y = cps1_cps_a_regs[CPS1_SCROLL2_SCROLLY];
1828   cps1_scroll3x = cps1_cps_a_regs[CPS1_SCROLL3_SCROLLX] + scroll3xoff;
1829   cps1_scroll3y = cps1_cps_a_regs[CPS1_SCROLL3_SCROLLY];
1830   stars1x = cps1_cps_a_regs[CPS1_STARS1_SCROLLX];
1831   stars1y = cps1_cps_a_regs[CPS1_STARS1_SCROLLY];
1832   stars2x = cps1_cps_a_regs[CPS1_STARS2_SCROLLX];
1833   stars2y = cps1_cps_a_regs[CPS1_STARS2_SCROLLY];
1737   state->scroll1x = state->cps_a_regs[CPS1_SCROLL1_SCROLLX] + scroll1xoff;
1738   state->scroll1y = state->cps_a_regs[CPS1_SCROLL1_SCROLLY];
1739   state->scroll2x = state->cps_a_regs[CPS1_SCROLL2_SCROLLX] + scroll2xoff;
1740   state->scroll2y = state->cps_a_regs[CPS1_SCROLL2_SCROLLY];
1741   state->scroll3x = state->cps_a_regs[CPS1_SCROLL3_SCROLLX] + scroll3xoff;
1742   state->scroll3y = state->cps_a_regs[CPS1_SCROLL3_SCROLLY];
1743   state->stars1x = state->cps_a_regs[CPS1_STARS1_SCROLLX];
1744   state->stars1y = state->cps_a_regs[CPS1_STARS1_SCROLLY];
1745   state->stars2x = state->cps_a_regs[CPS1_STARS2_SCROLLX];
1746   state->stars2y = state->cps_a_regs[CPS1_STARS2_SCROLLY];
18341747
18351748   /* Get layer enable bits */
1836   layercontrol = cps1_cps_b_regs[cps1_game_config->layer_control/2];
1837   videocontrol = cps1_cps_a_regs[CPS1_VIDEOCONTROL];
1838   tilemap_set_enable(cps1_bg_tilemap[0],layercontrol & cps1_game_config->layer_enable_mask[0]);
1839   tilemap_set_enable(cps1_bg_tilemap[1],(layercontrol & cps1_game_config->layer_enable_mask[1]) && (videocontrol & 4));
1840   tilemap_set_enable(cps1_bg_tilemap[2],(layercontrol & cps1_game_config->layer_enable_mask[2]) && (videocontrol & 8));
1841   cps1_stars_enabled[0] = layercontrol & cps1_game_config->layer_enable_mask[3];
1842   cps1_stars_enabled[1] = layercontrol & cps1_game_config->layer_enable_mask[4];
1749   layercontrol = state->cps_b_regs[state->game_config->layer_control / 2];
1750   videocontrol = state->cps_a_regs[CPS1_VIDEOCONTROL];
1751   tilemap_set_enable(state->bg_tilemap[0],layercontrol & state->game_config->layer_enable_mask[0]);
1752   tilemap_set_enable(state->bg_tilemap[1],(layercontrol & state->game_config->layer_enable_mask[1]) && (videocontrol & 4));
1753   tilemap_set_enable(state->bg_tilemap[2],(layercontrol & state->game_config->layer_enable_mask[2]) && (videocontrol & 8));
1754   state->stars_enabled[0] = layercontrol & state->game_config->layer_enable_mask[3];
1755   state->stars_enabled[1] = layercontrol & state->game_config->layer_enable_mask[4];
18431756
18441757
18451758{
1846   int enablemask;
1759   int enablemask = 0;
18471760
1848   enablemask = 0;
1849   if (cps1_game_config->layer_enable_mask[0] == cps1_game_config->layer_enable_mask[1])
1850      enablemask = cps1_game_config->layer_enable_mask[0];
1851   if (cps1_game_config->layer_enable_mask[0] == cps1_game_config->layer_enable_mask[2])
1852      enablemask = cps1_game_config->layer_enable_mask[0];
1853   if (cps1_game_config->layer_enable_mask[1] == cps1_game_config->layer_enable_mask[2])
1854      enablemask = cps1_game_config->layer_enable_mask[1];
1761   if (state->game_config->layer_enable_mask[0] == state->game_config->layer_enable_mask[1])
1762      enablemask = state->game_config->layer_enable_mask[0];
1763
1764   if (state->game_config->layer_enable_mask[0] == state->game_config->layer_enable_mask[2])
1765      enablemask = state->game_config->layer_enable_mask[0];
1766
1767   if (state->game_config->layer_enable_mask[1] == state->game_config->layer_enable_mask[2])
1768      enablemask = state->game_config->layer_enable_mask[1];
1769
18551770   if (enablemask)
18561771   {
18571772      if (((layercontrol & enablemask) && (layercontrol & enablemask) != enablemask))
1858         popmessage("layer %02x contact MAMEDEV",layercontrol&0xc03f);
1773         popmessage("layer %02x contact MAMEDEV", layercontrol & 0xc03f);
18591774   }
18601775
1861   enablemask = cps1_game_config->layer_enable_mask[0] | cps1_game_config->layer_enable_mask[1]
1862         | cps1_game_config->layer_enable_mask[2]
1863         | cps1_game_config->layer_enable_mask[3] | cps1_game_config->layer_enable_mask[4];
1776   enablemask = state->game_config->layer_enable_mask[0] | state->game_config->layer_enable_mask[1]
1777         | state->game_config->layer_enable_mask[2]
1778         | state->game_config->layer_enable_mask[3] | state->game_config->layer_enable_mask[4];
1779
18641780   if (((layercontrol & ~enablemask) & 0x003e) != 0)
1865      popmessage("layer %02x contact MAMEDEV",layercontrol&0xc03f);
1781      popmessage("layer %02x contact MAMEDEV", layercontrol & 0xc03f);
18661782}
18671783
18681784}
r6740r6741
18701786
18711787WRITE16_HANDLER( cps1_gfxram_w )
18721788{
1789   cps_state *state = (cps_state *)space->machine->driver_data;
18731790   int page = (offset >> 7) & 0x3c0;
1874   COMBINE_DATA(&cps1_gfxram[offset]);
1791   COMBINE_DATA(&state->gfxram[offset]);
18751792
1876   if (page == (cps1_cps_a_regs[CPS1_SCROLL1_BASE] & 0x3c0))
1877      tilemap_mark_tile_dirty(cps1_bg_tilemap[0],offset/2 & 0x0fff);
1878   if (page == (cps1_cps_a_regs[CPS1_SCROLL2_BASE] & 0x3c0))
1879      tilemap_mark_tile_dirty(cps1_bg_tilemap[1],offset/2 & 0x0fff);
1880   if (page == (cps1_cps_a_regs[CPS1_SCROLL3_BASE] & 0x3c0))
1881      tilemap_mark_tile_dirty(cps1_bg_tilemap[2],offset/2 & 0x0fff);
1793   if (page == (state->cps_a_regs[CPS1_SCROLL1_BASE] & 0x3c0))
1794      tilemap_mark_tile_dirty(state->bg_tilemap[0], offset / 2 & 0x0fff);
1795
1796   if (page == (state->cps_a_regs[CPS1_SCROLL2_BASE] & 0x3c0))
1797      tilemap_mark_tile_dirty(state->bg_tilemap[1], offset / 2 & 0x0fff);
1798
1799   if (page == (state->cps_a_regs[CPS1_SCROLL3_BASE] & 0x3c0))
1800      tilemap_mark_tile_dirty(state->bg_tilemap[2], offset / 2 & 0x0fff);
18821801}
18831802
18841803
18851804
1886static int gfxrom_bank_mapper(running_machine *machine, int type, int code)
1805static int gfxrom_bank_mapper( running_machine *machine, int type, int code )
18871806{
1888   const struct gfx_range *range = cps1_game_config->bank_mapper;
1807   cps_state *state = (cps_state *)machine->driver_data;
1808   const struct gfx_range *range = state->game_config->bank_mapper;
18891809   int shift = 0;
18901810
18911811   assert(range);
r6740r6741
19101830            int i;
19111831
19121832            for (i = 0; i < range->bank; ++i)
1913               base += cps1_game_config->bank_sizes[i];
1833               base += state->game_config->bank_sizes[i];
19141834
1915            return (base + (code & (cps1_game_config->bank_sizes[range->bank] - 1))) >> shift;
1835            return (base + (code & (state->game_config->bank_sizes[range->bank] - 1))) >> shift;
19161836         }
19171837      }
19181838
r6740r6741
19201840   }
19211841
19221842#ifdef MAME_DEBUG
1923//  popmessage("tile %02x/%04x out of range", type,code>>shift);
1843//  popmessage("tile %02x/%04x out of range", type, code >> shift);
19241844#endif
19251845
19261846   return -1;
r6740r6741
19511871   return (row & 0x07) + ((col & 0x3f) << 3) + ((row & 0x38) << 6);
19521872}
19531873
1954static UINT8 empty_tile8x8[8*8];
1955static UINT8 empty_tile[32*32/2];
1956
19571874static TILE_GET_INFO( get_tile0_info )
19581875{
1959   int code = cps1_scroll1[2*tile_index];
1960   int attr = cps1_scroll1[2*tile_index+1];
1876   cps_state *state = (cps_state *)machine->driver_data;
1877   int code = state->scroll1[2 * tile_index];
1878   int attr = state->scroll1[2 * tile_index + 1];
19611879   int gfxset;
19621880
19631881   code = gfxrom_bank_mapper(machine, GFXTYPE_SCROLL1, code);
r6740r6741
19771895   // for out of range tiles, switch to fully transparent data
19781896   // (but still call SET_TILE_INFO, otherwise problems might occur on boot e.g. unsquad)
19791897   if (code == -1)
1980      tileinfo->pen_data = empty_tile8x8;
1898      tileinfo->pen_data = state->empty_tile8x8;
19811899}
19821900
19831901static TILE_GET_INFO( get_tile1_info )
19841902{
1985   int code = cps1_scroll2[2*tile_index];
1986   int attr = cps1_scroll2[2*tile_index+1];
1903   cps_state *state = (cps_state *)machine->driver_data;
1904   int code = state->scroll2[2 * tile_index];
1905   int attr = state->scroll2[2 * tile_index + 1];
19871906
19881907   code = gfxrom_bank_mapper(machine, GFXTYPE_SCROLL2, code);
19891908
r6740r6741
19961915
19971916   // for out of range tiles, switch to fully transparent data
19981917   if (code == -1)
1999      tileinfo->pen_data = empty_tile;
1918      tileinfo->pen_data = state->empty_tile;
20001919}
20011920
20021921static TILE_GET_INFO( get_tile2_info )
20031922{
2004   int code = cps1_scroll3[2*tile_index] & 0x3fff;
2005   int attr = cps1_scroll3[2*tile_index+1];
1923   cps_state *state = (cps_state *)machine->driver_data;
1924   int code = state->scroll3[2 * tile_index] & 0x3fff;
1925   int attr = state->scroll3[2 * tile_index + 1];
20061926
20071927   code = gfxrom_bank_mapper(machine, GFXTYPE_SCROLL3, code);
20081928
r6740r6741
20161936   // for out of range tiles, switch to fully transparent data
20171937   // (but still call SET_TILE_INFO, otherwise problems might occur on boot e.g. unsquad)
20181938   if (code == -1)
2019      tileinfo->pen_data = empty_tile;
1939      tileinfo->pen_data = state->empty_tile;
20201940}
20211941
20221942
20231943
2024static void cps1_update_transmasks(void)
1944static void cps1_update_transmasks( running_machine *machine )
20251945{
1946   cps_state *state = (cps_state *)machine->driver_data;
20261947   int i;
20271948
2028   for (i = 0;i < 4;i++)
1949   for (i = 0; i < 4; i++)
20291950   {
20301951      int mask;
20311952
20321953      /* Get transparency registers */
2033      if (cps1_game_config->priority[i] != -1)
2034         mask = cps1_cps_b_regs[cps1_game_config->priority[i]/2] ^ 0xffff;
2035      else mask = 0xffff;   /* completely transparent if priority masks not defined (qad) */
1954      if (state->game_config->priority[i] != -1)
1955         mask = state->cps_b_regs[state->game_config->priority[i] / 2] ^ 0xffff;
1956      else
1957         mask = 0xffff;   /* completely transparent if priority masks not defined (qad) */
20361958
2037      tilemap_set_transmask(cps1_bg_tilemap[0],i,mask,0x8000);
2038      tilemap_set_transmask(cps1_bg_tilemap[1],i,mask,0x8000);
2039      tilemap_set_transmask(cps1_bg_tilemap[2],i,mask,0x8000);
1959      tilemap_set_transmask(state->bg_tilemap[0], i, mask, 0x8000);
1960      tilemap_set_transmask(state->bg_tilemap[1], i, mask, 0x8000);
1961      tilemap_set_transmask(state->bg_tilemap[2], i, mask, 0x8000);
20401962   }
20411963}
20421964
1965static STATE_POSTLOAD( cps_postload )
1966{
1967   cps1_get_video_base(machine);
1968}
1969
20431970static VIDEO_START( cps )
20441971{
1972   cps_state *state = (cps_state *)machine->driver_data;
20451973   int i;
20461974
20471975   MACHINE_RESET_CALL(cps);
20481976
2049   cps1_bg_tilemap[0] = tilemap_create(machine, get_tile0_info,tilemap0_scan, 8, 8,64,64);
2050   cps1_bg_tilemap[1] = tilemap_create(machine, get_tile1_info,tilemap1_scan,16,16,64,64);
2051   cps1_bg_tilemap[2] = tilemap_create(machine, get_tile2_info,tilemap2_scan,32,32,64,64);
1977   /* Put in some const */
1978   state->scroll_size    = 0x4000;   /* scroll1, scroll2, scroll3 */
1979   state->obj_size       = 0x0800;
1980   state->cps2_obj_size  = 0x2000;
1981   state->other_size     = 0x0800;
1982   state->palette_align  = 0x0400;   /* minimum alignment is a single palette page (512 colors). Verified on pcb. */
1983   state->palette_size   = cps1_palette_entries * 32; /* Size of palette RAM */
1984   state->stars_rom_size = 0x2000;   /* first 0x4000 of gfx ROM are used, but 0x0000-0x1fff is == 0x2000-0x3fff */
20521985
1986   /* create tilemaps */
1987   state->bg_tilemap[0] = tilemap_create(machine, get_tile0_info, tilemap0_scan,  8,  8, 64, 64);
1988   state->bg_tilemap[1] = tilemap_create(machine, get_tile1_info, tilemap1_scan, 16, 16, 64, 64);
1989   state->bg_tilemap[2] = tilemap_create(machine, get_tile2_info, tilemap2_scan, 32, 32, 64, 64);
1990
1991   /* create empty tiles */
1992   memset(state->empty_tile8x8, 0x0f, sizeof(state->empty_tile8x8));
1993   memset(state->empty_tile, 0xff, sizeof(state->empty_tile));   // 16x16 and 32x32 use packed graphics, 8x8 does not
1994
20531995   /* front masks will change at runtime to handle sprite occluding */
2054   cps1_update_transmasks();
1996   cps1_update_transmasks(machine);
20551997
2056   memset(empty_tile8x8,0x0f,sizeof(empty_tile8x8));
2057   memset(empty_tile,0xff,sizeof(empty_tile));   // 16x16 and 32x32 use packed graphics, 8x8 does not
1998   for (i = 0; i < cps1_palette_entries * 16; i++)
1999      palette_set_color(machine, i, MAKE_RGB(0,0,0));
20582000
2059   for (i = 0;i < cps1_palette_entries*16;i++)
2060   {
2061      palette_set_color(machine,i,MAKE_RGB(0,0,0));
2062   }
2001   state->buffered_obj = auto_alloc_array_clear(machine, UINT16, state->obj_size / 2);
20632002
2064    cps1_buffered_obj = auto_alloc_array_clear(machine, UINT16, cps1_obj_size/2);
2003   if (state->cps_version == 2)
2004      state->cps2_buffered_obj = auto_alloc_array_clear(machine, UINT16, state->cps2_obj_size / 2);
20652005
2066   if (cps_version==2)
2067   {
2068      cps2_buffered_obj = auto_alloc_array_clear(machine, UINT16, cps2_obj_size/2);
2069   }
2006   /* clear RAM regions */
2007   memset(state->gfxram, 0, state->gfxram_size);   /* Clear GFX RAM */
2008   memset(state->cps_a_regs, 0, 0x40);   /* Clear CPS-A registers */
2009   memset(state->cps_b_regs, 0, 0x40);   /* Clear CPS-B registers */
20702010
2071   memset(cps1_gfxram, 0, cps1_gfxram_size);   /* Clear GFX RAM */
2072   memset(cps1_cps_a_regs, 0, 0x40);   /* Clear CPS-A registers */
2073   memset(cps1_cps_b_regs, 0, 0x40);   /* Clear CPS-B registers */
2074
2075   if (cps_version == 2)
2011   if (state->cps_version == 2)
20762012   {
2077      memset(cps2_objram1, 0, cps2_obj_size);
2078      memset(cps2_objram2, 0, cps2_obj_size);
2013      memset(state->objram1, 0, state->cps2_obj_size);
2014      memset(state->objram2, 0, state->cps2_obj_size);
20792015   }
20802016
20812017   /* Put in some defaults */
2082   cps1_cps_a_regs[CPS1_OBJ_BASE]     = 0x9200;
2083   cps1_cps_a_regs[CPS1_SCROLL1_BASE] = 0x9000;
2084   cps1_cps_a_regs[CPS1_SCROLL2_BASE] = 0x9040;
2085   cps1_cps_a_regs[CPS1_SCROLL3_BASE] = 0x9080;
2086   cps1_cps_a_regs[CPS1_OTHER_BASE]   = 0x9100;
2018   state->cps_a_regs[CPS1_OBJ_BASE]     = 0x9200;
2019   state->cps_a_regs[CPS1_SCROLL1_BASE] = 0x9000;
2020   state->cps_a_regs[CPS1_SCROLL2_BASE] = 0x9040;
2021   state->cps_a_regs[CPS1_SCROLL3_BASE] = 0x9080;
2022   state->cps_a_regs[CPS1_OTHER_BASE]   = 0x9100;
20872023
2088   assert_always(cps1_game_config, "cps1_game_config hasn't been set up yet");
2024   /* This should never be hit, since game_config is set in MACHINE_RESET */
2025   assert_always(state->game_config, "state_game_config hasn't been set up yet");
20892026
2027
20902028   /* Set up old base */
2091   cps1_get_video_base();   /* Calculate base pointers */
2092   cps1_get_video_base();   /* Calculate old base pointers */
2029   state->scroll1 = NULL;
2030   state->scroll2 = NULL;
2031   state->scroll3 = NULL;
2032   state->obj = NULL;
2033   state->other = NULL;
2034   cps1_get_video_base(machine);   /* Calculate base pointers */
2035   cps1_get_video_base(machine);   /* Calculate old base pointers */
2036
2037   /* state save register */
2038   state_save_register_global(machine, state->scanline1);
2039   state_save_register_global(machine, state->scanline2);
2040   state_save_register_global(machine, state->scancalls);
2041#if 0
2042   /* these do not need to be saved, because they are recovered from cps_a_regs in cps1_postload */
2043   state_save_register_global(machine, state->scroll1x);
2044   state_save_register_global(machine, state->scroll1y);
2045   state_save_register_global(machine, state->scroll2x);
2046   state_save_register_global(machine, state->scroll2y);
2047   state_save_register_global(machine, state->scroll3x);
2048   state_save_register_global(machine, state->scroll3y);
2049   state_save_register_global(machine, state->stars1x);
2050   state_save_register_global(machine, state->stars1y);
2051   state_save_register_global(machine, state->stars2x);
2052   state_save_register_global(machine, state->stars2y);
2053   state_save_register_global_array(machine, state->stars_enabled);
2054#endif
2055   state_save_register_global(machine, state->last_sprite_offset);
2056   state_save_register_global(machine, state->pri_ctrl);
2057   state_save_register_global(machine, state->objram_bank);
2058
2059   state_save_register_global_pointer(machine, state->buffered_obj, state->obj_size / 2);
2060   if (state->cps_version == 2)
2061   {
2062      state_save_register_global(machine, state->cps2_last_sprite_offset);
2063      state_save_register_global_pointer(machine, state->cps2_buffered_obj, state->cps2_obj_size / 2);
2064   }
2065
2066   state_save_register_postload(machine, cps_postload, NULL);
20932067}
20942068
20952069VIDEO_START( cps1 )
20962070{
2097   cps_version=1;
2071   cps_state *state = (cps_state *)machine->driver_data;
2072
2073   state->cps_version = 1;
20982074   VIDEO_START_CALL(cps);
20992075}
21002076
21012077VIDEO_START( cps2 )
21022078{
2103   cps_version=2;
2079   cps_state *state = (cps_state *)machine->driver_data;
2080
2081   state->cps_version = 2;
21042082   VIDEO_START_CALL(cps);
21052083}
21062084
r6740r6741
21122090
21132091***************************************************************************/
21142092
2115static void cps1_build_palette(running_machine *machine, const UINT16* const palette_base)
2093static void cps1_build_palette( running_machine *machine, const UINT16* const palette_base )
21162094{
2095   cps_state *state = (cps_state *)machine->driver_data;
21172096   int offset, page;
21182097   const UINT16 *palette_ram = palette_base;
2098   int ctrl = state->cps_b_regs[state->game_config->palette_control/2];
21192099
2120   int ctrl = cps1_cps_b_regs[cps1_game_config->palette_control/2];
2121
21222100   /*
21232101    The palette is copied only for pages that are enabled in the ctrl
21242102    register. Note that if the first palette pages are skipped, all
r6740r6741
21262104    */
21272105   for (page = 0; page < 6; ++page)
21282106   {
2129      if (BIT(ctrl,page))
2107      if (BIT(ctrl, page))
21302108      {
21312109         for (offset = 0; offset < 0x200; ++offset)
21322110         {
r6740r6741
21362114            // from my understanding of the schematics, when the 'brightness'
21372115            // component is set to 0 it should reduce brightness to 1/3
21382116
2139            bright = 0x0f + ((palette>>12)<<1);
2117            bright = 0x0f + ((palette >> 12) << 1);
21402118
2141            r = ((palette>>8)&0x0f) * 0x11 * bright / 0x2d;
2142            g = ((palette>>4)&0x0f) * 0x11 * bright / 0x2d;
2143            b = ((palette>>0)&0x0f) * 0x11 * bright / 0x2d;
2119            r = ((palette >> 8) & 0x0f) * 0x11 * bright / 0x2d;
2120            g = ((palette >> 4) & 0x0f) * 0x11 * bright / 0x2d;
2121            b = ((palette >> 0) & 0x0f) * 0x11 * bright / 0x2d;
21442122
2145            palette_set_color (machine, 0x200*page + offset, MAKE_RGB(r, g, b));
2123            palette_set_color (machine, 0x200 * page + offset, MAKE_RGB(r, g, b));
21462124         }
21472125      }
21482126      else
r6740r6741
21902168
21912169***************************************************************************/
21922170
2193static void cps1_find_last_sprite(void)    /* Find the offset of last sprite */
2171static void cps1_find_last_sprite( running_machine *machine )    /* Find the offset of last sprite */
21942172{
2195    int offset=0;
2173   cps_state *state = (cps_state *)machine->driver_data;
2174   int offset = 0;
21962175   /* Locate the end of table marker */
2197    while (offset < cps1_obj_size/2)
2176   while (offset < state->obj_size / 2)
21982177   {
2199        int colour=cps1_buffered_obj[offset+3];
2178      int colour = state->buffered_obj[offset + 3];
22002179      if ((colour & 0xff00) == 0xff00)
22012180      {
22022181         /* Marker found. This is the last sprite. */
2203            cps1_last_sprite_offset=offset-4;
2182         state->last_sprite_offset = offset - 4;
22042183         return;
22052184      }
2206        offset+=4;
2185
2186      offset += 4;
22072187   }
22082188   /* Sprites must use full sprite RAM */
2209    cps1_last_sprite_offset=cps1_obj_size/2-4;
2189   state->last_sprite_offset = state->obj_size / 2 - 4;
22102190}
22112191
22122192
2213static void cps1_render_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
2193static void cps1_render_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
22142194{
2195   cps_state *state = (cps_state *)machine->driver_data;
2196
22152197#define DRAWSPRITE(CODE,COLOR,FLIPX,FLIPY,SX,SY)               \
22162198{                                                   \
22172199   if (flip_screen_get(machine))                                 \
r6740r6741
22202202            CODE,                                    \
22212203            COLOR,                                    \
22222204            !(FLIPX),!(FLIPY),                           \
2223            511-16-(SX),255-16-(SY),                     machine->priority_bitmap,0x02,15);               \
2205            511-16-(SX),255-16-(SY),   machine->priority_bitmap,0x02,15);               \
22242206   else                                             \
22252207      pdrawgfx_transpen(bitmap,\
22262208            cliprect,machine->gfx[2],                     \
22272209            CODE,                                    \
22282210            COLOR,                                    \
22292211            FLIPX,FLIPY,                              \
2230            SX,SY,                                    machine->priority_bitmap,0x02,15);               \
2212            SX,SY,            machine->priority_bitmap,0x02,15);               \
22312213}
22322214
22332215
22342216   int i, baseadd;
2235   UINT16 *base=cps1_buffered_obj;
2217   UINT16 *base = state->buffered_obj;
22362218
22372219   /* some sf2 hacks draw the sprites in reverse order */
2238   if (cps1_game_config->bootleg_kludge == 1)
2220   if (state->game_config->bootleg_kludge == 1)
22392221   {
2240      base += cps1_last_sprite_offset;
2222      base += state->last_sprite_offset;
22412223      baseadd = -4;
22422224   }
22432225   else
r6740r6741
22452227      baseadd = 4;
22462228   }
22472229
2248   for (i=cps1_last_sprite_offset; i>=0; i-=4)
2230   for (i = state->last_sprite_offset; i >= 0; i -= 4)
22492231   {
2250      int x=*(base+0);
2251      int y=*(base+1);
2252      int code  =*(base+2);
2253      int colour=*(base+3);
2254      int col=colour&0x1f;
2232      int x = *(base + 0);
2233      int y = *(base + 1);
2234      int code = *(base + 2);
2235      int colour = *(base + 3);
2236      int col = colour & 0x1f;
22552237
2256//      x-=0x20;
2257//      y+=0x20;
2238//      x -= 0x20;
2239//      y += 0x20;
22582240
22592241      code = gfxrom_bank_mapper(machine, GFXTYPE_SPRITES, code);
22602242
r6740r6741
22632245         if (colour & 0xff00 )
22642246         {
22652247            /* handle blocked sprites */
2266            int nx=(colour & 0x0f00) >> 8;
2267            int ny=(colour & 0xf000) >> 12;
2268            int nxs,nys,sx,sy;
2248            int nx = (colour & 0x0f00) >> 8;
2249            int ny = (colour & 0xf000) >> 12;
2250            int nxs, nys, sx, sy;
22692251            nx++;
22702252            ny++;
22712253
22722254            if (colour & 0x40)
22732255            {
22742256               /* Y flip */
2275               if (colour &0x20)
2257               if (colour & 0x20)
22762258               {
2277                  for (nys=0; nys<ny; nys++)
2259                  for (nys = 0; nys < ny; nys++)
22782260                  {
2279                     for (nxs=0; nxs<nx; nxs++)
2261                     for (nxs = 0; nxs < nx; nxs++)
22802262                     {
2281                        sx = (x+nxs*16) & 0x1ff;
2282                        sy = (y+nys*16) & 0x1ff;
2263                        sx = (x + nxs * 16) & 0x1ff;
2264                        sy = (y + nys * 16) & 0x1ff;
22832265
22842266                        DRAWSPRITE(
2285//                                      code+(nx-1)-nxs+0x10*(ny-1-nys),
2286                              (code & ~0xf) + ((code + (nx-1) - nxs) & 0xf) + 0x10*(ny-1-nys),
2287                              (col&0x1f),
2267//                                      code + (nx - 1) - nxs + 0x10 * (ny - 1 - nys),
2268                              (code & ~0xf) + ((code + (nx - 1) - nxs) & 0xf) + 0x10 * (ny - 1 - nys),
2269                              (col & 0x1f),
22882270                              1,1,
22892271                              sx,sy);
22902272                     }
r6740r6741
22922274               }
22932275               else
22942276               {
2295                  for (nys=0; nys<ny; nys++)
2277                  for (nys = 0; nys < ny; nys++)
22962278                  {
2297                     for (nxs=0; nxs<nx; nxs++)
2279                     for (nxs = 0; nxs < nx; nxs++)
22982280                     {
2299                        sx = (x+nxs*16) & 0x1ff;
2300                        sy = (y+nys*16) & 0x1ff;
2281                        sx = (x + nxs * 16) & 0x1ff;
2282                        sy = (y + nys * 16) & 0x1ff;
23012283
23022284                        DRAWSPRITE(
2303//                                      code+nxs+0x10*(ny-1-nys),
2304                              (code & ~0xf) + ((code + nxs) & 0xf) + 0x10*(ny-1-nys),
2305                              (col&0x1f),
2285//                                      code + nxs + 0x10 * (ny - 1 - nys),
2286                              (code & ~0xf) + ((code + nxs) & 0xf) + 0x10 * (ny - 1 - nys),
2287                              (col & 0x1f),
23062288                              0,1,
23072289                              sx,sy);
23082290                     }
r6740r6741
23112293            }
23122294            else
23132295            {
2314               if (colour &0x20)
2296               if (colour & 0x20)
23152297               {
2316                  for (nys=0; nys<ny; nys++)
2298                  for (nys = 0; nys < ny; nys++)
23172299                  {
2318                     for (nxs=0; nxs<nx; nxs++)
2300                     for (nxs = 0; nxs<nx; nxs++)
23192301                     {
2320                        sx = (x+nxs*16) & 0x1ff;
2321                        sy = (y+nys*16) & 0x1ff;
2302                        sx = (x + nxs * 16) & 0x1ff;
2303                        sy = (y + nys * 16) & 0x1ff;
23222304
23232305                        DRAWSPRITE(
2324//                                      code+(nx-1)-nxs+0x10*nys,
2325                              (code & ~0xf) + ((code + (nx-1) - nxs) & 0xf) + 0x10*nys,
2326                              (col&0x1f),
2306//                                      code + (nx - 1) - nxs + 0x10 * nys,
2307                              (code & ~0xf) + ((code + (nx - 1) - nxs) & 0xf) + 0x10 * nys,
2308                              (col & 0x1f),
23272309                              1,0,
23282310                              sx,sy);
23292311                     }
r6740r6741
23312313               }
23322314               else
23332315               {
2334                  for (nys=0; nys<ny; nys++)
2316                  for (nys = 0; nys < ny; nys++)
23352317                  {
2336                     for (nxs=0; nxs<nx; nxs++)
2318                     for (nxs = 0; nxs < nx; nxs++)
23372319                     {
2338                        sx = (x+nxs*16) & 0x1ff;
2339                        sy = (y+nys*16) & 0x1ff;
2320                        sx = (x + nxs * 16) & 0x1ff;
2321                        sy = (y + nys * 16) & 0x1ff;
23402322
23412323                        DRAWSPRITE(
2342//                                      code+nxs+0x10*nys,
2343                              (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.
2344                              (col&0x1f),
2324//                                      code + nxs + 0x10 * nys,
2325                              (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.
2326                              (col & 0x1f),
23452327                              0,0,
23462328                              sx,sy);
23472329                     }
r6740r6741
23542336            /* Simple case... 1 sprite */
23552337                  DRAWSPRITE(
23562338                  code,
2357                  (col&0x1f),
2339                  (col & 0x1f),
23582340                  colour&0x20,colour&0x40,
23592341                  x & 0x1ff,y & 0x1ff);
23602342         }
r6740r6741
23692351
23702352WRITE16_HANDLER( cps2_objram_bank_w )
23712353{
2354   cps_state *state = (cps_state *)space->machine->driver_data;
2355
23722356   if (ACCESSING_BITS_0_7)
2373   {
2374      cps2_objram_bank = data & 1;
2375   }
2357      state->objram_bank = data & 1;
23762358}
23772359
23782360READ16_HANDLER( cps2_objram1_r )
23792361{
2380   if (cps2_objram_bank & 1)
2381      return cps2_objram2[offset];
2362   cps_state *state = (cps_state *)space->machine->driver_data;
2363   if (state->objram_bank & 1)
2364      return state->objram2[offset];
23822365   else
2383      return cps2_objram1[offset];
2366      return state->objram1[offset];
23842367}
23852368
23862369READ16_HANDLER( cps2_objram2_r )
23872370{
2388   if (cps2_objram_bank & 1)
2389      return cps2_objram1[offset];
2371   cps_state *state = (cps_state *)space->machine->driver_data;
2372   if (state->objram_bank & 1)
2373      return state->objram1[offset];
23902374   else
2391      return cps2_objram2[offset];
2375      return state->objram2[offset];
23922376}
23932377
23942378WRITE16_HANDLER( cps2_objram1_w )
23952379{
2396   if (cps2_objram_bank & 1)
2397      COMBINE_DATA(&cps2_objram2[offset]);
2380   cps_state *state = (cps_state *)space->machine->driver_data;
2381   if (state->objram_bank & 1)
2382      COMBINE_DATA(&state->objram2[offset]);
23982383   else
2399      COMBINE_DATA(&cps2_objram1[offset]);
2384      COMBINE_DATA(&state->objram1[offset]);
24002385}
24012386
24022387WRITE16_HANDLER( cps2_objram2_w )
24032388{
2404   if (cps2_objram_bank & 1)
2405      COMBINE_DATA(&cps2_objram1[offset]);
2389   cps_state *state = (cps_state *)space->machine->driver_data;
2390   if (state->objram_bank & 1)
2391      COMBINE_DATA(&state->objram1[offset]);
24062392   else
2407      COMBINE_DATA(&cps2_objram2[offset]);
2393      COMBINE_DATA(&state->objram2[offset]);
24082394}
24092395
2410static UINT16 *cps2_objbase(void)
2396static UINT16 *cps2_objbase( running_machine *machine )
24112397{
2398   cps_state *state = (cps_state *)machine->driver_data;
24122399   int baseptr;
24132400   baseptr = 0x7000;
24142401
2415   if (cps2_objram_bank & 1) baseptr ^= 0x0080;
2402   if (state->objram_bank & 1)
2403      baseptr ^= 0x0080;
24162404
2417//popmessage("%04x %d",cps2_port(CPS2_OBJ_BASE),cps2_objram_bank&1);
2405//popmessage("%04x %d", cps2_port(machine, CPS2_OBJ_BASE), state->objram_bank & 1);
24182406
24192407   if (baseptr == 0x7000)
2420      return cps2_objram1;
2408      return state->objram1;
24212409   else //if (baseptr == 0x7080)
2422      return cps2_objram2;
2410      return state->objram2;
24232411}
24242412
24252413
2426static void cps2_find_last_sprite(void)    /* Find the offset of last sprite */
2414static void cps2_find_last_sprite( running_machine *machine )    /* Find the offset of last sprite */
24272415{
2428   int offset=0;
2429   UINT16 *base=cps2_buffered_obj;
2416   cps_state *state = (cps_state *)machine->driver_data;
2417   int offset = 0;
2418   UINT16 *base = state->cps2_buffered_obj;
24302419
24312420   /* Locate the end of table marker */
2432   while (offset < cps2_obj_size/2)
2421   while (offset < state->cps2_obj_size / 2)
24332422   {
2434      if (base[offset+1]>=0x8000
2435            || base[offset+3]>=0xff00)
2423      if (base[offset + 1] >= 0x8000 || base[offset + 3] >= 0xff00)
24362424      {
24372425         /* Marker found. This is the last sprite. */
2438         cps2_last_sprite_offset=offset-4;
2426         state->cps2_last_sprite_offset = offset - 4;
24392427         return;
24402428      }
24412429
2442      offset+=4;
2430      offset += 4;
24432431   }
24442432   /* Sprites must use full sprite RAM */
2445   cps2_last_sprite_offset=cps2_obj_size/2-4;
2446#undef DRAWSPRITE
2433   state->cps2_last_sprite_offset = state->cps2_obj_size / 2 - 4;
24472434}
24482435
2449static void cps2_render_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int *primasks)
2436static void cps2_render_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int *primasks )
24502437{
2438   cps_state *state = (cps_state *)machine->driver_data;
2439
24512440#define DRAWSPRITE(CODE,COLOR,FLIPX,FLIPY,SX,SY)                           \
24522441{                                                               \
24532442   if (flip_screen_get(machine))                                             \
r6740r6741
24562445            CODE,                                                \
24572446            COLOR,                                                \
24582447            !(FLIPX),!(FLIPY),                                       \
2459            511-16-(SX),255-16-(SY),                                 machine->priority_bitmap,primasks[priority],15);               \
2448            511-16-(SX),255-16-(SY),            machine->priority_bitmap,primasks[priority],15);               \
24602449   else                                                         \
24612450      pdrawgfx_transpen(bitmap,\
24622451            cliprect,machine->gfx[2],                                 \
24632452            CODE,                                                \
24642453            COLOR,                                                \
24652454            FLIPX,FLIPY,                                          \
2466            SX,SY,                                                machine->priority_bitmap,primasks[priority],15);               \
2455            SX,SY,                     machine->priority_bitmap,primasks[priority],15);               \
24672456}
24682457
24692458   int i;
2470   UINT16 *base=cps2_buffered_obj;
2471   int xoffs = 64-cps2_port(CPS2_OBJ_XOFFS);
2472   int yoffs = 16-cps2_port(CPS2_OBJ_YOFFS);
2459   UINT16 *base = state->cps2_buffered_obj;
2460   int xoffs = 64 - cps2_port(machine, CPS2_OBJ_XOFFS);
2461   int yoffs = 16 - cps2_port(machine, CPS2_OBJ_YOFFS);
24732462
24742463#ifdef MAME_DEBUG
24752464   if (input_code_pressed(machine, KEYCODE_Z) && input_code_pressed(machine, KEYCODE_R))
r6740r6741
24782467   }
24792468#endif
24802469
2481   for (i=cps2_last_sprite_offset; i>=0; i-=4)
2470   for (i = state->cps2_last_sprite_offset; i >= 0; i -= 4)
24822471   {
2483      int x=base[i+0];
2484      int y=base[i+1];
2485      int priority=(x>>13)&0x07;
2486      int code  = base[i+2]+((y & 0x6000) <<3);
2487      int colour= base[i+3];
2488      int col=colour&0x1f;
2472      int x = base[i + 0];
2473      int y = base[i + 1];
2474      int priority = (x >> 13) & 0x07;
2475      int code = base[i + 2] + ((y & 0x6000) << 3);
2476      int colour = base[i + 3];
2477      int col = colour & 0x1f;
24892478
2490      if(colour & 0x80)
2479      if (colour & 0x80)
24912480      {
2492         x += cps2_port(CPS2_OBJ_XOFFS);  /* fix the offset of some games */
2493         y += cps2_port(CPS2_OBJ_YOFFS);  /* like Marvel vs. Capcom ending credits */
2481         x += cps2_port(machine, CPS2_OBJ_XOFFS);  /* fix the offset of some games */
2482         y += cps2_port(machine, CPS2_OBJ_YOFFS);  /* like Marvel vs. Capcom ending credits */
24942483      }
24952484
2496      if (colour & 0xff00 )
2485      if (colour & 0xff00)
24972486      {
24982487         /* handle blocked sprites */
2499         int nx=(colour & 0x0f00) >> 8;
2500         int ny=(colour & 0xf000) >> 12;
2501         int nxs,nys,sx,sy;
2488         int nx = (colour & 0x0f00) >> 8;
2489         int ny = (colour & 0xf000) >> 12;
2490         int nxs, nys, sx, sy;
25022491         nx++;
25032492         ny++;
25042493
25052494         if (colour & 0x40)
25062495         {
25072496            /* Y flip */
2508            if (colour &0x20)
2497            if (colour & 0x20)
25092498            {
2510               for (nys=0; nys<ny; nys++)
2499               for (nys = 0; nys < ny; nys++)
25112500               {
2512                  for (nxs=0; nxs<nx; nxs++)
2501                  for (nxs = 0; nxs < nx; nxs++)
25132502                  {
2514                     sx = (x+nxs*16+xoffs) & 0x3ff;
2515                     sy = (y+nys*16+yoffs) & 0x3ff;
2503                     sx = (x + nxs * 16 + xoffs) & 0x3ff;
2504                     sy = (y + nys * 16 + yoffs) & 0x3ff;
25162505                     DRAWSPRITE(
2517                           code+(nx-1)-nxs+0x10*(ny-1-nys),
2518                           (col&0x1f),
2506                           code + (nx - 1) - nxs + 0x10 * (ny - 1 - nys),
2507                           (col & 0x1f),
25192508                           1,1,
25202509                           sx,sy);
25212510                  }
r6740r6741
25232512            }
25242513            else
25252514            {
2526               for (nys=0; nys<ny; nys++)
2515               for (nys = 0; nys < ny; nys++)
25272516               {
2528                  for (nxs=0; nxs<nx; nxs++)
2517                  for (nxs = 0; nxs < nx; nxs++)
25292518                  {
2530                     sx = (x+nxs*16+xoffs) & 0x3ff;
2531                     sy = (y+nys*16+yoffs) & 0x3ff;
2519                     sx = (x + nxs * 16 + xoffs) & 0x3ff;
2520                     sy = (y + nys * 16 + yoffs) & 0x3ff;
25322521
25332522                     DRAWSPRITE(
2534                           code+nxs+0x10*(ny-1-nys),
2535                           (col&0x1f),
2523                           code + nxs + 0x10 * (ny - 1 - nys),
2524                           (col & 0x1f),
25362525                           0,1,
25372526                           sx,sy);
25382527                  }
r6740r6741
25412530         }
25422531         else
25432532         {
2544            if (colour &0x20)
2533            if (colour & 0x20)
25452534            {
2546               for (nys=0; nys<ny; nys++)
2535               for (nys = 0; nys < ny; nys++)
25472536               {
2548                  for (nxs=0; nxs<nx; nxs++)
2537                  for (nxs = 0; nxs < nx; nxs++)
25492538                  {
2550                     sx = (x+nxs*16+xoffs) & 0x3ff;
2551                     sy = (y+nys*16+yoffs) & 0x3ff;
2539                     sx = (x + nxs * 16 + xoffs) & 0x3ff;
2540                     sy = (y + nys * 16 + yoffs) & 0x3ff;
25522541
25532542                     DRAWSPRITE(
2554                           code+(nx-1)-nxs+0x10*nys,
2555                           (col&0x1f),
2543                           code + (nx - 1) - nxs + 0x10 * nys,
2544                           (col & 0x1f),
25562545                           1,0,
25572546                           sx,sy);
25582547                  }
r6740r6741
25602549            }
25612550            else
25622551            {
2563               for (nys=0; nys<ny; nys++)
2552               for (nys = 0; nys < ny; nys++)
25642553               {
2565                  for (nxs=0; nxs<nx; nxs++)
2554                  for (nxs = 0; nxs < nx; nxs++)
25662555                  {
2567                     sx = (x+nxs*16+xoffs) & 0x3ff;
2568                     sy = (y+nys*16+yoffs) & 0x3ff;
2556                     sx = (x + nxs * 16 + xoffs) & 0x3ff;
2557                     sy = (y + nys * 16 + yoffs) & 0x3ff;
25692558
25702559                     DRAWSPRITE(
2571//                                      code+nxs+0x10*nys,
2572                           (code & ~0xf) + ((code + nxs) & 0xf) + 0x10*nys,   //  pgear fix
2573                           (col&0x1f),
2560//                                      code + nxs + 0x10 * nys,
2561                           (code & ~0xf) + ((code + nxs) & 0xf) + 0x10 * nys,   //  pgear fix
2562                           (col & 0x1f),
25742563                           0,0,
25752564                           sx,sy);
25762565                  }
r6740r6741
25832572         /* Simple case... 1 sprite */
25842573         DRAWSPRITE(
25852574               code,
2586               (col&0x1f),
2575               (col & 0x1f),
25872576               colour&0x20,colour&0x40,
25882577               (x+xoffs) & 0x3ff,(y+yoffs) & 0x3ff);
25892578      }
r6740r6741
25932582
25942583
25952584
2596static void cps1_render_stars(const device_config *screen, bitmap_t *bitmap,const rectangle *cliprect)
2585static void cps1_render_stars( const device_config *screen, bitmap_t *bitmap, const rectangle *cliprect )
25972586{
2587   cps_state *state = (cps_state *)screen->machine->driver_data;
25982588   int offs;
25992589   UINT8 *stars_rom = memory_region(screen->machine, "stars");
26002590
2601   if (!stars_rom && (cps1_stars_enabled[0] || cps1_stars_enabled[1]))
2591   if (!stars_rom && (state->stars_enabled[0] || state->stars_enabled[1]))
26022592   {
26032593#ifdef MAME_DEBUG
26042594//      popmessage("stars enabled but no stars ROM");
r6740r6741
26062596      return;
26072597   }
26082598
2609   if (cps1_stars_enabled[0])
2599   if (state->stars_enabled[0])
26102600   {
2611      for (offs = 0;offs < stars_rom_size/2;offs++)
2601      for (offs = 0; offs < state->stars_rom_size / 2; offs++)
26122602      {
2613         int col = stars_rom[8*offs+4];
2603         int col = stars_rom[8 * offs + 4];
26142604         if (col != 0x0f)
26152605         {
26162606            int sx = (offs / 256) * 32;
26172607            int sy = (offs % 256);
2618            sx = (sx - stars2x + (col & 0x1f)) & 0x1ff;
2619            sy = (sy - stars2y) & 0xff;
2608            sx = (sx - state->stars2x + (col & 0x1f)) & 0x1ff;
2609            sy = (sy - state->stars2y) & 0xff;
26202610            if (flip_screen_get(screen->machine))
26212611            {
26222612               sx = 511 - sx;
26232613               sy = 255 - sy;
26242614            }
26252615
2626            col = ((col & 0xe0) >> 1) + (video_screen_get_frame_number(screen)/16 & 0x0f);
2616            col = ((col & 0xe0) >> 1) + (video_screen_get_frame_number(screen) / 16 & 0x0f);
26272617
26282618            if (sx >= cliprect->min_x && sx <= cliprect->max_x &&
26292619               sy >= cliprect->min_y && sy <= cliprect->max_y)
r6740r6741
26322622      }
26332623   }
26342624
2635   if (cps1_stars_enabled[1])
2625   if (state->stars_enabled[1])
26362626   {
2637      for (offs = 0;offs < stars_rom_size/2;offs++)
2627      for (offs = 0; offs < state->stars_rom_size / 2; offs++)
26382628      {
26392629         int col = stars_rom[8*offs];
26402630         if (col != 0x0f)
26412631         {
26422632            int sx = (offs / 256) * 32;
26432633            int sy = (offs % 256);
2644            sx = (sx - stars1x + (col & 0x1f)) & 0x1ff;
2645            sy = (sy - stars1y) & 0xff;
2634            sx = (sx - state->stars1x + (col & 0x1f)) & 0x1ff;
2635            sy = (sy - state->stars1y) & 0xff;
26462636            if (flip_screen_get(screen->machine))
26472637            {
26482638               sx = 511 - sx;
26492639               sy = 255 - sy;
26502640            }
26512641
2652            col = ((col & 0xe0) >> 1) + (video_screen_get_frame_number(screen)/16 & 0x0f);
2642            col = ((col & 0xe0) >> 1) + (video_screen_get_frame_number(screen) / 16 & 0x0f);
26532643
26542644            if (sx >= cliprect->min_x && sx <= cliprect->max_x &&
26552645               sy >= cliprect->min_y && sy <= cliprect->max_y)
r6740r6741
26602650}
26612651
26622652
2663static void cps1_render_layer(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int layer,int primask)
2653static void cps1_render_layer( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, int primask )
26642654{
2655   cps_state *state = (cps_state *)machine->driver_data;
26652656   switch (layer)
26662657   {
26672658      case 0:
2668         cps1_render_sprites(machine,bitmap,cliprect);
2659         cps1_render_sprites(machine, bitmap, cliprect);
26692660         break;
26702661      case 1:
26712662      case 2:
26722663      case 3:
2673         tilemap_draw(bitmap,cliprect,cps1_bg_tilemap[layer-1],TILEMAP_DRAW_LAYER1,primask);
2664         tilemap_draw(bitmap, cliprect, state->bg_tilemap[layer - 1], TILEMAP_DRAW_LAYER1, primask);
26742665         break;
26752666   }
26762667}
26772668
2678static void cps1_render_high_layer(bitmap_t *bitmap, const rectangle *cliprect, int layer)
2669static void cps1_render_high_layer( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer )
26792670{
2671   cps_state *state = (cps_state *)machine->driver_data;
26802672   switch (layer)
26812673   {
26822674      case 0:
r6740r6741
26852677      case 1:
26862678      case 2:
26872679      case 3:
2688         tilemap_draw(NULL,cliprect,cps1_bg_tilemap[layer-1],TILEMAP_DRAW_LAYER0,1);
2680         tilemap_draw(NULL, cliprect, state->bg_tilemap[layer - 1], TILEMAP_DRAW_LAYER0, 1);
26892681         break;
26902682   }
26912683}
r6740r6741
26992691
27002692VIDEO_UPDATE( cps1 )
27012693{
2702   int layercontrol,l0,l1,l2,l3;
2703   int videocontrol = cps1_cps_a_regs[CPS1_VIDEOCONTROL];
2694   cps_state *state = (cps_state *)screen->machine->driver_data;
2695   int layercontrol, l0, l1, l2, l3;
2696   int videocontrol = state->cps_a_regs[CPS1_VIDEOCONTROL];
27042697
2705
27062698   flip_screen_set(screen->machine, videocontrol & 0x8000);
27072699
2708   layercontrol = cps1_cps_b_regs[cps1_game_config->layer_control/2];
2700   layercontrol = state->cps_b_regs[state->game_config->layer_control / 2];
27092701
27102702   /* Get video memory base registers */
2711   cps1_get_video_base();
2703   cps1_get_video_base(screen->machine);
27122704
27132705   /* Find the offset of the last sprite in the sprite table */
2714   cps1_find_last_sprite();
2715   if (cps_version == 2)
2706   cps1_find_last_sprite(screen->machine);
2707
2708   if (state->cps_version == 2)
27162709   {
2717      cps2_find_last_sprite();
2710      cps2_find_last_sprite(screen->machine);
27182711   }
27192712
2720   cps1_update_transmasks();
2713   cps1_update_transmasks(screen->machine);
27212714
2722   tilemap_set_scrollx(cps1_bg_tilemap[0],0,cps1_scroll1x);
2723   tilemap_set_scrolly(cps1_bg_tilemap[0],0,cps1_scroll1y);
2715   tilemap_set_scrollx(state->bg_tilemap[0], 0, state->scroll1x);
2716   tilemap_set_scrolly(state->bg_tilemap[0], 0, state->scroll1y);
2717
27242718   if (videocontrol & 0x01)   /* linescroll enable */
27252719   {
2726      int scrly=-cps1_scroll2y;
2720      int scrly = -state->scroll2y;
27272721      int i;
27282722      int otheroffs;
27292723
2730      tilemap_set_scroll_rows(cps1_bg_tilemap[1],1024);
2724      tilemap_set_scroll_rows(state->bg_tilemap[1], 1024);
27312725
2732      otheroffs = cps1_cps_a_regs[CPS1_ROWSCROLL_OFFS];
2726      otheroffs = state->cps_a_regs[CPS1_ROWSCROLL_OFFS];
27332727
2734      for (i = 0;i < 256;i++)
2735         tilemap_set_scrollx(cps1_bg_tilemap[1],(i - scrly) & 0x3ff,cps1_scroll2x + cps1_other[(i + otheroffs) & 0x3ff]);
2728      for (i = 0; i < 256; i++)
2729         tilemap_set_scrollx(state->bg_tilemap[1], (i - scrly) & 0x3ff, state->scroll2x + state->other[(i + otheroffs) & 0x3ff]);
27362730   }
27372731   else
27382732   {
2739      tilemap_set_scroll_rows(cps1_bg_tilemap[1],1);
2740      tilemap_set_scrollx(cps1_bg_tilemap[1],0,cps1_scroll2x);
2733      tilemap_set_scroll_rows(state->bg_tilemap[1], 1);
2734      tilemap_set_scrollx(state->bg_tilemap[1], 0, state->scroll2x);
27412735   }
2742   tilemap_set_scrolly(cps1_bg_tilemap[1],0,cps1_scroll2y);
2743   tilemap_set_scrollx(cps1_bg_tilemap[2],0,cps1_scroll3x);
2744   tilemap_set_scrolly(cps1_bg_tilemap[2],0,cps1_scroll3y);
2736   tilemap_set_scrolly(state->bg_tilemap[1], 0, state->scroll2y);
2737   tilemap_set_scrollx(state->bg_tilemap[2], 0, state->scroll3x);
2738   tilemap_set_scrolly(state->bg_tilemap[2], 0, state->scroll3y);
27452739
27462740
27472741   /* Blank screen */
2748   if (cps_version == 1)
2742   if (state->cps_version == 1)
27492743   {
27502744      // CPS1 games use pen 0xbff as background color; this is used in 3wonders,
27512745      // mtwins (explosion during attract), mercs (intermission).
2752      bitmap_fill(bitmap,cliprect,0xbff);
2746      bitmap_fill(bitmap, cliprect, 0xbff);
27532747   }
27542748   else
27552749   {
r6740r6741
27582752      // Maybe Capcom changed the background handling due to the problems that
27592753      // it caused on several monitors (because the background extended into the
27602754      // blanking area instead of going black, causing the monitor to clip).
2761      bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
2755      bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
27622756   }
27632757
2764   cps1_render_stars(screen, bitmap,cliprect);
2758   cps1_render_stars(screen, bitmap, cliprect);
27652759
27662760   /* Draw layers (0 = sprites, 1-3 = tilemaps) */
27672761   l0 = (layercontrol >> 0x06) & 03;
27682762   l1 = (layercontrol >> 0x08) & 03;
27692763   l2 = (layercontrol >> 0x0a) & 03;
27702764   l3 = (layercontrol >> 0x0c) & 03;
2771   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
2765   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
27722766
2773   if (cps_version == 1)
2767   if (state->cps_version == 1)
27742768   {
2775      cps1_render_layer(screen->machine,bitmap,cliprect,l0,0);
2776      if (l1 == 0) cps1_render_high_layer(bitmap,cliprect,l0); /* prepare mask for sprites */
2777      cps1_render_layer(screen->machine,bitmap,cliprect,l1,0);
2778      if (l2 == 0) cps1_render_high_layer(bitmap,cliprect,l1); /* prepare mask for sprites */
2779      cps1_render_layer(screen->machine,bitmap,cliprect,l2,0);
2780      if (l3 == 0) cps1_render_high_layer(bitmap,cliprect,l2); /* prepare mask for sprites */
2781      cps1_render_layer(screen->machine,bitmap,cliprect,l3,0);
2769      cps1_render_layer(screen->machine, bitmap, cliprect, l0, 0);
2770
2771      if (l1 == 0)
2772         cps1_render_high_layer(screen->machine, bitmap, cliprect, l0); /* prepare mask for sprites */
2773
2774      cps1_render_layer(screen->machine, bitmap, cliprect, l1, 0);
2775
2776      if (l2 == 0)
2777         cps1_render_high_layer(screen->machine, bitmap, cliprect, l1); /* prepare mask for sprites */
2778
2779      cps1_render_layer(screen->machine, bitmap, cliprect, l2, 0);
2780
2781      if (l3 == 0)
2782         cps1_render_high_layer(screen->machine, bitmap, cliprect, l2); /* prepare mask for sprites */
2783
2784      cps1_render_layer(screen->machine, bitmap, cliprect, l3, 0);
27822785   }
27832786   else
27842787   {
2785      int l0pri,l1pri,l2pri,l3pri;
2786      int primasks[8],i;
2787      l0pri = (pri_ctrl >> 4*l0) & 0x0f;
2788      l1pri = (pri_ctrl >> 4*l1) & 0x0f;
2789      l2pri = (pri_ctrl >> 4*l2) & 0x0f;
2790      l3pri = (pri_ctrl >> 4*l3) & 0x0f;
2788      int l0pri, l1pri, l2pri, l3pri;
2789      int primasks[8], i;
2790      l0pri = (state->pri_ctrl >> 4 * l0) & 0x0f;
2791      l1pri = (state->pri_ctrl >> 4 * l1) & 0x0f;
2792      l2pri = (state->pri_ctrl >> 4 * l2) & 0x0f;
2793      l3pri = (state->pri_ctrl >> 4 * l3) & 0x0f;
27912794
27922795#if 0
2793if (   (cps2_port(CPS2_OBJ_BASE) != 0x7080 && cps2_port(CPS2_OBJ_BASE) != 0x7000) ||
2794      cps2_port(CPS2_OBJ_UK1) != 0x807d ||
2795      (cps2_port(CPS2_OBJ_UK2) != 0x0000 && cps2_port(CPS2_OBJ_UK2) != 0x1101 && cps2_port(CPS2_OBJ_UK2) != 0x0001) ||
2796if (   (cps2_port(screen->machine, CPS2_OBJ_BASE) != 0x7080 && cps2_port(screen->machine, CPS2_OBJ_BASE) != 0x7000) ||
2797      cps2_port(screen->machine, CPS2_OBJ_UK1) != 0x807d ||
2798      (cps2_port(screen->machine, CPS2_OBJ_UK2) != 0x0000 && cps2_port(screen->machine, CPS2_OBJ_UK2) != 0x1101 && cps2_port(screen->machine, CPS2_OBJ_UK2) != 0x0001))
27962799   popmessage("base %04x uk1 %04x uk2 %04x",
2797         cps2_port(CPS2_OBJ_BASE),
2798         cps2_port(CPS2_OBJ_UK1),
2799         cps2_port(CPS2_OBJ_UK2));
2800         cps2_port(screen->machine, CPS2_OBJ_BASE),
2801         cps2_port(screen->machine, CPS2_OBJ_UK1),
2802         cps2_port(screen->machine, CPS2_OBJ_UK2));
28002803
28012804if (0 && input_code_pressed(screen->machine, KEYCODE_Z))
28022805   popmessage("order: %d (%d) %d (%d) %d (%d) %d (%d)",l0,l0pri,l1,l1pri,l2,l2pri,l3,l3pri);
r6740r6741
28102813      {
28112814         int mask0 = 0xaa;
28122815         int mask1 = 0xcc;
2813         if(l0pri>l1pri) mask0 &= ~0x88;
2814         if(l0pri>l2pri) mask0 &= ~0xa0;
2815         if(l1pri>l2pri) mask1 &= ~0xc0;
2816         if (l0pri > l1pri) mask0 &= ~0x88;
2817         if (l0pri > l2pri) mask0 &= ~0xa0;
2818         if (l1pri > l2pri) mask1 &= ~0xc0;
28162819
28172820         primasks[0] = 0xff;
2818         for (i = 1;i < 8;i++)
2821         for (i = 1; i < 8; i++)
28192822         {
28202823            if (i <= l0pri && i <= l1pri && i <= l2pri)
28212824            {
r6740r6741
28292832         }
28302833      }
28312834
2832      cps1_render_layer(screen->machine,bitmap,cliprect,l0,1);
2833      cps1_render_layer(screen->machine,bitmap,cliprect,l1,2);
2834      cps1_render_layer(screen->machine,bitmap,cliprect,l2,4);
2835      cps2_render_sprites(screen->machine,bitmap,cliprect,primasks);
2835      cps1_render_layer(screen->machine, bitmap, cliprect, l0, 1);
2836      cps1_render_layer(screen->machine, bitmap, cliprect, l1, 2);
2837      cps1_render_layer(screen->machine, bitmap, cliprect, l2, 4);
2838      cps2_render_sprites(screen->machine, bitmap, cliprect, primasks);
28362839   }
28372840
28382841   return 0;
r6740r6741
28402843
28412844VIDEO_EOF( cps1 )
28422845{
2846   cps_state *state = (cps_state *)machine->driver_data;
2847
28432848   /* Get video memory base registers */
2844   cps1_get_video_base();
2849   cps1_get_video_base(machine);
28452850
2846   if (cps_version == 1)
2851   if (state->cps_version == 1)
28472852   {
28482853      /* CPS1 sprites have to be delayed one frame */
2849      memcpy(cps1_buffered_obj, cps1_obj, cps1_obj_size);
2854      memcpy(state->buffered_obj, state->obj, state->obj_size);
28502855   }
28512856}
28522857
2853void cps2_set_sprite_priorities(void)
2858void cps2_set_sprite_priorities( running_machine *machine )
28542859{
2855   pri_ctrl = cps2_port(CPS2_OBJ_PRI);
2860   cps_state *state = (cps_state *)machine->driver_data;
2861   state->pri_ctrl = cps2_port(machine, CPS2_OBJ_PRI);
28562862}
28572863
2858void cps2_objram_latch(void)
2864void cps2_objram_latch( running_machine *machine )
28592865{
2860   cps2_set_sprite_priorities();
2861   memcpy(cps2_buffered_obj, cps2_objbase(), cps2_obj_size);
2866   cps_state *state = (cps_state *)machine->driver_data;
2867   cps2_set_sprite_priorities(machine);
2868   memcpy(state->cps2_buffered_obj, cps2_objbase(machine), state->cps2_obj_size);
28622869}
src/mame/video/yunsun16.c
r6740r6741
2121***************************************************************************/
2222
2323#include "driver.h"
24#include "yunsun16.h"
24#include "includes/yunsun16.h"
2525
2626
2727/***************************************************************************
src/mame/video/stactics.c
r6740r6741
4747***************************************************************************/
4848
4949#include "driver.h"
50#include "stactics.h"
50#include "includes/stactics.h"
5151
5252
5353
src/mame/video/mermaid.c
r6740r6741
22
33static tilemap *bg_tilemap, *fg_tilemap;
44
5UINT8* mermaid_videoram;
6UINT8* mermaid_colorram;
57UINT8* mermaid_videoram2;
68UINT8* mermaid_bg_scrollram;
79UINT8* mermaid_fg_scrollram;
r6740r6741
6264
6365WRITE8_HANDLER( mermaid_videoram_w )
6466{
65   space->machine->generic.videoram.u8[offset] = data;
67   mermaid_videoram[offset] = data;
6668   tilemap_mark_tile_dirty(fg_tilemap, offset);
6769}
6870
6971WRITE8_HANDLER( mermaid_colorram_w )
7072{
71   space->machine->generic.colorram.u8[offset] = data;
73   mermaid_colorram[offset] = data;
7274   tilemap_mark_tile_dirty(fg_tilemap, offset);
7375}
7476
r6740r6741
143145
144146static TILE_GET_INFO( get_fg_tile_info )
145147{
146   int attr = machine->generic.colorram.u8[tile_index];
147   int code = machine->generic.videoram.u8[tile_index] + ((attr & 0x30) << 4);
148   int attr = mermaid_colorram[tile_index];
149   int code = mermaid_videoram[tile_index] + ((attr & 0x30) << 4);
148150   int color = attr & 0x0f;
149151   int flags = TILE_FLIPYX((attr & 0xc0) >> 6);
150152
src/mame/video/gaelco3d.c
r6740r6741
88
99#include "driver.h"
1010#include "eminline.h"
11#include "gaelco3d.h"
11#include "includes/gaelco3d.h"
1212#include "cpu/tms32031/tms32031.h"
1313#include "video/rgbutil.h"
1414#include "video/poly.h"
src/mame/video/lethalj.c
r6740r6741
66
77#include "driver.h"
88#include "cpu/tms34010/tms34010.h"
9#include "lethalj.h"
9#include "includes/lethalj.h"
1010
1111
1212#define BLITTER_SOURCE_WIDTH      1024
src/mame/video/itech8.c
r6740r6741
9191#include "video/tms34061.h"
9292#include "video/tlc34076.h"
9393#include "cpu/m6809/m6809.h"
94#include "itech8.h"
94#include "includes/itech8.h"
9595
9696
9797/*************************************
src/mame/video/gstriker.c
r6740r6741
11#include "driver.h"
2#include "gstriker.h"
2#include "includes/gstriker.h"
33
44//UINT16 *gs_videoram3;
55//UINT16 *gs_mixer_regs;
src/mame/video/snk.c
r6740r6741
11#include "driver.h"
2#include "snk.h"
2#include "includes/snk.h"
33
44/*******************************************************************************
55 Shadow Handling Notes
src/mame/video/namconb1.c
r6740r6741
11/* video/namconb1.c */
22
33#include "driver.h"
4#include "namconb1.h"
5#include "namcoic.h"
6#include "namcos2.h"
4#include "includes/namconb1.h"
5#include "includes/namcoic.h"
6#include "includes/namcos2.h"
77#include "audio/namcoc7x.h"
88
99static UINT32 tilemap_tile_bank[4];
src/mame/video/arcadecl.c
r6740r6741
99
1010
1111#include "driver.h"
12#include "arcadecl.h"
12#include "includes/arcadecl.h"
1313
1414
1515
src/mame/video/suprslam.c
r6740r6741
11/* Super Slams - video, see notes in driver file */
22
33#include "driver.h"
4#include "video/konamiic.h"
4#include "video/konicdev.h"
5#include "includes/suprslam.h"
56
67
7UINT16 *suprslam_screen_videoram, *suprslam_bg_videoram,*suprslam_sp_videoram, *suprslam_spriteram;
8static UINT16 screen_bank, bg_bank;
9static tilemap *suprslam_screen_tilemap, *suprslam_bg_tilemap;
10
11/* todo, fix zooming correctly, its _not_ like aerofgt */
12static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
8/* todo, fix zooming correctly, it's _not_ like aerofgt */
9static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
1310{
1411   /* SPRITE INFO
1512
r6740r6741
3330
3431    */
3532
36
33   suprslam_state *state = (suprslam_state *)machine->driver_data;
3734   const gfx_element *gfx = machine->gfx[1];
38   UINT16 *source = suprslam_spriteram;
39   UINT16 *source2 = suprslam_spriteram;
35   UINT16 *source = state->spriteram;
36   UINT16 *source2 = state->spriteram;
4037   UINT16 *finish = source + 0x2000/2;
4138
42   while( source<finish )
39   while (source < finish)
4340   {
4441      UINT32 sprnum = source[0] & 0x03ff;
4542      if (source[0] == 0x4000) break;
r6740r6741
4946      source++;
5047      /* DRAW START */
5148      {
52         int ypos = source2[sprnum+0] & 0x1ff;
53         int high = (source2[sprnum+0] & 0x0e00) >> 9;
54         int yzoom = (source2[sprnum+0] & 0xf000) >> 12;
49         int ypos = source2[sprnum + 0] & 0x1ff;
50         int high = (source2[sprnum + 0] & 0x0e00) >> 9;
51         int yzoom = (source2[sprnum + 0] & 0xf000) >> 12;
5552
56         int xpos = source2[sprnum+1] & 0x1ff;
57         int wide = (source2[sprnum+1] & 0x0e00) >> 9;
58         int xzoom = (source2[sprnum+1] & 0xf000) >> 12;
53         int xpos = source2[sprnum + 1] & 0x1ff;
54         int wide = (source2[sprnum + 1] & 0x0e00) >> 9;
55         int xzoom = (source2[sprnum + 1] & 0xf000) >> 12;
5956
60         int col = (source2[sprnum+2] & 0x3f00) >> 8;
61         int flipx = (source2[sprnum+2] & 0x4000) >> 14;
62//          int flipy = (source2[sprnum+2] & 0x8000) >> 15;
57         int col = (source2[sprnum + 2] & 0x3f00) >> 8;
58         int flipx = (source2[sprnum + 2] & 0x4000) >> 14;
59//          int flipy = (source2[sprnum + 2] & 0x8000) >> 15;
6360
64         int word_offset = source2[sprnum+3] & 0x7fff;
61         int word_offset = source2[sprnum + 3] & 0x7fff;
6562         int xcnt, ycnt;
6663
6764         int loopno = 0;
r6740r6741
7168
7269         if (ypos > 0xff) ypos -=0x200;
7370
74         for (ycnt = 0; ycnt < high+1; ycnt ++) {
75            if (!flipx) {
76               for (xcnt = 0; xcnt < wide+1; xcnt ++)   {
77                  int tileno = suprslam_sp_videoram[word_offset+loopno];
71         for (ycnt = 0; ycnt < high+1; ycnt ++)
72         {
73            if (!flipx)
74         {
75               for (xcnt = 0; xcnt < wide+1; xcnt ++)
76               {
77                  int tileno = state->sp_videoram[word_offset + loopno];
7878                  drawgfxzoom_transpen(bitmap, cliprect, gfx, tileno, col, 0, 0,xpos + xcnt * xzoom/2, ypos + ycnt * yzoom/2,xzoom << 11, yzoom << 11, 15);
7979                  drawgfxzoom_transpen(bitmap, cliprect, gfx, tileno, col, 0, 0,-0x200+xpos + xcnt * xzoom/2, ypos + ycnt * yzoom/2,xzoom << 11, yzoom << 11, 15);
8080                  loopno ++;
8181               }
82            } else {
83               for (xcnt = wide; xcnt >= 0; xcnt --)   {
84                  int tileno = suprslam_sp_videoram[word_offset+loopno];
82            }
83            else
84            {
85               for (xcnt = wide; xcnt >= 0; xcnt --)
86               {
87                  int tileno = state->sp_videoram[word_offset + loopno];
8588                  drawgfxzoom_transpen(bitmap, cliprect, gfx, tileno, col, 1, 0,xpos + xcnt * xzoom/2, ypos + ycnt * yzoom/2,xzoom << 11, yzoom << 11, 15);
8689                  drawgfxzoom_transpen(bitmap, cliprect, gfx, tileno, col, 1, 0,-0x200+xpos + xcnt * xzoom/2, ypos + ycnt * yzoom/2,xzoom << 11, yzoom << 11, 15);
8790                  loopno ++;
r6740r6741
9699
97100WRITE16_HANDLER( suprslam_screen_videoram_w )
98101{
99   suprslam_screen_videoram[offset] = data;
100   tilemap_mark_tile_dirty(suprslam_screen_tilemap,offset);
102   suprslam_state *state = (suprslam_state *)space->machine->driver_data;
103
104   state->screen_videoram[offset] = data;
105   tilemap_mark_tile_dirty(state->screen_tilemap, offset);
101106}
102107
103108
104109static TILE_GET_INFO( get_suprslam_tile_info )
105110{
106   int tileno, colour;
111   suprslam_state *state = (suprslam_state *)machine->driver_data;
112   int tileno = state->screen_videoram[tile_index] & 0x0fff;
113   int colour = state->screen_videoram[tile_index] & 0xf000;
107114
108   tileno = suprslam_screen_videoram[tile_index] & 0x0fff;
109   colour = suprslam_screen_videoram[tile_index] & 0xf000;
110
111   tileno += screen_bank;
115   tileno += state->screen_bank;
112116   colour = colour >> 12;
113117
114   SET_TILE_INFO(0,tileno,colour,0);
118   SET_TILE_INFO(0, tileno, colour, 0);
115119}
116120
117121
118122/* BG LAYER */
119123WRITE16_HANDLER( suprslam_bg_videoram_w )
120124{
121   suprslam_bg_videoram[offset] = data;
122   tilemap_mark_tile_dirty(suprslam_bg_tilemap,offset);
125   suprslam_state *state = (suprslam_state *)space->machine->driver_data;
126
127   state->bg_videoram[offset] = data;
128   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
123129}
124130
125131
126132static TILE_GET_INFO( get_suprslam_bg_tile_info )
127133{
128   int tileno, colour;
134   suprslam_state *state = (suprslam_state *)machine->driver_data;
135   int tileno = state->bg_videoram[tile_index] & 0x0fff;
136   int colour = state->bg_videoram[tile_index] & 0xf000;
129137
130   tileno = suprslam_bg_videoram[tile_index] & 0x0fff;
131   colour = suprslam_bg_videoram[tile_index] & 0xf000;
132
133   tileno += bg_bank;
138   tileno += state->bg_bank;
134139   colour = colour >> 12;
135140
136   SET_TILE_INFO(2,tileno,colour,0);
141   SET_TILE_INFO(2, tileno, colour, 0);
137142}
138143
139144
140145VIDEO_START( suprslam )
141146{
142   suprslam_bg_tilemap = tilemap_create(machine, get_suprslam_bg_tile_info,tilemap_scan_rows, 16, 16,64,64);
143   suprslam_screen_tilemap = tilemap_create(machine, get_suprslam_tile_info,tilemap_scan_rows, 8, 8,64,32);
147   suprslam_state *state = (suprslam_state *)machine->driver_data;
144148
145   K053936_wraparound_enable(0, 1);
146   K053936_set_offset(0, -45, -21);
149   state->bg_tilemap = tilemap_create(machine, get_suprslam_bg_tile_info, tilemap_scan_rows, 16, 16, 64, 64);
150   state->screen_tilemap = tilemap_create(machine, get_suprslam_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
147151
148   tilemap_set_transparent_pen(suprslam_screen_tilemap,15);
152   tilemap_set_transparent_pen(state->screen_tilemap, 15);
149153}
150154
151155VIDEO_UPDATE( suprslam )
152156{
153   bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
154   K053936_0_zoom_draw(bitmap,cliprect,suprslam_bg_tilemap,0,0,1);
155   draw_sprites(screen->machine, bitmap, cliprect);
156   tilemap_draw(bitmap,cliprect,suprslam_screen_tilemap,0,0);
157   suprslam_state *state = (suprslam_state *)screen->machine->driver_data;
158   tilemap_set_scrollx( state->screen_tilemap,0, state->screen_vregs[0x04/2] );
159
160   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
161   k053936_zoom_draw(state->k053936, bitmap, cliprect, state->bg_tilemap, 0, 0, 1);
162   if(!(state->spr_ctrl[0] & 8))
163      draw_sprites(screen->machine, bitmap, cliprect);
164   tilemap_draw(bitmap, cliprect, state->screen_tilemap, 0, 0);
165   if(state->spr_ctrl[0] & 8)
166      draw_sprites(screen->machine, bitmap, cliprect);
157167   return 0;
158168}
159169
160170WRITE16_HANDLER (suprslam_bank_w)
161171{
172   suprslam_state *state = (suprslam_state *)space->machine->driver_data;
162173   UINT16 old_screen_bank, old_bg_bank;
163   old_screen_bank = screen_bank;
164   old_bg_bank = bg_bank;
174   old_screen_bank = state->screen_bank;
175   old_bg_bank = state->bg_bank;
165176
166   screen_bank = data & 0xf000;
167   bg_bank = (data & 0x0f00) << 4;
177   state->screen_bank = data & 0xf000;
178   state->bg_bank = (data & 0x0f00) << 4;
168179
169   if (screen_bank != old_screen_bank) tilemap_mark_all_tiles_dirty (suprslam_screen_tilemap);
170   if (bg_bank != old_bg_bank) tilemap_mark_all_tiles_dirty (suprslam_bg_tilemap);
180   if (state->screen_bank != old_screen_bank)
181      tilemap_mark_all_tiles_dirty(state->screen_tilemap);
182   if (state->bg_bank != old_bg_bank)
183      tilemap_mark_all_tiles_dirty(state->bg_tilemap);
171184}
src/mame/video/calomega.c
r6740r6741
1515
1616#include "driver.h"
1717
18UINT8 *calomega_videoram;
19UINT8 *calomega_colorram;
1820static tilemap *bg_tilemap;
1921
2022WRITE8_HANDLER( calomega_videoram_w )
2123{
22   space->machine->generic.videoram.u8[offset] = data;
24   calomega_videoram[offset] = data;
2325   tilemap_mark_tile_dirty(bg_tilemap, offset);
2426}
2527
2628WRITE8_HANDLER( calomega_colorram_w )
2729{
28   space->machine->generic.colorram.u8[offset] = data;
30   calomega_colorram[offset] = data;
2931   tilemap_mark_tile_dirty(bg_tilemap, offset);
3032}
3133
r6740r6741
3739    ---- --x-   tiles bank.
3840    xx-- ---x   seems unused. */
3941
40   int attr = machine->generic.colorram.u8[tile_index];
41   int code = machine->generic.videoram.u8[tile_index];
42   int attr = calomega_colorram[tile_index];
43   int code = calomega_videoram[tile_index];
4244   int bank = (attr & 0x02) >> 1;   /* bit 1 switch the gfx banks */
4345   int color = (attr & 0x3c);   /* bits 2-3-4-5 for color */
4446
src/mame/video/atetris.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "atetris.h"
8#include "includes/atetris.h"
99
1010
1111static tilemap *bg_tilemap;
src/mame/video/cosmic.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "cosmic.h"
10#include "includes/cosmic.h"
1111
1212
1313WRITE8_HANDLER( cosmic_color_register_w )
src/mame/video/shaolins.c
r6740r6741
1212extern UINT8 shaolins_nmi_enable;
1313
1414static int palettebank;
15UINT8 *shaolins_videoram;
16UINT8 *shaolins_colorram;
1517static tilemap *bg_tilemap;
1618
1719/***************************************************************************
r6740r6741
9395
9496WRITE8_HANDLER( shaolins_videoram_w )
9597{
96   space->machine->generic.videoram.u8[offset] = data;
98   shaolins_videoram[offset] = data;
9799   tilemap_mark_tile_dirty(bg_tilemap, offset);
98100}
99101
100102WRITE8_HANDLER( shaolins_colorram_w )
101103{
102   space->machine->generic.colorram.u8[offset] = data;
104   shaolins_colorram[offset] = data;
103105   tilemap_mark_tile_dirty(bg_tilemap, offset);
104106}
105107
r6740r6741
133135
134136static TILE_GET_INFO( get_bg_tile_info )
135137{
136   int attr = machine->generic.colorram.u8[tile_index];
137   int code = machine->generic.videoram.u8[tile_index] + ((attr & 0x40) << 2);
138   int attr = shaolins_colorram[tile_index];
139   int code = shaolins_videoram[tile_index] + ((attr & 0x40) << 2);
138140   int color = (attr & 0x0f) + 16 * palettebank;
139141   int flags = (attr & 0x20) ? TILE_FLIPY : 0;
140142
src/mame/video/wiping.c
r6740r6741
1212
1313
1414static int flipscreen;
15UINT8 *wiping_videoram;
16UINT8 *wiping_colorram;
1517
1618
1719/***************************************************************************
r6740r6741
9395   UINT8 *spriteram = screen->machine->generic.spriteram.u8;
9496   int offs;
9597
96   for (offs = screen->machine->generic.videoram_size - 1; offs > 0; offs--)
98   for (offs = 0x3ff; offs > 0; offs--)
9799   {
98100      int mx,my,sx,sy;
99101
r6740r6741
123125      }
124126
125127      drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0],
126            screen->machine->generic.videoram.u8[offs],
127            screen->machine->generic.colorram.u8[offs] & 0x3f,
128            wiping_videoram[offs],
129            wiping_colorram[offs] & 0x3f,
128130            flipscreen,flipscreen,
129131            sx*8,sy*8);
130132   }
r6740r6741
159161   }
160162
161163   /* redraw high priority chars */
162   for (offs = screen->machine->generic.videoram_size - 1; offs > 0; offs--)
164   for (offs = 0x3ff; offs > 0; offs--)
163165   {
164      if (screen->machine->generic.colorram.u8[offs] & 0x80)
166      if (wiping_colorram[offs] & 0x80)
165167      {
166168         int mx,my,sx,sy;
167169
168           mx = offs % 32;
170         mx = offs % 32;
169171         my = offs / 32;
170172
171173         if (my < 2)
r6740r6741
191193         }
192194
193195         drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0],
194               screen->machine->generic.videoram.u8[offs],
195               screen->machine->generic.colorram.u8[offs] & 0x3f,
196               wiping_videoram[offs],
197               wiping_colorram[offs] & 0x3f,
196198               flipscreen,flipscreen,
197199               sx*8,sy*8);
198200           }
src/mame/video/leland.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "leland.h"
10#include "includes/leland.h"
1111
1212
1313/* constants */
src/mame/video/popeye.c
r6740r6741
88
99#include "driver.h"
1010
11UINT8 *popeye_videoram;
12UINT8 *popeye_colorram;
1113UINT8 *popeye_background_pos;
1214UINT8 *popeye_palettebank;
1315static UINT8 *popeye_bitmapram;
r6740r6741
173175
174176WRITE8_HANDLER( popeye_videoram_w )
175177{
176   space->machine->generic.videoram.u8[offset] = data;
178   popeye_videoram[offset] = data;
177179   tilemap_mark_tile_dirty(fg_tilemap, offset);
178180}
179181
180182WRITE8_HANDLER( popeye_colorram_w )
181183{
182   space->machine->generic.colorram.u8[offset] = data;
184   popeye_colorram[offset] = data;
183185   tilemap_mark_tile_dirty(fg_tilemap, offset);
184186}
185187
r6740r6741
236238
237239static TILE_GET_INFO( get_fg_tile_info )
238240{
239   int code = machine->generic.videoram.u8[tile_index];
240   int color = machine->generic.colorram.u8[tile_index] & 0x0f;
241   int code = popeye_videoram[tile_index];
242   int color = popeye_colorram[tile_index] & 0x0f;
241243
242244   SET_TILE_INFO(0, code, color, 0);
243245}
src/mame/video/taxidrvr.c
r6740r6741
11#include "driver.h"
2#include "taxidrvr.h"
2#include "includes/taxidrvr.h"
33
44
55UINT8 *taxidrvr_vram0,*taxidrvr_vram1,*taxidrvr_vram2,*taxidrvr_vram3;
src/mame/video/compgolf.c
r6740r6741
66****************************************************************************************/
77
88#include "driver.h"
9#include "compgolf.h"
9#include "includes/compgolf.h"
1010
1111
1212PALETTE_INIT( compgolf )
src/mame/video/lordgun.c
r6740r6741
3636***************************************************************************/
3737
3838#include "driver.h"
39#include "lordgun.h"
39#include "includes/lordgun.h"
4040
4141// Variables needed by driver:
4242
src/mame/video/zerozone.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "zerozone.h"
8#include "includes/zerozone.h"
99
1010WRITE16_HANDLER( zerozone_tilemap_w )
1111{
src/mame/video/toaplan1.c
r6740r6741
119119
120120
121121#include "driver.h"
122#include "toaplan1.h"
122#include "includes/toaplan1.h"
123123#include "cpu/m68000/m68000.h"
124124
125125
src/mame/video/segag80r.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "segag80r.h"
8#include "includes/segag80r.h"
99#include "machine/rescap.h"
1010#include "video/resnet.h"
1111
src/mame/video/tmnt.c
r6740r6741
11#include "driver.h"
2#include "machine/eeprom.h"
3#include "video/konamiic.h"
2#include "video/konicdev.h"
43#include "includes/tmnt.h"
54
65
r6740r6741
4746
4847/* Missing in Action */
4948
50static void mia_tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
49void mia_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
5150{
5251   *flags = (*color & 0x04) ? TILE_FLIPX : 0;
5352   if (layer == 0)
r6740r6741
6261   }
6362}
6463
65static void cuebrick_tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
64void cuebrick_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
6665{
67   if ((K052109_get_RMRD_line() == CLEAR_LINE) && (layer == 0))
66   const device_config *k052109 = devtag_get_device(machine, "k052109");
67
68   if ((k052109_get_rmrd_line(k052109) == CLEAR_LINE) && (layer == 0))
6869   {
6970      *code |= ((*color & 0x01) << 8);
7071      *color = layer_colorbase[layer]  + ((*color & 0x80) >> 5) + ((*color & 0x10) >> 1);
r6740r6741
7677   }
7778}
7879
79static void tmnt_tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
80void tmnt_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
8081{
8182   *code |= ((*color & 0x03) << 8) | ((*color & 0x10) << 6) | ((*color & 0x0c) << 9)
8283         | (bank << 13);
8384   *color = layer_colorbase[layer] + ((*color & 0xe0) >> 5);
8485}
8586
86static void ssbl_tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
87void ssbl_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
8788{
8889   if (layer == 0)
8990   {
r6740r6741
102103
103104static int blswhstl_rombank;
104105
105static void blswhstl_tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
106void blswhstl_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
106107{
107108   /* (color & 0x02) is flip y handled internally by the 052109 */
108109   *code |= ((*color & 0x01) << 8) | ((*color & 0x10) << 5) | ((*color & 0x0c) << 8)
r6740r6741
118119
119120***************************************************************************/
120121
121static void mia_sprite_callback(int *code,int *color,int *priority,int *shadow)
122void mia_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow)
122123{
123124   *color = sprite_colorbase + (*color & 0x0f);
124125}
125126
126static void tmnt_sprite_callback(int *code,int *color,int *priority,int *shadow)
127void tmnt_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow)
127128{
128129   *code |= (*color & 0x10) << 9;
129130   *color = sprite_colorbase + (*color & 0x0f);
130131}
131132
132static void punkshot_sprite_callback(int *code,int *color,int *priority_mask,int *shadow)
133void punkshot_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask,int *shadow)
133134{
134135   int pri = 0x20 | ((*color & 0x60) >> 2);
135136   if (pri <= layerpri[2])                        *priority_mask = 0;
r6740r6741
141142   *color = sprite_colorbase + (*color & 0x0f);
142143}
143144
144static void thndrx2_sprite_callback(int *code,int *color,int *priority_mask,int *shadow)
145void thndrx2_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask,int *shadow)
145146{
146147   int pri = 0x20 | ((*color & 0x60) >> 2);
147148   if (pri <= layerpri[2])                        *priority_mask = 0;
r6740r6741
159160
160161***************************************************************************/
161162
162static void lgtnfght_sprite_callback(int *code,int *color,int *priority_mask)
163void lgtnfght_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask)
163164{
164165   int pri = 0x20 | ((*color & 0x60) >> 2);
165166   if (pri <= layerpri[2])                        *priority_mask = 0;
r6740r6741
170171   *color = sprite_colorbase + (*color & 0x1f);
171172}
172173
173static void blswhstl_sprite_callback(int *code,int *color,int *priority_mask)
174void blswhstl_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask)
174175{
175176#if 0
176177if (input_code_pressed(machine, KEYCODE_Q) && (*color & 0x20)) *color = rand();
r6740r6741
186187   *color = sprite_colorbase + (*color & 0x1f);
187188}
188189
189static void prmrsocr_sprite_callback(int *code,int *color,int *priority_mask)
190void prmrsocr_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask)
190191{
191192   int pri = 0x20 | ((*color & 0x60) >> 2);
192193   if (pri <= layerpri[2])                        *priority_mask = 0;
r6740r6741
207208
208209***************************************************************************/
209210
210VIDEO_START( mia )
211VIDEO_START( cuebrick )
211212{
212213   layer_colorbase[0] = 0;
213214   layer_colorbase[1] = 32;
214215   layer_colorbase[2] = 40;
215216   sprite_colorbase = 16;
216   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,mia_tile_callback);
217   K051960_vh_start(machine,"gfx2",REVERSE_PLANE_ORDER,mia_sprite_callback);
218217}
219218
220VIDEO_START( cuebrick )
219VIDEO_START( mia )
221220{
222221   layer_colorbase[0] = 0;
223222   layer_colorbase[1] = 32;
224223   layer_colorbase[2] = 40;
225224   sprite_colorbase = 16;
226   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,cuebrick_tile_callback);
227   K051960_vh_start(machine,"gfx2",REVERSE_PLANE_ORDER,mia_sprite_callback);
228225}
229226
230227VIDEO_START( tmnt )
r6740r6741
233230   layer_colorbase[1] = 32;
234231   layer_colorbase[2] = 40;
235232   sprite_colorbase = 16;
236   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tmnt_tile_callback);
237   K051960_vh_start(machine,"gfx2",REVERSE_PLANE_ORDER,tmnt_sprite_callback);
238233}
239234
240VIDEO_START( punkshot )
241{
242   K053251_vh_start(machine);
243   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tmnt_tile_callback);
244   K051960_vh_start(machine,"gfx2",NORMAL_PLANE_ORDER,punkshot_sprite_callback);
245}
246
247235VIDEO_START( lgtnfght )   /* also tmnt2, ssriders */
248236{
249   K053251_vh_start(machine);
250   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tmnt_tile_callback);
251   K053245_vh_start(machine,0, "gfx2",NORMAL_PLANE_ORDER,lgtnfght_sprite_callback);
237   const device_config *k053245 = devtag_get_device(machine, "k053245");
252238
253   K05324x_set_z_rejection(0);
239   k05324x_set_z_rejection(k053245, 0);
254240
255241   dim_c = dim_v = lastdim = lasten = 0;
256242
r6740r6741
260246   state_save_register_global(machine, lasten);
261247}
262248
263VIDEO_START( sunsetbl )
264{
265   K053251_vh_start(machine);
266   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,ssbl_tile_callback);
267   K053245_vh_start(machine,0, "gfx2",NORMAL_PLANE_ORDER,lgtnfght_sprite_callback);
268}
269
270VIDEO_START( blswhstl )
271{
272   K053251_vh_start(machine);
273   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,blswhstl_tile_callback);
274   K053245_vh_start(machine,0, "gfx2",NORMAL_PLANE_ORDER,blswhstl_sprite_callback);
275}
276
277249VIDEO_START( glfgreat )
278250{
279   K053251_vh_start(machine);
280   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tmnt_tile_callback);
281   K053245_vh_start(machine,0, "gfx2",NORMAL_PLANE_ORDER,lgtnfght_sprite_callback);
282
283251   roz_tilemap = tilemap_create(machine, glfgreat_get_roz_tile_info,tilemap_scan_rows,16,16,512,512);
284252
285253   tilemap_set_transparent_pen(roz_tilemap,0);
286
287   K053936_wraparound_enable(0, 1);
288   K053936_set_offset(0, 85, 0);
289254}
290255
291VIDEO_START( thndrx2 )
292{
293   K053251_vh_start(machine);
294   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tmnt_tile_callback);
295   K051960_vh_start(machine,"gfx2",NORMAL_PLANE_ORDER,thndrx2_sprite_callback);
296}
297
298256VIDEO_START( prmrsocr )
299257{
300   K053251_vh_start(machine);
301   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tmnt_tile_callback);
302   K053245_vh_start(machine,0, "gfx2",NORMAL_PLANE_ORDER,prmrsocr_sprite_callback);
303
304258   roz_tilemap = tilemap_create(machine, prmrsocr_get_roz_tile_info,tilemap_scan_rows,16,16,512,256);
305259
306260   tilemap_set_transparent_pen(roz_tilemap,0);
307
308   K053936_wraparound_enable(0, 0);
309   K053936_set_offset(0, 85, 1);
310261}
311262
312263
313
314264/***************************************************************************
315265
316266  Memory handlers
r6740r6741
330280
331281WRITE16_HANDLER( tmnt_0a0000_w )
332282{
283   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
284
333285   if (ACCESSING_BITS_0_7)
334286   {
335287      static int last;
r6740r6741
348300      interrupt_enable_w(space, 0, data & 0x20);
349301
350302      /* bit 7 = enable char ROM reading through the video RAM */
351      K052109_set_RMRD_line((data & 0x80) ? ASSERT_LINE : CLEAR_LINE);
303      k052109_set_rmrd_line(k052109, (data & 0x80) ? ASSERT_LINE : CLEAR_LINE);
352304
353305      /* other bits unused */
354306   }
r6740r6741
356308
357309WRITE16_HANDLER( punkshot_0a0020_w )
358310{
311   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
312
359313   if (ACCESSING_BITS_0_7)
360314   {
361315      static int last;
r6740r6741
371325      last = data & 0x04;
372326
373327      /* bit 3 = enable char ROM reading through the video RAM */
374      K052109_set_RMRD_line((data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
328      k052109_set_rmrd_line(k052109, (data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
375329   }
376330}
377331
378332WRITE16_HANDLER( lgtnfght_0a0018_w )
379333{
334   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
335
380336   if (ACCESSING_BITS_0_7)
381337   {
382338      static int last;
383339
384
385340      /* bit 0,1 = coin counter */
386341      coin_counter_w(space->machine, 0, data & 0x01);
387342      coin_counter_w(space->machine, 1, data & 0x02);
r6740r6741
393348      last = data & 0x04;
394349
395350      /* bit 3 = enable char ROM reading through the video RAM */
396      K052109_set_RMRD_line((data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
351      k052109_set_rmrd_line(k052109, (data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
397352   }
398353}
399354
400355WRITE16_HANDLER( blswhstl_700300_w )
401356{
357   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
358
402359   if (ACCESSING_BITS_0_7)
403360   {
404361      /* bit 0,1 = coin counter */
r6740r6741
406363      coin_counter_w(space->machine, 1,data & 0x02);
407364
408365      /* bit 3 = enable char ROM reading through the video RAM */
409      K052109_set_RMRD_line((data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
366      k052109_set_rmrd_line(k052109, (data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
410367
411368      /* bit 7 = select char ROM bank */
412369      if (blswhstl_rombank != ((data & 0x80) >> 7))
r6740r6741
436393
437394WRITE16_HANDLER( glfgreat_122000_w )
438395{
396   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
397
439398   if (ACCESSING_BITS_0_7)
440399   {
441400      /* bit 0,1 = coin counter */
r6740r6741
443402      coin_counter_w(space->machine, 1,data & 0x02);
444403
445404      /* bit 4 = enable char ROM reading through the video RAM */
446      K052109_set_RMRD_line((data & 0x10) ? ASSERT_LINE : CLEAR_LINE);
405      k052109_set_rmrd_line(k052109, (data & 0x10) ? ASSERT_LINE : CLEAR_LINE);
447406
448407      /* bit 5 = 53596 tile rom bank selection */
449408      if (glfgreat_roz_rom_bank != (data & 0x20) >> 5)
r6740r6741
467426
468427WRITE16_HANDLER( ssriders_eeprom_w )
469428{
429   const device_config *k053245 = devtag_get_device(space->machine, "k053245");
430
470431   if (ACCESSING_BITS_0_7)
471432   {
472433      /* bit 0 is data */
473434      /* bit 1 is cs (active low) */
474435      /* bit 2 is clock (active high) */
475      eeprom_write_bit(data & 0x01);
476      eeprom_set_cs_line((data & 0x02) ? CLEAR_LINE : ASSERT_LINE);
477      eeprom_set_clock_line((data & 0x04) ? ASSERT_LINE : CLEAR_LINE);
436      input_port_write(space->machine, "EEPROMOUT", data, 0xff);
478437
479438      /* bits 3-4 control palette dimming */
480439      /* 4 = DIMPOL = when set, negate SHAD */
r6740r6741
482441      dim_c = data & 0x18;
483442
484443      /* bit 5 selects sprite ROM for testing in TMNT2 (bits 5-7, actually, according to the schematics) */
485      K053244_bankselect(0, ((data & 0x20) >> 5) << 2);
444      k053244_bankselect(k053245, ((data & 0x20) >> 5) << 2);
486445   }
487446}
488447
489448WRITE16_HANDLER( ssriders_1c0300_w )
490449{
450   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
451
491452   if (ACCESSING_BITS_0_7)
492453   {
493454      /* bit 0,1 = coin counter */
r6740r6741
495456      coin_counter_w(space->machine, 1,data & 0x02);
496457
497458      /* bit 3 = enable char ROM reading through the video RAM */
498      K052109_set_RMRD_line((data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
459      k052109_set_rmrd_line(k052109, (data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
499460
500461      /* bits 4-6 control palette dimming (DIM0-DIM2) */
501462      dim_v = (data & 0x70) >> 4;
r6740r6741
504465
505466WRITE16_HANDLER( prmrsocr_122000_w )
506467{
468   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
469   const device_config *k053245 = devtag_get_device(space->machine, "k053245");
470
507471   if (ACCESSING_BITS_0_7)
508472   {
509473      /* bit 0,1 = coin counter */
r6740r6741
511475      coin_counter_w(space->machine, 1,data & 0x02);
512476
513477      /* bit 4 = enable char ROM reading through the video RAM */
514      K052109_set_RMRD_line((data & 0x10) ? ASSERT_LINE : CLEAR_LINE);
478      k052109_set_rmrd_line(k052109, (data & 0x10) ? ASSERT_LINE : CLEAR_LINE);
515479
516480      /* bit 6 = sprite ROM bank */
517481      prmrsocr_sprite_bank = (data & 0x40) >> 6;
518      K053244_bankselect(0, prmrsocr_sprite_bank << 2);
482      k053244_bankselect(k053245, prmrsocr_sprite_bank << 2);
519483
520484      /* bit 7 = 53596 region selector for ROM test */
521485      glfgreat_roz_char_bank = (data & 0x80) >> 7;
r6740r6741
587551
588552VIDEO_UPDATE( mia )
589553{
590   K052109_tilemap_update();
554   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
555   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
591556
592   tilemap_draw(bitmap,cliprect,K052109_tilemap[2],TILEMAP_DRAW_OPAQUE,0);
593   if ((priorityflag & 1) == 1) K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
594   tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
595   if ((priorityflag & 1) == 0) K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
596   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
557   k052109_tilemap_update(k052109);
558
559   k052109_tilemap_draw(k052109, bitmap, cliprect, 2, TILEMAP_DRAW_OPAQUE,0);
560   if ((priorityflag & 1) == 1) k051960_sprites_draw(k051960,bitmap,cliprect,0,0);
561   k052109_tilemap_draw(k052109, bitmap, cliprect, 1, 0, 0);
562   if ((priorityflag & 1) == 0) k051960_sprites_draw(k051960,bitmap,cliprect,0,0);
563   k052109_tilemap_draw(k052109, bitmap, cliprect, 0, 0, 0);
564
597565   return 0;
598566}
599567
600568VIDEO_UPDATE( tmnt )
601569{
602   K052109_tilemap_update();
570   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
571   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
603572
604   tilemap_draw(bitmap,cliprect,K052109_tilemap[2],TILEMAP_DRAW_OPAQUE,0);
605   if ((priorityflag & 1) == 1) K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
606   tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
607   if ((priorityflag & 1) == 0) K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
608   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
573   k052109_tilemap_update(k052109);
574
575   k052109_tilemap_draw(k052109, bitmap, cliprect, 2, TILEMAP_DRAW_OPAQUE,0);
576   if ((priorityflag & 1) == 1) k051960_sprites_draw(k051960,bitmap,cliprect,0,0);
577   k052109_tilemap_draw(k052109, bitmap, cliprect, 1, 0, 0);
578   if ((priorityflag & 1) == 0) k051960_sprites_draw(k051960,bitmap,cliprect,0,0);
579   k052109_tilemap_draw(k052109, bitmap, cliprect, 0, 0, 0);
580
609581   return 0;
610582}
611583
612584
613585VIDEO_UPDATE( punkshot )
614586{
615   bg_colorbase       = K053251_get_palette_index(K053251_CI0);
616   sprite_colorbase   = K053251_get_palette_index(K053251_CI1);
617   layer_colorbase[0] = K053251_get_palette_index(K053251_CI2);
618   layer_colorbase[1] = K053251_get_palette_index(K053251_CI4);
619   layer_colorbase[2] = K053251_get_palette_index(K053251_CI3);
587   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
588   const device_config *k053251 = devtag_get_device(screen->machine, "k053251");
589   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
620590
621   K052109_tilemap_update();
591   bg_colorbase       = k053251_get_palette_index(k053251, K053251_CI0);
592   sprite_colorbase   = k053251_get_palette_index(k053251, K053251_CI1);
593   layer_colorbase[0] = k053251_get_palette_index(k053251, K053251_CI2);
594   layer_colorbase[1] = k053251_get_palette_index(k053251, K053251_CI4);
595   layer_colorbase[2] = k053251_get_palette_index(k053251, K053251_CI3);
622596
597   k052109_tilemap_update(k052109);
598
623599   sorted_layer[0] = 0;
624   layerpri[0] = K053251_get_priority(K053251_CI2);
600   layerpri[0] = k053251_get_priority(k053251, K053251_CI2);
625601   sorted_layer[1] = 1;
626   layerpri[1] = K053251_get_priority(K053251_CI4);
602   layerpri[1] = k053251_get_priority(k053251, K053251_CI4);
627603   sorted_layer[2] = 2;
628   layerpri[2] = K053251_get_priority(K053251_CI3);
604   layerpri[2] = k053251_get_priority(k053251, K053251_CI3);
629605
630606   sortlayers(sorted_layer,layerpri);
631607
632608   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
633   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[0]],TILEMAP_DRAW_OPAQUE,1);
634   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[1]],0,2);
635   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[2]],0,4);
609   k052109_tilemap_draw(k052109, bitmap, cliprect, sorted_layer[0], TILEMAP_DRAW_OPAQUE, 1);
610   k052109_tilemap_draw(k052109, bitmap, cliprect, sorted_layer[1], 0, 2);
611   k052109_tilemap_draw(k052109, bitmap, cliprect, sorted_layer[2], 0, 4);
636612
637   K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
613   k051960_sprites_draw(k051960, bitmap, cliprect, -1, -1);
638614   return 0;
639615}
640616
641617
642618VIDEO_UPDATE( lgtnfght )
643619{
644   bg_colorbase       = K053251_get_palette_index(K053251_CI0);
645   sprite_colorbase   = K053251_get_palette_index(K053251_CI1);
646   layer_colorbase[0] = K053251_get_palette_index(K053251_CI2);
647   layer_colorbase[1] = K053251_get_palette_index(K053251_CI4);
648   layer_colorbase[2] = K053251_get_palette_index(K053251_CI3);
620   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
621   const device_config *k053251 = devtag_get_device(screen->machine, "k053251");
622   const device_config *k053245 = devtag_get_device(screen->machine, "k053245");
649623
650   K052109_tilemap_update();
624   bg_colorbase       = k053251_get_palette_index(k053251, K053251_CI0);
625   sprite_colorbase   = k053251_get_palette_index(k053251, K053251_CI1);
626   layer_colorbase[0] = k053251_get_palette_index(k053251, K053251_CI2);
627   layer_colorbase[1] = k053251_get_palette_index(k053251, K053251_CI4);
628   layer_colorbase[2] = k053251_get_palette_index(k053251, K053251_CI3);
651629
630   k052109_tilemap_update(k052109);
631
652632   sorted_layer[0] = 0;
653   layerpri[0] = K053251_get_priority(K053251_CI2);
633   layerpri[0] = k053251_get_priority(k053251, K053251_CI2);
654634   sorted_layer[1] = 1;
655   layerpri[1] = K053251_get_priority(K053251_CI4);
635   layerpri[1] = k053251_get_priority(k053251, K053251_CI4);
656636   sorted_layer[2] = 2;
657   layerpri[2] = K053251_get_priority(K053251_CI3);
637   layerpri[2] = k053251_get_priority(k053251, K053251_CI3);
658638
659639   sortlayers(sorted_layer,layerpri);
660640
661641   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
662642   bitmap_fill(bitmap,cliprect,16 * bg_colorbase);
663   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[0]],0,1);
664   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[1]],0,2);
665   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[2]],0,4);
643   k052109_tilemap_draw(k052109, bitmap, cliprect, sorted_layer[0], 0, 1);
644   k052109_tilemap_draw(k052109, bitmap, cliprect, sorted_layer[1], 0, 2);
645   k052109_tilemap_draw(k052109, bitmap, cliprect, sorted_layer[2], 0, 4);
666646
667   K053245_sprites_draw(screen->machine, 0, bitmap,cliprect);
647   k053245_sprites_draw(k053245, bitmap, cliprect);
668648   return 0;
669649}
670650
r6740r6741
682662
683663VIDEO_UPDATE( glfgreat )
684664{
685   K053251_set_tilemaps(NULL,NULL,K052109_tilemap[0],K052109_tilemap[1],K052109_tilemap[2]);
665   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
666   const device_config *k053251 = devtag_get_device(screen->machine, "k053251");
667   const device_config *k053245 = devtag_get_device(screen->machine, "k053245");
668   const device_config *k053936 = devtag_get_device(screen->machine, "k053936");
686669
687   bg_colorbase       = K053251_get_palette_index(K053251_CI0);
688   sprite_colorbase   = K053251_get_palette_index(K053251_CI1);
689   layer_colorbase[0] = K053251_get_palette_index(K053251_CI2);
690   layer_colorbase[1] = K053251_get_palette_index(K053251_CI3) + 8;   /* weird... */
691   layer_colorbase[2] = K053251_get_palette_index(K053251_CI4);
670   bg_colorbase       = k053251_get_palette_index(k053251, K053251_CI0);
671   sprite_colorbase   = k053251_get_palette_index(k053251, K053251_CI1);
672   layer_colorbase[0] = k053251_get_palette_index(k053251, K053251_CI2);
673   layer_colorbase[1] = k053251_get_palette_index(k053251, K053251_CI3) + 8;   /* weird... */
674   layer_colorbase[2] = k053251_get_palette_index(k053251, K053251_CI4);
692675
693   K052109_tilemap_update();
676   k052109_tilemap_update(k052109);
694677
695678   sorted_layer[0] = 0;
696   layerpri[0] = K053251_get_priority(K053251_CI2);
679   layerpri[0] = k053251_get_priority(k053251, K053251_CI2);
697680   sorted_layer[1] = 1;
698   layerpri[1] = K053251_get_priority(K053251_CI3);
681   layerpri[1] = k053251_get_priority(k053251, K053251_CI3);
699682   sorted_layer[2] = 2;
700   layerpri[2] = K053251_get_priority(K053251_CI4);
683   layerpri[2] = k053251_get_priority(k053251, K053251_CI4);
701684
702685   sortlayers(sorted_layer,layerpri);
703686
r6740r6741
705688
706689   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
707690   bitmap_fill(bitmap,cliprect,16 * bg_colorbase);
708   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[0]],0,1);
691   k052109_tilemap_draw(k052109, bitmap, cliprect, sorted_layer[0], 0, 1);
692
709693   if (layerpri[0] >= 0x30 && layerpri[1] < 0x30)
710694   {
711      K053936_0_zoom_draw(bitmap,cliprect,roz_tilemap,0,1,1);
695      k053936_zoom_draw(k053936, bitmap, cliprect, roz_tilemap, 0, 1, 1);
712696      glfgreat_pixel = *BITMAP_ADDR16(bitmap,0x80,0x105);
713697   }
714   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[1]],0,2);
698
699   k052109_tilemap_draw(k052109, bitmap, cliprect, sorted_layer[1], 0, 2);
700
715701   if (layerpri[1] >= 0x30 && layerpri[2] < 0x30)
716702   {
717      K053936_0_zoom_draw(bitmap,cliprect,roz_tilemap,0,1,1);
703      k053936_zoom_draw(k053936, bitmap, cliprect, roz_tilemap, 0, 1, 1);
718704      glfgreat_pixel = *BITMAP_ADDR16(bitmap,0x80,0x105);
719705   }
720   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[2]],0,4);
706
707   k052109_tilemap_draw(k052109, bitmap, cliprect, sorted_layer[2], 0, 4);
708
721709   if (layerpri[2] >= 0x30)
722710   {
723      K053936_0_zoom_draw(bitmap,cliprect,roz_tilemap,0,1,1);
711      k053936_zoom_draw(k053936, bitmap, cliprect, roz_tilemap, 0, 1, 1);
724712      glfgreat_pixel = *BITMAP_ADDR16(bitmap,0x80,0x105);
725713   }
726714
727   K053245_sprites_draw(screen->machine, 0, bitmap,cliprect);
715   k053245_sprites_draw(k053245, bitmap, cliprect);
728716   return 0;
729717}
730718
731719VIDEO_UPDATE( tmnt2 )
732720{
721   const device_config *k053251 = devtag_get_device(screen->machine, "k053251");
733722   double brt;
734723   int i, newdim, newen, cb, ce;
735724
736725   newdim = dim_v | ((~dim_c & 0x10) >> 1);
737   newen  = (K053251_get_priority(5) && K053251_get_priority(5) != 0x3e);
726   newen  = (k053251_get_priority(k053251, 5) && k053251_get_priority(k053251, 5) != 0x3e);
738727
739728   if (newdim != lastdim || newen != lasten)
740729   {
r6740r6741
756745      ce = cb + 128;
757746
758747      // dim all colors before it
759      for (i=0; i<cb; i++)
760         palette_set_pen_contrast(screen->machine,i,brt);
748      for (i = 0; i < cb; i++)
749         palette_set_pen_contrast(screen->machine, i, brt);
761750
762751      // reset all colors in range
763      for (i=cb; i<ce; i++)
764         palette_set_pen_contrast(screen->machine,i,1.0);
752      for (i = cb; i < ce; i++)
753         palette_set_pen_contrast(screen->machine, i, 1.0);
765754
766755      // dim all colors after it
767      for (i=ce; i<2048; i++)
768         palette_set_pen_contrast(screen->machine,i,brt);
756      for (i = ce; i < 2048; i++)
757         palette_set_pen_contrast(screen->machine, i, brt);
769758
770759      // toggle shadow/highlight
771760      if (~dim_c & 0x10)
r6740r6741
781770
782771VIDEO_UPDATE( thndrx2 )
783772{
784   bg_colorbase       = K053251_get_palette_index(K053251_CI0);
785   sprite_colorbase   = K053251_get_palette_index(K053251_CI1);
786   layer_colorbase[0] = K053251_get_palette_index(K053251_CI2);
787   layer_colorbase[1] = K053251_get_palette_index(K053251_CI4);
788   layer_colorbase[2] = K053251_get_palette_index(K053251_CI3);
773   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
774   const device_config *k053251 = devtag_get_device(screen->machine, "k053251");
775   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
789776
790   K052109_tilemap_update();
777   bg_colorbase       = k053251_get_palette_index(k053251, K053251_CI0);
778   sprite_colorbase   = k053251_get_palette_index(k053251, K053251_CI1);
779   layer_colorbase[0] = k053251_get_palette_index(k053251, K053251_CI2);
780   layer_colorbase[1] = k053251_get_palette_index(k053251, K053251_CI4);
781   layer_colorbase[2] = k053251_get_palette_index(k053251, K053251_CI3);
791782
783   k052109_tilemap_update(k052109);
784
792785   sorted_layer[0] = 0;
793   layerpri[0] = K053251_get_priority(K053251_CI2);
786   layerpri[0] = k053251_get_priority(k053251, K053251_CI2);
794787   sorted_layer[1] = 1;
795   layerpri[1] = K053251_get_priority(K053251_CI4);
788   layerpri[1] = k053251_get_priority(k053251, K053251_CI4);
796789   sorted_layer[2] = 2;
797   layerpri[2] = K053251_get_priority(K053251_CI3);
790   layerpri[2] = k053251_get_priority(k053251, K053251_CI3);
798791
799792   sortlayers(sorted_layer,layerpri);
800793
801794   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
802795   bitmap_fill(bitmap,cliprect,16 * bg_colorbase);
803   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[0]],0,1);
804   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[1]],0,2);
805   tilemap_draw(bitmap,cliprect,K052109_tilemap[sorted_layer[2]],0,4);
796   k052109_tilemap_draw(k052109, bitmap, cliprect, sorted_layer[0], 0, 1);
797   k052109_tilemap_draw(k052109, bitmap, cliprect, sorted_layer[1], 0, 2);
798   k052109_tilemap_draw(k052109, bitmap, cliprect, sorted_layer[2], 0, 4);
806799
807   K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
800   k051960_sprites_draw(k051960, bitmap, cliprect, -1, -1);
808801   return 0;
809802}
810803
r6740r6741
818811
819812VIDEO_EOF( blswhstl )
820813{
821   K053245_clear_buffer(0);
814   const device_config *k053245 = devtag_get_device(machine, "k053245");
815   k053245_clear_buffer(k053245);
822816}
src/mame/video/jpmimpct.c
r6740r6741
66
77#include "driver.h"
88#include "cpu/tms34010/tms34010.h"
9#include "jpmimpct.h"
9#include "includes/jpmimpct.h"
1010
1111
1212UINT16 *tms_vram;
src/mame/video/dc.c
r6740r6741
44*/
55
66#include "driver.h"
7#include "dc.h"
7#include "includes/dc.h"
88#include "cpu/sh4/sh4.h"
99#include "render.h"
1010#include "rendutil.h"
src/mame/video/liberatr.c
r6740r6741
1414***************************************************************************/
1515
1616#include "driver.h"
17#include "liberatr.h"
17#include "includes/liberatr.h"
1818
1919
2020#define NUM_PENS   (0x18)
src/mame/video/tehkanwc.c
r6740r6741
1313
1414#include "driver.h"
1515
16UINT8 *tehkanwc_videoram;
17UINT8 *tehkanwc_colorram;
1618UINT8 *tehkanwc_videoram2;
1719static UINT8 scroll_x[2];
1820static UINT8 led0,led1;
r6740r6741
2123
2224WRITE8_HANDLER( tehkanwc_videoram_w )
2325{
24   space->machine->generic.videoram.u8[offset] = data;
26   tehkanwc_videoram[offset] = data;
2527   tilemap_mark_tile_dirty(fg_tilemap, offset);
2628}
2729
2830WRITE8_HANDLER( tehkanwc_colorram_w )
2931{
30   space->machine->generic.colorram.u8[offset] = data;
32   tehkanwc_colorram[offset] = data;
3133   tilemap_mark_tile_dirty(fg_tilemap, offset);
3234}
3335
r6740r6741
7981
8082static TILE_GET_INFO( get_fg_tile_info )
8183{
82   int attr = machine->generic.colorram.u8[tile_index];
83   int code = machine->generic.videoram.u8[tile_index] + ((attr & 0x10) << 4);
84   int attr = tehkanwc_colorram[tile_index];
85   int code = tehkanwc_videoram[tile_index] + ((attr & 0x10) << 4);
8486   int color = attr & 0x0f;
8587   int flags = ((attr & 0x40) ? TILE_FLIPX : 0) | ((attr & 0x80) ? TILE_FLIPY : 0);
8688
src/mame/video/bionicc.c
r6740r6741
2424***************************************************************************/
2525
2626#include "driver.h"
27#include "bionicc.h"
27#include "includes/bionicc.h"
2828
2929
3030/***************************************************************************
src/mame/video/citycon.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "citycon.h"
10#include "includes/citycon.h"
1111
1212
1313/***************************************************************************
src/mame/video/suprridr.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "suprridr.h"
8#include "includes/suprridr.h"
99
1010
1111UINT8 *suprridr_bgram;
src/mame/video/spy.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
44
55int spy_video_enable;
r6740r6741
1313
1414***************************************************************************/
1515
16static void tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
16void spy_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
1717{
1818   *flags = (*color & 0x20) ? TILE_FLIPX : 0;
1919   *code |= ((*color & 0x03) << 8) | ((*color & 0x10) << 6) | ((*color & 0x0c) << 9)
r6740r6741
2828
2929***************************************************************************/
3030
31static void sprite_callback(int *code,int *color,int *priority_mask,int *shadow)
31void spy_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask,int *shadow)
3232{
3333   /* bit 4 = priority over layer A (0 = have priority) */
3434   /* bit 5 = priority over layer B (1 = have priority) */
r6740r6741
5252   layer_colorbase[1] = 0;
5353   layer_colorbase[2] = 16;
5454   sprite_colorbase = 32;
55   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tile_callback);
56   K051960_vh_start(machine,"gfx2",NORMAL_PLANE_ORDER,sprite_callback);
5755}
5856
5957
r6740r6741
6664
6765VIDEO_UPDATE( spy )
6866{
69   K052109_tilemap_update();
67   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
68   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
7069
70   k052109_tilemap_update(k052109);
71
7172   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
7273
7374   if (!spy_video_enable)
7475      bitmap_fill(bitmap,cliprect,16 * layer_colorbase[0]);
7576   else
7677   {
77      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],TILEMAP_DRAW_OPAQUE,1);
78      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,2);
79      K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
80      tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
78      k052109_tilemap_draw(k052109, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE, 1);
79      k052109_tilemap_draw(k052109, bitmap, cliprect, 2, 0, 2);
80      k051960_sprites_draw(k051960, bitmap, cliprect, -1, -1);
81      k052109_tilemap_draw(k052109, bitmap, cliprect, 0, 0, 0);
8182   }
8283
8384   return 0;
src/mame/video/psikyo.c
r6740r6741
5555**************************************************************************/
5656
5757#include "driver.h"
58#include "includes/psikyo.h"
5859
59/* Variables that driver has access to: */
6060
61UINT32 *psikyo_vram_0, *psikyo_vram_1, *psikyo_vregs;
62int psikyo_ka302c_banking;
63UINT32* psikyo_bootleg_spritebuffer;
64
65/* Variables only used here: */
66
67static tilemap    *tilemap_0_size0, *tilemap_0_size1, *tilemap_0_size2, *tilemap_0_size3,
68                  *tilemap_1_size0, *tilemap_1_size1, *tilemap_1_size2, *tilemap_1_size3;
69static UINT8 tilemap_0_bank, tilemap_1_bank;
70static UINT32 *spritebuf1, *spritebuf2;
71
7261/***************************************************************************
7362
7463                        Callbacks for the TileMap code
r6740r6741
8473
8574static TILE_GET_INFO( get_tile_info_0 )
8675{
87   UINT16 code = ((UINT16 *)psikyo_vram_0)[BYTE_XOR_BE(tile_index)];
76   psikyo_state *state = (psikyo_state *)machine->driver_data;
77   UINT16 code = ((UINT16 *)state->vram_0)[BYTE_XOR_BE(tile_index)];
8878   SET_TILE_INFO(
8979         1,
90         (code & 0x1fff) + 0x2000*tilemap_0_bank,
80         (code & 0x1fff) + 0x2000 * state->tilemap_0_bank,
9181         (code >> 13) & 7,
9282         0);
9383}
9484
9585static TILE_GET_INFO( get_tile_info_1 )
9686{
97   UINT16 code = ((UINT16 *)psikyo_vram_1)[BYTE_XOR_BE(tile_index)];
87   psikyo_state *state = (psikyo_state *)machine->driver_data;
88   UINT16 code = ((UINT16 *)state->vram_1)[BYTE_XOR_BE(tile_index)];
9889   SET_TILE_INFO(
9990         1,
100         (code & 0x1fff) + 0x2000*tilemap_1_bank,
91         (code & 0x1fff) + 0x2000 * state->tilemap_1_bank,
10192         ((code >> 13) & 7) + 0x40, // So we only have to decode the gfx once.
10293         0);
10394}
r6740r6741
10596
10697WRITE32_HANDLER( psikyo_vram_0_w )
10798{
108   COMBINE_DATA(&psikyo_vram_0[offset]);
99   psikyo_state *state = (psikyo_state *)space->machine->driver_data;
100
101   COMBINE_DATA(&state->vram_0[offset]);
109102   if (ACCESSING_BITS_16_31)
110103   {
111      tilemap_mark_tile_dirty(tilemap_0_size0, offset*2);
112      tilemap_mark_tile_dirty(tilemap_0_size1, offset*2);
113      tilemap_mark_tile_dirty(tilemap_0_size2, offset*2);
114      tilemap_mark_tile_dirty(tilemap_0_size3, offset*2);
104      tilemap_mark_tile_dirty(state->tilemap_0_size0, offset * 2);
105      tilemap_mark_tile_dirty(state->tilemap_0_size1, offset * 2);
106      tilemap_mark_tile_dirty(state->tilemap_0_size2, offset * 2);
107      tilemap_mark_tile_dirty(state->tilemap_0_size3, offset * 2);
115108   }
116109
117110   if (ACCESSING_BITS_0_15)
118111   {
119      tilemap_mark_tile_dirty(tilemap_0_size0, offset*2+1);
120      tilemap_mark_tile_dirty(tilemap_0_size1, offset*2+1);
121      tilemap_mark_tile_dirty(tilemap_0_size2, offset*2+1);
122      tilemap_mark_tile_dirty(tilemap_0_size3, offset*2+1);
112      tilemap_mark_tile_dirty(state->tilemap_0_size0, offset * 2 + 1);
113      tilemap_mark_tile_dirty(state->tilemap_0_size1, offset * 2 + 1);
114      tilemap_mark_tile_dirty(state->tilemap_0_size2, offset * 2 + 1);
115      tilemap_mark_tile_dirty(state->tilemap_0_size3, offset * 2 + 1);
123116   }
124117}
125118
126119WRITE32_HANDLER( psikyo_vram_1_w )
127120{
128   COMBINE_DATA(&psikyo_vram_1[offset]);
121   psikyo_state *state = (psikyo_state *)space->machine->driver_data;
122
123   COMBINE_DATA(&state->vram_1[offset]);
129124   if (ACCESSING_BITS_16_31)
130125   {
131      tilemap_mark_tile_dirty(tilemap_1_size0, offset*2);
132      tilemap_mark_tile_dirty(tilemap_1_size1, offset*2);
133      tilemap_mark_tile_dirty(tilemap_1_size2, offset*2);
134      tilemap_mark_tile_dirty(tilemap_1_size3, offset*2);
126      tilemap_mark_tile_dirty(state->tilemap_1_size0, offset * 2);
127      tilemap_mark_tile_dirty(state->tilemap_1_size1, offset * 2);
128      tilemap_mark_tile_dirty(state->tilemap_1_size2, offset * 2);
129      tilemap_mark_tile_dirty(state->tilemap_1_size3, offset * 2);
135130   }
136131
137132   if (ACCESSING_BITS_0_15)
138133   {
139      tilemap_mark_tile_dirty(tilemap_1_size0, offset*2+1);
140      tilemap_mark_tile_dirty(tilemap_1_size1, offset*2+1);
141      tilemap_mark_tile_dirty(tilemap_1_size2, offset*2+1);
142      tilemap_mark_tile_dirty(tilemap_1_size3, offset*2+1);
134      tilemap_mark_tile_dirty(state->tilemap_1_size0, offset * 2 + 1);
135      tilemap_mark_tile_dirty(state->tilemap_1_size1, offset * 2 + 1);
136      tilemap_mark_tile_dirty(state->tilemap_1_size2, offset * 2 + 1);
137      tilemap_mark_tile_dirty(state->tilemap_1_size3, offset * 2 + 1);
143138   }
144139}
145140
146void psikyo_switch_banks( int tmap, int bank )
141void psikyo_switch_banks( running_machine *machine, int tmap, int bank )
147142{
148   if((tmap==0) && (bank != tilemap_0_bank))
143   psikyo_state *state = (psikyo_state *)machine->driver_data;
144
145   if ((tmap == 0) && (bank != state->tilemap_0_bank))
149146   {
150      tilemap_0_bank = bank;
151      tilemap_mark_all_tiles_dirty(tilemap_0_size0);
152      tilemap_mark_all_tiles_dirty(tilemap_0_size1);
153      tilemap_mark_all_tiles_dirty(tilemap_0_size2);
154      tilemap_mark_all_tiles_dirty(tilemap_0_size3);
147      state->tilemap_0_bank = bank;
148      tilemap_mark_all_tiles_dirty(state->tilemap_0_size0);
149      tilemap_mark_all_tiles_dirty(state->tilemap_0_size1);
150      tilemap_mark_all_tiles_dirty(state->tilemap_0_size2);
151      tilemap_mark_all_tiles_dirty(state->tilemap_0_size3);
155152   }
156   else if((tmap==1) && (bank != tilemap_1_bank))
153   else if ((tmap == 1) && (bank != state->tilemap_1_bank))
157154   {
158      tilemap_1_bank = bank;
159      tilemap_mark_all_tiles_dirty(tilemap_1_size0);
160      tilemap_mark_all_tiles_dirty(tilemap_1_size1);
161      tilemap_mark_all_tiles_dirty(tilemap_1_size2);
162      tilemap_mark_all_tiles_dirty(tilemap_1_size3);
155      state->tilemap_1_bank = bank;
156      tilemap_mark_all_tiles_dirty(state->tilemap_1_size0);
157      tilemap_mark_all_tiles_dirty(state->tilemap_1_size1);
158      tilemap_mark_all_tiles_dirty(state->tilemap_1_size2);
159      tilemap_mark_all_tiles_dirty(state->tilemap_1_size3);
163160   }
164161}
165162
166163
167164VIDEO_START( psikyo )
168165{
166   psikyo_state *state = (psikyo_state *)machine->driver_data;
167
169168   /* The Hardware is Capable of Changing the Dimensions of the Tilemaps, its safer to create
170169       the various sized tilemaps now as opposed to later */
171170
172   tilemap_0_size0   =   tilemap_create(   machine, get_tile_info_0,
173                           tilemap_scan_rows,
171   state->tilemap_0_size0 = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 16, 16, 0x20, 0x80);
172   state->tilemap_0_size1 = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 16, 16, 0x40, 0x40);
173   state->tilemap_0_size2 = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 16, 16, 0x80, 0x20);
174   state->tilemap_0_size3 = tilemap_create(machine, get_tile_info_0, tilemap_scan_rows, 16, 16, 0x100, 0x10);
174175
175                           16,16,
176                           0x20, 0x80 );
177   tilemap_0_size1   =   tilemap_create(   machine, get_tile_info_0,
178                           tilemap_scan_rows,
176   state->tilemap_1_size0 = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 16, 16, 0x20, 0x80);
177   state->tilemap_1_size1 = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 16, 16, 0x40, 0x40);
178   state->tilemap_1_size2 = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 16, 16, 0x80, 0x20);
179   state->tilemap_1_size3 = tilemap_create(machine, get_tile_info_1, tilemap_scan_rows, 16, 16, 0x100, 0x10);
179180
180                           16,16,
181                           0x40, 0x40 );
181   state->spritebuf1 = auto_alloc_array(machine, UINT32, 0x2000 / 4);
182   state->spritebuf2 = auto_alloc_array(machine, UINT32, 0x2000 / 4);
182183
183   tilemap_0_size2   =   tilemap_create(   machine, get_tile_info_0,
184                           tilemap_scan_rows,
184   tilemap_set_scroll_rows(state->tilemap_0_size0, 0x80 * 16);   // line scrolling
185   tilemap_set_scroll_cols(state->tilemap_0_size0, 1);
185186
186                           16,16,
187                           0x80, 0x20 );
187   tilemap_set_scroll_rows(state->tilemap_0_size1, 0x40 * 16);   // line scrolling
188   tilemap_set_scroll_cols(state->tilemap_0_size1, 1);
188189
189   tilemap_0_size3   =   tilemap_create(   machine, get_tile_info_0,
190                           tilemap_scan_rows,
190   tilemap_set_scroll_rows(state->tilemap_0_size2, 0x20 * 16);   // line scrolling
191   tilemap_set_scroll_cols(state->tilemap_0_size2, 1);
191192
192                           16,16,
193                           0x100, 0x10 );
193   tilemap_set_scroll_rows(state->tilemap_0_size3, 0x10 * 16);   // line scrolling
194   tilemap_set_scroll_cols(state->tilemap_0_size3, 1);
194195
195   tilemap_1_size0   =   tilemap_create(   machine, get_tile_info_1,
196                           tilemap_scan_rows,
196   tilemap_set_scroll_rows(state->tilemap_1_size0, 0x80 * 16);   // line scrolling
197   tilemap_set_scroll_cols(state->tilemap_1_size0, 1);
197198
198                           16,16,
199                           0x20, 0x80 );
199   tilemap_set_scroll_rows(state->tilemap_1_size1, 0x40 * 16);   // line scrolling
200   tilemap_set_scroll_cols(state->tilemap_1_size1, 1);
200201
201   tilemap_1_size1   =   tilemap_create(   machine, get_tile_info_1,
202                           tilemap_scan_rows,
202   tilemap_set_scroll_rows(state->tilemap_1_size2, 0x20 * 16);   // line scrolling
203   tilemap_set_scroll_cols(state->tilemap_1_size2, 1);
203204
204                           16,16,
205                           0x40, 0x40 );
205   tilemap_set_scroll_rows(state->tilemap_1_size3, 0x10 * 16);   // line scrolling
206   tilemap_set_scroll_cols(state->tilemap_1_size3, 1);
206207
207   tilemap_1_size2   =   tilemap_create(   machine, get_tile_info_1,
208                           tilemap_scan_rows,
209
210                           16,16,
211                           0x80, 0x20 );
212
213   tilemap_1_size3   =   tilemap_create(   machine, get_tile_info_1,
214                           tilemap_scan_rows,
215
216                           16,16,
217                           0x100, 0x10 );
218
219   spritebuf1 = auto_alloc_array(machine, UINT32, 0x2000/4);
220   spritebuf2 = auto_alloc_array(machine, UINT32, 0x2000/4);
221
222      tilemap_set_scroll_rows(tilemap_0_size0,0x80*16);   // line scrolling
223      tilemap_set_scroll_cols(tilemap_0_size0,1);
224
225      tilemap_set_scroll_rows(tilemap_0_size1,0x40*16);   // line scrolling
226      tilemap_set_scroll_cols(tilemap_0_size1,1);
227
228      tilemap_set_scroll_rows(tilemap_0_size2,0x20*16);   // line scrolling
229      tilemap_set_scroll_cols(tilemap_0_size2,1);
230
231      tilemap_set_scroll_rows(tilemap_0_size3,0x10*16);   // line scrolling
232      tilemap_set_scroll_cols(tilemap_0_size3,1);
233
234      tilemap_set_scroll_rows(tilemap_1_size0,0x80*16);   // line scrolling
235      tilemap_set_scroll_cols(tilemap_1_size0,1);
236
237      tilemap_set_scroll_rows(tilemap_1_size1,0x40*16);   // line scrolling
238      tilemap_set_scroll_cols(tilemap_1_size1,1);
239
240      tilemap_set_scroll_rows(tilemap_1_size2,0x20*16);   // line scrolling
241      tilemap_set_scroll_cols(tilemap_1_size2,1);
242
243      tilemap_set_scroll_rows(tilemap_1_size3,0x10*16);   // line scrolling
244      tilemap_set_scroll_cols(tilemap_1_size3,1);
208   state_save_register_global_pointer(machine, state->spritebuf1, 0x2000 / 4);
209   state_save_register_global_pointer(machine, state->spritebuf2, 0x2000 / 4);
245210}
246211
247212VIDEO_START( sngkace )
248213{
249214   VIDEO_START_CALL( psikyo );
250215
251   psikyo_switch_banks(0, 0); // sngkace / samuraia don't use banking
252   psikyo_switch_banks(1, 1); // They share "gfx2" to save memory on other boards
216   psikyo_switch_banks(machine, 0, 0); // sngkace / samuraia don't use banking
217   psikyo_switch_banks(machine, 1, 1); // They share "gfx2" to save memory on other boards
253218}
254219
255220
r6740r6741
298263
299264***************************************************************************/
300265
301static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int trans_pen)
266static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int trans_pen )
302267{
268   psikyo_state *state = (psikyo_state *)machine->driver_data;
269
303270   /* tile layers 0 & 1 have priorities 1 & 2 */
304271   static const int pri[] = { 0, 0xfc, 0xff, 0xff };
305
306272   int offs;
273   UINT16 *spritelist = (UINT16 *)(state->spritebuf2 + 0x1800 / 4);
274   UINT8 *TILES = memory_region(machine, "spritelut");   // Sprites LUT
275   int TILES_LEN = memory_region_length(machine, "spritelut");
307276
308   UINT16 *spritelist   =   (UINT16 *)(spritebuf2 + 0x1800/4);
309
310   UINT8 *TILES   =   memory_region(machine, "spritelut");   // Sprites LUT
311   int TILES_LEN         =   memory_region_length(machine, "spritelut");
312
313277   int width = video_screen_get_width(machine->primary_screen);
314278   int height = video_screen_get_height(machine->primary_screen);
315279
316280   /* Exit if sprites are disabled */
317   if ( spritelist[ BYTE_XOR_BE((0x800-2)/2) ] & 1 )   return;
281   if (spritelist[BYTE_XOR_BE((0x800 - 2) / 2)] & 1)   return;
318282
319283   /* Look for "end of sprites" marker in the sprites list */
320   for ( offs = 0/2 ; offs < (0x800-2)/2 ; offs += 2/2 )   // skip last "sprite"
284   for (offs = 0/2 ; offs < (0x800 - 2)/2 ; offs += 2/2)   // skip last "sprite"
321285   {
322      UINT16 sprite = spritelist[ BYTE_XOR_BE(offs) ];
323      if (sprite == 0xffff)   break;
286      UINT16 sprite = spritelist[BYTE_XOR_BE(offs)];
287      if (sprite == 0xffff)
288         break;
324289   }
325290
326291   offs -= 2/2;
327292
328293   //  fprintf(stderr, "\n");
329   for ( ; offs >= 0/2 ; offs -= 2/2 )
294   for ( ; offs >= 0/2 ; offs -= 2/2)
330295   {
331296      UINT32 *source;
332      int   sprite;
297      int sprite;
333298
334      int   x,y, attr,code, flipx,flipy, nx,ny, zoomx,zoomy;
335      int dx,dy, xstart,ystart, xend,yend, xinc,yinc;
299      int x, y, attr, code, flipx, flipy, nx, ny, zoomx, zoomy;
300      int dx, dy, xstart, ystart, xend, yend, xinc, yinc;
336301
337302      /* Get next entry in the list */
338      sprite   =   spritelist[ BYTE_XOR_BE(offs) ];
303      sprite = spritelist[BYTE_XOR_BE(offs)];
339304
340      sprite   %=   0x300;
341      source   =   &spritebuf2[ sprite*8/4 ];
305      sprite %= 0x300;
306      source = &state->spritebuf2[sprite * 8 / 4];
342307
343308      /* Draw this sprite */
344309
345      y      =   source[ 0/4 ] >> 16;
346      x      =   source[ 0/4 ] & 0xffff;
347      attr   =   source[ 4/4 ] >> 16;
348      code   =   source[ 4/4 ] & 0x1ffff;
310      y   =   source[0 / 4] >> 16;
311      x   =   source[0 / 4] & 0xffff;
312      attr   =   source[4 / 4] >> 16;
313      code   =   source[4 / 4] & 0x1ffff;
349314
350315      flipx   =   attr & 0x4000;
351316      flipy   =   attr & 0x8000;
352317
353318      zoomx   =   ((x & 0xf000) >> 12);
354319      zoomy   =   ((y & 0xf000) >> 12);
355      nx      =   ((x & 0x0e00) >> 9) + 1;
356      ny      =   ((y & 0x0e00) >> 9) + 1;
357      x      =   ((x & 0x01ff));
358      y      =   ((y & 0x00ff)) - (y & 0x100);
320      nx   =   ((x & 0x0e00) >> 9) + 1;
321      ny   =   ((y & 0x0e00) >> 9) + 1;
322      x   =   ((x & 0x01ff));
323      y   =   ((y & 0x00ff)) - (y & 0x100);
359324
360325      /* 180-1ff are negative coordinates. Note that $80 pixels is
361326           the maximum extent of a sprite, which can therefore be moved
362327           out of screen without problems */
363      if (x >= 0x180)   x -= 0x200;
328      if (x >= 0x180)
329         x -= 0x200;
364330
365      x += (nx*zoomx+2)/4;
366      y += (ny*zoomy+2)/4;
331      x += (nx * zoomx + 2) / 4;
332      y += (ny * zoomy + 2) / 4;
367333
368334      zoomx = 32 - zoomx;
369335      zoomy = 32 - zoomy;
370336
371
372337      if (flip_screen_get(machine))
373338      {
374         x = width  - x - (nx * zoomx)/2;
375         y = height - y - (ny * zoomy)/2;
339         x = width  - x - (nx * zoomx) / 2;
340         y = height - y - (ny * zoomy) / 2;
376341         flipx = !flipx;
377342         flipy = !flipy;
378343      }
379344
380      if (flipx)   { xstart = nx-1;  xend = -1;  xinc = -1; }
381      else      { xstart = 0;     xend = nx;  xinc = +1; }
345      if (flipx)   { xstart = nx - 1;  xend = -1;  xinc = -1; }
346      else      { xstart = 0;       xend = nx;  xinc = +1; }
382347
383      if (flipy)   { ystart = ny-1;  yend = -1;   yinc = -1; }
384      else      { ystart = 0;     yend = ny;   yinc = +1; }
348      if (flipy)   { ystart = ny - 1;  yend = -1;   yinc = -1; }
349      else      { ystart = 0;       yend = ny;   yinc = +1; }
385350
386351      for (dy = ystart; dy != yend; dy += yinc)
387352      {
388353         for (dx = xstart; dx != xend; dx += xinc)
389354         {
390            int addr   =   (code*2) & (TILES_LEN-1);
355            int addr = (code * 2) & (TILES_LEN - 1);
391356
392357            if (zoomx == 32 && zoomy == 32)
393358               pdrawgfx_transpen(bitmap,cliprect,machine->gfx[0],
r6740r6741
417382// until I work out why it makes a partial copy of the sprite list, and how best to apply it
418383// sprite placement of the explosion graphic seems incorrect compared to the original sets? (no / different zoom support?)
419384// it might be a problem with the actual bootleg
420static void draw_sprites_bootleg(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int trans_pen)
385static void draw_sprites_bootleg( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int trans_pen )
421386{
387   psikyo_state *state = (psikyo_state *)machine->driver_data;
388
422389   /* tile layers 0 & 1 have priorities 1 & 2 */
423390   static const int pri[] = { 0, 0xfc, 0xff, 0xff };
424
425391   int offs;
426392
427393//  UINT16 *spritelist  =   (UINT16 *)(machine->generic.spriteram.u32 + 0x1800/4);
428   UINT16 *spritelist   =   (UINT16 *)(spritebuf2 + 0x1800/4);
394   UINT16 *spritelist = (UINT16 *)(state->spritebuf2 + 0x1800 / 4);
429395
430   UINT8 *TILES   =   memory_region(machine, "spritelut");   // Sprites LUT
431   int TILES_LEN         =   memory_region_length(machine, "spritelut");
396   UINT8 *TILES = memory_region(machine, "spritelut");   // Sprites LUT
397   int TILES_LEN = memory_region_length(machine, "spritelut");
432398
433399   int width = video_screen_get_width(machine->primary_screen);
434400   int height = video_screen_get_height(machine->primary_screen);
435401
436402   /* Exit if sprites are disabled */
437   if ( spritelist[ BYTE_XOR_BE((0x800-2)/2) ] & 1 )   return;
403   if (spritelist[BYTE_XOR_BE((0x800 - 2) / 2)] & 1)
404      return;
438405
439406   /* Look for "end of sprites" marker in the sprites list */
440   for ( offs = 0/2 ; offs < (0x800-2)/2 ; offs += 2/2 )   // skip last "sprite"
407   for (offs = 0/2 ; offs < (0x800 - 2)/2 ; offs += 2/2)   // skip last "sprite"
441408   {
442      UINT16 sprite = spritelist[ BYTE_XOR_BE(offs) ];
443      if (sprite == 0xffff)   break;
409      UINT16 sprite = spritelist[BYTE_XOR_BE(offs)];
410      if (sprite == 0xffff)
411         break;
444412   }
445413
446414   offs -= 2/2;
447415
448416   //  fprintf(stderr, "\n");
449   for ( ; offs >= 0/2 ; offs -= 2/2 )
417   for ( ; offs >= 0/2 ; offs -= 2/2)
450418   {
451419      UINT32 *source;
452      int   sprite;
420      int sprite;
453421
454      int   x,y, attr,code, flipx,flipy, nx,ny, zoomx,zoomy;
455      int dx,dy, xstart,ystart, xend,yend, xinc,yinc;
422      int x, y, attr, code, flipx, flipy, nx, ny, zoomx, zoomy;
423      int dx, dy, xstart, ystart, xend, yend, xinc, yinc;
456424
457425      /* Get next entry in the list */
458      sprite   =   spritelist[ BYTE_XOR_BE(offs) ];
426      sprite = spritelist[BYTE_XOR_BE(offs)];
459427
460      sprite   %=   0x300;
461//      source  =   &psikyo_bootleg_spritebuffer[ sprite*8/4 ];
462      source   =   &spritebuf2[ sprite*8/4 ];
428      sprite %= 0x300;
429//      source = &state->bootleg_spritebuffer[sprite * 8 / 4];
430      source = &state->spritebuf2[sprite * 8 / 4];
463431
464432      /* Draw this sprite */
465433
466      y      =   source[ 0 ] >> 16;
467      x      =   source[ 0 ] & 0xffff;
468      attr   =   source[ 1 ] >> 16;
469      code   =   source[ 1 ] & 0x1ffff;
434      y   =   source[0] >> 16;
435      x   =   source[0] & 0xffff;
436      attr   =   source[1] >> 16;
437      code   =   source[1] & 0x1ffff;
470438
471439      flipx   =   attr & 0x4000;
472440      flipy   =   attr & 0x8000;
473441
474442      zoomx   =   ((x & 0xf000) >> 12);
475443      zoomy   =   ((y & 0xf000) >> 12);
476      nx      =   ((x & 0x0e00) >> 9) + 1;
477      ny      =   ((y & 0x0e00) >> 9) + 1;
478      x      =   ((x & 0x01ff));
479      y      =   ((y & 0x00ff)) - (y & 0x100);
444      nx   =   ((x & 0x0e00) >> 9) + 1;
445      ny   =   ((y & 0x0e00) >> 9) + 1;
446      x   =   ((x & 0x01ff));
447      y   =   ((y & 0x00ff)) - (y & 0x100);
480448
481449      /* 180-1ff are negative coordinates. Note that $80 pixels is
482450           the maximum extent of a sprite, which can therefore be moved
483451           out of screen without problems */
484      if (x >= 0x180)   x -= 0x200;
452      if (x >= 0x180)
453         x -= 0x200;
485454
486      x += (nx*zoomx+2)/4;
487      y += (ny*zoomy+2)/4;
455      x += (nx * zoomx + 2) / 4;
456      y += (ny * zoomy + 2) / 4;
488457
489458      zoomx = 32 - zoomx;
490459      zoomy = 32 - zoomy;
r6740r6741
492461
493462      if (flip_screen_get(machine))
494463      {
495         x = width  - x - (nx * zoomx)/2;
496         y = height - y - (ny * zoomy)/2;
464         x = width  - x - (nx * zoomx) / 2;
465         y = height - y - (ny * zoomy) / 2;
497466         flipx = !flipx;
498467         flipy = !flipy;
499468      }
500469
501      if (flipx)   { xstart = nx-1;  xend = -1;  xinc = -1; }
502      else      { xstart = 0;     xend = nx;  xinc = +1; }
470      if (flipx)   { xstart = nx - 1;  xend = -1;  xinc = -1; }
471      else      { xstart = 0;       xend = nx;  xinc = +1; }
503472
504      if (flipy)   { ystart = ny-1;  yend = -1;   yinc = -1; }
505      else      { ystart = 0;     yend = ny;   yinc = +1; }
473      if (flipy)   { ystart = ny - 1;  yend = -1;   yinc = -1; }
474      else      { ystart = 0;       yend = ny;   yinc = +1; }
506475
507476      for (dy = ystart; dy != yend; dy += yinc)
508477      {
509478         for (dx = xstart; dx != xend; dx += xinc)
510479         {
511            int addr   =   (code*2) & (TILES_LEN-1);
480            int addr = (code * 2) & (TILES_LEN-1);
512481
513482            if (zoomx == 32 && zoomy == 32)
514483               pdrawgfx_transpen(bitmap,cliprect,machine->gfx[0],
r6740r6741
545514
546515static int tilemap_width( int size )
547516{
548   if(size==0)         return 0x80*16;
549   else if(size==1)   return 0x40*16;
550   else if(size==2)   return 0x20*16;
551   else            return 0x10*16;
517   if (size == 0)
518      return 0x80 * 16;
519   else if(size == 1)
520      return 0x40 * 16;
521   else if(size == 2)
522      return 0x20 * 16;
523   else
524      return 0x10 * 16;
552525}
553526
554527VIDEO_UPDATE( psikyo )
555528{
529   psikyo_state *state = (psikyo_state *)screen->machine->driver_data;
556530   int i, layers_ctrl = -1;
557531
558532   UINT32 tm0size, tm1size;
559533
560534   UINT32 layer0_scrollx, layer0_scrolly;
561535   UINT32 layer1_scrollx, layer1_scrolly;
562   UINT32 layer0_ctrl = psikyo_vregs[ 0x412/4 ];
563   UINT32 layer1_ctrl = psikyo_vregs[ 0x416/4 ];
564   UINT32 spr_ctrl = spritebuf2[ 0x1ffe/4 ];
536   UINT32 layer0_ctrl = state->vregs[0x412 / 4];
537   UINT32 layer1_ctrl = state->vregs[0x416 / 4];
538   UINT32 spr_ctrl = state->spritebuf2[0x1ffe / 4];
565539
566540   tilemap *tmptilemap0, *tmptilemap1;
567541
r6740r6741
598572*/
599573
600574   /* For gfx banking for s1945jn/gunbird/btlkroad */
601   if(psikyo_ka302c_banking)
575   if (state->ka302c_banking)
602576   {
603      psikyo_switch_banks(0, (layer0_ctrl&0x400)>>10);
604      psikyo_switch_banks(1, (layer1_ctrl&0x400)>>10);
577      psikyo_switch_banks(screen->machine, 0, (layer0_ctrl & 0x400) >> 10);
578      psikyo_switch_banks(screen->machine, 1, (layer1_ctrl & 0x400) >> 10);
605579   }
606580
607   switch((layer0_ctrl & 0x00c0)>>6) {
608      case 0:
609         tm0size=1;
610         break;
611      case 1:
612         tm0size=2;
613         break;
614      case 2:
615         tm0size=3;
616         break;
617      default:
618         tm0size=0;
619         break;
581   switch ((layer0_ctrl & 0x00c0) >> 6)
582   {
583   case 0:   tm0size = 1;   break;
584   case 1:   tm0size = 2;   break;
585   case 2:   tm0size = 3;   break;
586   default:   tm0size = 0;   break;
620587   }
621588
622   switch((layer1_ctrl & 0x00c0)>>6) {
623      case 0:
624         tm1size=1;
625         break;
626      case 1:
627         tm1size=2;
628         break;
629      case 2:
630         tm1size=3;
631         break;
632      default:
633         tm1size=0;
634         break;
589   switch ((layer1_ctrl & 0x00c0) >> 6)
590   {
591   case 0:   tm1size = 1;   break;
592   case 1:   tm1size = 2;   break;
593   case 2:   tm1size = 3;   break;
594   default:   tm1size = 0;   break;
635595   }
636596
637   if(tm0size==0) tmptilemap0 = tilemap_0_size0;
638   else if (tm0size==1) tmptilemap0 = tilemap_0_size1;
639   else if (tm0size==2) tmptilemap0 = tilemap_0_size2;
640   else tmptilemap0 = tilemap_0_size3;
597   if (tm0size == 0)
598      tmptilemap0 = state->tilemap_0_size0;
599   else if (tm0size == 1)
600      tmptilemap0 = state->tilemap_0_size1;
601   else if (tm0size == 2)
602      tmptilemap0 = state->tilemap_0_size2;
603   else
604      tmptilemap0 = state->tilemap_0_size3;
641605
642   if(tm1size==0) tmptilemap1 = tilemap_1_size0;
643   else if (tm1size==1) tmptilemap1 = tilemap_1_size1;
644   else if (tm1size==2) tmptilemap1 = tilemap_1_size2;
645   else tmptilemap1 = tilemap_1_size3;
606   if (tm1size == 0)
607      tmptilemap1 = state->tilemap_1_size0;
608   else if (tm1size == 1)
609      tmptilemap1 = state->tilemap_1_size1;
610   else if (tm1size == 2)
611      tmptilemap1 = state->tilemap_1_size2;
612   else
613      tmptilemap1 = state->tilemap_1_size3;
646614
647615   tilemap_set_enable(tmptilemap0, ~layer0_ctrl & 1);
648
649616   tilemap_set_enable(tmptilemap1, ~layer1_ctrl & 1);
650617
651618   /* Layers scrolling */
652619
653   layer0_scrolly = psikyo_vregs[ 0x402/4 ];
654   layer0_scrollx = psikyo_vregs[ 0x406/4 ];
655   layer1_scrolly = psikyo_vregs[ 0x40a/4 ];
656   layer1_scrollx = psikyo_vregs[ 0x40e/4 ];
620   layer0_scrolly = state->vregs[0x402 / 4];
621   layer0_scrollx = state->vregs[0x406 / 4];
622   layer1_scrolly = state->vregs[0x40a / 4];
623   layer1_scrollx = state->vregs[0x40e / 4];
657624
658   tilemap_set_scrolly(tmptilemap0, 0, layer0_scrolly );
625   tilemap_set_scrolly(tmptilemap0, 0, layer0_scrolly);
659626
660   tilemap_set_scrolly(tmptilemap1, 0, layer1_scrolly );
627   tilemap_set_scrolly(tmptilemap1, 0, layer1_scrolly);
661628
662   for (i=0; i<256; i++)   /* 256 screen lines */
629   for (i = 0; i < 256; i++)   /* 256 screen lines */
663630   {
664631      int x0 = 0, x1 = 0;
665632
r6740r6741
668635      {
669636         if (layer0_ctrl & 0x0200)
670637            /* per-tile rowscroll */
671            x0 = ((UINT16 *)psikyo_vregs)[BYTE_XOR_BE(0x000/2 + i/16)];
638            x0 = ((UINT16 *)state->vregs)[BYTE_XOR_BE(0x000/2 + i/16)];
672639         else
673640            /* per-line rowscroll */
674            x0 = ((UINT16 *)psikyo_vregs)[BYTE_XOR_BE(0x000/2 + i)];
641            x0 = ((UINT16 *)state->vregs)[BYTE_XOR_BE(0x000/2 + i)];
675642      }
676643
677644      tilemap_set_scrollx(
678645         tmptilemap0,
679         (i+layer0_scrolly) % tilemap_width(tm0size),
646         (i + layer0_scrolly) % tilemap_width(tm0size),
680647         layer0_scrollx + x0 );
681648
682649
r6740r6741
685652      {
686653         if (layer1_ctrl & 0x0200)
687654            /* per-tile rowscroll */
688            x1 = ((UINT16 *)psikyo_vregs)[BYTE_XOR_BE(0x200/2 + i/16)];
655            x1 = ((UINT16 *)state->vregs)[BYTE_XOR_BE(0x200/2 + i/16)];
689656         else
690657            /* per-line rowscroll */
691            x1 = ((UINT16 *)psikyo_vregs)[BYTE_XOR_BE(0x200/2 + i)];
658            x1 = ((UINT16 *)state->vregs)[BYTE_XOR_BE(0x200/2 + i)];
692659      }
693660
694661      tilemap_set_scrollx(
695662         tmptilemap1,
696         (i+layer1_scrolly) % tilemap_width(tm1size),
663         (i + layer1_scrolly) % tilemap_width(tm1size),
697664         layer1_scrollx + x1 );
698665   }
699666
700   tilemap_set_transparent_pen(tilemap_0_size0,(layer0_ctrl & 8 ?0:15));
701   tilemap_set_transparent_pen(tilemap_0_size1,(layer0_ctrl & 8 ?0:15));
702   tilemap_set_transparent_pen(tilemap_0_size2,(layer0_ctrl & 8 ?0:15));
703   tilemap_set_transparent_pen(tilemap_0_size3,(layer0_ctrl & 8 ?0:15));
667   tilemap_set_transparent_pen(state->tilemap_0_size0, (layer0_ctrl & 8 ? 0 : 15));
668   tilemap_set_transparent_pen(state->tilemap_0_size1, (layer0_ctrl & 8 ? 0 : 15));
669   tilemap_set_transparent_pen(state->tilemap_0_size2, (layer0_ctrl & 8 ? 0 : 15));
670   tilemap_set_transparent_pen(state->tilemap_0_size3, (layer0_ctrl & 8 ? 0 : 15));
704671
705   tilemap_set_transparent_pen(tilemap_1_size0,(layer1_ctrl & 8 ?0:15));
706   tilemap_set_transparent_pen(tilemap_1_size1,(layer1_ctrl & 8 ?0:15));
707   tilemap_set_transparent_pen(tilemap_1_size2,(layer1_ctrl & 8 ?0:15));
708   tilemap_set_transparent_pen(tilemap_1_size3,(layer1_ctrl & 8 ?0:15));
672   tilemap_set_transparent_pen(state->tilemap_1_size0, (layer1_ctrl & 8 ? 0 : 15));
673   tilemap_set_transparent_pen(state->tilemap_1_size1, (layer1_ctrl & 8 ? 0 : 15));
674   tilemap_set_transparent_pen(state->tilemap_1_size2, (layer1_ctrl & 8 ? 0 : 15));
675   tilemap_set_transparent_pen(state->tilemap_1_size3, (layer1_ctrl & 8 ? 0 : 15));
709676
710   bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
677   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
711678
712   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
679   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
713680
714681   if (layers_ctrl & 1)
715      tilemap_draw(bitmap,cliprect,tmptilemap0, layer0_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 1);
682      tilemap_draw(bitmap, cliprect, tmptilemap0, layer0_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 1);
716683
717684   if (layers_ctrl & 2)
718      tilemap_draw(bitmap,cliprect,tmptilemap1, layer1_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 2);
685      tilemap_draw(bitmap, cliprect, tmptilemap1, layer1_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 2);
719686
720687   if (layers_ctrl & 4)
721      draw_sprites(screen->machine, bitmap,cliprect,(spr_ctrl & 4 ? 0 : 15));
688      draw_sprites(screen->machine, bitmap, cliprect, (spr_ctrl & 4 ? 0 : 15));
722689
723690   return 0;
724691}
r6740r6741
733700
734701VIDEO_UPDATE( psikyo_bootleg )
735702{
703   psikyo_state *state = (psikyo_state *)screen->machine->driver_data;
736704   int i, layers_ctrl = -1;
737705
738706   UINT32 tm0size, tm1size;
739707
740708   UINT32 layer0_scrollx, layer0_scrolly;
741709   UINT32 layer1_scrollx, layer1_scrolly;
742   UINT32 layer0_ctrl = psikyo_vregs[ 0x412/4 ];
743   UINT32 layer1_ctrl = psikyo_vregs[ 0x416/4 ];
744   UINT32 spr_ctrl = spritebuf2[ 0x1ffe/4 ];
710   UINT32 layer0_ctrl = state->vregs[0x412 / 4];
711   UINT32 layer1_ctrl = state->vregs[0x416 / 4];
712   UINT32 spr_ctrl = state->spritebuf2[0x1ffe / 4];
745713
746714   tilemap *tmptilemap0, *tmptilemap1;
747715
r6740r6741
778746*/
779747
780748   /* For gfx banking for s1945jn/gunbird/btlkroad */
781   if(psikyo_ka302c_banking)
749   if (state->ka302c_banking)
782750   {
783      psikyo_switch_banks(0, (layer0_ctrl&0x400)>>10);
784      psikyo_switch_banks(1, (layer1_ctrl&0x400)>>10);
751      psikyo_switch_banks(screen->machine, 0, (layer0_ctrl & 0x400) >> 10);
752      psikyo_switch_banks(screen->machine, 1, (layer1_ctrl & 0x400) >> 10);
785753   }
786754
787   switch((layer0_ctrl & 0x00c0)>>6) {
788      case 0:
789         tm0size=1;
790         break;
791      case 1:
792         tm0size=2;
793         break;
794      case 2:
795         tm0size=3;
796         break;
797      default:
798         tm0size=0;
799         break;
755   switch ((layer0_ctrl & 0x00c0) >> 6)
756   {
757   case 0:   tm0size = 1;   break;
758   case 1:   tm0size = 2;   break;
759   case 2:   tm0size = 3;   break;
760   default:   tm0size = 0;   break;
800761   }
801762
802   switch((layer1_ctrl & 0x00c0)>>6) {
803      case 0:
804         tm1size=1;
805         break;
806      case 1:
807         tm1size=2;
808         break;
809      case 2:
810         tm1size=3;
811         break;
812      default:
813         tm1size=0;
814         break;
763   switch ((layer1_ctrl & 0x00c0) >> 6)
764   {
765   case 0:   tm1size = 1;   break;
766   case 1:   tm1size = 2;   break;
767   case 2:   tm1size = 3;   break;
768   default:   tm1size = 0;   break;
815769   }
816770
817   if(tm0size==0) tmptilemap0 = tilemap_0_size0;
818   else if (tm0size==1) tmptilemap0 = tilemap_0_size1;
819   else if (tm0size==2) tmptilemap0 = tilemap_0_size2;
820   else tmptilemap0 = tilemap_0_size3;
771   if (tm0size == 0)
772      tmptilemap0 = state->tilemap_0_size0;
773   else if (tm0size == 1)
774      tmptilemap0 = state->tilemap_0_size1;
775   else if (tm0size == 2)
776      tmptilemap0 = state->tilemap_0_size2;
777   else
778      tmptilemap0 = state->tilemap_0_size3;
821779
822   if(tm1size==0) tmptilemap1 = tilemap_1_size0;
823   else if (tm1size==1) tmptilemap1 = tilemap_1_size1;
824   else if (tm1size==2) tmptilemap1 = tilemap_1_size2;
825   else tmptilemap1 = tilemap_1_size3;
780   if (tm1size == 0)
781      tmptilemap1 = state->tilemap_1_size0;
782   else if (tm1size == 1)
783      tmptilemap1 = state->tilemap_1_size1;
784   else if (tm1size == 2)
785      tmptilemap1 = state->tilemap_1_size2;
786   else
787      tmptilemap1 = state->tilemap_1_size3;
826788
827789   tilemap_set_enable(tmptilemap0, ~layer0_ctrl & 1);
828
829790   tilemap_set_enable(tmptilemap1, ~layer1_ctrl & 1);
830791
831792   /* Layers scrolling */
832793
833   layer0_scrolly = psikyo_vregs[ 0x402/4 ];
834   layer0_scrollx = psikyo_vregs[ 0x406/4 ];
835   layer1_scrolly = psikyo_vregs[ 0x40a/4 ];
836   layer1_scrollx = psikyo_vregs[ 0x40e/4 ];
794   layer0_scrolly = state->vregs[0x402 / 4];
795   layer0_scrollx = state->vregs[0x406 / 4];
796   layer1_scrolly = state->vregs[0x40a / 4];
797   layer1_scrollx = state->vregs[0x40e / 4];
837798
838   tilemap_set_scrolly(tmptilemap0, 0, layer0_scrolly );
799   tilemap_set_scrolly(tmptilemap0, 0, layer0_scrolly);
839800
840   tilemap_set_scrolly(tmptilemap1, 0, layer1_scrolly );
801   tilemap_set_scrolly(tmptilemap1, 0, layer1_scrolly);
841802
842   for (i=0; i<256; i++)   /* 256 screen lines */
803   for (i = 0; i < 256; i++)   /* 256 screen lines */
843804   {
844805      int x0 = 0, x1 = 0;
845806
r6740r6741
848809      {
849810         if (layer0_ctrl & 0x0200)
850811            /* per-tile rowscroll */
851            x0 = ((UINT16 *)psikyo_vregs)[BYTE_XOR_BE(0x000/2 + i/16)];
812            x0 = ((UINT16 *)state->vregs)[BYTE_XOR_BE(0x000/2 + i/16)];
852813         else
853814            /* per-line rowscroll */
854            x0 = ((UINT16 *)psikyo_vregs)[BYTE_XOR_BE(0x000/2 + i)];
815            x0 = ((UINT16 *)state->vregs)[BYTE_XOR_BE(0x000/2 + i)];
855816      }
856817
857818      tilemap_set_scrollx(
858819         tmptilemap0,
859         (i+layer0_scrolly) % tilemap_width(tm0size),
820         (i + layer0_scrolly) % tilemap_width(tm0size),
860821         layer0_scrollx + x0 );
861822
862823
r6740r6741
865826      {
866827         if (layer1_ctrl & 0x0200)
867828            /* per-tile rowscroll */
868            x1 = ((UINT16 *)psikyo_vregs)[BYTE_XOR_BE(0x200/2 + i/16)];
829            x1 = ((UINT16 *)state->vregs)[BYTE_XOR_BE(0x200/2 + i/16)];
869830         else
870831            /* per-line rowscroll */
871            x1 = ((UINT16 *)psikyo_vregs)[BYTE_XOR_BE(0x200/2 + i)];
832            x1 = ((UINT16 *)state->vregs)[BYTE_XOR_BE(0x200/2 + i)];
872833      }
873834
874835      tilemap_set_scrollx(
875836         tmptilemap1,
876         (i+layer1_scrolly) % tilemap_width(tm1size),
837         (i + layer1_scrolly) % tilemap_width(tm1size),
877838         layer1_scrollx + x1 );
878839   }
879840
880   tilemap_set_transparent_pen(tilemap_0_size0,(layer0_ctrl & 8 ?0:15));
881   tilemap_set_transparent_pen(tilemap_0_size1,(layer0_ctrl & 8 ?0:15));
882   tilemap_set_transparent_pen(tilemap_0_size2,(layer0_ctrl & 8 ?0:15));
883   tilemap_set_transparent_pen(tilemap_0_size3,(layer0_ctrl & 8 ?0:15));
841   tilemap_set_transparent_pen(state->tilemap_0_size0, (layer0_ctrl & 8 ? 0 : 15));
842   tilemap_set_transparent_pen(state->tilemap_0_size1, (layer0_ctrl & 8 ? 0 : 15));
843   tilemap_set_transparent_pen(state->tilemap_0_size2, (layer0_ctrl & 8 ? 0 : 15));
844   tilemap_set_transparent_pen(state->tilemap_0_size3, (layer0_ctrl & 8 ? 0 : 15));
884845
885   tilemap_set_transparent_pen(tilemap_1_size0,(layer1_ctrl & 8 ?0:15));
886   tilemap_set_transparent_pen(tilemap_1_size1,(layer1_ctrl & 8 ?0:15));
887   tilemap_set_transparent_pen(tilemap_1_size2,(layer1_ctrl & 8 ?0:15));
888   tilemap_set_transparent_pen(tilemap_1_size3,(layer1_ctrl & 8 ?0:15));
846   tilemap_set_transparent_pen(state->tilemap_1_size0, (layer1_ctrl & 8 ? 0 : 15));
847   tilemap_set_transparent_pen(state->tilemap_1_size1, (layer1_ctrl & 8 ? 0 : 15));
848   tilemap_set_transparent_pen(state->tilemap_1_size2, (layer1_ctrl & 8 ? 0 : 15));
849   tilemap_set_transparent_pen(state->tilemap_1_size3, (layer1_ctrl & 8 ? 0 : 15));
889850
890851   bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
891852
892   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
853   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
893854
894855   if (layers_ctrl & 1)
895      tilemap_draw(bitmap,cliprect,tmptilemap0, layer0_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 1);
856      tilemap_draw(bitmap, cliprect, tmptilemap0, layer0_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 1);
896857
897858   if (layers_ctrl & 2)
898      tilemap_draw(bitmap,cliprect,tmptilemap1, layer1_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 2);
859      tilemap_draw(bitmap, cliprect, tmptilemap1, layer1_ctrl & 2 ? TILEMAP_DRAW_OPAQUE : 0, 2);
899860
900861   if (layers_ctrl & 4)
901      draw_sprites_bootleg(screen->machine, bitmap,cliprect,(spr_ctrl & 4 ? 0 : 15));
862      draw_sprites_bootleg(screen->machine, bitmap, cliprect, (spr_ctrl & 4 ? 0 : 15));
902863
903864   return 0;
904865}
r6740r6741
906867
907868VIDEO_EOF( psikyo )
908869{
909   memcpy(spritebuf2, spritebuf1, 0x2000);
910   memcpy(spritebuf1, machine->generic.spriteram.u32, 0x2000);
870   psikyo_state *state = (psikyo_state *)machine->driver_data;
871   memcpy(state->spritebuf2, state->spritebuf1, 0x2000);
872   memcpy(state->spritebuf1, machine->generic.spriteram.u32, 0x2000);
911873}
src/mame/video/esd16.c
r6740r6741
3434***************************************************************************/
3535
3636#include "driver.h"
37#include "esd16.h"
37#include "includes/esd16.h"
3838
3939
4040/***************************************************************************
src/mame/video/namcos21.c
r6740r6741
77*/
88
99#include "driver.h"
10#include "namcos2.h"
11#include "namcoic.h"
12#include "namcos21.h"
10#include "includes/namcos2.h"
11#include "includes/namcoic.h"
12#include "includes/namcos21.h"
1313
1414#define FRAMEBUFFER_SIZE_IN_BYTES (sizeof(UINT16)*NAMCOS21_POLY_FRAME_WIDTH*NAMCOS21_POLY_FRAME_HEIGHT)
1515
src/mame/video/pgm.c
r6740r6741
44#include "driver.h"
55#include "includes/pgm.h"
66
7static tilemap *pgm_tx_tilemap, *pgm_bg_tilemap;
8static UINT16 *pgm_spritebufferram; // buffered spriteram
9static UINT16 *sprite_temp_render;
10static bitmap_t *tmppgmbitmap;
11
127/* Sprites - These are a pain! */
138
149/* this decodes one of the funky sprites to a bitmap so we can draw it more easily -- slow but easier to use*/
15static void pgm_prepare_sprite(running_machine *machine, int wide, int high,int palt, int boffset)
10static void pgm_prepare_sprite( running_machine *machine, int wide, int high, int palt, int boffset )
1611{
17   UINT8 *bdata    = memory_region       ( machine, "gfx4" );
18   size_t  bdatasize = memory_region_length( machine, "gfx4" )-1;
19   UINT8 *adata    = pgm_sprite_a_region;
20   size_t  adatasize = pgm_sprite_a_region_allocate-1;
12   pgm_state *state = (pgm_state *)machine->driver_data;
13   UINT8 *bdata = memory_region(machine, "gfx4");
14   size_t  bdatasize = memory_region_length(machine, "gfx4") - 1;
15   UINT8 *adata = state->sprite_a_region;
16   size_t  adatasize = state->sprite_a_region_size - 1;
2117   int xcnt, ycnt;
2218
2319   UINT32 aoffset;
2420   UINT16 msk;
2521
26   aoffset = (bdata[(boffset+3) & bdatasize] << 24) | (bdata[(boffset+2) & bdatasize] << 16) | (bdata[(boffset+1) & bdatasize] << 8) | (bdata[(boffset+0) & bdatasize] << 0);
22   aoffset = (bdata[(boffset + 3) & bdatasize] << 24) | (bdata[(boffset + 2) & bdatasize] << 16) |
23            (bdata[(boffset + 1) & bdatasize] << 8) | (bdata[(boffset + 0) & bdatasize] << 0);
2724   aoffset = aoffset >> 2; aoffset *= 3;
2825
2926   boffset += 4; /* because the first dword is the a data offset */
3027
31   for (ycnt = 0 ; ycnt < high ; ycnt++) {
32      for (xcnt = 0 ; xcnt < wide ; xcnt++) {
28   for (ycnt = 0 ; ycnt < high ; ycnt++)
29   {
30      for (xcnt = 0 ; xcnt < wide ; xcnt++)
31      {
3332         int x;
3433
35         msk = (( bdata[(boffset+1) & bdatasize] << 8) |( bdata[(boffset+0) & bdatasize] << 0) );
34         msk = ((bdata[(boffset + 1) & bdatasize] << 8) |( bdata[(boffset + 0) & bdatasize] << 0));
3635
37         for (x=0;x<16;x++)
36         for (x = 0; x < 16; x++)
3837         {
3938            if (!(msk & 0x0001))
4039            {
41               sprite_temp_render[(ycnt*(wide*16))+(xcnt*16+x)] = adata[aoffset & adatasize]+ palt*32;
40               state->sprite_temp_render[(ycnt * (wide * 16))+(xcnt * 16 + x)] = adata[aoffset & adatasize] + palt * 32;
4241               aoffset++;
4342            }
4443            else
4544            {
46               sprite_temp_render[(ycnt*(wide*16))+(xcnt*16+x)] = 0x8000;
45               state->sprite_temp_render[(ycnt * (wide * 16)) + (xcnt * 16 + x)] = 0x8000;
4746            }
48            msk >>=1;
47            msk >>= 1;
4948         }
5049
51         boffset+=2;
50         boffset += 2;
5251      }
5352   }
5453}
5554
5655
5756// in the dest bitmap 0x10000 is used to mark 'used pixel' and 0x8000 is used to mark 'high priority'
58static void draw_sprite_line(int wide, UINT32* dest, int xzoom, int xgrow, int yoffset, int flip, int xpos, int pri)
57static void draw_sprite_line( running_machine *machine, int wide, UINT32* dest, int xzoom, int xgrow, int yoffset, int flip, int xpos, int pri )
5958{
59   pgm_state *state = (pgm_state *)machine->driver_data;
6060   int xcnt,xcntdraw;
6161   int xzoombit;
6262   int xoffset;
r6740r6741
6464
6565   xcnt = 0;
6666   xcntdraw = 0;
67   while (xcnt < wide*16)
67   while (xcnt < wide * 16)
6868   {
6969      UINT32 srcdat;
70      if (!(flip&0x01)) xoffset = xcnt;
71      else xoffset = (wide*16)-xcnt-1;
70      if (!(flip & 0x01))
71         xoffset = xcnt;
72      else
73         xoffset = (wide * 16) - xcnt - 1;
7274
73      srcdat = sprite_temp_render[yoffset+xoffset];
74      xzoombit = (xzoom >> (xcnt&0x1f))&1;
75      srcdat = state->sprite_temp_render[yoffset + xoffset];
76      xzoombit = (xzoom >> (xcnt & 0x1f)) & 1;
7577
76      if (xzoombit == 1 && xgrow ==1)
78      if (xzoombit == 1 && xgrow == 1)
7779      { // double this column
7880         xdrawpos = xpos + xcntdraw;
79         if (!(srcdat&0x8000))
81         if (!(srcdat & 0x8000))
8082         {
8183            if ((xdrawpos >= 0) && (xdrawpos < 448))
8284            {
83               if (pri) dest[xdrawpos] = srcdat | 0x8000 | 0x10000;
84               else dest[xdrawpos] = srcdat | 0x10000;
85               if (pri)
86                  dest[xdrawpos] = srcdat | 0x8000 | 0x10000;
87               else
88                  dest[xdrawpos] = srcdat | 0x10000;
8589            }
8690         }
8791         xcntdraw++;
8892
8993         xdrawpos = xpos + xcntdraw;
9094
91         if (!(srcdat&0x8000))
95         if (!(srcdat & 0x8000))
9296         {
9397            if ((xdrawpos >= 0) && (xdrawpos < 448))
9498            {
95               if (pri) dest[xdrawpos] = srcdat | 0x8000 | 0x10000;
96               else dest[xdrawpos] = srcdat | 0x10000;
99               if (pri)
100                  dest[xdrawpos] = srcdat | 0x8000 | 0x10000;
101               else
102                  dest[xdrawpos] = srcdat | 0x10000;
97103            }
98104         }
99105         xcntdraw++;
100106      }
101      else if (xzoombit ==1 && xgrow ==0)
107      else if (xzoombit == 1 && xgrow == 0)
102108      {
103109         /* skip this column */
104110      }
105111      else //normal column
106112      {
107113         xdrawpos = xpos + xcntdraw;
108         if (!(srcdat&0x8000))
114         if (!(srcdat & 0x8000))
109115         {
110116            if ((xdrawpos >= 0) && (xdrawpos < 448))
111117            {
112               if (pri) dest[xdrawpos] = srcdat | 0x8000 | 0x10000;
113               else dest[xdrawpos] = srcdat | 0x10000;
118               if (pri)
119                  dest[xdrawpos] = srcdat | 0x8000 | 0x10000;
120               else
121                  dest[xdrawpos] = srcdat | 0x10000;
114122            }
115123         }
116124         xcntdraw++;
r6740r6741
122130   }
123131}
124132/* this just loops over our decoded bitmap and puts it on the screen */
125static void draw_sprite_new_zoomed(running_machine *machine, int wide, int high, int xpos, int ypos, int palt, int boffset, int flip, bitmap_t* bitmap, UINT32 xzoom, int xgrow, UINT32 yzoom, int ygrow, int pri )
133static void draw_sprite_new_zoomed( running_machine *machine, int wide, int high, int xpos, int ypos, int palt, int boffset, int flip, bitmap_t* bitmap, UINT32 xzoom, int xgrow, UINT32 yzoom, int ygrow, int pri )
126134{
127135   int ycnt;
128136   int ydrawpos;
r6740r6741
131139   int ycntdraw;
132140   int yzoombit;
133141
134   pgm_prepare_sprite( machine, wide,high, palt, boffset );
142   pgm_prepare_sprite(machine, wide,high, palt, boffset);
135143
136144   /* now draw it */
137145   ycnt = 0;
138146   ycntdraw = 0;
139147   while (ycnt < high)
140148   {
141      yzoombit = (yzoom >> (ycnt&0x1f))&1;
149      yzoombit = (yzoom >> (ycnt & 0x1f)) & 1;
142150
143151      if (yzoombit == 1 && ygrow == 1) // double this line
144152      {
145153         ydrawpos = ypos + ycntdraw;
146154
147         if (!(flip&0x02)) yoffset = (ycnt*(wide*16));
148         else yoffset = ( (high-ycnt-1)*(wide*16));
155         if (!(flip & 0x02))
156            yoffset = (ycnt * (wide * 16));
157         else
158            yoffset = ((high - ycnt - 1) * (wide * 16));
159
149160         if ((ydrawpos >= 0) && (ydrawpos < 224))
150161         {
151162            dest = BITMAP_ADDR32(bitmap, ydrawpos, 0);
152            draw_sprite_line(wide, dest, xzoom, xgrow, yoffset, flip, xpos, pri);
163            draw_sprite_line(machine, wide, dest, xzoom, xgrow, yoffset, flip, xpos, pri);
153164         }
154165         ycntdraw++;
155166
156167         ydrawpos = ypos + ycntdraw;
157         if (!(flip&0x02)) yoffset = (ycnt*(wide*16));
158         else yoffset = ( (high-ycnt-1)*(wide*16));
168         if (!(flip & 0x02))
169            yoffset = (ycnt * (wide * 16));
170         else
171            yoffset = ((high - ycnt - 1) * (wide * 16));
172
159173         if ((ydrawpos >= 0) && (ydrawpos < 224))
160174         {
161175            dest = BITMAP_ADDR32(bitmap, ydrawpos, 0);
162            draw_sprite_line(wide, dest, xzoom, xgrow, yoffset, flip, xpos, pri);
176            draw_sprite_line(machine, wide, dest, xzoom, xgrow, yoffset, flip, xpos, pri);
163177         }
164178         ycntdraw++;
165179
166         if (ydrawpos ==224) ycnt = high;
180         if (ydrawpos ==224)
181            ycnt = high;
167182      }
168      else if (yzoombit ==1 && ygrow == 0)
183      else if (yzoombit == 1 && ygrow == 0)
169184      {
170185         /* skip this line */
171186         /* we should process anyway if we don't do the pre-decode.. */
r6740r6741
174189      {
175190         ydrawpos = ypos + ycntdraw;
176191
177         if (!(flip&0x02)) yoffset = (ycnt*(wide*16));
178         else yoffset = ( (high-ycnt-1)*(wide*16));
192         if (!(flip & 0x02))
193            yoffset = (ycnt * (wide * 16));
194         else
195            yoffset = ((high - ycnt - 1) * (wide * 16));
196
179197         if ((ydrawpos >= 0) && (ydrawpos < 224))
180198         {
181199            dest = BITMAP_ADDR32(bitmap, ydrawpos, 0);
182            draw_sprite_line(wide, dest, xzoom, xgrow, yoffset, flip, xpos, pri);
200            draw_sprite_line(machine, wide, dest, xzoom, xgrow, yoffset, flip, xpos, pri);
183201         }
184202         ycntdraw++;
185203
186         if (ydrawpos ==224) ycnt = high;
204         if (ydrawpos == 224)
205            ycnt = high;
187206      }
188207
189208      ycnt++;
r6740r6741
191210}
192211
193212
194static UINT16 *pgm_sprite_source;
195
196static void draw_sprites(running_machine *machine, bitmap_t* spritebitmap)
213static void draw_sprites( running_machine *machine, bitmap_t* spritebitmap, UINT16 *sprite_source )
197214{
198215   /* ZZZZ Zxxx xxxx xxxx
199216       zzzz z-yy yyyy yyyy
r6740r6741
203220    */
204221
205222
206   const UINT16 *finish = pgm_spritebufferram+(0xa00/2);
223   pgm_state *state = (pgm_state *)machine->driver_data;
224   const UINT16 *finish = state->spritebufferram + (0xa00 / 2);
207225
208   while( pgm_sprite_source<finish )
226   while (sprite_source < finish)
209227   {
210      int xpos = pgm_sprite_source[0] & 0x07ff;
211      int ypos = pgm_sprite_source[1] & 0x03ff;
212      int xzom = (pgm_sprite_source[0] & 0x7800) >> 11;
213      int xgrow = (pgm_sprite_source[0] & 0x8000) >> 15;
214      int yzom = (pgm_sprite_source[1] & 0x7800) >> 11;
215      int ygrow = (pgm_sprite_source[1] & 0x8000) >> 15;
216      int palt = (pgm_sprite_source[2] & 0x1f00) >> 8;
217      int flip = (pgm_sprite_source[2] & 0x6000) >> 13;
218      int boff = ((pgm_sprite_source[2] & 0x007f) << 16) | (pgm_sprite_source[3] & 0xffff);
219      int wide = (pgm_sprite_source[4] & 0x7e00) >> 9;
220      int high = pgm_sprite_source[4] & 0x01ff;
221      int pri = (pgm_sprite_source[2] & 0x0080) >>  7;
228      int xpos = sprite_source[0] & 0x07ff;
229      int ypos = sprite_source[1] & 0x03ff;
230      int xzom = (sprite_source[0] & 0x7800) >> 11;
231      int xgrow = (sprite_source[0] & 0x8000) >> 15;
232      int yzom = (sprite_source[1] & 0x7800) >> 11;
233      int ygrow = (sprite_source[1] & 0x8000) >> 15;
234      int palt = (sprite_source[2] & 0x1f00) >> 8;
235      int flip = (sprite_source[2] & 0x6000) >> 13;
236      int boff = ((sprite_source[2] & 0x007f) << 16) | (sprite_source[3] & 0xffff);
237      int wide = (sprite_source[4] & 0x7e00) >> 9;
238      int high = sprite_source[4] & 0x01ff;
239      int pri = (sprite_source[2] & 0x0080) >>  7;
222240
223241      UINT32 xzoom, yzoom;
224242
225      UINT16* pgm_sprite_zoomtable = &pgm_videoregs[0x1000/2];
243      UINT16* sprite_zoomtable = &state->videoregs[0x1000 / 2];
226244
227245      if (xgrow)
228246      {
229      //  xzom = 0xf-xzom; // would make more sense but everything gets zoomed slightly in dragon world 2 ?!
230         xzom = 0x10-xzom; // this way it doesn't but there is a bad line when zooming after the level select?
247      //  xzom = 0xf - xzom; // would make more sense but everything gets zoomed slightly in dragon world 2 ?!
248         xzom = 0x10 - xzom; // this way it doesn't but there is a bad line when zooming after the level select?
231249      }
232250
233251      if (ygrow)
234252      {
235      //  yzom = 0xf-yzom; // see comment above
236         yzom = 0x10-yzom;
253      //  yzom = 0xf - yzom; // see comment above
254         yzom = 0x10 - yzom;
237255      }
238256
239      xzoom = (pgm_sprite_zoomtable[xzom*2]<<16)|pgm_sprite_zoomtable[xzom*2+1];
240      yzoom = (pgm_sprite_zoomtable[yzom*2]<<16)|pgm_sprite_zoomtable[yzom*2+1];
257      xzoom = (sprite_zoomtable[xzom * 2] << 16) | sprite_zoomtable[xzom * 2 + 1];
258      yzoom = (sprite_zoomtable[yzom * 2] << 16) | sprite_zoomtable[yzom * 2 + 1];
241259
242260      boff *= 2;
243261      if (xpos > 0x3ff) xpos -=0x800;
r6740r6741
247265
248266      //if ((priority == 1) && (pri == 0)) break;
249267
250      draw_sprite_new_zoomed(machine, wide, high, xpos, ypos, palt, boff, flip, spritebitmap, xzoom,xgrow, yzoom,ygrow, pri);
268      draw_sprite_new_zoomed(machine, wide, high, xpos, ypos, palt, boff, flip, spritebitmap, xzoom, xgrow, yzoom, ygrow, pri);
251269
252      pgm_sprite_source += 5;
270      sprite_source += 5;
253271   }
254272}
255273
256274/* TX Layer */
257
258275WRITE16_HANDLER( pgm_tx_videoram_w )
259276{
260   pgm_tx_videoram[offset] = data;
261   tilemap_mark_tile_dirty(pgm_tx_tilemap,offset/2);
277   pgm_state *state = (pgm_state *)space->machine->driver_data;
278   state->tx_videoram[offset] = data;
279   tilemap_mark_tile_dirty(state->tx_tilemap, offset / 2);
262280}
263281
264282static TILE_GET_INFO( get_pgm_tx_tilemap_tile_info )
r6740r6741
278296    p = palette
279297    f = flip
280298*/
281   int tileno,colour,flipyx; //,game;
299   pgm_state *state = (pgm_state *)machine->driver_data;
300   int tileno, colour, flipyx; //,game;
282301
283   tileno = pgm_tx_videoram[tile_index *2] & 0xffff;
284   colour = (pgm_tx_videoram[tile_index*2+1] & 0x3e) >> 1;
285   flipyx = (pgm_tx_videoram[tile_index*2+1] & 0xc0) >> 6;
302   tileno = state->tx_videoram[tile_index * 2] & 0xffff;
303   colour = (state->tx_videoram[tile_index * 2 + 1] & 0x3e) >> 1;
304   flipyx = (state->tx_videoram[tile_index * 2 + 1] & 0xc0) >> 6;
286305
287306   if (tileno > 0xbfff) { tileno -= 0xc000 ; tileno += 0x20000; } /* not sure about this */
288307
r6740r6741
293312
294313WRITE16_HANDLER( pgm_bg_videoram_w )
295314{
296   pgm_bg_videoram[offset] = data;
297   tilemap_mark_tile_dirty(pgm_bg_tilemap,offset/2);
315   pgm_state *state = (pgm_state *)space->machine->driver_data;
316   state->bg_videoram[offset] = data;
317   tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
298318}
299319
300320static TILE_GET_INFO( get_pgm_bg_tilemap_tile_info )
301321{
302322   /* pretty much the same as tx layer */
303323
304   int tileno,colour,flipyx;
324   pgm_state *state = (pgm_state *)machine->driver_data;
325   int tileno, colour, flipyx;
305326
306   tileno = pgm_bg_videoram[tile_index *2] & 0xffff;
307   if (tileno > 0x7ff) tileno+=0x1000; /* Tiles 0x800+ come from the GAME Roms */
308   colour = (pgm_bg_videoram[tile_index*2+1] & 0x3e) >> 1;
309   flipyx = (pgm_bg_videoram[tile_index*2+1] & 0xc0) >> 6;
327   tileno = state->bg_videoram[tile_index *2] & 0xffff;
328   if (tileno > 0x7ff)
329      tileno += 0x1000; /* Tiles 0x800+ come from the GAME Roms */
330   colour = (state->bg_videoram[tile_index * 2 + 1] & 0x3e) >> 1;
331   flipyx = (state->bg_videoram[tile_index * 2 + 1] & 0xc0) >> 6;
310332
311333   SET_TILE_INFO(1,tileno,colour,TILE_FLIPYX(flipyx));
312334}
r6740r6741
317339
318340VIDEO_START( pgm )
319341{
342   pgm_state *state = (pgm_state *)machine->driver_data;
320343   int i;
321344
322   pgm_tx_tilemap= tilemap_create(machine, get_pgm_tx_tilemap_tile_info,tilemap_scan_rows, 8, 8,64,32);
323   tilemap_set_transparent_pen(pgm_tx_tilemap,15);
345   state->tx_tilemap = tilemap_create(machine, get_pgm_tx_tilemap_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
346   tilemap_set_transparent_pen(state->tx_tilemap, 15);
324347
325   pgm_bg_tilemap = tilemap_create(machine, get_pgm_bg_tilemap_tile_info,tilemap_scan_rows, 32, 32,64,64);
326   tilemap_set_transparent_pen(pgm_bg_tilemap,31);
327   tilemap_set_scroll_rows(pgm_bg_tilemap,64*32);
348   state->bg_tilemap = tilemap_create(machine, get_pgm_bg_tilemap_tile_info, tilemap_scan_rows, 32, 32, 64, 64);
349   tilemap_set_transparent_pen(state->bg_tilemap, 31);
350   tilemap_set_scroll_rows(state->bg_tilemap, 64 * 32);
328351
329   tmppgmbitmap = auto_bitmap_alloc(machine,448,224,BITMAP_FORMAT_RGB32);
352   state->tmppgmbitmap = auto_bitmap_alloc(machine, 448, 224, BITMAP_FORMAT_RGB32);
330353
331   for (i=0; i < 0x1200/2; i++)
354   for (i = 0; i < 0x1200 / 2; i++)
332355      palette_set_color(machine, i, MAKE_RGB(0, 0, 0));
333356
334   pgm_spritebufferram = auto_alloc_array(machine, UINT16, 0xa00/2);
357   state->spritebufferram = auto_alloc_array(machine, UINT16, 0xa00/2);
335358
336359   /* we render each sprite to a bitmap then copy the bitmap to screen bitmap with zooming */
337360   /* easier this way because of the funky sprite format */
338   sprite_temp_render = auto_alloc_array(machine, UINT16, 0x400*0x200);
361   state->sprite_temp_render = auto_alloc_array(machine, UINT16, 0x400*0x200);
362
363   state_save_register_global_pointer(machine, state->spritebufferram, 0xa00/2);
364   state_save_register_global_pointer(machine, state->sprite_temp_render, 0x400*0x200);
365   state_save_register_global_bitmap(machine, state->tmppgmbitmap);
339366}
340367
341368VIDEO_UPDATE( pgm )
342369{
370   pgm_state *state = (pgm_state *)screen->machine->driver_data;
343371   int y;
344372
345   bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
346   bitmap_fill(tmppgmbitmap, cliprect, 0x00000000);
373   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
374   bitmap_fill(state->tmppgmbitmap, cliprect, 0x00000000);
347375
376   draw_sprites(screen->machine, state->tmppgmbitmap, state->spritebufferram);
348377
349   pgm_sprite_source = pgm_spritebufferram;
350   draw_sprites(screen->machine, tmppgmbitmap);
378   tilemap_set_scrolly(state->bg_tilemap,0, state->videoregs[0x2000/2]);
351379
352   tilemap_set_scrolly(pgm_bg_tilemap,0, pgm_videoregs[0x2000/2]);
353
354380   for (y = 0; y < 224; y++)
355      tilemap_set_scrollx(pgm_bg_tilemap,(y+pgm_videoregs[0x2000/2])&0x7ff, pgm_videoregs[0x3000/2]+pgm_rowscrollram[y]);
381      tilemap_set_scrollx(state->bg_tilemap, (y + state->videoregs[0x2000 / 2]) & 0x7ff, state->videoregs[0x3000 / 2] + state->rowscrollram[y]);
356382
357383   {
358      int y,x;
384      int y, x;
359385
360      for (y=0;y<224;y++)
386      for (y = 0; y < 224; y++)
361387      {
362         UINT32* src = BITMAP_ADDR32(tmppgmbitmap, y, 0);
388         UINT32* src = BITMAP_ADDR32(state->tmppgmbitmap, y, 0);
363389         UINT16* dst = BITMAP_ADDR16(bitmap, y, 0);
364390
365         for (x=0;x<448;x++)
391         for (x = 0; x < 448; x++)
366392         {
367            if (src[x]&0x10000)
368               if ((src[x]&0x8000)==0x8000)
369                  dst[x] = src[x]&0x7fff;
393            if (src[x] & 0x10000)
394               if ((src[x] & 0x8000) == 0x8000)
395                  dst[x] = src[x] & 0x7fff;
370396         }
371397      }
372398   }
373399
374
375   tilemap_draw(bitmap,cliprect,pgm_bg_tilemap,0,0);
376
400   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
377401   {
378      int y,x;
402      int y, x;
379403
380      for (y=0;y<224;y++)
404      for (y = 0; y < 224; y++)
381405      {
382         UINT32* src = BITMAP_ADDR32(tmppgmbitmap, y, 0);
406         UINT32* src = BITMAP_ADDR32(state->tmppgmbitmap, y, 0);
383407         UINT16* dst = BITMAP_ADDR16(bitmap, y, 0);
384408
385         for (x=0;x<448;x++)
409         for (x = 0; x < 448; x++)
386410         {
387            if (src[x]&0x10000)
388               if ((src[x]&0x8000)==0x0000)
411            if (src[x] & 0x10000)
412               if ((src[x] & 0x8000) == 0x0000)
389413                  dst[x] = src[x];
390414         }
391415      }
392416   }
393417
394   tilemap_set_scrolly(pgm_tx_tilemap,0, pgm_videoregs[0x5000/2]);
395   tilemap_set_scrollx(pgm_tx_tilemap,0, pgm_videoregs[0x6000/2]); // Check
396   tilemap_draw(bitmap,cliprect,pgm_tx_tilemap,0,0);
418   tilemap_set_scrolly(state->tx_tilemap, 0, state->videoregs[0x5000/2]);
419   tilemap_set_scrollx(state->tx_tilemap, 0, state->videoregs[0x6000/2]); // Check
420   tilemap_draw(bitmap, cliprect, state->tx_tilemap, 0, 0);
397421   return 0;
398422}
399423
400424VIDEO_EOF( pgm )
401425{
426   pgm_state *state = (pgm_state *)machine->driver_data;
427
402428   /* first 0xa00 of main ram = sprites, seems to be buffered, DMA? */
403   memcpy(pgm_spritebufferram,pgm_mainram,0xa00);
429   memcpy(state->spritebufferram, pgm_mainram, 0xa00);
404430}
src/mame/video/gameplan.c
r6740r6741
88
99#include "driver.h"
1010#include "machine/6522via.h"
11#include "gameplan.h"
11#include "includes/gameplan.h"
1212
1313
1414
src/mame/video/iqblock.c
r6740r6741
11#include "driver.h"
2#include "iqblock.h"
2#include "includes/iqblock.h"
33
44
55UINT8 *iqblock_bgvideoram;
src/mame/video/capbowl.c
r6740r6741
77#include "driver.h"
88#include "video/tms34061.h"
99#include "cpu/m6809/m6809.h"
10#include "capbowl.h"
10#include "includes/capbowl.h"
1111
1212
1313/*************************************
src/mame/video/cbasebal.c
r6740r6741
11#include "driver.h"
2#include "includes/cbasebal.h"
23
34
4static UINT8 *cbasebal_textram,*cbasebal_scrollram;
5static tilemap *fg_tilemap,*bg_tilemap;
6static int tilebank,spritebank;
7static int text_on,bg_on,obj_on;
8static int flipscreen;
9
10
11
125/***************************************************************************
136
147  Callbacks for the TileMap code
r6740r6741
1710
1811static TILE_GET_INFO( get_bg_tile_info )
1912{
20   UINT8 attr = cbasebal_scrollram[2*tile_index+1];
13   cbasebal_state *state = (cbasebal_state *)machine->driver_data;
14   UINT8 attr = state->scrollram[2 * tile_index + 1];
2115   SET_TILE_INFO(
2216         1,
23         cbasebal_scrollram[2*tile_index] + ((attr & 0x07) << 8) + 0x800 * tilebank,
17         state->scrollram[2 * tile_index] + ((attr & 0x07) << 8) + 0x800 * state->tilebank,
2418         (attr & 0xf0) >> 4,
2519         (attr & 0x08) ? TILE_FLIPX : 0);
2620}
2721
2822static TILE_GET_INFO( get_fg_tile_info )
2923{
30   UINT8 attr = cbasebal_textram[tile_index+0x800];
24   cbasebal_state *state = (cbasebal_state *)machine->driver_data;
25   UINT8 attr = state->textram[tile_index + 0x800];
3126   SET_TILE_INFO(
3227         0,
33         cbasebal_textram[tile_index] + ((attr & 0xf0) << 4),
28         state->textram[tile_index] + ((attr & 0xf0) << 4),
3429         attr & 0x07,
3530         (attr & 0x08) ? TILE_FLIPX : 0);
3631}
r6740r6741
4540
4641VIDEO_START( cbasebal )
4742{
48   cbasebal_textram = auto_alloc_array(machine, UINT8, 0x1000);
49   cbasebal_scrollram = auto_alloc_array(machine, UINT8, 0x1000);
43   cbasebal_state *state = (cbasebal_state *)machine->driver_data;
5044
51   bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,   16,16,64,32);
52   fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,64,32);
45   state->textram = auto_alloc_array(machine, UINT8, 0x1000);
46   state->scrollram = auto_alloc_array(machine, UINT8, 0x1000);
5347
54   tilemap_set_transparent_pen(fg_tilemap,3);
48   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 16, 16, 64, 32);
49   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
50
51   tilemap_set_transparent_pen(state->fg_tilemap, 3);
52
53   state_save_register_global_pointer(machine, state->textram, 0x1000);
54   state_save_register_global_pointer(machine, state->scrollram, 0x1000);
5555}
5656
5757
r6740r6741
6464
6565WRITE8_HANDLER( cbasebal_textram_w )
6666{
67   cbasebal_textram[offset] = data;
68   tilemap_mark_tile_dirty(fg_tilemap,offset & 0x7ff);
67   cbasebal_state *state = (cbasebal_state *)space->machine->driver_data;
68
69   state->textram[offset] = data;
70   tilemap_mark_tile_dirty(state->fg_tilemap, offset & 0x7ff);
6971}
7072
7173READ8_HANDLER( cbasebal_textram_r )
7274{
73   return cbasebal_textram[offset];
75   cbasebal_state *state = (cbasebal_state *)space->machine->driver_data;
76   return state->textram[offset];
7477}
7578
7679WRITE8_HANDLER( cbasebal_scrollram_w )
7780{
78   cbasebal_scrollram[offset] = data;
79   tilemap_mark_tile_dirty(bg_tilemap,offset/2);
81   cbasebal_state *state = (cbasebal_state *)space->machine->driver_data;
82
83   state->scrollram[offset] = data;
84   tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
8085}
8186
8287READ8_HANDLER( cbasebal_scrollram_r )
8388{
84   return cbasebal_scrollram[offset];
89   cbasebal_state *state = (cbasebal_state *)space->machine->driver_data;
90   return state->scrollram[offset];
8591}
8692
8793WRITE8_HANDLER( cbasebal_gfxctrl_w )
8894{
95   cbasebal_state *state = (cbasebal_state *)space->machine->driver_data;
96
8997   /* bit 0 is unknown - toggles continuously */
9098
9199   /* bit 1 is flip screen */
92   flipscreen = data & 0x02;
93   tilemap_set_flip_all(space->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
100   state->flipscreen = data & 0x02;
101   tilemap_set_flip_all(space->machine, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
94102
95103   /* bit 2 is unknown - unused? */
96104
97105   /* bit 3 is tile bank */
98   if (tilebank != ((data & 0x08) >> 3))
106   if (state->tilebank != ((data & 0x08) >> 3))
99107   {
100      tilebank = (data & 0x08) >> 3;
101      tilemap_mark_all_tiles_dirty(bg_tilemap);
108      state->tilebank = (data & 0x08) >> 3;
109      tilemap_mark_all_tiles_dirty(state->bg_tilemap);
102110   }
103111
104112   /* bit 4 is sprite bank */
105   spritebank = (data & 0x10) >> 4;
113   state->spritebank = (data & 0x10) >> 4;
106114
107115   /* bits 5 is text enable */
108   text_on = ~data & 0x20;
116   state->text_on = ~data & 0x20;
109117
110118   /* bits 6-7 are bg/sprite enable (don't know which is which) */
111   bg_on = ~data & 0x40;
112   obj_on = ~data & 0x80;
119   state->bg_on = ~data & 0x40;
120   state->obj_on = ~data & 0x80;
113121
114122   /* other bits unknown, but used */
115123}
116124
117125WRITE8_HANDLER( cbasebal_scrollx_w )
118126{
119   static UINT8 scroll[2];
120
121   scroll[offset] = data;
122   tilemap_set_scrollx(bg_tilemap,0,scroll[0] + 256 * scroll[1]);
127   cbasebal_state *state = (cbasebal_state *)space->machine->driver_data;
128   state->scroll_x[offset] = data;
129   tilemap_set_scrollx(state->bg_tilemap, 0, state->scroll_x[0] + 256 * state->scroll_x[1]);
123130}
124131
125132WRITE8_HANDLER( cbasebal_scrolly_w )
126133{
127   static UINT8 scroll[2];
128
129   scroll[offset] = data;
130   tilemap_set_scrolly(bg_tilemap,0,scroll[0] + 256 * scroll[1]);
134   cbasebal_state *state = (cbasebal_state *)space->machine->driver_data;
135   state->scroll_y[offset] = data;
136   tilemap_set_scrolly(state->bg_tilemap, 0, state->scroll_y[0] + 256 * state->scroll_y[1]);
131137}
132138
133139
r6740r6741
138144
139145***************************************************************************/
140146
141static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
147static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
142148{
143   UINT8 *spriteram = machine->generic.spriteram.u8;
144   int offs,sx,sy;
149   cbasebal_state *state = (cbasebal_state *)machine->driver_data;
150   UINT8 *spriteram = state->spriteram;
151   int offs, sx, sy;
145152
146153   /* the last entry is not a sprite, we skip it otherwise spang shows a bubble */
147154   /* moving diagonally across the screen */
148   for (offs = machine->generic.spriteram_size-8;offs >= 0;offs -= 4)
155   for (offs = state->spriteram_size - 8; offs >= 0; offs -= 4)
149156   {
150157      int code = spriteram[offs];
151      int attr = spriteram[offs+1];
158      int attr = spriteram[offs + 1];
152159      int color = attr & 0x07;
153160      int flipx = attr & 0x08;
154      sx = spriteram[offs+3] + ((attr & 0x10) << 4);
155      sy = ((spriteram[offs+2] + 8) & 0xff) - 8;
161      sx = spriteram[offs + 3] + ((attr & 0x10) << 4);
162      sy = ((spriteram[offs + 2] + 8) & 0xff) - 8;
156163      code += (attr & 0xe0) << 3;
157      code += spritebank * 0x800;
164      code += state->spritebank * 0x800;
158165
159      if (flipscreen)
166      if (state->flipscreen)
160167      {
161168         sx = 496 - sx;
162169         sy = 240 - sy;
r6740r6741
166173      drawgfx_transpen(bitmap,cliprect,machine->gfx[2],
167174            code,
168175            color,
169            flipx,flipscreen,
176            flipx,state->flipscreen,
170177            sx,sy,15);
171178   }
172179}
173180
174181VIDEO_UPDATE( cbasebal )
175182{
176   if (bg_on)
177      tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
183   cbasebal_state *state = (cbasebal_state *)screen->machine->driver_data;
184
185   if (state->bg_on)
186      tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
178187   else
179      bitmap_fill(bitmap,cliprect,768);
188      bitmap_fill(bitmap, cliprect, 768);
180189
181   if (obj_on)
182      draw_sprites(screen->machine, bitmap,cliprect);
190   if (state->obj_on)
191      draw_sprites(screen->machine, bitmap, cliprect);
183192
184   if (text_on)
185      tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
193   if (state->text_on)
194      tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
186195   return 0;
187196}
src/mame/video/st0016.c
r6740r6741
44************************************/
55
66#include "driver.h"
7#include "st0016.h"
7#include "includes/st0016.h"
88
99UINT8 *st0016_charram;
1010static UINT8 *st0016_spriteram,*st0016_paletteram;
src/mame/video/beathead.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "beathead.h"
8#include "includes/beathead.h"
99
1010
1111
1212/*************************************
1313 *
14 *  Statics
15 *
16 *************************************/
17
18static UINT32            finescroll;
19static offs_t            vram_latch_offset;
20
21static offs_t            hsyncram_offset;
22static offs_t            hsyncram_start;
23static UINT8 *            hsyncram;
24
25
26
27/*************************************
28 *
2914 *  Video start/stop
3015 *
3116 *************************************/
3217
3318VIDEO_START( beathead )
3419{
35   hsyncram = auto_alloc_array(machine, UINT8, 0x800);
20   beathead_state *state = (beathead_state *)machine->driver_data;
21   state_save_register_global(machine, state->finescroll);
22   state_save_register_global(machine, state->vram_latch_offset);
23   state_save_register_global(machine, state->hsyncram_offset);
24   state_save_register_global(machine, state->hsyncram_start);
25   state_save_register_global_array(machine, state->hsyncram);
3626}
3727
3828
r6740r6741
7767WRITE32_HANDLER( beathead_vram_latch_w )
7868{
7969   /* latch the address */
80   vram_latch_offset = (4 * offset) & 0x7ffff;
70   beathead_state *state = (beathead_state *)space->machine->driver_data;
71   state->vram_latch_offset = (4 * offset) & 0x7ffff;
8172}
8273
8374
8475WRITE32_HANDLER( beathead_vram_copy_w )
8576{
8677   /* copy from VRAM to VRAM, for 1024 bytes */
78   beathead_state *state = (beathead_state *)space->machine->driver_data;
8779   offs_t dest_offset = (4 * offset) & 0x7ffff;
88   memcpy(&space->machine->generic.videoram.u32[dest_offset / 4], &space->machine->generic.videoram.u32[vram_latch_offset / 4], 0x400);
80   memcpy(&space->machine->generic.videoram.u32[dest_offset / 4], &space->machine->generic.videoram.u32[state->vram_latch_offset / 4], 0x400);
8981}
9082
9183
r6740r6741
9890
9991WRITE32_HANDLER( beathead_finescroll_w )
10092{
101   UINT32 oldword = finescroll;
102   UINT32 newword = COMBINE_DATA(&finescroll);
93   beathead_state *state = (beathead_state *)space->machine->driver_data;
94   UINT32 oldword = state->finescroll;
95   UINT32 newword = COMBINE_DATA(&state->finescroll);
10396
10497   /* if VBLANK is going off on a scanline other than the last, suspend time */
10598   if ((oldword & 8) && !(newword & 8) && video_screen_get_vpos(space->machine->primary_screen) != 261)
r6740r6741
136129
137130READ32_HANDLER( beathead_hsync_ram_r )
138131{
132   beathead_state *state = (beathead_state *)space->machine->driver_data;
133
139134   /* offset 0 is probably write-only */
140135   if (offset == 0)
141136      logerror("%08X:Unexpected HSYNC RAM read at offset 0\n", cpu_get_previouspc(space->cpu));
142137
143138   /* offset 1 reads the data */
144139   else
145      return hsyncram[hsyncram_offset];
140      return state->hsyncram[state->hsyncram_offset];
146141
147142   return 0;
148143}
149144
150145WRITE32_HANDLER( beathead_hsync_ram_w )
151146{
147   beathead_state *state = (beathead_state *)space->machine->driver_data;
148
152149   /* offset 0 selects the address, and can specify the start address */
153150   if (offset == 0)
154151   {
155      COMBINE_DATA(&hsyncram_offset);
156      if (hsyncram_offset & 0x800)
157         hsyncram_start = hsyncram_offset & 0x7ff;
152      COMBINE_DATA(&state->hsyncram_offset);
153      if (state->hsyncram_offset & 0x800)
154         state->hsyncram_start = state->hsyncram_offset & 0x7ff;
158155   }
159156
160157   /* offset 1 writes the data */
161158   else
162      COMBINE_DATA(&hsyncram[hsyncram_offset]);
159      COMBINE_DATA(&state->hsyncram[state->hsyncram_offset]);
163160}
164161
165162
r6740r6741
183180      UINT16 scanline[336];
184181
185182      /* blanking */
186      if (finescroll & 8)
183      if (state->finescroll & 8)
187184         for (x = cliprect->min_x; x <= cliprect->max_x; x++)
188185            scanline[x] = pen_base;
189186
190187      /* non-blanking */
191188      else
192189      {
193         offs_t scanline_offset = vram_latch_offset + (finescroll & 3);
190         offs_t scanline_offset = state->vram_latch_offset + (state->finescroll & 3);
194191         offs_t src = scanline_offset + cliprect->min_x;
195192
196193         /* unswizzle the scanline first */
src/mame/video/cchasm.c
r6740r6741
66
77#include "driver.h"
88#include "video/vector.h"
9#include "cchasm.h"
9#include "includes/cchasm.h"
1010
1111#define HALT   0
1212#define JUMP   1
src/mame/video/funkyjet.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "deco16ic.h"
8#include "includes/deco16ic.h"
99
1010/******************************************************************************/
1111
src/mame/video/xexex.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
44static int sprite_colorbase;
55static int layer_colorbase[4], layerpri[4];
r6740r6741
1010   cur_alpha = on;
1111}
1212
13static void xexex_sprite_callback(int *code, int *color, int *priority_mask)
13void xexex_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask)
1414{
1515   int pri, c = *color;
1616
r6740r6741
2727   *color = sprite_colorbase | (c & 0x001f);
2828}
2929
30static void xexex_tile_callback(int layer, int *code, int *color, int *flags)
30void xexex_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags)
3131{
3232   *color = layer_colorbase[layer] | (*color>>2 & 0x0f);
3333}
3434
3535VIDEO_START( xexex )
3636{
37   const char * region = "gfx3";
37   const device_config *k056832 = devtag_get_device(machine, "k056832");
3838
3939   assert(video_screen_get_format(machine->primary_screen) == BITMAP_FORMAT_RGB32);
4040
4141   cur_alpha = 0;
4242
43   K053251_vh_start(machine);
44   K054338_vh_start(machine);
45   K053250_vh_start(machine, 1, &region);
46
47   K056832_vh_start(machine, "gfx1", K056832_BPP_4, 1, NULL, xexex_tile_callback, 0);
48   K053247_vh_start(machine, "gfx2", -48, 32, NORMAL_PLANE_ORDER, xexex_sprite_callback);
49
5043   // Xexex has relative plane offsets of -2,2,4,6 vs. -2,0,2,3 in MW and GX.
51   K056832_set_LayerOffset(0, -2, 16);
52   K056832_set_LayerOffset(1,  2, 16);
53   K056832_set_LayerOffset(2,  4, 16);
54   K056832_set_LayerOffset(3,  6, 16);
55
56   K053250_set_LayerOffset(0, -5,-16);
57
58   K054338_invert_alpha(0);
44   k056832_set_layer_offs(k056832, 0, -2, 16);
45   k056832_set_layer_offs(k056832, 1,  2, 16);
46   k056832_set_layer_offs(k056832, 2,  4, 16);
47   k056832_set_layer_offs(k056832, 3,  6, 16);
5948}
6049
6150/* useful function to sort the four tile layers by priority order */
r6740r6741
8170VIDEO_UPDATE( xexex )
8271{
8372   static const int K053251_CI[4] = { K053251_CI1, K053251_CI2, K053251_CI3, K053251_CI4 };
73   const device_config *k056832 = devtag_get_device(screen->machine, "k056832");
74   const device_config *k053246 = devtag_get_device(screen->machine, "k053246");
75   const device_config *k053251 = devtag_get_device(screen->machine, "k053251");
76   const device_config *k053250 = devtag_get_device(screen->machine, "k053250");
77   const device_config *k054338 = devtag_get_device(screen->machine, "k054338");
8478   int layer[4];
8579   int bg_colorbase, new_colorbase, plane, alpha;
8680
87   sprite_colorbase   = K053251_get_palette_index(K053251_CI0);
88   bg_colorbase       = K053251_get_palette_index(K053251_CI1);
81   sprite_colorbase   = k053251_get_palette_index(k053251, K053251_CI0);
82   bg_colorbase       = k053251_get_palette_index(k053251, K053251_CI1);
8983   layer_colorbase[0] = 0x70;
9084
91   for (plane=1; plane<4; plane++)
85   for (plane = 1; plane < 4; plane++)
9286   {
93      new_colorbase = K053251_get_palette_index(K053251_CI[plane]);
87      new_colorbase = k053251_get_palette_index(k053251, K053251_CI[plane]);
9488      if (layer_colorbase[plane] != new_colorbase)
9589      {
9690         layer_colorbase[plane] = new_colorbase;
97         K056832_mark_plane_dirty(plane);
91         k056832_mark_plane_dirty(k056832, plane);
9892      }
9993   }
10094
10195   layer[0] = 1;
102   layerpri[0] = K053251_get_priority(K053251_CI2);
96   layerpri[0] = k053251_get_priority(k053251, K053251_CI2);
10397   layer[1] = 2;
104   layerpri[1] = K053251_get_priority(K053251_CI3);
98   layerpri[1] = k053251_get_priority(k053251, K053251_CI3);
10599   layer[2] = 3;
106   layerpri[2] = K053251_get_priority(K053251_CI4);
100   layerpri[2] = k053251_get_priority(k053251, K053251_CI4);
107101   layer[3] = -1;
108   layerpri[3] = K053251_get_priority(K053251_CI1);
102   layerpri[3] = k053251_get_priority(k053251, K053251_CI1);
109103
110104   sortlayers(layer, layerpri);
111105
112   K054338_update_all_shadows(screen->machine, 0);
113   K054338_fill_backcolor(screen->machine, bitmap, 0);
106   k054338_update_all_shadows(k054338, 0);
107   k054338_fill_backcolor(k054338, bitmap, 0);
114108
115109   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
116110
r6740r6741
118112   {
119113      if (layer[plane] < 0)
120114      {
121         K053250_draw(screen->machine, bitmap, cliprect, 0, bg_colorbase, 0, 1<<plane);
115         k053250_draw(k053250, bitmap, cliprect, bg_colorbase, 0, 1 << plane);
122116      }
123117      else if (!cur_alpha || layer[plane] != 1)
124118      {
125         K056832_tilemap_draw(screen->machine, bitmap, cliprect, layer[plane], 0, 1<<plane);
119         k056832_tilemap_draw(k056832, bitmap, cliprect, layer[plane], 0, 1 << plane);
126120      }
127121   }
128122
129   K053247_sprites_draw(screen->machine, bitmap, cliprect);
123   k053247_sprites_draw(k053246, bitmap, cliprect);
130124
131125   if (cur_alpha)
132126   {
133      alpha = K054338_set_alpha_level(1);
127      alpha = k054338_set_alpha_level(k054338, 1);
134128
135129      if (alpha > 0)
136130      {
137         K056832_tilemap_draw(screen->machine, bitmap, cliprect, 1, TILEMAP_DRAW_ALPHA(alpha), 0);
131         k056832_tilemap_draw(k056832, bitmap, cliprect, 1, TILEMAP_DRAW_ALPHA(alpha), 0);
138132      }
139133   }
140134
141   K056832_tilemap_draw(screen->machine, bitmap, cliprect, 0, 0, 0);
135   k056832_tilemap_draw(k056832, bitmap, cliprect, 0, 0, 0);
142136   return 0;
143137}
src/mame/video/qix.c
r6740r6741
88
99#include "driver.h"
1010#include "video/mc6845.h"
11#include "qix.h"
11#include "includes/qix.h"
1212#include "cpu/m6809/m6809.h"
1313
1414
src/mame/video/battlex.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "battlex.h"
8#include "includes/battlex.h"
99
1010PALETTE_INIT( battlex )
1111{
src/mame/video/epos.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "epos.h"
8#include "includes/epos.h"
99
1010/***************************************************************************
1111
src/mame/video/snes.c
r6740r6741
13571357
13581358#define SNES_DBG_HORZ_POS 545
13591359
1360   printf( "snes_dbg_video: %d\n", curline );
13611360   /* Check if the user has enabled or disabled stuff */
13621361   if( curline == 0 )
13631362   {
r6740r6741
13671366      if( !debug_options.input_count-- )
13681367      {
13691368         UINT8 toggles = input_port_read_safe(machine, "DEBUG2", 0);
1370         printf( "Checking\n" );
1371         if(toggles)
1372         {
1373            printf( "%02x\n", toggles );
1374         }
13751369         if( toggles & 0x1 )
13761370            debug_options.bg_disabled[0] = !debug_options.bg_disabled[0];
13771371         if( toggles & 0x2 )
src/mame/video/cinemat.c
r6740r6741
77#include "driver.h"
88#include "video/vector.h"
99#include "cpu/ccpu/ccpu.h"
10#include "cinemat.h"
10#include "includes/cinemat.h"
1111
1212
1313/*************************************
src/mame/video/gaelco.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "gaelco.h"
10#include "includes/gaelco.h"
1111
1212/***************************************************************************
1313
src/mame/video/wecleman.c
r6740r6741
88***************************************************************************/
99
1010#include "driver.h"
11#include "video/konamiic.h"
11#include "video/konicdev.h"
1212
1313#define BMP_PAD      8
1414#define BLEND_STEPS   16
r6740r6741
983983}
984984
985985//  Callbacks for the K051316
986#define ZOOMROM0_MEM_REGION "gfx2"
987#define ZOOMROM1_MEM_REGION "gfx3"
988986
989static void zoom_callback_0(int *code,int *color,int *flags)
987void hotchase_zoom_callback_0(running_machine *machine, int *code,int *color,int *flags)
990988{
991989   *code |= (*color & 0x03) << 8;
992990   *color = (*color & 0xfc) >> 2;
993991}
994992
995static void zoom_callback_1(int *code,int *color,int *flags)
993void hotchase_zoom_callback_1(running_machine *machine, int *code,int *color,int *flags)
996994{
997995   *code |= (*color & 0x01) << 8;
998996   *color = ((*color & 0x3f) << 1) | ((*code & 0x80) >> 7);
r6740r6741
10251023   spr_ptr_list = (struct sprite **)buffer;
10261024
10271025   sprite_list = auto_alloc_array_clear(machine, struct sprite, NUM_SPRITES);
1028
1029   K051316_vh_start_0(machine,ZOOMROM0_MEM_REGION,4,FALSE,0,zoom_callback_0);
1030   K051316_vh_start_1(machine,ZOOMROM1_MEM_REGION,4,FALSE,0,zoom_callback_1);
1031
1032   K051316_wraparound_enable(0,1);
1033//  K051316_wraparound_enable(1,1);
1034   K051316_set_offset(0, -0xB0/2, -16);
1035   K051316_set_offset(1, -0xB0/2, -16);
10361026}
10371027
10381028
r6740r6741
11351125
11361126VIDEO_UPDATE( hotchase )
11371127{
1128   const device_config *k051316_1 = devtag_get_device(screen->machine, "k051316_1");
1129   const device_config *k051316_2 = devtag_get_device(screen->machine, "k051316_2");
11381130   int video_on;
11391131
11401132   video_on = wecleman_irqctrl & 0x40;
r6740r6741
11461138   bitmap_fill(bitmap, cliprect, black_pen);
11471139
11481140   /* Draw the background */
1149   if (video_on) K051316_zoom_draw_0(bitmap,cliprect, 0, 0);
1141   if (video_on)
1142      k051316_zoom_draw(k051316_1, bitmap, cliprect, 0, 0);
11501143
11511144   /* Draw the road */
1152   if (video_on) hotchase_draw_road(screen->machine, bitmap, cliprect);
1145   if (video_on)
1146      hotchase_draw_road(screen->machine, bitmap, cliprect);
11531147
11541148   /* Draw the sprites */
1155   if (video_on) sprite_draw(bitmap,cliprect);
1149   if (video_on)
1150      sprite_draw(bitmap,cliprect);
11561151
11571152   /* Draw the foreground (text) */
1158   if (video_on) K051316_zoom_draw_1(bitmap,cliprect, 0, 0);
1153   if (video_on)
1154      k051316_zoom_draw(k051316_2, bitmap, cliprect, 0, 0);
11591155   return 0;
11601156}
src/mame/video/tankbust.c
r6740r6741
88*   variables
99*/
1010
11UINT8 * tankbust_videoram;
12UINT8 * tankbust_colorram;
1113static tilemap *bg_tilemap;
14
1215static tilemap *txt_tilemap;
1316UINT8 * tankbust_txtram;
1417
r6740r6741
3437
3538static TILE_GET_INFO( get_bg_tile_info )
3639{
37   int code = machine->generic.videoram.u8[tile_index];
38   int attr = machine->generic.colorram.u8[tile_index];
40   int code = tankbust_videoram[tile_index];
41   int attr = tankbust_colorram[tile_index];
3942
4043   int color = ((attr>>4) & 0x07);
4144
r6740r6741
101104
102105WRITE8_HANDLER( tankbust_background_videoram_w )
103106{
104   space->machine->generic.videoram.u8[offset] = data;
107   tankbust_videoram[offset] = data;
105108   tilemap_mark_tile_dirty(bg_tilemap, offset);
106109}
107110READ8_HANDLER( tankbust_background_videoram_r )
108111{
109   return space->machine->generic.videoram.u8[offset];
112   return tankbust_videoram[offset];
110113}
111114
112115WRITE8_HANDLER( tankbust_background_colorram_w )
113116{
114   space->machine->generic.colorram.u8[offset] = data;
117   tankbust_colorram[offset] = data;
115118   tilemap_mark_tile_dirty(bg_tilemap, offset);
116119}
117120READ8_HANDLER( tankbust_background_colorram_r )
118121{
119   return space->machine->generic.colorram.u8[offset];
122   return tankbust_colorram[offset];
120123}
121124
122125WRITE8_HANDLER( tankbust_txtram_w )
r6740r6741
235238
236239   for (i=0; i<0x800; i++)
237240   {
238      int tile_attrib = screen->machine->generic.colorram.u8[i];
241      int tile_attrib = tankbust_colorram[i];
239242
240243      if ( (tile_attrib&8) || (tile_attrib&0x80) )
241244      {
src/mame/video/bankp.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "bankp.h"
10#include "includes/bankp.h"
1111
1212
1313/***************************************************************************
src/mame/video/pastelg.c
r6740r6741
77******************************************************************************/
88
99#include "driver.h"
10#include "nb1413m3.h"
10#include "includes/nb1413m3.h"
1111
1212
1313static int blitter_destx, blitter_desty;
src/mame/video/funkybee.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "funkybee.h"
10#include "includes/funkybee.h"
1111
1212PALETTE_INIT( funkybee )
1313{
src/mame/video/btoads.c
r6740r6741
99#include "driver.h"
1010#include "cpu/tms34010/tms34010.h"
1111#include "video/tlc34076.h"
12#include "btoads.h"
12#include "includes/btoads.h"
1313
1414
1515#define BT_DEBUG 0
src/mame/video/starfire.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "starfire.h"
8#include "includes/starfire.h"
99
1010
1111#define   NUM_PENS   (0x40)
src/mame/video/freekick.c
r6740r6741
11/* Free Kick Video Hardware */
22
33#include "driver.h"
4#include "freekick.h"
4#include "includes/freekick.h"
55
66
77static TILE_GET_INFO( get_freek_tile_info )
src/mame/video/cischeat.c
r6740r6741
5454***************************************************************************/
5555
5656#include "driver.h"
57#include "megasys1.h"
57#include "includes/megasys1.h"
5858#include "includes/cischeat.h"
5959
6060/* Variables only used here: */
src/mame/video/namcos22.c
r6740r6741
3636#include "driver.h"
3737#include "eminline.h"
3838#include "video/rgbutil.h"
39#include "namcos22.h"
39#include "includes/namcos22.h"
4040#include "video/poly.h"
4141
4242// uncomment this line to render everything as quads
r6740r6741
837837   }
838838   else
839839   {
840#define SCENE_NODE_POOL_SIZE 64
841      struct SceneNode *pSceneNodePool = auto_alloc_array(machine, struct SceneNode, SCENE_NODE_POOL_SIZE);
842      {
843         int i;
844         for( i=0; i<SCENE_NODE_POOL_SIZE; i++ )
845         {
846            FreeSceneNode( &pSceneNodePool[i] );
847         }
848         return MallocSceneNode(machine);
849      }
840        node = alloc_or_die(struct SceneNode);
850841   }
851842   memset( node, 0, sizeof(*node) );
852843   return node;
r6740r6741
22082199
22092200static void namcos22_exit(running_machine *machine)
22102201{
2202   while (mpFreeSceneNode != NULL)
2203   {
2204      struct SceneNode *node = mpFreeSceneNode;
2205      mpFreeSceneNode = node->nextInBucket;
2206      free(node);
2207   }
2208
22112209   poly_free(poly);
22122210}
22132211
src/mame/video/centiped.c
r6740r6741
55*************************************************************************/
66
77#include "driver.h"
8#include "centiped.h"
8#include "includes/centiped.h"
99
1010
1111static tilemap *bg_tilemap;
src/mame/video/atarisy1.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "atarisy1.h"
8#include "includes/atarisy1.h"
99
1010
1111
r6740r6741
8282static void update_timers(running_machine *machine, int scanline);
8383static void decode_gfx(running_machine *machine, UINT16 *pflookup, UINT16 *molookup);
8484static int get_bank(running_machine *machine, UINT8 prom1, UINT8 prom2, int bpp);
85static TIMER_CALLBACK( int3_callback );
86static TIMER_CALLBACK( int3off_callback );
87static TIMER_CALLBACK( reset_yscroll_callback );
8885
8986
9087
r6740r6741
199196   /* reset the statics */
200197   atarimo_set_yscroll(0, 256);
201198   state->next_timer_scanline = -1;
202   state->scanline_timer = timer_alloc(machine, int3_callback, NULL);
203   state->int3off_timer = timer_alloc(machine, int3off_callback, NULL);
204   state->yscroll_reset_timer = timer_alloc(machine, reset_yscroll_callback, NULL);
199   state->scanline_timer = devtag_get_device(machine, "scan_timer");
200   state->int3off_timer = devtag_get_device(machine, "int3off_timer");
201   state->yscroll_reset_timer = devtag_get_device(machine, "yreset_timer");
202
203   /* save state */
204   state_save_register_global(machine, state->playfield_tile_bank);
205   state_save_register_global(machine, state->playfield_priority_pens);
206   state_save_register_global(machine, state->next_timer_scanline);
205207}
206208
207209
r6740r6741
304306 *
305307 *************************************/
306308
307static TIMER_CALLBACK( reset_yscroll_callback )
309TIMER_DEVICE_CALLBACK( atarisy1_reset_yscroll_callback )
308310{
309   atarisy1_state *state = (atarisy1_state *)machine->driver_data;
311   atarisy1_state *state = (atarisy1_state *)timer->machine->driver_data;
310312   tilemap_set_scrolly(state->atarigen.playfield_tilemap, 0, param);
311313}
312314
r6740r6741
332334
333335   /* but since we've adjusted it, we must reset it to the normal value
334336       once we hit scanline 0 again */
335   timer_adjust_oneshot(state->yscroll_reset_timer, video_screen_get_time_until_pos(space->machine->primary_screen, 0, 0), newscroll);
337   timer_device_adjust_oneshot(state->yscroll_reset_timer, video_screen_get_time_until_pos(space->machine->primary_screen, 0, 0), newscroll);
336338
337339   /* update the data */
338340   *state->atarigen.yscroll = newscroll;
r6740r6741
385387 *
386388 *************************************/
387389
388static TIMER_CALLBACK( int3off_callback )
390TIMER_DEVICE_CALLBACK( atarisy1_int3off_callback )
389391{
390   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
392   const address_space *space = cputag_get_address_space(timer->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
391393
392394   /* clear the state */
393395   atarigen_scanline_int_ack_w(space, 0, 0, 0xffff);
394396}
395397
396398
397static TIMER_CALLBACK( int3_callback )
399TIMER_DEVICE_CALLBACK( atarisy1_int3_callback )
398400{
399   atarisy1_state *state = (atarisy1_state *)machine->driver_data;
401   atarisy1_state *state = (atarisy1_state *)timer->machine->driver_data;
400402   int scanline = param;
401403
402404   /* update the state */
403   atarigen_scanline_int_gen(cputag_get_cpu(machine, "maincpu"));
405   atarigen_scanline_int_gen(cputag_get_cpu(timer->machine, "maincpu"));
404406
405407   /* set a timer to turn it off */
406   timer_adjust_oneshot(state->int3off_timer, video_screen_get_scan_period(machine->primary_screen), 0);
408   timer_device_adjust_oneshot(state->int3off_timer, video_screen_get_scan_period(timer->machine->primary_screen), 0);
407409
408410   /* determine the time of the next one */
409411   state->next_timer_scanline = -1;
410   update_timers(machine, scanline);
412   update_timers(timer->machine, scanline);
411413}
412414
413415
r6740r6741
484486
485487      /* set a new one */
486488      if (best != -1)
487         timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, best, 0), best);
489         timer_device_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, best, 0), best);
488490      else
489         timer_adjust_oneshot(state->scanline_timer, attotime_never, 0);
491         timer_device_adjust_oneshot(state->scanline_timer, attotime_never, 0);
490492   }
491493}
492494
src/mame/video/ssv.c
r6740r6741
136136***************************************************************************/
137137
138138#include "driver.h"
139#include "seta.h"
139#include "includes/seta.h"
140140#ifdef MAME_DEBUG
141141#include "ui.h"
142142#endif
src/mame/video/atarig42.c
r6740r6741
2121
2222#include "driver.h"
2323#include "machine/atarigen.h"
24#include "atarig42.h"
24#include "includes/atarig42.h"
2525
2626
2727
2828/*************************************
2929 *
30 *  Statics
31 *
32 *************************************/
33
34
35
36/*************************************
37 *
3830 *  Tilemap callbacks
3931 *
4032 *************************************/
r6740r6741
116108   /* initialize the alphanumerics */
117109   state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows,  8,8, 64,32);
118110   tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0);
111
112   /* save states */
113   state_save_register_global(machine, state->current_control);
114   state_save_register_global(machine, state->playfield_tile_bank);
115   state_save_register_global(machine, state->playfield_color_bank);
116   state_save_register_global(machine, state->playfield_xscroll);
117   state_save_register_global(machine, state->playfield_yscroll);
119118}
120119
121120
src/mame/video/tceptor.c
r6740r6741
44 */
55
66#include "driver.h"
7#include "namcoic.h"
7#include "includes/namcoic.h"
88
99#define TX_TILE_OFFSET_CENTER   (32 * 2)
1010#define TX_TILE_OFFSET_RIGHT   (32 * 0 + 2)
src/mame/video/vindictr.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "vindictr.h"
9#include "thunderj.h"
8#include "includes/vindictr.h"
9#include "includes/thunderj.h"
1010
1111
1212
r6740r6741
9393   /* initialize the alphanumerics */
9494   state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows,  8,8, 64,32);
9595   tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0);
96
97   /* save states */
98   state_save_register_global(machine, state->playfield_tile_bank);
99   state_save_register_global(machine, state->playfield_xscroll);
100   state_save_register_global(machine, state->playfield_yscroll);
96101}
97102
98103
src/mame/video/cop01.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "cop01.h"
10#include "includes/cop01.h"
1111
1212
1313PALETTE_INIT( cop01 )
src/mame/video/metro.c
r6740r6741
5252***************************************************************************/
5353
5454#include "driver.h"
55#include "video/konamiic.h"
55#include "video/konicdev.h"
5656
5757/* Variables that driver has access to: */
5858
r6740r6741
419419   tilemap_16x16[1] = NULL;
420420   tilemap_16x16[2] = NULL;
421421
422    tilemap_map_pen_to_layer(bg_tilemap[0], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
423    tilemap_map_pen_to_layer(bg_tilemap[0], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
422   tilemap_map_pen_to_layer(bg_tilemap[0], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
423   tilemap_map_pen_to_layer(bg_tilemap[0], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
424424
425    tilemap_map_pen_to_layer(bg_tilemap[1], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
426    tilemap_map_pen_to_layer(bg_tilemap[1], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
425   tilemap_map_pen_to_layer(bg_tilemap[1], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
426   tilemap_map_pen_to_layer(bg_tilemap[1], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
427427
428    tilemap_map_pen_to_layer(bg_tilemap[2], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
429    tilemap_map_pen_to_layer(bg_tilemap[2], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
428   tilemap_map_pen_to_layer(bg_tilemap[2], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
429   tilemap_map_pen_to_layer(bg_tilemap[2], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
430430
431431}
432432
r6740r6741
448448   tilemap_16x16[1] = NULL;
449449   tilemap_16x16[2] = NULL;
450450
451    tilemap_map_pen_to_layer(bg_tilemap[0], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
452    tilemap_map_pen_to_layer(bg_tilemap[0], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
451   tilemap_map_pen_to_layer(bg_tilemap[0], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
452   tilemap_map_pen_to_layer(bg_tilemap[0], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
453453
454    tilemap_map_pen_to_layer(bg_tilemap[1], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
455    tilemap_map_pen_to_layer(bg_tilemap[1], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
454   tilemap_map_pen_to_layer(bg_tilemap[1], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
455   tilemap_map_pen_to_layer(bg_tilemap[1], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
456456
457    tilemap_map_pen_to_layer(bg_tilemap[2], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
458    tilemap_map_pen_to_layer(bg_tilemap[2], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
457   tilemap_map_pen_to_layer(bg_tilemap[2], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
458   tilemap_map_pen_to_layer(bg_tilemap[2], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
459459
460460   tilemap_set_scrolldx(bg_tilemap[0], -2, 2);
461461   tilemap_set_scrolldx(bg_tilemap[1], -2, 2);
r6740r6741
480480   tilemap_16x16[1] = tilemap_create(machine, get_tile_info_1_16x16_8bit,tilemap_scan_rows,16,16,WIN_NX,WIN_NY);
481481   tilemap_16x16[2] = tilemap_create(machine, get_tile_info_2_16x16_8bit,tilemap_scan_rows,16,16,WIN_NX,WIN_NY);
482482
483    tilemap_map_pen_to_layer(bg_tilemap[0], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
484    tilemap_map_pen_to_layer(bg_tilemap[0], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
483   tilemap_map_pen_to_layer(bg_tilemap[0], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
484   tilemap_map_pen_to_layer(bg_tilemap[0], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
485485
486    tilemap_map_pen_to_layer(bg_tilemap[1], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
487    tilemap_map_pen_to_layer(bg_tilemap[1], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
486   tilemap_map_pen_to_layer(bg_tilemap[1], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
487   tilemap_map_pen_to_layer(bg_tilemap[1], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
488488
489    tilemap_map_pen_to_layer(bg_tilemap[2], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
490    tilemap_map_pen_to_layer(bg_tilemap[2], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
489   tilemap_map_pen_to_layer(bg_tilemap[2], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
490   tilemap_map_pen_to_layer(bg_tilemap[2], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
491491
492492
493    tilemap_map_pen_to_layer(tilemap_16x16[0], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
494    tilemap_map_pen_to_layer(tilemap_16x16[0], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
493   tilemap_map_pen_to_layer(tilemap_16x16[0], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
494   tilemap_map_pen_to_layer(tilemap_16x16[0], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
495495
496    tilemap_map_pen_to_layer(tilemap_16x16[1], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
497    tilemap_map_pen_to_layer(tilemap_16x16[1], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
496   tilemap_map_pen_to_layer(tilemap_16x16[1], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
497   tilemap_map_pen_to_layer(tilemap_16x16[1], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
498498
499    tilemap_map_pen_to_layer(tilemap_16x16[2], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
500    tilemap_map_pen_to_layer(tilemap_16x16[2], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
499   tilemap_map_pen_to_layer(tilemap_16x16[2], 0, 15,  TILEMAP_PIXEL_TRANSPARENT);
500   tilemap_map_pen_to_layer(tilemap_16x16[2], 1, 255, TILEMAP_PIXEL_TRANSPARENT);
501501
502502}
503503
r6740r6741
507507
508508   has_zoom = 1;
509509
510   metro_K053936_tilemap = tilemap_create(machine, metro_K053936_get_tile_info, tilemap_scan_rows,
511                         8,8, 256, 512 );
510   metro_K053936_tilemap = tilemap_create(machine, metro_K053936_get_tile_info, tilemap_scan_rows, 8,8, 256, 512 );
512511
513   K053936_wraparound_enable(0, 0);
514   K053936_set_offset(0, -69, -21);
515
516512   tilemap_set_scrolldx(bg_tilemap[0], 8, -8);
517513   tilemap_set_scrolldx(bg_tilemap[1], 8, -8);
518514   tilemap_set_scrolldx(bg_tilemap[2], 8, -8);
r6740r6741
524520
525521   has_zoom = 1;
526522
527   metro_K053936_tilemap = tilemap_create(machine, metro_K053936_gstrik2_get_tile_info, tilemap_scan_gstrik2,
528                         16,16, 128, 256 );
523   metro_K053936_tilemap = tilemap_create(machine, metro_K053936_gstrik2_get_tile_info, tilemap_scan_gstrik2, 16,16, 128, 256 );
529524
530   K053936_wraparound_enable(0, 0);
531   K053936_set_offset(0, -69, -19);
532
533525   tilemap_set_scrolldx(bg_tilemap[0], 8, -8);
534526   tilemap_set_scrolldx(bg_tilemap[1], 0, 0);
535527   tilemap_set_scrolldx(bg_tilemap[2], 8, -8);
r6740r6741
856848
857849VIDEO_UPDATE( metro )
858850{
851   const device_config *k053936 = devtag_get_device(screen->machine, "k053936");
859852   int i,pri,layers_ctrl = -1;
860853   UINT16 screenctrl = *metro_screenctrl;
861854
r6740r6741
941934}
942935#endif
943936
944   if (has_zoom) K053936_0_zoom_draw(bitmap,cliprect,metro_K053936_tilemap,0,0, 1);
937   if (has_zoom)
938      k053936_zoom_draw(k053936, bitmap, cliprect, metro_K053936_tilemap, 0, 0, 1);
945939
946
947   for (pri=3; pri>=0; pri--)
940   for (pri = 3; pri >= 0; pri--)
948941      draw_layers(screen->machine, bitmap,cliprect,pri,layers_ctrl);
949942
950943   if (layers_ctrl & 0x08)
src/mame/video/angelkds.c
r6740r6741
77*/
88
99#include "driver.h"
10#include "angelkds.h"
10#include "includes/angelkds.h"
1111
1212
1313/*** Text Layer Tilemap
src/mame/video/circusc.c
r6740r6741
88
99#include "driver.h"
1010#include "video/resnet.h"
11#include "circusc.h"
11#include "includes/circusc.h"
1212
1313
1414/***************************************************************************
src/mame/video/mikie.c
r6740r6741
1111
1212static int palettebank;
1313
14UINT8 *mikie_videoram;
15UINT8 *mikie_colorram;
1416static tilemap *bg_tilemap;
1517
1618/***************************************************************************
r6740r6741
9294
9395WRITE8_HANDLER( mikie_videoram_w )
9496{
95   space->machine->generic.videoram.u8[offset] = data;
97   mikie_videoram[offset] = data;
9698   tilemap_mark_tile_dirty(bg_tilemap, offset);
9799}
98100
99101WRITE8_HANDLER( mikie_colorram_w )
100102{
101   space->machine->generic.colorram.u8[offset] = data;
103   mikie_colorram[offset] = data;
102104   tilemap_mark_tile_dirty(bg_tilemap, offset);
103105}
104106
r6740r6741
122124
123125static TILE_GET_INFO( get_bg_tile_info )
124126{
125   int code = machine->generic.videoram.u8[tile_index] + ((machine->generic.colorram.u8[tile_index] & 0x20) << 3);
126   int color = (machine->generic.colorram.u8[tile_index] & 0x0f) + 16 * palettebank;
127   int flags = ((machine->generic.colorram.u8[tile_index] & 0x40) ? TILE_FLIPX : 0) | ((machine->generic.colorram.u8[tile_index] & 0x80) ? TILE_FLIPY : 0);
127   int code = mikie_videoram[tile_index] + ((mikie_colorram[tile_index] & 0x20) << 3);
128   int color = (mikie_colorram[tile_index] & 0x0f) + 16 * palettebank;
129   int flags = ((mikie_colorram[tile_index] & 0x40) ? TILE_FLIPX : 0) | ((mikie_colorram[tile_index] & 0x80) ? TILE_FLIPY : 0);
128130
129131   SET_TILE_INFO(0, code, color, flags);
130132}
src/mame/video/midvunit.c
r6740r6741
99#include "cpu/adsp2100/adsp2100.h"
1010#include "audio/williams.h"
1111#include "video/poly.h"
12#include "midvunit.h"
12#include "includes/midvunit.h"
1313
1414
1515#define WATCH_RENDER      (0)
src/mame/video/surpratk.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
44static int layer_colorbase[3],sprite_colorbase,bg_colorbase;
55static int layerpri[3];
r6740r6741
1111
1212***************************************************************************/
1313
14static void tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
14void surpratk_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
1515{
1616   *flags = (*color & 0x80) ? TILE_FLIPX : 0;
1717   *code |= ((*color & 0x03) << 8) | ((*color & 0x10) << 6) | ((*color & 0x0c) << 9) | (bank << 13);
r6740r6741
2424
2525***************************************************************************/
2626
27static void sprite_callback(int *code,int *color,int *priority_mask)
27void surpratk_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask)
2828{
2929   int pri = 0x20 | ((*color & 0x60) >> 2);
3030   if (pri <= layerpri[2])                        *priority_mask = 0;
r6740r6741
4242
4343***************************************************************************/
4444
45VIDEO_START( surpratk )
46{
47   K053251_vh_start(machine);
48
49   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tile_callback);
50   K053245_vh_start(machine,0,"gfx2",NORMAL_PLANE_ORDER,sprite_callback);
51}
52
5345/* useful function to sort the three tile layers by priority order */
5446static void sortlayers(int *layer,int *pri)
5547{
r6740r6741
6860
6961VIDEO_UPDATE( surpratk )
7062{
63   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
64   const device_config *k053244 = devtag_get_device(screen->machine, "k053244");
65   const device_config *k053251 = devtag_get_device(screen->machine, "k053251");
7166   int layer[3];
7267
7368
74   bg_colorbase       = K053251_get_palette_index(K053251_CI0);
75   sprite_colorbase   = K053251_get_palette_index(K053251_CI1);
76   layer_colorbase[0] = K053251_get_palette_index(K053251_CI2);
77   layer_colorbase[1] = K053251_get_palette_index(K053251_CI4);
78   layer_colorbase[2] = K053251_get_palette_index(K053251_CI3);
69   bg_colorbase       = k053251_get_palette_index(k053251, K053251_CI0);
70   sprite_colorbase   = k053251_get_palette_index(k053251, K053251_CI1);
71   layer_colorbase[0] = k053251_get_palette_index(k053251, K053251_CI2);
72   layer_colorbase[1] = k053251_get_palette_index(k053251, K053251_CI4);
73   layer_colorbase[2] = k053251_get_palette_index(k053251, K053251_CI3);
7974
80   K052109_tilemap_update();
75   k052109_tilemap_update(k052109);
8176
8277   layer[0] = 0;
83   layerpri[0] = K053251_get_priority(K053251_CI2);
78   layerpri[0] = k053251_get_priority(k053251, K053251_CI2);
8479   layer[1] = 1;
85   layerpri[1] = K053251_get_priority(K053251_CI4);
80   layerpri[1] = k053251_get_priority(k053251, K053251_CI4);
8681   layer[2] = 2;
87   layerpri[2] = K053251_get_priority(K053251_CI3);
82   layerpri[2] = k053251_get_priority(k053251, K053251_CI3);
8883
89   sortlayers(layer,layerpri);
84   sortlayers(layer, layerpri);
9085
91   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
92   bitmap_fill(bitmap,cliprect,16 * bg_colorbase);
93   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[0]],0,1);
94   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[1]],0,2);
95   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[2]],0,4);
86   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
87   bitmap_fill(bitmap, cliprect, 16 * bg_colorbase);
88   k052109_tilemap_draw(k052109, bitmap, cliprect, layer[0], 0, 1);
89   k052109_tilemap_draw(k052109, bitmap, cliprect, layer[1], 0, 2);
90   k052109_tilemap_draw(k052109, bitmap, cliprect, layer[2], 0, 4);
9691
97   K053245_sprites_draw(screen->machine,0,bitmap,cliprect);
92   k053245_sprites_draw(k053244, bitmap, cliprect);
9893   return 0;
9994}
src/mame/video/tagteam.c
r6740r6741
1010
1111static int palettebank;
1212
13UINT8 *tagteam_videoram;
14UINT8 *tagteam_colorram;
1315static tilemap *bg_tilemap;
1416
1517PALETTE_INIT( tagteam )
r6740r6741
4446
4547WRITE8_HANDLER( tagteam_videoram_w )
4648{
47   space->machine->generic.videoram.u8[offset] = data;
49   tagteam_videoram[offset] = data;
4850   tilemap_mark_tile_dirty(bg_tilemap, offset);
4951}
5052
5153WRITE8_HANDLER( tagteam_colorram_w )
5254{
53   space->machine->generic.colorram.u8[offset] = data;
55   tagteam_colorram[offset] = data;
5456   tilemap_mark_tile_dirty(bg_tilemap, offset);
5557}
5658
r6740r6741
6365   y = offset % 32;
6466   offset = 32 * y + x;
6567
66   return space->machine->generic.videoram.u8[offset];
68   return tagteam_videoram[offset];
6769}
6870
6971READ8_HANDLER( tagteam_mirrorcolorram_r )
r6740r6741
7577   y = offset % 32;
7678   offset = 32 * y + x;
7779
78   return space->machine->generic.colorram.u8[offset];
80   return tagteam_colorram[offset];
7981}
8082
8183WRITE8_HANDLER( tagteam_mirrorvideoram_w )
r6740r6741
121123
122124static TILE_GET_INFO( get_bg_tile_info )
123125{
124   int code = machine->generic.videoram.u8[tile_index] + 256 * machine->generic.colorram.u8[tile_index];
126   int code = tagteam_videoram[tile_index] + 256 * tagteam_colorram[tile_index];
125127   int color = palettebank * 2; // GUESS
126128
127129   SET_TILE_INFO(0, code, color, 0);
r6740r6741
139141
140142   for (offs = 0; offs < 0x20; offs += 4)
141143   {
142      int spritebank = (machine->generic.videoram.u8[offs] & 0x30) << 4;
143      int code = machine->generic.videoram.u8[offs + 1] + 256 * spritebank;
144      int spritebank = (tagteam_videoram[offs] & 0x30) << 4;
145      int code = tagteam_videoram[offs + 1] + 256 * spritebank;
144146      int color = 1 + 2 * palettebank; // GUESS
145      int flipx = machine->generic.videoram.u8[offs] & 0x04;
146      int flipy = machine->generic.videoram.u8[offs] & 0x02;
147      int sx = 240 - machine->generic.videoram.u8[offs + 3];
148      int sy = 240 - machine->generic.videoram.u8[offs + 2];
147      int flipx = tagteam_videoram[offs] & 0x04;
148      int flipy = tagteam_videoram[offs] & 0x02;
149      int sx = 240 - tagteam_videoram[offs + 3];
150      int sy = 240 - tagteam_videoram[offs + 2];
149151
150      if (!(machine->generic.videoram.u8[offs] & 0x01)) continue;
152      if (!(tagteam_videoram[offs] & 0x01)) continue;
151153
152154      if (flip_screen_get(machine))
153155      {
r6740r6741
165167
166168      /* Wrap around */
167169
168      code = machine->generic.videoram.u8[offs + 0x20] + 256 * spritebank;
170      code = tagteam_videoram[offs + 0x20] + 256 * spritebank;
169171      color = palettebank;
170172      sy += (flip_screen_get(machine) ? -256 : 256);
171173
src/mame/video/bagman.c
r6740r6741
1313
1414UINT8 *bagman_video_enable;
1515
16UINT8 *bagman_videoram;
17UINT8 *bagman_colorram;
1618static tilemap *bg_tilemap;
1719
1820
1921WRITE8_HANDLER( bagman_videoram_w )
2022{
21   space->machine->generic.videoram.u8[offset] = data;
23   bagman_videoram[offset] = data;
2224   tilemap_mark_tile_dirty(bg_tilemap, offset);
2325}
2426
2527WRITE8_HANDLER( bagman_colorram_w )
2628{
27   space->machine->generic.colorram.u8[offset] = data;
29   bagman_colorram[offset] = data;
2830   tilemap_mark_tile_dirty(bg_tilemap, offset);
2931}
3032
r6740r6741
9597
9698static TILE_GET_INFO( get_bg_tile_info )
9799{
98   int gfxbank = (machine->gfx[2] && (machine->generic.colorram.u8[tile_index] & 0x10)) ? 2 : 0;
99   int code = machine->generic.videoram.u8[tile_index] + 8 * (machine->generic.colorram.u8[tile_index] & 0x20);
100   int color = machine->generic.colorram.u8[tile_index] & 0x0f;
100   int gfxbank = (machine->gfx[2] && (bagman_colorram[tile_index] & 0x10)) ? 2 : 0;
101   int code = bagman_videoram[tile_index] + 8 * (bagman_colorram[tile_index] & 0x20);
102   int color = bagman_colorram[tile_index] & 0x0f;
101103
102104   SET_TILE_INFO(gfxbank, code, color, 0);
103105}
src/mame/video/commando.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "commando.h"
10#include "includes/commando.h"
1111
1212
1313WRITE8_HANDLER( commando_videoram_w )
src/mame/video/atarisy2.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "slapstic.h"
9#include "atarisy2.h"
8#include "includes/slapstic.h"
9#include "includes/atarisy2.h"
1010
1111
1212
src/mame/video/skydiver.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "skydiver.h"
8#include "includes/skydiver.h"
99#include "sound/discrete.h"
1010
1111
src/mame/video/ninjakd2.c
r6740r6741
11#include "driver.h"
2#include "ninjakd2.h"
2#include "includes/ninjakd2.h"
33
44UINT8* ninjakd2_bg_videoram;
55UINT8* ninjakd2_fg_videoram;
src/mame/video/warpwarp.c
r6740r6741
88
99#include "driver.h"
1010#include "video/resnet.h"
11#include "warpwarp.h"
11#include "includes/warpwarp.h"
1212
1313
1414UINT8 *geebee_videoram,*warpwarp_videoram;
src/mame/video/spacefb.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "spacefb.h"
8#include "includes/spacefb.h"
99#include "video/resnet.h"
1010
1111
src/mame/video/cbuster.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "deco16ic.h"
8#include "includes/deco16ic.h"
99
1010static int twocrude_pri;
1111
src/mame/video/nbmj8891.c
r6740r6741
77******************************************************************************/
88
99#include "driver.h"
10#include "nb1413m3.h"
10#include "includes/nb1413m3.h"
1111#include "includes/nbmj8891.h"
1212
1313
src/mame/video/liberate.c
r6740r6741
1212#include "driver.h"
1313#include "cpu/m6502/m6502.h"
1414
15UINT8 *liberate_videoram;
16UINT8 *liberate_colorram;
1517static int background_color, background_disable;
1618static tilemap *background_tilemap, *fix_tilemap;
1719static UINT8 deco16_io_ram[16];
r6740r6741
7072
7173static TILE_GET_INFO( get_fix_tile_info )
7274{
73   UINT8 *videoram = machine->generic.videoram.u8;
74   UINT8 *colorram = machine->generic.colorram.u8;
75   UINT8 *videoram = liberate_videoram;
76   UINT8 *colorram = liberate_colorram;
7577   int tile, color;
7678
7779   tile = videoram[tile_index] + (colorram[tile_index] << 8);
r6740r6741
183185
184186WRITE8_HANDLER( liberate_videoram_w )
185187{
186   space->machine->generic.videoram.u8[offset] = data;
188   liberate_videoram[offset] = data;
187189   tilemap_mark_tile_dirty(fix_tilemap, offset);
188190}
189191
190192WRITE8_HANDLER( liberate_colorram_w )
191193{
192   space->machine->generic.colorram.u8[offset] = data;
194   liberate_colorram[offset] = data;
193195   tilemap_mark_tile_dirty(fix_tilemap, offset);
194196}
195197
r6740r6741
527529
528530   for (offs = 0;offs < 0x400;offs++)
529531   {
530      tile=screen->machine->generic.videoram.u8[offs]+((screen->machine->generic.colorram.u8[offs]&0x3)<<8);
532      tile=liberate_videoram[offs]+((liberate_colorram[offs]&0x3)<<8);
531533
532534      if(deco16_io_ram[0]&0x40) //dynamic ram-based gfxs for Pro Golf
533535         gfx_region = 3;
src/mame/video/turbo.c
r6740r6741
55*************************************************************************/
66
77#include "driver.h"
8#include "turbo.h"
8#include "includes/turbo.h"
99#include "video/resnet.h"
1010
1111
src/mame/video/cvs.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "video/s2636.h"
1110#include "cpu/s2650/s2650.h"
12#include "cvs.h"
11#include "includes/cvs.h"
12#include "video/s2636.h"
1313
1414
1515#define SPRITE_PEN_BASE      (0x820)
1616#define BULLET_STAR_PEN      (0x828)
1717
18#define MAX_STARS           250
1918#define STARS_COLOR_BASE    16
2019
2120
22static bitmap_t *background_bitmap;
23bitmap_t *cvs_collision_background;
24static bitmap_t *scrolled_collision_background;
25
26int cvs_collision_register;
27
28struct star
29{
30   int x,y,code;
31};
32
33
34static struct star stars[MAX_STARS];
35static int    total_stars;
36static int    stars_on;
37static UINT8  scroll_reg;
38static int    stars_scroll;
39
40
4121/******************************************************
4222 * Convert Colour prom to format for Mame Colour Map  *
4323 *                                                    *
r6740r6741
8666}
8767
8868
89static void set_pens(colortable_t *colortable)
69static void set_pens( running_machine *machine )
9070{
71   cvs_state *state = (cvs_state *)machine->driver_data;
9172   int i;
9273
9374   for (i = 0; i < 0x10; i++)
9475   {
95      int r = pal2bit(~cvs_palette_ram[i] >> 0);
96      int g = pal3bit(~cvs_palette_ram[i] >> 2);
97      int b = pal3bit(~cvs_palette_ram[i] >> 5);
76      int r = pal2bit(~state->palette_ram[i] >> 0);
77      int g = pal3bit(~state->palette_ram[i] >> 2);
78      int b = pal3bit(~state->palette_ram[i] >> 5);
9879
99      colortable_palette_set_color(colortable, i, MAKE_RGB(r, g, b));
80      colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b));
10081   }
10182}
10283
r6740r6741
10485
10586WRITE8_HANDLER( cvs_video_fx_w )
10687{
88   cvs_state *state = (cvs_state *)space->machine->driver_data;
89
10790   if (data & 0xce)
10891      logerror("%4x : CVS: Unimplemented CVS video fx = %2x\n",cpu_get_pc(space->cpu), data & 0xce);
10992
110    stars_on = data & 0x01;
93   state->stars_on = data & 0x01;
11194
112    if (data & 0x02)   logerror("           SHADE BRIGHTER TO RIGHT\n");
113    if (data & 0x04)   logerror("           SCREEN ROTATE\n");
114    if (data & 0x08)   logerror("           SHADE BRIGHTER TO LEFT\n");
95   if (data & 0x02)   logerror("           SHADE BRIGHTER TO RIGHT\n");
96   if (data & 0x04)   logerror("           SCREEN ROTATE\n");
97   if (data & 0x08)   logerror("           SHADE BRIGHTER TO LEFT\n");
11598
116    set_led_status(space->machine, 1, data & 0x10);   /* lamp 1 */
117    set_led_status(space->machine, 2, data & 0x20);   /* lamp 2 */
99   set_led_status(space->machine, 1, data & 0x10);   /* lamp 1 */
100   set_led_status(space->machine, 2, data & 0x20);   /* lamp 2 */
118101
119    if (data & 0x40)   logerror("           SHADE BRIGHTER TO BOTTOM\n");
120    if (data & 0x80)   logerror("           SHADE BRIGHTER TO TOP\n");
102   if (data & 0x40)   logerror("           SHADE BRIGHTER TO BOTTOM\n");
103   if (data & 0x80)   logerror("           SHADE BRIGHTER TO TOP\n");
121104}
122105
123106
124107
125108READ8_HANDLER( cvs_collision_r )
126109{
127   return cvs_collision_register;
110   cvs_state *state = (cvs_state *)space->machine->driver_data;
111   return state->collision_register;
128112}
129113
130114READ8_HANDLER( cvs_collision_clear )
131115{
132   cvs_collision_register = 0;
133
116   cvs_state *state = (cvs_state *)space->machine->driver_data;
117   state->collision_register = 0;
134118   return 0;
135119}
136120
137121
138122WRITE8_HANDLER( cvs_scroll_w )
139123{
140   scroll_reg = 255 - data;
124   cvs_state *state = (cvs_state *)space->machine->driver_data;
125   state->scroll_reg = 255 - data;
141126}
142127
143128
144129VIDEO_START( cvs )
145130{
131   cvs_state *state = (cvs_state *)machine->driver_data;
146132   int generator = 0;
147133   int y;
148134
149135   /* precalculate the star background */
150136
151   total_stars = 0;
137   state->total_stars = 0;
152138
153   for (y = 255;y >= 0;y--)
139   for (y = 255; y >= 0; y--)
154140   {
155141      int x;
156142
157      for (x = 511;x >= 0;x--)
143      for (x = 511; x >= 0; x--)
158144      {
159         int bit1,bit2;
145         int bit1, bit2;
160146
161147         generator <<= 1;
162148         bit1 = (~generator >> 17) & 1;
163149         bit2 = (generator >> 5) & 1;
164150
165         if (bit1 ^ bit2) generator |= 1;
151         if (bit1 ^ bit2)
152            generator |= 1;
166153
167154         if (((~generator >> 16) & 1) && (generator & 0xfe) == 0xfe)
168155         {
169               if(((~(generator >> 12)) & 0x01) && ((~(generator >> 13)) & 0x01))
170                {
171                if (total_stars < MAX_STARS)
172                {
173                   stars[total_stars].x = x;
174                   stars[total_stars].y = y;
175                   stars[total_stars].code = 1;
156            if(((~(generator >> 12)) & 0x01) && ((~(generator >> 13)) & 0x01))
157            {
158               if (state->total_stars < CVS_MAX_STARS)
159               {
160                  state->stars[state->total_stars].x = x;
161                  state->stars[state->total_stars].y = y;
162                  state->stars[state->total_stars].code = 1;
176163
177                   total_stars++;
178                }
179                }
164                  state->total_stars++;
165               }
166            }
180167         }
181168      }
182169   }
183170
184171   /* create helper bitmaps */
185   background_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
186   cvs_collision_background = video_screen_auto_bitmap_alloc(machine->primary_screen);
187   scrolled_collision_background = video_screen_auto_bitmap_alloc(machine->primary_screen);
172   state->background_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
173   state->collision_background = video_screen_auto_bitmap_alloc(machine->primary_screen);
174   state->scrolled_collision_background = video_screen_auto_bitmap_alloc(machine->primary_screen);
175
176   /* register save */
177   state_save_register_global_bitmap(machine, state->background_bitmap);
178   state_save_register_global_bitmap(machine, state->collision_background);
179   state_save_register_global_bitmap(machine, state->scrolled_collision_background);
188180}
189181
190182
191
192void cvs_scroll_stars(void)
183void cvs_scroll_stars( running_machine *machine )
193184{
194   stars_scroll++;
185   cvs_state *state = (cvs_state *)machine->driver_data;
186   state->stars_scroll++;
195187}
196188
197189
198
199190VIDEO_UPDATE( cvs )
200191{
192   cvs_state *state = (cvs_state *)screen->machine->driver_data;
201193   static const int ram_based_char_start_indices[] = { 0xe0, 0xc0, 0x100, 0x80 };
202194   offs_t offs;
203195   int scroll[8];
204   UINT8 character_banking_mode;
205   bitmap_t *s2636_0_bitmap;
206   bitmap_t *s2636_1_bitmap;
207   bitmap_t *s2636_2_bitmap;
208   const device_config *s2636_0 = devtag_get_device(screen->machine, "s2636_0");
209   const device_config *s2636_1 = devtag_get_device(screen->machine, "s2636_1");
210   const device_config *s2636_2 = devtag_get_device(screen->machine, "s2636_2");
196   bitmap_t *s2636_0_bitmap, *s2636_1_bitmap, *s2636_2_bitmap;
211197
212   set_pens(screen->machine->colortable);
198   set_pens(screen->machine);
213199
214   /* create our background character set, which is a software
215       selectable mixture of RAM and ROM based tiles */
216
217   character_banking_mode = cvs_get_character_banking_mode();
218
219200   /* draw the background */
220201   for (offs = 0; offs < 0x0400; offs++)
221202   {
222203      int collision_color = 0x100;
204      UINT8 code = state->video_ram[offs];
205      UINT8 color = state->color_ram[offs];
223206
224      UINT8 code = cvs_video_ram[offs];
225      UINT8 color = cvs_color_ram[offs];
226
227207      UINT8 x = offs << 3;
228208      UINT8 y = offs >> 5 << 3;
229209
230      int gfxnum = (code < ram_based_char_start_indices[character_banking_mode]) ? 0 : 1;
210      int gfxnum = (code < ram_based_char_start_indices[state->character_banking_mode]) ? 0 : 1;
231211
232      drawgfx_opaque(background_bitmap, 0, screen->machine->gfx[gfxnum],
212      drawgfx_opaque(state->background_bitmap, 0, screen->machine->gfx[gfxnum],
233213            code, color,
234214            0, 0,
235215            x, y);
r6740r6741
245225            collision_color = 0x102;
246226      }
247227
248      drawgfx_opaque(cvs_collision_background, 0, screen->machine->gfx[gfxnum],
228      drawgfx_opaque(state->collision_background, 0, screen->machine->gfx[gfxnum],
249229            code, collision_color,
250230            0, 0,
251231            x, y);
252232   }
253233
254234
255    /* Update screen - 8 regions, fixed scrolling area */
235   /* Update screen - 8 regions, fixed scrolling area */
236   scroll[0] = 0;
237   scroll[1] = state->scroll_reg;
238   scroll[2] = state->scroll_reg;
239   scroll[3] = state->scroll_reg;
240   scroll[4] = state->scroll_reg;
241   scroll[5] = state->scroll_reg;
242   scroll[6] = 0;
243   scroll[7] = 0;
256244
257    scroll[0] = 0;
258    scroll[1] = scroll_reg;
259    scroll[2] = scroll_reg;
260    scroll[3] = scroll_reg;
261    scroll[4] = scroll_reg;
262    scroll[5] = scroll_reg;
263    scroll[6] = 0;
264    scroll[7] = 0;
245   copyscrollbitmap(bitmap, state->background_bitmap, 0, 0, 8, scroll, cliprect);
246   copyscrollbitmap(state->scrolled_collision_background, state->collision_background, 0, 0, 8, scroll, cliprect);
265247
266   copyscrollbitmap(bitmap, background_bitmap, 0, 0, 8, scroll, cliprect);
267   copyscrollbitmap(scrolled_collision_background, cvs_collision_background, 0, 0, 8, scroll, cliprect);
248   /* update the S2636 chips */
249   s2636_0_bitmap = s2636_update(state->s2636_0, cliprect);
250   s2636_1_bitmap = s2636_update(state->s2636_1, cliprect);
251   s2636_2_bitmap = s2636_update(state->s2636_2, cliprect);
268252
269    /* update the S2636 chips */
270   s2636_0_bitmap = s2636_update(s2636_0, cliprect);
271   s2636_1_bitmap = s2636_update(s2636_1, cliprect);
272   s2636_2_bitmap = s2636_update(s2636_2, cliprect);
253   /* Bullet Hardware */
254   for (offs = 8; offs < 256; offs++ )
255   {
256      if (state->bullet_ram[offs] != 0)
257      {
258         int ct;
259         for (ct = 0; ct < 4; ct++)
260         {
261            int bx = 255 - 7 - state->bullet_ram[offs] - ct;
273262
274    /* Bullet Hardware */
275    for (offs = 8; offs < 256; offs++ )
276    {
277        if (cvs_bullet_ram[offs] != 0)
278        {
279           int ct;
280            for(ct=0;ct<4;ct++)
281            {
282               int bx=255-7-cvs_bullet_ram[offs]-ct;
283
284               /* Bullet/Object Collision */
263            /* Bullet/Object Collision */
285264            if ((*BITMAP_ADDR16(s2636_0_bitmap, offs, bx) != 0) ||
286265               (*BITMAP_ADDR16(s2636_1_bitmap, offs, bx) != 0) ||
287266               (*BITMAP_ADDR16(s2636_2_bitmap, offs, bx) != 0))
288               cvs_collision_register |= 0x08;
267               state->collision_register |= 0x08;
289268
290               /* Bullet/Background Collision */
291            if (colortable_entry_get_value(screen->machine->colortable, *BITMAP_ADDR16(scrolled_collision_background, offs, bx)))
292                      cvs_collision_register |= 0x80;
269            /* Bullet/Background Collision */
270            if (colortable_entry_get_value(screen->machine->colortable, *BITMAP_ADDR16(state->scrolled_collision_background, offs, bx)))
271               state->collision_register |= 0x80;
293272
294273            *BITMAP_ADDR16(bitmap, offs, bx) = BULLET_STAR_PEN;
295            }
296        }
297    }
274         }
275      }
276   }
298277
299278
300279   /* mix and copy the S2636 images into the main bitmap, also check for collision */
r6740r6741
318297               *BITMAP_ADDR16(bitmap, y, x) = SPRITE_PEN_BASE + S2636_PIXEL_COLOR(pixel);
319298
320299               /* S2636 vs. S2636 collision detection */
321               if (S2636_IS_PIXEL_DRAWN(pixel0) && S2636_IS_PIXEL_DRAWN(pixel1)) cvs_collision_register |= 0x01;
322               if (S2636_IS_PIXEL_DRAWN(pixel1) && S2636_IS_PIXEL_DRAWN(pixel2)) cvs_collision_register |= 0x02;
323               if (S2636_IS_PIXEL_DRAWN(pixel0) && S2636_IS_PIXEL_DRAWN(pixel2)) cvs_collision_register |= 0x04;
300               if (S2636_IS_PIXEL_DRAWN(pixel0) && S2636_IS_PIXEL_DRAWN(pixel1)) state->collision_register |= 0x01;
301               if (S2636_IS_PIXEL_DRAWN(pixel1) && S2636_IS_PIXEL_DRAWN(pixel2)) state->collision_register |= 0x02;
302               if (S2636_IS_PIXEL_DRAWN(pixel0) && S2636_IS_PIXEL_DRAWN(pixel2)) state->collision_register |= 0x04;
324303
325304               /* S2636 vs. background collision detection */
326               if (colortable_entry_get_value(screen->machine->colortable, *BITMAP_ADDR16(scrolled_collision_background, y, x)))
305               if (colortable_entry_get_value(screen->machine->colortable, *BITMAP_ADDR16(state->scrolled_collision_background, y, x)))
327306               {
328                  if (S2636_IS_PIXEL_DRAWN(pixel0)) cvs_collision_register |= 0x10;
329                  if (S2636_IS_PIXEL_DRAWN(pixel1)) cvs_collision_register |= 0x20;
330                  if (S2636_IS_PIXEL_DRAWN(pixel2)) cvs_collision_register |= 0x40;
307                  if (S2636_IS_PIXEL_DRAWN(pixel0)) state->collision_register |= 0x10;
308                  if (S2636_IS_PIXEL_DRAWN(pixel1)) state->collision_register |= 0x20;
309                  if (S2636_IS_PIXEL_DRAWN(pixel2)) state->collision_register |= 0x40;
331310               }
332311            }
333312         }
334313      }
335314   }
336315
337
338    /* stars circuit */
339
340   if (stars_on)
316   /* stars circuit */
317   if (state->stars_on)
341318   {
342      for (offs = 0;offs < total_stars;offs++)
319      for (offs = 0; offs < state->total_stars; offs++)
343320      {
344         UINT8 x = (stars[offs].x + stars_scroll) >> 1;
345         UINT8 y = stars[offs].y + ((stars_scroll + stars[offs].x) >> 9);
321         UINT8 x = (state->stars[offs].x + state->stars_scroll) >> 1;
322         UINT8 y = state->stars[offs].y + ((state->stars_scroll + state->stars[offs].x) >> 9);
346323
347324         if ((y & 1) ^ ((x >> 4) & 1))
348325         {
src/mame/video/seta.c
r6740r6741
137137
138138#include "driver.h"
139139#include "sound/x1_010.h"
140#include "seta.h"
140#include "includes/seta.h"
141141
142142/* Variables only used here */
143143
src/mame/video/rohga.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "deco16ic.h"
8#include "includes/deco16ic.h"
99
1010static UINT16 * rohga_spriteram;
1111
src/mame/video/plygonet.c
r6740r6741
88*/
99
1010#include "driver.h"
11#include "video/konamiic.h"
11#include "video/konicdev.h"
1212
1313/* TTL text plane stuff */
1414
r6740r6741
123123
124124VIDEO_UPDATE( polygonet )
125125{
126   const device_config *k053936 = devtag_get_device(screen->machine, "k053936");
126127   bitmap_fill(screen->machine->priority_bitmap, NULL, 0);
127128   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
128129
129   K053936_0_zoom_draw(bitmap, cliprect, roz_tilemap, 0, 0, 0);
130   k053936_zoom_draw(k053936, bitmap, cliprect, roz_tilemap, 0, 0, 0);
130131
131132   tilemap_draw(bitmap, cliprect, ttl_tilemap, 0, 1<<0);
132133   return 0;
src/mame/video/batman.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "batman.h"
9#include "thunderj.h"
8#include "includes/batman.h"
9#include "includes/thunderj.h"
1010
1111
1212
src/mame/video/cheekyms.c
r6740r6741
1010
1111#include "driver.h"
1212#include "sound/dac.h"
13#include "cheekyms.h"
13#include "includes/cheekyms.h"
1414
1515/* bit 3 and 7 of the char color PROMs are used for something -- not currently emulated -
1616   thus GAME_IMPERFECT_GRAPHICS */
src/mame/video/deco16ic.c
r6740r6741
140140***************************************************************************/
141141
142142#include "driver.h"
143#include "deco16ic.h"
143#include "includes/deco16ic.h"
144144#include "ui.h"
145145
146146UINT16 *deco16_pf1_data,*deco16_pf2_data;
src/mame/video/bishi.c
r6740r6741
88***************************************************************************/
99
1010#include "driver.h"
11#include "video/konamiic.h"
12#include "konamigx.h"
11#include "video/konicdev.h"
12//#include "includes/konamigx.h"
1313
1414static int layer_colorbase[4], layerpri[4];
1515
16static void bishi_tile_callback(int layer, int *code, int *color, int *flags)
16void bishi_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags)
1717{
1818//  *code -= '0';
1919//  *color = layer_colorbase[layer] | (*color>>2 & 0x0f);
r6740r6741
2525
2626VIDEO_START(bishi)
2727{
28   const device_config *k056832 = devtag_get_device(machine, "k056832");
29
2830   assert(video_screen_get_format(machine->primary_screen) == BITMAP_FORMAT_RGB32);
2931
30   K055555_vh_start(machine);
31   K054338_vh_start(machine);
32   k056832_set_layer_association(k056832, 0);
3233
33   K056832_vh_start(machine, "gfx1", K056832_BPP_8, 1, NULL, bishi_tile_callback, 0);
34   k056832_set_layer_offs(k056832, 0, -2, 0);
35   k056832_set_layer_offs(k056832, 1,  2, 0);
36   k056832_set_layer_offs(k056832, 2,  4, 0);
37   k056832_set_layer_offs(k056832, 3,  6, 0);
3438
35   K056832_set_LayerAssociation(0);
36
37   K056832_set_LayerOffset(0, -2, 0);
38   K056832_set_LayerOffset(1,  2, 0);
39   K056832_set_LayerOffset(2,  4, 0);
40   K056832_set_LayerOffset(3,  6, 0);
41
4239   // the 55555 is set to "0x10, 0x11, 0x12, 0x13", but these values are almost correct...
4340   layer_colorbase[0] = 0x00;
4441   layer_colorbase[1] = 0x40;   // this one is wrong
r6740r6741
6764
6865VIDEO_UPDATE(bishi)
6966{
67   const device_config *k056832 = devtag_get_device(screen->machine, "k056832");
68   const device_config *k054338 = devtag_get_device(screen->machine, "k054338");
69   const device_config *k055555 = devtag_get_device(screen->machine, "k055555");
7070   int layers[4], i;/*, old;*/
7171/*  int bg_colorbase, new_colorbase, plane, dirty; */
7272   static const int pris[4] = { K55_PRIINP_0, K55_PRIINP_3, K55_PRIINP_6, K55_PRIINP_7 };
7373   static const int enables[4] = { K55_INP_VRAM_A, K55_INP_VRAM_B, K55_INP_VRAM_C, K55_INP_VRAM_D };
7474
75   K054338_update_all_shadows(screen->machine,0 );
76   K054338_fill_backcolor(screen->machine, bitmap, 0);
75   k054338_update_all_shadows(k054338, 0);
76   k054338_fill_backcolor(k054338, bitmap, 0);
7777
7878   for (i = 0; i < 4; i++)
7979   {
8080      layers[i] = i;
81      layerpri[i] = K055555_read_register(pris[i]);
81      layerpri[i] = k055555_read_register(k055555, pris[i]);
8282   }
8383
8484   sortlayers(layers, layerpri);
r6740r6741
8787
8888   for (i = 0; i < 4; i++)
8989   {
90      if (K055555_read_register(K55_INPUT_ENABLES) & enables[layers[i]])
90      if (k055555_read_register(k055555, K55_INPUT_ENABLES) & enables[layers[i]])
9191      {
92         K056832_tilemap_draw(screen->machine, bitmap, cliprect, layers[i], 0, 1<<i);
92         k056832_tilemap_draw(k056832, bitmap, cliprect, layers[i], 0, 1 << i);
9393      }
9494   }
9595   return 0;
src/mame/video/1942.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "1942.h"
10#include "includes/1942.h"
1111
1212/***************************************************************************
1313
src/mame/video/bombjack.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "bombjack.h"
10#include "includes/bombjack.h"
1111
1212WRITE8_HANDLER( bombjack_videoram_w )
1313{
src/mame/video/trucocl.c
r6740r6741
3434
3535#include "driver.h"
3636
37UINT8 *trucocl_videoram;
38UINT8 *trucocl_colorram;
3739static tilemap *bg_tilemap;
3840
3941PALETTE_INIT( trucocl )
r6740r6741
4648
4749WRITE8_HANDLER( trucocl_videoram_w )
4850{
49   space->machine->generic.videoram.u8[offset] = data;
51   trucocl_videoram[offset] = data;
5052   tilemap_mark_tile_dirty(bg_tilemap, offset);
5153}
5254
5355WRITE8_HANDLER( trucocl_colorram_w )
5456{
55   space->machine->generic.colorram.u8[offset] = data;
57   trucocl_colorram[offset] = data;
5658   tilemap_mark_tile_dirty(bg_tilemap, offset);
5759}
5860
5961static TILE_GET_INFO( get_bg_tile_info )
6062{
61   int gfxsel = machine->generic.colorram.u8[tile_index] & 1;
62   int bank = ( ( machine->generic.colorram.u8[tile_index] >> 2 ) & 0x07 );
63   int code = machine->generic.videoram.u8[tile_index];
64   int colour = (machine->generic.colorram.u8[tile_index] & 2) >> 1;
63   int gfxsel = trucocl_colorram[tile_index] & 1;
64   int bank = ( ( trucocl_colorram[tile_index] >> 2 ) & 0x07 );
65   int code = trucocl_videoram[tile_index];
66   int colour = (trucocl_colorram[tile_index] & 2) >> 1;
6567
6668   code |= ( bank & 1 ) << 10;
6769   code |= ( bank & 2 ) << 8;
src/mame/video/rallyx.c
r6740r6741
302302         {
303303            int color = (~(generator >> 8)) & 0x3f;
304304
305            if (color && state->total_stars < MAX_STARS)
305            if (color && state->total_stars < JUNGLER_MAX_STARS)
306306            {
307307               state->stars[state->total_stars].x = x;
308308               state->stars[state->total_stars].y = y;
src/mame/video/unico.c
r6740r6741
3737***************************************************************************/
3838
3939#include "driver.h"
40#include "unico.h"
40#include "includes/unico.h"
4141
4242/* Variables needed by drivers: */
4343
src/mame/video/blockhl.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
44
55
r6740r6741
1111
1212***************************************************************************/
1313
14static void tile_callback(int layer,int bank,int *code,int *color, int *flags, int *priority)
14void blockhl_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color, int *flags, int *priority)
1515{
1616   *code |= ((*color & 0x0f) << 8);
1717   *color = layer_colorbase[layer] + ((*color & 0xe0) >> 5);
r6740r6741
2323
2424***************************************************************************/
2525
26static void sprite_callback(int *code,int *color,int *priority,int *shadow)
26void blockhl_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow)
2727{
2828   if(*color & 0x10)
2929      *priority = 0xfe; // under K052109_tilemap[0]
r6740r6741
4646   layer_colorbase[1] = 16;
4747   layer_colorbase[2] = 32;
4848   sprite_colorbase = 48;
49
50   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tile_callback);
51   K051960_vh_start(machine,"gfx2",NORMAL_PLANE_ORDER,sprite_callback);
5249}
5350
5451
5552VIDEO_UPDATE( blockhl )
5653{
54   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
55   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
56
5757   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
5858
59   K052109_tilemap_update();
59   k052109_tilemap_update(k052109);
6060
61   tilemap_draw(bitmap,cliprect,K052109_tilemap[2],TILEMAP_DRAW_OPAQUE,0);
62   tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,1);
63   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,2);
61   k052109_tilemap_draw(k052109, bitmap, cliprect, 2, TILEMAP_DRAW_OPAQUE, 0);   // tile 2
62   k052109_tilemap_draw(k052109, bitmap, cliprect, 1, 0, 1);   // tile 1
63   k052109_tilemap_draw(k052109, bitmap, cliprect, 0, 0, 2);   // tile 0
6464
65   K051960_sprites_draw(screen->machine,bitmap,cliprect,0,-1); // draw sprites with pdrawgfx
65   k051960_sprites_draw(k051960, bitmap,cliprect,0,-1);
6666   return 0;
6767}
src/mame/video/realbrk.c
r6740r6741
2020***************************************************************************/
2121
2222#include "driver.h"
23#include "realbrk.h"
23#include "includes/realbrk.h"
2424
25//UINT16 *realbrk_vram_0, *realbrk_vram_1, *realbrk_vram_2, *realbrk_vregs;
2625UINT16 *realbrk_vram_0, *realbrk_vram_1, *realbrk_vram_2, *realbrk_vregs, *realbrk_vram_0ras, *realbrk_vram_1ras;
2726static bitmap_t *tmpbitmap0 = NULL;
2827static bitmap_t *tmpbitmap1 = NULL;
src/mame/video/carjmbre.c
r6740r6741
66***************************************************************************/
77
88#include "driver.h"
9#include "carjmbre.h"
9#include "includes/carjmbre.h"
1010
1111PALETTE_INIT( carjmbre )
1212{
src/mame/video/bottom9.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
44
55
r6740r6741
1414
1515***************************************************************************/
1616
17static void tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
17void bottom9_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
1818{
1919   *code |= (*color & 0x3f) << 8;
2020   *color = layer_colorbase[layer] + ((*color & 0xc0) >> 6);
r6740r6741
2727
2828***************************************************************************/
2929
30static void sprite_callback(int *code,int *color,int *priority,int *shadow)
30void bottom9_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow)
3131{
3232   /* bit 4 = priority over zoom (0 = have priority) */
3333   /* bit 5 = priority over B (1 = have priority) */
r6740r6741
4242
4343***************************************************************************/
4444
45static void zoom_callback(int *code,int *color,int *flags)
45void bottom9_zoom_callback(running_machine *machine, int *code,int *color,int *flags)
4646{
4747   *flags = (*color & 0x40) ? TILE_FLIPX : 0;
4848   *code |= ((*color & 0x03) << 8);
r6740r6741
6363   layer_colorbase[2] = 16;
6464   sprite_colorbase = 32;
6565   zoom_colorbase = 48;
66   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tile_callback);
67   K051960_vh_start(machine,"gfx2",NORMAL_PLANE_ORDER,sprite_callback);
68   K051316_vh_start_0(machine,"gfx3",4,FALSE,0,zoom_callback);
6966}
7067
7168
r6740r6741
7875
7976VIDEO_UPDATE( bottom9 )
8077{
81   K052109_tilemap_update();
78   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
79   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
80   const device_config *k051316 = devtag_get_device(screen->machine, "k051316");
8281
82   k052109_tilemap_update(k052109);
83
8384   /* note: FIX layer is not used */
8485   bitmap_fill(bitmap,cliprect,layer_colorbase[1]);
8586//  if (bottom9_video_enable)
8687   {
87      K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
88      K051316_zoom_draw_0(bitmap,cliprect,0,0);
89      K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
90      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,0);
88      k051960_sprites_draw(k051960, bitmap, cliprect, 1, 1);
89      k051316_zoom_draw(k051316, bitmap, cliprect, 0, 0);
90      k051960_sprites_draw(k051960, bitmap, cliprect, 0, 0);
91      k052109_tilemap_draw(k052109, bitmap, cliprect, 2, 0, 0);
9192      /* note that priority 3 is opposite to the basic layer priority! */
9293      /* (it IS used, but hopefully has no effect) */
93      K051960_sprites_draw(screen->machine,bitmap,cliprect,2,3);
94      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
94      k051960_sprites_draw(k051960, bitmap, cliprect, 2, 3);
95      k052109_tilemap_draw(k052109, bitmap, cliprect, 1, 0, 0);
9596   }
9697   return 0;
9798}
src/mame/video/mainevt.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "video/konamiic.h"
10#include "video/konicdev.h"
1111
1212
1313static int layer_colorbase[3],sprite_colorbase;
r6740r6741
2020
2121***************************************************************************/
2222
23static void mainevt_tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
23void mainevt_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
2424{
2525   *flags = (*color & 0x02) ? TILE_FLIPX : 0;
2626
r6740r6741
3030   *color = layer_colorbase[layer] + ((*color & 0xc0) >> 6);
3131}
3232
33static void dv_tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
33void dv_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
3434{
3535   /* (color & 0x02) is flip y handled internally by the 052109 */
3636   *code |= ((*color & 0x01) << 8) | ((*color & 0x3c) << 7);
r6740r6741
4444
4545***************************************************************************/
4646
47static void mainevt_sprite_callback(int *code,int *color,int *priority_mask,int *shadow)
47void mainevt_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask,int *shadow)
4848{
4949   /* bit 5 = priority over layer B (has precedence) */
5050   /* bit 6 = HALF priority over layer B (used for crowd when you get out of the ring) */
r6740r6741
5656   *color = sprite_colorbase + (*color & 0x03);
5757}
5858
59static void dv_sprite_callback(int *code,int *color,int *priority,int *shadow)
59void dv_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow)
6060{
6161   /* TODO: the priority/shadow handling (bits 5-7) seems to be quite complex (see PROM) */
6262   *color = sprite_colorbase + (*color & 0x07);
r6740r6741
7171   layer_colorbase[1] = 8;
7272   layer_colorbase[2] = 4;
7373   sprite_colorbase = 12;
74
75   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,mainevt_tile_callback);
76   K051960_vh_start(machine,"gfx2",NORMAL_PLANE_ORDER,mainevt_sprite_callback);
7774}
7875
7976VIDEO_START( dv )
r6740r6741
8279   layer_colorbase[1] = 0;
8380   layer_colorbase[2] = 4;
8481   sprite_colorbase = 8;
85
86   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,dv_tile_callback);
87   K051960_vh_start(machine,"gfx2",NORMAL_PLANE_ORDER,dv_sprite_callback);
8882}
8983
9084/*****************************************************************************/
9185
9286VIDEO_UPDATE( mainevt )
9387{
94   K052109_tilemap_update();
88   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
89   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
9590
91   k052109_tilemap_update(k052109);
92
9693   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
97   tilemap_draw(bitmap,cliprect,K052109_tilemap[1],TILEMAP_DRAW_OPAQUE,1);
98   tilemap_draw(bitmap,cliprect,K052109_tilemap[2],1,2);   /* low priority part of layer */
99   tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,4);   /* high priority part of layer */
100   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,8);
94   k052109_tilemap_draw(k052109, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE, 1);
95   k052109_tilemap_draw(k052109, bitmap, cliprect, 2, 1, 2);   /* low priority part of layer */
96   k052109_tilemap_draw(k052109, bitmap, cliprect, 2, 0, 4);   /* high priority part of layer */
97   k052109_tilemap_draw(k052109, bitmap, cliprect, 0, 0, 8);
10198
102   K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
99   k051960_sprites_draw(k051960, bitmap, cliprect, -1, -1);
103100   return 0;
104101}
105102
106103VIDEO_UPDATE( dv )
107104{
108   K052109_tilemap_update();
105   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
106   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
109107
110   tilemap_draw(bitmap,cliprect,K052109_tilemap[1],TILEMAP_DRAW_OPAQUE,0);
111   tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,0);
112   K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
113   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
108   k052109_tilemap_update(k052109);
109
110   k052109_tilemap_draw(k052109, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE, 0);
111   k052109_tilemap_draw(k052109, bitmap, cliprect, 2, 0, 0);
112   k051960_sprites_draw(k051960, bitmap, cliprect, 0, 0);
113   k052109_tilemap_draw(k052109, bitmap, cliprect, 0, 0, 0);
114114   return 0;
115115}
src/mame/video/megazone.c
r6740r6741
1313UINT8 *megazone_scrolly;
1414static int flipscreen;
1515
16UINT8 *megazone_videoram;
17UINT8 *megazone_colorram;
1618UINT8 *megazone_videoram2;
1719UINT8 *megazone_colorram2;
20size_t megazone_videoram_size;
1821size_t megazone_videoram2_size;
1922
2023/***************************************************************************
r6740r6741
119122   int x,y;
120123
121124   /* for every character in the Video RAM */
122   for (offs = screen->machine->generic.videoram_size - 1;offs >= 0;offs--)
125   for (offs = megazone_videoram_size - 1;offs >= 0;offs--)
123126   {
124127      int sx,sy,flipx,flipy;
125128
126129      sx = offs % 32;
127130      sy = offs / 32;
128      flipx = screen->machine->generic.colorram.u8[offs] & (1<<6);
129      flipy = screen->machine->generic.colorram.u8[offs] & (1<<5);
131      flipx = megazone_colorram[offs] & (1<<6);
132      flipy = megazone_colorram[offs] & (1<<5);
130133      if (flipscreen)
131134      {
132135         sx = 31 - sx;
r6740r6741
136139      }
137140
138141      drawgfx_opaque(screen->machine->generic.tmpbitmap,0,screen->machine->gfx[1],
139            ((int)screen->machine->generic.videoram.u8[offs]) + ((screen->machine->generic.colorram.u8[offs] & (1<<7) ? 256 : 0) ),
140            (screen->machine->generic.colorram.u8[offs] & 0x0f) + 0x10,
142            ((int)megazone_videoram[offs]) + ((megazone_colorram[offs] & (1<<7) ? 256 : 0) ),
143            (megazone_colorram[offs] & 0x0f) + 0x10,
141144            flipx,flipy,
142145            8*sx,8*sy);
143146   }
src/mame/video/nbmj8688.c
r6740r6741
77******************************************************************************/
88
99#include "driver.h"
10#include "nb1413m3.h"
10#include "includes/nb1413m3.h"
1111#include "includes/nbmj8688.h"
1212
1313
src/mame/video/8080bw.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "8080bw.h"
11#include "mw8080bw.h"
10#include "includes/mw8080bw.h"
1211
1312
1413#define NUM_PENS   (8)
1514
1615
17UINT8 *c8080bw_colorram;
18
19static UINT8 c8080bw_flip_screen;
20static UINT8 color_map;
21static UINT8 screen_red;
22static UINT8 schaser_background_disable;
23static UINT8 schaser_background_select;
24
2516MACHINE_START( extra_8080bw_vh )
2617{
27    state_save_register_global(machine, c8080bw_flip_screen);
28    state_save_register_global(machine, color_map);
29    state_save_register_global(machine, screen_red);
18    mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
3019
31    // These two only belong to schaser, but for simplicity's sake let's waste
32    // two bytes in other drivers' .sta files.
33    state_save_register_global(machine, schaser_background_disable);
34    state_save_register_global(machine, schaser_background_select);
35}
20   state_save_register_global(machine, state->c8080bw_flip_screen);
21   state_save_register_global(machine, state->color_map);
22   state_save_register_global(machine, state->screen_red);
3623
37void c8080bw_flip_screen_w(const address_space *space, int data)
38{
39   color_map = data;
40   c8080bw_flip_screen = data && (input_port_read(space->machine, CABINET_PORT_TAG) & 0x01);
24   // These two only belong to schaser, but for simplicity's sake let's waste
25   // two bytes in other drivers' .sta files.
26   state_save_register_global(machine, state->schaser_background_disable);
27   state_save_register_global(machine, state->schaser_background_select);
4128}
4229
4330
44void lupin3_flip_screen_w(const address_space *space, int data)
31static void invadpt2_get_pens( pen_t *pens )
4532{
46   color_map = data & 0x40;
47   c8080bw_flip_screen = (data & 0x20) && (input_port_read(space->machine, "IN2") & 0x04);
48}
49
50
51void c8080bw_screen_red_w(int data)
52{
53   screen_red = data;
54}
55
56
57void schaser_background_control_w(int data)
58{
59   schaser_background_disable = (data >> 3) & 0x01;
60   schaser_background_select = (data >> 4) & 0x01;
61}
62
63
64static void invadpt2_get_pens(pen_t *pens)
65{
6633   offs_t i;
6734
6835   for (i = 0; i < NUM_PENS; i++)
r6740r6741
7239}
7340
7441
75static void sflush_get_pens(pen_t *pens)
42static void sflush_get_pens( pen_t *pens )
7643{
7744   offs_t i;
7845
r6740r6741
8552}
8653
8754
88static void cosmo_get_pens(pen_t *pens)
55static void cosmo_get_pens( pen_t *pens )
8956{
9057   offs_t i;
9158
r6740r6741
9663}
9764
9865
99INLINE void set_pixel(bitmap_t *bitmap, UINT8 y, UINT8 x, pen_t *pens, UINT8 color)
66INLINE void set_pixel( running_machine *machine, bitmap_t *bitmap, UINT8 y, UINT8 x, pen_t *pens, UINT8 color )
10067{
68    mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
69
10170   if (y >= MW8080BW_VCOUNTER_START_NO_VBLANK)
10271   {
103      if (c8080bw_flip_screen)
72      if (state->c8080bw_flip_screen)
10473         *BITMAP_ADDR32(bitmap, MW8080BW_VBSTART - 1 - (y - MW8080BW_VCOUNTER_START_NO_VBLANK), MW8080BW_HPIXCOUNT - 1 - x) = pens[color];
10574      else
10675         *BITMAP_ADDR32(bitmap, y - MW8080BW_VCOUNTER_START_NO_VBLANK, x) = pens[color];
r6740r6741
10877}
10978
11079
111INLINE void set_8_pixels(bitmap_t *bitmap, UINT8 y, UINT8 x, UINT8 data,
112                    pen_t *pens, UINT8 fore_color, UINT8 back_color)
80INLINE void set_8_pixels( running_machine *machine, bitmap_t *bitmap, UINT8 y, UINT8 x, UINT8 data, pen_t *pens, UINT8 fore_color, UINT8 back_color )
11381{
11482   int i;
11583
11684   for (i = 0; i < 8; i++)
11785   {
118      set_pixel(bitmap, y, x, pens, (data & 0x01) ? fore_color : back_color);
86      set_pixel(machine, bitmap, y, x, pens, (data & 0x01) ? fore_color : back_color);
11987
12088      x = x + 1;
12189      data = data >> 1;
r6740r6741
12492
12593
12694/* this is needed as this driver doesn't emulate the shift register like mw8080bw does */
127static void clear_extra_columns(bitmap_t *bitmap, pen_t *pens, UINT8 color)
95static void clear_extra_columns( running_machine *machine, bitmap_t *bitmap, pen_t *pens, UINT8 color )
12896{
97    mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
12998   UINT8 x;
13099
131100   for (x = 0; x < 4; x++)
r6740r6741
134103
135104      for (y = MW8080BW_VCOUNTER_START_NO_VBLANK; y != 0; y++)
136105      {
137         if (c8080bw_flip_screen)
106         if (state->c8080bw_flip_screen)
138107            *BITMAP_ADDR32(bitmap, MW8080BW_VBSTART - 1 - (y - MW8080BW_VCOUNTER_START_NO_VBLANK), MW8080BW_HPIXCOUNT - 1 - (256 + x)) = pens[color];
139108         else
140109            *BITMAP_ADDR32(bitmap, y - MW8080BW_VCOUNTER_START_NO_VBLANK, 256 + x) = pens[color];
r6740r6741
145114
146115VIDEO_UPDATE( invadpt2 )
147116{
117    mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data;
148118   pen_t pens[NUM_PENS];
149119   offs_t offs;
150120   UINT8 *prom;
r6740r6741
153123   invadpt2_get_pens(pens);
154124
155125   prom = memory_region(screen->machine, "proms");
156   color_map_base = color_map ? &prom[0x0400] : &prom[0x0000];
126   color_map_base = state->color_map ? &prom[0x0400] : &prom[0x0000];
157127
158   for (offs = 0; offs < mw8080bw_ram_size; offs++)
128   for (offs = 0; offs < state->main_ram_size; offs++)
159129   {
160130      UINT8 y = offs >> 5;
161131      UINT8 x = offs << 3;
162132
163133      offs_t color_address = (offs >> 8 << 5) | (offs & 0x1f);
164134
165      UINT8 data = mw8080bw_ram[offs];
166      UINT8 fore_color = screen_red ? 1 : color_map_base[color_address] & 0x07;
135      UINT8 data = state->main_ram[offs];
136      UINT8 fore_color = state->screen_red ? 1 : color_map_base[color_address] & 0x07;
167137
168      set_8_pixels(bitmap, y, x, data, pens, fore_color, 0);
138      set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, 0);
169139   }
170140
171   clear_extra_columns(bitmap, pens, 0);
141   clear_extra_columns(screen->machine, bitmap, pens, 0);
172142
173143   return 0;
174144}
r6740r6741
176146
177147VIDEO_UPDATE( ballbomb )
178148{
149    mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data;
179150   pen_t pens[NUM_PENS];
180151   offs_t offs;
181152   UINT8 *color_map_base;
r6740r6741
184155   invadpt2_get_pens(pens);
185156
186157   prom = memory_region(screen->machine, "proms");
187   color_map_base = color_map ? &prom[0x0400] : &prom[0x0000];
158   color_map_base = state->color_map ? &prom[0x0400] : &prom[0x0000];
188159
189   for (offs = 0; offs < mw8080bw_ram_size; offs++)
160   for (offs = 0; offs < state->main_ram_size; offs++)
190161   {
191162      UINT8 y = offs >> 5;
192163      UINT8 x = offs << 3;
193164
194165      offs_t color_address = (offs >> 8 << 5) | (offs & 0x1f);
195166
196      UINT8 data = mw8080bw_ram[offs];
197      UINT8 fore_color = screen_red ? 1 : color_map_base[color_address] & 0x07;
167      UINT8 data = state->main_ram[offs];
168      UINT8 fore_color = state->screen_red ? 1 : color_map_base[color_address] & 0x07;
198169
199170      /* blue background */
200      set_8_pixels(bitmap, y, x, data, pens, fore_color, 2);
171      set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, 2);
201172   }
202173
203   clear_extra_columns(bitmap, pens, 2);
174   clear_extra_columns(screen->machine, bitmap, pens, 2);
204175
205176   return 0;
206177}
r6740r6741
208179
209180VIDEO_UPDATE( schaser )
210181{
182    mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data;
211183   pen_t pens[NUM_PENS];
212184   offs_t offs;
213185   UINT8 *background_map_base;
r6740r6741
216188
217189   background_map_base = memory_region(screen->machine, "proms");
218190
219   for (offs = 0; offs < mw8080bw_ram_size; offs++)
191   for (offs = 0; offs < state->main_ram_size; offs++)
220192   {
221193      UINT8 back_color = 0;
222194
223195      UINT8 y = offs >> 5;
224196      UINT8 x = offs << 3;
225197
226      UINT8 data = mw8080bw_ram[offs];
227      UINT8 fore_color = c8080bw_colorram[offs & 0x1f9f] & 0x07;
198      UINT8 data = state->main_ram[offs];
199      UINT8 fore_color = state->colorram[offs & 0x1f9f] & 0x07;
228200
229      if (!schaser_background_disable)
201      if (!state->schaser_background_disable)
230202      {
231203         offs_t back_address = (offs >> 8 << 5) | (offs & 0x1f);
232204
r6740r6741
234206
235207         /* the equations derived from the schematics don't appear to produce
236208               the right colors, but this one does, at least for this PROM */
237         back_color = (((back_data & 0x0c) == 0x0c) && schaser_background_select) ? 4 : 2;
209         back_color = (((back_data & 0x0c) == 0x0c) && state->schaser_background_select) ? 4 : 2;
238210      }
239211
240      set_8_pixels(bitmap, y, x, data, pens, fore_color, back_color);
212      set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, back_color);
241213   }
242214
243   clear_extra_columns(bitmap, pens, schaser_background_disable ? 0 : 2);
215   clear_extra_columns(screen->machine, bitmap, pens, state->schaser_background_disable ? 0 : 2);
244216
245217   return 0;
246218}
r6740r6741
248220
249221VIDEO_UPDATE( schasrcv )
250222{
223    mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data;
251224   pen_t pens[NUM_PENS];
252225   offs_t offs;
253226
254227   invadpt2_get_pens(pens);
255228
256   for (offs = 0; offs < mw8080bw_ram_size; offs++)
229   for (offs = 0; offs < state->main_ram_size; offs++)
257230   {
258231      UINT8 y = offs >> 5;
259232      UINT8 x = offs << 3;
260233
261      UINT8 data = mw8080bw_ram[offs];
262      UINT8 fore_color = c8080bw_colorram[offs & 0x1f9f] & 0x07;
234      UINT8 data = state->main_ram[offs];
235      UINT8 fore_color = state->colorram[offs & 0x1f9f] & 0x07;
263236
264237      /* blue background */
265      set_8_pixels(bitmap, y, x, data, pens, fore_color, 2);
238      set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, 2);
266239   }
267240
268   clear_extra_columns(bitmap, pens, 2);
241   clear_extra_columns(screen->machine, bitmap, pens, 2);
269242
270243   return 0;
271244}
r6740r6741
273246
274247VIDEO_UPDATE( rollingc )
275248{
249    mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data;
276250   pen_t pens[NUM_PENS];
277251   offs_t offs;
278252
279253   invadpt2_get_pens(pens);
280254
281   for (offs = 0; offs < mw8080bw_ram_size; offs++)
255   for (offs = 0; offs < state->main_ram_size; offs++)
282256   {
283257      UINT8 y = offs >> 5;
284258      UINT8 x = offs << 3;
285259
286      UINT8 data = mw8080bw_ram[offs];
287      UINT8 fore_color = c8080bw_colorram[offs & 0x1f1f] & 0x07;
260      UINT8 data = state->main_ram[offs];
261      UINT8 fore_color = state->colorram[offs & 0x1f1f] & 0x07;
288262
289      set_8_pixels(bitmap, y, x, data, pens, fore_color, 0);
263      set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, 0);
290264   }
291265
292   clear_extra_columns(bitmap, pens, 0);
266   clear_extra_columns(screen->machine, bitmap, pens, 0);
293267
294268   return 0;
295269}
r6740r6741
297271
298272VIDEO_UPDATE( polaris )
299273{
274    mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data;
300275   pen_t pens[NUM_PENS];
301276   offs_t offs;
302277   UINT8 *color_map_base;
r6740r6741
307282   color_map_base = memory_region(screen->machine, "proms");
308283   cloud_gfx = memory_region(screen->machine, "user1");
309284
310   for (offs = 0; offs < mw8080bw_ram_size; offs++)
285   for (offs = 0; offs < state->main_ram_size; offs++)
311286   {
312287      UINT8 y = offs >> 5;
313288      UINT8 x = offs << 3;
314289
315      UINT8 data = mw8080bw_ram[offs];
290      UINT8 data = state->main_ram[offs];
316291
317292      offs_t color_address = (offs >> 8 << 5) | (offs & 0x1f);
318293
r6740r6741
323298           bits 1 and 2 are marked 'not use' (sic) */
324299
325300      UINT8 back_color = (color_map_base[color_address] & 0x01) ? 6 : 2;
326      UINT8 fore_color = ~c8080bw_colorram[offs & 0x1f9f] & 0x07;
301      UINT8 fore_color = ~state->colorram[offs & 0x1f9f] & 0x07;
327302
328      UINT8 cloud_y = y - polaris_get_cloud_pos();
303      UINT8 cloud_y = y - state->polaris_cloud_pos;
329304
330305      if ((color_map_base[color_address] & 0x08) || (cloud_y >= 64))
331306      {
332         set_8_pixels(bitmap, y, x, data, pens, fore_color, back_color);
307         set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, back_color);
333308      }
334309      else
335310      {
r6740r6741
352327               color = (cloud_gfx[cloud_gfx_offs] & bit) ? 7 : back_color;
353328            }
354329
355            set_pixel(bitmap, y, x, pens, color);
330            set_pixel(screen->machine, bitmap, y, x, pens, color);
356331
357332            x = x + 1;
358333            data = data >> 1;
r6740r6741
360335      }
361336   }
362337
363   clear_extra_columns(bitmap, pens, 6);
338   clear_extra_columns(screen->machine, bitmap, pens, 6);
364339
365340   return 0;
366341}
r6740r6741
368343
369344VIDEO_UPDATE( lupin3 )
370345{
346    mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data;
371347   pen_t pens[NUM_PENS];
372348   offs_t offs;
373349
374350   invadpt2_get_pens(pens);
375351
376   for (offs = 0; offs < mw8080bw_ram_size; offs++)
352   for (offs = 0; offs < state->main_ram_size; offs++)
377353   {
378354      UINT8 y = offs >> 5;
379355      UINT8 x = offs << 3;
380356
381      UINT8 data = mw8080bw_ram[offs];
382      UINT8 fore_color = ~c8080bw_colorram[offs & 0x1f9f] & 0x07;
357      UINT8 data = state->main_ram[offs];
358      UINT8 fore_color = ~state->colorram[offs & 0x1f9f] & 0x07;
383359
384      set_8_pixels(bitmap, y, x, data, pens, fore_color, 0);
360      set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, 0);
385361   }
386362
387   clear_extra_columns(bitmap, pens, 0);
363   clear_extra_columns(screen->machine, bitmap, pens, 0);
388364
389365   return 0;
390366}
r6740r6741
392368
393369VIDEO_UPDATE( cosmo )
394370{
371    mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data;
395372   pen_t pens[NUM_PENS];
396373   offs_t offs;
397374
398375   cosmo_get_pens(pens);
399376
400   for (offs = 0; offs < mw8080bw_ram_size; offs++)
377   for (offs = 0; offs < state->main_ram_size; offs++)
401378   {
402379      UINT8 y = offs >> 5;
403380      UINT8 x = offs << 3;
404381
405382      offs_t color_address = (offs >> 8 << 5) | (offs & 0x1f);
406383
407      UINT8 data = mw8080bw_ram[offs];
408      UINT8 fore_color = c8080bw_colorram[color_address] & 0x07;
384      UINT8 data = state->main_ram[offs];
385      UINT8 fore_color = state->colorram[color_address] & 0x07;
409386
410      set_8_pixels(bitmap, y, x, data, pens, fore_color, 0);
387      set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, 0);
411388   }
412389
413   clear_extra_columns(bitmap, pens, 0);
390   clear_extra_columns(screen->machine, bitmap, pens, 0);
414391
415392   return 0;
416393}
r6740r6741
418395
419396VIDEO_UPDATE( indianbt )
420397{
398    mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data;
421399   pen_t pens[NUM_PENS];
422400   offs_t offs;
423401   UINT8 *color_map_base;
r6740r6741
426404   cosmo_get_pens(pens);
427405
428406   prom = memory_region(screen->machine, "proms");
429   color_map_base = color_map ? &prom[0x0400] : &prom[0x0000];
407   color_map_base = state->color_map ? &prom[0x0400] : &prom[0x0000];
430408
431   for (offs = 0; offs < mw8080bw_ram_size; offs++)
409   for (offs = 0; offs < state->main_ram_size; offs++)
432410   {
433411      UINT8 y = offs >> 5;
434412      UINT8 x = offs << 3;
435413
436414      offs_t color_address = (offs >> 8 << 5) | (offs & 0x1f);
437415
438      UINT8 data = mw8080bw_ram[offs];
416      UINT8 data = state->main_ram[offs];
439417      UINT8 fore_color = color_map_base[color_address] & 0x07;
440418
441      set_8_pixels(bitmap, y, x, data, pens, fore_color, 0);
419      set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, 0);
442420   }
443421
444   clear_extra_columns(bitmap, pens, 0);
422   clear_extra_columns(screen->machine, bitmap, pens, 0);
445423
446424   return 0;
447425}
r6740r6741
449427
450428VIDEO_UPDATE( shuttlei )
451429{
430    mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data;
452431   pen_t pens[2] = { RGB_BLACK, RGB_WHITE };
453432   offs_t offs;
454433
455   for (offs = 0; offs < mw8080bw_ram_size; offs++)
434   for (offs = 0; offs < state->main_ram_size; offs++)
456435   {
457436      int i;
458437
459438      UINT8 y = offs >> 5;
460439      UINT8 x = offs << 3;
461440
462      UINT8 data = mw8080bw_ram[offs];
441      UINT8 data = state->main_ram[offs];
463442
464443      for (i = 0; i < 8; i++)
465444      {
r6740r6741
471450      }
472451   }
473452
474   clear_extra_columns(bitmap, pens, 0);
453   clear_extra_columns(screen->machine, bitmap, pens, 0);
475454
476455   return 0;
477456}
r6740r6741
479458
480459VIDEO_UPDATE( sflush )
481460{
461    mw8080bw_state *state = (mw8080bw_state *)screen->machine->driver_data;
482462   pen_t pens[NUM_PENS];
483463   offs_t offs;
484464
485465   sflush_get_pens(pens);
486466
487   for (offs = 0; offs < mw8080bw_ram_size; offs++)
467   for (offs = 0; offs < state->main_ram_size; offs++)
488468   {
489469      UINT8 y = offs >> 5;
490470      UINT8 x = offs << 3;
491471
492      UINT8 data = mw8080bw_ram[offs];
493      UINT8 fore_color = c8080bw_colorram[offs & 0x1f9f] & 0x07;
472      UINT8 data = state->main_ram[offs];
473      UINT8 fore_color = state->colorram[offs & 0x1f9f] & 0x07;
494474
495      set_8_pixels(bitmap, y, x, data, pens, fore_color, 0);
475      set_8_pixels(screen->machine, bitmap, y, x, data, pens, fore_color, 0);
496476   }
497477
498   clear_extra_columns(bitmap, pens, 0);
478   clear_extra_columns(screen->machine, bitmap, pens, 0);
499479
500480   return 0;
501481}
src/mame/video/tail2nos.c
r6740r6741
11#include "driver.h"
2#include "konamiic.h"
2#include "video/konicdev.h"
33
44
55UINT16 *tail2nos_bgvideoram;
r6740r6741
3636
3737***************************************************************************/
3838
39static void zoom_callback(int *code,int *color,int *flags)
39void tail2nos_zoom_callback(running_machine *machine, int *code,int *color,int *flags)
4040{
4141   *code |= ((*color & 0x03) << 8);
4242   *color = 32 + ((*color & 0x38) >> 3);
r6740r6741
5252{
5353   bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,64,32);
5454
55   K051316_vh_start_0(machine,"gfx3",-4,TRUE,0,zoom_callback);
56
5755   tilemap_set_transparent_pen(bg_tilemap,15);
5856
59   K051316_wraparound_enable(0,1);
60   K051316_set_offset(0,-89,-14);
6157   zoomdata = (UINT16 *)memory_region(machine, "gfx3");
6258}
6359
r6740r6741
157153
158154VIDEO_UPDATE( tail2nos )
159155{
156   const device_config *k051316 = devtag_get_device(screen->machine, "k051316");
157
160158   if (video_enable)
161159   {
162      K051316_zoom_draw_0(bitmap,cliprect,0,0);
163      draw_sprites(screen->machine, bitmap,cliprect);
164      tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
160      k051316_zoom_draw(k051316, bitmap,cliprect, 0, 0);
161      draw_sprites(screen->machine, bitmap, cliprect);
162      tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
165163   }
166164   else
167      bitmap_fill(bitmap,cliprect,0);
165      bitmap_fill(bitmap, cliprect, 0);
166
168167   return 0;
169168}
src/mame/video/mrjong.c
r6740r6741
88
99#include "driver.h"
1010
11UINT8 *mrjong_videoram;
12UINT8 *mrjong_colorram;
1113static tilemap *bg_tilemap;
1214
1315/***************************************************************************
r6740r6741
6870***************************************************************************/
6971WRITE8_HANDLER( mrjong_videoram_w )
7072{
71   space->machine->generic.videoram.u8[offset] = data;
73   mrjong_videoram[offset] = data;
7274   tilemap_mark_tile_dirty(bg_tilemap, offset);
7375}
7476
7577WRITE8_HANDLER( mrjong_colorram_w )
7678{
77   space->machine->generic.colorram.u8[offset] = data;
79   mrjong_colorram[offset] = data;
7880   tilemap_mark_tile_dirty(bg_tilemap, offset);
7981}
8082
r6740r6741
8991
9092static TILE_GET_INFO( get_bg_tile_info )
9193{
92   int code = machine->generic.videoram.u8[tile_index] | ((machine->generic.colorram.u8[tile_index] & 0x20) << 3);
93   int color = machine->generic.colorram.u8[tile_index] & 0x1f;
94   int flags = ((machine->generic.colorram.u8[tile_index] & 0x40) ? TILE_FLIPX : 0) | ((machine->generic.colorram.u8[tile_index] & 0x80) ? TILE_FLIPY : 0);
94   int code = mrjong_videoram[tile_index] | ((mrjong_colorram[tile_index] & 0x20) << 3);
95   int color = mrjong_colorram[tile_index] & 0x1f;
96   int flags = ((mrjong_colorram[tile_index] & 0x40) ? TILE_FLIPX : 0) | ((mrjong_colorram[tile_index] & 0x80) ? TILE_FLIPY : 0);
9597
9698   SET_TILE_INFO(0, code, color, flags);
9799}
r6740r6741
115117      int sx, sy;
116118      int flipx, flipy;
117119
118      sprt = (((machine->generic.videoram.u8[offs + 1] >> 2) & 0x3f) | ((machine->generic.videoram.u8[offs + 3] & 0x20) << 1));
119      flipx = (machine->generic.videoram.u8[offs + 1] & 0x01) >> 0;
120      flipy = (machine->generic.videoram.u8[offs + 1] & 0x02) >> 1;
121      color = (machine->generic.videoram.u8[offs + 3] & 0x1f);
120      sprt = (((mrjong_videoram[offs + 1] >> 2) & 0x3f) | ((mrjong_videoram[offs + 3] & 0x20) << 1));
121      flipx = (mrjong_videoram[offs + 1] & 0x01) >> 0;
122      flipy = (mrjong_videoram[offs + 1] & 0x02) >> 1;
123      color = (mrjong_videoram[offs + 3] & 0x1f);
122124
123      sx = 224 - machine->generic.videoram.u8[offs + 2];
124      sy = machine->generic.videoram.u8[offs + 0];
125      sx = 224 - mrjong_videoram[offs + 2];
126      sy = mrjong_videoram[offs + 0];
125127      if (flip_screen_get(machine))
126128      {
127129         sx = 208 - sx;
src/mame/video/quasar.c
r6740r6741
1515***************************************************************************/
1616
1717#include "driver.h"
18#include "cvs.h"
1918#include "video/s2636.h"
2019#include "cpu/s2650/s2650.h"
20#include "includes/cvs.h"
2121
22
23UINT8 *quasar_effectram;
24UINT8 quasar_effectcontrol;
25
2622PALETTE_INIT( quasar )
2723{
2824   int i;
r6740r6741
9692
9793VIDEO_START( quasar )
9894{
99   quasar_effectram = auto_alloc_array(machine, UINT8, 0x400);
95   cvs_state *state = (cvs_state *)machine->driver_data;
96   state->effectram = auto_alloc_array(machine, UINT8, 0x400);
10097
101   /* create helper bitmaps */
102   cvs_collision_background = video_screen_auto_bitmap_alloc(machine->primary_screen);
98   /* create helper bitmap */
99   state->collision_background = video_screen_auto_bitmap_alloc(machine->primary_screen);
100
101   /* register save */
102   state_save_register_global_bitmap(machine, state->collision_background);
103   state_save_register_global_pointer(machine, state->effectram, 0x400);
103104}
104105
105106VIDEO_UPDATE( quasar )
106107{
108   cvs_state *state = (cvs_state *)screen->machine->driver_data;
107109   int offs;
108   bitmap_t *s2636_0_bitmap;
109   bitmap_t *s2636_1_bitmap;
110   bitmap_t *s2636_2_bitmap;
111   const device_config *s2636_0 = devtag_get_device(screen->machine, "s2636_0");
112   const device_config *s2636_1 = devtag_get_device(screen->machine, "s2636_1");
113   const device_config *s2636_2 = devtag_get_device(screen->machine, "s2636_2");
110   bitmap_t *s2636_0_bitmap, *s2636_1_bitmap, *s2636_2_bitmap;
114111
115112   /* for every character in the video RAM */
116113   for (offs = 0; offs < 0x0400; offs++)
117114   {
118115      int ox, oy;
119        UINT8 code = cvs_video_ram[offs];
120
116      UINT8 code = state->video_ram[offs];
121117      UINT8 x = (offs & 0x1f) << 3;
122118      UINT8 y = (offs >> 5) << 3;
123119
124120      // While we have the current character code, draw the effects layer
125121      // intensity / on and off controlled by latch
126122
127      int forecolor = 0x208 + quasar_effectram[offs] + (256 * (((quasar_effectcontrol >> 4) ^ 3) & 3));
123      int forecolor = 0x208 + state->effectram[offs] + (256 * (((state->effectcontrol >> 4) ^ 3) & 3));
128124
129      for(ox=0;ox<8;ox++)
130         for(oy=0;oy<8;oy++)
131            *BITMAP_ADDR16(bitmap, y+oy, x+ox) = forecolor;
125      for (ox = 0; ox < 8; ox++)
126         for (oy = 0; oy < 8; oy++)
127            *BITMAP_ADDR16(bitmap, y + oy, x + ox) = forecolor;
132128
133129      /* Main Screen */
134
135130      drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],
136131            code,
137            cvs_color_ram[offs] & 0x3f,
132            state->color_ram[offs] & 0x3f,
138133            0,0,
139134            x,y,0);
140135
141136
142137      /* background for Collision Detection (it can only hit certain items) */
143
144      if((cvs_color_ram[offs] & 7) == 0)
138      if((state->color_ram[offs] & 7) == 0)
145139      {
146         drawgfx_opaque(cvs_collision_background,cliprect,screen->machine->gfx[0],
140         drawgfx_opaque(state->collision_background,cliprect,screen->machine->gfx[0],
147141               code,
148142               64,
149143               0,0,
r6740r6741
152146   }
153147
154148    /* update the S2636 chips */
155   s2636_0_bitmap = s2636_update(s2636_0, cliprect);
156   s2636_1_bitmap = s2636_update(s2636_1, cliprect);
157   s2636_2_bitmap = s2636_update(s2636_2, cliprect);
149   s2636_0_bitmap = s2636_update(state->s2636_0, cliprect);
150   s2636_1_bitmap = s2636_update(state->s2636_1, cliprect);
151   s2636_2_bitmap = s2636_update(state->s2636_2, cliprect);
158152
159153    /* Bullet Hardware */
160154    for (offs = 8; offs < 256; offs++ )
161155    {
162        if(cvs_bullet_ram[offs] != 0)
156        if(state->bullet_ram[offs] != 0)
163157        {
164158           int ct;
165            for(ct=0;ct<1;ct++)
159            for (ct = 0; ct < 1; ct++)
166160            {
167               int bx=255-9-cvs_bullet_ram[offs]-ct;
161               int bx = 255 - 9 - state->bullet_ram[offs] - ct;
168162
169163               /* bullet/object Collision */
170            if (*BITMAP_ADDR16(s2636_0_bitmap, offs, bx) != 0) cvs_collision_register |= 0x04;
171            if (*BITMAP_ADDR16(s2636_2_bitmap, offs, bx) != 0) cvs_collision_register |= 0x08;
164            if (*BITMAP_ADDR16(s2636_0_bitmap, offs, bx) != 0) state->collision_register |= 0x04;
165            if (*BITMAP_ADDR16(s2636_2_bitmap, offs, bx) != 0) state->collision_register |= 0x08;
172166
173167            *BITMAP_ADDR16(bitmap, offs, bx) = 7;
174168            }
r6740r6741
197191               *BITMAP_ADDR16(bitmap, y, x) = S2636_PIXEL_COLOR(pixel);
198192
199193               /* S2636 vs. background collision detection */
200               if (colortable_entry_get_value(screen->machine->colortable, *BITMAP_ADDR16(cvs_collision_background, y, x)))
194               if (colortable_entry_get_value(screen->machine->colortable, *BITMAP_ADDR16(state->collision_background, y, x)))
201195               {
202                  if (S2636_IS_PIXEL_DRAWN(pixel0)) cvs_collision_register |= 0x01;
203                  if (S2636_IS_PIXEL_DRAWN(pixel2)) cvs_collision_register |= 0x02;
196                  if (S2636_IS_PIXEL_DRAWN(pixel0)) state->collision_register |= 0x01;
197                  if (S2636_IS_PIXEL_DRAWN(pixel2)) state->collision_register |= 0x02;
204198               }
205199            }
206200         }
src/mame/video/victory.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "victory.h"
8#include "includes/victory.h"
99
1010
1111/* globally-accessible storage */
src/mame/video/1943.c
r6740r6741
2828***************************************************************************/
2929
3030#include "driver.h"
31#include "1943.h"
31#include "includes/1943.h"
3232
3333/***************************************************************************
3434
src/mame/video/cninja.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "deco16ic.h"
9#include "cninja.h"
8#include "includes/deco16ic.h"
9#include "includes/cninja.h"
1010
1111/******************************************************************************/
1212
src/mame/video/psikyo4.c
r6740r6741
2727*/
2828
2929#include "driver.h"
30#include "includes/psikyo4.h"
3031
31/* defined in drivers/psikyo4.c */
32extern UINT32 *psikyo4_vidregs;
3332
3433/* --- SPRITES --- */
35static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT32 scr )
34static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT32 scr )
3635{
3736   /*- Sprite Format 0x0000 - 0x2bff -**
3837
r6740r6741
5352
5453    **- End Sprite Format -*/
5554
55   psikyo4_state *state = (psikyo4_state *)machine->driver_data;
5656   const gfx_element *gfx = machine->gfx[0];
57   UINT32 *source = machine->generic.spriteram.u32;
58   UINT16 *list = (UINT16 *)machine->generic.spriteram.u32 + 0x2c00/2 + 0x04/2; /* 0x2c00/0x2c02 what are these for, pointers? one for each screen */
59   UINT16 listlen=(0xc00/2 - 0x04/2), listcntr=0;
57   UINT32 *source = state->spriteram;
58   UINT16 *list = (UINT16 *)state->spriteram + 0x2c00/2 + 0x04/2; /* 0x2c00/0x2c02 what are these for, pointers? one for each screen */
59   UINT16 listlen = (0xc00/2 - 0x04/2), listcntr = 0;
6060   int flipscreen1, flipscreen2;
6161
62   flipscreen1 = (((psikyo4_vidregs[1]>>30)&2) == 2) ? 1 : 0;
63   flipscreen2 = (((psikyo4_vidregs[1]>>22)&2) == 2) ? 1 : 0;
62   flipscreen1 = (((state->vidregs[1] >> 30) & 2) == 2) ? 1 : 0;
63   flipscreen2 = (((state->vidregs[1] >> 22) & 2) == 2) ? 1 : 0;
6464
65   while( listcntr < listlen )
65   while (listcntr < listlen)
6666   {
6767      UINT16 listdat, sprnum, thisscreen;
6868
r6740r6741
7575      /* start drawing */
7676      if (!(listdat & 0x8000) && thisscreen) /* draw only selected screen */
7777      {
78         int loopnum=0, i, j;
78         int loopnum = 0, i, j;
7979         UINT32 xpos, ypos, tnum, wide, high, colr, flipx, flipy;
8080         int xstart, ystart, xend, yend, xinc, yinc;
8181
82         ypos = (source[sprnum+0] & 0x03ff0000) >> 16;
83         xpos = (source[sprnum+0] & 0x000003ff) >> 00;
82         ypos = (source[sprnum + 0] & 0x03ff0000) >> 16;
83         xpos = (source[sprnum + 0] & 0x000003ff) >> 00;
8484
85         high = ((source[sprnum+0] & 0xf0000000) >> (12+16)) + 1;
86         wide = ((source[sprnum+0] & 0x0000f000) >> 12) + 1;
85         high = ((source[sprnum + 0] & 0xf0000000) >> (12 + 16)) + 1;
86         wide = ((source[sprnum + 0] & 0x0000f000) >> 12) + 1;
8787
88         tnum = (source[sprnum+1] & 0x0007ffff) >> 00;
88         tnum = (source[sprnum + 1] & 0x0007ffff) >> 00;
8989
90         colr = (source[sprnum+1] & 0x3f000000) >> 24;
91            if(scr) colr += 0x40; /* Use second copy of palette which is dimmed appropriately */
90         colr = (source[sprnum + 1] & 0x3f000000) >> 24;
91            if (scr)
92            colr += 0x40; /* Use second copy of palette which is dimmed appropriately */
9293
93         flipx = (source[sprnum+1] & 0x40000000);
94         flipy = (source[sprnum+1] & 0x80000000); /* Guess */
94         flipx = (source[sprnum + 1] & 0x40000000);
95         flipy = (source[sprnum + 1] & 0x80000000); /* Guess */
9596
96         if(ypos & 0x200) ypos -= 0x400;
97         if(xpos & 0x200) xpos -= 0x400;
97         if (ypos & 0x200) ypos -= 0x400;
98         if (xpos & 0x200) xpos -= 0x400;
9899
99         if((!scr && flipscreen1) || (scr && flipscreen2))
100         if ((!scr && flipscreen1) || (scr && flipscreen2))
100101         {
101            ypos = video_screen_get_visible_area(machine->primary_screen)->max_y+1 - ypos - high*16; /* Screen Height depends on game */
102            xpos = 40*8 - xpos - wide*16;
102            ypos = video_screen_get_visible_area(machine->primary_screen)->max_y + 1 - ypos - high * 16; /* Screen Height depends on game */
103            xpos = 40 * 8 - xpos - wide * 16;
103104            flipx = !flipx;
104105            flipy = !flipy;
105106         }
106107
107         if (flipx)   { xstart = wide-1;  xend = -1;    xinc = -1; }
108         else      { xstart = 0;       xend = wide;  xinc = +1; }
108         if (flipx)   { xstart = wide - 1;  xend = -1;    xinc = -1; }
109         else      { xstart = 0;         xend = wide;  xinc = +1; }
109110
110         if (flipy)   { ystart = high-1;  yend = -1;     yinc = -1; }
111         else      { ystart = 0;       yend = high;   yinc = +1; }
111         if (flipy)   { ystart = high - 1;  yend = -1;     yinc = -1; }
112         else      { ystart = 0;         yend = high;   yinc = +1; }
112113
113         for (j = ystart; j != yend; j += yinc) {
114            for (i = xstart; i != xend; i += xinc) {
115               drawgfx_transpen(bitmap,cliprect,gfx,tnum+loopnum,colr,flipx,flipy,xpos+16*i,ypos+16*j,0);
114         for (j = ystart; j != yend; j += yinc)
115         {
116            for (i = xstart; i != xend; i += xinc)
117            {
118               drawgfx_transpen(bitmap, cliprect, gfx, tnum + loopnum, colr, flipx, flipy, xpos + 16 * i, ypos + 16 * j, 0);
116119               loopnum++;
117120            }
118121         }
119122      }
120123      /* end drawing */
121124      listcntr++;
122      if (listdat & 0x4000) break;
125      if (listdat & 0x4000)
126         break;
123127   }
124128}
125129
r6740r6741
143147
144148VIDEO_START( psikyo4 )
145149{
146   machine->gfx[0]->color_granularity=32; /* 256 colour sprites with palette selectable on 32 colour boundaries */
150   machine->gfx[0]->color_granularity = 32; /* 256 colour sprites with palette selectable on 32 colour boundaries */
147151}
src/mame/video/rollrace.c
r6740r6741
11#include "driver.h"
22
3UINT8 *rollrace_videoram;
4UINT8 *rollrace_colorram;
35
46static int ra_charbank[2] = { 0,0 };
57static int ra_bkgpage = 0;
r6740r6741
7072   bitmap_fill(bitmap,cliprect,ra_bkgpen);
7173
7274   /* draw road */
73   for (offs = screen->machine->generic.videoram_size - 1;offs >= 0;offs--)
75   for (offs = 0x3ff; offs >= 0; offs--)
7476      {
7577         if(!(ra_bkgflip))
7678            {
r6740r6741
138140
139141
140142   /* draw foreground characters */
141   for (offs = screen->machine->generic.videoram_size - 1;offs >= 0;offs--)
143   for (offs = 0x3ff; offs >= 0; offs--)
142144   {
143145
144146      sx =  offs % 32;
145147      sy =  offs / 32;
146148
147      scroll = ( 8 * sy + screen->machine->generic.colorram.u8[2 * sx] ) % 256;
148      col = screen->machine->generic.colorram.u8[ sx * 2 + 1 ]&0x1f;
149      scroll = ( 8 * sy + rollrace_colorram[2 * sx] ) % 256;
150      col = rollrace_colorram[ sx * 2 + 1 ]&0x1f;
149151
150152      if (!ra_flipy)
151153      {
r6740r6741
155157      if (ra_flipx) sx = 31 - sx;
156158
157159      drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[RA_FGCHAR_BASE + ra_chrbank]  ,
158         screen->machine->generic.videoram.u8[ offs ]  ,
160         rollrace_videoram[ offs ]  ,
159161         col,
160162         ra_flipx,ra_flipy,
161163         8*sx,scroll,0);
src/mame/video/popper.c
r6740r6741
88
99#include "driver.h"
1010#include "video/resnet.h"
11#include "popper.h"
11#include "includes/popper.h"
1212
1313
1414/***************************************************************************
src/mame/video/sidearms.c
r6740r6741
1212
1313UINT8 *sidearms_bg_scrollx;
1414UINT8 *sidearms_bg_scrolly;
15UINT8 *sidearms_videoram;
16UINT8 *sidearms_colorram;
1517
1618static UINT8 *tilerom;
1719static int bgon, objon, staron, charon, flipon;
r6740r6741
2123
2224WRITE8_HANDLER( sidearms_videoram_w )
2325{
24   space->machine->generic.videoram.u8[offset] = data;
26   sidearms_videoram[offset] = data;
2527   tilemap_mark_tile_dirty(fg_tilemap, offset);
2628}
2729
2830WRITE8_HANDLER( sidearms_colorram_w )
2931{
30   space->machine->generic.colorram.u8[offset] = data;
32   sidearms_colorram[offset] = data;
3133   tilemap_mark_tile_dirty(fg_tilemap, offset);
3234}
3335
r6740r6741
128130
129131static TILE_GET_INFO( get_fg_tile_info )
130132{
131   int attr = machine->generic.colorram.u8[tile_index];
132   int code = machine->generic.videoram.u8[tile_index] + (attr<<2 & 0x300);
133   int attr = sidearms_colorram[tile_index];
134   int code = sidearms_videoram[tile_index] + (attr<<2 & 0x300);
133135   int color = attr & 0x3f;
134136
135137   SET_TILE_INFO(0, code, color, 0);
src/mame/video/djboy.c
r6740r6741
44 * video hardware for DJ Boy
55 */
66#include "driver.h"
7#include "kan_pand.h"
7#include "video/kan_pand.h"
8#include "includes/djboy.h"
89
9static UINT8 djboy_videoreg, djboy_scrollx, djboy_scrolly;
10static tilemap *background;
11
12void djboy_set_videoreg( UINT8 data )
13{
14   djboy_videoreg = data;
15}
16
1710WRITE8_HANDLER( djboy_scrollx_w )
1811{
19   djboy_scrollx = data;
12   djboy_state *state = (djboy_state *)space->machine->driver_data;
13   state->scrollx = data;
2014}
2115
2216WRITE8_HANDLER( djboy_scrolly_w )
2317{
24   djboy_scrolly = data;
18   djboy_state *state = (djboy_state *)space->machine->driver_data;
19   state->scrolly = data;
2520}
2621
2722static TILE_GET_INFO( get_bg_tile_info )
2823{
29   UINT8 attr = machine->generic.videoram.u8[tile_index + 0x800];
30   int code = machine->generic.videoram.u8[tile_index] + (attr&0xf)*256;
31   int color = attr>>4;
32   if( color&8 )
33   {
24   djboy_state *state = (djboy_state *)machine->driver_data;
25   UINT8 attr = state->videoram[tile_index + 0x800];
26   int code = state->videoram[tile_index] + (attr & 0xf) * 256;
27   int color = attr >> 4;
28
29   if (color & 8)
3430      code |= 0x1000;
35   }
31
3632   SET_TILE_INFO(1, code, color, 0);   /* no flip */
3733}
3834
3935WRITE8_HANDLER( djboy_videoram_w )
4036{
41   space->machine->generic.videoram.u8[offset] = data;
42   tilemap_mark_tile_dirty( background, offset & 0x7ff);
37   djboy_state *state = (djboy_state *)space->machine->driver_data;
38
39   state->videoram[offset] = data;
40   tilemap_mark_tile_dirty(state->background, offset & 0x7ff);
4341}
4442
4543VIDEO_START( djboy )
4644{
47   background = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,16,16,64,32);
45   djboy_state *state = (djboy_state *)machine->driver_data;
46   state->background = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 16, 16, 64, 32);
4847}
4948
5049WRITE8_HANDLER( djboy_paletteram_w )
5150{
51   djboy_state *state = (djboy_state *)space->machine->driver_data;
5252   int val;
5353
54   space->machine->generic.paletteram.u8[offset] = data;
54   state->paletteram[offset] = data;
5555   offset &= ~1;
56   val = (space->machine->generic.paletteram.u8[offset]<<8) | space->machine->generic.paletteram.u8[offset+1];
56   val = (state->paletteram[offset] << 8) | state->paletteram[offset + 1];
5757
58   palette_set_color_rgb(space->machine,offset/2,pal4bit(val >> 8),pal4bit(val >> 4),pal4bit(val >> 0));
58   palette_set_color_rgb(space->machine, offset / 2, pal4bit(val >> 8), pal4bit(val >> 4), pal4bit(val >> 0));
5959}
6060
6161VIDEO_UPDATE( djboy )
r6740r6741
6666     * ---x---- flipscreen?
6767     * ----xxxx ROM bank
6868     */
69   const device_config *pandora = devtag_get_device(screen->machine, "pandora");
69   djboy_state *state = (djboy_state *)screen->machine->driver_data;
7070   int scroll;
71   scroll = djboy_scrollx | ((djboy_videoreg&0xc0)<<2);
72   tilemap_set_scrollx( background, 0, scroll-0x391 );
73   scroll = djboy_scrolly | ((djboy_videoreg&0x20)<<3);
74   tilemap_set_scrolly( background, 0, scroll );
75   tilemap_draw( bitmap, cliprect,background,0,0 );
76   pandora_update(pandora, bitmap, cliprect);
71
72   scroll = state->scrollx | ((state->videoreg & 0xc0) << 2);
73   tilemap_set_scrollx(state->background, 0, scroll - 0x391);
74
75   scroll = state->scrolly | ((state->videoreg & 0x20) << 3);
76   tilemap_set_scrolly(state->background, 0, scroll);
77
78   tilemap_draw(bitmap, cliprect, state->background, 0, 0);
79   pandora_update(state->pandora, bitmap, cliprect);
80
7781   return 0;
7882}
7983
8084VIDEO_EOF( djboy )
8185{
82   const device_config *pandora = devtag_get_device(machine, "pandora");
83   pandora_eof(pandora);
86   djboy_state *state = (djboy_state *)machine->driver_data;
87   pandora_eof(state->pandora);
8488}
src/mame/video/tumblep.c
r6740r6741
1414***************************************************************************/
1515
1616#include "driver.h"
17#include "deco16ic.h"
17#include "includes/deco16ic.h"
1818
1919static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
2020{
src/mame/video/dogfgt.c
r6740r6741
11#include "driver.h"
2#include "dogfgt.h"
2#include "includes/dogfgt.h"
33
44
55/***************************************************************************
src/mame/video/dietgo.c
r6740r6741
11#include "driver.h"
2#include "deco16ic.h"
2#include "includes/deco16ic.h"
33
44static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectangle *cliprect)
55{
src/mame/video/esripsys.c
r6740r6741
66
77#include "driver.h"
88#include "cpu/m6809/m6809.h"
9#include "esripsys.h"
9#include "includes/esripsys.h"
1010
1111
1212/*************************************
src/mame/video/nbmj8991.c
r6740r6741
77******************************************************************************/
88
99#include "driver.h"
10#include "nb1413m3.h"
10#include "includes/nb1413m3.h"
1111#include "includes/nbmj8991.h"
1212
1313
src/mame/video/blockout.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "blockout.h"
8#include "includes/blockout.h"
99
1010
1111static void setcolor( running_machine *machine, int color, int rgb )
src/mame/video/tsamurai.c
r6740r6741
99** variables
1010*/
1111UINT8 *tsamurai_videoram;
12UINT8 *tsamurai_colorram;
13UINT8 *tsamurai_bg_videoram;
1214static int bgcolor;
1315static int textbank1, textbank2;
1416
r6740r6741
2325
2426static TILE_GET_INFO( get_bg_tile_info )
2527{
26   UINT8 attributes = tsamurai_videoram[2*tile_index+1];
27   int tile_number = tsamurai_videoram[2*tile_index];
28   UINT8 attributes = tsamurai_bg_videoram[2*tile_index+1];
29   int tile_number = tsamurai_bg_videoram[2*tile_index];
2830   tile_number += (( attributes & 0xc0 ) >> 6 ) * 256;    /* legacy */
2931   tile_number += (( attributes & 0x20 ) >> 5 ) * 1024; /* Mission 660 add-on*/
3032   SET_TILE_INFO(
r6740r6741
3638
3739static TILE_GET_INFO( get_fg_tile_info )
3840{
39   int tile_number = machine->generic.videoram.u8[tile_index];
41   int tile_number = tsamurai_videoram[tile_index];
4042   if (textbank1 & 0x01) tile_number += 256; /* legacy */
4143   if (textbank2 & 0x01) tile_number += 512; /* Mission 660 add-on */
4244   SET_TILE_INFO(
4345         1,
4446         tile_number,
45         machine->generic.colorram.u8[((tile_index&0x1f)*2)+1] & 0x1f,
47         tsamurai_colorram[((tile_index&0x1f)*2)+1] & 0x1f,
4648         0);
4749}
4850
r6740r6741
104106
105107WRITE8_HANDLER( tsamurai_bg_videoram_w )
106108{
107   tsamurai_videoram[offset]=data;
109   tsamurai_bg_videoram[offset]=data;
108110   offset = offset/2;
109111   tilemap_mark_tile_dirty(background,offset);
110112}
111113WRITE8_HANDLER( tsamurai_fg_videoram_w )
112114{
113   space->machine->generic.videoram.u8[offset]=data;
115   tsamurai_videoram[offset]=data;
114116   tilemap_mark_tile_dirty(foreground,offset);
115117}
116118WRITE8_HANDLER( tsamurai_fg_colorram_w )
117119{
118   if( space->machine->generic.colorram.u8[offset]!=data )
120   if( tsamurai_colorram[offset]!=data )
119121   {
120      space->machine->generic.colorram.u8[offset]=data;
122      tsamurai_colorram[offset]=data;
121123      if (offset & 1)
122124      {
123125         int col = offset/2;
r6740r6741
203205   tilemap_set_scroll_cols(foreground, 32);
204206   for (i = 0 ; i < 32 ; i++)
205207   {
206      tilemap_set_scrolly(foreground, i, screen->machine->generic.colorram.u8[i*2]);
208      tilemap_set_scrolly(foreground, i, tsamurai_colorram[i*2]);
207209   }
208210/* end of column scroll code */
209211
r6740r6741
242244
243245static TILE_GET_INFO( get_vsgongf_tile_info )
244246{
245   int tile_number = machine->generic.videoram.u8[tile_index];
247   int tile_number = tsamurai_videoram[tile_index];
246248   int color = vsgongf_color&0x1f;
247249   if( textbank1 ) tile_number += 0x100;
248250   SET_TILE_INFO(
src/mame/video/f1gp.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
3#include "f1gp.h"
2#include "video/konicdev.h"
3#include "includes/f1gp.h"
44
55
6UINT16 *f1gp_spr1vram,*f1gp_spr2vram,*f1gp_spr1cgram,*f1gp_spr2cgram;
7UINT16 *f1gp_fgvideoram,*f1gp_rozvideoram;
8UINT16 *f1gp2_sprcgram,*f1gp2_spritelist;
9UINT16 *f1gpb_rozregs, *f1gpb_fgregs;
10size_t f1gp_spr1cgram_size,f1gp_spr2cgram_size;
11
12static UINT16 *zoomdata;
13static int flipscreen,gfxctrl;
14
156#define TOTAL_CHARS 0x800
167
17static tilemap *fg_tilemap,*roz_tilemap;
18static int f1gp2_roz_bank;
198
20
219/***************************************************************************
2210
2311  Callbacks for the TileMap code
r6740r6741
2614
2715static TILE_GET_INFO( f1gp_get_roz_tile_info )
2816{
29   int code = f1gp_rozvideoram[tile_index];
17   f1gp_state *state = (f1gp_state *)machine->driver_data;
18   int code = state->rozvideoram[tile_index];
3019
31   SET_TILE_INFO(3,code & 0x7ff,code >> 12,0);
20   SET_TILE_INFO(3, code & 0x7ff, code >> 12, 0);
3221}
3322
3423static TILE_GET_INFO( f1gp2_get_roz_tile_info )
3524{
36   int code = f1gp_rozvideoram[tile_index];
25   f1gp_state *state = (f1gp_state *)machine->driver_data;
26   int code = state->rozvideoram[tile_index];
3727
38   SET_TILE_INFO(2,(code & 0x7ff) + (f1gp2_roz_bank << 11),code >> 12,0);
28   SET_TILE_INFO(2, (code & 0x7ff) + (state->roz_bank << 11), code >> 12, 0);
3929}
4030
4131static TILE_GET_INFO( get_fg_tile_info )
4232{
43   int code = f1gp_fgvideoram[tile_index];
33   f1gp_state *state = (f1gp_state *)machine->driver_data;
34   int code = state->fgvideoram[tile_index];
4435
45   SET_TILE_INFO(0,code & 0x7fff,0,(code & 0x8000)?TILE_FLIPY:0);
36   SET_TILE_INFO(0, code & 0x7fff, 0, (code & 0x8000) ? TILE_FLIPY : 0);
4637}
4738
4839
r6740r6741
5445
5546VIDEO_START( f1gp )
5647{
57   roz_tilemap = tilemap_create(machine, f1gp_get_roz_tile_info,tilemap_scan_rows,16,16,64,64);
58   fg_tilemap =  tilemap_create(machine, get_fg_tile_info,      tilemap_scan_rows, 8, 8,64,32);
48   f1gp_state *state = (f1gp_state *)machine->driver_data;
5949
60   K053936_wraparound_enable(0, 1);
61   K053936_set_offset(0, -58, -2);
50   state->roz_tilemap = tilemap_create(machine, f1gp_get_roz_tile_info, tilemap_scan_rows, 16, 16, 64, 64);
51   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
6252
63   tilemap_set_transparent_pen(fg_tilemap,0xff);
53   tilemap_set_transparent_pen(state->fg_tilemap, 0xff);
6454
65   zoomdata = (UINT16 *)memory_region(machine, "gfx4");
66   gfx_element_set_source(machine->gfx[3], (UINT8 *)zoomdata);
55   state->zoomdata = (UINT16 *)memory_region(machine, "gfx4");
56   gfx_element_set_source(machine->gfx[3], (UINT8 *)state->zoomdata);
57
58//  state_save_register_global_pointer(machine, state->zoomdata, memory_region_length(machine, "gfx4"));
6759}
6860
61
6962VIDEO_START( f1gpb )
7063{
71   roz_tilemap = tilemap_create(machine, f1gp_get_roz_tile_info,tilemap_scan_rows,16,16,64,64);
72   fg_tilemap =  tilemap_create(machine, get_fg_tile_info,      tilemap_scan_rows, 8, 8,64,32);
64   f1gp_state *state = (f1gp_state *)machine->driver_data;
7365
74   tilemap_set_transparent_pen(fg_tilemap,0xff);
66   state->roz_tilemap = tilemap_create(machine, f1gp_get_roz_tile_info, tilemap_scan_rows, 16, 16, 64, 64);
67   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
7568
76   zoomdata = (UINT16 *)memory_region(machine, "gfx4");
77   gfx_element_set_source(machine->gfx[3], (UINT8 *)zoomdata);
69   tilemap_set_transparent_pen(state->fg_tilemap, 0xff);
70
71   state->zoomdata = (UINT16 *)memory_region(machine, "gfx4");
72   gfx_element_set_source(machine->gfx[3], (UINT8 *)state->zoomdata);
73
74//  state_save_register_global_pointer(machine, state->zoomdata, memory_region_length(machine, "gfx4"));
7875}
7976
8077VIDEO_START( f1gp2 )
8178{
82   roz_tilemap = tilemap_create(machine, f1gp2_get_roz_tile_info,tilemap_scan_rows,16,16,64,64);
83   fg_tilemap =  tilemap_create(machine, get_fg_tile_info,       tilemap_scan_rows, 8, 8,64,32);
79   f1gp_state *state = (f1gp_state *)machine->driver_data;
8480
85   K053936_wraparound_enable(0, 1);
86   K053936_set_offset(0, -48, -21);
81   state->roz_tilemap = tilemap_create(machine, f1gp2_get_roz_tile_info, tilemap_scan_rows, 16, 16, 64, 64);
82   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
8783
88   tilemap_set_transparent_pen(fg_tilemap,0xff);
89   tilemap_set_transparent_pen(roz_tilemap,0x0f);
84   tilemap_set_transparent_pen(state->fg_tilemap, 0xff);
85   tilemap_set_transparent_pen(state->roz_tilemap, 0x0f);
9086
91   tilemap_set_scrolldx(fg_tilemap,-80,0);
92   tilemap_set_scrolldy(fg_tilemap,-26,0);
87   tilemap_set_scrolldx(state->fg_tilemap, -80, 0);
88   tilemap_set_scrolldy(state->fg_tilemap, -26, 0);
9389}
9490
9591
r6740r6741
10197
10298READ16_HANDLER( f1gp_zoomdata_r )
10399{
104   return zoomdata[offset];
100   f1gp_state *state = (f1gp_state *)space->machine->driver_data;
101   return state->zoomdata[offset];
105102}
106103
107104WRITE16_HANDLER( f1gp_zoomdata_w )
108105{
109   COMBINE_DATA(&zoomdata[offset]);
106   f1gp_state *state = (f1gp_state *)space->machine->driver_data;
107   COMBINE_DATA(&state->zoomdata[offset]);
110108   gfx_element_mark_dirty(space->machine->gfx[3], offset / 64);
111109}
112110
113111READ16_HANDLER( f1gp_rozvideoram_r )
114112{
115   return f1gp_rozvideoram[offset];
113   f1gp_state *state = (f1gp_state *)space->machine->driver_data;
114   return state->rozvideoram[offset];
116115}
117116
118117WRITE16_HANDLER( f1gp_rozvideoram_w )
119118{
120   COMBINE_DATA(&f1gp_rozvideoram[offset]);
121   tilemap_mark_tile_dirty(roz_tilemap,offset);
119   f1gp_state *state = (f1gp_state *)space->machine->driver_data;
120   COMBINE_DATA(&state->rozvideoram[offset]);
121   tilemap_mark_tile_dirty(state->roz_tilemap, offset);
122122}
123123
124124WRITE16_HANDLER( f1gp_fgvideoram_w )
125125{
126   COMBINE_DATA(&f1gp_fgvideoram[offset]);
127   tilemap_mark_tile_dirty(fg_tilemap,offset);
126   f1gp_state *state = (f1gp_state *)space->machine->driver_data;
127   COMBINE_DATA(&state->fgvideoram[offset]);
128   tilemap_mark_tile_dirty(state->fg_tilemap, offset);
128129}
129130
130131WRITE16_HANDLER( f1gp_fgscroll_w )
131132{
132   static int scroll[2];
133   f1gp_state *state = (f1gp_state *)space->machine->driver_data;
134   COMBINE_DATA(&state->scroll[offset]);
133135
134   COMBINE_DATA(&scroll[offset]);
135
136   tilemap_set_scrollx(fg_tilemap,0,scroll[0]);
137   tilemap_set_scrolly(fg_tilemap,0,scroll[1]);
136   tilemap_set_scrollx(state->fg_tilemap, 0, state->scroll[0]);
137   tilemap_set_scrolly(state->fg_tilemap, 0, state->scroll[1]);
138138}
139139
140140WRITE16_HANDLER( f1gp_gfxctrl_w )
141141{
142   f1gp_state *state = (f1gp_state *)space->machine->driver_data;
142143   if (ACCESSING_BITS_0_7)
143144   {
144      flipscreen = data & 0x20;
145      gfxctrl = data & 0xdf;
145      state->flipscreen = data & 0x20;
146      state->gfxctrl = data & 0xdf;
146147   }
147148}
148149
149150WRITE16_HANDLER( f1gp2_gfxctrl_w )
150151{
152   f1gp_state *state = (f1gp_state *)space->machine->driver_data;
151153   if (ACCESSING_BITS_0_7)
152154   {
153      flipscreen = data & 0x20;
155      state->flipscreen = data & 0x20;
154156
155157      /* bit 0/1 = fg/sprite/roz priority */
156158      /* bit 2 = blank screen */
157159
158      gfxctrl = data & 0xdf;
160      state->gfxctrl = data & 0xdf;
159161   }
160162
161163   if (ACCESSING_BITS_8_15)
162164   {
163      if (f1gp2_roz_bank != (data >> 8))
165      if (state->roz_bank != (data >> 8))
164166      {
165         f1gp2_roz_bank = (data >> 8);
166         tilemap_mark_all_tiles_dirty(roz_tilemap);
167         state->roz_bank = (data >> 8);
168         tilemap_mark_all_tiles_dirty(state->roz_tilemap);
167169      }
168170   }
169171}
r6740r6741
175177
176178***************************************************************************/
177179
178static void f1gp_draw_sprites(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect,int chip,int primask)
180static void f1gp_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int chip, int primask )
179181{
180   int attr_start,first;
181   UINT16 *spram = chip ? f1gp_spr2vram : f1gp_spr1vram;
182   f1gp_state *state = (f1gp_state *)machine->driver_data;
183   int attr_start, first;
184   UINT16 *spram = chip ? state->spr2vram : state->spr1vram;
182185
183186   first = 4 * spram[0x1fe];
184187
185   for (attr_start = 0x0200-8;attr_start >= first;attr_start -= 4)
188   for (attr_start = 0x0200 - 8; attr_start >= first; attr_start -= 4)
186189   {
187190      int map_start;
188      int ox,oy,x,y,xsize,ysize,zoomx,zoomy,flipx,flipy,color,pri;
191      int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color, pri;
189192      /* table hand made by looking at the ship explosion in attract mode */
190193      /* it's almost a logarithmic scale but not exactly */
191194      static const int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
r6740r6741
204207      pri = 0;//spram[attr_start + 2] & 0x0010;
205208      map_start = spram[attr_start + 3];
206209
207      zoomx = 16 - zoomtable[zoomx]/8;
208      zoomy = 16 - zoomtable[zoomy]/8;
210      zoomx = 16 - zoomtable[zoomx] / 8;
211      zoomy = 16 - zoomtable[zoomy] / 8;
209212
210      for (y = 0;y <= ysize;y++)
213      for (y = 0; y <= ysize; y++)
211214      {
212         int sx,sy;
215         int sx, sy;
213216
214217         if (flipy) sy = ((oy + zoomy * (ysize - y) + 16) & 0x1ff) - 16;
215218         else sy = ((oy + zoomy * y + 16) & 0x1ff) - 16;
216219
217         for (x = 0;x <= xsize;x++)
220         for (x = 0; x <= xsize; x++)
218221         {
219222            int code;
220223
r6740r6741
222225            else sx = ((ox + zoomx * x + 16) & 0x1ff) - 16;
223226
224227            if (chip == 0)
225               code = f1gp_spr1cgram[map_start % (f1gp_spr1cgram_size/2)];
228               code = state->spr1cgram[map_start % (state->spr1cgram_size / 2)];
226229            else
227               code = f1gp_spr2cgram[map_start % (f1gp_spr2cgram_size/2)];
230               code = state->spr2cgram[map_start % (state->spr2cgram_size / 2)];
228231
229232            pdrawgfxzoom_transpen(bitmap,cliprect,machine->gfx[1 + chip],
230233                  code,
r6740r6741
246249   }
247250}
248251
249static void f1gpb_draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
252
253VIDEO_UPDATE( f1gp )
250254{
251   UINT16 *spriteram16 = machine->generic.spriteram.u16;
252   int attr_start, start_offset = machine->generic.spriteram_size/2 - 4;
255   f1gp_state *state = (f1gp_state *)screen->machine->driver_data;
253256
257   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
258
259   k053936_zoom_draw(state->k053936, bitmap, cliprect, state->roz_tilemap, 0, 0, 1);
260
261   tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 1);
262
263   /* quick kludge for "continue" screen priority */
264   if (state->gfxctrl == 0x00)
265   {
266      f1gp_draw_sprites(screen->machine, bitmap, cliprect, 0, 0x02);
267      f1gp_draw_sprites(screen->machine, bitmap, cliprect, 1, 0x02);
268   }
269   else
270   {
271      f1gp_draw_sprites(screen->machine, bitmap, cliprect, 0, 0x00);
272      f1gp_draw_sprites(screen->machine, bitmap, cliprect, 1, 0x02);
273   }
274   return 0;
275}
276
277
278static void f1gpb_draw_sprites( running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect )
279{
280   f1gp_state *state = (f1gp_state *)machine->driver_data;
281   UINT16 *spriteram = state->spriteram;
282   int attr_start, start_offset = state->spriteram_size / 2 - 4;
283
254284   // find the "end of list" to draw the sprites in reverse order
255   for (attr_start = 4;attr_start < machine->generic.spriteram_size/2;attr_start += 4)
285   for (attr_start = 4; attr_start < state->spriteram_size / 2; attr_start += 4)
256286   {
257      if (spriteram16[attr_start+3-4] == 0xffff) /* end of list marker */
287      if (spriteram[attr_start + 3 - 4] == 0xffff) /* end of list marker */
258288      {
259289         start_offset = attr_start - 4;
260290         break;
r6740r6741
263293
264294   for (attr_start = start_offset;attr_start >= 4;attr_start -= 4)
265295   {
266      int code,gfx;
267      int x,y,flipx,flipy,color,pri;
296      int code, gfx;
297      int x, y, flipx, flipy, color, pri;
268298
269      x = (spriteram16[attr_start + 2] & 0x03ff) - 48;
270      y = (256 - (spriteram16[attr_start + 3 - 4] & 0x03ff)) - 15;
271      flipx = spriteram16[attr_start + 1] & 0x0800;
272      flipy = spriteram16[attr_start + 1] & 0x8000;
273      color = spriteram16[attr_start + 1] & 0x000f;
274      code = spriteram16[attr_start + 0] & 0x3fff;
299      x = (spriteram[attr_start + 2] & 0x03ff) - 48;
300      y = (256 - (spriteram[attr_start + 3 - 4] & 0x03ff)) - 15;
301      flipx = spriteram[attr_start + 1] & 0x0800;
302      flipy = spriteram[attr_start + 1] & 0x8000;
303      color = spriteram[attr_start + 1] & 0x000f;
304      code = spriteram[attr_start + 0] & 0x3fff;
275305      pri = 0; //?
276306
277      if((spriteram16[attr_start + 1] & 0x00f0) && (spriteram16[attr_start + 1] & 0x00f0) != 0xc0)
307      if((spriteram[attr_start + 1] & 0x00f0) && (spriteram[attr_start + 1] & 0x00f0) != 0xc0)
278308      {
279         printf("attr %X\n",spriteram16[attr_start + 1] & 0x00f0);
309         printf("attr %X\n",spriteram[attr_start + 1] & 0x00f0);
280310         code = mame_rand(machine);
281311      }
282312
283313/*
284        if(spriteram16[attr_start + 1] & ~0x88cf)
285            printf("1 = %X\n",spriteram16[attr_start + 1] & ~0x88cf);
314        if (spriteram[attr_start + 1] & ~0x88cf)
315            printf("1 = %X\n", spriteram[attr_start + 1] & ~0x88cf);
286316*/
287317      if(code >= 0x2000)
288318      {
r6740r6741
313343   }
314344}
315345
316
317VIDEO_UPDATE( f1gp )
318{
319   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
320
321   K053936_0_zoom_draw(bitmap,cliprect,roz_tilemap,0,0,1);
322
323   tilemap_draw(bitmap,cliprect,fg_tilemap,0,1);
324
325   /* quick kludge for "continue" screen priority */
326   if (gfxctrl == 0x00)
327   {
328      f1gp_draw_sprites(screen->machine,bitmap,cliprect,0,0x02);
329      f1gp_draw_sprites(screen->machine,bitmap,cliprect,1,0x02);
330   }
331   else
332   {
333      f1gp_draw_sprites(screen->machine,bitmap,cliprect,0,0x00);
334      f1gp_draw_sprites(screen->machine,bitmap,cliprect,1,0x02);
335   }
336   return 0;
337}
338
339346VIDEO_UPDATE( f1gpb )
340347{
341   UINT32 startx,starty;
342   int incxx,incxy,incyx,incyy;
348   f1gp_state *state = (f1gp_state *)screen->machine->driver_data;
349   UINT32 startx, starty;
350   int incxx, incxy, incyx, incyy;
343351
344   incxy = (INT16)f1gpb_rozregs[1];
352   incxy = (INT16)state->rozregs[1];
345353   incyx = -incxy;
346   incxx = incyy = (INT16)f1gpb_rozregs[3];
347   startx = f1gpb_rozregs[0] + 328;
348   starty = f1gpb_rozregs[2];
354   incxx = incyy = (INT16)state->rozregs[3];
355   startx = state->rozregs[0] + 328;
356   starty = state->rozregs[2];
349357
350   tilemap_set_scrolly(fg_tilemap,0,f1gpb_fgregs[0] + 8);
358   tilemap_set_scrolly(state->fg_tilemap, 0, state->fgregs[0] + 8);
351359
352360   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
353361
354   tilemap_draw_roz(bitmap, cliprect, roz_tilemap,
362   tilemap_draw_roz(bitmap, cliprect, state->roz_tilemap,
355363      startx << 13, starty << 13,
356364      incxx << 5, incxy << 5, incyx << 5, incyy << 5,
357365      1, 0, 0);
358366
359   tilemap_draw(bitmap,cliprect,fg_tilemap,0,1);
367   tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 1);
360368
361   f1gpb_draw_sprites(screen->machine,bitmap,cliprect);
369   f1gpb_draw_sprites(screen->machine, bitmap, cliprect);
362370
363371   return 0;
364372}
365373
366374
367static void f1gp2_draw_sprites(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect)
375static void f1gp2_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
368376{
377   f1gp_state *state = (f1gp_state *)machine->driver_data;
369378   int offs;
370379
371
372380   offs = 0;
373   while (offs < 0x0400 && (f1gp2_spritelist[offs] & 0x4000) == 0)
381   while (offs < 0x0400 && (state->spritelist[offs] & 0x4000) == 0)
374382   {
375383      int attr_start;
376384      int map_start;
377      int ox,oy,x,y,xsize,ysize,zoomx,zoomy,flipx,flipy,color;
385      int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color;
378386
379      attr_start = 4 * (f1gp2_spritelist[offs++] & 0x01ff);
387      attr_start = 4 * (state->spritelist[offs++] & 0x01ff);
380388
381      ox = f1gp2_spritelist[attr_start + 1] & 0x01ff;
382      xsize = (f1gp2_spritelist[attr_start + 1] & 0x0e00) >> 9;
383      zoomx = (f1gp2_spritelist[attr_start + 1] & 0xf000) >> 12;
384      oy = f1gp2_spritelist[attr_start + 0] & 0x01ff;
385      ysize = (f1gp2_spritelist[attr_start + 0] & 0x0e00) >> 9;
386      zoomy = (f1gp2_spritelist[attr_start + 0] & 0xf000) >> 12;
387      flipx = f1gp2_spritelist[attr_start + 2] & 0x4000;
388      flipy = f1gp2_spritelist[attr_start + 2] & 0x8000;
389      color = (f1gp2_spritelist[attr_start + 2] & 0x1f00) >> 8;
390      map_start = f1gp2_spritelist[attr_start + 3] & 0x7fff;
389      ox = state->spritelist[attr_start + 1] & 0x01ff;
390      xsize = (state->spritelist[attr_start + 1] & 0x0e00) >> 9;
391      zoomx = (state->spritelist[attr_start + 1] & 0xf000) >> 12;
392      oy = state->spritelist[attr_start + 0] & 0x01ff;
393      ysize = (state->spritelist[attr_start + 0] & 0x0e00) >> 9;
394      zoomy = (state->spritelist[attr_start + 0] & 0xf000) >> 12;
395      flipx = state->spritelist[attr_start + 2] & 0x4000;
396      flipy = state->spritelist[attr_start + 2] & 0x8000;
397      color = (state->spritelist[attr_start + 2] & 0x1f00) >> 8;
398      map_start = state->spritelist[attr_start + 3] & 0x7fff;
391399
392400// aerofgt has the following adjustment, but doing it here would break the title screen
393401//      ox += (xsize*zoomx+2)/4;
r6740r6741
396404      zoomx = 32 - zoomx;
397405      zoomy = 32 - zoomy;
398406
399      if (f1gp2_spritelist[attr_start + 2] & 0x20ff) color = mame_rand(machine);
407      if (state->spritelist[attr_start + 2] & 0x20ff)
408         color = mame_rand(machine);
400409
401      for (y = 0;y <= ysize;y++)
410      for (y = 0; y <= ysize; y++)
402411      {
403412         int sx,sy;
404413
405414         if (flipy) sy = ((oy + zoomy * (ysize - y)/2 + 16) & 0x1ff) - 16;
406415         else sy = ((oy + zoomy * y / 2 + 16) & 0x1ff) - 16;
407416
408         for (x = 0;x <= xsize;x++)
417         for (x = 0; x <= xsize; x++)
409418         {
410419            int code;
411420
412421            if (flipx) sx = ((ox + zoomx * (xsize - x) / 2 + 16) & 0x1ff) - 16;
413422            else sx = ((ox + zoomx * x / 2 + 16) & 0x1ff) - 16;
414423
415            code = f1gp2_sprcgram[map_start & 0x3fff];
424            code = state->sprcgram[map_start & 0x3fff];
416425            map_start++;
417426
418            if (flipscreen)
427            if (state->flipscreen)
419428               drawgfxzoom_transpen(bitmap,cliprect,machine->gfx[1],
420429                     code,
421430                     color,
r6740r6741
437446
438447VIDEO_UPDATE( f1gp2 )
439448{
440   if (gfxctrl & 4)   /* blank screen */
449   f1gp_state *state = (f1gp_state *)screen->machine->driver_data;
450
451   if (state->gfxctrl & 4)   /* blank screen */
441452      bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
442453   else
443454   {
444      switch (gfxctrl & 3)
455      switch (state->gfxctrl & 3)
445456      {
446457         case 0:
447            K053936_0_zoom_draw(bitmap,cliprect,roz_tilemap,TILEMAP_DRAW_OPAQUE,0,1);
448            f1gp2_draw_sprites(screen->machine,bitmap,cliprect);
449            tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
458            k053936_zoom_draw(state->k053936, bitmap, cliprect, state->roz_tilemap, TILEMAP_DRAW_OPAQUE, 0, 1);
459            f1gp2_draw_sprites(screen->machine, bitmap, cliprect);
460            tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
450461            break;
451462         case 1:
452            K053936_0_zoom_draw(bitmap,cliprect,roz_tilemap,TILEMAP_DRAW_OPAQUE,0,1);
453            tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
454            f1gp2_draw_sprites(screen->machine,bitmap,cliprect);
463            k053936_zoom_draw(state->k053936, bitmap, cliprect, state->roz_tilemap, TILEMAP_DRAW_OPAQUE, 0, 1);
464            tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
465            f1gp2_draw_sprites(screen->machine, bitmap, cliprect);
455466            break;
456467         case 2:
457            tilemap_draw(bitmap,cliprect,fg_tilemap,TILEMAP_DRAW_OPAQUE,0);
458            K053936_0_zoom_draw(bitmap,cliprect,roz_tilemap,0,0,1);
459            f1gp2_draw_sprites(screen->machine,bitmap,cliprect);
468            tilemap_draw(bitmap, cliprect, state->fg_tilemap, TILEMAP_DRAW_OPAQUE, 0);
469            k053936_zoom_draw(state->k053936, bitmap, cliprect, state->roz_tilemap, 0, 0, 1);
470            f1gp2_draw_sprites(screen->machine, bitmap, cliprect);
460471            break;
461472#ifdef MAME_DEBUG
462473         case 3:
src/mame/video/lvcards.c
r6740r6741
88
99#include "driver.h"
1010
11UINT8 *lvcards_videoram;
12UINT8 *lvcards_colorram;
1113static tilemap *bg_tilemap;
1214
1315PALETTE_INIT( ponttehk )
r6740r6741
8284
8385WRITE8_HANDLER( lvcards_videoram_w )
8486{
85   space->machine->generic.videoram.u8[offset] = data;
87   lvcards_videoram[offset] = data;
8688   tilemap_mark_tile_dirty(bg_tilemap, offset);
8789}
8890
8991WRITE8_HANDLER( lvcards_colorram_w )
9092{
91   space->machine->generic.colorram.u8[offset] = data;
93   lvcards_colorram[offset] = data;
9294   tilemap_mark_tile_dirty(bg_tilemap, offset);
9395}
9496
9597static TILE_GET_INFO( get_bg_tile_info )
9698{
97   int attr = machine->generic.colorram.u8[tile_index];
98   int code = machine->generic.videoram.u8[tile_index] + ((attr & 0x30) << 4) + ((attr & 0x80) << 3);
99   int attr = lvcards_colorram[tile_index];
100   int code = lvcards_videoram[tile_index] + ((attr & 0x30) << 4) + ((attr & 0x80) << 3);
99101   int color = attr & 0x0f;
100102   int flags = (attr & 0x40) ? TILE_FLIPX : 0;
101103
src/mame/video/namcos2.c
r6740r6741
22
33#include "driver.h"
44
5#include "namcos2.h"
6#include "namcoic.h"
5#include "includes/namcos2.h"
6#include "includes/namcoic.h"
77
88UINT16 *namcos2_sprite_ram;
99UINT16 *namcos2_68k_palette_ram;
src/mame/video/snk6502.c
r6740r6741
1010#include "includes/snk6502.h"
1111
1212
13UINT8 *snk6502_videoram;
14UINT8 *snk6502_colorram;
1315UINT8 *snk6502_videoram2;
1416UINT8 *snk6502_charram;
1517
r6740r6741
8688
8789WRITE8_HANDLER( snk6502_videoram_w )
8890{
89   space->machine->generic.videoram.u8[offset] = data;
91   snk6502_videoram[offset] = data;
9092   tilemap_mark_tile_dirty(bg_tilemap, offset);
9193}
9294
r6740r6741
98100
99101WRITE8_HANDLER( snk6502_colorram_w )
100102{
101   space->machine->generic.colorram.u8[offset] = data;
103   snk6502_colorram[offset] = data;
102104   tilemap_mark_tile_dirty(bg_tilemap, offset);
103105   tilemap_mark_tile_dirty(fg_tilemap, offset);
104106}
r6740r6741
161163
162164static TILE_GET_INFO( get_bg_tile_info )
163165{
164   int code = machine->generic.videoram.u8[tile_index] + 256 * charbank;
165   int color = (machine->generic.colorram.u8[tile_index] & 0x38) >> 3;
166   int code = snk6502_videoram[tile_index] + 256 * charbank;
167   int color = (snk6502_colorram[tile_index] & 0x38) >> 3;
166168
167169   SET_TILE_INFO(1, code, color, 0);
168170}
r6740r6741
170172static TILE_GET_INFO( get_fg_tile_info )
171173{
172174   int code = snk6502_videoram2[tile_index];
173   int color = machine->generic.colorram.u8[tile_index] & 0x07;
175   int color = snk6502_colorram[tile_index] & 0x07;
174176
175177   SET_TILE_INFO(0, code, color, 0);
176178}
r6740r6741
281283
282284static TILE_GET_INFO( satansat_get_bg_tile_info )
283285{
284   int code = machine->generic.videoram.u8[tile_index];
285   int color = (machine->generic.colorram.u8[tile_index] & 0x0c) >> 2;
286   int code = snk6502_videoram[tile_index];
287   int color = (snk6502_colorram[tile_index] & 0x0c) >> 2;
286288
287289   SET_TILE_INFO(1, code, color, 0);
288290}
r6740r6741
290292static TILE_GET_INFO( satansat_get_fg_tile_info )
291293{
292294   int code = snk6502_videoram2[tile_index];
293   int color = machine->generic.colorram.u8[tile_index] & 0x03;
295   int color = snk6502_colorram[tile_index] & 0x03;
294296
295297   SET_TILE_INFO(0, code, color, 0);
296298}
src/mame/video/exidy440.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "exidy440.h"
8#include "includes/exidy440.h"
99
1010
1111#define PIXEL_CLOCK         (EXIDY440_MASTER_CLOCK / 2)
src/mame/video/tx1.c
r6740r6741
88#include "render.h"
99#include "video/resnet.h"
1010#include "cpu/i86/i86.h"
11#include "tx1.h"
11#include "includes/tx1.h"
1212
1313
1414/*************************************
src/mame/video/dassault.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "deco16ic.h"
8#include "includes/deco16ic.h"
99
1010/******************************************************************************/
1111
src/mame/video/pingpong.c
r6740r6741
99#include "driver.h"
1010
1111static tilemap *bg_tilemap;
12UINT8 *pingpong_videoram;
13UINT8 *pingpong_colorram;
1214
1315
1416/* This is strange; it's unlikely that the sprites actually have a hardware */
r6740r6741
9597
9698WRITE8_HANDLER( pingpong_videoram_w )
9799{
98   space->machine->generic.videoram.u8[offset] = data;
100   pingpong_videoram[offset] = data;
99101   tilemap_mark_tile_dirty(bg_tilemap, offset);
100102}
101103
102104WRITE8_HANDLER( pingpong_colorram_w )
103105{
104   space->machine->generic.colorram.u8[offset] = data;
106   pingpong_colorram[offset] = data;
105107   tilemap_mark_tile_dirty(bg_tilemap, offset);
106108}
107109
108110static TILE_GET_INFO( get_bg_tile_info )
109111{
110   int attr = machine->generic.colorram.u8[tile_index];
111   int code = machine->generic.videoram.u8[tile_index] + ((attr & 0x20) << 3);
112   int attr = pingpong_colorram[tile_index];
113   int code = pingpong_videoram[tile_index] + ((attr & 0x20) << 3);
112114   int color = attr & 0x1f;
113115   int flags = ((attr & 0x40) ? TILE_FLIPX : 0) | ((attr & 0x80) ? TILE_FLIPY : 0);
114116
src/mame/video/blstroid.c
r6740r6741
66
77#include "driver.h"
88#include "machine/atarigen.h"
9#include "blstroid.h"
9#include "includes/blstroid.h"
1010
1111
1212
src/mame/video/aztarac.c
r6740r6741
66
77#include "driver.h"
88#include "video/vector.h"
9#include "aztarac.h"
9#include "includes/aztarac.h"
1010
1111#define AVECTOR(m, x, y, color, intensity) \
1212vector_add_point (m, xcenter + ((x) << 16), ycenter - ((y) << 16), color, intensity)
src/mame/video/tatsumi.c
r6740r6741
11#include "driver.h"
2#include "tatsumi.h"
2#include "includes/tatsumi.h"
33
44static tilemap *tx_layer;
55static tilemap *layer0, *layer1, *layer2, *layer3;
src/mame/video/supbtime.c
r6740r6741
1313***************************************************************************/
1414
1515#include "driver.h"
16#include "deco16ic.h"
16#include "includes/deco16ic.h"
1717
1818/******************************************************************************/
1919
src/mame/video/blmbycar.c
r6740r6741
2929***************************************************************************/
3030
3131#include "driver.h"
32#include "blmbycar.h"
32#include "includes/blmbycar.h"
3333
3434
3535/***************************************************************************
src/mame/video/gbusters.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
44
55
r6740r6741
1212
1313***************************************************************************/
1414
15static void tile_callback(int layer,int bank,int *code,int *color,int *flags, int *priority)
15void gbusters_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags, int *priority)
1616{
1717   /* (color & 0x02) is flip y handled internally by the 052109 */
1818   *code |= ((*color & 0x0d) << 8) | ((*color & 0x10) << 5) | (bank << 12);
r6740r6741
2525
2626***************************************************************************/
2727
28static void sprite_callback(int *code,int *color,int *priority,int *shadow)
28void gbusters_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow)
2929{
3030   *priority = (*color & 0x30) >> 4;
3131   *color = sprite_colorbase + (*color & 0x0f);
r6740r6741
4444   layer_colorbase[1] = 0;
4545   layer_colorbase[2] = 16;
4646   sprite_colorbase = 32;
47
48   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tile_callback);
49   K051960_vh_start(machine,"gfx2",NORMAL_PLANE_ORDER,sprite_callback);
5047}
5148
5249
5350VIDEO_UPDATE( gbusters )
5451{
55   K052109_tilemap_update();
52   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
53   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
5654
55   k052109_tilemap_update(k052109);
56
5757   /* sprite priority 3 = disable */
5858   if (gbusters_priority)
5959   {
60//      K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);  /* are these used? */
61      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],TILEMAP_DRAW_OPAQUE,0);
62      K051960_sprites_draw(screen->machine,bitmap,cliprect,2,2);
63      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,0);
64      K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
65      tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
60//      k051960_sprites_draw(k051960, bitmap, cliprect, 1, 1);  /* are these used? */
61      k052109_tilemap_draw(k052109, bitmap, cliprect, 2, TILEMAP_DRAW_OPAQUE, 0);
62      k051960_sprites_draw(k051960, bitmap, cliprect, 2, 2);
63      k052109_tilemap_draw(k052109, bitmap, cliprect, 1, 0, 0);
64      k051960_sprites_draw(k051960, bitmap, cliprect, 0, 0);
65      k052109_tilemap_draw(k052109, bitmap, cliprect, 0, 0, 0);
6666   }
6767   else
6868   {
69//      K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);  /* are these used? */
70      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],TILEMAP_DRAW_OPAQUE,0);
71      K051960_sprites_draw(screen->machine,bitmap,cliprect,2,2);
72      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,0);
73      K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
74      tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
69//      k051960_sprites_draw(k051960, bitmap, cliprect, 1, 1);  /* are these used? */
70      k052109_tilemap_draw(k052109, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE, 0);
71      k051960_sprites_draw(k051960, bitmap, cliprect, 2, 2);
72      k052109_tilemap_draw(k052109, bitmap, cliprect, 2, 0, 0);
73      k051960_sprites_draw(k051960, bitmap, cliprect, 0, 0);
74      k052109_tilemap_draw(k052109, bitmap, cliprect, 0, 0, 0);
7575   }
7676   return 0;
7777}
src/mame/video/meadows.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "meadows.h"
8#include "includes/meadows.h"
99
1010/* some constants to make life easier */
1111#define SPR_ADJUST_X    -18
src/mame/video/bogeyman.c
r6740r6741
11#include "driver.h"
2#include "bogeyman.h"
2#include "includes/bogeyman.h"
33
44
55PALETTE_INIT( bogeyman )
src/mame/video/harddriv.c
r6740r6741
66
77#include "driver.h"
88#include "cpu/tms34010/tms34010.h"
9#include "harddriv.h"
9#include "includes/harddriv.h"
1010
1111
1212
src/mame/video/m72.c
r6740r6741
11#include "driver.h"
22#include "audio/m72.h"
3#include "m72.h"
3#include "includes/m72.h"
44
55
66
src/mame/video/aeroboto.c
r6740r6741
66
77
88#include "driver.h"
9#include "aeroboto.h"
9#include "includes/aeroboto.h"
1010
1111
1212// how the starfield ROM is interpreted: 0=256x256x1 linear bitmap, 1=8x8x1x1024 tilemap
src/mame/video/madalien.c
r6740r6741
88
99#include "driver.h"
1010#include "video/mc6845.h"
11#include "madalien.h"
11#include "includes/madalien.h"
1212
1313
1414#define PIXEL_CLOCK (MADALIEN_MAIN_CLOCK / 2)
src/mame/video/firetrap.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "firetrap.h"
10#include "includes/firetrap.h"
1111
1212
1313/***************************************************************************
src/mame/video/crgolf.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "crgolf.h"
8#include "includes/crgolf.h"
99
1010
1111#define NUM_PENS      (0x20)
src/mame/video/thedeep.c
r6740r6741
2929***************************************************************************/
3030
3131#include "driver.h"
32#include "thedeep.h"
32#include "includes/thedeep.h"
3333
3434/* Variables only used here: */
3535
src/mame/video/atarig1.c
r6740r6741
66
77#include "driver.h"
88#include "machine/atarigen.h"
9#include "atarig1.h"
9#include "includes/atarig1.h"
1010
1111
1212
src/mame/video/bladestl.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
3#include "includes/bladestl.h"
34
4static int layer_colorbase[2];
5extern int bladestl_spritebank;
65
7
86PALETTE_INIT( bladestl )
97{
108   int i;
r6740r6741
2523}
2624
2725
28static void set_pens(running_machine *machine)
26static void set_pens( running_machine *machine )
2927{
28   bladestl_state *state = (bladestl_state *)machine->driver_data;
3029   int i;
3130
3231   for (i = 0x00; i < 0x60; i += 2)
3332   {
34      UINT16 data = machine->generic.paletteram.u8[i | 1] | (machine->generic.paletteram.u8[i] << 8);
33      UINT16 data = state->paletteram[i | 1] | (state->paletteram[i] << 8);
3534
3635      rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
3736
r6740r6741
4746
4847***************************************************************************/
4948
50static void tile_callback(int layer, int bank, int *code, int *color, int *flags)
49void bladestl_tile_callback( running_machine *machine, int layer, int bank, int *code, int *color, int *flags )
5150{
51   bladestl_state *state = (bladestl_state *)machine->driver_data;
52
5253   *code |= ((*color & 0x0f) << 8) | ((*color & 0x40) << 6);
53   *color = layer_colorbase[layer];
54   *color = state->layer_colorbase[layer];
5455}
5556
5657/***************************************************************************
r6740r6741
5960
6061***************************************************************************/
6162
62static void sprite_callback(int *code,int *color)
63void bladestl_sprite_callback( running_machine *machine, int *code,int *color )
6364{
64   *code |= ((*color & 0xc0) << 2) + bladestl_spritebank;
65   bladestl_state *state = (bladestl_state *)machine->driver_data;
66
67   *code |= ((*color & 0xc0) << 2) + state->spritebank;
6568   *code = (*code << 2) | ((*color & 0x30) >> 4);
6669   *color = 0 + (*color & 0x0f);
6770}
r6740r6741
6972
7073/***************************************************************************
7174
72    Start the video hardware emulation.
73
74***************************************************************************/
75
76VIDEO_START( bladestl )
77{
78   layer_colorbase[0] = 0;
79   layer_colorbase[1] = 1;
80
81   K007342_vh_start(machine,0,tile_callback);
82   K007420_vh_start(machine,1,sprite_callback);
83}
84
85/***************************************************************************
86
8775  Screen Refresh
8876
8977***************************************************************************/
9078
9179VIDEO_UPDATE( bladestl )
9280{
81   bladestl_state *state = (bladestl_state *)screen->machine->driver_data;
9382   set_pens(screen->machine);
9483
95   K007342_tilemap_update();
84   k007342_tilemap_update(state->k007342);
9685
97   K007342_tilemap_draw( bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE ,0);
98   K007420_sprites_draw( bitmap, cliprect );
99   K007342_tilemap_draw( bitmap, cliprect, 1, 1 | TILEMAP_DRAW_OPAQUE ,0);
100   K007342_tilemap_draw( bitmap, cliprect, 0, 0 ,0);
101   K007342_tilemap_draw( bitmap, cliprect, 0, 1 ,0);
86   k007342_tilemap_draw(state->k007342, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE ,0);
87   k007420_sprites_draw(state->k007420, bitmap, cliprect, screen->machine->gfx[1]);
88   k007342_tilemap_draw(state->k007342, bitmap, cliprect, 1, 1 | TILEMAP_DRAW_OPAQUE ,0);
89   k007342_tilemap_draw(state->k007342, bitmap, cliprect, 0, 0 ,0);
90   k007342_tilemap_draw(state->k007342, bitmap, cliprect, 0, 1 ,0);
10291   return 0;
10392}
src/mame/video/toobin.c
r6740r6741
66
77#include "driver.h"
88#include "machine/atarigen.h"
9#include "toobin.h"
9#include "includes/toobin.h"
1010
1111
1212
r6740r6741
9797
9898   /* allocate a playfield bitmap for rendering */
9999   state->pfbitmap = auto_bitmap_alloc(machine, video_screen_get_width(machine->primary_screen), video_screen_get_height(machine->primary_screen), BITMAP_FORMAT_INDEXED16);
100
101   state_save_register_global(machine, state->brightness);
100102}
101103
102104
src/mame/video/pbaction.c
r6740r6741
88
99#include "driver.h"
1010
11UINT8 *pbaction_videoram, *pbaction_colorram;
1112UINT8 *pbaction_videoram2, *pbaction_colorram2;
1213
1314static int scroll;
r6740r6741
1617
1718WRITE8_HANDLER( pbaction_videoram_w )
1819{
19   space->machine->generic.videoram.u8[offset] = data;
20   pbaction_videoram[offset] = data;
2021   tilemap_mark_tile_dirty(bg_tilemap, offset);
2122}
2223
2324WRITE8_HANDLER( pbaction_colorram_w )
2425{
25   space->machine->generic.colorram.u8[offset] = data;
26   pbaction_colorram[offset] = data;
2627   tilemap_mark_tile_dirty(bg_tilemap, offset);
2728}
2829
r6740r6741
5354
5455static TILE_GET_INFO( get_bg_tile_info )
5556{
56   int attr = machine->generic.colorram.u8[tile_index];
57   int code = machine->generic.videoram.u8[tile_index] + 0x10 * (attr & 0x70);
57   int attr = pbaction_colorram[tile_index];
58   int code = pbaction_videoram[tile_index] + 0x10 * (attr & 0x70);
5859   int color = attr & 0x07;
5960   int flags = (attr & 0x80) ? TILE_FLIPY : 0;
6061
src/mame/video/mcr68.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "mcr.h"
8#include "includes/mcr.h"
99
1010
1111#define LOW_BYTE(x) ((x) & 0xff)
src/mame/video/overdriv.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
44
55static int zoom_colorbase[2],road_colorbase[2],sprite_colorbase;
r6740r6741
1111
1212***************************************************************************/
1313
14static void overdriv_sprite_callback(int *code,int *color,int *priority_mask)
14void overdriv_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask)
1515{
1616   int pri = (*color & 0xffe0) >> 5;   /* ??????? */
1717   if (pri) *priority_mask = 0x02;
r6740r6741
2727
2828***************************************************************************/
2929
30static void zoom_callback_0(int *code,int *color,int *flags)
30void overdriv_zoom_callback_0(running_machine *machine, int *code,int *color,int *flags)
3131{
3232   *flags = (*color & 0x40) ? TILE_FLIPX : 0;
3333   *code |= ((*color & 0x03) << 8);
3434   *color = zoom_colorbase[0] + ((*color & 0x3c) >> 2);
3535}
3636
37static void zoom_callback_1(int *code,int *color,int *flags)
37void overdriv_zoom_callback_1(running_machine *machine, int *code,int *color,int *flags)
3838{
3939   *flags = (*color & 0x40) ? TILE_FLIPX : 0;
4040   *code |= ((*color & 0x03) << 8);
r6740r6741
5151
5252VIDEO_START( overdriv )
5353{
54   K053251_vh_start(machine);
55   K051316_vh_start_0(machine,"gfx2",4,TRUE,0,zoom_callback_0);
56   K051316_vh_start_1(machine,"gfx3",4,FALSE,0,zoom_callback_1);
57   K053247_vh_start(machine,"gfx1",77,22,NORMAL_PLANE_ORDER,overdriv_sprite_callback);
54//  const device_config *k051316_1 = devtag_get_device(machine, "k051316_1");
55//  const device_config *k051316_2 = devtag_get_device(machine, "k051316_2");
5856
59   K051316_wraparound_enable(0,1);
60   K051316_set_offset(0,14,-1);
61   K051316_set_offset(1,15,0);
57//  K053251_vh_start(machine);
58//  K051316_vh_start_0(machine,"gfx2",4,TRUE,0,zoom_callback_0);
59//  K051316_vh_start_1(machine,"gfx3",4,FALSE,0,zoom_callback_1);
60//  K053247_vh_start(machine,"gfx1",77,22,NORMAL_PLANE_ORDER,overdriv_sprite_callback);
61
62//  k051316_wraparound_enable(k051316_1, 1);
63//  k051316_set_offset(k051316_1, 14, -1);
64//  k051316_set_offset(k051316_2, 15, 0);
6265}
6366
6467
r6740r6741
7174
7275VIDEO_UPDATE( overdriv )
7376{
74   sprite_colorbase  = K053251_get_palette_index(K053251_CI0);
75   road_colorbase[1] = K053251_get_palette_index(K053251_CI1);
76   road_colorbase[0] = K053251_get_palette_index(K053251_CI2);
77   zoom_colorbase[1] = K053251_get_palette_index(K053251_CI3);
78   zoom_colorbase[0] = K053251_get_palette_index(K053251_CI4);
77   const device_config *k051316_1 = devtag_get_device(screen->machine, "k051316_1");
78   const device_config *k051316_2 = devtag_get_device(screen->machine, "k051316_2");
79   const device_config *k053246 = devtag_get_device(screen->machine, "k053246");
80   const device_config *k053251 = devtag_get_device(screen->machine, "k053251");
7981
80   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
82   sprite_colorbase  = k053251_get_palette_index(k053251, K053251_CI0);
83   road_colorbase[1] = k053251_get_palette_index(k053251, K053251_CI1);
84   road_colorbase[0] = k053251_get_palette_index(k053251, K053251_CI2);
85   zoom_colorbase[1] = k053251_get_palette_index(k053251, K053251_CI3);
86   zoom_colorbase[0] = k053251_get_palette_index(k053251, K053251_CI4);
8187
82   K051316_zoom_draw_0(bitmap,cliprect,0,0);
83   K051316_zoom_draw_1(bitmap,cliprect,0,1);
88   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
8489
85   K053247_sprites_draw(screen->machine, bitmap,cliprect);
90   k051316_zoom_draw(k051316_1, bitmap, cliprect, 0, 0);
91   k051316_zoom_draw(k051316_2, bitmap, cliprect, 0, 1);
92
93   k053247_sprites_draw(k053246, bitmap,cliprect);
8694   return 0;
8795}
src/mame/video/funworld.c
r6740r6741
6161#include "video/resnet.h"
6262
6363static tilemap *bg_tilemap;
64UINT8 *funworld_colorram;
65UINT8 *funworld_videoram;
6466
6567
6668/***** RESISTORS *****
r6740r6741
119121
120122WRITE8_HANDLER( funworld_videoram_w )
121123{
122   space->machine->generic.videoram.u8[offset] = data;
124   funworld_videoram[offset] = data;
123125   tilemap_mark_tile_dirty(bg_tilemap, offset);
124126}
125127
126128WRITE8_HANDLER( funworld_colorram_w )
127129{
128   space->machine->generic.colorram.u8[offset] = data;
130   funworld_colorram[offset] = data;
129131   tilemap_mark_tile_dirty(bg_tilemap, offset);
130132}
131133
r6740r6741
146148    ---- xxxx   unused.
147149*/
148150   int offs = tile_index;
149   int attr = machine->generic.videoram.u8[offs] + (machine->generic.colorram.u8[offs] << 8);
151   int attr = funworld_videoram[offs] + (funworld_colorram[offs] << 8);
150152   int code = attr & 0xfff;
151   int color = machine->generic.colorram.u8[offs] >> 4;   // 4 bits for color.
153   int color = funworld_colorram[offs] >> 4;   // 4 bits for color.
152154
153155   SET_TILE_INFO(0, code, color, 0);
154156}
src/mame/video/thunderx.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
4
54int scontra_priority;
65static int layer_colorbase[3],sprite_colorbase;
76
r6740r6741
1110
1211***************************************************************************/
1312
14static void tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
13void thunderx_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
1514{
1615   *code |= ((*color & 0x1f) << 8) | (bank << 13);
1716   *color = layer_colorbase[layer] + ((*color & 0xe0) >> 5);
r6740r6741
2423
2524***************************************************************************/
2625
27static void sprite_callback(int *code,int *color,int *priority_mask,int *shadow)
26void thunderx_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask,int *shadow)
2827{
2928   /* Sprite priority 1 means appear behind background, used only to mask sprites */
3029   /* in the foreground */
r6740r6741
5453   layer_colorbase[1] = 0;
5554   layer_colorbase[2] = 16;
5655   sprite_colorbase = 32;
57
58   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tile_callback);
59   K051960_vh_start(machine,"gfx2",NORMAL_PLANE_ORDER,sprite_callback);
6056}
6157
6258
r6740r6741
6864
6965VIDEO_UPDATE( scontra )
7066{
71   K052109_tilemap_update();
67   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
68   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
7269
70   k052109_tilemap_update(k052109);
71
7372   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
7473
7574   /* The background color is always from layer 1 - but it's always black anyway */
7675//  bitmap_fill(bitmap,cliprect,16 * layer_colorbase[1]);
7776   if (scontra_priority)
7877   {
79      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],TILEMAP_DRAW_OPAQUE,1);
80      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,2);
78      k052109_tilemap_draw(k052109, bitmap, cliprect, 2, TILEMAP_DRAW_OPAQUE, 1);
79      k052109_tilemap_draw(k052109, bitmap, cliprect, 1, 0, 2);
8180   }
8281   else
8382   {
84      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],TILEMAP_DRAW_OPAQUE,1);
85      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,2);
83      k052109_tilemap_draw(k052109, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE, 1);
84      k052109_tilemap_draw(k052109, bitmap, cliprect, 2, 0, 2);
8685   }
87   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,4);
86   k052109_tilemap_draw(k052109, bitmap, cliprect, 0, 0, 4);
8887
89   K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
88   k051960_sprites_draw(k051960, bitmap, cliprect, -1, -1);
9089   return 0;
9190}
src/mame/video/spcforce.c
r6740r6741
1010
1111
1212UINT8 *spcforce_scrollram;
13UINT8 *spcforce_videoram;
14UINT8 *spcforce_colorram;
1315
1416
1517WRITE8_HANDLER( spcforce_flip_screen_w )
r6740r6741
2830   bitmap_fill(bitmap,cliprect,0);
2931
3032
31   for (offs = 0; offs < screen->machine->generic.videoram_size; offs++)
33   for (offs = 0; offs < 0x400; offs++)
3234   {
3335      int code,sx,sy,col;
3436
r6740r6741
3638      sy = 8 * (offs / 32) -  (spcforce_scrollram[offs]       & 0x0f);
3739      sx = 8 * (offs % 32) + ((spcforce_scrollram[offs] >> 4) & 0x0f);
3840
39      code = screen->machine->generic.videoram.u8[offs] + ((screen->machine->generic.colorram.u8[offs] & 0x01) << 8);
40      col  = (~screen->machine->generic.colorram.u8[offs] >> 4) & 0x07;
41      code = spcforce_videoram[offs] + ((spcforce_colorram[offs] & 0x01) << 8);
42      col  = (~spcforce_colorram[offs] >> 4) & 0x07;
4143
4244      if (flip_screen_get(screen->machine))
4345      {
src/mame/video/nbmj8900.c
r6740r6741
77******************************************************************************/
88
99#include "driver.h"
10#include "nb1413m3.h"
10#include "includes/nb1413m3.h"
1111
1212
1313static int nbmj8900_scrolly;
src/mame/video/xmen.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33#include "includes/xmen.h"
44
55
r6740r6741
1313
1414***************************************************************************/
1515
16static void xmen_tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
16void xmen_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
1717{
1818   /* (color & 0x02) is flip y handled internally by the 052109 */
1919   if (layer == 0)
r6740r6741
2828
2929***************************************************************************/
3030
31static void xmen_sprite_callback(int *code,int *color,int *priority_mask)
31void xmen_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask)
3232{
3333   int pri = (*color & 0x00e0) >> 4;   /* ??????? */
3434   if (pri <= layerpri[2])                        *priority_mask = 0;
r6740r6741
4747
4848***************************************************************************/
4949
50VIDEO_START( xmen )
51{
52   K053251_vh_start(machine);
53
54   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,xmen_tile_callback);
55   K053247_vh_start(machine,"gfx2",53,-2,NORMAL_PLANE_ORDER,xmen_sprite_callback);
56}
57
5850static bitmap_t * screen_right;
5951static bitmap_t * screen_left;
6052static UINT16 *K053247_ram;
6153
6254VIDEO_START( xmen6p )
6355{
64   K053251_vh_start(machine);
56   const device_config *k053246 = devtag_get_device(machine, "k053246");
6557
66   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,xmen_tile_callback);
67   K053247_vh_start(machine,"gfx2",53,-2,NORMAL_PLANE_ORDER,xmen_sprite_callback);
68   K053247_export_config(&K053247_ram, NULL, NULL, NULL, NULL);
58   k053247_get_ram(k053246, &K053247_ram);
6959
7060   screen_left = auto_bitmap_alloc(machine, 64*8, 32*8, BITMAP_FORMAT_INDEXED16);
7161   screen_right = auto_bitmap_alloc(machine, 64*8, 32*8, BITMAP_FORMAT_INDEXED16);
r6740r6741
9787
9888VIDEO_UPDATE( xmen )
9989{
90   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
91   const device_config *k053246 = devtag_get_device(screen->machine, "k053246");
92   const device_config *k053251 = devtag_get_device(screen->machine, "k053251");
10093   int layer[3];
10194
95   bg_colorbase       = k053251_get_palette_index(k053251, K053251_CI4);
96   sprite_colorbase   = k053251_get_palette_index(k053251, K053251_CI1);
97   layer_colorbase[0] = k053251_get_palette_index(k053251, K053251_CI3);
98   layer_colorbase[1] = k053251_get_palette_index(k053251, K053251_CI0);
99   layer_colorbase[2] = k053251_get_palette_index(k053251, K053251_CI2);
102100
103   bg_colorbase       = K053251_get_palette_index(K053251_CI4);
104   sprite_colorbase   = K053251_get_palette_index(K053251_CI1);
105   layer_colorbase[0] = K053251_get_palette_index(K053251_CI3);
106   layer_colorbase[1] = K053251_get_palette_index(K053251_CI0);
107   layer_colorbase[2] = K053251_get_palette_index(K053251_CI2);
101   k052109_tilemap_update(k052109);
108102
109   K052109_tilemap_update();
110
111103   layer[0] = 0;
112   layerpri[0] = K053251_get_priority(K053251_CI3);
104   layerpri[0] = k053251_get_priority(k053251, K053251_CI3);
113105   layer[1] = 1;
114   layerpri[1] = K053251_get_priority(K053251_CI0);
106   layerpri[1] = k053251_get_priority(k053251, K053251_CI0);
115107   layer[2] = 2;
116   layerpri[2] = K053251_get_priority(K053251_CI2);
108   layerpri[2] = k053251_get_priority(k053251, K053251_CI2);
117109
118110   sortlayers(layer,layerpri);
119111
120112   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
121113   /* note the '+1' in the background color!!! */
122114   bitmap_fill(bitmap,cliprect,16 * bg_colorbase+1);
123   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[0]],0,1);
124   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[1]],0,2);
125   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[2]],0,4);
115   k052109_tilemap_draw(k052109, bitmap, cliprect, layer[0], 0, 1);
116   k052109_tilemap_draw(k052109, bitmap, cliprect, layer[1], 0, 2);
117   k052109_tilemap_draw(k052109, bitmap, cliprect, layer[2], 0, 4);
126118
127119/* this isn't supported anymore and it is unsure if still needed; keeping here for reference
128120    pdrawgfx_shadow_lowpri = 1; fix shadows of boulders in front of feet */
129   K053247_sprites_draw(screen->machine, bitmap,cliprect);
121   k053247_sprites_draw(k053246, bitmap, cliprect);
130122   return 0;
131123}
132124
133125
134126VIDEO_UPDATE( xmen6p )
135127{
136   int x,y;
137
138128    const device_config *left_screen   = devtag_get_device(screen->machine, "lscreen");
139129   const device_config *right_screen  = devtag_get_device(screen->machine, "rscreen");
130   int x,y;
140131
141132   if (screen == left_screen)
142      for(y=0;y<32*8;y++)
133      for(y = 0; y < 32 * 8; y++)
143134      {
144135         UINT16* line_dest = BITMAP_ADDR16(bitmap, y, 0);
145136         UINT16* line_src = BITMAP_ADDR16(screen_left, y, 0);
146137
147         for (x=12*8;x<52*8;x++)
138         for (x = 12 * 8; x < 52 * 8; x++)
148139            line_dest[x] = line_src[x];
149140      }
150141   else if (screen == right_screen)
151      for(y=0;y<32*8;y++)
142      for(y = 0; y < 32 * 8; y++)
152143      {
153144         UINT16* line_dest = BITMAP_ADDR16(bitmap, y, 0);
154145         UINT16* line_src = BITMAP_ADDR16(screen_right, y, 0);
155146
156         for (x=12*8;x<52*8;x++)
147         for (x = 12 * 8; x < 52 * 8; x++)
157148            line_dest[x] = line_src[x];
158149      }
159150
r6740r6741
163154/* my lefts and rights are mixed up in several places.. */
164155VIDEO_EOF( xmen6p )
165156{
166   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
157   const device_config *k052109 = devtag_get_device(machine, "k052109");
158   const device_config *k053246 = devtag_get_device(machine, "k053246");
159   const device_config *k053251 = devtag_get_device(machine, "k053251");
167160   int layer[3];
168161   bitmap_t * renderbitmap;
169162   rectangle cliprect;
r6740r6741
186179   if (xmen_current_frame & 0x01)
187180   {
188181
189         /* copy the desired spritelist to the chip */
182      /* copy the desired spritelist to the chip */
190183      memcpy(K053247_ram, xmen6p_spriteramright, 0x1000);
184
191185      /* we write the entire content of the tileram to the chip to ensure
192186           everything gets marked as dirty and the desired tilemap is rendered
193
194187           this is not very efficient!
195188           */
196189      for (offset = 0; offset < (0xc000 / 2); offset++)
197190      {
198191//          K052109_lsb_w
199         K052109_w(space, offset, xmen6p_tilemapright[offset] & 0x00ff);
192         k052109_w(k052109, offset, xmen6p_tilemapright[offset] & 0x00ff);
200193      }
201194
202195
r6740r6741
215208      for (offset = 0; offset < (0xc000 / 2); offset++)
216209      {
217210//          K052109_lsb_w
218         K052109_w(space, offset, xmen6p_tilemapleft[offset] & 0x00ff);
211         k052109_w(k052109, offset, xmen6p_tilemapleft[offset] & 0x00ff);
219212      }
220213
221214
r6740r6741
223216   }
224217
225218
226   bg_colorbase       = K053251_get_palette_index(K053251_CI4);
227   sprite_colorbase   = K053251_get_palette_index(K053251_CI1);
228   layer_colorbase[0] = K053251_get_palette_index(K053251_CI3);
229   layer_colorbase[1] = K053251_get_palette_index(K053251_CI0);
230   layer_colorbase[2] = K053251_get_palette_index(K053251_CI2);
219   bg_colorbase       = k053251_get_palette_index(k053251, K053251_CI4);
220   sprite_colorbase   = k053251_get_palette_index(k053251, K053251_CI1);
221   layer_colorbase[0] = k053251_get_palette_index(k053251, K053251_CI3);
222   layer_colorbase[1] = k053251_get_palette_index(k053251, K053251_CI0);
223   layer_colorbase[2] = k053251_get_palette_index(k053251, K053251_CI2);
231224
232   K052109_tilemap_update();
225   k052109_tilemap_update(k052109);
233226
234227   layer[0] = 0;
235   layerpri[0] = K053251_get_priority(K053251_CI3);
228   layerpri[0] = k053251_get_priority(k053251, K053251_CI3);
236229   layer[1] = 1;
237   layerpri[1] = K053251_get_priority(K053251_CI0);
230   layerpri[1] = k053251_get_priority(k053251, K053251_CI0);
238231   layer[2] = 2;
239   layerpri[2] = K053251_get_priority(K053251_CI2);
232   layerpri[2] = k053251_get_priority(k053251, K053251_CI2);
240233
241234   sortlayers(layer,layerpri);
242235
243236   bitmap_fill(machine->priority_bitmap, &cliprect, 0);
244237   /* note the '+1' in the background color!!! */
245238   bitmap_fill(renderbitmap, &cliprect, 16 * bg_colorbase + 1);
246   tilemap_draw(renderbitmap, &cliprect, K052109_tilemap[layer[0]], 0, 1);
247   tilemap_draw(renderbitmap, &cliprect, K052109_tilemap[layer[1]], 0, 2);
248   tilemap_draw(renderbitmap, &cliprect, K052109_tilemap[layer[2]], 0, 4);
239   k052109_tilemap_draw(k052109, renderbitmap, &cliprect, layer[0], 0, 1);
240   k052109_tilemap_draw(k052109, renderbitmap, &cliprect, layer[1], 0, 2);
241   k052109_tilemap_draw(k052109, renderbitmap, &cliprect, layer[2], 0, 4);
249242
250243/* this isn't supported anymore and it is unsure if still needed; keeping here for reference
251244    pdrawgfx_shadow_lowpri = 1; fix shadows of boulders in front of feet */
252   K053247_sprites_draw(machine, renderbitmap, &cliprect);
245   k053247_sprites_draw(k053246, renderbitmap, &cliprect);
253246}
src/mame/video/lethal.c
r6740r6741
88***************************************************************************/
99
1010#include "driver.h"
11#include "video/konamiic.h"
11#include "video/konicdev.h"
1212
1313
1414static int sprite_colorbase;
1515static int layer_colorbase[4];
1616//static int layerpri[4] ={ 1,2,4,0 };
1717
18static void lethalen_sprite_callback(int *code, int *color, int *priority_mask)
18void lethalen_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask)
1919{
2020   int pri = (*color & 0xfff0);
2121   *color = *color & 0x000f;
r6740r6741
3838   *code = (*code & 0x3fff); // | spritebanks[(*code >> 12) & 3];
3939}
4040
41static void lethalen_tile_callback(int layer, int *code, int *color, int *flags)
41void lethalen_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags)
4242{
4343   *color = layer_colorbase[layer] + ((*color & 0x3c)<<2);
4444}
4545
4646VIDEO_START(lethalen)
4747{
48   K053251_vh_start(machine);
48   const device_config *k056832 = devtag_get_device(machine, "k056832");
4949
50   K056832_vh_start(machine, "gfx1", K056832_BPP_8LE, 1, NULL, lethalen_tile_callback, 0);
51
52   K053245_vh_start(machine, 0, "gfx3",NORMAL_PLANE_ORDER, lethalen_sprite_callback);
53
5450   // this game uses external linescroll RAM
55   K056832_SetExtLinescroll();
51   k056832_SetExtLinescroll(k056832);
5652
5753   // the US and Japanese cabinets apparently use different mirror setups
5854   if (!strcmp(machine->gamedrv->name, "lethalenj"))
5955   {
60      K056832_set_LayerOffset(0, -196, 0);
61      K056832_set_LayerOffset(1, -194, 0);
62      K056832_set_LayerOffset(2, -192, 0);
63      K056832_set_LayerOffset(3, -190, 0);
64      K053245_set_SpriteOffset(0, -105, 0);
56      k056832_set_layer_offs(k056832, 0, -196, 0);
57      k056832_set_layer_offs(k056832, 1, -194, 0);
58      k056832_set_layer_offs(k056832, 2, -192, 0);
59      k056832_set_layer_offs(k056832, 3, -190, 0);
6560   }
6661   else
6762   { /* fixme */
68       K056832_set_LayerOffset(0, 188, 0);
69      K056832_set_LayerOffset(1, 190, 0);
70      K056832_set_LayerOffset(2, 192, 0);
71      K056832_set_LayerOffset(3, 194, 0);
72      K053245_set_SpriteOffset(0, 95, 0);
63       k056832_set_layer_offs(k056832, 0, 188, 0);
64      k056832_set_layer_offs(k056832, 1, 190, 0);
65      k056832_set_layer_offs(k056832, 2, 192, 0);
66      k056832_set_layer_offs(k056832, 3, 194, 0);
7367   }
7468
7569   layer_colorbase[0] = 0x00;
r6740r6741
8074
8175WRITE8_HANDLER(lethalen_palette_control)
8276{
77   const device_config *k056832 = devtag_get_device(space->machine, "k056832");
78
8379   switch (offset)
8480   {
8581      case 0:   // 40c8 - PCU1 from schematics
8682         layer_colorbase[0] = ((data & 0x7)-1) * 0x40;
8783         layer_colorbase[1] = (((data>>4) & 0x7)-1) * 0x40;
88         K056832_mark_plane_dirty(0);
89         K056832_mark_plane_dirty(1);
84         k056832_mark_plane_dirty(k056832, 0);
85         k056832_mark_plane_dirty(k056832, 1);
9086         break;
9187
9288      case 4: // 40cc - PCU2 from schematics
9389         layer_colorbase[2] = ((data & 0x7)-1) * 0x40;
9490         layer_colorbase[3] = (((data>>4) & 0x7)-1) * 0x40;
95         K056832_mark_plane_dirty(2);
96         K056832_mark_plane_dirty(3);
91         k056832_mark_plane_dirty(k056832, 2);
92         k056832_mark_plane_dirty(k056832, 3);
9793         break;
9894
9995      case 8:   // 40d0 - PCU3 from schematics
r6740r6741
104100
105101VIDEO_UPDATE(lethalen)
106102{
103   const device_config *k056832 = devtag_get_device(screen->machine, "k056832");
104   const device_config *k053244 = devtag_get_device(screen->machine, "k053244");
105
107106   bitmap_fill(bitmap, cliprect, 7168);
108107   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
109108
110   K056832_tilemap_draw(screen->machine, bitmap, cliprect, 3, 0, 1);
111   K056832_tilemap_draw(screen->machine, bitmap, cliprect, 2, 0, 2);
112   K056832_tilemap_draw(screen->machine, bitmap, cliprect, 1, 0, 4);
109   k056832_tilemap_draw(k056832, bitmap, cliprect, 3, 0, 1);
110   k056832_tilemap_draw(k056832, bitmap, cliprect, 2, 0, 2);
111   k056832_tilemap_draw(k056832, bitmap, cliprect, 1, 0, 4);
113112
114   K053245_sprites_draw_lethal(screen->machine,0, bitmap, cliprect);
113   k053245_sprites_draw_lethal(k053244, bitmap, cliprect);
115114
116115   // force "A" layer over top of everything
117   K056832_tilemap_draw(screen->machine, bitmap, cliprect, 0, 0, 0);
116   k056832_tilemap_draw(k056832, bitmap, cliprect, 0, 0, 0);
118117
119
120#if 0
121   {
122      extern UINT16 *K056832_videoram;
123      FILE *fp;
124
125      fp=fopen("K056832_videoram", "w+b");
126      if (fp)
127      {
128         fwrite(K056832_videoram, 0x10000, 2, fp);
129         fclose(fp);
130      }
131   }
132#endif
133118   return 0;
134119}
src/mame/video/exprraid.c
r6740r6741
11#include "driver.h"
2#include "exprraid.h"
2#include "includes/exprraid.h"
33
44
55WRITE8_HANDLER( exprraid_videoram_w )
src/mame/video/ultratnk.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "ultratnk.h"
8#include "includes/ultratnk.h"
99#include "audio/sprint4.h"
1010
1111static tilemap* playfield;
src/mame/video/scotrsht.c
r6740r6741
22
33UINT8 *scotrsht_scroll;
44
5UINT8 *scotrsht_videoram;
6UINT8 *scotrsht_colorram;
57static tilemap *bg_tilemap;
68static int scotrsht_charbank = 0;
79static int scotrsht_palette_bank = 0;
r6740r6741
4244
4345WRITE8_HANDLER( scotrsht_videoram_w )
4446{
45   space->machine->generic.videoram.u8[offset] = data;
47   scotrsht_videoram[offset] = data;
4648   tilemap_mark_tile_dirty(bg_tilemap, offset);
4749}
4850
4951WRITE8_HANDLER( scotrsht_colorram_w )
5052{
51   space->machine->generic.colorram.u8[offset] = data;
53   scotrsht_colorram[offset] = data;
5254   tilemap_mark_tile_dirty(bg_tilemap, offset);
5355}
5456
r6740r6741
8082
8183static TILE_GET_INFO( scotrsht_get_bg_tile_info )
8284{
83   int attr = machine->generic.colorram.u8[tile_index];
84   int code = machine->generic.videoram.u8[tile_index] + (scotrsht_charbank << 9) + ((attr & 0x40) << 2);
85   int attr = scotrsht_colorram[tile_index];
86   int code = scotrsht_videoram[tile_index] + (scotrsht_charbank << 9) + ((attr & 0x40) << 2);
8587   int color = (attr & 0x0f) + scotrsht_palette_bank * 16;
8688   int flag = 0;
8789
src/mame/video/phoenix.c
r6740r6741
88
99#include "driver.h"
1010#include "video/resnet.h"
11#include "phoenix.h"
11#include "includes/phoenix.h"
1212
1313static UINT8 *videoram_pg[2];
1414static UINT8 videoram_pg_index;
src/mame/video/dday.c
r6740r6741
1010
1111#include "driver.h"
1212#include "sound/ay8910.h"
13#include "dday.h"
13#include "includes/dday.h"
1414
1515
1616/* Note: There seems to be no way to reset this timer via hardware.
src/mame/video/cyberbal.c
r6740r6741
66
77#include "driver.h"
88#include "machine/atarigen.h"
9#include "cyberbal.h"
9#include "includes/cyberbal.h"
1010
1111
1212#define SCREEN_WIDTH      (42*16)
r6740r6741
172172      tilemap_set_scrollx(state->atarigen.alpha2_tilemap, 0, 0);
173173      tilemap_set_transparent_pen(state->atarigen.alpha2_tilemap, 0);
174174   }
175
176   /* save states */
177   state_save_register_global_array(machine, state->current_slip);
178   state_save_register_global_array(machine, state->playfield_palette_bank);
179   state_save_register_global_array(machine, state->playfield_xscroll);
180   state_save_register_global_array(machine, state->playfield_yscroll);
175181}
176182
177183
src/mame/video/lockon.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "lockon.h"
8#include "includes/lockon.h"
99#include "cpu/nec/nec.h"
1010#include "video/resnet.h"
1111
src/mame/video/gijoe.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
44
55static int AVAC_bits[4], AVAC_occupancy[4];
66static int layer_colorbase[4], layer_pri[4];
77static int AVAC_vrc, sprite_colorbase;
88
9static void gijoe_sprite_callback(int *code, int *color, int *priority_mask)
9void gijoe_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask)
1010{
1111   int pri, c = *color;
1212
r6740r6741
2121   *color = sprite_colorbase | (c & 0x001f);
2222}
2323
24static void gijoe_tile_callback(int layer, int *code, int *color, int *flags)
24void gijoe_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags)
2525{
2626   int tile = *code;
2727
r6740r6741
3939
4040VIDEO_START( gijoe )
4141{
42   const device_config *k056832 = devtag_get_device(machine, "k056832");
4243   int i;
4344
44   K053251_vh_start(machine);
45   K056832_vh_start(machine, "gfx1", K056832_BPP_4, 1, NULL, gijoe_tile_callback, 0);
45   k056832_linemap_enable(k056832, 1);
4646
47   K056832_linemap_enable(1);
47   for (i = 0; i < 4; i++)
48      AVAC_occupancy[i] = 0;
4849
49   K053247_vh_start(machine, "gfx2", -37, 20, NORMAL_PLANE_ORDER, gijoe_sprite_callback);
50
51   for (i=0; i<4; i++) AVAC_occupancy[i] = 0;
5250   AVAC_vrc = 0xffff;
5351}
5452
r6740r6741
7371
7472VIDEO_UPDATE( gijoe )
7573{
74   const device_config *k056832 = devtag_get_device(screen->machine, "k056832");
75   const device_config *k053251 = devtag_get_device(screen->machine, "k053251");
76   const device_config *k053246 = devtag_get_device(screen->machine, "k053246");
7677   static const int K053251_CI[4] = { K053251_CI1, K053251_CI2, K053251_CI3, K053251_CI4 };
7778   int layer[4];
7879   int vrc_mode, vrc_new, colorbase_new, primode, dirty, i;
7980   int mask = 0;
8081
8182   // update tile offsets
82   K056832_read_AVAC(&vrc_mode, &vrc_new);
83   k056832_read_avac(k056832, &vrc_mode, &vrc_new);
8384
8485   if (vrc_mode)
8586   {
86      for (dirty=0xf000; dirty; dirty>>=4) if ((AVAC_vrc & dirty) != (vrc_new & dirty)) mask |= dirty;
87      for (dirty = 0xf000; dirty; dirty >>= 4)
88         if ((AVAC_vrc & dirty) != (vrc_new & dirty))
89            mask |= dirty;
8790
8891      AVAC_vrc = vrc_new;
8992      AVAC_bits[0] = vrc_new<<4  & 0xf000;
r6740r6741
9598      AVAC_bits[3] = AVAC_bits[2] = AVAC_bits[1] = AVAC_bits[0] = 0xf000;
9699
97100   // update color info and refresh tilemaps
98   sprite_colorbase = K053251_get_palette_index(K053251_CI0);
101   sprite_colorbase = k053251_get_palette_index(k053251, K053251_CI0);
99102
100   for (i=0; i<4; i++)
103   for (i = 0; i < 4; i++)
101104   {
102105      dirty = 0;
103106
104      colorbase_new = K053251_get_palette_index(K053251_CI[i]);
105      if (layer_colorbase[i] != colorbase_new) { layer_colorbase[i] = colorbase_new; dirty = 1; }
106      if (AVAC_occupancy[i] & mask) dirty = 1;
107      colorbase_new = k053251_get_palette_index(k053251, K053251_CI[i]);
108      if (layer_colorbase[i] != colorbase_new)
109      {
110         layer_colorbase[i] = colorbase_new;
111         dirty = 1;
112      }
113      if (AVAC_occupancy[i] & mask)
114         dirty = 1;
107115
108      if (dirty) { AVAC_occupancy[i] = 0; K056832_mark_plane_dirty(i); }
116      if (dirty)
117      {
118         AVAC_occupancy[i] = 0;
119         k056832_mark_plane_dirty(k056832, i);
120      }
109121   }
110122
111123   /*
r6740r6741
114126        written to the layer's X-scroll register otherwise the chip expects totally
115127        different alignment values.
116128    */
117   if (K056832_read_register(0x14) == 2)
129   if (k056832_read_register(k056832, 0x14) == 2)
118130   {
119      K056832_set_LayerOffset(0,  2, 0);
120      K056832_set_LayerOffset(1,  4, 0);
121      K056832_set_LayerOffset(2,  6, 0); // 7?
122      K056832_set_LayerOffset(3,  8, 0);
131      k056832_set_layer_offs(k056832, 0,  2, 0);
132      k056832_set_layer_offs(k056832, 1,  4, 0);
133      k056832_set_layer_offs(k056832, 2,  6, 0); // 7?
134      k056832_set_layer_offs(k056832, 3,  8, 0);
123135   }
124136   else
125137   {
126      K056832_set_LayerOffset(0,  0, 0);
127      K056832_set_LayerOffset(1,  8, 0);
128      K056832_set_LayerOffset(2, 14, 0);
129      K056832_set_LayerOffset(3, 16, 0); // smaller?
138      k056832_set_layer_offs(k056832, 0,  0, 0);
139      k056832_set_layer_offs(k056832, 1,  8, 0);
140      k056832_set_layer_offs(k056832, 2, 14, 0);
141      k056832_set_layer_offs(k056832, 3, 16, 0); // smaller?
130142   }
131143
132144   // seems to switch the K053251 between different priority modes, detail unknown
133   primode = K053251_get_priority(K053251_CI1);
145   primode = k053251_get_priority(k053251, K053251_CI1);
134146
135147   layer[0] = 0;
136148   layer_pri[0] = 0; // not sure
137149   layer[1] = 1;
138   layer_pri[1] = K053251_get_priority(K053251_CI2);
150   layer_pri[1] = k053251_get_priority(k053251, K053251_CI2);
139151   layer[2] = 2;
140   layer_pri[2] = K053251_get_priority(K053251_CI3);
152   layer_pri[2] = k053251_get_priority(k053251, K053251_CI3);
141153   layer[3] = 3;
142   layer_pri[3] = K053251_get_priority(K053251_CI4);
154   layer_pri[3] = k053251_get_priority(k053251, K053251_CI4);
143155
144156   sortlayers(layer, layer_pri);
145157
146158   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
147159   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
148160
149   K056832_tilemap_draw(screen->machine, bitmap,cliprect, layer[0], 0, 1);
150   K056832_tilemap_draw(screen->machine, bitmap,cliprect, layer[1], 0, 2);
151   K056832_tilemap_draw(screen->machine, bitmap,cliprect, layer[2], 0, 4);
152   K056832_tilemap_draw(screen->machine, bitmap,cliprect, layer[3], 0, 8);
161   k056832_tilemap_draw(k056832, bitmap,cliprect, layer[0], 0, 1);
162   k056832_tilemap_draw(k056832, bitmap,cliprect, layer[1], 0, 2);
163   k056832_tilemap_draw(k056832, bitmap,cliprect, layer[2], 0, 4);
164   k056832_tilemap_draw(k056832, bitmap,cliprect, layer[3], 0, 8);
153165
154   K053247_sprites_draw(screen->machine, bitmap, cliprect);
166   k053247_sprites_draw(k053246, bitmap, cliprect);
155167   return 0;
156168}
src/mame/video/rdpupd16.c
r6740r6741
8787            //{
8888               //if (vibuffering)
8989               //{
90               //   restore_filter16_buffer(&r, &g, &b, &ViBuffer[i][j], n64_vi_width);
90               //  restore_filter16_buffer(&r, &g, &b, &ViBuffer[i][j], n64_vi_width);
9191               //}
9292               //else
9393               //{
r6740r6741
9999            {
100100               //if (vibuffering)
101101               //{
102               //   divot_filter16_buffer(&r, &g, &b, &ViBuffer[i][j]);
102               //  divot_filter16_buffer(&r, &g, &b, &ViBuffer[i][j]);
103103               //}
104104               //else
105105               //{
r6740r6741
109109#endif
110110
111111            /*
112            if (gamma_dither)
113            {
114               dith = mame_rand(screen->machine) & 0x3f;
115            }
116            if (gamma)
117            {
118               if (gamma_dither)
119               {
120                  r = gamma_dither_table[(r << 6)|dith];
121                  g = gamma_dither_table[(g << 6)|dith];
122                  b = gamma_dither_table[(b << 6)|dith];
123               }
124               else
125               {
126                  r = gamma_table[r];
127                  g = gamma_table[g];
128                  b = gamma_table[b];
129               }
130            }
131            else if (gamma_dither)
132            {
133               if (r < 255)
134                  r += (dith & 1);
135               if (g < 255)
136                  g += (dith & 1);
137               if (b < 255)
138                  b += (dith & 1);
139            }
140            */
112                if (gamma_dither)
113                {
114                    dith = mame_rand(screen->machine) & 0x3f;
115                }
116                if (gamma)
117                {
118                    if (gamma_dither)
119                    {
120                        r = gamma_dither_table[(r << 6)|dith];
121                        g = gamma_dither_table[(g << 6)|dith];
122                        b = gamma_dither_table[(b << 6)|dith];
123                    }
124                    else
125                    {
126                        r = gamma_table[r];
127                        g = gamma_table[g];
128                        b = gamma_table[b];
129                    }
130                }
131                else if (gamma_dither)
132                {
133                    if (r < 255)
134                        r += (dith & 1);
135                    if (g < 255)
136                        g += (dith & 1);
137                    if (b < 255)
138                        b += (dith & 1);
139                }
140                */
141141            pixels++;
142142
143143            final = (r << 16) | (g << 8) | b;
src/mame/video/segas32.c
r6740r6741
143143
144144#include "driver.h"
145145#include "profiler.h"
146#include "segas32.h"
146#include "includes/segas32.h"
147147
148148
149149
src/mame/video/badlands.c
r6740r6741
7777
7878   /* initialize the motion objects */
7979   atarimo_init(machine, 0, &modesc);
80
81   /* save states */
82   state_save_register_global(machine, state->playfield_tile_bank);
8083}
8184
8285
src/mame/video/slapfght.c
r6740r6741
1111
1212UINT8 *slapfight_videoram;
1313UINT8 *slapfight_colorram;
14size_t slapfight_videoram_size;
14UINT8 *slapfight_fixvideoram;
15UINT8 *slapfight_fixcolorram;
1516UINT8 *slapfight_scrollx_lo,*slapfight_scrollx_hi,*slapfight_scrolly;
1617static int flipscreen, slapfight_palette_bank = 0;
1718
r6740r6741
3031{
3132   int tile,color;
3233
33   tile=machine->generic.videoram.u8[tile_index] + ((machine->generic.colorram.u8[tile_index] & 0x03) << 8);
34   color=(machine->generic.colorram.u8[tile_index] >> 3) & 0x0f;
34   tile=slapfight_videoram[tile_index] + ((slapfight_colorram[tile_index] & 0x03) << 8);
35   color=(slapfight_colorram[tile_index] >> 3) & 0x0f;
3536   SET_TILE_INFO(
3637         0,
3738         tile,
r6740r6741
4344{
4445   int tile,color;
4546
46   tile=machine->generic.videoram.u8[tile_index] + ((machine->generic.colorram.u8[tile_index] & 0x0f) << 8);
47   color=(machine->generic.colorram.u8[tile_index] & 0xf0) >> 4;
47   tile=slapfight_videoram[tile_index] + ((slapfight_colorram[tile_index] & 0x0f) << 8);
48   color=(slapfight_colorram[tile_index] & 0xf0) >> 4;
4849
4950   SET_TILE_INFO(
5051         1,
r6740r6741
5758{
5859   int tile,color;
5960
60   tile=slapfight_videoram[tile_index] + ((slapfight_colorram[tile_index] & 0x03) << 8);
61   color=(slapfight_colorram[tile_index] & 0xfc) >> 2;
61   tile=slapfight_fixvideoram[tile_index] + ((slapfight_fixcolorram[tile_index] & 0x03) << 8);
62   color=(slapfight_fixcolorram[tile_index] & 0xfc) >> 2;
6263
6364   SET_TILE_INFO(
6465         0,
r6740r6741
9899
99100WRITE8_HANDLER( slapfight_videoram_w )
100101{
101   space->machine->generic.videoram.u8[offset]=data;
102   slapfight_videoram[offset]=data;
102103   tilemap_mark_tile_dirty(pf1_tilemap,offset);
103104}
104105
105106WRITE8_HANDLER( slapfight_colorram_w )
106107{
107   space->machine->generic.colorram.u8[offset]=data;
108   slapfight_colorram[offset]=data;
108109   tilemap_mark_tile_dirty(pf1_tilemap,offset);
109110}
110111
111112WRITE8_HANDLER( slapfight_fixram_w )
112113{
113   slapfight_videoram[offset]=data;
114   slapfight_fixvideoram[offset]=data;
114115   tilemap_mark_tile_dirty(fix_tilemap,offset);
115116}
116117
117118WRITE8_HANDLER( slapfight_fixcol_w )
118119{
119   slapfight_colorram[offset]=data;
120   slapfight_fixcolorram[offset]=data;
120121   tilemap_mark_tile_dirty(fix_tilemap,offset);
121122}
122123
r6740r6741
140141      int i;
141142      for (i=0; i<0x800; i++)
142143      {
143         logerror("Offset:%03x   TileRAM:%02x   AttribRAM:%02x   SpriteRAM:%02x\n",i, machine->generic.videoram.u8[i],machine->generic.colorram.u8[i],machine->generic.spriteram.u8[i]);
144         logerror("Offset:%03x   TileRAM:%02x   AttribRAM:%02x   SpriteRAM:%02x\n",i, slapfight_videoram[i],slapfight_colorram[i],machine->generic.spriteram.u8[i]);
144145      }
145146   }
146147#endif
src/mame/video/psikyosh.c
r6740r6741
4242
4343/*
4444BG Scroll/Priority/Zoom/Alpha/Tilebank:
45Either at 0x30053f0/4/8 (For 0a/0c/0d), 0x3005bf0/4/8 (For 0b) Or per-line in a bank (For 0e-1f)
45Either at 0x30053f0 / 4/8 (For 0a/0c/0d), 0x3005bf0 / 4/8 (For 0b) Or per-line in a bank (For 0e-1f)
4646   0x?vvv?xxx - v = vertical scroll - x = x scroll
47Either at 0x30057f0/4/8 (For 0a/0c/0d), 0x3005ff0/4/8 (For 0b) Or per-line in a bank (For 0e-1f)
47Either at 0x30057f0 / 4/8 (For 0a/0c/0d), 0x3005ff0 / 4/8 (For 0b) Or per-line in a bank (For 0e-1f)
4848   0xppzzaabb - p = priority, z = zoom/expand(00 is none), a = alpha value/effect, b = tilebank (used when register below = 0x0a)
4949
5050
r6740r6741
9191
9292#include "driver.h"
9393#include "profiler.h"
94#include "psikyosh.h"
9594#include "drawgfxm.h"
95#include "includes/psikyosh.h"
9696
97/* Needed for psikyosh_drawgfxzoom */
98static bitmap_t *zoom_bitmap, *z_bitmap;
99static UINT8 alphatable[256];
100
10197/* Psikyo PS6406B */
10298/* --- BACKGROUNDS --- */
10399
104#define PIXEL_OP_REMAP_TRANS0_ALPHATABLE32(DEST, PRIORITY, SOURCE)               \
105do                                                               \
106{                                                               \
100static UINT8 alphatable[256];   // this might be moved to psikyosh_state, if we ever add a *machine parameter to drawgfxm.h macros
101
102#define PIXEL_OP_REMAP_TRANS0_ALPHATABLE32(DEST, PRIORITY, SOURCE)            \
103do                                                         \
104{                                                         \
107105   UINT32 srcdata = (SOURCE);                                          \
108106   if (srcdata != 0)                                                \
109107      (DEST) = alpha_blend_r32((DEST), paldata[srcdata], alphatable[srcdata]);   \
110}                                                               \
111while (0)                                                         \
108}                                                         \
109while (0)                                                      \
112110
113111static void drawgfx_alphatable(bitmap_t *dest, const rectangle *cliprect, const gfx_element *gfx,
114112      UINT32 code, UINT32 color, int flipx, int flipy, INT32 destx, INT32 desty,
r6740r6741
145143
146144
147145/* 'Normal' layers, no line/columnscroll. No per-line effects */
148static void draw_bglayer(running_machine *machine, int layer, bitmap_t *bitmap, const rectangle *cliprect )
146static void draw_bglayer( running_machine *machine, int layer, bitmap_t *bitmap, const rectangle *cliprect )
149147{
148   psikyosh_state *state = (psikyosh_state *)machine->driver_data;
150149   gfx_element *gfx;
151   int offs=0, sx, sy;
150   int offs = 0, sx, sy;
152151   int scrollx, scrolly, bank, alpha, alphamap, size, width;
153152
154   if ( BG_TYPE(layer) == BG_NORMAL_ALT )
153   if (BG_TYPE(layer) == BG_NORMAL_ALT)
155154   {
156      bank    = (psikyosh_bgram[0x1ff0/4 + (layer*0x04)/4] & 0x000000ff) >> 0;
157      alpha   = (psikyosh_bgram[0x1ff0/4 + (layer*0x04)/4] & 0x00003f00) >> 8;
158      alphamap =(psikyosh_bgram[0x1ff0/4 + (layer*0x04)/4] & 0x00008000) >> 15;
159      scrollx = (psikyosh_bgram[0x1bf0/4 + (layer*0x04)/4] & 0x000001ff) >> 0;
160      scrolly = (psikyosh_bgram[0x1bf0/4 + (layer*0x04)/4] & 0x03ff0000) >> 16;
155      bank     = (state->bgram[0x1ff0 / 4 + (layer * 0x04) / 4] & 0x000000ff) >> 0;
156      alpha    = (state->bgram[0x1ff0 / 4 + (layer * 0x04) / 4] & 0x00003f00) >> 8;
157      alphamap = (state->bgram[0x1ff0 / 4 + (layer * 0x04) / 4] & 0x00008000) >> 15;
158      scrollx  = (state->bgram[0x1bf0 / 4 + (layer * 0x04) / 4] & 0x000001ff) >> 0;
159      scrolly  = (state->bgram[0x1bf0 / 4 + (layer * 0x04) / 4] & 0x03ff0000) >> 16;
161160   }
162161   else /* BG_NORMAL */
163162   {
164      bank    = (psikyosh_bgram[0x17f0/4 + (layer*0x04)/4] & 0x000000ff) >> 0;
165      alpha   = (psikyosh_bgram[0x17f0/4 + (layer*0x04)/4] & 0x00003f00) >> 8;
166      alphamap =(psikyosh_bgram[0x17f0/4 + (layer*0x04)/4] & 0x00008000) >> 15;
167      scrollx = (psikyosh_bgram[0x13f0/4 + (layer*0x04)/4] & 0x000001ff) >> 0;
168      scrolly = (psikyosh_bgram[0x13f0/4 + (layer*0x04)/4] & 0x03ff0000) >> 16;
163      bank     = (state->bgram[0x17f0 / 4 + (layer * 0x04) / 4] & 0x000000ff) >> 0;
164      alpha    = (state->bgram[0x17f0 / 4 + (layer * 0x04) / 4] & 0x00003f00) >> 8;
165      alphamap = (state->bgram[0x17f0 / 4 + (layer * 0x04) / 4] & 0x00008000) >> 15;
166      scrollx  = (state->bgram[0x13f0 / 4 + (layer * 0x04) / 4] & 0x000001ff) >> 0;
167      scrolly  = (state->bgram[0x13f0 / 4 + (layer * 0x04) / 4] & 0x03ff0000) >> 16;
169168   }
170169
171   if ( BG_TYPE(layer) == BG_SCROLL_0D ) scrollx += 0x08; /* quick kludge until using rowscroll */
170   if (BG_TYPE(layer) == BG_SCROLL_0D)
171      scrollx += 0x08; /* quick kludge until using rowscroll */
172172
173173   gfx = BG_DEPTH_8BPP(layer) ? machine->gfx[1] : machine->gfx[0];
174174   size = BG_LARGE(layer) ? 32 : 16;
175175   width = BG_LARGE(layer) ? 0x200 : 0x100;
176176
177   if(alphamap) { /* alpha values are per-pen */
177   if (alphamap) /* alpha values are per-pen */
178178      alpha = -1;
179   } else {
180      alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
181   }
179   else
180      alpha = ((0x3f - alpha) * 0xff) / 0x3f;   /* 0x3f-0x00 maps to 0x00-0xff */
182181
183   if((bank>=0x0c) && (bank<=0x1f)) /* shouldn't happen, 20 banks of 0x800 bytes */
182
183   if ((bank >= 0x0c) && (bank <= 0x1f)) /* shouldn't happen, 20 banks of 0x800 bytes */
184184   {
185      for (sy=0; sy<size; sy++)
185      for (sy = 0; sy < size; sy++)
186186      {
187         for (sx=0; sx<32; sx++)
187         for (sx = 0; sx < 32; sx++)
188188         {
189189            int tileno, colour;
190190
191            tileno = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
192            colour = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0xff000000) >> 24;
191            tileno = (state->bgram[(bank * 0x800) / 4 + offs - 0x4000 / 4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
192            colour = (state->bgram[(bank * 0x800) / 4 + offs - 0x4000 / 4] & 0xff000000) >> 24;
193193
194            drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),alpha); /* normal */
195            if(scrollx)
196               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),alpha); /* wrap x */
197            if(scrolly)
198               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap y */
199            if(scrollx && scrolly)
200               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap xy */
194            drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)), alpha); /* normal */
201195
196            if (scrollx)
197               drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, ((16 * sx + scrollx) & 0x1ff) - 0x200, ((16 * sy + scrolly) & (width - 1)), alpha); /* wrap x */
198            if (scrolly)
199               drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)) - width, alpha); /* wrap y */
200            if (scrollx && scrolly)
201               drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, ((16 * sx + scrollx) & 0x1ff) - 0x200, ((16 * sy + scrolly) & (width - 1)) - width, alpha); /* wrap xy */
202
202203            offs++;
203204         }
204205      }
r6740r6741
207208
208209/* This is a complete bodge for the daraku text layers. There is not enough info to be sure how it is supposed to work */
209210/* It appears that there are row/column scroll values for 2 seperate layers, just drawing it twice using one of each of the sets of values for now */
210static void draw_bglayertext(running_machine *machine, int layer, bitmap_t *bitmap, const rectangle *cliprect )
211static void draw_bglayertext( running_machine *machine, int layer, bitmap_t *bitmap, const rectangle *cliprect )
211212{
213   psikyosh_state *state = (psikyosh_state *)machine->driver_data;
212214   gfx_element *gfx;
213215   int offs, sx, sy;
214   int scrollx, scrolly, bank, size, width, scrollbank,alpha,alphamap;
216   int scrollx, scrolly, bank, size, width, scrollbank, alpha, alphamap;
215217
216218   scrollbank = BG_TYPE(layer); /* Scroll bank appears to be same as layer type */
217219
r6740r6741
220222   width = BG_LARGE(layer) ? 0x200 : 0x100;
221223
222224   /* Use first values from the first set of scroll values */
223   bank    = (psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 - 0x4000/4] & 0x000000ff) >> 0;
224   alpha   = (psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 - 0x4000/4] & 0x00003f00) >> 8;
225   alphamap =(psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 - 0x4000/4] & 0x00008000) >> 15;
226   scrollx = (psikyosh_bgram[(scrollbank*0x800)/4 - 0x4000/4] & 0x000001ff) >> 0;
227   scrolly = (psikyosh_bgram[(scrollbank*0x800)/4 - 0x4000/4] & 0x03ff0000) >> 16;
225   bank     = (state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 - 0x4000 / 4] & 0x000000ff) >> 0;
226   alpha    = (state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 - 0x4000 / 4] & 0x00003f00) >> 8;
227   alphamap = (state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 - 0x4000 / 4] & 0x00008000) >> 15;
228   scrollx  = (state->bgram[(scrollbank * 0x800) / 4 - 0x4000 / 4] & 0x000001ff) >> 0;
229   scrolly  = (state->bgram[(scrollbank * 0x800) / 4 - 0x4000 / 4] & 0x03ff0000) >> 16;
228230
229   if(alphamap) { /* alpha values are per-pen */
231   if (alphamap)   /* alpha values are per-pen */
230232      alpha = -1;
231   } else {
232      alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
233   }
233   else
234      alpha = ((0x3f - alpha) * 0xff) / 0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
234235
235
236   if((bank>=0x0c) && (bank<=0x1f)) { /* shouldn't happen, 20 banks of 0x800 bytes */
237      offs=0;
238      for ( sy=0; sy<size; sy++) {
239         for (sx=0; sx<32; sx++)   {
236   if ((bank >= 0x0c) && (bank <= 0x1f)) /* shouldn't happen, 20 banks of 0x800 bytes */
237   {
238      offs = 0;
239      for (sy = 0; sy < size; sy++)
240      {
241         for (sx = 0; sx < 32; sx++)
242         {
240243            int tileno, colour;
241244
242            tileno = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
243            colour = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0xff000000) >> 24;
245            tileno = (state->bgram[(bank * 0x800) / 4 + offs - 0x4000 / 4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
246            colour = (state->bgram[(bank * 0x800) / 4 + offs - 0x4000 / 4] & 0xff000000) >> 24;
244247
245            drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),alpha); /* normal */
246            if(scrollx)
247               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),alpha); /* wrap x */
248            if(scrolly)
249               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap y */
250            if(scrollx && scrolly)
251               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap xy */
248            drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)), alpha); /* normal */
252249
250            if (scrollx)
251               drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, ((16 * sx + scrollx) & 0x1ff) - 0x200, ((16 * sy + scrolly) & (width - 1)), alpha); /* wrap x */
252            if (scrolly)
253               drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)) - width, alpha); /* wrap y */
254            if (scrollx && scrolly)
255               drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, ((16 * sx + scrollx) & 0x1ff) - 0x200, ((16 * sy + scrolly) & (width - 1)) - width, alpha); /* wrap xy */
256
253257            offs++;
254   }}}
258         }
259      }
260   }
255261
256262   /* Use first values from the second set of scroll values */
257   bank    = (psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 + 0x20/4 - 0x4000/4] & 0x000000ff) >> 0;
258   alpha   = (psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 + 0x20/4 - 0x4000/4] & 0x00003f00) >> 8;
259   alphamap =(psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 + 0x20/4 - 0x4000/4] & 0x00008000) >> 15;
260   scrollx = (psikyosh_bgram[(scrollbank*0x800)/4 - 0x4000/4 + 0x20/4] & 0x000001ff) >> 0;
261   scrolly = (psikyosh_bgram[(scrollbank*0x800)/4 - 0x4000/4 + 0x20/4] & 0x03ff0000) >> 16;
263   bank     = (state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 + 0x20 / 4 - 0x4000 / 4] & 0x000000ff) >> 0;
264   alpha    = (state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 + 0x20 / 4 - 0x4000 / 4] & 0x00003f00) >> 8;
265   alphamap = (state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 + 0x20 / 4 - 0x4000 / 4] & 0x00008000) >> 15;
266   scrollx  = (state->bgram[(scrollbank * 0x800) / 4 - 0x4000 / 4 + 0x20 / 4] & 0x000001ff) >> 0;
267   scrolly  = (state->bgram[(scrollbank * 0x800) / 4 - 0x4000 / 4 + 0x20 / 4] & 0x03ff0000) >> 16;
262268
263   if(alphamap) { /* alpha values are per-pen */
269   if (alphamap) /* alpha values are per-pen */
264270      alpha = -1;
265   } else {
266      alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
267   }
271   else
272      alpha = ((0x3f - alpha) * 0xff) / 0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
268273
269   if((bank>=0x0c) && (bank<=0x1f)) { /* shouldn't happen, 20 banks of 0x800 bytes */
270      offs=0;
271      for ( sy=0; sy<size; sy++) {
272         for (sx=0; sx<32; sx++) {
274   if ((bank >= 0x0c) && (bank <= 0x1f)) /* shouldn't happen, 20 banks of 0x800 bytes */
275   {
276      offs = 0;
277      for (sy = 0; sy < size; sy++)
278      {
279         for (sx = 0; sx < 32; sx++)
280         {
273281            int tileno, colour;
274282
275            tileno = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
276            colour = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0xff000000) >> 24;
283            tileno = (state->bgram[(bank * 0x800) / 4 + offs - 0x4000 / 4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
284            colour = (state->bgram[(bank * 0x800) / 4 + offs - 0x4000 / 4] & 0xff000000) >> 24;
277285
278            drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),alpha); /* normal */
279            if(scrollx)
280               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),alpha); /* wrap x */
281            if(scrolly)
282               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap y */
283            if(scrollx && scrolly)
284               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap xy */
286            drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)), alpha); /* normal */
285287
288            if (scrollx)
289               drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, ((16 * sx + scrollx) & 0x1ff) - 0x200, ((16 * sy + scrolly) & (width - 1)), alpha); /* wrap x */
290            if (scrolly)
291               drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)) - width, alpha); /* wrap y */
292            if (scrollx && scrolly)
293               drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, ((16 * sx + scrollx) & 0x1ff) - 0x200, ((16 * sy + scrolly) & (width - 1)) - width, alpha); /* wrap xy */
294
286295            offs++;
287   }}}
296         }
297      }
298   }
288299}
289300
290301/* Row Scroll and/or Column Scroll/Zoom, has per-column Alpha/Bank/Priority. This isn't correct, just testing */
291302/* For now I'm just using the first alpha/bank/priority values and sodding the rest of it */
292static void draw_bglayerscroll(running_machine *machine, int layer, bitmap_t *bitmap, const rectangle *cliprect )
303static void draw_bglayerscroll( running_machine *machine, int layer, bitmap_t *bitmap, const rectangle *cliprect )
293304{
305   psikyosh_state *state = (psikyosh_state *)machine->driver_data;
294306   gfx_element *gfx;
295307   int offs, sx, sy;
296308   int scrollx, scrolly, bank, alpha, alphamap, size, width, scrollbank;
r6740r6741
300312//  bank = BG_TYPE(layer) - 0x02; /* This is an assumption which seems to hold true so far, although the bank seems to be selectable per-line */
301313
302314   /* Take the following details from the info for the first row, the same for every row in all cases so far */
303   bank    = (psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 - 0x4000/4] & 0x000000ff) >> 0;
304   alpha   = (psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 - 0x4000/4] & 0x00003f00) >> 8;
305   alphamap =(psikyosh_bgram[(scrollbank*0x800)/4 + 0x400/4 - 0x4000/4] & 0x00008000) >> 15;
315   bank    = (state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 - 0x4000 / 4] & 0x000000ff) >> 0;
316   alpha   = (state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 - 0x4000 / 4] & 0x00003f00) >> 8;
317   alphamap =(state->bgram[(scrollbank * 0x800) / 4 + 0x400 / 4 - 0x4000 / 4] & 0x00008000) >> 15;
306318
307319   /* Just to get things moving :) */
308   scrollx =(psikyosh_bgram[(scrollbank*0x800)/4 - 0x4000/4] & 0x000001ff) >> 0;
320   scrollx =(state->bgram[(scrollbank * 0x800) / 4 - 0x4000 / 4] & 0x000001ff) >> 0;
309321   scrolly = 0; // ColumnZoom is combined with ColumnScroll values :(
310322
311323   gfx = BG_DEPTH_8BPP(layer) ? machine->gfx[1] : machine->gfx[0];
312324   size = BG_LARGE(layer) ? 32 : 16;
313325   width = BG_LARGE(layer) ? 0x200 : 0x100;
314326
315   if(alphamap) { /* alpha values are per-pen */
327   if (alphamap) /* alpha values are per-pen */
316328      alpha = -1;
317   } else {
318      alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
319   }
329   else
330      alpha = ((0x3f - alpha) * 0xff) / 0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
320331
321   if((bank>=0x0c) && (bank<=0x1f)) /* shouldn't happen, 20 banks of 0x800 bytes */
332   if ((bank >= 0x0c) && (bank <= 0x1f)) /* shouldn't happen, 20 banks of 0x800 bytes */
322333   {
323334/* Looks better with blending and one scroll value than with 1D linescroll and no zoom */
324335#if 0
325336      int bg_scrollx[256], bg_scrolly[512];
326      bitmap_fill(zoom_bitmap, NULL, get_black_pen(screen->machine));
327      for (offs=0; offs<(0x400/4); offs++) /* 224 values for each */
337      bitmap_fill(state->zoom_bitmap, NULL, get_black_pen(screen->machine));
338      for (offs = 0; offs < (0x400 / 4); offs++) /* 224 values for each */
328339      {
329         bg_scrollx[offs] = (psikyosh_bgram[(scrollbank*0x800)/4 + offs - 0x4000/4] & 0x000001ff) >> 0;
330         bg_scrolly[2*offs] = (psikyosh_bgram[(scrollbank*0x800)/4 + offs - 0x4000/4] & 0x03ff0000) >> 16;
331         bg_scrolly[2*offs+1] = (psikyosh_bgram[(scrollbank*0x800)/4 + offs - 0x4000/4] & 0x03ff0000) >> 16;
340         bg_scrollx[offs]         = (state->bgram[(scrollbank * 0x800) / 4 + offs - 0x4000 / 4] & 0x000001ff) >> 0;
341         bg_scrolly[2 * offs]     = (state->bgram[(scrollbank * 0x800) / 4 + offs - 0x4000 / 4] & 0x03ff0000) >> 16;
342         bg_scrolly[2 * offs + 1] = (state->bgram[(scrollbank * 0x800) / 4 + offs - 0x4000 / 4] & 0x03ff0000) >> 16;
332343      }
333344#endif
334345
335      offs=0;
336      for ( sy=0; sy<size; sy++)
346      offs = 0;
347      for (sy = 0; sy < size; sy++)
337348      {
338         for (sx=0; sx<32; sx++)
349         for (sx = 0; sx < 32; sx++)
339350         {
340351            int tileno, colour;
341352
342            tileno = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
343            colour = (psikyosh_bgram[(bank*0x800)/4 + offs - 0x4000/4] & 0xff000000) >> 24;
353            tileno = (state->bgram[(bank * 0x800) / 4 + offs - 0x4000 / 4] & 0x0007ffff); /* seems to take into account spriteram, hence -0x4000 */
354            colour = (state->bgram[(bank * 0x800) / 4 + offs - 0x4000 / 4] & 0xff000000) >> 24;
344355
345//              drawgfx_transpen(zoom_bitmap,NULL,gfx,tileno,colour,0,0,(16*sx)&0x1ff,((16*sy)&(width-1)),0);
356//              drawgfx_transpen(state->zoom_bitmap, NULL, gfx, tileno, colour, 0, 0, (16 * sx) & 0x1ff, ((16 * sy) & (width - 1)), 0);
346357
347            drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1)),alpha); /* normal */
348            if(scrollx)
349               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1)),alpha); /* wrap x */
350            if(scrolly)
351               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,(16*sx+scrollx)&0x1ff,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap y */
352            if(scrollx && scrolly)
353               drawgfx_alphatable(bitmap,cliprect,gfx,tileno,colour,0,0,((16*sx+scrollx)&0x1ff)-0x200,((16*sy+scrolly)&(width-1))-width,alpha); /* wrap xy */
358            drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)), alpha); /* normal */
354359
360            if (scrollx)
361               drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, ((16 * sx + scrollx) & 0x1ff) - 0x200, ((16 * sy + scrolly) & (width - 1)), alpha); /* wrap x */
362            if (scrolly)
363               drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, (16 * sx + scrollx) & 0x1ff, ((16 * sy + scrolly) & (width - 1)) - width, alpha); /* wrap y */
364            if (scrollx && scrolly)
365               drawgfx_alphatable(bitmap, cliprect, gfx, tileno, colour, 0, 0, ((16 * sx + scrollx) & 0x1ff) - 0x200, ((16 * sy + scrolly) & (width - 1)) - width, alpha); /* wrap xy */
366
355367            offs++;
356368         }
357369      }
358370      /* Only ever seems to use one linescroll value, ok for now */
359371      /* Disabled for now, as they doesn't even support alpha :( */
360//      copyscrollbitmap_trans(bitmap,zoom_bitmap,1,bg_scrollx,512,bg_scrolly,cliprect,0);
361//      copyscrollbitmap_trans(bitmap,zoom_bitmap,256,bg_scrollx,0,bg_scrolly,cliprect,0);
372//      copyscrollbitmap_trans(bitmap, state->zoom_bitmap, 1, bg_scrollx, 512, bg_scrolly, cliprect, 0);
373//      copyscrollbitmap_trans(bitmap, state->zoom_bitmap, 256, bg_scrollx, 0, bg_scrolly, cliprect, 0);
362374   }
363375}
364376
365377/* 3 BG layers, with priority */
366static void draw_background(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 req_pri )
378static void draw_background( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 req_pri )
367379{
380   psikyosh_state *state = (psikyosh_state *)machine->driver_data;
368381   int i;
369382
370383#if 0
r6740r6741
377390#endif
378391
379392   /* 1st-3rd layers */
380   for(i=0; i<3; i++)
393   for (i = 0; i < 3; i++)
381394   {
382      if ( !BG_LAYER_ENABLE(i) )
395      if (!BG_LAYER_ENABLE(i))
383396         continue;
384397
385      switch(BG_TYPE(i))
398      switch (BG_TYPE(i))
386399      {
387400         case BG_NORMAL:
388            if(((psikyosh_bgram[0x17f0/4 + (i*0x04)/4] & 0xff000000) >> 24) == req_pri)
401            if (((state->bgram[0x17f0 / 4 + (i * 0x04) / 4] & 0xff000000) >> 24) == req_pri)
389402               draw_bglayer(machine, i, bitmap, cliprect);
390403            break;
391404         case BG_NORMAL_ALT:
392            if(((psikyosh_bgram[0x1ff0/4 + (i*0x04)/4] & 0xff000000) >> 24) == req_pri)
405            if (((state->bgram[0x1ff0 / 4 + (i * 0x04) / 4] & 0xff000000) >> 24) == req_pri)
393406               draw_bglayer(machine, i, bitmap, cliprect);
394407            break;
395408         case BG_SCROLL_0C: // Using normal for now
396409         case BG_SCROLL_0D: // Using normal for now
397            if(((psikyosh_bgram[(BG_TYPE(i)*0x800)/4 + 0x400/4 - 0x4000/4] & 0xff000000) >> 24) == req_pri)
410            if (((state->bgram[(BG_TYPE(i) * 0x800) / 4 + 0x400 / 4 - 0x4000 / 4] & 0xff000000) >> 24) == req_pri)
398411               draw_bglayertext(machine, i, bitmap, cliprect);
399412            break;
400413         case BG_SCROLL_ZOOM:
r6740r6741
403416         case 0x14: case 0x15: case 0x16: case 0x17:
404417         case 0x18: case 0x19: case 0x1a: case 0x1b:
405418         case 0x1c: case 0x1d: case 0x1e: case 0x1f:
406            if(((psikyosh_bgram[(BG_TYPE(i)*0x800)/4 + 0x400/4 - 0x4000/4] & 0xff000000) >> 24) == req_pri)
419            if (((state->bgram[(BG_TYPE(i) * 0x800) / 4 + 0x400 / 4 - 0x4000 / 4] & 0xff000000) >> 24) == req_pri)
407420               draw_bglayerscroll(machine, i, bitmap, cliprect);
408421            break;
409422         default:
r6740r6741
421434/* sx and sy is top-left of entire sprite regardless of flip */
422435/* Note that Level 5-4 of sbomberb boss is perfect! (Alpha blended zoomed) as well as S1945II logo */
423436/* pixel is only plotted if z is >= priority_buffer[y][x] */
424static void psikyosh_drawgfxzoom(
437static void psikyosh_drawgfxzoom( running_machine *machine,
425438      bitmap_t *dest_bmp,const rectangle *clip,const gfx_element *gfx,
426439      UINT32 code,UINT32 color,int flipx,int flipy,int offsx,int offsy,
427440      int alpha,
428441      int zoomx, int zoomy, int wide, int high, UINT32 z)
429442{
443   psikyosh_state *state = (psikyosh_state *)machine->driver_data;
430444   rectangle myclip; /* Clip to screen boundaries */
431445   int code_offset = 0;
432446   int xtile, ytile, xpixel, ypixel;
433447
434   if (!zoomx || !zoomy) return;
448   if (!zoomx || !zoomy)
449      return;
435450
436451   profiler_mark_start(PROFILER_DRAWGFX);
437452
438453   assert(dest_bmp->bpp == 32);
439454
440455   /* KW 991012 -- Added code to force clip to bitmap boundary */
441   if(clip)
456   if (clip)
442457   {
443458      myclip.min_x = clip->min_x;
444459      myclip.max_x = clip->max_x;
r6740r6741
446461      myclip.max_y = clip->max_y;
447462
448463      if (myclip.min_x < 0) myclip.min_x = 0;
449      if (myclip.max_x >= dest_bmp->width) myclip.max_x = dest_bmp->width-1;
464      if (myclip.max_x >= dest_bmp->width) myclip.max_x = dest_bmp->width - 1;
450465      if (myclip.min_y < 0) myclip.min_y = 0;
451466      if (myclip.max_y >= dest_bmp->height) myclip.max_y = dest_bmp->height-1;
452467
453      clip=&myclip;
468      clip = &myclip;
454469   }
455470
456471   /* Temporary fallback for non-zoomed, needs z-buffer. Note that this is probably a lot slower than drawgfx.c, especially if there was seperate code for flipped cases */
r6740r6741
458473   {
459474      int xstart, ystart, xend, yend, xinc, yinc;
460475
461      if (flipx)   { xstart = wide-1; xend = -1;   xinc = -1; }
462      else      { xstart = 0;      xend = wide; xinc = +1; }
476      if (flipx)   { xstart = wide - 1; xend = -1;   xinc = -1; }
477      else      { xstart = 0;        xend = wide; xinc = +1; }
463478
464      if (flipy)   { ystart = high-1; yend = -1;   yinc = -1; }
465      else      { ystart = 0;      yend = high; yinc = +1; }
479      if (flipy)   { ystart = high - 1; yend = -1;   yinc = -1; }
480      else      { ystart = 0;        yend = high; yinc = +1; }
466481
467482      /* Start drawing */
468      if( gfx )
483      if (gfx)
469484      {
470         for (ytile = ystart; ytile != yend; ytile += yinc )
485         for (ytile = ystart; ytile != yend; ytile += yinc)
471486         {
472            for (xtile = xstart; xtile != xend; xtile += xinc )
487            for (xtile = xstart; xtile != xend; xtile += xinc)
473488            {
474489               const pen_t *pal = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
475490               const UINT8 *code_base = gfx_element_get_data(gfx, (code + code_offset++) % gfx->total_elements);
476491
477492               int x_index_base, y_index, sx, sy, ex, ey;
478493
479               if (flipx)   { x_index_base = gfx->width-1; }
494               if (flipx)   { x_index_base = gfx->width - 1; }
480495               else      { x_index_base = 0; }
481496
482497               if (flipy)   { y_index = gfx->height-1; }
483498               else      { y_index = 0; }
484499
485500               /* start coordinates */
486               sx = offsx + xtile*gfx->width;
487               sy = offsy + ytile*gfx->height;
501               sx = offsx + xtile * gfx->width;
502               sy = offsy + ytile * gfx->height;
488503
489504               /* end coordinates */
490505               ex = sx + gfx->width;
491506               ey = sy + gfx->height;
492507
493               if( clip )
508               if (clip)
494509               {
495                  if( sx < clip->min_x)
510                  if (sx < clip->min_x)
496511                  { /* clip left */
497                     int pixels = clip->min_x-sx;
512                     int pixels = clip->min_x - sx;
498513                     sx += pixels;
499                     x_index_base += xinc*pixels;
514                     x_index_base += xinc * pixels;
500515                  }
501                  if( sy < clip->min_y )
516                  if (sy < clip->min_y)
502517                  { /* clip top */
503                     int pixels = clip->min_y-sy;
518                     int pixels = clip->min_y - sy;
504519                     sy += pixels;
505                     y_index += yinc*pixels;
520                     y_index += yinc * pixels;
506521                  }
507522                  /* NS 980211 - fixed incorrect clipping */
508                  if( ex > clip->max_x+1 )
523                  if (ex > clip->max_x + 1)
509524                  { /* clip right */
510                     int pixels = ex-clip->max_x-1;
525                     int pixels = ex - clip->max_x - 1;
511526                     ex -= pixels;
512527                  }
513                  if( ey > clip->max_y+1 )
528                  if (ey > clip->max_y + 1)
514529                  { /* clip bottom */
515                     int pixels = ey-clip->max_y-1;
530                     int pixels = ey - clip->max_y - 1;
516531                     ey -= pixels;
517532                  }
518533               }
519534
520               if( ex>sx )
535               if (ex > sx)
521536               { /* skip if inner loop doesn't draw anything */
522537                  int y;
523538
524539                  /* case 1: no alpha */
525540                  if (alpha == 0xff)
526541                  {
527                     if( z > 0 )
542                     if (z > 0)
528543                     {
529                        const UINT8 *source = code_base + (y_index)*gfx->line_modulo + x_index_base;
530                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
531                        UINT16 *pri = (UINT16 *)z_bitmap->base + sy*z_bitmap->rowpixels + sx;
532                        int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
533                        int dst_modulo = dest_bmp->rowpixels - (ex-sx);
544                        const UINT8 *source = code_base + (y_index) * gfx->line_modulo + x_index_base;
545                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy * dest_bmp->rowpixels + sx;
546                        UINT16 *pri = (UINT16 *)state->z_bitmap->base + sy * state->z_bitmap->rowpixels + sx;
547                        int src_modulo = yinc * gfx->line_modulo - xinc * (ex - sx);
548                        int dst_modulo = dest_bmp->rowpixels - (ex - sx);
534549
535                        for( y=sy; y<ey; y++ )
550                        for (y = sy; y < ey; y++)
536551                        {
537552                           int x;
538                           for( x=sx; x<ex; x++ )
553                           for (x = sx; x < ex; x++)
539554                           {
540                              if(z >= *pri)
555                              if (z >= *pri)
541556                              {
542557                                 int c = *source;
543                                 if( c != 0 )
558                                 if (c != 0)
544559                                 {
545560                                    *dest = pal[c];
546561                                    *pri = z;
r6740r6741
557572                     }
558573                     else
559574                     {
560                        const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base;
561                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
562                        int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
563                        int dst_modulo = dest_bmp->rowpixels - (ex-sx);
575                        const UINT8 *source = code_base + y_index * gfx->line_modulo + x_index_base;
576                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy * dest_bmp->rowpixels + sx;
577                        int src_modulo = yinc * gfx->line_modulo - xinc * (ex - sx);
578                        int dst_modulo = dest_bmp->rowpixels - (ex - sx);
564579
565                        for( y=sy; y<ey; y++ )
580                        for (y = sy; y < ey; y++)
566581                        {
567582                           int x;
568                           for( x=sx; x<ex; x++ )
583                           for (x = sx; x < ex; x++)
569584                           {
570585                              int c = *source;
571                              if( c != 0 ) *dest = pal[c];
586                              if (c != 0)
587                                 *dest = pal[c];
572588
573589                              dest++;
574590                              source += xinc;
r6740r6741
582598                  /* case 6: alpha-blended */
583599                  else if (alpha >= 0)
584600                  {
585                     if ( z > 0 )
601                     if (z > 0)
586602                     {
587                        const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base;
588                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
589                        UINT16 *pri = (UINT16 *)z_bitmap->base + sy*z_bitmap->rowpixels + sx;
590                        int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
591                        int dst_modulo = dest_bmp->rowpixels - (ex-sx);
603                        const UINT8 *source = code_base + y_index * gfx->line_modulo + x_index_base;
604                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy * dest_bmp->rowpixels + sx;
605                        UINT16 *pri = (UINT16 *)state->z_bitmap->base + sy * state->z_bitmap->rowpixels + sx;
606                        int src_modulo = yinc * gfx->line_modulo - xinc * (ex - sx);
607                        int dst_modulo = dest_bmp->rowpixels - (ex - sx);
592608
593                        for( y=sy; y<ey; y++ )
609                        for (y = sy; y < ey; y++)
594610                        {
595611                           int x;
596                           for( x=sx; x<ex; x++ )
612                           for (x = sx; x < ex; x++)
597613                           {
598                              if(z >= *pri)
614                              if (z >= *pri)
599615                              {
600616                                 int c = *source;
601                                 if( c != 0 )
617                                 if (c != 0)
602618                                 {
603619                                    *dest = alpha_blend_r32(*dest, pal[c], alpha);
604620                                    *pri = z;
r6740r6741
615631                     }
616632                     else
617633                     {
618                        const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base;
619                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
620                        int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
621                        int dst_modulo = dest_bmp->rowpixels - (ex-sx);
634                        const UINT8 *source = code_base + y_index * gfx->line_modulo + x_index_base;
635                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy * dest_bmp->rowpixels + sx;
636                        int src_modulo = yinc * gfx->line_modulo - xinc * (ex - sx);
637                        int dst_modulo = dest_bmp->rowpixels - (ex - sx);
622638
623                        for( y=sy; y<ey; y++ )
639                        for (y = sy; y < ey; y++)
624640                        {
625641                           int x;
626                           for( x=sx; x<ex; x++ )
642                           for (x = sx; x < ex; x++)
627643                           {
628644                              int c = *source;
629                              if( c != 0 ) *dest = alpha_blend_r32(*dest, pal[c], alpha);
645                              if (c != 0)
646                                 *dest = alpha_blend_r32(*dest, pal[c], alpha);
630647
631648                              dest++;
632649                              source += xinc;
r6740r6741
641658                  /* case 7: TRANSPARENCY_ALPHARANGE */
642659                  else
643660                  {
644                     if ( z > 0 )
661                     if (z > 0)
645662                     {
646                        const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base;
647                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
648                        UINT16 *pri = (UINT16 *)z_bitmap->base + sy*z_bitmap->rowpixels + sx;
649                        int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
650                        int dst_modulo = dest_bmp->rowpixels - (ex-sx);
663                        const UINT8 *source = code_base + y_index * gfx->line_modulo + x_index_base;
664                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy * dest_bmp->rowpixels + sx;
665                        UINT16 *pri = (UINT16 *)state->z_bitmap->base + sy * state->z_bitmap->rowpixels + sx;
666                        int src_modulo = yinc * gfx->line_modulo - xinc * (ex - sx);
667                        int dst_modulo = dest_bmp->rowpixels - (ex - sx);
651668
652                        for( y=sy; y<ey; y++ )
669                        for (y = sy; y < ey; y++)
653670                        {
654671                           int x;
655                           for( x=sx; x<ex; x++ )
672                           for (x = sx; x < ex; x++)
656673                           {
657                              if(z >= *pri)
674                              if (z >= *pri)
658675                              {
659676                                 int c = *source;
660                                 if( c != 0 )
677                                 if (c != 0)
661678                                 {
662                                    if( alphatable[c] == 0xff )
679                                    if (alphatable[c] == 0xff)
663680                                       *dest = pal[c];
664681                                    else
665682                                       *dest = alpha_blend_r32(*dest, pal[c], alphatable[c]);
r6740r6741
678695                     }
679696                     else
680697                     {
681                        const UINT8 *source = code_base + y_index*gfx->line_modulo + x_index_base;
682                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy*dest_bmp->rowpixels + sx;
683                        int src_modulo = yinc*gfx->line_modulo - xinc*(ex-sx);
684                        int dst_modulo = dest_bmp->rowpixels - (ex-sx);
698                        const UINT8 *source = code_base + y_index * gfx->line_modulo + x_index_base;
699                        UINT32 *dest = (UINT32 *)dest_bmp->base + sy * dest_bmp->rowpixels + sx;
700                        int src_modulo = yinc * gfx->line_modulo - xinc * (ex - sx);
701                        int dst_modulo = dest_bmp->rowpixels - (ex - sx);
685702
686                        for( y=sy; y<ey; y++ )
703                        for (y = sy; y < ey; y++)
687704                        {
688705                           int x;
689                           for( x=sx; x<ex; x++ )
706                           for (x = sx; x < ex; x++)
690707                           {
691708                              int c = *source;
692                              if( c != 0 )
709                              if (c != 0)
693710                              {
694                                 if( alphatable[c] == 0xff )
711                                 if (alphatable[c] == 0xff)
695712                                    *dest = pal[c];
696713                                 else
697714                                    *dest = alpha_blend_r32(*dest, pal[c], alphatable[c]);
r6740r6741
714731   {
715732      /* Make a copy of complete sprite at top-left of zoom_bitmap */
716733      /* Because I'm too slow to get it to work on the fly */
717      for(ytile=0; ytile<high; ytile++)
734      for (ytile = 0; ytile < high; ytile++)
718735      {
719         for(xtile=0; xtile<wide; xtile++)
736         for (xtile = 0; xtile < wide; xtile++)
720737         {
721738            const UINT8 *code_base = gfx_element_get_data(gfx, (code + code_offset++) % gfx->total_elements);
722            for( ypixel=0; ypixel<gfx->height; ypixel++ )
739            for (ypixel = 0; ypixel < gfx->height; ypixel++)
723740            {
724741               const UINT8 *source = code_base + ypixel * gfx->line_modulo;
725               UINT8 *dest = BITMAP_ADDR8(zoom_bitmap, ypixel + ytile*gfx->height, 0);
742               UINT8 *dest = BITMAP_ADDR8(state->zoom_bitmap, ypixel + ytile*gfx->height, 0);
726743
727               for( xpixel=0; xpixel<gfx->width; xpixel++ )
744               for (xpixel = 0; xpixel < gfx->width; xpixel++)
728745               {
729746                  dest[xpixel + xtile*gfx->width] = source[xpixel];
730747               }
r6740r6741
733750      }
734751
735752      /* Start drawing */
736      if( gfx )
753      if (gfx)
737754      {
738755         const pen_t *pal = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
739756
740         int sprite_screen_height = ((high*gfx->height*(0x400*0x400))/zoomy + 0x200)>>10; /* Round up to nearest pixel */
741         int sprite_screen_width = ((wide*gfx->width*(0x400*0x400))/zoomx + 0x200)>>10;
757         int sprite_screen_height = ((high * gfx->height * (0x400 * 0x400)) / zoomy + 0x200) >> 10; /* Round up to nearest pixel */
758         int sprite_screen_width = ((wide * gfx->width * (0x400 * 0x400)) / zoomx + 0x200) >> 10;
742759
743760         if (sprite_screen_width && sprite_screen_height)
744761         {
r6740r6741
755772
756773            int dx, dy;
757774
758            if( flipx )   { x_index_base = (sprite_screen_width-1)*zoomx; dx = -zoomx; }
775            if (flipx)   { x_index_base = (sprite_screen_width - 1) * zoomx; dx = -zoomx; }
759776            else      { x_index_base = 0; dx = zoomx; }
760777
761            if( flipy )   { y_index = (sprite_screen_height-1)*zoomy; dy = -zoomy; }
778            if (flipy)   { y_index = (sprite_screen_height - 1) * zoomy; dy = -zoomy; }
762779            else      { y_index = 0; dy = zoomy; }
763780
764            if( clip )
781            if (clip)
765782            {
766               if( sx < clip->min_x)
783               if (sx < clip->min_x)
767784               { /* clip left */
768                  int pixels = clip->min_x-sx;
785                  int pixels = clip->min_x - sx;
769786                  sx += pixels;
770                  x_index_base += pixels*dx;
787                  x_index_base += pixels * dx;
771788               }
772               if( sy < clip->min_y )
789               if (sy < clip->min_y)
773790               { /* clip top */
774                  int pixels = clip->min_y-sy;
791                  int pixels = clip->min_y - sy;
775792                  sy += pixels;
776                  y_index += pixels*dy;
793                  y_index += pixels * dy;
777794               }
778795               /* NS 980211 - fixed incorrect clipping */
779               if( ex > clip->max_x+1 )
796               if (ex > clip->max_x + 1)
780797               { /* clip right */
781                  int pixels = ex-clip->max_x-1;
798                  int pixels = ex-clip->max_x - 1;
782799                  ex -= pixels;
783800               }
784               if( ey > clip->max_y+1 )
801               if (ey > clip->max_y + 1)
785802               { /* clip bottom */
786                  int pixels = ey-clip->max_y-1;
803                  int pixels = ey-clip->max_y - 1;
787804                  ey -= pixels;
788805               }
789806            }
790807
791            if( ex>sx )
808            if (ex > sx)
792809            { /* skip if inner loop doesn't draw anything */
793810               int y;
794811
r6740r6741
796813               /* Note: adjusted to >>10 and draws from zoom_bitmap not gfx */
797814               if (alpha == 0xff)
798815               {
799                  if( z > 0 )
816                  if (z > 0)
800817                  {
801                     for( y=sy; y<ey; y++ )
818                     for (y = sy; y < ey; y++)
802819                     {
803                        UINT8 *source = BITMAP_ADDR8(zoom_bitmap, y_index>>10, 0);
820                        UINT8 *source = BITMAP_ADDR8(state->zoom_bitmap, y_index >> 10, 0);
804821                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
805                        UINT16 *pri = BITMAP_ADDR16(z_bitmap, y, 0);
822                        UINT16 *pri = BITMAP_ADDR16(state->z_bitmap, y, 0);
806823
807824                        int x, x_index = x_index_base;
808                        for( x=sx; x<ex; x++ )
825                        for (x = sx; x < ex; x++)
809826                        {
810                           if(z >= pri[x])
827                           if (z >= pri[x])
811828                           {
812                              int c = source[x_index>>10];
813                              if( c != 0 )
829                              int c = source[x_index >> 10];
830                              if (c != 0)
814831                              {
815832                                 dest[x] = pal[c];
816833                                 pri[x] = z;
r6740r6741
824841                  }
825842                  else
826843                  {
827                     for( y=sy; y<ey; y++ )
844                     for (y = sy; y < ey; y++)
828845                     {
829                        UINT8 *source = BITMAP_ADDR8(zoom_bitmap, y_index>>10, 0);
846                        UINT8 *source = BITMAP_ADDR8(state->zoom_bitmap, y_index >> 10, 0);
830847                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
831848
832849                        int x, x_index = x_index_base;
833                        for( x=sx; x<ex; x++ )
850                        for (x = sx; x < ex; x++)
834851                        {
835                           int c = source[x_index>>10];
836                           if( c != 0 ) dest[x] = pal[c];
852                           int c = source[x_index >> 10];
853                           if (c != 0)
854                              dest[x] = pal[c];
837855                           x_index += dx;
838856                        }
839857
r6740r6741
845863               /* case 6: alpha-blended */
846864               else if (alpha >= 0)
847865               {
848                  if( z > 0 )
866                  if (z > 0)
849867                  {
850                     for( y=sy; y<ey; y++ )
868                     for (y = sy; y < ey; y++)
851869                     {
852                        UINT8 *source = BITMAP_ADDR8(zoom_bitmap, y_index>>10, 0);
870                        UINT8 *source = BITMAP_ADDR8(state->zoom_bitmap, y_index >> 10, 0);
853871                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
854                        UINT16 *pri = BITMAP_ADDR16(z_bitmap, y, 0);
872                        UINT16 *pri = BITMAP_ADDR16(state->z_bitmap, y, 0);
855873
856874                        int x, x_index = x_index_base;
857                        for( x=sx; x<ex; x++ )
875                        for (x = sx; x < ex; x++)
858876                        {
859                           if(z >= pri[x])
877                           if (z >= pri[x])
860878                           {
861                              int c = source[x_index>>10];
862                              if( c != 0 )
879                              int c = source[x_index >> 10];
880                              if (c != 0)
863881                              {
864882                                 dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
865883                                 pri[x] = z;
r6740r6741
873891                  }
874892                  else
875893                  {
876                     for( y=sy; y<ey; y++ )
894                     for (y = sy; y < ey; y++)
877895                     {
878                        UINT8 *source = BITMAP_ADDR8(zoom_bitmap, y_index>>10, 0);
896                        UINT8 *source = BITMAP_ADDR8(state->zoom_bitmap, y_index >> 10, 0);
879897                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
880898
881899                        int x, x_index = x_index_base;
882                        for( x=sx; x<ex; x++ )
900                        for (x = sx; x < ex; x++)
883901                        {
884                           int c = source[x_index>>10];
885                           if( c != 0 ) dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
902                           int c = source[x_index >> 10];
903                           if (c != 0) dest[x] = alpha_blend_r32(dest[x], pal[c], alpha);
886904                           x_index += dx;
887905                        }
888906
r6740r6741
894912               /* case 7: TRANSPARENCY_ALPHARANGE */
895913               else
896914               {
897                  if( z > 0 )
915                  if (z > 0)
898916                  {
899                     for( y=sy; y<ey; y++ )
917                     for (y = sy; y < ey; y++)
900918                     {
901                        UINT8 *source = BITMAP_ADDR8(zoom_bitmap, y_index>>10, 0);
919                        UINT8 *source = BITMAP_ADDR8(state->zoom_bitmap, y_index >> 10, 0);
902920                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
903                        UINT16 *pri = BITMAP_ADDR16(z_bitmap, y, 0);
921                        UINT16 *pri = BITMAP_ADDR16(state->z_bitmap, y, 0);
904922
905923                        int x, x_index = x_index_base;
906                        for( x=sx; x<ex; x++ )
924                        for (x = sx; x < ex; x++)
907925                        {
908                           if(z >= pri[x])
926                           if (z >= pri[x])
909927                           {
910                              int c = source[x_index>>10];
911                              if( c != 0 )
928                              int c = source[x_index >> 10];
929                              if (c != 0)
912930                              {
913                                 if( alphatable[c] == 0xff )
931                                 if (alphatable[c] == 0xff)
914932                                    dest[x] = pal[c];
915933                                 else
916934                                    dest[x] = alpha_blend_r32(dest[x], pal[c], alphatable[c]);
r6740r6741
926944                  }
927945                  else
928946                  {
929                     for( y=sy; y<ey; y++ )
947                     for (y = sy; y < ey; y++)
930948                     {
931                        UINT8 *source = BITMAP_ADDR8(zoom_bitmap, y_index>>10, 0);
949                        UINT8 *source = BITMAP_ADDR8(state->zoom_bitmap, y_index >> 10, 0);
932950                        UINT32 *dest = BITMAP_ADDR32(dest_bmp, y, 0);
933951
934952                        int x, x_index = x_index_base;
935                        for( x=sx; x<ex; x++ )
953                        for (x = sx; x < ex; x++)
936954                        {
937                           int c = source[x_index>>10];
938                           if( c != 0 )
955                           int c = source[x_index >> 10];
956                           if (c != 0)
939957                           {
940                              if( alphatable[c] == 0xff )
958                              if (alphatable[c] == 0xff)
941959                                 dest[x] = pal[c];
942960                              else
943961                                 dest[x] = alpha_blend_r32(dest[x], pal[c], alphatable[c]);
r6740r6741
956974   profiler_mark_end();
957975}
958976
959#define SPRITE_PRI(n) (((psikyosh_vidregs[2] << (4*n)) & 0xf0000000 ) >> 28)
977#define SPRITE_PRI(n) (((state->vidregs[2] << (4*n)) & 0xf0000000 ) >> 28)
960978
961979static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 req_pri )
962980{
r6740r6741
9901008
9911009    **- End Sprite Format -*/
9921010
1011   psikyosh_state *state = (psikyosh_state *)machine->driver_data;
9931012   const gfx_element *gfx;
9941013   UINT32 *src = machine->generic.buffered_spriteram.u32; /* Use buffered spriteram */
995   UINT16 *list = (UINT16 *)src + 0x3800/2;
996   UINT16 listlen=0x800/2, listcntr=0;
997   UINT16 *zoom_table = (UINT16 *)psikyosh_zoomram;
998   UINT8  *alpha_table = (UINT8 *)psikyosh_vidregs;
1014   UINT16 *list = (UINT16 *)src + 0x3800 / 2;
1015   UINT16 listlen = 0x800/2, listcntr = 0;
1016   UINT16 *zoom_table = (UINT16 *)state->zoomram;
1017   UINT8  *alpha_table = (UINT8 *)state->vidregs;
9991018
1000   while( listcntr < listlen )
1019   while (listcntr < listlen)
10011020   {
10021021      UINT32 listdat, sprnum, xpos, ypos, high, wide, flpx, flpy, zoomx, zoomy, tnum, colr, dpth;
10031022      UINT32 pri, alphamap;
r6740r6741
10061025      listdat = list[BYTE_XOR_BE(listcntr)];
10071026      sprnum = (listdat & 0x03ff) * 4;
10081027
1009      pri  = (src[sprnum+1] & 0x00003000) >> 12; // & 0x00007000/0x00003000 ?
1028      pri  = (src[sprnum + 1] & 0x00003000) >> 12; // & 0x00007000/0x00003000 ?
10101029      pri = SPRITE_PRI(pri);
10111030
1012      if(pri == req_pri)
1031      if (pri == req_pri)
10131032      {
1014         ypos = (src[sprnum+0] & 0x03ff0000) >> 16;
1015         xpos = (src[sprnum+0] & 0x000003ff) >> 00;
1033         ypos = (src[sprnum + 0] & 0x03ff0000) >> 16;
1034         xpos = (src[sprnum + 0] & 0x000003ff) >> 00;
10161035
1017         if(ypos & 0x200) ypos -= 0x400;
1018         if(xpos & 0x200) xpos -= 0x400;
1036         if (ypos & 0x200) ypos -= 0x400;
1037         if (xpos & 0x200) xpos -= 0x400;
10191038
1020         high  = ((src[sprnum+1] & 0x0f000000) >> 24) + 1;
1021         wide  = ((src[sprnum+1] & 0x00000f00) >> 8) + 1;
1039         high  = ((src[sprnum + 1] & 0x0f000000) >> 24) + 1;
1040         wide  = ((src[sprnum + 1] & 0x00000f00) >> 8) + 1;
10221041
1023         flpy  = (src[sprnum+1] & 0x80000000) >> 31;
1024         flpx  = (src[sprnum+1] & 0x00008000) >> 15;
1042         flpy  = (src[sprnum + 1] & 0x80000000) >> 31;
1043         flpx  = (src[sprnum + 1] & 0x00008000) >> 15;
10251044
1026         zoomy = (src[sprnum+1] & 0x00ff0000) >> 16;
1027         zoomx = (src[sprnum+1] & 0x000000ff) >> 00;
1045         zoomy = (src[sprnum + 1] & 0x00ff0000) >> 16;
1046         zoomx = (src[sprnum + 1] & 0x000000ff) >> 00;
10281047
1029         tnum  = (src[sprnum+2] & 0x0007ffff) >> 00;
1030         dpth  = (src[sprnum+2] & 0x00800000) >> 23;
1031         colr  = (src[sprnum+2] & 0xff000000) >> 24;
1048         tnum  = (src[sprnum + 2] & 0x0007ffff) >> 00;
1049         dpth  = (src[sprnum + 2] & 0x00800000) >> 23;
1050         colr  = (src[sprnum + 2] & 0xff000000) >> 24;
10321051
1033         alpha = (src[sprnum+2] & 0x00700000) >> 20;
1052         alpha = (src[sprnum + 2] & 0x00700000) >> 20;
10341053
10351054         alphamap = (alpha_table[BYTE4_XOR_BE(alpha)] & 0x80)? 1:0;
10361055         alpha = alpha_table[BYTE4_XOR_BE(alpha)] & 0x3f;
10371056
10381057         gfx = dpth ? machine->gfx[1] : machine->gfx[0];
10391058
1040         if(alphamap) { /* alpha values are per-pen */
1059         if (alphamap) /* alpha values are per-pen */
10411060            alpha = -1;
1042         } else {
1043            alpha = ((0x3f-alpha)*0xff)/0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
1044         }
1061         else
1062            alpha = ((0x3f - alpha) * 0xff) / 0x3f; /* 0x3f-0x00 maps to 0x00-0xff */
10451063
10461064         /* start drawing */
1047         if( zoom_table[BYTE_XOR_BE(zoomy)] && zoom_table[BYTE_XOR_BE(zoomx)] ) /* Avoid division-by-zero when table contains 0 (Uninitialised/Bug) */
1065         if (zoom_table[BYTE_XOR_BE(zoomy)] && zoom_table[BYTE_XOR_BE(zoomx)]) /* Avoid division-by-zero when table contains 0 (Uninitialised/Bug) */
10481066         {
1049            psikyosh_drawgfxzoom(bitmap,cliprect,gfx,tnum,colr,flpx,flpy,xpos,ypos,alpha,
1067            psikyosh_drawgfxzoom(machine, bitmap, cliprect, gfx, tnum, colr, flpx, flpy, xpos, ypos, alpha,
10501068                           (UINT32)zoom_table[BYTE_XOR_BE(zoomx)], (UINT32)zoom_table[BYTE_XOR_BE(zoomy)], wide, high, listcntr);
10511069
10521070#if 0
r6740r6741
10571075               int x, y;
10581076
10591077               sprintf(buf, "%X",xdim/16); /* Display Zoom in 16.16 */
1060               if (machine->gamedrv->flags & ORIENTATION_SWAP_XY) {
1078               if (machine->gamedrv->flags & ORIENTATION_SWAP_XY)
1079               {
10611080                  x = ypos;
10621081                  y = video_screen_get_visible_area(machine->primary_screen)->max_x - xpos; /* ORIENTATION_FLIP_Y */
10631082               }
1064               else {
1083               else
1084               {
10651085                  x = xpos;
10661086                  y = ypos;
10671087               }
r6740r6741
10791099
10801100VIDEO_START( psikyosh )
10811101{
1102   psikyosh_state *state = (psikyosh_state *)machine->driver_data;
10821103   int width = video_screen_get_width(machine->primary_screen);
10831104   int height = video_screen_get_height(machine->primary_screen);
1084   z_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16);
1105   state->z_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16);
10851106
10861107   /* Need 16-bit z-buffer */
1087   zoom_bitmap = auto_bitmap_alloc(machine, 16*16, 16*16, BITMAP_FORMAT_INDEXED8);
1108   state->zoom_bitmap = auto_bitmap_alloc(machine, 16*16, 16*16, BITMAP_FORMAT_INDEXED8);
10881109
1089   machine->gfx[1]->color_granularity=16; /* 256 colour sprites with palette selectable on 16 colour boundaries */
1110   machine->gfx[1]->color_granularity = 16; /* 256 colour sprites with palette selectable on 16 colour boundaries */
10901111
10911112   { /* Pens 0xc0-0xff have a gradient of alpha values associated with them */
10921113      int i;
1093      for (i=0; i<0xc0; i++)
1114      for (i = 0; i < 0xc0; i++)
10941115         alphatable[i] = 0xff;
1095      for (i=0; i<0x40; i++) {
1096         int alpha = ((0x3f-i)*0xff)/0x3f;
1097         alphatable[i+0xc0] = alpha;
1116      for (i = 0; i < 0x40; i++)
1117      {
1118         int alpha = ((0x3f - i) * 0xff) / 0x3f;
1119         alphatable[i + 0xc0] = alpha;
10981120      }
10991121   }
11001122
1123   state_save_register_global_bitmap(machine, state->z_bitmap);
1124   state_save_register_global_bitmap(machine, state->zoom_bitmap);
11011125}
11021126
1103static void psikyosh_prelineblend( bitmap_t *bitmap, const rectangle *cliprect )
1127static void psikyosh_prelineblend( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
11041128{
11051129   /* There are 224 values for pre-lineblending. Using one for every row currently */
11061130   /* I suspect that it should be blended against black by the amount specified as
11071131       gnbarich sets the 0x000000ff to 0x7f in test mode whilst the others use 0x80.
11081132       As it's only used in testmode I'll just leave it as a toggle for now */
1133   psikyosh_state *state = (psikyosh_state *)machine->driver_data;
11091134   UINT32 *dstline;
1110   UINT32 *linefill = psikyosh_bgram; /* Per row */
1111   int x,y;
1135   UINT32 *linefill = state->bgram; /* Per row */
1136   int x, y;
11121137
11131138   assert(bitmap->bpp == 32);
11141139
r6740r6741
11171142
11181143      dstline = BITMAP_ADDR32(bitmap, y, 0);
11191144
1120      if(linefill[y]&0xff) /* Row */
1145      if (linefill[y] & 0xff) /* Row */
11211146         for (x = cliprect->min_x; x <= cliprect->max_x; x += 1)
1122               dstline[x] = linefill[y]>>8;
1147               dstline[x] = linefill[y] >> 8;
11231148   }
11241149   profiler_mark_end();
11251150}
11261151
1127static void psikyosh_postlineblend( bitmap_t *bitmap, const rectangle *cliprect )
1152static void psikyosh_postlineblend( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
11281153{
11291154   /* There are 224 values for post-lineblending. Using one for every row currently */
1155   psikyosh_state *state = (psikyosh_state *)machine->driver_data;
11301156   UINT32 *dstline;
1131   UINT32 *lineblend = psikyosh_bgram+0x400/4; /* Per row */
1132   int x,y;
1157   UINT32 *lineblend = state->bgram + 0x400 / 4; /* Per row */
1158   int x, y;
11331159
11341160   assert(bitmap->bpp == 32);
11351161
r6740r6741
11381164
11391165      dstline = BITMAP_ADDR32(bitmap, y, 0);
11401166
1141      if(lineblend[y]&0x80) /* Row */
1167      if (lineblend[y] & 0x80) /* Row */
11421168      {
11431169         for (x = cliprect->min_x; x <= cliprect->max_x; x += 1)
1144            dstline[x] = lineblend[y]>>8;
1170            dstline[x] = lineblend[y] >> 8;
11451171      }
1146      else if(lineblend[y]&0x7f) /* Row */
1172      else if (lineblend[y] & 0x7f) /* Row */
11471173      {
11481174         for (x = cliprect->min_x; x <= cliprect->max_x; x += 1)
1149            dstline[x] = alpha_blend_r32(dstline[x], lineblend[y]>>8, 2*(lineblend[y]&0x7f));
1175            dstline[x] = alpha_blend_r32(dstline[x], lineblend[y] >> 8, 2 * (lineblend[y] & 0x7f));
11501176      }
11511177   }
11521178   profiler_mark_end();
r6740r6741
11541180
11551181VIDEO_UPDATE( psikyosh ) /* Note the z-buffer on each sprite to get correct priority */
11561182{
1157      int i;
1158      bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
1159   bitmap_fill(z_bitmap,cliprect,0); /* z-buffer */
1183   psikyosh_state *state = (psikyosh_state *)screen->machine->driver_data;
1184   int i;
11601185
1161      psikyosh_prelineblend(bitmap, cliprect);
1186   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
1187   bitmap_fill(state->z_bitmap, cliprect, 0); /* z-buffer */
11621188
1163      for (i=0; i<=7; i++) {
1189   psikyosh_prelineblend(screen->machine, bitmap, cliprect);
1190
1191   for (i = 0; i <= 7; i++)
1192   {
11641193      draw_sprites(screen->machine, bitmap, cliprect, i); // When same priority bg's have higher pri
11651194      draw_background(screen->machine, bitmap, cliprect, i);
1166         if((psikyosh_vidregs[2]&0xf) == i) psikyosh_postlineblend(bitmap, cliprect);
1167      }
1195      if ((state->vidregs[2] & 0xf) == i)
1196         psikyosh_postlineblend(screen->machine, bitmap, cliprect);
1197   }
11681198   return 0;
11691199}
11701200
r6740r6741
11721202{
11731203   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
11741204
1175   buffer_spriteram32_w(space,0,0,0xffffffff);
1205   buffer_spriteram32_w(space, 0, 0, 0xffffffff);
11761206}
11771207
11781208/*popmessage   ("Regs %08x %08x %08x\n     %08x %08x %08x",
1179    psikyosh_bgram[0x17f0/4], psikyosh_bgram[0x17f4/4], psikyosh_bgram[0x17f8/4],
1180    psikyosh_bgram[0x1ff0/4], psikyosh_bgram[0x1ff4/4], psikyosh_bgram[0x1ff8/4]);*/
1209    state->bgram[0x17f0 / 4], state->bgram[0x17f4 / 4], state->bgram[0x17f8 / 4],
1210    state->bgram[0x1ff0 / 4], state->bgram[0x1ff4 / 4], state->bgram[0x1ff8 / 4]);*/
11811211/*popmessage   ("Regs %08x %08x %08x\n     %08x %08x %08x",
1182    psikyosh_bgram[0x13f0/4], psikyosh_bgram[0x13f4/4], psikyosh_bgram[0x13f8/4],
1183    psikyosh_bgram[0x1bf0/4], psikyosh_bgram[0x1bf4/4], psikyosh_bgram[0x1bf8/4]);*/
1212    state->bgram[0x13f0 / 4], state->bgram[0x13f4 / 4], state->bgram[0x13f8 / 4],
1213    state->bgram[0x1bf0 / 4], state->bgram[0x1bf4 / 4], state->bgram[0x1bf8 / 4]);*/
11841214/*popmessage   ("Regs %08x %08x %08x %08x %08x %08x %08x %08x",
1185    psikyosh_vidregs[0], psikyosh_vidregs[1],
1186    psikyosh_vidregs[2], psikyosh_vidregs[3],
1187    psikyosh_vidregs[4], psikyosh_vidregs[5],
1188    psikyosh_vidregs[6], psikyosh_vidregs[7]);*/
1215    state->vidregs[0], state->vidregs[1],
1216    state->vidregs[2], state->vidregs[3],
1217    state->vidregs[4], state->vidregs[5],
1218    state->vidregs[6], state->vidregs[7]);*/
src/mame/video/boogwing.c
r6740r6741
11#include "driver.h"
2#include "deco16ic.h"
2#include "includes/deco16ic.h"
33
44static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect, UINT16* spriteram_base, int gfx_region)
55{
src/mame/video/offtwall.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "offtwall.h"
8#include "includes/offtwall.h"
99
1010
1111
src/mame/video/equites.c
r6740r6741
11#include "driver.h"
2#include "equites.h"
2#include "includes/equites.h"
33
44
55/*************************************
src/mame/video/gradius3.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
44
55#define TOTAL_CHARS 0x1000
r6740r6741
1717
1818***************************************************************************/
1919
20static void gradius3_tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
20void gradius3_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
2121{
2222   /* (color & 0x02) is flip y handled internally by the 052109 */
2323   *code |= ((*color & 0x01) << 8) | ((*color & 0x1c) << 7);
r6740r6741
3232
3333***************************************************************************/
3434
35static void gradius3_sprite_callback(int *code,int *color,int *priority_mask,int *shadow)
35void gradius3_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask,int *shadow)
3636{
3737   #define L0 0xaa
3838   #define L1 0xcc
r6740r6741
6060
6161VIDEO_START( gradius3 )
6262{
63   const device_config *k052109 = devtag_get_device(machine, "k052109");
64   const device_config *k051960 = devtag_get_device(machine, "k051960");
6365   int i;
6466
6567   layer_colorbase[0] = 0;
6668   layer_colorbase[1] = 32;
6769   layer_colorbase[2] = 48;
6870   sprite_colorbase = 16;
69   K052109_vh_start(machine,"gfx1",GRADIUS3_PLANE_ORDER,gradius3_tile_callback);
70   K051960_vh_start(machine,"gfx2",GRADIUS3_PLANE_ORDER,gradius3_sprite_callback);
7171
72   K052109_set_layer_offsets(2, -2, 0);
73   K051960_set_sprite_offsets(2, 0);
72   k052109_set_layer_offsets(k052109, 2, -2, 0);
73   k051960_set_sprite_offsets(k051960, 2, 0);
7474
7575   /* re-decode the sprites because the ROMs are connected to the custom IC differently
7676       from how they are connected to the CPU. */
77   for (i = 0;i < TOTAL_SPRITES;i++)
77   for (i = 0; i < TOTAL_SPRITES; i++)
7878      gfx_element_mark_dirty(machine->gfx[1],i);
7979
8080   gfx_element_set_source(machine->gfx[0], (UINT8 *)gradius3_gfxram);
r6740r6741
113113
114114VIDEO_UPDATE( gradius3 )
115115{
116   const address_space *space = cputag_get_address_space(screen->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
116   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
117   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
117118
118119   /* TODO: this kludge enforces the char banks. For some reason, they don't work otherwise. */
119   K052109_w(space,0x1d80,0x10);
120   K052109_w(space,0x1f00,0x32);
120   k052109_w(k052109, 0x1d80, 0x10);
121   k052109_w(k052109, 0x1f00, 0x32);
121122
122   K052109_tilemap_update();
123   k052109_tilemap_update(k052109);
123124
124125   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
125126   if (gradius3_priority == 0)
126127   {
127      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],TILEMAP_DRAW_OPAQUE,2);
128      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,4);
129      tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,1);
128      k052109_tilemap_draw(k052109, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE, 2);
129      k052109_tilemap_draw(k052109, bitmap, cliprect, 2, 0, 4);
130      k052109_tilemap_draw(k052109, bitmap, cliprect, 0, 0, 1);
130131   }
131132   else
132133   {
133      tilemap_draw(bitmap,cliprect,K052109_tilemap[0],TILEMAP_DRAW_OPAQUE,1);
134      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,2);
135      tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,4);
134      k052109_tilemap_draw(k052109, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 1);
135      k052109_tilemap_draw(k052109, bitmap, cliprect, 1, 0, 2);
136      k052109_tilemap_draw(k052109, bitmap, cliprect, 2, 0, 4);
136137   }
137138
138   K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
139   k051960_sprites_draw(k051960, bitmap, cliprect, -1, -1);
139140   return 0;
140141}
src/mame/video/mystwarr.c
r6740r6741
77
88#include "driver.h"
99#include "video/konamiic.h"
10#include "konamigx.h"
10#include "includes/konamigx.h"
1111
1212static int layer_colorbase[6];
1313static int oinprion, cbparam;
src/mame/video/irobot.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "irobot.h"
8#include "includes/irobot.h"
99
1010#define BITMAP_WIDTH   256
1111static UINT8 *polybitmap1,*polybitmap2;
src/mame/video/klax.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "klax.h"
8#include "includes/klax.h"
99
1010
1111
src/mame/video/konicdev.c
r0r6741
1/***************************************************************************
2
3TODO:
4- It seems shadows can both affect underlying sprites and not. This is currently
5  hardcoded in the drivers; there might be a control bit somewhere.
6  Games requiring shadows to affect sprites behind them:
7  - Surprise Attack (dark glass walls in level 3)
8  - 88 Games (angle indicator in the long jump event).
9  - Sunset Riders (bull's eye in the saloon cutscene)
10  Games requiring shadows to NOT affect sprites behind them:
11  - Asterix (Asterix's shadow would be over his feet otherwise)
12  - X-Men is dubious, see enemies halfway through level 1 coming from above with
13    boulders over their heads.
14
15- scrollcontrol = 30 in Golfing Greats (leader board)
16
17- detatwin: sprites are left on screen during attract mode
18
19
20                      Emulated
21                         |
22                  board #|year    CPU      tiles        sprites  priority palette    other
23                    -----|---- ------- ------------- ------------- ------ ------ ----------------
24Hyper Crash         GX401 1985                   GX400
25Twinbee             GX412*1985   68000           GX400
26Yie Ar Kung Fu      GX407*1985    6809
27Gradius / Nemesis   GX456*1985   68000           GX400
28Shao-lins Road      GX477*1985    6809
29Jail Break          GX507*1986 KONAMI-1          005849                   PROMs
30Finalizer           GX523*1985 KONAMI-1          005885                   PROMs
31Konami's Ping Pong  GX555*1985     Z80
32Iron Horse          GX560*1986    6809           005885                   PROMs
33Konami GT           GX561*1985   68000           GX400
34Green Beret         GX577*1985     Z80           005849                   PROMs
35Galactic Warriors   GX578*1985   68000           GX400
36Salamander          GX587*1986   68000           GX400
37WEC Le Mans 24      GX602*1986 2x68000
38BAW / Black Panther GX604*1987   68000           GX400                    007593
39Combat School /     GX611*1987    6309           007121(x2)               007327
40  Boot Camp
41Rock 'n Rage /      GX620*1986    6309 007342        007420               007327
42  Koi no Hotrock
43Mr Kabuki/Mr Goemon GX621*1986     Z80           005849
44Jackal              GX631*1986    6809           005885(x2)               007327 007343 (address decoder)
45Contra / Gryzor     GX633*1987    6809?          007121(x2)               007593
46Flak Attack         GX669*1987    6309           007121                   007327 007452
47Devil World / Dark  GX687*1987 2x68000           TWIN16
48  Adventure / Majuu no Oukoku
49Double Dribble      GX690*1986  3x6809           005885(x2)               007327 007452
50Kitten Kaboodle /   GX712*1988                   GX400                    007593 051550
51  Nyan Nyan Panic
52Chequered Flag      GX717*1988  052001               051960 051937(x2)           051316(x2) (roz) 051733 (protection)
53Fast Lane           GX752*1987    6309           007121                          051733 (protection) 007801
54Hot Chase           GX763*1988 2x68000                                           051316(x3) (roz) 007634 007635 007558 007557
55Rack 'Em Up /       GX765*1987    6309 007342        007420               007327 007324
56  The Hustler
57Haunted Castle      GX768*1988  052001           007121(x2)               007327
58Ajax / Typhoon      GX770*1987   6309+ 052109 051962 051960 051937  PROM  007327 051316 (roz)
59                                052001
60Labyrinth Runner /  GX771*1987    6309           007121                   007593 051733 (protection) 051550
61  Trick Trap
62Super Contra        GX775*1988  052001 052109 051962 051960 051937  PROM  007327
63Battlantis          GX777*1987    6309 007342        007420               007327 007324
64Vulcan Venture /    GX785*1988 2x68000           TWIN16
65  Gradius 2
66City Bomber         GX787*1987   68000           GX400                    007593 051550
67Over Drive          GX789*1990 2x68000               053247 053246 053251 051316(x2) (roz) 053249 053250(x2) (road) 053252(*)
68Hyper Crash         GX790 1987
69Blades of Steel     GX797*1987    6309 007342        007420               007327 051733 (protection)
70The Main Event      GX799*1988    6309 052109 051962 051960 051937  PROM
71Missing in Action   GX808*1989   68000 052109 051962 051960 051937  PROM
72Missing in Action J GX808*1989 2x68000           TWIN16
73Crime Fighters      GX821*1989  052526 052109 051962 051960 051937  PROM
74Special Project Y   GX857*1989    6309 052109 051962 051960 051937  PROM         052591 (protection)
75'88 Games           GX861*1988  052001 052109 051962 051960 051937  PROM         051316 (roz)
76Final Round /       GX870*1988 1x68000           TWIN16?
77  Hard Puncher
78Thunder Cross       GX873*1988  052001 052109 051962 051960 051937  PROM  007327 052591 (protection)
79Aliens              GX875*1990  052526 052109 051962 051960 051937  PROM
80Gang Busters        GX878*1988  052526 052109 051962 051960 051937  PROM
81Devastators         GX890*1988    6309 052109 051962 051960 051937  PROM         007324 051733 (protection)
82Bottom of the Ninth GX891*1989    6809 052109 051962 051960 051937  PROM         051316 (roz)
83Cue Brick           GX903*1989   68000 052109 051962 051960 051937  PROM
84Cue Brick           GX903*1989 2x68000           TWIN16
85Punk Shot           GX907*1990   68000 052109 051962 051960 051937 053251
86Ultraman            GX910*1991   68000 ------ ------ 051960 051937  PROM         051316(x3) (roz) 051550
87Surprise Attack     GX911*1990  053248 052109 051962 053245 053244 053251
88Lightning Fighters /GX939*1990   68000 052109 051962 053245 053244 053251
89  Trigon
90Gradius 3           GX945*1989 2x68000 052109 051962 051960 051937  PROM
91Parodius            GX955*1990  053248 052109 051962 053245 053244 053251
92TMNT                GX963*1989   68000 052109 051962 051960 051937  PROM
93Block Hole          GX973*1989  052526 052109 051962 051960 051937  PROM
94Escape Kids         GX975*1991  053248 052109 051962 053247 053246 053251        053252(*)
95Rollergames         GX999*1991  053248 ------ ------ 053245 053244               051316 (roz) 053252(*)
96Bells & Whistles /  GX060*1991   68000 052109 051962 053245 053244 053251        054000 (collision)
97  Detana!! Twin Bee
98Golfing Greats      GX061*1991   68000 052109 051962 053245 053244 053251        053936 (roz+)
99TMNT 2              GX063*1991   68000 052109 051962 053245 053244 053251        053990 (protection) 051550
100Sunset Riders       GX064*1991   68000 052109 051962 053245 053244 053251        054358
101X-Men               GX065*1992   68000 052109 051962 053247 053246 053251        054539 (sound)
102XEXEX               GX067*1991   68000 054157 054156 053247 053246 053251        053250?("road") 054338 (alpha blending) 054539 (sound)
103Asterix             GX068*1992   68000 054157 054156 053245 053244 053251        054358
104G.I. Joe            GX069*1992   68000 054157 054156 053247 053246 053251        054539 (sound)
105The Simpsons        GX072*1991  053248 052109 051962 053247 053246 053251
106Thunder Cross 2     GX073*1991   68000 052109 051962 051960 051937 053251        054000 (collision)
107Vendetta /          GX081*1991  053248 052109 051962 053247 053246 053251        054000 (collision)
108  Crime Fighters 2
109Premier Soccer      GX101*1993   68000 052109 051962 053245 053244 053251        053936 (roz+) 054986
110Hexion              GX122*1992     Z80                                           052591 (protection) 053252(*)
111Entapous /          GX123*1993   68000 054157 054156 055673 053246 055555        053252(*) 054000 053936 (roz+)
112  Gaiapolis
113Mystic Warrior      GX128*1993   68000 054157 054156 055673 053246 055555        054338 (alpha blending) 053252(*) 054539(x2) (sound)
114Cowboys of Moo Mesa GX151*1992   68000 054157 054156 053247 053246 053251        053252(*) 054338 (alpha blending) 053990 (protection)
115Violent Storm       GX168*1993   68000 054157 054156 055673 053246 055555        054338 (alpha blending) 055550 054539(x2) (sound)
116Monster Maulers /   GX170*1993   68000 054157 054156 055673 053246 055555        053252(*) 055550 054338 (alpha blending) 054539 (sound) 053936 (roz+)
117  Ultimate Battler Dadandarn
118Bucky 'O Hare       GX173*1992   68000 054157 054156 053247 053246 053251        054338 (alpha blending) 054539 (sound)
119Potrio              GX174 1992
120Lethal Enforcers    GX191*1992    6309 054157(x2) 054156 053245 053244(x2)       054000 054539 (sound)
121Metamorphic Force   GX224*1993   68000 054157 054157 055673 053246 055555
122Martial Champion    GX234*1993   68000 054157 054156 055673 053246 055555        053252(*) 054338 (alpha blending) 053990 054539 (sound)
123Run and Gun         GX247*1993   68000 (TTL tilemap) 055673 053246               053253(x2) 053252(*) 053936 (roz+) 054539(x2) (sound)
124Quiz Gakumon no     GX248*1993   68000 052109 051962 053245 053244 053251        053990 (protection) 051550 - same board as TMNT2
125  Susume
126Polygonet Commander GX305+1993   68020 (TTL tilemap)                             XC56156-40(3D DSP) 054009(x2) 054010(x2) 054539 (sound)
127System GX (ver 1)   GX300*1993   68020 056832 054156 055673 053246 055555        054338 (alpha blending) 054539(x2) (sound) 053252(*) 053936 (optional on ROM board, roz+)
128System GX (ver 2)   GX300*1995   68020 056832 058143 055673 058142 055555        058144 (alpha blending) 058141 (sound) 053252(*) 053936 (optional on ROM board, roz+)
129Beatmania DJ Main   GX858+1996   68020 056832 058143 056766        055555        058144 (alpha blending) 058141 (sound) 053252(*)
130Tail to Nose             *1989   68000          V-System                         051316 (roz)
131F-1 Grand Prix           *1991 2x68000          V-System                         053936 (roz+)
132F-1 Grand Prix Part II   *1992 2x68000          V-System                         053936 (roz+)
133Lethal Crash Race        *1993   68000          V-System                         053936 (roz+)
134Super Slams              *1995   68000          V-System                         053936 (roz+)
135Blazing Tornado          *1991   68000            Metro                          053936 (roz+)
136Dragonball Z 2           *1994   68000 054157 054156 053247 053246 053251(x2)    053936(x2) (roz+) 053252(*)
137
138
139Notes:
140* 053252 seems to be just a timing/interrupt controller (see Vendetta schematics).
141
142- Old games use 051961 instead of 052109, it is an earlier version functionally
143  equivalent (maybe 052109 had bugs fixed). The list always shows 052109 because
144  the two are exchangeable and 052109's are found also on original boards whose
145  schematics show a 051961.
146
147- Starting with the version 2 System GX mainboard, the following chip substitutions took place.
148  All "new" chips are equivalent to their older counterparts, but are in a smaller package (and
149  presumably are made on a smaller process).  The exception is the 058141, which is equivalent
150  to 2 54539s (and yet takes less board space than even 1).
151
152  058141 = 054539 (x2) (2 sound chips in one)
153  058142 = 053246 (sprites)
154  058143 = 054156 (tiles)
155  058144 = 054338 (alpha blending)
156
157
158
159Status of the ROM tests in the emulated games:
160
161Chequered Flag      pass
162Ajax / Typhoon      pass
163Super Contra        pass
164Over Drive          fails 16..20 (053250)
165The Main Event      pass
166Missing in Action   pass
167Crime Fighters      pass
168Special Project Y   pass
169Konami 88           pass
170Thunder Cross       pass
171Aliens              pass
172Gang Busters        pass
173Devastators         pass
174Bottom of the Ninth pass
175Punk Shot           pass
176Surprise Attack     fails D05-6 (052109) because it uses mirror addresses to
177                    select banks, and supporting those addresses breaks the
178                    normal game ;-(
179Lightning Fighters  pass
180Gradius 3           pass
181Parodius            pass
182TMNT                pass
183Block Hole          pass
184Escape Kids         pass
185Rollergames         pass
186Bells & Whistles    pass
187Golfing Greats      pass
188TMNT 2              pass
189Sunset Riders       pass
190X-Men               pass
191The Simpsons        pass
192Thunder Cross 2     pass
193Xexex               pass
194Asterix             pass
195GiJoe               pass
196Vendetta            pass
197Premier Soccer      fails 16D 18D 18F (053936)
198Hexion              pass
199Run and Gun         fails 36M (053936) 2U 2Y 5U 5Y (sprites)
200Quiz Gakumon no Susume  pass
201Dragonball Z 2      fails
202
203
204THE FOLLOWING INFORMATION IS PRELIMINARY AND INACCURATE. DON'T RELY ON IT.
205
206
207005885
208------
209Some games use two of these in pair. Jackal even puts together the two 4bpp
210tilemaps to form a single 8bpp one.
211It manages sprites and 32x32 or 64x32 tilemap (only Double Dribble uses the
21264x32 one).
213The chip also generates clock and interrupt signals suitable for a 6809.
214It uses 0x2000 bytes of RAM for the tilemaps and sprites, and an additional
2150x100 bytes, maybe for scroll RAM and line buffers. The maximum addressable
216ROM is 0x20000 bytes (addressed 16 bits at a time). Tile and sprite data both
217come from the same ROM space. Double Dribble and Jackal have external circuitry
218to extend the limits and use separated addressing spaces for sprites and tiles.
219All games use external circuitry to reuse one or both the tile flip attributes
220as an additional address bit.
221Two 256x4 lookup PROMs are also used to increase the color combinations.
222All tilemap / sprite priority handling is done internally and the chip exports
2235 bits of color code, composed of 1 bit indicating tile or sprite, and 4 bits
224of ROM data remapped through the PROM.
225
226inputs:
227- address lines (A0-A13)
228- data lines (DB0-DB7)
229- misc interface stuff
230- data from the gfx ROMs (RDL0-RDL7, RDU0-RDU7)
231- data from the tile lookup PROMs (VCD0-VCD3)
232- data from the sprite lookup PROMs (OCD0-OCD3)
233
234outputs:
235- address lines for tilemap RAM (AX0-AX12)
236- data lines for tilemap RAM (VO0-VO7)
237- address lines for the small RAM (FA0-FA7)
238- data lines for the small RAM (FD0-FD7)
239- address lines for the gfx ROMs (R0-R15)
240- address lines for the tile lookup PROMs (VCF0-VCF3, VCB0-VCB3)
241- address lines for the sprite lookup PROMs (OCB0-OCB3, OCF0-OCF3)
242- NNMI, NIRQ, NFIR, NCPE, NCPQ, NEQ for the main CPU
243- misc interface stuff
244- color code to be output on screen (COL0-COL4)
245
246
247control registers
248000:          scroll y
249001:          scroll x (low 8 bits)
250002: -------x scroll x (high bit)
251     ----xxx- row/colscroll control
252              000 = solid scroll (finalizr, ddribble bg)
253              100 = solid scroll (jackal)
254              001 = ? (ddribble fg)
255              011 = colscroll (jackal high scores)
256              101 = rowscroll (ironhors, jackal map)
257003: ------xx high bits of the tile code
258     -----x-- unknown (finalizr)
259     ----x--- selects sprite buffer (and makes a copy to a private buffer?)
260     --x----- unknown (ironhors)
261     -x------ unknown (ironhors)
262     x------- unknown (ironhors, jackal)
263004: -------x nmi enable
264     ------x- irq enable
265     -----x-- firq enable
266     ----x--- flip screen
267
268
269
270007121
271------
272This is an interesting beast. It is an evolution of the 005885, with more
273features. Many games use two of these in pair.
274It manages sprites and two 32x32 tilemaps. The tilemaps can be joined to form
275a single 64x32 one, or one of them can be moved to the side of screen, giving
276a high score display suitable for vertical games.
277The chip also generates clock and interrupt signals suitable for a 6809.
278It uses 0x2000 bytes of RAM for the tilemaps and sprites, and an additional
2790x100 bytes, maybe for scroll RAM and line buffers. The maximum addressable
280ROM is 0x80000 bytes (addressed 16 bits at a time). Tile and sprite data both
281come from the same ROM space.
282Two 256x4 lookup PROMs are also used to increase the color combinations.
283All tilemap / sprite priority handling is done internally and the chip exports
2847 bits of color code, composed of 2 bits of palette bank, 1 bit indicating tile
285or sprite, and 4 bits of ROM data remapped through the PROM.
286
287inputs:
288- address lines (A0-A13)
289- data lines (DB0-DB7)
290- misc interface stuff
291- data from the gfx ROMs (RDL0-RDL7, RDU0-RDU7)
292- data from the tile lookup PROMs (VCD0-VCD3)
293- data from the sprite lookup PROMs (OCD0-OCD3)
294
295outputs:
296- address lines for tilemap RAM (AX0-AX12)
297- data lines for tilemap RAM (VO0-VO7)
298- address lines for the small RAM (FA0-FA7)
299- data lines for the small RAM (FD0-FD7)
300- address lines for the gfx ROMs (R0-R17)
301- address lines for the tile lookup PROMs (VCF0-VCF3, VCB0-VCB3)
302- address lines for the sprite lookup PROMs (OCB0-OCB3, OCF0-OCF3)
303- NNMI, NIRQ, NFIR, NE, NQ for the main CPU
304- misc interface stuff
305- color code to be output on screen (COA0-COA6)
306
307
308control registers
309000:          scroll x (low 8 bits)
310001: -------x scroll x (high bit)
311     ------x- enable rowscroll? (combasc)
312     ----x--- this probably selects an alternate screen layout used in combat
313              school where tilemap #2 is overlayed on front and doesn't scroll.
314              The 32 lines of the front layer can be individually turned on or
315              off using the second 32 bytes of scroll RAM.
316002:          scroll y
317003: -------x bit 13 of the tile code
318     ------x- unknown (contra)
319     -----x-- might be sprite / tilemap priority (0 = sprites have priority)
320              (combat school, contra, haunted castle(0/1), labyrunr)
321     ----x--- selects sprite buffer (and makes a copy to a private buffer?)
322     ---x---- screen layout selector:
323              when this is set, 5 columns are added on the left of the screen
324              (that means 5 rows at the top for vertical games), and the
325              rightmost 2 columns are chopped away.
326              Tilemap #2 is used to display the 5 additional columns on the
327              left. The rest of tilemap #2 is not used and can be used as work
328              RAM by the program.
329              The visible area becomes 280x224.
330              Note that labyrunr changes this at runtime, setting it during
331              gameplay and resetting it on the title screen and crosshatch.
332     --x----- might be sprite / tilemap priority (0 = sprites have priority)
333              (combat school, contra, haunted castle(0/1), labyrunr)
334     -x------ Chops away the leftmost and rightmost columns, switching the
335              visible area from 256 to 240 pixels. This is used by combasc on
336              the scrolling stages, and by labyrunr on the title screen.
337              At first I thought that this enabled an extra bank of 0x40
338              sprites, needed by combasc, but labyrunr proves that this is not
339              the case
340     x------- unknown (contra)
341004: ----xxxx bits 9-12 of the tile code. Only the bits enabled by the following
342              mask are actually used, and replace the ones selected by register
343              005.
344     xxxx---- mask enabling the above bits
345005: selects where in the attribute byte to pick bits 9-12 of the tile code,
346     output to pins R12-R15. The bit of the attribute byte to use is the
347     specified bit (0-3) + 3, that is one of bits 3-6. Bit 7 is hardcoded as
348     bit 8 of the code. Bits 0-2 are used for the color, however note that
349     some games use bit 3 as well (see below).
350     ------xx attribute bit to use for tile code bit  9
351     ----xx-- attribute bit to use for tile code bit 10
352     --xx---- attribute bit to use for tile code bit 11
353     xx------ attribute bit to use for tile code bit 12
354006: ----xxxx select additional effect for bits 3-6 of the tile attribute (the
355              same ones indexed by register 005). Note that an attribute bit
356              can therefore be used at the same time to be BOTH a tile code bit
357              and an additional effect.
358     -------x bit 3 of attribute is bit 3 of color (combasc, fastlane, flkatck)
359     ------x- bit 4 of attribute is tile flip X (assumption - no game uses this)
360     -----x-- bit 5 of attribute is tile flip Y (flkatck)
361     ----x--- bit 6 of attribute is tile priority over sprites (combasc, hcastle,
362              labyrunr)
363              Note that hcastle sets this bit for layer 0, and bit 6 of the
364              attribute is also used as bit 12 of the tile code, however that
365              bit is ALWAYS set throughout the game.
366              combasc uses the bit in the "graduation" scene during attract mode,
367              to place soldiers behind the stand.
368              Use in labyrunr has not been investigated yet.
369     --xx---- palette bank (both tiles and sprites, see contra)
370007: -------x nmi enable
371     ------x- irq enable
372     -----x-- firq enable
373     ----x--- flip screen
374     ---x---- unknown (contra, labyrunr)
375
376
377
378007342
379------
380The 007342 manages 2 64x32 scrolling tilemaps with 8x8 characters, and
381optionally generates timing clocks and interrupt signals. It uses 0x2000
382bytes of RAM, plus 0x0200 bytes for scrolling, and a variable amount of ROM.
383It cannot read the ROMs.
384
385control registers
386000: ------x- INT control
387     ---x---- flip screen (TODO: doesn't work with thehustl)
388001: Used for banking in Rock'n'Rage
389002: -------x MSB of x scroll 1
390     ------x- MSB of x scroll 2
391     ---xxx-- layer 1 row/column scroll control
392              000 = disabled
393              010 = unknown (bladestl shootout between periods)
394              011 = 32 columns (Blades of Steel)
395              101 = 256 rows (Battlantis, Rock 'n Rage)
396     x------- enable sprite wraparound from bottom to top (see Blades of Steel
397              high score table)
398003: x scroll 1
399004: y scroll 1
400005: x scroll 2
401006: y scroll 2
402007: not used
403
404
405007420
406------
407Sprite generator. 8 bytes per sprite with zoom. It uses 0x200 bytes of RAM,
408and a variable amount of ROM. Nothing is known about its external interface.
409
410
411
412052109/051962
413-------------
414These work in pair.
415The 052109 manages 3 64x32 scrolling tilemaps with 8x8 characters, and
416optionally generates timing clocks and interrupt signals. It uses 0x4000
417bytes of RAM, and a variable amount of ROM. It cannot read the ROMs:
418instead, it exports 21 bits (16 from the tilemap RAM + 3 for the character
419raster line + 2 additional ones for ROM banking) and these are externally
420used to generate the address of the required data on the ROM; the output of
421the ROMs is sent to the 051962, along with a color code. In theory you could
422have any combination of bits in the tilemap RAM, as long as they add to 16.
423In practice, all the games supported so far standardize on the same format
424which uses 3 bits for the color code and 13 bits for the character code.
425The 051962 multiplexes the data of the three layers and converts it into
426palette indexes and transparency bits which will be mixed later in the video
427chain.
428Priority is handled externally: these chips only generate the tilemaps, they
429don't mix them.
430Both chips are interfaced with the main CPU. When the RMRD pin is asserted,
431the CPU can read the gfx ROM data. This is done by telling the 052109 which
432dword to read (this is a combination of some banking registers, and the CPU
433address lines), and then reading it from the 051962.
434
435052109 inputs:
436- address lines (AB0-AB15, AB13-AB15 seem to have a different function)
437- data lines (DB0-DB7)
438- misc interface stuff
439
440052109 outputs:
441- address lines for the private RAM (RA0-RA12)
442- data lines for the private RAM (VD0-VD15)
443- NMI, IRQ, FIRQ for the main CPU
444- misc interface stuff
445- ROM bank selector (CAB1-CAB2)
446- character "code" (VC0-VC10)
447- character "color" (COL0-COL7); used foc color but also bank switching and tile
448  flipping. Exact meaning depends on externl connections. All evidence indicates
449  that COL2 and COL3 select the tile bank, and are replaced with the low 2 bits
450  from the bank register. The top 2 bits of the register go to CAB1-CAB2.
451  However, this DOES NOT WORK with Gradius III. "color" seems to pass through
452  unaltered.
453- layer A horizontal scroll (ZA1H-ZA4H)
454- layer B horizontal scroll (ZB1H-ZB4H)
455- ????? (BEN)
456
457051962 inputs:
458- gfx data from the ROMs (VC0-VC31)
459- color code (COL0-COL7); only COL4-COL7 seem to really be used for color; COL0
460  is tile flip X.
461- layer A horizontal scroll (ZA1H-ZA4H)
462- layer B horizontal scroll (ZB1H-ZB4H)
463- let main CPU read the gfx ROMs (RMRD)
464- address lines to be used with RMRD (AB0-AB1)
465- data lines to be used with RMRD (DB0-DB7)
466- ????? (BEN)
467- misc interface stuff
468
469051962 outputs:
470- FIX layer palette index (DFI0-DFI7)
471- FIX layer transparency (NFIC)
472- A layer palette index (DSA0-DSAD); DSAA-DSAD seem to be unused
473- A layer transparency (NSAC)
474- B layer palette index (DSB0-DSBD); DSBA-DSBD seem to be unused
475- B layer transparency (NSBC)
476- misc interface stuff
477
478
479052109 memory layout:
4800000-07ff: layer FIX tilemap (attributes)
4810800-0fff: layer A tilemap (attributes)
4821000-1fff: layer B tilemap (attributes)
483180c-1833: A y scroll
4841a00-1bff: A x scroll
4851c00     : ?
4861c80     : row/column scroll control
487           ------xx layer A row scroll
488                    00 = disabled
489                    01 = disabled? (gradius3, vendetta)
490                    10 = 32 lines
491                    11 = 256 lines
492           -----x-- layer A column scroll
493                    0 = disabled
494                    1 = 64 (actually 40) columns
495           ---xx--- layer B row scroll
496           --x----- layer B column scroll
497           surpratk sets this register to 70 during the second boss. There is
498           nothing obviously wrong so it's not clear what should happen.
499           glfgreat sets it to 30 when showing the leader board
5001d00     : bits 0 & 1 might enable NMI and FIRQ, not sure
501         : bit 2 = IRQ enable
5021d80     : ROM bank selector bits 0-3 = bank 0 bits 4-7 = bank 1
5031e00     : ROM subbank selector for ROM testing
5041e80     : bit 0 = flip screen (applies to tilemaps only, not sprites)
505         : bit 1 = set by crimfght, mainevt, surpratk, xmen, mia, punkshot, thndrx2, spy
506         :         it seems to enable tile flip X, however flip X is handled by the
507         :         051962 and it is not hardwired to a specific tile attribute.
508         :         Note that xmen, punkshot and thndrx2 set the bit but the current
509         :         drivers don't use flip X and seem to work fine.
510         : bit 2 = enables tile flip Y when bit 1 of the tile attribute is set
5111f00     : ROM bank selector bits 0-3 = bank 2 bits 4-7 = bank 3
5122000-27ff: layer FIX tilemap (code)
5132800-2fff: layer A tilemap (code)
5143000-37ff: layer B tilemap (code)
5153800-3807: nothing here, so the chip can share address space with a 051937
516380c-3833: B y scroll
5173a00-3bff: B x scroll
5183c00-3fff: nothing here, so the chip can share address space with a 051960
5193d80     : mirror of 1d80, but ONLY during ROM test (surpratk)
5203e00     : mirror of 1e00, but ONLY during ROM test (surpratk)
5213f00     : mirror of 1f00, but ONLY during ROM test (surpratk)
522EXTRA ADDRESSING SPACE USED BY X-MEN:
5234000-47ff: layer FIX tilemap (code high bits)
5244800-4fff: layer A tilemap (code high bits)
5255000-57ff: layer B tilemap (code high bits)
526
527The main CPU doesn't have direct acces to the RAM used by the 052109, it has
528to through the chip.
529
530
531
532054156/054157
533054156/056832
534-------------
535
536[Except for tilemap sizes, all numbers are in hex]
537
538These work in pairs.  Similar in principle to the 052109/051962, they
539manage 4 64x32 or 64x64 tilemaps.  They also handle linescroll on each
540layer, and optional tile banking.  They use 4000 to 10000 bytes of
541RAM, organized in 1000 or 2000 bytes banks.
542
543The 56832 is a complete superset of the 54157 and supports higher color
544depths (the 156/157 combo only goes to 5 bpp, the 156/832 combo goes to 8bpp).
545
546These chips work in a fairly unusual way.  There are 4, 8, or 16 pages of VRAM, arranged
547conceptually in a 4x4 2 dimensional grid.  Each page is a complete 64x32 tile tilemap.
548
549The 4 physical tilemaps A, B, C, and, D are made up of these pages "glued together".
550Each physical tilemap has an X and Y position in the 4x4 page grid indicating where
551the page making up it's upper left corner is, as well as a width and height in pages.
552If two tilemaps try to use the same page, the higher-letter one wins and the lower-letter
553one is disabled completely.  E.g. A > B > C > D, so if A and B both try to use the
554same page only A will be displayed.  Some games rely on this behavior to implicitly
555disable tilemaps which otherwise should be displayed.
556
557Tile encoding 2 bytes/tile (banks of 1000 bytes):
558        pppx bbcc cccc cccc
559  p = color palette
560  x = flip x
561  b = tile bank (0..3)
562  c = tile code (0..3ff)
563
564
565Tile encoding 4 bytes/tile (banks of 2000 bytes):
566        ---- ---- pppp --yx  cccc cccc cccc cccc
567  p = color palette
568  x = flip x
569  y = flip y
570  b = tile bank (0..3)
571  c = tile code (0..3ff)
572
573
574Communication with these ics go through 4 memory zones:
575  1000/2000 bytes: access to the currently selected ram bank
576       2000 bytes: readonly access the the currently select tile
577                   rom bank for rom checksumming
578         40 bytes: writeonly access to the first register bank
579          8 bytes: writeonly access to the second register bank
580
581One of the register banks is probably on the 054156, and the other on
582the 054157.
583
584First register bank map (offsets in bytes, '-' means unused):
58500    ---- ---- ??yx ????
586  flip control
587
58802    ---- ---- ???? ????
589  unknown
590
59104    ---- ---- ???? ????
592  unknown (bit 1 may be bank count selection, 0 in xexex, 1 everywhere
593  else)
594
59506    ---- ---- ???? ???e
596  enable irq
597
59808    ---- ---- ???? ????
599  unknown
600
6010a    ---- ---- 3322 1100
602  linescroll control, each pair of bits indicates the mode for the
603  corresponding layer:
604    0: per-line linescroll
605    1: unused/unknown
606    2: per-8 lines linescroll
607    3: no linescroll
608
6090c    ---- ---- ???? ????
610  unknown (bit 1 may be bank size selection, 1 in asterix, 0 everywhere
611  else)
612
6130e    ---- ---- ---- ----
614
61510-13 ---- ---- ---y y-hh
616   layer Y position in the VRAM grid and height in pages
617
61814-17 ---- ---- ---x x-ww
619   layer X position in the VRAM grid and width in pages
62018-1f ---- ---- ???? ????
621
62220-27 yyyy yyyy yyyy yyyy
623  scroll y position for each layer
624
62528-2f xxxx xxxx xxxx xxxx
626  scroll x position for each layer
627
62830    ---- ---- ---b b--b
629  linescroll ram bank selection
630
63132    ---- ---- ---b b--b
632  cpu-accessible ram bank selection
633
63434    bbbb bbbb bbbb bbbb
635  rom bank selection for checksumming (each bank is 0x2000 bytes)
636
63736    ---- ---- ---- bbbb
638  secondary rom bank selection for checksumming when tile banking is
639  used
640
64138    3333 2222 1111 0000
642  tile banking look up table.  4 bits are looked up here for the two
643  bits in the tile data.
644
6453a    ???? ???? ???? ????
646  unknown
647
6483c    ???? ???? ???? ????
649  unknown
650
6513e    ---- ---- ---- ----
652
653
654Second register bank map:
65500    ---- ---- ???? ????
656  unknown
657
65802-07 are copies of the 02-07 registers from the first bank.
659
660
661  Linescroll:
662
663The linescroll is controlled by the register 0b, and uses the data in
664the ram bank pointed by register 31.  The data for tilemap <n> starts
665at offset 400*n in the bank for 1000 bytes ram banks, and 800*n+2 for
6662000 bytes ram banks.  The scrolling information is a vector of half
667words separated by 1 word padding for 2000 bytes banks.
668
669This is a source-oriented linescroll, i.e. the first word is
670associated to the first one of the tilemap, not matter what the
671current scrolly position is.
672
673In per-line mode, each word indicates the horizontal scroll of the
674associated line.  Global scrollx is ignored.
675
676In per-8 lines mode, each word associated to a line multiple of 8
677indicates the horizontal scroll for that line and the 7 following
678ones.  The other 7 words are ignored.  Global scrollx is ignored.
679
680
681
682051960/051937
683-------------
684Sprite generators. Designed to work in pair. The 051960 manages the sprite
685list and produces and address that is fed to the gfx ROMs. The data from the
686ROMs is sent to the 051937, along with color code and other stuff from the
687051960. The 051937 outputs up to 12 bits of palette index, plus "shadow" and
688transparency information.
689Both chips are interfaced to the main CPU, through 8-bit data buses and 11
690bits of address space. The 051937 sits in the range 000-007, while the 051960
691in the range 400-7ff (all RAM). The main CPU can read the gfx ROM data though
692the 051937 data bus, while the 051960 provides the address lines.
693The 051960 is designed to directly address 1MB of ROM space, since it produces
69418 address lines that go to two 16-bit wide ROMs (the 051937 has a 32-bit data
695bus to the ROMs). However, the addressing space can be increased by using one
696or more of the "color attribute" bits of the sprites as bank selectors.
697Moreover a few games store the gfx data in the ROMs in a format different from
698the one expected by the 051960, and use external logic to reorder the address
699lines.
700The 051960 can also genenrate IRQ, FIRQ and NMI signals.
701
702memory map:
703000-007 is for the 051937, but also seen by the 051960
704400-7ff is 051960 only
705000     R  bit 0 = unknown, looks like a status flag or something
706                   aliens waits for it to be 0 before starting to copy sprite data
707                   thndrx2 needs it to pulse for the startup checks to succeed
708000     W  bit 0 = irq enable/acknowledge?
709           bit 2 = nmi enable?
710           bit 3 = flip screen (applies to sprites only, not tilemaps)
711           bit 4 = unknown, used by Devastators, TMNT, Aliens, Chequered Flag, maybe others
712                   aliens sets it just after checking bit 0, and before copying
713                   the sprite data
714           bit 5 = enable gfx ROM reading
715001     W  Devastators sets bit 1, function unknown.
716           Ultraman sets the register to 0x0f.
717           None of the other games I tested seem to set this register to other than 0.
718002-003 W  selects the portion of the gfx ROMs to be read.
719004     W  Aliens uses this to select the ROM bank to be read, but Punk Shot
720           and TMNT don't, they use another bit of the registers above. Many
721           other games write to this register before testing.
722           It is possible that bits 2-7 of 003 go to OC0-OC5, and bits 0-1 of
723           004 go to OC6-OC7.
724004-007 R  reads data from the gfx ROMs (32 bits in total). The address of the
725           data is determined by the register above and by the last address
726           accessed on the 051960; plus bank switch bits for larger ROMs.
727           It seems that the data can also be read directly from the 051960
728           address space: 88 Games does this. First it reads 004 and discards
729           the result, then it reads from the 051960 the data at the address
730           it wants. The normal order is the opposite, read from the 051960 at
731           the address you want, discard the result, and fetch the data from
732           004-007.
733400-7ff RW sprite RAM, 8 bytes per sprite
734
735
736
737053245/053244
738-------------
739Sprite generators. The 053245 has a 16-bit data bus to the main CPU.
740The sprites are buffered, a write to 006 activates to copy between the
741main ram and the buffer.
742
743053244 memory map (but the 053245 sees and processes them too):
744000-001  W global X offset
745002-003  W global Y offset
746004      W unknown
747005      W bit 0 = flip screen X
748           bit 1 = flip screen Y
749           bit 2 = unknown, used by Parodius
750           bit 4 = enable gfx ROM reading
751           bit 5 = unknown, used by Rollergames
752006     RW accessing this register copies the sprite ram to the internal buffer
753007      W unknown
754008-009  W low 16 bits of the ROM address to read
75500a-00b  W high bits of the ROM address to read.  3 bits for most games, 1 for asterix
75600c-00f R  reads data from the gfx ROMs (32 bits in total). The address of the
757           data is determined by the registers above; plus bank switch bits for
758           larger ROMs.
759
760
761
762053247/053246
763-------------
764Sprite generators. Nothing is known about their external interface.
765The sprite RAM format is very similar to the 053245.
766
767053246 memory map (but the 053247 sees and processes them too):
768000-001 W  global X offset
769002-003 W  global Y offset
770004     W  low 8 bits of the ROM address to read
771005     W  bit 0 = flip screen X
772           bit 1 = flip screen Y
773           bit 2 = unknown
774           bit 4 = interrupt enable
775           bit 5 = unknown
776006-007 W  high 16 bits of the ROM address to read
777
778???-??? R  reads data from the gfx ROMs (16 bits in total). The address of the
779           data is determined by the registers above
780
781
782
783051316
784------
785Manages a 32x32 tilemap (16x16 tiles, 512x512 pixels) which can be zoomed,
786distorted and rotated.
787It uses two internal 24 bit counters which are incremented while scanning the
788picture. The coordinates of the pixel in the tilemap that has to be drawn to
789the current beam position are the counters / (2^11).
790The chip doesn't directly generate the color information for the pixel, it
791just generates a 24 bit address (whose top 16 bits are the contents of the
792tilemap RAM), and a "visible" signal. It's up to external circuitry to convert
793the address into a pixel color. Most games seem to use 4bpp graphics, but Ajax
794uses 7bpp.
795If the value in the internal counters is out of the visible range (0..511), it
796is truncated and the corresponding address is still generated, but the "visible"
797signal is not asserted. The external circuitry might ignore that signal and
798still generate the pixel, therefore making the tilemap a continuous playfield
799that wraps around instead of a large sprite.
800
801control registers
802000-001 X counter starting value / 256
803002-003 amount to add to the X counter after each horizontal pixel
804004-005 amount to add to the X counter after each line (0 = no rotation)
805006-007 Y counter starting value / 256
806008-009 amount to add to the Y counter after each horizontal pixel (0 = no rotation)
80700a-00b amount to add to the Y counter after each line
80800c-00d ROM bank to read, used during ROM testing
80900e     bit 0 = enable ROM reading (active low). This only makes the chip output the
810                requested address: the ROM is actually read externally, not through
811                the chip's data bus.
812        bit 1 = unknown
813        bit 2 = unknown
81400f     unused
815
816
817
818053936
819------
820Evolution of the 051316. The data bus is 16-bit instead of 8-bit.
821When used in "simple" mode it can generate the same effects of the 051316, but it
822doesn't have internal tilemap RAM, so it just generates a couple of X/Y coordinates
823indicating the pixel to display at each moment. Therefore, the tilemap and tile
824sizes are not fixed.
825The important addition over the 051316 is 512x4 words of internal RAM used to control
826rotation and zoom scanline by scanline instead that on the whole screen, allowing for
827effects like linescroll (Super Slams) or 3D rotation of the tilemap (Golfing Greats,
828Premier Soccer).
829
830control registers
831000 X counter starting value / 256
832001 Y counter starting value / 256
833002 ["simple" mode only] amount to add to the X counter after each line (0 = no rotation)
834003 ["simple" mode only] amount to add to the Y counter after each line
835004 ["simple" mode only] amount to add to the X counter after each horizontal pixel
836005 ["simple" mode only] amount to add to the Y counter after each horizontal pixel (0 = no rotation)
837006 x------- -------- when set, register (line*4)+2 must be multiplied by 256
838    -x------ -------- when set, registers 002 and 003 must be multiplied by 256
839    --xxxxxx -------- clipping for the generated address? usually 3F, Premier Soccer
840                      sets it to 07 before penalty kicks
841    -------- x------- when set, register (line*4)+3 must be multiplied by 256
842    -------- -x------ when set, registers 004 and 005 must be multiplied by 256
843    -------- --xxxxxx clipping for the generated address? usually 3F, Premier Soccer
844                      sets it to 0F before penalty kicks
845007 -------- -x------ enable "super" mode
846    -------- --x----- unknown (enable address clipping from register 006?)
847    -------- ---x---- unknown
848    -------- ------x- (not sure) enable clipping with registers 008-00b
849008 min x screen coordinate to draw to (only when enabled by register 7)
850009 max x screen coordinate to draw to (only when enabled by register 7)
85100a min y screen coordinate to draw to (only when enabled by register 7)
85200b max y screen coordinate to draw to (only when enabled by register 7)
85300c unknown
85400d unknown
85500e unknown
85600f unknown
857
858additional control from extra RAM:
859(line*4)+0 X counter starting value / 256 (add to register 000)
860(line*4)+1 Y counter starting value / 256 (add to register 001)
861(line*4)+2 amount to add to the X counter after each horizontal pixel
862(line*4)+3 amount to add to the Y counter after each horizontal pixel
863
864
865
866053251
867------
868Priority encoder.
869
870The chip has inputs for 5 layers (CI0-CI4); only 4 are used (CI1-CI4)
871CI0-CI2 are 9(=5+4) bits inputs, CI3-CI4 8(=4+4) bits
872
873The input connctions change from game to game. E.g. in Simpsons,
874CI0 = grounded (background color)
875CI1 = sprites
876CI2 = FIX
877CI3 = A
878CI4 = B
879
880in lgtnfght:
881CI0 = grounded
882CI1 = sprites
883CI2 = FIX
884CI3 = B
885CI4 = A
886
887there are three 6 bit priority inputs, PR0-PR2
888
889simpsons:
890PR0 = 111111
891PR1 = xxxxx0 x bits coming from the sprite attributes
892PR2 = 111111
893
894lgtnfght:
895PR0 = 111111
896PR1 = 1xx000 x bits coming from the sprite attributes
897PR2 = 111111
898
899also two shadow inputs, SDI0 and SDI1 (from the sprite attributes)
900
901the chip outputs the 11 bit palette index, CO0-CO10, and two shadow bits.
902
90316 internal registers; registers are 6 bits wide (input is D0-D5)
904For the most part, their meaning is unknown
905All registers are write only.
906There must be a way to enable/disable the three external PR inputs.
907Some games initialize the priorities of the sprite & background layers,
908others don't. It isn't clear whether the data written to those registers is
909actually used, since the priority is taken from the external ports.
910
911 0  priority of CI0 (higher = lower priority)
912    punkshot: unused?
913    lgtnfght: unused?
914    simpsons: 3f = 111111
915    xmen:     05 = 000101  default value
916    xmen:     09 = 001001  used to swap CI0 and CI2
917 1  priority of CI1 (higher = lower priority)
918    punkshot: 28 = 101000
919    lgtnfght: unused?
920    simpsons: unused?
921    xmen:     02 = 000010
922 2  priority of CI2 (higher = lower priority)
923    punkshot: 24 = 100100
924    lgtnfght: 24 = 100100
925    simpsons: 04 = 000100
926    xmen:     09 = 001001  default value
927    xmen:     05 = 000101  used to swap CI0 and CI2
928 3  priority of CI3 (higher = lower priority)
929    punkshot: 34 = 110100
930    lgtnfght: 34 = 110100
931    simpsons: 28 = 101000
932    xmen:     00 = 000000
933 4  priority of CI4 (higher = lower priority)
934    punkshot: 2c = 101100  default value
935    punkshot: 3c = 111100  used to swap CI3 and CI4
936    punkshot: 26 = 100110  used to swap CI1 and CI4
937    lgtnfght: 2c = 101100
938    simpsons: 18 = 011000
939    xmen:     fe = 111110
940 5  unknown
941    punkshot: unused?
942    lgtnfght: 2a = 101010
943    simpsons: unused?
944    xmen: unused?
945 6  unknown
946    punkshot: 26 = 100110
947    lgtnfght: 30 = 110000
948    simpsons: 17 = 010111
949    xmen:     03 = 000011 (written after initial tests)
950 7  unknown
951    punkshot: unused?
952    lgtnfght: unused?
953    simpsons: 27 = 100111
954    xmen:     07 = 000111 (written after initial tests)
955 8  unknown
956    punkshot: unused?
957    lgtnfght: unused?
958    simpsons: 37 = 110111
959    xmen:     ff = 111111 (written after initial tests)
960 9  ----xx CI0 palette index base (CO9-CO10)
961    --xx-- CI1 palette index base (CO9-CO10)
962    xx---- CI2 palette index base (CO9-CO10)
96310  ---xxx CI3 palette index base (CO8-CO10)
964    xxx--- CI4 palette index base (CO8-CO10)
96511  unknown
966    punkshot: 00 = 000000
967    lgtnfght: 00 = 000000
968    simpsons: 00 = 000000
969    xmen:     00 = 000000 (written after initial tests)
97012  unknown
971    punkshot: 04 = 000100
972    lgtnfght: 04 = 000100
973    simpsons: 05 = 000101
974    xmen:     05 = 000101
97513  unused
97614  unused
97715  unused
978
979
980054000
981------
982Sort of a protection device, used for collision detection.
983It is passed a few parameters, and returns a boolean telling if collision
984happened. It has no access to gfx data, it only does arithmetical operations
985on the parameters.
986
987Memory map:
98800      unused
98901-03 W A center X
99004    W unknown, needed by thndrx2 to pass the startup check, we use a hack
99105      unused
99206    W A semiaxis X
99307    W A semiaxis Y
99408      unused
99509-0b W A center Y
9960c    W unknown, needed by thndrx2 to pass the startup check, we use a hack
9970d      unused
9980e    W B semiaxis X
9990f    W B semiaxis Y
100010      unused
100111-13 W B center Y
100214      unused
100315-17 W B center X
100418    R 0 = collision, 1 = no collision
1005
1006
1007051733
1008------
1009Sort of a protection device, used for collision detection, and for
1010arithmetical operations.
1011It is passed a few parameters, and returns the result.
1012
1013Memory map(preliminary):
1014------------------------
101500-01 W operand 1
101602-03 W operand 2
101704-05 W operand 3
1018
101900-01 R operand 1 / operand 2
102002-03 R operand 1 % operand 2?
102104-05 R sqrt(operand 3<<16)
102206    R unknown - return value written to 13?
1023
102406-07 W distance for collision check
102508-09 W Y pos of obj1
10260a-0b W X pos of obj1
10270c-0d W Y pos of obj2
10280e-0f W X pos of obj2
102913    W unknown
1030
103107    R collision (0x80 = no, 0x00 = yes)
10320a-0b R unknown (chequered flag), might just read back X pos
10330e-0f R unknown (chequered flag), might just read back X pos
1034
1035Other addresses are unknown or unused.
1036
1037Fast Lane:
1038----------
1039$9def:
1040This routine is called only after a collision.
1041(R) 0x0006: unknown. Only bits 0-3 are used.
1042
1043Blades of Steel:
1044----------------
1045$ac2f:
1046(R) 0x2f86: unknown. Only uses bit 0.
1047
1048$a5de:
1049writes to 0x2f84-0x2f85, waits a little, and then reads from 0x2f84.
1050
1051$7af3:
1052(R) 0x2f86: unknown. Only uses bit 0.
1053
1054
1055Devastators:
1056------------
1057$6ce8:
1058reads from 0x0006, and only uses bit 1.
1059
1060
1061K055550
1062-------
1063
1064Protection chip which performs a memset() operation.
1065
1066Used in Violent Storm and Ultimate Battler to clear VRAM between scenes, among
1067other things.  May also perform other functions since Violent Storm still isn't
1068happy...
1069
1070Has word-wide registers as follows:
1071
10720: Count of units to transfer.  The write here triggers the transfer.
10731-6: Unknown
10747: Destination address, MSW
10758: Destination address, LSW
10769: Unknown
107710: Size of transfer units, MSW
107811: Size of transfer units, LSW
107912: Unknown
108013: Value to fill destination region with
108114-15: Unknown
1082
1083
1084K055555
1085-------
1086
1087Priority encoder.  Always found in conjunction with k054338, but the reverse
1088isn't true.  The 55555 has 8 inputs: "A", "B", "C", and "D" intended for a 156/157
1089type tilemap chip, "OBJ" intended for a '246 type sprite chip, and "SUB1-SUB3"
1090which can be used for 3 additional layers.
1091
1092When used in combintion with a k054338, each input can be chosen to participate
1093in shadow/highlight operations, R/G/B alpha blending, and R/G/B brightness control.
1094Per-tile priority is supported for tilemap planes A and B.
1095
1096There are also 3 shadow priority registers.  When these are enabled, layers and
1097sprites with a priority greater than or equal to them become a shadow, and either
1098then gets drawn as a shadow/highlight or not at all (I'm not sure what selects
1099this yet.  Dadandarn relies on this mechanism to hide the 53936 plane when
1100it doesn't want it visible).
1101
1102It also appears that brightness control and alpha blend can be decided per-tile
1103and per-sprite, although this is not certain.
1104
1105Additionally the 55555 can provide a gradient background with one palette entry
1106per scanline.  This is fairly rarely used, but does turn up in Gokujou Parodius as
1107well as the Sexy Parodius title screen.
1108
1109Lots of byte-wise registers.  A partial map:
1110
11110: Palette index(?) for the gradient background
11121: related to tilemap brightness control
11132-5: COLSEL for various inputs (?)
11146: COLCHG ON
11157-18: priority levels (VA1/VA2/VAC/VB1/VB2/VBC/VC/VD/OBJ/S1/S2/S3)
111619-22: INPRI for OBJ/S1/S2/S3
111723-32: palette bases (VA/VB/VC/VD/OBJ/S1/S2/S3)
111837: shadow 1 priority
111938: shadow 2 priority
112039: shadow 3 priority
112140: shadow/highlight master enable
112241: master shadow/highlight priority
112342: VBRI: enables brightness control for each VRAM layer (bits: x x x x D B C A)
112443: OSBRI: enables brightness control for OBJ and SUB layers, depending for OBJ on attr bits
112544: OSBRI_ON: not quite sure
112645: input enables.  bits as follows: (MSB) S3 S2 S1 OB VD VC VB VA (LSB)
1127
1128
1129k054338
1130-------
1131Color combiner engine.  Designed for use with the 55555, but also found in games
1132without one.
1133
1134Registers (word-wise):
1135
11360: first 8 bits unknown, second 8 bits are the R component of the background color
11371: G and B components (8 bits each) of the background color
11382-4: shadow 1 R/G/B (16 bits per component.  In shadow mode, determines a blend
1139     value between total blackness and the original color.  In highlight mode,
1140     determines a blend value between total whiteness and the original color.
1141     The hardware clamps at black or white as necessary: see the Graphics Test
1142     in many System GX games).
11435-7: shadow 2 R/G/B
11448-10: shadow 3 R/G/B
114511-12: brightness R/G/B (external circuit such as the 55555 decides which layers
1146       this applies to)
114713-14: alpha blend R/G/B (external circuit such as the 55555 decides which layers
1148       this applies to)
1149
1150***************************************************************************/
1151
1152#include "driver.h"
1153#include "video/konicdev.h"
1154
1155#define VERBOSE 0
1156#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
1157
1158
1159#define XOR(a) WORD_XOR_BE(a)
1160
1161/*
1162    This recursive function doesn't use additional memory
1163    (it could be easily converted into an iterative one).
1164    It's called shuffle because it mimics the shuffling of a deck of cards.
1165*/
1166static void konami_shuffle_16(UINT16 *buf,int len)
1167{
1168   int i;
1169   UINT16 t;
1170
1171   if (len == 2) return;
1172
1173   if (len % 4) fatalerror("shuffle() - not modulo 4");   /* must not happen */
1174
1175   len /= 2;
1176
1177   for (i = 0;i < len/2;i++)
1178   {
1179      t = buf[len/2 + i];
1180      buf[len/2 + i] = buf[len + i];
1181      buf[len + i] = t;
1182   }
1183
1184   konami_shuffle_16(buf,len);
1185   konami_shuffle_16(buf + len,len);
1186}
1187
1188static void konami_shuffle_8(UINT8 *buf,int len)
1189{
1190   int i;
1191   UINT8 t;
1192
1193   if (len == 2) return;
1194
1195   if (len % 4) fatalerror("shuffle() - not modulo 4");   /* must not happen */
1196
1197   len /= 2;
1198
1199   for (i = 0;i < len/2;i++)
1200   {
1201      t = buf[len/2 + i];
1202      buf[len/2 + i] = buf[len + i];
1203      buf[len + i] = t;
1204   }
1205
1206   konami_shuffle_8(buf,len);
1207   konami_shuffle_8(buf + len,len);
1208}
1209
1210
1211/* helper function to join two 16-bit ROMs and form a 32-bit data stream */
1212void konamid_rom_deinterleave_2(running_machine *machine, const char *mem_region)
1213{
1214   konami_shuffle_16((UINT16 *)memory_region(machine, mem_region),memory_region_length(machine, mem_region)/2);
1215}
1216
1217/* hacked version of rom_deinterleave_2_half for Lethal Enforcers */
1218void konamid_rom_deinterleave_2_half(running_machine *machine, const char *mem_region)
1219{
1220   UINT8 *rgn = memory_region(machine, mem_region);
1221
1222   konami_shuffle_16((UINT16 *)rgn,memory_region_length(machine, mem_region)/4);
1223   konami_shuffle_16((UINT16 *)(rgn+memory_region_length(machine, mem_region)/2),memory_region_length(machine, mem_region)/4);
1224}
1225
1226/* helper function to join four 16-bit ROMs and form a 64-bit data stream */
1227void konamid_rom_deinterleave_4(running_machine *machine, const char *mem_region)
1228{
1229   konamid_rom_deinterleave_2(machine, mem_region);
1230   konamid_rom_deinterleave_2(machine, mem_region);
1231}
1232
1233
1234static void decode_gfx(running_machine *machine, int gfx_index, UINT8 *data, UINT32 total, const gfx_layout *layout, int bpp)
1235{
1236   gfx_layout gl;
1237
1238   memcpy(&gl, layout, sizeof(gl));
1239   gl.total = total;
1240   machine->gfx[gfx_index] = gfx_element_alloc(machine, &gl, data, machine->config->total_colors >> bpp, 0);
1241}
1242
1243
1244static void deinterleave_gfx(running_machine *machine, const char *gfx_memory_region, int deinterleave)
1245{
1246   switch (deinterleave)
1247   {
1248   case KONAMI_ROM_DEINTERLEAVE_NONE:
1249      break;
1250   case KONAMI_ROM_DEINTERLEAVE_2:
1251      konamid_rom_deinterleave_2(machine, gfx_memory_region);
1252      break;
1253   case KONAMI_ROM_DEINTERLEAVE_2_HALF:
1254      konamid_rom_deinterleave_2_half(machine, gfx_memory_region);
1255      break;
1256   case KONAMI_ROM_DEINTERLEAVE_4:
1257      konamid_rom_deinterleave_4(machine, gfx_memory_region);
1258      break;
1259   case KONAMI_ROM_SHUFFLE8:
1260      konami_shuffle_8(memory_region(machine, gfx_memory_region), memory_region_length(machine, gfx_memory_region));
1261      break;
1262   }
1263}
1264
1265/***************************************************************************/
1266/*                                                                         */
1267/*                                 007121                                  */
1268/*                                                                         */
1269/***************************************************************************/
1270
1271typedef struct _k007121_state  k007121_state ;
1272struct _k007121_state
1273{
1274
1275   UINT8    ctrlram[8];
1276   int      flipscreen;
1277};
1278
1279/*****************************************************************************
1280    INLINE FUNCTIONS
1281*****************************************************************************/
1282
1283INLINE k007121_state *k007121_get_safe_token( const device_config *device )
1284{
1285   assert(device != NULL);
1286   assert(device->token != NULL);
1287   assert(device->type == K007121);
1288
1289   return (k007121_state *)device->token;
1290}
1291
1292/*****************************************************************************
1293    DEVICE HANDLERS
1294*****************************************************************************/
1295
1296/* FIXME: this is probably unused... check! */
1297WRITE8_DEVICE_HANDLER( k007121_ctrlram_w )
1298{
1299   k007121_state *k007121 = k007121_get_safe_token(device);
1300
1301   assert(offset < 8);
1302
1303   k007121->ctrlram[offset] = data;
1304}
1305
1306
1307READ8_DEVICE_HANDLER( k007121_ctrlram_r )
1308{
1309   k007121_state *k007121 = k007121_get_safe_token(device);
1310
1311   assert(offset < 8);
1312
1313   return k007121->ctrlram[offset];
1314}
1315
1316
1317WRITE8_DEVICE_HANDLER( k007121_ctrl_w )
1318{
1319   k007121_state *k007121 = k007121_get_safe_token(device);
1320
1321   assert(offset < 8);
1322
1323   switch (offset)
1324   {
1325   case 6:
1326      /* palette bank change */
1327      if ((k007121->ctrlram[offset] & 0x30) != (data & 0x30))
1328         tilemap_mark_all_tiles_dirty_all(device->machine);
1329      break;
1330   case 7:
1331      k007121->flipscreen = data & 0x08;
1332      break;
1333   }
1334
1335   k007121->ctrlram[offset] = data;
1336}
1337
1338/*
1339 * Sprite Format
1340 * ------------------
1341 *
1342 * There are 0x40 sprites, each one using 5 bytes. However the number of
1343 * sprites can be increased to 0x80 with a control register (Combat School
1344 * sets it on and off during the game).
1345 *
1346 * Byte | Bit(s)   | Use
1347 * -----+-76543210-+----------------
1348 *   0  | xxxxxxxx | sprite code
1349 *   1  | xxxx---- | color
1350 *   1  | ----xx-- | sprite code low 2 bits for 16x8/8x8 sprites
1351 *   1  | ------xx | sprite code bank bits 1/0
1352 *   2  | xxxxxxxx | y position
1353 *   3  | xxxxxxxx | x position (low 8 bits)
1354 *   4  | xx------ | sprite code bank bits 3/2
1355 *   4  | --x----- | flip y
1356 *   4  | ---x---- | flip x
1357 *   4  | ----xxx- | sprite size 000=16x16 001=16x8 010=8x16 011=8x8 100=32x32
1358 *   4  | -------x | x position (high bit)
1359 *
1360 * Flack Attack uses a different, "wider" layout with 32 bytes per sprite,
1361 * mapped as follows, and the priority order is reversed. Maybe it is a
1362 * compatibility mode with an older custom IC. It is not known how this
1363 * alternate layout is selected.
1364 *
1365 * 0 -> e
1366 * 1 -> f
1367 * 2 -> 6
1368 * 3 -> 4
1369 * 4 -> 8
1370 *
1371 */
1372
1373void k007121_sprites_draw( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, gfx_element *gfx, colortable_t *ctable,
1374                    const UINT8 *source, int base_color, int global_x_offset, int bank_base, UINT32 pri_mask )
1375{
1376   k007121_state *k007121 = k007121_get_safe_token(device);
1377//  const gfx_element *gfx = gfxs[chip];
1378   bitmap_t *priority_bitmap = gfx->machine->priority_bitmap;
1379   int flipscreen = k007121->flipscreen;
1380   int i, num, inc, offs[5];
1381   int is_flakatck = (ctable == NULL);
1382
1383   if (is_flakatck)
1384   {
1385      num = 0x40;
1386      inc = -0x20;
1387      source += 0x3f * 0x20;
1388      offs[0] = 0x0e;
1389      offs[1] = 0x0f;
1390      offs[2] = 0x06;
1391      offs[3] = 0x04;
1392      offs[4] = 0x08;
1393   }
1394   else   /* all others */
1395   {
1396      //num = (k007121->ctrlram[0x03] & 0x40) ? 0x80 : 0x40; /* WRONG!!! (needed by combasc)  */
1397      num = 0x40; // Combasc writes 70 sprites to VRAM at peak but the chip only processes the first 64.
1398
1399      inc = 5;
1400      offs[0] = 0x00;
1401      offs[1] = 0x01;
1402      offs[2] = 0x02;
1403      offs[3] = 0x03;
1404      offs[4] = 0x04;
1405      /* when using priority buffer, draw front to back */
1406      if (pri_mask != -1)
1407      {
1408         source += (num - 1)*inc;
1409         inc = -inc;
1410      }
1411   }
1412
1413   for (i = 0; i < num; i++)
1414   {
1415      int number = source[offs[0]];            /* sprite number */
1416      int sprite_bank = source[offs[1]] & 0x0f;   /* sprite bank */
1417      int sx = source[offs[3]];               /* vertical position */
1418      int sy = source[offs[2]];               /* horizontal position */
1419      int attr = source[offs[4]];            /* attributes */
1420      int xflip = source[offs[4]] & 0x10;      /* flip x */
1421      int yflip = source[offs[4]] & 0x20;      /* flip y */
1422      int color = base_color + ((source[offs[1]] & 0xf0) >> 4);
1423      int width, height;
1424      int transparent_mask;
1425      static const int x_offset[4] = {0x0,0x1,0x4,0x5};
1426      static const int y_offset[4] = {0x0,0x2,0x8,0xa};
1427      int x,y, ex, ey, flipx, flipy, destx, desty;
1428
1429      if (attr & 0x01) sx -= 256;
1430      if (sy >= 240) sy -= 256;
1431
1432      number += ((sprite_bank & 0x3) << 8) + ((attr & 0xc0) << 4);
1433      number = number << 2;
1434      number += (sprite_bank >> 2) & 3;
1435
1436      /* Flak Attack doesn't use a lookup PROM, it maps the color code directly */
1437      /* to a palette entry */
1438      if (is_flakatck)
1439         transparent_mask = 1 << 0;
1440      else
1441         transparent_mask = colortable_get_transpen_mask(ctable, gfx, color, 0);
1442
1443      if (!is_flakatck || source[0x00])   /* Flak Attack needs this */
1444      {
1445         number += bank_base;
1446
1447         switch (attr & 0xe)
1448         {
1449            case 0x06: width = height = 1; break;
1450            case 0x04: width = 1; height = 2; number &= (~2); break;
1451            case 0x02: width = 2; height = 1; number &= (~1); break;
1452            case 0x00: width = height = 2; number &= (~3); break;
1453            case 0x08: width = height = 4; number &= (~3); break;
1454            default: width = 1; height = 1;
1455//                  logerror("Unknown sprite size %02x\n", attr & 0xe);
1456//                  popmessage("Unknown sprite size %02x\n", attr & 0xe);
1457         }
1458
1459         for (y = 0; y < height; y++)
1460         {
1461            for (x = 0; x < width; x++)
1462            {
1463               ex = xflip ? (width - 1 - x) : x;
1464               ey = yflip ? (height - 1 - y) : y;
1465
1466               if (flipscreen)
1467               {
1468                  flipx = !xflip;
1469                  flipy = !yflip;
1470                  destx = 248 - (sx + x * 8);
1471                  desty = 248 - (sy + y * 8);
1472               }
1473               else
1474               {
1475                  flipx = xflip;
1476                  flipy = yflip;
1477                  destx = global_x_offset + sx + x * 8;
1478                  desty = sy + y * 8;
1479               }
1480
1481               if (pri_mask != -1)
1482                  pdrawgfx_transmask(bitmap,cliprect,gfx,
1483                     number + x_offset[ex] + y_offset[ey],
1484                     color,
1485                     flipx,flipy,
1486                     destx,desty,
1487                     priority_bitmap,pri_mask,
1488                     transparent_mask);
1489               else
1490                  drawgfx_transmask(bitmap,cliprect,gfx,
1491                     number + x_offset[ex] + y_offset[ey],
1492                     color,
1493                     flipx,flipy,
1494                     destx,desty,
1495                     transparent_mask);
1496            }
1497         }
1498      }
1499
1500      source += inc;
1501   }
1502}
1503
1504/*****************************************************************************
1505    DEVICE INTERFACE
1506*****************************************************************************/
1507
1508static DEVICE_START( k007121 )
1509{
1510   k007121_state *k007121 = k007121_get_safe_token(device);
1511
1512   state_save_register_device_item_array(device, 0, k007121->ctrlram);
1513   state_save_register_device_item(device, 0, k007121->flipscreen);
1514}
1515
1516static DEVICE_RESET( k007121 )
1517{
1518   k007121_state *k007121 = k007121_get_safe_token(device);
1519   int i;
1520
1521   k007121->flipscreen = 0;
1522
1523   for (i = 0; i < 8; i++)
1524      k007121->ctrlram[i] = 0;
1525}
1526
1527
1528/***************************************************************************/
1529/*                                                                         */
1530/*                                 007342                                  */
1531/*                                                                         */
1532/***************************************************************************/
1533
1534typedef struct _k007342_state k007342_state;
1535struct _k007342_state
1536{
1537   UINT8    *ram;
1538   UINT8    *scroll_ram;
1539   UINT8    *videoram_0;
1540   UINT8    *videoram_1;
1541   UINT8    *colorram_0;
1542   UINT8    *colorram_1;
1543
1544   tilemap  *tilemap[2];
1545   int      flipscreen, gfxnum, int_enabled;
1546   UINT8    regs[8];
1547   UINT16   scrollx[2];
1548   UINT8    scrolly[2];
1549
1550   k007342_callback callback;
1551};
1552
1553/*****************************************************************************
1554    INLINE FUNCTIONS
1555*****************************************************************************/
1556
1557INLINE k007342_state *k007342_get_safe_token( const device_config *device )
1558{
1559   assert(device != NULL);
1560   assert(device->token != NULL);
1561   assert(device->type == K007342);
1562
1563   return (k007342_state *)device->token;
1564}
1565
1566INLINE const k007342_interface *k007342_get_interface( const device_config *device )
1567{
1568   assert(device != NULL);
1569   assert((device->type == K007342));
1570   return (const k007342_interface *) device->static_config;
1571}
1572
1573/*****************************************************************************
1574    DEVICE HANDLERS
1575*****************************************************************************/
1576
1577READ8_DEVICE_HANDLER( k007342_r )
1578{
1579   k007342_state *k007342 = k007342_get_safe_token(device);
1580   return k007342->ram[offset];
1581}
1582
1583WRITE8_DEVICE_HANDLER( k007342_w )
1584{
1585   k007342_state *k007342 = k007342_get_safe_token(device);
1586   k007342->ram[offset] = data;
1587
1588   if (offset < 0x1000)   /* layer 0 */
1589      tilemap_mark_tile_dirty(k007342->tilemap[0], offset & 0x7ff);
1590   else            /* layer 1 */
1591      tilemap_mark_tile_dirty(k007342->tilemap[1], offset & 0x7ff);
1592}
1593
1594READ8_DEVICE_HANDLER( k007342_scroll_r )
1595{
1596   k007342_state *k007342 = k007342_get_safe_token(device);
1597   return k007342->scroll_ram[offset];
1598}
1599
1600WRITE8_DEVICE_HANDLER( k007342_scroll_w )
1601{
1602   k007342_state *k007342 = k007342_get_safe_token(device);
1603   k007342->scroll_ram[offset] = data;
1604}
1605
1606WRITE8_DEVICE_HANDLER( k007342_vreg_w )
1607{
1608   k007342_state *k007342 = k007342_get_safe_token(device);
1609   switch(offset)
1610   {
1611      case 0x00:
1612         /* bit 1: INT control */
1613         k007342->int_enabled = data & 0x02;
1614         k007342->flipscreen = data & 0x10;
1615         tilemap_set_flip(k007342->tilemap[0], k007342->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
1616         tilemap_set_flip(k007342->tilemap[1], k007342->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
1617         break;
1618      case 0x01:  /* used for banking in Rock'n'Rage */
1619         if (data != k007342->regs[1])
1620            tilemap_mark_all_tiles_dirty_all(device->machine);
1621      case 0x02:
1622         k007342->scrollx[0] = (k007342->scrollx[0] & 0xff) | ((data & 0x01) << 8);
1623         k007342->scrollx[1] = (k007342->scrollx[1] & 0xff) | ((data & 0x02) << 7);
1624         break;
1625      case 0x03:  /* scroll x (register 0) */
1626         k007342->scrollx[0] = (k007342->scrollx[0] & 0x100) | data;
1627         break;
1628      case 0x04:  /* scroll y (register 0) */
1629         k007342->scrolly[0] = data;
1630         break;
1631      case 0x05:  /* scroll x (register 1) */
1632         k007342->scrollx[1] = (k007342->scrollx[1] & 0x100) | data;
1633         break;
1634      case 0x06:  /* scroll y (register 1) */
1635         k007342->scrolly[1] = data;
1636      case 0x07:  /* unused */
1637         break;
1638   }
1639   k007342->regs[offset] = data;
1640}
1641
1642void k007342_tilemap_update( const device_config *device )
1643{
1644   k007342_state *k007342 = k007342_get_safe_token(device);
1645   int offs;
1646
1647   /* update scroll */
1648   switch (k007342->regs[2] & 0x1c)
1649   {
1650      case 0x00:
1651      case 0x08:   /* unknown, blades of steel shootout between periods */
1652         tilemap_set_scroll_rows(k007342->tilemap[0], 1);
1653         tilemap_set_scroll_cols(k007342->tilemap[0], 1);
1654         tilemap_set_scrollx(k007342->tilemap[0], 0, k007342->scrollx[0]);
1655         tilemap_set_scrolly(k007342->tilemap[0], 0, k007342->scrolly[0]);
1656         break;
1657
1658      case 0x0c:   /* 32 columns */
1659         tilemap_set_scroll_rows(k007342->tilemap[0], 1);
1660         tilemap_set_scroll_cols(k007342->tilemap[0], 512);
1661         tilemap_set_scrollx(k007342->tilemap[0], 0, k007342->scrollx[0]);
1662         for (offs = 0; offs < 256; offs++)
1663            tilemap_set_scrolly(k007342->tilemap[0], (offs + k007342->scrollx[0]) & 0x1ff,
1664                  k007342->scroll_ram[2 * (offs / 8)] + 256 * k007342->scroll_ram[2 * (offs / 8) + 1]);
1665         break;
1666
1667      case 0x14:   /* 256 rows */
1668         tilemap_set_scroll_rows(k007342->tilemap[0], 256);
1669         tilemap_set_scroll_cols(k007342->tilemap[0], 1);
1670         tilemap_set_scrolly(k007342->tilemap[0], 0, k007342->scrolly[0]);
1671         for (offs = 0; offs < 256; offs++)
1672            tilemap_set_scrollx(k007342->tilemap[0], (offs + k007342->scrolly[0]) & 0xff,
1673                  k007342->scroll_ram[2 * offs] + 256 * k007342->scroll_ram[2 * offs + 1]);
1674         break;
1675
1676      default:
1677//          popmessage("unknown scroll ctrl %02x", k007342->regs[2] & 0x1c);
1678         break;
1679   }
1680
1681   tilemap_set_scrollx(k007342->tilemap[1], 0, k007342->scrollx[1]);
1682   tilemap_set_scrolly(k007342->tilemap[1], 0, k007342->scrolly[1]);
1683
1684#if 0
1685   {
1686      static int current_layer = 0;
1687
1688      if (input_code_pressed_once(machine, KEYCODE_Z)) current_layer = !current_layer;
1689      tilemap_set_enable(k007342->tilemap[current_layer], 1);
1690      tilemap_set_enable(k007342->tilemap[!current_layer], 0);
1691
1692      popmessage("regs:%02x %02x %02x %02x-%02x %02x %02x %02x:%02x",
1693         k007342->regs[0], k007342->regs[1], k007342->regs[2], k007342->regs[3],
1694         k007342->regs[4], k007342->regs[5], k007342->regs[6], k007342->regs[7],
1695         current_layer);
1696   }
1697#endif
1698}
1699
1700void k007342_tilemap_set_enable( const device_config *device, int tmap, int enable )
1701{
1702   k007342_state *k007342 = k007342_get_safe_token(device);
1703   tilemap_set_enable(k007342->tilemap[tmap], enable);
1704}
1705
1706void k007342_tilemap_draw( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int num, int flags, UINT32 priority )
1707{
1708   k007342_state *k007342 = k007342_get_safe_token(device);
1709   tilemap_draw(bitmap, cliprect, k007342->tilemap[num], flags, priority);
1710}
1711
1712int k007342_is_int_enabled( const device_config *device )
1713{
1714   k007342_state *k007342 = k007342_get_safe_token(device);
1715   return k007342->int_enabled;
1716}
1717
1718
1719/***************************************************************************
1720
1721  Callbacks for the TileMap code
1722
1723***************************************************************************/
1724
1725/*
1726  data format:
1727  video RAM     xxxxxxxx    tile number (bits 0-7)
1728  color RAM     x-------    tiles with priority over the sprites
1729  color RAM     -x------    depends on external conections
1730  color RAM     --x-----    flip Y
1731  color RAM     ---x----    flip X
1732  color RAM     ----xxxx    depends on external connections (usually color and banking)
1733*/
1734
1735static TILEMAP_MAPPER( k007342_scan )
1736{
1737   /* logical (col,row) -> memory offset */
1738   return (col & 0x1f) + ((row & 0x1f) << 5) + ((col & 0x20) << 5);
1739}
1740
1741INLINE void k007342_get_tile_info( const device_config *device, tile_data *tileinfo, int tile_index, int layer, UINT8 *cram, UINT8 *vram )
1742{
1743   k007342_state *k007342 = k007342_get_safe_token(device);
1744   int color, code, flags;
1745
1746   color = cram[tile_index];
1747   code = vram[tile_index];
1748   flags = TILE_FLIPYX((color & 0x30) >> 4);
1749
1750   tileinfo->category = (color & 0x80) >> 7;
1751
1752   k007342->callback(device->machine, layer, k007342->regs[1], &code, &color, &flags);
1753
1754   SET_TILE_INFO_DEVICE(
1755         k007342->gfxnum,
1756         code,
1757         color,
1758         flags);
1759}
1760
1761static TILE_GET_INFO_DEVICE( k007342_get_tile_info0 )
1762{
1763   k007342_state *k007342 = k007342_get_safe_token(device);
1764   k007342_get_tile_info(device, tileinfo, tile_index, 0, k007342->colorram_0, k007342->videoram_0);
1765}
1766
1767static TILE_GET_INFO_DEVICE( k007342_get_tile_info1 )
1768{
1769   k007342_state *k007342 = k007342_get_safe_token(device);
1770   k007342_get_tile_info(device, tileinfo, tile_index, 1, k007342->colorram_1, k007342->videoram_1);
1771}
1772
1773
1774/*****************************************************************************
1775    DEVICE INTERFACE
1776*****************************************************************************/
1777
1778static DEVICE_START( k007342 )
1779{
1780   k007342_state *k007342 = k007342_get_safe_token(device);
1781   const k007342_interface *intf = k007342_get_interface(device);
1782
1783   k007342->gfxnum = intf->gfxnum;
1784   k007342->callback = intf->callback;
1785
1786   k007342->tilemap[0] = tilemap_create_device(device, k007342_get_tile_info0, k007342_scan, 8, 8, 64, 32);
1787   k007342->tilemap[1] = tilemap_create_device(device, k007342_get_tile_info1, k007342_scan, 8, 8, 64, 32);
1788
1789   k007342->ram = auto_alloc_array(device->machine, UINT8, 0x2000);
1790   k007342->scroll_ram = auto_alloc_array(device->machine, UINT8, 0x0200);
1791
1792   k007342->colorram_0 = &k007342->ram[0x0000];
1793   k007342->colorram_1 = &k007342->ram[0x1000];
1794   k007342->videoram_0 = &k007342->ram[0x0800];
1795   k007342->videoram_1 = &k007342->ram[0x1800];
1796
1797   tilemap_set_transparent_pen(k007342->tilemap[0], 0);
1798   tilemap_set_transparent_pen(k007342->tilemap[1], 0);
1799
1800   state_save_register_device_item_pointer(device, 0, k007342->ram, 0x2000);
1801   state_save_register_device_item_pointer(device, 0, k007342->scroll_ram, 0x0200);
1802   state_save_register_device_item(device, 0, k007342->int_enabled);
1803   state_save_register_device_item(device, 0, k007342->flipscreen);
1804   state_save_register_device_item_array(device, 0, k007342->scrollx);
1805   state_save_register_device_item_array(device, 0, k007342->scrolly);
1806   state_save_register_device_item_array(device, 0, k007342->regs);
1807}
1808
1809static DEVICE_RESET( k007342 )
1810{
1811   k007342_state *k007342 = k007342_get_safe_token(device);
1812   int i;
1813
1814   k007342->int_enabled = 0;
1815   k007342->flipscreen = 0;
1816   k007342->scrollx[0] = 0;
1817   k007342->scrollx[1] = 0;
1818   k007342->scrolly[0] = 0;
1819   k007342->scrolly[1] = 0;
1820
1821   for (i = 0; i < 8; i++)
1822      k007342->regs[i] = 0;
1823}
1824
1825
1826/***************************************************************************/
1827/*                                                                         */
1828/*                                 007420                                  */
1829/*                                                                         */
1830/***************************************************************************/
1831
1832typedef struct _k007420_state k007420_state;
1833struct _k007420_state
1834{
1835   UINT8        *ram;
1836
1837   int          banklimit;
1838   int          flipscreen;   // current code uses the 7342 flipscreen!!
1839   UINT8        regs[8];   // current code uses the 7342 regs!! (only [2])
1840
1841   k007420_callback callback;
1842};
1843
1844/*****************************************************************************
1845    INLINE FUNCTIONS
1846*****************************************************************************/
1847
1848INLINE k007420_state *k007420_get_safe_token( const device_config *device )
1849{
1850   assert(device != NULL);
1851   assert(device->token != NULL);
1852   assert(device->type == K007420);
1853
1854   return (k007420_state *)device->token;
1855}
1856
1857INLINE const k007420_interface *k007420_get_interface( const device_config *device )
1858{
1859   assert(device != NULL);
1860   assert((device->type == K007420));
1861   return (const k007420_interface *) device->static_config;
1862}
1863
1864/*****************************************************************************
1865    DEVICE HANDLERS
1866*****************************************************************************/
1867
1868READ8_DEVICE_HANDLER( k007420_r )
1869{
1870   k007420_state *k007420 = k007420_get_safe_token(device);
1871   return k007420->ram[offset];
1872}
1873
1874WRITE8_DEVICE_HANDLER( k007420_w )
1875{
1876   k007420_state *k007420 = k007420_get_safe_token(device);
1877   k007420->ram[offset] = data;
1878}
1879
1880/*
1881 * Sprite Format
1882 * ------------------
1883 *
1884 * Byte | Bit(s)   | Use
1885 * -----+-76543210-+----------------
1886 *   0  | xxxxxxxx | y position
1887 *   1  | xxxxxxxx | sprite code (low 8 bits)
1888 *   2  | xxxxxxxx | depends on external conections. Usually banking
1889 *   3  | xxxxxxxx | x position (low 8 bits)
1890 *   4  | x------- | x position (high bit)
1891 *   4  | -xxx---- | sprite size 000=16x16 001=8x16 010=16x8 011=8x8 100=32x32
1892 *   4  | ----x--- | flip y
1893 *   4  | -----x-- | flip x
1894 *   4  | ------xx | zoom (bits 8 & 9)
1895 *   5  | xxxxxxxx | zoom (low 8 bits)  0x080 = normal, < 0x80 enlarge, > 0x80 reduce
1896 *   6  | xxxxxxxx | unused
1897 *   7  | xxxxxxxx | unused
1898 */
1899
1900void k007420_sprites_draw( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, gfx_element *gfx )
1901{
1902   k007420_state *k007420 = k007420_get_safe_token(device);
1903   int offs;
1904   int codemask = k007420->banklimit;
1905   int bankmask = ~k007420->banklimit;
1906
1907   for (offs = K007420_SPRITERAM_SIZE - 8; offs >= 0; offs -= 8)
1908   {
1909      int ox, oy, code, color, flipx, flipy, zoom, w, h, x, y, bank;
1910      static const int xoffset[4] = { 0, 1, 4, 5 };
1911      static const int yoffset[4] = { 0, 2, 8, 10 };
1912
1913      code = k007420->ram[offs + 1];
1914      color = k007420->ram[offs + 2];
1915      ox = k007420->ram[offs + 3] - ((k007420->ram[offs + 4] & 0x80) << 1);
1916      oy = 256 - k007420->ram[offs + 0];
1917      flipx = k007420->ram[offs + 4] & 0x04;
1918      flipy = k007420->ram[offs + 4] & 0x08;
1919
1920      k007420->callback(device->machine, &code, &color);
1921
1922      bank = code & bankmask;
1923      code &= codemask;
1924
1925      /* 0x080 = normal scale, 0x040 = double size, 0x100 half size */
1926      zoom = k007420->ram[offs + 5] | ((k007420->ram[offs + 4] & 0x03) << 8);
1927      if (!zoom)
1928         continue;
1929      zoom = 0x10000 * 128 / zoom;
1930
1931      switch (k007420->ram[offs + 4] & 0x70)
1932      {
1933         case 0x30: w = h = 1; break;
1934         case 0x20: w = 2; h = 1; code &= (~1); break;
1935         case 0x10: w = 1; h = 2; code &= (~2); break;
1936         case 0x00: w = h = 2; code &= (~3); break;
1937         case 0x40: w = h = 4; code &= (~3); break;
1938         default: w = 1; h = 1;
1939//logerror("Unknown sprite size %02x\n",(k007420->ram[offs + 4] & 0x70) >> 4);
1940      }
1941
1942      if (k007420->flipscreen)
1943      {
1944         ox = 256 - ox - ((zoom * w + (1 << 12)) >> 13);
1945         oy = 256 - oy - ((zoom * h + (1 << 12)) >> 13);
1946         flipx = !flipx;
1947         flipy = !flipy;
1948      }
1949
1950      if (zoom == 0x10000)
1951      {
1952         int sx, sy;
1953
1954         for (y = 0; y < h; y++)
1955         {
1956            sy = oy + 8 * y;
1957
1958            for (x = 0; x < w; x++)
1959            {
1960               int c = code;
1961
1962               sx = ox + 8 * x;
1963               if (flipx)
1964                  c += xoffset[(w - 1 - x)];
1965               else
1966                  c += xoffset[x];
1967
1968               if (flipy)
1969                  c += yoffset[(h - 1 - y)];
1970               else
1971                  c += yoffset[y];
1972
1973               if (c & bankmask)
1974                  continue;
1975               else
1976                  c += bank;
1977
1978               drawgfx_transpen(bitmap,cliprect,gfx,
1979                  c,
1980                  color,
1981                  flipx,flipy,
1982                  sx,sy,0);
1983
1984               if (k007420->regs[2] & 0x80)
1985                  drawgfx_transpen(bitmap,cliprect,gfx,
1986                     c,
1987                     color,
1988                     flipx,flipy,
1989                     sx,sy-256,0);
1990            }
1991         }
1992      }
1993      else
1994      {
1995         int sx, sy, zw, zh;
1996         for (y = 0; y < h; y++)
1997         {
1998            sy = oy + ((zoom * y + (1 << 12)) >> 13);
1999            zh = (oy + ((zoom * (y + 1) + (1 << 12)) >> 13)) - sy;
2000
2001            for (x = 0; x < w; x++)
2002            {
2003               int c = code;
2004
2005               sx = ox + ((zoom * x + (1<<12)) >> 13);
2006               zw = (ox + ((zoom * (x + 1) + (1 << 12)) >> 13)) - sx;
2007               if (flipx)
2008                  c += xoffset[(w - 1 - x)];
2009               else
2010                  c += xoffset[x];
2011
2012               if (flipy)
2013                  c += yoffset[(h - 1 - y)];
2014               else
2015                  c += yoffset[y];
2016
2017               if (c & bankmask)
2018                  continue;
2019               else
2020                  c += bank;
2021
2022               drawgfxzoom_transpen(bitmap,cliprect,gfx,
2023                  c,
2024                  color,
2025                  flipx,flipy,
2026                  sx,sy,
2027                  (zw << 16) / 8,(zh << 16) / 8,0);
2028
2029               if (k007420->regs[2] & 0x80)
2030                  drawgfxzoom_transpen(bitmap,cliprect,gfx,
2031                     c,
2032                     color,
2033                     flipx,flipy,
2034                     sx,sy-256,
2035                     (zw << 16) / 8,(zh << 16) / 8,0);
2036            }
2037         }
2038      }
2039   }
2040#if 0
2041   {
2042      static int current_sprite = 0;
2043
2044      if (input_code_pressed_once(machine, KEYCODE_Z)) current_sprite = (current_sprite+1) & ((K007420_SPRITERAM_SIZE/8)-1);
2045      if (input_code_pressed_once(machine, KEYCODE_X)) current_sprite = (current_sprite-1) & ((K007420_SPRITERAM_SIZE/8)-1);
2046
2047      popmessage("%02x:%02x %02x %02x %02x %02x %02x %02x %02x", current_sprite,
2048         k007420->ram[(current_sprite*8)+0], k007420->ram[(current_sprite*8)+1],
2049         k007420->ram[(current_sprite*8)+2], k007420->ram[(current_sprite*8)+3],
2050         k007420->ram[(current_sprite*8)+4], k007420->ram[(current_sprite*8)+5],
2051         k007420->ram[(current_sprite*8)+6], k007420->ram[(current_sprite*8)+7]);
2052   }
2053#endif
2054}
2055
2056/*****************************************************************************
2057    DEVICE INTERFACE
2058*****************************************************************************/
2059
2060static DEVICE_START( k007420 )
2061{
2062   k007420_state *k007420 = k007420_get_safe_token(device);
2063   const k007420_interface *intf = k007420_get_interface(device);
2064
2065   k007420->callback = intf->callback;
2066   k007420->banklimit = intf->banklimit;
2067
2068   k007420->ram = auto_alloc_array(device->machine, UINT8, 0x200);
2069
2070   state_save_register_device_item_pointer(device, 0, k007420->ram, 0x200);
2071   state_save_register_device_item(device, 0, k007420->flipscreen);   // current one uses 7342 one
2072   state_save_register_device_item_array(device, 0, k007420->regs);   // current one uses 7342 ones
2073}
2074
2075static DEVICE_RESET( k007420 )
2076{
2077   k007420_state *k007420 = k007420_get_safe_token(device);
2078   int i;
2079
2080   k007420->flipscreen = 0;
2081   for (i = 0; i < 8; i++)
2082      k007420->regs[i] = 0;
2083}
2084
2085
2086/***************************************************************************/
2087/*                                                                         */
2088/*                                 052109                                  */
2089/*                                                                         */
2090/***************************************************************************/
2091
2092typedef struct _k052109_state k052109_state;
2093struct _k052109_state
2094{
2095   UINT8    *ram;
2096   UINT8    *videoram_F;
2097   UINT8    *videoram_A;
2098   UINT8    *videoram_B;
2099   UINT8    *videoram2_F;
2100   UINT8    *videoram2_A;
2101   UINT8    *videoram2_B;
2102   UINT8    *colorram_F;
2103   UINT8    *colorram_A;
2104   UINT8    *colorram_B;
2105
2106   tilemap  *tilemap[3];
2107   int      tileflip_enable, gfxnum;
2108   UINT8    charrombank[4];
2109   UINT8    charrombank_2[4];
2110   UINT8    has_extra_video_ram;
2111   INT32    RMRD_line;
2112   UINT8    irq_enabled;
2113   INT32    dx[3], dy[3];
2114   UINT8    romsubbank, scrollctrl;
2115
2116   k052109_callback callback;
2117
2118   const char *memory_region;
2119};
2120
2121
2122/*****************************************************************************
2123    INLINE FUNCTIONS
2124*****************************************************************************/
2125
2126INLINE k052109_state *k052109_get_safe_token( const device_config *device )
2127{
2128   assert(device != NULL);
2129   assert(device->token != NULL);
2130   assert(device->type == K052109);
2131
2132   return (k052109_state *)device->token;
2133}
2134
2135INLINE const k052109_interface *k052109_get_interface( const device_config *device )
2136{
2137   assert(device != NULL);
2138   assert((device->type == K052109));
2139   return (const k052109_interface *) device->static_config;
2140}
2141
2142/*****************************************************************************
2143    DEVICE HANDLERS
2144*****************************************************************************/
2145
2146READ8_DEVICE_HANDLER( k052109_r )
2147{
2148   k052109_state *k052109 = k052109_get_safe_token(device);
2149
2150   if (k052109->RMRD_line == CLEAR_LINE)
2151   {
2152      if ((offset & 0x1fff) >= 0x1800)
2153      {
2154         if (offset >= 0x180c && offset < 0x1834)
2155         {   /* A y scroll */   }
2156         else if (offset >= 0x1a00 && offset < 0x1c00)
2157         {   /* A x scroll */   }
2158         else if (offset == 0x1d00)
2159         {   /* read for bitwise operations before writing */   }
2160         else if (offset >= 0x380c && offset < 0x3834)
2161         {   /* B y scroll */   }
2162         else if (offset >= 0x3a00 && offset < 0x3c00)
2163         {   /* B x scroll */   }
2164//          else
2165//logerror("%04x: read from unknown 052109 address %04x\n",cpu_get_pc(space->cpu),offset);
2166      }
2167
2168      return k052109->ram[offset];
2169   }
2170   else   /* Punk Shot and TMNT read from 0000-1fff, Aliens from 2000-3fff */
2171   {
2172      int code = (offset & 0x1fff) >> 5;
2173      int color = k052109->romsubbank;
2174      int flags = 0;
2175      int priority = 0;
2176      int bank = k052109->charrombank[(color & 0x0c) >> 2] >> 2;   /* discard low bits (TMNT) */
2177      int addr;
2178
2179      bank |= (k052109->charrombank_2[(color & 0x0c) >> 2] >> 2); // Surprise Attack uses this 2nd bank in the rom test
2180
2181   if (k052109->has_extra_video_ram)
2182      code |= color << 8;   /* kludge for X-Men */
2183   else
2184      k052109->callback(device->machine, 0, bank, &code, &color, &flags, &priority);
2185
2186      addr = (code << 5) + (offset & 0x1f);
2187      addr &= memory_region_length(device->machine, k052109->memory_region) - 1;
2188
2189//      logerror("%04x: off = %04x sub = %02x (bnk = %x) adr = %06x\n", cpu_get_pc(space->cpu), offset, k052109->romsubbank, bank, addr);
2190
2191      return memory_region(device->machine, k052109->memory_region)[addr];
2192   }
2193}
2194
2195WRITE8_DEVICE_HANDLER( k052109_w )
2196{
2197   k052109_state *k052109 = k052109_get_safe_token(device);
2198
2199   if ((offset & 0x1fff) < 0x1800) /* tilemap RAM */
2200   {
2201      if (offset >= 0x4000)
2202         k052109->has_extra_video_ram = 1;  /* kludge for X-Men */
2203
2204      k052109->ram[offset] = data;
2205      tilemap_mark_tile_dirty(k052109->tilemap[(offset & 0x1800) >> 11],offset & 0x7ff);
2206   }
2207   else   /* control registers */
2208   {
2209      k052109->ram[offset] = data;
2210
2211      if (offset >= 0x180c && offset < 0x1834)
2212      {   /* A y scroll */   }
2213      else if (offset >= 0x1a00 && offset < 0x1c00)
2214      {   /* A x scroll */   }
2215      else if (offset == 0x1c80)
2216      {
2217         if (k052109->scrollctrl != data)
2218         {
2219//popmessage("scrollcontrol = %02x", data);
2220//logerror("%04x: rowscrollcontrol = %02x\n", cpu_get_pc(space->cpu), data);
2221            k052109->scrollctrl = data;
2222         }
2223      }
2224      else if (offset == 0x1d00)
2225      {
2226//logerror("%04x: 052109 register 1d00 = %02x\n", cpu_get_pc(space->cpu), data);
2227         /* bit 2 = irq enable */
2228         /* the custom chip can also generate NMI and FIRQ, for use with a 6809 */
2229         k052109->irq_enabled = data & 0x04;
2230      }
2231      else if (offset == 0x1d80)
2232      {
2233         int dirty = 0;
2234
2235         if (k052109->charrombank[0] != (data & 0x0f))
2236            dirty |= 1;
2237         if (k052109->charrombank[1] != ((data >> 4) & 0x0f))
2238            dirty |= 2;
2239
2240         if (dirty)
2241         {
2242            int i;
2243
2244            k052109->charrombank[0] = data & 0x0f;
2245            k052109->charrombank[1] = (data >> 4) & 0x0f;
2246
2247            for (i = 0; i < 0x1800; i++)
2248            {
2249               int bank = (k052109->ram[i]&0x0c) >> 2;
2250               if ((bank == 0 && (dirty & 1)) || (bank == 1 && (dirty & 2)))
2251               {
2252                  tilemap_mark_tile_dirty(k052109->tilemap[(i & 0x1800) >> 11], i & 0x7ff);
2253               }
2254            }
2255         }
2256      }
2257      else if (offset == 0x1e00 || offset == 0x3e00) // Surprise Attack uses offset 0x3e00
2258      {
2259//logerror("%04x: 052109 register 1e00 = %02x\n",cpu_get_pc(space->cpu),data);
2260         k052109->romsubbank = data;
2261      }
2262      else if (offset == 0x1e80)
2263      {
2264//if ((data & 0xfe)) logerror("%04x: 052109 register 1e80 = %02x\n",cpu_get_pc(space->cpu),data);
2265         tilemap_set_flip(k052109->tilemap[0], (data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
2266         tilemap_set_flip(k052109->tilemap[1], (data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
2267         tilemap_set_flip(k052109->tilemap[2], (data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
2268         if (k052109->tileflip_enable != ((data & 0x06) >> 1))
2269         {
2270            k052109->tileflip_enable = ((data & 0x06) >> 1);
2271
2272            tilemap_mark_all_tiles_dirty(k052109->tilemap[0]);
2273            tilemap_mark_all_tiles_dirty(k052109->tilemap[1]);
2274            tilemap_mark_all_tiles_dirty(k052109->tilemap[2]);
2275         }
2276      }
2277      else if (offset == 0x1f00)
2278      {
2279         int dirty = 0;
2280
2281         if (k052109->charrombank[2] != (data & 0x0f))
2282            dirty |= 1;
2283
2284         if (k052109->charrombank[3] != ((data >> 4) & 0x0f))
2285            dirty |= 2;
2286
2287         if (dirty)
2288         {
2289            int i;
2290
2291            k052109->charrombank[2] = data & 0x0f;
2292            k052109->charrombank[3] = (data >> 4) & 0x0f;
2293
2294            for (i = 0; i < 0x1800; i++)
2295            {
2296               int bank = (k052109->ram[i] & 0x0c) >> 2;
2297               if ((bank == 2 && (dirty & 1)) || (bank == 3 && (dirty & 2)))
2298                  tilemap_mark_tile_dirty(k052109->tilemap[(i & 0x1800) >> 11],i & 0x7ff);
2299            }
2300         }
2301      }
2302      else if (offset >= 0x380c && offset < 0x3834)
2303      {   /* B y scroll */   }
2304      else if (offset >= 0x3a00 && offset < 0x3c00)
2305      {   /* B x scroll */   }
2306      else if (offset == 0x3d80) // Surprise Attack uses offset 0x3d80 in rom test
2307      {
2308         // mirroring this write, breaks Surprise Attack in game tilemaps
2309         k052109->charrombank_2[0] = data & 0x0f;
2310         k052109->charrombank_2[1] = (data >> 4) & 0x0f;
2311      }
2312      else if (offset == 0x3f00) // Surprise Attack uses offset 0x3f00 in rom test
2313      {
2314         // mirroring this write, breaks Surprise Attack in game tilemaps
2315         k052109->charrombank_2[2] = data & 0x0f;
2316         k052109->charrombank_2[3] = (data >> 4) & 0x0f;
2317      }
2318//      else
2319//          logerror("%04x: write %02x to unknown 052109 address %04x\n",cpu_get_pc(space->cpu),data,offset);
2320   }
2321}
2322
2323READ16_DEVICE_HANDLER( k052109_word_r )
2324{
2325   return k052109_r(device, offset + 0x2000) | (k052109_r(device, offset) << 8);
2326}
2327
2328WRITE16_DEVICE_HANDLER( k052109_word_w )
2329{
2330   if (ACCESSING_BITS_8_15)
2331      k052109_w(device, offset, (data >> 8) & 0xff);
2332   if (ACCESSING_BITS_0_7)
2333      k052109_w(device, offset + 0x2000, data & 0xff);
2334}
2335
2336READ16_DEVICE_HANDLER( k052109_lsb_r )
2337{
2338   return k052109_r(device, offset);
2339}
2340
2341WRITE16_DEVICE_HANDLER( k052109_lsb_w )
2342{
2343   if(ACCESSING_BITS_0_7)
2344      k052109_w(device, offset, data & 0xff);
2345}
2346
2347void k052109_set_rmrd_line( const device_config *device, int state )
2348{
2349   k052109_state *k052109 = k052109_get_safe_token(device);
2350   k052109->RMRD_line = state;
2351}
2352
2353int k052109_get_rmrd_line(const device_config *device )
2354{
2355   k052109_state *k052109 = k052109_get_safe_token(device);
2356   return k052109->RMRD_line;
2357}
2358
2359
2360void k052109_tilemap_mark_dirty( const device_config *device, int tmap_num )
2361{
2362   k052109_state *k052109 = k052109_get_safe_token(device);
2363   tilemap_mark_all_tiles_dirty(k052109->tilemap[tmap_num]);
2364}
2365
2366
2367void k052109_tilemap_update( const device_config *device )
2368{
2369   k052109_state *k052109 = k052109_get_safe_token(device);
2370   int xscroll, yscroll, offs;
2371
2372#if 0
2373{
2374popmessage("%x %x %x %x",
2375   k052109->charrombank[0],
2376   k052109->charrombank[1],
2377   k052109->charrombank[2],
2378   k052109->charrombank[3]);
2379}
2380#endif
2381
2382   if ((k052109->scrollctrl & 0x03) == 0x02)
2383   {
2384      UINT8 *scrollram = &k052109->ram[0x1a00];
2385
2386      tilemap_set_scroll_rows(k052109->tilemap[1], 256);
2387      tilemap_set_scroll_cols(k052109->tilemap[1], 1);
2388      yscroll = k052109->ram[0x180c];
2389      tilemap_set_scrolly(k052109->tilemap[1], 0, yscroll + k052109->dy[1]);
2390      for (offs = 0; offs < 256; offs++)
2391      {
2392         xscroll = scrollram[2 * (offs & 0xfff8) + 0] + 256 * scrollram[2 * (offs & 0xfff8) + 1];
2393         xscroll -= 6;
2394         tilemap_set_scrollx(k052109->tilemap[1], (offs + yscroll) & 0xff, xscroll + k052109->dx[1]);
2395      }
2396   }
2397   else if ((k052109->scrollctrl & 0x03) == 0x03)
2398   {
2399      UINT8 *scrollram = &k052109->ram[0x1a00];
2400
2401      tilemap_set_scroll_rows(k052109->tilemap[1], 256);
2402      tilemap_set_scroll_cols(k052109->tilemap[1], 1);
2403      yscroll = k052109->ram[0x180c];
2404      tilemap_set_scrolly(k052109->tilemap[1], 0, yscroll + k052109->dy[1]);
2405      for (offs = 0; offs < 256; offs++)
2406      {
2407         xscroll = scrollram[2 * offs + 0] + 256 * scrollram[2 * offs + 1];
2408         xscroll -= 6;
2409         tilemap_set_scrollx(k052109->tilemap[1], (offs + yscroll) & 0xff, xscroll + k052109->dx[1]);
2410      }
2411   }
2412   else if ((k052109->scrollctrl & 0x04) == 0x04)
2413   {
2414      UINT8 *scrollram = &k052109->ram[0x1800];
2415
2416      tilemap_set_scroll_rows(k052109->tilemap[1], 1);
2417      tilemap_set_scroll_cols(k052109->tilemap[1], 512);
2418      xscroll = k052109->ram[0x1a00] + 256 * k052109->ram[0x1a01];
2419      xscroll -= 6;
2420      tilemap_set_scrollx(k052109->tilemap[1], 0, xscroll + k052109->dx[1]);
2421      for (offs = 0; offs < 512; offs++)
2422      {
2423         yscroll = scrollram[offs / 8];
2424         tilemap_set_scrolly(k052109->tilemap[1], (offs + xscroll) & 0x1ff, yscroll + k052109->dy[1]);
2425      }
2426   }
2427   else
2428   {
2429      UINT8 *scrollram = &k052109->ram[0x1a00];
2430
2431      tilemap_set_scroll_rows(k052109->tilemap[1], 1);
2432      tilemap_set_scroll_cols(k052109->tilemap[1], 1);
2433      xscroll = scrollram[0] + 256 * scrollram[1];
2434      xscroll -= 6;
2435      yscroll = k052109->ram[0x180c];
2436      tilemap_set_scrollx(k052109->tilemap[1], 0, xscroll + k052109->dx[1]);
2437      tilemap_set_scrolly(k052109->tilemap[1], 0, yscroll + k052109->dy[1]);
2438   }
2439
2440   if ((k052109->scrollctrl & 0x18) == 0x10)
2441   {
2442      UINT8 *scrollram = &k052109->ram[0x3a00];
2443
2444      tilemap_set_scroll_rows(k052109->tilemap[2], 256);
2445      tilemap_set_scroll_cols(k052109->tilemap[2], 1);
2446      yscroll = k052109->ram[0x380c];
2447      tilemap_set_scrolly(k052109->tilemap[2], 0, yscroll + k052109->dy[2]);
2448      for (offs = 0; offs < 256; offs++)
2449      {
2450         xscroll = scrollram[2 * (offs & 0xfff8) + 0] + 256 * scrollram[2 * (offs & 0xfff8) + 1];
2451         xscroll -= 6;
2452         tilemap_set_scrollx(k052109->tilemap[2], (offs + yscroll) & 0xff, xscroll + k052109->dx[2]);
2453      }
2454   }
2455   else if ((k052109->scrollctrl & 0x18) == 0x18)
2456   {
2457      UINT8 *scrollram = &k052109->ram[0x3a00];
2458
2459      tilemap_set_scroll_rows(k052109->tilemap[2], 256);
2460      tilemap_set_scroll_cols(k052109->tilemap[2], 1);
2461      yscroll = k052109->ram[0x380c];
2462      tilemap_set_scrolly(k052109->tilemap[2], 0, yscroll + k052109->dy[2]);
2463      for (offs = 0; offs < 256; offs++)
2464      {
2465         xscroll = scrollram[2 * offs + 0] + 256 * scrollram[2 * offs + 1];
2466         xscroll -= 6;
2467         tilemap_set_scrollx(k052109->tilemap[2], (offs + yscroll) & 0xff, xscroll + k052109->dx[2]);
2468      }
2469   }
2470   else if ((k052109->scrollctrl & 0x20) == 0x20)
2471   {
2472      UINT8 *scrollram = &k052109->ram[0x3800];
2473
2474      tilemap_set_scroll_rows(k052109->tilemap[2], 1);
2475      tilemap_set_scroll_cols(k052109->tilemap[2], 512);
2476      xscroll = k052109->ram[0x3a00] + 256 * k052109->ram[0x3a01];
2477      xscroll -= 6;
2478      tilemap_set_scrollx(k052109->tilemap[2], 0, xscroll + k052109->dx[2]);
2479      for (offs = 0; offs < 512; offs++)
2480      {
2481         yscroll = scrollram[offs / 8];
2482         tilemap_set_scrolly(k052109->tilemap[2], (offs + xscroll) & 0x1ff, yscroll + k052109->dy[2]);
2483      }
2484   }
2485   else
2486   {
2487      UINT8 *scrollram = &k052109->ram[0x3a00];
2488
2489      tilemap_set_scroll_rows(k052109->tilemap[2], 1);
2490      tilemap_set_scroll_cols(k052109->tilemap[2], 1);
2491      xscroll = scrollram[0] + 256 * scrollram[1];
2492      xscroll -= 6;
2493      yscroll = k052109->ram[0x380c];
2494      tilemap_set_scrollx(k052109->tilemap[2], 0, xscroll + k052109->dx[2]);
2495      tilemap_set_scrolly(k052109->tilemap[2], 0, yscroll + k052109->dy[2]);
2496   }
2497
2498#if 0
2499if ((k052109->scrollctrl & 0x03) == 0x01 ||
2500      (k052109->scrollctrl & 0x18) == 0x08 ||
2501      ((k052109->scrollctrl & 0x04) && (k052109->scrollctrl & 0x03)) ||
2502      ((k052109->scrollctrl & 0x20) && (k052109->scrollctrl & 0x18)) ||
2503      (k052109->scrollctrl & 0xc0) != 0)
2504   popmessage("scrollcontrol = %02x", k052109->scrollctrl);
2505
2506if (input_code_pressed(machine, KEYCODE_F))
2507{
2508   FILE *fp;
2509   fp=fopen("TILE.DMP", "w+b");
2510   if (fp)
2511   {
2512      fwrite(k052109->ram, 0x6000, 1, fp);
2513      popmessage("saved");
2514      fclose(fp);
2515   }
2516}
2517#endif
2518}
2519
2520void k052109_tilemap_draw( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int tmap_num, UINT32 flags, UINT8 priority )
2521{
2522   k052109_state *k052109 = k052109_get_safe_token(device);
2523   tilemap_draw(bitmap, cliprect, k052109->tilemap[tmap_num], flags, priority);
2524}
2525
2526int k052109_is_irq_enabled( const device_config *device )
2527{
2528   k052109_state *k052109 = k052109_get_safe_token(device);
2529
2530   return k052109->irq_enabled;
2531}
2532
2533void k052109_set_layer_offsets( const device_config *device, int layer, int dx, int dy )
2534{
2535   k052109_state *k052109 = k052109_get_safe_token(device);
2536
2537   k052109->dx[layer] = dx;
2538   k052109->dy[layer] = dy;
2539}
2540
2541
2542/***************************************************************************
2543
2544  Callbacks for the TileMap code
2545
2546***************************************************************************/
2547
2548/*
2549  data format:
2550  video RAM    xxxxxxxx  tile number (low 8 bits)
2551  color RAM    xxxx----  depends on external connections (usually color and banking)
2552  color RAM    ----xx--  bank select (0-3): these bits are replaced with the 2
2553                         bottom bits of the bank register before being placed on
2554                         the output pins. The other two bits of the bank register are
2555                         placed on the CAB1 and CAB2 output pins.
2556  color RAM    ------xx  depends on external connections (usually banking, flip)
2557*/
2558
2559INLINE void k052109_get_tile_info( const device_config *device, tile_data *tileinfo, int tile_index, int layer, UINT8 *cram, UINT8 *vram1, UINT8 *vram2 )
2560{
2561   k052109_state *k052109 = k052109_get_safe_token(device);
2562   int flipy = 0;
2563   int code = vram1[tile_index] + 256 * vram2[tile_index];
2564   int color = cram[tile_index];
2565   int flags = 0;
2566   int priority = 0;
2567   int bank = k052109->charrombank[(color & 0x0c) >> 2];
2568   if (k052109->has_extra_video_ram)
2569      bank = (color & 0x0c) >> 2;   /* kludge for X-Men */
2570
2571   color = (color & 0xf3) | ((bank & 0x03) << 2);
2572   bank >>= 2;
2573
2574   flipy = color & 0x02;
2575
2576   k052109->callback(device->machine, layer, bank, &code, &color, &flags, &priority);
2577
2578   /* if the callback set flip X but it is not enabled, turn it off */
2579   if (!(k052109->tileflip_enable & 1))
2580      flags &= ~TILE_FLIPX;
2581
2582   /* if flip Y is enabled and the attribute but is set, turn it on */
2583   if (flipy && (k052109->tileflip_enable & 2))
2584      flags |= TILE_FLIPY;
2585
2586   SET_TILE_INFO_DEVICE(
2587         k052109->gfxnum,
2588         code,
2589         color,
2590         flags);
2591
2592   tileinfo->category = priority;
2593}
2594
2595static TILE_GET_INFO_DEVICE( k052109_get_tile_info0 )
2596{
2597   k052109_state *k052109 = k052109_get_safe_token(device);
2598   k052109_get_tile_info(device, tileinfo, tile_index, 0, k052109->colorram_F, k052109->videoram_F, k052109->videoram2_F);
2599}
2600
2601static TILE_GET_INFO_DEVICE( k052109_get_tile_info1 )
2602{
2603   k052109_state *k052109 = k052109_get_safe_token(device);
2604   k052109_get_tile_info(device, tileinfo, tile_index, 1, k052109->colorram_A, k052109->videoram_A, k052109->videoram2_A);
2605}
2606
2607static TILE_GET_INFO_DEVICE( k052109_get_tile_info2 )
2608{
2609   k052109_state *k052109 = k052109_get_safe_token(device);
2610   k052109_get_tile_info(device, tileinfo, tile_index, 2, k052109->colorram_B, k052109->videoram_B, k052109->videoram2_B);
2611}
2612
2613
2614//static STATE_POSTLOAD( k052109_tileflip_reset )
2615void k052109_postload_tileflip_reset( const device_config *device )
2616{
2617   k052109_state *k052109 = k052109_get_safe_token(device);
2618   int data = k052109->ram[0x1e80];
2619   tilemap_set_flip(k052109->tilemap[0], (data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
2620   tilemap_set_flip(k052109->tilemap[1], (data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
2621   tilemap_set_flip(k052109->tilemap[2], (data & 1) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
2622   k052109->tileflip_enable = ((data & 0x06) >> 1);
2623}
2624
2625static DEVICE_START( k052109 )
2626{
2627   k052109_state *k052109 = k052109_get_safe_token(device);
2628   const k052109_interface *intf = k052109_get_interface(device);
2629   running_machine *machine = device->machine;
2630   UINT32 total;
2631   static const gfx_layout charlayout =
2632   {
2633      8,8,
2634      0,
2635      4,
2636      { 24, 16, 8, 0 },
2637      { 0, 1, 2, 3, 4, 5, 6, 7 },
2638      { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
2639      32*8
2640   };
2641   static const gfx_layout charlayout_gradius3 =
2642   {
2643      8,8,
2644      0,
2645      4,
2646      { 0, 1, 2, 3 },
2647      { XOR(0)*4, XOR(1)*4, XOR(2)*4, XOR(3)*4, XOR(4)*4, XOR(5)*4, XOR(6)*4, XOR(7)*4 },
2648      { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
2649      32*8
2650   };
2651
2652
2653   /* decode the graphics */
2654   switch (intf->plane_order)
2655   {
2656   case NORMAL_PLANE_ORDER:
2657      total = memory_region_length(machine, intf->gfx_memory_region) / 32;
2658      decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &charlayout, 4);
2659      break;
2660
2661   case GRADIUS3_PLANE_ORDER:
2662      total = 0x1000;
2663      decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &charlayout_gradius3, 4);
2664      break;
2665
2666   default:
2667      fatalerror("Unsupported plane_order");
2668   }
2669
2670   /* deinterleave the graphics, if needed */
2671   deinterleave_gfx(machine, intf->gfx_memory_region, intf->deinterleave);
2672
2673   k052109->memory_region = intf->gfx_memory_region;
2674   k052109->gfxnum = intf->gfx_num;
2675   k052109->callback = intf->callback;
2676
2677   k052109->tilemap[0] = tilemap_create_device(device, k052109_get_tile_info0, tilemap_scan_rows, 8, 8, 64, 32);
2678   k052109->tilemap[1] = tilemap_create_device(device, k052109_get_tile_info1, tilemap_scan_rows, 8, 8, 64, 32);
2679   k052109->tilemap[2] = tilemap_create_device(device, k052109_get_tile_info2, tilemap_scan_rows, 8, 8, 64, 32);
2680
2681   k052109->ram = auto_alloc_array(machine, UINT8, 0x6000);
2682
2683   k052109->colorram_F = &k052109->ram[0x0000];
2684   k052109->colorram_A = &k052109->ram[0x0800];
2685   k052109->colorram_B = &k052109->ram[0x1000];
2686   k052109->videoram_F = &k052109->ram[0x2000];
2687   k052109->videoram_A = &k052109->ram[0x2800];
2688   k052109->videoram_B = &k052109->ram[0x3000];
2689   k052109->videoram2_F = &k052109->ram[0x4000];
2690   k052109->videoram2_A = &k052109->ram[0x4800];
2691   k052109->videoram2_B = &k052109->ram[0x5000];
2692
2693   tilemap_set_transparent_pen(k052109->tilemap[0], 0);
2694   tilemap_set_transparent_pen(k052109->tilemap[1], 0);
2695   tilemap_set_transparent_pen(k052109->tilemap[2], 0);
2696
2697   state_save_register_device_item_pointer(device, 0, k052109->ram, 0x6000);
2698   state_save_register_device_item(device, 0, k052109->RMRD_line);
2699   state_save_register_device_item(device, 0, k052109->romsubbank);
2700   state_save_register_device_item(device, 0, k052109->scrollctrl);
2701   state_save_register_device_item(device, 0, k052109->irq_enabled);
2702   state_save_register_device_item_array(device, 0, k052109->charrombank);
2703   state_save_register_device_item_array(device, 0, k052109->charrombank_2);
2704   state_save_register_device_item_array(device, 0, k052109->dx);
2705   state_save_register_device_item_array(device, 0, k052109->dy);
2706   state_save_register_device_item(device, 0, k052109->has_extra_video_ram);
2707
2708//  state_save_register_postload(machine, k052109_tileflip_reset, NULL);    // to be moved into the drivers
2709}
2710
2711static DEVICE_RESET( k052109 )
2712{
2713   k052109_state *k052109 = k052109_get_safe_token(device);
2714   int i;
2715
2716   k052109->RMRD_line = CLEAR_LINE;
2717   k052109->irq_enabled = 0;
2718
2719   k052109->has_extra_video_ram = 0;
2720
2721   for (i = 0; i < 3; i++)
2722      k052109->dx[i] = k052109->dy[i] = 0;
2723}
2724
2725
2726/***************************************************************************/
2727/*                                                                         */
2728/*                                 051960                                  */
2729/*                                                                         */
2730/***************************************************************************/
2731
2732typedef struct _k051960_state k051960_state;
2733struct _k051960_state
2734{
2735   UINT8    *ram;
2736
2737   gfx_element *gfx;
2738
2739   UINT8    spriterombank[3];
2740   int      dx, dy;
2741   int      romoffset;
2742   int      spriteflip, readroms;
2743   int      irq_enabled, nmi_enabled;
2744
2745   int      k051937_counter;
2746
2747   k051960_callback callback;
2748
2749   const char *memory_region;
2750};
2751
2752
2753/*****************************************************************************
2754    INLINE FUNCTIONS
2755*****************************************************************************/
2756
2757INLINE k051960_state *k051960_get_safe_token( const device_config *device )
2758{
2759   assert(device != NULL);
2760   assert(device->token != NULL);
2761   assert(device->type == K051960);
2762
2763   return (k051960_state *)device->token;
2764}
2765
2766INLINE const k051960_interface *k051960_get_interface( const device_config *device )
2767{
2768   assert(device != NULL);
2769   assert((device->type == K051960));
2770   return (const k051960_interface *) device->static_config;
2771}
2772
2773/*****************************************************************************
2774    DEVICE HANDLERS
2775*****************************************************************************/
2776
2777static int k051960_fetchromdata( const device_config *device, int byte )
2778{
2779   k051960_state *k051960 = k051960_get_safe_token(device);
2780   int code, color, pri, shadow, off1, addr;
2781
2782   addr = k051960->romoffset + (k051960->spriterombank[0] << 8) + ((k051960->spriterombank[1] & 0x03) << 16);
2783   code = (addr & 0x3ffe0) >> 5;
2784   off1 = addr & 0x1f;
2785   color = ((k051960->spriterombank[1] & 0xfc) >> 2) + ((k051960->spriterombank[2] & 0x03) << 6);
2786   pri = 0;
2787   shadow = color & 0x80;
2788   k051960->callback(device->machine, &code, &color, &pri, &shadow);
2789
2790   addr = (code << 7) | (off1 << 2) | byte;
2791   addr &= memory_region_length(device->machine, k051960->memory_region) - 1;
2792
2793//  popmessage("%s: addr %06x", cpuexec_describe_context(device->machine), addr);
2794
2795   return memory_region(device->machine, k051960->memory_region)[addr];
2796}
2797
2798READ8_DEVICE_HANDLER( k051960_r )
2799{
2800   k051960_state *k051960 = k051960_get_safe_token(device);
2801   if (k051960->readroms)
2802   {
2803      /* the 051960 remembers the last address read and uses it when reading the sprite ROMs */
2804      k051960->romoffset = (offset & 0x3fc) >> 2;
2805      return k051960_fetchromdata(device, offset & 3);   /* only 88 Games reads the ROMs from here */
2806   }
2807   else
2808      return k051960->ram[offset];
2809}
2810
2811WRITE8_DEVICE_HANDLER( k051960_w )
2812{
2813   k051960_state *k051960 = k051960_get_safe_token(device);
2814   k051960->ram[offset] = data;
2815}
2816
2817READ16_DEVICE_HANDLER( k051960_word_r )
2818{
2819   return k051960_r(device, offset * 2 + 1) | (k051960_r(device, offset * 2) << 8);
2820}
2821
2822WRITE16_DEVICE_HANDLER( k051960_word_w )
2823{
2824   if (ACCESSING_BITS_8_15)
2825      k051960_w(device, offset * 2, (data >> 8) & 0xff);
2826   if (ACCESSING_BITS_0_7)
2827      k051960_w(device, offset * 2 + 1, data & 0xff);
2828}
2829
2830
2831/* should this be split by k051960? */
2832READ8_DEVICE_HANDLER( k051937_r )
2833{
2834   k051960_state *k051960 = k051960_get_safe_token(device);
2835
2836   if (k051960->readroms && offset >= 4 && offset < 8)
2837      return k051960_fetchromdata(device, offset & 3);
2838   else
2839   {
2840      if (offset == 0)
2841      {
2842         /* some games need bit 0 to pulse */
2843         return (k051960->k051937_counter++) & 1;
2844      }
2845      //logerror("%04x: read unknown 051937 address %x\n", cpu_get_pc(device->cpu), offset);
2846      return 0;
2847   }
2848}
2849
2850WRITE8_DEVICE_HANDLER( k051937_w )
2851{
2852   k051960_state *k051960 = k051960_get_safe_token(device);
2853
2854   if (offset == 0)
2855   {
2856
2857      //if (data & 0xc2) popmessage("051937 reg 00 = %02x",data);
2858
2859      /* bit 0 is IRQ enable */
2860      k051960->irq_enabled = data & 0x01;
2861
2862      /* bit 1: probably FIRQ enable */
2863
2864      /* bit 2 is NMI enable */
2865      k051960->nmi_enabled = data & 0x04;
2866
2867      /* bit 3 = flip screen */
2868      k051960->spriteflip = data & 0x08;
2869
2870      /* bit 4 used by Devastators and TMNT, unknown */
2871
2872      /* bit 5 = enable gfx ROM reading */
2873      k051960->readroms = data & 0x20;
2874      //logerror("%04x: write %02x to 051937 address %x\n", cpu_get_pc(machine->cpu), data, offset);
2875   }
2876   else if (offset == 1)
2877   {
2878//  popmessage("%04x: write %02x to 051937 address %x", cpu_get_pc(machine->cpu), data, offset);
2879//logerror("%04x: write %02x to unknown 051937 address %x\n", cpu_get_pc(machine->cpu), data, offset);
2880   }
2881   else if (offset >= 2 && offset < 5)
2882   {
2883      k051960->spriterombank[offset - 2] = data;
2884   }
2885   else
2886   {
2887   //  popmessage("%04x: write %02x to 051937 address %x", cpu_get_pc(machine->cpu), data, offset);
2888   //logerror("%04x: write %02x to unknown 051937 address %x\n", cpu_get_pc(machine->cpu), data, offset);
2889   }
2890}
2891
2892int k051960_is_irq_enabled( const device_config *device )
2893{
2894   k051960_state *k051960 = k051960_get_safe_token(device);
2895   return k051960->irq_enabled;
2896}
2897
2898int k051960_is_nmi_enabled( const device_config *device )
2899{
2900   k051960_state *k051960 = k051960_get_safe_token(device);
2901   return k051960->nmi_enabled;
2902}
2903
2904void k051960_set_sprite_offsets( const device_config *device, int dx, int dy )
2905{
2906   k051960_state *k051960 = k051960_get_safe_token(device);
2907   k051960->dx = dx;
2908   k051960->dy = dy;
2909}
2910
2911
2912READ16_DEVICE_HANDLER( k051937_word_r )
2913{
2914   return k051937_r(device, offset * 2 + 1) | (k051937_r(device, offset * 2) << 8);
2915}
2916
2917WRITE16_DEVICE_HANDLER( k051937_word_w )
2918{
2919   if (ACCESSING_BITS_8_15)
2920      k051937_w(device, offset * 2,(data >> 8) & 0xff);
2921   if (ACCESSING_BITS_0_7)
2922      k051937_w(device, offset * 2 + 1,data & 0xff);
2923}
2924
2925/*
2926 * Sprite Format
2927 * ------------------
2928 *
2929 * Byte | Bit(s)   | Use
2930 * -----+-76543210-+----------------
2931 *   0  | x------- | active (show this sprite)
2932 *   0  | -xxxxxxx | priority order
2933 *   1  | xxx----- | sprite size (see below)
2934 *   1  | ---xxxxx | sprite code (high 5 bits)
2935 *   2  | xxxxxxxx | sprite code (low 8 bits)
2936 *   3  | xxxxxxxx | "color", but depends on external connections (see below)
2937 *   4  | xxxxxx-- | zoom y (0 = normal, >0 = shrink)
2938 *   4  | ------x- | flip y
2939 *   4  | -------x | y position (high bit)
2940 *   5  | xxxxxxxx | y position (low 8 bits)
2941 *   6  | xxxxxx-- | zoom x (0 = normal, >0 = shrink)
2942 *   6  | ------x- | flip x
2943 *   6  | -------x | x position (high bit)
2944 *   7  | xxxxxxxx | x position (low 8 bits)
2945 *
2946 * Example of "color" field for Punk Shot:
2947 *   3  | x------- | shadow
2948 *   3  | -xx----- | priority
2949 *   3  | ---x---- | use second gfx ROM bank
2950 *   3  | ----xxxx | color code
2951 *
2952 * shadow enables transparent shadows. Note that it applies to pen 0x0f ONLY.
2953 * The rest of the sprite remains normal.
2954 * Note that Aliens also uses the shadow bit to select the second sprite bank.
2955 */
2956
2957void k051960_sprites_draw( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int min_priority, int max_priority )
2958{
2959#define NUM_SPRITES 128
2960   k051960_state *k051960 = k051960_get_safe_token(device);
2961   running_machine *machine = device->machine;
2962   int offs, pri_code;
2963   int sortedlist[NUM_SPRITES];
2964   UINT8 drawmode_table[256];
2965
2966   memset(drawmode_table, DRAWMODE_SOURCE, sizeof(drawmode_table));
2967   drawmode_table[0] = DRAWMODE_NONE;
2968
2969   for (offs = 0; offs < NUM_SPRITES; offs++)
2970      sortedlist[offs] = -1;
2971
2972   /* prebuild a sorted table */
2973   for (offs = 0; offs < 0x400; offs += 8)
2974   {
2975      if (k051960->ram[offs] & 0x80)
2976      {
2977         if (max_priority == -1)   /* draw front to back when using priority buffer */
2978            sortedlist[(k051960->ram[offs] & 0x7f) ^ 0x7f] = offs;
2979         else
2980            sortedlist[k051960->ram[offs] & 0x7f] = offs;
2981      }
2982   }
2983
2984   for (pri_code = 0; pri_code < NUM_SPRITES; pri_code++)
2985   {
2986      int ox, oy, code, color, pri, shadow, size, w, h, x, y, flipx, flipy, zoomx, zoomy;
2987      /* sprites can be grouped up to 8x8. The draw order is
2988             0  1  4  5 16 17 20 21
2989             2  3  6  7 18 19 22 23
2990             8  9 12 13 24 25 28 29
2991            10 11 14 15 26 27 30 31
2992            32 33 36 37 48 49 52 53
2993            34 35 38 39 50 51 54 55
2994            40 41 44 45 56 57 60 61
2995            42 43 46 47 58 59 62 63
2996        */
2997      static const int xoffset[8] = { 0, 1, 4, 5, 16, 17, 20, 21 };
2998      static const int yoffset[8] = { 0, 2, 8, 10, 32, 34, 40, 42 };
2999      static const int width[8] =  { 1, 2, 1, 2, 4, 2, 4, 8 };
3000      static const int height[8] = { 1, 1, 2, 2, 2, 4, 4, 8 };
3001
3002      offs = sortedlist[pri_code];
3003      if (offs == -1)
3004         continue;
3005
3006      code = k051960->ram[offs + 2] + ((k051960->ram[offs + 1] & 0x1f) << 8);
3007      color = k051960->ram[offs + 3] & 0xff;
3008      pri = 0;
3009      shadow = color & 0x80;
3010      k051960->callback(device->machine, &code, &color, &pri, &shadow);
3011
3012      if (max_priority != -1)
3013         if (pri < min_priority || pri > max_priority)
3014            continue;
3015
3016      size = (k051960->ram[offs + 1] & 0xe0) >> 5;
3017      w = width[size];
3018      h = height[size];
3019
3020      if (w >= 2) code &= ~0x01;
3021      if (h >= 2) code &= ~0x02;
3022      if (w >= 4) code &= ~0x04;
3023      if (h >= 4) code &= ~0x08;
3024      if (w >= 8) code &= ~0x10;
3025      if (h >= 8) code &= ~0x20;
3026
3027      ox = (256 * k051960->ram[offs + 6] + k051960->ram[offs + 7]) & 0x01ff;
3028      oy = 256 - ((256 * k051960->ram[offs + 4] + k051960->ram[offs + 5]) & 0x01ff);
3029      ox += k051960->dx;
3030      oy += k051960->dy;
3031      flipx = k051960->ram[offs + 6] & 0x02;
3032      flipy = k051960->ram[offs + 4] & 0x02;
3033      zoomx = (k051960->ram[offs + 6] & 0xfc) >> 2;
3034      zoomy = (k051960->ram[offs + 4] & 0xfc) >> 2;
3035      zoomx = 0x10000 / 128 * (128 - zoomx);
3036      zoomy = 0x10000 / 128 * (128 - zoomy);
3037
3038      if (k051960->spriteflip)
3039      {
3040         ox = 512 - (zoomx * w >> 12) - ox;
3041         oy = 256 - (zoomy * h >> 12) - oy;
3042         flipx = !flipx;
3043         flipy = !flipy;
3044      }
3045
3046      drawmode_table[k051960->gfx->color_granularity - 1] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
3047
3048      if (zoomx == 0x10000 && zoomy == 0x10000)
3049      {
3050         int sx, sy;
3051
3052         for (y = 0; y < h; y++)
3053         {
3054            sy = oy + 16 * y;
3055
3056            for (x = 0; x < w; x++)
3057            {
3058               int c = code;
3059
3060               sx = ox + 16 * x;
3061               if (flipx)
3062                  c += xoffset[(w - 1 - x)];
3063               else
3064                  c += xoffset[x];
3065
3066               if (flipy)
3067                  c += yoffset[(h - 1 - y)];
3068               else
3069                  c += yoffset[y];
3070
3071               if (max_priority == -1)
3072                  pdrawgfx_transtable(bitmap,cliprect,k051960->gfx,
3073                        c,
3074                        color,
3075                        flipx,flipy,
3076                        sx & 0x1ff,sy,
3077                        machine->priority_bitmap,pri,
3078                        drawmode_table,machine->shadow_table);
3079               else
3080                  drawgfx_transtable(bitmap,cliprect,k051960->gfx,
3081                        c,
3082                        color,
3083                        flipx,flipy,
3084                        sx & 0x1ff,sy,
3085                        drawmode_table,machine->shadow_table);
3086            }
3087         }
3088      }
3089      else
3090      {
3091         int sx, sy, zw, zh;
3092
3093         for (y = 0; y < h; y++)
3094         {
3095            sy = oy + ((zoomy * y + (1 << 11)) >> 12);
3096            zh = (oy + ((zoomy * (y + 1) + (1 << 11)) >> 12)) - sy;
3097
3098            for (x = 0; x < w; x++)
3099            {
3100               int c = code;
3101
3102               sx = ox + ((zoomx * x + (1 << 11)) >> 12);
3103               zw = (ox + ((zoomx * (x+1) + (1 << 11)) >> 12)) - sx;
3104               if (flipx)
3105                  c += xoffset[(w - 1 - x)];
3106               else
3107                  c += xoffset[x];
3108
3109               if (flipy)
3110                  c += yoffset[(h - 1 - y)];
3111               else
3112                  c += yoffset[y];
3113
3114               if (max_priority == -1)
3115                  pdrawgfxzoom_transtable(bitmap,cliprect,k051960->gfx,
3116                        c,
3117                        color,
3118                        flipx,flipy,
3119                        sx & 0x1ff,sy,
3120                        (zw << 16) / 16,(zh << 16) / 16,
3121                        machine->priority_bitmap,pri,
3122                        drawmode_table,machine->shadow_table);
3123               else
3124                  drawgfxzoom_transtable(bitmap,cliprect,k051960->gfx,
3125                        c,
3126                        color,
3127                        flipx,flipy,
3128                        sx & 0x1ff,sy,
3129                        (zw << 16) / 16,(zh << 16) / 16,
3130                        drawmode_table,machine->shadow_table);
3131            }
3132         }
3133      }
3134   }
3135#if 0
3136if (input_code_pressed(machine, KEYCODE_D))
3137{
3138   FILE *fp;
3139   fp=fopen("SPRITE.DMP", "w+b");
3140   if (fp)
3141   {
3142      fwrite(k051960_ram, 0x400, 1, fp);
3143      popmessage("saved");
3144      fclose(fp);
3145   }
3146}
3147#endif
3148#undef NUM_SPRITES
3149}
3150
3151/*****************************************************************************
3152    DEVICE INTERFACE
3153*****************************************************************************/
3154
3155static DEVICE_START( k051960 )
3156{
3157   k051960_state *k051960 = k051960_get_safe_token(device);
3158   const k051960_interface *intf = k051960_get_interface(device);
3159   running_machine *machine = device->machine;
3160   UINT32 total;
3161   static const gfx_layout spritelayout =
3162   {
3163      16,16,
3164      0,
3165      4,
3166      { 0, 8, 16, 24 },
3167      { 0, 1, 2, 3, 4, 5, 6, 7,
3168            8*32+0, 8*32+1, 8*32+2, 8*32+3, 8*32+4, 8*32+5, 8*32+6, 8*32+7 },
3169      { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
3170            16*32, 17*32, 18*32, 19*32, 20*32, 21*32, 22*32, 23*32 },
3171      128*8
3172   };
3173   static const gfx_layout spritelayout_reverse =
3174   {
3175      16,16,
3176      0,
3177      4,
3178      { 24, 16, 8, 0 },
3179      { 0, 1, 2, 3, 4, 5, 6, 7,
3180            8*32+0, 8*32+1, 8*32+2, 8*32+3, 8*32+4, 8*32+5, 8*32+6, 8*32+7 },
3181      { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
3182            16*32, 17*32, 18*32, 19*32, 20*32, 21*32, 22*32, 23*32 },
3183      128*8
3184   };
3185   static const gfx_layout spritelayout_gradius3 =
3186   {
3187      16,16,
3188      0,
3189      4,
3190      { 0, 1, 2, 3 },
3191      { 2*4, 3*4, 0*4, 1*4, 6*4, 7*4, 4*4, 5*4,
3192         32*8+2*4, 32*8+3*4, 32*8+0*4, 32*8+1*4, 32*8+6*4, 32*8+7*4, 32*8+4*4, 32*8+5*4 },
3193      { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
3194         64*8+0*32, 64*8+1*32, 64*8+2*32, 64*8+3*32, 64*8+4*32, 64*8+5*32, 64*8+6*32, 64*8+7*32 },
3195      128*8
3196   };
3197
3198   /* decode the graphics */
3199   switch (intf->plane_order)
3200   {
3201   case NORMAL_PLANE_ORDER:
3202      total = memory_region_length(machine, intf->gfx_memory_region) / 128;
3203      decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &spritelayout, 4);
3204      break;
3205
3206   case REVERSE_PLANE_ORDER:
3207      total = memory_region_length(machine, intf->gfx_memory_region) / 128;
3208      decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &spritelayout_reverse, 4);
3209      break;
3210
3211   case GRADIUS3_PLANE_ORDER:
3212      total = 0x4000;
3213      decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &spritelayout_gradius3, 4);
3214      break;
3215
3216   default:
3217      fatalerror("Unknown plane_order");
3218   }
3219
3220   if (VERBOSE && !(machine->config->video_attributes & VIDEO_HAS_SHADOWS))
3221      popmessage("driver should use VIDEO_HAS_SHADOWS");
3222
3223   /* deinterleave the graphics, if needed */
3224   deinterleave_gfx(machine, intf->gfx_memory_region, intf->deinterleave);
3225
3226   k051960->memory_region = intf->gfx_memory_region;
3227   k051960->gfx = machine->gfx[intf->gfx_num];
3228   k051960->callback = intf->callback;
3229   k051960->ram = auto_alloc_array_clear(machine, UINT8, 0x400);
3230
3231   state_save_register_device_item(device, 0, k051960->romoffset);
3232   state_save_register_device_item(device, 0, k051960->spriteflip);
3233   state_save_register_device_item(device, 0, k051960->readroms);
3234   state_save_register_device_item_array(device, 0, k051960->spriterombank);
3235   state_save_register_device_item_pointer(device, 0, k051960->ram, 0x400);
3236   state_save_register_device_item(device, 0, k051960->irq_enabled);
3237   state_save_register_device_item(device, 0, k051960->nmi_enabled);
3238   state_save_register_device_item(device, 0, k051960->dx);
3239   state_save_register_device_item(device, 0, k051960->dy);
3240
3241   state_save_register_device_item(device, 0, k051960->k051937_counter);
3242}
3243
3244static DEVICE_RESET( k051960 )
3245{
3246   k051960_state *k051960 = k051960_get_safe_token(device);
3247
3248   k051960->dx = k051960->dy = 0;
3249   k051960->k051937_counter = 0;
3250}
3251
3252
3253#if 0 // to be moved in the specific drivers!
3254READ8_DEVICE_HANDLER( k052109_051960_r )
3255{
3256   if (k052109_RMRD_line == CLEAR_LINE)
3257   {
3258      if (offset >= 0x3800 && offset < 0x3808)
3259         return k051937_r(space,offset - 0x3800);
3260      else if (offset < 0x3c00)
3261         return k052109_r(space,offset);
3262      else
3263         return k051960_r(space,offset - 0x3c00);
3264   }
3265   else return k052109_r(space,offset);
3266}
3267
3268WRITE8_DEVICE_HANDLER( k052109_051960_w )
3269{
3270   if (offset >= 0x3800 && offset < 0x3808)
3271      k051937_w(space,offset - 0x3800,data);
3272   else if (offset < 0x3c00)
3273      k052109_w(space,offset,data);
3274   else
3275      k051960_w(space,offset - 0x3c00,data);
3276}
3277#endif
3278
3279
3280/***************************************************************************/
3281/*                                                                         */
3282/*                      05324x Family Sprite Generators                    */
3283/*                                                                         */
3284/***************************************************************************/
3285
3286/***************************************************************************/
3287/*                                                                         */
3288/*                         053244 / 053245                                 */
3289/*                                                                         */
3290/***************************************************************************/
3291
3292typedef struct _k05324x_state k05324x_state;
3293struct _k05324x_state
3294{
3295   UINT16    *ram;
3296   UINT16    *buffer;
3297
3298   gfx_element *gfx;
3299
3300   UINT8    regs[0x10];   // 053244
3301   int      dx, dy;
3302   int      rombank;      // 053244
3303   int      ramsize;
3304   int      z_rejection;
3305
3306   k05324x_callback callback;
3307
3308   const char *memory_region;
3309};
3310
3311
3312/*****************************************************************************
3313    INLINE FUNCTIONS
3314*****************************************************************************/
3315
3316INLINE k05324x_state *k05324x_get_safe_token( const device_config *device )
3317{
3318   assert(device != NULL);
3319   assert(device->token != NULL);
3320   assert((device->type == K053244 || device->type == K053245));
3321
3322   return (k05324x_state *)device->token;
3323}
3324
3325INLINE const k05324x_interface *k05324x_get_interface( const device_config *device )
3326{
3327   assert(device != NULL);
3328   assert((device->type == K053244 || device->type == K053245));
3329   return (const k05324x_interface *) device->static_config;
3330}
3331
3332/*****************************************************************************
3333    DEVICE HANDLERS
3334*****************************************************************************/
3335
3336void k053245_set_sprite_offs( const device_config *device, int offsx, int offsy )
3337{
3338   k05324x_state *k053245 = k05324x_get_safe_token(device);
3339   k053245->dx = offsx;
3340   k053245->dy = offsy;
3341}
3342
3343READ16_DEVICE_HANDLER( k053245_word_r )
3344{
3345   k05324x_state *k053245 = k05324x_get_safe_token(device);
3346   return k053245->ram[offset];
3347}
3348
3349WRITE16_DEVICE_HANDLER( k053245_word_w )
3350{
3351   k05324x_state *k053245 = k05324x_get_safe_token(device);
3352   COMBINE_DATA(k053245->ram + offset);
3353}
3354
3355READ8_DEVICE_HANDLER( k053245_r )
3356{
3357   k05324x_state *k053245 = k05324x_get_safe_token(device);
3358
3359   if(offset & 1)
3360      return k053245->ram[offset >> 1] & 0xff;
3361   else
3362      return (k053245->ram[offset >> 1] >> 8) & 0xff;
3363}
3364
3365
3366WRITE8_DEVICE_HANDLER( k053245_w )
3367{
3368   k05324x_state *k053245 = k05324x_get_safe_token(device);
3369
3370   if(offset & 1)
3371      k053245->ram[offset >> 1] = (k053245->ram[offset >> 1] & 0xff00) | data;
3372   else
3373      k053245->ram[offset >> 1] = (k053245->ram[offset >> 1] & 0x00ff) | (data << 8);
3374}
3375
3376void k053245_clear_buffer( const device_config *device )
3377{
3378   k05324x_state *k053245 = k05324x_get_safe_token(device);
3379   int i, e;
3380
3381   for (e = k053245->ramsize / 2, i = 0; i < e; i += 8)
3382      k053245->buffer[i] = 0;
3383}
3384
3385INLINE void k053245_update_buffer( const device_config *device )
3386{
3387   k05324x_state *k053245 = k05324x_get_safe_token(device);
3388   memcpy(k053245->buffer, k053245->ram, k053245->ramsize);
3389}
3390
3391READ8_DEVICE_HANDLER( k053244_r )
3392{
3393   k05324x_state *k053244 = k05324x_get_safe_token(device);
3394   running_machine *machine = device->machine;
3395
3396   if ((k053244->regs[5] & 0x10) && offset >= 0x0c && offset < 0x10)
3397   {
3398      int addr;
3399
3400      addr = (k053244->rombank << 19) | ((k053244->regs[11] & 0x7) << 18)
3401         | (k053244->regs[8] << 10) | (k053244->regs[9] << 2)
3402         | ((offset & 3) ^ 1);
3403      addr &= memory_region_length(machine, k053244->memory_region) - 1;
3404
3405      //  popmessage("%s: offset %02x addr %06x", cpuexec_describe_context(machine), offset & 3, addr);
3406
3407      return memory_region(machine, k053244->memory_region)[addr];
3408   }
3409   else if (offset == 0x06)
3410   {
3411      k053245_update_buffer(device);
3412      return 0;
3413   }
3414   else
3415   {
3416      //logerror("%s: read from unknown 053244 address %x\n", cpuexec_describe_context(machine), offset);
3417      return 0;
3418   }
3419}
3420
3421WRITE8_DEVICE_HANDLER( k053244_w )
3422{
3423   k05324x_state *k053244 = k05324x_get_safe_token(device);
3424
3425   k053244->regs[offset] = data;
3426
3427   switch(offset)
3428   {
3429   case 0x05:
3430//      if (data & 0xc8)
3431//          popmessage("053244 reg 05 = %02x",data);
3432      /* bit 2 = unknown, Parodius uses it */
3433      /* bit 5 = unknown, Rollergames uses it */
3434//      logerror("%s: write %02x to 053244 address 5\n", cpuexec_describe_context(device->machine), data);
3435      break;
3436
3437   case 0x06:
3438      k053245_update_buffer(device);
3439      break;
3440   }
3441}
3442
3443
3444READ16_DEVICE_HANDLER( k053244_lsb_r )
3445{
3446   return k053244_r(device, offset);
3447}
3448
3449WRITE16_DEVICE_HANDLER( k053244_lsb_w )
3450{
3451   if (ACCESSING_BITS_0_7)
3452      k053244_w(device, offset, data & 0xff);
3453}
3454
3455READ16_DEVICE_HANDLER( k053244_word_r )
3456{
3457   return (k053244_r(device, offset * 2) << 8) | k053244_r(device, offset * 2 + 1);
3458}
3459
3460WRITE16_DEVICE_HANDLER( k053244_word_w )
3461{
3462   if (ACCESSING_BITS_8_15)
3463      k053244_w(device, offset * 2, (data >> 8) & 0xff);
3464   if (ACCESSING_BITS_0_7)
3465      k053244_w(device, offset * 2 + 1, data & 0xff);
3466}
3467
3468void k053244_bankselect( const device_config *device, int bank )
3469{
3470   k05324x_state *k053244 = k05324x_get_safe_token(device);
3471   k053244->rombank = bank;
3472}
3473
3474/*
3475 * Sprite Format
3476 * ------------------
3477 *
3478 * Word | Bit(s)           | Use
3479 * -----+-fedcba9876543210-+----------------
3480 *   0  | x--------------- | active (show this sprite)
3481 *   0  | -x-------------- | maintain aspect ratio (when set, zoom y acts on both axis)
3482 *   0  | --x------------- | flip y
3483 *   0  | ---x------------ | flip x
3484 *   0  | ----xxxx-------- | sprite size (see below)
3485 *   0  | ---------xxxxxxx | priority order
3486 *   1  | --xxxxxxxxxxxxxx | sprite code. We use an additional bit in TMNT2, but this is
3487 *                           probably not accurate (protection related so we can't verify)
3488 *   2  | ------xxxxxxxxxx | y position
3489 *   3  | ------xxxxxxxxxx | x position
3490 *   4  | xxxxxxxxxxxxxxxx | zoom y (0x40 = normal, <0x40 = enlarge, >0x40 = reduce)
3491 *   5  | xxxxxxxxxxxxxxxx | zoom x (0x40 = normal, <0x40 = enlarge, >0x40 = reduce)
3492 *   6  | ------x--------- | mirror y (top half is drawn as mirror image of the bottom)
3493 *   6  | -------x-------- | mirror x (right half is drawn as mirror image of the left)
3494 *   6  | --------x------- | shadow
3495 *   6  | ---------xxxxxxx | "color", but depends on external connections
3496 *   7  | ---------------- |
3497 *
3498 * shadow enables transparent shadows. Note that it applies to pen 0x0f ONLY.
3499 * The rest of the sprite remains normal.
3500 */
3501
3502void k053245_sprites_draw( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect )
3503{
3504#define NUM_SPRITES 128
3505   k05324x_state *k053245 = k05324x_get_safe_token(device);
3506   running_machine *machine = device->machine;
3507   int offs, pri_code, i;
3508   int sortedlist[NUM_SPRITES];
3509   int flipscreenX, flipscreenY, spriteoffsX, spriteoffsY;
3510   UINT8 drawmode_table[256];
3511
3512   memset(drawmode_table, DRAWMODE_SOURCE, sizeof(drawmode_table));
3513   drawmode_table[0] = DRAWMODE_NONE;
3514
3515   flipscreenX = k053245->regs[5] & 0x01;
3516   flipscreenY = k053245->regs[5] & 0x02;
3517   spriteoffsX = (k053245->regs[0] << 8) | k053245->regs[1];
3518   spriteoffsY = (k053245->regs[2] << 8) | k053245->regs[3];
3519
3520   for (offs = 0; offs < NUM_SPRITES; offs++)
3521      sortedlist[offs] = -1;
3522
3523   /* prebuild a sorted table */
3524   for (i = k053245->ramsize / 2, offs = 0; offs < i; offs += 8)
3525   {
3526      pri_code = k053245->buffer[offs];
3527      if (pri_code & 0x8000)
3528      {
3529         pri_code &= 0x007f;
3530
3531         if (offs && pri_code == k053245->z_rejection)
3532            continue;
3533
3534         if (sortedlist[pri_code] == -1)
3535            sortedlist[pri_code] = offs;
3536      }
3537   }
3538
3539   for (pri_code = NUM_SPRITES - 1; pri_code >= 0; pri_code--)
3540   {
3541      int ox, oy, color, code, size, w, h, x, y, flipx, flipy, mirrorx, mirrory, shadow, zoomx, zoomy, pri;
3542
3543      offs = sortedlist[pri_code];
3544      if (offs == -1)
3545         continue;
3546
3547      /* the following changes the sprite draw order from
3548             0  1  4  5 16 17 20 21
3549             2  3  6  7 18 19 22 23
3550             8  9 12 13 24 25 28 29
3551            10 11 14 15 26 27 30 31
3552            32 33 36 37 48 49 52 53
3553            34 35 38 39 50 51 54 55
3554            40 41 44 45 56 57 60 61
3555            42 43 46 47 58 59 62 63
3556
3557            to
3558
3559             0  1  2  3  4  5  6  7
3560             8  9 10 11 12 13 14 15
3561            16 17 18 19 20 21 22 23
3562            24 25 26 27 28 29 30 31
3563            32 33 34 35 36 37 38 39
3564            40 41 42 43 44 45 46 47
3565            48 49 50 51 52 53 54 55
3566            56 57 58 59 60 61 62 63
3567        */
3568
3569      /* NOTE: from the schematics, it looks like the top 2 bits should be ignored */
3570      /* (there are not output pins for them), and probably taken from the "color" */
3571      /* field to do bank switching. However this applies only to TMNT2, with its */
3572      /* protection mcu creating the sprite table, so we don't know where to fetch */
3573      /* the bits from. */
3574      code = k053245->buffer[offs + 1];
3575      code = ((code & 0xffe1) + ((code & 0x0010) >> 2) + ((code & 0x0008) << 1)
3576             + ((code & 0x0004) >> 1) + ((code & 0x0002) << 2));
3577      color = k053245->buffer[offs + 6] & 0x00ff;
3578      pri = 0;
3579
3580      k053245->callback(device->machine, &code, &color, &pri);
3581
3582      size = (k053245->buffer[offs] & 0x0f00) >> 8;
3583
3584      w = 1 << (size & 0x03);
3585      h = 1 << ((size >> 2) & 0x03);
3586
3587      /* zoom control:
3588           0x40 = normal scale
3589          <0x40 enlarge (0x20 = double size)
3590          >0x40 reduce (0x80 = half size)
3591        */
3592      zoomy = k053245->buffer[offs + 4];
3593      if (zoomy > 0x2000)
3594         continue;
3595
3596      if (zoomy)
3597         zoomy = (0x400000 + zoomy / 2) / zoomy;
3598      else
3599         zoomy = 2 * 0x400000;
3600      if ((k053245->buffer[offs] & 0x4000) == 0)
3601      {
3602         zoomx = k053245->buffer[offs + 5];
3603         if (zoomx > 0x2000)
3604            continue;
3605         if (zoomx)
3606            zoomx = (0x400000 + zoomx / 2) / zoomx;
3607         else
3608            zoomx = 2 * 0x400000;
3609//          else zoomx = zoomy; /* workaround for TMNT2 */
3610      }
3611      else
3612         zoomx = zoomy;
3613
3614      ox = k053245->buffer[offs+3] + spriteoffsX;
3615      oy = k053245->buffer[offs+2];
3616
3617      ox += k053245->dx;
3618      oy += k053245->dy;
3619
3620      flipx = k053245->buffer[offs] & 0x1000;
3621      flipy = k053245->buffer[offs] & 0x2000;
3622      mirrorx = k053245->buffer[offs + 6] & 0x0100;
3623      if (mirrorx)
3624         flipx = 0; // documented and confirmed
3625
3626      mirrory = k053245->buffer[offs + 6] & 0x0200;
3627      shadow = k053245->buffer[offs + 6] & 0x0080;
3628
3629      if (flipscreenX)
3630      {
3631         ox = 512 - ox;
3632         if (!mirrorx)
3633            flipx = !flipx;
3634      }
3635      if (flipscreenY)
3636      {
3637         oy = -oy;
3638         if (!mirrory)
3639            flipy = !flipy;
3640      }
3641
3642      ox = (ox + 0x5d) & 0x3ff;
3643      if (ox >= 768) ox -= 1024;
3644      oy = (-(oy + spriteoffsY + 0x07)) & 0x3ff;
3645      if (oy >= 640) oy -= 1024;
3646
3647      /* the coordinates given are for the *center* of the sprite */
3648      ox -= (zoomx * w) >> 13;
3649      oy -= (zoomy * h) >> 13;
3650
3651      drawmode_table[k053245->gfx->color_granularity - 1] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
3652
3653      for (y = 0; y < h; y++)
3654      {
3655         int sx, sy, zw, zh;
3656
3657         sy = oy + ((zoomy * y + (1 << 11)) >> 12);
3658         zh = (oy + ((zoomy * (y + 1) + (1 << 11)) >> 12)) - sy;
3659
3660         for (x = 0; x < w; x++)
3661         {
3662            int c, fx, fy;
3663
3664            sx = ox + ((zoomx * x + (1 << 11)) >> 12);
3665            zw = (ox + ((zoomx * (x+1) + (1 << 11)) >> 12)) - sx;
3666            c = code;
3667            if (mirrorx)
3668            {
3669               if ((flipx == 0) ^ (2*x < w))
3670               {
3671                  /* mirror left/right */
3672                  c += (w - x - 1);
3673                  fx = 1;
3674               }
3675               else
3676               {
3677                  c += x;
3678                  fx = 0;
3679               }
3680            }
3681            else
3682            {
3683               if (flipx) c += w-1-x;
3684               else c += x;
3685               fx = flipx;
3686            }
3687            if (mirrory)
3688            {
3689               if ((flipy == 0) ^ (2*y >= h))
3690               {
3691                  /* mirror top/bottom */
3692                  c += 8 * (h - y - 1);
3693                  fy = 1;
3694               }
3695               else
3696               {
3697                  c += 8 * y;
3698                  fy = 0;
3699               }
3700            }
3701            else
3702            {
3703               if (flipy) c += 8 * (h - 1 - y);
3704               else c += 8 * y;
3705               fy = flipy;
3706            }
3707
3708            /* the sprite can start at any point in the 8x8 grid, but it must stay */
3709            /* in a 64 entries window, wrapping around at the edges. The animation */
3710            /* at the end of the saloon level in Sunset Riders breaks otherwise. */
3711            c = (c & 0x3f) | (code & ~0x3f);
3712
3713            if (zoomx == 0x10000 && zoomy == 0x10000)
3714            {
3715               pdrawgfx_transtable(bitmap,cliprect,k053245->gfx,
3716                     c,
3717                     color,
3718                     fx,fy,
3719                     sx,sy,
3720                     machine->priority_bitmap,pri,
3721                     drawmode_table,machine->shadow_table);
3722            }
3723            else
3724            {
3725               pdrawgfxzoom_transtable(bitmap,cliprect,k053245->gfx,
3726                     c,
3727                     color,
3728                     fx,fy,
3729                     sx,sy,
3730                     (zw << 16) / 16,(zh << 16) / 16,
3731                     machine->priority_bitmap,pri,
3732                     drawmode_table,machine->shadow_table);
3733
3734            }
3735         }
3736      }
3737   }
3738#if 0
3739if (input_code_pressed(machine, KEYCODE_D))
3740{
3741   FILE *fp;
3742   fp=fopen("SPRITE.DMP", "w+b");
3743   if (fp)
3744   {
3745      fwrite(k053245->buffer, 0x800, 1, fp);
3746      popmessage("saved");
3747      fclose(fp);
3748   }
3749}
3750#endif
3751#undef NUM_SPRITES
3752}
3753
3754/* Lethal Enforcers has 2 of these chips hooked up in parallel to give 6bpp gfx.. lets cheat a
3755  bit and make emulating it a little less messy by using a custom function instead */
3756void k053245_sprites_draw_lethal( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect )
3757{
3758#define NUM_SPRITES 128
3759   k05324x_state *k053245 = k05324x_get_safe_token(device);
3760   int offs, pri_code, i;
3761   int sortedlist[NUM_SPRITES];
3762   int flipscreenX, flipscreenY, spriteoffsX, spriteoffsY;
3763   UINT8 drawmode_table[256];
3764   running_machine *machine = device->machine;
3765
3766   memset(drawmode_table, DRAWMODE_SOURCE, sizeof(drawmode_table));
3767   drawmode_table[0] = DRAWMODE_NONE;
3768
3769   flipscreenX = k053245->regs[5] & 0x01;
3770   flipscreenY = k053245->regs[5] & 0x02;
3771   spriteoffsX = (k053245->regs[0] << 8) | k053245->regs[1];
3772   spriteoffsY = (k053245->regs[2] << 8) | k053245->regs[3];
3773
3774   for (offs = 0; offs < NUM_SPRITES; offs++)
3775      sortedlist[offs] = -1;
3776
3777   /* prebuild a sorted table */
3778   for (i = k053245->ramsize / 2, offs = 0; offs < i; offs += 8)
3779   {
3780      pri_code = k053245->buffer[offs];
3781      if (pri_code & 0x8000)
3782      {
3783         pri_code &= 0x007f;
3784
3785         if (offs && pri_code == k053245->z_rejection)
3786            continue;
3787
3788         if (sortedlist[pri_code] == -1)
3789            sortedlist[pri_code] = offs;
3790      }
3791   }
3792
3793   for (pri_code = NUM_SPRITES - 1; pri_code >= 0; pri_code--)
3794   {
3795      int ox, oy, color, code, size, w, h, x, y, flipx, flipy, mirrorx, mirrory, shadow, zoomx, zoomy, pri;
3796
3797      offs = sortedlist[pri_code];
3798      if (offs == -1)
3799         continue;
3800
3801      /* the following changes the sprite draw order from
3802             0  1  4  5 16 17 20 21
3803             2  3  6  7 18 19 22 23
3804             8  9 12 13 24 25 28 29
3805            10 11 14 15 26 27 30 31
3806            32 33 36 37 48 49 52 53
3807            34 35 38 39 50 51 54 55
3808            40 41 44 45 56 57 60 61
3809            42 43 46 47 58 59 62 63
3810
3811            to
3812
3813             0  1  2  3  4  5  6  7
3814             8  9 10 11 12 13 14 15
3815            16 17 18 19 20 21 22 23
3816            24 25 26 27 28 29 30 31
3817            32 33 34 35 36 37 38 39
3818            40 41 42 43 44 45 46 47
3819            48 49 50 51 52 53 54 55
3820            56 57 58 59 60 61 62 63
3821        */
3822
3823      /* NOTE: from the schematics, it looks like the top 2 bits should be ignored */
3824      /* (there are not output pins for them), and probably taken from the "color" */
3825      /* field to do bank switching. However this applies only to TMNT2, with its */
3826      /* protection mcu creating the sprite table, so we don't know where to fetch */
3827      /* the bits from. */
3828      code = k053245->buffer[offs + 1];
3829      code = ((code & 0xffe1) + ((code & 0x0010) >> 2) + ((code & 0x0008) << 1)
3830             + ((code & 0x0004) >> 1) + ((code & 0x0002) << 2));
3831      color = k053245->buffer[offs + 6] & 0x00ff;
3832      pri = 0;
3833
3834      k053245->callback(device->machine, &code, &color, &pri);
3835
3836      size = (k053245->buffer[offs] & 0x0f00) >> 8;
3837
3838      w = 1 << (size & 0x03);
3839      h = 1 << ((size >> 2) & 0x03);
3840
3841      /* zoom control:
3842           0x40 = normal scale
3843          <0x40 enlarge (0x20 = double size)
3844          >0x40 reduce (0x80 = half size)
3845        */
3846      zoomy = k053245->buffer[offs + 4];
3847      if (zoomy > 0x2000)
3848         continue;
3849      if (zoomy)
3850         zoomy = (0x400000 + zoomy / 2) / zoomy;
3851      else
3852         zoomy = 2 * 0x400000;
3853      if ((k053245->buffer[offs] & 0x4000) == 0)
3854      {
3855         zoomx = k053245->buffer[offs + 5];
3856         if (zoomx > 0x2000)
3857            continue;
3858         if (zoomx)
3859            zoomx = (0x400000 + zoomx / 2) / zoomx;
3860         else
3861            zoomx = 2 * 0x400000;
3862//          else zoomx = zoomy; /* workaround for TMNT2 */
3863      }
3864      else
3865         zoomx = zoomy;
3866
3867      ox = k053245->buffer[offs + 3] + spriteoffsX;
3868      oy = k053245->buffer[offs + 2];
3869
3870      ox += k053245->dx;
3871      oy += k053245->dy;
3872
3873      flipx = k053245->buffer[offs] & 0x1000;
3874      flipy = k053245->buffer[offs] & 0x2000;
3875      mirrorx = k053245->buffer[offs + 6] & 0x0100;
3876      if (mirrorx)
3877         flipx = 0; // documented and confirmed
3878      mirrory = k053245->buffer[offs + 6] & 0x0200;
3879      shadow = k053245->buffer[offs + 6] & 0x0080;
3880
3881      if (flipscreenX)
3882      {
3883         ox = 512 - ox;
3884         if (!mirrorx) flipx = !flipx;
3885      }
3886      if (flipscreenY)
3887      {
3888         oy = -oy;
3889         if (!mirrory) flipy = !flipy;
3890      }
3891
3892      ox = (ox + 0x5d) & 0x3ff;
3893      if (ox >= 768) ox -= 1024;
3894      oy = (-(oy + spriteoffsY + 0x07)) & 0x3ff;
3895      if (oy >= 640) oy -= 1024;
3896
3897      /* the coordinates given are for the *center* of the sprite */
3898      ox -= (zoomx * w) >> 13;
3899      oy -= (zoomy * h) >> 13;
3900
3901      drawmode_table[machine->gfx[0]->color_granularity - 1] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
3902
3903      for (y = 0; y < h; y++)
3904      {
3905         int sx, sy, zw, zh;
3906
3907         sy = oy + ((zoomy * y + (1<<11)) >> 12);
3908         zh = (oy + ((zoomy * (y+1) + (1<<11)) >> 12)) - sy;
3909
3910         for (x = 0; x < w; x++)
3911         {
3912            int c, fx, fy;
3913
3914            sx = ox + ((zoomx * x + (1 << 11)) >> 12);
3915            zw = (ox + ((zoomx * (x+1) + (1 << 11)) >> 12)) - sx;
3916            c = code;
3917            if (mirrorx)
3918            {
3919               if ((flipx == 0) ^ (2 * x < w))
3920               {
3921                  /* mirror left/right */
3922                  c += (w - x - 1);
3923                  fx = 1;
3924               }
3925               else
3926               {
3927                  c += x;
3928                  fx = 0;
3929               }
3930            }
3931            else
3932            {
3933               if (flipx) c += w-1-x;
3934               else c += x;
3935               fx = flipx;
3936            }
3937            if (mirrory)
3938            {
3939               if ((flipy == 0) ^ (2 * y >= h))
3940               {
3941                  /* mirror top/bottom */
3942                  c += 8 * (h - y - 1);
3943                  fy = 1;
3944               }
3945               else
3946               {
3947                  c += 8 * y;
3948                  fy = 0;
3949               }
3950            }
3951            else
3952            {
3953               if (flipy) c += 8 * (h - 1 - y);
3954               else c += 8 * y;
3955               fy = flipy;
3956            }
3957
3958            /* the sprite can start at any point in the 8x8 grid, but it must stay */
3959            /* in a 64 entries window, wrapping around at the edges. The animation */
3960            /* at the end of the saloon level in Sunset Riders breaks otherwise. */
3961            c = (c & 0x3f) | (code & ~0x3f);
3962
3963            if (zoomx == 0x10000 && zoomy == 0x10000)
3964            {
3965               pdrawgfx_transtable(bitmap,cliprect,machine->gfx[0], /* hardcoded to 0 (decoded 6bpp gfx) for le */
3966                     c,
3967                     color,
3968                     fx,fy,
3969                     sx,sy,
3970                     machine->priority_bitmap,pri,
3971                     drawmode_table,machine->shadow_table);
3972            }
3973            else
3974            {
3975               pdrawgfxzoom_transtable(bitmap,cliprect,machine->gfx[0],  /* hardcoded to 0 (decoded 6bpp gfx) for le */
3976                     c,
3977                     color,
3978                     fx,fy,
3979                     sx,sy,
3980                     (zw << 16) / 16,(zh << 16) / 16,
3981                     machine->priority_bitmap,pri,
3982                     drawmode_table,machine->shadow_table);
3983
3984            }
3985         }
3986      }
3987   }
3988#if 0
3989if (input_code_pressed(machine, KEYCODE_D))
3990{
3991   FILE *fp;
3992   fp=fopen("SPRITE.DMP", "w+b");
3993   if (fp)
3994   {
3995      fwrite(k053245->buffer, 0x800, 1, fp);
3996      popmessage("saved");
3997      fclose(fp);
3998   }
3999}
4000#endif
4001#undef NUM_SPRITES
4002}
4003
4004
4005/*****************************************************************************
4006    DEVICE INTERFACE
4007*****************************************************************************/
4008
4009static DEVICE_START( k05324x )
4010{
4011   k05324x_state *k05324x = k05324x_get_safe_token(device);
4012   const k05324x_interface *intf = k05324x_get_interface(device);
4013   running_machine *machine = device->machine;
4014   UINT32 total;
4015   static const gfx_layout spritelayout =
4016   {
4017      16,16,
4018      0,
4019      4,
4020        { 24, 16, 8, 0 },
4021      { 0, 1, 2, 3, 4, 5, 6, 7,
4022            8*32+0, 8*32+1, 8*32+2, 8*32+3, 8*32+4, 8*32+5, 8*32+6, 8*32+7 },
4023      { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
4024            16*32, 17*32, 18*32, 19*32, 20*32, 21*32, 22*32, 23*32 },
4025      128*8
4026   };
4027
4028   /* decode the graphics */
4029   switch (intf->plane_order)
4030   {
4031   case NORMAL_PLANE_ORDER:
4032      total = memory_region_length(machine, intf->gfx_memory_region) / 128;
4033      decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &spritelayout, 4);
4034      break;
4035
4036   default:
4037      fatalerror("Unsupported plane_order");
4038   }
4039
4040   if (VERBOSE && !(machine->config->video_attributes & VIDEO_HAS_SHADOWS))
4041      popmessage("driver should use VIDEO_HAS_SHADOWS");
4042
4043   /* deinterleave the graphics, if needed */
4044   deinterleave_gfx(machine, intf->gfx_memory_region, intf->deinterleave);
4045
4046   k05324x->ramsize = 0x800;
4047
4048   k05324x->memory_region = intf->gfx_memory_region;
4049   k05324x->gfx = machine->gfx[intf->gfx_num];
4050   k05324x->dx = intf->dx;
4051   k05324x->dy = intf->dy;
4052   k05324x->callback = intf->callback;
4053   k05324x->ram = auto_alloc_array(machine, UINT16, k05324x->ramsize / 2);
4054
4055   k05324x->buffer = auto_alloc_array(machine, UINT16, k05324x->ramsize / 2);
4056
4057   state_save_register_device_item_pointer(device, 0, k05324x->ram, k05324x->ramsize / 2);
4058   state_save_register_device_item_pointer(device, 0, k05324x->buffer, k05324x->ramsize / 2);
4059   state_save_register_device_item(device, 0, k05324x->rombank);
4060   state_save_register_device_item(device, 0, k05324x->z_rejection);
4061   state_save_register_device_item_array(device, 0, k05324x->regs);
4062}
4063
4064static DEVICE_RESET( k05324x )
4065{
4066   k05324x_state *k05324x = k05324x_get_safe_token(device);
4067   int i;
4068
4069   k05324x->z_rejection = -1;
4070   k05324x->rombank = 0;
4071
4072   for (i = 0; i < 0x10; i++)
4073      k05324x->regs[i] = 0;
4074}
4075
4076/***************************************************************************/
4077/*                                                                         */
4078/*                                 053246/053247                           */
4079/*                                                                         */
4080/***************************************************************************/
4081
4082typedef struct _k053247_state k053247_state;
4083struct _k053247_state
4084{
4085   UINT16    *ram;
4086
4087   gfx_element *gfx;
4088
4089   UINT8    Kx46_regs[8];
4090   UINT16   Kx47_regs[16];
4091   int      dx, dy, wraparound;
4092   UINT8    objcha_line;
4093   int      z_rejection;
4094
4095   k05324x_callback callback;
4096
4097   const char *memory_region;
4098   const device_config *screen;
4099};
4100
4101
4102
4103/*****************************************************************************
4104    INLINE FUNCTIONS
4105*****************************************************************************/
4106
4107INLINE k053247_state *k053247_get_safe_token( const device_config *device )
4108{
4109   assert(device != NULL);
4110   assert(device->token != NULL);
4111   assert((device->type == K053246 || device->type == K053247 || device->type == K055673));
4112
4113   return (k053247_state *)device->token;
4114}
4115
4116INLINE const k053247_interface *k053247_get_interface( const device_config *device )
4117{
4118   assert(device != NULL);
4119   assert((device->type == K053246 || device->type == K053247 || device->type == K055673));
4120   return (const k053247_interface *) device->static_config;
4121}
4122
4123/*****************************************************************************
4124    DEVICE HANDLERS
4125*****************************************************************************/
4126
4127#if 0
4128void k053247_get_gfx( const device_config *device, gfx_element **gfx )
4129{
4130   k053247_state *k053247 = k053247_get_safe_token(device);
4131   *gfx = k053247->gfx;
4132}
4133
4134void k053247_get_cb( const device_config *device, void (**callback)(int *, int *, int *) )
4135{
4136   k053247_state *k053247 = k053247_get_safe_token(device);
4137   *callback = k053247->callback;
4138}
4139
4140#endif
4141
4142void k053247_get_ram( const device_config *device, UINT16 **ram )
4143{
4144   k053247_state *k053247 = k053247_get_safe_token(device);
4145   *ram = k053247->ram;
4146}
4147
4148int k053247_get_dx( const device_config *device )
4149{
4150   k053247_state *k053247 = k053247_get_safe_token(device);
4151   return k053247->dx;
4152}
4153
4154int k053247_get_dy( const device_config *device )
4155{
4156   k053247_state *k053247 = k053247_get_safe_token(device);
4157   return k053247->dy;
4158}
4159
4160int k053246_read_register( const device_config *device, int regnum )
4161{
4162   k053247_state *k053247 = k053247_get_safe_token(device);
4163   return(k053247->Kx46_regs[regnum]);
4164}
4165
4166int k053247_read_register( const device_config *device, int regnum )
4167{
4168   k053247_state *k053247 = k053247_get_safe_token(device);
4169   return(k053247->Kx47_regs[regnum]);
4170}
4171
4172void k053247_set_sprite_offs( const device_config *device, int offsx, int offsy )
4173{
4174   k053247_state *k053247 = k053247_get_safe_token(device);
4175   k053247->dx = offsx;
4176   k053247->dy = offsy;
4177}
4178
4179void k053247_wraparound_enable( const device_config *device, int status )
4180{
4181   k053247_state *k053247 = k053247_get_safe_token(device);
4182   k053247->wraparound = status;
4183}
4184
4185WRITE16_DEVICE_HANDLER( k053247_reg_word_w ) // write-only OBJSET2 registers (see p.43 table 6.1)
4186{
4187   k053247_state *k053247 = k053247_get_safe_token(device);
4188   COMBINE_DATA(k053247->Kx47_regs + offset);
4189}
4190
4191WRITE32_DEVICE_HANDLER( k053247_reg_long_w )
4192{
4193   k053247_state *k053247 = k053247_get_safe_token(device);
4194   offset <<= 1;
4195   COMBINE_DATA(k053247->Kx47_regs + offset + 1);
4196   mem_mask >>= 16;
4197   data >>= 16;
4198   COMBINE_DATA(k053247->Kx47_regs + offset);
4199}
4200
4201READ16_DEVICE_HANDLER( k053247_word_r )
4202{
4203   k053247_state *k053247 = k053247_get_safe_token(device);
4204   return k053247->ram[offset];
4205}
4206
4207WRITE16_DEVICE_HANDLER( k053247_word_w )
4208{
4209   k053247_state *k053247 = k053247_get_safe_token(device);
4210   COMBINE_DATA(k053247->ram + offset);
4211}
4212
4213READ32_DEVICE_HANDLER( k053247_long_r )
4214{
4215   k053247_state *k053247 = k053247_get_safe_token(device);
4216   return k053247->ram[offset * 2 + 1] | (k053247->ram[offset * 2] << 16);
4217}
4218
4219WRITE32_DEVICE_HANDLER( k053247_long_w )
4220{
4221   k053247_state *k053247 = k053247_get_safe_token(device);
4222   offset <<= 1;
4223   COMBINE_DATA(k053247->ram + offset + 1);
4224   mem_mask >>= 16;
4225   data >>= 16;
4226   COMBINE_DATA(k053247->ram + offset);
4227}
4228
4229READ8_DEVICE_HANDLER( k053247_r )
4230{
4231   k053247_state *k053247 = k053247_get_safe_token(device);
4232   int offs = offset >> 1;
4233
4234   if (offset & 1)
4235      return(k053247->ram[offs] & 0xff);
4236   else
4237      return(k053247->ram[offs] >> 8);
4238}
4239
4240WRITE8_DEVICE_HANDLER( k053247_w )
4241{
4242   k053247_state *k053247 = k053247_get_safe_token(device);
4243   int offs = offset >> 1;
4244
4245   if (offset & 1)
4246      k053247->ram[offs] = (k053247->ram[offs] & 0xff00) | data;
4247   else
4248      k053247->ram[offs] = (k053247->ram[offs] & 0x00ff) | (data << 8);
4249}
4250
4251// Mystic Warriors hardware games support a non-objcha based ROM readback
4252// write the address to the 246 as usual, but there's a completely separate ROM
4253// window that works without needing an objcha line.
4254// in this window, +0 = 32 bits from one set of ROMs, and +8 = 32 bits from another set
4255READ16_DEVICE_HANDLER( k055673_rom_word_r )   // 5bpp
4256{
4257   k053247_state *k053246 = k053247_get_safe_token(device);
4258   UINT8 *ROM8 = (UINT8 *)memory_region(device->machine, k053246->memory_region);
4259   UINT16 *ROM = (UINT16 *)memory_region(device->machine, k053246->memory_region);
4260   int size4 = (memory_region_length(device->machine, k053246->memory_region) / (1024 * 1024)) / 5;
4261   int romofs;
4262
4263   size4 *= 4 * 1024 * 1024;   // get offset to 5th bit
4264   ROM8 += size4;
4265
4266   romofs = k053246->Kx46_regs[6] << 16 | k053246->Kx46_regs[7] << 8 | k053246->Kx46_regs[4];
4267
4268   switch (offset)
4269   {
4270      case 0:   // 20k / 36u
4271         return ROM[romofs + 2];
4272      case 1:   // 17k / 36y
4273         return ROM[romofs + 3];
4274      case 2: // 10k / 32y
4275      case 3:
4276         romofs /= 2;
4277         return ROM8[romofs + 1];
4278      case 4:   // 22k / 34u
4279         return ROM[romofs];
4280      case 5:   // 19k / 34y
4281         return ROM[romofs + 1];
4282      case 6:   // 12k / 29y
4283      case 7:
4284         romofs /= 2;
4285         return ROM8[romofs];
4286      default:
4287         LOG(("55673_rom_word_r: Unknown read offset %x\n", offset));
4288         break;
4289   }
4290
4291   return 0;
4292}
4293
4294READ16_DEVICE_HANDLER( k055673_GX6bpp_rom_word_r )
4295{
4296   k053247_state *k053246 = k053247_get_safe_token(device);
4297   UINT16 *ROM = (UINT16 *)memory_region(device->machine, k053246->memory_region);
4298   int romofs;
4299
4300   romofs = k053246->Kx46_regs[6] << 16 | k053246->Kx46_regs[7] << 8 | k053246->Kx46_regs[4];
4301
4302   romofs /= 4;   // romofs increments 4 at a time
4303   romofs *= 12 / 2;   // each increment of romofs = 12 new bytes (6 new words)
4304
4305   switch (offset)
4306   {
4307      case 0:
4308         return ROM[romofs + 3];
4309      case 1:
4310         return ROM[romofs + 4];
4311      case 2:
4312      case 3:
4313         return ROM[romofs + 5];
4314      case 4:
4315         return ROM[romofs];
4316      case 5:
4317         return ROM[romofs + 1];
4318      case 6:
4319      case 7:
4320         return ROM[romofs + 2];
4321      default:
4322//          LOG(("55673_rom_word_r: Unknown read offset %x (PC=%x)\n", offset, cpu_get_pc(space->cpu)));
4323         break;
4324   }
4325
4326   return 0;
4327}
4328
4329READ8_DEVICE_HANDLER( k053246_r )
4330{
4331   k053247_state *k053246 = k053247_get_safe_token(device);
4332   if (k053246->objcha_line == ASSERT_LINE)
4333   {
4334      int addr;
4335
4336      addr = (k053246->Kx46_regs[6] << 17) | (k053246->Kx46_regs[7] << 9) | (k053246->Kx46_regs[4] << 1) | ((offset & 1) ^ 1);
4337      addr &= memory_region_length(device->machine, k053246->memory_region) - 1;
4338//      if (VERBOSE)
4339//          popmessage("%04x: offset %02x addr %06x", cpu_get_pc(space->cpu), offset, addr);
4340      return memory_region(device->machine, k053246->memory_region)[addr];
4341   }
4342   else
4343   {
4344//      LOG(("%04x: read from unknown 053246 address %x\n", cpu_get_pc(space->cpu), offset));
4345      return 0;
4346   }
4347}
4348
4349WRITE8_DEVICE_HANDLER( k053246_w )
4350{
4351   k053247_state *k053247 = k053247_get_safe_token(device);
4352   k053247->Kx46_regs[offset] = data;
4353}
4354
4355READ16_DEVICE_HANDLER( k053246_word_r )
4356{
4357   offset <<= 1;
4358   return k053246_r(device, offset + 1) | (k053246_r(device, offset) << 8);
4359}
4360
4361WRITE16_DEVICE_HANDLER( k053246_word_w )
4362{
4363   if (ACCESSING_BITS_8_15)
4364      k053246_w(device, offset << 1,(data >> 8) & 0xff);
4365   if (ACCESSING_BITS_0_7)
4366      k053246_w(device, (offset << 1) + 1,data & 0xff);
4367}
4368
4369READ32_DEVICE_HANDLER( k053246_long_r )
4370{
4371   offset <<= 1;
4372   return (k053246_word_r(device, offset + 1, 0xffff) | k053246_word_r(device, offset, 0xffff) << 16);
4373}
4374
4375WRITE32_DEVICE_HANDLER( k053246_long_w )
4376{
4377   offset <<= 1;
4378   k053246_word_w(device, offset, data >> 16, mem_mask >> 16);
4379   k053246_word_w(device, offset + 1, data, mem_mask);
4380}
4381
4382void k053246_set_objcha_line( const device_config *device, int state )
4383{
4384   k053247_state *k053246 = k053247_get_safe_token(device);
4385   k053246->objcha_line = state;
4386}
4387
4388int k053246_is_irq_enabled( const device_config *device )
4389{
4390   k053247_state *k053247 = k053247_get_safe_token(device);
4391   // This bit enables obj DMA rather than obj IRQ even though the two functions usually coincide.
4392   return k053247->Kx46_regs[5] & 0x10;
4393}
4394
4395/*
4396 * Sprite Format
4397 * ------------------
4398 *
4399 * Word | Bit(s)           | Use
4400 * -----+-fedcba9876543210-+----------------
4401 *   0  | x--------------- | active (show this sprite)
4402 *   0  | -x-------------- | maintain aspect ratio (when set, zoom y acts on both axis)
4403 *   0  | --x------------- | flip y
4404 *   0  | ---x------------ | flip x
4405 *   0  | ----xxxx-------- | sprite size (see below)
4406 *   0  | --------xxxxxxxx | zcode
4407 *   1  | xxxxxxxxxxxxxxxx | sprite code
4408 *   2  | ------xxxxxxxxxx | y position
4409 *   3  | ------xxxxxxxxxx | x position
4410 *   4  | xxxxxxxxxxxxxxxx | zoom y (0x40 = normal, <0x40 = enlarge, >0x40 = reduce)
4411 *   5  | xxxxxxxxxxxxxxxx | zoom x (0x40 = normal, <0x40 = enlarge, >0x40 = reduce)
4412 *   6  | x--------------- | mirror y (top half is drawn as mirror image of the bottom)
4413 *   6  | -x-------------- | mirror x (right half is drawn as mirror image of the left)
4414 *   6  | --xx------------ | reserved (sprites with these two bits set don't seem to be graphics data at all)
4415 *   6  | ----xx---------- | shadow code: 0=off, 0x400=preset1, 0x800=preset2, 0xc00=preset3
4416 *   6  | ------xx-------- | effect code: flicker, upper palette, full shadow...etc. (game dependent)
4417 *   6  | --------xxxxxxxx | "color", but depends on external connections (implies priority)
4418 *   7  | xxxxxxxxxxxxxxxx | game dependent
4419 *
4420 * shadow enables transparent shadows. Note that it applies to the last sprite pen ONLY.
4421 * The rest of the sprite remains normal.
4422 */
4423
4424void k053247_sprites_draw( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect )
4425{
4426#define NUM_SPRITES 256
4427   k053247_state *k053246 = k053247_get_safe_token(device);
4428   running_machine *machine = device->machine;
4429
4430   /* sprites can be grouped up to 8x8. The draw order is
4431         0  1  4  5 16 17 20 21
4432         2  3  6  7 18 19 22 23
4433         8  9 12 13 24 25 28 29
4434        10 11 14 15 26 27 30 31
4435        32 33 36 37 48 49 52 53
4436        34 35 38 39 50 51 54 55
4437        40 41 44 45 56 57 60 61
4438        42 43 46 47 58 59 62 63
4439    */
4440   static const int xoffset[8] = { 0, 1, 4, 5, 16, 17, 20, 21 };
4441   static const int yoffset[8] = { 0, 2, 8, 10, 32, 34, 40, 42 };
4442
4443   int sortedlist[NUM_SPRITES];
4444   int offs,zcode;
4445   int ox, oy, color, code, size, w, h, x, y, xa, ya, flipx, flipy, mirrorx, mirrory, shadow, zoomx, zoomy, primask;
4446   int shdmask, nozoom, count, temp;
4447
4448   int flipscreenx = k053246->Kx46_regs[5] & 0x01;
4449   int flipscreeny = k053246->Kx46_regs[5] & 0x02;
4450   int offx = (short)((k053246->Kx46_regs[0] << 8) | k053246->Kx46_regs[1]);
4451   int offy = (short)((k053246->Kx46_regs[2] << 8) | k053246->Kx46_regs[3]);
4452
4453   int screen_width = video_screen_get_width(k053246->screen);
4454   UINT8 drawmode_table[256];
4455   UINT8 shadowmode_table[256];
4456   UINT8 *whichtable;
4457
4458   memset(drawmode_table, DRAWMODE_SOURCE, sizeof(drawmode_table));
4459   drawmode_table[0] = DRAWMODE_NONE;
4460   memset(shadowmode_table, DRAWMODE_SHADOW, sizeof(shadowmode_table));
4461   shadowmode_table[0] = DRAWMODE_NONE;
4462
4463   /*
4464        safeguard older drivers missing any of the following video attributes:
4465
4466        VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS
4467    */
4468   if (machine->config->video_attributes & VIDEO_HAS_SHADOWS)
4469   {
4470      if (bitmap->bpp == 32 && (machine->config->video_attributes & VIDEO_HAS_HIGHLIGHTS))
4471         shdmask = 3; // enable all shadows and highlights
4472      else
4473         shdmask = 0; // enable default shadows
4474   }
4475   else
4476      shdmask = -1; // disable everything
4477
4478   /*
4479        The k053247 does not draw pixels on top of those with equal or smaller Z-values
4480        regardless of priority. Embedded shadows inherit Z-values from their host sprites
4481        but do not assume host priorities unless explicitly told. In other words shadows
4482        can have priorities different from that of normal pens in the same sprite,
4483        in addition to the ability of masking themselves from specific layers or pixels
4484        on the other sprites.
4485
4486        In front-to-back rendering, sprites cannot sandwich between alpha blended layers
4487        or the draw code will have to figure out the percentage opacities of what is on
4488        top and beneath each sprite pixel and blend the target accordingly. The process
4489        is overly demanding for realtime software and is thus another shortcoming of
4490        pdrawgfx and pixel based mixers. Even mahjong games with straight forward video
4491        subsystems are feeling the impact by which the girls cannot appear under
4492        translucent dialogue boxes.
4493
4494        These are a small part of the k053247's feature set but many games expect them
4495        to be the minimum compliances. The specification will undoubtedly require
4496        redesigning the priority system from the ground up. Drawgfx.c and tilemap.c must
4497        also undergo heavy facelifts but in the end the changes could hurt simpler games
4498        more than they help complex systems; therefore the new engine should remain
4499        completely stand alone and self-contained. Implementation details are being
4500        hammered down but too early to make propositions.
4501    */
4502
4503   // Prebuild a sorted table by descending Z-order.
4504   zcode = k053246->z_rejection;
4505   offs = count = 0;
4506
4507   if (zcode == -1)
4508   {
4509      for (; offs < 0x800; offs += 8)
4510         if (k053246->ram[offs] & 0x8000)
4511            sortedlist[count++] = offs;
4512   }
4513   else
4514   {
4515      for (; offs < 0x800; offs += 8)
4516         if ((k053246->ram[offs] & 0x8000) && ((k053246->ram[offs] & 0xff) != zcode))
4517            sortedlist[count++] = offs;
4518   }
4519
4520   w = count;
4521   count--;
4522   h = count;
4523
4524   if (!(k053246->Kx47_regs[0xc / 2] & 0x10))
4525   {
4526      // sort objects in decending order(smaller z closer) when OPSET PRI is clear
4527      for (y = 0; y < h; y++)
4528      {
4529         offs = sortedlist[y];
4530         zcode = k053246->ram[offs] & 0xff;
4531         for (x = y + 1; x < w; x++)
4532         {
4533            temp = sortedlist[x];
4534            code = k053246->ram[temp] & 0xff;
4535            if (zcode <= code)
4536            {
4537               zcode = code;
4538               sortedlist[x] = offs;
4539               sortedlist[y] = offs = temp;
4540            }
4541         }
4542      }
4543   }
4544   else
4545   {
4546      // sort objects in ascending order(bigger z closer) when OPSET PRI is set
4547      for (y = 0; y < h; y++)
4548      {
4549         offs = sortedlist[y];
4550         zcode = k053246->ram[offs] & 0xff;
4551         for (x = y + 1; x < w; x++)
4552         {
4553            temp = sortedlist[x];
4554            code = k053246->ram[temp] & 0xff;
4555            if (zcode >= code)
4556            {
4557               zcode = code;
4558               sortedlist[x] = offs;
4559               sortedlist[y] = offs = temp;
4560            }
4561         }
4562      }
4563   }
4564
4565   for (; count >= 0; count--)
4566   {
4567      offs = sortedlist[count];
4568
4569      code = k053246->ram[offs + 1];
4570      shadow = color = k053246->ram[offs + 6];
4571      primask = 0;
4572
4573      k053246->callback(device->machine, &code, &color, &primask);
4574
4575      temp = k053246->ram[offs];
4576
4577      size = (temp & 0x0f00) >> 8;
4578      w = 1 << (size & 0x03);
4579      h = 1 << ((size >> 2) & 0x03);
4580
4581      /* the sprite can start at any point in the 8x8 grid. We have to */
4582      /* adjust the offsets to draw it correctly. Simpsons does this all the time. */
4583      xa = 0;
4584      ya = 0;
4585      if (code & 0x01) xa += 1;
4586      if (code & 0x02) ya += 1;
4587      if (code & 0x04) xa += 2;
4588      if (code & 0x08) ya += 2;
4589      if (code & 0x10) xa += 4;
4590      if (code & 0x20) ya += 4;
4591      code &= ~0x3f;
4592
4593      oy = (short)k053246->ram[offs + 2];
4594      ox = (short)k053246->ram[offs + 3];
4595
4596      if (k053246->wraparound)
4597      {
4598         offx &= 0x3ff;
4599         offy &= 0x3ff;
4600         oy &= 0x3ff;
4601         ox &= 0x3ff;
4602      }
4603
4604      /* zoom control:
4605           0x40 = normal scale
4606          <0x40 enlarge (0x20 = double size)
4607          >0x40 reduce (0x80 = half size)
4608        */
4609      y = zoomy = k053246->ram[offs + 4] & 0x3ff;
4610      if (zoomy)
4611         zoomy = (0x400000 + (zoomy >> 1)) / zoomy;
4612      else
4613         zoomy = 0x800000;
4614
4615      if (!(temp & 0x4000))
4616      {
4617         x = zoomx = k053246->ram[offs + 5] & 0x3ff;
4618         if (zoomx)
4619            zoomx = (0x400000 + (zoomx >> 1)) / zoomx;
4620         else
4621            zoomx = 0x800000;
4622      }
4623      else
4624      {
4625         zoomx = zoomy;
4626         x = y;
4627      }
4628
4629// ************************************************************************************
4630//  for Escape Kids (GX975)
4631// ************************************************************************************
4632//    Escape Kids use 053246 #5 register's UNKNOWN Bit #5, #3 and #2.
4633//    Bit #5, #3, #2 always set "1".
4634//    Maybe, Bit #5 or #3 or #2 or combination means "FIX SPRITE WIDTH TO HALF" ?????
4635//    Below 7 lines supports this 053246's(???) function.
4636//    Don't rely on it, Please.  But, Escape Kids works correctly!
4637// ************************************************************************************
4638      if ( k053246->Kx46_regs[5] & 0x08 ) // Check only "Bit #3 is '1'?" (NOTE: good guess)
4639      {
4640         zoomx >>= 1;      // Fix sprite width to HALF size
4641         ox = (ox >> 1) + 1;   // Fix sprite draw position
4642         if (flipscreenx)
4643            ox += screen_width;
4644         nozoom = 0;
4645      }
4646      else
4647         nozoom = (x == 0x40 && y == 0x40);
4648
4649      flipx = temp & 0x1000;
4650      flipy = temp & 0x2000;
4651      mirrorx = shadow & 0x4000;
4652      if (mirrorx)
4653         flipx = 0; // documented and confirmed
4654      mirrory = shadow & 0x8000;
4655
4656      whichtable = drawmode_table;
4657      if (color == -1)
4658      {
4659         // drop the entire sprite to shadow unconditionally
4660         if (shdmask < 0) continue;
4661         color = 0;
4662         shadow = -1;
4663         whichtable = shadowmode_table;
4664         palette_set_shadow_mode(machine, 0);
4665      }
4666      else
4667      {
4668         if (shdmask >= 0)
4669         {
4670            shadow = (color & K053247_CUSTOMSHADOW) ? (color >> K053247_SHDSHIFT) : (shadow >> 10);
4671            if (shadow &= 3) palette_set_shadow_mode(machine, (shadow - 1) & shdmask);
4672         }
4673         else
4674            shadow = 0;
4675      }
4676
4677      color &= 0xffff; // strip attribute flags
4678
4679      if (flipscreenx)
4680      {
4681         ox = -ox;
4682         if (!mirrorx) flipx = !flipx;
4683      }
4684      if (flipscreeny)
4685      {
4686         oy = -oy;
4687         if (!mirrory) flipy = !flipy;
4688      }
4689
4690      // apply wrapping and global offsets
4691      if (k053246->wraparound)
4692      {
4693         ox = ( ox - offx) & 0x3ff;
4694         oy = (-oy - offy) & 0x3ff;
4695         if (ox >= 0x300) ox -= 0x400;
4696         if (oy >= 0x280) oy -= 0x400;
4697      }
4698      else
4699      {
4700         ox =  ox - offx;
4701         oy = -oy - offy;
4702      }
4703      ox += k053246->dx;
4704      oy -= k053246->dy;
4705
4706      // apply global and display window offsets
4707
4708      /* the coordinates given are for the *center* of the sprite */
4709      ox -= (zoomx * w) >> 13;
4710      oy -= (zoomy * h) >> 13;
4711
4712      drawmode_table[k053246->gfx->color_granularity - 1] = shadow ? DRAWMODE_SHADOW : DRAWMODE_SOURCE;
4713
4714      for (y = 0; y < h; y++)
4715      {
4716         int sx, sy, zw, zh;
4717
4718         sy = oy + ((zoomy * y + (1 << 11)) >> 12);
4719         zh = (oy + ((zoomy * (y + 1) + (1 << 11)) >> 12)) - sy;
4720
4721         for (x = 0; x < w; x++)
4722         {
4723            int c, fx, fy;
4724
4725            sx = ox + ((zoomx * x + (1 << 11)) >> 12);
4726            zw = (ox + ((zoomx * (x+1) + (1 << 11)) >> 12)) - sx;
4727            c = code;
4728            if (mirrorx)
4729            {
4730               if ((flipx == 0) ^ ((x << 1) < w))
4731               {
4732                  /* mirror left/right */
4733                  c += xoffset[(w - 1 - x + xa) & 7];
4734                  fx = 1;
4735               }
4736               else
4737               {
4738                  c += xoffset[(x + xa) & 7];
4739                  fx = 0;
4740               }
4741            }
4742            else
4743            {
4744               if (flipx) c += xoffset[(w - 1 - x + xa) & 7];
4745               else c += xoffset[(x + xa) & 7];
4746               fx = flipx;
4747            }
4748            if (mirrory)
4749            {
4750               if ((flipy == 0) ^ ((y<<1) >= h))
4751               {
4752                  /* mirror top/bottom */
4753                  c += yoffset[(h - 1 - y + ya) & 7];
4754                  fy = 1;
4755               }
4756               else
4757               {
4758                  c += yoffset[(y + ya) & 7];
4759                  fy = 0;
4760               }
4761            }
4762            else
4763            {
4764               if (flipy) c += yoffset[(h - 1 - y + ya) & 7];
4765               else c += yoffset[(y + ya) & 7];
4766               fy = flipy;
4767            }
4768
4769            if (nozoom)
4770            {
4771               pdrawgfx_transtable(bitmap,cliprect,k053246->gfx,
4772                     c,
4773                     color,
4774                     fx,fy,
4775                     sx,sy,
4776                     machine->priority_bitmap,primask,
4777                     whichtable,machine->shadow_table);
4778            }
4779            else
4780            {
4781               pdrawgfxzoom_transtable(bitmap,cliprect,k053246->gfx,
4782                     c,
4783                     color,
4784                     fx,fy,
4785                     sx,sy,
4786                     (zw << 16) >> 4,(zh << 16) >> 4,
4787                     machine->priority_bitmap,primask,
4788                     whichtable,machine->shadow_table);
4789            }
4790
4791            if (mirrory && h == 1)  /* Simpsons shadows */
4792            {
4793               if (nozoom)
4794               {
4795                  pdrawgfx_transtable(bitmap,cliprect,k053246->gfx,
4796                        c,
4797                        color,
4798                        fx,!fy,
4799                        sx,sy,
4800                        machine->priority_bitmap,primask,
4801                        whichtable,machine->shadow_table);
4802               }
4803               else
4804               {
4805                  pdrawgfxzoom_transtable(bitmap,cliprect,k053246->gfx,
4806                        c,
4807                        color,
4808                        fx,!fy,
4809                        sx,sy,
4810                        (zw << 16) >> 4,(zh << 16) >> 4,
4811                        machine->priority_bitmap,primask,
4812                        whichtable,machine->shadow_table);
4813               }
4814            }
4815         } // end of X loop
4816      } // end of Y loop
4817
4818   } // end of sprite-list loop
4819#undef NUM_SPRITES
4820}
4821
4822
4823/*****************************************************************************
4824    DEVICE INTERFACE
4825*****************************************************************************/
4826
4827static DEVICE_START( k053247 )
4828{
4829   k053247_state *k053247 = k053247_get_safe_token(device);
4830   const k053247_interface *intf = k053247_get_interface(device);
4831   running_machine *machine = device->machine;
4832   UINT32 total;
4833   static const gfx_layout spritelayout =
4834   {
4835      16,16,
4836      0,
4837      4,
4838      { 0, 1, 2, 3 },
4839      { 2*4, 3*4, 0*4, 1*4, 6*4, 7*4, 4*4, 5*4,
4840            10*4, 11*4, 8*4, 9*4, 14*4, 15*4, 12*4, 13*4 },
4841      { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64,
4842            8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 },
4843      128*8
4844   };
4845
4846   k053247->screen = devtag_get_device(device->machine, intf->screen);
4847
4848   /* decode the graphics */
4849   switch (intf->plane_order)
4850   {
4851   case NORMAL_PLANE_ORDER:
4852      total = memory_region_length(machine, intf->gfx_memory_region) / 128;
4853      decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &spritelayout, 4);
4854      break;
4855
4856   default:
4857      fatalerror("Unsupported plane_order");
4858   }
4859
4860   if (VERBOSE)
4861   {
4862      if (video_screen_get_format(k053247->screen) == BITMAP_FORMAT_RGB32)
4863      {
4864         if ((machine->config->video_attributes & (VIDEO_HAS_SHADOWS|VIDEO_HAS_HIGHLIGHTS)) != VIDEO_HAS_SHADOWS+VIDEO_HAS_HIGHLIGHTS)
4865            popmessage("driver missing SHADOWS or HIGHLIGHTS flag");
4866      }
4867      else
4868      {
4869         if (!(machine->config->video_attributes & VIDEO_HAS_SHADOWS))
4870            popmessage("driver should use VIDEO_HAS_SHADOWS");
4871      }
4872   }
4873
4874   /* deinterleave the graphics, if needed */
4875   deinterleave_gfx(machine, intf->gfx_memory_region, intf->deinterleave);
4876
4877   k053247->dx = intf->dx;
4878   k053247->dy = intf->dy;
4879   k053247->memory_region = intf->gfx_memory_region;
4880   k053247->gfx = machine->gfx[intf->gfx_num];
4881   k053247->callback = intf->callback;
4882
4883   k053247->ram = auto_alloc_array(machine, UINT16, 0x1000/2);
4884
4885   state_save_register_device_item_pointer(device, 0, k053247->ram, 0x800);
4886   state_save_register_device_item_array(device, 0, k053247->Kx46_regs);
4887   state_save_register_device_item_array(device, 0, k053247->Kx47_regs);
4888   state_save_register_device_item(device, 0, k053247->objcha_line);
4889   state_save_register_device_item(device, 0, k053247->wraparound);
4890   state_save_register_device_item(device, 0, k053247->z_rejection);
4891}
4892
4893/* K055673 used with the 54246 in PreGX/Run and Gun/System GX games */
4894static DEVICE_START( k055673 )
4895{
4896   k053247_state *k053247 = k053247_get_safe_token(device);
4897   const k053247_interface *intf = k053247_get_interface(device);
4898   running_machine *machine = device->machine;
4899   UINT32 total;
4900   UINT8 *s1, *s2, *d;
4901   long i;
4902   UINT16 *K055673_rom;
4903   int size4;
4904
4905   static const gfx_layout spritelayout =   /* System GX sprite layout */
4906   {
4907      16,16,
4908      0,
4909      5,
4910      { 32, 24, 16, 8, 0 },
4911      { 0, 1, 2, 3, 4, 5, 6, 7, 40, 41, 42, 43, 44, 45, 46, 47 },
4912      { 0, 10*8, 10*8*2, 10*8*3, 10*8*4, 10*8*5, 10*8*6, 10*8*7, 10*8*8,
4913        10*8*9, 10*8*10, 10*8*11, 10*8*12, 10*8*13, 10*8*14, 10*8*15 },
4914      16*16*5
4915   };
4916   static const gfx_layout spritelayout2 =   /* Run and Gun sprite layout */
4917   {
4918      16,16,
4919      0,
4920      4,
4921      { 24, 16, 8, 0 },
4922      { 0, 1, 2, 3, 4, 5, 6, 7, 32, 33, 34, 35, 36, 37, 38, 39 },
4923      { 0, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960 },
4924      16*16*4
4925   };
4926   static const gfx_layout spritelayout3 =   /* Lethal Enforcers II sprite layout */
4927   {
4928      16,16,
4929      0,
4930      8,
4931      { 8*1,8*0,8*3,8*2,8*5,8*4,8*7,8*6 },
4932      {  0,1,2,3,4,5,6,7,64+0,64+1,64+2,64+3,64+4,64+5,64+6,64+7 },
4933      { 128*0, 128*1, 128*2,  128*3,  128*4,  128*5,  128*6,  128*7,
4934        128*8, 128*9, 128*10, 128*11, 128*12, 128*13, 128*14, 128*15 },
4935      128*16
4936   };
4937   static const gfx_layout spritelayout4 =   /* System GX 6bpp sprite layout */
4938   {
4939      16,16,
4940      0,
4941      6,
4942      { 40, 32, 24, 16, 8, 0 },
4943      { 0, 1, 2, 3, 4, 5, 6, 7, 48, 49, 50, 51, 52, 53, 54, 55 },
4944      { 0, 12*8, 12*8*2, 12*8*3, 12*8*4, 12*8*5, 12*8*6, 12*8*7, 12*8*8,
4945        12*8*9, 12*8*10, 12*8*11, 12*8*12, 12*8*13, 12*8*14, 12*8*15 },
4946      16*16*6
4947   };
4948
4949   k053247->screen = devtag_get_device(device->machine, intf->screen);
4950
4951   K055673_rom = (UINT16 *)memory_region(machine, intf->gfx_memory_region);
4952
4953   /* decode the graphics */
4954   switch (intf->plane_order)   /* layout would be more correct than plane_order, but we use k053247_interface */
4955   {
4956   case K055673_LAYOUT_GX:
4957      size4 = (memory_region_length(machine, intf->gfx_memory_region) / (1024 * 1024)) / 5;
4958      size4 *= 4 * 1024 * 1024;
4959      /* set the # of tiles based on the 4bpp section */
4960      K055673_rom = auto_alloc_array(machine, UINT16, size4 * 5 / 2);
4961      d = (UINT8 *)K055673_rom;
4962      // now combine the graphics together to form 5bpp
4963      s1 = memory_region(machine, intf->gfx_memory_region); // 4bpp area
4964      s2 = s1 + (size4);    // 1bpp area
4965      for (i = 0; i < size4; i+= 4)
4966      {
4967         *d++ = *s1++;
4968         *d++ = *s1++;
4969         *d++ = *s1++;
4970         *d++ = *s1++;
4971         *d++ = *s2++;
4972      }
4973
4974      total = size4 / 128;
4975      decode_gfx(machine, intf->gfx_num, (UINT8 *)K055673_rom, total, &spritelayout, 4);
4976      break;
4977
4978   case K055673_LAYOUT_RNG:
4979      total = memory_region_length(machine, intf->gfx_memory_region) / (16 * 16 / 2);
4980      decode_gfx(machine, intf->gfx_num, (UINT8 *)K055673_rom, total, &spritelayout2, 4);
4981      break;
4982
4983   case K055673_LAYOUT_LE2:
4984      total = memory_region_length(machine, intf->gfx_memory_region) / (16 * 16);
4985      decode_gfx(machine, intf->gfx_num, (UINT8 *)K055673_rom, total, &spritelayout3, 4);
4986      break;
4987
4988   case K055673_LAYOUT_GX6:
4989      total = memory_region_length(machine, intf->gfx_memory_region) / (16 * 16 * 6 / 8);
4990      decode_gfx(machine, intf->gfx_num, (UINT8 *)K055673_rom, total, &spritelayout4, 4);
4991      break;
4992
4993   default:
4994      fatalerror("Unsupported layout");
4995   }
4996
4997   if (VERBOSE && !(machine->config->video_attributes & VIDEO_HAS_SHADOWS))
4998      popmessage("driver should use VIDEO_HAS_SHADOWS");
4999
5000   k053247->dx = intf->dx;
5001   k053247->dy = intf->dy;
5002   k053247->memory_region = intf->gfx_memory_region;
5003   k053247->gfx = machine->gfx[intf->gfx_num];
5004   k053247->callback = intf->callback;
5005
5006   k053247->ram = auto_alloc_array(machine, UINT16, 0x1000 / 2);
5007
5008   state_save_register_device_item_pointer(device, 0, k053247->ram, 0x800);
5009   state_save_register_device_item_array(device, 0, k053247->Kx46_regs);
5010   state_save_register_device_item_array(device, 0, k053247->Kx47_regs);
5011   state_save_register_device_item(device, 0, k053247->objcha_line);
5012   state_save_register_device_item(device, 0, k053247->wraparound);
5013   state_save_register_device_item(device, 0, k053247->z_rejection);
5014}
5015
5016static DEVICE_RESET( k053247 )
5017{
5018   k053247_state *k053247 = k053247_get_safe_token(device);
5019
5020   k053247->wraparound = 1;
5021   k053247->z_rejection = -1;
5022   k053247->objcha_line = CLEAR_LINE;
5023
5024   memset(k053247->Kx46_regs, 0, 8);
5025   memset(k053247->Kx47_regs, 0, 32);
5026}
5027
5028/*
5029    In a K053247+K055555 setup objects with Z-code 0x00 should be ignored
5030    when PRFLIP is cleared, while objects with Z-code 0xff should be
5031    ignored when PRFLIP is set.
5032
5033    These behaviors can also be seen in older K053245(6)+K053251 setups.
5034    Bucky'O Hare, The Simpsons and Sunset Riders rely on their implications
5035    to prepare and retire sprites. They probably apply to many other Konami
5036    games but it's hard to tell because most artifacts have been filtered
5037    by exclusion sort.
5038
5039    A driver may call K05324x_set_z_rejection() to set which zcode to ignore.
5040    Parameter:
5041               -1 = accept all(default)
5042        0x00-0xff = zcode to ignore
5043*/
5044
5045
5046void k05324x_set_z_rejection( const device_config *device, int zcode )
5047{
5048   k05324x_state *k05324x = k05324x_get_safe_token(device);
5049   k05324x->z_rejection = zcode;
5050}
5051
5052void k053247_set_z_rejection( const device_config *device, int zcode )
5053{
5054   k053247_state *k053247 = k053247_get_safe_token(device);
5055   k053247->z_rejection = zcode;
5056}
5057
5058/***************************************************************************/
5059/*                                                                         */
5060/*                                 051316                                  */
5061/*                                                                         */
5062/***************************************************************************/
5063
5064typedef struct _k051316_state k051316_state;
5065struct _k051316_state
5066{
5067   UINT8    *ram;
5068
5069   tilemap  *tmap;
5070
5071   int      gfxnum, wraparound, bpp;
5072   int      offset[2];
5073   UINT8    ctrlram[16];
5074
5075   k051316_callback callback;
5076
5077   const char *memory_region;
5078};
5079
5080/*****************************************************************************
5081    INLINE FUNCTIONS
5082*****************************************************************************/
5083
5084INLINE k051316_state *k051316_get_safe_token( const device_config *device )
5085{
5086   assert(device != NULL);
5087   assert(device->token != NULL);
5088   assert(device->type == K051316);
5089
5090   return (k051316_state *)device->token;
5091}
5092
5093INLINE const k051316_interface *k051316_get_interface( const device_config *device )
5094{
5095   assert(device != NULL);
5096   assert(device->type == K051316);
5097   return (const k051316_interface *) device->static_config;
5098}
5099
5100/*****************************************************************************
5101    DEVICE HANDLERS
5102*****************************************************************************/
5103
5104READ8_DEVICE_HANDLER( k051316_r )
5105{
5106   k051316_state *k051316= k051316_get_safe_token(device);
5107   return k051316->ram[offset];
5108}
5109
5110WRITE8_DEVICE_HANDLER( k051316_w )
5111{
5112   k051316_state *k051316= k051316_get_safe_token(device);
5113
5114   k051316->ram[offset] = data;
5115   tilemap_mark_tile_dirty(k051316->tmap, offset & 0x3ff);
5116}
5117
5118
5119READ8_DEVICE_HANDLER( k051316_rom_r )
5120{
5121   k051316_state *k051316= k051316_get_safe_token(device);
5122
5123   if ((k051316->ctrlram[0x0e] & 0x01) == 0)
5124   {
5125      int addr = offset + (k051316->ctrlram[0x0c] << 11) + (k051316->ctrlram[0x0d] << 19);
5126      if (k051316->bpp <= 4)
5127         addr /= 2;
5128      addr &= memory_region_length(device->machine, k051316->memory_region) - 1;
5129
5130      //  popmessage("%s: offset %04x addr %04x", cpuexec_describe_context(device->machine), offset, addr);
5131
5132      return memory_region(device->machine, k051316->memory_region)[addr];
5133   }
5134   else
5135   {
5136      //logerror("%s: read 051316 ROM offset %04x but reg 0x0c bit 0 not clear\n", cpuexec_describe_context(device->machine), offset);
5137      return 0;
5138   }
5139}
5140
5141WRITE8_DEVICE_HANDLER( k051316_ctrl_w )
5142{
5143   k051316_state *k051316= k051316_get_safe_token(device);
5144   k051316->ctrlram[offset] = data;
5145   //if (offset >= 0x0c) logerror("%s: write %02x to 051316 reg %x\n", cpuexec_describe_context(device->machine), data, offset);
5146}
5147
5148// a few games (ajax, rollerg, ultraman, etc.) can enable and disable wraparound after start
5149void k051316_wraparound_enable( const device_config *device, int status )
5150{
5151   k051316_state *k051316= k051316_get_safe_token(device);
5152   k051316->wraparound = status;
5153}
5154
5155/***************************************************************************
5156
5157  Callbacks for the TileMap code
5158
5159***************************************************************************/
5160
5161INLINE void k051316_get_tile_info( const device_config *device, tile_data *tileinfo, int tile_index )
5162{
5163   k051316_state *k051316 = k051316_get_safe_token(device);
5164   int code = k051316->ram[tile_index];
5165   int color = k051316->ram[tile_index + 0x400];
5166   int flags = 0;
5167
5168   k051316->callback(device->machine, &code, &color, &flags);
5169
5170   SET_TILE_INFO_DEVICE(
5171         k051316->gfxnum,
5172         code,
5173         color,
5174         flags);
5175}
5176
5177
5178static TILE_GET_INFO_DEVICE( k051316_get_tile_info0 ) { k051316_get_tile_info(device, tileinfo, tile_index); }
5179
5180
5181void k051316_zoom_draw( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int flags, UINT32 priority )
5182{
5183   k051316_state *k051316= k051316_get_safe_token(device);
5184   UINT32 startx, starty;
5185   int incxx, incxy, incyx, incyy;
5186
5187   startx = 256 * ((INT16)(256 * k051316->ctrlram[0x00] + k051316->ctrlram[0x01]));
5188   incxx  =        (INT16)(256 * k051316->ctrlram[0x02] + k051316->ctrlram[0x03]);
5189   incyx  =        (INT16)(256 * k051316->ctrlram[0x04] + k051316->ctrlram[0x05]);
5190   starty = 256 * ((INT16)(256 * k051316->ctrlram[0x06] + k051316->ctrlram[0x07]));
5191   incxy  =        (INT16)(256 * k051316->ctrlram[0x08] + k051316->ctrlram[0x09]);
5192   incyy  =        (INT16)(256 * k051316->ctrlram[0x0a] + k051316->ctrlram[0x0b]);
5193
5194   startx -= (16 + k051316->offset[1]) * incyx;
5195   starty -= (16 + k051316->offset[1]) * incyy;
5196
5197   startx -= (89 + k051316->offset[0]) * incxx;
5198   starty -= (89 + k051316->offset[0]) * incxy;
5199
5200   tilemap_draw_roz(bitmap,cliprect,k051316->tmap,startx << 5,starty << 5,
5201         incxx << 5,incxy << 5,incyx << 5,incyy << 5,
5202         k051316->wraparound,
5203         flags,priority);
5204
5205#if 0
5206   popmessage("%02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x",
5207         k051316->ctrlram[0x00],
5208         k051316->ctrlram[0x01],
5209         k051316->ctrlram[0x02],
5210         k051316->ctrlram[0x03],
5211         k051316->ctrlram[0x04],
5212         k051316->ctrlram[0x05],
5213         k051316->ctrlram[0x06],
5214         k051316->ctrlram[0x07],
5215         k051316->ctrlram[0x08],
5216         k051316->ctrlram[0x09],
5217         k051316->ctrlram[0x0a],
5218         k051316->ctrlram[0x0b],
5219         k051316->ctrlram[0x0c],   /* bank for ROM testing */
5220         k051316->ctrlram[0x0d],
5221         k051316->ctrlram[0x0e],   /* 0 = test ROMs */
5222         k051316->ctrlram[0x0f]);
5223#endif
5224}
5225
5226
5227/*****************************************************************************
5228    DEVICE INTERFACE
5229*****************************************************************************/
5230
5231static DEVICE_START( k051316 )
5232{
5233   k051316_state *k051316 = k051316_get_safe_token(device);
5234   const k051316_interface *intf = k051316_get_interface(device);
5235   running_machine *machine = device->machine;
5236
5237   int is_tail2nos = 0;
5238   UINT32 total;
5239
5240   static const gfx_layout charlayout4 =
5241   {
5242      16,16,
5243      0,
5244      4,
5245      { 0, 1, 2, 3 },
5246      { 0*4, 1*4, 2*4, 3*4, 4*4, 5*4, 6*4, 7*4,
5247            8*4, 9*4, 10*4, 11*4, 12*4, 13*4, 14*4, 15*4 },
5248      { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64,
5249            8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 },
5250      128*8
5251   };
5252
5253   static const gfx_layout charlayout7 =
5254   {
5255      16,16,
5256      0,
5257      7,
5258      { 1,2,3,4,5,6,7 },
5259      { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
5260            8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
5261      { 0*128, 1*128, 2*128, 3*128, 4*128, 5*128, 6*128, 7*128,
5262            8*128, 9*128, 10*128, 11*128, 12*128, 13*128, 14*128, 15*128 },
5263      256*8
5264   };
5265
5266   static const gfx_layout charlayout8 =
5267   {
5268      16,16,
5269      0,
5270      8,
5271      { 0,1,2,3,4,5,6,7 },
5272      { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
5273            8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
5274      { 0*128, 1*128, 2*128, 3*128, 4*128, 5*128, 6*128, 7*128,
5275            8*128, 9*128, 10*128, 11*128, 12*128, 13*128, 14*128, 15*128 },
5276      256*8
5277   };
5278
5279   static const gfx_layout charlayout_tail2nos =
5280   {
5281      16,16,
5282      0,
5283      4,
5284      { 0, 1, 2, 3 },
5285      { XOR(0)*4, XOR(1)*4, XOR(2)*4, XOR(3)*4, XOR(4)*4, XOR(5)*4, XOR(6)*4, XOR(7)*4,
5286            XOR(8)*4, XOR(9)*4, XOR(10)*4, XOR(11)*4, XOR(12)*4, XOR(13)*4, XOR(14)*4, XOR(15)*4 },
5287      { 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64,
5288            8*64, 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64 },
5289      128*8
5290   };
5291
5292   /* decode the graphics */
5293   switch (intf->bpp)
5294   {
5295   case -4:
5296      total = 0x400;
5297      is_tail2nos = 1;
5298      decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &charlayout_tail2nos, 4);
5299      break;
5300
5301   case 4:
5302      total = memory_region_length(machine, intf->gfx_memory_region) / 128;
5303      decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &charlayout4, 4);
5304      break;
5305
5306   case 7:
5307      total = memory_region_length(machine, intf->gfx_memory_region) / 256;
5308      decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &charlayout7, 7);
5309      break;
5310
5311   case 8:
5312      total = memory_region_length(machine, intf->gfx_memory_region) / 256;
5313      decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &charlayout8, 8);
5314      break;
5315
5316   default:
5317      fatalerror("Unsupported bpp");
5318   }
5319
5320   k051316->memory_region = intf->gfx_memory_region;
5321   k051316->gfxnum = intf->gfx_num;
5322   k051316->bpp = is_tail2nos ? 4 : intf->bpp;   // tail2nos is passed with bpp = -4 to setup the custom charlayout!
5323   k051316->callback = intf->callback;
5324
5325   k051316->tmap = tilemap_create_device(device, k051316_get_tile_info0, tilemap_scan_rows, 16, 16, 32, 32);
5326
5327   k051316->ram = auto_alloc_array(machine, UINT8, 0x800);
5328
5329   if (!intf->pen_is_mask)
5330      tilemap_set_transparent_pen(k051316->tmap, intf->transparent_pen);
5331   else
5332   {
5333      tilemap_map_pens_to_layer(k051316->tmap, 0, 0, 0, TILEMAP_PIXEL_LAYER1);
5334      tilemap_map_pens_to_layer(k051316->tmap, 0, intf->transparent_pen, intf->transparent_pen, TILEMAP_PIXEL_LAYER0);
5335   }
5336
5337   k051316->wraparound = intf->wrap;
5338   k051316->offset[0] = intf->xoffs;
5339   k051316->offset[1] = intf->yoffs;
5340
5341   state_save_register_device_item_pointer(device, 0, k051316->ram, 0x800);
5342   state_save_register_device_item_array(device, 0, k051316->ctrlram);
5343   state_save_register_device_item(device, 0, k051316->wraparound);
5344}
5345
5346static DEVICE_RESET( k051316 )
5347{
5348   k051316_state *k051316 = k051316_get_safe_token(device);
5349
5350   memset(k051316->ctrlram,  0, 0x10);
5351}
5352
5353/***************************************************************************/
5354/*                                                                         */
5355/*                                 053936                                  */
5356/*                                                                         */
5357/***************************************************************************/
5358
5359typedef struct _k053936_state k053936_state;
5360struct _k053936_state
5361{
5362   UINT16    *ctrl;
5363   UINT16    *linectrl;
5364
5365   int      wraparound;
5366   int      offset[2];
5367};
5368
5369/*****************************************************************************
5370    INLINE FUNCTIONS
5371*****************************************************************************/
5372
5373INLINE k053936_state *k053936_get_safe_token( const device_config *device )
5374{
5375   assert(device != NULL);
5376   assert(device->token != NULL);
5377   assert(device->type == K053936);
5378
5379   return (k053936_state *)device->token;
5380}
5381
5382INLINE const k053936_interface *k053936_get_interface( const device_config *device )
5383{
5384   assert(device != NULL);
5385   assert(device->type == K053936);
5386   return (const k053936_interface *) device->static_config;
5387}
5388
5389/*****************************************************************************
5390    DEVICE HANDLERS
5391*****************************************************************************/
5392
5393WRITE16_DEVICE_HANDLER( k053936_ctrl_w )
5394{
5395   k053936_state *k053936= k053936_get_safe_token(device);
5396   COMBINE_DATA(&k053936->ctrl[offset]);
5397}
5398
5399/* FIXME: this is probably unused... check! */
5400READ16_DEVICE_HANDLER( k053936_ctrl_r )
5401{
5402   k053936_state *k053936= k053936_get_safe_token(device);
5403   return k053936->ctrl[offset];
5404}
5405
5406WRITE16_DEVICE_HANDLER( k053936_linectrl_w )
5407{
5408   k053936_state *k053936= k053936_get_safe_token(device);
5409   COMBINE_DATA(&k053936->linectrl[offset]);
5410}
5411
5412READ16_DEVICE_HANDLER( k053936_linectrl_r )
5413{
5414   k053936_state *k053936= k053936_get_safe_token(device);
5415   return k053936->linectrl[offset];
5416}
5417
5418// there is another implementation of this in  video/konamigx.c (!)
5419//  why? shall they be merged?
5420void k053936_zoom_draw( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, tilemap *tmap, int flags, UINT32 priority, int glfgreat_hack )
5421{
5422   k053936_state *k053936= k053936_get_safe_token(device);
5423   if (!tmap)
5424      return;
5425
5426   if (k053936->ctrl[0x07] & 0x0040)
5427   {
5428      UINT32 startx, starty;
5429      int incxx, incxy;
5430      rectangle my_clip;
5431      int y, maxy;
5432
5433      // Racin' Force will get to here if glfgreat_hack is enabled, and it ends
5434      // up setting a maximum y value of '13', thus causing nothing to be drawn.
5435      // It looks like the roz output should be flipped somehow as it seems to be
5436      // displaying the wrong areas of the tilemap and is rendered upside down,
5437      // although due to the additional post-processing the voxel renderer performs
5438      // it's difficult to know what the output SHOULD be.  (hold W in Racin' Force
5439      // to see the chip output)
5440
5441      if (((k053936->ctrl[0x07] & 0x0002) && k053936->ctrl[0x09]) && (glfgreat_hack))   /* wrong, but fixes glfgreat */
5442      {
5443         my_clip.min_x = k053936->ctrl[0x08] + k053936->offset[0] + 2;
5444         my_clip.max_x = k053936->ctrl[0x09] + k053936->offset[0] + 2 - 1;
5445         if (my_clip.min_x < cliprect->min_x)
5446            my_clip.min_x = cliprect->min_x;
5447         if (my_clip.max_x > cliprect->max_x)
5448            my_clip.max_x = cliprect->max_x;
5449
5450         y = k053936->ctrl[0x0a] + k053936->offset[1] - 2;
5451         if (y < cliprect->min_y)
5452            y = cliprect->min_y;
5453         maxy = k053936->ctrl[0x0b] + k053936->offset[1] - 2 - 1;
5454         if (maxy > cliprect->max_y)
5455            maxy = cliprect->max_y;
5456      }
5457      else
5458      {
5459         my_clip.min_x = cliprect->min_x;
5460         my_clip.max_x = cliprect->max_x;
5461
5462         y = cliprect->min_y;
5463         maxy = cliprect->max_y;
5464      }
5465
5466      while (y <= maxy)
5467      {
5468         UINT16 *lineaddr = k053936->linectrl + 4 * ((y - k053936->offset[1]) & 0x1ff);
5469
5470         my_clip.min_y = my_clip.max_y = y;
5471
5472         startx = 256 * (INT16)(lineaddr[0] + k053936->ctrl[0x00]);
5473         starty = 256 * (INT16)(lineaddr[1] + k053936->ctrl[0x01]);
5474         incxx  =       (INT16)(lineaddr[2]);
5475         incxy  =       (INT16)(lineaddr[3]);
5476
5477         if (k053936->ctrl[0x06] & 0x8000)
5478            incxx *= 256;
5479
5480         if (k053936->ctrl[0x06] & 0x0080)
5481            incxy *= 256;
5482
5483         startx -= k053936->offset[0] * incxx;
5484         starty -= k053936->offset[0] * incxy;
5485
5486         tilemap_draw_roz(bitmap,&my_clip,tmap,startx << 5,starty << 5,
5487               incxx << 5,incxy << 5,0,0,
5488               k053936->wraparound,
5489               flags,priority);
5490
5491         y++;
5492      }
5493   }
5494   else   /* "simple" mode */
5495   {
5496      UINT32 startx, starty;
5497      int incxx, incxy, incyx, incyy;
5498
5499      startx = 256 * (INT16)(k053936->ctrl[0x00]);
5500      starty = 256 * (INT16)(k053936->ctrl[0x01]);
5501      incyx  =       (INT16)(k053936->ctrl[0x02]);
5502      incyy  =       (INT16)(k053936->ctrl[0x03]);
5503      incxx  =       (INT16)(k053936->ctrl[0x04]);
5504      incxy  =       (INT16)(k053936->ctrl[0x05]);
5505
5506      if (k053936->ctrl[0x06] & 0x4000)
5507      {
5508         incyx *= 256;
5509         incyy *= 256;
5510      }
5511
5512      if (k053936->ctrl[0x06] & 0x0040)
5513      {
5514         incxx *= 256;
5515         incxy *= 256;
5516      }
5517
5518      startx -= k053936->offset[1] * incyx;
5519      starty -= k053936->offset[1] * incyy;
5520
5521      startx -= k053936->offset[0] * incxx;
5522      starty -= k053936->offset[0] * incxy;
5523
5524      tilemap_draw_roz(bitmap,cliprect,tmap,startx << 5,starty << 5,
5525            incxx << 5,incxy << 5,incyx << 5,incyy << 5,
5526            k053936->wraparound,
5527            flags,priority);
5528   }
5529
5530#if 0
5531if (input_code_pressed(machine, KEYCODE_D))
5532   popmessage("%04x %04x %04x %04x\n%04x %04x %04x %04x\n%04x %04x %04x %04x\n%04x %04x %04x %04x",
5533         k053936->ctrl[0x00],
5534         k053936->ctrl[0x01],
5535         k053936->ctrl[0x02],
5536         k053936->ctrl[0x03],
5537         k053936->ctrl[0x04],
5538         k053936->ctrl[0x05],
5539         k053936->ctrl[0x06],
5540         k053936->ctrl[0x07],
5541         k053936->ctrl[0x08],
5542         k053936->ctrl[0x09],
5543         k053936->ctrl[0x0a],
5544         k053936->ctrl[0x0b],
5545         k053936->ctrl[0x0c],
5546         k053936->ctrl[0x0d],
5547         k053936->ctrl[0x0e],
5548         k053936->ctrl[0x0f]);
5549#endif
5550}
5551
5552/*****************************************************************************
5553    DEVICE INTERFACE
5554*****************************************************************************/
5555
5556static DEVICE_START( k053936 )
5557{
5558   k053936_state *k053936 = k053936_get_safe_token(device);
5559   const k053936_interface *intf = k053936_get_interface(device);
5560
5561   k053936->ctrl = auto_alloc_array(device->machine, UINT16, 0x20);
5562   k053936->linectrl = auto_alloc_array(device->machine, UINT16, 0x4000);
5563
5564   k053936->wraparound = intf->wrap;
5565   k053936->offset[0] = intf->xoff;
5566   k053936->offset[1] = intf->yoff;
5567
5568   state_save_register_device_item_pointer(device, 0, k053936->ctrl, 0x20);
5569   state_save_register_device_item_pointer(device, 0, k053936->linectrl, 0x4000);
5570}
5571
5572static DEVICE_RESET( k053936 )
5573{
5574   k053936_state *k053936 = k053936_get_safe_token(device);
5575
5576   memset(k053936->ctrl, 0, 0x20);
5577}
5578
5579/***************************************************************************/
5580/*                                                                         */
5581/*                                 053251                                  */
5582/*                                                                         */
5583/***************************************************************************/
5584
5585typedef struct _k053251_state k053251_state;
5586struct _k053251_state
5587{
5588   int      dirty_tmap[5];
5589
5590   UINT8    ram[16];
5591   int      tilemaps_set;
5592   int      palette_index[5];
5593};
5594
5595/*****************************************************************************
5596    INLINE FUNCTIONS
5597*****************************************************************************/
5598
5599INLINE k053251_state *k053251_get_safe_token( const device_config *device )
5600{
5601   assert(device != NULL);
5602   assert(device->token != NULL);
5603   assert(device->type == K053251);
5604
5605   return (k053251_state *)device->token;
5606}
5607
5608/*****************************************************************************
5609    DEVICE HANDLERS
5610*****************************************************************************/
5611
5612void k053251_postload_reset_indexes( const device_config *device )
5613{
5614   k053251_state *k053251 = k053251_get_safe_token(device);
5615
5616   k053251->palette_index[0] = 32 * ((k053251->ram[9] >> 0) & 0x03);
5617   k053251->palette_index[1] = 32 * ((k053251->ram[9] >> 2) & 0x03);
5618   k053251->palette_index[2] = 32 * ((k053251->ram[9] >> 4) & 0x03);
5619   k053251->palette_index[3] = 16 * ((k053251->ram[10] >> 0) & 0x07);
5620   k053251->palette_index[4] = 16 * ((k053251->ram[10] >> 3) & 0x07);
5621}
5622
5623WRITE8_DEVICE_HANDLER( k053251_w )
5624{
5625   k053251_state *k053251 = k053251_get_safe_token(device);
5626   int i, newind;
5627
5628   data &= 0x3f;
5629
5630   if (k053251->ram[offset] != data)
5631   {
5632      k053251->ram[offset] = data;
5633      if (offset == 9)
5634      {
5635         /* palette base index */
5636         for (i = 0; i < 3; i++)
5637         {
5638            newind = 32 * ((data >> 2 * i) & 0x03);
5639            if (k053251->palette_index[i] != newind)
5640            {
5641               k053251->palette_index[i] = newind;
5642               k053251->dirty_tmap[i] = 1;
5643            }
5644         }
5645
5646         if (!k053251->tilemaps_set)
5647            tilemap_mark_all_tiles_dirty_all(device->machine);
5648      }
5649      else if (offset == 10)
5650      {
5651         /* palette base index */
5652         for (i = 0; i < 2; i++)
5653         {
5654            newind = 16 * ((data >> 3 * i) & 0x07);
5655            if (k053251->palette_index[3 + i] != newind)
5656            {
5657               k053251->palette_index[3 + i] = newind;
5658               k053251->dirty_tmap[3 + i] = 1;
5659            }
5660         }
5661
5662         if (!k053251->tilemaps_set)
5663            tilemap_mark_all_tiles_dirty_all(device->machine);
5664      }
5665   }
5666}
5667
5668WRITE16_DEVICE_HANDLER( k053251_lsb_w )
5669{
5670   if (ACCESSING_BITS_0_7)
5671      k053251_w(device, offset, data & 0xff);
5672}
5673
5674WRITE16_DEVICE_HANDLER( k053251_msb_w )
5675{
5676   if (ACCESSING_BITS_8_15)
5677      k053251_w(device, offset, (data >> 8) & 0xff);
5678}
5679
5680int k053251_get_priority( const device_config *device, int ci )
5681{
5682   k053251_state *k053251 = k053251_get_safe_token(device);
5683   return k053251->ram[ci];
5684}
5685
5686int k053251_get_palette_index( const device_config *device, int ci )
5687{
5688   k053251_state *k053251 = k053251_get_safe_token(device);
5689   return k053251->palette_index[ci];
5690}
5691
5692int k053251_get_tmap_dirty( const device_config *device, int tmap_num )
5693{
5694   k053251_state *k053251 = k053251_get_safe_token(device);
5695   assert(tmap_num < 5);
5696   return k053251->dirty_tmap[tmap_num];
5697}
5698
5699void k053251_set_tmap_dirty( const device_config *device, int tmap_num, int data )
5700{
5701   k053251_state *k053251 = k053251_get_safe_token(device);
5702   assert(tmap_num < 5);
5703   k053251->dirty_tmap[tmap_num] = data ? 1 : 0;
5704}
5705
5706
5707/*****************************************************************************
5708    DEVICE INTERFACE
5709*****************************************************************************/
5710
5711static DEVICE_START( k053251 )
5712{
5713   k053251_state *k053251 = k053251_get_safe_token(device);
5714
5715   state_save_register_device_item_array(device, 0, k053251->ram);
5716   state_save_register_device_item(device, 0, k053251->tilemaps_set);
5717   state_save_register_device_item_array(device, 0, k053251->dirty_tmap);
5718}
5719
5720static DEVICE_RESET( k053251 )
5721{
5722   k053251_state *k053251 = k053251_get_safe_token(device);
5723   int i;
5724
5725   for (i = 0; i < 0x10; i++)
5726      k053251->ram[i] = 0;
5727
5728   for (i = 0; i < 5; i++)
5729      k053251->dirty_tmap[i] = 0;
5730}
5731
5732
5733/***************************************************************************/
5734/*                                                                         */
5735/*                                 054000                                  */
5736/*                                                                         */
5737/***************************************************************************/
5738
5739typedef struct _k054000_state k054000_state;
5740struct _k054000_state
5741{
5742   UINT8    regs[0x20];
5743};
5744
5745/*****************************************************************************
5746    INLINE FUNCTIONS
5747*****************************************************************************/
5748
5749INLINE k054000_state *k054000_get_safe_token( const device_config *device )
5750{
5751   assert(device != NULL);
5752   assert(device->token != NULL);
5753   assert(device->type == K054000);
5754
5755   return (k054000_state *)device->token;
5756}
5757
5758/*****************************************************************************
5759    DEVICE HANDLERS
5760*****************************************************************************/
5761
5762WRITE8_DEVICE_HANDLER( k054000_w )
5763{
5764   k054000_state *k054000 = k054000_get_safe_token(device);
5765
5766   //logerror("%04x: write %02x to 054000 address %02x\n",cpu_get_pc(space->cpu),data,offset);
5767   k054000->regs[offset] = data;
5768}
5769
5770READ8_DEVICE_HANDLER( k054000_r )
5771{
5772   k054000_state *k054000 = k054000_get_safe_token(device);
5773   int Acx, Acy, Aax, Aay;
5774   int Bcx, Bcy, Bax, Bay;
5775
5776   //logerror("%04x: read 054000 address %02x\n", cpu_get_pc(space->cpu), offset);
5777
5778   if (offset != 0x18)
5779      return 0;
5780
5781   Acx = (k054000->regs[0x01] << 16) | (k054000->regs[0x02] << 8) | k054000->regs[0x03];
5782   Acy = (k054000->regs[0x09] << 16) | (k054000->regs[0x0a] << 8) | k054000->regs[0x0b];
5783
5784   /* TODO: this is a hack to make thndrx2 pass the startup check. It is certainly wrong. */
5785   if (k054000->regs[0x04] == 0xff)
5786      Acx+=3;
5787   if (k054000->regs[0x0c] == 0xff)
5788      Acy+=3;
5789
5790   Aax = k054000->regs[0x06] + 1;
5791   Aay = k054000->regs[0x07] + 1;
5792
5793   Bcx = (k054000->regs[0x15] << 16) | (k054000->regs[0x16] << 8) | k054000->regs[0x17];
5794   Bcy = (k054000->regs[0x11] << 16) | (k054000->regs[0x12] << 8) | k054000->regs[0x13];
5795   Bax = k054000->regs[0x0e] + 1;
5796   Bay = k054000->regs[0x0f] + 1;
5797
5798   if (Acx + Aax < Bcx - Bax)
5799      return 1;
5800
5801   if (Bcx + Bax < Acx - Aax)
5802      return 1;
5803
5804   if (Acy + Aay < Bcy - Bay)
5805      return 1;
5806
5807   if (Bcy + Bay < Acy - Aay)
5808      return 1;
5809
5810   return 0;
5811}
5812
5813READ16_DEVICE_HANDLER( k054000_lsb_r )
5814{
5815   return k054000_r(device, offset);
5816}
5817
5818WRITE16_DEVICE_HANDLER( k054000_lsb_w )
5819{
5820   if (ACCESSING_BITS_0_7)
5821      k054000_w(device, offset, data & 0xff);
5822}
5823
5824/*****************************************************************************
5825    DEVICE INTERFACE
5826*****************************************************************************/
5827
5828static DEVICE_START( k054000 )
5829{
5830   k054000_state *k054000 = k054000_get_safe_token(device);
5831
5832   state_save_register_device_item_array(device, 0, k054000->regs);
5833}
5834
5835static DEVICE_RESET( k054000 )
5836{
5837   k054000_state *k054000 = k054000_get_safe_token(device);
5838   int i;
5839
5840   for (i = 0; i < 0x20; i++)
5841      k054000->regs[i] = 0;
5842}
5843
5844
5845/***************************************************************************/
5846/*                                                                         */
5847/*                                 051733                                  */
5848/*                                                                         */
5849/***************************************************************************/
5850
5851typedef struct _k051733_state k051733_state;
5852struct _k051733_state
5853{
5854   UINT8    ram[0x20];
5855};
5856
5857/*****************************************************************************
5858    INLINE FUNCTIONS
5859*****************************************************************************/
5860
5861INLINE k051733_state *k051733_get_safe_token( const device_config *device )
5862{
5863   assert(device != NULL);
5864   assert(device->token != NULL);
5865   assert(device->type == K051733);
5866
5867   return (k051733_state *)device->token;
5868}
5869
5870/*****************************************************************************
5871    DEVICE HANDLERS
5872*****************************************************************************/
5873
5874WRITE8_DEVICE_HANDLER( k051733_w )
5875{
5876   k051733_state *k051733= k051733_get_safe_token(device);
5877   //logerror("%04x: write %02x to 051733 address %02x\n", cpu_get_pc(space->cpu), data, offset);
5878
5879   k051733->ram[offset] = data;
5880}
5881
5882
5883static int k051733_int_sqrt( UINT32 op )
5884{
5885   UINT32 i = 0x8000;
5886   UINT32 step = 0x4000;
5887
5888   while (step)
5889   {
5890      if (i * i == op)
5891         return i;
5892      else if (i * i > op)
5893         i -= step;
5894      else
5895         i += step;
5896      step >>= 1;
5897   }
5898   return i;
5899}
5900
5901READ8_DEVICE_HANDLER( k051733_r )
5902{
5903   k051733_state *k051733= k051733_get_safe_token(device);
5904
5905   int op1 = (k051733->ram[0x00] << 8) | k051733->ram[0x01];
5906   int op2 = (k051733->ram[0x02] << 8) | k051733->ram[0x03];
5907   int op3 = (k051733->ram[0x04] << 8) | k051733->ram[0x05];
5908
5909   int rad = (k051733->ram[0x06] << 8) | k051733->ram[0x07];
5910   int yobj1c = (k051733->ram[0x08] << 8) | k051733->ram[0x09];
5911   int xobj1c = (k051733->ram[0x0a] << 8) | k051733->ram[0x0b];
5912   int yobj2c = (k051733->ram[0x0c] << 8) | k051733->ram[0x0d];
5913   int xobj2c = (k051733->ram[0x0e] << 8) | k051733->ram[0x0f];
5914
5915   //logerror("%04x: read 051733 address %02x\n", cpu_get_pc(space->cpu), offset);
5916
5917   switch (offset)
5918   {
5919      case 0x00:
5920         if (op2)
5921            return (op1 / op2) >> 8;
5922         else
5923            return 0xff;
5924      case 0x01:
5925         if (op2)
5926            return (op1 / op2) & 0xff;
5927         else
5928            return 0xff;
5929
5930      /* this is completely unverified */
5931      case 0x02:
5932         if (op2)
5933            return (op1 % op2) >> 8;
5934         else
5935            return 0xff;
5936      case 0x03:
5937         if (op2)
5938            return (op1 % op2) & 0xff;
5939         else
5940            return 0xff;
5941
5942      case 0x04:
5943         return k051733_int_sqrt(op3 << 16) >> 8;
5944
5945      case 0x05:
5946         return k051733_int_sqrt(op3 << 16) & 0xff;
5947
5948      case 0x06:
5949         return k051733->ram[0x13];
5950
5951      case 0x07:{
5952         if (xobj1c + rad < xobj2c)
5953            return 0x80;
5954
5955         if (xobj2c + rad < xobj1c)
5956            return 0x80;
5957
5958         if (yobj1c + rad < yobj2c)
5959            return 0x80;
5960
5961         if (yobj2c + rad < yobj1c)
5962            return 0x80;
5963
5964         return 0;
5965      }
5966      case 0x0e:
5967         return ~k051733->ram[offset];
5968      case 0x0f:
5969         return ~k051733->ram[offset];
5970      default:
5971         return k051733->ram[offset];
5972   }
5973}
5974
5975/*****************************************************************************
5976    DEVICE INTERFACE
5977*****************************************************************************/
5978
5979static DEVICE_START( k051733 )
5980{
5981   k051733_state *k051733 = k051733_get_safe_token(device);
5982
5983   state_save_register_device_item_array(device, 0, k051733->ram);
5984}
5985
5986static DEVICE_RESET( k051733 )
5987{
5988   k051733_state *k051733 = k051733_get_safe_token(device);
5989   int i;
5990
5991   for (i = 0; i < 0x20; i++)
5992      k051733->ram[i] = 0;
5993}
5994
5995
5996/***************************************************************************/
5997/*                                                                         */
5998/*                                 054157 / 056832                         */
5999/*                                                                         */
6000/***************************************************************************/
6001
6002#define K056832_PAGE_COLS 64
6003#define K056832_PAGE_ROWS 32
6004#define K056832_PAGE_HEIGHT (K056832_PAGE_ROWS*8)
6005#define K056832_PAGE_WIDTH  (K056832_PAGE_COLS*8)
6006#define K056832_PAGE_COUNT 16
6007
6008typedef struct _k056832_state k056832_state;
6009struct _k056832_state
6010{
6011   tilemap   *tilemap[K056832_PAGE_COUNT];
6012   bitmap_t  *pixmap[K056832_PAGE_COUNT];
6013
6014   UINT16    regs[0x20];   // 157/832 regs group 1
6015   UINT16    regsb[4];   // 157/832 regs group 2, board dependent
6016
6017   UINT8 *   rombase;   // pointer to tile gfx data
6018   UINT16 *  videoram;
6019   int       num_gfx_banks;   // depends on size of graphics ROMs
6020   int       cur_gfx_banks;      // cached info for K056832_regs[0x1a]
6021   int       gfxnum;         // graphics element index for unpacked tiles
6022   const char *memory_region;   // memory region for tile gfx data
6023
6024
6025   // ROM readback involves reading 2 halves of a word
6026   // from the same location in a row.  Reading the
6027   // RAM window resets this state so you get the first half.
6028   int       rom_half;
6029
6030
6031   // locally cached values
6032   int       layer_assoc_with_page[K056832_PAGE_COUNT];
6033   int       layer_offs[8][2];
6034   int       lsram_page[8][2];
6035   INT32     x[8];   // 0..3 left
6036   INT32     y[8];   // 0..3 top
6037   INT32     w[8];   // 0..3 width  -> 1..4 pages
6038   INT32     h[8];   // 0..3 height -> 1..4 pages
6039   INT32     dx[8];   // scroll
6040   INT32     dy[8];   // scroll
6041   UINT32    line_dirty[K056832_PAGE_COUNT][8];
6042   UINT8     all_lines_dirty[K056832_PAGE_COUNT];
6043   UINT8     page_tile_mode[K056832_PAGE_COUNT];
6044   int       last_colorbase[K056832_PAGE_COUNT];
6045   UINT8     layer_tile_mode[8];
6046   int       default_layer_association;
6047   int       layer_association;
6048   int       active_layer;
6049   int       selected_page;
6050   int       selected_page_x4096;
6051   int       linemap_enabled;
6052   int       use_ext_linescroll;
6053   int       uses_tile_banks, cur_tile_bank;
6054
6055   int       djmain_hack;
6056
6057   k056832_callback  callback;
6058
6059   const device_config *k055555;   /* used to choose colorbase */
6060};
6061
6062/*****************************************************************************
6063    INLINE FUNCTIONS
6064*****************************************************************************/
6065
6066INLINE k056832_state *k056832_get_safe_token( const device_config *device )
6067{
6068   assert(device != NULL);
6069   assert(device->token != NULL);
6070   assert(device->type == K056832);
6071
6072   return (k056832_state *)device->token;
6073}
6074
6075INLINE const k056832_interface *k056832_get_interface( const device_config *device )
6076{
6077   assert(device != NULL);
6078   assert(device->type == K056832);
6079   return (const k056832_interface *) device->static_config;
6080}
6081
6082/*****************************************************************************
6083    DEVICE HANDLERS
6084*****************************************************************************/
6085
6086#define k056832_mark_line_dirty(P, L) if (L < 0x100) k056832->line_dirty[P][L >> 5] |= 1 << (L & 0x1f)
6087#define k056832_mark_all_lines_dirty(P) k056832->all_lines_dirty[P] = 1
6088
6089static void k056832_mark_page_dirty( const device_config *device, int page )
6090{
6091   k056832_state *k056832 = k056832_get_safe_token(device);
6092
6093   if (k056832->page_tile_mode[page])
6094      tilemap_mark_all_tiles_dirty(k056832->tilemap[page]);
6095   else
6096      k056832_mark_all_lines_dirty(page);
6097}
6098
6099void k056832_mark_plane_dirty( const device_config *device, int layer )
6100{
6101   k056832_state *k056832 = k056832_get_safe_token(device);
6102   int tilemode, i;
6103
6104   tilemode = k056832->layer_tile_mode[layer];
6105
6106   for (i = 0; i < K056832_PAGE_COUNT; i++)
6107   {
6108      if (k056832->layer_assoc_with_page[i] == layer)
6109      {
6110         k056832->page_tile_mode[i] = tilemode;
6111         k056832_mark_page_dirty(device, i);
6112      }
6113   }
6114}
6115
6116void k056832_mark_all_tmaps_dirty( const device_config *device )
6117{
6118   k056832_state *k056832 = k056832_get_safe_token(device);
6119   int i;
6120
6121   for (i = 0; i < K056832_PAGE_COUNT; i++)
6122   {
6123      if (k056832->layer_assoc_with_page[i] != -1)
6124      {
6125         k056832->page_tile_mode[i] = k056832->layer_tile_mode[k056832->layer_assoc_with_page[i]];
6126         k056832_mark_page_dirty(device, i);
6127      }
6128   }
6129}
6130
6131static void k056832_update_page_layout( const device_config *device )
6132{
6133   k056832_state *k056832 = k056832_get_safe_token(device);
6134   int layer, rowstart, rowspan, colstart, colspan, r, c, page_idx, setlayer;
6135
6136   // enable layer association by default
6137   k056832->layer_association = k056832->default_layer_association;
6138
6139   // disable association if a layer grabs the entire 4x4 map (happens in Twinbee and Dadandarn)
6140   for (layer = 0; layer < 4; layer++)
6141   {
6142      if (!k056832->y[layer] && !k056832->x[layer] && k056832->h[layer] == 3 && k056832->w[layer] == 3)
6143      {
6144         k056832->layer_association = 0;
6145         break;
6146      }
6147   }
6148
6149   // winning spike doesn't like layer association..
6150   if (k056832->djmain_hack == 2)
6151      k056832->layer_association = 0;
6152
6153   // disable all tilemaps
6154   for (page_idx = 0; page_idx < K056832_PAGE_COUNT; page_idx++)
6155   {
6156      k056832->layer_assoc_with_page[page_idx] = -1;
6157   }
6158
6159
6160   // enable associated tilemaps
6161   for (layer = 0; layer < 4; layer++)
6162   {
6163      rowstart = k056832->y[layer];
6164      colstart = k056832->x[layer];
6165      rowspan  = k056832->h[layer] + 1;
6166      colspan  = k056832->w[layer] + 1;
6167
6168      setlayer = (k056832->layer_association) ? layer : k056832->active_layer;
6169
6170      for (r = 0; r < rowspan; r++)
6171      {
6172         for (c = 0; c < colspan; c++)
6173         {
6174            page_idx = (((rowstart + r) & 3) << 2) + ((colstart + c) & 3);
6175            if (!(k056832->djmain_hack==1) || k056832->layer_assoc_with_page[page_idx] == -1)
6176               k056832->layer_assoc_with_page[page_idx] = setlayer;
6177         }
6178      }
6179   }
6180
6181   // refresh associated tilemaps
6182   k056832_mark_all_tmaps_dirty(device);
6183}
6184
6185int k056832_get_lookup( const device_config *device, int bits )
6186{
6187   k056832_state *k056832 = k056832_get_safe_token(device);
6188   int res;
6189
6190   res = (k056832->regs[0x1c] >> (bits << 2)) & 0x0f;
6191
6192   if (k056832->uses_tile_banks)   /* Asterix */
6193      res |= k056832->cur_tile_bank << 4;
6194
6195   return res;
6196}
6197
6198INLINE void k056832_get_tile_info( const device_config *device, tile_data *tileinfo, int tile_index, int pageIndex )
6199{
6200   k056832_state *k056832 = k056832_get_safe_token(device);
6201   static const struct K056832_SHIFTMASKS
6202   {
6203      int flips, palm1, pals2, palm2;
6204   }
6205   k056832_shiftmasks[4] = {{6,0x3f,0,0x00},{4,0x0f,2,0x30},{2,0x03,2,0x3c},{0,0x00,2,0x3f}};
6206
6207   const struct K056832_SHIFTMASKS *smptr;
6208   int layer, flip, fbits, attr, code, color, flags;
6209   UINT16 *pMem;
6210
6211   pMem  = &k056832->videoram[(pageIndex << 12) + (tile_index << 1)];
6212
6213   if (k056832->layer_association)
6214   {
6215      layer = k056832->layer_assoc_with_page[pageIndex];
6216      if (layer == -1)
6217         layer = 0;   // use layer 0's palette info for unmapped pages
6218   }
6219   else
6220      layer = k056832->active_layer;
6221
6222   fbits = (k056832->regs[3] >> 6) & 3;
6223   flip  = (k056832->regs[1] >> (layer << 1)) & 0x3; // tile-flip override (see p.20 3.2.2 "REG2")
6224   smptr = &k056832_shiftmasks[fbits];
6225   attr  = pMem[0];
6226   code  = pMem[1];
6227
6228   // normalize the flip/palette flags
6229   // see the tables on pages 4 and 10 of the Pt. 2-3 "VRAM" manual
6230   // for a description of these bits "FBIT0" and "FBIT1"
6231   flip &= attr >> smptr->flips & 3;
6232   color = (attr & smptr->palm1) | (attr >> smptr->pals2 & smptr->palm2);
6233   flags = TILE_FLIPYX(flip);
6234
6235   k056832->callback(device->machine, layer, &code, &color, &flags);
6236
6237   SET_TILE_INFO_DEVICE(
6238         k056832->gfxnum,
6239         code,
6240         color,
6241         flags);
6242}
6243
6244static TILE_GET_INFO_DEVICE( k056832_get_tile_info0 ) { k056832_get_tile_info(device, tileinfo, tile_index, 0x0); }
6245static TILE_GET_INFO_DEVICE( k056832_get_tile_info1 ) { k056832_get_tile_info(device, tileinfo, tile_index, 0x1); }
6246static TILE_GET_INFO_DEVICE( k056832_get_tile_info2 ) { k056832_get_tile_info(device, tileinfo, tile_index, 0x2); }
6247static TILE_GET_INFO_DEVICE( k056832_get_tile_info3 ) { k056832_get_tile_info(device, tileinfo, tile_index, 0x3); }
6248static TILE_GET_INFO_DEVICE( k056832_get_tile_info4 ) { k056832_get_tile_info(device, tileinfo, tile_index, 0x4); }
6249static TILE_GET_INFO_DEVICE( k056832_get_tile_info5 ) { k056832_get_tile_info(device, tileinfo, tile_index, 0x5); }
6250static TILE_GET_INFO_DEVICE( k056832_get_tile_info6 ) { k056832_get_tile_info(device, tileinfo, tile_index, 0x6); }
6251static TILE_GET_INFO_DEVICE( k056832_get_tile_info7 ) { k056832_get_tile_info(device, tileinfo, tile_index, 0x7); }
6252static TILE_GET_INFO_DEVICE( k056832_get_tile_info8 ) { k056832_get_tile_info(device, tileinfo, tile_index, 0x8); }
6253static TILE_GET_INFO_DEVICE( k056832_get_tile_info9 ) { k056832_get_tile_info(device, tileinfo, tile_index, 0x9); }
6254static TILE_GET_INFO_DEVICE( k056832_get_tile_infoa ) { k056832_get_tile_info(device, tileinfo, tile_index, 0xa); }
6255static TILE_GET_INFO_DEVICE( k056832_get_tile_infob ) { k056832_get_tile_info(device, tileinfo, tile_index, 0xb); }
6256static TILE_GET_INFO_DEVICE( k056832_get_tile_infoc ) { k056832_get_tile_info(device, tileinfo, tile_index, 0xc); }
6257static TILE_GET_INFO_DEVICE( k056832_get_tile_infod ) { k056832_get_tile_info(device, tileinfo, tile_index, 0xd); }
6258static TILE_GET_INFO_DEVICE( k056832_get_tile_infoe ) { k056832_get_tile_info(device, tileinfo, tile_index, 0xe); }
6259static TILE_GET_INFO_DEVICE( k056832_get_tile_infof ) { k056832_get_tile_info(device, tileinfo, tile_index, 0xf); }
6260
6261static void k056832_change_rambank( const device_config *device )
6262{
6263   /* ------xx page col
6264     * ---xx--- page row
6265     */
6266   k056832_state *k056832 = k056832_get_safe_token(device);
6267   int bank = k056832->regs[0x19];
6268
6269   if (k056832->regs[0] & 0x02)   // external linescroll enable
6270      k056832->selected_page = K056832_PAGE_COUNT;
6271   else
6272      k056832->selected_page = ((bank >> 1) & 0xc) | (bank & 3);
6273
6274   k056832->selected_page_x4096 = k056832->selected_page << 12;
6275
6276   // refresh associated tilemaps
6277   k056832_mark_all_tmaps_dirty(device);
6278}
6279
6280int k056832_get_current_rambank( const device_config *device )
6281{
6282   k056832_state *k056832 = k056832_get_safe_token(device);
6283   int bank = k056832->regs[0x19];
6284
6285   return ((bank >> 1) & 0xc) | (bank & 3);
6286}
6287
6288static void k056832_change_rombank( const device_config *device )
6289{
6290   k056832_state *k056832 = k056832_get_safe_token(device);
6291   int bank;
6292
6293   if (k056832->uses_tile_banks)   /* Asterix */
6294      bank = (k056832->regs[0x1a] >> 8) | (k056832->regs[0x1b] << 4) | (k056832->cur_tile_bank << 6);
6295   else
6296      bank = k056832->regs[0x1a] | (k056832->regs[0x1b] << 16);
6297
6298   k056832->cur_gfx_banks = bank % k056832->num_gfx_banks;
6299}
6300
6301void k056832_set_tile_bank( const device_config *device, int bank )
6302{
6303   k056832_state *k056832 = k056832_get_safe_token(device);
6304   k056832->uses_tile_banks = 1;
6305
6306   if (k056832->cur_tile_bank != bank)
6307   {
6308      k056832->cur_tile_bank = bank;
6309
6310      k056832_mark_plane_dirty(device, 0);
6311      k056832_mark_plane_dirty(device, 1);
6312      k056832_mark_plane_dirty(device, 2);
6313      k056832_mark_plane_dirty(device, 3);
6314   }
6315
6316   k056832_change_rombank(device);
6317}
6318
6319/* call if a game uses external linescroll */
6320void k056832_SetExtLinescroll( const device_config *device )
6321{
6322   k056832_state *k056832 = k056832_get_safe_token(device);
6323   k056832->use_ext_linescroll = 1;
6324}
6325
6326/* generic helper routine for ROM checksumming */
6327static int k056832_rom_read_b( const device_config *device, int offset, int blksize, int blksize2, int zerosec )
6328{
6329   k056832_state *k056832 = k056832_get_safe_token(device);
6330   UINT8 *rombase;
6331   int base, ret;
6332
6333   rombase = (UINT8 *)memory_region(device->machine, k056832->memory_region);
6334
6335   if ((k056832->rom_half) && (zerosec))
6336   {
6337      return 0;
6338   }
6339
6340   // add in the bank offset
6341   offset += (k056832->cur_gfx_banks * 0x2000);
6342
6343   // figure out the base of the ROM block
6344   base = (offset / blksize) * blksize2;
6345
6346   // get the starting offset of the proper word inside the block
6347   base += (offset % blksize) * 2;
6348
6349   if (k056832->rom_half)
6350   {
6351      ret = rombase[base + 1];
6352   }
6353   else
6354   {
6355      ret = rombase[base];
6356      k056832->rom_half = 1;
6357   }
6358
6359   return ret;
6360}
6361
6362READ16_DEVICE_HANDLER( k056832_5bpp_rom_word_r )
6363{
6364   if (mem_mask == 0xff00)
6365      return k056832_rom_read_b(device, offset * 2, 4, 5, 0)<<8;
6366   else if (mem_mask == 0x00ff)
6367      return k056832_rom_read_b(device, offset * 2 + 1, 4, 5, 0)<<16;
6368   else
6369   {
6370      //LOG(("Non-byte read of tilemap ROM, PC=%x (mask=%x)\n", cpu_get_pc(space->cpu), mem_mask));
6371   }
6372   return 0;
6373}
6374
6375READ32_DEVICE_HANDLER( k056832_5bpp_rom_long_r )
6376{
6377   if (mem_mask == 0xff000000)
6378      return k056832_rom_read_b(device, offset * 4, 4, 5, 0) << 24;
6379   else if (mem_mask == 0x00ff0000)
6380      return k056832_rom_read_b(device, offset * 4 + 1, 4, 5, 0) << 16;
6381   else if (mem_mask == 0x0000ff00)
6382      return k056832_rom_read_b(device, offset * 4 + 2, 4, 5, 0) << 8;
6383   else if (mem_mask == 0x000000ff)
6384      return k056832_rom_read_b(device, offset * 4 + 3, 4, 5, 1);
6385   else
6386   {
6387      //LOG(("Non-byte read of tilemap ROM, PC=%x (mask=%x)\n", cpu_get_pc(space->cpu), mem_mask));
6388   }
6389   return 0;
6390}
6391
6392READ32_DEVICE_HANDLER( k056832_6bpp_rom_long_r )
6393{
6394   if (mem_mask == 0xff000000)
6395      return k056832_rom_read_b(device, offset * 4, 4, 6, 0) << 24;
6396   else if (mem_mask == 0x00ff0000)
6397      return k056832_rom_read_b(device, offset * 4 + 1, 4, 6, 0) << 16;
6398   else if (mem_mask == 0x0000ff00)
6399      return k056832_rom_read_b(device, offset * 4 + 2, 4, 6, 0) << 8;
6400   else if (mem_mask == 0x000000ff)
6401      return k056832_rom_read_b(device, offset * 4 + 3, 4, 6, 0);
6402   else
6403   {
6404      //LOG(("Non-byte read of tilemap ROM, PC=%x (mask=%x)\n", cpu_get_pc(space->cpu), mem_mask));
6405   }
6406   return 0;
6407}
6408
6409READ16_DEVICE_HANDLER( k056832_rom_word_r )
6410{
6411   k056832_state *k056832 = k056832_get_safe_token(device);
6412   int ofs16, ofs8;
6413   UINT8 *rombase;
6414   int ret;
6415
6416   ofs16 = (offset / 8)*5;
6417   ofs8 = (offset / 4)*5;
6418
6419   ofs16 += (k056832->cur_gfx_banks * 5 * 1024);
6420   ofs8 += (k056832->cur_gfx_banks * 10 * 1024);
6421
6422   if (!k056832->rombase)
6423   {
6424      k056832->rombase = memory_region(device->machine, k056832->memory_region);
6425   }
6426   rombase = (UINT8 *)k056832->rombase;
6427
6428   ret = (rombase[ofs8 + 4]<<8);
6429   if ((offset % 8) >= 4)
6430   {
6431      ret |= (rombase[ofs16 + 1] << 24) | (rombase[ofs16 + 3] << 16);
6432   }
6433   else
6434   {
6435      ret |= (rombase[ofs16] << 24) | (rombase[ofs16 + 2] << 16);
6436   }
6437
6438   return ret;
6439}
6440
6441// data is arranged like this:
6442// 0000 1111 22 0000 1111 22
6443READ16_DEVICE_HANDLER( k056832_mw_rom_word_r )
6444{
6445   k056832_state *k056832 = k056832_get_safe_token(device);
6446   int bank = 10240 * k056832->cur_gfx_banks;
6447   int addr;
6448
6449   if (!k056832->rombase)
6450      k056832->rombase = memory_region(device->machine, k056832->memory_region);
6451
6452   if (k056832->regsb[2] & 0x8)
6453   {
6454      // we want only the 2s
6455      int bit;
6456      int res, temp;
6457
6458      bit = offset % 4;
6459      addr = (offset / 4) * 5;
6460
6461      temp = k056832->rombase[addr + 4 + bank];
6462
6463      switch (bit)
6464      {
6465         default:
6466         case 0:
6467            res = (temp & 0x80) << 5;
6468            res |= ((temp & 0x40) >> 2);
6469            break;
6470
6471         case 1:
6472            res = (temp & 0x20) << 7;
6473            res |= (temp & 0x10);
6474            break;
6475
6476         case 2:
6477            res = (temp & 0x08) << 9;
6478            res |= ((temp & 0x04) << 2);
6479            break;
6480
6481         case 3:
6482            res = (temp & 0x02) << 11;
6483            res |= ((temp & 0x01) << 4);
6484            break;
6485      }
6486
6487      return res;
6488   }
6489   else
6490   {
6491      // we want only the 0s and 1s.
6492
6493      addr = (offset >> 1) * 5;
6494
6495      if (offset & 1)
6496      {
6497         addr += 2;
6498      }
6499
6500      addr += bank;
6501
6502      return k056832->rombase[addr + 1] | (k056832->rombase[addr] << 8);
6503   }
6504
6505}
6506
6507READ16_DEVICE_HANDLER( k056832_bishi_rom_word_r )
6508{
6509   k056832_state *k056832 = k056832_get_safe_token(device);
6510   int addr = 0x4000 * k056832->cur_gfx_banks + offset;
6511
6512   if (!k056832->rombase)
6513      k056832->rombase = memory_region(device->machine, k056832->memory_region);
6514
6515   return k056832->rombase[addr + 2] | (k056832->rombase[addr] << 8);
6516}
6517
6518READ16_DEVICE_HANDLER( k056832_rom_word_8000_r )
6519{
6520   k056832_state *k056832 = k056832_get_safe_token(device);
6521   int addr = 0x8000 * k056832->cur_gfx_banks + 2 * offset;
6522
6523   if (!k056832->rombase)
6524      k056832->rombase = memory_region(device->machine, k056832->memory_region);
6525
6526   return k056832->rombase[addr + 2] | (k056832->rombase[addr] << 8);
6527}
6528
6529READ16_DEVICE_HANDLER( k056832_old_rom_word_r )
6530{
6531   k056832_state *k056832 = k056832_get_safe_token(device);
6532   int addr = 0x2000 * k056832->cur_gfx_banks + 2 * offset;
6533
6534   if (!k056832->rombase)
6535      k056832->rombase = memory_region(device->machine, k056832->memory_region);
6536
6537   return k056832->rombase[addr + 1] | (k056832->rombase[addr] << 8);
6538}
6539
6540READ32_DEVICE_HANDLER( k056832_rom_long_r )
6541{
6542   offset <<= 1;
6543   return (k056832_rom_word_r(device, offset + 1, 0xffff) | (k056832_rom_word_r(device, offset, 0xffff) << 16));
6544}
6545
6546/* only one page is mapped to videoram at a time through a window */
6547READ16_DEVICE_HANDLER( k056832_ram_word_r )
6548{
6549   k056832_state *k056832 = k056832_get_safe_token(device);
6550
6551   // reading from tile RAM resets the ROM readback "half" offset
6552   k056832->rom_half = 0;
6553
6554   return k056832->videoram[k056832->selected_page_x4096 + offset];
6555}
6556
6557READ16_DEVICE_HANDLER( k056832_ram_half_word_r )
6558{
6559   k056832_state *k056832 = k056832_get_safe_token(device);
6560   return k056832->videoram[k056832->selected_page_x4096 + (((offset << 1) & 0xffe) | ((offset >> 11) ^ 1))];
6561}
6562
6563READ32_DEVICE_HANDLER( k056832_ram_long_r )
6564{
6565   k056832_state *k056832 = k056832_get_safe_token(device);
6566   UINT16 *pMem = &k056832->videoram[k056832->selected_page_x4096 + offset * 2];
6567
6568   // reading from tile RAM resets the ROM readback "half" offset
6569   k056832->rom_half = 0;
6570
6571   return (pMem[0]<<16 | pMem[1]);
6572}
6573
6574/* special 8-bit handlers for Lethal Enforcers */
6575READ8_DEVICE_HANDLER( k056832_ram_code_lo_r )
6576{
6577   k056832_state *k056832 = k056832_get_safe_token(device);
6578   UINT16 *adr = &k056832->videoram[k056832->selected_page_x4096 + (offset * 2) + 1];
6579
6580   return *adr & 0xff;
6581}
6582
6583READ8_DEVICE_HANDLER( k056832_ram_code_hi_r )
6584{
6585   k056832_state *k056832 = k056832_get_safe_token(device);
6586   UINT16 *adr = &k056832->videoram[k056832->selected_page_x4096 + (offset * 2) + 1];
6587
6588   return *adr >> 8;
6589}
6590
6591READ8_DEVICE_HANDLER( k056832_ram_attr_lo_r )
6592{
6593   k056832_state *k056832 = k056832_get_safe_token(device);
6594   UINT16 *adr = &k056832->videoram[k056832->selected_page_x4096 + (offset * 2)];
6595
6596   return *adr & 0xff;
6597}
6598
6599READ8_DEVICE_HANDLER( k056832_ram_attr_hi_r )
6600{
6601   k056832_state *k056832 = k056832_get_safe_token(device);
6602   UINT16 *adr = &k056832->videoram[k056832->selected_page_x4096 + (offset * 2)];
6603
6604   return *adr >> 8;
6605}
6606
6607WRITE8_DEVICE_HANDLER( k056832_ram_code_lo_w )
6608{
6609   k056832_state *k056832 = k056832_get_safe_token(device);
6610   UINT16 *adr = &k056832->videoram[k056832->selected_page_x4096 + (offset * 2) + 1];
6611
6612   *adr &= 0xff00;
6613   *adr |= data;
6614
6615   if (!(k056832->regs[0] & 0x02))   // external linescroll enable
6616   {
6617      if (k056832->page_tile_mode[k056832->selected_page])
6618         tilemap_mark_tile_dirty(k056832->tilemap[k056832->selected_page], offset);
6619      else
6620         k056832_mark_line_dirty(k056832->selected_page, offset);
6621   }
6622}
6623
6624WRITE8_DEVICE_HANDLER( k056832_ram_code_hi_w )
6625{
6626   k056832_state *k056832 = k056832_get_safe_token(device);
6627   UINT16 *adr = &k056832->videoram[k056832->selected_page_x4096 + (offset * 2) + 1];
6628
6629   *adr &= 0x00ff;
6630   *adr |= data << 8;
6631
6632   if (!(k056832->regs[0] & 0x02))   // external linescroll enable
6633   {
6634      if (k056832->page_tile_mode[k056832->selected_page])
6635         tilemap_mark_tile_dirty(k056832->tilemap[k056832->selected_page], offset);
6636      else
6637         k056832_mark_line_dirty(k056832->selected_page, offset);
6638   }
6639}
6640
6641WRITE8_DEVICE_HANDLER( k056832_ram_attr_lo_w )
6642{
6643   k056832_state *k056832 = k056832_get_safe_token(device);
6644   UINT16 *adr = &k056832->videoram[k056832->selected_page_x4096 + (offset * 2)];
6645
6646   *adr &= 0xff00;
6647   *adr |= data;
6648
6649   if (!(k056832->regs[0] & 0x02))   // external linescroll enable
6650   {
6651      if (k056832->page_tile_mode[k056832->selected_page])
6652         tilemap_mark_tile_dirty(k056832->tilemap[k056832->selected_page], offset);
6653      else
6654         k056832_mark_line_dirty(k056832->selected_page, offset);
6655   }
6656}
6657
6658WRITE8_DEVICE_HANDLER( k056832_ram_attr_hi_w )
6659{
6660   k056832_state *k056832 = k056832_get_safe_token(device);
6661   UINT16 *adr = &k056832->videoram[k056832->selected_page_x4096 + (offset * 2)];
6662
6663   *adr &= 0x00ff;
6664   *adr |= data << 8;
6665
6666   if (!(k056832->regs[0] & 0x02))   // external linescroll enable
6667   {
6668      if (k056832->page_tile_mode[k056832->selected_page])
6669         tilemap_mark_tile_dirty(k056832->tilemap[k056832->selected_page], offset);
6670      else
6671         k056832_mark_line_dirty(k056832->selected_page, offset);
6672   }
6673}
6674
6675WRITE16_DEVICE_HANDLER( k056832_ram_word_w )
6676{
6677   k056832_state *k056832 = k056832_get_safe_token(device);
6678   UINT16 *tile_ptr;
6679   UINT16 old_mask, old_data;
6680
6681   tile_ptr = &k056832->videoram[k056832->selected_page_x4096 + offset];
6682   old_mask = ~mem_mask;
6683   old_data = *tile_ptr;
6684   data = (data & mem_mask) | (old_data & old_mask);
6685
6686   if(data != old_data)
6687   {
6688      offset >>= 1;
6689      *tile_ptr = data;
6690
6691      if (k056832->page_tile_mode[k056832->selected_page])
6692         tilemap_mark_tile_dirty(k056832->tilemap[k056832->selected_page], offset);
6693      else
6694         k056832_mark_line_dirty(k056832->selected_page, offset);
6695   }
6696}
6697
6698WRITE16_DEVICE_HANDLER( k056832_ram_half_word_w )
6699{
6700   k056832_state *k056832 = k056832_get_safe_token(device);
6701   UINT16 *adr = &k056832->videoram[k056832->selected_page_x4096 + (((offset << 1) & 0xffe) | 1)];
6702   UINT16 old = *adr;
6703
6704   COMBINE_DATA(adr);
6705   if(*adr != old)
6706   {
6707      int dofs = (((offset << 1) & 0xffe) | 1);
6708
6709      dofs >>= 1;
6710
6711      if (k056832->page_tile_mode[k056832->selected_page])
6712         tilemap_mark_tile_dirty(k056832->tilemap[k056832->selected_page], dofs);
6713      else
6714             k056832_mark_line_dirty(k056832->selected_page, dofs);
6715   }
6716}
6717
6718WRITE32_DEVICE_HANDLER( k056832_ram_long_w )
6719{
6720   k056832_state *k056832 = k056832_get_safe_token(device);
6721   UINT16 *tile_ptr;
6722   UINT32 old_mask, old_data;
6723
6724   tile_ptr = &k056832->videoram[k056832->selected_page_x4096 + offset * 2];
6725   old_mask = ~mem_mask;
6726   old_data = (UINT32)tile_ptr[0] << 16 | (UINT32)tile_ptr[1];
6727   data = (data & mem_mask) | (old_data & old_mask);
6728
6729   if (data != old_data)
6730   {
6731      tile_ptr[0] = data >> 16;
6732      tile_ptr[1] = data;
6733
6734      if (k056832->page_tile_mode[k056832->selected_page])
6735         tilemap_mark_tile_dirty(k056832->tilemap[k056832->selected_page], offset);
6736      else
6737         k056832_mark_line_dirty(k056832->selected_page, offset);
6738   }
6739}
6740
6741WRITE16_DEVICE_HANDLER( k056832_word_w )
6742{
6743   k056832_state *k056832 = k056832_get_safe_token(device);
6744   int layer, flip, mask, i;
6745   UINT32 old_data, new_data;
6746
6747   old_data = k056832->regs[offset];
6748   COMBINE_DATA(&k056832->regs[offset]);
6749   new_data = k056832->regs[offset];
6750
6751   if (new_data != old_data)
6752   {
6753      switch(offset)
6754      {
6755         /* -x-- ---- dotclock select: 0=8Mhz, 1=6Mhz (not used by GX)
6756             * --x- ---- screen flip y
6757             * ---x ---- screen flip x
6758             * ---- --x- external linescroll RAM page enable
6759             */
6760         case 0x00/2:
6761            if ((new_data & 0x30) != (old_data & 0x30))
6762            {
6763               flip = 0;
6764               if (new_data & 0x20) flip |= TILEMAP_FLIPY;
6765               if (new_data & 0x10) flip |= TILEMAP_FLIPX;
6766               for (i = 0; i < K056832_PAGE_COUNT; i++)
6767               {
6768                  tilemap_set_flip(k056832->tilemap[i], flip);
6769               }
6770            }
6771
6772            if ((new_data & 0x02) != (old_data & 0x02))
6773            {
6774               k056832_change_rambank(device);
6775            }
6776         break;
6777
6778         /* -------- -----xxx external irqlines enable (not used by GX)
6779             * -------- xx------ tilemap attribute config (FBIT0 and FBIT1)
6780             */
6781         //case 0x06/2: break;
6782
6783         // -------- ----DCBA tile mode: 0=512x1, 1=8x8
6784         // -------- DCBA---- synchronous scroll: 0=off, 1=on
6785         case 0x08/2:
6786            for (layer = 0; layer < 4; layer++)
6787            {
6788               mask = 1 << layer;
6789               i = new_data & mask;
6790               if (i != (old_data & mask))
6791               {
6792                  k056832->layer_tile_mode[layer] = i;
6793                  k056832_mark_plane_dirty(device, layer);
6794               }
6795            }
6796         break;
6797
6798         /* -------- ------xx layer A linescroll config
6799             * -------- ----xx-- layer B linescroll config
6800             * -------- --xx---- layer C linescroll config
6801             * -------- xx------ layer D linescroll config
6802             *
6803             * 0: linescroll
6804             * 2: rowscroll
6805             * 3: xy scroll
6806             */
6807         //case 0x0a/2: break;
6808
6809         case 0x32/2:
6810            k056832_change_rambank(device);
6811         break;
6812
6813         case 0x34/2: /* ROM bank select for checksum */
6814         case 0x36/2: /* secondary ROM bank select for use with tile banking */
6815            k056832_change_rombank(device);
6816         break;
6817
6818         // extended tile address
6819         //case 0x38/2: break;
6820
6821         // 12 bit (signed) horizontal offset if global HFLIP enabled
6822         //case 0x3a/2: break;
6823
6824         // 11 bit (signed) vertical offset if global VFLIP enabled
6825         //case 0x3c/2: break;
6826
6827         default:
6828            layer = offset & 3;
6829
6830            if (offset >= 0x10/2 && offset <= 0x16/2)
6831            {
6832               k056832->y[layer] = (new_data & 0x18) >> 3;
6833               k056832->h[layer] = (new_data & 0x3);
6834               k056832->active_layer = layer;
6835               k056832_update_page_layout(device);
6836            } else
6837
6838            if (offset >= 0x18/2 && offset <= 0x1e/2)
6839            {
6840               k056832->x[layer] = (new_data & 0x18) >> 3;
6841               k056832->w[layer] = (new_data & 0x03);
6842               k056832->active_layer = layer;
6843               k056832_update_page_layout(device);
6844            } else
6845
6846            if (offset >= 0x20/2 && offset <= 0x26/2)
6847            {
6848               k056832->dy[layer] = (INT16)new_data;
6849            } else
6850
6851            if (offset >= 0x28/2 && offset <= 0x2e/2)
6852            {
6853               k056832->dx[layer] = (INT16)new_data;
6854            }
6855         break;
6856      }
6857   }
6858}
6859
6860WRITE32_DEVICE_HANDLER( k056832_long_w )
6861{
6862   // GX does access of all 3 widths (8/16/32) so we can't do the
6863   // if (ACCESSING_xxx) trick.  in particular, 8-bit writes
6864   // are used to the tilemap bank register.
6865   offset <<= 1;
6866   k056832_word_w(device, offset, data >> 16, mem_mask >> 16);
6867   k056832_word_w(device, offset + 1, data, mem_mask);
6868}
6869
6870WRITE16_DEVICE_HANDLER( k056832_b_word_w )
6871{
6872   k056832_state *k056832 = k056832_get_safe_token(device);
6873   COMBINE_DATA(&k056832->regsb[offset]);
6874}
6875
6876WRITE8_DEVICE_HANDLER( k056832_w )
6877{
6878   if (offset & 1)
6879   {
6880      k056832_word_w(device, (offset >> 1), data, 0x00ff);
6881   }
6882   else
6883   {
6884      k056832_word_w(device, (offset >> 1), data << 8, 0xff00);
6885   }
6886}
6887
6888WRITE8_DEVICE_HANDLER( k056832_b_w )
6889{
6890   if (offset & 1)
6891   {
6892      k056832_b_word_w(device, (offset >> 1), data, 0x00ff);
6893   }
6894   else
6895   {
6896      k056832_b_word_w(device, (offset >> 1), data<<8, 0xff00);
6897   }
6898}
6899
6900WRITE32_DEVICE_HANDLER( k056832_b_long_w )
6901{
6902   if (ACCESSING_BITS_16_31)
6903   {
6904      k056832_b_word_w(device, offset << 1, data >> 16, mem_mask >> 16);
6905   }
6906   if (ACCESSING_BITS_0_15)
6907   {
6908      k056832_b_word_w(device, (offset << 1) + 1, data, mem_mask);
6909   }
6910}
6911
6912static int k056832_update_linemap( const device_config *device, bitmap_t *bitmap, int page, int flags )
6913{
6914   k056832_state *k056832 = k056832_get_safe_token(device);
6915
6916   if (k056832->page_tile_mode[page])
6917      return(0);
6918   if (!k056832->linemap_enabled)
6919      return(1);
6920
6921   {
6922      rectangle zerorect;
6923      tilemap *tmap;
6924      UINT32 *dirty;
6925      int all_dirty;
6926      bitmap_t* xprmap;
6927      UINT8 *xprdata;
6928
6929      tmap = k056832->tilemap[page];
6930      xprmap  = tilemap_get_flagsmap(tmap);
6931      xprdata = tilemap_get_tile_flags(tmap);
6932
6933      dirty = k056832->line_dirty[page];
6934      all_dirty = k056832->all_lines_dirty[page];
6935
6936      if (all_dirty)
6937      {
6938         dirty[7] = dirty[6] = dirty[5] = dirty[4] = dirty[3] = dirty[2] = dirty[1] = dirty[0] = 0;
6939         k056832->all_lines_dirty[page] = 0;
6940
6941         // force tilemap into a clean, static state
6942         // *really ugly but it minimizes alteration to tilemap.c
6943         memset(&zerorect, 0, sizeof(rectangle));   // zero dimension
6944         tilemap_draw(bitmap, &zerorect, tmap, 0, 0);   // dummy call to reset tile_dirty_map
6945         bitmap_fill(xprmap, 0, 0);                  // reset pixel transparency_bitmap;
6946         memset(xprdata, TILEMAP_PIXEL_LAYER0, 0x800);   // reset tile transparency_data;
6947      }
6948      else
6949      {
6950         if (!(dirty[0] | dirty[1] | dirty[2] | dirty[3] | dirty[4] | dirty[5] | dirty[6] | dirty[7]))
6951            return 0;
6952      }
6953
6954#if 0   /* this code is broken.. really broken .. gijoe uses it for some line/column scroll style effects (lift level of attract mode)
6955            we REALLY shouldn't be writing directly back into the pixmap, surely this should
6956            be done when rendering instead
6957
6958        */
6959      {
6960
6961         bitmap_t *pixmap;
6962         running_machine *machine = device->machine;
6963
6964         UINT8 code_transparent, code_opaque;
6965         const pen_t *pal_ptr;
6966         const UINT8  *src_ptr;
6967         UINT8  *xpr_ptr;
6968         UINT16 *dst_ptr;
6969         UINT16 pen, basepen;
6970         int count, src_pitch, src_modulo;
6971         int dst_pitch;
6972         int line;
6973         const gfx_element *src_gfx;
6974         int offs, mask;
6975
6976         #define LINE_WIDTH 512
6977
6978         #define DRAW_PIX(N) \
6979            pen = src_ptr[N]; \
6980            if (pen) \
6981            { pen += basepen; xpr_ptr[count+N] = TILEMAP_PIXEL_LAYER0; dst_ptr[count+N] = pen; } else \
6982            { xpr_ptr[count+N] = 0; }
6983
6984         pixmap  = k056832->pixmap[page];
6985         pal_ptr = machine->pens;
6986         src_gfx = machine->gfx[k056832->gfxnum];
6987         src_pitch  = src_gfx->line_modulo;
6988         src_modulo = src_gfx->char_modulo;
6989         dst_pitch  = pixmap->rowpixels;
6990
6991         for (line = 0; line < 256; line++)
6992         {
6993            tile_data tileinfo = {0};
6994
6995            dst_ptr = BITMAP_ADDR16(pixmap, line, 0);
6996            xpr_ptr = BITMAP_ADDR8(xprmap, line, 0);
6997
6998            if (!all_dirty)
6999            {
7000               offs = line >> 5;
7001               mask = 1 << (line & 0x1f);
7002               if (!(dirty[offs] & mask)) continue;
7003               dirty[offs] ^= mask;
7004            }
7005
7006            for (count = 0; count < LINE_WIDTH; count += 8)
7007            {
7008               k056832_get_tile_info(device, &tileinfo, line, page);
7009               basepen = tileinfo.palette_base;
7010               code_transparent = tileinfo.category;
7011               code_opaque = code_transparent | TILEMAP_PIXEL_LAYER0;
7012
7013               src_ptr = tileinfo.pen_data + count * 8;//src_base + ((tileinfo.tile_number & ~7) << 6);
7014
7015               DRAW_PIX(0)
7016               DRAW_PIX(1)
7017               DRAW_PIX(2)
7018               DRAW_PIX(3)
7019               DRAW_PIX(4)
7020               DRAW_PIX(5)
7021               DRAW_PIX(6)
7022               DRAW_PIX(7)
7023            }
7024         }
7025
7026         #undef LINE_WIDTH
7027         #undef DRAW_PIX
7028      }
7029#endif
7030
7031   }
7032
7033   return(0);
7034}
7035
7036void k056832_tilemap_draw( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int layer, UINT32 flags, UINT32 priority )
7037{
7038   k056832_state *k056832 = k056832_get_safe_token(device);
7039   UINT32 last_dx, last_visible, new_colorbase, last_active;
7040   int sx, sy, ay, tx, ty, width, height;
7041   int clipw, clipx, cliph, clipy, clipmaxy;
7042   int line_height, line_endy, line_starty, line_y;
7043   int sdat_start, sdat_walk, sdat_adv, sdat_wrapmask, sdat_offs;
7044   int pageIndex, flipx, flipy, corr, r, c;
7045   int cminy, cmaxy, cminx, cmaxx;
7046   int dminy, dmaxy, dminx, dmaxx;
7047   rectangle drawrect;
7048   tilemap *tmap;
7049   UINT16 *p_scroll_data;
7050   UINT16 ram16[2];
7051
7052   int rowstart = k056832->y[layer];
7053   int colstart = k056832->x[layer];
7054   int rowspan  = k056832->h[layer] + 1;
7055   int colspan  = k056832->w[layer] + 1;
7056   int dy = k056832->dy[layer];
7057   int dx = k056832->dx[layer];
7058   int scrollbank = ((k056832->regs[0x18] >> 1) & 0xc) | (k056832->regs[0x18] & 3);
7059   int scrollmode = k056832->regs[0x05] >> (k056832->lsram_page[layer][0] << 1) & 3;
7060
7061   if (k056832->use_ext_linescroll)
7062   {
7063      scrollbank = K056832_PAGE_COUNT;
7064   }
7065
7066   height = rowspan * K056832_PAGE_HEIGHT;
7067   width  = colspan * K056832_PAGE_WIDTH;
7068
7069   cminx = cliprect->min_x;
7070   cmaxx = cliprect->max_x;
7071   cminy = cliprect->min_y;
7072   cmaxy = cliprect->max_y;
7073
7074   // flip correction registers
7075   flipy = k056832->regs[0] & 0x20;
7076   if (flipy)
7077   {
7078      corr = k056832->regs[0x3c/2];
7079      if (corr & 0x400)
7080         corr |= 0xfffff800;
7081   }
7082   else
7083      corr = 0;
7084
7085   dy += corr;
7086   ay = (unsigned)(dy - k056832->layer_offs[layer][1]) % height;
7087
7088   flipx = k056832->regs[0] & 0x10;
7089   if (flipx)
7090   {
7091      corr = k056832->regs[0x3a/2];
7092      if (corr & 0x800)
7093         corr |= 0xfffff000;
7094   }
7095   else
7096      corr = 0;
7097
7098   corr -= k056832->layer_offs[layer][0];
7099
7100   if (scrollmode == 0 && (flags & K056832_DRAW_FLAG_FORCE_XYSCROLL))
7101   {
7102      scrollmode = 3;
7103      flags &= ~K056832_DRAW_FLAG_FORCE_XYSCROLL;
7104   }
7105
7106   switch( scrollmode )
7107   {
7108      case 0: // linescroll
7109         p_scroll_data = &k056832->videoram[scrollbank<<12] + (k056832->lsram_page[layer][1]>>1);
7110         line_height = 1;
7111         sdat_wrapmask = 0x3ff;
7112         sdat_adv = 2;
7113      break;
7114      case 2: // rowscroll
7115
7116         p_scroll_data = &k056832->videoram[scrollbank << 12] + (k056832->lsram_page[layer][1] >> 1);
7117         line_height = 8;
7118         sdat_wrapmask = 0x3ff;
7119         sdat_adv = 16;
7120      break;
7121      default: // xyscroll
7122         p_scroll_data = ram16;
7123         line_height = K056832_PAGE_HEIGHT;
7124         sdat_wrapmask = 0;
7125         sdat_adv = 0;
7126         ram16[0] = 0;
7127         ram16[1] = dx;
7128   }
7129   if (flipy)
7130      sdat_adv = -sdat_adv;
7131
7132   last_active = k056832->active_layer;
7133   new_colorbase = (k056832->k055555 != NULL) ? k055555_get_palette_index(k056832->k055555, layer) : 0;
7134
7135   for (r = 0; r < rowspan; r++)
7136   {
7137      if (rowspan > 1)
7138      {
7139         sy = ay;
7140         ty = r * K056832_PAGE_HEIGHT;
7141
7142         if (!flipy)
7143         {
7144            // handle bottom-edge wraparoundness and cull off-screen tilemaps
7145            if ((r == 0) && (sy > height - K056832_PAGE_HEIGHT)) sy -= height;
7146            if ((sy + K056832_PAGE_HEIGHT <= ty) || (sy - K056832_PAGE_HEIGHT >= ty)) continue;
7147
7148            // switch frame of reference and clip y
7149            if ((ty -= sy) >= 0)
7150            {
7151               cliph = K056832_PAGE_HEIGHT - ty;
7152               clipy = line_starty = ty;
7153               line_endy = K056832_PAGE_HEIGHT;
7154               sdat_start = 0;
7155            }
7156            else
7157            {
7158               cliph = K056832_PAGE_HEIGHT + ty;
7159               ty = -ty;
7160               clipy = line_starty = 0;
7161               line_endy = cliph;
7162               sdat_start = ty;
7163               if (scrollmode == 2) { sdat_start &= ~7; line_starty -= ty & 7; }
7164            }
7165         }
7166         else
7167         {
7168            ty += K056832_PAGE_HEIGHT;
7169
7170            // handle top-edge wraparoundness and cull off-screen tilemaps
7171            if ((r == rowspan - 1) && (sy < K056832_PAGE_HEIGHT)) sy += height;
7172            if ((sy + K056832_PAGE_HEIGHT <= ty) || (sy - K056832_PAGE_HEIGHT >= ty)) continue;
7173
7174            // switch frame of reference and clip y
7175            if ((ty -= sy) <= 0)
7176            {
7177               cliph = K056832_PAGE_HEIGHT + ty;
7178               clipy = line_starty = -ty;
7179               line_endy = K056832_PAGE_HEIGHT;
7180               sdat_start = K056832_PAGE_HEIGHT - 1;
7181               if (scrollmode == 2) sdat_start &= ~7;
7182            }
7183            else
7184            {
7185               cliph = K056832_PAGE_HEIGHT - ty;
7186               clipy = line_starty = 0;
7187               line_endy = cliph;
7188               sdat_start = cliph - 1;
7189               if (scrollmode == 2)
7190               {
7191                  sdat_start &= ~7;
7192                  line_starty -= ty & 7;
7193               }
7194            }
7195         }
7196      }
7197      else
7198      {
7199         cliph = line_endy = K056832_PAGE_HEIGHT;
7200         clipy = line_starty = 0;
7201
7202         if (!flipy)
7203            sdat_start = dy;
7204         else
7205            /*
7206                    doesn't work with Metamorphic Force and Martial Champion (software Y-flipped) but
7207                    LE2U (naturally Y-flipped) seems to expect this condition as an override.
7208
7209                    sdat_start = K056832_PAGE_HEIGHT-1 -dy;
7210                */
7211         sdat_start = K056832_PAGE_HEIGHT - 1;
7212
7213         if (scrollmode == 2) { sdat_start &= ~7; line_starty -= dy & 7; }
7214      }
7215
7216      sdat_start += r * K056832_PAGE_HEIGHT;
7217      sdat_start <<= 1;
7218
7219      clipmaxy = clipy + cliph - 1;
7220
7221      for (c = 0; c < colspan; c++)
7222      {
7223         pageIndex = (((rowstart + r) & 3) << 2) + ((colstart + c) & 3);
7224
7225         if (k056832->layer_association)
7226         {
7227            if (k056832->layer_assoc_with_page[pageIndex] != layer)
7228               continue;
7229         }
7230         else
7231         {
7232            if (k056832->layer_assoc_with_page[pageIndex] == -1)
7233               continue;
7234
7235            k056832->active_layer = layer;
7236         }
7237
7238         if (k056832->k055555 != NULL)      // are we using k055555 palette?
7239         {
7240            if (k056832->last_colorbase[pageIndex] != new_colorbase)
7241            {
7242               k056832->last_colorbase[pageIndex] = new_colorbase;
7243               k056832_mark_page_dirty(device, pageIndex);
7244            }
7245         }
7246         else
7247         {
7248            if (!pageIndex)
7249               k056832->active_layer = 0;
7250         }
7251
7252         if (k056832_update_linemap(device, bitmap, pageIndex, flags))
7253            continue;
7254
7255         tmap = k056832->tilemap[pageIndex];
7256         tilemap_set_scrolly(tmap, 0, ay);
7257
7258         last_dx = 0x100000;
7259         last_visible = 0;
7260
7261         for (sdat_walk = sdat_start, line_y = line_starty; line_y < line_endy; sdat_walk += sdat_adv, line_y += line_height)
7262         {
7263            dminy = line_y;
7264            dmaxy = line_y + line_height - 1;
7265
7266            if (dminy < clipy) dminy = clipy;
7267            if (dmaxy > clipmaxy) dmaxy = clipmaxy;
7268            if (dminy > cmaxy || dmaxy < cminy) continue;
7269
7270            sdat_offs = sdat_walk & sdat_wrapmask;
7271
7272            drawrect.min_y = (dminy < cminy ) ? cminy : dminy;
7273            drawrect.max_y = (dmaxy > cmaxy ) ? cmaxy : dmaxy;
7274
7275            dx = ((int)p_scroll_data[sdat_offs]<<16 | (int)p_scroll_data[sdat_offs + 1]) + corr;
7276
7277            if (last_dx == dx) { if (last_visible) goto LINE_SHORTCIRCUIT; continue; }
7278            last_dx = dx;
7279
7280            if (colspan > 1)
7281            {
7282               //sx = (unsigned)dx % width;
7283               sx = (unsigned)dx & (width-1);
7284
7285               //tx = c * K056832_PAGE_WIDTH;
7286               tx = c << 9;
7287
7288               if (!flipx)
7289               {
7290                  // handle right-edge wraparoundness and cull off-screen tilemaps
7291                  if ((c == 0) && (sx > width - K056832_PAGE_WIDTH)) sx -= width;
7292                  if ((sx + K056832_PAGE_WIDTH <= tx) || (sx - K056832_PAGE_WIDTH >= tx))
7293                     { last_visible = 0; continue; }
7294
7295                  // switch frame of reference and clip x
7296                  if ((tx -= sx) <= 0) { clipw = K056832_PAGE_WIDTH + tx; clipx = 0; }
7297                  else { clipw = K056832_PAGE_WIDTH - tx; clipx = tx; }
7298               }
7299               else
7300               {
7301                  tx += K056832_PAGE_WIDTH;
7302
7303                  // handle left-edge wraparoundness and cull off-screen tilemaps
7304                  if ((c == colspan-1) && (sx < K056832_PAGE_WIDTH)) sx += width;
7305                  if ((sx + K056832_PAGE_WIDTH <= tx) || (sx - K056832_PAGE_WIDTH >= tx))
7306                     { last_visible = 0; continue; }
7307
7308                  // switch frame of reference and clip y
7309                  if ((tx -= sx) >= 0) { clipw = K056832_PAGE_WIDTH - tx; clipx = 0; }
7310                  else { clipw = K056832_PAGE_WIDTH + tx; clipx = -tx; }
7311               }
7312            }
7313            else { clipw = K056832_PAGE_WIDTH; clipx = 0; }
7314
7315            last_visible = 1;
7316
7317            dminx = clipx;
7318            dmaxx = clipx + clipw - 1;
7319
7320            drawrect.min_x = (dminx < cminx ) ? cminx : dminx;
7321            drawrect.max_x = (dmaxx > cmaxx ) ? cmaxx : dmaxx;
7322
7323            // soccer superstars visible area is >512 pixels, this causes problems with the logic because
7324            // the tilemaps are 512 pixels across.  Assume that if the limits were set as below that we
7325            // want the tilemap to be drawn on the right hand side..  this is probably not the correct
7326            // logic, but it works.
7327            if ((drawrect.min_x>0) && (drawrect.max_x==511))
7328               drawrect.max_x=cliprect->max_x;
7329
7330            tilemap_set_scrollx(tmap, 0, dx);
7331
7332            LINE_SHORTCIRCUIT:
7333               tilemap_draw(bitmap, &drawrect, tmap, flags, priority);
7334
7335         } // end of line loop
7336      } // end of column loop
7337   } // end of row loop
7338
7339   k056832->active_layer = last_active;
7340} // end of function
7341
7342
7343void k056832_tilemap_draw_dj( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int layer, UINT32 flags, UINT32 priority )
7344{
7345   k056832_state *k056832 = k056832_get_safe_token(device);
7346   UINT32 last_dx, last_visible, new_colorbase, last_active;
7347   int sx, sy, ay, tx, ty, width, height;
7348   int clipw, clipx, cliph, clipy, clipmaxy;
7349   int line_height, line_endy, line_starty, line_y;
7350   int sdat_start, sdat_walk, sdat_adv, sdat_wrapmask, sdat_offs;
7351   int pageIndex, flipx, flipy, corr, r, c;
7352   int cminy, cmaxy, cminx, cmaxx;
7353   int dminy, dmaxy, dminx, dmaxx;
7354   rectangle drawrect;
7355   tilemap *tmap;
7356   UINT16 *p_scroll_data;
7357   UINT16 ram16[2];
7358
7359   int rowstart = k056832->y[layer];
7360   int colstart = k056832->x[layer];
7361   int rowspan  = k056832->h[layer] + 1;
7362   int colspan  = k056832->w[layer] + 1;
7363   int dy = k056832->dy[layer];
7364   int dx = k056832->dx[layer];
7365   int scrollbank = ((k056832->regs[0x18] >> 1) & 0xc) | (k056832->regs[0x18] & 3);
7366   int scrollmode = k056832->regs[0x05] >> (k056832->lsram_page[layer][0] << 1) & 3;
7367   int need_wrap = -1;
7368
7369   height = rowspan * K056832_PAGE_HEIGHT;
7370   width  = colspan * K056832_PAGE_WIDTH;
7371
7372   cminx = cliprect->min_x;
7373   cmaxx = cliprect->max_x;
7374   cminy = cliprect->min_y;
7375   cmaxy = cliprect->max_y;
7376
7377   // flip correction registers
7378   flipy = k056832->regs[0] & 0x20;
7379   if (flipy)
7380   {
7381      corr = k056832->regs[0x3c/2];
7382      if (corr & 0x400)
7383         corr |= 0xfffff800;
7384   }
7385   else
7386      corr = 0;
7387   dy += corr;
7388   ay = (unsigned)(dy - k056832->layer_offs[layer][1]) % height;
7389
7390   flipx = k056832->regs[0] & 0x10;
7391   if (flipx)
7392   {
7393      corr = k056832->regs[0x3a/2];
7394      if (corr & 0x800)
7395         corr |= 0xfffff000;
7396   }
7397   else
7398      corr = 0;
7399
7400   corr -= k056832->layer_offs[layer][0];
7401
7402   if (scrollmode == 0 && (flags & K056832_DRAW_FLAG_FORCE_XYSCROLL))
7403   {
7404      scrollmode = 3;
7405      flags &= ~K056832_DRAW_FLAG_FORCE_XYSCROLL;
7406   }
7407
7408   switch( scrollmode )
7409   {
7410      case 0: // linescroll
7411         p_scroll_data = &k056832->videoram[scrollbank << 12] + (k056832->lsram_page[layer][1] >> 1);
7412         line_height = 1;
7413         sdat_wrapmask = 0x3ff;
7414         sdat_adv = 2;
7415      break;
7416      case 2: // rowscroll
7417         p_scroll_data = &k056832->videoram[scrollbank << 12] + (k056832->lsram_page[layer][1] >> 1);
7418         line_height = 8;
7419         sdat_wrapmask = 0x3ff;
7420         sdat_adv = 16;
7421      break;
7422      default: // xyscroll
7423         p_scroll_data = ram16;
7424         line_height = K056832_PAGE_HEIGHT;
7425         sdat_wrapmask = 0;
7426         sdat_adv = 0;
7427         ram16[0] = 0;
7428         ram16[1] = dx;
7429   }
7430   if (flipy)
7431      sdat_adv = -sdat_adv;
7432
7433   last_active = k056832->active_layer;
7434   new_colorbase = (k056832->k055555 != NULL) ? k055555_get_palette_index(k056832->k055555, layer) : 0;
7435
7436   for (r = 0; r <= rowspan; r++)
7437   {
7438      sy = ay;
7439      if (r == rowspan)
7440      {
7441         if (need_wrap < 0)
7442            continue;
7443
7444         ty = need_wrap * K056832_PAGE_HEIGHT;
7445      }
7446      else
7447      {
7448         ty = r * K056832_PAGE_HEIGHT;
7449      }
7450
7451      // cull off-screen tilemaps
7452      if ((sy + height <= ty) || (sy - height >= ty))
7453         continue;
7454
7455      // switch frame of reference
7456      ty -= sy;
7457
7458         // handle top-edge wraparoundness
7459         if (r == rowspan)
7460         {
7461            cliph = K056832_PAGE_HEIGHT + ty;
7462            clipy = line_starty = 0;
7463            line_endy = cliph;
7464            ty = -ty;
7465            sdat_start = ty;
7466            if (scrollmode == 2) { sdat_start &= ~7; line_starty -= ty & 7; }
7467         }
7468
7469         // clip y
7470         else
7471         {
7472            if (ty < 0)
7473               ty += height;
7474
7475            clipy = ty;
7476            cliph = K056832_PAGE_HEIGHT;
7477
7478            if (clipy + cliph > height)
7479            {
7480               cliph = height - clipy;
7481               need_wrap =r;
7482            }
7483
7484            line_starty = ty;
7485            line_endy = line_starty + cliph;
7486            sdat_start = 0;
7487         }
7488
7489      if (r == rowspan)
7490         sdat_start += need_wrap * K056832_PAGE_HEIGHT;
7491      else
7492         sdat_start += r * K056832_PAGE_HEIGHT;
7493      sdat_start <<= 1;
7494
7495      clipmaxy = clipy + cliph - 1;
7496
7497      for (c = 0; c < colspan; c++)
7498      {
7499         if (r == rowspan)
7500            pageIndex = (((rowstart + need_wrap) & 3) << 2) + ((colstart + c) & 3);
7501         else
7502            pageIndex = (((rowstart + r) & 3) << 2) + ((colstart + c) & 3);
7503
7504         if (k056832->layer_association)
7505         {
7506            if (k056832->layer_assoc_with_page[pageIndex] != layer)
7507               continue;
7508         }
7509         else
7510         {
7511            if (k056832->layer_assoc_with_page[pageIndex] == -1) continue;
7512            k056832->active_layer = layer;
7513         }
7514
7515         if (k056832->k055555 != NULL)      // are we using k055555 palette?
7516         {
7517            if (k056832->last_colorbase[pageIndex] != new_colorbase)
7518            {
7519               k056832->last_colorbase[pageIndex] = new_colorbase;
7520               k056832_mark_page_dirty(device, pageIndex);
7521            }
7522         }
7523         else
7524         {
7525            if (!pageIndex)
7526               k056832->active_layer = 0;
7527         }
7528
7529         if (k056832_update_linemap(device, bitmap, pageIndex, flags))
7530            continue;
7531
7532         tmap = k056832->tilemap[pageIndex];
7533         tilemap_set_scrolly(tmap, 0, ay);
7534
7535         last_dx = 0x100000;
7536         last_visible = 0;
7537
7538         for (sdat_walk = sdat_start, line_y = line_starty; line_y < line_endy; sdat_walk += sdat_adv, line_y += line_height)
7539         {
7540            dminy = line_y;
7541            dmaxy = line_y + line_height - 1;
7542
7543            if (dminy < clipy) dminy = clipy;
7544            if (dmaxy > clipmaxy) dmaxy = clipmaxy;
7545            if (dminy > cmaxy || dmaxy < cminy) continue;
7546
7547            sdat_offs = sdat_walk & sdat_wrapmask;
7548
7549            drawrect.min_y = (dminy < cminy ) ? cminy : dminy;
7550            drawrect.max_y = (dmaxy > cmaxy ) ? cmaxy : dmaxy;
7551
7552            dx = ((int)p_scroll_data[sdat_offs] << 16 | (int)p_scroll_data[sdat_offs + 1]) + corr;
7553
7554            if (last_dx == dx) { if (last_visible) goto LINE_SHORTCIRCUIT; continue; }
7555            last_dx = dx;
7556
7557            if (colspan > 1)
7558            {
7559               //sx = (unsigned)dx % width;
7560               sx = (unsigned)dx & (width-1);
7561
7562               //tx = c * K056832_PAGE_WIDTH;
7563               tx = c << 9;
7564
7565               if (!flipx)
7566               {
7567                  // handle right-edge wraparoundness and cull off-screen tilemaps
7568                  if ((c == 0) && (sx > width - K056832_PAGE_WIDTH)) sx -= width;
7569                  if ((sx + K056832_PAGE_WIDTH <= tx) || (sx - K056832_PAGE_WIDTH >= tx))
7570                     { last_visible = 0; continue; }
7571
7572                  // switch frame of reference and clip x
7573                  if ((tx -= sx) <= 0) { clipw = K056832_PAGE_WIDTH + tx; clipx = 0; }
7574                  else { clipw = K056832_PAGE_WIDTH - tx; clipx = tx; }
7575               }
7576               else
7577               {
7578                  tx += K056832_PAGE_WIDTH;
7579
7580                  // handle left-edge wraparoundness and cull off-screen tilemaps
7581                  if ((c == colspan-1) && (sx < K056832_PAGE_WIDTH)) sx += width;
7582                  if ((sx + K056832_PAGE_WIDTH <= tx) || (sx - K056832_PAGE_WIDTH >= tx))
7583                     { last_visible = 0; continue; }
7584
7585                  // switch frame of reference and clip y
7586                  if ((tx -= sx) >= 0) { clipw = K056832_PAGE_WIDTH - tx; clipx = 0; }
7587                  else { clipw = K056832_PAGE_WIDTH + tx; clipx = -tx; }
7588               }
7589            }
7590            else
7591            {
7592               clipw = K056832_PAGE_WIDTH;
7593               clipx = 0;
7594            }
7595
7596            last_visible = 1;
7597
7598            dminx = clipx;
7599            dmaxx = clipx + clipw - 1;
7600
7601            drawrect.min_x = (dminx < cminx ) ? cminx : dminx;
7602            drawrect.max_x = (dmaxx > cmaxx ) ? cmaxx : dmaxx;
7603
7604            tilemap_set_scrollx(tmap, 0, dx);
7605
7606            LINE_SHORTCIRCUIT:
7607               tilemap_draw(bitmap, &drawrect, tmap, flags, priority);
7608
7609         } // end of line loop
7610      } // end of column loop
7611   } // end of row loop
7612
7613   k056832->active_layer = last_active;
7614
7615} // end of function
7616
7617
7618void k056832_set_layer_association( const device_config *device, int status )
7619{
7620   k056832_state *k056832 = k056832_get_safe_token(device);
7621   k056832->default_layer_association = status;
7622}
7623
7624int k056832_get_layer_association( const device_config *device )
7625{
7626   k056832_state *k056832 = k056832_get_safe_token(device);
7627   return(k056832->layer_association);
7628}
7629
7630void k056832_set_layer_offs( const device_config *device, int layer, int offsx, int offsy )
7631{
7632   k056832_state *k056832 = k056832_get_safe_token(device);
7633   k056832->layer_offs[layer][0] = offsx;
7634   k056832->layer_offs[layer][1] = offsy;
7635}
7636
7637void k056832_set_lsram_page( const device_config *device, int logical_page, int physical_page, int physical_offset )
7638{
7639   k056832_state *k056832 = k056832_get_safe_token(device);
7640   k056832->lsram_page[logical_page][0] = physical_page;
7641   k056832->lsram_page[logical_page][1] = physical_offset;
7642}
7643
7644void k056832_linemap_enable( const device_config *device, int enable )
7645{
7646   k056832_state *k056832 = k056832_get_safe_token(device);
7647   k056832->linemap_enabled = enable;
7648}
7649
7650int k056832_is_irq_enabled( const device_config *device, int irqline )
7651{
7652   k056832_state *k056832 = k056832_get_safe_token(device);
7653   return(k056832->regs[0x06/2] & (1 << irqline & 7));
7654}
7655
7656void k056832_read_avac( const device_config *device, int *mode, int *data )
7657{
7658   k056832_state *k056832 = k056832_get_safe_token(device);
7659   *mode = k056832->regs[0x04/2] & 7;
7660   *data = k056832->regs[0x38/2];
7661}
7662
7663int k056832_read_register( const device_config *device, int regnum )
7664{
7665   k056832_state *k056832 = k056832_get_safe_token(device);
7666   return(k056832->regs[regnum]);
7667}
7668
7669//static STATE_POSTLOAD( k056832_postload )
7670void k056832_postload( const device_config *device )
7671{
7672   k056832_update_page_layout(device);
7673   k056832_change_rambank(device);
7674   k056832_change_rombank(device);
7675}
7676
7677/*****************************************************************************
7678    DEVICE INTERFACE
7679*****************************************************************************/
7680
7681/* TODO: understand which elements MUST be init here (to keep correct layer
7682   associations) and which ones can can be init at RESET, if any */
7683static DEVICE_START( k056832 )
7684{
7685   k056832_state *k056832 = k056832_get_safe_token(device);
7686   const k056832_interface *intf = k056832_get_interface(device);
7687   running_machine *machine = device->machine;
7688   tilemap *tmap;
7689   int i;
7690   UINT32 total;
7691   static const gfx_layout charlayout8 =
7692   {
7693      8, 8,
7694      0,
7695      8,
7696      { 8*7,8*3,8*5,8*1,8*6,8*2,8*4,8*0 },
7697      { 0, 1, 2, 3, 4, 5, 6, 7 },
7698      { 0, 8*8, 8*8*2, 8*8*3, 8*8*4, 8*8*5, 8*8*6, 8*8*7 },
7699      8*8*8
7700   };
7701   static const gfx_layout charlayout8le =
7702   {
7703      8, 8,
7704      0,
7705      8,
7706//      { 0, 1, 2, 3, 0+(0x200000*8), 1+(0x200000*8), 2+(0x200000*8), 3+(0x200000*8) },
7707      { 0+(0x200000*8), 1+(0x200000*8), 2+(0x200000*8), 3+(0x200000*8), 0, 1, 2, 3 },
7708      { 2*4, 3*4, 0*4, 1*4, 6*4, 7*4, 4*4, 5*4 },
7709      { 0*8*4, 1*8*4, 2*8*4, 3*8*4, 4*8*4, 5*8*4, 6*8*4, 7*8*4 },
7710      8*8*4
7711   };
7712   static const gfx_layout charlayout6 =
7713   {
7714      8, 8,
7715      0,
7716      6,
7717      { 40, 32, 24, 8, 16, 0 },
7718      { 0, 1, 2, 3, 4, 5, 6, 7 },
7719      { 0, 6*8, 6*8*2, 6*8*3, 6*8*4, 6*8*5, 6*8*6, 6*8*7 },
7720      8*8*6
7721   };
7722   static const gfx_layout charlayout5 =
7723   {
7724      8, 8,
7725      0,
7726      5,
7727      { 32, 24, 8, 16, 0 },
7728      { 0, 1, 2, 3, 4, 5, 6, 7 },
7729      { 0, 5*8, 5*8*2, 5*8*3, 5*8*4, 5*8*5, 5*8*6, 5*8*7 },
7730      8*8*5
7731   };
7732   static const gfx_layout charlayout4 =
7733   {
7734      8, 8,
7735      0,
7736      4,
7737      { 0, 1, 2, 3 },
7738      { 2*4, 3*4, 0*4, 1*4, 6*4, 7*4, 4*4, 5*4 },
7739      { 0*8*4, 1*8*4, 2*8*4, 3*8*4, 4*8*4, 5*8*4, 6*8*4, 7*8*4 },
7740      8*8*4
7741   };
7742   static const gfx_layout charlayout4dj =
7743   {
7744      8, 8,
7745      0,
7746      4,
7747      { 8*3,8*1,8*2,8*0 },
7748      { 0, 1, 2, 3, 4, 5, 6, 7 },
7749      { 0, 8*4, 8*4*2, 8*4*3, 8*4*4, 8*4*5, 8*4*6, 8*4*7 },
7750      8*8*4
7751   };
7752
7753
7754   /* handle the various graphics formats */
7755   i = (intf->big) ? 8 : 16;
7756
7757
7758   /* decode the graphics */
7759   switch (intf->bpp)
7760   {
7761      case K056832_BPP_4:
7762         total = memory_region_length(machine, intf->gfx_memory_region) / (i * 4);
7763         decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &charlayout4, 4);
7764         break;
7765
7766      case K056832_BPP_5:
7767         total = memory_region_length(machine, intf->gfx_memory_region) / (i * 5);
7768         decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &charlayout5, 4);
7769         break;
7770
7771      case K056832_BPP_6:
7772         total = memory_region_length(machine, intf->gfx_memory_region) / (i * 6);
7773         decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &charlayout6, 4);
7774         break;
7775
7776      case K056832_BPP_8:
7777         total = memory_region_length(machine, intf->gfx_memory_region) / (i * 8);
7778         decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &charlayout8, 4);
7779         break;
7780
7781      case K056832_BPP_8LE:
7782         total = memory_region_length(machine, intf->gfx_memory_region) / (i * 8);
7783         decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &charlayout8le, 4);
7784         break;
7785
7786      case K056832_BPP_4dj:
7787         total = memory_region_length(machine, intf->gfx_memory_region) / (i * 4);
7788         decode_gfx(machine, intf->gfx_num, memory_region(machine, intf->gfx_memory_region), total, &charlayout4dj, 4);
7789         break;
7790
7791      default:
7792         fatalerror("Unsupported bpp");
7793   }
7794
7795   machine->gfx[intf->gfx_num]->color_granularity = 16; /* override */
7796
7797   /* deinterleave the graphics, if needed */
7798   deinterleave_gfx(machine, intf->gfx_memory_region, intf->deinterleave);
7799
7800   k056832->memory_region = intf->gfx_memory_region;
7801   k056832->gfxnum = intf->gfx_num;
7802   k056832->callback = intf->callback;
7803
7804   k056832->rombase = memory_region(machine, intf->gfx_memory_region);
7805   k056832->num_gfx_banks = memory_region_length(machine, intf->gfx_memory_region) / 0x2000;
7806   k056832->djmain_hack = intf->djmain_hack;
7807
7808   k056832->cur_gfx_banks = 0;
7809   k056832->use_ext_linescroll = 0;
7810   k056832->uses_tile_banks = 0;
7811
7812   for (i = 0; i < 4; i++)
7813   {
7814      k056832->layer_offs[i][0] = 0;
7815      k056832->layer_offs[i][1] = 0;
7816      k056832->lsram_page[i][0] = i;
7817      k056832->lsram_page[i][1] = i << 11;
7818      k056832->x[i] = 0;
7819      k056832->y[i] = 0;
7820      k056832->w[i] = 0;
7821      k056832->h[i] = 0;
7822      k056832->dx[i] = 0;
7823      k056832->dy[i] = 0;
7824      k056832->layer_tile_mode[i] = 1;
7825   }
7826
7827   k056832->default_layer_association = 1;
7828   k056832->active_layer = 0;
7829   k056832->linemap_enabled = 0;
7830
7831   k056832->k055555 = devtag_get_device(device->machine, intf->k055555);
7832
7833   memset(k056832->line_dirty, 0, sizeof(UINT32) * K056832_PAGE_COUNT * 8);
7834
7835   for (i = 0; i < K056832_PAGE_COUNT; i++)
7836   {
7837      k056832->all_lines_dirty[i] = 0;
7838      k056832->page_tile_mode[i] = 1;
7839   }
7840
7841   k056832->videoram = auto_alloc_array(machine, UINT16, 0x2000 * (K056832_PAGE_COUNT + 1) / 2);
7842
7843   k056832->tilemap[0x0] = tilemap_create_device(device, k056832_get_tile_info0, tilemap_scan_rows,  8, 8, 64, 32);
7844   k056832->tilemap[0x1] = tilemap_create_device(device, k056832_get_tile_info1, tilemap_scan_rows,  8, 8, 64, 32);
7845   k056832->tilemap[0x2] = tilemap_create_device(device, k056832_get_tile_info2, tilemap_scan_rows,  8, 8, 64, 32);
7846   k056832->tilemap[0x3] = tilemap_create_device(device, k056832_get_tile_info3, tilemap_scan_rows,  8, 8, 64, 32);
7847   k056832->tilemap[0x4] = tilemap_create_device(device, k056832_get_tile_info4, tilemap_scan_rows,  8, 8, 64, 32);
7848   k056832->tilemap[0x5] = tilemap_create_device(device, k056832_get_tile_info5, tilemap_scan_rows,  8, 8, 64, 32);
7849   k056832->tilemap[0x6] = tilemap_create_device(device, k056832_get_tile_info6, tilemap_scan_rows,  8, 8, 64, 32);
7850   k056832->tilemap[0x7] = tilemap_create_device(device, k056832_get_tile_info7, tilemap_scan_rows,  8, 8, 64, 32);
7851   k056832->tilemap[0x8] = tilemap_create_device(device, k056832_get_tile_info8, tilemap_scan_rows,  8, 8, 64, 32);
7852   k056832->tilemap[0x9] = tilemap_create_device(device, k056832_get_tile_info9, tilemap_scan_rows,  8, 8, 64, 32);
7853   k056832->tilemap[0xa] = tilemap_create_device(device, k056832_get_tile_infoa, tilemap_scan_rows,  8, 8, 64, 32);
7854   k056832->tilemap[0xb] = tilemap_create_device(device, k056832_get_tile_infob, tilemap_scan_rows,  8, 8, 64, 32);
7855   k056832->tilemap[0xc] = tilemap_create_device(device, k056832_get_tile_infoc, tilemap_scan_rows,  8, 8, 64, 32);
7856   k056832->tilemap[0xd] = tilemap_create_device(device, k056832_get_tile_infod, tilemap_scan_rows,  8, 8, 64, 32);
7857   k056832->tilemap[0xe] = tilemap_create_device(device, k056832_get_tile_infoe, tilemap_scan_rows,  8, 8, 64, 32);
7858   k056832->tilemap[0xf] = tilemap_create_device(device, k056832_get_tile_infof, tilemap_scan_rows,  8, 8, 64, 32);
7859
7860   for (i = 0; i < K056832_PAGE_COUNT; i++)
7861   {
7862      tmap = k056832->tilemap[i];
7863
7864      k056832->pixmap[i] = tilemap_get_pixmap(tmap);
7865
7866      tilemap_set_transparent_pen(tmap, 0);
7867   }
7868
7869   memset(k056832->videoram, 0x00, 0x20000);
7870   memset(k056832->regs,     0x00, sizeof(k056832->regs) );
7871   memset(k056832->regsb,    0x00, sizeof(k056832->regsb) );
7872
7873   k056832_update_page_layout(device);
7874
7875   k056832_change_rambank(device);
7876   k056832_change_rombank(device);
7877
7878   state_save_register_device_item_pointer(device, 0, k056832->videoram, 0x10000);
7879   state_save_register_device_item_array(device, 0, k056832->regs);
7880   state_save_register_device_item_array(device, 0, k056832->regsb);
7881   state_save_register_device_item_array(device, 0, k056832->x);
7882   state_save_register_device_item_array(device, 0, k056832->y);
7883   state_save_register_device_item_array(device, 0, k056832->w);
7884   state_save_register_device_item_array(device, 0, k056832->h);
7885   state_save_register_device_item_array(device, 0, k056832->dx);
7886   state_save_register_device_item_array(device, 0, k056832->dy);
7887   state_save_register_device_item_array(device, 0, k056832->layer_tile_mode);
7888
7889   state_save_register_device_item(device, 0, k056832->default_layer_association);
7890   state_save_register_device_item(device, 0, k056832->active_layer);
7891   state_save_register_device_item(device, 0, k056832->linemap_enabled);
7892   state_save_register_device_item(device, 0, k056832->use_ext_linescroll);
7893   state_save_register_device_item(device, 0, k056832->uses_tile_banks);
7894   state_save_register_device_item(device, 0, k056832->cur_tile_bank);
7895   state_save_register_device_item(device, 0, k056832->rom_half);
7896   state_save_register_device_item_array(device, 0, k056832->all_lines_dirty);
7897   state_save_register_device_item_array(device, 0, k056832->page_tile_mode);
7898
7899   for (i = 0; i < 8; i++)
7900   {
7901      state_save_register_device_item_array(device, i, k056832->layer_offs[i]);
7902      state_save_register_device_item_array(device, i, k056832->lsram_page[i]);
7903   }
7904
7905   for (i = 0; i < K056832_PAGE_COUNT; i++)
7906   {
7907      state_save_register_device_item_array(device, i, k056832->line_dirty[i]);
7908      state_save_register_device_item(device, i, k056832->all_lines_dirty[i]);
7909      state_save_register_device_item(device, i, k056832->page_tile_mode[i]);
7910      state_save_register_device_item(device, i, k056832->last_colorbase[i]);
7911   }
7912
7913//  state_save_register_postload(device->machine, k056832_postload, NULL);
7914}
7915
7916/***************************************************************************/
7917/*                                                                         */
7918/*                                 055555                                  */
7919/*                                                                         */
7920/***************************************************************************/
7921
7922/* K055555 5-bit-per-pixel priority encoder */
7923/* This device has 48 8-bit-wide registers */
7924
7925typedef struct _k055555_state k055555_state;
7926struct _k055555_state
7927{
7928   UINT8    regs[128];
7929};
7930
7931/*****************************************************************************
7932    INLINE FUNCTIONS
7933*****************************************************************************/
7934
7935INLINE k055555_state *k055555_get_safe_token( const device_config *device )
7936{
7937   assert(device != NULL);
7938   assert(device->token != NULL);
7939   assert(device->type == K055555);
7940
7941   return (k055555_state *)device->token;
7942}
7943
7944/*****************************************************************************
7945    DEVICE HANDLERS
7946*****************************************************************************/
7947
7948void k055555_write_reg( const device_config *device, UINT8 regnum, UINT8 regdat )
7949{
7950   k055555_state *k055555 = k055555_get_safe_token(device);
7951
7952   static const char *const rnames[46] =
7953   {
7954      "BGC CBLK", "BGC SET", "COLSET0", "COLSET1", "COLSET2", "COLSET3", "COLCHG ON",
7955      "A PRI 0", "A PRI 1", "A COLPRI", "B PRI 0", "B PRI 1", "B COLPRI", "C PRI", "D PRI",
7956      "OBJ PRI", "SUB1 PRI", "SUB2 PRI", "SUB3 PRI", "OBJ INPRI ON", "S1 INPRI ON", "S2 INPRI ON",
7957      "S3 INPRI ON", "A PAL", "B PAL", "C PAL", "D PAL", "OBJ PAL", "SUB1 PAL", "SUB2 PAL", "SUB3 PAL",
7958      "SUB2 PAL ON", "SUB3 PAL ON", "V INMIX", "V INMIX ON", "OS INMIX", "OS INMIX ON", "SHD PRI 1",
7959      "SHD PRI 2", "SHD PRI 3", "SHD ON", "SHD PRI SEL", "V BRI", "OS INBRI", "OS INBRI ON", "ENABLE"
7960   };
7961
7962   if (regdat != k055555->regs[regnum])
7963   {
7964      LOG(("5^5: %x to reg %x (%s)\n", regdat, regnum, rnames[regnum]));
7965   }
7966
7967   k055555->regs[regnum] = regdat;
7968}
7969
7970WRITE32_DEVICE_HANDLER( k055555_long_w )
7971{
7972   UINT8 regnum, regdat;
7973
7974   if (ACCESSING_BITS_24_31)
7975   {
7976      regnum = offset << 1;
7977      regdat = data >> 24;
7978   }
7979   else
7980   {
7981      if (ACCESSING_BITS_8_15)
7982      {
7983         regnum = (offset << 1) + 1;
7984         regdat = data >> 8;
7985      }
7986      else
7987      {
7988         // logerror("5^5: unknown mem_mask %08x\n", mem_mask);
7989         return;
7990      }
7991   }
7992
7993   k055555_write_reg(device, regnum, regdat);
7994}
7995
7996WRITE16_DEVICE_HANDLER( k055555_word_w )
7997{
7998   if (mem_mask == 0x00ff)
7999   {
8000      k055555_write_reg(device, offset, data & 0xff);
8001   }
8002   else
8003   {
8004      k055555_write_reg(device, offset, data >> 8);
8005   }
8006}
8007
8008int k055555_read_register( const device_config *device, int regnum )
8009{
8010   k055555_state *k055555 = k055555_get_safe_token(device);
8011   return k055555->regs[regnum];
8012}
8013
8014int k055555_get_palette_index( const device_config *device, int idx )
8015{
8016   k055555_state *k055555 = k055555_get_safe_token(device);
8017   return k055555->regs[K55_PALBASE_A + idx];
8018}
8019
8020/*****************************************************************************
8021    DEVICE INTERFACE
8022*****************************************************************************/
8023
8024static DEVICE_START( k055555 )
8025{
8026   k055555_state *k055555 = k055555_get_safe_token(device);
8027   state_save_register_device_item_array(device, 0, k055555->regs);
8028}
8029
8030static DEVICE_RESET( k055555 )
8031{
8032   k055555_state *k055555 = k055555_get_safe_token(device);
8033   memset(k055555->regs, 0, 64 * sizeof(UINT8));
8034}
8035
8036
8037/***************************************************************************/
8038/*                                                                         */
8039/*                                 054338                                  */
8040/*                                                                         */
8041/***************************************************************************/
8042
8043// k054338 alpha blend / final mixer (normally used with the 55555)
8044// because the implementation is video dependant, this is just a
8045// register-handling shell.
8046
8047
8048typedef struct _k054338_state k054338_state;
8049struct _k054338_state
8050{
8051   UINT16    regs[32];
8052   int       shd_rgb[9];
8053   int       alphainverted;
8054
8055   const device_config *screen;
8056   const device_config *k055555;   /* used to fill BG color */
8057};
8058
8059/*****************************************************************************
8060    INLINE FUNCTIONS
8061*****************************************************************************/
8062
8063INLINE k054338_state *k054338_get_safe_token( const device_config *device )
8064{
8065   assert(device != NULL);
8066   assert(device->token != NULL);
8067   assert(device->type == K054338);
8068
8069   return (k054338_state *)device->token;
8070}
8071
8072INLINE const k054338_interface *k054338_get_interface( const device_config *device )
8073{
8074   assert(device != NULL);
8075   assert(device->type == K054338);
8076   return (const k054338_interface *) device->static_config;
8077}
8078
8079/*****************************************************************************
8080    DEVICE HANDLERS
8081*****************************************************************************/
8082
8083WRITE16_DEVICE_HANDLER( k054338_word_w )
8084{
8085   k054338_state *k054338 = k054338_get_safe_token(device);
8086   COMBINE_DATA(k054338->regs + offset);
8087}
8088
8089WRITE32_DEVICE_HANDLER( k054338_long_w )
8090{
8091   offset <<= 1;
8092   k054338_word_w(device, offset, data >> 16, mem_mask >> 16);
8093   k054338_word_w(device, offset + 1, data, mem_mask);
8094}
8095
8096// returns a 16-bit '338 register
8097int  k054338_register_r( const device_config *device, int reg )
8098{
8099   k054338_state *k054338 = k054338_get_safe_token(device);
8100   return k054338->regs[reg];
8101}
8102
8103void k054338_update_all_shadows( const device_config *device, int rushingheroes_hack )
8104{
8105   k054338_state *k054338 = k054338_get_safe_token(device);
8106   running_machine *machine = device->machine;
8107   int i, d;
8108   int noclip = k054338->regs[K338_REG_CONTROL] & K338_CTL_CLIPSL;
8109
8110   for (i = 0; i < 9; i++)
8111   {
8112      d = k054338->regs[K338_REG_SHAD1R + i] & 0x1ff;
8113      if (d >= 0x100)
8114         d -= 0x200;
8115      k054338->shd_rgb[i] = d;
8116   }
8117
8118   if (!rushingheroes_hack)
8119   {
8120      palette_set_shadow_dRGB32(machine, 0, k054338->shd_rgb[0], k054338->shd_rgb[1], k054338->shd_rgb[2], noclip);
8121      palette_set_shadow_dRGB32(machine, 1, k054338->shd_rgb[3], k054338->shd_rgb[4], k054338->shd_rgb[5], noclip);
8122      palette_set_shadow_dRGB32(machine, 2, k054338->shd_rgb[6], k054338->shd_rgb[7], k054338->shd_rgb[8], noclip);
8123   }
8124   else // rushing heroes seems to specify shadows in another format, or it's not being interpreted properly.
8125   {
8126      palette_set_shadow_dRGB32(machine, 0, -80, -80, -80, 0);
8127      palette_set_shadow_dRGB32(machine, 1, -80, -80, -80, 0);
8128      palette_set_shadow_dRGB32(machine, 2, -80, -80, -80, 0);
8129   }
8130}
8131
8132// k054338 BG color fill
8133void k054338_fill_solid_bg( const device_config *device, bitmap_t *bitmap )
8134{
8135   UINT32 bgcolor;
8136   UINT32 *pLine;
8137   int x, y;
8138
8139   bgcolor = (k054338_register_r(device, K338_REG_BGC_R) & 0xff) << 16;
8140   bgcolor |= k054338_register_r(device, K338_REG_BGC_GB);
8141
8142   /* and fill the screen with it */
8143   for (y = 0; y < bitmap->height; y++)
8144   {
8145      pLine = (UINT32 *)bitmap->base;
8146      pLine += (bitmap->rowpixels * y);
8147      for (x = 0; x < bitmap->width; x++)
8148         *pLine++ = bgcolor;
8149   }
8150}
8151
8152// Unified k054338/K055555 BG color fill
8153void k054338_fill_backcolor( const device_config *device, bitmap_t *bitmap, int mode ) // (see p.67)
8154{
8155   k054338_state *k054338 = k054338_get_safe_token(device);
8156   int clipx, clipy, clipw, cliph, i, dst_pitch;
8157   int BGC_CBLK, BGC_SET;
8158   UINT32 *dst_ptr, *pal_ptr;
8159   int bgcolor;
8160   const rectangle *visarea = video_screen_get_visible_area(k054338->screen);
8161
8162   clipx = visarea->min_x & ~3;
8163   clipy = visarea->min_y;
8164   clipw = (visarea->max_x - clipx + 4) & ~3;
8165   cliph = visarea->max_y - clipy + 1;
8166
8167   dst_ptr = BITMAP_ADDR32(bitmap, clipy, 0);
8168   dst_pitch = bitmap->rowpixels;
8169   dst_ptr += clipx;
8170
8171   BGC_SET = 0;
8172   pal_ptr = device->machine->generic.paletteram.u32;
8173
8174   if (!mode || k054338->k055555 == NULL)
8175   {
8176      // single color output from CLTC
8177      bgcolor = (int)(k054338->regs[K338_REG_BGC_R] & 0xff) << 16 | (int)k054338->regs[K338_REG_BGC_GB];
8178   }
8179   else
8180   {
8181      BGC_CBLK = k055555_read_register(k054338->k055555, 0);
8182      BGC_SET  = k055555_read_register(k054338->k055555, 1);
8183
8184      pal_ptr += BGC_CBLK << 9;
8185
8186      // single color output from PCU2
8187      if (!(BGC_SET & 2))
8188      {
8189         bgcolor = *pal_ptr;
8190         mode = 0;
8191      }
8192      else bgcolor = 0;
8193   }
8194
8195   if (!mode)
8196   {
8197      // single color fill
8198      dst_ptr += clipw;
8199      i = clipw = -clipw;
8200      do
8201      {
8202         do
8203         {
8204            dst_ptr[i] = dst_ptr[i+1] = dst_ptr[i+2] = dst_ptr[i+3] = bgcolor;
8205         }
8206         while (i += 4);
8207
8208         dst_ptr += dst_pitch;
8209         i = clipw;
8210      }
8211      while (--cliph);
8212   }
8213   else
8214   {
8215      if (!(BGC_SET & 1))
8216      {
8217         // vertical gradient fill
8218         pal_ptr += clipy;
8219         dst_ptr += clipw;
8220         bgcolor = *pal_ptr++;
8221         i = clipw = -clipw;
8222         do
8223         {
8224            do
8225            {
8226               dst_ptr[i] = dst_ptr[i+1] = dst_ptr[i+2] = dst_ptr[i+3] = bgcolor;
8227            }
8228            while (i += 4);
8229
8230            dst_ptr += dst_pitch;
8231            bgcolor = *pal_ptr++;
8232            i = clipw;
8233         }
8234         while (--cliph);
8235      }
8236      else
8237      {
8238         // horizontal gradient fill
8239         pal_ptr += clipx;
8240         clipw <<= 2;
8241         do
8242         {
8243            memcpy(dst_ptr, pal_ptr, clipw);
8244            dst_ptr += dst_pitch;
8245         }
8246         while (--cliph);
8247      }
8248   }
8249}
8250
8251// addition blending unimplemented (requires major changes to drawgfx and tilemap.c)
8252int k054338_set_alpha_level( const device_config *device, int pblend )
8253{
8254   k054338_state *k054338 = k054338_get_safe_token(device);
8255   UINT16 *regs;
8256   int ctrl, mixpri, mixset, mixlv;
8257
8258   if (pblend <= 0 || pblend > 3)
8259   {
8260      return (255);
8261   }
8262
8263   regs   = k054338->regs;
8264   ctrl   = k054338->regs[K338_REG_CONTROL];
8265   mixpri = ctrl & K338_CTL_MIXPRI;
8266   mixset = regs[K338_REG_PBLEND + (pblend >> 1 & 1)] >> (~pblend << 3 & 8);
8267   mixlv  = mixset & 0x1f;
8268
8269   if (k054338->alphainverted)
8270      mixlv = 0x1f - mixlv;
8271
8272   if (!(mixset & 0x20))
8273   {
8274      mixlv = (mixlv << 3) | (mixlv >> 2);
8275   }
8276   else
8277   {
8278      if (!mixpri)
8279      {
8280         // source x alpha  +  target (clipped at 255)
8281      }
8282      else
8283      {
8284         // source  +  target x alpha (clipped at 255)
8285      }
8286
8287      // DUMMY
8288      if (mixlv && mixlv < 0x1f)
8289         mixlv = 0x10;
8290
8291      mixlv = (mixlv << 3) | (mixlv >> 2);
8292
8293      if (VERBOSE)
8294         popmessage("MIXSET%1d %s addition mode: %02x", pblend, (mixpri) ? "dst" : "src", mixset & 0x1f);
8295   }
8296
8297   return mixlv;
8298}
8299
8300void k054338_invert_alpha( const device_config *device, int invert )
8301{
8302   k054338_state *k054338 = k054338_get_safe_token(device);
8303   k054338->alphainverted = invert;
8304}
8305
8306
8307#if 0
8308// FIXME
8309void k054338->export_config( const device_config *device, int **shd_rgb )
8310{
8311   k054338_state *k054338 = k054338_get_safe_token(device);
8312   *shd_rgb = k054338->shd_rgb;
8313}
8314#endif
8315
8316/*****************************************************************************
8317    DEVICE INTERFACE
8318*****************************************************************************/
8319
8320static DEVICE_START( k054338 )
8321{
8322   k054338_state *k054338 = k054338_get_safe_token(device);
8323   const k054338_interface *intf = k054338_get_interface(device);
8324
8325   k054338->screen = devtag_get_device(device->machine, intf->screen);
8326   k054338->k055555 = devtag_get_device(device->machine, intf->k055555);
8327
8328   k054338->alphainverted = intf->alpha_inv;
8329
8330   state_save_register_device_item_array(device, 0, k054338->regs);
8331   state_save_register_device_item_array(device, 0, k054338->shd_rgb);
8332}
8333
8334static DEVICE_RESET( k054338 )
8335{
8336   k054338_state *k054338 = k054338_get_safe_token(device);
8337
8338   memset(k054338->regs, 0, sizeof(UINT16)*32);
8339   memset(k054338->shd_rgb, 0, sizeof(int)*9);
8340}
8341
8342
8343/***************************************************************************/
8344/*                                                                         */
8345/*                                 053250                                  */
8346/*                                                                         */
8347/***************************************************************************/
8348
8349typedef struct _k053250_state k053250_state;
8350struct _k053250_state
8351{
8352   UINT8       regs[8];
8353   UINT8       *base;
8354   UINT16      *ram, *rammax;
8355   UINT16      *buffer[2];
8356   UINT32      rommask;
8357   int         page;
8358   int         frame, offsx, offsy;
8359
8360   const device_config *screen;
8361};
8362
8363/*****************************************************************************
8364    INLINE FUNCTIONS
8365*****************************************************************************/
8366
8367INLINE k053250_state *k053250_get_safe_token( const device_config *device )
8368{
8369   assert(device != NULL);
8370   assert(device->token != NULL);
8371   assert(device->type == K053250);
8372
8373   return (k053250_state *)device->token;
8374}
8375
8376INLINE const k053250_interface *k053250_get_interface( const device_config *device )
8377{
8378   assert(device != NULL);
8379   assert((device->type == K053250));
8380   return (const k053250_interface *) device->static_config;
8381}
8382
8383
8384/*****************************************************************************
8385    DEVICE HANDLERS
8386*****************************************************************************/
8387
8388// The DMA process should be instantaneous but since rendering in MAME is performed at VIDEO_UPDATE()
8389// the k053250 memory must be buffered to maintain visual integrity.
8390void k053250_dma( const device_config *device, int limiter )
8391{
8392   k053250_state *k053250 = k053250_get_safe_token(device);
8393   int last_frame, current_frame;
8394
8395   current_frame = video_screen_get_frame_number(k053250->screen);
8396   last_frame = k053250->frame;
8397
8398   if (limiter && current_frame == last_frame)
8399      return; // make sure we only do DMA transfer once per frame
8400
8401   k053250->frame = current_frame;
8402   memcpy(k053250->buffer[k053250->page], k053250->ram, 0x1000);
8403   k053250->page ^= 1;
8404}
8405
8406WRITE16_DEVICE_HANDLER( k053250_w )
8407{
8408   k053250_state *k053250 = k053250_get_safe_token(device);
8409
8410   if (ACCESSING_BITS_0_7)
8411   {
8412      // start LVC DMA transfer at the falling edge of control register's bit1
8413      if (offset == 4 && !(data & 2) && (k053250->regs[4] & 2))
8414         k053250_dma(device, 1);
8415
8416      k053250->regs[offset] = data;
8417   }
8418}
8419
8420READ16_DEVICE_HANDLER( k053250_r )
8421{
8422   k053250_state *k053250 = k053250_get_safe_token(device);
8423   return k053250->regs[offset];
8424}
8425
8426WRITE16_DEVICE_HANDLER( k053250_ram_w )
8427{
8428   k053250_state *k053250 = k053250_get_safe_token(device);
8429   COMBINE_DATA(k053250->ram + offset);
8430}
8431
8432READ16_DEVICE_HANDLER( k053250_ram_r )
8433{
8434   k053250_state *k053250 = k053250_get_safe_token(device);
8435   return k053250->ram[offset];
8436}
8437
8438READ16_DEVICE_HANDLER( k053250_rom_r )
8439{
8440   k053250_state *k053250 = k053250_get_safe_token(device);
8441
8442//  if (!(k053250->regs[5] & 1)) logerror("Back: Reading rom memory with enable=0\n");
8443
8444   return *(k053250->base + 0x80000 * k053250->regs[6] + 0x800 * k053250->regs[7] + (offset >> 1));
8445}
8446
8447
8448// Pixel data of the k053250 is nibble packed. It's preferable to be unpacked into byte format.
8449static void k053250_unpack_pixels(running_machine *machine, const char *region)
8450{
8451   UINT8 *src_ptr, *dst_ptr;
8452   int hi_nibble, lo_nibble, offset;
8453
8454   dst_ptr = src_ptr = memory_region(machine, region);
8455   offset = memory_region_length(machine, region) / 2 - 1;
8456
8457   do
8458   {
8459      lo_nibble = hi_nibble = src_ptr[offset];
8460      hi_nibble >>= 4;
8461      lo_nibble &= 0xf;
8462      dst_ptr[offset * 2    ] = hi_nibble;
8463      dst_ptr[offset * 2 + 1] = lo_nibble;
8464   }
8465   while ((--offset) >= 0);
8466}
8467
8468
8469// utility function to render a clipped scanline vertically or horizontally
8470INLINE void k053250_pdraw_scanline32(bitmap_t *bitmap, const pen_t *palette, UINT8 *source,
8471      const rectangle *cliprect, int linepos, int scroll, int zoom,
8472      UINT32 clipmask, UINT32 wrapmask, UINT32 orientation, bitmap_t *priority, UINT8 pri)
8473{
8474// a sixteen-bit fixed point resolution should be adequate to our application
8475#define FIXPOINT_PRECISION      16
8476#define FIXPOINT_PRECISION_HALF   (1<<(FIXPOINT_PRECISION-1))
8477
8478   int end_pixel, flip, dst_min, dst_max, dst_start, dst_length;
8479
8480   UINT32 src_wrapmask;
8481   UINT8  *src_base;
8482   //int src_x;
8483   int src_fx, src_fdx;
8484   int pix_data, dst_offset;
8485   const pen_t  *pal_base;
8486   UINT8  *pri_base;
8487   UINT32 *dst_base;
8488   int dst_adv;
8489
8490   // flip X and flip Y also switch role when the X Y coordinates are swapped
8491   if (!(orientation & ORIENTATION_SWAP_XY))
8492   {
8493      flip = orientation & ORIENTATION_FLIP_X;
8494      dst_min = cliprect->min_x;
8495      dst_max = cliprect->max_x;
8496   }
8497   else
8498   {
8499      flip = orientation & ORIENTATION_FLIP_Y;
8500      dst_min = cliprect->min_y;
8501      dst_max = cliprect->max_y;
8502   }
8503
8504   if (clipmask)
8505   {
8506      // reject scanlines that are outside of the target bitmap's right(bottom) clip boundary
8507      dst_start = -scroll;
8508      if (dst_start > dst_max) return;
8509
8510      // calculate target length
8511      dst_length = clipmask + 1;
8512      if (zoom) dst_length = (dst_length << 6) / zoom;
8513
8514      // reject scanlines that are outside of the target bitmap's left(top) clip boundary
8515      end_pixel = dst_start + dst_length - 1;
8516      if (end_pixel < dst_min) return;
8517
8518      // clip scanline tail
8519      if ((end_pixel -= dst_max) > 0) dst_length -= end_pixel;
8520
8521      // reject zero-length scanlines
8522      if (dst_length <= 0) return;
8523
8524      // calculate zoom factor
8525      src_fdx = zoom << (FIXPOINT_PRECISION-6);
8526
8527      // clip scanline head
8528      end_pixel = dst_min;
8529      if ((end_pixel -= dst_start) > 0)
8530      {
8531         // chop scanline to the correct length and move target start location to the left(top) clip boundary
8532         dst_length -= end_pixel;
8533         dst_start = dst_min;
8534
8535         // and skip the source for the left(top) clip region
8536         src_fx = end_pixel * src_fdx + FIXPOINT_PRECISION_HALF;
8537      }
8538      else
8539         // the point five bias is to ensure even distribution of stretched or shrinked pixels
8540         src_fx = FIXPOINT_PRECISION_HALF;
8541
8542      // adjust flipped source
8543      if (flip)
8544      {
8545         // start from the target's clipped end if the scanline is flipped
8546         dst_start = dst_max + dst_min - dst_start - (dst_length-1);
8547
8548         // and move source start location to the opposite end
8549         src_fx += (dst_length-1) * src_fdx - 1;
8550         src_fdx = -src_fdx;
8551      }
8552   }
8553   else
8554   {
8555      // draw wrapped scanline at virtual bitmap boundary when source clipping is off
8556      dst_start = dst_min;
8557      dst_length = dst_max - dst_min + 1;   // target scanline spans the entire visible area
8558      src_fdx = zoom << (FIXPOINT_PRECISION-6);
8559
8560      // pre-advance source for the clipped region
8561      if (!flip)
8562         src_fx = (scroll + dst_min) * src_fdx + FIXPOINT_PRECISION_HALF;
8563      else
8564      {
8565         src_fx = (scroll + dst_max) * src_fdx + FIXPOINT_PRECISION_HALF-1;
8566         src_fdx = -src_fdx;
8567      }
8568   }
8569
8570   if (!(orientation & ORIENTATION_SWAP_XY))
8571   {
8572      // calculate target increment for horizontal scanlines which is exactly one
8573      dst_adv = 1;
8574      dst_offset = dst_length;
8575      pri_base = BITMAP_ADDR8(priority, linepos, dst_start + dst_offset);
8576      dst_base = BITMAP_ADDR32(bitmap, linepos, dst_start + dst_length);
8577   }
8578   else
8579   {
8580      // calculate target increment for vertical scanlines which is the bitmap's pitch value
8581      dst_adv = bitmap->rowpixels;
8582      dst_offset= dst_length * dst_adv;
8583      pri_base = BITMAP_ADDR8(priority, dst_start, linepos + dst_offset);
8584      dst_base = BITMAP_ADDR32(bitmap, dst_start, linepos + dst_offset);
8585   }
8586
8587   // generalized
8588   src_base = source;
8589   //src_x = 0;
8590
8591   // there is no need to wrap source offsets along with source clipping
8592   // so we set all bits of the wrapmask to one
8593   src_wrapmask = (clipmask) ? ~0 : wrapmask;
8594
8595   pal_base = palette;
8596   dst_offset = -dst_offset; // negate target offset in order to terminated draw loop at zero condition
8597
8598   if (pri)
8599   {
8600      // draw scanline and update priority bitmap
8601      do
8602      {
8603         pix_data = src_base[(src_fx>>FIXPOINT_PRECISION) & src_wrapmask];
8604         src_fx += src_fdx;
8605
8606         if (pix_data)
8607         {
8608            pix_data = pal_base[pix_data];
8609            pri_base[dst_offset] = pri;
8610            dst_base[dst_offset] = pix_data;
8611         }
8612      }
8613      while (dst_offset += dst_adv);
8614   }
8615   else
8616   {
8617      // draw scanline but do not update priority bitmap
8618      do
8619      {
8620         pix_data = src_base[(src_fx>>FIXPOINT_PRECISION) & src_wrapmask];
8621         src_fx += src_fdx;
8622
8623         if (pix_data)
8624         {
8625            dst_base[dst_offset] = pal_base[pix_data];
8626         }
8627      }
8628      while (dst_offset += dst_adv);
8629   }
8630
8631#undef FIXPOINT_PRECISION
8632#undef FIXPOINT_PRECISION_HALF
8633}
8634
8635void k053250_draw( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int colorbase, int flags, int priority )
8636{
8637   k053250_state *k053250 = k053250_get_safe_token(device);
8638   UINT16 *line_ram;
8639   UINT8 *pix_base, *pix_ptr, *regs;
8640   const pen_t *pal_base, *pal_ptr;
8641   UINT32 rommask, src_clipmask, src_wrapmask, dst_wrapmask;
8642   int map_scrollx, map_scrolly, ctrl, orientation;
8643   int dst_minx, dst_maxx, dst_miny, dst_maxy;
8644   int linedata_offs, linedata_adv, line_pos, line_start, line_end, scroll_corr;
8645   int color, offset, zoom, scroll, passes, i, dst_height;
8646
8647   line_ram = k053250->buffer[k053250->page];   // pointer to physical line RAM
8648   pix_base = k053250->base;                     // pointer to source pixel ROM
8649   rommask  = k053250->rommask;                  // source ROM limit
8650   regs     = k053250->regs;                     // pointer to registers group
8651
8652   map_scrollx = (short)(regs[0] << 8 | regs[1]);      // signed horizontal scroll value
8653   map_scrolly = (short)(regs[2] << 8 | regs[3]);      // signed vertical scroll value
8654   map_scrollx -= k053250->offsx;                  // add user X offset to horizontal scroll
8655   map_scrolly -= k053250->offsy;                  // add user Y offset to vertical scroll
8656   ctrl = regs[4];                              // register four is the main control register
8657
8658   // copy visible boundary values to more accessible locations
8659   dst_minx  = cliprect->min_x;
8660   dst_maxx  = cliprect->max_x;
8661   dst_miny  = cliprect->min_y;
8662   dst_maxy  = cliprect->max_y;
8663
8664   orientation  = 0;   // orientation defaults to no swapping and no flipping
8665   dst_height   = 512;   // virtual bitmap height defaults to five hundred and twelve pixels
8666   linedata_adv = 4;   // line info packets are four words(eight bytes) apart
8667
8668   {
8669      // switch X and Y parameters when the first bit of the control register is cleared
8670      if (!(ctrl & 0x01)) orientation |= ORIENTATION_SWAP_XY;
8671
8672      // invert X parameters when the forth bit of the control register is set
8673      if   (ctrl & 0x08)  orientation |= ORIENTATION_FLIP_X;
8674
8675      // invert Y parameters when the fifth bit of the control register is set
8676      if   (ctrl & 0x10)  orientation |= ORIENTATION_FLIP_Y;
8677
8678      switch (ctrl >> 5) // the upper four bits of the control register select source and target dimensions
8679      {
8680         case 0 :
8681            // Xexex: L6 galaxies
8682            // Metam: L4 forest, L5 arena, L6 tower interior, final boss
8683
8684            // crop source offset between zero and two hundred and fifty-five inclusive,
8685            // and set virtual bitmap height to two hundred and fifty-six pixels
8686            src_wrapmask = src_clipmask = 0xff;
8687            dst_height = 0x100;
8688         break;
8689         case 1 :
8690            // Xexex: prologue, L7 nebulae
8691
8692            // the source offset is cropped to zero and five hundred and eleven inclusive
8693            src_wrapmask = src_clipmask = 0x1ff;
8694         break;
8695         case 4 :
8696            // Xexex: L1 sky and boss, L3 planet, L5 poly-face, L7 battle ship patches
8697            // Metam: L1 summoning circle, L3 caves, L6 gargoyle towers
8698
8699            // crop source offset between zero and two hundred and fifty-five inclusive,
8700            // and allow source offset to wrap back at 500 hexadecimal to minus 300 hexadecimal
8701            src_wrapmask = src_clipmask = 0xff;
8702            flags |= K053250_WRAP500;
8703         break;
8704//          case 2 : // Xexex: title
8705//          case 7 : // Xexex: L4 organic stage
8706         default:
8707
8708            // crop source offset between zero and one thousand and eleven inclusive,
8709            // keep other dimensions to their defaults
8710            src_wrapmask = src_clipmask = 0x3ff;
8711         break;
8712      }
8713
8714      // disable source clipping when the third bit of the control register is set
8715      if (ctrl & 0x04) src_clipmask = 0;
8716
8717      if (!(orientation & ORIENTATION_SWAP_XY))   // normal orientaion with no X Y switching
8718      {
8719         line_start = dst_miny;         // the first scanline starts at the minimum Y clip location
8720         line_end   = dst_maxy;         // the last scanline ends at the maximum Y clip location
8721         scroll_corr = map_scrollx;      // concentrate global X scroll
8722         linedata_offs = map_scrolly;   // determine where to get info for the first line
8723
8724         if (orientation & ORIENTATION_FLIP_X)
8725         {
8726            scroll_corr = -scroll_corr;   // X scroll adjustment should be negated in X flipped scenarioes
8727         }
8728
8729         if (orientation & ORIENTATION_FLIP_Y)
8730         {
8731            linedata_adv = -linedata_adv;         // traverse line RAM backward in Y flipped scenarioes
8732            linedata_offs += bitmap->height - 1;   // and get info for the first line from the bottom
8733         }
8734
8735         dst_wrapmask = ~0;   // scanlines don't seem to wrap horizontally in normal orientation
8736         passes = 1;         // draw scanline in a single pass
8737      }
8738      else  // orientaion with X and Y parameters switched
8739      {
8740         line_start = dst_minx;         // the first scanline starts at the minimum X clip location
8741         line_end   = dst_maxx;         // the last scanline ends at the maximum X clip location
8742         scroll_corr = map_scrolly;      // concentrate global Y scroll
8743         linedata_offs = map_scrollx;   // determine where to get info for the first line
8744
8745         if (orientation & ORIENTATION_FLIP_Y)
8746         {
8747            scroll_corr = 0x100 - scroll_corr;   // apply common vertical correction
8748
8749            // Y correction (ref: 1st and 5th boss)
8750            scroll_corr -= 2;   // apply unique vertical correction
8751
8752            // X correction (ref: 1st boss, seems to undo non-rotated global X offset)
8753            linedata_offs -= 5;   // apply unique horizontal correction
8754         }
8755
8756         if (orientation & ORIENTATION_FLIP_X)
8757         {
8758            linedata_adv = -linedata_adv;      // traverse line RAM backward in X flipped scenarioes
8759            linedata_offs += bitmap->width - 1;   // and get info for the first line from the bottom
8760         }
8761
8762         if (src_clipmask)
8763         {
8764            // determine target wrap boundary and draw scanline in two passes if the source is clipped
8765            dst_wrapmask = dst_height - 1;
8766            passes = 2;
8767         }
8768         else
8769         {
8770            // otherwise disable target wraparound and draw scanline in a single pass
8771            dst_wrapmask = ~0;
8772            passes = 1;
8773         }
8774      }
8775   }
8776
8777   linedata_offs *= 4;                        // each line info packet has four words(eight bytes)
8778   linedata_offs &= 0x7ff;                     // and it should wrap at the four-kilobyte boundary
8779   linedata_offs += line_start * linedata_adv;      // pre-advance line info offset for the clipped region
8780
8781   // load physical palette base
8782   pal_base = device->machine->pens + (colorbase << 4) % device->machine->config->total_colors;
8783
8784   // walk the target bitmap within the visible area vertically or horizontally, one line at a time
8785   for (line_pos=line_start; line_pos <= line_end; linedata_offs += linedata_adv, line_pos++)
8786   {
8787      linedata_offs &= 0x7ff;                  // line info data wraps at the four-kilobyte boundary
8788
8789      color  = line_ram[linedata_offs];         // get scanline color code
8790      if (color == 0xffff) continue;            // reject scanline if color code equals minus one
8791
8792      offset   = line_ram[linedata_offs + 1];      // get first pixel offset in ROM
8793      if (!(color & 0xff) && !offset) continue;   // reject scanline if both color and pixel offset are zero
8794
8795      // calculate physical palette location
8796      // there can be thirty-two color codes and each code represents sixteen pens
8797      pal_ptr = pal_base + ((color & 0x1f) << 4);
8798
8799      // calculate physical pixel location
8800      // each offset unit represents two hundred and fifty six pixels and should wrap at ROM boundary for safty
8801      pix_ptr = pix_base + (offset << 8) % rommask;
8802
8803      // get scanline zoom factor
8804      // For example, 0x20 doubles the length, 0x40 maintains a one-to-one length,
8805      // and 0x80 halves the length. The zoom center is at the beginning of the
8806      // scanline therefore it is not necessary to adjust render start position
8807      zoom    = line_ram[linedata_offs + 2];
8808
8809      scroll  = (short)line_ram[linedata_offs + 3];   // get signed local scroll value for the current scanline
8810
8811      // scavenged from old code; improves Xexex' first level sky
8812      if (flags & K053250_WRAP500 && scroll >= 0x500) scroll -= 0x800;
8813
8814      scroll += scroll_corr;   // apply final scroll correction
8815      scroll &= dst_wrapmask;   // wraparound scroll value if necessary
8816
8817      // draw scanlines wrapped at virtual bitmap boundary in two passes
8818      // this should not impose too much overhead due to clipping performed by the render code
8819      i = passes;
8820      do
8821      {
8822         /*
8823                Parameter descriptions:
8824
8825                bitmap       : pointer to a MAME bitmap as the render target
8826                pal_ptr      : pointer to the palette's physical location relative to the scanline
8827                pix_ptr      : pointer to the physical start location of source pixels in ROM
8828                cliprect     : pointer to a rectangle structue which describes the visible area of the target bitmap
8829                line_pos     : scanline render position relative to the target bitmap
8830                               should be a Y offset to the target bitmap in normal orientaion,
8831                               or an X offset to the target bitmap if X,Y are swapped
8832                scroll       : source scroll value of the scanline
8833                zoom         : source zoom factor of the scanline
8834                src_clipmask : source offset clip mask; source pixels with offsets beyond the scope of this mask will not be drawn
8835                src_wrapmask : source offset wrap mask; wraps source offset around, no effect when src_clipmask is set
8836                orientation  : flags indicating whether scanlines should be drawn horizontally, vertically, forward or backward
8837                priority     : value to be written to the priority bitmap, no effect when equals zero
8838            */
8839         k053250_pdraw_scanline32(bitmap, pal_ptr, pix_ptr, cliprect,
8840            line_pos, scroll, zoom, src_clipmask, src_wrapmask, orientation, device->machine->priority_bitmap, (UINT8)priority);
8841
8842         // shift scanline position one virtual screen upward to render the wrapped end if necessary
8843         scroll -= dst_height;
8844      }
8845      while (--i);
8846   }
8847}
8848
8849/*****************************************************************************
8850    DEVICE INTERFACE
8851*****************************************************************************/
8852
8853static DEVICE_START( k053250 )
8854{
8855   k053250_state *k053250 = k053250_get_safe_token(device);
8856   const k053250_interface *intf = k053250_get_interface(device);
8857
8858   k053250->base = memory_region(device->machine, intf->gfx_memory_region);
8859   k053250->rommask = memory_region_length(device->machine, intf->gfx_memory_region);
8860
8861   k053250->screen = devtag_get_device(device->machine, intf->screen);
8862
8863   k053250->ram = auto_alloc_array(device->machine, UINT16, 0x6000 / 2);
8864
8865   k053250->rammax = k053250->ram + 0x800;
8866   k053250->buffer[0] = k053250->ram + 0x2000;
8867   k053250->buffer[1] = k053250->ram + 0x2800;
8868
8869   k053250->offsx = intf->xoff;
8870   k053250->offsy = intf->yoff;
8871
8872   /* unpack graphics */
8873   k053250_unpack_pixels(device->machine, intf->gfx_memory_region);
8874
8875   state_save_register_device_item_pointer(device, 0, k053250->ram, 0x6000 / 2);
8876   state_save_register_device_item_array(device, 0, k053250->regs);
8877   state_save_register_device_item(device, 0, k053250->page);
8878   state_save_register_device_item(device, 0, k053250->frame);
8879}
8880
8881static DEVICE_RESET( k053250 )
8882{
8883   k053250_state *k053250 = k053250_get_safe_token(device);
8884   int i;
8885
8886   k053250->page = 0;
8887   k053250->frame = -1;
8888
8889   for (i = 0; i < 8; i++)
8890      k053250->regs[i] = 0;
8891
8892}
8893
8894
8895/***************************************************************************/
8896/*                                                                         */
8897/*                                 053252                                  */
8898/*                                                                         */
8899/***************************************************************************/
8900
8901typedef struct _k053252_state k053252_state;
8902struct _k053252_state
8903{
8904   UINT16   regs[16];
8905};
8906
8907/*****************************************************************************
8908    INLINE FUNCTIONS
8909*****************************************************************************/
8910
8911INLINE k053252_state *k053252_get_safe_token( const device_config *device )
8912{
8913   assert(device != NULL);
8914   assert(device->token != NULL);
8915   assert(device->type == K053252);
8916
8917   return (k053252_state *)device->token;
8918}
8919
8920/*****************************************************************************
8921    DEVICE HANDLERS
8922*****************************************************************************/
8923
8924READ16_DEVICE_HANDLER( k053252_word_r )
8925{
8926   k053252_state *k053252 = k053252_get_safe_token(device);
8927   return k053252->regs[offset];
8928}
8929
8930WRITE16_DEVICE_HANDLER( k053252_word_w )
8931{
8932   k053252_state *k053252 = k053252_get_safe_token(device);
8933   COMBINE_DATA(k053252->regs + offset);
8934}
8935
8936WRITE32_DEVICE_HANDLER( k053252_long_w )
8937{
8938   offset <<= 1;
8939   k053252_word_w(device, offset, data >> 16, mem_mask >> 16);
8940   k053252_word_w(device, offset + 1, data, mem_mask);
8941}
8942
8943/*****************************************************************************
8944    DEVICE INTERFACE
8945*****************************************************************************/
8946
8947static DEVICE_START( k053252 )
8948{
8949   k053252_state *k053252 = k053252_get_safe_token(device);
8950
8951   state_save_register_device_item_array(device, 0, k053252->regs);
8952}
8953
8954static DEVICE_RESET( k053252 )
8955{
8956   k053252_state *k053252 = k053252_get_safe_token(device);
8957   int i;
8958
8959   for (i = 0; i < 16; i++)
8960      k053252->regs[i] = 0;
8961}
8962
8963
8964// debug handlers
8965READ16_DEVICE_HANDLER( k056832_word_r )
8966{
8967   k056832_state *k056832 = k056832_get_safe_token(device);
8968   return (k056832->regs[offset]);
8969}      // VACSET
8970
8971READ16_DEVICE_HANDLER( k056832_b_word_r )
8972{
8973   k056832_state *k056832 = k056832_get_safe_token(device);
8974   return (k056832->regsb[offset]);
8975}   // VSCCS (board dependent)
8976
8977READ16_DEVICE_HANDLER( k053246_reg_word_r )
8978{
8979   k053247_state *k053247 = k053247_get_safe_token(device);
8980   return(k053247->Kx46_regs[offset * 2] << 8 | k053247->Kx46_regs[offset * 2 + 1]);
8981}   // OBJSET1
8982
8983READ16_DEVICE_HANDLER( k053247_reg_word_r )
8984{
8985   k053247_state *k053247 = k053247_get_safe_token(device);
8986   return(k053247->Kx47_regs[offset]);
8987}   // OBJSET2
8988
8989READ16_DEVICE_HANDLER( k054338_word_r )
8990{
8991   k054338_state *k054338 = k054338_get_safe_token(device);
8992   return(k054338->regs[offset]);
8993}      // CLTC
8994
8995READ16_DEVICE_HANDLER( k053251_lsb_r )
8996{
8997   k053251_state *k053251 = k053251_get_safe_token(device);
8998   return(k053251->ram[offset]);
8999}      // PCU1
9000
9001READ16_DEVICE_HANDLER( k053251_msb_r )
9002{
9003   k053251_state *k053251 = k053251_get_safe_token(device);
9004   return(k053251->ram[offset] << 8);
9005}      // PCU1
9006
9007READ16_DEVICE_HANDLER( k055555_word_r )
9008{
9009   k055555_state *k055555 = k055555_get_safe_token(device);
9010   return(k055555->regs[offset] << 8);
9011}   // PCU2
9012
9013READ32_DEVICE_HANDLER( k056832_long_r )
9014{
9015   offset <<= 1;
9016   return (k056832_word_r(device, offset + 1, 0xffff) | k056832_word_r(device, offset, 0xffff) << 16);
9017}
9018
9019READ32_DEVICE_HANDLER( k053247_reg_long_r )
9020{
9021   offset <<= 1;
9022   return (k053247_reg_word_r(device, offset + 1, 0xffff) | k053247_reg_word_r(device, offset, 0xffff) << 16);
9023}
9024
9025READ32_DEVICE_HANDLER( k055555_long_r )
9026{
9027   offset <<= 1;
9028   return (k055555_word_r(device, offset + 1, 0xffff) | k055555_word_r(device, offset, 0xffff) << 16);
9029}
9030
9031READ16_DEVICE_HANDLER( k053244_reg_word_r )
9032{
9033   k05324x_state *k053244 = k05324x_get_safe_token(device);
9034   return(k053244->regs[offset * 2] << 8 | k053244->regs[offset * 2 + 1]);
9035}
9036
9037/*************************************************************************/
9038
9039DEVICE_GET_INFO( k007121 )
9040{
9041   switch (state)
9042   {
9043      /* --- the following bits of info are returned as 64-bit signed integers --- */
9044      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k007121_state);               break;
9045      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9046
9047      /* --- the following bits of info are returned as pointers to data or functions --- */
9048      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k007121);      break;
9049      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9050      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k007121);      break;
9051
9052      /* --- the following bits of info are returned as NULL-terminated strings --- */
9053      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 007121");            break;
9054      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9055      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9056      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9057      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9058   }
9059}
9060
9061
9062DEVICE_GET_INFO( k007342 )
9063{
9064   switch (state)
9065   {
9066      /* --- the following bits of info are returned as 64-bit signed integers --- */
9067      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k007342_state);               break;
9068      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9069
9070      /* --- the following bits of info are returned as pointers to data or functions --- */
9071      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k007342);      break;
9072      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9073      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k007342);      break;
9074
9075      /* --- the following bits of info are returned as NULL-terminated strings --- */
9076      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 007342");            break;
9077      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9078      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9079      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9080      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9081   }
9082}
9083
9084
9085DEVICE_GET_INFO( k007420 )
9086{
9087   switch (state)
9088   {
9089      /* --- the following bits of info are returned as 64-bit signed integers --- */
9090      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k007420_state);               break;
9091      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9092
9093      /* --- the following bits of info are returned as pointers to data or functions --- */
9094      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k007420);      break;
9095      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9096      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k007420);      break;
9097
9098      /* --- the following bits of info are returned as NULL-terminated strings --- */
9099      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 007420");            break;
9100      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9101      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9102      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9103      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9104   }
9105}
9106
9107
9108DEVICE_GET_INFO( k052109 )
9109{
9110   switch (state)
9111   {
9112      /* --- the following bits of info are returned as 64-bit signed integers --- */
9113      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k052109_state);               break;
9114      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9115
9116      /* --- the following bits of info are returned as pointers to data or functions --- */
9117      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k052109);      break;
9118      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9119      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k052109);      break;
9120
9121      /* --- the following bits of info are returned as NULL-terminated strings --- */
9122      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 052109");            break;
9123      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9124      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9125      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9126      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9127   }
9128}
9129
9130DEVICE_GET_INFO( k051960 )
9131{
9132   switch (state)
9133   {
9134      /* --- the following bits of info are returned as 64-bit signed integers --- */
9135      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k051960_state);               break;
9136      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9137
9138      /* --- the following bits of info are returned as pointers to data or functions --- */
9139      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k051960);      break;
9140      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9141      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k051960);      break;
9142
9143      /* --- the following bits of info are returned as NULL-terminated strings --- */
9144      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 051960");            break;
9145      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9146      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9147      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9148      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9149   }
9150}
9151
9152DEVICE_GET_INFO( k05324x )
9153{
9154   switch (state)
9155   {
9156      /* --- the following bits of info are returned as 64-bit signed integers --- */
9157      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k05324x_state);               break;
9158      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9159
9160      /* --- the following bits of info are returned as pointers to data or functions --- */
9161      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k05324x);      break;
9162      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9163      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k05324x);      break;
9164
9165      /* --- the following bits of info are returned as NULL-terminated strings --- */
9166      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 053244 & 053245");            break;
9167      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9168      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9169      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9170      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9171   }
9172}
9173
9174DEVICE_GET_INFO( k053247 )
9175{
9176   switch (state)
9177   {
9178      /* --- the following bits of info are returned as 64-bit signed integers --- */
9179      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k053247_state);               break;
9180      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9181
9182      /* --- the following bits of info are returned as pointers to data or functions --- */
9183      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k053247);      break;
9184      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9185      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k053247);      break;
9186
9187      /* --- the following bits of info are returned as NULL-terminated strings --- */
9188      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 053246 & 053247");            break;
9189      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9190      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9191      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9192      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9193   }
9194}
9195
9196DEVICE_GET_INFO( k055673 )
9197{
9198   switch (state)
9199   {
9200      /* --- the following bits of info are returned as 64-bit signed integers --- */
9201      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k053247_state);               break;
9202      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9203
9204      /* --- the following bits of info are returned as pointers to data or functions --- */
9205      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k055673);      break;
9206      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9207      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k053247);      break;
9208
9209      /* --- the following bits of info are returned as NULL-terminated strings --- */
9210      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 055673");            break;
9211      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9212      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9213      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9214      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9215   }
9216}
9217
9218DEVICE_GET_INFO( k051316 )
9219{
9220   switch (state)
9221   {
9222      /* --- the following bits of info are returned as 64-bit signed integers --- */
9223      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k051316_state);               break;
9224      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9225
9226      /* --- the following bits of info are returned as pointers to data or functions --- */
9227      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k051316);      break;
9228      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9229      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k051316);      break;
9230
9231      /* --- the following bits of info are returned as NULL-terminated strings --- */
9232      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 051316");            break;
9233      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9234      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9235      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9236      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9237   }
9238}
9239
9240DEVICE_GET_INFO( k053936 )
9241{
9242   switch (state)
9243   {
9244      /* --- the following bits of info are returned as 64-bit signed integers --- */
9245      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k053936_state);               break;
9246      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9247
9248      /* --- the following bits of info are returned as pointers to data or functions --- */
9249      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k053936);      break;
9250      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9251      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k053936);               break;
9252
9253      /* --- the following bits of info are returned as NULL-terminated strings --- */
9254      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 053936");            break;
9255      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9256      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9257      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9258      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9259   }
9260}
9261
9262DEVICE_GET_INFO( k053251 )
9263{
9264   switch (state)
9265   {
9266      /* --- the following bits of info are returned as 64-bit signed integers --- */
9267      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k053251_state);               break;
9268      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9269
9270      /* --- the following bits of info are returned as pointers to data or functions --- */
9271      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k053251);      break;
9272      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9273      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k053251);      break;
9274
9275      /* --- the following bits of info are returned as NULL-terminated strings --- */
9276      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 053251");            break;
9277      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9278      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9279      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9280      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9281   }
9282}
9283
9284DEVICE_GET_INFO( k054000 )
9285{
9286   switch (state)
9287   {
9288      /* --- the following bits of info are returned as 64-bit signed integers --- */
9289      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k054000_state);               break;
9290      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9291
9292      /* --- the following bits of info are returned as pointers to data or functions --- */
9293      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k054000);      break;
9294      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9295      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k054000);      break;
9296
9297      /* --- the following bits of info are returned as NULL-terminated strings --- */
9298      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 054000");            break;
9299      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9300      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9301      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9302      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9303   }
9304}
9305
9306DEVICE_GET_INFO( k051733 )
9307{
9308   switch (state)
9309   {
9310      /* --- the following bits of info are returned as 64-bit signed integers --- */
9311      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k051733_state);               break;
9312      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9313
9314      /* --- the following bits of info are returned as pointers to data or functions --- */
9315      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k051733);      break;
9316      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9317      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k051733);      break;
9318
9319      /* --- the following bits of info are returned as NULL-terminated strings --- */
9320      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 051733");            break;
9321      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9322      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9323      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9324      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9325   }
9326}
9327
9328DEVICE_GET_INFO( k056832 )
9329{
9330   switch (state)
9331   {
9332      /* --- the following bits of info are returned as 64-bit signed integers --- */
9333      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k056832_state);               break;
9334      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9335
9336      /* --- the following bits of info are returned as pointers to data or functions --- */
9337      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k056832);      break;
9338      case DEVINFO_FCT_STOP:               /* Nothing */                  break;
9339      case DEVINFO_FCT_RESET:               /* Nothing */                  break;
9340
9341      /* --- the following bits of info are returned as NULL-terminated strings --- */
9342      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 056832");            break;
9343      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9344      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9345      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9346      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9347   }
9348}
9349
9350DEVICE_GET_INFO( k055555 )
9351{
9352   switch (state)
9353   {
9354      /* --- the following bits of info are returned as 64-bit signed integers --- */
9355      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k055555_state);               break;
9356      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9357
9358      /* --- the following bits of info are returned as pointers to data or functions --- */
9359      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k055555);      break;
9360      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9361      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k055555);      break;
9362
9363      /* --- the following bits of info are returned as NULL-terminated strings --- */
9364      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 055555");            break;
9365      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9366      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9367      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9368      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9369   }
9370}
9371
9372DEVICE_GET_INFO( k054338 )
9373{
9374   switch (state)
9375   {
9376      /* --- the following bits of info are returned as 64-bit signed integers --- */
9377      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k054338_state);               break;
9378      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9379
9380      /* --- the following bits of info are returned as pointers to data or functions --- */
9381      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k054338);      break;
9382      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9383      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k054338);      break;
9384
9385      /* --- the following bits of info are returned as NULL-terminated strings --- */
9386      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 054338");            break;
9387      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9388      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9389      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9390      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9391   }
9392}
9393
9394DEVICE_GET_INFO( k053250 )
9395{
9396   switch (state)
9397   {
9398      /* --- the following bits of info are returned as 64-bit signed integers --- */
9399      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k053250_state);               break;
9400      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9401
9402      /* --- the following bits of info are returned as pointers to data or functions --- */
9403      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k053250);      break;
9404      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9405      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k053250);      break;
9406
9407      /* --- the following bits of info are returned as NULL-terminated strings --- */
9408      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 053250");            break;
9409      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9410      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9411      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9412      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9413   }
9414}
9415
9416DEVICE_GET_INFO( k053252 )
9417{
9418   switch (state)
9419   {
9420      /* --- the following bits of info are returned as 64-bit signed integers --- */
9421      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(k053252_state);               break;
9422      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
9423
9424      /* --- the following bits of info are returned as pointers to data or functions --- */
9425      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(k053252);      break;
9426      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
9427      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(k053252);      break;
9428
9429      /* --- the following bits of info are returned as NULL-terminated strings --- */
9430      case DEVINFO_STR_NAME:               strcpy(info->s, "Konami 053252");            break;
9431      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Konami Video IC");               break;
9432      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
9433      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
9434      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
9435   }
9436}
src/mame/video/djmain.c
r6740r6741
44 */
55
66#include "driver.h"
7#include "video/konamiic.h"
7#include "video/konicdev.h"
88
99#define NUM_SPRITES   (0x800 / 16)
1010#define NUM_LAYERS   2
r6740r6741
1414
1515static void draw_sprites(running_machine* machine, bitmap_t *bitmap, const rectangle *cliprect)
1616{
17   const device_config *k055555 = devtag_get_device(machine, "k055555");
1718   int offs, pri_code;
1819   int sortedlist[NUM_SPRITES];
1920
20   machine->gfx[0]->color_base = K055555_read_register(K55_PALBASE_SUB2) * 0x400;
21   machine->gfx[0]->color_base = k055555_read_register(k055555, K55_PALBASE_SUB2) * 0x400;
2122
2223   for (offs = 0; offs < NUM_SPRITES; offs++)
2324      sortedlist[offs] = -1;
r6740r6741
128129}
129130
130131
131static void game_tile_callback(int layer, int *code, int *color, int *flags)
132void djmain_tile_callback(running_machine* machine, int layer, int *code, int *color, int *flags)
132133{
133134}
134135
135136VIDEO_START( djmain )
136137{
137   static int scrolld[NUM_LAYERS][4][2] = {
138       {{ 0, 0}, {0, 0}, {0, 0}, {0, 0}},
139       {{ 0, 0}, {0, 0}, {0, 0}, {0, 0}}
140   };
138   const device_config *k056832 = devtag_get_device(machine, "k056832");
141139
142   K056832_vh_start(machine, "gfx2", K056832_BPP_4dj, 1, scrolld, game_tile_callback, 1);
143   K055555_vh_start(machine);
144
145   K056832_set_LayerOffset(0, -92, -27);
146   // K056832_set_LayerOffset(1, -87, -27);
147   K056832_set_LayerOffset(1, -88, -27);
140   k056832_set_layer_offs(k056832, 0, -92, -27);
141   // k056832_set_layer_offs(k056832, 1, -87, -27);
142   k056832_set_layer_offs(k056832, 1, -88, -27);
148143}
149144
150145VIDEO_UPDATE( djmain )
151146{
152   int enables = K055555_read_register(K55_INPUT_ENABLES);
147   const device_config *k056832 = devtag_get_device(screen->machine, "k056832");
148   const device_config *k055555 = devtag_get_device(screen->machine, "k055555");
149   int enables = k055555_read_register(k055555, K55_INPUT_ENABLES);
153150   int pri[NUM_LAYERS + 1];
154151   int order[NUM_LAYERS + 1];
155152   int i, j;
156153
157154   for (i = 0; i < NUM_LAYERS; i++)
158      pri[i] = K055555_read_register(K55_PRIINP_0 + i * 3);
159   pri[i] = K055555_read_register(K55_PRIINP_10);
155      pri[i] = k055555_read_register(k055555, K55_PRIINP_0 + i * 3);
156   pri[i] = k055555_read_register(k055555, K55_PRIINP_10);
160157
161158   for (i = 0; i < NUM_LAYERS + 1; i++)
162159      order[i] = i;
r6740r6741
185182      else
186183      {
187184         if (enables & (K55_INP_VRAM_A << layer))
188            K056832_tilemap_draw_dj(screen->machine, bitmap, cliprect, layer, 0, 1 << i);
185            k056832_tilemap_draw_dj(k056832, bitmap, cliprect, layer, 0, 1 << i);
189186      }
190187   }
191188   return 0;
src/mame/video/firetrk.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "firetrk.h"
8#include "includes/firetrk.h"
99
1010
1111UINT8 *firetrk_alpha_num_ram;
src/mame/video/konicdev.h
r0r6741
1/*************************************************************************
2
3    konicdev.h
4
5    Implementation of various Konami custom IC used for video
6
7**************************************************************************/
8
9#include "devcb.h"
10
11
12/***************************************************************************
13    TYPE DEFINITIONS
14***************************************************************************/
15
16typedef void (*k007342_callback)(running_machine *machine, int tmap, int bank, int *code, int *color, int *flags);
17typedef void (*k007420_callback)(running_machine *machine, int *code, int *color);
18typedef void (*k052109_callback)(running_machine *machine, int layer, int bank, int *code, int *color, int *flags, int *priority);
19typedef void (*k051960_callback)(running_machine *machine, int *code, int *color, int *priority, int *shadow);
20typedef void (*k05324x_callback)(running_machine *machine, int *code, int *color, int *priority);
21typedef void (*k051316_callback)(running_machine *machine, int *code, int *color, int *flags);
22typedef void (*k056832_callback)(running_machine *machine, int layer, int *code, int *color, int *flags);
23
24
25typedef struct _k007342_interface k007342_interface;
26struct _k007342_interface
27{
28   int                gfxnum;
29   k007342_callback   callback;
30};
31
32typedef struct _k007420_interface k007420_interface;
33struct _k007420_interface
34{
35   int                banklimit;
36   k007420_callback   callback;
37};
38
39typedef struct _k052109_interface k052109_interface;
40struct _k052109_interface
41{
42   const char         *gfx_memory_region;
43   int                gfx_num;
44   int                plane_order;
45   int                deinterleave;
46   k052109_callback   callback;
47};
48
49typedef struct _k051960_interface k051960_interface;
50struct _k051960_interface
51{
52   const char         *gfx_memory_region;
53   int                gfx_num;
54   int                plane_order;
55   int                deinterleave;
56   k051960_callback   callback;
57};
58
59typedef struct _k05324x_interface k05324x_interface;
60struct _k05324x_interface
61{
62   const char         *gfx_memory_region;
63   int                gfx_num;
64   int                plane_order;
65   int                dx, dy;
66   int                deinterleave;
67   k05324x_callback   callback;
68};
69
70typedef struct _k053247_interface k053247_interface;
71struct _k053247_interface
72{
73   const char         *screen;
74   const char         *gfx_memory_region;
75   int                gfx_num;
76   int                plane_order;
77   int                dx, dy;
78   int                deinterleave;
79   k05324x_callback   callback;
80};
81
82typedef struct _k051316_interface k051316_interface;
83struct _k051316_interface
84{
85   const char         *gfx_memory_region;
86   int                gfx_num;
87   int                bpp, pen_is_mask, transparent_pen;
88   int                wrap, xoffs, yoffs;
89   k051316_callback   callback;
90};
91
92typedef struct _k053936_interface k053936_interface;
93struct _k053936_interface
94{
95   int                wrap, xoff, yoff;
96};
97
98typedef struct _k056832_interface k056832_interface;
99struct _k056832_interface
100{
101   const char         *gfx_memory_region;
102   int                gfx_num;
103   int                bpp;
104   int                big;
105   int                djmain_hack;
106   int                deinterleave;
107   k056832_callback   callback;
108
109   const char         *k055555;   // tbyahhoo uses the k056832 together with a k055555
110};
111
112typedef struct _k054338_interface k054338_interface;
113struct _k054338_interface
114{
115   const char         *screen;
116   int                alpha_inv;
117   const char         *k055555;
118};
119
120typedef struct _k053250_interface k053250_interface;
121struct _k053250_interface
122{
123   const char         *screen;
124   const char         *gfx_memory_region;
125   int                xoff, yoff;
126};
127
128
129/***************************************************************************
130    FUNCTION PROTOTYPES
131***************************************************************************/
132
133DEVICE_GET_INFO( k007121 );
134DEVICE_GET_INFO( k007342 );
135DEVICE_GET_INFO( k007420 );
136DEVICE_GET_INFO( k052109 );
137DEVICE_GET_INFO( k051960 );
138DEVICE_GET_INFO( k05324x );
139DEVICE_GET_INFO( k053247 );
140DEVICE_GET_INFO( k055673 );
141DEVICE_GET_INFO( k051316 );
142DEVICE_GET_INFO( k053936 );
143DEVICE_GET_INFO( k053251 );
144DEVICE_GET_INFO( k054000 );
145DEVICE_GET_INFO( k051733 );
146DEVICE_GET_INFO( k056832 );
147DEVICE_GET_INFO( k055555 );
148DEVICE_GET_INFO( k054338 );
149DEVICE_GET_INFO( k053250 );
150DEVICE_GET_INFO( k053252 );
151
152
153/***************************************************************************
154    DEVICE CONFIGURATION MACROS
155***************************************************************************/
156
157#define K007121 DEVICE_GET_INFO_NAME( k007121 )
158
159#define MDRV_K007121_ADD(_tag) \
160   MDRV_DEVICE_ADD(_tag, K007121, 0)
161
162#define K007342 DEVICE_GET_INFO_NAME( k007342 )
163
164#define MDRV_K007342_ADD(_tag, _interface) \
165   MDRV_DEVICE_ADD(_tag, K007342, 0) \
166   MDRV_DEVICE_CONFIG(_interface)
167
168#define K007420 DEVICE_GET_INFO_NAME( k007420 )
169
170#define MDRV_K007420_ADD(_tag, _interface) \
171   MDRV_DEVICE_ADD(_tag, K007420, 0) \
172   MDRV_DEVICE_CONFIG(_interface)
173
174#define K052109 DEVICE_GET_INFO_NAME( k052109 )
175
176#define MDRV_K052109_ADD(_tag, _interface) \
177   MDRV_DEVICE_ADD(_tag, K052109, 0) \
178   MDRV_DEVICE_CONFIG(_interface)
179
180#define K051960 DEVICE_GET_INFO_NAME( k051960 )
181
182#define MDRV_K051960_ADD(_tag, _interface) \
183   MDRV_DEVICE_ADD(_tag, K051960, 0) \
184   MDRV_DEVICE_CONFIG(_interface)
185
186#define K053244 DEVICE_GET_INFO_NAME( k05324x )
187#define K053245 DEVICE_GET_INFO_NAME( k05324x )
188
189#define MDRV_K053244_ADD(_tag, _interface) \
190   MDRV_DEVICE_ADD(_tag, K053244, 0) \
191   MDRV_DEVICE_CONFIG(_interface)
192
193#define MDRV_K053245_ADD(_tag, _interface) \
194   MDRV_DEVICE_ADD(_tag, K053245, 0) \
195   MDRV_DEVICE_CONFIG(_interface)
196
197#define K053246 DEVICE_GET_INFO_NAME( k053247 )
198#define K053247 DEVICE_GET_INFO_NAME( k053247 )
199
200#define MDRV_K053246_ADD(_tag, _interface) \
201   MDRV_DEVICE_ADD(_tag, K053246, 0) \
202   MDRV_DEVICE_CONFIG(_interface)
203
204#define MDRV_K053247_ADD(_tag, _interface) \
205   MDRV_DEVICE_ADD(_tag, K053247, 0) \
206   MDRV_DEVICE_CONFIG(_interface)
207
208#define K055673 DEVICE_GET_INFO_NAME( k055673 )
209
210#define MDRV_K055673_ADD(_tag, _interface) \
211   MDRV_DEVICE_ADD(_tag, K055673, 0) \
212   MDRV_DEVICE_CONFIG(_interface)
213
214#define K051316 DEVICE_GET_INFO_NAME( k051316 )
215
216#define MDRV_K051316_ADD(_tag, _interface) \
217   MDRV_DEVICE_ADD(_tag, K051316, 0) \
218   MDRV_DEVICE_CONFIG(_interface)
219
220#define K053936 DEVICE_GET_INFO_NAME( k053936 )
221
222#define MDRV_K053936_ADD(_tag, _interface) \
223   MDRV_DEVICE_ADD(_tag, K053936, 0) \
224   MDRV_DEVICE_CONFIG(_interface)
225
226#define K053251 DEVICE_GET_INFO_NAME( k053251 )
227
228#define MDRV_K053251_ADD(_tag) \
229   MDRV_DEVICE_ADD(_tag, K053251, 0)
230
231#define K054000 DEVICE_GET_INFO_NAME( k054000 )
232
233#define MDRV_K054000_ADD(_tag) \
234   MDRV_DEVICE_ADD(_tag, K054000, 0)
235
236#define K051733 DEVICE_GET_INFO_NAME( k051733 )
237
238#define MDRV_K051733_ADD(_tag) \
239   MDRV_DEVICE_ADD(_tag, K051733, 0)
240
241#define K056832 DEVICE_GET_INFO_NAME( k056832 )
242
243#define MDRV_K056832_ADD(_tag, _interface) \
244   MDRV_DEVICE_ADD(_tag, K056832, 0) \
245   MDRV_DEVICE_CONFIG(_interface)
246
247#define K055555 DEVICE_GET_INFO_NAME( k055555 )
248
249#define MDRV_K055555_ADD(_tag) \
250   MDRV_DEVICE_ADD(_tag, K055555, 0)
251
252#define K054338 DEVICE_GET_INFO_NAME( k054338 )
253
254#define MDRV_K054338_ADD(_tag, _interface) \
255   MDRV_DEVICE_ADD(_tag, K054338, 0) \
256   MDRV_DEVICE_CONFIG(_interface)
257
258#define K053250 DEVICE_GET_INFO_NAME( k053250 )
259
260#define MDRV_K053250_ADD(_tag, _interface) \
261   MDRV_DEVICE_ADD(_tag, K053250, 0) \
262   MDRV_DEVICE_CONFIG(_interface)
263
264#define K053252 DEVICE_GET_INFO_NAME( k053252 )
265
266#define MDRV_K053252_ADD(_tag) \
267   MDRV_DEVICE_ADD(_tag, K053252, 0)
268
269
270/***************************************************************************
271    HELPERS FOR DRIVERS
272***************************************************************************/
273
274enum
275{
276   KONAMI_ROM_DEINTERLEAVE_NONE = 0,
277   KONAMI_ROM_DEINTERLEAVE_2,
278   KONAMI_ROM_DEINTERLEAVE_2_HALF,
279   KONAMI_ROM_DEINTERLEAVE_4,
280   KONAMI_ROM_SHUFFLE8
281};
282
283/* helper function to join two 16-bit ROMs and form a 32-bit data stream */
284void konamid_rom_deinterleave_2(running_machine *machine, const char *mem_region);
285void konamid_rom_deinterleave_2_half(running_machine *machine, const char *mem_region);
286/* helper function to join four 16-bit ROMs and form a 64-bit data stream */
287void konamid_rom_deinterleave_4(running_machine *machine, const char *mem_region);
288
289/***************************************************************************
290    DEVICE I/O FUNCTIONS
291***************************************************************************/
292
293/**  Konami 007121  **/
294WRITE8_DEVICE_HANDLER( k007121_ctrlram_w );   // FIXME: this is probably unused: writes to ctrlram should use ctrl_w below!
295READ8_DEVICE_HANDLER( k007121_ctrlram_r );
296WRITE8_DEVICE_HANDLER( k007121_ctrl_w );
297
298/* shall we move source in the interface? */
299/* also notice that now we directly pass *gfx[chip] instead of **gfx !! */
300void k007121_sprites_draw( const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, gfx_element *gfx, colortable_t *ctable,
301                    const UINT8 *source, int base_color, int global_x_offset, int bank_base, UINT32 pri_mask );
302
303
304/**  Konami 007342  **/
305READ8_DEVICE_HANDLER( k007342_r );
306WRITE8_DEVICE_HANDLER( k007342_w );
307READ8_DEVICE_HANDLER( k007342_scroll_r );
308WRITE8_DEVICE_HANDLER( k007342_scroll_w );
309WRITE8_DEVICE_HANDLER( k007342_vreg_w );
310
311void k007342_tilemap_update(const device_config *device);
312void k007342_tilemap_set_enable(const device_config *device, int layer, int enable);
313void k007342_tilemap_draw(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int num, int flags, UINT32 priority);
314int k007342_is_int_enabled(const device_config *device);
315
316
317/**  Konami 007420  **/
318#define K007420_SPRITERAM_SIZE 0x200
319
320READ8_DEVICE_HANDLER( k007420_r );
321WRITE8_DEVICE_HANDLER( k007420_w );
322void k007420_sprites_draw(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, gfx_element *gfx);
323
324
325/**  Konami 052109  **/
326/*
327You don't have to decode the graphics: the vh_start() routines will do that
328for you, using the plane order passed.
329Of course the ROM data must be in the correct order. This is a way to ensure
330that the ROM test will pass.
331The konami_rom_deinterleave() function above will do the reorganization for
332you in most cases (but see tmnt.c for additional bit rotations or byte
333permutations which may be required).
334*/
335#define NORMAL_PLANE_ORDER 0x0123
336#define REVERSE_PLANE_ORDER 0x3210
337#define GRADIUS3_PLANE_ORDER 0x1111
338
339
340/*
341The callback is passed:
342- layer number (0 = FIX, 1 = A, 2 = B)
343- bank (range 0-3, output of the pins CAB1 and CAB2)
344- code (range 00-FF, output of the pins VC3-VC10)
345  NOTE: code is in the range 0000-FFFF for X-Men, which uses extra RAM
346- color (range 00-FF, output of the pins COL0-COL7)
347The callback must put:
348- in code the resulting tile number
349- in color the resulting color index
350- if necessary, put flags and/or priority for the TileMap code in the tile_info
351  structure (e.g. TILE_FLIPX). Note that TILE_FLIPY is handled internally by the
352  chip so it must not be set by the callback.
353*/
354
355READ8_DEVICE_HANDLER( k052109_r );
356WRITE8_DEVICE_HANDLER( k052109_w );
357READ16_DEVICE_HANDLER( k052109_word_r );
358WRITE16_DEVICE_HANDLER( k052109_word_w );
359READ16_DEVICE_HANDLER( k052109_lsb_r );
360WRITE16_DEVICE_HANDLER( k052109_lsb_w );
361
362void k052109_set_rmrd_line(const device_config *device, int state);
363int k052109_get_rmrd_line(const device_config *device);
364void k052109_tilemap_update(const device_config *device);
365int k052109_is_irq_enabled(const device_config *device);
366void k052109_set_layer_offsets(const device_config *device, int layer, int dx, int dy);
367void k052109_tilemap_mark_dirty(const device_config *device, int tmap_num);
368void k052109_tilemap_draw(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int tmap_num, UINT32 flags, UINT8 priority);
369void k052109_postload_tileflip_reset( const device_config *device );   // this has to be added to POSTLOAD functions in each driver
370
371
372/**  Konami 051960 / 051937  **/
373/*
374The callback is passed:
375- code (range 00-1FFF, output of the pins CA5-CA17)
376- color (range 00-FF, output of the pins OC0-OC7). Note that most of the
377  time COL7 seems to be "shadow", but not always (e.g. Aliens).
378The callback must put:
379- in code the resulting sprite number
380- in color the resulting color index
381- if necessary, in priority the priority of the sprite wrt tilemaps
382- if necessary, alter shadow to indicate whether the sprite has shadows enabled.
383  shadow is preloaded with color & 0x80 so it doesn't need to be changed unless
384  the game has special treatment (Aliens)
385*/
386
387READ8_DEVICE_HANDLER( k051960_r );
388WRITE8_DEVICE_HANDLER( k051960_w );
389READ16_DEVICE_HANDLER( k051960_word_r );
390WRITE16_DEVICE_HANDLER( k051960_word_w );
391
392READ8_DEVICE_HANDLER( k051937_r );
393WRITE8_DEVICE_HANDLER( k051937_w );
394READ16_DEVICE_HANDLER( k051937_word_r );
395WRITE16_DEVICE_HANDLER( k051937_word_w );
396
397void k051960_sprites_draw(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int min_priority, int max_priority);
398int k051960_is_irq_enabled(const device_config *device);
399int k051960_is_nmi_enabled(const device_config *device);
400void k051960_set_sprite_offsets(const device_config *device, int dx, int dy);
401
402#if 0 // to be moved in the specific drivers!
403/* special handling for the chips sharing address space */
404READ8_HANDLER( k052109_051960_r );
405WRITE8_HANDLER( k052109_051960_w );
406#endif
407
408
409/**  Konami 053244 / 053245  **/
410READ16_DEVICE_HANDLER( k053245_word_r );
411WRITE16_DEVICE_HANDLER( k053245_word_w );
412READ8_DEVICE_HANDLER( k053245_r );
413WRITE8_DEVICE_HANDLER( k053245_w );
414READ8_DEVICE_HANDLER( k053244_r );
415WRITE8_DEVICE_HANDLER( k053244_w );
416READ16_DEVICE_HANDLER( k053244_lsb_r );
417WRITE16_DEVICE_HANDLER( k053244_lsb_w );
418READ16_DEVICE_HANDLER( k053244_word_r );
419WRITE16_DEVICE_HANDLER( k053244_word_w );
420void k053244_bankselect(const device_config *device, int bank);   /* used by TMNT2, Asterix and Premier Soccer for ROM testing */
421void k053245_sprites_draw(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect);
422void k053245_sprites_draw_lethal(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect); /* for lethal enforcers */
423void k053245_clear_buffer(const device_config *device);
424void k053245_set_sprite_offs(const device_config *device, int offsx, int offsy);
425
426
427
428/**  Konami 053246 / 053247 / 055673  **/
429#define K055673_LAYOUT_GX  0
430#define K055673_LAYOUT_RNG 1
431#define K055673_LAYOUT_LE2 2
432#define K055673_LAYOUT_GX6 3
433
434READ16_DEVICE_HANDLER( k055673_rom_word_r );
435READ16_DEVICE_HANDLER( k055673_GX6bpp_rom_word_r );
436
437/*
438Callback procedures for non-standard shadows:
439
4401) translate shadow code to the correct 2-bit form (0=off, 1-3=style)
4412) shift shadow code left by K053247_SHDSHIFT and add the K053247_CUSTOMSHADOW flag
4423) combine the result with sprite color
443*/
444#define K053247_CUSTOMSHADOW   0x20000000
445#define K053247_SHDSHIFT      20
446
447READ8_DEVICE_HANDLER( k053247_r );
448WRITE8_DEVICE_HANDLER( k053247_w );
449READ16_DEVICE_HANDLER( k053247_word_r );
450WRITE16_DEVICE_HANDLER( k053247_word_w );
451READ32_DEVICE_HANDLER( k053247_long_r );
452WRITE32_DEVICE_HANDLER( k053247_long_w );
453WRITE16_DEVICE_HANDLER( k053247_reg_word_w ); // "OBJSET2" registers
454WRITE32_DEVICE_HANDLER( k053247_reg_long_w );
455
456void k053247_sprites_draw(const device_config *device, bitmap_t *bitmap,const rectangle *cliprect);
457int k053247_read_register(const device_config *device, int regnum);
458void k053247_set_sprite_offs(const device_config *device, int offsx, int offsy);
459void k053247_wraparound_enable(const device_config *device, int status);
460void k05324x_set_z_rejection(const device_config *device, int zcode); // common to k053244/5
461void k053247_set_z_rejection(const device_config *device, int zcode); // common to k053246/7
462void k053247_get_ram(const device_config *device, UINT16 **ram);
463int k053247_get_dx(const device_config *device);
464int k053247_get_dy(const device_config *device);
465
466READ8_DEVICE_HANDLER( k053246_r );
467WRITE8_DEVICE_HANDLER( k053246_w );
468READ16_DEVICE_HANDLER( k053246_word_r );
469WRITE16_DEVICE_HANDLER( k053246_word_w );
470READ32_DEVICE_HANDLER( k053246_long_r );
471WRITE32_DEVICE_HANDLER( k053246_long_w );
472
473void k053246_set_objcha_line(const device_config *device, int state);
474int k053246_is_irq_enabled(const device_config *device);
475int k053246_read_register(const device_config *device, int regnum);
476
477/**  Konami 051316  **/
478/*
479The callback is passed:
480- code (range 00-FF, contents of the first tilemap RAM byte)
481- color (range 00-FF, contents of the first tilemap RAM byte). Note that bit 6
482  seems to be hardcoded as flip X.
483The callback must put:
484- in code the resulting tile number
485- in color the resulting color index
486- if necessary, put flags for the TileMap code in the tile_info
487  structure (e.g. TILE_FLIPX)
488*/
489
490READ8_DEVICE_HANDLER( k051316_r );
491WRITE8_DEVICE_HANDLER( k051316_w );
492READ8_DEVICE_HANDLER( k051316_rom_r );
493WRITE8_DEVICE_HANDLER( k051316_ctrl_w );
494void k051316_zoom_draw(const device_config *device, bitmap_t *bitmap,const rectangle *cliprect,int flags,UINT32 priority);
495void k051316_wraparound_enable(const device_config *device, int status);
496
497
498/**  Konami 053936  **/
499WRITE16_DEVICE_HANDLER( k053936_ctrl_w );
500READ16_DEVICE_HANDLER( k053936_ctrl_r );   // FIXME: this is probably unused... to be checked!
501WRITE16_DEVICE_HANDLER( k053936_linectrl_w );
502READ16_DEVICE_HANDLER( k053936_linectrl_r );
503void k053936_zoom_draw(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, tilemap *tmap, int flags, UINT32 priority, int glfgreat_hack);
504void k053936_wraparound_enable(const device_config *device, int status);   // shall we merge this into the configuration intf?
505void k053936_set_offset(const device_config *device, int xoffs, int yoffs);   // shall we merge this into the configuration intf?
506
507
508/**  Konami 053251 **/
509/*
510  Note: k053251_w() automatically does a tilemap_mark_all_tiles_dirty(ALL_TILEMAPS)
511  when some palette index changes. If ALL_TILEMAPS is too expensive, use
512  k053251_set_tilemaps() to indicate which tilemap is associated with each index.
513 */
514WRITE8_DEVICE_HANDLER( k053251_w );
515WRITE16_DEVICE_HANDLER( k053251_lsb_w );
516WRITE16_DEVICE_HANDLER( k053251_msb_w );
517int k053251_get_priority(const device_config *device, int ci);
518int k053251_get_palette_index(const device_config *device, int ci);
519int k053251_get_tmap_dirty(const device_config *device, int tmap_num);
520void k053251_set_tmap_dirty(const device_config *device, int tmap_num, int data);
521void k053251_postload_reset_indexes(const device_config *device);
522
523enum
524{
525   K053251_CI0 = 0,
526   K053251_CI1,
527   K053251_CI2,
528   K053251_CI3,
529   K053251_CI4
530};
531
532/**  Konami 054000 **/
533WRITE8_DEVICE_HANDLER( k054000_w );
534READ8_DEVICE_HANDLER( k054000_r );
535WRITE16_DEVICE_HANDLER( k054000_lsb_w );
536READ16_DEVICE_HANDLER( k054000_lsb_r );
537
538
539/**  Konami 051733 **/
540WRITE8_DEVICE_HANDLER( k051733_w );
541READ8_DEVICE_HANDLER( k051733_r );
542
543
544/**  Konami 056832 **/
545void k056832_SetExtLinescroll(const device_config *device);   /* Lethal Enforcers */
546
547#define K056832_DRAW_FLAG_FORCE_XYSCROLL      0x00800000
548
549READ16_DEVICE_HANDLER( k056832_ram_word_r );
550WRITE16_DEVICE_HANDLER( k056832_ram_word_w );
551READ16_DEVICE_HANDLER( k056832_ram_half_word_r );
552WRITE16_DEVICE_HANDLER( k056832_ram_half_word_w );
553READ16_DEVICE_HANDLER( k056832_5bpp_rom_word_r );
554READ32_DEVICE_HANDLER( k056832_5bpp_rom_long_r );
555READ32_DEVICE_HANDLER( k056832_6bpp_rom_long_r );
556READ16_DEVICE_HANDLER( k056832_rom_word_r );
557READ16_DEVICE_HANDLER( k056832_mw_rom_word_r );
558READ16_DEVICE_HANDLER( k056832_bishi_rom_word_r );
559READ16_DEVICE_HANDLER( k056832_old_rom_word_r );
560READ16_DEVICE_HANDLER( k056832_rom_word_8000_r );
561WRITE16_DEVICE_HANDLER( k056832_word_w ); // "VRAM" registers
562WRITE16_DEVICE_HANDLER( k056832_b_word_w );
563READ8_DEVICE_HANDLER( k056832_ram_code_lo_r );
564READ8_DEVICE_HANDLER( k056832_ram_code_hi_r );
565READ8_DEVICE_HANDLER( k056832_ram_attr_lo_r );
566READ8_DEVICE_HANDLER( k056832_ram_attr_hi_r );
567WRITE8_DEVICE_HANDLER( k056832_ram_code_lo_w );
568WRITE8_DEVICE_HANDLER( k056832_ram_code_hi_w );
569WRITE8_DEVICE_HANDLER( k056832_ram_attr_lo_w );
570WRITE8_DEVICE_HANDLER( k056832_ram_attr_hi_w );
571WRITE8_DEVICE_HANDLER( k056832_w );
572WRITE8_DEVICE_HANDLER( k056832_b_w );
573void k056832_mark_plane_dirty(const device_config *device, int num);
574void k056832_mark_all_tmaps_dirty(const device_config *device);
575void k056832_tilemap_draw(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int num, UINT32 flags, UINT32 priority);
576void k056832_tilemap_draw_dj(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int layer, UINT32 flags, UINT32 priority);
577void k056832_set_layer_association(const device_config *device, int status);
578int  k056832_get_layer_association(const device_config *device);
579void k056832_set_layer_offs(const device_config *device, int layer, int offsx, int offsy);
580void k056832_set_lsram_page(const device_config *device, int logical_page, int physical_page, int physical_offset);
581void k056832_linemap_enable(const device_config *device, int enable);
582int  k056832_is_irq_enabled(const device_config *device, int irqline);
583void k056832_read_avac(const device_config *device, int *mode, int *data);
584int  k056832_read_register(const device_config *device, int regnum);
585int k056832_get_current_rambank(const device_config *device);
586int k056832_get_lookup(const device_config *device, int bits);   /* Asterix */
587void k056832_set_tile_bank(const device_config *device, int bank);   /* Asterix */
588
589READ32_DEVICE_HANDLER( k056832_ram_long_r );
590READ32_DEVICE_HANDLER( k056832_rom_long_r );
591WRITE32_DEVICE_HANDLER( k056832_ram_long_w );
592WRITE32_DEVICE_HANDLER( k056832_long_w );
593WRITE32_DEVICE_HANDLER( k056832_b_long_w );
594
595/* bit depths for the 56832 */
596#define K056832_BPP_4   0
597#define K056832_BPP_5   1
598#define K056832_BPP_6   2
599#define K056832_BPP_8   3
600#define K056832_BPP_4dj   4
601#define K056832_BPP_8LE   5
602
603/**  Konami 055555  **/
604void k055555_write_reg(const device_config *device, UINT8 regnum, UINT8 regdat);
605WRITE16_DEVICE_HANDLER( k055555_word_w );
606WRITE32_DEVICE_HANDLER( k055555_long_w );
607int k055555_read_register(const device_config *device, int regnum);
608int k055555_get_palette_index(const device_config *device, int idx);
609
610
611/* K055555 registers */
612/* priority inputs */
613#define K55_PALBASE_BG        0   // background palette
614#define K55_CONTROL           1   // control register
615#define K55_COLSEL_0          2   // layer A, B color depth
616#define K55_COLSEL_1          3   // layer C, D color depth
617#define K55_COLSEL_2          4   // object, S1 color depth
618#define K55_COLSEL_3          5   // S2, S3 color depth
619
620#define K55_PRIINP_0          7   // layer A pri 0
621#define K55_PRIINP_1          8   // layer A pri 1
622#define K55_PRIINP_2          9   // layer A "COLPRI"
623#define K55_PRIINP_3          10   // layer B pri 0
624#define K55_PRIINP_4          11   // layer B pri 1
625#define K55_PRIINP_5          12   // layer B "COLPRI"
626#define K55_PRIINP_6          13   // layer C pri
627#define K55_PRIINP_7          14   // layer D pri
628#define K55_PRIINP_8          15   // OBJ pri
629#define K55_PRIINP_9          16   // sub 1 (GP:PSAC) pri
630#define K55_PRIINP_10         17   // sub 2 (GX:PSAC) pri
631#define K55_PRIINP_11         18   // sub 3 pri
632
633#define K55_OINPRI_ON         19   // object priority bits selector
634
635#define K55_PALBASE_A         23   // layer A palette
636#define K55_PALBASE_B         24   // layer B palette
637#define K55_PALBASE_C         25   // layer C palette
638#define K55_PALBASE_D         26   // layer D palette
639#define K55_PALBASE_OBJ       27   // OBJ palette
640#define K55_PALBASE_SUB1      28   // SUB1 palette
641#define K55_PALBASE_SUB2      29   // SUB2 palette
642#define K55_PALBASE_SUB3      30   // SUB3 palette
643
644#define K55_BLEND_ENABLES     33   // blend enables for tilemaps
645#define K55_VINMIX_ON         34   // additional blend enables for tilemaps
646#define K55_OSBLEND_ENABLES   35   // obj/sub blend enables
647#define K55_OSBLEND_ON        36   // not sure, related to obj/sub blend
648
649#define K55_SHAD1_PRI         37   // shadow/highlight 1 priority
650#define K55_SHAD2_PRI         38   // shadow/highlight 2 priority
651#define K55_SHAD3_PRI         39   // shadow/highlight 3 priority
652#define K55_SHD_ON            40   // shadow/highlight
653#define K55_SHD_PRI_SEL       41   // shadow/highlight
654
655#define K55_VBRI              42   // VRAM layer brightness enable
656#define K55_OSBRI             43   // obj/sub brightness enable, part 1
657#define K55_OSBRI_ON          44   // obj/sub brightness enable, part 2
658#define K55_INPUT_ENABLES     45   // input enables
659
660/* bit masks for the control register */
661#define K55_CTL_GRADDIR       0x01   // 0=vertical, 1=horizontal
662#define K55_CTL_GRADENABLE    0x02   // 0=BG is base color only, 1=gradient
663#define K55_CTL_FLIPPRI       0x04   // 0=standard Konami priority, 1=reverse
664#define K55_CTL_SDSEL         0x08   // 0=normal shadow timing, 1=(not used by GX)
665
666/* bit masks for the input enables */
667#define K55_INP_VRAM_A        0x01
668#define K55_INP_VRAM_B        0x02
669#define K55_INP_VRAM_C        0x04
670#define K55_INP_VRAM_D        0x08
671#define K55_INP_OBJ           0x10
672#define K55_INP_SUB1          0x20
673#define K55_INP_SUB2          0x40
674#define K55_INP_SUB3          0x80
675
676
677/**  Konami 054338  **/
678/* mixer/alpha blender */
679
680WRITE16_DEVICE_HANDLER( k054338_word_w ); // "CLCT" registers
681WRITE32_DEVICE_HANDLER( k054338_long_w );
682int k054338_register_r(const device_config *device, int reg);
683void k054338_update_all_shadows(const device_config *device, int rushingheroes_hack);         // called at the beginning of VIDEO_UPDATE()
684void k054338_fill_solid_bg(const device_config *device, bitmap_t *bitmap);            // solid backcolor fill
685void k054338_fill_backcolor(const device_config *device, bitmap_t *bitmap, int mode);   // unified fill, 0=solid, 1=gradient (by using a k055555)
686int  k054338_set_alpha_level(const device_config *device, int pblend);                     // blend style 0-2
687void k054338_invert_alpha(const device_config *device, int invert);                        // 0=0x00(invis)-0x1f(solid), 1=0x1f(invis)-0x00(solod)
688//void K054338_export_config(const device_config *device, int **shdRGB);
689
690#define K338_REG_BGC_R      0
691#define K338_REG_BGC_GB      1
692#define K338_REG_SHAD1R      2
693#define K338_REG_BRI3      11
694#define K338_REG_PBLEND      13
695#define K338_REG_CONTROL   15
696
697#define K338_CTL_KILL      0x01   /* 0 = no video output, 1 = enable */
698#define K338_CTL_MIXPRI      0x02
699#define K338_CTL_SHDPRI      0x04
700#define K338_CTL_BRTPRI      0x08
701#define K338_CTL_WAILSL      0x10
702#define K338_CTL_CLIPSL      0x20
703
704
705/**  Konami 053250  **/
706WRITE16_DEVICE_HANDLER( k053250_w );
707READ16_DEVICE_HANDLER( k053250_r );
708WRITE16_DEVICE_HANDLER( k053250_ram_w );
709READ16_DEVICE_HANDLER( k053250_ram_r );
710READ16_DEVICE_HANDLER( k053250_rom_r );
711
712// K053250_draw() control flags
713#define K053250_WRAP500      0x01
714#define K053250_OVERDRIVE   0x02
715
716void k053250_draw(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int colorbase, int flags, int pri);
717void k053250_dma(const device_config *device, int limiter);
718
719
720/**  Konami 053252  **/
721/* CRT and interrupt control unit */
722READ16_DEVICE_HANDLER( k053252_word_r );   // CCU registers
723WRITE16_DEVICE_HANDLER( k053252_word_w );
724WRITE32_DEVICE_HANDLER( k053252_long_w );
725
726
727// debug handlers
728READ16_DEVICE_HANDLER( k056832_word_r );        // VACSET
729READ16_DEVICE_HANDLER( k056832_b_word_r );      // VSCCS  (board dependent)
730READ16_DEVICE_HANDLER( k053246_reg_word_r );    // OBJSET1
731READ16_DEVICE_HANDLER( k053247_reg_word_r );    // OBJSET2
732READ16_DEVICE_HANDLER( k053251_lsb_r );         // PCU1
733READ16_DEVICE_HANDLER( k053251_msb_r );         // PCU1
734READ16_DEVICE_HANDLER( k055555_word_r );        // PCU2
735READ16_DEVICE_HANDLER( k054338_word_r );        // CLTC
736
737READ32_DEVICE_HANDLER( k056832_long_r );        // VACSET
738READ32_DEVICE_HANDLER( k053247_reg_long_r );    // OBJSET2
739READ32_DEVICE_HANDLER( k055555_long_r );        // PCU2
740
741READ16_DEVICE_HANDLER( k053244_reg_word_r );    // OBJSET0
src/mame/video/neogeo.c
r6740r6741
55****************************************************************************/
66
77#include "driver.h"
8#include "neogeo.h"
8#include "includes/neogeo.h"
99#include "video/resnet.h"
1010
11
1211#define NUM_PENS   (0x1000)
1312
1413#define VERBOSE    (0)
1514
16static UINT8 *sprite_gfx;
17static UINT32 sprite_gfx_address_mask;
18static UINT16 *neogeo_videoram;
19static UINT16 *palettes[2]; /* 0x100*16 2 byte palette entries */
20static pen_t *pens;
21static UINT8 palette_bank;
22static UINT8 screen_dark;
23static UINT16 videoram_read_buffer;
24static UINT16 videoram_modulo;
25static UINT16 videoram_offset;
26
27static UINT8 fixed_layer_source;
28int neogeo_fixed_layer_bank_type;      /* no need to state save */
29
30static UINT8 auto_animation_speed;
31static UINT8 auto_animation_disabled;
32static UINT8 auto_animation_counter;
33static UINT8 auto_animation_frame_counter;
34static emu_timer *auto_animation_timer;
35
36static emu_timer *sprite_line_timer;
37
38static const UINT8 *region_zoomy;
39
40
4115/*************************************
4216 *
4317 *  Video RAM access
4418 *
4519 *************************************/
4620
47static void set_videoram_offset(UINT16 data)
21static void set_videoram_offset( running_machine *machine, UINT16 data )
4822{
49   videoram_offset = data;
23   neogeo_state *state = (neogeo_state *)machine->driver_data;
24   state->videoram_offset = data;
5025
5126   /* the read happens right away */
52   videoram_read_buffer = neogeo_videoram[videoram_offset];
27   state->videoram_read_buffer = state->videoram[state->videoram_offset];
5328}
5429
5530
56static UINT16 get_videoram_data(void)
31static UINT16 get_videoram_data( running_machine *machine )
5732{
58   return videoram_read_buffer;
33   neogeo_state *state = (neogeo_state *)machine->driver_data;
34   return state->videoram_read_buffer;
5935}
6036
6137
62static void set_videoram_data(UINT16 data)
38static void set_videoram_data( running_machine *machine, UINT16 data)
6339{
64   neogeo_videoram[videoram_offset] = data;
40   neogeo_state *state = (neogeo_state *)machine->driver_data;
41   state->videoram[state->videoram_offset] = data;
6542
6643   /* auto increment/decrement the current offset - A15 is NOT effected */
67   videoram_offset = (videoram_offset & 0x8000) | ((videoram_offset + videoram_modulo) & 0x7fff);
44   state->videoram_offset = (state->videoram_offset & 0x8000) | ((state->videoram_offset + state->videoram_modulo) & 0x7fff);
6845
6946   /* read next value right away */
70   videoram_read_buffer = neogeo_videoram[videoram_offset];
47   state->videoram_read_buffer = state->videoram[state->videoram_offset];
7148}
7249
7350
74static void set_videoram_modulo(UINT16 data)
51static void set_videoram_modulo( running_machine *machine, UINT16 data)
7552{
76   videoram_modulo = data;
53   neogeo_state *state = (neogeo_state *)machine->driver_data;
54   state->videoram_modulo = data;
7755}
7856
7957
80static UINT16 get_videoram_modulo(void)
58static UINT16 get_videoram_modulo( running_machine *machine )
8159{
82   return videoram_modulo;
60   neogeo_state *state = (neogeo_state *)machine->driver_data;
61   return state->videoram_modulo;
8362}
8463
8564
r6740r6741
9069 *
9170 *************************************/
9271
93static double rgb_weights_normal[5];
94static double rgb_weights_normal_bit15[5];
95static double rgb_weights_dark[5];
96static double rgb_weights_dark_bit15[5];
97
98static void compute_rgb_weights(void)
72static void compute_rgb_weights( running_machine *machine )
9973{
74   neogeo_state *state = (neogeo_state *)machine->driver_data;
10075   static const int resistances[] = { 220, 470, 1000, 2200, 3900 };
10176
10277   /* compute four sets of weights - with or without the pulldowns -
10378       ensuring that we use the same scaler for all */
10479
10580   double scaler = compute_resistor_weights(0, 0xff, -1,
106                      5, resistances, rgb_weights_normal, 0, 0,
81                      5, resistances, state->rgb_weights_normal, 0, 0,
10782                      0, 0, 0, 0, 0,
10883                      0, 0, 0, 0, 0);
10984
11085   compute_resistor_weights(0, 0xff, scaler,
111                      5, resistances, rgb_weights_normal_bit15, 8200, 0,
86                      5, resistances, state->rgb_weights_normal_bit15, 8200, 0,
11287                      0, 0, 0, 0, 0,
11388                      0, 0, 0, 0, 0);
11489
11590   compute_resistor_weights(0, 0xff, scaler,
116                      5, resistances, rgb_weights_dark, 150, 0,
91                      5, resistances, state->rgb_weights_dark, 150, 0,
11792                      0, 0, 0, 0, 0,
11893                      0, 0, 0, 0, 0);
11994
12095   compute_resistor_weights(0, 0xff, scaler,
121                      5, resistances, rgb_weights_dark_bit15, 1 / ((1.0 / 8200) + (1.0 / 150)), 0,
96                      5, resistances, state->rgb_weights_dark_bit15, 1 / ((1.0 / 8200) + (1.0 / 150)), 0,
12297                      0, 0, 0, 0, 0,
12398                      0, 0, 0, 0, 0);
12499}
125100
126101
127static pen_t get_pen(UINT16 data)
102static pen_t get_pen( running_machine *machine, UINT16 data )
128103{
104   neogeo_state *state = (neogeo_state *)machine->driver_data;
129105   double *weights;
130106   UINT8 r, g, b;
131107
132   if (screen_dark)
108   if (state->screen_dark)
133109   {
134110      if (data & 0x8000)
135         weights = rgb_weights_dark_bit15;
111         weights = state->rgb_weights_dark_bit15;
136112      else
137         weights = rgb_weights_dark;
113         weights = state->rgb_weights_dark;
138114   }
139115   else
140116   {
141117      if (data & 0x8000)
142         weights = rgb_weights_normal_bit15;
118         weights = state->rgb_weights_normal_bit15;
143119      else
144         weights = rgb_weights_normal;
120         weights = state->rgb_weights_normal;
145121   }
146122
147123   r = combine_5_weights(weights,
r6740r6741
171147
172148static STATE_POSTLOAD( regenerate_pens )
173149{
150   neogeo_state *state = (neogeo_state *)machine->driver_data;
174151   int i;
175152
176153   for (i = 0; i < NUM_PENS; i++)
177      pens[i] = get_pen(palettes[palette_bank][i]);
154      state->pens[i] = get_pen(machine, state->palettes[state->palette_bank][i]);
178155}
179156
180157
181void neogeo_set_palette_bank(running_machine *machine, UINT8 data)
158void neogeo_set_palette_bank( running_machine *machine, UINT8 data )
182159{
183   if (data != palette_bank)
160   neogeo_state *state = (neogeo_state *)machine->driver_data;
161   if (data != state->palette_bank)
184162   {
185      palette_bank = data;
163      state->palette_bank = data;
186164
187165      regenerate_pens(machine, NULL);
188166   }
189167}
190168
191169
192void neogeo_set_screen_dark(running_machine *machine, UINT8 data)
170void neogeo_set_screen_dark( running_machine *machine, UINT8 data )
193171{
194   if (data != screen_dark)
172   neogeo_state *state = (neogeo_state *)machine->driver_data;
173   if (data != state->screen_dark)
195174   {
196      screen_dark = data;
175      state->screen_dark = data;
197176
198177      regenerate_pens(machine, NULL);
199178   }
r6740r6741
202181
203182READ16_HANDLER( neogeo_paletteram_r )
204183{
205   return palettes[palette_bank][offset];
184   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
185   return state->palettes[state->palette_bank][offset];
206186}
207187
208188
209189WRITE16_HANDLER( neogeo_paletteram_w )
210190{
211   UINT16 *addr = &palettes[palette_bank][offset];
191   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
192   UINT16 *addr = &state->palettes[state->palette_bank][offset];
212193
213194   COMBINE_DATA(addr);
214195
215   pens[offset] = get_pen(*addr);
196   state->pens[offset] = get_pen(space->machine, *addr);
216197}
217198
218199
r6740r6741
223204 *
224205 *************************************/
225206
226static void set_auto_animation_speed(UINT8 data)
207static void set_auto_animation_speed( running_machine *machine, UINT8 data)
227208{
228   auto_animation_speed = data;
209   neogeo_state *state = (neogeo_state *)machine->driver_data;
210   state->auto_animation_speed = data;
229211}
230212
231213
232static void set_auto_animation_disabled(UINT8 data)
214static void set_auto_animation_disabled( running_machine *machine, UINT8 data)
233215{
234   auto_animation_disabled = data;
216   neogeo_state *state = (neogeo_state *)machine->driver_data;
217   state->auto_animation_disabled = data;
235218}
236219
237220
238UINT8 neogeo_get_auto_animation_counter(void)
221UINT8 neogeo_get_auto_animation_counter( running_machine *machine )
239222{
240   return auto_animation_counter;
223   neogeo_state *state = (neogeo_state *)machine->driver_data;
224   return state->auto_animation_counter;
241225}
242226
243227
244228static TIMER_CALLBACK( auto_animation_timer_callback )
245229{
246   if (auto_animation_frame_counter == 0)
230   neogeo_state *state = (neogeo_state *)machine->driver_data;
231   if (state->auto_animation_frame_counter == 0)
247232   {
248      auto_animation_frame_counter = auto_animation_speed;
249      auto_animation_counter = auto_animation_counter + 1;
233      state->auto_animation_frame_counter = state->auto_animation_speed;
234      state->auto_animation_counter += 1;
250235   }
251236   else
252      auto_animation_frame_counter = auto_animation_frame_counter - 1;
237      state->auto_animation_frame_counter = state->auto_animation_frame_counter - 1;
253238
254   timer_adjust_oneshot(auto_animation_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VSSTART, 0), 0);
239   timer_adjust_oneshot(state->auto_animation_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VSSTART, 0), 0);
255240}
256241
257242
258static void create_auto_animation_timer(running_machine *machine)
243static void create_auto_animation_timer( running_machine *machine )
259244{
260   auto_animation_timer = timer_alloc(machine, auto_animation_timer_callback, NULL);
245   neogeo_state *state = (neogeo_state *)machine->driver_data;
246   state->auto_animation_timer = timer_alloc(machine, auto_animation_timer_callback, NULL);
261247}
262248
263249
264static void start_auto_animation_timer(running_machine *machine)
250static void start_auto_animation_timer( running_machine *machine )
265251{
266   timer_adjust_oneshot(auto_animation_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VSSTART, 0), 0);
252   neogeo_state *state = (neogeo_state *)machine->driver_data;
253   timer_adjust_oneshot(state->auto_animation_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VSSTART, 0), 0);
267254}
268255
269256
r6740r6741
274261 *
275262 *************************************/
276263
277void neogeo_set_fixed_layer_source(UINT8 data)
264void neogeo_set_fixed_layer_source( running_machine *machine, UINT8 data )
278265{
279   fixed_layer_source = data;
266   neogeo_state *state = (neogeo_state *)machine->driver_data;
267   state->fixed_layer_source = data;
280268}
281269
282270
283static void draw_fixed_layer(running_machine *machine, bitmap_t *bitmap, int scanline)
271static void draw_fixed_layer( running_machine *machine, bitmap_t *bitmap, int scanline )
284272{
273   neogeo_state *state = (neogeo_state *)machine->driver_data;
285274   int x;
286275
287   UINT8* gfx_base = memory_region(machine, fixed_layer_source ? "fixed" : "fixedbios");
288   UINT32 addr_mask = memory_region_length(machine, fixed_layer_source ? "fixed" : "fixedbios") - 1;
289   UINT16 *video_data = &neogeo_videoram[0x7000 | (scanline >> 3)];
276   UINT8* gfx_base = memory_region(machine, state->fixed_layer_source ? "fixed" : "fixedbios");
277   UINT32 addr_mask = memory_region_length(machine, state->fixed_layer_source ? "fixed" : "fixedbios") - 1;
278   UINT16 *video_data = &state->videoram[0x7000 | (scanline >> 3)];
290279   UINT32 *pixel_addr = BITMAP_ADDR32(bitmap, scanline, NEOGEO_HBEND);
291280
292int garouoffsets[32];
293int banked = fixed_layer_source && (addr_mask > 0x1ffff);
294{
295/* thanks to Mr K for the garou & kof2000 banking info */
296/* Build line banking table for Garou & MS3 before starting render */
297if (banked && neogeo_fixed_layer_bank_type == 1)
298{
299   int garoubank = 0;
300   int k = 0;
301   int y = 0;
302   while (y < 32)
281   int garouoffsets[32];
282   int banked = state->fixed_layer_source && (addr_mask > 0x1ffff);
283
284   /* thanks to Mr K for the garou & kof2000 banking info */
285   /* Build line banking table for Garou & MS3 before starting render */
286   if (banked && state->fixed_layer_bank_type == 1)
303287   {
304      if (neogeo_videoram[0x7500+k] == 0x0200 && (neogeo_videoram[0x7580+k] & 0xff00) == 0xff00)
288      int garoubank = 0;
289      int k = 0;
290      int y = 0;
291      while (y < 32)
305292      {
306         garoubank = neogeo_videoram[0x7580+k] & 3;
293         if (state->videoram[0x7500 + k] == 0x0200 && (state->videoram[0x7580 + k] & 0xff00) == 0xff00)
294         {
295            garoubank = state->videoram[0x7580 + k] & 3;
296            garouoffsets[y++] = garoubank;
297         }
307298         garouoffsets[y++] = garoubank;
299         k += 2;
308300      }
309      garouoffsets[y++] = garoubank;
310      k += 2;
311301   }
312}
313}
314302
315303   for (x = 0; x < 40; x++)
316304   {
317305      UINT16 code_and_palette = *video_data;
318
319306      UINT16 code = code_and_palette & 0x0fff;
320307
321if (banked)
322{
323   int y = scanline >> 3;
324   switch (neogeo_fixed_layer_bank_type)
325   {
326   case 1:
327      /* Garou, MSlug 3 */
328      code += 0x1000 * (garouoffsets[(y-2)&31] ^ 3);
329      break;
330   case 2:
331      code += 0x1000 * (((neogeo_videoram[0x7500 + ((y-1)&31) + 32 * (x/6)] >> (5-(x%6))*2) & 3) ^ 3);
332      break;
333   }
334}
308      if (banked)
309      {
310         int y = scanline >> 3;
311         switch (state->fixed_layer_bank_type)
312         {
313         case 1:
314            /* Garou, MSlug 3 */
315            code += 0x1000 * (garouoffsets[(y - 2) & 31] ^ 3);
316            break;
317         case 2:
318            code += 0x1000 * (((state->videoram[0x7500 + ((y - 1) & 31) + 32 * (x / 6)] >> (5 - (x % 6)) * 2) & 3) ^ 3);
319            break;
320         }
321      }
335322
336323      {
337324         UINT8 data;
338325         int i;
339326
340327         UINT8 *gfx = &gfx_base[((code << 5) | (scanline & 0x07)) & addr_mask];
341         pen_t *char_pens = &pens[code_and_palette >> 12 << 4];
328         pen_t *char_pens = &state->pens[code_and_palette >> 12 << 4];
342329
343330         for (i = 0; i < 4; i++)
344331         {
r6740r6741
368355 *
369356 *************************************/
370357
371#define MAX_SPRITES_PER_SCREEN   (381)
372#define MAX_SPRITES_PER_LINE   (96)
358#define MAX_SPRITES_PER_SCREEN    (381)
359#define MAX_SPRITES_PER_LINE      (96)
373360
374361
375362/* horizontal zoom table - verified on real hardware */
r6740r6741
414401}
415402
416403
417static void draw_sprites(bitmap_t *bitmap, int scanline)
404static void draw_sprites( running_machine *machine, bitmap_t *bitmap, int scanline )
418405{
406   neogeo_state *state = (neogeo_state *)machine->driver_data;
419407   int sprite_index;
420408   int max_sprite_index;
421409
r6740r6741
428416
429417   /* select the active list */
430418   if (scanline & 0x01)
431      sprite_list = &neogeo_videoram[0x8680];
419      sprite_list = &state->videoram[0x8680];
432420   else
433      sprite_list = &neogeo_videoram[0x8600];
421      sprite_list = &state->videoram[0x8600];
434422
435423   /* optimization -- find last non-zero entry and only draw that many +1
436424       sprite.  This is not 100% correct as the hardware will keep drawing
437425       the #0 sprite over and over, but we need the speed */
438    for (max_sprite_index = (MAX_SPRITES_PER_LINE - 1); max_sprite_index >= 0; max_sprite_index--)
439    {
426   for (max_sprite_index = (MAX_SPRITES_PER_LINE - 1); max_sprite_index >= 0; max_sprite_index--)
427   {
440428      if (sprite_list[max_sprite_index] != 0)
441429         break;
442430   }
r6740r6741
448436   for (sprite_index = 0; sprite_index <= max_sprite_index; sprite_index++)
449437   {
450438      UINT16 sprite_number = sprite_list[sprite_index] & 0x01ff;
439      UINT16 y_control = state->videoram[0x8200 | sprite_number];
440      UINT16 zoom_control = state->videoram[0x8000 | sprite_number];
451441
452      UINT16 y_control = neogeo_videoram[0x8200 | sprite_number];
453      UINT16 zoom_control = neogeo_videoram[0x8000 | sprite_number];
454
455442      /* if chained, go to next X coordinate and get new X zoom */
456443      if (y_control & 0x40)
457444      {
r6740r6741
462449      else
463450      {
464451         y = 0x200 - (y_control >> 7);
465         x = neogeo_videoram[0x8400 | sprite_number] >> 7;
452         x = state->videoram[0x8400 | sprite_number] >> 7;
466453         zoom_y = zoom_control & 0xff;
467454         zoom_x = (zoom_control >> 8) & 0x0f;
468455         rows = y_control & 0x3f;
r6740r6741
505492            }
506493         }
507494
508         sprite_y_and_tile = region_zoomy[(zoom_y << 8) | zoom_line];
495         sprite_y_and_tile = state->region_zoomy[(zoom_y << 8) | zoom_line];
509496         sprite_y = sprite_y_and_tile & 0x0f;
510497         tile = sprite_y_and_tile >> 4;
511498
r6740r6741
516503         }
517504
518505         attr_and_code_offs = (sprite_number << 6) | (tile << 1);
519         attr = neogeo_videoram[attr_and_code_offs + 1];
520         code = ((attr << 12) & 0x70000) | neogeo_videoram[attr_and_code_offs];
506         attr = state->videoram[attr_and_code_offs + 1];
507         code = ((attr << 12) & 0x70000) | state->videoram[attr_and_code_offs];
521508
522509         /* substitute auto animation bits */
523         if (!auto_animation_disabled)
510         if (!state->auto_animation_disabled)
524511         {
525512            if (attr & 0x0008)
526               code = (code & ~0x07) | (auto_animation_counter & 0x07);
513               code = (code & ~0x07) | (state->auto_animation_counter & 0x07);
527514            else if (attr & 0x0004)
528               code = (code & ~0x03) | (auto_animation_counter & 0x03);
515               code = (code & ~0x03) | (state->auto_animation_counter & 0x03);
529516         }
530517
531518         /* vertical flip? */
r6740r6741
535522         zoom_x_table = zoom_x_tables[zoom_x];
536523
537524         /* compute offset in gfx ROM and mask it to the number of bits available */
538         gfx = &sprite_gfx[((code << 8) | (sprite_y << 4)) & sprite_gfx_address_mask];
525         gfx = &state->sprite_gfx[((code << 8) | (sprite_y << 4)) & state->sprite_gfx_address_mask];
539526
540         line_pens = &pens[attr >> 8 << 4];
527         line_pens = &state->pens[attr >> 8 << 4];
541528
542529         /* horizontal flip? */
543530         if (attr & 0x0001)
r6740r6741
603590}
604591
605592
606static void parse_sprites(int scanline)
593static void parse_sprites( running_machine *machine, int scanline )
607594{
595   neogeo_state *state = (neogeo_state *)machine->driver_data;
608596   UINT16 sprite_number;
609597   int y = 0;
610598   int rows = 0;
r6740r6741
614602
615603   /* select the active list */
616604   if (scanline & 0x01)
617      sprite_list = &neogeo_videoram[0x8680];
605      sprite_list = &state->videoram[0x8680];
618606   else
619      sprite_list = &neogeo_videoram[0x8600];
607      sprite_list = &state->videoram[0x8600];
620608
621609   /* scan all sprites */
622610   for (sprite_number = 0; sprite_number < MAX_SPRITES_PER_SCREEN; sprite_number++)
623611   {
624      UINT16 y_control = neogeo_videoram[0x8200 | sprite_number];
612      UINT16 y_control = state->videoram[0x8200 | sprite_number];
625613
626614      /* if not chained, get Y position and height, otherwise use previous values */
627615      if (~y_control & 0x40)
r6740r6741
650638   }
651639
652640   /* fill the rest of the sprite list with 0, including one extra entry */
653   memset(sprite_list, 0,
654          sizeof(sprite_list[0]) * (MAX_SPRITES_PER_LINE - active_sprite_count + 1));
641   memset(sprite_list, 0, sizeof(sprite_list[0]) * (MAX_SPRITES_PER_LINE - active_sprite_count + 1));
655642}
656643
657644
658645static TIMER_CALLBACK( sprite_line_timer_callback )
659646{
647   neogeo_state *state = (neogeo_state *)machine->driver_data;
660648   int scanline = param;
661649
662650   /* we are at the beginning of a scanline -
663651       we need to draw the previous scanline and parse the sprites on the current one */
664    if (scanline != 0)
665       video_screen_update_partial(machine->primary_screen, scanline - 1);
652   if (scanline != 0)
653      video_screen_update_partial(machine->primary_screen, scanline - 1);
666654
667   parse_sprites(scanline);
655   parse_sprites(machine, scanline);
668656
669657   /* let's come back at the beginning of the next line */
670658   scanline = (scanline + 1) % NEOGEO_VTOTAL;
671659
672   timer_adjust_oneshot(sprite_line_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline);
660   timer_adjust_oneshot(state->sprite_line_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline);
673661}
674662
675663
676static void create_sprite_line_timer(running_machine *machine)
664static void create_sprite_line_timer( running_machine *machine )
677665{
678   sprite_line_timer = timer_alloc(machine, sprite_line_timer_callback, NULL);
666   neogeo_state *state = (neogeo_state *)machine->driver_data;
667   state->sprite_line_timer = timer_alloc(machine, sprite_line_timer_callback, NULL);
679668}
680669
681670
682static void start_sprite_line_timer(running_machine *machine)
671static void start_sprite_line_timer( running_machine *machine )
683672{
684   timer_adjust_oneshot(sprite_line_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
673   neogeo_state *state = (neogeo_state *)machine->driver_data;
674   timer_adjust_oneshot(state->sprite_line_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
685675}
686676
687677
688static void optimize_sprite_data(running_machine *machine)
678static void optimize_sprite_data( running_machine *machine )
689679{
680   neogeo_state *state = (neogeo_state *)machine->driver_data;
681
690682   /* convert the sprite graphics data into a format that
691683       allows faster blitting */
692684   int i;
r6740r6741
697689
698690   /* get mask based on the length rounded up to the nearest
699691       power of 2 */
700   sprite_gfx_address_mask = 0xffffffff;
692   state->sprite_gfx_address_mask = 0xffffffff;
701693
702694   len = memory_region_length(machine, "sprites");
695
703696   for (bit = 0x80000000; bit != 0; bit >>= 1)
704697   {
705698      if (((len * 2) - 1) & bit)
706699         break;
707700
708      sprite_gfx_address_mask >>= 1;
701      state->sprite_gfx_address_mask >>= 1;
709702   }
710703
711   sprite_gfx = auto_alloc_array_clear(machine, UINT8, sprite_gfx_address_mask + 1);
704   state->sprite_gfx = auto_alloc_array_clear(machine, UINT8, state->sprite_gfx_address_mask + 1);
712705
713706   src = memory_region(machine, "sprites");
714   dest = sprite_gfx;
707   dest = state->sprite_gfx;
715708
716709   for (i = 0; i < len; i += 0x80, src += 0x80)
717710   {
r6740r6741
748741 *
749742 *************************************/
750743
751static UINT16 get_video_control(running_machine *machine)
744static UINT16 get_video_control( running_machine *machine )
752745{
753746   UINT16 ret;
754747   UINT16 v_counter;
r6740r6741
780773   if (v_counter >= 0x200)
781774      v_counter = v_counter - NEOGEO_VTOTAL;
782775
783   ret = (v_counter << 7) | (neogeo_get_auto_animation_counter() & 0x0007);
776   ret = (v_counter << 7) | (neogeo_get_auto_animation_counter(machine) & 0x0007);
784777
785778   if (VERBOSE) logerror("%s: video_control read (%04x)\n", cpuexec_describe_context(machine), ret);
786779
r6740r6741
788781}
789782
790783
791static void set_video_control(running_machine *machine, UINT16 data)
784static void set_video_control( running_machine *machine, UINT16 data )
792785{
793786   /* this does much more than this, but I'm not sure exactly what */
794787   if (VERBOSE) logerror("%s: video control write %04x\n", cpuexec_describe_context(machine), data);
795788
796   set_auto_animation_speed(data >> 8);
797   set_auto_animation_disabled(data & 0x0008);
789   set_auto_animation_speed(machine, data >> 8);
790   set_auto_animation_disabled(machine, data & 0x0008);
798791
799   neogeo_set_display_position_interrupt_control(data & 0x00f0);
792   neogeo_set_display_position_interrupt_control(machine, data & 0x00f0);
800793}
801794
802795
r6740r6741
813806      {
814807      default:
815808      case 0x00:
816      case 0x01: ret = get_videoram_data(); break;
817      case 0x02: ret = get_videoram_modulo(); break;
809      case 0x01: ret = get_videoram_data(space->machine); break;
810      case 0x02: ret = get_videoram_modulo(space->machine); break;
818811      case 0x03: ret = get_video_control(space->machine); break;
819812      }
820813   }
r6740r6741
834827
835828      switch (offset)
836829      {
837      case 0x00: set_videoram_offset(data); break;
838      case 0x01: set_videoram_data(data); break;
839      case 0x02: set_videoram_modulo(data); break;
830      case 0x00: set_videoram_offset(space->machine, data); break;
831      case 0x01: set_videoram_data(space->machine, data); break;
832      case 0x02: set_videoram_modulo(space->machine, data); break;
840833      case 0x03: set_video_control(space->machine, data); break;
841834      case 0x04: neogeo_set_display_counter_msb(space, data); break;
842835      case 0x05: neogeo_set_display_counter_lsb(space, data); break;
r6740r6741
856849
857850VIDEO_START( neogeo )
858851{
852   neogeo_state *state = (neogeo_state *)machine->driver_data;
853
859854   /* allocate memory not directly mapped */
860   palettes[0] = auto_alloc_array(machine, UINT16, NUM_PENS);
861   palettes[1] = auto_alloc_array(machine, UINT16, NUM_PENS);
862   pens = auto_alloc_array(machine, pen_t, NUM_PENS);
863   neogeo_videoram = auto_alloc_array(machine, UINT16, 0x20000/2);
855   state->palettes[0] = auto_alloc_array(machine, UINT16, NUM_PENS);
856   state->palettes[1] = auto_alloc_array(machine, UINT16, NUM_PENS);
857   state->pens = auto_alloc_array(machine, pen_t, NUM_PENS);
858   state->videoram = auto_alloc_array(machine, UINT16, 0x20000/2);
864859
865860   /* clear allocated memory */
866   memset(palettes[0],0x00, NUM_PENS * sizeof(UINT16));
867   memset(palettes[1],0x00, NUM_PENS * sizeof(UINT16));
868   memset(pens,0x00, NUM_PENS * sizeof(pen_t));
869   memset(neogeo_videoram,0x00, 0x20000);
861   memset(state->palettes[0], 0x00, NUM_PENS * sizeof(UINT16));
862   memset(state->palettes[1], 0x00, NUM_PENS * sizeof(UINT16));
863   memset(state->pens, 0x00, NUM_PENS * sizeof(pen_t));
864   memset(state->videoram, 0x00, 0x20000);
870865
871   compute_rgb_weights();
866   compute_rgb_weights(machine);
872867   create_sprite_line_timer(machine);
873868   create_auto_animation_timer(machine);
874869   optimize_sprite_data(machine);
875870
876871   /* initialize values that are not modified on a reset */
877   videoram_read_buffer = 0;
878   videoram_offset = 0;
879   videoram_modulo = 0;
880   auto_animation_speed = 0;
881   auto_animation_disabled = 0;
882   auto_animation_counter = 0;
883   auto_animation_frame_counter = 0;
872   state->videoram_read_buffer = 0;
873   state->videoram_offset = 0;
874   state->videoram_modulo = 0;
875   state->auto_animation_speed = 0;
876   state->auto_animation_disabled = 0;
877   state->auto_animation_counter = 0;
878   state->auto_animation_frame_counter = 0;
884879
885880   /* register for state saving */
886   state_save_register_global_pointer(machine, palettes[0], NUM_PENS);
887   state_save_register_global_pointer(machine, palettes[1], NUM_PENS);
888   state_save_register_global_pointer(machine, neogeo_videoram, 0x20000/2);
889   state_save_register_global(machine, videoram_read_buffer);
890   state_save_register_global(machine, videoram_modulo);
891   state_save_register_global(machine, videoram_offset);
892   state_save_register_global(machine, fixed_layer_source);
893   state_save_register_global(machine, screen_dark);
894   state_save_register_global(machine, palette_bank);
895   state_save_register_global(machine, auto_animation_speed);
896   state_save_register_global(machine, auto_animation_disabled);
897   state_save_register_global(machine, auto_animation_counter);
898   state_save_register_global(machine, auto_animation_frame_counter);
881   state_save_register_global_pointer(machine, state->palettes[0], NUM_PENS);
882   state_save_register_global_pointer(machine, state->palettes[1], NUM_PENS);
883   state_save_register_global_pointer(machine, state->videoram, 0x20000/2);
884   state_save_register_global(machine, state->videoram_read_buffer);
885   state_save_register_global(machine, state->videoram_modulo);
886   state_save_register_global(machine, state->videoram_offset);
887   state_save_register_global(machine, state->fixed_layer_source);
888   state_save_register_global(machine, state->screen_dark);
889   state_save_register_global(machine, state->palette_bank);
890   state_save_register_global(machine, state->auto_animation_speed);
891   state_save_register_global(machine, state->auto_animation_disabled);
892   state_save_register_global(machine, state->auto_animation_counter);
893   state_save_register_global(machine, state->auto_animation_frame_counter);
899894
900895   state_save_register_postload(machine, regenerate_pens, NULL);
901896
902   region_zoomy = memory_region(machine, "zoomy");
897   state->region_zoomy = memory_region(machine, "zoomy");
903898}
904899
905900
r6740r6741
926921
927922VIDEO_UPDATE( neogeo )
928923{
924   neogeo_state *state = (neogeo_state *)screen->machine->driver_data;
925
929926   /* fill with background color first */
930   bitmap_fill(bitmap, cliprect, pens[0x0fff]);
927   bitmap_fill(bitmap, cliprect, state->pens[0x0fff]);
931928
932   draw_sprites(bitmap, cliprect->min_y);
929   draw_sprites(screen->machine, bitmap, cliprect->min_y);
933930
934931   draw_fixed_layer(screen->machine, bitmap, cliprect->min_y);
935932
src/mame/video/snookr10.c
r6740r6741
4040#include "driver.h"
4141#include "video/resnet.h"
4242
43UINT8 *snookr10_videoram;
44UINT8 *snookr10_colorram;
4345static tilemap *bg_tilemap;
4446
4547
4648WRITE8_HANDLER( snookr10_videoram_w )
4749{
48   space->machine->generic.videoram.u8[offset] = data;
50   snookr10_videoram[offset] = data;
4951   tilemap_mark_tile_dirty(bg_tilemap, offset);
5052}
5153
5254WRITE8_HANDLER( snookr10_colorram_w )
5355{
54   space->machine->generic.colorram.u8[offset] = data;
56   snookr10_colorram[offset] = data;
5557   tilemap_mark_tile_dirty(bg_tilemap, offset);
5658}
5759
r6740r6741
102104    ---- xxxx   seems unused.
103105*/
104106   int offs = tile_index;
105   int attr = machine->generic.videoram.u8[offs] + (machine->generic.colorram.u8[offs] << 8);
107   int attr = snookr10_videoram[offs] + (snookr10_colorram[offs] << 8);
106108   int code = attr & 0xfff;
107   int color = machine->generic.colorram.u8[offs] >> 4;
109   int color = snookr10_colorram[offs] >> 4;
108110
109111   SET_TILE_INFO(0, code, color, 0);
110112}
r6740r6741
164166    ---- xxxx   seems unused.
165167*/
166168   int offs = tile_index;
167   int attr = machine->generic.videoram.u8[offs] + (machine->generic.colorram.u8[offs] << 8);
169   int attr = snookr10_videoram[offs] + (snookr10_colorram[offs] << 8);
168170   int code = BITSWAP16((attr & 0xfff),15,14,13,12,8,9,10,11,0,1,2,3,4,5,6,7);   /* encrypted tile matrix */
169   int color = machine->generic.colorram.u8[offs] >> 4;
171   int color = snookr10_colorram[offs] >> 4;
170172
171173   SET_TILE_INFO(0, code, color, 0);
172174}
src/mame/video/konamigx.c
r6740r6741
55
66#include "driver.h"
77#include "video/konamiic.h"
8#include "konamigx.h"
8#include "includes/konamigx.h"
99
1010
1111#define GX_DEBUG 0
src/mame/video/ultraman.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
4#define SPRITEROM_MEM_REGION "gfx1"
5#define ZOOMROM0_MEM_REGION "gfx2"
6#define ZOOMROM1_MEM_REGION "gfx3"
7#define ZOOMROM2_MEM_REGION "gfx4"
8
94static int sprite_colorbase, zoom_colorbase[3];
105static int bank0,bank1,bank2;
116
r6740r6741
1611
1712***************************************************************************/
1813
19static void sprite_callback(int *code,int *color,int *priority,int *shadow)
14void ultraman_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow)
2015{
2116   *priority = (*color & 0x80) >> 7;
2217   *color = sprite_colorbase + ((*color & 0x7e) >> 1);
r6740r6741
3025
3126***************************************************************************/
3227
33static void zoom_callback_0(int *code,int *color,int *flags)
28void ultraman_zoom_callback_0(running_machine *machine, int *code,int *color,int *flags)
3429{
3530   *code |= ((*color & 0x07) << 8) | (bank0 << 11);
3631   *color = zoom_colorbase[0] + ((*color & 0xf8) >> 3);
3732}
3833
39static void zoom_callback_1(int *code,int *color,int *flags)
34void ultraman_zoom_callback_1(running_machine *machine, int *code,int *color,int *flags)
4035{
4136   *code |= ((*color & 0x07) << 8) | (bank1 << 11);
4237   *color = zoom_colorbase[1] + ((*color & 0xf8) >> 3);
4338}
4439
45static void zoom_callback_2(int *code,int *color,int *flags)
40void ultraman_zoom_callback_2(running_machine *machine, int *code,int *color,int *flags)
4641{
4742   *code |= ((*color & 0x07) << 8) | (bank2 << 11);
4843   *color = zoom_colorbase[2] + ((*color & 0xf8) >> 3);
r6740r6741
6257   zoom_colorbase[0] = 0;
6358   zoom_colorbase[1] = 64;
6459   zoom_colorbase[2] = 128;
65
66   K051960_vh_start(machine,SPRITEROM_MEM_REGION,NORMAL_PLANE_ORDER,sprite_callback);
67   K051316_vh_start_0(machine,ZOOMROM0_MEM_REGION,4,FALSE,0,zoom_callback_0);
68   K051316_vh_start_1(machine,ZOOMROM1_MEM_REGION,4,FALSE,0,zoom_callback_1);
69   K051316_vh_start_2(machine,ZOOMROM2_MEM_REGION,4,TRUE,0,zoom_callback_2);
70
71   K051316_set_offset(0, 8, 0);
72   K051316_set_offset(1, 8, 0);
73   K051316_set_offset(2, 8, 0);
7460}
7561
7662
r6740r6741
8369
8470WRITE16_HANDLER( ultraman_gfxctrl_w )
8571{
72   const device_config *k051316_1 = devtag_get_device(space->machine, "k051316_1");
73   const device_config *k051316_2 = devtag_get_device(space->machine, "k051316_2");
74   const device_config *k051316_3 = devtag_get_device(space->machine, "k051316_3");
75
8676   if (ACCESSING_BITS_0_7)
8777   {
8878      /*  bit 0: enable wraparound for scr #1
r6740r6741
9383            bit 5: msb of code for scr #3
9484            bit 6: coin counter 1
9585            bit 7: coin counter 2 */
96      K051316_wraparound_enable(0,data & 0x01);
86
87      k051316_wraparound_enable(k051316_1, data & 0x01);
88
9789      if (bank0 != ((data & 0x02) >> 1))
9890      {
9991         bank0 = (data & 0x02) >> 1;
10092         tilemap_mark_all_tiles_dirty_all(space->machine);   /* should mark only zoom0 */
10193      }
102      K051316_wraparound_enable(1,data & 0x04);
94
95      k051316_wraparound_enable(k051316_2, data & 0x04);
96
10397      if (bank1 != ((data & 0x08) >> 3))
10498      {
10599         bank1 = (data & 0x08) >> 3;
106100         tilemap_mark_all_tiles_dirty_all(space->machine);   /* should mark only zoom1 */
107101      }
108      K051316_wraparound_enable(2,data & 0x10);
102
103      k051316_wraparound_enable(k051316_3, data & 0x10);
104
109105      if (bank2 != ((data & 0x20) >> 5))
110106      {
111107         bank2 = (data & 0x20) >> 5;
112108         tilemap_mark_all_tiles_dirty_all(space->machine);   /* should mark only zoom2 */
113109      }
110
114111      coin_counter_w(space->machine, 0, data & 0x40);
115112      coin_counter_w(space->machine, 1, data & 0x80);
116113   }
r6740r6741
126123
127124VIDEO_UPDATE( ultraman )
128125{
129   K051316_zoom_draw_2(bitmap,cliprect,0,0);
130   K051316_zoom_draw_1(bitmap,cliprect,0,0);
131   K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
132   K051316_zoom_draw_0(bitmap,cliprect,0,0);
133   K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
126   const device_config *k051316_1 = devtag_get_device(screen->machine, "k051316_1");
127   const device_config *k051316_2 = devtag_get_device(screen->machine, "k051316_2");
128   const device_config *k051316_3 = devtag_get_device(screen->machine, "k051316_3");
129   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
130
131   k051316_zoom_draw(k051316_3, bitmap, cliprect, 0, 0);
132   k051316_zoom_draw(k051316_2, bitmap, cliprect, 0, 0);
133   k051960_sprites_draw(k051960, bitmap, cliprect, 0, 0);
134   k051316_zoom_draw(k051316_1, bitmap, cliprect, 0, 0);
135   k051960_sprites_draw(k051960, bitmap, cliprect, 1, 1);
134136   return 0;
135137}
src/mame/video/parodius.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
44
55static int layer_colorbase[3],sprite_colorbase,bg_colorbase;
r6740r6741
1212
1313***************************************************************************/
1414
15static void tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
15void parodius_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
1616{
1717   *code |= ((*color & 0x03) << 8) | ((*color & 0x10) << 6) | ((*color & 0x0c) << 9) | (bank << 13);
1818   *color = layer_colorbase[layer] + ((*color & 0xe0) >> 5);
r6740r6741
2424
2525***************************************************************************/
2626
27static void sprite_callback(int *code,int *color,int *priority_mask)
27void parodius_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask)
2828{
2929   int pri = 0x20 | ((*color & 0x60) >> 2);
3030   if (pri <= layerpri[2])                        *priority_mask = 0;
r6740r6741
4242
4343***************************************************************************/
4444
45VIDEO_START( parodius )
46{
47   K053251_vh_start(machine);
48   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tile_callback);
49   K053245_vh_start(machine,0,"gfx2",NORMAL_PLANE_ORDER,sprite_callback);
50}
51
5245/* useful function to sort the three tile layers by priority order */
5346static void sortlayers(int *layer,int *pri)
5447{
r6740r6741
6760
6861VIDEO_UPDATE( parodius )
6962{
63   const device_config *k053245 = devtag_get_device(screen->machine, "k053245");
64   const device_config *k053251 = devtag_get_device(screen->machine, "k053251");
65   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
7066   int layer[3];
7167
68   bg_colorbase       = k053251_get_palette_index(k053251, K053251_CI0);
69   sprite_colorbase   = k053251_get_palette_index(k053251, K053251_CI1);
70   layer_colorbase[0] = k053251_get_palette_index(k053251, K053251_CI2);
71   layer_colorbase[1] = k053251_get_palette_index(k053251, K053251_CI4);
72   layer_colorbase[2] = k053251_get_palette_index(k053251, K053251_CI3);
7273
73   bg_colorbase       = K053251_get_palette_index(K053251_CI0);
74   sprite_colorbase   = K053251_get_palette_index(K053251_CI1);
75   layer_colorbase[0] = K053251_get_palette_index(K053251_CI2);
76   layer_colorbase[1] = K053251_get_palette_index(K053251_CI4);
77   layer_colorbase[2] = K053251_get_palette_index(K053251_CI3);
74   k052109_tilemap_update(k052109);
7875
79   K052109_tilemap_update();
80
8176   layer[0] = 0;
82   layerpri[0] = K053251_get_priority(K053251_CI2);
77   layerpri[0] = k053251_get_priority(k053251, K053251_CI2);
8378   layer[1] = 1;
84   layerpri[1] = K053251_get_priority(K053251_CI4);
79   layerpri[1] = k053251_get_priority(k053251, K053251_CI4);
8580   layer[2] = 2;
86   layerpri[2] = K053251_get_priority(K053251_CI3);
81   layerpri[2] = k053251_get_priority(k053251, K053251_CI3);
8782
88   sortlayers(layer,layerpri);
83   sortlayers(layer, layerpri);
8984
9085   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
9186   bitmap_fill(bitmap,cliprect,16 * bg_colorbase);
92   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[0]],0,1);
93   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[1]],0,2);
94   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[2]],0,4);
87   k052109_tilemap_draw(k052109, bitmap, cliprect, layer[0], 0,1);
88   k052109_tilemap_draw(k052109, bitmap, cliprect, layer[1], 0,2);
89   k052109_tilemap_draw(k052109, bitmap, cliprect, layer[2], 0,4);
9590
96   K053245_sprites_draw(screen->machine,0,bitmap,cliprect);
91   k053245_sprites_draw(k053245, bitmap, cliprect);
9792   return 0;
9893}
src/mame/video/combatsc.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "video/konamiic.h"
10#include "video/konicdev.h"
11#include "includes/combatsc.h"
1112
12static tilemap *bg_tilemap[2];
13static tilemap *textlayer;
14static UINT8 *private_spriteram[2];
15static int priority;
16
17static UINT8 *combasc_io_ram;
18static int combasc_vreg;
19
20static int combasc_bank_select; /* 0x00..0x1f */
21static int combasc_video_circuit; /* 0 or 1 */
22static UINT8 *combasc_page[2];
23static UINT8 combasc_scrollram0[0x40];
24static UINT8 combasc_scrollram1[0x40];
25static UINT8 *combasc_scrollram;
26
27
28PALETTE_INIT( combasc )
13PALETTE_INIT( combatsc )
2914{
3015   int pal;
3116
r6740r6741
7560}
7661
7762
78PALETTE_INIT( combascb )
63PALETTE_INIT( combatscb )
7964{
8065   int pal;
8166
r6740r6741
10388}
10489
10590
106static void set_pens(running_machine *machine)
91static void set_pens( running_machine *machine )
10792{
93   combatsc_state *state = (combatsc_state *)machine->driver_data;
10894   int i;
10995
11096   for (i = 0x00; i < 0x100; i += 2)
11197   {
112      UINT16 data = machine->generic.paletteram.u8[i] | (machine->generic.paletteram.u8[i | 1] << 8);
98      UINT16 data = state->paletteram[i] | (state->paletteram[i | 1] << 8);
11399
114100      rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
115101
r6740r6741
127113
128114static TILE_GET_INFO( get_tile_info0 )
129115{
130   UINT8 attributes = combasc_page[0][tile_index];
131   int bank = 4*((combasc_vreg & 0x0f) - 1);
132   int number,color;
116   combatsc_state *state = (combatsc_state *)machine->driver_data;
117   UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_1, 6);
118   UINT8 attributes = state->page[0][tile_index];
119   int bank = 4 * ((state->vreg & 0x0f) - 1);
120   int number, color;
133121
134   if (bank < 0) bank = 0;
135   if ((attributes & 0xb0) == 0) bank = 0;   /* text bank */
122   if (bank < 0)
123      bank = 0;
136124
137   if (attributes & 0x80) bank += 1;
138   if (attributes & 0x10) bank += 2;
139   if (attributes & 0x20) bank += 4;
125   if ((attributes & 0xb0) == 0)
126      bank = 0;   /* text bank */
140127
141   color = ((K007121_ctrlram[0][6]&0x10)*2+16) + (attributes & 0x0f);
128   if (attributes & 0x80)
129      bank += 1;
142130
143   number = combasc_page[0][tile_index + 0x400] + 256*bank;
131   if (attributes & 0x10)
132      bank += 2;
144133
134   if (attributes & 0x20)
135      bank += 4;
136
137   color = ((ctrl_6 & 0x10) * 2 + 16) + (attributes & 0x0f);
138
139   number = state->page[0][tile_index + 0x400] + 256 * bank;
140
145141   SET_TILE_INFO(
146142         0,
147143         number,
r6740r6741
152148
153149static TILE_GET_INFO( get_tile_info1 )
154150{
155   UINT8 attributes = combasc_page[1][tile_index];
156   int bank = 4*((combasc_vreg >> 4) - 1);
151   combatsc_state *state = (combatsc_state *)machine->driver_data;
152   UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_2, 6);
153   UINT8 attributes = state->page[1][tile_index];
154   int bank = 4 * ((state->vreg >> 4) - 1);
157155   int number, color;
158156
159   if (bank < 0) bank = 0;
160   if ((attributes & 0xb0) == 0) bank = 0;   /* text bank */
157   if (bank < 0)
158      bank = 0;
161159
162   if (attributes & 0x80) bank += 1;
163   if (attributes & 0x10) bank += 2;
164   if (attributes & 0x20) bank += 4;
160   if ((attributes & 0xb0) == 0)
161      bank = 0;   /* text bank */
165162
166   color = ((K007121_ctrlram[1][6]&0x10)*2+16+4*16) + (attributes & 0x0f);
163   if (attributes & 0x80)
164      bank += 1;
167165
168   number = combasc_page[1][tile_index + 0x400] + 256*bank;
166   if (attributes & 0x10)
167      bank += 2;
169168
169   if (attributes & 0x20)
170      bank += 4;
171
172   color = ((ctrl_6 & 0x10) * 2 + 16 + 4 * 16) + (attributes & 0x0f);
173
174   number = state->page[1][tile_index + 0x400] + 256 * bank;
175
170176   SET_TILE_INFO(
171177         1,
172178         number,
r6740r6741
177183
178184static TILE_GET_INFO( get_text_info )
179185{
180   UINT8 attributes = combasc_page[0][tile_index + 0x800];
181   int number = combasc_page[0][tile_index + 0xc00];
186   combatsc_state *state = (combatsc_state *)machine->driver_data;
187   UINT8 attributes = state->page[0][tile_index + 0x800];
188   int number = state->page[0][tile_index + 0xc00];
182189   int color = 16 + (attributes & 0x0f);
183190
184191   SET_TILE_INFO(
r6740r6741
191198
192199static TILE_GET_INFO( get_tile_info0_bootleg )
193200{
194   UINT8 attributes = combasc_page[0][tile_index];
195   int bank = 4*((combasc_vreg & 0x0f) - 1);
201   combatsc_state *state = (combatsc_state *)machine->driver_data;
202   UINT8 attributes = state->page[0][tile_index];
203   int bank = 4 * ((state->vreg & 0x0f) - 1);
196204   int number, pal, color;
197205
198   if (bank < 0) bank = 0;
199   if ((attributes & 0xb0) == 0) bank = 0;   /* text bank */
206   if (bank < 0)
207      bank = 0;
200208
201   if (attributes & 0x80) bank += 1;
202   if (attributes & 0x10) bank += 2;
203   if (attributes & 0x20) bank += 4;
209   if ((attributes & 0xb0) == 0)
210      bank = 0;   /* text bank */
204211
212   if (attributes & 0x80)
213      bank += 1;
214
215   if (attributes & 0x10)
216      bank += 2;
217
218   if (attributes & 0x20)
219      bank += 4;
220
205221   pal = (bank == 0 || bank >= 0x1c || (attributes & 0x40)) ? 1 : 3;
206222   color = pal*16;// + (attributes & 0x0f);
207   number = combasc_page[0][tile_index + 0x400] + 256*bank;
223   number = state->page[0][tile_index + 0x400] + 256 * bank;
208224
209225   SET_TILE_INFO(
210226         0,
r6740r6741
215231
216232static TILE_GET_INFO( get_tile_info1_bootleg )
217233{
218   UINT8 attributes = combasc_page[1][tile_index];
219   int bank = 4*((combasc_vreg >> 4) - 1);
234   combatsc_state *state = (combatsc_state *)machine->driver_data;
235   UINT8 attributes = state->page[1][tile_index];
236   int bank = 4*((state->vreg >> 4) - 1);
220237   int number, pal, color;
221238
222   if (bank < 0) bank = 0;
223   if ((attributes & 0xb0) == 0) bank = 0;   /* text bank */
239   if (bank < 0)
240      bank = 0;
224241
225   if (attributes & 0x80) bank += 1;
226   if (attributes & 0x10) bank += 2;
227   if (attributes & 0x20) bank += 4;
242   if ((attributes & 0xb0) == 0)
243      bank = 0;   /* text bank */
228244
245   if (attributes & 0x80)
246      bank += 1;
247
248   if (attributes & 0x10)
249      bank += 2;
250
251   if (attributes & 0x20)
252      bank += 4;
253
229254   pal = (bank == 0 || bank >= 0x1c || (attributes & 0x40)) ? 5 : 7;
230   color = pal*16;// + (attributes & 0x0f);
231   number = combasc_page[1][tile_index + 0x400] + 256*bank;
255   color = pal * 16;// + (attributes & 0x0f);
256   number = state->page[1][tile_index + 0x400] + 256 * bank;
232257
233258   SET_TILE_INFO(
234259         1,
r6740r6741
239264
240265static TILE_GET_INFO( get_text_info_bootleg )
241266{
242//  UINT8 attributes = combasc_page[0][tile_index + 0x800];
243   int number = combasc_page[0][tile_index + 0xc00];
267   combatsc_state *state = (combatsc_state *)machine->driver_data;
268//  UINT8 attributes = state->page[0][tile_index + 0x800];
269   int number = state->page[0][tile_index + 0xc00];
244270   int color = 16;// + (attributes & 0x0f);
245271
246272   SET_TILE_INFO(
r6740r6741
256282
257283***************************************************************************/
258284
259VIDEO_START( combasc )
285VIDEO_START( combatsc )
260286{
261   combasc_vreg = -1;
287   combatsc_state *state = (combatsc_state *)machine->driver_data;
262288
263   bg_tilemap[0] = tilemap_create(machine, get_tile_info0,tilemap_scan_rows,8,8,32,32);
264   bg_tilemap[1] = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,8,8,32,32);
265   textlayer =  tilemap_create(machine, get_text_info, tilemap_scan_rows,     8,8,32,32);
289   state->bg_tilemap[0] = tilemap_create(machine, get_tile_info0, tilemap_scan_rows, 8, 8, 32, 32);
290   state->bg_tilemap[1] = tilemap_create(machine, get_tile_info1, tilemap_scan_rows, 8, 8, 32, 32);
291   state->textlayer =  tilemap_create(machine, get_text_info, tilemap_scan_rows, 8, 8, 32, 32);
266292
267   private_spriteram[0] = auto_alloc_array_clear(machine, UINT8, 0x800);
268   private_spriteram[1] = auto_alloc_array_clear(machine, UINT8, 0x800);
293   state->spriteram[0] = auto_alloc_array_clear(machine, UINT8, 0x800);
294   state->spriteram[1] = auto_alloc_array_clear(machine, UINT8, 0x800);
269295
270      tilemap_set_transparent_pen(bg_tilemap[0],0);
271      tilemap_set_transparent_pen(bg_tilemap[1],0);
272      tilemap_set_transparent_pen(textlayer,0);
296   tilemap_set_transparent_pen(state->bg_tilemap[0], 0);
297   tilemap_set_transparent_pen(state->bg_tilemap[1], 0);
298   tilemap_set_transparent_pen(state->textlayer, 0);
273299
274      tilemap_set_scroll_rows(textlayer,32);
300   tilemap_set_scroll_rows(state->textlayer, 32);
301
302   state_save_register_global_pointer(machine, state->spriteram[0], 0x800);
303   state_save_register_global_pointer(machine, state->spriteram[1], 0x800);
275304}
276305
277VIDEO_START( combascb )
306VIDEO_START( combatscb )
278307{
279   combasc_vreg = -1;
308   combatsc_state *state = (combatsc_state *)machine->driver_data;
280309
281   bg_tilemap[0] = tilemap_create(machine, get_tile_info0_bootleg,tilemap_scan_rows,8,8,32,32);
282   bg_tilemap[1] = tilemap_create(machine, get_tile_info1_bootleg,tilemap_scan_rows,8,8,32,32);
283   textlayer =  tilemap_create(machine, get_text_info_bootleg, tilemap_scan_rows,8,8,32,32);
310   state->bg_tilemap[0] = tilemap_create(machine, get_tile_info0_bootleg, tilemap_scan_rows, 8, 8, 32, 32);
311   state->bg_tilemap[1] = tilemap_create(machine, get_tile_info1_bootleg, tilemap_scan_rows, 8, 8, 32, 32);
312   state->textlayer = tilemap_create(machine, get_text_info_bootleg, tilemap_scan_rows, 8, 8, 32, 32);
284313
285   private_spriteram[0] = auto_alloc_array_clear(machine, UINT8, 0x800);
286   private_spriteram[1] = auto_alloc_array_clear(machine, UINT8, 0x800);
314   state->spriteram[0] = auto_alloc_array_clear(machine, UINT8, 0x800);
315   state->spriteram[1] = auto_alloc_array_clear(machine, UINT8, 0x800);
287316
288      tilemap_set_transparent_pen(bg_tilemap[0],0);
289      tilemap_set_transparent_pen(bg_tilemap[1],0);
290      tilemap_set_transparent_pen(textlayer,0);
317   tilemap_set_transparent_pen(state->bg_tilemap[0], 0);
318   tilemap_set_transparent_pen(state->bg_tilemap[1], 0);
319   tilemap_set_transparent_pen(state->textlayer, 0);
291320
292      tilemap_set_scroll_rows(bg_tilemap[0],32);
293      tilemap_set_scroll_rows(bg_tilemap[1],32);
321   tilemap_set_scroll_rows(state->bg_tilemap[0], 32);
322   tilemap_set_scroll_rows(state->bg_tilemap[1], 32);
323
324   state_save_register_global_pointer(machine, state->spriteram[0], 0x800);
325   state_save_register_global_pointer(machine, state->spriteram[1], 0x800);
294326}
295327
296328/***************************************************************************
r6740r6741
299331
300332***************************************************************************/
301333
302READ8_HANDLER( combasc_video_r )
334READ8_HANDLER( combatsc_video_r )
303335{
304   return space->machine->generic.videoram.u8[offset];
336   combatsc_state *state = (combatsc_state *)space->machine->driver_data;
337   return state->videoram[offset];
305338}
306339
307WRITE8_HANDLER( combasc_video_w )
340WRITE8_HANDLER( combatsc_video_w )
308341{
309   space->machine->generic.videoram.u8[offset] = data;
310   if( offset<0x800 )
342   combatsc_state *state = (combatsc_state *)space->machine->driver_data;
343   state->videoram[offset] = data;
344
345   if (offset < 0x800)
311346   {
312      if (combasc_video_circuit)
313         tilemap_mark_tile_dirty(bg_tilemap[1],offset & 0x3ff);
347      if (state->video_circuit)
348         tilemap_mark_tile_dirty(state->bg_tilemap[1], offset & 0x3ff);
314349      else
315         tilemap_mark_tile_dirty(bg_tilemap[0],offset & 0x3ff);
350         tilemap_mark_tile_dirty(state->bg_tilemap[0], offset & 0x3ff);
316351   }
317   else if( offset<0x1000 && combasc_video_circuit==0 )
352   else if (offset < 0x1000 && state->video_circuit == 0)
318353   {
319      tilemap_mark_tile_dirty( textlayer,offset & 0x3ff);
354      tilemap_mark_tile_dirty(state->textlayer, offset & 0x3ff);
320355   }
321356}
322357
323
324WRITE8_HANDLER( combasc_vreg_w )
358WRITE8_HANDLER( combatsc_pf_control_w )
325359{
326   if (data != combasc_vreg)
327   {
328      tilemap_mark_all_tiles_dirty( textlayer );
329      if ((data & 0x0f) != (combasc_vreg & 0x0f))
330         tilemap_mark_all_tiles_dirty( bg_tilemap[0] );
331      if ((data >> 4) != (combasc_vreg >> 4))
332         tilemap_mark_all_tiles_dirty( bg_tilemap[1] );
333      combasc_vreg = data;
334   }
335}
360   combatsc_state *state = (combatsc_state *)space->machine->driver_data;
361   const device_config *k007121 = state->video_circuit ? state->k007121_2 : state->k007121_1;
362   k007121_ctrl_w(k007121, offset, data);
336363
337static WRITE8_HANDLER( combascb_sh_irqtrigger_w )
338{
339   soundlatch_w(space, offset, data);
340   cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff);
341}
342
343static READ8_HANDLER( combascb_io_r )
344{
345   static const char *const portnames[] = { "IN0", "IN1", "DSW1", "DSW2" };
346
347   return input_port_read(space->machine, portnames[offset]);
348}
349
350static WRITE8_HANDLER( combascb_priority_w )
351{
352   priority = data & 0x20;
353}
354
355WRITE8_HANDLER( combasc_bankselect_w )
356{
357   UINT8 *page = memory_region(space->machine, "maincpu") + 0x10000;
358
359   if (data & 0x40)
360   {
361      combasc_video_circuit = 1;
362      space->machine->generic.videoram.u8 = combasc_page[1];
363      combasc_scrollram = combasc_scrollram1;
364   }
365   else
366   {
367      combasc_video_circuit = 0;
368      space->machine->generic.videoram.u8 = combasc_page[0];
369      combasc_scrollram = combasc_scrollram0;
370   }
371
372   priority = data & 0x20;
373
374   if (data & 0x10)
375   {
376      memory_set_bankptr(space->machine, "bank1",page + 0x4000 * ((data & 0x0e) >> 1));
377   }
378   else
379   {
380      memory_set_bankptr(space->machine, "bank1",page + 0x20000 + 0x4000 * (data & 1));
381   }
382}
383
384WRITE8_HANDLER( combascb_bankselect_w )
385{
386   if (data & 0x40)
387   {
388      combasc_video_circuit = 1;
389      space->machine->generic.videoram.u8 = combasc_page[1];
390   }
391   else
392   {
393      combasc_video_circuit = 0;
394      space->machine->generic.videoram.u8 = combasc_page[0];
395   }
396
397   data = data & 0x1f;
398   if( data != combasc_bank_select )
399   {
400      UINT8 *page = memory_region(space->machine, "maincpu") + 0x10000;
401      combasc_bank_select = data;
402
403      if (data & 0x10)
404      {
405         memory_set_bankptr(space->machine, "bank1",page + 0x4000 * ((data & 0x0e) >> 1));
406      }
407      else
408      {
409         memory_set_bankptr(space->machine, "bank1",page + 0x20000 + 0x4000 * (data & 1));
410      }
411
412      if (data == 0x1f)
413      {
414         memory_set_bankptr(space->machine, "bank1",page + 0x20000 + 0x4000 * (data & 1));
415         memory_install_read8_handler(space, 0x4400, 0x4403, 0, 0, combascb_io_r);/* IO RAM & Video Registers */
416         memory_install_write8_handler(space, 0x4400, 0x4400, 0, 0, combascb_priority_w);
417         memory_install_write8_handler(space, 0x4800, 0x4800, 0, 0, combascb_sh_irqtrigger_w);
418         memory_install_write8_handler(space, 0x4c00, 0x4c00, 0, 0, combasc_vreg_w);
419      }
420      else
421      {
422         memory_install_read_bank(space, 0x4000, 0x7fff, 0, 0, "bank1");   /* banked ROM */
423         memory_unmap_write(space, 0x4000, 0x7fff, 0, 0);   /* banked ROM */
424      }
425   }
426}
427
428MACHINE_RESET( combasc )
429{
430   UINT8 *MEM = memory_region(machine, "maincpu") + 0x38000;
431   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
432
433   combasc_io_ram  = MEM + 0x0000;
434   combasc_page[0] = MEM + 0x4000;
435   combasc_page[1] = MEM + 0x6000;
436
437   memset( combasc_io_ram,  0x00, 0x4000 );
438   memset( combasc_page[0], 0x00, 0x2000 );
439   memset( combasc_page[1], 0x00, 0x2000 );
440
441   combasc_bank_select = -1;
442   combasc_bankselect_w(space, 0, 0);
443}
444
445WRITE8_HANDLER( combasc_pf_control_w )
446{
447   K007121_ctrl_w(space->machine,combasc_video_circuit,offset,data);
448
449364   if (offset == 7)
450      tilemap_set_flip(bg_tilemap[combasc_video_circuit],(data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
365      tilemap_set_flip(state->bg_tilemap[state->video_circuit],(data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
451366
452367   if (offset == 3)
453368   {
454369      if (data & 0x08)
455         memcpy(private_spriteram[combasc_video_circuit],combasc_page[combasc_video_circuit]+0x1000,0x800);
370         memcpy(state->spriteram[state->video_circuit], state->page[state->video_circuit] + 0x1000, 0x800);
456371      else
457         memcpy(private_spriteram[combasc_video_circuit],combasc_page[combasc_video_circuit]+0x1800,0x800);
372         memcpy(state->spriteram[state->video_circuit], state->page[state->video_circuit] + 0x1800, 0x800);
458373   }
459374}
460375
461READ8_HANDLER( combasc_scrollram_r )
376READ8_HANDLER( combatsc_scrollram_r )
462377{
463   return combasc_scrollram[offset];
378   combatsc_state *state = (combatsc_state *)space->machine->driver_data;
379   return state->scrollram[offset];
464380}
465381
466WRITE8_HANDLER( combasc_scrollram_w )
382WRITE8_HANDLER( combatsc_scrollram_w )
467383{
468   combasc_scrollram[offset] = data;
384   combatsc_state *state = (combatsc_state *)space->machine->driver_data;
385   state->scrollram[offset] = data;
469386}
470387
471388
r6740r6741
476393
477394***************************************************************************/
478395
479static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT8 *source,int circuit,UINT32 pri_mask)
396static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT8 *source, int circuit, UINT32 pri_mask )
480397{
481   int base_color = (circuit*4)*16+(K007121_ctrlram[circuit][6]&0x10)*2;
398   combatsc_state *state = (combatsc_state *)machine->driver_data;
399   const device_config *k007121 = circuit ? state->k007121_2 : state->k007121_1;
400   int base_color = (circuit * 4) * 16 + (k007121_ctrlram_r(k007121, 6) & 0x10) * 2;
482401
483   K007121_sprites_draw(circuit,bitmap,cliprect,machine->gfx,machine->colortable,source,base_color,0,0,pri_mask);
402   k007121_sprites_draw(k007121, bitmap, cliprect, machine->gfx[circuit], machine->colortable, source, base_color, 0, 0, pri_mask);
484403}
485404
486405
487VIDEO_UPDATE( combasc )
406VIDEO_UPDATE( combatsc )
488407{
408   combatsc_state *state = (combatsc_state *)screen->machine->driver_data;
489409   int i;
490410
491411   set_pens(screen->machine);
492412
493   if (K007121_ctrlram[0][0x01] & 0x02)
413   if (k007121_ctrlram_r(state->k007121_1, 1) & 0x02)
494414   {
495      tilemap_set_scroll_rows(bg_tilemap[0],32);
496      for (i = 0;i < 32;i++)
497         tilemap_set_scrollx(bg_tilemap[0],i,combasc_scrollram0[i]);
415      tilemap_set_scroll_rows(state->bg_tilemap[0], 32);
416      for (i = 0; i < 32; i++)
417         tilemap_set_scrollx(state->bg_tilemap[0], i, state->scrollram0[i]);
498418   }
499419   else
500420   {
501      tilemap_set_scroll_rows(bg_tilemap[0],1);
502      tilemap_set_scrollx(bg_tilemap[0],0,K007121_ctrlram[0][0x00] | ((K007121_ctrlram[0][0x01] & 0x01) << 8));
421      tilemap_set_scroll_rows(state->bg_tilemap[0], 1);
422      tilemap_set_scrollx(state->bg_tilemap[0], 0, k007121_ctrlram_r(state->k007121_1, 0) | ((k007121_ctrlram_r(state->k007121_1, 1) & 0x01) << 8));
503423   }
504424
505   if (K007121_ctrlram[1][0x01] & 0x02)
425   if (k007121_ctrlram_r(state->k007121_2, 1) & 0x02)
506426   {
507      tilemap_set_scroll_rows(bg_tilemap[1],32);
508      for (i = 0;i < 32;i++)
509         tilemap_set_scrollx(bg_tilemap[1],i,combasc_scrollram1[i]);
427      tilemap_set_scroll_rows(state->bg_tilemap[1], 32);
428      for (i = 0; i < 32; i++)
429         tilemap_set_scrollx(state->bg_tilemap[1], i, state->scrollram1[i]);
510430   }
511431   else
512432   {
513      tilemap_set_scroll_rows(bg_tilemap[1],1);
514      tilemap_set_scrollx(bg_tilemap[1],0,K007121_ctrlram[1][0x00] | ((K007121_ctrlram[1][0x01] & 0x01) << 8));
433      tilemap_set_scroll_rows(state->bg_tilemap[1], 1);
434      tilemap_set_scrollx(state->bg_tilemap[1], 0, k007121_ctrlram_r(state->k007121_2, 0) | ((k007121_ctrlram_r(state->k007121_2, 1) & 0x01) << 8));
515435   }
516436
517   tilemap_set_scrolly(bg_tilemap[0],0,K007121_ctrlram[0][0x02]);
518   tilemap_set_scrolly(bg_tilemap[1],0,K007121_ctrlram[1][0x02]);
437   tilemap_set_scrolly(state->bg_tilemap[0], 0, k007121_ctrlram_r(state->k007121_1, 2));
438   tilemap_set_scrolly(state->bg_tilemap[1], 0, k007121_ctrlram_r(state->k007121_2, 2));
519439
520   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
440   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
521441
522   if (priority == 0)
442   if (state->priority == 0)
523443   {
524      tilemap_draw(bitmap,cliprect,bg_tilemap[1],TILEMAP_DRAW_OPAQUE|0,4);
525      tilemap_draw(bitmap,cliprect,bg_tilemap[1],TILEMAP_DRAW_OPAQUE|1,8);
526      tilemap_draw(bitmap,cliprect,bg_tilemap[0],0,1);
527      tilemap_draw(bitmap,cliprect,bg_tilemap[0],1,2);
444      tilemap_draw(bitmap, cliprect, state->bg_tilemap[1], TILEMAP_DRAW_OPAQUE | 0, 4);
445      tilemap_draw(bitmap, cliprect, state->bg_tilemap[1], TILEMAP_DRAW_OPAQUE | 1, 8);
446      tilemap_draw(bitmap, cliprect, state->bg_tilemap[0], 0, 1);
447      tilemap_draw(bitmap, cliprect, state->bg_tilemap[0], 1, 2);
528448
529449      /* we use the priority buffer so sprites are drawn front to back */
530      draw_sprites(screen->machine,bitmap,cliprect,private_spriteram[1],1,0x0f00);
531      draw_sprites(screen->machine,bitmap,cliprect,private_spriteram[0],0,0x4444);
450      draw_sprites(screen->machine, bitmap, cliprect, state->spriteram[1], 1, 0x0f00);
451      draw_sprites(screen->machine, bitmap, cliprect, state->spriteram[0], 0, 0x4444);
532452   }
533453   else
534454   {
535      tilemap_draw(bitmap,cliprect,bg_tilemap[0],TILEMAP_DRAW_OPAQUE|0,1);
536      tilemap_draw(bitmap,cliprect,bg_tilemap[0],TILEMAP_DRAW_OPAQUE|1,2);
537      tilemap_draw(bitmap,cliprect,bg_tilemap[1],1,4);
538      tilemap_draw(bitmap,cliprect,bg_tilemap[1],0,8);
455      tilemap_draw(bitmap, cliprect, state->bg_tilemap[0], TILEMAP_DRAW_OPAQUE | 0, 1);
456      tilemap_draw(bitmap, cliprect, state->bg_tilemap[0], TILEMAP_DRAW_OPAQUE | 1, 2);
457      tilemap_draw(bitmap, cliprect, state->bg_tilemap[1], 1, 4);
458      tilemap_draw(bitmap, cliprect, state->bg_tilemap[1], 0, 8);
539459
540460      /* we use the priority buffer so sprites are drawn front to back */
541      draw_sprites(screen->machine,bitmap,cliprect,private_spriteram[1],1,0x0f00);
542      draw_sprites(screen->machine,bitmap,cliprect,private_spriteram[0],0,0x4444);
461      draw_sprites(screen->machine, bitmap, cliprect, state->spriteram[1], 1, 0x0f00);
462      draw_sprites(screen->machine, bitmap, cliprect, state->spriteram[0], 0, 0x4444);
543463   }
544464
545   if (K007121_ctrlram[0][0x01] & 0x08)
465   if (k007121_ctrlram_r(state->k007121_1, 1) & 0x08)
546466   {
547      for (i = 0;i < 32;i++)
467      for (i = 0; i < 32; i++)
548468      {
549         tilemap_set_scrollx(textlayer,i,combasc_scrollram0[0x20+i] ? 0 : TILE_LINE_DISABLED);
550         tilemap_draw(bitmap,cliprect,textlayer,0,0);
469         tilemap_set_scrollx(state->textlayer, i, state->scrollram0[0x20 + i] ? 0 : TILE_LINE_DISABLED);
470         tilemap_draw(bitmap, cliprect, state->textlayer, 0, 0);
551471      }
552472   }
553473
554474   /* chop the extreme columns if necessary */
555   if (K007121_ctrlram[0][0x03] & 0x40)
475   if (k007121_ctrlram_r(state->k007121_1, 3) & 0x40)
556476   {
557477      rectangle clip;
558478
559479      clip = *cliprect;
560480      clip.max_x = clip.min_x + 7;
561      bitmap_fill(bitmap,&clip,0);
481      bitmap_fill(bitmap, &clip, 0);
562482
563483      clip = *cliprect;
564484      clip.min_x = clip.max_x - 7;
565      bitmap_fill(bitmap,&clip,0);
485      bitmap_fill(bitmap, &clip, 0);
566486   }
567487   return 0;
568488}
r6740r6741
595515
596516***************************************************************************/
597517
598static void bootleg_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT8 *source, int circuit )
518static void bootleg_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT8 *source, int circuit )
599519{
600520   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
601   const gfx_element *gfx = machine->gfx[circuit+2];
521   const gfx_element *gfx = machine->gfx[circuit + 2];
602522
603   int limit = ( circuit) ? (memory_read_byte(space, 0xc2)*256 + memory_read_byte(space, 0xc3)) : (memory_read_byte(space, 0xc0)*256 + memory_read_byte(space, 0xc1));
523   int limit = circuit ? (memory_read_byte(space, 0xc2) * 256 + memory_read_byte(space, 0xc3)) : (memory_read_byte(space, 0xc0) * 256 + memory_read_byte(space, 0xc1));
604524   const UINT8 *finish;
605525
606   source+=0x1000;
526   source += 0x1000;
607527   finish = source;
608   source+=0x400;
609   limit = (0x3400-limit)/8;
610   if( limit>=0 ) finish = source-limit*8;
611   source-=8;
528   source += 0x400;
529   limit = (0x3400 - limit) / 8;
530   if (limit >= 0)
531      finish = source - limit * 8;
532   source -= 8;
612533
613   while( source>finish )
534   while (source > finish)
614535   {
615536      UINT8 attributes = source[3]; /* PBxF ?xxX */
616537      {
r6740r6741
622543         int bank = (color & 0x03) | ((attributes & 0x40) >> 4);
623544
624545         number = ((number & 0x02) << 1) | ((number & 0x04) >> 1) | (number & (~6));
625         number += 256*bank;
546         number += 256 * bank;
626547
627         color = (circuit*4)*16 + (color >> 4);
548         color = (circuit * 4) * 16 + (color >> 4);
628549
629550         /*  hacks to select alternate palettes */
630//          if(combasc_vreg == 0x40 && (attributes & 0x40)) color += 1*16;
631//          if(combasc_vreg == 0x23 && (attributes & 0x02)) color += 1*16;
632//          if(combasc_vreg == 0x66 ) color += 2*16;
551//          if(state->vreg == 0x40 && (attributes & 0x40)) color += 1*16;
552//          if(state->vreg == 0x23 && (attributes & 0x02)) color += 1*16;
553//          if(state->vreg == 0x66 ) color += 2*16;
633554
634555         drawgfx_transpen( bitmap, cliprect, gfx,
635556            number, color,
r6740r6741
640561   }
641562}
642563
643VIDEO_UPDATE( combascb )
564VIDEO_UPDATE( combatscb )
644565{
566   combatsc_state *state = (combatsc_state *)screen->machine->driver_data;
645567   int i;
646568
647569   set_pens(screen->machine);
648570
649   for( i=0; i<32; i++ )
571   for (i = 0; i < 32; i++)
650572   {
651      tilemap_set_scrollx( bg_tilemap[0],i, combasc_io_ram[0x040+i]+5 );
652      tilemap_set_scrollx( bg_tilemap[1],i, combasc_io_ram[0x060+i]+3 );
573      tilemap_set_scrollx(state->bg_tilemap[0], i, state->io_ram[0x040 + i] + 5);
574      tilemap_set_scrollx(state->bg_tilemap[1], i, state->io_ram[0x060 + i] + 3);
653575   }
654   tilemap_set_scrolly( bg_tilemap[0],0, combasc_io_ram[0x000] );
655   tilemap_set_scrolly( bg_tilemap[1],0, combasc_io_ram[0x020] );
576   tilemap_set_scrolly(state->bg_tilemap[0], 0, state->io_ram[0x000]);
577   tilemap_set_scrolly(state->bg_tilemap[1], 0, state->io_ram[0x020]);
656578
657   if (priority == 0)
579   if (state->priority == 0)
658580   {
659      tilemap_draw( bitmap,cliprect,bg_tilemap[1],TILEMAP_DRAW_OPAQUE,0);
660      bootleg_draw_sprites(screen->machine, bitmap,cliprect, combasc_page[1], 1 );
581      tilemap_draw(bitmap, cliprect, state->bg_tilemap[1], TILEMAP_DRAW_OPAQUE,0);
582      bootleg_draw_sprites(screen->machine, bitmap,cliprect, state->page[1], 1);
661583
662      tilemap_draw( bitmap,cliprect,bg_tilemap[0],0 ,0);
663      bootleg_draw_sprites(screen->machine, bitmap,cliprect, combasc_page[0], 0 );
584      tilemap_draw(bitmap, cliprect, state->bg_tilemap[0], 0 ,0);
585      bootleg_draw_sprites(screen->machine, bitmap, cliprect, state->page[0], 0);
664586   }
665587   else
666588   {
667      tilemap_draw( bitmap,cliprect,bg_tilemap[0],TILEMAP_DRAW_OPAQUE,0);
668      bootleg_draw_sprites(screen->machine, bitmap,cliprect, combasc_page[0], 0 );
589      tilemap_draw(bitmap, cliprect, state->bg_tilemap[0], TILEMAP_DRAW_OPAQUE, 0);
590      bootleg_draw_sprites(screen->machine, bitmap,cliprect, state->page[0], 0);
669591
670      tilemap_draw( bitmap,cliprect,bg_tilemap[1],0 ,0);
671      bootleg_draw_sprites(screen->machine, bitmap,cliprect, combasc_page[1], 1 );
592      tilemap_draw(bitmap,cliprect, state->bg_tilemap[1], 0, 0);
593      bootleg_draw_sprites(screen->machine, bitmap,cliprect, state->page[1], 1);
672594   }
673595
674   tilemap_draw( bitmap,cliprect,textlayer,0,0);
596   tilemap_draw(bitmap, cliprect, state->textlayer, 0, 0);
675597   return 0;
676598}
src/mame/video/blueprnt.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "blueprnt.h"
8#include "includes/blueprnt.h"
99
1010
1111/***************************************************************************
src/mame/video/rockrage.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
3#include "includes/rockrage.h"
34
4static int layer_colorbase[2];
5static int rockrage_vreg;
6
7
85PALETTE_INIT( rockrage )
96{
107   int i;
r6740r6741
3027}
3128
3229
33static void set_pens(running_machine *machine)
30static void set_pens( running_machine *machine )
3431{
32   rockrage_state *state = (rockrage_state *)machine->driver_data;
3533   int i;
3634
3735   for (i = 0x00; i < 0x80; i += 2)
3836   {
39      UINT16 data = machine->generic.paletteram.u8[i] | (machine->generic.paletteram.u8[i | 1] << 8);
37      UINT16 data = state->paletteram[i] | (state->paletteram[i | 1] << 8);
4038
4139      rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
4240
r6740r6741
5149
5250***************************************************************************/
5351
54static void tile_callback(int layer, int bank, int *code, int *color, int *flags)
52void rockrage_tile_callback( running_machine *machine, int layer, int bank, int *code, int *color, int *flags )
5553{
54   rockrage_state *state = (rockrage_state *)machine->driver_data;
55
5656   if (layer == 1)
5757      *code |= ((*color & 0x40) << 2) | ((bank & 0x01) << 9);
5858   else
59      *code |= ((*color & 0x40) << 2) | ((bank & 0x03) << 10) | ((rockrage_vreg & 0x04) << 7) | ((rockrage_vreg & 0x08) << 9);
60   *color = layer_colorbase[layer] + (*color & 0x0f);
59      *code |= ((*color & 0x40) << 2) | ((bank & 0x03) << 10) | ((state->vreg & 0x04) << 7) | ((state->vreg & 0x08) << 9);
60   *color = state->layer_colorbase[layer] + (*color & 0x0f);
6161}
6262
6363/***************************************************************************
r6740r6741
6666
6767***************************************************************************/
6868
69static void sprite_callback(int *code,int *color)
69void rockrage_sprite_callback( running_machine *machine, int *code, int *color )
7070{
71   *code |= ((*color & 0x40) << 2) | ((*color & 0x80) << 1)*((rockrage_vreg & 0x03) << 1);
71   rockrage_state *state = (rockrage_state *)machine->driver_data;
72
73   *code |= ((*color & 0x40) << 2) | ((*color & 0x80) << 1) * ((state->vreg & 0x03) << 1);
7274   *code = (*code << 2) | ((*color & 0x30) >> 4);
7375   *color = 0;
7476}
7577
7678
77WRITE8_HANDLER( rockrage_vreg_w ){
79WRITE8_HANDLER( rockrage_vreg_w )
80{
7881   /* bits 4-7: unused */
7982   /* bit 3: bit 4 of bank # (layer 0) */
8083   /* bit 2: bit 1 of bank # (layer 0) */
8184   /* bits 0-1: sprite bank select */
85   rockrage_state *state = (rockrage_state *)space->machine->driver_data;
8286
83   if ((data & 0x0c) != (rockrage_vreg & 0x0c))
87   if ((data & 0x0c) != (state->vreg & 0x0c))
8488      tilemap_mark_all_tiles_dirty_all(space->machine);
8589
86   rockrage_vreg = data;
90   state->vreg = data;
8791}
8892
8993/***************************************************************************
9094
91    Start the video hardware emulation.
92
93***************************************************************************/
94
95VIDEO_START( rockrage )
96{
97   layer_colorbase[0] = 0x00;
98   layer_colorbase[1] = 0x10;
99
100   K007342_vh_start(machine,0,tile_callback);
101   K007420_vh_start(machine,1,sprite_callback);
102
103   K007420_set_banklimit(0x3ff); // bladestl and battlnts may also need this
104}
105
106
107/***************************************************************************
108
10995  Screen Refresh
11096
11197***************************************************************************/
11298
11399VIDEO_UPDATE( rockrage )
114100{
101   rockrage_state *state = (rockrage_state *)screen->machine->driver_data;
102
115103   set_pens(screen->machine);
116104
117   K007342_tilemap_update();
105   k007342_tilemap_update(state->k007342);
118106
119   K007342_tilemap_draw(bitmap,cliprect, 0, TILEMAP_DRAW_OPAQUE ,0);
120   K007420_sprites_draw(bitmap,cliprect );
121   K007342_tilemap_draw(bitmap,cliprect, 0, 1 | TILEMAP_DRAW_OPAQUE ,0);
122   K007342_tilemap_draw(bitmap,cliprect, 1, 0 ,0);
123   K007342_tilemap_draw(bitmap,cliprect, 1, 1 ,0);
107   k007342_tilemap_draw(state->k007342, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0);
108   k007420_sprites_draw(state->k007420, bitmap, cliprect, screen->machine->gfx[1]);
109   k007342_tilemap_draw(state->k007342, bitmap, cliprect, 0, 1 | TILEMAP_DRAW_OPAQUE, 0);
110   k007342_tilemap_draw(state->k007342, bitmap, cliprect, 1, 0, 0);
111   k007342_tilemap_draw(state->k007342, bitmap, cliprect, 1, 1, 0);
124112   return 0;
125113}
src/mame/video/pandoras.c
r6740r6741
11#include "driver.h"
2#include "pandoras.h"
2#include "includes/pandoras.h"
33#include "video/resnet.h"
44
55/***********************************************************************
src/mame/video/n64.c
r6740r6741
783783   //vibuffering = 0; // Disabled for now
784784
785785   /*
786   if (vibuffering && ((n64_vi_control & 3) == 2))
787   {
788      if (frame_buffer)
789      {
790         for (j=0; j < vres; j++)
791         {
792            for (i=0; i < hres; i++)
793            {
794               UINT16 pix;
795               pix = frame_buffer[pixels ^ WORD_ADDR_XOR];
796               curpixel_cvg = ((pix & 1) << 2) | (hidden_buffer[pixels ^ BYTE_ADDR_XOR] & 3); // Reuse of this variable
797               if (curpixel_cvg < 7 && i > 1 && j > 1 && i < (hres - 2) && j < (vres - 2) && fsaa)
798               {
799                  newc = video_filter16(&frame_buffer[pixels ^ WORD_ADDR_XOR], &hidden_buffer[pixels ^ BYTE_ADDR_XOR], n64_vi_width);
800                  ViBuffer[i][j] = newc;
801               }
802               else
803               {
804                  newc.i.r = ((pix >> 8) & 0xf8) | (pix >> 13);
805                  newc.i.g = ((pix >> 3) & 0xf8) | ((pix >>  8) & 0x07);
806                  newc.i.b = ((pix << 2) & 0xf8) | ((pix >>  3) & 0x07);
807                  ViBuffer[i][j] = newc;
808               }
809               pixels++;
810            }
811            pixels += invisiblewidth;
812         }
813      }
814   }
815   */
786    if (vibuffering && ((n64_vi_control & 3) == 2))
787    {
788        if (frame_buffer)
789        {
790            for (j=0; j < vres; j++)
791            {
792                for (i=0; i < hres; i++)
793                {
794                    UINT16 pix;
795                    pix = frame_buffer[pixels ^ WORD_ADDR_XOR];
796                    curpixel_cvg = ((pix & 1) << 2) | (hidden_buffer[pixels ^ BYTE_ADDR_XOR] & 3); // Reuse of this variable
797                    if (curpixel_cvg < 7 && i > 1 && j > 1 && i < (hres - 2) && j < (vres - 2) && fsaa)
798                    {
799                        newc = video_filter16(&frame_buffer[pixels ^ WORD_ADDR_XOR], &hidden_buffer[pixels ^ BYTE_ADDR_XOR], n64_vi_width);
800                        ViBuffer[i][j] = newc;
801                    }
802                    else
803                    {
804                        newc.i.r = ((pix >> 8) & 0xf8) | (pix >> 13);
805                        newc.i.g = ((pix >> 3) & 0xf8) | ((pix >>  8) & 0x07);
806                        newc.i.b = ((pix << 2) & 0xf8) | ((pix >>  3) & 0x07);
807                        ViBuffer[i][j] = newc;
808                    }
809                    pixels++;
810                }
811                pixels += invisiblewidth;
812            }
813        }
814    }
815    */
816816
817817    if (n64_vi_blank)
818818    {
r6740r6741
13011301#define XOR_SWAP_DWORD   1
13021302
13031303/*
1304   UINT32 twidth = tile[tilenum].line;
1305   UINT32 tbase = tile[tilenum].tmem;
1306   UINT32 tpal = tile[tilenum].palette & 0xf;
1304    UINT32 twidth = tile[tilenum].line;
1305    UINT32 tbase = tile[tilenum].tmem;
1306    UINT32 tpal = tile[tilenum].palette & 0xf;
13071307
1308   if (t < 0) t = 0;
1309   if (s < 0) s = 0;
1308    if (t < 0) t = 0;
1309    if (s < 0) s = 0;
13101310*/
13111311
13121312static INT32 tbase;
r6740r6741
28482848/*
28492849static void triangle(UINT32 w1, UINT32 w2, int shade, int texture, int zbuffer)
28502850{
2851   int j;
2852   int xleft, xright, xleft_inc, xright_inc;
2853   int xstart, xend;
2854   int r = 0, g = 0, b = 0, a = 0, z = 0, s = 0, t = 0, w = 0;
2855   int dr, dg, db, da;
2856   int drdx = 0, dgdx = 0, dbdx = 0, dadx = 0, dzdx = 0, dsdx = 0, dtdx = 0, dwdx = 0;
2857   int drdy = 0, dgdy = 0, dbdy = 0, dady = 0, dzdy = 0, dsdy = 0, dtdy = 0, dwdy = 0;
2858   int drde = 0, dgde = 0, dbde = 0, dade = 0, dzde = 0, dsde = 0, dtde = 0, dwde = 0;
2859   int tilenum;
2860   int flip = (w1 & 0x800000) ? 1 : 0;
2851    int j;
2852    int xleft, xright, xleft_inc, xright_inc;
2853    int xstart, xend;
2854    int r = 0, g = 0, b = 0, a = 0, z = 0, s = 0, t = 0, w = 0;
2855    int dr, dg, db, da;
2856    int drdx = 0, dgdx = 0, dbdx = 0, dadx = 0, dzdx = 0, dsdx = 0, dtdx = 0, dwdx = 0;
2857    int drdy = 0, dgdy = 0, dbdy = 0, dady = 0, dzdy = 0, dsdy = 0, dtdy = 0, dwdy = 0;
2858    int drde = 0, dgde = 0, dbde = 0, dade = 0, dzde = 0, dsde = 0, dtde = 0, dwde = 0;
2859    int tilenum;
2860    int flip = (w1 & 0x800000) ? 1 : 0;
28612861
2862   INT32 yl, ym, yh;
2863   INT32 xl, xm, xh;
2864   INT32 dxldy, dxhdy, dxmdy;
2865   int dzdy_dz, dzdx_dz;
2866   int dsdylod, dtdylod;
2867   UINT32 w3, w4, w5, w6, w7, w8;
2862    INT32 yl, ym, yh;
2863    INT32 xl, xm, xh;
2864    INT32 dxldy, dxhdy, dxmdy;
2865    int dzdy_dz, dzdx_dz;
2866    int dsdylod, dtdylod;
2867    UINT32 w3, w4, w5, w6, w7, w8;
28682868
2869   int k = 0;
2869    int k = 0;
28702870
2871   INT32 limcvg = 0;
2872   INT32 startcvg = 0;
2871    INT32 limcvg = 0;
2872    INT32 startcvg = 0;
28732873
2874   int sign_dxldy = 0;
2875   int sign_dxmdy = 0;
2876   int samesign = 0;
2874    int sign_dxldy = 0;
2875    int sign_dxmdy = 0;
2876    int samesign = 0;
28772877
2878   int dsdiff = 0, dtdiff = 0, dwdiff = 0, drdiff = 0, dgdiff = 0, dbdiff = 0, dadiff = 0, dzdiff = 0;
2879   int sign_dxhdy = 0;
2878    int dsdiff = 0, dtdiff = 0, dwdiff = 0, drdiff = 0, dgdiff = 0, dbdiff = 0, dadiff = 0, dzdiff = 0;
2879    int sign_dxhdy = 0;
28802880
2881   int dsdeh = 0, dtdeh = 0, dwdeh = 0, drdeh = 0, dgdeh = 0, dbdeh = 0, dadeh = 0, dzdeh = 0, dsdyh = 0, dtdyh = 0, dwdyh = 0, drdyh = 0, dgdyh = 0, dbdyh = 0, dadyh = 0, dzdyh = 0;
2882   int do_offset = 0;
2881    int dsdeh = 0, dtdeh = 0, dwdeh = 0, drdeh = 0, dgdeh = 0, dbdeh = 0, dadeh = 0, dzdeh = 0, dsdyh = 0, dtdyh = 0, dwdyh = 0, drdyh = 0, dgdyh = 0, dbdyh = 0, dadyh = 0, dzdyh = 0;
2882    int do_offset = 0;
28832883
2884   int xfrac = 0;
2885   int dseoff = 0, dteoff = 0, dweoff = 0, dreoff = 0, dgeoff = 0, dbeoff = 0, daeoff = 0, dzeoff = 0;
2884    int xfrac = 0;
2885    int dseoff = 0, dteoff = 0, dweoff = 0, dreoff = 0, dgeoff = 0, dbeoff = 0, daeoff = 0, dzeoff = 0;
28862886
2887   int dsdxh = 0, dtdxh = 0, dwdxh = 0, drdxh = 0, dgdxh = 0, dbdxh = 0, dadxh = 0, dzdxh = 0;
2887    int dsdxh = 0, dtdxh = 0, dwdxh = 0, drdxh = 0, dgdxh = 0, dbdxh = 0, dadxh = 0, dzdxh = 0;
28882888
2889   int m_inc;
2890   UINT32 min=0, max=3;
2891   INT32 maxxmx = 0, minxmx = 0, maxxhx = 0, minxhx = 0;
2889    int m_inc;
2890    UINT32 min=0, max=3;
2891    INT32 maxxmx = 0, minxmx = 0, maxxhx = 0, minxhx = 0;
28922892
2893   int spix = 0; // Current subpixel
2894   int ycur;
2895   int ylfar;
2896   int ldflag;
2897   int yhpix;
2898   int ympix;
2899   int ylpix;
2893    int spix = 0; // Current subpixel
2894    int ycur;
2895    int ylfar;
2896    int ldflag;
2897    int yhpix;
2898    int ympix;
2899    int ylpix;
29002900
2901   int shade_base = rdp_cmd_cur + 8;
2902   int texture_base = rdp_cmd_cur + 8;
2903   int zbuffer_base = rdp_cmd_cur + 8;
2901    int shade_base = rdp_cmd_cur + 8;
2902    int texture_base = rdp_cmd_cur + 8;
2903    int zbuffer_base = rdp_cmd_cur + 8;
29042904
2905   if (shade)
2906   {
2907      texture_base += 16;
2908      zbuffer_base += 16;
2909   }
2910   if (texture)
2911   {
2912      zbuffer_base += 16;
2913   }
2905    if (shade)
2906    {
2907        texture_base += 16;
2908        zbuffer_base += 16;
2909    }
2910    if (texture)
2911    {
2912        zbuffer_base += 16;
2913    }
29142914
2915   w3 = rdp_cmd_data[rdp_cmd_cur+2];
2916   w4 = rdp_cmd_data[rdp_cmd_cur+3];
2917   w5 = rdp_cmd_data[rdp_cmd_cur+4];
2918   w6 = rdp_cmd_data[rdp_cmd_cur+5];
2919   w7 = rdp_cmd_data[rdp_cmd_cur+6];
2920   w8 = rdp_cmd_data[rdp_cmd_cur+7];
2915    w3 = rdp_cmd_data[rdp_cmd_cur+2];
2916    w4 = rdp_cmd_data[rdp_cmd_cur+3];
2917    w5 = rdp_cmd_data[rdp_cmd_cur+4];
2918    w6 = rdp_cmd_data[rdp_cmd_cur+5];
2919    w7 = rdp_cmd_data[rdp_cmd_cur+6];
2920    w8 = rdp_cmd_data[rdp_cmd_cur+7];
29212921
2922   yl = (w1 & 0x3fff);
2923   ym = ((w2 >> 16) & 0x3fff);
2924   yh = ((w2 >>  0) & 0x3fff);
2925   xl = (INT32)(w3 & 0x3fffffff);
2926   xh = (INT32)(w5 & 0x3fffffff);
2927   xm = (INT32)(w7 & 0x3fffffff);
2928   // Inverse slopes in 16.16 format
2929   dxldy = (INT32)(w4);
2930   dxhdy = (INT32)(w6);
2931   dxmdy = (INT32)(w8);
2922    yl = (w1 & 0x3fff);
2923    ym = ((w2 >> 16) & 0x3fff);
2924    yh = ((w2 >>  0) & 0x3fff);
2925    xl = (INT32)(w3 & 0x3fffffff);
2926    xh = (INT32)(w5 & 0x3fffffff);
2927    xm = (INT32)(w7 & 0x3fffffff);
2928    // Inverse slopes in 16.16 format
2929    dxldy = (INT32)(w4);
2930    dxhdy = (INT32)(w6);
2931    dxmdy = (INT32)(w8);
29322932
2933   max_level = ((w1 >> 19) & 7);
2934   tilenum = (w1 >> 16) & 0x7;
2933    max_level = ((w1 >> 19) & 7);
2934    tilenum = (w1 >> 16) & 0x7;
29352935
2936   if (yl & 0x2000)  yl |= 0xffffc000;
2937   if (ym & 0x2000)  ym |= 0xffffc000;
2938   if (yh & 0x2000)  yh |= 0xffffc000;
2936    if (yl & 0x2000)  yl |= 0xffffc000;
2937    if (ym & 0x2000)  ym |= 0xffffc000;
2938    if (yh & 0x2000)  yh |= 0xffffc000;
29392939
2940   if (xl & 0x20000000)  xl |= 0xc0000000;
2941   if (xm & 0x20000000)  xm |= 0xc0000000;
2942   if (xh & 0x20000000)  xh |= 0xc0000000;
2940    if (xl & 0x20000000)  xl |= 0xc0000000;
2941    if (xm & 0x20000000)  xm |= 0xc0000000;
2942    if (xh & 0x20000000)  xh |= 0xc0000000;
29432943
2944   z = 0;
2945   s = 0;   t = 0;   w = 0;
2946   dr = 0;      dg = 0;      db = 0;      da = 0;
2944    z = 0;
2945    s = 0;  t = 0;  w = 0;
2946    dr = 0;     dg = 0;     db = 0;     da = 0;
29472947
2948   if (shade)
2949   {
2950      r    = (rdp_cmd_data[shade_base+0 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+4 ] >> 16) & 0x0000ffff);
2951      g    = ((rdp_cmd_data[shade_base+0 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+4 ] & 0x0000ffff);
2952      b    = (rdp_cmd_data[shade_base+1 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+5 ] >> 16) & 0x0000ffff);
2953      a    = ((rdp_cmd_data[shade_base+1 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+5 ] & 0x0000ffff);
2954      drdx = (rdp_cmd_data[shade_base+2 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+6 ] >> 16) & 0x0000ffff);
2955      dgdx = ((rdp_cmd_data[shade_base+2 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+6 ] & 0x0000ffff);
2956      dbdx = (rdp_cmd_data[shade_base+3 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+7 ] >> 16) & 0x0000ffff);
2957      dadx = ((rdp_cmd_data[shade_base+3 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+7 ] & 0x0000ffff);
2958      drde = (rdp_cmd_data[shade_base+8 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+12] >> 16) & 0x0000ffff);
2959      dgde = ((rdp_cmd_data[shade_base+8 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+12] & 0x0000ffff);
2960      dbde = (rdp_cmd_data[shade_base+9 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+13] >> 16) & 0x0000ffff);
2961      dade = ((rdp_cmd_data[shade_base+9 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+13] & 0x0000ffff);
2962      drdy = (rdp_cmd_data[shade_base+10] & 0xffff0000) | ((rdp_cmd_data[shade_base+14] >> 16) & 0x0000ffff);
2963      dgdy = ((rdp_cmd_data[shade_base+10] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+14] & 0x0000ffff);
2964      dbdy = (rdp_cmd_data[shade_base+11] & 0xffff0000) | ((rdp_cmd_data[shade_base+15] >> 16) & 0x0000ffff);
2965      dady = ((rdp_cmd_data[shade_base+11] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+15] & 0x0000ffff);
2966   }
2967   if (texture)
2968   {
2969      s    = (rdp_cmd_data[texture_base+0 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+4 ] >> 16) & 0x0000ffff);
2970      t    = ((rdp_cmd_data[texture_base+0 ] << 16) & 0xffff0000)   | (rdp_cmd_data[texture_base+4 ] & 0x0000ffff);
2971      w    = (rdp_cmd_data[texture_base+1 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+5 ] >> 16) & 0x0000ffff);
2972      dsdx = (rdp_cmd_data[texture_base+2 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+6 ] >> 16) & 0x0000ffff);
2973      dtdx = ((rdp_cmd_data[texture_base+2 ] << 16) & 0xffff0000)   | (rdp_cmd_data[texture_base+6 ] & 0x0000ffff);
2974      dwdx = (rdp_cmd_data[texture_base+3 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+7 ] >> 16) & 0x0000ffff);
2975      dsde = (rdp_cmd_data[texture_base+8 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+12] >> 16) & 0x0000ffff);
2976      dtde = ((rdp_cmd_data[texture_base+8 ] << 16) & 0xffff0000)   | (rdp_cmd_data[texture_base+12] & 0x0000ffff);
2977      dwde = (rdp_cmd_data[texture_base+9 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+13] >> 16) & 0x0000ffff);
2978      dsdy = (rdp_cmd_data[texture_base+10] & 0xffff0000) | ((rdp_cmd_data[texture_base+14] >> 16) & 0x0000ffff);
2979      dtdy = ((rdp_cmd_data[texture_base+10] << 16) & 0xffff0000)   | (rdp_cmd_data[texture_base+14] & 0x0000ffff);
2980      dwdy = (rdp_cmd_data[texture_base+11] & 0xffff0000) | ((rdp_cmd_data[texture_base+15] >> 16) & 0x0000ffff);
2981   }
2982   if (zbuffer)
2983   {
2984      z    = rdp_cmd_data[zbuffer_base+0];
2985      dzdx = rdp_cmd_data[zbuffer_base+1];
2986      dzde = rdp_cmd_data[zbuffer_base+2];
2987      dzdy = rdp_cmd_data[zbuffer_base+3];
2988   }
2948    if (shade)
2949    {
2950        r    = (rdp_cmd_data[shade_base+0 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+4 ] >> 16) & 0x0000ffff);
2951        g    = ((rdp_cmd_data[shade_base+0 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+4 ] & 0x0000ffff);
2952        b    = (rdp_cmd_data[shade_base+1 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+5 ] >> 16) & 0x0000ffff);
2953        a    = ((rdp_cmd_data[shade_base+1 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+5 ] & 0x0000ffff);
2954        drdx = (rdp_cmd_data[shade_base+2 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+6 ] >> 16) & 0x0000ffff);
2955        dgdx = ((rdp_cmd_data[shade_base+2 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+6 ] & 0x0000ffff);
2956        dbdx = (rdp_cmd_data[shade_base+3 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+7 ] >> 16) & 0x0000ffff);
2957        dadx = ((rdp_cmd_data[shade_base+3 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+7 ] & 0x0000ffff);
2958        drde = (rdp_cmd_data[shade_base+8 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+12] >> 16) & 0x0000ffff);
2959        dgde = ((rdp_cmd_data[shade_base+8 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+12] & 0x0000ffff);
2960        dbde = (rdp_cmd_data[shade_base+9 ] & 0xffff0000) | ((rdp_cmd_data[shade_base+13] >> 16) & 0x0000ffff);
2961        dade = ((rdp_cmd_data[shade_base+9 ] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+13] & 0x0000ffff);
2962        drdy = (rdp_cmd_data[shade_base+10] & 0xffff0000) | ((rdp_cmd_data[shade_base+14] >> 16) & 0x0000ffff);
2963        dgdy = ((rdp_cmd_data[shade_base+10] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+14] & 0x0000ffff);
2964        dbdy = (rdp_cmd_data[shade_base+11] & 0xffff0000) | ((rdp_cmd_data[shade_base+15] >> 16) & 0x0000ffff);
2965        dady = ((rdp_cmd_data[shade_base+11] << 16) & 0xffff0000) | (rdp_cmd_data[shade_base+15] & 0x0000ffff);
2966    }
2967    if (texture)
2968    {
2969        s    = (rdp_cmd_data[texture_base+0 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+4 ] >> 16) & 0x0000ffff);
2970        t    = ((rdp_cmd_data[texture_base+0 ] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+4 ] & 0x0000ffff);
2971        w    = (rdp_cmd_data[texture_base+1 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+5 ] >> 16) & 0x0000ffff);
2972        dsdx = (rdp_cmd_data[texture_base+2 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+6 ] >> 16) & 0x0000ffff);
2973        dtdx = ((rdp_cmd_data[texture_base+2 ] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+6 ] & 0x0000ffff);
2974        dwdx = (rdp_cmd_data[texture_base+3 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+7 ] >> 16) & 0x0000ffff);
2975        dsde = (rdp_cmd_data[texture_base+8 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+12] >> 16) & 0x0000ffff);
2976        dtde = ((rdp_cmd_data[texture_base+8 ] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+12] & 0x0000ffff);
2977        dwde = (rdp_cmd_data[texture_base+9 ] & 0xffff0000) | ((rdp_cmd_data[texture_base+13] >> 16) & 0x0000ffff);
2978        dsdy = (rdp_cmd_data[texture_base+10] & 0xffff0000) | ((rdp_cmd_data[texture_base+14] >> 16) & 0x0000ffff);
2979        dtdy = ((rdp_cmd_data[texture_base+10] << 16) & 0xffff0000) | (rdp_cmd_data[texture_base+14] & 0x0000ffff);
2980        dwdy = (rdp_cmd_data[texture_base+11] & 0xffff0000) | ((rdp_cmd_data[texture_base+15] >> 16) & 0x0000ffff);
2981    }
2982    if (zbuffer)
2983    {
2984        z    = rdp_cmd_data[zbuffer_base+0];
2985        dzdx = rdp_cmd_data[zbuffer_base+1];
2986        dzde = rdp_cmd_data[zbuffer_base+2];
2987        dzdy = rdp_cmd_data[zbuffer_base+3];
2988    }
29892989
2990   span[0].ds.w = dsdx;
2991   span[0].dt.w = dtdx;
2992   span[0].dw.w = dwdx;
2993   span[0].dr.w = drdx & ~0x1f;
2994   span[0].dg.w = dgdx & ~0x1f;
2995   span[0].db.w = dbdx & ~0x1f;
2996   span[0].da.w = dadx & ~0x1f;
2997   span[0].dz.w = dzdx;
2998   dzdy_dz = (dzdy >> 16) & 0xffff;
2999   dzdx_dz = (dzdx >> 16) & 0xffff;
3000   span[0].dzpix = ((dzdy_dz & 0x8000) ? ((~dzdy_dz) & 0x7fff) : dzdy_dz) + ((dzdx_dz & 0x8000) ? ((~dzdx_dz) & 0x7fff) : dzdx_dz);
3001   span[0].dzpix = normalize_dzpix(span[0].dzpix);
3002   dsdylod = dsdy >> 16;
3003   dtdylod = dtdy >> 16;
3004   if (dsdylod & 0x20000)
3005   {
3006      dsdylod = ~dsdylod & 0x1ffff;
3007   }
3008   if (dtdylod & 0x20000)
3009   {
3010      dtdylod = ~dtdylod & 0x1ffff;
3011   }
3012   span[0].dymax = (dsdylod > dtdylod)? dsdylod : dtdylod;
2990    span[0].ds.w = dsdx;
2991    span[0].dt.w = dtdx;
2992    span[0].dw.w = dwdx;
2993    span[0].dr.w = drdx & ~0x1f;
2994    span[0].dg.w = dgdx & ~0x1f;
2995    span[0].db.w = dbdx & ~0x1f;
2996    span[0].da.w = dadx & ~0x1f;
2997    span[0].dz.w = dzdx;
2998    dzdy_dz = (dzdy >> 16) & 0xffff;
2999    dzdx_dz = (dzdx >> 16) & 0xffff;
3000    span[0].dzpix = ((dzdy_dz & 0x8000) ? ((~dzdy_dz) & 0x7fff) : dzdy_dz) + ((dzdx_dz & 0x8000) ? ((~dzdx_dz) & 0x7fff) : dzdx_dz);
3001    span[0].dzpix = normalize_dzpix(span[0].dzpix);
3002    dsdylod = dsdy >> 16;
3003    dtdylod = dtdy >> 16;
3004    if (dsdylod & 0x20000)
3005    {
3006        dsdylod = ~dsdylod & 0x1ffff;
3007    }
3008    if (dtdylod & 0x20000)
3009    {
3010        dtdylod = ~dtdylod & 0x1ffff;
3011    }
3012    span[0].dymax = (dsdylod > dtdylod)? dsdylod : dtdylod;
30133013
3014   xleft_inc = dxmdy >> 2;
3015   xright_inc = dxhdy >> 2;
3014    xleft_inc = dxmdy >> 2;
3015    xright_inc = dxhdy >> 2;
30163016
3017   xright = xh;
3018   xleft = xm;
3017    xright = xh;
3018    xleft = xm;
30193019
3020   limcvg = ((yl>>2) <= 1023) ? (yl>>2) : 1023; // Needed by 40 Winks
3021   if (limcvg < 0)
3022   {
3023      limcvg = 0;
3024   }
3020    limcvg = ((yl>>2) <= 1023) ? (yl>>2) : 1023; // Needed by 40 Winks
3021    if (limcvg < 0)
3022    {
3023        limcvg = 0;
3024    }
30253025
3026   startcvg = ((yh>>2)>=0) ? (yh>>2) : 0;
3027   for (k = startcvg; k <= limcvg; k++)
3028   {
3029      memset((void*)&span[k].cvg[0],0,640);
3030   }
3026    startcvg = ((yh>>2)>=0) ? (yh>>2) : 0;
3027    for (k = startcvg; k <= limcvg; k++)
3028    {
3029        memset((void*)&span[k].cvg[0],0,640);
3030    }
30313031
3032   sign_dxldy = (dxldy & 0x80000000) ? 1 : 0;
3033   sign_dxmdy = (dxmdy & 0x80000000) ? 1 : 0;
3034   samesign = !(sign_dxldy ^ sign_dxmdy);
3032    sign_dxldy = (dxldy & 0x80000000) ? 1 : 0;
3033    sign_dxmdy = (dxmdy & 0x80000000) ? 1 : 0;
3034    samesign = !(sign_dxldy ^ sign_dxmdy);
30353035
3036   sign_dxhdy = (dxhdy & 0x80000000) ? 1 : 0;
3036    sign_dxhdy = (dxhdy & 0x80000000) ? 1 : 0;
30373037
3038   do_offset = !(sign_dxhdy ^ (flip));
3038    do_offset = !(sign_dxhdy ^ (flip));
30393039
3040   if (do_offset)
3041   {
3042      dsdeh = dsde >> 9;   dsdyh = dsdy >> 9;
3043      dtdeh = dtde >> 9;   dtdyh = dtdy >> 9;
3044      dwdeh = dwde >> 9;   dwdyh = dwdy >> 9;
3045      drdeh = drde >> 9;   drdyh = drdy >> 9;
3046      dgdeh = dgde >> 9;   dgdyh = dgdy >> 9;
3047      dbdeh = dbde >> 9;   dbdyh = dbdy >> 9;
3048      dadeh = dade >> 9;   dadyh = dady >> 9;
3049      dzdeh = dzde >> 9;   dzdyh = dzdy >> 9;
3040    if (do_offset)
3041    {
3042        dsdeh = dsde >> 9;  dsdyh = dsdy >> 9;
3043        dtdeh = dtde >> 9;  dtdyh = dtdy >> 9;
3044        dwdeh = dwde >> 9;  dwdyh = dwdy >> 9;
3045        drdeh = drde >> 9;  drdyh = drdy >> 9;
3046        dgdeh = dgde >> 9;  dgdyh = dgdy >> 9;
3047        dbdeh = dbde >> 9;  dbdyh = dbdy >> 9;
3048        dadeh = dade >> 9;  dadyh = dady >> 9;
3049        dzdeh = dzde >> 9;  dzdyh = dzdy >> 9;
30503050
3051      dsdiff = (dsdeh*3 - dsdyh*3) << 7;
3052      dtdiff = (dtdeh*3 - dtdyh*3) << 7;
3053      dwdiff = (dwdeh*3 - dwdyh*3) << 7;
3054      drdiff = (drdeh*3 - drdyh*3) << 7;
3055      dgdiff = (dgdeh*3 - dgdyh*3) << 7;
3056      dbdiff = (dbdeh*3 - dbdyh*3) << 7;
3057      dadiff = (dadeh*3 - dadyh*3) << 7;
3058      dzdiff = (dzdeh*3 - dzdyh*3) << 7;
3059   }
3060   else
3061   {
3062      dsdiff = dtdiff = dwdiff = drdiff = dgdiff = dbdiff = dadiff = dzdiff = 0;
3063   }
3051        dsdiff = (dsdeh*3 - dsdyh*3) << 7;
3052        dtdiff = (dtdeh*3 - dtdyh*3) << 7;
3053        dwdiff = (dwdeh*3 - dwdyh*3) << 7;
3054        drdiff = (drdeh*3 - drdyh*3) << 7;
3055        dgdiff = (dgdeh*3 - dgdyh*3) << 7;
3056        dbdiff = (dbdeh*3 - dbdyh*3) << 7;
3057        dadiff = (dadeh*3 - dadyh*3) << 7;
3058        dzdiff = (dzdeh*3 - dzdyh*3) << 7;
3059    }
3060    else
3061    {
3062        dsdiff = dtdiff = dwdiff = drdiff = dgdiff = dbdiff = dadiff = dzdiff = 0;
3063    }
30643064
3065   if (do_offset)
3066   {
3067      dseoff = (dsdeh*3) << 7;
3068      dteoff = (dtdeh*3) << 7;
3069      dweoff = (dwdeh*3) << 7;
3070      dreoff = (drdeh*3) << 7;
3071      dgeoff = (dgdeh*3) << 7;
3072      dbeoff = (dbdeh*3) << 7;
3073      daeoff = (dadeh*3) << 7;
3074      dzeoff = (dzdeh*3) << 7;
3075   }
3076   else
3077   {
3078      dseoff = dteoff = dweoff = dreoff = dgeoff = dbeoff = daeoff = dzeoff = 0;
3079   }
3080#define adjust_deoff_only()      \
3081{                     \
3082         span[j].s = s + dseoff;            \
3083         span[j].t = t + dteoff;            \
3084         span[j].w = w + dweoff;            \
3085         span[j].r = r + dreoff;            \
3086         span[j].g = g + dgeoff;            \
3087         span[j].b = b + dbeoff;            \
3088         span[j].a = a + daeoff;            \
3089         span[j].z = z + dzeoff;            \
3065    if (do_offset)
3066    {
3067        dseoff = (dsdeh*3) << 7;
3068        dteoff = (dtdeh*3) << 7;
3069        dweoff = (dwdeh*3) << 7;
3070        dreoff = (drdeh*3) << 7;
3071        dgeoff = (dgdeh*3) << 7;
3072        dbeoff = (dbdeh*3) << 7;
3073        daeoff = (dadeh*3) << 7;
3074        dzeoff = (dzdeh*3) << 7;
3075    }
3076    else
3077    {
3078        dseoff = dteoff = dweoff = dreoff = dgeoff = dbeoff = daeoff = dzeoff = 0;
3079    }
3080#define adjust_deoff_only()     \
3081{                           \
3082            span[j].s = s + dseoff;             \
3083            span[j].t = t + dteoff;             \
3084            span[j].w = w + dweoff;             \
3085            span[j].r = r + dreoff;             \
3086            span[j].g = g + dgeoff;             \
3087            span[j].b = b + dbeoff;             \
3088            span[j].a = a + daeoff;             \
3089            span[j].z = z + dzeoff;             \
30903090}
30913091
30923092#define addleft(x) addleftcvg(x,k)
30933093#define addright(x) addrightcvg(x,k)
3094#define setvalues() {               \
3095         addvalues();            \
3096         adjust_attr();   \
3094#define setvalues() {                   \
3095            addvalues();                \
3096            adjust_attr();  \
30973097}
30983098
3099   dsdxh = dsdx >> 8;
3100   dtdxh = dtdx >> 8;
3101   dwdxh = dwdx >> 8;
3102   drdxh = drdx >> 8;
3103   dgdxh = dgdx >> 8;
3104   dbdxh = dbdx >> 8;
3105   dadxh = dadx >> 8;
3106   dzdxh = dzdx >> 8;
3099    dsdxh = dsdx >> 8;
3100    dtdxh = dtdx >> 8;
3101    dwdxh = dwdx >> 8;
3102    drdxh = drdx >> 8;
3103    dgdxh = dgdx >> 8;
3104    dbdxh = dbdx >> 8;
3105    dadxh = dadx >> 8;
3106    dzdxh = dzdx >> 8;
31073107
3108#define adjust_attr()      \
3109{                     \
3110         span[j].s.w = (s + dsdiff - (xfrac * dsdxh)) & ~0x1f;            \
3111         span[j].t.w = (t + dtdiff - (xfrac * dtdxh)) & ~0x1f;            \
3112         span[j].w.w = (w + dwdiff - (xfrac * dwdxh)) & ~0x1f;            \
3113         span[j].r.w = r + drdiff - (xfrac * drdxh);            \
3114         span[j].g.w = g + dgdiff - (xfrac * dgdxh);            \
3115         span[j].b.w = b + dbdiff - (xfrac * dbdxh);            \
3116         span[j].a.w = a + dadiff - (xfrac * dadxh);            \
3117         span[j].z.w = z + dzdiff - (xfrac * dzdxh);            \
3108#define adjust_attr()       \
3109{                           \
3110            span[j].s.w = (s + dsdiff - (xfrac * dsdxh)) & ~0x1f;               \
3111            span[j].t.w = (t + dtdiff - (xfrac * dtdxh)) & ~0x1f;               \
3112            span[j].w.w = (w + dwdiff - (xfrac * dwdxh)) & ~0x1f;               \
3113            span[j].r.w = r + drdiff - (xfrac * drdxh);             \
3114            span[j].g.w = g + dgdiff - (xfrac * dgdxh);             \
3115            span[j].b.w = b + dbdiff - (xfrac * dbdxh);             \
3116            span[j].a.w = a + dadiff - (xfrac * dadxh);             \
3117            span[j].z.w = z + dzdiff - (xfrac * dzdxh);             \
31183118}
31193119
3120#define adjust_diffonly()      \
3121{                     \
3122         span[j].s = s + dsdiff;            \
3123         span[j].t = t + dtdiff;            \
3124         span[j].w = w + dwdiff;            \
3125         span[j].r = r + drdiff;            \
3126         span[j].g = g + dgdiff;            \
3127         span[j].b = b + dbdiff;            \
3128         span[j].a = a + dadiff;            \
3129         span[j].z = z + dzdiff;            \
3120#define adjust_diffonly()       \
3121{                           \
3122            span[j].s = s + dsdiff;             \
3123            span[j].t = t + dtdiff;             \
3124            span[j].w = w + dwdiff;             \
3125            span[j].r = r + drdiff;             \
3126            span[j].g = g + dgdiff;             \
3127            span[j].b = b + dbdiff;             \
3128            span[j].a = a + dadiff;             \
3129            span[j].z = z + dzdiff;             \
31303130}
31313131
3132#define addvalues() {   \
3133         s += dsde;   \
3134         t += dtde;   \
3135         w += dwde; \
3136         r += drde; \
3137         g += dgde; \
3138         b += dbde; \
3139         a += dade; \
3140         z += dzde; \
3132#define addvalues() {   \
3133            s += dsde;  \
3134            t += dtde;  \
3135            w += dwde; \
3136            r += drde; \
3137            g += dgde; \
3138            b += dbde; \
3139            a += dade; \
3140            z += dzde; \
31413141}
31423142
3143#define justassign()      \
3144{                     \
3145         span[j].s = s & ~0x1f;            \
3146         span[j].t = t & ~0x1f;            \
3147         span[j].w = w & ~0x1f;            \
3148         span[j].r = r;            \
3149         span[j].g = g;            \
3150         span[j].b = b;            \
3151         span[j].a = a;            \
3152         span[j].z = z;            \
3143#define justassign()        \
3144{                           \
3145            span[j].s = s & ~0x1f;              \
3146            span[j].t = t & ~0x1f;              \
3147            span[j].w = w & ~0x1f;              \
3148            span[j].r = r;              \
3149            span[j].g = g;              \
3150            span[j].b = b;              \
3151            span[j].a = a;              \
3152            span[j].z = z;              \
31533153}
31543154
3155   m_inc = flip ? 1 : -1;
3155    m_inc = flip ? 1 : -1;
31563156
3157   ycur =   yh & ~3;
3158   ylfar = yl | 3;
3159   ldflag = (sign_dxhdy ^ flip) ? 0 : 3;
3160   yhpix = yh >> 2;
3161   ympix = ym >> 2;
3162   ylpix = yl >> 2;
3157    ycur =  yh & ~3;
3158    ylfar = yl | 3;
3159    ldflag = (sign_dxhdy ^ flip) ? 0 : 3;
3160    yhpix = yh >> 2;
3161    ympix = ym >> 2;
3162    ylpix = yl >> 2;
31633163
3164   for (k = ycur; k <= ylfar; k++)
3165   {
3166      if (k == ym)
3167      {
3168         xleft = xl;
3169         xleft_inc = dxldy >> 2;
3170      }
3164    for (k = ycur; k <= ylfar; k++)
3165    {
3166        if (k == ym)
3167        {
3168            xleft = xl;
3169            xleft_inc = dxldy >> 2;
3170        }
31713171
3172      xstart = xleft >> 16;
3173      xend = xright >> 16;
3174      j = k >> 2;
3175      spix = k & 3;
3172        xstart = xleft >> 16;
3173        xend = xright >> 16;
3174        j = k >> 2;
3175        spix = k & 3;
31763176
3177      if (k >= 0 && k < 0x1000)
3178      {
3179         int m = 0;
3180         int n = 0;
3181         int length = 0;
3182         min = 0; max = 3;
3183         if (j == yhpix)
3184         {
3185            min = yh & 3;
3186         }
3187         if (j == ylpix)
3188         {
3189            max = yl & 3;
3190         }
3191         if (spix >= min && spix <= max)
3192         {
3193            if (spix == min)
3194            {
3195               minxmx = maxxmx = xstart;
3196               minxhx = maxxhx = xend;
3197            }
3198            else
3199            {
3200               minxmx = (xstart < minxmx) ? xstart : minxmx;
3201               maxxmx = (xstart > maxxmx) ? xstart : maxxmx;
3202               minxhx = (xend < minxhx) ? xend : minxhx;
3203               maxxhx = (xend > maxxhx) ? xend : maxxhx;
3204            }
3205         }
3177        if (k >= 0 && k < 0x1000)
3178        {
3179            int m = 0;
3180            int n = 0;
3181            int length = 0;
3182            min = 0; max = 3;
3183            if (j == yhpix)
3184            {
3185                min = yh & 3;
3186            }
3187            if (j == ylpix)
3188            {
3189                max = yl & 3;
3190            }
3191            if (spix >= min && spix <= max)
3192            {
3193                if (spix == min)
3194                {
3195                    minxmx = maxxmx = xstart;
3196                    minxhx = maxxhx = xend;
3197                }
3198                else
3199                {
3200                    minxmx = (xstart < minxmx) ? xstart : minxmx;
3201                    maxxmx = (xstart > maxxmx) ? xstart : maxxmx;
3202                    minxhx = (xend < minxhx) ? xend : minxhx;
3203                    maxxhx = (xend > maxxhx) ? xend : maxxhx;
3204                }
3205            }
32063206
3207         if (spix == max)
3208         {
3209            if (flip)
3210            {
3211               span[j].lx = maxxmx;
3212               span[j].rx = minxhx;
3213            }
3214            else
3215            {
3216               span[j].lx = minxmx;
3217               span[j].rx = maxxhx;
3218            }
3219         }
3207            if (spix == max)
3208            {
3209                if (flip)
3210                {
3211                    span[j].lx = maxxmx;
3212                    span[j].rx = minxhx;
3213                }
3214                else
3215                {
3216                    span[j].lx = minxmx;
3217                    span[j].rx = maxxhx;
3218                }
3219            }
32203220
3221         length = flip ? (xstart - xend) : (xend - xstart);
3221            length = flip ? (xstart - xend) : (xend - xstart);
32223222
3223         if (spix == ldflag)
3224         {
3225            xfrac = ((xright >> 8) & 0xff);
3226            adjust_attr();
3227         }
3223            if (spix == ldflag)
3224            {
3225                xfrac = ((xright >> 8) & 0xff);
3226                adjust_attr();
3227            }
32283228
3229         m = flip ? (xend+1) : (xend-1);
3229            m = flip ? (xend+1) : (xend-1);
32303230
3231         if (k >= yh && length >= 0 && k <= yl)
3232         {
3233            if (xstart>=0 && xstart <1024)
3234            {
3235               if (!flip)
3236               {
3237                  span[j].cvg[xstart] += addleft(xleft);
3238               }
3239               else
3240               {
3241                  span[j].cvg[xstart] += addright(xleft);
3242               }
3243            }
3244            if (xend>=0 && xend<1024)
3245            {
3246               if (xstart != xend)
3247               {
3248                  if (!flip)
3249                  {
3250                     span[j].cvg[xend] += addright(xright);
3251                  }
3252                  else
3253                  {
3254                     span[j].cvg[xend] += addleft(xright);
3255                  }
3256               }
3257               else
3258               {
3259                  if (!flip)
3260                  {
3261                     span[j].cvg[xend] -= (2 - addright(xright));
3262                  }
3263                  else
3264                  {
3265                     span[j].cvg[xend] -= (2 - addleft(xright));
3266                  }
3267                  if (span[j].cvg[xend] > 200)
3268                  {
3269                     span[j].cvg[xend] = 0;
3270                  }
3271               }
3272            }
3273            for (n = 0; n < (length - 1); n++)
3274            {
3275               if (m>=0 && m < 640)
3276               {
3277                  span[j].cvg[m] += 2;
3278               }
3231            if (k >= yh && length >= 0 && k <= yl)
3232            {
3233                if (xstart>=0 && xstart <1024)
3234                {
3235                    if (!flip)
3236                    {
3237                        span[j].cvg[xstart] += addleft(xleft);
3238                    }
3239                    else
3240                    {
3241                        span[j].cvg[xstart] += addright(xleft);
3242                    }
3243                }
3244                if (xend>=0 && xend<1024)
3245                {
3246                    if (xstart != xend)
3247                    {
3248                        if (!flip)
3249                        {
3250                            span[j].cvg[xend] += addright(xright);
3251                        }
3252                        else
3253                        {
3254                            span[j].cvg[xend] += addleft(xright);
3255                        }
3256                    }
3257                    else
3258                    {
3259                        if (!flip)
3260                        {
3261                            span[j].cvg[xend] -= (2 - addright(xright));
3262                        }
3263                        else
3264                        {
3265                            span[j].cvg[xend] -= (2 - addleft(xright));
3266                        }
3267                        if (span[j].cvg[xend] > 200)
3268                        {
3269                            span[j].cvg[xend] = 0;
3270                        }
3271                    }
3272                }
3273                for (n = 0; n < (length - 1); n++)
3274                {
3275                    if (m>=0 && m < 640)
3276                    {
3277                        span[j].cvg[m] += 2;
3278                    }
32793279
3280               m += m_inc;
3281            }
3282         }
3283      }
3280                    m += m_inc;
3281                }
3282            }
3283        }
32843284
3285      if (spix == 3)
3286      {
3287         addvalues();
3288      }
3289      xleft += xleft_inc;
3290      xright += xright_inc;
3291   }
3285        if (spix == 3)
3286        {
3287            addvalues();
3288        }
3289        xleft += xleft_inc;
3290        xright += xright_inc;
3291    }
32923292
3293   switch (fb_size) // 8bpp needs to be implemented
3294   {
3295      case PIXEL_SIZE_16BIT:   render_spans_16(yh>>2, yl>>2, &tile[tilenum], shade, texture, zbuffer, flip); break;
3296      case PIXEL_SIZE_32BIT:   render_spans_32(yh>>2, yl>>2, &tile[tilenum], shade, texture, zbuffer, flip); break;
3297      default: break; // V-Rally2 does this, fb_size=0
3298   }
3293    switch (fb_size) // 8bpp needs to be implemented
3294    {
3295        case PIXEL_SIZE_16BIT:  render_spans_16(yh>>2, yl>>2, &tile[tilenum], shade, texture, zbuffer, flip); break;
3296        case PIXEL_SIZE_32BIT:  render_spans_32(yh>>2, yl>>2, &tile[tilenum], shade, texture, zbuffer, flip); break;
3297        default: break; // V-Rally2 does this, fb_size=0
3298    }
32993299}
33003300*/
33013301
src/mame/video/gottlieb.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "gottlieb.h"
8#include "includes/gottlieb.h"
99#include "machine/laserdsc.h"
1010#include "video/resnet.h"
1111
src/mame/video/ddragon.c
r6740r6741
4141***************************************************************************/
4242
4343#include "driver.h"
44#include "ddragon.h"
44#include "includes/ddragon.h"
4545
4646
4747/***************************************************************************
src/mame/video/asterix.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
44
55static int sprite_colorbase;
r6740r6741
88static int tilebanks[4];
99static int spritebanks[4];
1010
11static void reset_spritebank(void)
11static void reset_spritebank( running_machine *machine )
1212{
13   K053244_bankselect(0, spritebank & 7);
13   const device_config *k053244 = devtag_get_device(machine, "k053244");
14   k053244_bankselect(k053244, spritebank & 7);
1415   spritebanks[0] = (spritebank << 12) & 0x7000;
1516   spritebanks[1] = (spritebank <<  9) & 0x7000;
1617   spritebanks[2] = (spritebank <<  6) & 0x7000;
r6740r6741
2021WRITE16_HANDLER( asterix_spritebank_w )
2122{
2223   COMBINE_DATA(&spritebank);
23   reset_spritebank();
24   reset_spritebank(space->machine);
2425}
2526
26static void asterix_sprite_callback(int *code, int *color, int *priority_mask)
27void asterix_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask)
2728{
2829   int pri = (*color & 0x00e0) >> 2;
2930   if (pri <= layerpri[2])                        *priority_mask = 0;
r6740r6741
3536}
3637
3738
38static void asterix_tile_callback(int layer, int *code, int *color, int *flags)
39void asterix_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags)
3940{
4041   *flags = *code & 0x1000 ? TILE_FLIPX : 0;
4142   *color = (layer_colorbase[layer] + ((*code & 0xe000) >> 13)) & 0x7f;
4243   *code = (*code & 0x03ff) | tilebanks[(*code >> 10) & 3];
4344}
4445
45VIDEO_START( asterix )
46{
47   K053251_vh_start(machine);
48   K056832_vh_start(machine, "gfx1", K056832_BPP_4, 1, NULL, asterix_tile_callback, 1);
49   K053245_vh_start(machine,0, "gfx2",NORMAL_PLANE_ORDER, asterix_sprite_callback);
50
51   K053245_set_SpriteOffset(0,-3,-1);
52}
53
5446/* useful function to sort the three tile layers by priority order */
5547static void sortlayers(int *layer,int *pri)
5648{
r6740r6741
7062VIDEO_UPDATE( asterix )
7163{
7264   static const int K053251_CI[4] = { K053251_CI0, K053251_CI2, K053251_CI3, K053251_CI4 };
65   const device_config *k053244 = devtag_get_device(screen->machine, "k053244");
66   const device_config *k056832 = devtag_get_device(screen->machine, "k056832");
67   const device_config *k053251 = devtag_get_device(screen->machine, "k053251");
7368   int layer[3], plane, new_colorbase;
7469
7570   /* Layer offsets are different if horizontally flipped */
76   if (K056832_read_register(0x0) & 0x10)
71   if (k056832_read_register(k056832, 0x0) & 0x10)
7772   {
78      K056832_set_LayerOffset(0, 89-176, 0);
79      K056832_set_LayerOffset(1, 91-176, 0);
80      K056832_set_LayerOffset(2, 89-176, 0);
81      K056832_set_LayerOffset(3, 95-176, 0);
73      k056832_set_layer_offs(k056832, 0, 89 - 176, 0);
74      k056832_set_layer_offs(k056832, 1, 91 - 176, 0);
75      k056832_set_layer_offs(k056832, 2, 89 - 176, 0);
76      k056832_set_layer_offs(k056832, 3, 95 - 176, 0);
8277   }
8378   else
8479   {
85      K056832_set_LayerOffset(0, 89, 0);
86      K056832_set_LayerOffset(1, 91, 0);
87      K056832_set_LayerOffset(2, 89, 0);
88      K056832_set_LayerOffset(3, 95, 0);
80      k056832_set_layer_offs(k056832, 0, 89, 0);
81      k056832_set_layer_offs(k056832, 1, 91, 0);
82      k056832_set_layer_offs(k056832, 2, 89, 0);
83      k056832_set_layer_offs(k056832, 3, 95, 0);
8984   }
9085
9186
92   tilebanks[0] = (K056832_get_lookup(0) << 10);
93   tilebanks[1] = (K056832_get_lookup(1) << 10);
94   tilebanks[2] = (K056832_get_lookup(2) << 10);
95   tilebanks[3] = (K056832_get_lookup(3) << 10);
87   tilebanks[0] = (k056832_get_lookup(k056832, 0) << 10);
88   tilebanks[1] = (k056832_get_lookup(k056832, 1) << 10);
89   tilebanks[2] = (k056832_get_lookup(k056832, 2) << 10);
90   tilebanks[3] = (k056832_get_lookup(k056832, 3) << 10);
9691
9792   // update color info and refresh tilemaps
98   sprite_colorbase = K053251_get_palette_index(K053251_CI1);
93   sprite_colorbase = k053251_get_palette_index(k053251, K053251_CI1);
9994
100   for (plane=0; plane<4; plane++)
95   for (plane = 0; plane < 4; plane++)
10196   {
102      new_colorbase = K053251_get_palette_index(K053251_CI[plane]);
97      new_colorbase = k053251_get_palette_index(k053251, K053251_CI[plane]);
10398      if (layer_colorbase[plane] != new_colorbase)
10499      {
105100         layer_colorbase[plane] = new_colorbase;
106         K056832_mark_plane_dirty(plane);
101         k056832_mark_plane_dirty(k056832, plane);
107102      }
108103   }
109104
110105   layer[0] = 0;
111   layerpri[0] = K053251_get_priority(K053251_CI0);
106   layerpri[0] = k053251_get_priority(k053251, K053251_CI0);
112107   layer[1] = 1;
113   layerpri[1] = K053251_get_priority(K053251_CI2);
108   layerpri[1] = k053251_get_priority(k053251, K053251_CI2);
114109   layer[2] = 3;
115   layerpri[2] = K053251_get_priority(K053251_CI4);
110   layerpri[2] = k053251_get_priority(k053251, K053251_CI4);
116111
117112   sortlayers(layer, layerpri);
118113
119114   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
120115   bitmap_fill(bitmap, cliprect, 0);
121116
122   K056832_tilemap_draw(screen->machine, bitmap, cliprect, layer[0], 0, 1);
123   K056832_tilemap_draw(screen->machine, bitmap, cliprect, layer[1], 0, 2);
124   K056832_tilemap_draw(screen->machine, bitmap, cliprect, layer[2], 0, 4);
117   k056832_tilemap_draw(k056832, bitmap, cliprect, layer[0], 0, 1);
118   k056832_tilemap_draw(k056832, bitmap, cliprect, layer[1], 0, 2);
119   k056832_tilemap_draw(k056832, bitmap, cliprect, layer[2], 0, 4);
125120
126121/* this isn't supported anymore and it is unsure if still needed; keeping here for reference
127122    pdrawgfx_shadow_lowpri = 1; fix shadows in front of feet */
128   K053245_sprites_draw(screen->machine, 0, bitmap, cliprect);
123   k053245_sprites_draw(k053244, bitmap, cliprect);
129124
130   K056832_tilemap_draw(screen->machine, bitmap, cliprect, 2, 0, 0);
125   k056832_tilemap_draw(k056832, bitmap, cliprect, 2, 0, 0);
131126   return 0;
132127}
src/mame/video/homedata.c
r6740r6741
11#include "driver.h"
22#include "cpu/m6809/m6809.h"
3#include "homedata.h"
3#include "includes/homedata.h"
44
55/*
66    video control registers:
src/mame/video/exidy.c
r6740r6741
66
77#include "driver.h"
88#include "deprecat.h"
9#include "exidy.h"
9#include "includes/exidy.h"
1010
1111
1212UINT8 *exidy_videoram;
src/mame/video/hyhoo.c
r6740r6741
77******************************************************************************/
88
99#include "driver.h"
10#include "nb1413m3.h"
10#include "includes/nb1413m3.h"
1111
1212
1313UINT8 *hyhoo_clut;
src/mame/video/hng64.c
r6740r6741
11#include "driver.h"
2#include "hng64.h"
2#include "includes/hng64.h"
33
44#include <math.h>
55#include "drawgfxm.h"
r6740r6741
3333
3434UINT8 hng64_screen_dis;
3535
36// 3d memory and prototypes
37#define MAX_ONSCREEN_POLYS (10000)
38struct polyVert
39{
40   float worldCoords[4];   // World space coordinates (X Y Z 1.0)
41
42   float texCoords[4];      // Texture coordinates (U V 0 1.0) -> OpenGL style...
43
44   float normal[4];      // Normal (X Y Z 1.0)
45   float clipCoords[4];   // Homogeneous screen space coordinates (X Y Z W)
46
47   float light[3];         // The intensity of the illumination at this point
48};
49
50struct polygon
51{
52   int n;                  // Number of sides
53   struct polyVert vert[10];   // Vertices (maximum number per polygon is 10 -> 3+6)
54
55   float faceNormal[4];      // Normal of the face overall - for calculating visibility and flat-shading...
56   int visible;            // Polygon visibility in scene
57
58   INT8 texIndex;            // Which texture to draw from (0x00-0x0f)
59   INT8 texType;            // How to index into the texture
60   UINT8 palIndex;            // Which palette to use when rasterizing
61};
62
36// 3d display buffers
37// (Temporarily global - someday they will live with the proper bit-depth in the memory map)
6338static float* depthBuffer3d;
6439static UINT32* colorBuffer3d;
65static struct polygon *polys;
66static void draw3d(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect);
40static void clear3d(running_machine *machine);   // TODO: Inline
6741
6842
69
7043static void hng64_mark_all_tiles_dirty( int tilemap )
7144{
7245   if (tilemap == 0)
r6740r6741
390363
391364//      if (((source[2] & 0xffff0000) >> 16) == 0x0001)
392365//      {
393//          usrintf_showmessage("T %.8x %.8x %.8x %.8x %.8x", source[0], source[1], source[2], source[3], source[4]);
394//          // usrintf_showmessage("T %.8x %.8x %.8x %.8x %.8x", source[0], source[1], source[2], source[3], source[4]);
366//          popmessage("T %.8x %.8x %.8x %.8x %.8x", source[0], source[1], source[2], source[3], source[4]);
367//          // popmessage("T %.8x %.8x %.8x %.8x %.8x", source[0], source[1], source[2], source[3], source[4]);
395368//      }
396369
397370      for(ydrw=0;ydrw<=chainy;ydrw++)
r6740r6741
15211494   if (hng64_mcu_type != RACING_MCU) // disable on racing games until it stops crashing MAME!
15221495   {
15231496      int x, y;
1524      draw3d(screen->machine, bitmap, cliprect);
15251497
15261498      // Blit the color buffer into the primary bitmap
15271499      for (y = cliprect->min_y; y <= cliprect->max_y; y++)
r6740r6741
15381510            src++;
15391511         }
15401512      }
1513      //printf("\n");   /* Debug - ajg */
1514      clear3d(screen->machine);
15411515   }
15421516
15431517   if(0)
r6740r6741
15481522
15491523   if (0)
15501524    popmessage("%08x %08x TR(%04x %04x %04x %04x) SB(%04x %04x %04x %04x) %08x %08x %08x %08x %08x AA(%08x %08x) %08x %08x",
1551    hng64_videoregs[0x00],
1552    hng64_videoregs[0x01],
1525    hng64_videoregs[0x00],
1526     hng64_videoregs[0x01],
15531527    (hng64_videoregs[0x02]>>16)&0xf9ff, // bits we're sure about are masked out
15541528    (hng64_videoregs[0x02]>>0)&0xf9ff,
15551529    (hng64_videoregs[0x03]>>16)&0xf9ff,
r6740r6741
15581532    (hng64_videoregs[0x04]>>0)&0xffff,
15591533    (hng64_videoregs[0x05]>>16)&0xffff,
15601534    (hng64_videoregs[0x05]>>0)&0xffff,
1561    hng64_videoregs[0x06],
1562    hng64_videoregs[0x07],
1563    hng64_videoregs[0x08],
1564    hng64_videoregs[0x09],
1565    hng64_videoregs[0x0a],
1566    hng64_videoregs[0x0b],
1567    hng64_videoregs[0x0c],
1568    hng64_videoregs[0x0d],
1569    hng64_videoregs[0x0e]);
1535     hng64_videoregs[0x06],
1536     hng64_videoregs[0x07],
1537     hng64_videoregs[0x08],
1538     hng64_videoregs[0x09],
1539     hng64_videoregs[0x0a],
1540     hng64_videoregs[0x0b],
1541     hng64_videoregs[0x0c],
1542     hng64_videoregs[0x0d],
1543     hng64_videoregs[0x0e]);
15701544
15711545   if (0)
15721546   popmessage("3D: %08x %08x %08x %08x : %08x %08x %08x %08x : %08x %08x %08x %08x",
r6740r6741
16621636   tilemap_set_transparent_pen(hng64_tilemap3_16x16,0);
16631637   tilemap_set_transparent_pen(hng64_tilemap3_16x16_alt,0);
16641638
1665   // debug switch, turn on / off additive blending on a per-tilemap basis
1639   // Debug switch, turn on / off additive blending on a per-tilemap basis
16661640   additive_tilemap_debug = 0;
16671641
16681642   // 3d Buffer Allocation
16691643   depthBuffer3d = auto_alloc_array(machine, float,  (visarea->max_x)*(visarea->max_y));
16701644   colorBuffer3d = auto_alloc_array(machine, UINT32, (visarea->max_x)*(visarea->max_y));
1671
1672   // The general display list of polygons in the scene...
1673   polys = auto_alloc_array(machine, struct polygon, MAX_ONSCREEN_POLYS);
16741645}
16751646
16761647
r6740r6741
16791650///////////////
16801651UINT32 hng64_dls[2][0x81];
16811652
1682static float uToF(UINT16 input);
1653// 3d State
1654static int paletteState3d = 0x00;
1655static float projectionMatrix[16];
1656static float modelViewMatrix[16];
1657static float cameraMatrix[16];
16831658
1659struct polyVert
1660{
1661   float worldCoords[4];   // World space coordinates (X Y Z 1.0)
1662
1663   float texCoords[4];      // Texture coordinates (U V 0 1.0) -> OpenGL style...
1664
1665   float normal[4];      // Normal (X Y Z 1.0)
1666   float clipCoords[4];   // Homogeneous screen space coordinates (X Y Z W)
1667
1668   float light[3];         // The intensity of the illumination at this point
1669};
1670
1671struct polygon
1672{
1673   int n;                  // Number of sides
1674   struct polyVert vert[10];   // Vertices (maximum number per polygon is 10 -> 3+6)
1675
1676   float faceNormal[4];      // Normal of the face overall - for calculating visibility and flat-shading...
1677   int visible;            // Polygon visibility in scene
1678
1679   INT8 texIndex;            // Which texture to draw from (0x00-0x0f)
1680   INT8 texType;            // How to index into the texture
1681   UINT8 palIndex;            // Which palette to use when rasterizing
1682};
1683
16841684static void setIdentity(float *matrix);
16851685static void matmul4(float *product, const float *a, const float *b);
16861686static void vecmatmul4(float *product, const float *a, const float *b);
r6740r6741
16881688//static void normalize(float* x);
16891689
16901690static void performFrustumClip(struct polygon *p);
1691static void drawShaded(running_machine *machine, struct polygon *p, bitmap_t *bitmap);
1691static void drawShaded(running_machine *machine, struct polygon *p);
16921692//static void plot(INT32 x, INT32 y, INT32 color, bitmap_t *bitmap);
16931693//static void drawline2d(INT32 x0, INT32 y0, INT32 x1, INT32 y1, INT32 color, bitmap_t *bitmap);
16941694//static void DrawWireframe(struct polygon *p, bitmap_t *bitmap);
16951695
1696#define WORD_AT(BUFFER,OFFSET) ( (BUFFER[OFFSET] << 8) | BUFFER[OFFSET+1] )
1696static float uToF(UINT16 input);
16971697
1698/* 3D/framebuffer video registers
1699 * ------------------------------
1700 *
1701 * UINT32 | Bits                                    | Use
1702 *        | 3322 2222 2222 1111 1111 11             |
1703 * -------+-1098-7654-3210-9876-5432-1098-7654-3210-+----------------
1704 *      0 | ???? ???? ???? ???? ccc? ???? ???? ???? | framebuffer color base, 0x311800 in Fatal Fury WA, 0x313800 in Buriki One
1705 *      1 |                                         |
1706 *      2 | ???? ???? ???? ???? ???? ???? ???? ???? | camera / framebuffer global x/y? Actively used by Samurai Shodown 64 2
1707 *      3 | ---- --?x ---- ---- ---- ---- ---- ---- | unknown, unsetted by Buriki One and setted by Fatal Fury WA, buffering mode?
1708 *   4-11 | ---- ???? ---- ???? ---- ???? ---- ???? | Table filled with 0x0? data
1709 *
1710 */
1711static void draw3d(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
1712{
1713   int i,j,k,l,m;
17141698
1715   float projectionMatrix[16];
1716   float modelViewMatrix[16];
1717   float cameraMatrix[16];
1718   float objectMatrix[16];
1699////////////////////
1700// 3d 'Functions' //
1701////////////////////
17191702
1720   int paletteState = 0x00;
1703// Operation 0001
1704// Camera transformation.
1705static void setCameraTransformation(const UINT16* packet)
1706{
1707   /*//////////////
1708    // PACKET FORMAT
1709    // [0]  - 0001 ... ID
1710    // [1]  - xxxx ... Extrinsic camera matrix
1711    // [2]  - xxxx ... Extrinsic camera matrix
1712    // [3]  - xxxx ... Extrinsic camera matrix
1713    // [4]  - xxxx ... Extrinsic camera matrix
1714    // [5]  - xxxx ... Extrinsic camera matrix
1715    // [6]  - xxxx ... Extrinsic camera matrix
1716    // [7]  - xxxx ... Extrinsic camera matrix
1717    // [8]  - xxxx ... Extrinsic camera matrix
1718    // [9]  - xxxx ... Extrinsic camera matrix
1719    // [10] - xxxx ... Extrinsic camera matrix
1720    // [11] - xxxx ... Extrinsic camera matrix
1721    // [12] - xxxx ... Extrinsic camera matrix
1722    // [13] - ???? ... ? Flips per-frame during fatfurwa 'HNG64'
1723    // [14] - ???? ... ? Could be some floating-point values during buriki 'door run'
1724    // [15] - ???? ... ? Same as 13 & 14
1725    ////////////*/
1726   // CAMERA TRANSFORMATION MATRIX
1727   cameraMatrix[0]  = uToF(packet[1]);
1728   cameraMatrix[4]  = uToF(packet[2]);
1729   cameraMatrix[8]  = uToF(packet[3]);
1730   cameraMatrix[3]  = 0.0f;
17211731
1722   UINT32 numPolys = 0;
1732   cameraMatrix[1]  = uToF(packet[4]);
1733   cameraMatrix[5]  = uToF(packet[5]);
1734   cameraMatrix[9]  = uToF(packet[6]);
1735   cameraMatrix[7]  = 0.0f;
17231736
1724   struct polygon lastPoly = { 0 };
1725   const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen);
1737   cameraMatrix[2]  = uToF(packet[7]);
1738   cameraMatrix[6]  = uToF(packet[8]);
1739   cameraMatrix[10] = uToF(packet[9]);
1740   cameraMatrix[11] = 0.0f;
17261741
1727   // Set some matrices to the identity...
1728   setIdentity(projectionMatrix);
1729   setIdentity(modelViewMatrix);
1730   setIdentity(cameraMatrix);
1731   setIdentity(objectMatrix);
1742   cameraMatrix[12] = uToF(packet[10]);
1743   cameraMatrix[13] = uToF(packet[11]);
1744   cameraMatrix[14] = uToF(packet[12]);
1745   cameraMatrix[15] = 1.0f;
1746}
17321747
1733   // Display list 2 comes after display list 1.  Go figure.
1734   for (j = 1; j >= 0; j--)
1735   {
1736      UINT32 *workingList = hng64_dls[j];
1748// Operation 0011
1749// Palette / Model flags?
1750static void set3dFlags(const UINT16* packet)
1751{
1752   /*//////////////
1753    // PACKET FORMAT
1754    // [0]  - 0011 ... ID
1755    // [1]  - ???? ...
1756    // [2]  - ???? ...
1757    // [3]  - ???? ...
1758    // [4]  - ???? ...
1759    // [5]  - ???? ...
1760    // [6]  - ???? ... ? Flip & flop around like mad during fatfurwa intro
1761    // [7]  - ???? ... ? Flip & flop around like mad during fatfurwa intro
1762    // [8]  - xx?? ... Palette offset & ??
1763    // [9]  - ???? ... ? Very much used - seem to bounce around when characters are on screen
1764    // [10] - ???? ... ? ''  ''
1765    // [11] - ???? ... ? ''  ''
1766    // [12] - ???? ... ? ''  ''
1767    // [13] - ???? ... ? ''  ''
1768    // [14] - ???? ... ? ''  ''
1769    // [15] - ???? ... ? ''  ''
1770    ////////////*/
1771   paletteState3d  = (packet[8] & 0xff00) >> 8;
1772   paletteState3d += ((hng64_3dregs[0x00/4] & 0x2000) >> 9); /* Palette is + 0x0800 in buriki. */
1773   /* FIXME: Buriki One door colors in attract mode still aren't quite right, investigate... */
1774}
17371775
1738      for (i = 0; i < 0x80; i += 0x08)
1739      {
1740         float left, right, top, bottom, near_, far_;
1741         UINT8 *threeDRoms;
1742         UINT8 *threeDPointer;
1743         UINT32 threeDOffset;
1744         UINT32 size[4];
1745         UINT32 address[4];
1746         UINT32 megaOffset;
1747         float eyeCoords[4];         // objectCoords transformed by the modelViewMatrix
1748         // float clipCoords[4];     // eyeCoords transformed by the projectionMatrix
1749         float ndCoords[4];         // normalized device coordinates/clipCoordinates (x/w, y/w, z/w)
1750         float windowCoords[4];      // mapped ndCoordinates to screen space
1751         float cullRay[4];
1776// Operation 0012
1777// Projection Matrix.
1778static void setCameraProjectionMatrix(const UINT16* packet)
1779{
1780   /*//////////////
1781    // PACKET FORMAT
1782    // [0]  - 0012 ... ID
1783    // [1]  - ???? ... ? Contains a value in buriki's 'how to play' - probably a projection window/offset.
1784    // [2]  - ???? ... ? Contains a value in buriki's 'how to play' - probably a projection window/offset.
1785    // [3]  - ???? ... ? Contains a value
1786    // [4]  - ???? ... ? Contains a value in buriki
1787    // [5]  - ???? ... ? Contains a value
1788    // [6]  - xxxx ... camera projection near
1789    // [7]  - xxxx ... camera projection far
1790    // [8]  - ???? ... ? Contains a value
1791    // [9]  - ???? ... ? Contains a value
1792    // [10] - xxxx ... camera projection right
1793    // [11] - xxxx ... camera projection left
1794    // [12] - xxxx ... camera projection top
1795    // [13] - xxxx ... camera projection bottom
1796    // [14] - ???? ... ? Gets data during buriki door-run
1797    // [15] - ???? ... ? Gets data during buriki door-run
1798    ////////////*/
17521799
1753         // Debug...
1754//          mame_printf_debug("Element %.2d (%d) : %.8x %.8x %.8x %.8x %.8x %.8x %.8x %.8x\n", i/0x08, j,
1755//                             (UINT32)hng64_dls[j][i+0], (UINT32)hng64_dls[j][i+1],
1756//                             (UINT32)hng64_dls[j][i+2], (UINT32)hng64_dls[j][i+3],
1757//                             (UINT32)hng64_dls[j][i+4], (UINT32)hng64_dls[j][i+5],
1758//                             (UINT32)hng64_dls[j][i+6], (UINT32)hng64_dls[j][i+7]);
1800   // This packet changes when fatfurwa 'How to play' is on the screen.
1801   // Not too much, but if this is right, the aspect ratio is different...
17591802
1760         // Depending on what the initial flags are, do sumthin'...
1761         switch((workingList[i+0] & 0xffff0000) >> 16)
1762         {
1763         case 0x0012:
1764            // UNKNOWN - seems an awful lot parameters for a projection matrix though...
1803   // Heisted from GLFrustum - 6 parameters...
1804   float left, right, top, bottom, near_, far_;
17651805
1766            ;
1806   left    = uToF(packet[11]);
1807   right   = uToF(packet[10]);
1808   top     = uToF(packet[12]);
1809   bottom  = uToF(packet[13]);
1810   near_   = uToF(packet[6]);
1811   far_    = uToF(packet[7]);
17671812
1768            // It changes when 'How to play' is on the screen...  not too much, but if this is right, the aspect
1769            // ratio is different...
1813   projectionMatrix[0]  = (2.0f*near_)/(right-left);
1814   projectionMatrix[1]  = 0.0f;
1815   projectionMatrix[2]  = 0.0f;
1816   projectionMatrix[3]  = 0.0f;
17701817
1771            // Heisted from GLFrustum - 6 parameters...
1772            left   = uToF( workingList[i+5] & 0x0000ffff);
1773            right  = uToF((workingList[i+5] & 0xffff0000) >> 16);
1774            top    = uToF((workingList[i+6] & 0xffff0000) >> 16);
1775            bottom = uToF( workingList[i+6] & 0x0000ffff);
1776            near_   = uToF((workingList[i+3] & 0xffff0000) >> 16);
1777            far_    = uToF( workingList[i+3] & 0x0000ffff);
1818   projectionMatrix[4]  = 0.0f;
1819   projectionMatrix[5]  = (2.0f*near_)/(top-bottom);
1820   projectionMatrix[6]  = 0.0f;
1821   projectionMatrix[7]  = 0.0f;
17781822
1779            // It's almost .always. these values in fatfurwa...
1780            // 0.070313    0.000000 [0]     (scaled by 128)
1781            // 0.000000   10.000000 [1]
1782            // 0.000000    0.500000 [2]
1783            // 2.000000   11.062500 [3]
1784            // 10.000000  11.000000 [4]
1785            // 1.000000   -1.000000 [5]
1786            // 0.875000   -0.875000 [6]
1787            // 0.000000    0.000000 [7]
1823   projectionMatrix[8]  = (right+left)/(right-left);
1824   projectionMatrix[9]  = (top+bottom)/(top-bottom);
1825   projectionMatrix[10] = -((far_+near_)/(far_-near_));
1826   projectionMatrix[11] = -1.0f;
17881827
1789            projectionMatrix[0]  = (2.0f*near_)/(right-left);
1790            projectionMatrix[1]  = 0.0f;
1791            projectionMatrix[2]  = 0.0f;
1792            projectionMatrix[3]  = 0.0f;
1828   projectionMatrix[12] = 0.0f;
1829   projectionMatrix[13] = 0.0f;
1830   projectionMatrix[14] = -((2.0f*far_*near_)/(far_-near_));
1831   projectionMatrix[15] = 0.0f;
1832}
17931833
1794            projectionMatrix[4]  = 0.0f;
1795            projectionMatrix[5]  = (2.0f*near_)/(top-bottom);
1796            projectionMatrix[6]  = 0.0f;
1797            projectionMatrix[7]  = 0.0f;
1834// Operation 0100
1835// Polygon rasterization.
1836void recoverPolygonBlock(running_machine* machine, const UINT16* packet, struct polygon* polys, int* numPolys)
1837{
1838   /*//////////////
1839    // PACKET FORMAT
1840    // [0]  - 0100 ... ID
1841    // [1]  - xxxx ... Flags for sure (0118 for buriki characters,
1842    //                                 0010 for buriki door,
1843    //                                 0110 for fatfurwa hng64,
1844    //                                 0118|0108 for fatfurwa building intro,
1845    //                                 0118|0108 for fatfurwa fighters infight,
1846    //                                 0108->0118 for fatfurwa globe (transitions when players are selected,
1847    //                                 00d8 for segfaulting geo in xrally & roadedge)
1848    //                                (00!0 is thought to be for lighting maybe?)
1849    // [2]  - xxxx ... offset into ROM
1850    // [3]  - xxxx ... offset into ROM
1851    // [4]  - xxxx ... Transformation matrix
1852    // [5]  - xxxx ... Transformation matrix
1853    // [6]  - xxxx ... Transformation matrix
1854    // [7]  - xxxx ... Transformation matrix
1855    // [8]  - xxxx ... Transformation matrix
1856    // [9]  - xxxx ... Transformation matrix
1857    // [10] - xxxx ... Transformation matrix
1858    // [11] - xxxx ... Transformation matrix
1859    // [12] - xxxx ... Transformation matrix
1860    // [13] - ???? ... Transformation matrix
1861    // [14] - ???? ... Transformation matrix
1862    // [15] - ???? ... Transformation matrix
1863    ////////////*/
1864   int k, l, m;
17981865
1799            projectionMatrix[8]  = (right+left)/(right-left);
1800            projectionMatrix[9]  = (top+bottom)/(top-bottom);
1801            projectionMatrix[10] = -((far_+near_)/(far_-near_));
1802            projectionMatrix[11] = -1.0f;
1866   UINT32  tempDWord;
1867   UINT32  threeDOffset;
1868   UINT16* threeDRoms;
1869   UINT16* threeDPointer;
18031870
1804            projectionMatrix[12] = 0.0f;
1805            projectionMatrix[13] = 0.0f;
1806            projectionMatrix[14] = -((2.0f*far_*near_)/(far_-near_));
1807            projectionMatrix[15] = 0.0f;
1871   UINT32 size[4];
1872   UINT32 address[4];
1873   UINT32 megaOffset;
1874   float eyeCoords[4];         // ObjectCoords transformed by the modelViewMatrix
1875   // float clipCoords[4];     // EyeCoords transformed by the projectionMatrix
1876   float ndCoords[4];         // Normalized device coordinates/clipCoordinates (x/w, y/w, z/w)
1877   float windowCoords[4];      // Mapped ndCoordinates to screen space
1878   float cullRay[4];
18081879
1809            /*
1810                int xxx;
1811                for (xxx = 0; xxx < 16; xxx++)
1812                    mame_printf_debug("%f ", projectionMatrix[xxx]);
1813                mame_printf_debug("\n");
1880   float objectMatrix[16];
1881   struct polygon lastPoly = { 0 };
18141882
1815                mame_printf_debug("Vars   : %f %f %f %f %f %f\n", left, right, top, bottom, near, far);
1816                mame_printf_debug("Camera : %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n",
1817                                 uToF((workingList[i+0] & 0xffff0000) >> 16)*128, uToF( workingList[i+0] & 0x0000ffff)*128,
1818                                 uToF((workingList[i+1] & 0xffff0000) >> 16)*128, uToF( workingList[i+1] & 0x0000ffff)*128,
1883   const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen);
18191884
1820                                 uToF((workingList[i+2] & 0xffff0000) >> 16)*128, uToF( workingList[i+2] & 0x0000ffff)*128,
1821                                 uToF((workingList[i+3] & 0xffff0000) >> 16)*128, uToF( workingList[i+3] & 0x0000ffff)*128,
1885   // GEOMETRY
1886   setIdentity(objectMatrix);
18221887
1823                                 uToF((workingList[i+4] & 0xffff0000) >> 16)*128, uToF( workingList[i+4] & 0x0000ffff)*128,
1824                                 uToF((workingList[i+5] & 0xffff0000) >> 16)*128, uToF( workingList[i+5] & 0x0000ffff)*128,
1888   /////////////////
1889   // HEADER INFO //
1890   /////////////////
18251891
1826                                 uToF((workingList[i+6] & 0xffff0000) >> 16)*128, uToF( workingList[i+6] & 0x0000ffff)*128,
1827                                 uToF((workingList[i+7] & 0xffff0000) >> 16)*128, uToF( workingList[i+7] & 0x0000ffff)*128);
1828                */
1892   // 3d ROM Offset
1893   tempDWord = (((UINT32)packet[2]) << 16) | ((UINT32)packet[3]);
1894   threeDOffset = tempDWord & 0xffffffff;
18291895
1830            break;
1896   threeDRoms = (UINT16*)(memory_region(machine, "verts"));
1897   threeDPointer = &threeDRoms[threeDOffset * 3];
18311898
1832         case 0x0001:
1833            // CAMERA TRANSFORMATION MATRIX
1834            cameraMatrix[0]  = uToF( workingList[i+0] & 0x0000ffff);
1835            cameraMatrix[4]  = uToF((workingList[i+1] & 0xffff0000) >> 16);
1836            cameraMatrix[8]  = uToF( workingList[i+1] & 0x0000ffff);
1837            cameraMatrix[3]  = 0.0f;
1899   // Debug - ajg
1900   /*
1901    printf("%08x : ", tempDWord*3*2);
1902    for (k = 0; k < 7*3; k++)
1903    {
1904        printf("%04x ", threeDPointer[k]);
1905        if ((k % 3) == 2) printf(" ");
1906    }
1907    printf("\n");
1908    */
18381909
1839            cameraMatrix[1]  = uToF((workingList[i+2] & 0xffff0000) >> 16);
1840            cameraMatrix[5]  = uToF( workingList[i+2] & 0x0000ffff);
1841            cameraMatrix[9]  = uToF((workingList[i+3] & 0xffff0000) >> 16);
1842            cameraMatrix[7]  = 0.0f;
1910   //////////////////////////////////////
1911   // THE OBJECT TRANSFORMATION MATRIX //
1912   //////////////////////////////////////
1913   objectMatrix[8] = uToF(packet[7]);
1914   objectMatrix[4] = uToF(packet[8]);
1915   objectMatrix[0] = uToF(packet[9]);
1916   objectMatrix[3] = 0.0f;
18431917
1844            cameraMatrix[2]  = uToF( workingList[i+3] & 0x0000ffff);
1845            cameraMatrix[6]  = uToF((workingList[i+4] & 0xffff0000) >> 16);
1846            cameraMatrix[10] = uToF( workingList[i+4] & 0x0000ffff);
1847            cameraMatrix[11] = 0.0f;
1918   objectMatrix[9] = uToF(packet[10]);
1919   objectMatrix[5] = uToF(packet[11]);
1920   objectMatrix[1] = uToF(packet[12]);
1921   objectMatrix[7] = 0.0f;
18481922
1849            cameraMatrix[12] = uToF((workingList[i+5] & 0xffff0000) >> 16);
1850            cameraMatrix[13] = uToF( workingList[i+5] & 0x0000ffff);
1851            cameraMatrix[14] = uToF((workingList[i+6] & 0xffff0000) >> 16);
1852            cameraMatrix[15] = 1.0f;
1853            break;
1923   objectMatrix[10] = uToF(packet[13]);
1924   objectMatrix[6 ] = uToF(packet[14]);
1925   objectMatrix[2 ] = uToF(packet[15]);
1926   objectMatrix[11] = 0.0f;
18541927
1855         case 0x0010:
1856            // UNKNOWN - light maybe
1857            break;
1928   objectMatrix[12] = uToF(packet[4]);
1929   objectMatrix[13] = uToF(packet[5]);
1930   objectMatrix[14] = uToF(packet[6]);
1931   objectMatrix[15] = 1.0f;
18581932
1859         case 0x0011:
1860            // Model Flags?
1861            // 00110000 00000000 00000100 01000100 0400-0000 00007fff 00000000 00000020
1862            // ----                                pal  ---- -------- -------- -------- not used (known)
1863            paletteState = (workingList[i+4] & 0xff000000) >> 24;
1864            paletteState+=((hng64_3dregs[0x00/4] & 0x2000) >> 9); //framebuffer base color reg? Used by Buriki One
1865            /* FIXME: Buriki One door colors in attract mode still aren't quite right, investigate... */
1866            break;
18671933
1868         case 0x0100:
1869            // GEOMETRY
1870            ;
1934   //////////////////////////////////////////////////////////
1935   // EXTRACT DATA FROM THE ADDRESS POINTED TO IN THE FILE //
1936   //////////////////////////////////////////////////////////
1937   /*//////////////////////////////////////////////
1938    // DIRECTLY-POINTED-TO FORMAT (7 words x 3 ROMs)
1939    // [0]  - lower word of sub-address 1
1940    // [1]  - lower word of sub-address 2
1941    // [2]  - upper word of all sub-addresses
1942    // [3]  - lower word of sub-address 3
1943    // [4]  - lower word of sub-address 4
1944    // [5]  - ???? always 0 ????
1945    // [6]  - number of triangles in sub-address 1 block
1946    // [7]  - number of triangles in sub-address 2 block
1947    // [8]  - ???? always 0 ????
1948    // [9]  - number of triangles in sub-address 3 block
1949    // [10] - number of triangles in sub-address 4 block
1950    // [11] - ? definitely used.
1951    // [12] - ? definitely used.
1952    // [13] - ? definitely used.
1953    // [14] - ? definitely used.
1954    // [15] - ???? always 0 ????
1955    // [16] - ???? always 0 ????
1956    // [17] - ???? always 0 ????
1957    // [18] - ???? always 0 ????
1958    // [19] - ???? always 0 ????
1959    // [20] - ???? always 0 ????
1960    //////////////////////////////////////////////*/
18711961
1872            threeDRoms = memory_region(machine, "verts");
1962   // There are 4 hunks per address.
1963   address[0] = threeDPointer[0];
1964   address[1] = threeDPointer[1];
1965   megaOffset = threeDPointer[2];
18731966
1874            /////////////////////////
1875            // GET THE HEADER INFO //
1876            /////////////////////////
1967   address[2] = threeDPointer[3];
1968   address[3] = threeDPointer[4];
1969   if (threeDPointer[5] != 0x0000) printf("ZOMG!  3dPointer[5] is non-zero!\n");
18771970
1878            // 3d ROM Offset
1879            // !!! This might be more than just 20 bits...
1880            threeDOffset = workingList[i+1] & 0x000fffff;
1881            threeDOffset = (threeDOffset<<1) * 3;
1971   size[0]    = threeDPointer[6];
1972   size[1]    = threeDPointer[7];
1973   if (threeDPointer[8] != 0x0000) printf("ZOMG!  3dPointer[8] is non-zero!\n");
18821974
1883            threeDPointer = &threeDRoms[threeDOffset];
1975   size[2]    = threeDPointer[9];
1976   size[3]    = threeDPointer[10];
1977   /*           ????         [11]; Used. */
18841978
1979   /*           ????         [12]; Used. */
1980   /*           ????         [13]; Used. */
1981   /*           ????         [14]; Used. */
18851982
1886            // 66 byte versus 48 byte chunk flag
1887            //    WRONG !  I think it's something to do with lighting...
1888            //    it's 0 for the 66-byte lit globe in the character select and 0 for something in terry's hand...
1889            // if (workingList[i+0] & 0x00000010)
1983   /*           ????         [15]; Used? */
1984   /*           ????         [16]; Used? */
1985   /*           ????         [17]; Used? */
18901986
1987   /*           ????         [18]; Used? */
1988   /*           ????         [19]; Used? */
1989   /*           ????         [20]; Used? */
18911990
1892            //////////////////////////////////////////
1893            // GET THE OBJECT TRANSFORMATION MATRIX //
1894            //////////////////////////////////////////
1991   /* Concatenate the megaOffset with the addresses */
1992   address[0] |= (megaOffset << 16);
1993   address[1] |= (megaOffset << 16);
1994   address[2] |= (megaOffset << 16);
1995   address[3] |= (megaOffset << 16);
18951996
1896            objectMatrix[8 ] = uToF( workingList[i+3] & 0x0000ffff);
1897            objectMatrix[4 ] = uToF((workingList[i+4] & 0xffff0000) >> 16);
1898            objectMatrix[0 ] = uToF( workingList[i+4] & 0x0000ffff);
1899            objectMatrix[3]  = 0.0f;
1997   /* For all 4 polygon chunks */
1998   for (k = 0; k < 4; k++)
1999   {
2000      threeDPointer = &threeDRoms[address[k] * 3];
2001      for (l = 0; l < size[k]; l++)
2002      {
2003         ////////////////////////////////////////////
2004         // GATHER A SINGLE TRIANGLE'S INFORMATION //
2005         ////////////////////////////////////////////
2006         /*/////////////////////////
2007            // SINGLE POLY CHUNK FORMAT
2008            // [0] ??-- - ???? unused ????
2009            // [0] --xx - chunk type
2010            // [1] x--- - 'texture type' (or UV-mapping style)?
2011            // [1] -??- - ???? '18' for untextured buildings in fatfurwa ????
2012            // [1] ---x - texture index
2013            // [2] ???? - used in fatfurwa 'hng64' & everywhere in roadedge
2014            /////////////////////////*/
2015         UINT8 chunkLength = 0;
2016         UINT8 chunkType = threeDPointer[0] & 0x00ff;
19002017
1901            objectMatrix[9 ] = uToF((workingList[i+5] & 0xffff0000) >> 16);
1902            objectMatrix[5 ] = uToF( workingList[i+5] & 0x0000ffff);
1903            objectMatrix[1 ] = uToF((workingList[i+6] & 0xffff0000) >> 16);
1904            objectMatrix[7]  = 0.0f;
2018         // Debug - ajg
2019         //printf("%d (%08x) : %04x %04x %04x ", k, address[k]*3*2, threeDPointer[0], threeDPointer[1], threeDPointer[2]);
2020         //break;
19052021
1906            objectMatrix[10] = uToF( workingList[i+6] & 0x0000ffff);
1907            objectMatrix[6 ] = uToF((workingList[i+7] & 0xffff0000) >> 16);
1908            objectMatrix[2 ] = uToF( workingList[i+7] & 0x0000ffff);
1909            objectMatrix[11] = 0.0f;
2022         // Debug - ajg
2023         //if ((threeDPointer[0] & 0xff00) != 0x0000)
2024         //{
2025         //  printf("!!! Doesn't appear to be a valid chunk !!!\n");
2026         //  continue;
2027         //}
19102028
1911            objectMatrix[12] = uToF((workingList[i+2] & 0xffff0000) >> 16);
1912            objectMatrix[13] = uToF( workingList[i+2] & 0x0000ffff);
1913            objectMatrix[14] = uToF((workingList[i+3] & 0xffff0000) >> 16);
1914            objectMatrix[15] = 1.0f;
2029         // Get which texture this polygon refers to...
2030         // In fatfur it's 0xc for the smooth-shaded earth - maybe this is for all things with alpha - check the hair at some point.
2031         //                0x9 for the untextured buildings
2032         //                0xd for the 'explosion' of the HNG64
2033         //            and 0x8 everywhere else...
2034         //        they're 0x8 in the buriki intro too (those are 66-byte chunks!)
2035         polys[*numPolys].texType = ((threeDPointer[1] & 0xf000) >> 4 >> 8);
19152036
2037         if (polys[*numPolys].texType == 0x8 || polys[*numPolys].texType == 0xc)      //  || polys[*numPolys].texType == 0x9
2038         {
2039            polys[*numPolys].texIndex = threeDPointer[1] & 0x000f;
2040         }
2041         else
2042         {
2043            polys[*numPolys].texIndex = -1;
2044         }
19162045
2046         // Set the polygon's palette
2047         polys[*numPolys].palIndex = paletteState3d;
19172048
1918            //////////////////////////////////////////////////////////
1919            // EXTRACT DATA FROM THE ADDRESS POINTED TO IN THE FILE //
1920            //////////////////////////////////////////////////////////
2049         switch(chunkType)
2050         {
2051         /*/////////////////////////
2052            // CHUNK TYPE BITS - These are very likely incorrect.
2053            // x--- ---- - 1 = Has only 1 vertex (part of a triangle fan/strip)
2054            // -x-- ---- -
2055            // --x- ---- -
2056            // ---x ---- -
2057            // ---- x--- -
2058            // ---- -x-- - 1 = Has per-vert UVs
2059            // ---- --x- -
2060            // ---- ---x - 1 = Has per-vert normals
2061            /////////////////////////*/
19212062
1922            // Okay, there are 4 hunks per address.  They all seem good too...
2063         // 33 word chunk, 3 vertices, per-vertex UVs & normals
2064         case 0x05:   // 0000 0101
2065         case 0x0f:   // 0000 1111
2066            for (m = 0; m < 3; m++)
2067            {
2068               polys[*numPolys].vert[m].worldCoords[0] = uToF(threeDPointer[3 + (9*m)]);
2069               polys[*numPolys].vert[m].worldCoords[1] = uToF(threeDPointer[4 + (9*m)]);
2070               polys[*numPolys].vert[m].worldCoords[2] = uToF(threeDPointer[5 + (9*m)]);
2071               polys[*numPolys].vert[m].worldCoords[3] = 1.0f;
2072               polys[*numPolys].n = 3;
19232073
1924            // First tell me how many 'chunks' are at each address...
1925            size[0] = WORD_AT( threeDPointer, ( 6<<1) );
1926            size[1] = WORD_AT( threeDPointer, ( 7<<1) );
1927            size[2] = WORD_AT( threeDPointer, ( 9<<1) );
1928            size[3] = WORD_AT( threeDPointer, (10<<1) );
2074               // threeDPointer[6 + (9*m)] is almost always 0080, but it's 0070 for the translucent globe in fatfurwa player select
2075               polys[*numPolys].vert[m].texCoords[0] = uToF(threeDPointer[7 + (9*m)]);
2076               polys[*numPolys].vert[m].texCoords[1] = uToF(threeDPointer[8 + (9*m)]);
2077               polys[*numPolys].vert[m].texCoords[2] = 0.0f;
2078               polys[*numPolys].vert[m].texCoords[3] = 1.0f;
19292079
1930            megaOffset = ( WORD_AT(threeDRoms, (threeDOffset + 4)) ) << 16;
1931            address[0] = megaOffset | WORD_AT(threeDPointer, (0<<1));
1932            address[1] = megaOffset | WORD_AT(threeDPointer, (1<<1));
1933            address[2] = megaOffset | WORD_AT(threeDPointer, (3<<1));
1934            address[3] = megaOffset | WORD_AT(threeDPointer, (4<<1));
2080               polys[*numPolys].vert[m].normal[0] = uToF(threeDPointer[9  + (9*m)]);
2081               polys[*numPolys].vert[m].normal[1] = uToF(threeDPointer[10 + (9*m)] );
2082               polys[*numPolys].vert[m].normal[2] = uToF(threeDPointer[11 + (9*m)] );
2083               polys[*numPolys].vert[m].normal[3] = 0.0f;
19352084
1936            // DEBUG
1937            // mame_printf_debug("%.5x %.3x %.5x %.3x %.5x %.3x %.5x %.3x\n", address[0], size[0], address[1], size[1], address[2], size[2], address[3], size[3]);
1938            // !! END DEBUG !!
2085               // !!! DUMB !!!
2086               polys[*numPolys].vert[m].light[0] = polys[*numPolys].vert[m].texCoords[0] * 255.0f;
2087               polys[*numPolys].vert[m].light[1] = polys[*numPolys].vert[m].texCoords[1] * 255.0f;
2088               polys[*numPolys].vert[m].light[2] = polys[*numPolys].vert[m].texCoords[2] * 255.0f;
2089            }
19392090
2091            // Redundantly called, but it works...
2092            polys[*numPolys].faceNormal[0] = uToF(threeDPointer[30]);
2093            polys[*numPolys].faceNormal[1] = uToF(threeDPointer[31]);
2094            polys[*numPolys].faceNormal[2] = uToF(threeDPointer[32]);
2095            polys[*numPolys].faceNormal[3] = 0.0f;
19402096
2097            chunkLength = 33;
2098            break;
19412099
1942            ////////////////////////////////////
1943            // A FEW 'GLOBAL' TRANSFORMATIONS //
1944            ////////////////////////////////////
19452100
1946            // Now perform the world transformations...
1947            // !! Can eliminate this step with a matrix stack (maybe necessary?) !!
1948            setIdentity(modelViewMatrix);
1949            matmul4(modelViewMatrix, modelViewMatrix, cameraMatrix);
1950            matmul4(modelViewMatrix, modelViewMatrix, objectMatrix);
1951
1952            for (k = 0; k < 4; k++)                              // For all 4 chunks
2101         // 24 word chunk, 3 vertices, per-vertex UVs
2102         case 0x04:   // 0000 0100
2103         case 0x0e:   // 0000 1110
2104            for (m = 0; m < 3; m++)
19532105            {
1954               threeDPointer = &threeDRoms[(address[k]<<1) * 3];
2106               polys[*numPolys].vert[m].worldCoords[0] = uToF(threeDPointer[3 + (6*m)]);
2107               polys[*numPolys].vert[m].worldCoords[1] = uToF(threeDPointer[4 + (6*m)]);
2108               polys[*numPolys].vert[m].worldCoords[2] = uToF(threeDPointer[5 + (6*m)]);
2109               polys[*numPolys].vert[m].worldCoords[3] = 1.0f;
2110               polys[*numPolys].n = 3;
19552111
1956               for (l = 0; l < size[k]; l++)
1957               {
1958                  ////////////////////////////////////////////
1959                  // GATHER A SINGLE TRIANGLE'S INFORMATION //
1960                  ////////////////////////////////////////////
2112               // threeDPointer[6 + (6*m)] is almost always 0080, but it's 0070 for the translucent globe in fatfurwa player select
2113               polys[*numPolys].vert[m].texCoords[0] = uToF(threeDPointer[7 + (6*m)]);
2114               polys[*numPolys].vert[m].texCoords[1] = uToF(threeDPointer[8 + (6*m)]);
2115               polys[*numPolys].vert[m].texCoords[2] = 0.0f;
2116               polys[*numPolys].vert[m].texCoords[3] = 1.0f;
19612117
1962                  UINT8 triangleType = threeDPointer[1];
2118               polys[*numPolys].vert[m].normal[0] = uToF(threeDPointer[21]);
2119               polys[*numPolys].vert[m].normal[1] = uToF(threeDPointer[22]);
2120               polys[*numPolys].vert[m].normal[2] = uToF(threeDPointer[23]);
2121               polys[*numPolys].vert[m].normal[3] = 0.0f;
19632122
1964                  UINT8 numVertices = 3;
1965                  UINT8 chunkLength = 0;
2123               // !!! DUMB !!!
2124               polys[*numPolys].vert[m].light[0] = polys[*numPolys].vert[m].texCoords[0] * 255.0f;
2125               polys[*numPolys].vert[m].light[1] = polys[*numPolys].vert[m].texCoords[1] * 255.0f;
2126               polys[*numPolys].vert[m].light[2] = polys[*numPolys].vert[m].texCoords[2] * 255.0f;
2127            }
19662128
1967                  // Some chunks only have 1 vertex (they act as a vertex fan)
1968                  if (triangleType == 0x97 ||
1969                     triangleType == 0x87 ||
1970                     triangleType == 0xd7 ||
1971                     triangleType == 0x96)
1972                     numVertices = 1;
2129            // Redundantly called, but it works...
2130            polys[*numPolys].faceNormal[0] = polys[*numPolys].vert[m].normal[0];
2131            polys[*numPolys].faceNormal[1] = polys[*numPolys].vert[m].normal[1];
2132            polys[*numPolys].faceNormal[2] = polys[*numPolys].vert[m].normal[2];
2133            polys[*numPolys].faceNormal[3] = 0.0f;
19732134
1974                  // Get which texture this polygon refers to...
1975                  // In fatfur it's 0xc for the smooth-shaded earth       - maybe this is for all things with alpha - check the hair at some point...
1976                  //                0x9 for the untextured buildings
1977                  //                0xd for the 'explosion' of the HNG64
1978                  //            and 0x8 everywhere else...
1979                  //        they're 0x8 in the buriki intro too (those are 66-byte chunks!)
1980                  polys[numPolys].texType = ((threeDPointer[2] & 0xf0) >> 4);
2135            chunkLength = 24;
2136            break;
19812137
1982                  if (polys[numPolys].texType == 0x8 || polys[numPolys].texType == 0xc)      //  || polys[numPolys].texType == 0x9
1983                     polys[numPolys].texIndex = threeDPointer[3] & 0x0f;
1984                  else
1985                     polys[numPolys].texIndex = -1;
19862138
1987                  // Set the polygon's palette
1988                  polys[numPolys].palIndex = paletteState;
2139         // 15 word chunk, 1 vertex, per-vertex UVs & normals
2140         case 0x97:   // 1001 0111
2141         case 0x87:   // 1000 0111
2142         case 0xd7:   // 1101 0111
2143            // Copy over the proper vertices from the previous triangle...
2144            memcpy(&polys[*numPolys].vert[1], &lastPoly.vert[0], sizeof(struct polyVert));
2145            memcpy(&polys[*numPolys].vert[2], &lastPoly.vert[2], sizeof(struct polyVert));
19892146
1990                  for (m = 0; m < numVertices; m++)                        // For all vertices of the chunk
1991                  {
1992                     switch(triangleType)
1993                     {
1994                     // 42 byte chunk
1995                     case 0x04:
1996                     case 0x0e:
1997                        polys[numPolys].vert[m].worldCoords[0] = uToF(WORD_AT(threeDPointer, ((3<<1) + (6<<1)*m)) );
1998                        polys[numPolys].vert[m].worldCoords[1] = uToF(WORD_AT(threeDPointer, ((4<<1) + (6<<1)*m)) );
1999                        polys[numPolys].vert[m].worldCoords[2] = uToF(WORD_AT(threeDPointer, ((5<<1) + (6<<1)*m)) );
2000                        polys[numPolys].vert[m].worldCoords[3] = 1.0f;
2001                        polys[numPolys].n = 3;
2147            // Fill in the appropriate data...
2148            polys[*numPolys].vert[0].worldCoords[0] = uToF(threeDPointer[3]);
2149            polys[*numPolys].vert[0].worldCoords[1] = uToF(threeDPointer[4]);
2150            polys[*numPolys].vert[0].worldCoords[2] = uToF(threeDPointer[5]);
2151            polys[*numPolys].vert[0].worldCoords[3] = 1.0f;
2152            polys[*numPolys].n = 3;
20022153
2003                        // !! What is the first coordinate here (6) - maybe denotes size of chunk? !!
2004                        polys[numPolys].vert[m].texCoords[0] = uToF(WORD_AT(threeDPointer, ((7<<1) + (6<<1)*m)) );
2005                        polys[numPolys].vert[m].texCoords[1] = uToF(WORD_AT(threeDPointer, ((8<<1) + (6<<1)*m)) );
2006                        polys[numPolys].vert[m].texCoords[2] = 0.0f;
2007                        polys[numPolys].vert[m].texCoords[3] = 1.0f;
2154            // threeDPointer[6] is almost always 0080, but it's 0070 for the translucent globe in fatfurwa player select
2155            polys[*numPolys].vert[0].texCoords[0] = uToF(threeDPointer[7]);
2156            polys[*numPolys].vert[0].texCoords[1] = uToF(threeDPointer[8]);
2157            polys[*numPolys].vert[0].texCoords[2] = 0.0f;
2158            polys[*numPolys].vert[0].texCoords[3] = 1.0f;
20082159
2009                        polys[numPolys].vert[m].normal[0] = uToF(WORD_AT(threeDPointer, (21<<1) ));
2010                        polys[numPolys].vert[m].normal[1] = uToF(WORD_AT(threeDPointer, (22<<1) ));
2011                        polys[numPolys].vert[m].normal[2] = uToF(WORD_AT(threeDPointer, (23<<1) ));
2012                        polys[numPolys].vert[m].normal[3] = 0.0f;
2160            polys[*numPolys].vert[0].normal[0] = uToF(threeDPointer[9]);
2161            polys[*numPolys].vert[0].normal[1] = uToF(threeDPointer[10]);
2162            polys[*numPolys].vert[0].normal[2] = uToF(threeDPointer[11]);
2163            polys[*numPolys].vert[0].normal[3] = 0.0f;
20132164
2014                        // !!! DUMB !!!
2015                        polys[numPolys].vert[m].light[0] = polys[numPolys].vert[m].texCoords[0] * 255.0f;
2016                        polys[numPolys].vert[m].light[1] = polys[numPolys].vert[m].texCoords[1] * 255.0f;
2017                        polys[numPolys].vert[m].light[2] = polys[numPolys].vert[m].texCoords[2] * 255.0f;
2165            polys[*numPolys].vert[0].light[0] = polys[*numPolys].vert[0].texCoords[0] * 255.0f;
2166            polys[*numPolys].vert[0].light[1] = polys[*numPolys].vert[0].texCoords[1] * 255.0f;
2167            polys[*numPolys].vert[0].light[2] = polys[*numPolys].vert[0].texCoords[2] * 255.0f;
20182168
2019                        // Redundantly called, but it works...
2020                        polys[numPolys].faceNormal[0] = polys[numPolys].vert[m].normal[0];
2021                        polys[numPolys].faceNormal[1] = polys[numPolys].vert[m].normal[1];
2022                        polys[numPolys].faceNormal[2] = polys[numPolys].vert[m].normal[2];
2023                        polys[numPolys].faceNormal[3] = 0.0f;
2169            polys[*numPolys].faceNormal[0] = uToF(threeDPointer[12]);
2170            polys[*numPolys].faceNormal[1] = uToF(threeDPointer[13]);
2171            polys[*numPolys].faceNormal[2] = uToF(threeDPointer[14]);
2172            polys[*numPolys].faceNormal[3] = 0.0f;
20242173
2025                        chunkLength = (24<<1);
2026                        break;
2174            chunkLength = 15;
2175            break;
20272176
2028                     // 66 byte chunk
2029                     case 0x05:
2030                     case 0x0f:
2031                        polys[numPolys].vert[m].worldCoords[0] = uToF(WORD_AT(threeDPointer, ((3<<1) + (9<<1)*m)) );
2032                        polys[numPolys].vert[m].worldCoords[1] = uToF(WORD_AT(threeDPointer, ((4<<1) + (9<<1)*m)) );
2033                        polys[numPolys].vert[m].worldCoords[2] = uToF(WORD_AT(threeDPointer, ((5<<1) + (9<<1)*m)) );
2034                        polys[numPolys].vert[m].worldCoords[3] = 1.0f;
2035                        polys[numPolys].n = 3;
20362177
2037                        // !! See above - (6) - why? !!
2038                        polys[numPolys].vert[m].texCoords[0] = uToF(WORD_AT(threeDPointer, ((7<<1) + (9<<1)*m)) );
2039                        polys[numPolys].vert[m].texCoords[1] = uToF(WORD_AT(threeDPointer, ((8<<1) + (9<<1)*m)) );
2040                        polys[numPolys].vert[m].texCoords[2] = 0.0f;
2041                        polys[numPolys].vert[m].texCoords[3] = 1.0f;
2178         // 12 word chunk, 1 vertex, per-vertex UVs
2179         case 0x96:   // 1001 0110
2180            // Copy over the proper vertices from the previous triangle...
2181            memcpy(&polys[*numPolys].vert[1], &lastPoly.vert[0], sizeof(struct polyVert));
2182            memcpy(&polys[*numPolys].vert[2], &lastPoly.vert[2], sizeof(struct polyVert));
20422183
2043                        polys[numPolys].vert[m].normal[0] = uToF(WORD_AT(threeDPointer, ((9<<1) + (9<<1)*m)) );
2044                        polys[numPolys].vert[m].normal[1] = uToF(WORD_AT(threeDPointer, ((10<<1) + (9<<1)*m)) );
2045                        polys[numPolys].vert[m].normal[2] = uToF(WORD_AT(threeDPointer, ((11<<1) + (9<<1)*m)) );
2046                        polys[numPolys].vert[m].normal[3] = 0.0f;
2184            polys[*numPolys].vert[0].worldCoords[0] = uToF(threeDPointer[3]);
2185            polys[*numPolys].vert[0].worldCoords[1] = uToF(threeDPointer[4]);
2186            polys[*numPolys].vert[0].worldCoords[2] = uToF(threeDPointer[5]);
2187            polys[*numPolys].vert[0].worldCoords[3] = 1.0f;
2188            polys[*numPolys].n = 3;
20472189
2048                        // !!! DUMB !!!
2049                        polys[numPolys].vert[m].light[0] = polys[numPolys].vert[m].texCoords[0] * 255.0f;
2050                        polys[numPolys].vert[m].light[1] = polys[numPolys].vert[m].texCoords[1] * 255.0f;
2051                        polys[numPolys].vert[m].light[2] = polys[numPolys].vert[m].texCoords[2] * 255.0f;
2190            // threeDPointer[6] is almost always 0080, but it's 0070 for the translucent globe in fatfurwa player select
2191            polys[*numPolys].vert[0].texCoords[0] = uToF(threeDPointer[7]);
2192            polys[*numPolys].vert[0].texCoords[1] = uToF(threeDPointer[8]);
2193            polys[*numPolys].vert[0].texCoords[2] = 0.0f;
2194            polys[*numPolys].vert[0].texCoords[3] = 1.0f;
20522195
2053                        // Redundantly called, but it works...
2054                        polys[numPolys].faceNormal[0] = uToF(WORD_AT(threeDPointer, (30<<1) ));
2055                        polys[numPolys].faceNormal[1] = uToF(WORD_AT(threeDPointer, (31<<1) ));
2056                        polys[numPolys].faceNormal[2] = uToF(WORD_AT(threeDPointer, (32<<1) ));
2057                        polys[numPolys].faceNormal[3] = 0.0f;
2196            // !!! DUMB !!!
2197            polys[*numPolys].vert[0].light[0] = polys[*numPolys].vert[0].texCoords[0] * 255.0f;
2198            polys[*numPolys].vert[0].light[1] = polys[*numPolys].vert[0].texCoords[1] * 255.0f;
2199            polys[*numPolys].vert[0].light[2] = polys[*numPolys].vert[0].texCoords[2] * 255.0f;
20582200
2059                        chunkLength = (33<<1);
2060                        break;
2201            // This normal could be right, but I'm not entirely sure - there is no normal in the 18 bytes!
2202            polys[*numPolys].vert[0].normal[0] = lastPoly.faceNormal[0];
2203            polys[*numPolys].vert[0].normal[1] = lastPoly.faceNormal[1];
2204            polys[*numPolys].vert[0].normal[2] = lastPoly.faceNormal[2];
2205            polys[*numPolys].vert[0].normal[3] = lastPoly.faceNormal[3];
20612206
2062                     // 30 byte chunk
2063                     case 0x97:
2064                     case 0x87:
2065                     case 0xd7:
2207            polys[*numPolys].faceNormal[0] = lastPoly.faceNormal[0];
2208            polys[*numPolys].faceNormal[1] = lastPoly.faceNormal[1];
2209            polys[*numPolys].faceNormal[2] = lastPoly.faceNormal[2];
2210            polys[*numPolys].faceNormal[3] = lastPoly.faceNormal[3];
20662211
2067                        // Copy over the proper vertices from the previous triangle...
2068                        memcpy(&polys[numPolys].vert[1], &lastPoly.vert[0], sizeof(struct polyVert));
2069                        memcpy(&polys[numPolys].vert[2], &lastPoly.vert[2], sizeof(struct polyVert));
2212            // TODO: I'm not reading 3 necessary words here (maybe face normal) !!!
20702213
2071                        // Fill in the appropriate data...
2072                        polys[numPolys].vert[0].worldCoords[0] = uToF(WORD_AT(threeDPointer, (3<<1) ));
2073                        polys[numPolys].vert[0].worldCoords[1] = uToF(WORD_AT(threeDPointer, (4<<1) ));
2074                        polys[numPolys].vert[0].worldCoords[2] = uToF(WORD_AT(threeDPointer, (5<<1) ));
2075                        polys[numPolys].vert[0].worldCoords[3] = 1.0f;
2076                        polys[numPolys].n = 3;
2214            chunkLength = 12;
2215            break;
20772216
2078                        // !! See above - (6) - why? !!
2079                        polys[numPolys].vert[0].texCoords[0] = uToF(WORD_AT(threeDPointer, (7<<1) ));
2080                        polys[numPolys].vert[0].texCoords[1] = uToF(WORD_AT(threeDPointer, (8<<1) ));
2081                        polys[numPolys].vert[0].texCoords[2] = 0.0f;
2082                        polys[numPolys].vert[0].texCoords[3] = 1.0f;
2217#if 0
2218         // TODO: DECODE THESE GUYS //
2219         case 0x2e:   // 0010 1110
2220            /* There's something fishy about this guy - see 0x7a below.  Very likely not fixed-length */
2221            /*
2222                printf("0x2e : %08x\n", address[k]*3*2);
2223                for (m = 0; m < 37; m++)
2224                    printf("%04x ", threeDPointer[m]);
2225                printf("\n\n");
2226                */
2227            chunkLength = 36;
2228         break;
20832229
2084                        polys[numPolys].vert[0].normal[0] = uToF(WORD_AT(threeDPointer, (9<<1) ));
2085                        polys[numPolys].vert[0].normal[1] = uToF(WORD_AT(threeDPointer, (10<<1) ));
2086                        polys[numPolys].vert[0].normal[2] = uToF(WORD_AT(threeDPointer, (11<<1) ));
2087                        polys[numPolys].vert[0].normal[3] = 0.0f;
2230         /* This shouldn't exist. */
2231         /* There's something funky going on with 0x2e - it's often well-behaved, except for
2232               when it "ends" with e67a.  Maybe this chunkLength thing isn't where it's at?
2233               Luckily the 0x7a is always at the end of a series of 2 chunks (2e,7a) so ignoring
2234               it won't kill us for now. */
2235         case 0x7a:   // 0111 1010
2236            /*
2237                printf("0x7a : %08x (%d/%d)\n", mame_rand(machine), l, size[k]);
2238                for (m = 0; m < 100; m++)
2239                    printf("%04x ", threeDPointer[m]);
2240                printf("\n\n");
2241                */
2242            chunkLength = 0;
2243         break;
20882244
2089                        polys[numPolys].vert[0].light[0] = polys[numPolys].vert[0].texCoords[0] * 255.0f;
2090                        polys[numPolys].vert[0].light[1] = polys[numPolys].vert[0].texCoords[1] * 255.0f;
2091                        polys[numPolys].vert[0].light[2] = polys[numPolys].vert[0].texCoords[2] * 255.0f;
2245         case 0x24:   // 0010 0100
2246            /*
2247                printf("0x24 : %08x\n", address[k]*3*2);
2248                for (m = 0; m < 49; m++)
2249                    printf("%04x ", threeDPointer[m]);
2250                printf("\n\n");
2251                */
2252            chunkLength = 48;
2253         break;
20922254
2093                        polys[numPolys].faceNormal[0] = uToF(WORD_AT(threeDPointer, (12<<1) ));
2094                        polys[numPolys].faceNormal[1] = uToF(WORD_AT(threeDPointer, (13<<1) ));
2095                        polys[numPolys].faceNormal[2] = uToF(WORD_AT(threeDPointer, (14<<1) ));
2096                        polys[numPolys].faceNormal[3] = 0.0f;
2255         case 0xb6:   // 1011 0110
2256            /*
2257                printf("0xb6 : %08x\n", address[k]*3*2);
2258                for (m = 0; m < 13; m++)
2259                    printf("%04x ", threeDPointer[m]);
2260                printf("\n\n");
2261                */
2262            chunkLength = 12;
2263         break;
20972264
2098                        chunkLength = (15<<1);
2099                        break;
2265         case 0x86:   // 1000 0110
2266            /* Very likely not fixed-length since it leads into c6 & d6 */
2267            /*
2268                printf("0x86 : %08x\n", address[k]*3*2);
2269                for (m = 0; m < 13; m++)
2270                    printf("%04x ", threeDPointer[m]);
2271                printf("\n\n");
2272                */
2273            chunkLength = 12;
2274         break;
21002275
2101                     // 18 byte chunk
2102                     case 0x96:
2276         /* Are c6 and d6 just insanely long? They aren't at the end of the numTris like 0x7a */
2277         case 0xc6:   // 1100 0110
2278            /*
2279                printf("0xc6 : %08x (%d/%d)\n", address[k]*3*2, l, size[k]);
2280                for (m = 0; m < 100; m++)
2281                    printf("%04x ", threeDPointer[m]);
2282                printf("\n\n");
2283                */
2284            chunkLength = 0;
2285         break;
21032286
2104                        // Copy over the proper vertices from the previous triangle...
2105                        memcpy(&polys[numPolys].vert[1], &lastPoly.vert[0], sizeof(struct polyVert));
2106                        memcpy(&polys[numPolys].vert[2], &lastPoly.vert[2], sizeof(struct polyVert));
2287         /* Are c6 and d6 just insanely long? They aren't at the end of numTris like 0x7a */
2288         case 0xd6:   // 1101 0110
2289            /*
2290                printf("0xd6 : %08x (%d/%d)\n", address[k]*3*2, l, size[k]);
2291                for (m = 0; m < 100; m++)
2292                    printf("%04x ", threeDPointer[m]);
2293                printf("\n\n");
2294                */
2295            chunkLength = 0;
2296         break;
2297#endif
21072298
2108                        // !!! Too lazy to have finished this yet !!!
2299         default:
2300            logerror("UNKNOWN geometry CHUNK TYPE : %02x\n", chunkType);
2301            chunkLength = 0;
2302            break;
2303         }
21092304
2110                        polys[numPolys].vert[0].worldCoords[0] = uToF(WORD_AT(threeDPointer, (3<<1)));
2111                        polys[numPolys].vert[0].worldCoords[1] = uToF(WORD_AT(threeDPointer, (4<<1)));
2112                        polys[numPolys].vert[0].worldCoords[2] = uToF(WORD_AT(threeDPointer, (5<<1)));
2113                        polys[numPolys].vert[0].worldCoords[3] = 1.0f;
2114                        polys[numPolys].n = 3;
2305         // Debug - ajg
2306         //printf("(chunkLength %d)\n", chunkLength);
21152307
2116                        // !! See above - (6) - why? !!
2117                        polys[numPolys].vert[0].texCoords[0] = uToF(WORD_AT(threeDPointer, (7<<1)));
2118                        polys[numPolys].vert[0].texCoords[1] = uToF(WORD_AT(threeDPointer, (8<<1)));
2119                        polys[numPolys].vert[0].texCoords[2] = 0.0f;
2120                        polys[numPolys].vert[0].texCoords[3] = 1.0f;
2308         polys[*numPolys].visible = 1;
21212309
2122                        // !!! DUMB !!!
2123                        polys[numPolys].vert[0].light[0] = polys[numPolys].vert[0].texCoords[0] * 255.0f;
2124                        polys[numPolys].vert[0].light[1] = polys[numPolys].vert[0].texCoords[1] * 255.0f;
2125                        polys[numPolys].vert[0].light[2] = polys[numPolys].vert[0].texCoords[2] * 255.0f;
2310         // Backup the last polygon (for triangle fans [strips?])
2311         memcpy(&lastPoly, &polys[*numPolys], sizeof(struct polygon));
21262312
2127                        // This normal could be right, but I'm not entirely sure - there is no normal in the 18 bytes!
2128                        polys[numPolys].vert[0].normal[0] = lastPoly.faceNormal[0];
2129                        polys[numPolys].vert[0].normal[1] = lastPoly.faceNormal[1];
2130                        polys[numPolys].vert[0].normal[2] = lastPoly.faceNormal[2];
2131                        polys[numPolys].vert[0].normal[3] = lastPoly.faceNormal[3];
21322313
2133                        polys[numPolys].faceNormal[0] = lastPoly.faceNormal[0];
2134                        polys[numPolys].faceNormal[1] = lastPoly.faceNormal[1];
2135                        polys[numPolys].faceNormal[2] = lastPoly.faceNormal[2];
2136                        polys[numPolys].faceNormal[3] = lastPoly.faceNormal[3];
2314         ////////////////////////////////////
2315         // Project and clip               //
2316         ////////////////////////////////////
2317         // Perform the world transformations...
2318         // !! Can eliminate this step with a matrix stack (maybe necessary?) !!
2319         setIdentity(modelViewMatrix);
2320         matmul4(modelViewMatrix, modelViewMatrix, cameraMatrix);
2321         matmul4(modelViewMatrix, modelViewMatrix, objectMatrix);
21372322
2138                        chunkLength = (9<<1);
2139                        break;
2323         // BACKFACE CULL //
2324         // EMPIRICAL EVIDENCE SEEMS TO SHOW THE HNG64 HARDWARE DOES NOT BACKFACE CULL //
2325         /*
2326            float cullRay[4];
2327            float cullNorm[4];
21402328
2141                     default:
2142                        mame_printf_debug("UNKNOWN geometry CHUNK TYPE : %x\n", triangleType);
2143                        break;
2144                     }
2145                  }
2329            // Cast a ray out of the camera towards the polygon's point in eyespace.
2330            vecmatmul4(cullRay, modelViewMatrix, polys[*numPolys].vert[0].worldCoords);
2331            normalize(cullRay);
2332            // Dot product that with the normal to see if you're negative...
2333            vecmatmul4(cullNorm, modelViewMatrix, polys[*numPolys].faceNormal);
21462334
2147                  polys[numPolys].visible = 1;
2335            float result = vecDotProduct(cullRay, cullNorm);
21482336
2149                  memcpy(&lastPoly, &polys[numPolys], sizeof(struct polygon));
2337            if (result < 0.0f)
2338                polys[*numPolys].visible = 1;
2339            else
2340                polys[*numPolys].visible = 0;
2341            */
21502342
2343         // BEHIND-THE-CAMERA CULL //
2344         vecmatmul4(cullRay, modelViewMatrix, polys[*numPolys].vert[0].worldCoords);
2345         if (cullRay[2] > 0.0f)            // Camera is pointing down -Z
2346         {
2347            polys[*numPolys].visible = 0;
2348         }
21512349
21522350
2351         // TRANSFORM THE TRIANGLE INTO HOMOGENEOUS SCREEN SPACE //
2352         if (polys[*numPolys].visible)
2353         {
2354            for (m = 0; m < polys[*numPolys].n; m++)
2355            {
2356               // Transform and project the vertex into pre-divided homogeneous coordinates...
2357               vecmatmul4(eyeCoords, modelViewMatrix, polys[*numPolys].vert[m].worldCoords);
2358               vecmatmul4(polys[*numPolys].vert[m].clipCoords, projectionMatrix, eyeCoords);
2359            }
21532360
2154                  // THE HNG64 HARDWARE DOES NOT SEEM TO BACKFACE CULL //
2361            if (polys[*numPolys].visible)
2362            {
2363               // Clip the triangles to the view frustum...
2364               performFrustumClip(&polys[*numPolys]);
21552365
2156                  ///////////////////
2157                  // BACKFACE CULL //
2158                  ///////////////////
2159/*
2160                        float cullRay[4];
2161                        float cullNorm[4];
2366               for (m = 0; m < polys[*numPolys].n; m++)
2367               {
2368                  // Convert into normalized device coordinates...
2369                  ndCoords[0] = polys[*numPolys].vert[m].clipCoords[0] / polys[*numPolys].vert[m].clipCoords[3];
2370                  ndCoords[1] = polys[*numPolys].vert[m].clipCoords[1] / polys[*numPolys].vert[m].clipCoords[3];
2371                  ndCoords[2] = polys[*numPolys].vert[m].clipCoords[2] / polys[*numPolys].vert[m].clipCoords[3];
2372                  ndCoords[3] = polys[*numPolys].vert[m].clipCoords[3];
21622373
2163                        // Cast a ray out of the camera towards the polygon's point in eyespace.
2164                        vecmatmul4(cullRay, modelViewMatrix, polys[numPolys].vert[0].worldCoords);
2165                        normalize(cullRay);
2166                        // Dot product that with the normal to see if you're negative...
2167                        vecmatmul4(cullNorm, modelViewMatrix, polys[numPolys].faceNormal);
2374                  // Final pixel values are garnered here :
2375                  windowCoords[0] = (ndCoords[0]+1.0f) * ((float)(visarea->max_x) / 2.0f) + 0.0f;
2376                  windowCoords[1] = (ndCoords[1]+1.0f) * ((float)(visarea->max_y) / 2.0f) + 0.0f;
2377                  windowCoords[2] = (ndCoords[2]+1.0f) * 0.5f;
21682378
2169                       float result = vecDotProduct(cullRay, cullNorm);
2379                  windowCoords[1] = (float)visarea->max_y - windowCoords[1];      // Flip Y
21702380
2171                        if (result < 0.0f)
2172                            polys[numPolys].visible = 1;
2173                        else
2174                            polys[numPolys].visible = 0;
2175*/
2381                  // Store the points in a list for later use...
2382                  polys[*numPolys].vert[m].clipCoords[0] = windowCoords[0];
2383                  polys[*numPolys].vert[m].clipCoords[1] = windowCoords[1];
2384                  polys[*numPolys].vert[m].clipCoords[2] = windowCoords[2];
2385                  polys[*numPolys].vert[m].clipCoords[3] = ndCoords[3];
2386               }
2387            }
2388         }
21762389
2177                  ////////////////////////////
2178                  // BEHIND-THE-CAMERA CULL //
2179                  ////////////////////////////
2180                  vecmatmul4(cullRay, modelViewMatrix, polys[numPolys].vert[0].worldCoords);
2390         /*
2391            // DEBUG
2392            if (chunkLength == (9 << 1))
2393            {
2394                mame_printf_debug("Chunk : ");
2395                for (int a = 0; a < chunkLength; a+=2)
2396                    mame_printf_debug("%.2x%.2x ", threeDPointer[a], threeDPointer[a+1]);
2397                mame_printf_debug("\n");
2398            }
2399            // END DEBUG
2400            */
21812401
2182                  if (cullRay[2] > 0.0f)            // Camera is pointing down -Z
2183                  {
2184                     polys[numPolys].visible = 0;
2185                  }
2402         // Advance to the next polygon chunk...
2403         threeDPointer += chunkLength;
21862404
2405         (*numPolys)++;
2406      }
2407   }
2408}
21872409
2188                  //////////////////////////////////////////////////////////
2189                  // TRANSFORM THE TRIANGLE INTO HOMOGENEOUS SCREEN SPACE //
2190                  //////////////////////////////////////////////////////////
2410#ifdef UNUSED_FUNCTION
2411void printPacket(const UINT16* packet, int hex)
2412{
2413   if (hex)
2414   {
2415      printf("Packet : %04x %04x  2:%04x %04x  4:%04x %04x  6:%04x %04x  8:%04x %04x  10:%04x %04x  12:%04x %04x  14:%04x %04x\n",
2416            packet[0],  packet[1],
2417            packet[2],  packet[3],
2418            packet[4],  packet[5],
2419            packet[6],  packet[7],
2420            packet[8],  packet[9],
2421            packet[10], packet[11],
2422            packet[12], packet[13],
2423            packet[14], packet[15]);
2424   }
2425   else
2426   {
2427      printf("Packet : %04x %3.4f  2:%3.4f %3.4f  4:%3.4f %3.4f  6:%3.4f %3.4f  8:%3.4f %3.4f  10:%3.4f %3.4f  12:%3.4f %3.4f  14:%3.4f %3.4f\n",
2428            packet[0],            uToF(packet[1] )*128,
2429            uToF(packet[2] )*128, uToF(packet[3] )*128,
2430            uToF(packet[4] )*128, uToF(packet[5] )*128,
2431            uToF(packet[6] )*128, uToF(packet[7] )*128,
2432            uToF(packet[8] )*128, uToF(packet[9] )*128,
2433            uToF(packet[10])*128, uToF(packet[11])*128,
2434            uToF(packet[12])*128, uToF(packet[13])*128,
2435            uToF(packet[14])*128, uToF(packet[15])*128);
2436   }
2437}
2438#endif
21912439
2192                  if (polys[numPolys].visible)
2193                  {
2194                     for (m = 0; m < polys[numPolys].n; m++)
2195                     {
2196                        // Transform and project the vertex into pre-divided homogeneous coordinates...
2197                        vecmatmul4(eyeCoords, modelViewMatrix, polys[numPolys].vert[m].worldCoords);
2198                        vecmatmul4(polys[numPolys].vert[m].clipCoords, projectionMatrix, eyeCoords);
2199                     }
2440void hng64_command3d(running_machine* machine, const UINT16* packet)
2441{
2442   int i;
22002443
2201                     if (polys[numPolys].visible)
2202                     {
2203                        // Clip the triangles to the view frustum...
2204                        performFrustumClip(&polys[numPolys]);
2444   /* A temporary place to put some polygons.  This will optimize away if the compiler's any good. */
2445   int numPolys = 0;
2446   struct polygon* polys = malloc(sizeof(struct polygon) * (1024*5));
22052447
2206                        for (m = 0; m < polys[numPolys].n; m++)
2207                        {
2208                           // Convert into normalized device coordinates...
2209                           ndCoords[0] = polys[numPolys].vert[m].clipCoords[0] / polys[numPolys].vert[m].clipCoords[3];
2210                           ndCoords[1] = polys[numPolys].vert[m].clipCoords[1] / polys[numPolys].vert[m].clipCoords[3];
2211                           ndCoords[2] = polys[numPolys].vert[m].clipCoords[2] / polys[numPolys].vert[m].clipCoords[3];
2212                           ndCoords[3] = polys[numPolys].vert[m].clipCoords[3];
2448   //printf("packet type : %04x\n", packet[0]);
2449   switch (packet[0])
2450   {
2451   case 0x0000:   // Appears to be a NOP.
2452      break;
22132453
2214                           // Final pixel values are garnered here :
2215                           windowCoords[0] = (ndCoords[0]+1.0f) * ((float)(visarea->max_x) / 2.0f) + 0.0f;
2216                           windowCoords[1] = (ndCoords[1]+1.0f) * ((float)(visarea->max_y) / 2.0f) + 0.0f;
2217                           windowCoords[2] = (ndCoords[2]+1.0f) * 0.5f;
2454   case 0x0001:   // Camera transformation.
2455      setCameraTransformation(packet);
2456      break;
22182457
2219                           windowCoords[1] = (float)visarea->max_y - windowCoords[1];      // Flip Y
2458   case 0x0010:   // Unknown
2459      // Called very interestingly per-frame in every game.  Floats for sure.  Light-related?
2460      break;
22202461
2221                           // Store the points in a list for later use...
2222                           polys[numPolys].vert[m].clipCoords[0] = windowCoords[0];
2223                           polys[numPolys].vert[m].clipCoords[1] = windowCoords[1];
2224                           polys[numPolys].vert[m].clipCoords[2] = windowCoords[2];
2225                           polys[numPolys].vert[m].clipCoords[3] = ndCoords[3];
2226                        }
2227                     }
2228                  }
2462   case 0x0011:   // Palette / Model flags?
2463      set3dFlags(packet);
2464      break;
22292465
2466   case 0x0012:   // Projection Matrix
2467      setCameraProjectionMatrix(packet);
2468      break;
22302469
2231/*
2232                        // DEBUG
2233                        if (chunkLength == (9 << 1))
2234                        {
2235                            mame_printf_debug("Chunk : ");
2236                            for (int ajg = 0; ajg < chunkLength; ajg+=2)
2237                                mame_printf_debug("%.2x%.2x ", threeDPointer[ajg], threeDPointer[ajg+1]);
2238                            mame_printf_debug("\n");
2239                        }
2240                        // END DEBUG
2241*/
2470   case 0x0100:   // Geometry
2471      recoverPolygonBlock(machine, packet, polys, &numPolys);
22422472
2243                  // Advance to the next polygon chunk...
2244                  threeDPointer += chunkLength;
2473      /* Immeditately rasterize the chunk's polygons into the display buffer */
2474      for (i = 0; i < numPolys; i++)
2475      {
2476         if (polys[i].visible)
2477         {
2478            //DrawWireframe(&polys[i], bitmap);
2479            drawShaded(machine, &polys[i]);
2480         }
2481      }
22452482
2246                  numPolys++;            // Add one more to the display list...
2247               }
2248            }
2483      numPolys = 0;
2484      break;
22492485
2250            break;
2486   case 0x0101:   // Unknown: Geometry?
2487      break;
22512488
2252         default:
2253            break;
2254         }
2255      }
2489   case 0x0102:   // Unknown: Geometry?
2490      break;
22562491
2257      // Don't forget about this !!!
2258      //mame_printf_debug("                 %.8x\n\n", (UINT32)hng64_dls[j][0x80]);
2492   case 0x1000:   // Unknown: Some sort of global flags?
2493      break;
22592494
2495   case 0x1001:   // Unknown: Some sort of global flags (a group of 4, actually)?
2496      break;
2497
2498   default:
2499      printf("HNG64: Unknown 3d command %04x.\n", packet[0]);
2500      break;
22602501   }
22612502
2503   free(polys);
2504}
22622505
2263   /////////////////////////////////////////////////
2264   // FINALLY RENDER THE TRIANGLES INTO THE FRAME //
2265   /////////////////////////////////////////////////
2506static void clear3d(running_machine *machine)
2507{
2508   int i;
22662509
2510   const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen);
2511
2512   // Clear each of the display list buffers after drawing - todo: kill!
2513   for (i = 0; i < 0x81; i++)
2514   {
2515      hng64_dls[0][i] = 0;
2516      hng64_dls[1][i] = 0;
2517   }
2518
22672519   // Reset the buffers...
22682520   for (i = 0; i < (visarea->max_x)*(visarea->max_y); i++)
22692521   {
r6740r6741
22712523      colorBuffer3d[i] = MAKE_ARGB(0,0,0,0);
22722524   }
22732525
2274   for (i = 0; i < numPolys; i++)
2275   {
2276      if (polys[i].visible)
2277      {
2278         //DrawWireframe(&polys[i], bitmap);
2279         drawShaded(machine, &polys[i], bitmap);
2280      }
2281   }
2526   // Set some matrices to the identity...
2527   setIdentity(projectionMatrix);
2528   setIdentity(modelViewMatrix);
2529   setIdentity(cameraMatrix);
2530}
22822531
2283   // usrintf_showmessage("%d", numPolys);
2532/* 3D/framebuffer video registers
2533 * ------------------------------
2534 *
2535 * UINT32 | Bits                                    | Use
2536 *        | 3322 2222 2222 1111 1111 11             |
2537 * -------+-1098-7654-3210-9876-5432-1098-7654-3210-+----------------
2538 *      0 | ???? ???? ???? ???? ccc? ???? ???? ???? | framebuffer color base, 0x311800 in Fatal Fury WA, 0x313800 in Buriki One
2539 *      1 |                                         |
2540 *      2 | ???? ???? ???? ???? ???? ???? ???? ???? | camera / framebuffer global x/y? Actively used by Samurai Shodown 64 2
2541 *      3 | ---- --?x ---- ---- ---- ---- ---- ---- | unknown, unsetted by Buriki One and setted by Fatal Fury WA, buffering mode?
2542 *   4-11 | ---- ???? ---- ???? ---- ???? ---- ???? | Table filled with 0x0? data
2543 *
2544 */
22842545
2285   // Clear each of the display list buffers after drawing...
2286   for (i = 0; i < 0x81; i++)
2287   {
2288      hng64_dls[0][i] = 0;
2289      hng64_dls[1][i] = 0;
2290   }
2291}
2546/////////////////////
2547// 3D UTILITY CODE //
2548/////////////////////
22922549
2293
22942550/* 4x4 matrix multiplication */
22952551static void matmul4( float *product, const float *a, const float *b )
22962552{
22972553   int i;
22982554   for (i = 0; i < 4; i++)
22992555   {
2300      const float ai0 = a[0  + i];
2301     const float ai1 = a[4  + i];
2302     const float ai2 = a[8  + i];
2303     const float ai3 = a[12 + i];
2556      const float ai0 = a[0  + i];
2557      const float ai1 = a[4  + i];
2558      const float ai2 = a[8  + i];
2559      const float ai3 = a[12 + i];
23042560
2305     product[0  + i] = ai0 * b[0 ] + ai1 * b[1 ] + ai2 * b[2 ] + ai3 * b[3 ];
2306     product[4  + i] = ai0 * b[4 ] + ai1 * b[5 ] + ai2 * b[6 ] + ai3 * b[7 ];
2307     product[8  + i] = ai0 * b[8 ] + ai1 * b[9 ] + ai2 * b[10] + ai3 * b[11];
2308     product[12 + i] = ai0 * b[12] + ai1 * b[13] + ai2 * b[14] + ai3 * b[15];
2561      product[0  + i] = ai0 * b[0 ] + ai1 * b[1 ] + ai2 * b[2 ] + ai3 * b[3 ];
2562      product[4  + i] = ai0 * b[4 ] + ai1 * b[5 ] + ai2 * b[6 ] + ai3 * b[7 ];
2563      product[8  + i] = ai0 * b[8 ] + ai1 * b[9 ] + ai2 * b[10] + ai3 * b[11];
2564      product[12 + i] = ai0 * b[12] + ai1 * b[13] + ai2 * b[14] + ai3 * b[15];
23092565   }
23102566}
23112567
r6740r6741
23482604   retVal = (float)((INT16)input) / 32768.0f;
23492605   return retVal;
23502606
2351/*  if ((INT16)input < 0)
2607/*
2608    if ((INT16)input < 0)
23522609        retVal = (float)((INT16)input) / 32768.0f;
23532610    else
2354        retVal = (float)((INT16)input) / 32767.0f; */
2611        retVal = (float)((INT16)input) / 32767.0f;
2612*/
23552613}
23562614
23572615#ifdef UNUSED_FUNCTION
r6740r6741
23752633///////////////////////////////////////////////////////////////////////////////////
23762634// The remainder of the code in this file is heavily                             //
23772635//   influenced by, and sometimes copied verbatim from Andrew Zaferakis' SoftGL  //
2378//   rasterizing system.  http://www.cs.unc.edu/~andrewz/comp236/                //
2636//   rasterizing system.                                                         //
23792637//                                                                               //
23802638//   Andrew granted permission for its use in MAME in October of 2004.           //
23812639///////////////////////////////////////////////////////////////////////////////////
r6740r6741
24052663
24062664   case HNG64_NEAR:
24072665      return (v->clipCoords[2] <=  v->clipCoords[3]) ? 1 : 0;
2408
24092666   case HNG64_FAR:
24102667      return (v->clipCoords[2] >= -v->clipCoords[3]) ? 1 : 0;
2411
24122668   }
24132669
24142670   return 0;
r6740r6741
24692725
24702726static void performFrustumClip(struct polygon *p)
24712727{
2472   int i, j;
2473   int k;
2474
2728   int i, j, k;
24752729   //////////////////////////////////////////////////////////////////////////
24762730   // Clip against the volumes defined by the homogeneous clip coordinates //
24772731   //////////////////////////////////////////////////////////////////////////
r6740r6741
26342888/**                                                                 **/
26352889/**     Output: none                                                **/
26362890/*********************************************************************/
2637INLINE void FillSmoothTexPCHorizontalLine(running_machine *machine, bitmap_t *Color,
2891INLINE void FillSmoothTexPCHorizontalLine(running_machine *machine,
26382892                                int Wrapping, int Filtering, int Function,
26392893                                int x_start, int x_end, int y, float z_start, float z_delta,
26402894                                float w_start, float w_delta, float r_start, float r_delta,
r6740r6741
26762930               // Greyscale texture - for Buriki...
26772931               // *BITMAP_ADDR32(Color, y, x_start) = MAKE_ARGB(255, (UINT8)paletteEntry, (UINT8)paletteEntry, (UINT8)paletteEntry);
26782932
2679               //*BITMAP_ADDR32(Color, y, x_start) = machine->pens[(128*(Filtering))+paletteEntry];
2933               // *BITMAP_ADDR32(Color, y, x_start) = machine->pens[(128*(Filtering))+paletteEntry];
26802934               *cb = machine->pens[(128*(Filtering))+paletteEntry];
26812935               *db = z_start;
26822936            }
26832937         }
26842938         else
26852939         {
2686            //*BITMAP_ADDR32(Color, y, x_start) = MAKE_ARGB(255, (UINT8)(r_start/w_start), (UINT8)(g_start/w_start), (UINT8)(b_start/w_start));
2940            // *BITMAP_ADDR32(Color, y, x_start) = MAKE_ARGB(255, (UINT8)(r_start/w_start), (UINT8)(g_start/w_start), (UINT8)(b_start/w_start));
26872941            *cb = MAKE_ARGB(255, (UINT8)(r_start/w_start), (UINT8)(g_start/w_start), (UINT8)(b_start/w_start));
26882942            *db = z_start;
26892943         }
r6740r6741
27302984//   nearest and bilinear filtering: Filtering={0,1}
27312985//   replace and modulate application modes: Function={0,1}
27322986//---------------------------------------------------------------------------
2733static void RasterizeTriangle_SMOOTH_TEX_PC(running_machine *machine, bitmap_t *Color,
2987static void RasterizeTriangle_SMOOTH_TEX_PC(running_machine *machine,
27342988                                 float A[4], float B[4], float C[4],
27352989                                 float Ca[3], float Cb[3], float Cc[3], // PER-VERTEX RGB COLORS
27362990                                 float Ta[2], float Tb[2], float Tc[2], // PER-VERTEX (S,T) TEX-COORDS
r6740r6741
29253179
29263180      // Pass the horizontal line to the filler, this could be put in the routine
29273181      // then interpolate for the next values of x and z
2928      FillSmoothTexPCHorizontalLine(machine, Color, Wrapping, Filtering, Function,
3182      FillSmoothTexPCHorizontalLine(machine, Wrapping, Filtering, Function,
29293183         x_start, x_end, y_min, z_interp_x, z_delta_x, w_interp_x, w_delta_x,
29303184         r_interp_x, r_delta_x, g_interp_x, g_delta_x, b_interp_x, b_delta_x,
29313185         s_interp_x, s_delta_x, t_interp_x, t_delta_x);
r6740r6741
30053259
30063260      // Pass the horizontal line to the filler, this could be put in the routine
30073261      // then interpolate for the next values of x and z
3008      FillSmoothTexPCHorizontalLine(machine, Color, Wrapping, Filtering, Function,
3262      FillSmoothTexPCHorizontalLine(machine, Wrapping, Filtering, Function,
30093263         x_start, x_end, y_mid, z_interp_x, z_delta_x, w_interp_x, w_delta_x,
30103264         r_interp_x, r_delta_x, g_interp_x, g_delta_x, b_interp_x, b_delta_x,
30113265         s_interp_x, s_delta_x, t_interp_x, t_delta_x);
r6740r6741
30203274   }
30213275}
30223276
3023static void drawShaded(running_machine *machine, struct polygon *p, bitmap_t *bitmap)
3277static void drawShaded(running_machine *machine, struct polygon *p)
30243278{
30253279   // The perspective-correct texture divide...
30263280   // !!! There is a very good chance the HNG64 hardware does not do perspective-correct texture-mapping !!!
r6740r6741
30373291
30383292   for (j = 1; j < p->n-1; j++)
30393293   {
3040      RasterizeTriangle_SMOOTH_TEX_PC(machine, bitmap,
3294      RasterizeTriangle_SMOOTH_TEX_PC(machine,
30413295                              p->vert[0].clipCoords, p->vert[j].clipCoords, p->vert[j+1].clipCoords,
30423296                              p->vert[0].light,      p->vert[j].light,      p->vert[j+1].light,
30433297                              p->vert[0].texCoords,  p->vert[j].texCoords,  p->vert[j+1].texCoords,
src/mame/video/solomon.c
r6740r6741
11#include "driver.h"
22
3UINT8 *solomon_videoram;
4UINT8 *solomon_colorram;
35UINT8 *solomon_videoram2;
46UINT8 *solomon_colorram2;
57
r6740r6741
79
810WRITE8_HANDLER( solomon_videoram_w )
911{
10   space->machine->generic.videoram.u8[offset] = data;
12   solomon_colorram[offset] = data;
1113   tilemap_mark_tile_dirty(fg_tilemap, offset);
1214}
1315
1416WRITE8_HANDLER( solomon_colorram_w )
1517{
16   space->machine->generic.colorram.u8[offset] = data;
18   solomon_colorram[offset] = data;
1719   tilemap_mark_tile_dirty(fg_tilemap, offset);
1820}
1921
r6740r6741
5052
5153static TILE_GET_INFO( get_fg_tile_info )
5254{
53   int attr = machine->generic.colorram.u8[tile_index];
54   int code = machine->generic.videoram.u8[tile_index] + 256 * (attr & 0x07);
55   int attr = solomon_colorram[tile_index];
56   int code = solomon_colorram[tile_index] + 256 * (attr & 0x07);
5557   int color = (attr & 0x70) >> 4;
5658
5759   SET_TILE_INFO(0, code, color, 0);
src/mame/video/moo.c
r6740r6741
99***************************************************************************/
1010
1111#include "driver.h"
12#include "video/konamiic.h"
12#include "video/konicdev.h"
1313
1414static int sprite_colorbase;
1515static int layer_colorbase[4], layerpri[3];
r6740r6741
2222}
2323#endif
2424
25static void moo_sprite_callback(int *code, int *color, int *priority_mask)
25void moo_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask)
2626{
2727   int pri = (*color & 0x03e0) >> 4;
2828
r6740r6741
3434   *color = sprite_colorbase | (*color & 0x001f);
3535}
3636
37static void moo_tile_callback(int layer, int *code, int *color, int *flags)
37void moo_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags)
3838{
3939   *color = layer_colorbase[layer] | (*color>>2 & 0x0f);
4040}
4141
4242VIDEO_START(moo)
4343{
44   int offsx, offsy;
45
44   const device_config *k056832 = devtag_get_device(machine, "k056832");
4645   assert(video_screen_get_format(machine->primary_screen) == BITMAP_FORMAT_RGB32);
4746
4847   alpha_enabled = 0;
4948
50   K053251_vh_start(machine);
51   K054338_vh_start(machine);
52
53   K056832_vh_start(machine, "gfx1", K056832_BPP_4, 1, NULL, moo_tile_callback, 0);
54
5549   if (!strcmp(machine->gamedrv->name, "bucky") || !strcmp(machine->gamedrv->name, "buckyua") || !strcmp(machine->gamedrv->name, "buckyaa"))
5650   {
5751      // Bucky doesn't chain tilemaps
58      K056832_set_LayerAssociation(0);
52      k056832_set_layer_association(k056832, 0);
5953
60      K056832_set_LayerOffset(0, -2, 0);
61      K056832_set_LayerOffset(1,  2, 0);
62      K056832_set_LayerOffset(2,  4, 0);
63      K056832_set_LayerOffset(3,  6, 0);
64
65      offsx = -48;
66      offsy =  23;
54      k056832_set_layer_offs(k056832, 0, -2, 0);
55      k056832_set_layer_offs(k056832, 1,  2, 0);
56      k056832_set_layer_offs(k056832, 2,  4, 0);
57      k056832_set_layer_offs(k056832, 3,  6, 0);
6758   }
6859   else
6960   {
7061      // other than the intro showing one blank line alignment is good through the game
71      K056832_set_LayerOffset(0, -2+1, 0);
72      K056832_set_LayerOffset(1,  2+1, 0);
73      K056832_set_LayerOffset(2,  4+1, 0);
74      K056832_set_LayerOffset(3,  6+1, 0);
75
76      offsx = -48+1;
77      offsy =  23;
62      k056832_set_layer_offs(k056832, 0, -2+1, 0);
63      k056832_set_layer_offs(k056832, 1,  2+1, 0);
64      k056832_set_layer_offs(k056832, 2,  4+1, 0);
65      k056832_set_layer_offs(k056832, 3,  6+1, 0);
7866   }
79
80   K053247_vh_start(machine, "gfx2", offsx, offsy, NORMAL_PLANE_ORDER, moo_sprite_callback);
81
82   K054338_invert_alpha(0);
8367}
8468
8569/* useful function to sort the three tile layers by priority order */
r6740r6741
10084
10185VIDEO_UPDATE(moo)
10286{
87   const device_config *k053246 = devtag_get_device(screen->machine, "k053246");
88   const device_config *k056832 = devtag_get_device(screen->machine, "k056832");
89   const device_config *k053251 = devtag_get_device(screen->machine, "k053251");
90   const device_config *k054338 = devtag_get_device(screen->machine, "k054338");
10391   static const int K053251_CI[4] = { K053251_CI1, K053251_CI2, K053251_CI3, K053251_CI4 };
10492   int layers[3];
10593   int bg_colorbase, new_colorbase, plane, dirty, alpha;
10694
107   bg_colorbase       = K053251_get_palette_index(K053251_CI1);
108   sprite_colorbase   = K053251_get_palette_index(K053251_CI0);
95   bg_colorbase       = k053251_get_palette_index(k053251, K053251_CI1);
96   sprite_colorbase   = k053251_get_palette_index(k053251, K053251_CI0);
10997   layer_colorbase[0] = 0x70;
11098
111   if (K056832_get_LayerAssociation())
99   if (k056832_get_layer_association(k056832))
112100   {
113      for (plane=1; plane<4; plane++)
101      for (plane = 1; plane < 4; plane++)
114102      {
115         new_colorbase = K053251_get_palette_index(K053251_CI[plane]);
103         new_colorbase = k053251_get_palette_index(k053251, K053251_CI[plane]);
116104         if (layer_colorbase[plane] != new_colorbase)
117105         {
118106            layer_colorbase[plane] = new_colorbase;
119            K056832_mark_plane_dirty(plane);
107            k056832_mark_plane_dirty(k056832, plane);
120108         }
121109      }
122110   }
123111   else
124112   {
125      for (dirty=0, plane=1; plane<4; plane++)
113      for (dirty = 0, plane = 1; plane < 4; plane++)
126114      {
127         new_colorbase = K053251_get_palette_index(K053251_CI[plane]);
115         new_colorbase = k053251_get_palette_index(k053251, K053251_CI[plane]);
128116         if (layer_colorbase[plane] != new_colorbase)
129117         {
130118            layer_colorbase[plane] = new_colorbase;
131119            dirty = 1;
132120         }
133121      }
134      if (dirty) K056832_MarkAllTilemapsDirty();
122      if (dirty)
123         k056832_mark_all_tmaps_dirty(k056832);
135124   }
136125
137126   layers[0] = 1;
138   layerpri[0] = K053251_get_priority(K053251_CI2);
127   layerpri[0] = k053251_get_priority(k053251, K053251_CI2);
139128   layers[1] = 2;
140   layerpri[1] = K053251_get_priority(K053251_CI3);
129   layerpri[1] = k053251_get_priority(k053251, K053251_CI3);
141130   layers[2] = 3;
142   layerpri[2] = K053251_get_priority(K053251_CI4);
131   layerpri[2] = k053251_get_priority(k053251, K053251_CI4);
143132
144133   sortlayers(layers, layerpri);
145134
146   K054338_update_all_shadows(screen->machine, 0);
147   K054338_fill_backcolor(screen->machine, bitmap, 0);
135   k054338_update_all_shadows(k054338, 0);
136   k054338_fill_backcolor(k054338, bitmap, 0);
148137
149138   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
150139
151   if (layerpri[0] < K053251_get_priority(K053251_CI1))   /* bucky hides back layer behind background */
152      K056832_tilemap_draw(screen->machine, bitmap, cliprect, layers[0], 0, 1);
140   if (layerpri[0] < k053251_get_priority(k053251, K053251_CI1))   /* bucky hides back layer behind background */
141      k056832_tilemap_draw(k056832, bitmap, cliprect, layers[0], 0, 1);
153142
154   K056832_tilemap_draw(screen->machine, bitmap, cliprect, layers[1], 0, 2);
143   k056832_tilemap_draw(k056832, bitmap, cliprect, layers[1], 0, 2);
155144
156145   // Enabling alpha improves fog and fading in Moo but causes other things to disappear.
157146   // There is probably a control bit somewhere to turn off alpha blending.
158   alpha_enabled = K054338_read_register(K338_REG_CONTROL) & K338_CTL_MIXPRI; // DUMMY
147   alpha_enabled = k054338_register_r(k054338, K338_REG_CONTROL) & K338_CTL_MIXPRI; // DUMMY
159148
160   alpha = (alpha_enabled) ? K054338_set_alpha_level(1) : 255;
149   alpha = (alpha_enabled) ? k054338_set_alpha_level(k054338, 1) : 255;
161150
162151   if (alpha > 0)
163      K056832_tilemap_draw(screen->machine, bitmap, cliprect, layers[2], TILEMAP_DRAW_ALPHA(alpha), 4);
152      k056832_tilemap_draw(k056832, bitmap, cliprect, layers[2], TILEMAP_DRAW_ALPHA(alpha), 4);
164153
165   K053247_sprites_draw(screen->machine, bitmap,cliprect);
154   k053247_sprites_draw(k053246, bitmap, cliprect);
166155
167   K056832_tilemap_draw(screen->machine, bitmap, cliprect, 0, 0, 0);
156   k056832_tilemap_draw(k056832, bitmap, cliprect, 0, 0, 0);
168157   return 0;
169158}
src/mame/video/fastlane.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
3#include "includes/fastlane.h"
34
4UINT8 *fastlane_k007121_regs,*fastlane_videoram1,*fastlane_videoram2;
5static tilemap *layer0, *layer1;
6static rectangle clip0, clip1;
75
8
96PALETTE_INIT( fastlane )
107{
118   int pal;
r6740r6741
2623}
2724
2825
29static void set_pens(running_machine *machine)
26static void set_pens( running_machine *machine )
3027{
28   fastlane_state *state = (fastlane_state *)machine->driver_data;
3129   int i;
3230
3331   for (i = 0x00; i < 0x800; i += 2)
3432   {
35      UINT16 data = machine->generic.paletteram.u8[i | 1] | (machine->generic.paletteram.u8[i] << 8);
33      UINT16 data = state->paletteram[i | 1] | (state->paletteram[i] << 8);
3634
3735      rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
3836
r6740r6741
5048
5149static TILE_GET_INFO( get_tile_info0 )
5250{
53   int attr = fastlane_videoram1[tile_index];
54   int code = fastlane_videoram1[tile_index + 0x400];
55   int bit0 = (K007121_ctrlram[0][0x05] >> 0) & 0x03;
56   int bit1 = (K007121_ctrlram[0][0x05] >> 2) & 0x03;
57   int bit2 = (K007121_ctrlram[0][0x05] >> 4) & 0x03;
58   int bit3 = (K007121_ctrlram[0][0x05] >> 6) & 0x03;
51   fastlane_state *state = (fastlane_state *)machine->driver_data;
52   UINT8 ctrl_3 = k007121_ctrlram_r(state->k007121, 3);
53   UINT8 ctrl_4 = k007121_ctrlram_r(state->k007121, 4);
54   UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121, 5);
55   int attr = state->videoram1[tile_index];
56   int code = state->videoram1[tile_index + 0x400];
57   int bit0 = (ctrl_5 >> 0) & 0x03;
58   int bit1 = (ctrl_5 >> 2) & 0x03;
59   int bit2 = (ctrl_5 >> 4) & 0x03;
60   int bit3 = (ctrl_5 >> 6) & 0x03;
5961   int bank = ((attr & 0x80) >> 7) |
6062         ((attr >> (bit0+2)) & 0x02) |
6163         ((attr >> (bit1+1)) & 0x04) |
6264         ((attr >> (bit2  )) & 0x08) |
6365         ((attr >> (bit3-1)) & 0x10) |
64         ((K007121_ctrlram[0][0x03] & 0x01) << 5);
65   int mask = (K007121_ctrlram[0][0x04] & 0xf0) >> 4;
66         ((ctrl_3 & 0x01) << 5);
67   int mask = (ctrl_4 & 0xf0) >> 4;
6668
67   bank = (bank & ~(mask << 1)) | ((K007121_ctrlram[0][0x04] & mask) << 1);
69   bank = (bank & ~(mask << 1)) | ((ctrl_4 & mask) << 1);
6870
6971   SET_TILE_INFO(
7072         0,
r6740r6741
7577
7678static TILE_GET_INFO( get_tile_info1 )
7779{
78   int attr = fastlane_videoram2[tile_index];
79   int code = fastlane_videoram2[tile_index + 0x400];
80   int bit0 = (K007121_ctrlram[0][0x05] >> 0) & 0x03;
81   int bit1 = (K007121_ctrlram[0][0x05] >> 2) & 0x03;
82   int bit2 = (K007121_ctrlram[0][0x05] >> 4) & 0x03;
83   int bit3 = (K007121_ctrlram[0][0x05] >> 6) & 0x03;
80   fastlane_state *state = (fastlane_state *)machine->driver_data;
81   UINT8 ctrl_3 = k007121_ctrlram_r(state->k007121, 3);
82   UINT8 ctrl_4 = k007121_ctrlram_r(state->k007121, 4);
83   UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121, 5);
84   int attr = state->videoram2[tile_index];
85   int code = state->videoram2[tile_index + 0x400];
86   int bit0 = (ctrl_5 >> 0) & 0x03;
87   int bit1 = (ctrl_5 >> 2) & 0x03;
88   int bit2 = (ctrl_5 >> 4) & 0x03;
89   int bit3 = (ctrl_5 >> 6) & 0x03;
8490   int bank = ((attr & 0x80) >> 7) |
8591         ((attr >> (bit0+2)) & 0x02) |
8692         ((attr >> (bit1+1)) & 0x04) |
8793         ((attr >> (bit2  )) & 0x08) |
8894         ((attr >> (bit3-1)) & 0x10) |
89         ((K007121_ctrlram[0][0x03] & 0x01) << 5);
90   int mask = (K007121_ctrlram[0][0x04] & 0xf0) >> 4;
95         ((ctrl_3 & 0x01) << 5);
96   int mask = (ctrl_4 & 0xf0) >> 4;
9197
92   bank = (bank & ~(mask << 1)) | ((K007121_ctrlram[0][0x04] & mask) << 1);
98   bank = (bank & ~(mask << 1)) | ((ctrl_4 & mask) << 1);
9399
94100   SET_TILE_INFO(
95101         0,
r6740r6741
106112
107113VIDEO_START( fastlane )
108114{
109   layer0 = tilemap_create(machine, get_tile_info0,tilemap_scan_rows,8,8,32,32);
110   layer1 = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,8,8,32,32);
115   fastlane_state *state = (fastlane_state *)machine->driver_data;
111116
112   tilemap_set_scroll_rows( layer0, 32 );
117   state->layer0 = tilemap_create(machine, get_tile_info0, tilemap_scan_rows, 8, 8, 32, 32);
118   state->layer1 = tilemap_create(machine, get_tile_info1, tilemap_scan_rows, 8, 8, 32, 32);
113119
114   clip0 = *video_screen_get_visible_area(machine->primary_screen);
115   clip0.min_x += 40;
120   tilemap_set_scroll_rows(state->layer0, 32);
116121
117   clip1 = *video_screen_get_visible_area(machine->primary_screen);
118   clip1.max_x = 39;
119   clip1.min_x = 0;
122   state->clip0 = *video_screen_get_visible_area(machine->primary_screen);
123   state->clip0.min_x += 40;
124
125   state->clip1 = *video_screen_get_visible_area(machine->primary_screen);
126   state->clip1.max_x = 39;
127   state->clip1.min_x = 0;
120128}
121129
122130/***************************************************************************
r6740r6741
127135
128136WRITE8_HANDLER( fastlane_vram1_w )
129137{
130   fastlane_videoram1[offset] = data;
131   tilemap_mark_tile_dirty(layer0,offset & 0x3ff);
138   fastlane_state *state = (fastlane_state *)space->machine->driver_data;
139   state->videoram1[offset] = data;
140   tilemap_mark_tile_dirty(state->layer0, offset & 0x3ff);
132141}
133142
134143WRITE8_HANDLER( fastlane_vram2_w )
135144{
136   fastlane_videoram2[offset] = data;
137   tilemap_mark_tile_dirty(layer1,offset & 0x3ff);
145   fastlane_state *state = (fastlane_state *)space->machine->driver_data;
146   state->videoram2[offset] = data;
147   tilemap_mark_tile_dirty(state->layer1, offset & 0x3ff);
138148}
139149
140150
r6740r6741
147157
148158VIDEO_UPDATE( fastlane )
149159{
150   rectangle finalclip0 = clip0, finalclip1 = clip1;
160   fastlane_state *state = (fastlane_state *)screen->machine->driver_data;
161   rectangle finalclip0 = state->clip0, finalclip1 = state->clip1;
151162   int i, xoffs;
152163
153164   sect_rect(&finalclip0, cliprect);
r6740r6741
156167   set_pens(screen->machine);
157168
158169   /* set scroll registers */
159   xoffs = K007121_ctrlram[0][0x00];
160   for( i=0; i<32; i++ ){
161      tilemap_set_scrollx(layer0, i, fastlane_k007121_regs[0x20 + i] + xoffs - 40);
162   }
163   tilemap_set_scrolly( layer0, 0, K007121_ctrlram[0][0x02] );
170   xoffs = k007121_ctrlram_r(state->k007121, 0);
171   for (i = 0; i < 32; i++)
172      tilemap_set_scrollx(state->layer0, i, state->k007121_regs[0x20 + i] + xoffs - 40);
164173
165   tilemap_draw(bitmap,&finalclip0,layer0,0,0);
166   K007121_sprites_draw(0,bitmap,cliprect,screen->machine->gfx,screen->machine->colortable,screen->machine->generic.spriteram.u8,0,40,0,-1);
167   tilemap_draw(bitmap,&finalclip1,layer1,0,0);
174   tilemap_set_scrolly(state->layer0, 0, k007121_ctrlram_r(state->k007121, 2));
175
176   tilemap_draw(bitmap, &finalclip0, state->layer0, 0, 0);
177   k007121_sprites_draw(state->k007121, bitmap, cliprect, screen->machine->gfx[0], screen->machine->colortable, state->spriteram, 0, 40, 0, -1);
178   tilemap_draw(bitmap, &finalclip1, state->layer1, 0, 0);
168179   return 0;
169180}
src/mame/video/cidelsa.c
r6740r6741
11#include "driver.h"
22#include "sound/cdp1869.h"
33#include "sound/ay8910.h"
4#include "cidelsa.h"
4#include "includes/cidelsa.h"
55
66/* Page RAM Access */
77
src/mame/video/vendetta.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
44
55static int layer_colorbase[3],bg_colorbase,sprite_colorbase;
r6740r6741
1212
1313***************************************************************************/
1414
15static void vendetta_tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
15void vendetta_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
1616{
1717   *code |= ((*color & 0x03) << 8) | ((*color & 0x30) << 6) |
1818         ((*color & 0x0c) << 10) | (bank << 14);
1919   *color = layer_colorbase[layer] + ((*color & 0xc0) >> 6);
2020}
2121
22static void esckids_tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
22void esckids_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
2323{
2424   *code |= ((*color & 0x03) << 8) | ((*color & 0x10) << 6) |
2525         ((*color & 0x0c) <<  9) | (bank << 13);
r6740r6741
3333
3434***************************************************************************/
3535
36static void sprite_callback(int *code,int *color,int *priority_mask)
36void vendetta_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask)
3737{
3838   int pri = (*color & 0x03e0) >> 4;   /* ??????? */
3939   if (pri <= layerpri[2])                        *priority_mask = 0;
r6740r6741
4545}
4646
4747
48
4948/***************************************************************************
5049
51    Start the video hardware emulation.
52
53***************************************************************************/
54
55VIDEO_START( vendetta )
56{
57   K053251_vh_start(machine);
58
59   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,vendetta_tile_callback);
60   K053247_vh_start(machine,"gfx2",53,6,NORMAL_PLANE_ORDER,sprite_callback);
61}
62
63VIDEO_START( esckids )
64{
65    K053251_vh_start(machine);
66
67    K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,esckids_tile_callback);
68   K053247_vh_start(machine,"gfx2",101,6,NORMAL_PLANE_ORDER,sprite_callback);
69}
70
71
72
73/***************************************************************************
74
7550  Display refresh
7651
7752***************************************************************************/
r6740r6741
9469
9570VIDEO_UPDATE( vendetta )
9671{
72   const device_config *k053246 = devtag_get_device(screen->machine, "k053246");
73   const device_config *k053251 = devtag_get_device(screen->machine, "k053251");
74   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
9775   int layer[3];
9876
9977
100   bg_colorbase       = K053251_get_palette_index(K053251_CI0);
101   sprite_colorbase   = K053251_get_palette_index(K053251_CI1);
102   layer_colorbase[0] = K053251_get_palette_index(K053251_CI2);
103   layer_colorbase[1] = K053251_get_palette_index(K053251_CI3);
104   layer_colorbase[2] = K053251_get_palette_index(K053251_CI4);
78   bg_colorbase       = k053251_get_palette_index(k053251, K053251_CI0);
79   sprite_colorbase   = k053251_get_palette_index(k053251, K053251_CI1);
80   layer_colorbase[0] = k053251_get_palette_index(k053251, K053251_CI2);
81   layer_colorbase[1] = k053251_get_palette_index(k053251, K053251_CI3);
82   layer_colorbase[2] = k053251_get_palette_index(k053251, K053251_CI4);
10583
106   K052109_tilemap_update();
84   k052109_tilemap_update(k052109);
10785
10886   layer[0] = 0;
109   layerpri[0] = K053251_get_priority(K053251_CI2);
87   layerpri[0] = k053251_get_priority(k053251, K053251_CI2);
11088   layer[1] = 1;
111   layerpri[1] = K053251_get_priority(K053251_CI3);
89   layerpri[1] = k053251_get_priority(k053251, K053251_CI3);
11290   layer[2] = 2;
113   layerpri[2] = K053251_get_priority(K053251_CI4);
91   layerpri[2] = k053251_get_priority(k053251, K053251_CI4);
11492
11593   sortlayers(layer,layerpri);
11694
11795   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
118   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[0]],TILEMAP_DRAW_OPAQUE,1);
119   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[1]],0,2);
120   tilemap_draw(bitmap,cliprect,K052109_tilemap[layer[2]],0,4);
96   k052109_tilemap_draw(k052109, bitmap, cliprect, layer[0], TILEMAP_DRAW_OPAQUE, 1);
97   k052109_tilemap_draw(k052109, bitmap, cliprect, layer[1], 0, 2);
98   k052109_tilemap_draw(k052109, bitmap, cliprect, layer[2], 0, 4);
12199
122   K053247_sprites_draw(screen->machine, bitmap,cliprect);
100   k053247_sprites_draw(k053246, bitmap, cliprect);
123101   return 0;
124102}
src/mame/video/fcombat.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "fcombat.h"
8#include "includes/fcombat.h"
99
1010
1111static TILE_GET_INFO( get_bg_tile_info )
src/mame/video/pktgaldx.c
r6740r6741
11#include "driver.h"
2#include "deco16ic.h"
2#include "includes/deco16ic.h"
33
44UINT16* pcktgaldb_fgram;
55UINT16* pcktgaldb_sprites;
src/mame/video/atarigx2.c
r6740r6741
2121
2222#include "driver.h"
2323#include "machine/atarigen.h"
24#include "atarigx2.h"
24#include "includes/atarigx2.h"
2525
2626
2727
r6740r6741
108108   /* initialize the alphanumerics */
109109   state->atarigen.alpha_tilemap = tilemap_create(machine, get_alpha_tile_info, tilemap_scan_rows,  8,8, 64,32);
110110   tilemap_set_transparent_pen(state->atarigen.alpha_tilemap, 0);
111
112   /* save states */
113   state_save_register_global(machine, state->current_control);
114   state_save_register_global(machine, state->playfield_tile_bank);
115   state_save_register_global(machine, state->playfield_color_bank);
116   state_save_register_global(machine, state->playfield_xscroll);
117   state_save_register_global(machine, state->playfield_yscroll);
111118}
112119
113120
src/mame/video/fuukifg2.c
r6740r6741
2525***************************************************************************/
2626
2727#include "driver.h"
28#include "fuukifg2.h"
28#include "includes/fuukifg2.h"
2929
3030/***************************************************************************
3131
src/mame/video/circus.c
r6740r6741
1212
1313#include "driver.h"
1414#include "sound/samples.h"
15#include "circus.h"
15#include "includes/circus.h"
1616
1717
1818WRITE8_HANDLER( circus_videoram_w )
src/mame/video/relief.c
r6740r6741
66
77#include "driver.h"
88#include "machine/atarigen.h"
9#include "relief.h"
9#include "includes/relief.h"
1010
1111
1212
src/mame/video/taito_f3.c
r6740r6741
205205***************************************************************************/
206206
207207#include "driver.h"
208#include "taito_f3.h"
208#include "includes/taito_f3.h"
209209#include "ui.h"
210210
211211#define VERBOSE 0
src/mame/video/champbas.c
r6740r6741
11#include "driver.h"
22#include "video/resnet.h"
3#include "champbas.h"
3#include "includes/champbas.h"
44
55
66/***************************************************************************
src/mame/video/ssozumo.c
r6740r6741
99
1010#include "driver.h"
1111
12UINT8 *ssozumo_videoram;
13UINT8 *ssozumo_colorram;
1214UINT8 *ssozumo_videoram2;
1315UINT8 *ssozumo_colorram2;
1416
r6740r6741
4648
4749WRITE8_HANDLER( ssozumo_videoram_w )
4850{
49   space->machine->generic.videoram.u8[offset] = data;
51   ssozumo_videoram[offset] = data;
5052   tilemap_mark_tile_dirty(bg_tilemap, offset);
5153}
5254
5355WRITE8_HANDLER( ssozumo_colorram_w )
5456{
55   space->machine->generic.colorram.u8[offset] = data;
57   ssozumo_colorram[offset] = data;
5658   tilemap_mark_tile_dirty(bg_tilemap, offset);
5759}
5860
r6740r6741
113115
114116static TILE_GET_INFO( get_bg_tile_info )
115117{
116   int code = machine->generic.videoram.u8[tile_index] + ((machine->generic.colorram.u8[tile_index] & 0x08) << 5);
117   int color = (machine->generic.colorram.u8[tile_index] & 0x30) >> 4;
118   int code = ssozumo_videoram[tile_index] + ((ssozumo_colorram[tile_index] & 0x08) << 5);
119   int color = (ssozumo_colorram[tile_index] & 0x30) >> 4;
118120   int flags = ((tile_index % 32) >= 16) ? TILE_FLIPY : 0;
119121
120122   SET_TILE_INFO(1, code, color, flags);
src/mame/video/mcr.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "mcr.h"
8#include "includes/mcr.h"
99
1010
1111INT8 mcr12_sprite_xoffs;
src/mame/video/m107.c
r6740r6741
3535*****************************************************************************/
3636
3737#include "driver.h"
38#include "m107.h"
38#include "includes/m107.h"
3939
4040typedef struct _pf_layer_info pf_layer_info;
4141struct _pf_layer_info
src/mame/video/matmania.c
r6740r6741
1717
1818
1919
20UINT8 *matmania_videoram,*matmania_colorram;
21size_t matmania_videoram_size;
2022UINT8 *matmania_videoram2,*matmania_colorram2;
2123size_t matmania_videoram2_size;
2224UINT8 *matmania_videoram3,*matmania_colorram3;
r6740r6741
144146
145147
146148   /* Update the tiles in the left tile ram bank */
147   for (offs = screen->machine->generic.videoram_size - 1;offs >= 0;offs--)
149   for (offs = matmania_videoram_size - 1;offs >= 0;offs--)
148150   {
149151      int sx,sy;
150152
r6740r6741
153155      sy = offs % 32;
154156
155157      drawgfx_opaque(tmpbitmap,0,screen->machine->gfx[1],
156            screen->machine->generic.videoram.u8[offs] + ((screen->machine->generic.colorram.u8[offs] & 0x08) << 5),
157            (screen->machine->generic.colorram.u8[offs] & 0x30) >> 4,
158            matmania_videoram3[offs] + ((matmania_colorram[offs] & 0x08) << 5),
159            (matmania_colorram[offs] & 0x30) >> 4,
158160            0,sy >= 16,   /* flip horizontally tiles on the right half of the bitmap */
159161            16*sx,16*sy);
160162   }
r6740r6741
228230
229231
230232   /* Update the tiles in the left tile ram bank */
231   for (offs = screen->machine->generic.videoram_size - 1;offs >= 0;offs--)
233   for (offs = matmania_videoram_size - 1;offs >= 0;offs--)
232234   {
233235      int sx,sy;
234236
r6740r6741
237239      sy = offs % 32;
238240
239241      drawgfx_opaque(tmpbitmap,0,screen->machine->gfx[1],
240            screen->machine->generic.videoram.u8[offs] + ((screen->machine->generic.colorram.u8[offs] & 0x03) << 8),
241            (screen->machine->generic.colorram.u8[offs] & 0x30) >> 4,
242            matmania_videoram[offs] + ((matmania_colorram[offs] & 0x03) << 8),
243            (matmania_colorram[offs] & 0x30) >> 4,
242244            0,sy >= 16,   /* flip horizontally tiles on the right half of the bitmap */
243245            16*sx,16*sy);
244246   }
src/mame/video/megasys1.c
r6740r6741
192192***************************************************************************/
193193
194194#include "driver.h"
195#include "megasys1.h"
195#include "includes/megasys1.h"
196196
197197/* Variables defined here, that have to be shared: */
198198tilemap *megasys1_tmap[3];
src/mame/video/crshrace.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
3#include "crshrace.h"
2#include "video/konicdev.h"
3#include "includes/crshrace.h"
44
55
6UINT16 *crshrace_videoram1,*crshrace_videoram2;
7//UINT16 *crshrace_roz_ctrl1,*crshrace_roz_ctrl2;
8
9static int roz_bank,gfxctrl,flipscreen;
10
11static tilemap *tilemap1,*tilemap2;
12
13
14
156/***************************************************************************
167
178  Callbacks for the TileMap code
r6740r6741
2011
2112static TILE_GET_INFO( get_tile_info1 )
2213{
23   int code = crshrace_videoram1[tile_index];
14   crshrace_state *state = (crshrace_state *)machine->driver_data;
15   int code = state->videoram1[tile_index];
2416
25   SET_TILE_INFO(1,(code & 0xfff) + (roz_bank << 12),code >> 12,0);
17   SET_TILE_INFO(1, (code & 0xfff) + (state->roz_bank << 12), code >> 12, 0);
2618}
2719
2820static TILE_GET_INFO( get_tile_info2 )
2921{
30   int code = crshrace_videoram2[tile_index];
22   crshrace_state *state = (crshrace_state *)machine->driver_data;
23   int code = state->videoram2[tile_index];
3124
32   SET_TILE_INFO(0,code,0,0);
25   SET_TILE_INFO(0, code, 0, 0);
3326}
3427
3528
r6740r6741
4134
4235VIDEO_START( crshrace )
4336{
44   tilemap1 = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,16,16,64,64);
45   tilemap2 = tilemap_create(machine, get_tile_info2,tilemap_scan_rows, 8, 8,64,64);
37   crshrace_state *state = (crshrace_state *)machine->driver_data;
4638
47   K053936_wraparound_enable(0, 1);
48   K053936_set_offset(0, -48, -21);
39   state->tilemap1 = tilemap_create(machine, get_tile_info1, tilemap_scan_rows, 16, 16, 64, 64);
40   state->tilemap2 = tilemap_create(machine, get_tile_info2, tilemap_scan_rows, 8, 8, 64, 64);
4941
50   tilemap_set_transparent_pen(tilemap1,0x0f);
51   tilemap_set_transparent_pen(tilemap2,0xff);
42   tilemap_set_transparent_pen(state->tilemap1, 0x0f);
43   tilemap_set_transparent_pen(state->tilemap2, 0xff);
5244}
5345
5446
r6740r6741
6052
6153WRITE16_HANDLER( crshrace_videoram1_w )
6254{
63   COMBINE_DATA(&crshrace_videoram1[offset]);
64   tilemap_mark_tile_dirty(tilemap1,offset);
55   crshrace_state *state = (crshrace_state *)space->machine->driver_data;
56
57   COMBINE_DATA(&state->videoram1[offset]);
58   tilemap_mark_tile_dirty(state->tilemap1, offset);
6559}
6660
6761WRITE16_HANDLER( crshrace_videoram2_w )
6862{
69   COMBINE_DATA(&crshrace_videoram2[offset]);
70   tilemap_mark_tile_dirty(tilemap2,offset);
63   crshrace_state *state = (crshrace_state *)space->machine->driver_data;
64
65   COMBINE_DATA(&state->videoram2[offset]);
66   tilemap_mark_tile_dirty(state->tilemap2, offset);
7167}
7268
7369WRITE16_HANDLER( crshrace_roz_bank_w )
7470{
71   crshrace_state *state = (crshrace_state *)space->machine->driver_data;
72
7573   if (ACCESSING_BITS_0_7)
7674   {
77      if (roz_bank != (data & 0xff))
75      if (state->roz_bank != (data & 0xff))
7876      {
79         roz_bank = data & 0xff;
80         tilemap_mark_all_tiles_dirty(tilemap1);
77         state->roz_bank = data & 0xff;
78         tilemap_mark_all_tiles_dirty(state->tilemap1);
8179      }
8280   }
8381}
r6740r6741
8583
8684WRITE16_HANDLER( crshrace_gfxctrl_w )
8785{
86   crshrace_state *state = (crshrace_state *)space->machine->driver_data;
87
8888   if (ACCESSING_BITS_0_7)
8989   {
90      gfxctrl = data & 0xdf;
91      flipscreen = data & 0x20;
90      state->gfxctrl = data & 0xdf;
91      state->flipscreen = data & 0x20;
9292   }
9393}
9494
r6740r6741
101101
102102static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
103103{
104   UINT16 *buffered_spriteram16 = machine->generic.buffered_spriteram.u16;
105   UINT16 *buffered_spriteram16_2 = machine->generic.buffered_spriteram2.u16;
104   crshrace_state *state = (crshrace_state *)machine->driver_data;
105   UINT16 *buffered_spriteram = machine->generic.buffered_spriteram.u16;
106   UINT16 *buffered_spriteram_2 = machine->generic.buffered_spriteram2.u16;
106107   int offs;
107108
108
109109   offs = 0;
110   while (offs < 0x0400 && (buffered_spriteram16[offs] & 0x4000) == 0)
110   while (offs < 0x0400 && (buffered_spriteram[offs] & 0x4000) == 0)
111111   {
112112      int attr_start;
113113      int map_start;
114      int ox,oy,x,y,xsize,ysize,zoomx,zoomy,flipx,flipy,color;
114      int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color;
115115      /* table hand made by looking at the ship explosion in aerofgt attract mode */
116116      /* it's almost a logarithmic scale but not exactly */
117117      static const int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 };
118118
119      attr_start = 4 * (buffered_spriteram16[offs++] & 0x03ff);
119      attr_start = 4 * (buffered_spriteram[offs++] & 0x03ff);
120120
121      ox = buffered_spriteram16[attr_start + 1] & 0x01ff;
122      xsize = (buffered_spriteram16[attr_start + 1] & 0x0e00) >> 9;
123      zoomx = (buffered_spriteram16[attr_start + 1] & 0xf000) >> 12;
124      oy = buffered_spriteram16[attr_start + 0] & 0x01ff;
125      ysize = (buffered_spriteram16[attr_start + 0] & 0x0e00) >> 9;
126      zoomy = (buffered_spriteram16[attr_start + 0] & 0xf000) >> 12;
127      flipx = buffered_spriteram16[attr_start + 2] & 0x4000;
128      flipy = buffered_spriteram16[attr_start + 2] & 0x8000;
129      color = (buffered_spriteram16[attr_start + 2] & 0x1f00) >> 8;
130      map_start = buffered_spriteram16[attr_start + 3] & 0x7fff;
121      ox = buffered_spriteram[attr_start + 1] & 0x01ff;
122      xsize = (buffered_spriteram[attr_start + 1] & 0x0e00) >> 9;
123      zoomx = (buffered_spriteram[attr_start + 1] & 0xf000) >> 12;
124      oy = buffered_spriteram[attr_start + 0] & 0x01ff;
125      ysize = (buffered_spriteram[attr_start + 0] & 0x0e00) >> 9;
126      zoomy = (buffered_spriteram[attr_start + 0] & 0xf000) >> 12;
127      flipx = buffered_spriteram[attr_start + 2] & 0x4000;
128      flipy = buffered_spriteram[attr_start + 2] & 0x8000;
129      color = (buffered_spriteram[attr_start + 2] & 0x1f00) >> 8;
130      map_start = buffered_spriteram[attr_start + 3] & 0x7fff;
131131
132      zoomx = 16 - zoomtable[zoomx]/8;
133      zoomy = 16 - zoomtable[zoomy]/8;
132      zoomx = 16 - zoomtable[zoomx] / 8;
133      zoomy = 16 - zoomtable[zoomy] / 8;
134134
135      if (buffered_spriteram16[attr_start + 2] & 0x20ff) color = mame_rand(machine);
135      if (buffered_spriteram[attr_start + 2] & 0x20ff) color = mame_rand(machine);
136136
137      for (y = 0;y <= ysize;y++)
137      for (y = 0; y <= ysize; y++)
138138      {
139139         int sx,sy;
140140
141141         if (flipy) sy = ((oy + zoomy * (ysize - y) + 16) & 0x1ff) - 16;
142142         else sy = ((oy + zoomy * y + 16) & 0x1ff) - 16;
143143
144         for (x = 0;x <= xsize;x++)
144         for (x = 0; x <= xsize; x++)
145145         {
146146            int code;
147147
148148            if (flipx) sx = ((ox + zoomx * (xsize - x) + 16) & 0x1ff) - 16;
149149            else sx = ((ox + zoomx * x + 16) & 0x1ff) - 16;
150150
151            code = buffered_spriteram16_2[map_start & 0x7fff];
151            code = buffered_spriteram_2[map_start & 0x7fff];
152152            map_start++;
153153
154            if (flipscreen)
154            if (state->flipscreen)
155155               drawgfxzoom_transpen(bitmap,cliprect,machine->gfx[2],
156156                     code,
157157                     color,
r6740r6741
171171}
172172
173173
174static void draw_bg(bitmap_t *bitmap,const rectangle *cliprect)
174static void draw_bg( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
175175{
176   tilemap_draw(bitmap,cliprect,tilemap2,0,0);
176   crshrace_state *state = (crshrace_state *)machine->driver_data;
177   tilemap_draw(bitmap, cliprect, state->tilemap2, 0, 0);
177178}
178179
179180
180static void draw_fg(bitmap_t *bitmap,const rectangle *cliprect)
181static void draw_fg(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
181182{
182   K053936_0_zoom_draw(bitmap,cliprect,tilemap1,0,0,1);
183   crshrace_state *state = (crshrace_state *)machine->driver_data;
184   k053936_zoom_draw(state->k053936, bitmap, cliprect, state->tilemap1, 0, 0, 1);
183185}
184186
185187
186188VIDEO_UPDATE( crshrace )
187189{
188   if (gfxctrl & 0x04)   /* display disable? */
190   crshrace_state *state = (crshrace_state *)screen->machine->driver_data;
191
192   if (state->gfxctrl & 0x04)   /* display disable? */
189193   {
190      bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
194      bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
191195      return 0;
192196   }
193197
194   bitmap_fill(bitmap,cliprect,0x1ff);
198   bitmap_fill(bitmap, cliprect, 0x1ff);
195199
196   switch (gfxctrl & 0xfb)
200   switch (state->gfxctrl & 0xfb)
197201   {
198202      case 0x00:   /* high score screen */
199         draw_sprites(screen->machine,bitmap,cliprect);
200         draw_bg(bitmap,cliprect);
201         draw_fg(bitmap,cliprect);
203         draw_sprites(screen->machine, bitmap, cliprect);
204         draw_bg(screen->machine, bitmap, cliprect);
205         draw_fg(screen->machine, bitmap, cliprect);
202206         break;
203207      case 0x01:
204208      case 0x02:
205         draw_bg(bitmap,cliprect);
206         draw_fg(bitmap,cliprect);
207         draw_sprites(screen->machine,bitmap,cliprect);
209         draw_bg(screen->machine, bitmap, cliprect);
210         draw_fg(screen->machine, bitmap, cliprect);
211         draw_sprites(screen->machine, bitmap, cliprect);
208212         break;
209213      default:
210popmessage("gfxctrl = %02x",gfxctrl);
214         popmessage("gfxctrl = %02x", state->gfxctrl);
211215         break;
212216   }
213217   return 0;
r6740r6741
217221{
218222   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
219223
220   buffer_spriteram16_w(space,0,0,0xffff);
221   buffer_spriteram16_2_w(space,0,0,0xffff);
224   buffer_spriteram16_w(space, 0, 0, 0xffff);
225   buffer_spriteram16_2_w(space, 0, 0, 0xffff);
222226}
src/mame/video/airbustr.c
r6740r6741
3131
3232**************************************************************************/
3333#include "driver.h"
34#include "kan_pand.h"
34#include "video/kan_pand.h"
35#include "includes/airbustr.h"
3536
36UINT8 *airbustr_videoram2, *airbustr_colorram2;
37//int airbustr_clear_sprites;
38static tilemap *bg_tilemap, *fg_tilemap;
39static bitmap_t *sprites_bitmap;
40
4137WRITE8_HANDLER( airbustr_videoram_w )
4238{
43   space->machine->generic.videoram.u8[offset] = data;
44   tilemap_mark_tile_dirty(bg_tilemap, offset);
39   airbustr_state *state = (airbustr_state *)space->machine->driver_data;
40   state->videoram[offset] = data;
41   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
4542}
4643
4744WRITE8_HANDLER( airbustr_colorram_w )
4845{
49   space->machine->generic.colorram.u8[offset] = data;
50   tilemap_mark_tile_dirty(bg_tilemap, offset);
46   airbustr_state *state = (airbustr_state *)space->machine->driver_data;
47   state->colorram[offset] = data;
48   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
5149}
5250
5351WRITE8_HANDLER( airbustr_videoram2_w )
5452{
55   airbustr_videoram2[offset] = data;
56   tilemap_mark_tile_dirty(fg_tilemap, offset);
53   airbustr_state *state = (airbustr_state *)space->machine->driver_data;
54   state->videoram2[offset] = data;
55   tilemap_mark_tile_dirty(state->fg_tilemap, offset);
5756}
5857
5958WRITE8_HANDLER( airbustr_colorram2_w )
6059{
61   airbustr_colorram2[offset] = data;
62   tilemap_mark_tile_dirty(fg_tilemap, offset);
60   airbustr_state *state = (airbustr_state *)space->machine->driver_data;
61   state->colorram2[offset] = data;
62   tilemap_mark_tile_dirty(state->fg_tilemap, offset);
6363}
6464
6565/*  Scroll Registers
r6740r6741
7676
7777WRITE8_HANDLER( airbustr_scrollregs_w )
7878{
79   static int bg_scrollx, bg_scrolly, fg_scrollx, fg_scrolly, highbits;
80
79   airbustr_state *state = (airbustr_state *)space->machine->driver_data;
8180   switch (offset)      // offset 0 <-> port 4
8281   {
83      case 0x00:   fg_scrolly =  data;   break;   // low 8 bits
84      case 0x02:   fg_scrollx =  data;   break;
85      case 0x04:   bg_scrolly =  data;   break;
86      case 0x06:   bg_scrollx =  data;   break;
87      case 0x08:   highbits   = ~data;   break;   // complemented high bits
82      case 0x00:   state->fg_scrolly = data;   break;   // low 8 bits
83      case 0x02:   state->fg_scrollx = data;   break;
84      case 0x04:   state->bg_scrolly = data;   break;
85      case 0x06:   state->bg_scrollx = data;   break;
86      case 0x08:   state->highbits   = ~data;   break;   // complemented high bits
8887
8988      default:   logerror("CPU #2 - port %02X written with %02X - PC = %04X\n", offset, data, cpu_get_pc(space->cpu));
9089   }
9190
92   tilemap_set_scrolly(bg_tilemap, 0, ((highbits << 5) & 0x100) + bg_scrolly);
93   tilemap_set_scrollx(bg_tilemap, 0, ((highbits << 6) & 0x100) + bg_scrollx);
94   tilemap_set_scrolly(fg_tilemap, 0, ((highbits << 7) & 0x100) + fg_scrolly);
95   tilemap_set_scrollx(fg_tilemap, 0, ((highbits << 8) & 0x100) + fg_scrollx);
91   tilemap_set_scrolly(state->bg_tilemap, 0, ((state->highbits << 5) & 0x100) + state->bg_scrolly);
92   tilemap_set_scrollx(state->bg_tilemap, 0, ((state->highbits << 6) & 0x100) + state->bg_scrollx);
93   tilemap_set_scrolly(state->fg_tilemap, 0, ((state->highbits << 7) & 0x100) + state->fg_scrolly);
94   tilemap_set_scrollx(state->fg_tilemap, 0, ((state->highbits << 8) & 0x100) + state->fg_scrollx);
9695}
9796
9897static TILE_GET_INFO( get_fg_tile_info )
9998{
100   int attr = airbustr_colorram2[tile_index];
101   int code = airbustr_videoram2[tile_index] + ((attr & 0x0f) << 8);
99   airbustr_state *state = (airbustr_state *)machine->driver_data;
100   int attr = state->colorram2[tile_index];
101   int code = state->videoram2[tile_index] + ((attr & 0x0f) << 8);
102102   int color = attr >> 4;
103103
104104   SET_TILE_INFO(0, code, color, 0);
r6740r6741
106106
107107static TILE_GET_INFO( get_bg_tile_info )
108108{
109   int attr = machine->generic.colorram.u8[tile_index];
110   int code = machine->generic.videoram.u8[tile_index] + ((attr & 0x0f) << 8);
109   airbustr_state *state = (airbustr_state *)machine->driver_data;
110   int attr = state->colorram[tile_index];
111   int code = state->videoram[tile_index] + ((attr & 0x0f) << 8);
111112   int color = (attr >> 4) + 16;
112113
113114   SET_TILE_INFO(0, code, color, 0);
r6740r6741
115116
116117VIDEO_START( airbustr )
117118{
118   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
119   fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
119   airbustr_state *state = (airbustr_state *)machine->driver_data;
120120
121   sprites_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
122   state_save_register_global_bitmap(machine, sprites_bitmap);
123   tilemap_set_transparent_pen(fg_tilemap, 0);
121   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
122   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
124123
125   tilemap_set_scrolldx(bg_tilemap, 0x094, 0x06a);
126   tilemap_set_scrolldy(bg_tilemap, 0x100, 0x1ff);
127   tilemap_set_scrolldx(fg_tilemap, 0x094, 0x06a);
128   tilemap_set_scrolldy(fg_tilemap, 0x100, 0x1ff);
124   state->sprites_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
125   tilemap_set_transparent_pen(state->fg_tilemap, 0);
126
127   tilemap_set_scrolldx(state->bg_tilemap, 0x094, 0x06a);
128   tilemap_set_scrolldy(state->bg_tilemap, 0x100, 0x1ff);
129   tilemap_set_scrolldx(state->fg_tilemap, 0x094, 0x06a);
130   tilemap_set_scrolldy(state->fg_tilemap, 0x100, 0x1ff);
131
132   state_save_register_global_bitmap(machine, state->sprites_bitmap);
129133}
130134
131135
132136VIDEO_UPDATE( airbustr )
133137{
134   const device_config *pandora = devtag_get_device(screen->machine, "pandora");
135   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
136   tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
138   airbustr_state *state = (airbustr_state *)screen->machine->driver_data;
137139
140   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
141   tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
142
138143   // copy the sprite bitmap to the screen
139   pandora_update(pandora, bitmap, cliprect);
144   pandora_update(state->pandora, bitmap, cliprect);
140145
141146   return 0;
142147}
143148
144149VIDEO_EOF( airbustr )
145150{
146   const device_config *pandora = devtag_get_device(machine, "pandora");
151   airbustr_state *state = (airbustr_state *)machine->driver_data;
152
147153   // update the sprite bitmap
148   pandora_eof(pandora);
154   pandora_eof(state->pandora);
149155}
150156
src/mame/video/pacman.c
r6740r6741
2020#include "includes/pacman.h"
2121#include "video/resnet.h"
2222
23UINT8 *pacman_videoram;
24UINT8 *pacman_colorram;
2325static tilemap *bg_tilemap;
2426static UINT8 charbank;
2527static UINT8 spritebank;
r6740r6741
152154
153155static TILE_GET_INFO( pacman_get_tile_info )
154156{
155   int code = machine->generic.videoram.u8[tile_index] | (charbank << 8);
156   int attr = (machine->generic.colorram.u8[tile_index] & 0x1f) | (colortablebank << 5) | (palettebank << 6 );
157   int code = pacman_videoram[tile_index] | (charbank << 8);
158   int attr = (pacman_colorram[tile_index] & 0x1f) | (colortablebank << 5) | (palettebank << 6 );
157159
158160   SET_TILE_INFO(0,code,attr,0);
159161}
r6740r6741
198200
199201WRITE8_HANDLER( pacman_videoram_w )
200202{
201   space->machine->generic.videoram.u8[offset] = data;
203   pacman_videoram[offset] = data;
202204   tilemap_mark_tile_dirty( bg_tilemap, offset );
203205}
204206
205207WRITE8_HANDLER( pacman_colorram_w )
206208{
207   space->machine->generic.colorram.u8[offset] = data;
209   pacman_colorram[offset] = data;
208210   tilemap_mark_tile_dirty( bg_tilemap, offset );
209211}
210212
r6740r6741
367369
368370   colbank = s2650games_tileram[tile_index & 0x1f] & 0x3;
369371
370   code = machine->generic.videoram.u8[tile_index] + (colbank << 8);
371   attr = machine->generic.colorram.u8[tile_index & 0x1f];
372   code = pacman_videoram[tile_index] + (colbank << 8);
373   attr = pacman_colorram[tile_index & 0x1f];
372374
373375   SET_TILE_INFO(0,code,attr & 0x1f,0);
374376}
r6740r6741
442444
443445WRITE8_HANDLER( s2650games_videoram_w )
444446{
445   space->machine->generic.videoram.u8[offset] = data;
447   pacman_videoram[offset] = data;
446448   tilemap_mark_tile_dirty(bg_tilemap,offset);
447449}
448450
449451WRITE8_HANDLER( s2650games_colorram_w )
450452{
451453   int i;
452   space->machine->generic.colorram.u8[offset & 0x1f] = data;
454   pacman_colorram[offset & 0x1f] = data;
453455   for (i = offset; i < 0x0400; i += 32)
454456      tilemap_mark_tile_dirty(bg_tilemap, i);
455457}
r6740r6741
512514      color_index = tile_index + 0x80;
513515   }
514516
515   code = machine->generic.videoram.u8[tile_index] | (charbank << 8);
516   attr = (machine->generic.videoram.u8[color_index] & 0x1f) | (colortablebank << 5) | (palettebank << 6 );
517   code = pacman_videoram[tile_index] | (charbank << 8);
518   attr = (pacman_videoram[color_index] & 0x1f) | (colortablebank << 5) | (palettebank << 6 );
517519
518520   SET_TILE_INFO(0,code,attr,0);
519521}
r6740r6741
567569
568570WRITE8_HANDLER( jrpacman_videoram_w )
569571{
570   space->machine->generic.videoram.u8[offset] = data;
572   pacman_videoram[offset] = data;
571573   jrpacman_mark_tile_dirty(offset);
572574}
573575
src/mame/video/dcheese.c
r6740r6741
66
77
88#include "driver.h"
9#include "dcheese.h"
9#include "includes/dcheese.h"
1010
1111
1212/*************************************
src/mame/video/chqflag.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "video/konamiic.h"
11#include "cpu/z80/z80.h"
10#include "video/konicdev.h"
1211
13#define SPRITEROM_MEM_REGION "gfx1"
14#define ZOOMROM0_MEM_REGION "gfx2"
15#define ZOOMROM1_MEM_REGION "gfx3"
16
1712static int sprite_colorbase,zoom_colorbase[2];
1813
1914/***************************************************************************
r6740r6741
2217
2318***************************************************************************/
2419
25static void sprite_callback(int *code,int *color,int *priority,int *shadow)
20void chqflag_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow)
2621{
2722   *priority = (*color & 0x10) >> 4;
2823   *color = sprite_colorbase + (*color & 0x0f);
r6740r6741
3530
3631***************************************************************************/
3732
38static void zoom_callback_0(int *code,int *color,int *flags)
39{
40   *code |= ((*color & 0x03) << 8);
33void chqflag_zoom_callback_0(running_machine *machine, int *code,int *color,int *flags)
34{   *code |= ((*color & 0x03) << 8);
4135   *color = zoom_colorbase[0] + ((*color & 0x3c) >> 2);
4236}
4337
44static void zoom_callback_1(int *code,int *color,int *flags)
38void chqflag_zoom_callback_1(running_machine *machine, int *code,int *color,int *flags)
4539{
4640   *flags = TILE_FLIPYX((*color & 0xc0) >> 6);
4741   *code |= ((*color & 0x0f) << 8);
r6740r6741
5953   sprite_colorbase = 0;
6054   zoom_colorbase[0] = 0x10;
6155   zoom_colorbase[1] = 0x02;
62
63   K051960_vh_start(machine,SPRITEROM_MEM_REGION,NORMAL_PLANE_ORDER,sprite_callback);
64   K051316_vh_start_0(machine,ZOOMROM0_MEM_REGION,4,FALSE,0,zoom_callback_0);
65   K051316_vh_start_1(machine,ZOOMROM1_MEM_REGION,8,TRUE,0xc0,zoom_callback_1);
66
67   K051316_set_offset(0,7,0);
68   K051316_wraparound_enable(1,1);
6956}
7057
7158/***************************************************************************
r6740r6741
7663
7764VIDEO_UPDATE( chqflag )
7865{
79   bitmap_fill(bitmap,cliprect,0);
66   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
67   const device_config *k051316_1 = devtag_get_device(screen->machine, "k051316_1");
68   const device_config *k051316_2 = devtag_get_device(screen->machine, "k051316_2");
8069
81   K051316_zoom_draw_1(bitmap,cliprect,TILEMAP_DRAW_LAYER1,0);
82   K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
83   K051316_zoom_draw_1(bitmap,cliprect,TILEMAP_DRAW_LAYER0,0);
84   K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
85   K051316_zoom_draw_0(bitmap,cliprect,0,0);
70   bitmap_fill(bitmap, cliprect, 0);
71
72   k051316_zoom_draw(k051316_2, bitmap, cliprect, TILEMAP_DRAW_LAYER1, 0);
73   k051960_sprites_draw(k051960, bitmap, cliprect, 0, 0);
74   k051316_zoom_draw(k051316_2, bitmap, cliprect, TILEMAP_DRAW_LAYER0, 0);
75   k051960_sprites_draw(k051960, bitmap, cliprect, 1, 1);
76   k051316_zoom_draw(k051316_1, bitmap, cliprect, 0, 0);
8677   return 0;
8778}
src/mame/video/bwing.c
r6740r6741
99// Directives
1010
1111#include "driver.h"
12#include "bwing.h"
12#include "includes/bwing.h"
1313
1414
1515#define BW_DEBUG 0
src/mame/video/sf.c
r6740r6741
11#include "driver.h"
2#include "includes/sf.h"
23
3
4UINT16 *sf_objectram,*sf_videoram;
5
6static int sf_active = 0;
7
8static tilemap *bg_tilemap, *fg_tilemap, *tx_tilemap;
9
10
114/***************************************************************************
125
136  Callbacks for the TileMap code
r6740r6741
169
1710static TILE_GET_INFO( get_bg_tile_info )
1811{
19   UINT8 *base = memory_region(machine, "gfx5") + 2*tile_index;
12   UINT8 *base = memory_region(machine, "gfx5") + 2 * tile_index;
2013   int attr = base[0x10000];
2114   int color = base[0];
22   int code = (base[0x10000+1]<<8) | base[1];
15   int code = (base[0x10000 + 1] << 8) | base[1];
2316   SET_TILE_INFO(
2417         0,
2518         code,
r6740r6741
2922
3023static TILE_GET_INFO( get_fg_tile_info )
3124{
32   UINT8 *base = memory_region(machine, "gfx5") + 0x20000 + 2*tile_index;
25   UINT8 *base = memory_region(machine, "gfx5") + 0x20000 + 2 * tile_index;
3326   int attr = base[0x10000];
3427   int color = base[0];
35   int code = (base[0x10000+1]<<8) | base[1];
28   int code = (base[0x10000 + 1] << 8) | base[1];
3629   SET_TILE_INFO(
3730         1,
3831         code,
r6740r6741
4235
4336static TILE_GET_INFO( get_tx_tile_info )
4437{
45   int code = sf_videoram[tile_index];
38   sf_state *state = (sf_state *)machine->driver_data;
39   int code = state->videoram[tile_index];
4640   SET_TILE_INFO(
4741         3,
4842         code & 0x3ff,
r6740r6741
6054
6155VIDEO_START( sf )
6256{
63   bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_cols,     16,16,2048,16);
64   fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_cols,16,16,2048,16);
65   tx_tilemap = tilemap_create(machine, get_tx_tile_info,tilemap_scan_rows, 8, 8,  64,32);
57   sf_state *state = (sf_state *)machine->driver_data;
6658
67   tilemap_set_transparent_pen(fg_tilemap,15);
68   tilemap_set_transparent_pen(tx_tilemap,3);
59   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_cols, 16, 16, 2048, 16);
60   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_cols, 16, 16, 2048, 16);
61   state->tx_tilemap = tilemap_create(machine, get_tx_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
62
63   tilemap_set_transparent_pen(state->fg_tilemap, 15);
64   tilemap_set_transparent_pen(state->tx_tilemap, 3);
6965}
7066
7167
r6740r6741
7874
7975WRITE16_HANDLER( sf_videoram_w )
8076{
81   COMBINE_DATA(&sf_videoram[offset]);
82   tilemap_mark_tile_dirty(tx_tilemap,offset);
77   sf_state *state = (sf_state *)space->machine->driver_data;
78   COMBINE_DATA(&state->videoram[offset]);
79   tilemap_mark_tile_dirty(state->tx_tilemap, offset);
8380}
8481
8582WRITE16_HANDLER( sf_bg_scroll_w )
8683{
87   static UINT16 scroll;
88   COMBINE_DATA(&scroll);
89   tilemap_set_scrollx(bg_tilemap,0,scroll);
84   sf_state *state = (sf_state *)space->machine->driver_data;
85   COMBINE_DATA(&state->bgscroll);
86   tilemap_set_scrollx(state->bg_tilemap, 0, state->bgscroll);
9087}
9188
9289WRITE16_HANDLER( sf_fg_scroll_w )
9390{
94   static UINT16 scroll;
95   COMBINE_DATA(&scroll);
96   tilemap_set_scrollx(fg_tilemap,0,scroll);
91   sf_state *state = (sf_state *)space->machine->driver_data;
92   COMBINE_DATA(&state->fgscroll);
93   tilemap_set_scrollx(state->fg_tilemap, 0, state->fgscroll);
9794}
9895
9996WRITE16_HANDLER( sf_gfxctrl_w )
10097{
101/* b0 = reset, or maybe "set anyway" */
102/* b1 = pulsed when control6.b6==0 until it's 1 */
103/* b2 = active when dip 8 (flip) on */
104/* b3 = active character plane */
105/* b4 = unused */
106/* b5 = active background plane */
107/* b6 = active middle plane */
108/* b7 = active sprites */
98   /* b0 = reset, or maybe "set anyway" */
99   /* b1 = pulsed when control6.b6==0 until it's 1 */
100   /* b2 = active when dip 8 (flip) on */
101   /* b3 = active character plane */
102   /* b4 = unused */
103   /* b5 = active background plane */
104   /* b6 = active middle plane */
105   /* b7 = active sprites */
106
107   sf_state *state = (sf_state *)space->machine->driver_data;
109108   if (ACCESSING_BITS_0_7)
110109   {
111      sf_active = data & 0xff;
110      state->sf_active = data & 0xff;
112111      flip_screen_set(space->machine, data & 0x04);
113      tilemap_set_enable(tx_tilemap,data & 0x08);
114      tilemap_set_enable(bg_tilemap,data & 0x20);
115      tilemap_set_enable(fg_tilemap,data & 0x40);
112      tilemap_set_enable(state->tx_tilemap, data & 0x08);
113      tilemap_set_enable(state->bg_tilemap, data & 0x20);
114      tilemap_set_enable(state->fg_tilemap, data & 0x40);
116115   }
117116}
118117
r6740r6741
124123
125124***************************************************************************/
126125
127INLINE int sf_invert(int nb)
126INLINE int sf_invert( int nb )
128127{
129128   static const int delta[4] = {0x00, 0x18, 0x18, 0x00};
130129   return nb ^ delta[(nb >> 3) & 3];
131130}
132131
133static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
132static void draw_sprites( running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect )
134133{
134   sf_state *state = (sf_state *)machine->driver_data;
135135   int offs;
136136
137   for (offs = 0x1000-0x20;offs >= 0;offs -= 0x20)
137   for (offs = 0x1000 - 0x20; offs >= 0; offs -= 0x20)
138138   {
139      int c = sf_objectram[offs];
140      int attr = sf_objectram[offs+1];
141      int sy = sf_objectram[offs+2];
142      int sx = sf_objectram[offs+3];
139      int c = state->objectram[offs];
140      int attr = state->objectram[offs + 1];
141      int sy = state->objectram[offs + 2];
142      int sx = state->objectram[offs + 3];
143143      int color = attr & 0x000f;
144144      int flipx = attr & 0x0100;
145145      int flipy = attr & 0x0200;
146146
147147      if (attr & 0x400)   /* large sprite */
148148      {
149         int c1,c2,c3,c4,t;
149         int c1, c2, c3, c4, t;
150150
151151         if (flip_screen_get(machine))
152152         {
r6740r6741
157157         }
158158
159159         c1 = c;
160         c2 = c+1;
161         c3 = c+16;
162         c4 = c+17;
160         c2 = c + 1;
161         c3 = c + 16;
162         c4 = c + 17;
163163
164164         if (flipx)
165165         {
r6740r6741
220220
221221VIDEO_UPDATE( sf )
222222{
223   if (sf_active & 0x20)
224      tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
223   sf_state *state = (sf_state *)screen->machine->driver_data;
224
225   if (state->sf_active & 0x20)
226      tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
225227   else
226      bitmap_fill(bitmap,cliprect,0);
228      bitmap_fill(bitmap, cliprect, 0);
227229
228   tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
230   tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
229231
230   if (sf_active & 0x80)
231      draw_sprites(screen->machine,bitmap,cliprect);
232   if (state->sf_active & 0x80)
233      draw_sprites(screen->machine, bitmap, cliprect);
232234
233   tilemap_draw(bitmap,cliprect,tx_tilemap,0,0);
235   tilemap_draw(bitmap, cliprect, state->tx_tilemap, 0, 0);
234236   return 0;
235237}
src/mame/video/cave.c
r6740r6741
4545**************************************************************************/
4646
4747#include "driver.h"
48#include "cave.h"
48#include "includes/cave.h"
4949
5050/* Variables that driver has access to: */
5151
src/mame/video/brkthru.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "brkthru.h"
8#include "includes/brkthru.h"
99
1010
1111/***************************************************************************
src/mame/video/williams.c
r6740r6741
9393
9494#include "driver.h"
9595#include "video/resnet.h"
96#include "williams.h"
96#include "includes/williams.h"
9797
9898
9999
src/mame/video/fuukifg3.c
r6740r6741
2828***************************************************************************/
2929
3030#include "driver.h"
31#include "fuukifg3.h"
31#include "includes/fuukifg3.h"
3232
3333
3434/***************************************************************************
src/mame/video/battlane.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "battlane.h"
8#include "includes/battlane.h"
99
1010/*
1111    Video control register
src/mame/video/atarigt.c
r6740r6741
2121
2222#include "driver.h"
2323#include "machine/atarigen.h"
24#include "atarigt.h"
24#include "includes/atarigt.h"
2525
2626
2727/*************************************
r6740r6741
130130
131131   /* reset statics */
132132   memset(state->colorram, 0, 0x80000);
133
134   /* save states */
135   state_save_register_global(machine, state->playfield_tile_bank);
136   state_save_register_global(machine, state->playfield_color_bank);
137   state_save_register_global(machine, state->playfield_xscroll);
138   state_save_register_global(machine, state->playfield_yscroll);
139   state_save_register_global(machine, state->tram_checksum);
140   state_save_register_global_array(machine, state->expanded_mram);
133141}
134142
135143
src/mame/video/genesis.c
r6740r6741
1010#include "driver.h"
1111#include "sound/sn76496.h"
1212
13#include "genesis.h"
13#include "includes/genesis.h"
1414
1515
1616static const device_config *genesis_screen;
src/mame/video/cloud9.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "cloud9.h"
8#include "includes/cloud9.h"
99#include "video/resnet.h"
1010
1111
src/mame/video/crimfght.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
44
55static int layer_colorbase[3],sprite_colorbase;
r6740r6741
1010
1111***************************************************************************/
1212
13static void tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
13void crimfght_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
1414{
1515   *flags = (*color & 0x20) ? TILE_FLIPX : 0;
1616   *code |= ((*color & 0x1f) << 8) | (bank << 13);
r6740r6741
2323
2424***************************************************************************/
2525
26static void sprite_callback(int *code,int *color,int *priority,int *shadow)
26void crimfght_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow)
2727{
2828   /* Weird priority scheme. Why use three bits when two would suffice? */
2929   /* The PROM allows for mixed priorities, where sprites would have */
r6740r6741
6060   layer_colorbase[1] = 4;
6161   layer_colorbase[2] = 8;
6262   sprite_colorbase = 16;
63   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tile_callback);
64   K051960_vh_start(machine,"gfx2",NORMAL_PLANE_ORDER,sprite_callback);
6563}
6664
6765
r6740r6741
7472
7573VIDEO_UPDATE( crimfght )
7674{
77   K052109_tilemap_update();
75   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
76   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
7877
79   tilemap_draw(bitmap,cliprect,K052109_tilemap[1],TILEMAP_DRAW_OPAQUE,0);
80   K051960_sprites_draw(screen->machine,bitmap,cliprect,2,2);
81   tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,0);
82   K051960_sprites_draw(screen->machine,bitmap,cliprect,1,1);
83   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,0);
84   K051960_sprites_draw(screen->machine,bitmap,cliprect,0,0);
78   k052109_tilemap_update(k052109);
79
80   k052109_tilemap_draw(k052109, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE, 0);
81   k051960_sprites_draw(k051960, bitmap,cliprect,2,2);
82   k052109_tilemap_draw(k052109, bitmap, cliprect, 2, 0, 0);
83   k051960_sprites_draw(k051960, bitmap,cliprect,1,1);
84   k052109_tilemap_draw(k052109, bitmap, cliprect, 0, 0, 0);
85   k051960_sprites_draw(k051960, bitmap,cliprect,0,0);
8586   return 0;
8687}
src/mame/video/triplhnt.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "triplhnt.h"
8#include "includes/triplhnt.h"
99
1010
1111UINT8* triplhnt_playfield_ram;
src/mame/video/rollerg.c
r6740r6741
11#include "driver.h"
2#include "video/konamiic.h"
2#include "video/konicdev.h"
33
44
55static int bg_colorbase,sprite_colorbase,zoom_colorbase;
r6740r6741
1212
1313***************************************************************************/
1414
15static void sprite_callback(int *code,int *color,int *priority_mask)
15void rollerg_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask)
1616{
1717#if 0
1818if (input_code_pressed(machine, KEYCODE_Q) && (*color & 0x80)) *color = rand();
r6740r6741
3131
3232***************************************************************************/
3333
34static void zoom_callback(int *code,int *color,int *flags)
34void rollerg_zoom_callback(running_machine *machine, int *code,int *color,int *flags)
3535{
3636   *flags = TILE_FLIPYX((*color & 0xc0) >> 6);
3737   *code |= ((*color & 0x0f) << 8);
r6740r6741
5151   bg_colorbase = 16;
5252   sprite_colorbase = 16;
5353   zoom_colorbase = 0;
54
55   K053245_vh_start(machine,0,"gfx1",NORMAL_PLANE_ORDER,sprite_callback);
56   K051316_vh_start_0(machine,"gfx2",4,FALSE,0,zoom_callback);
57
58   K051316_set_offset(0, 22, 1);
5954}
6055
6156
r6740r6741
6863
6964VIDEO_UPDATE( rollerg )
7065{
71   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
72   bitmap_fill(bitmap,cliprect,16 * bg_colorbase);
73   K051316_zoom_draw_0(bitmap,cliprect,0,1);
74   K053245_sprites_draw(screen->machine,0,bitmap,cliprect);
66   const device_config *k053244 = devtag_get_device(screen->machine, "k053244");
67   const device_config *k051316 = devtag_get_device(screen->machine, "k051316");
68
69   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
70   bitmap_fill(bitmap, cliprect, 16 * bg_colorbase);
71   k051316_zoom_draw(k051316, bitmap, cliprect, 0, 1);
72   k053245_sprites_draw(k053244, bitmap, cliprect);
7573   return 0;
7674}
src/mame/video/sidepckt.c
r6740r6741
11#include "driver.h"
22
33
4UINT8 *sidepckt_videoram;
5UINT8 *sidepckt_colorram;
46static tilemap *bg_tilemap;
57static int flipscreen;
68
r6740r6741
4648
4749static TILE_GET_INFO( get_tile_info )
4850{
49   UINT8 attr = machine->generic.colorram.u8[tile_index];
51   UINT8 attr = sidepckt_colorram[tile_index];
5052   SET_TILE_INFO(
5153         0,
52         machine->generic.videoram.u8[tile_index] + ((attr & 0x07) << 8),
54         sidepckt_videoram[tile_index] + ((attr & 0x07) << 8),
5355         ((attr & 0x10) >> 3) | ((attr & 0x20) >> 5),
5456         TILE_FLIPX);
5557   tileinfo->group = (attr & 0x80) >> 7;
r6740r6741
8385
8486WRITE8_HANDLER( sidepckt_videoram_w )
8587{
86   space->machine->generic.videoram.u8[offset] = data;
88   sidepckt_videoram[offset] = data;
8789   tilemap_mark_tile_dirty(bg_tilemap,offset);
8890}
8991
9092WRITE8_HANDLER( sidepckt_colorram_w )
9193{
92   space->machine->generic.colorram.u8[offset] = data;
94   sidepckt_colorram[offset] = data;
9395   tilemap_mark_tile_dirty(bg_tilemap,offset);
9496}
9597
src/mame/video/exerion.c
r6740r6741
66
77#include "driver.h"
88#include "video/resnet.h"
9#include "exerion.h"
9#include "includes/exerion.h"
1010
1111
1212#define BACKGROUND_X_START      32
src/mame/video/crospang.c
r6740r6741
1010*/
1111
1212#include "driver.h"
13#include "crospang.h"
13#include "includes/crospang.h"
1414
1515WRITE16_HANDLER( bestri_tilebank_w)
1616{
src/mame/video/subs.c
r6740r6741
55***************************************************************************/
66
77#include "driver.h"
8#include "subs.h"
8#include "includes/subs.h"
99#include "sound/discrete.h"
1010
1111WRITE8_HANDLER( subs_invert1_w )
src/mame/video/ajax.c
r6740r6741
77***************************************************************************/
88
99#include "driver.h"
10#include "video/konamiic.h"
10#include "video/konicdev.h"
1111#include "includes/ajax.h"
1212
1313
r6740r6741
2121
2222***************************************************************************/
2323
24static void tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority)
24void ajax_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority)
2525{
2626   *code |= ((*color & 0x0f) << 8) | (bank << 12);
2727   *color = layer_colorbase[layer] + ((*color & 0xf0) >> 4);
r6740r6741
3434
3535***************************************************************************/
3636
37static void sprite_callback(int *code,int *color,int *priority,int *shadow)
37void ajax_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow)
3838{
3939   /* priority bits:
4040       4 over zoom (0 = have priority)
r6740r6741
5656
5757***************************************************************************/
5858
59static void zoom_callback(int *code,int *color,int *flags)
59void ajax_zoom_callback(running_machine *machine, int *code,int *color,int *flags)
6060{
6161   *code |= ((*color & 0x07) << 8);
6262   *color = zoom_colorbase + ((*color & 0x08) >> 3);
r6740r6741
7676   layer_colorbase[2] = 32;
7777   sprite_colorbase = 16;
7878   zoom_colorbase = 6;   /* == 48 since it's 7-bit graphics */
79   K052109_vh_start(machine,"gfx1",NORMAL_PLANE_ORDER,tile_callback);
80   K051960_vh_start(machine,"gfx2",NORMAL_PLANE_ORDER,sprite_callback);
81   K051316_vh_start_0(machine,"gfx3",7,FALSE,0,zoom_callback);
82    state_save_register_global(machine, ajax_priority);
79   state_save_register_global(machine, ajax_priority);
8380}
8481
8582
r6740r6741
9289
9390VIDEO_UPDATE( ajax )
9491{
95   K052109_tilemap_update();
92   const device_config *k051316 = devtag_get_device(screen->machine, "k051316");
93   const device_config *k052109 = devtag_get_device(screen->machine, "k052109");
94   const device_config *k051960 = devtag_get_device(screen->machine, "k051960");
9695
96   k052109_tilemap_update(k052109);
97
9798   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
9899
99100   bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
100   tilemap_draw(bitmap,cliprect,K052109_tilemap[2],0,1);
101   k052109_tilemap_draw(k052109, bitmap, cliprect, 2, 0, 1);
101102   if (ajax_priority)
102103   {
103104      /* basic layer order is B, zoom, A, F */
104      K051316_zoom_draw_0(bitmap,cliprect,0,4);
105      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,2);
105      k051316_zoom_draw(k051316, bitmap, cliprect, 0, 4);
106      k052109_tilemap_draw(k052109, bitmap, cliprect, 1, 0, 2);
106107   }
107108   else
108109   {
109110      /* basic layer order is B, A, zoom, F */
110      tilemap_draw(bitmap,cliprect,K052109_tilemap[1],0,2);
111      K051316_zoom_draw_0(bitmap,cliprect,0,4);
111      k052109_tilemap_draw(k052109, bitmap, cliprect, 1, 0, 2);
112      k051316_zoom_draw(k051316, bitmap, cliprect, 0, 4);
112113   }
113   tilemap_draw(bitmap,cliprect,K052109_tilemap[0],0,8);
114   k052109_tilemap_draw(k052109, bitmap, cliprect, 0, 0, 8);
114115
115   K051960_sprites_draw(screen->machine,bitmap,cliprect,-1,-1);
116   k051960_sprites_draw(k051960, bitmap, cliprect, -1, -1);
116117   return 0;
117118}
src/mame/video/funybubl.c
r6740r6741
66
77
88#include "driver.h"
9#include "funybubl.h"
9#include "includes/funybubl.h"
1010
1111
1212WRITE8_HANDLER ( funybubl_paldatawrite )
src/mame/video/m10.c
r6740r6741
1111***************************************************************************/
1212
1313#include "driver.h"
14#include "m10.h"
14#include "includes/m10.h"
1515
1616static UINT32 extyoffs[32 * 8];   // FIXME: this should be moved to m10_state, but backlayout would have problems
1717
src/mame/drivers/bfcobra.c
r6740r6741
9090/*
9191    Globals
9292*/
93static UINT8 bank[4];
93static UINT8 bank_data[4];
9494static UINT8 *work_ram;
9595static UINT8 *video_ram;
9696static UINT8 h_scroll;
r6740r6741
121121/*
122122    Function prototypes
123123*/
124INLINE void z80_bank(running_machine *machine, const char *bank, int data);
124INLINE void z80_bank(running_machine *machine, int num, int data);
125125
126126
127127static void update_irqs(running_machine *machine)
r6740r6741
389389   else if(addr < 0x20000)
390390   {
391391      addr &= 0xffff;
392      addr += (bank[0] & 1) ? 0x10000 : 0;
392      addr += (bank_data[0] & 1) ? 0x10000 : 0;
393393
394      return (UINT8*)(memory_region(machine, "user1") + addr + ((bank[0] >> 1) * 0x20000));
394      return (UINT8*)(memory_region(machine, "user1") + addr + ((bank_data[0] >> 1) * 0x20000));
395395   }
396396   else if (addr >= 0x20000 && addr < 0x40000)
397397   {
r6740r6741
830830      case 2:
831831      case 3:
832832      {
833         val = bank[offset];
833         val = bank_data[offset];
834834         break;
835835      }
836836      case 6:
r6740r6741
882882      case 0x02:
883883      case 0x03:
884884      {
885         static const char * const bankname[] = { "bank1", "bank2", "bank3" };
886885         if (data > 0x3f)
887886            popmessage("%x: Unusual bank access (%x)\n", cpu_get_previouspc(space->cpu), data);
888887
889888         data &= 0x3f;
890         bank[offset] = data;
891         z80_bank(space->machine, bankname[offset - 1], data);
889         bank_data[offset] = data;
890         z80_bank(space->machine, offset, data);
892891         break;
893892      }
894893
r6740r6741
963962   }
964963}
965964
966INLINE void z80_bank(running_machine *machine, const char *bank, int data)
965INLINE void z80_bank(running_machine *machine, int num, int data)
967966{
967   static const char * const bank_names[] = { "bank1", "bank2", "bank3" };
968
968969   if (data < 0x08)
969970   {
970      /* TODO: Don't need this table! */
971      static const UINT32 offs_table[2][8] =
972      {
973         { 0x10000, 0x14000, 0x18000, 0x1c000, 0x00000, 0x04000, 0x08000, 0x0c000 },
974         { 0x00000, 0x04000, 0x08000, 0x0c000, 0x10000, 0x14000, 0x18000, 0x1c000 }
975      };
971      UINT32 offset = ((bank_data[0] >> 1) * 0x20000) + ((0x4000 * data) ^ ((bank_data[0] & 1) ? 0 : 0x10000));
976972
977      UINT32 offset = ((bank[0] >> 1) * 0x20000) + offs_table[bank[0] & 0x1][data];
978
979      memory_set_bankptr(machine, bank, memory_region(machine, "user1") + offset);
973      memory_set_bankptr(machine, bank_names[num - 1], memory_region(machine, "user1") + offset);
980974   }
981975   else if (data < 0x10)
982976   {
983      memory_set_bankptr(machine, bank, &video_ram[(data - 0x08) * 0x4000]);
977      memory_set_bankptr(machine, bank_names[num - 1], &video_ram[(data - 0x08) * 0x4000]);
984978   }
985979   else
986980   {
987      memory_set_bankptr(machine, bank, &work_ram[(data - 0x10) * 0x4000]);
981      memory_set_bankptr(machine, bank_names[num - 1], &work_ram[(data - 0x10) * 0x4000]);
988982   }
989983}
990984
991985static WRITE8_HANDLER( rombank_w )
992986{
993   bank[0] = data;
994   z80_bank(space->machine, "bank1", bank[1]);
995   z80_bank(space->machine, "bank2", bank[2]);
996   z80_bank(space->machine, "bank3", bank[3]);
987   bank_data[0] = data;
988   z80_bank(space->machine, 1, bank_data[1]);
989   z80_bank(space->machine, 2, bank_data[2]);
990   z80_bank(space->machine, 3, bank_data[3]);
997991}
998992
999993
r6740r6741
12931287      palette_set_color_rgb(machine, pal, pal3bit((pal>>5)&7), pal3bit((pal>>2)&7), pal2bit(pal&3));
12941288   }
12951289
1296   bank[0] = 1;
1290   bank_data[0] = 1;
12971291   memset(&ramdac, 0, sizeof(ramdac));
12981292   reset_fdc();
12991293
r6740r6741
16951689
16961690   init_ram(machine);
16971691
1698   bank[0] = 1;
1699   bank[1] = 0;
1700   bank[2] = 0;
1701   bank[3] = 0;
1692   bank_data[0] = 1;
1693   bank_data[1] = 0;
1694   bank_data[2] = 0;
1695   bank_data[3] = 0;
17021696
17031697   /* Fixed 16kB ROM region */
17041698   memory_set_bankptr(machine, "bank4", memory_region(machine, "user1"));
r6740r6741
17171711   state_save_register_global(machine, flip_22);
17181712   state_save_register_global(machine, z80_int);
17191713   state_save_register_global(machine, z80_inten);
1720   state_save_register_global_array(machine, bank);
1714   state_save_register_global_array(machine, bank_data);
17211715   state_save_register_global_pointer(machine, work_ram, 0xc0000);
17221716   state_save_register_global_pointer(machine, video_ram, 0x20000);
17231717}
src/mame/drivers/mitchell.c
r6740r6741
1/***************************************************************************
1/*************************************************************************************
22
3"Mitchell hardware". Actually used mostly by Capcom.
3    "Mitchell hardware". Actually used mostly by Capcom.
44
5All games run on the same hardware except mgakuen, which runs on an
6earlier version, without RAM banking, not encrypted (standard Z80)
7and without EEPROM.
5    All games run on the same hardware except mgakuen, which runs on an
6    earlier version, without RAM banking, not encrypted (standard Z80)
7    and without EEPROM.
88
9Other games that might run on this hardware:
10"Chi-toitsu"(YUGA 1988)-Another version of"Mahjong Gakuen"
9    Other games that might run on this hardware:
10    "Chi-toitsu"(YUGA 1988)-Another version of"Mahjong Gakuen"
1111
12Notes:
13- Super Pang has a protection which involves copying code stored in the
14  EEPROM to RAM and execute it from there. The first time the game is run,
15  you have to keep the player 1 start button pressed until the title screen
16  appears. This forces the game to initialize the EEPROM, otherwise it will
17  not work.
18  This is simulated with a kluge in input_r.
19  This doesn't work with spangj! The data written to EEPROM is wrong. This is
20  currently fixed by patching the ROM data so the EEPROM is right. It would be
21  better to just preload the correct EEPROM, without needing the input_r kludge.
12    Notes:
13    - Super Pang has a protection which involves copying code stored in the
14      EEPROM to RAM and execute it from there. The first time the game is run,
15      you have to keep the player 1 start button pressed until the title screen
16      appears. This forces the game to initialize the EEPROM, otherwise it will
17      not work.
18      This is simulated with a kluge in input_r.
19      This doesn't work with spangj! The data written to EEPROM is wrong. This is
20      currently fixed by patching the ROM data so the EEPROM is right. It would be
21      better to just preload the correct EEPROM, without needing the input_r kludge.
2222
23TODO:
24- understand what bits 0 and 3 of input port 0x05 are
25- ball speed is erratic in Block Block. It was not like this at one point.
26  This is probably related to interrupts and maybe to the above bits.
23    TODO:
24    - understand what bits 0 and 3 of input port 0x05 are
25    - ball speed is erratic in Block Block. It was not like this at one point.
26      This is probably related to interrupts and maybe to the above bits.
2727
28***************************************************************************/
2928
30/*****************************************************************************
29******************************************************************************
3130 Monsters World (c)1994 TCH
3231
3332 Monsters World is basically a bootleg of Mitchell's Super Pang
r6740r6741
7372mw-8.rom = ST M27C1001 \
7473mw-9.rom = ST M27C1001 / GFX
7574
76******************************************************************************/
75*************************************************************************************/
7776
7877
7978#include "driver.h"
8079#include "cpu/z80/z80.h"
8180#include "deprecat.h"
8281#include "machine/eeprom.h"
83#include "includes/cps1.h"
82#include "includes/cps1.h"   // needed for decoding functions only
83#include "includes/mitchell.h"
8484#include "sound/okim6295.h"
8585#include "sound/3812intf.h"
8686#include "sound/2413intf.h"
8787#include "sound/msm5205.h"
8888
8989
90VIDEO_START( pang );
91VIDEO_UPDATE( pang );
90/*************************************
91 *
92 *  EEPROM
93 *
94 *************************************/
9295
93WRITE8_HANDLER( mgakuen_paletteram_w );
94READ8_HANDLER( mgakuen_paletteram_r );
95WRITE8_HANDLER( mgakuen_videoram_w );
96READ8_HANDLER( mgakuen_videoram_r );
97WRITE8_HANDLER( mgakuen_objram_w );
98READ8_HANDLER( mgakuen_objram_r );
99
100WRITE8_HANDLER( pang_video_bank_w );
101WRITE8_HANDLER( pang_videoram_w );
102READ8_HANDLER( pang_videoram_r );
103WRITE8_HANDLER( pang_colorram_w );
104READ8_HANDLER( pang_colorram_r );
105WRITE8_HANDLER( pang_gfxctrl_w );
106WRITE8_HANDLER( pang_paletteram_w );
107READ8_HANDLER( pang_paletteram_r );
108
109extern UINT8 *pang_videoram;
110extern UINT8 *pang_colorram;
111
112extern size_t pang_videoram_size;
113static UINT8 pang_port5_kludge = 0;
114
115
116
117static WRITE8_HANDLER( pang_bankswitch_w )
118{
119   memory_set_bank(space->machine, "bank1", data & 0x0f);
120}
121
122
123
124/***************************************************************************
125
126  EEPROM
127
128***************************************************************************/
129
13096static const eeprom_interface eeprom_intf =
13197{
13298   6,      /* address bits */
r6740r6741
166132
167133static READ8_HANDLER( pang_port5_r )
168134{
135   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
169136   int bit;
170137
171138   bit = eeprom_read_bit() << 7;
r6740r6741
175142   /* bit 3 is checked before updating the palette so it really seems to be vblank. */
176143   /* Many games require two interrupts per frame and for these bits to toggle, */
177144   /* otherwise music doesn't work. */
178   if (cpu_getiloops(space->cpu) & 1) bit |= 0x01;
179   else bit |= 0x08;
145   if (cpu_getiloops(space->cpu) & 1)
146      bit |= 0x01;
147   else
148      bit |= 0x08;
180149
181      if (pang_port5_kludge)   /* hack... music doesn't work otherwise */
182         bit ^= 0x08;
150   if (state->port5_kludge)   /* hack... music doesn't work otherwise */
151      bit ^= 0x08;
183152
184153   return (input_port_read(space->machine, "DSW0") & 0x76) | bit;
185154}
r6740r6741
200169}
201170
202171
172/*************************************
173 *
174 *  Bankswitch handling
175 *
176 *************************************/
203177
204/***************************************************************************
178static WRITE8_HANDLER( pang_bankswitch_w )
179{
180   memory_set_bank(space->machine, "bank1", data & 0x0f);
181}
205182
206  Input handling
183/*************************************
184 *
185 *  Input handling
186 *
187 *************************************/
207188
208***************************************************************************/
209
210static int dial[2],dial_selected;
211
212189static READ8_HANDLER( block_input_r )
213190{
214   static int dir[2];
191   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
215192   static const char *const dialnames[] = { "DIAL1", "DIAL2" };
216193   static const char *const portnames[] = { "IN1", "IN2" };
217194
218   if (dial_selected)
195   if (state->dial_selected)
219196   {
220      int delta;
197      int delta = (input_port_read(space->machine, dialnames[offset]) - state->dial[offset]) & 0xff;
221198
222      delta = (input_port_read(space->machine, dialnames[offset]) - dial[offset]) & 0xff;
223199      if (delta & 0x80)
224200      {
225201         delta = (-delta) & 0xff;
226         if (dir[offset])
202         if (state->dir[offset])
227203         {
228204         /* don't report movement on a direction change, otherwise it will stutter */
229            dir[offset] = 0;
205            state->dir[offset] = 0;
230206            delta = 0;
231207         }
232208      }
233209      else if (delta > 0)
234210      {
235         if (dir[offset] == 0)
211         if (!state->dir[offset])
236212         {
237213         /* don't report movement on a direction change, otherwise it will stutter */
238            dir[offset] = 1;
214            state->dir[offset] = 1;
239215            delta = 0;
240216         }
241217      }
242      if (delta > 0x3f) delta = 0x3f;
218      if (delta > 0x3f)
219         delta = 0x3f;
220
243221      return delta << 2;
244222   }
245223   else
246224   {
247      int res;
225      int res = input_port_read(space->machine, portnames[offset]) & 0xf7;
248226
249      res = input_port_read(space->machine, portnames[offset]) & 0xf7;
250      if (dir[offset]) res |= 0x08;
227      if (state->dir[offset])
228         res |= 0x08;
251229
252230      return res;
253231   }
r6740r6741
255233
256234static WRITE8_HANDLER( block_dial_control_w )
257235{
236   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
237
258238   if (data == 0x08)
259239   {
260240      /* reset the dial counters */
261      dial[0] = input_port_read(space->machine, "DIAL1");
262      dial[1] = input_port_read(space->machine, "DIAL2");
241      state->dial[0] = input_port_read(space->machine, "DIAL1");
242      state->dial[1] = input_port_read(space->machine, "DIAL2");
263243   }
264244   else if (data == 0x80)
265      dial_selected = 0;
245      state->dial_selected = 0;
266246   else
267      dial_selected = 1;
247      state->dial_selected = 1;
268248}
269249
270250
271static int keymatrix;
272
273251static READ8_HANDLER( mahjong_input_r )
274252{
253   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
275254   int i;
276255   static const char *const keynames[2][5] =
277256         {
r6740r6741
280259         };
281260
282261   for (i = 0; i < 5; i++)
283      if (keymatrix & (0x80 >> i)) return input_port_read(space->machine, keynames[offset][i]);
262   {
263      if (state->keymatrix & (0x80 >> i))
264         return input_port_read(space->machine, keynames[offset][i]);
265   }
284266
285267   return 0xff;
286268}
287269
288270static WRITE8_HANDLER( mahjong_input_select_w )
289271{
290   keymatrix = data;
272   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
273   state->keymatrix = data;
291274}
292275
293276
294static int input_type;
295
296277static READ8_HANDLER( input_r )
297278{
279   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
298280   static const char *const portnames[] = { "IN0", "IN1", "IN2" };
299281
300   switch (input_type)
282   switch (state->input_type)
301283   {
302284      case 0:
303285      default:
304286         return input_port_read(space->machine, portnames[offset]);
305287      case 1:      /* Mahjong games */
306         if (offset) return mahjong_input_r(space, offset-1);
307         else return input_port_read(space->machine, "IN0");
288         if (offset)
289            return mahjong_input_r(space, offset - 1);
290         else
291            return input_port_read(space->machine, "IN0");
308292         break;
309293      case 2:      /* Block Block - dial control */
310         if (offset) return block_input_r(space, offset-1);
311         else return input_port_read(space->machine, "IN0");
294         if (offset)
295            return block_input_r(space, offset - 1);
296         else
297            return input_port_read(space->machine, "IN0");
312298         break;
313299      case 3:      /* Super Pang - simulate START 1 press to initialize EEPROM */
314         if (offset || init_eeprom_count == 0) return input_port_read(space->machine, portnames[offset]);
300         if (offset || init_eeprom_count == 0)
301            return input_port_read(space->machine, portnames[offset]);
315302         else
316303         {
317304            init_eeprom_count--;
r6740r6741
324311
325312static WRITE8_HANDLER( input_w )
326313{
327   switch (input_type)
314   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
315
316   switch (state->input_type)
328317   {
329318      case 0:
330319      default:
331logerror("PC %04x: write %02x to port 01\n",cpu_get_pc(space->cpu),data);
320         logerror("PC %04x: write %02x to port 01\n", cpu_get_pc(space->cpu), data);
332321         break;
333322      case 1:
334         mahjong_input_select_w(space,offset,data);
323         mahjong_input_select_w(space, offset, data);
335324         break;
336325      case 2:
337         block_dial_control_w(space,offset,data);
326         block_dial_control_w(space, offset, data);
338327         break;
339328   }
340329}
341330
342331
332/*************************************
333 *
334 *  Address maps
335 *
336 *************************************/
343337
344/***************************************************************************
345
346  Memory handlers
347
348***************************************************************************/
349
350338static ADDRESS_MAP_START( mgakuen_map, ADDRESS_SPACE_PROGRAM, 8 )
351339   AM_RANGE(0x0000, 0x7fff) AM_ROM
352340   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
353   AM_RANGE(0xc000, 0xc7ff) AM_READWRITE(mgakuen_paletteram_r,mgakuen_paletteram_w)   /* palette RAM */
354   AM_RANGE(0xc800, 0xcfff) AM_READWRITE(pang_colorram_r,pang_colorram_w) AM_BASE(&pang_colorram) /* Attribute RAM */
355   AM_RANGE(0xd000, 0xdfff) AM_READWRITE(mgakuen_videoram_r,mgakuen_videoram_w) AM_BASE(&pang_videoram) AM_SIZE(&pang_videoram_size) /* char RAM */
341   AM_RANGE(0xc000, 0xc7ff) AM_READWRITE(mgakuen_paletteram_r, mgakuen_paletteram_w)   /* palette RAM */
342   AM_RANGE(0xc800, 0xcfff) AM_READWRITE(pang_colorram_r, pang_colorram_w) AM_BASE_MEMBER(mitchell_state, colorram) /* Attribute RAM */
343   AM_RANGE(0xd000, 0xdfff) AM_READWRITE(mgakuen_videoram_r, mgakuen_videoram_w) AM_BASE_SIZE_MEMBER(mitchell_state, videoram, videoram_size) /* char RAM */
356344   AM_RANGE(0xe000, 0xefff) AM_RAM   /* Work RAM */
357   AM_RANGE(0xf000, 0xffff) AM_READWRITE(mgakuen_objram_r,mgakuen_objram_w)   /* OBJ RAM */
345   AM_RANGE(0xf000, 0xffff) AM_READWRITE(mgakuen_objram_r, mgakuen_objram_w)   /* OBJ RAM */
358346ADDRESS_MAP_END
359347
360348static ADDRESS_MAP_START( mitchell_map, ADDRESS_SPACE_PROGRAM, 8 )
361349   AM_RANGE(0x0000, 0x7fff) AM_ROM
362350   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
363351   AM_RANGE(0xc000, 0xc7ff) AM_READWRITE(pang_paletteram_r,pang_paletteram_w) /* Banked palette RAM */
364   AM_RANGE(0xc800, 0xcfff) AM_READWRITE(pang_colorram_r,pang_colorram_w) AM_BASE(&pang_colorram) /* Attribute RAM */
365   AM_RANGE(0xd000, 0xdfff) AM_READWRITE(pang_videoram_r,pang_videoram_w) AM_BASE(&pang_videoram) AM_SIZE(&pang_videoram_size)/* Banked char / OBJ RAM */
352   AM_RANGE(0xc800, 0xcfff) AM_READWRITE(pang_colorram_r,pang_colorram_w) AM_BASE_MEMBER(mitchell_state, colorram) /* Attribute RAM */
353   AM_RANGE(0xd000, 0xdfff) AM_READWRITE(pang_videoram_r,pang_videoram_w) AM_BASE_SIZE_MEMBER(mitchell_state, videoram, videoram_size)/* Banked char / OBJ RAM */
366354   AM_RANGE(0xe000, 0xffff) AM_RAM   /* Work RAM */
367355ADDRESS_MAP_END
368356
r6740r6741
384372ADDRESS_MAP_END
385373
386374/* spangbl */
387
388375static ADDRESS_MAP_START( spangbl_map, ADDRESS_SPACE_PROGRAM, 8 )
389376   AM_RANGE(0x0000, 0x7fff) AM_ROM
390377   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1") AM_WRITENOP
391378   AM_RANGE(0xc000, 0xc7ff) AM_READWRITE(pang_paletteram_r, pang_paletteram_w)   /* Banked palette RAM */
392   AM_RANGE(0xc800, 0xcfff) AM_READWRITE(pang_colorram_r, pang_colorram_w)   AM_BASE(&pang_colorram)/* Attribute RAM */
393   AM_RANGE(0xd000, 0xdfff) AM_READWRITE(pang_videoram_r, pang_videoram_w)   AM_BASE(&pang_videoram) AM_SIZE(&pang_videoram_size) /* Banked char / OBJ RAM */
379   AM_RANGE(0xc800, 0xcfff) AM_READWRITE(pang_colorram_r, pang_colorram_w)   AM_BASE_MEMBER(mitchell_state, colorram)/* Attribute RAM */
380   AM_RANGE(0xd000, 0xdfff) AM_READWRITE(pang_videoram_r, pang_videoram_w)   AM_BASE_SIZE_MEMBER(mitchell_state, videoram, videoram_size) /* Banked char / OBJ RAM */
394381   AM_RANGE(0xe000, 0xffff) AM_RAM      /* Work RAM */
395382ADDRESS_MAP_END
396383
r6740r6741
410397ADDRESS_MAP_END
411398
412399
413static int sample_buffer = 0;
414static int sample_select = 0;
415
416400#ifdef UNUSED_FUNCTION
417401static WRITE8_HANDLER( spangbl_msm5205_data_w )
418402{
419    sample_buffer = data;
403   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
404   state->sample_buffer = data;
420405}
421406#endif
422407
r6740r6741
430415   ADDRESS_MAP_GLOBAL_MASK(0xff)
431416ADDRESS_MAP_END
432417
418
433419/**** Monsters World ****/
434
435420static WRITE8_DEVICE_HANDLER( oki_banking_w )
436421{
437422   okim6295_set_bank_base(device, 0x40000 * (data & 3));
r6740r6741
447432
448433static WRITE8_HANDLER(mstworld_sound_w)
449434{
435   mitchell_state *state = (mitchell_state *)space->machine->driver_data;
450436   soundlatch_w(space, 0, data);
451   cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE);
437   cpu_set_input_line(state->audiocpu, 0, HOLD_LINE);
452438}
453439
454extern WRITE8_HANDLER( mstworld_gfxctrl_w );
455extern WRITE8_HANDLER( mstworld_video_bank_w );
456
457440static ADDRESS_MAP_START( mstworld_io_map, ADDRESS_SPACE_IO, 8 )
458441   ADDRESS_MAP_GLOBAL_MASK(0xff)
459442   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0") AM_WRITE(mstworld_gfxctrl_w)   /* Palette bank, layer enable, coin counters, more */
r6740r6741
467450   AM_RANGE(0x07, 0x07) AM_WRITE(mstworld_video_bank_w)   /* Video RAM bank register */
468451ADDRESS_MAP_END
469452
470/**** End Monsters World ****/
471453
454/*************************************
455 *
456 *  Input ports
457 *
458 *************************************/
472459
473460static INPUT_PORTS_START( mj_common )
474   PORT_START("DSW0")   /* DSW */
461   PORT_START("DSW0")
475462   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* USED - handled in port5_r */
476463   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
477464   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
r6740r6741
479466   PORT_BIT( 0x70, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
480467   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* data from EEPROM */
481468
482   PORT_START("IN0")   /* IN0 */
469   PORT_START("IN0")
483470   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
484471   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
485472   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
489476   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
490477   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
491478
492   PORT_START("KEY0")   /* IN1 */
479   PORT_START("KEY0")
493480   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
494481   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
495482   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 )
r6740r6741
499486   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_MAHJONG_E )
500487   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_MAHJONG_A )
501488
502   PORT_START("KEY1")   /* IN1 */
489   PORT_START("KEY1")
503490   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
504491   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
505492   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
509496   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_MAHJONG_F )
510497   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_MAHJONG_B )
511498
512   PORT_START("KEY2")   /* IN1 */
499   PORT_START("KEY2")
513500   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
514501   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
515502   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
519506   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_MAHJONG_G )
520507   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_MAHJONG_C )
521508
522   PORT_START("KEY3")   /* IN1 */
509   PORT_START("KEY3")
523510   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
524511   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
525512   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
529516   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_MAHJONG_H )
530517   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_MAHJONG_D )
531518
532   PORT_START("KEY4")   /* IN1 */
519   PORT_START("KEY4")
533520   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
534521   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
535522   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
539526   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
540527   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
541528
542   PORT_START("KEY5")   /* IN2 */
529   PORT_START("KEY5")
543530   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
544531   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
545532   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START2 )
r6740r6741
549536   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_MAHJONG_E ) PORT_PLAYER(2)
550537   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_MAHJONG_A ) PORT_PLAYER(2)
551538
552   PORT_START("KEY6")   /* IN2 */
539   PORT_START("KEY6")
553540   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
554541   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
555542   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
559546   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_MAHJONG_F ) PORT_PLAYER(2)
560547   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_MAHJONG_B ) PORT_PLAYER(2)
561548
562   PORT_START("KEY7")   /* IN2 */
549   PORT_START("KEY7")
563550   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
564551   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
565552   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
569556   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_MAHJONG_G ) PORT_PLAYER(2)
570557   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_MAHJONG_C ) PORT_PLAYER(2)
571558
572   PORT_START("KEY8")   /* IN2 */
559   PORT_START("KEY8")
573560   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
574561   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
575562   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
579566   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_MAHJONG_H ) PORT_PLAYER(2)
580567   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_MAHJONG_D ) PORT_PLAYER(2)
581568
582   PORT_START("KEY9")   /* IN2 */
569   PORT_START("KEY9")
583570   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
584571   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
585572   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
593580static INPUT_PORTS_START( mgakuen )
594581   PORT_INCLUDE( mj_common )
595582
596   PORT_START("DSW1")   /* DSW1 */
583   PORT_START("DSW1")
597584   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) )
598585   PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) )
599586   PORT_DIPSETTING(    0x01, DEF_STR( 3C_1C ) )
r6740r6741
617604   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
618605   PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
619606
620   PORT_START("DSW2")      /* DSW2 */
607   PORT_START("DSW2")
621608   PORT_DIPNAME( 0x03, 0x03, "Player 1 Skill" )
622609   PORT_DIPSETTING(    0x03, "Weak" )
623610   PORT_DIPSETTING(    0x02, DEF_STR( Normal ) )
r6740r6741
653640   /* same unknown ports as the mahjong games, so we include the following */
654641   PORT_INCLUDE( marukin )
655642
656   PORT_MODIFY("IN0")      /* IN0 */
643   PORT_MODIFY("IN0")
657644   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE )   /* same as the service mode farther down */
658645
659   PORT_MODIFY("KEY0")      /* IN1 */
646   PORT_MODIFY("KEY0")
660647   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
661648   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
662649   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
664651   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P1 E") PORT_CODE(KEYCODE_E)
665652   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P1 A") PORT_CODE(KEYCODE_A)
666653
667   PORT_MODIFY("KEY1")      /* IN1 */
654   PORT_MODIFY("KEY1")
668655   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
669656   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
670657   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P1 Cancel") PORT_CODE(KEYCODE_LALT)
671658   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
672659   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P1 B") PORT_CODE(KEYCODE_B)
673660
674   PORT_MODIFY("KEY2")      /* IN1 */
661   PORT_MODIFY("KEY2")
675662   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
676663   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
677664   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P1 Flip") PORT_CODE(KEYCODE_SPACE)
678665   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
679666   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P1 C") PORT_CODE(KEYCODE_C)
680667
681   PORT_MODIFY("KEY3")      /* IN1 */
668   PORT_MODIFY("KEY3")
682669   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
683670   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
684671   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
685672   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P1 D") PORT_CODE(KEYCODE_D)
686673
687   PORT_MODIFY("KEY4")      /* IN1 */
674   PORT_MODIFY("KEY4")
688675   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
689676
690   PORT_MODIFY("KEY5")      /* IN2 */
677   PORT_MODIFY("KEY5")
691678   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
692679   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
693680   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
695682   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P2 E") PORT_CODE(KEYCODE_E)
696683   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P2 A") PORT_CODE(KEYCODE_A)
697684
698   PORT_MODIFY("KEY6")      /* IN2 */
685   PORT_MODIFY("KEY6")
699686   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
700687   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
701688   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P2 Cancel") PORT_CODE(KEYCODE_LALT)
702689   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
703690   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P2 B") PORT_CODE(KEYCODE_B)
704691
705   PORT_MODIFY("KEY7")      /* IN2 */
692   PORT_MODIFY("KEY7")
706693   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
707694   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
708695   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P2 Flip") PORT_CODE(KEYCODE_SPACE)
709696   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
710697   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P2 C") PORT_CODE(KEYCODE_C)
711698
712   PORT_MODIFY("KEY8")      /* IN2 */
699   PORT_MODIFY("KEY8")
713700   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
714701   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
715702   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
716703   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("P2 D") PORT_CODE(KEYCODE_D)
717704
718   PORT_MODIFY("KEY9")      /* IN2 */
705   PORT_MODIFY("KEY9")
719706   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
720707INPUT_PORTS_END
721708
722709static INPUT_PORTS_START( pang )
723   PORT_START("DSW0")      /* DSW */
710   PORT_START("DSW0")
724711   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* USED - handled in port5_r */
725712   PORT_SERVICE_NO_TOGGLE( 0x02, IP_ACTIVE_LOW )
726713   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
r6740r6741
728715   PORT_BIT( 0x70, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
729716   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* data from EEPROM */
730717
731   PORT_START("IN0")      /* IN0 */
718   PORT_START("IN0")
732719   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
733720   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
734721   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
r6740r6741
738725   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 )
739726   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
740727
741   PORT_START("IN1")      /* IN1 */
728   PORT_START("IN1")
742729   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
743730   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
744731   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 )
r6740r6741
748735   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
749736   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
750737
751   PORT_START("IN2")      /* IN2 */
738   PORT_START("IN2")
752739   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
753740   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
754741   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
r6740r6741
768755
769756static INPUT_PORTS_START( mstworld )
770757   /* this port may not have the same role */
771   PORT_START("DSW0")      /* DSW */
758   PORT_START("DSW0")
772759   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* USED - handled in port5_r */
773760   PORT_SERVICE_NO_TOGGLE( 0x02, IP_ACTIVE_LOW )
774761   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
r6740r6741
776763   PORT_BIT( 0x70, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
777764   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* data from EEPROM (spang) */
778765
779   PORT_START("IN0")      /* IN0 */
766   PORT_START("IN0")
780767   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
781768   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
782769   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
r6740r6741
786773   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 )
787774   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
788775
789   PORT_START("IN1")      /* IN1 */
776   PORT_START("IN1")
790777   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) // don't think this one matters..
791778   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 )
792779   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 )
r6740r6741
796783   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
797784   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
798785
799   PORT_START("IN2")      /* IN2 */
786   PORT_START("IN2")
800787   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // if not active high gfx aren't copied for game screen?! .. is this instead of a bit in port 5?
801788   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
802789   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
r6740r6741
884871INPUT_PORTS_END
885872
886873static INPUT_PORTS_START( qtono1 )
887   PORT_START("DSW0")      /* DSW */
874   PORT_START("DSW0")
888875   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* USED - handled in port5_r */
889876   PORT_SERVICE_NO_TOGGLE( 0x02, IP_ACTIVE_LOW )
890877   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
r6740r6741
892879   PORT_BIT( 0x70, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
893880   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* data from EEPROM */
894881
895   PORT_START("IN0")      /* IN0 */
882   PORT_START("IN0")
896883   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE )   /* same as the service mode farther down */
897884   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
898885   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
902889   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 )
903890   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
904891
905   PORT_START("IN1")      /* IN1 */
892   PORT_START("IN1")
906893   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
907894   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
908895   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 )
r6740r6741
912899   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 )
913900   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 )
914901
915   PORT_START("IN2")      /* IN2 */
902   PORT_START("IN2")
916903   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
917904   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
918905   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START2 )
r6740r6741
924911INPUT_PORTS_END
925912
926913static INPUT_PORTS_START( block )
927   PORT_START("DSW0")      /* DSW */
914   PORT_START("DSW0")
928915   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* USED - handled in port5_r */
929916   PORT_SERVICE_NO_TOGGLE( 0x02, IP_ACTIVE_LOW )
930917   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
r6740r6741
932919   PORT_BIT( 0x70, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
933920   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* data from EEPROM */
934921
935   PORT_START("IN0")      /* IN0 */
922   PORT_START("IN0")
936923   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
937924   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
938925   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
r6740r6741
942929   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 )
943930   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
944931
945   PORT_START("IN1")      /* IN1 */
932   PORT_START("IN1")
946933   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
947934   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
948935   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
950937   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
951938   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 )
952939
953   PORT_START("IN2")      /* IN2 */
940   PORT_START("IN2")
954941   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
955942   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
956943   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
958945   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
959946   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
960947
961   PORT_START("DIAL1")      /* DIAL1 */
948   PORT_START("DIAL1")
962949   PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(50) PORT_KEYDELTA(20)
963950
964   PORT_START("DIAL2")      /* DIAL2 */
951   PORT_START("DIAL2")
965952   PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(50) PORT_KEYDELTA(20) PORT_PLAYER(2)
966953INPUT_PORTS_END
967954
968955static INPUT_PORTS_START( blockjoy )
969   PORT_START("DSW0")      /* DSW */
956   PORT_START("DSW0")
970957   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* USED - handled in port5_r */
971958   PORT_SERVICE_NO_TOGGLE( 0x02, IP_ACTIVE_LOW )
972959   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
r6740r6741
974961   PORT_BIT( 0x70, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
975962   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* data from EEPROM */
976963
977   PORT_START("IN0")      /* IN0 */
964   PORT_START("IN0")
978965   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
979966   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
980967   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* probably unused */
r6740r6741
984971   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN2 )
985972   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
986973
987   PORT_START("IN1")      /* IN1 */
974   PORT_START("IN1")
988975   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
989976   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
990977   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
994981   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
995982   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 )
996983
997   PORT_START("IN2")      /* IN2 */
984   PORT_START("IN2")
998985   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
999986   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1000987   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
1007994
1008995
1009996
997/*************************************
998 *
999 *  Graphics definitions
1000 *
1001 *************************************/
1002
10101003static const gfx_layout charlayout =
10111004{
10121005   8,8,   /* 8*8 characters */
r6740r6741
10881081   GFXDECODE_ENTRY( "gfx2", 0, mstworld_spritelayout, 0x000, 0x40 )
10891082GFXDECODE_END
10901083
1084
1085/*************************************
1086 *
1087 *  Machine driver
1088 *
1089 *************************************/
1090
1091static MACHINE_START( mitchell )
1092{
1093   mitchell_state *state = (mitchell_state *)machine->driver_data;
1094
1095   state->audiocpu = devtag_get_device(machine, "audiocpu");
1096   state->oki = devtag_get_device(machine, "oki");
1097
1098   state_save_register_global(machine, state->sample_buffer);
1099   state_save_register_global(machine, state->sample_select);
1100   state_save_register_global(machine, state->dial_selected);
1101   state_save_register_global(machine, state->keymatrix);
1102   state_save_register_global_array(machine, state->dir);
1103   state_save_register_global_array(machine, state->dial);
1104//  state_save_register_global(machine, init_eeprom_count);
1105}
1106
1107static MACHINE_RESET( mitchell )
1108{
1109   mitchell_state *state = (mitchell_state *)machine->driver_data;
1110
1111   state->sample_buffer = 0;
1112   state->sample_select = 0;
1113   state->dial_selected = 0;
1114   state->dial[0] = 0;
1115   state->dial[1] = 0;
1116   state->dir[0] = 0;
1117   state->dir[1] = 0;
1118   state->keymatrix = 0;
1119}
1120
10911121static MACHINE_DRIVER_START( mgakuen )
10921122
1123   /* driver data */
1124   MDRV_DRIVER_DATA(mitchell_state)
1125
10931126   /* basic machine hardware */
10941127   MDRV_CPU_ADD("maincpu", Z80, 6000000)   /* ??? */
10951128   MDRV_CPU_PROGRAM_MAP(mgakuen_map)
10961129   MDRV_CPU_IO_MAP(mitchell_io_map)
10971130   MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold,2)   /* ??? one extra irq seems to be needed for music (see input5_r) */
10981131
1132   MDRV_MACHINE_START(mitchell)
1133   MDRV_MACHINE_RESET(mitchell)
1134
10991135   /* video hardware */
11001136   MDRV_SCREEN_ADD("screen", RASTER)
11011137   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
11241160
11251161static MACHINE_DRIVER_START( pang )
11261162
1163   /* driver data */
1164   MDRV_DRIVER_DATA(mitchell_state)
1165
11271166   /* basic machine hardware */
11281167   MDRV_CPU_ADD("maincpu",Z80, XTAL_16MHz/2) /* verified on pcb */
11291168   MDRV_CPU_PROGRAM_MAP(mitchell_map)
11301169   MDRV_CPU_IO_MAP(mitchell_io_map)
11311170   MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold,2)   /* ??? one extra irq seems to be needed for music (see input5_r) */
11321171
1172   MDRV_MACHINE_START(mitchell)
1173   MDRV_MACHINE_RESET(mitchell)
1174
11331175   MDRV_NVRAM_HANDLER(mitchell)
11341176
11351177   /* video hardware */
r6740r6741
11761218
11771219
11781220
1179static void spangbl_adpcm_int(const device_config *device)
1221static void spangbl_adpcm_int( const device_config *device )
11801222{
1181   msm5205_data_w(device, sample_buffer & 0x0F);
1182   sample_buffer >>= 4;
1183   sample_select ^= 1;
1184   if(sample_select == 0)
1185      cputag_set_input_line(device->machine, "soundcpu", INPUT_LINE_NMI, PULSE_LINE);
1223   mitchell_state *state = (mitchell_state *)device->machine->driver_data;
1224   msm5205_data_w(device, state->sample_buffer & 0x0f);
1225   state->sample_buffer >>= 4;
1226   state->sample_select ^= 1;
1227   if(state->sample_select == 0)
1228      cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
11861229}
11871230
11881231
r6740r6741
12011244   MDRV_CPU_IO_MAP(spangbl_io_map)
12021245   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
12031246
1204   MDRV_CPU_ADD("soundcpu",Z80, 8000000)
1247   MDRV_CPU_ADD("audiocpu", Z80, 8000000)
12051248   MDRV_CPU_PROGRAM_MAP(spangbl_sound_map)
12061249   MDRV_CPU_IO_MAP(spangbl_sound_io_map)
12071250   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
r6740r6741
12091252
12101253   MDRV_GFXDECODE(spangbl)
12111254
1212
12131255   MDRV_SOUND_REPLACE("oki", MSM5205, 384000)
12141256   MDRV_SOUND_CONFIG(msm5205_config)
12151257   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
r6740r6741
12171259
12181260static MACHINE_DRIVER_START( mstworld )
12191261
1262   /* driver data */
1263   MDRV_DRIVER_DATA(mitchell_state)
1264
12201265   /* basic machine hardware */
12211266   /* it doesn't glitch with the clock speed set to 4x normal, however this is incorrect..
12221267      the interrupt handling (and probably various irq flags / vbl flags handling etc.) is
r6740r6741
12291274   MDRV_CPU_ADD("audiocpu", Z80,6000000)       /* 6 MHz? */
12301275   MDRV_CPU_PROGRAM_MAP(mstworld_sound_map)
12311276
1277   MDRV_MACHINE_START(mitchell)
1278   MDRV_MACHINE_RESET(mitchell)
1279
12321280   /* video hardware */
12331281   MDRV_SCREEN_ADD("screen", RASTER)
12341282   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
12541302
12551303static MACHINE_DRIVER_START( marukin )
12561304
1305   /* driver data */
1306   MDRV_DRIVER_DATA(mitchell_state)
1307
12571308   /* basic machine hardware */
12581309   MDRV_CPU_ADD("maincpu", Z80, 8000000)   /* Super Pang says 8MHZ ORIGINAL BOARD */
12591310   MDRV_CPU_PROGRAM_MAP(mitchell_map)
r6740r6741
12881339MACHINE_DRIVER_END
12891340
12901341
1342/*************************************
1343 *
1344 *  ROM definition(s)
1345 *
1346 *************************************/
12911347
12921348ROM_START( mgakuen )
12931349   ROM_REGION( 0x50000, "maincpu", 0 )
r6740r6741
15221578   ROM_CONTINUE(        0x74000, 0x04000 )
15231579   ROM_CONTINUE(        0x24000, 0x04000 )
15241580
1525   ROM_REGION( 0x20000, "soundcpu", 0 ) /* Sound Z80 + M5205(?) samples */
1581   ROM_REGION( 0x20000, "audiocpu", 0 ) /* Sound Z80 + M5205(?) samples */
15261582   ROM_LOAD( "pang.4",   0x00000, 0x10000, CRC(88a7b1f8) SHA1(b34fa26dbc613bf3b525d19df90fa3ba4efb6e5d) ) // this is the same as the microhard game 'rebus' ...
15271583
15281584   ROM_REGION( 0x100000, "gfx1", ROMREGION_INVERT | ROMREGION_ERASEFF )
r6740r6741
17351791   ROM_CONTINUE(0x44000,0x4000)
17361792   ROM_CONTINUE(0x4c000,0x4000)
17371793
1738   ROM_REGION( 0x20000, "soundcpu", 0 ) /* Sound Z80 + M5205 samples */
1794   ROM_REGION( 0x20000, "audiocpu", 0 ) /* Sound Z80 + M5205 samples */
17391795   ROM_LOAD( "ic28.4",   0x00000, 0x10000, CRC(02b07d0a) SHA1(77cb9bf1b0d93ebad1bd8cdbedb7fdbad23697be) )
17401796   ROM_LOAD( "ic45.5",   0x10000, 0x10000, CRC(95c32824) SHA1(02de90a7bfbe89feb7708fda8dfac4ed32bc0773) )
17411797
r6740r6741
19672023ROM_END
19682024
19692025
1970static void bootleg_decode(running_machine *machine)
2026/*************************************
2027 *
2028 *  Driver initialization
2029 *
2030 *************************************/
2031
2032static void bootleg_decode( running_machine *machine )
19712033{
19722034   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
19732035   memory_set_decrypted_region(space, 0x0000, 0x7fff, memory_region(machine, "maincpu") + 0x50000);
r6740r6741
19752037}
19762038
19772039
1978static void configure_banks(running_machine *machine)
2040static void configure_banks( running_machine *machine )
19792041{
2042   mitchell_state *state = (mitchell_state *)machine->driver_data;
2043
19802044   memory_configure_bank(machine, "bank1", 0, 16, memory_region(machine, "maincpu") + 0x10000, 0x4000);
1981   pang_port5_kludge = 0;
2045   state->port5_kludge = 0;
19822046}
19832047
19842048
19852049static DRIVER_INIT( dokaben )
19862050{
1987   input_type = 0;
2051   mitchell_state *state = (mitchell_state *)machine->driver_data;
2052   state->input_type = 0;
19882053   nvram_size = 0;
19892054   mgakuen2_decode(machine);
19902055   configure_banks(machine);
19912056}
19922057static DRIVER_INIT( pang )
19932058{
1994   input_type = 0;
2059   mitchell_state *state = (mitchell_state *)machine->driver_data;
2060   state->input_type = 0;
19952061   nvram_size = 0;
19962062   pang_decode(machine);
19972063   configure_banks(machine);
19982064}
19992065static DRIVER_INIT( pangb )
20002066{
2001   input_type = 0;
2067   mitchell_state *state = (mitchell_state *)machine->driver_data;
2068   state->input_type = 0;
20022069   nvram_size = 0;
20032070   bootleg_decode(machine);
20042071   configure_banks(machine);
20052072}
20062073static DRIVER_INIT( cworld )
20072074{
2008   input_type = 0;
2075   mitchell_state *state = (mitchell_state *)machine->driver_data;
2076   state->input_type = 0;
20092077   nvram_size = 0;
20102078   cworld_decode(machine);
20112079   configure_banks(machine);
20122080}
20132081static DRIVER_INIT( hatena )
20142082{
2015   input_type = 0;
2083   mitchell_state *state = (mitchell_state *)machine->driver_data;
2084   state->input_type = 0;
20162085   nvram_size = 0;
20172086   hatena_decode(machine);
20182087   configure_banks(machine);
20192088}
20202089static DRIVER_INIT( spang )
20212090{
2022   input_type = 3;
2091   mitchell_state *state = (mitchell_state *)machine->driver_data;
2092   state->input_type = 3;
20232093   nvram_size = 0x80;
20242094   nvram = &memory_region(machine, "maincpu")[0xe000];   /* NVRAM */
20252095   spang_decode(machine);
r6740r6741
20282098
20292099static DRIVER_INIT( spangbl )
20302100{
2031   input_type = 3;
2101   mitchell_state *state = (mitchell_state *)machine->driver_data;
2102   state->input_type = 3;
20322103   nvram_size = 0x80;
20332104   nvram = &memory_region(machine, "maincpu")[0xe000];   /* NVRAM */
20342105   bootleg_decode(machine);
r6740r6741
20372108
20382109static DRIVER_INIT( spangj )
20392110{
2040   input_type = 3;
2111   mitchell_state *state = (mitchell_state *)machine->driver_data;
2112   state->input_type = 3;
20412113   nvram_size = 0x80;
20422114   nvram = &memory_region(machine, "maincpu")[0xe000];   /* NVRAM */
20432115   spangj_decode(machine);
r6740r6741
20532125}
20542126static DRIVER_INIT( sbbros )
20552127{
2056   input_type = 3;
2128   mitchell_state *state = (mitchell_state *)machine->driver_data;
2129   state->input_type = 3;
20572130   nvram_size = 0x80;
20582131   nvram = &memory_region(machine, "maincpu")[0xe000];   /* NVRAM */
20592132   sbbros_decode(machine);
r6740r6741
20612134}
20622135static DRIVER_INIT( qtono1 )
20632136{
2064   input_type = 0;
2137   mitchell_state *state = (mitchell_state *)machine->driver_data;
2138   state->input_type = 0;
20652139   nvram_size = 0;
20662140   qtono1_decode(machine);
20672141   configure_banks(machine);
20682142}
20692143static DRIVER_INIT( qsangoku )
20702144{
2071   input_type = 0;
2145   mitchell_state *state = (mitchell_state *)machine->driver_data;
2146   state->input_type = 0;
20722147   nvram_size = 0;
20732148   qsangoku_decode(machine);
20742149   configure_banks(machine);
20752150}
20762151static DRIVER_INIT( mgakuen )
20772152{
2078   input_type = 1;
2153   mitchell_state *state = (mitchell_state *)machine->driver_data;
2154   state->input_type = 1;
20792155   configure_banks(machine);
20802156   memory_install_read_port(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x03, 0x03, 0, 0, "DSW1");
20812157   memory_install_read_port(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO), 0x04, 0x04, 0, 0, "DSW2");
20822158}
20832159static DRIVER_INIT( mgakuen2 )
20842160{
2085   input_type = 1;
2161   mitchell_state *state = (mitchell_state *)machine->driver_data;
2162   state->input_type = 1;
20862163   nvram_size = 0;
20872164   mgakuen2_decode(machine);
20882165   configure_banks(machine);
2089   pang_port5_kludge = 1;
2166   state->port5_kludge = 1;
20902167}
20912168static DRIVER_INIT( pkladies )
20922169{
2093   input_type = 1;
2170   mitchell_state *state = (mitchell_state *)machine->driver_data;
2171   state->input_type = 1;
20942172   nvram_size = 0;
20952173   mgakuen2_decode(machine);
20962174   configure_banks(machine);
20972175}
20982176static DRIVER_INIT( marukin )
20992177{
2100   input_type = 1;
2178   mitchell_state *state = (mitchell_state *)machine->driver_data;
2179   state->input_type = 1;
21012180   nvram_size = 0;
21022181   marukin_decode(machine);
21032182   configure_banks(machine);
21042183}
21052184static DRIVER_INIT( block )
21062185{
2107   input_type = 2;
2186   mitchell_state *state = (mitchell_state *)machine->driver_data;
2187   state->input_type = 2;
21082188   nvram_size = 0x80;
21092189   nvram = &memory_region(machine, "maincpu")[0xff80];   /* NVRAM */
21102190   block_decode(machine);
r6740r6741
21122192}
21132193static DRIVER_INIT( blockbl )
21142194{
2115   input_type = 2;
2195   mitchell_state *state = (mitchell_state *)machine->driver_data;
2196   state->input_type = 2;
21162197   nvram_size = 0x80;
21172198   nvram = &memory_region(machine, "maincpu")[0xff80];   /* NVRAM */
21182199   bootleg_decode(machine);
r6740r6741
21242205   /* descramble the program rom .. */
21252206   int len = memory_region_length(machine, "maincpu");
21262207   UINT8* source = alloc_array_or_die(UINT8, len);
2127   UINT8* dst    = memory_region(machine, "maincpu") ;
2208   UINT8* dst = memory_region(machine, "maincpu") ;
21282209   int x;
21292210
21302211   static const int tablebank[]=
r6740r6741
21522233   };
21532234
21542235   memcpy(source, dst, len);
2155   for (x=0;x<40;x+=2)
2236   for (x = 0; x < 40; x += 2)
21562237   {
2157      if (tablebank[x]!=-1)
2238      if (tablebank[x] != -1)
21582239      {
2159         memcpy(&dst[(x/2)*0x4000],&source[tablebank[x]*0x4000],0x4000);
2160         memcpy(&dst[((x/2)*0x4000)+0x50000],&source[tablebank[x+1]*0x4000],0x4000);
2240         memcpy(&dst[(x / 2) * 0x4000], &source[tablebank[x] * 0x4000], 0x4000);
2241         memcpy(&dst[((x / 2) * 0x4000) + 0x50000],&source[tablebank[x + 1] * 0x4000], 0x4000);
21612242      }
21622243   }
21632244   free(source);
r6740r6741
21672248}
21682249
21692250
2170GAME( 1988, mgakuen,   0,        mgakuen, mgakuen,  mgakuen,  ROT0,   "Yuga", "Mahjong Gakuen", 0 )
2171GAME( 1988, 7toitsu,   mgakuen,  mgakuen, mgakuen,  mgakuen,  ROT0,   "Yuga", "Chi-Toitsu", 0 )
2172GAME( 1989, mgakuen2,  0,        marukin, marukin,  mgakuen2, ROT0,   "Face", "Mahjong Gakuen 2 Gakuen-chou no Fukushuu", 0 )
2173GAME( 1989, pkladies,  0,        marukin, pkladies, pkladies, ROT0,   "Mitchell", "Poker Ladies", 0 )
2174GAME( 1989, pkladiesl, pkladies, marukin, pkladies, pkladies, ROT0,   "Leprechaun", "Poker Ladies (Leprechaun ver. 510)", 0 )
2175GAME( 1989, pkladiesla,pkladies, marukin, pkladies, pkladies, ROT0,   "Leprechaun", "Poker Ladies (Leprechaun ver. 401)", 0 )
2176GAME( 1989, dokaben,   0,        pang,    pang,     dokaben,  ROT0,   "Capcom", "Dokaben (Japan)", 0 )
2177GAME( 1989, pang,      0,        pang,    pang,     pang,     ROT0,   "Mitchell", "Pang (World)", 0 )
2178GAME( 1989, pangb,     pang,     pang,    pang,     pangb,    ROT0,   "[Mitchell] (bootleg)", "Pang (bootleg, set 1)", 0 )
2179GAME( 1989, pangbold,  pang,     pang,    pang,     pangb,    ROT0,   "[Mitchell] (bootleg)", "Pang (bootleg, set 2)", 0 )
2180GAME( 1989, pangba,    pang,     spangbl, pang,     pangb,    ROT0,   "[Mitchell] (bootleg)", "Pang (bootleg, set 3)", GAME_NO_SOUND )
2181GAME( 1989, bbros,     pang,     pang,    pang,     pang,     ROT0,   "Capcom", "Buster Bros. (US)", 0 )
2182GAME( 1989, pompingw,  pang,     pang,    pang,     pang,     ROT0,   "Mitchell", "Pomping World (Japan)", 0 )
2183GAME( 1989, cworld,    0,        pang,    qtono1,   cworld,   ROT0,   "Capcom", "Capcom World (Japan)", 0 )
2184GAME( 1990, hatena,    0,        pang,    qtono1,   hatena,   ROT0,   "Capcom", "Adventure Quiz 2 Hatena Hatena no Dai-Bouken (Japan 900228)", 0 )
2185GAME( 1990, spang,     0,        pang,    pang,     spang,    ROT0,   "Mitchell", "Super Pang (World 900914)", 0 )
2186GAME( 1990, spangj,    spang,    pang,    pang,     spangj,   ROT0,   "Mitchell", "Super Pang (Japan 901023)", 0 )
2187GAME( 1990, spangbl,   spang,    spangbl, spangbl,  spangbl,  ROT0,   "[Mitchell] (bootleg)", "Super Pang (World 900914, bootleg)", GAME_NO_SOUND ) // different sound hardware
2188GAME( 1994, mstworld,  0,        mstworld,mstworld, mstworld, ROT0,   "TCH", "Monsters World",GAME_IMPERFECT_GRAPHICS ) // bootleg of Spang
2189GAME( 1990, sbbros,    spang,    pang,    pang,     sbbros,   ROT0,   "Mitchell + Capcom", "Super Buster Bros. (US 901001)", 0 )
2190GAME( 1990, marukin,   0,        marukin, marukin,  marukin,  ROT0,   "Yuga", "Super Marukin-Ban (Japan 901017)", 0 )
2191GAME( 1991, qtono1,    0,        pang,    qtono1,   qtono1,   ROT0,   "Capcom", "Quiz Tonosama no Yabou (Japan)", 0 )
2192GAME( 1991, qsangoku,  0,        pang,    qtono1,   qsangoku, ROT0,   "Capcom", "Quiz Sangokushi (Japan)", 0 )
2193GAME( 1991, block,     0,        pang,    block,    block,    ROT270, "Capcom", "Block Block (World 910910)", 0 )
2194GAME( 1991, blockj,    block,    pang,    block,    block,    ROT270, "Capcom", "Block Block (Japan 910910)", 0 )
2195GAME( 1991, blockjoy,  block,    pang,    blockjoy, block,    ROT270, "Capcom", "Block Block (World 911106 Joystick)", 0 )
2196GAME( 1991, blockbl,   block,    pang,    block,    blockbl,  ROT270, "bootleg", "Block Block (bootleg)", 0 )
2251/*************************************
2252 *
2253 *  Game driver(s)
2254 *
2255 *************************************/
21972256
2257GAME( 1988, mgakuen,   0,        mgakuen, mgakuen,  mgakuen,  ROT0,   "Yuga", "Mahjong Gakuen", GAME_SUPPORTS_SAVE )
2258GAME( 1988, 7toitsu,   mgakuen,  mgakuen, mgakuen,  mgakuen,  ROT0,   "Yuga", "Chi-Toitsu", GAME_SUPPORTS_SAVE )
2259GAME( 1989, mgakuen2,  0,        marukin, marukin,  mgakuen2, ROT0,   "Face", "Mahjong Gakuen 2 Gakuen-chou no Fukushuu", GAME_SUPPORTS_SAVE )
2260GAME( 1989, pkladies,  0,        marukin, pkladies, pkladies, ROT0,   "Mitchell", "Poker Ladies", GAME_SUPPORTS_SAVE )
2261GAME( 1989, pkladiesl, pkladies, marukin, pkladies, pkladies, ROT0,   "Leprechaun", "Poker Ladies (Leprechaun ver. 510)", GAME_SUPPORTS_SAVE )
2262GAME( 1989, pkladiesla,pkladies, marukin, pkladies, pkladies, ROT0,   "Leprechaun", "Poker Ladies (Leprechaun ver. 401)", GAME_SUPPORTS_SAVE )
2263GAME( 1989, dokaben,   0,        pang,    pang,     dokaben,  ROT0,   "Capcom", "Dokaben (Japan)", GAME_SUPPORTS_SAVE )
2264GAME( 1989, pang,      0,        pang,    pang,     pang,     ROT0,   "Mitchell", "Pang (World)", GAME_SUPPORTS_SAVE )
2265GAME( 1989, pangb,     pang,     pang,    pang,     pangb,    ROT0,   "[Mitchell] (bootleg)", "Pang (bootleg, set 1)", GAME_SUPPORTS_SAVE )
2266GAME( 1989, pangbold,  pang,     pang,    pang,     pangb,    ROT0,   "[Mitchell] (bootleg)", "Pang (bootleg, set 2)", GAME_SUPPORTS_SAVE )
2267GAME( 1989, pangba,    pang,     spangbl, pang,     pangb,    ROT0,   "[Mitchell] (bootleg)", "Pang (bootleg, set 3)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
2268GAME( 1989, bbros,     pang,     pang,    pang,     pang,     ROT0,   "Capcom", "Buster Bros. (US)", GAME_SUPPORTS_SAVE )
2269GAME( 1989, pompingw,  pang,     pang,    pang,     pang,     ROT0,   "Mitchell", "Pomping World (Japan)", GAME_SUPPORTS_SAVE )
2270GAME( 1989, cworld,    0,        pang,    qtono1,   cworld,   ROT0,   "Capcom", "Capcom World (Japan)", GAME_SUPPORTS_SAVE )
2271GAME( 1990, hatena,    0,        pang,    qtono1,   hatena,   ROT0,   "Capcom", "Adventure Quiz 2 Hatena Hatena no Dai-Bouken (Japan 900228)", GAME_SUPPORTS_SAVE )
2272GAME( 1990, spang,     0,        pang,    pang,     spang,    ROT0,   "Mitchell", "Super Pang (World 900914)", GAME_SUPPORTS_SAVE )
2273GAME( 1990, spangj,    spang,    pang,    pang,     spangj,   ROT0,   "Mitchell", "Super Pang (Japan 901023)", GAME_SUPPORTS_SAVE )
2274GAME( 1990, spangbl,   spang,    spangbl, spangbl,  spangbl,  ROT0,   "[Mitchell] (bootleg)", "Super Pang (World 900914, bootleg)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE ) // different sound hardware
2275GAME( 1994, mstworld,  0,        mstworld,mstworld, mstworld, ROT0,   "TCH", "Monsters World", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) // bootleg of Spang
2276GAME( 1990, sbbros,    spang,    pang,    pang,     sbbros,   ROT0,   "Mitchell + Capcom", "Super Buster Bros. (US 901001)", GAME_SUPPORTS_SAVE )
2277GAME( 1990, marukin,   0,        marukin, marukin,  marukin,  ROT0,   "Yuga", "Super Marukin-Ban (Japan 901017)", GAME_SUPPORTS_SAVE )
2278GAME( 1991, qtono1,    0,        pang,    qtono1,   qtono1,   ROT0,   "Capcom", "Quiz Tonosama no Yabou (Japan)", GAME_SUPPORTS_SAVE )
2279GAME( 1991, qsangoku,  0,        pang,    qtono1,   qsangoku, ROT0,   "Capcom", "Quiz Sangokushi (Japan)", GAME_SUPPORTS_SAVE )
2280GAME( 1991, block,     0,        pang,    block,    block,    ROT270, "Capcom", "Block Block (World 910910)", GAME_SUPPORTS_SAVE )
2281GAME( 1991, blockj,    block,    pang,    block,    block,    ROT270, "Capcom", "Block Block (Japan 910910)", GAME_SUPPORTS_SAVE )
2282GAME( 1991, blockjoy,  block,    pang,    blockjoy, block,    ROT270, "Capcom", "Block Block (World 911106 Joystick)", GAME_SUPPORTS_SAVE )
2283GAME( 1991, blockbl,   block,    pang,    block,    blockbl,  ROT270, "bootleg", "Block Block (bootleg)", GAME_SUPPORTS_SAVE )
src/mame/drivers/blktiger.c
r6740r6741
1717#include "cpu/z80/z80.h"
1818#include "sound/2203intf.h"
1919#include "cpu/mcs51/mcs51.h"
20#include "blktiger.h"
20#include "includes/blktiger.h"
2121
2222
2323/**************************************************
src/mame/drivers/deco_mlc.c
r6740r6741
9999#include "includes/decocrpt.h"
100100#include "machine/eeprom.h"
101101#include "sound/ymz280b.h"
102#include "decoprot.h"
102#include "includes/decoprot.h"
103103#include "cpu/arm/arm.h"
104104#include "cpu/sh2/sh2.h"
105105
r6740r6741
109109
110110extern UINT32 *mlc_vram, *mlc_clip_ram;
111111static UINT32 *mlc_ram, *irq_ram;
112static emu_timer *raster_irq_timer;
112static const device_config *raster_irq_timer;
113113static int mainCpuIsArm;
114114static int mlc_raster_table[9][256];
115115static UINT32 vbl_i;
r6740r6741
174174   return video_screen_get_vpos(space->machine->primary_screen);
175175}
176176
177static TIMER_CALLBACK( interrupt_gen )
177static TIMER_DEVICE_CALLBACK( interrupt_gen )
178178{
179179//  logerror("hit scanline IRQ %d (%08x)\n", video_screen_get_vpos(machine->primary_screen), info.i);
180   cputag_set_input_line(machine, "maincpu", mainCpuIsArm ? ARM_IRQ_LINE : 1, HOLD_LINE);
180   cputag_set_input_line(timer->machine, "maincpu", mainCpuIsArm ? ARM_IRQ_LINE : 1, HOLD_LINE);
181181}
182182
183183static WRITE32_HANDLER( mlc_irq_w )
r6740r6741
192192      cputag_set_input_line(space->machine, "maincpu", mainCpuIsArm ? ARM_IRQ_LINE : 1, CLEAR_LINE);
193193      return;
194194   case 0x14: /* Prepare scanline interrupt */
195      timer_adjust_oneshot(raster_irq_timer,video_screen_get_time_until_pos(space->machine->primary_screen, irq_ram[0x14/4], 0),0);
195      timer_device_adjust_oneshot(raster_irq_timer,video_screen_get_time_until_pos(space->machine->primary_screen, irq_ram[0x14/4], 0),0);
196196      //logerror("prepare scanline to fire at %d (currently on %d)\n", irq_ram[0x14/4], video_screen_get_vpos(space->machine->primary_screen));
197197      return;
198198   case 0x18:
r6740r6741
379379static MACHINE_RESET( mlc )
380380{
381381   vbl_i = 0xffffffff;
382   raster_irq_timer = timer_alloc(machine, interrupt_gen, NULL);
382   raster_irq_timer = devtag_get_device(machine, "int_timer");
383383}
384384
385385static NVRAM_HANDLER( mlc )
r6740r6741
410410   MDRV_MACHINE_RESET(mlc)
411411   MDRV_NVRAM_HANDLER(mlc) /* Actually 93c45 */
412412
413   MDRV_TIMER_ADD("int_timer", interrupt_gen)
414
413415   /* video hardware */
414416   MDRV_SCREEN_ADD("screen", RASTER)
415417   MDRV_SCREEN_REFRESH_RATE(58)
r6740r6741
441443   MDRV_MACHINE_RESET(mlc)
442444   MDRV_NVRAM_HANDLER(mlc) /* Actually 93c45 */
443445
446   MDRV_TIMER_ADD("int_timer", interrupt_gen)
447
444448   /* video hardware */
445449   MDRV_SCREEN_ADD("screen", RASTER)
446450   MDRV_SCREEN_REFRESH_RATE(58)
src/mame/drivers/fgoal.c
r6740r6741
1818
1919#include "driver.h"
2020#include "cpu/m6800/m6800.h"
21#include "machine/mb14241.h"
2122#include "includes/fgoal.h"
2223
2324
r6740r6741
138139static WRITE8_HANDLER( fgoal_row_w )
139140{
140141   fgoal_state *state = (fgoal_state *)space->machine->driver_data;
142
141143   state->row = data;
142   state->shift_data = state->shift_data >> 8;
144   mb14241_shift_data_w(state->mb14241, 0, 0);
143145}
144146
145147static WRITE8_HANDLER( fgoal_col_w )
146148{
147149   fgoal_state *state = (fgoal_state *)space->machine->driver_data;
150
148151   state->col = data;
149   state->shift_bits = data & 7;
152   mb14241_shift_count_w(state->mb14241, 0, data);
150153}
151154
152
153static WRITE8_HANDLER( fgoal_shifter_w )
154{
155   fgoal_state *state = (fgoal_state *)space->machine->driver_data;
156   state->shift_data = (state->shift_data >> 8) | (data << 8); /* MB14241 custom chip */
157}
158
159
160155static READ8_HANDLER( fgoal_address_hi_r )
161156{
162157   return video_ram_address(space->machine) >> 8;
r6740r6741
167162   return video_ram_address(space->machine) & 0xff;
168163}
169164
170
171165static READ8_HANDLER( fgoal_shifter_r )
172166{
173167   fgoal_state *state = (fgoal_state *)space->machine->driver_data;
174   UINT8 v = state->shift_data >> (8 - state->shift_bits);
168   UINT8 v = mb14241_shift_result_r(state->mb14241, 0);
175169
176170   return BITSWAP8(v, 7, 6, 5, 4, 3, 2, 1, 0);
177171}
r6740r6741
179173static READ8_HANDLER( fgoal_shifter_reverse_r )
180174{
181175   fgoal_state *state = (fgoal_state *)space->machine->driver_data;
182   UINT8 v = state->shift_data >> (8 - state->shift_bits);
176   UINT8 v = mb14241_shift_result_r(state->mb14241, 0);
183177
184178   return BITSWAP8(v, 0, 1, 2, 3, 4, 5, 6, 7);
185179}
r6740r6741
230224   AM_RANGE(0x00f1, 0x00f1) AM_WRITE(fgoal_col_w)
231225   AM_RANGE(0x00f2, 0x00f2) AM_WRITE(fgoal_row_w)
232226   AM_RANGE(0x00f3, 0x00f3) AM_WRITE(fgoal_col_w)
233   AM_RANGE(0x00f4, 0x00f7) AM_WRITE(fgoal_shifter_w)
227   AM_RANGE(0x00f4, 0x00f7) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
234228   AM_RANGE(0x00f8, 0x00fb) AM_WRITE(fgoal_sound1_w)
235229   AM_RANGE(0x00fc, 0x00ff) AM_WRITE(fgoal_sound2_w)
236230
r6740r6741
347341   fgoal_state *state = (fgoal_state *)machine->driver_data;
348342
349343   state->maincpu = devtag_get_device(machine, "maincpu");
344   state->mb14241 = devtag_get_device(machine, "mb14241");
350345
351346   state_save_register_global(machine, state->xpos);
352347   state_save_register_global(machine, state->ypos);
r6740r6741
354349   state_save_register_global(machine, state->fgoal_player);
355350   state_save_register_global(machine, state->row);
356351   state_save_register_global(machine, state->col);
357   state_save_register_global(machine, state->shift_data);
358   state_save_register_global(machine, state->shift_bits);
359352   state_save_register_global(machine, state->prev_coin);
360353}
361354
r6740r6741
371364   state->fgoal_player = 0;
372365   state->row = 0;
373366   state->col = 0;
374   state->shift_data = 0;
375   state->shift_bits = 0;
376367   state->prev_coin = 0;
377368}
378369
r6740r6741
388379   MDRV_MACHINE_START(fgoal)
389380   MDRV_MACHINE_RESET(fgoal)
390381
382   /* add shifter */
383   MDRV_MB14241_ADD("mb14241")
384
391385   /* video hardware */
392386   MDRV_SCREEN_ADD("screen", RASTER)
393387   MDRV_SCREEN_REFRESH_RATE(60)
src/mame/drivers/mystston.c
r6740r6741
1616#include "driver.h"
1717#include "cpu/m6502/m6502.h"
1818#include "sound/ay8910.h"
19#include "mystston.h"
19#include "includes/mystston.h"
2020
2121
2222
src/mame/drivers/mainsnk.c
r6740r6741
109109
110110#include "driver.h"
111111#include "cpu/z80/z80.h"
112#include "snk.h"
112#include "includes/snk.h"
113113#include "sound/ay8910.h"
114114
115115extern UINT8 *mainsnk_fgram;
src/mame/drivers/rampart.c
r6740r6741
2424
2525#include "driver.h"
2626#include "cpu/m68000/m68000.h"
27#include "rampart.h"
27#include "includes/rampart.h"
2828#include "sound/okim6295.h"
2929#include "sound/2413intf.h"
3030
r6740r6741
6060 *
6161 *************************************/
6262
63static MACHINE_START( rampart )
64{
65   atarigen_init(machine);
66}
67
68
6369static MACHINE_RESET( rampart )
6470{
6571   rampart_state *state = (rampart_state *)machine->driver_data;
r6740r6741
343349   MDRV_CPU_PROGRAM_MAP(main_map)
344350   MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen)
345351
352   MDRV_MACHINE_START(rampart)
346353   MDRV_MACHINE_RESET(rampart)
347354   MDRV_NVRAM_HANDLER(atarigen)
348355   MDRV_WATCHDOG_VBLANK_INIT(8)
src/mame/drivers/segaxbd.c
r6740r6741
233233
234234#include "driver.h"
235235#include "cpu/z80/z80.h"
236#include "system16.h"
236#include "includes/system16.h"
237237#include "cpu/m68000/m68000.h"
238238#include "machine/segaic16.h"
239239#include "sound/2151intf.h"
src/mame/drivers/nbmj9195.c
r6740r6741
2222#include "driver.h"
2323#include "cpu/z80/z80.h"
2424#include "machine/z80ctc.h"
25#include "nb1413m3.h"      // needed for mahjong input controller
25#include "includes/nb1413m3.h"      // needed for mahjong input controller
2626#include "sound/3812intf.h"
2727#include "sound/dac.h"
2828#include "cpu/z80/z80daisy.h"
src/mame/drivers/hcastle.c
r6740r6741
1212#include "sound/3812intf.h"
1313#include "sound/k007232.h"
1414#include "sound/k051649.h"
15#include "konamipt.h"
15#include "video/konicdev.h"
16#include "includes/konamipt.h"
17#include "includes/hcastle.h"
1618
17PALETTE_INIT( hcastle );
18VIDEO_UPDATE( hcastle );
19VIDEO_START( hcastle );
2019
21extern UINT8 *hcastle_pf1_videoram,*hcastle_pf2_videoram;
22
23WRITE8_HANDLER( hcastle_pf1_video_w );
24WRITE8_HANDLER( hcastle_pf2_video_w );
25READ8_HANDLER( hcastle_gfxbank_r );
26WRITE8_HANDLER( hcastle_gfxbank_w );
27WRITE8_HANDLER( hcastle_pf1_control_w );
28WRITE8_HANDLER( hcastle_pf2_control_w );
29
3020static WRITE8_HANDLER( hcastle_bankswitch_w )
3121{
32   UINT8 *RAM = memory_region(space->machine, "maincpu");
33   int bankaddress;
34
35   bankaddress = 0x10000 + (data & 0x1f) * 0x2000;
36   memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]);
22   memory_set_bank(space->machine, "bank1", data & 0x1f);
3723}
3824
3925static WRITE8_HANDLER( hcastle_soundirq_w )
4026{
41   cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE );
27   hcastle_state *state = (hcastle_state *)space->machine->driver_data;
28   cpu_set_input_line(state->audiocpu, 0, HOLD_LINE);
4229}
4330
4431static WRITE8_HANDLER( hcastle_coin_w )
4532{
46   coin_counter_w(space->machine, 0,data & 0x40);
47   coin_counter_w(space->machine, 1,data & 0x80);
33   coin_counter_w(space->machine, 0, data & 0x40);
34   coin_counter_w(space->machine, 1, data & 0x80);
4835}
4936
5037
r6740r6741
6552   AM_RANGE(0x0414, 0x0414) AM_READ_PORT("DSW1")
6653   AM_RANGE(0x0415, 0x0415) AM_READ_PORT("DSW2")
6754   AM_RANGE(0x0418, 0x0418) AM_READWRITE(hcastle_gfxbank_r, hcastle_gfxbank_w)
68   AM_RANGE(0x0600, 0x06ff) AM_RAM AM_BASE_GENERIC(paletteram)
55   AM_RANGE(0x0600, 0x06ff) AM_RAM AM_BASE_MEMBER(hcastle_state, paletteram)
6956   AM_RANGE(0x0700, 0x1fff) AM_RAM
70   AM_RANGE(0x2000, 0x2fff) AM_RAM_WRITE(hcastle_pf1_video_w) AM_BASE(&hcastle_pf1_videoram)
57   AM_RANGE(0x2000, 0x2fff) AM_RAM_WRITE(hcastle_pf1_video_w) AM_BASE_MEMBER(hcastle_state, pf1_videoram)
7158   AM_RANGE(0x3000, 0x3fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
72   AM_RANGE(0x4000, 0x4fff) AM_RAM_WRITE(hcastle_pf2_video_w) AM_BASE(&hcastle_pf2_videoram)
59   AM_RANGE(0x4000, 0x4fff) AM_RAM_WRITE(hcastle_pf2_video_w) AM_BASE_MEMBER(hcastle_state, pf2_videoram)
7360   AM_RANGE(0x5000, 0x5fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram2)
7461   AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank1")
7562   AM_RANGE(0x8000, 0xffff) AM_ROM
r6740r6741
169156
170157static void irqhandler(const device_config *device, int linestate)
171158{
172//  cputag_set_input_line(device->machine, "audiocpu", 0, linestate);
159//  hcastle_state *state = (hcastle_state *)device->machine->driver_data;
160//  cputag_set_input_line(state->audiocpu, 0, linestate);
173161}
174162
175163static void volume_callback(const device_config *device, int v)
176164{
177   k007232_set_volume(device,0,(v >> 4) * 0x11,0);
178   k007232_set_volume(device,1,0,(v & 0x0f) * 0x11);
165   k007232_set_volume(device, 0, (v >> 4) * 0x11, 0);
166   k007232_set_volume(device, 1, 0, (v & 0x0f) * 0x11);
179167}
180168
181169static const k007232_interface k007232_config =
r6740r6741
188176   irqhandler
189177};
190178
179static MACHINE_START( hcastle )
180{
181   hcastle_state *state = (hcastle_state *)machine->driver_data;
182   UINT8 *ROM = memory_region(machine, "maincpu");
183
184   memory_configure_bank(machine, "bank1", 0, 16, &ROM[0x10000], 0x2000);
185
186   state->audiocpu = devtag_get_device(machine, "audiocpu");
187   state->k007121_1 = devtag_get_device(machine, "k007121_1");
188   state->k007121_2 = devtag_get_device(machine, "k007121_2");
189
190   state_save_register_global(machine, state->pf2_bankbase);
191   state_save_register_global(machine, state->pf1_bankbase);
192   state_save_register_global(machine, state->gfx_bank);
193   state_save_register_global(machine, state->old_pf1);
194   state_save_register_global(machine, state->old_pf2);
195}
196
197static MACHINE_RESET( hcastle )
198{
199   hcastle_state *state = (hcastle_state *)machine->driver_data;
200
201   state->pf2_bankbase = 0;
202   state->pf1_bankbase = 0;
203   state->gfx_bank = 0;
204   state->old_pf1 = -1;
205   state->old_pf2 = -1;
206}
207
191208static MACHINE_DRIVER_START( hcastle )
192209
210   /* driver data */
211   MDRV_DRIVER_DATA(hcastle_state)
212
193213   /* basic machine hardware */
194214   MDRV_CPU_ADD("maincpu", KONAMI, 3000000)   /* Derived from 24 MHz clock */
195215   MDRV_CPU_PROGRAM_MAP(hcastle_map)
r6740r6741
198218   MDRV_CPU_ADD("audiocpu", Z80, 3579545)
199219   MDRV_CPU_PROGRAM_MAP(sound_map)
200220
221   MDRV_MACHINE_START(hcastle)
222   MDRV_MACHINE_RESET(hcastle)
223
201224   /* video hardware */
202225   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
203226
r6740r6741
215238   MDRV_VIDEO_START(hcastle)
216239   MDRV_VIDEO_UPDATE(hcastle)
217240
241   MDRV_K007121_ADD("k007121_1")
242   MDRV_K007121_ADD("k007121_2")
243
218244   /* sound hardware */
219245   MDRV_SPEAKER_STANDARD_MONO("mono")
220246
r6740r6741
343369
344370
345371
346GAME( 1988, hcastle,  0,       hcastle, hcastle, 0, ROT0, "Konami", "Haunted Castle (version M)", 0 )
347GAME( 1988, hcastleo, hcastle, hcastle, hcastle, 0, ROT0, "Konami", "Haunted Castle (version K)", 0 )
348GAME( 1988, hcastlej, hcastle, hcastle, hcastle, 0, ROT0, "Konami", "Akuma-Jou Dracula (Japan version P)", 0 )
349GAME( 1988, hcastljo, hcastle, hcastle, hcastle, 0, ROT0, "Konami", "Akuma-Jou Dracula (Japan version N)", 0 )
372GAME( 1988, hcastle,  0,       hcastle, hcastle, 0, ROT0, "Konami", "Haunted Castle (version M)", GAME_SUPPORTS_SAVE )
373GAME( 1988, hcastleo, hcastle, hcastle, hcastle, 0, ROT0, "Konami", "Haunted Castle (version K)", GAME_SUPPORTS_SAVE )
374GAME( 1988, hcastlej, hcastle, hcastle, hcastle, 0, ROT0, "Konami", "Akuma-Jou Dracula (Japan version P)", GAME_SUPPORTS_SAVE )
375GAME( 1988, hcastljo, hcastle, hcastle, hcastle, 0, ROT0, "Konami", "Akuma-Jou Dracula (Japan version N)", GAME_SUPPORTS_SAVE )
src/mame/drivers/copsnrob.c
r6740r6741
5757
5858#include "driver.h"
5959#include "cpu/m6502/m6502.h"
60#include "copsnrob.h"
60#include "includes/copsnrob.h"
6161#include "copsnrob.lh"
6262
6363
src/mame/drivers/dblewing.c
r6740r6741
2020#include "driver.h"
2121#include "cpu/z80/z80.h"
2222#include "cpu/m68000/m68000.h"
23#include "decocrpt.h"
24#include "deco16ic.h"
23#include "includes/decocrpt.h"
24#include "includes/deco16ic.h"
2525#include "sound/2151intf.h"
2626#include "sound/okim6295.h"
2727
src/mame/drivers/arabian.c
r6740r6741
6868
6969#include "driver.h"
7070#include "cpu/z80/z80.h"
71#include "arabian.h"
71#include "includes/arabian.h"
7272#include "sound/ay8910.h"
7373
7474/* constants */
src/mame/drivers/labyrunr.c
r6740r6741
11/***************************************************************************
22
3Labyrinth Runner (GX771) (c) 1987 Konami
3    Labyrinth Runner (GX771) (c) 1987 Konami
44
5similar to Fast Lane
5    similar to Fast Lane
66
7Driver by Nicola Salmoria
7    Driver by Nicola Salmoria
88
99***************************************************************************/
1010
1111#include "driver.h"
1212#include "deprecat.h"
1313#include "cpu/hd6309/hd6309.h"
14#include "video/konamiic.h"
1514#include "sound/2203intf.h"
16#include "konamipt.h"
15#include "video/konicdev.h"
16#include "includes/konamipt.h"
17#include "includes/labyrunr.h"
1718
18/* from video/labyrunr.c */
19extern UINT8 *labyrunr_videoram1,*labyrunr_videoram2,*labyrunr_scrollram;
20PALETTE_INIT( labyrunr );
21WRITE8_HANDLER( labyrunr_vram1_w );
22WRITE8_HANDLER( labyrunr_vram2_w );
23VIDEO_START( labyrunr );
24VIDEO_UPDATE( labyrunr );
2519
2620static INTERRUPT_GEN( labyrunr_interrupt )
2721{
22   labyrunr_state *state = (labyrunr_state *)device->machine->driver_data;
23
2824   if (cpu_getiloops(device) == 0)
2925   {
30      if (K007121_ctrlram[0][0x07] & 0x02)
26      if (k007121_ctrlram_r(state->k007121, 7) & 0x02)
3127         cpu_set_input_line(device, HD6309_IRQ_LINE, HOLD_LINE);
3228   }
3329   else if (cpu_getiloops(device) % 2)
3430   {
35      if (K007121_ctrlram[0][0x07] & 0x01)
31      if (k007121_ctrlram_r(state->k007121, 7) & 0x01)
3632         cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
3733   }
3834}
3935
4036static WRITE8_HANDLER( labyrunr_bankswitch_w )
4137{
42   int bankaddress;
43   UINT8 *RAM = memory_region(space->machine, "maincpu");
38   if (data & 0xe0) popmessage("bankswitch %02x", data);
4439
45if (data & 0xe0) popmessage("bankswitch %02x",data);
46
4740   /* bits 0-2 = bank number */
48   bankaddress = 0x10000 + (data & 0x07) * 0x4000;
49   memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]);
41   memory_set_bank(space->machine, "bank1", data & 0x07);   // shall we check if data&7 > #banks?
5042
5143   /* bits 3 and 4 are coin counters */
52   coin_counter_w(space->machine, 0,data & 0x08);
53   coin_counter_w(space->machine, 1,data & 0x10);
44   coin_counter_w(space->machine, 0, data & 0x08);
45   coin_counter_w(space->machine, 1, data & 0x10);
5446}
5547
5648static ADDRESS_MAP_START( labyrunr_map, ADDRESS_SPACE_PROGRAM, 8 )
57   AM_RANGE(0x0000, 0x0007) AM_WRITE(K007121_ctrl_0_w)
58   AM_RANGE(0x0020, 0x005f) AM_RAM AM_BASE(&labyrunr_scrollram)
49   AM_RANGE(0x0000, 0x0007) AM_DEVWRITE("k007121", k007121_ctrl_w)
50   AM_RANGE(0x0020, 0x005f) AM_RAM AM_BASE_MEMBER(labyrunr_state, scrollram)
5951   AM_RANGE(0x0800, 0x0800) AM_DEVREADWRITE("ym1", ym2203_read_port_r, ym2203_write_port_w)
6052   AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE("ym1", ym2203_status_port_r, ym2203_control_port_w)
6153   AM_RANGE(0x0900, 0x0900) AM_DEVREADWRITE("ym2", ym2203_read_port_r, ym2203_write_port_w)
r6740r6741
6456   AM_RANGE(0x0a01, 0x0a01) AM_READ_PORT("P1")
6557   AM_RANGE(0x0b00, 0x0b00) AM_READ_PORT("SYSTEM")
6658   AM_RANGE(0x0c00, 0x0c00) AM_WRITE(labyrunr_bankswitch_w)
67   AM_RANGE(0x0d00, 0x0d1f) AM_READWRITE(K051733_r, K051733_w)
59   AM_RANGE(0x0d00, 0x0d1f) AM_DEVREADWRITE("k051733", k051733_r, k051733_w)
6860   AM_RANGE(0x0e00, 0x0e00) AM_WRITE(watchdog_reset_w)
69   AM_RANGE(0x1000, 0x10ff) AM_RAM AM_BASE_GENERIC(paletteram)
61   AM_RANGE(0x1000, 0x10ff) AM_RAM AM_BASE_MEMBER(labyrunr_state, paletteram)
7062   AM_RANGE(0x1800, 0x1fff) AM_RAM
71   AM_RANGE(0x2000, 0x2fff) AM_RAM AM_BASE_GENERIC(spriteram)
72   AM_RANGE(0x3000, 0x37ff) AM_RAM_WRITE(labyrunr_vram1_w) AM_BASE(&labyrunr_videoram1)
73   AM_RANGE(0x3800, 0x3fff) AM_RAM_WRITE(labyrunr_vram2_w) AM_BASE(&labyrunr_videoram2)
63   AM_RANGE(0x2000, 0x2fff) AM_RAM AM_BASE_MEMBER(labyrunr_state, spriteram)
64   AM_RANGE(0x3000, 0x37ff) AM_RAM_WRITE(labyrunr_vram1_w) AM_BASE_MEMBER(labyrunr_state, videoram1)
65   AM_RANGE(0x3800, 0x3fff) AM_RAM_WRITE(labyrunr_vram2_w) AM_BASE_MEMBER(labyrunr_state, videoram2)
7466   AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1")
7567   AM_RANGE(0x8000, 0xffff) AM_ROM
7668ADDRESS_MAP_END
r6740r6741
191183
192184
193185
186static MACHINE_START( labyrunr )
187{
188   labyrunr_state *state = (labyrunr_state *)machine->driver_data;
189   UINT8 *ROM = memory_region(machine, "maincpu");
190
191   memory_configure_bank(machine, "bank1", 0, 6, &ROM[0x10000], 0x4000);
192
193   state->k007121 = devtag_get_device(machine, "k007121");
194}
195
194196static MACHINE_DRIVER_START( labyrunr )
195197
198   /* driver data */
199   MDRV_DRIVER_DATA(labyrunr_state)
200
196201   /* basic machine hardware */
197202   MDRV_CPU_ADD("maincpu", HD6309, 3000000*4)      /* 24MHz/8? */
198203   MDRV_CPU_PROGRAM_MAP(labyrunr_map)
199204   MDRV_CPU_VBLANK_INT_HACK(labyrunr_interrupt,8)   /* 1 IRQ + 4 NMI (generated by 007121) */
200205
206   MDRV_MACHINE_START(labyrunr)
207
201208   /* video hardware */
202209   MDRV_SCREEN_ADD("screen", RASTER)
203210   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
213220   MDRV_VIDEO_START(labyrunr)
214221   MDRV_VIDEO_UPDATE(labyrunr)
215222
223   MDRV_K007121_ADD("k007121")
224   MDRV_K051733_ADD("k051733")
225
216226   /* sound hardware */
217227   MDRV_SPEAKER_STANDARD_MONO("mono")
218228
r6740r6741
287297ROM_END
288298
289299
290GAME( 1987, tricktrp, 0,        labyrunr, labyrunr, 0, ROT90, "Konami", "Trick Trap (World?)", 0 )
291GAME( 1987, labyrunr, tricktrp, labyrunr, labyrunr, 0, ROT90, "Konami", "Labyrinth Runner (Japan)", 0 )
292GAME( 1987, labyrunrk,tricktrp, labyrunr, labyrunr, 0, ROT90, "Konami", "Labyrinth Runner (World Ver. K)", 0 )
300GAME( 1987, tricktrp, 0,        labyrunr, labyrunr, 0, ROT90, "Konami", "Trick Trap (World?)", GAME_SUPPORTS_SAVE )
301GAME( 1987, labyrunr, tricktrp, labyrunr, labyrunr, 0, ROT90, "Konami", "Labyrinth Runner (Japan)", GAME_SUPPORTS_SAVE )
302GAME( 1987, labyrunrk,tricktrp, labyrunr, labyrunr, 0, ROT90, "Konami", "Labyrinth Runner (World Ver. K)", GAME_SUPPORTS_SAVE )
src/mame/drivers/hornet.c
r6740r6741
311311#include "cpu/m68000/m68000.h"
312312#include "cpu/powerpc/ppc.h"
313313#include "cpu/sharc/sharc.h"
314#include "machine/eeprom.h"
314#include "machine/eepromdev.h"
315315#include "machine/konppc.h"
316#include "machine/konamiic.h"
317316#include "video/voodoo.h"
318317#include "machine/timekpr.h"
319318#include "sound/rf5c400.h"
320319#include "rendlay.h"
321320#include "machine/adc1213x.h"
321#include "sound/k056800.h"
322322
323323static UINT8 led_reg0, led_reg1;
324324static UINT32 *workram;
r6740r6741
633633   UINT8 r = 0;
634634   static const char *const portnames[] = { "IN0", "IN1", "IN2" };
635635   const device_config *adc12138 = devtag_get_device(space->machine, "adc12138");
636   const device_config *eeprom = devtag_get_device(space->machine, "eeprom");
636637
637638   switch (offset)
638639   {
r6740r6741
652653                0x02 = ADDOR (ADC DOR)
653654                0x01 = ADDO (ADC DO)
654655            */
655         r = 0xf0 | (eeprom_read_bit() << 3);
656         r = 0xf0 | (eepromdev_read_bit(eeprom) << 3);
656657         r |= adc1213x_do_r(adc12138, 0) | (adc1213x_eoc_r(adc12138, 0) << 2);
657658         break;
658659
r6740r6741
692693                0x02 = LAMP1
693694                0x01 = LAMP0
694695            */
695         eeprom_write_bit((data & 0x10) ? 1 : 0);
696         eeprom_set_clock_line((data & 0x20) ? ASSERT_LINE : CLEAR_LINE);
697         eeprom_set_cs_line((data & 0x40) ? CLEAR_LINE : ASSERT_LINE);
696         input_port_write(space->machine, "EEPROMOUT", data, 0xff);
698697         mame_printf_debug("System register 0 = %02X\n", data);
699698         break;
700699
r6740r6741
807806   AM_RANGE(0x7d000000, 0x7d00ffff) AM_READ8(sysreg_r, 0xffffffff)
808807   AM_RANGE(0x7d010000, 0x7d01ffff) AM_WRITE8(sysreg_w, 0xffffffff)
809808   AM_RANGE(0x7d020000, 0x7d021fff) AM_DEVREADWRITE8("m48t58", timekeeper_r, timekeeper_w, 0xffffffff)   /* M48T58Y RTC/NVRAM */
810   AM_RANGE(0x7d030000, 0x7d030007) AM_READWRITE(K056800_host_r, K056800_host_w)
809   AM_RANGE(0x7d030000, 0x7d030007) AM_DEVREADWRITE("k056800", k056800_host_r, k056800_host_w)
811810   AM_RANGE(0x7d042000, 0x7d043fff) AM_RAM            /* COMM BOARD 0 */
812811   AM_RANGE(0x7d044000, 0x7d044007) AM_READ(comm0_unk_r)
813812   AM_RANGE(0x7d048000, 0x7d048003) AM_WRITE(comm1_w)
r6740r6741
824823   AM_RANGE(0x000000, 0x07ffff) AM_ROM
825824   AM_RANGE(0x100000, 0x10ffff) AM_RAM      /* Work RAM */
826825   AM_RANGE(0x200000, 0x200fff) AM_DEVREADWRITE("rfsnd", rf5c400_r, rf5c400_w)      /* Ricoh RF5C400 */
827   AM_RANGE(0x300000, 0x30000f) AM_READWRITE(K056800_sound_r, K056800_sound_w)
826   AM_RANGE(0x300000, 0x30000f) AM_DEVREADWRITE("k056800", k056800_sound_r, k056800_sound_w)
828827   AM_RANGE(0x480000, 0x480001) AM_WRITENOP
829828   AM_RANGE(0x4c0000, 0x4c0001) AM_WRITENOP
830829   AM_RANGE(0x500000, 0x500001) AM_WRITENOP
r6740r6741
967966   PORT_DIPNAME( 0x01, 0x01, "Monitor Type" ) PORT_DIPLOCATION("SW:8")
968967   PORT_DIPSETTING( 0x01, "24KHz" )
969968   PORT_DIPSETTING( 0x00, "15KHz" )
969
970   PORT_START( "EEPROMOUT" )
971   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
972   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
973   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
970974INPUT_PORTS_END
971975
972976static INPUT_PORTS_START( sscope )
r6740r6741
10141018   PORT_DIPNAME( 0x01, 0x01, "Monitor Type" ) PORT_DIPLOCATION("SW:8")
10151019   PORT_DIPSETTING( 0x01, "24KHz" )
10161020   PORT_DIPSETTING( 0x00, "15KHz" )
1021
1022   PORT_START( "EEPROMOUT" )
1023   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
1024   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
1025   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
10171026INPUT_PORTS_END
10181027
10191028static const sharc_config sharc_cfg =
r6740r6741
10641073      memory_set_bankptr(machine, "bank5", usr5);
10651074}
10661075
1067static NVRAM_HANDLER( hornet )
1068{
1069   NVRAM_HANDLER_CALL(93C46);
1070}
1071
10721076static double adc12138_input_callback( const device_config *device, UINT8 input )
10731077{
10741078   return (double)0.0;
r6740r6741
10781082   adc12138_input_callback
10791083};
10801084
1085static TIMER_CALLBACK( irq_off )
1086{
1087   cputag_set_input_line(machine, "audiocpu", param, CLEAR_LINE);
1088}
1089
1090static void sound_irq_callback( running_machine *machine, int irq )
1091{
1092   int line = (irq == 0) ? INPUT_LINE_IRQ1 : INPUT_LINE_IRQ2;
1093
1094   cputag_set_input_line(machine, "audiocpu", line, ASSERT_LINE);
1095   timer_set(machine, ATTOTIME_IN_USEC(1), NULL, line, irq_off);
1096}
1097
1098static const k056800_interface hornet_k056800_interface =
1099{
1100   sound_irq_callback
1101};
1102
10811103static MACHINE_DRIVER_START( hornet )
10821104
10831105   /* basic machine hardware */
r6740r6741
10961118   MDRV_MACHINE_START( hornet )
10971119   MDRV_MACHINE_RESET( hornet )
10981120
1099   MDRV_NVRAM_HANDLER( hornet )
1121   MDRV_EEPROM_93C46_NODEFAULT_ADD("eeprom")
11001122
11011123   MDRV_3DFX_VOODOO_1_ADD("voodoo0", STD_VOODOO_1_CLOCK, 2, "screen")
11021124   MDRV_3DFX_VOODOO_CPU("dsp")
r6740r6741
11151137   MDRV_VIDEO_START(hornet)
11161138   MDRV_VIDEO_UPDATE(hornet)
11171139
1140   MDRV_K056800_ADD("k056800", hornet_k056800_interface)
1141
11181142   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
11191143
11201144   MDRV_SOUND_ADD("rfsnd", RF5C400, 16934400)   // value from Guru readme, gives 44100 Hz sample rate
r6740r6741
11261150   MDRV_ADC12138_ADD( "adc12138", hornet_adc_interface )
11271151MACHINE_DRIVER_END
11281152
1153
11291154static MACHINE_RESET( hornet_2board )
11301155{
11311156   UINT8 *usr3 = memory_region(machine, "user3");
r6740r6741
13521377/*****************************************************************************/
13531378
13541379
1355static TIMER_CALLBACK( irq_off )
1356{
1357   cputag_set_input_line(machine, "audiocpu", param, CLEAR_LINE);
1358}
1359
1360static void sound_irq_callback(running_machine *machine, int irq)
1361{
1362   int line = (irq == 0) ? INPUT_LINE_IRQ1 : INPUT_LINE_IRQ2;
1363   cputag_set_input_line(machine, "audiocpu", line, ASSERT_LINE);
1364   timer_set(machine, ATTOTIME_IN_USEC(1), NULL, line, irq_off);
1365}
1366
13671380static DRIVER_INIT(hornet)
13681381{
13691382   init_konami_cgboard(machine, 1, CGBOARD_TYPE_HORNET);
13701383   set_cgboard_texture_bank(machine, 0, "bank5", memory_region(machine, "user5"));
13711384
1372   K056800_init(machine, sound_irq_callback);
13731385   K033906_init(machine);
13741386
13751387   led_reg0 = led_reg1 = 0x7f;
r6740r6741
13831395   set_cgboard_texture_bank(machine, 0, "bank5", memory_region(machine, "user5"));
13841396   set_cgboard_texture_bank(machine, 1, "bank6", memory_region(machine, "user5"));
13851397
1386   K056800_init(machine, sound_irq_callback);
13871398   K033906_init(machine);
13881399
13891400   led_reg0 = led_reg1 = 0x7f;
r6740r6741
15951606
15961607/*************************************************************************/
15971608
1598GAME(  1998, gradius4, 0,      hornet,           hornet, hornet,        ROT0, "Konami", "Gradius 4: Fukkatsu", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1599GAME(  1998, nbapbp,   0,      hornet,           hornet, hornet,        ROT0, "Konami", "NBA Play By Play", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1600GAMEL( 1998, terabrst, 0,      terabrst,        hornet, hornet_2board, ROT0, "Konami", "Teraburst (1998/07/17 ver UEL)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1601GAMEL( 1998, terabrsta,terabrst,terabrst,       hornet, hornet_2board, ROT0, "Konami", "Teraburst (1998/02/25 ver AAA)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1602GAMEL( 2000, sscope,   0,      hornet_2board,    sscope, hornet_2board, ROT0, "Konami", "Silent Scope (ver JZD)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1603GAMEL( 2000, sscopea,  sscope, hornet_2board,    sscope, hornet_2board, ROT0, "Konami", "Silent Scope (ver UAB)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1604GAMEL( 2000, sscopeb,  sscope, hornet_2board,    sscope, hornet_2board, ROT0, "Konami", "Silent Scope (ver UAA)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1605GAMEL( 2000, sscope2,  0,      hornet_2board_v2, sscope, hornet_2board, ROT0, "Konami", "Silent Scope 2", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1609GAME(  1998, gradius4,  0,        hornet,           hornet, hornet,        ROT0, "Konami", "Gradius 4: Fukkatsu", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1610GAME(  1998, nbapbp,    0,        hornet,           hornet, hornet,        ROT0, "Konami", "NBA Play By Play", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1611GAMEL( 1998, terabrst,  0,        terabrst,         hornet, hornet_2board, ROT0, "Konami", "Teraburst (1998/07/17 ver UEL)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1612GAMEL( 1998, terabrsta, terabrst, terabrst,         hornet, hornet_2board, ROT0, "Konami", "Teraburst (1998/02/25 ver AAA)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1613GAMEL( 2000, sscope,    0,        hornet_2board,    sscope, hornet_2board, ROT0, "Konami", "Silent Scope (ver JZD)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1614GAMEL( 2000, sscopea,   sscope,   hornet_2board,    sscope, hornet_2board, ROT0, "Konami", "Silent Scope (ver UAB)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1615GAMEL( 2000, sscopeb,   sscope,   hornet_2board,    sscope, hornet_2board, ROT0, "Konami", "Silent Scope (ver UAA)", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_dualhsxs )
1616GAMEL( 2000, sscope2,   0,        hornet_2board_v2, sscope, hornet_2board, ROT0, "Konami", "Silent Scope 2", GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE, layout_dualhsxs )
src/mame/drivers/ccastles.c
r6740r6741
122122#include "driver.h"
123123#include "cpu/m6502/m6502.h"
124124#include "sound/pokey.h"
125#include "ccastles.h"
125#include "includes/ccastles.h"
126126
127127
128128#define MASTER_CLOCK   (10000000)
src/mame/drivers/ddragon3.c
r6740r6741
143143#include "cpu/m68000/m68000.h"
144144#include "sound/2151intf.h"
145145#include "sound/okim6295.h"
146#include "ddragon3.h"
146#include "includes/ddragon3.h"
147147
148148#define PIXEL_CLOCK      (XTAL_28MHz / 4)
149149
src/mame/drivers/mediagx.c
r6740r6741
113113static int dacl_ptr = 0;
114114static int dacr_ptr = 0;
115115
116static emu_timer *sound_timer;
117116static UINT8 ad1847_regs[16];
118117static UINT32 ad1847_sample_counter = 0;
119118static UINT32 ad1847_sample_rate;
r6740r6741
635634
636635/* Analog Devices AD1847 Stereo DAC */
637636
638static TIMER_CALLBACK( sound_timer_callback )
637static TIMER_DEVICE_CALLBACK( sound_timer_callback )
639638{
640639   ad1847_sample_counter = 0;
641   timer_adjust_oneshot(sound_timer, ATTOTIME_IN_MSEC(10), 0);
640   timer_device_adjust_oneshot(timer, ATTOTIME_IN_MSEC(10), 0);
642641
643642   dmadac_transfer(&dmadac[0], 1, 0, 1, dacl_ptr, dacl);
644643   dmadac_transfer(&dmadac[1], 1, 0, 1, dacr_ptr, dacr);
r6740r6741
965964   mediagx_devices.pic8259_2 = devtag_get_device( machine, "pic8259_slave" );
966965   mediagx_devices.dma8237_1 = devtag_get_device( machine, "dma8237_1" );
967966   mediagx_devices.dma8237_2 = devtag_get_device( machine, "dma8237_2" );
967
968   dacl = auto_alloc_array(machine, INT16, 65536);
969   dacr = auto_alloc_array(machine, INT16, 65536);
968970}
969971
970972static MACHINE_RESET(mediagx)
r6740r6741
976978   memcpy(bios_ram, rom, 0x40000);
977979   device_reset(cputag_get_cpu(machine, "maincpu"));
978980
979   dacl = auto_alloc_array(machine, INT16, 65536);
980   dacr = auto_alloc_array(machine, INT16, 65536);
981   timer_device_adjust_oneshot(devtag_get_device(machine, "sound_timer"), ATTOTIME_IN_MSEC(10), 0);
981982
982   sound_timer = timer_alloc(machine, sound_timer_callback, NULL);
983   timer_adjust_oneshot(sound_timer, ATTOTIME_IN_MSEC(10), 0);
984
985983   dmadac[0] = devtag_get_device(machine, "dac1");
986984   dmadac[1] = devtag_get_device(machine, "dac2");
987985   dmadac_enable(&dmadac[0], 2, 1);
r6740r6741
10701068
10711069   MDRV_IDE_CONTROLLER_ADD("ide", ide_interrupt)
10721070
1071   MDRV_TIMER_ADD("sound_timer", sound_timer_callback)
1072
10731073   MDRV_NVRAM_HANDLER( mc146818 )
10741074
10751075    /* video hardware */
src/mame/drivers/ambush.c
r6740r6741
3636#include "driver.h"
3737#include "cpu/z80/z80.h"
3838#include "sound/ay8910.h"
39#include "ambush.h"
39#include "includes/ambush.h"
4040
4141
4242/*************************************
src/mame/drivers/orbit.c
r6740r6741
1919
2020#include "driver.h"
2121#include "cpu/m6800/m6800.h"
22#include "orbit.h"
22#include "includes/orbit.h"
2323#include "sound/discrete.h"
2424
2525
src/mame/drivers/policetr.c
r6740r6741
8686#include "driver.h"
8787#include "cpu/mips/r3000.h"
8888#include "machine/eeprom.h"
89#include "policetr.h"
89#include "includes/policetr.h"
9090#include "sound/bsmt2000.h"
9191
9292
src/mame/drivers/carpolo.c
r6740r6741
1818
1919#include "driver.h"
2020#include "cpu/m6502/m6502.h"
21#include "machine/7474.h"
22#include "machine/74148.h"
23#include "machine/74153.h"
2124#include "machine/6821pia.h"
22#include "carpolo.h"
25#include "includes/carpolo.h"
2326
2427
2528
r6740r6741
241244   MDRV_PIA6821_ADD("pia0", carpolo_pia0_intf)
242245   MDRV_PIA6821_ADD("pia1", carpolo_pia1_intf)
243246
247   MDRV_7474_ADD("7474_2s_1", carpolo_7474_2s_1_cb)
248   MDRV_7474_ADD("7474_2s_2", carpolo_7474_2s_2_cb)
249   MDRV_7474_ADD("7474_2u_1", carpolo_7474_2u_1_cb)
250   MDRV_7474_ADD("7474_2u_2", carpolo_7474_2u_2_cb)
251   MDRV_7474_ADD("7474_1f_1", NULL)
252   MDRV_7474_ADD("7474_1f_2", NULL)
253   MDRV_7474_ADD("7474_1d_1", NULL)
254   MDRV_7474_ADD("7474_1d_2", NULL)
255   MDRV_7474_ADD("7474_1c_1", NULL)
256   MDRV_7474_ADD("7474_1c_2", NULL)
257   MDRV_7474_ADD("7474_1a_1", NULL)
258   MDRV_7474_ADD("7474_1a_2", NULL)
259
260   MDRV_74148_ADD("74148_3s", carpolo_74148_3s_cb)
261   MDRV_74153_ADD("74153_1k", NULL)
262
244263   /* video hardware */
245264   MDRV_SCREEN_ADD("screen", RASTER)
246265   MDRV_SCREEN_REFRESH_RATE(60)
src/mame/drivers/speedatk.c
r6740r6741
7979#include "sound/ay8910.h"
8080#include "video/mc6845.h"
8181
82extern UINT8 *speedatk_videoram;
83extern UINT8 *speedatk_colorram;
8284static UINT8 mux_data;
8385static UINT8 km_status,coin_settings;
8486
r6740r6741
189191   AM_RANGE(0x8000, 0x8000) AM_READWRITE(key_matrix_r,key_matrix_w)
190192   AM_RANGE(0x8001, 0x8001) AM_READWRITE(key_matrix_status_r,key_matrix_status_w)
191193   AM_RANGE(0x8800, 0x8fff) AM_RAM
192   AM_RANGE(0xa000, 0xa3ff) AM_RAM_WRITE(speedatk_videoram_w) AM_BASE_GENERIC(videoram)
193   AM_RANGE(0xb000, 0xb3ff) AM_RAM_WRITE(speedatk_colorram_w) AM_BASE_GENERIC(colorram)
194   AM_RANGE(0xa000, 0xa3ff) AM_RAM_WRITE(speedatk_videoram_w) AM_BASE(&speedatk_videoram)
195   AM_RANGE(0xb000, 0xb3ff) AM_RAM_WRITE(speedatk_colorram_w) AM_BASE(&speedatk_colorram)
194196ADDRESS_MAP_END
195197
196198static ADDRESS_MAP_START( speedatk_io, ADDRESS_SPACE_IO, 8 )
src/mame/drivers/vroulet.c
r6740r6741
4242/* video */
4343
4444static UINT8 *vroulet_ball;
45static UINT8 *videoram;
46static UINT8 *colorram;
4547static tilemap *bg_tilemap;
4648
4749static WRITE8_HANDLER(vroulet_paletteram_w)
r6740r6741
6668
6769static WRITE8_HANDLER( vroulet_videoram_w )
6870{
69   space->machine->generic.videoram.u8[offset] = data;
71   videoram[offset] = data;
7072   tilemap_mark_tile_dirty(bg_tilemap, offset);
7173}
7274
7375static WRITE8_HANDLER( vroulet_colorram_w )
7476{
75   space->machine->generic.colorram.u8[offset] = data;
77   colorram[offset] = data;
7678   tilemap_mark_tile_dirty(bg_tilemap, offset);
7779}
7880
7981static TILE_GET_INFO( get_bg_tile_info )
8082{
81   int attr = machine->generic.colorram.u8[tile_index];
82   int code = machine->generic.videoram.u8[tile_index] + ((attr & 0xc0) << 2);
83   int attr = colorram[tile_index];
84   int code = videoram[tile_index] + ((attr & 0xc0) << 2);
8385   int color = attr & 0x1f;
8486
8587   SET_TILE_INFO(0, code, color, 0);
r6740r6741
105107   AM_RANGE(0x0000, 0x5fff) AM_ROM
106108   AM_RANGE(0x6000, 0x67ff) AM_RAM AM_BASE_SIZE_GENERIC(nvram)
107109   AM_RANGE(0x8000, 0x8000) AM_NOP
108   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(vroulet_videoram_w) AM_BASE_GENERIC(videoram)
109   AM_RANGE(0x9400, 0x97ff) AM_RAM_WRITE(vroulet_colorram_w) AM_BASE_GENERIC(colorram)
110   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(vroulet_videoram_w) AM_BASE(&videoram)
111   AM_RANGE(0x9400, 0x97ff) AM_RAM_WRITE(vroulet_colorram_w) AM_BASE(&colorram)
110112   AM_RANGE(0xa000, 0xa001) AM_RAM AM_BASE(&vroulet_ball)
111113   AM_RANGE(0xb000, 0xb0ff) AM_WRITE(vroulet_paletteram_w) AM_BASE_GENERIC(paletteram)
112114   AM_RANGE(0xc000, 0xc000) AM_NOP
src/mame/drivers/exedexes.c
r6740r6741
1414#include "deprecat.h"
1515#include "sound/ay8910.h"
1616#include "sound/sn76496.h"
17#include "exedexes.h"
17#include "includes/exedexes.h"
1818
1919
2020static INTERRUPT_GEN( exedexes_interrupt )
src/mame/drivers/jedi.c
r6740r6741
112112
113113#include "driver.h"
114114#include "cpu/m6502/m6502.h"
115#include "jedi.h"
115#include "includes/jedi.h"
116116
117117
118118
src/mame/drivers/seta2.c
r6740r6741
533533#include "cpu/m68000/m68000.h"
534534#include "machine/tmp68301.h"
535535#include "cpu/h83002/h8.h"
536#include "machine/eeprom.h"
536#include "machine/eepromdev.h"
537537#include "sound/x1_010.h"
538#include "seta.h"
538#include "includes/seta.h"
539539
540540/***************************************************************************
541541
r6740r6741
600600                        Mobile Suit Gundam EX Revue
601601***************************************************************************/
602602
603static NVRAM_HANDLER(93C46_gundamex)
603static READ16_DEVICE_HANDLER( gundamex_eeprom_r )
604604{
605   if (read_or_write)
606   {
607      eeprom_save(file);
608   }
609   else
610   {
611      eeprom_init(machine, &eeprom_interface_93C46);
612      if (file)
613      {
614         eeprom_load(file);
615      }
616      else
617      {
618         UINT32 length, size;
619         UINT16 *dat;
620
621         dat = (UINT16 *)eeprom_get_data_pointer(&length, &size);
622         dat[0] = 0x7008;
623      }
624   }
605   return ((eepromdev_read_bit(device) & 1)) << 3;
625606}
626607
627static READ16_HANDLER( gundamex_eeprom_r )
608static WRITE16_DEVICE_HANDLER( gundamex_eeprom_w )
628609{
629   return ((eeprom_read_bit() & 1)) << 3;
610      eepromdev_set_clock_line(device, (data & 0x2) ? ASSERT_LINE : CLEAR_LINE);
611      eepromdev_write_bit(device, data & 0x1);
612      eepromdev_set_cs_line(device, (data & 0x4) ? CLEAR_LINE : ASSERT_LINE);
630613}
631614
632static WRITE16_HANDLER( gundamex_eeprom_w )
633{
634      eeprom_set_clock_line((data & 0x2) ? ASSERT_LINE : CLEAR_LINE);
635      eeprom_write_bit(data & 0x1);
636      eeprom_set_cs_line((data & 0x4) ? CLEAR_LINE : ASSERT_LINE);
637}
638
639615static ADDRESS_MAP_START( gundamex_map, ADDRESS_SPACE_PROGRAM, 16 )
640616   AM_RANGE(0x000000, 0x1fffff) AM_ROM                        // ROM
641617   AM_RANGE(0x200000, 0x20ffff) AM_RAM                        // RAM
r6740r6741
655631   AM_RANGE(0xc50000, 0xc5ffff) AM_RAM                        // cleared
656632   AM_RANGE(0xc60000, 0xc6003f) AM_WRITE(seta2_vregs_w) AM_BASE(&seta2_vregs)   // Video Registers
657633   AM_RANGE(0xe00010, 0xe0001f) AM_WRITE(seta2_sound_bank_w)      // Samples Banks
658   AM_RANGE(0xfffd0a, 0xfffd0b) AM_READWRITE(gundamex_eeprom_r,gundamex_eeprom_w)   // parallel data register
634   AM_RANGE(0xfffd0a, 0xfffd0b) AM_DEVREADWRITE("eeprom", gundamex_eeprom_r,gundamex_eeprom_w)   // parallel data register
659635   AM_RANGE(0xfffc00, 0xffffff) AM_RAM_WRITE(tmp68301_regs_w) AM_BASE(&tmp68301_regs)   // TMP68301 Registers
660636ADDRESS_MAP_END
661637
r6740r6741
22982274   MDRV_CPU_PROGRAM_MAP(mj4simai_map)
22992275   MDRV_CPU_VBLANK_INT("screen", seta2_interrupt)
23002276
2277   MDRV_MACHINE_START( tmp68301 )
23012278   MDRV_MACHINE_RESET( tmp68301 )
23022279
23032280   /* video hardware */
r6740r6741
23312308   MDRV_CPU_MODIFY("maincpu")
23322309   MDRV_CPU_PROGRAM_MAP(gundamex_map)
23332310
2334   MDRV_NVRAM_HANDLER(93C46_gundamex)
2311   MDRV_EEPROM_93C46_NODEFAULT_ADD("eeprom")
23352312
23362313   /* video hardware */
23372314   MDRV_SCREEN_MODIFY("screen")
r6740r6741
25332510   ROM_REGION( 0x300000, "x1snd", 0 )   /* Samples */
25342511   /* Leave 1MB empty (addressable by the chip) */
25352512   ROM_LOAD( "ka001015.u28", 0x100000, 0x200000, CRC(ada2843b) SHA1(09d06026031bc7558da511c3c0e29187ea0a0099) )
2513
2514   ROM_REGION16_BE( 0x80, "eeprom", 0 )
2515   ROM_LOAD( "eeprom.bin", 0x0000, 0x0080, CRC(80f8e248) SHA1(1a9787811e56d95f7acbedfb00225b6e7df265eb) )
25362516ROM_END
25372517
25382518ROM_START( grdians )
src/mame/drivers/flkatck.c
r6740r6741
11/***************************************************************************
22
3Flak Attack/MX5000 (Konami GX669)
3    Flak Attack / MX5000 (Konami GX669)
44
5Driver by:
6    Manuel Abadia <manu@teleline.es>
5    Driver by:
6        Manuel Abadia <manu@teleline.es>
77
8TO DO:
9    -What does 0x900X do? (Z80)
8    TO DO:
9        -What does 0x900X do? (Z80)
1010
1111***************************************************************************/
1212
r6740r6741
1515#include "cpu/hd6309/hd6309.h"
1616#include "sound/2151intf.h"
1717#include "sound/k007232.h"
18#include "konamipt.h"
18#include "video/konicdev.h"
19#include "includes/konamipt.h"
20#include "includes/flkatck.h"
1921
20/* from video/flkatck.c */
21VIDEO_START( flkatck );
22VIDEO_UPDATE( flkatck );
23WRITE8_HANDLER( flkatck_k007121_w );
24WRITE8_HANDLER( flkatck_k007121_regs_w );
2522
26extern UINT8 *k007121_ram;
27extern int flkatck_irq_enabled;
28
29static int multiply_reg[2];
30
31/***************************************************************************/
32
33static MACHINE_RESET( flkatck )
23static INTERRUPT_GEN( flkatck_interrupt )
3424{
35   k007232_set_bank( devtag_get_device(machine, "konami"), 0, 1 );
36}
25   flkatck_state *state = (flkatck_state *)device->machine->driver_data;
3726
38static INTERRUPT_GEN( flkatck_interrupt )
39{
40   if (flkatck_irq_enabled)
27   if (state->irq_enabled)
4128      cpu_set_input_line(device, HD6309_IRQ_LINE, HOLD_LINE);
4229}
4330
4431static WRITE8_HANDLER( flkatck_bankswitch_w )
4532{
46   UINT8 *RAM = memory_region(space->machine, "maincpu");
47   int bankaddress = 0;
48
4933   /* bits 3-4: coin counters */
50   coin_counter_w(space->machine, 0,data & 0x08);
51   coin_counter_w(space->machine, 1,data & 0x10);
34   coin_counter_w(space->machine, 0, data & 0x08);
35   coin_counter_w(space->machine, 1, data & 0x10);
5236
5337   /* bits 0-1: bank # */
54   bankaddress += 0x10000 + (data & 0x03)*0x2000;
5538   if ((data & 0x03) != 0x03)   /* for safety */
56      memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]);
39      memory_set_bank(space->machine, "bank1", data & 0x03);
5740}
5841
5942static READ8_HANDLER( flkatck_ls138_r )
6043{
6144   int data = 0;
6245
63   switch ((offset & 0x1c) >> 2){
46   switch ((offset & 0x1c) >> 2)
47   {
6448      case 0x00:
6549         if (offset & 0x02)
6650            data = input_port_read(space->machine, (offset & 0x01) ? "COIN" : "DSW3");
r6740r6741
7862
7963static WRITE8_HANDLER( flkatck_ls138_w )
8064{
81   switch ((offset & 0x1c) >> 2){
65   flkatck_state *state = (flkatck_state *)space->machine->driver_data;
66
67   switch ((offset & 0x1c) >> 2)
68   {
8269      case 0x04:   /* bankswitch */
8370         flkatck_bankswitch_w(space, 0, data);
8471         break;
r6740r6741
8673         soundlatch_w(space, 0, data);
8774         break;
8875      case 0x06:   /* Cause interrupt on audio CPU */
89         cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE);
76         cpu_set_input_line(state->audiocpu, 0, HOLD_LINE);
9077         break;
9178      case 0x07:   /* watchdog reset */
9279         watchdog_reset_w(space, 0, data);
r6740r6741
9784/* Protection - an external multiplyer connected to the sound CPU */
9885static READ8_HANDLER( multiply_r )
9986{
100   return (multiply_reg[0] * multiply_reg[1]) & 0xFF;
87   flkatck_state *state = (flkatck_state *)space->machine->driver_data;
88   return (state->multiply_reg[0] * state->multiply_reg[1]) & 0xff;
10189}
10290
10391static WRITE8_HANDLER( multiply_w )
10492{
105   multiply_reg[offset] = data;
93   flkatck_state *state = (flkatck_state *)space->machine->driver_data;
94   state->multiply_reg[offset] = data;
10695}
10796
10897
r6740r6741
112101   AM_RANGE(0x0400, 0x041f) AM_READWRITE(flkatck_ls138_r, flkatck_ls138_w)                     /* inputs, DIPS, bankswitch, counters, sound command */
113102   AM_RANGE(0x0800, 0x0bff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_le_w) AM_BASE_GENERIC(paletteram)   /* palette */
114103   AM_RANGE(0x1000, 0x1fff) AM_RAM                                                   /* RAM */
115   AM_RANGE(0x2000, 0x3fff) AM_RAM_WRITE(flkatck_k007121_w) AM_BASE(&k007121_ram)               /* Video RAM (007121) */
104   AM_RANGE(0x2000, 0x3fff) AM_RAM_WRITE(flkatck_k007121_w) AM_BASE_MEMBER(flkatck_state, k007121_ram)               /* Video RAM (007121) */
116105   AM_RANGE(0x4000, 0x5fff) AM_ROMBANK("bank1")                                             /* banked ROM */
117106   AM_RANGE(0x6000, 0xffff) AM_ROM                                                   /* ROM */
118107ADDRESS_MAP_END
r6740r6741
196185
197186static void volume_callback0(const device_config *device, int v)
198187{
199   k007232_set_volume(device,0,(v >> 4) * 0x11,0);
200   k007232_set_volume(device,1,0,(v & 0x0f) * 0x11);
188   k007232_set_volume(device, 0, (v >> 4) * 0x11, 0);
189   k007232_set_volume(device, 1, 0, (v & 0x0f) * 0x11);
201190}
202191
203192static const k007232_interface k007232_config =
r6740r6741
206195};
207196
208197
198static MACHINE_START( flkatck )
199{
200   flkatck_state *state = (flkatck_state *)machine->driver_data;
201   UINT8 *ROM = memory_region(machine, "maincpu");
202
203   memory_configure_bank(machine, "bank1", 0, 3, &ROM[0x10000], 0x2000);
204
205   state->audiocpu = devtag_get_device(machine, "audiocpu");
206   state->k007121 = devtag_get_device(machine, "k007121");
207
208   state_save_register_global(machine, state->irq_enabled);
209   state_save_register_global_array(machine, state->multiply_reg);
210   state_save_register_global(machine, state->flipscreen);
211}
212
213static MACHINE_RESET( flkatck )
214{
215   flkatck_state *state = (flkatck_state *)machine->driver_data;
216
217   k007232_set_bank(devtag_get_device(machine, "konami"), 0, 1);
218
219   state->irq_enabled = 0;
220   state->multiply_reg[0] = 0;
221   state->multiply_reg[1] = 0;
222   state->flipscreen = 0;
223}
224
209225static MACHINE_DRIVER_START( flkatck )
210226
227   /* driver data */
228   MDRV_DRIVER_DATA(flkatck_state)
229
211230   /* basic machine hardware */
212231   MDRV_CPU_ADD("maincpu", HD6309,3000000*4) /* HD63C09EP, 24/8 MHz */
213232   MDRV_CPU_PROGRAM_MAP(flkatck_map)
r6740r6741
218237
219238   MDRV_QUANTUM_TIME(HZ(600))
220239
240   MDRV_MACHINE_START(flkatck)
221241   MDRV_MACHINE_RESET(flkatck)
222242
223243   /* video hardware */
r6740r6741
234254   MDRV_VIDEO_START(flkatck)
235255   MDRV_VIDEO_UPDATE(flkatck)
236256
257   MDRV_K007121_ADD("k007121")
258
237259   /* sound hardware */
238260   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
239261
r6740r6741
283305
284306
285307
286GAME( 1987, mx5000,  0,     flkatck, flkatck, 0, ROT90, "Konami", "MX5000", 0 )
287GAME( 1987, flkatck, mx5000, flkatck, flkatck, 0, ROT90, "Konami", "Flak Attack (Japan)", 0 )
308GAME( 1987, mx5000,  0,     flkatck, flkatck, 0, ROT90, "Konami", "MX5000", GAME_SUPPORTS_SAVE )
309GAME( 1987, flkatck, mx5000, flkatck, flkatck, 0, ROT90, "Konami", "Flak Attack (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/contra.c
r6740r6741
1919#include "driver.h"
2020#include "cpu/m6809/m6809.h"
2121#include "sound/2151intf.h"
22#include "konamipt.h"
22#include "video/konicdev.h"
23#include "includes/konamipt.h"
24#include "includes/contra.h"
2325
24extern UINT8 *contra_fg_vram,*contra_fg_cram;
25extern UINT8 *contra_bg_vram,*contra_bg_cram;
26extern UINT8 *contra_text_vram,*contra_text_cram;
2726
28PALETTE_INIT( contra );
29
30WRITE8_HANDLER( contra_fg_vram_w );
31WRITE8_HANDLER( contra_fg_cram_w );
32WRITE8_HANDLER( contra_bg_vram_w );
33WRITE8_HANDLER( contra_bg_cram_w );
34WRITE8_HANDLER( contra_text_vram_w );
35WRITE8_HANDLER( contra_text_cram_w );
36
37WRITE8_HANDLER( contra_K007121_ctrl_0_w );
38WRITE8_HANDLER( contra_K007121_ctrl_1_w );
39VIDEO_UPDATE( contra );
40VIDEO_START( contra );
41
42
4327static WRITE8_HANDLER( contra_bankswitch_w )
4428{
45   UINT32 bankaddress;
46   UINT8 *RAM = memory_region(space->machine, "maincpu");
47
48
49   bankaddress = 0x10000 + (data & 0x0f) * 0x2000;
50   if (bankaddress < 0x28000)   /* for safety */
51      memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]);
29   if ((data & 0x0f) < 12)   /* for safety */
30      memory_set_bank(space->machine, "bank1", data & 0x0f);
5231}
5332
5433static WRITE8_HANDLER( contra_sh_irqtrigger_w )
5534{
56   cputag_set_input_line(space->machine, "audiocpu", M6809_IRQ_LINE, HOLD_LINE);
35   contra_state *state = (contra_state *)space->machine->driver_data;
36   cpu_set_input_line(state->audiocpu, M6809_IRQ_LINE, HOLD_LINE);
5737}
5838
5939static WRITE8_HANDLER( contra_coin_counter_w )
6040{
61   if (data & 0x01) coin_counter_w(space->machine, 0,data & 0x01);
62   if (data & 0x02) coin_counter_w(space->machine, 1,(data & 0x02) >> 1);
41   if (data & 0x01)
42      coin_counter_w(space->machine, 0, data & 0x01);
43
44   if (data & 0x02)
45      coin_counter_w(space->machine, 1, (data & 0x02) >> 1);
6346}
6447
6548static WRITE8_HANDLER( cpu_sound_command_w )
6649{
67   soundlatch_w(space,offset,data);
50   soundlatch_w(space, offset, data);
6851}
6952
7053
r6740r6741
8568   AM_RANGE(0x001e, 0x001e) AM_WRITENOP   /* ? */
8669   AM_RANGE(0x0060, 0x0067) AM_WRITE(contra_K007121_ctrl_1_w)
8770
88   AM_RANGE(0x0c00, 0x0cff) AM_RAM AM_BASE_GENERIC(paletteram)
71   AM_RANGE(0x0c00, 0x0cff) AM_RAM AM_BASE_MEMBER(contra_state, paletteram)
8972
9073   AM_RANGE(0x1000, 0x1fff) AM_RAM
9174
9275   AM_RANGE(0x2000, 0x5fff) AM_READONLY
93   AM_RANGE(0x2000, 0x23ff) AM_WRITE(contra_fg_cram_w) AM_BASE(&contra_fg_cram)
94   AM_RANGE(0x2400, 0x27ff) AM_WRITE(contra_fg_vram_w) AM_BASE(&contra_fg_vram)
95   AM_RANGE(0x2800, 0x2bff) AM_WRITE(contra_text_cram_w) AM_BASE(&contra_text_cram)
96   AM_RANGE(0x2c00, 0x2fff) AM_WRITE(contra_text_vram_w) AM_BASE(&contra_text_vram)
76   AM_RANGE(0x2000, 0x23ff) AM_WRITE(contra_fg_cram_w) AM_BASE_MEMBER(contra_state, fg_cram)
77   AM_RANGE(0x2400, 0x27ff) AM_WRITE(contra_fg_vram_w) AM_BASE_MEMBER(contra_state, fg_vram)
78   AM_RANGE(0x2800, 0x2bff) AM_WRITE(contra_text_cram_w) AM_BASE_MEMBER(contra_state, tx_cram)
79   AM_RANGE(0x2c00, 0x2fff) AM_WRITE(contra_text_vram_w) AM_BASE_MEMBER(contra_state, tx_vram)
9780   AM_RANGE(0x3000, 0x37ff) AM_WRITEONLY AM_BASE_GENERIC(spriteram)/* 2nd bank is at 0x5000 */
9881   AM_RANGE(0x3800, 0x3fff) AM_WRITEONLY // second sprite buffer
99   AM_RANGE(0x4000, 0x43ff) AM_WRITE(contra_bg_cram_w) AM_BASE(&contra_bg_cram)
100   AM_RANGE(0x4400, 0x47ff) AM_WRITE(contra_bg_vram_w) AM_BASE(&contra_bg_vram)
82   AM_RANGE(0x4000, 0x43ff) AM_WRITE(contra_bg_cram_w) AM_BASE_MEMBER(contra_state, bg_cram)
83   AM_RANGE(0x4400, 0x47ff) AM_WRITE(contra_bg_vram_w) AM_BASE_MEMBER(contra_state, bg_vram)
10184   AM_RANGE(0x4800, 0x5fff) AM_WRITEONLY
10285
10386   AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank1")
r6740r6741
186169
187170
188171
172static MACHINE_START( contra )
173{
174   contra_state *state = (contra_state *)machine->driver_data;
175   UINT8 *ROM = memory_region(machine, "maincpu");
176
177   memory_configure_bank(machine, "bank1", 0, 12, &ROM[0x10000], 0x2000);
178
179   state->audiocpu = devtag_get_device(machine, "audiocpu");
180   state->k007121_1 = devtag_get_device(machine, "k007121_1");
181   state->k007121_2 = devtag_get_device(machine, "k007121_2");
182}
183
189184static MACHINE_DRIVER_START( contra )
190185
186   /* driver data */
187   MDRV_DRIVER_DATA(contra_state)
188
191189   /* basic machine hardware */
192190    MDRV_CPU_ADD("maincpu", M6809, XTAL_24MHz/16) /* 1500000? */
193191   MDRV_CPU_PROGRAM_MAP(contra_map)
r6740r6741
198196
199197   MDRV_QUANTUM_TIME(HZ(600))   /* 10 CPU slices per frame - enough for the sound CPU to read all commands */
200198
199   MDRV_MACHINE_START(contra)
200
201201   /* video hardware */
202202   MDRV_SCREEN_ADD("screen", RASTER)
203203   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
213213   MDRV_VIDEO_START(contra)
214214   MDRV_VIDEO_UPDATE(contra)
215215
216   MDRV_K007121_ADD("k007121_1")
217   MDRV_K007121_ADD("k007121_2")
218
216219   /* sound hardware */
217220   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
218221
r6740r6741
246249   ROM_LOAD( "633f11.20g",   0x0300, 0x0100, CRC(14ca5e19) SHA1(eeee2f8b3d1e4acf47de1e74c4e507ff924591e7) )   /* 007121 #1 char lookup table */
247250
248251   ROM_REGION( 0x0001, "pals", 0 )
249    ROM_LOAD( "007766.20d.bin", 0x0000, 0x0001, NO_DUMP ) /* PAL16L8A-2CN */
252   ROM_LOAD( "007766.20d.bin", 0x0000, 0x0001, NO_DUMP ) /* PAL16L8A-2CN */
250253ROM_END
251254
252255ROM_START( contra1 )
r6740r6741
273276   ROM_LOAD( "633f11.20g",   0x0300, 0x0100, CRC(14ca5e19) SHA1(eeee2f8b3d1e4acf47de1e74c4e507ff924591e7) )   /* 007121 #1 char lookup table */
274277
275278   ROM_REGION( 0x0001, "pals", 0 )
276    ROM_LOAD( "007766.20d.bin", 0x0000, 0x0001, NO_DUMP ) /* PAL16L8A-2CN */
279   ROM_LOAD( "007766.20d.bin", 0x0000, 0x0001, NO_DUMP ) /* PAL16L8A-2CN */
277280ROM_END
278281
279282ROM_START( contrab )
r6740r6741
339342   ROM_LOAD( "633f11.20g",   0x0300, 0x0100, CRC(14ca5e19) SHA1(eeee2f8b3d1e4acf47de1e74c4e507ff924591e7) )   /* 007121 #1 char lookup table */
340343
341344   ROM_REGION( 0x0001, "pals", 0 )
342    ROM_LOAD( "007766.20d.bin", 0x0000, 0x0001, NO_DUMP ) /* PAL16L8A-2CN */
345   ROM_LOAD( "007766.20d.bin", 0x0000, 0x0001, NO_DUMP ) /* PAL16L8A-2CN */
343346ROM_END
344347
345348ROM_START( contrajb )
r6740r6741
405408   ROM_LOAD( "633f11.20g",   0x0300, 0x0100, CRC(14ca5e19) SHA1(eeee2f8b3d1e4acf47de1e74c4e507ff924591e7) )   /* 007121 #1 char lookup table */
406409
407410   ROM_REGION( 0x0001, "pals", 0 )
408    ROM_LOAD( "007766.20d.bin", 0x0000, 0x0001, NO_DUMP ) /* PAL16L8A-2CN */
411   ROM_LOAD( "007766.20d.bin", 0x0000, 0x0001, NO_DUMP ) /* PAL16L8A-2CN */
409412ROM_END
410413
411414ROM_START( gryzora )
r6740r6741
432435   ROM_LOAD( "633f11.20g",   0x0300, 0x0100, CRC(14ca5e19) SHA1(eeee2f8b3d1e4acf47de1e74c4e507ff924591e7) )   /* 007121 #1 char lookup table */
433436
434437   ROM_REGION( 0x0001, "pals", 0 )
435    ROM_LOAD( "007766.20d.bin", 0x0000, 0x0001, NO_DUMP ) /* PAL16L8A-2CN */
438   ROM_LOAD( "007766.20d.bin", 0x0000, 0x0001, NO_DUMP ) /* PAL16L8A-2CN */
436439ROM_END
437440
438441
439442
440GAME( 1987, contra,   0,      contra, contra, 0, ROT90, "Konami", "Contra (US, Set 1)", 0 )
441GAME( 1987, contra1,  contra, contra, contra, 0, ROT90, "Konami", "Contra (US, Set 2)", 0 )
442GAME( 1987, contrab,  contra, contra, contra, 0, ROT90, "bootleg", "Contra (bootleg)", 0 )
443GAME( 1987, contraj,  contra, contra, contra, 0, ROT90, "Konami", "Contra (Japan)", 0 )
444GAME( 1987, contrajb, contra, contra, contra, 0, ROT90, "bootleg", "Contra (Japan bootleg)", 0 )
445GAME( 1987, gryzor,   contra, contra, contra, 0, ROT90, "Konami", "Gryzor (Set 1)", 0 )
446GAME( 1987, gryzora,  contra, contra, contra, 0, ROT90, "Konami", "Gryzor (Set 2)", 0 )
443GAME( 1987, contra,   0,      contra, contra, 0, ROT90, "Konami", "Contra (US, Set 1)", GAME_SUPPORTS_SAVE )
444GAME( 1987, contra1,  contra, contra, contra, 0, ROT90, "Konami", "Contra (US, Set 2)", GAME_SUPPORTS_SAVE )
445GAME( 1987, contrab,  contra, contra, contra, 0, ROT90, "bootleg", "Contra (bootleg)", GAME_SUPPORTS_SAVE )
446GAME( 1987, contraj,  contra, contra, contra, 0, ROT90, "Konami", "Contra (Japan)", GAME_SUPPORTS_SAVE )
447GAME( 1987, contrajb, contra, contra, contra, 0, ROT90, "bootleg", "Contra (Japan bootleg)", GAME_SUPPORTS_SAVE )
448GAME( 1987, gryzor,   contra, contra, contra, 0, ROT90, "Konami", "Gryzor (Set 1)", GAME_SUPPORTS_SAVE )
449GAME( 1987, gryzora,  contra, contra, contra, 0, ROT90, "Konami", "Gryzor (Set 2)", GAME_SUPPORTS_SAVE )
src/mame/drivers/paradise.c
r6740r6741
3232#include "driver.h"
3333#include "cpu/z80/z80.h"
3434#include "deprecat.h"
35#include "paradise.h"
35#include "includes/paradise.h"
3636#include "sound/okim6295.h"
3737
3838/***************************************************************************
src/mame/drivers/balsente.c
r6740r6741
228228#include "cpu/z80/z80.h"
229229#include "cpu/m6809/m6809.h"
230230#include "cpu/m68000/m68000.h"
231#include "balsente.h"
231#include "includes/balsente.h"
232232#include "sound/cem3394.h"
233233
234234#include "stocker.lh"
r6740r6741
300300/* CPU 1 read addresses */
301301static ADDRESS_MAP_START( shrike68k_map, ADDRESS_SPACE_PROGRAM, 16 )
302302   AM_RANGE(0x000000, 0x003fff) AM_ROM
303   AM_RANGE(0x010000, 0x01001f) AM_RAM AM_BASE(&shrike_io)
304   AM_RANGE(0x018000, 0x018fff) AM_RAM AM_BASE(&shrike_shared)
303   AM_RANGE(0x010000, 0x01001f) AM_RAM AM_BASE_MEMBER(balsente_state, shrike_io)
304   AM_RANGE(0x018000, 0x018fff) AM_RAM AM_BASE_MEMBER(balsente_state, shrike_shared)
305305ADDRESS_MAP_END
306306
307307
r6740r6741
11911191 *************************************/
11921192
11931193static MACHINE_DRIVER_START( balsente )
1194   MDRV_DRIVER_DATA(balsente_state)
11941195
11951196   /* basic machine hardware */
11961197   MDRV_CPU_ADD("maincpu", M6809, 5000000/4)
r6740r6741
12031204
12041205   MDRV_QUANTUM_TIME(HZ(600))
12051206
1207   MDRV_MACHINE_START(balsente)
12061208   MDRV_MACHINE_RESET(balsente)
12071209   MDRV_NVRAM_HANDLER(generic_0fill)
12081210
1211   MDRV_TIMER_ADD("scan_timer", balsente_interrupt_timer)
1212   MDRV_TIMER_ADD("8253_0_timer", balsente_clock_counter_0_ff)
1213   MDRV_TIMER_ADD("8253_1_timer", balsente_counter_callback)
1214   MDRV_TIMER_ADD("8253_2_timer", balsente_counter_callback)
1215
12091216   /* video hardware */
12101217   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
12111218
r6740r6741
20472054   }
20482055}
20492056
2050static DRIVER_INIT( sentetst ) { expand_roms(machine, EXPAND_ALL);  balsente_shooter = 0; /* noanalog */ }
2051static DRIVER_INIT( cshift )   { expand_roms(machine, EXPAND_ALL);  balsente_shooter = 0; /* noanalog */ }
2052static DRIVER_INIT( gghost )   { expand_roms(machine, EXPAND_ALL);  balsente_shooter = 0; balsente_adc_shift = 1; }
2053static DRIVER_INIT( hattrick ) { expand_roms(machine, EXPAND_ALL);  balsente_shooter = 0; /* noanalog */ }
2054static DRIVER_INIT( otwalls )  { expand_roms(machine, EXPAND_ALL);  balsente_shooter = 0; balsente_adc_shift = 0; }
2055static DRIVER_INIT( snakepit ) { expand_roms(machine, EXPAND_ALL);  balsente_shooter = 0; balsente_adc_shift = 1; }
2056static DRIVER_INIT( snakjack ) { expand_roms(machine, EXPAND_ALL);  balsente_shooter = 0; balsente_adc_shift = 1; }
2057static DRIVER_INIT( stocker )  { expand_roms(machine, EXPAND_ALL);  balsente_shooter = 0; balsente_adc_shift = 0; }
2058static DRIVER_INIT( triviag1 ) { expand_roms(machine, EXPAND_ALL);  balsente_shooter = 0; /* noanalog */ }
2057INLINE void config_shooter_adc(running_machine *machine, UINT8 shooter, UINT8 adc_shift)
2058{
2059   balsente_state *state = (balsente_state *)machine->driver_data;
2060   state->shooter = shooter;
2061   state->adc_shift = adc_shift;
2062}
2063
2064static DRIVER_INIT( sentetst ) { expand_roms(machine, EXPAND_ALL);  config_shooter_adc(machine, FALSE, 0 /* noanalog */); }
2065static DRIVER_INIT( cshift )   { expand_roms(machine, EXPAND_ALL);  config_shooter_adc(machine, FALSE, 0 /* noanalog */); }
2066static DRIVER_INIT( gghost )   { expand_roms(machine, EXPAND_ALL);  config_shooter_adc(machine, FALSE, 1); }
2067static DRIVER_INIT( hattrick ) { expand_roms(machine, EXPAND_ALL);  config_shooter_adc(machine, FALSE, 0 /* noanalog */); }
2068static DRIVER_INIT( otwalls )  { expand_roms(machine, EXPAND_ALL);  config_shooter_adc(machine, FALSE, 0); }
2069static DRIVER_INIT( snakepit ) { expand_roms(machine, EXPAND_ALL);  config_shooter_adc(machine, FALSE, 1); }
2070static DRIVER_INIT( snakjack ) { expand_roms(machine, EXPAND_ALL);  config_shooter_adc(machine, FALSE, 1); }
2071static DRIVER_INIT( stocker )  { expand_roms(machine, EXPAND_ALL);  config_shooter_adc(machine, FALSE, 0); }
2072static DRIVER_INIT( triviag1 ) { expand_roms(machine, EXPAND_ALL);  config_shooter_adc(machine, FALSE, 0 /* noanalog */); }
20592073static DRIVER_INIT( triviag2 )
20602074{
20612075   UINT8 *rom = memory_region(machine, "maincpu");
20622076   memcpy(&rom[0x20000], &rom[0x28000], 0x4000);
20632077   memcpy(&rom[0x24000], &rom[0x28000], 0x4000);
2064   expand_roms(machine, EXPAND_NONE); balsente_shooter = 0; /* noanalog */
2078   expand_roms(machine, EXPAND_NONE); config_shooter_adc(machine, FALSE, 0 /* noanalog */);
20652079}
2066static DRIVER_INIT( triviaes )
2067{
2068   expand_roms(machine, EXPAND_NONE | SWAP_HALVES); balsente_shooter = 0; /* noanalog */
2069}
2070static DRIVER_INIT( gimeabrk ) { expand_roms(machine, EXPAND_ALL);  balsente_shooter = 0; balsente_adc_shift = 1; }
2071static DRIVER_INIT( minigolf ) { expand_roms(machine, EXPAND_NONE); balsente_shooter = 0; balsente_adc_shift = 2; }
2072static DRIVER_INIT( minigol2 ) { expand_roms(machine, 0x0c);        balsente_shooter = 0; balsente_adc_shift = 2; }
2073static DRIVER_INIT( toggle )   { expand_roms(machine, EXPAND_ALL);  balsente_shooter = 0; /* noanalog */ }
2080static DRIVER_INIT( triviaes ) { expand_roms(machine, EXPAND_NONE | SWAP_HALVES); config_shooter_adc(machine, FALSE, 0 /* noanalog */); }
2081static DRIVER_INIT( gimeabrk ) { expand_roms(machine, EXPAND_ALL);  config_shooter_adc(machine, FALSE, 1); }
2082static DRIVER_INIT( minigolf ) { expand_roms(machine, EXPAND_NONE); config_shooter_adc(machine, FALSE, 2); }
2083static DRIVER_INIT( minigol2 ) { expand_roms(machine, 0x0c);        config_shooter_adc(machine, FALSE, 2); }
2084static DRIVER_INIT( toggle )   { expand_roms(machine, EXPAND_ALL);  config_shooter_adc(machine, FALSE, 0 /* noanalog */); }
20742085static DRIVER_INIT( nametune )
20752086{
20762087   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
20772088   memory_install_write8_handler(space, 0x9f00, 0x9f00, 0, 0, balsente_rombank2_select_w);
2078   expand_roms(machine, EXPAND_NONE | SWAP_HALVES); balsente_shooter = 0; /* noanalog */
2089   expand_roms(machine, EXPAND_NONE | SWAP_HALVES); config_shooter_adc(machine, FALSE, 0 /* noanalog */);
20792090}
20802091static DRIVER_INIT( nstocker )
20812092{
20822093   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
20832094   memory_install_write8_handler(space, 0x9f00, 0x9f00, 0, 0, balsente_rombank2_select_w);
2084   expand_roms(machine, EXPAND_NONE | SWAP_HALVES); balsente_shooter = 1; balsente_adc_shift = 1;
2095   expand_roms(machine, EXPAND_NONE | SWAP_HALVES); config_shooter_adc(machine, TRUE, 1);
20852096}
20862097static DRIVER_INIT( sfootbal )
20872098{
20882099   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
20892100   memory_install_write8_handler(space, 0x9f00, 0x9f00, 0, 0, balsente_rombank2_select_w);
2090   expand_roms(machine, EXPAND_ALL  | SWAP_HALVES); balsente_shooter = 0; balsente_adc_shift = 0;
2101   expand_roms(machine, EXPAND_ALL  | SWAP_HALVES); config_shooter_adc(machine, FALSE, 0);
20912102}
20922103static DRIVER_INIT( spiker )
20932104{
20942105   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
20952106   memory_install_readwrite8_handler(space, 0x9f80, 0x9f8f, 0, 0, spiker_expand_r, spiker_expand_w);
20962107   memory_install_write8_handler(space, 0x9f00, 0x9f00, 0, 0, balsente_rombank2_select_w);
2097   expand_roms(machine, EXPAND_ALL  | SWAP_HALVES); balsente_shooter = 0; balsente_adc_shift = 1;
2108   expand_roms(machine, EXPAND_ALL  | SWAP_HALVES); config_shooter_adc(machine, FALSE, 1);
20982109}
20992110static DRIVER_INIT( stompin )
21002111{
21012112   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
21022113   memory_install_write8_handler(space, 0x9f00, 0x9f00, 0, 0, balsente_rombank2_select_w);
2103   expand_roms(machine, 0x0c | SWAP_HALVES); balsente_shooter = 0; balsente_adc_shift = 32;
2114   expand_roms(machine, 0x0c | SWAP_HALVES); config_shooter_adc(machine, FALSE, 32);
21042115}
2105static DRIVER_INIT( rescraid ) { expand_roms(machine, EXPAND_NONE); balsente_shooter = 0; /* noanalog */ }
2116static DRIVER_INIT( rescraid ) { expand_roms(machine, EXPAND_NONE); config_shooter_adc(machine, FALSE, 0 /* noanalog */); }
21062117static DRIVER_INIT( grudge )
21072118{
21082119   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
21092120   memory_install_read8_handler(space, 0x9400, 0x9400, 0, 0, grudge_steering_r);
2110   expand_roms(machine, EXPAND_NONE); balsente_shooter = 0;
2121   expand_roms(machine, EXPAND_NONE); config_shooter_adc(machine, FALSE, 0);
21112122}
21122123static DRIVER_INIT( shrike )
21132124{
r6740r6741
21162127   memory_install_write8_handler(space, 0x9e01, 0x9e01, 0, 0, shrike_sprite_select_w );
21172128   memory_install_readwrite16_handler(cputag_get_address_space(machine, "68k", ADDRESS_SPACE_PROGRAM), 0x10000, 0x1001f, 0, 0, shrike_io_68k_r, shrike_io_68k_w);
21182129
2119   expand_roms(machine, EXPAND_ALL);  balsente_shooter = 0; balsente_adc_shift = 32;
2130   expand_roms(machine, EXPAND_ALL);  config_shooter_adc(machine, FALSE, 32);
21202131}
21212132
21222133
src/mame/drivers/galpani3.c
r6740r6741
6868#include "deprecat.h"
6969#include "sound/ymz280b.h"
7070#include "includes/suprnova.h"
71#include "kaneko16.h"
71#include "includes/kaneko16.h"
7272
7373/***************************************************************************
7474
src/mame/drivers/vertigo.c
r6740r6741
1313#include "cpu/m6805/m6805.h"
1414#include "cpu/m68000/m68000.h"
1515#include "video/vector.h"
16#include "vertigo.h"
17#include "exidy440.h"
16#include "includes/vertigo.h"
17#include "includes/exidy440.h"
18#include "machine/74148.h"
1819#include "machine/pit8253.h"
1920
2021
r6740r6741
114115
115116   MDRV_PIT8254_ADD( "pit8254", vertigo_pit8254_config )
116117
118   MDRV_74148_ADD( "74148", vertigo_update_irq )
119
117120   /* motor controller */
118121   /*
119122    MDRV_CPU_ADD("motor", M6805, 1000000)
120123    MDRV_CPU_PROGRAM_MAP(vertigo_motor)
121124    */
125   MDRV_MACHINE_START(vertigo)
122126   MDRV_MACHINE_RESET(vertigo)
123127   MDRV_NVRAM_HANDLER(generic_0fill)
124128
src/mame/drivers/deco32.c
r6740r6741
229229#include "cpu/arm/arm.h"
230230#include "cpu/h6280/h6280.h"
231231#include "cpu/m6809/m6809.h"
232#include "decocrpt.h"
233#include "decoprot.h"
232#include "includes/decocrpt.h"
233#include "includes/decoprot.h"
234234#include "machine/eeprom.h"
235#include "deco32.h"
235#include "includes/deco32.h"
236236#include "sound/2151intf.h"
237237#include "sound/okim6295.h"
238238#include "sound/bsmt2000.h"
239239
240240static UINT32 *deco32_ram;
241241static int raster_enable;
242static emu_timer *raster_irq_timer;
242static const device_config *raster_irq_timer;
243243static UINT8 nslasher_sound_irq;
244244
245245/**********************************************************************************/
246246
247static TIMER_CALLBACK( interrupt_gen )
247static TIMER_DEVICE_CALLBACK( interrupt_gen )
248248{
249249   /* Save state of scroll registers before the IRQ */
250   deco32_raster_display_list[deco32_raster_display_position++]=video_screen_get_vpos(machine->primary_screen);
250   deco32_raster_display_list[deco32_raster_display_position++]=video_screen_get_vpos(timer->machine->primary_screen);
251251   deco32_raster_display_list[deco32_raster_display_position++]=deco32_pf12_control[1]&0xffff;
252252   deco32_raster_display_list[deco32_raster_display_position++]=deco32_pf12_control[2]&0xffff;
253253   deco32_raster_display_list[deco32_raster_display_position++]=deco32_pf12_control[3]&0xffff;
254254   deco32_raster_display_list[deco32_raster_display_position++]=deco32_pf12_control[4]&0xffff;
255255
256   cputag_set_input_line(machine, "maincpu", ARM_IRQ_LINE, HOLD_LINE);
256   cputag_set_input_line(timer->machine, "maincpu", ARM_IRQ_LINE, HOLD_LINE);
257257}
258258
259259static READ32_HANDLER( deco32_irq_controller_r )
r6740r6741
305305   case 1: /* Raster IRQ scanline position, only valid for values between 1 & 239 (0 and 240-256 do NOT generate IRQ's) */
306306      scanline=(data&0xff);
307307      if (raster_enable && scanline>0 && scanline<240)
308         timer_adjust_oneshot(raster_irq_timer,video_screen_get_time_until_pos(space->machine->primary_screen, scanline-1, 320),0);
308         timer_device_adjust_oneshot(raster_irq_timer,video_screen_get_time_until_pos(space->machine->primary_screen, scanline-1, 320),0);
309309      else
310         timer_adjust_oneshot(raster_irq_timer,attotime_never,0);
310         timer_device_adjust_oneshot(raster_irq_timer,attotime_never,0);
311311      break;
312312   case 2: /* VBL irq ack */
313313      break;
r6740r6741
16571657
16581658static MACHINE_RESET( deco32 )
16591659{
1660   raster_irq_timer = timer_alloc(machine, interrupt_gen, NULL);
1660   raster_irq_timer = devtag_get_device(machine, "int_timer");
16611661}
16621662
16631663static INTERRUPT_GEN( deco32_vbl_interrupt )
r6740r6741
16821682
16831683   MDRV_MACHINE_RESET(deco32)
16841684
1685   MDRV_TIMER_ADD("int_timer", interrupt_gen)
1686
16851687   /* video hardware */
16861688   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
16871689
r6740r6741
18221824   MDRV_MACHINE_RESET(deco32)
18231825   MDRV_NVRAM_HANDLER(93C46)
18241826
1827   MDRV_TIMER_ADD("int_timer", interrupt_gen)
1828
18251829   /* video hardware */
18261830   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM )
18271831
r6740r6741
18751879   MDRV_MACHINE_RESET(deco32)
18761880   MDRV_NVRAM_HANDLER(93C46)
18771881
1882   MDRV_TIMER_ADD("int_timer", interrupt_gen)
1883
18781884   /* video hardware */
18791885   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM )
18801886
src/mame/drivers/malzak.c
r6740r6741
6363*/
6464
6565#include "driver.h"
66#include "video/s2636.h"
6766#include "cpu/s2650/s2650.h"
6867#include "sound/sn76477.h"
68#include "video/s2636.h"
69#include "video/saa5050.h"
70#include "includes/malzak.h"
6971
70#define SAA5050_VBLANK 2500
7172
72static int malzak_bank1;
73
74extern int malzak_x;
75extern int malzak_y;
76
77extern UINT8 *saa5050_vidram;  /* Video RAM for SAA 5050 */
78
79// in video/malzak.c
80VIDEO_START( malzak );
81VIDEO_UPDATE( malzak );
82WRITE8_HANDLER( malzak_playfield_w );
83
84
8573static READ8_HANDLER( fake_VRLE_r )
8674{
87   const device_config *s2636_0 = devtag_get_device(space->machine, "s2636_0");
88
89   return (s2636_work_ram_r(s2636_0, 0xcb) & 0x3f) + (video_screen_get_vblank(space->machine->primary_screen)*0x40);
75   malzak_state *state = (malzak_state *)space->machine->driver_data;
76   return (s2636_work_ram_r(state->s2636_0, 0xcb) & 0x3f) + (video_screen_get_vblank(space->machine->primary_screen) * 0x40);
9077}
9178
92static READ8_HANDLER( bank_r )
93{
94   UINT8* bank = memory_region(space->machine, "user2");
95
96   return bank[offset + (malzak_bank1 * 0x0400)];
97}
98
9979static READ8_HANDLER( s2636_portA_r )
10080{
10181   // POT switch position, read from port A of the first S2636
10282   // Not sure of the correct values to return, but these should
10383   // do based on the game code.
104   switch(input_port_read(space->machine, "POT"))
84   switch (input_port_read(space->machine, "POT"))
10585   {
10686      case 0:  // Normal play
10787         return 0xf0;
r6740r6741
11999static ADDRESS_MAP_START( malzak_map, ADDRESS_SPACE_PROGRAM, 8 )
120100   ADDRESS_MAP_GLOBAL_MASK(0x7fff)
121101   AM_RANGE(0x0000, 0x0bff) AM_ROM
122   AM_RANGE(0x0c00, 0x0fff) AM_READ(bank_r)
102   AM_RANGE(0x0c00, 0x0fff) AM_ROMBANK("bank1")
123103   AM_RANGE(0x1000, 0x10ff) AM_MIRROR(0x6000) AM_RAM
124104   AM_RANGE(0x1100, 0x11ff) AM_MIRROR(0x6000) AM_RAM
125105   AM_RANGE(0x1200, 0x12ff) AM_MIRROR(0x6000) AM_RAM
r6740r6741
129109   AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_1", s2636_work_ram_r, s2636_work_ram_w)
130110   AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_RAM_WRITE(malzak_playfield_w)
131111   AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_RAM
132   AM_RANGE(0x1800, 0x1fff) AM_MIRROR(0x6000) AM_RAM AM_BASE(&saa5050_vidram)
112   AM_RANGE(0x1800, 0x1fff) AM_MIRROR(0x6000) AM_DEVREADWRITE("saa5050", saa5050_videoram_r, saa5050_videoram_w)
133113   AM_RANGE(0x2000, 0x2fff) AM_ROM
134114   AM_RANGE(0x4000, 0x4fff) AM_ROM
135115   AM_RANGE(0x6000, 0x6fff) AM_ROM
r6740r6741
139119static ADDRESS_MAP_START( malzak2_map, ADDRESS_SPACE_PROGRAM, 8 )
140120   ADDRESS_MAP_GLOBAL_MASK(0x7fff)
141121   AM_RANGE(0x0000, 0x0bff) AM_ROM
142   AM_RANGE(0x0c00, 0x0fff) AM_READ(bank_r)
122   AM_RANGE(0x0c00, 0x0fff) AM_ROMBANK("bank1")
143123   AM_RANGE(0x1000, 0x10ff) AM_MIRROR(0x6000) AM_RAM
144124   AM_RANGE(0x1100, 0x11ff) AM_MIRROR(0x6000) AM_RAM
145125   AM_RANGE(0x1200, 0x12ff) AM_MIRROR(0x6000) AM_RAM
r6740r6741
150130   AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_DEVREADWRITE("s2636_1", s2636_work_ram_r, s2636_work_ram_w)
151131   AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_RAM_WRITE(malzak_playfield_w)
152132   AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_RAM AM_BASE_SIZE_GENERIC(nvram)
153   AM_RANGE(0x1800, 0x1fff) AM_MIRROR(0x6000) AM_RAM AM_BASE(&saa5050_vidram)
133   AM_RANGE(0x1800, 0x1fff) AM_MIRROR(0x6000) AM_DEVREADWRITE("saa5050", saa5050_videoram_r, saa5050_videoram_w)
154134   AM_RANGE(0x2000, 0x2fff) AM_ROM
155135   AM_RANGE(0x4000, 0x4fff) AM_ROM
156136   AM_RANGE(0x6000, 0x6fff) AM_ROM
r6740r6741
172152//  Bit 6 is used only in Malzak II, and is set high after checking
173153//        the selected version
174154//  logerror("S2650 [0x%04x]: port 0x40 write: 0x%02x\n", cpu_get_pc(cputag_get_cpu(space->machine, "maincpu")), data);
175   if(data & 0x40)
176      malzak_bank1 = 1;
177   else
178      malzak_bank1 = 0;
155   memory_set_bank(space->machine, "bank1", (data & 0x40) >> 6);
179156}
180157
181158static WRITE8_HANDLER( port60_w )
182159{
183   malzak_x = data;
184//  logerror("I/O: port 0x60 write 0x%02x\n",data);
160   malzak_state *state = (malzak_state *)space->machine->driver_data;
161   state->malzak_x = data;
162   //  logerror("I/O: port 0x60 write 0x%02x\n", data);
185163}
186164
187165static WRITE8_HANDLER( portc0_w )
188166{
189   malzak_y = data;
190//  logerror("I/O: port 0xc0 write 0x%02x\n",data);
167   malzak_state *state = (malzak_state *)space->machine->driver_data;
168   state->malzak_y = data;
169   //  logerror("I/O: port 0xc0 write 0x%02x\n", data);
191170}
192171
193172static READ8_HANDLER( collision_r )
194173{
174   malzak_state *state = (malzak_state *)space->machine->driver_data;
175
195176   // High 4 bits seem to refer to the row affected.
196   static int counter;
177   if(++state->collision_counter > 15)
178      state->collision_counter = 0;
197179
198   if(++counter > 15)
199      counter = 0;
200//  logerror("I/O port 0x00 read\n");
201   return 0xd0 + counter;
180   //  logerror("I/O port 0x00 read\n");
181   return 0xd0 + state->collision_counter;
202182}
203183
204184static ADDRESS_MAP_START( malzak_io_map, ADDRESS_SPACE_IO, 8 )
r6740r6741
231211   PORT_START("POT")
232212   /* No POT switch on Malzak as far as I know */
233213
234   PORT_START("SENSE")      /* SENSE */
214   PORT_START("SENSE")
235215   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )
236216
237217INPUT_PORTS_END
r6740r6741
258238   PORT_DIPSETTING( 0x02, "3" )
259239   PORT_DIPSETTING( 0x03, "4" )  // Change settings
260240
261   PORT_START("SENSE")      /* SENSE */
241   PORT_START("SENSE")
262242   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )
263243
264244INPUT_PORTS_END
r6740r6741
327307{
328308   int i;
329309
330   for (i = 0; i < 8*8; i++)
310   for (i = 0; i < 8 * 8; i++)
331311   {
332312      palette_set_color_rgb(machine, i * 2 + 0, pal1bit(i >> 3), pal1bit(i >> 4), pal1bit(i >> 5));
333313      palette_set_color_rgb(machine, i * 2 + 1, pal1bit(i >> 0), pal1bit(i >> 1), pal1bit(i >> 2));
r6740r6741
363343};
364344
365345
366static const s2636_interface s2636_0_config =
346static const s2636_interface malzac_s2636_0_config =
367347{
368348   "screen",
369   0xff,
349   0x100,
370350   0, -16   /* -8, -16 */
371351};
372352
373static const s2636_interface s2636_1_config =
353static const s2636_interface malzac_s2636_1_config =
374354{
375355   "screen",
376   0xff,
356   0x100,
377357   0, -16   /* -9, -16 */
378358};
379359
360static const saa5050_interface malzac_saa5050_intf =
361{
362   "screen",
363   1,   /* starting gfxnum */
364   42, 24, 64,  /* x, y, size */
365      1     /* rev y order */
366};
367
368
369static MACHINE_START( malzak )
370{
371   malzak_state *state = (malzak_state *)machine->driver_data;
372
373   memory_configure_bank(machine, "bank1", 0, 2, memory_region(machine, "user2"), 0x400);
374
375   state->s2636_0 = devtag_get_device(machine, "s2636_0");
376   state->s2636_1 = devtag_get_device(machine, "s2636_1");
377   state->saa5050 = devtag_get_device(machine, "saa5050");
378
379   state_save_register_global_array(machine, state->playfield_code);
380   state_save_register_global(machine, state->malzak_x);
381   state_save_register_global(machine, state->malzak_y);
382}
383
384static MACHINE_RESET( malzak )
385{
386   malzak_state *state = (malzak_state *)machine->driver_data;
387
388   memset(state->playfield_code, 0, 256);
389
390   state->malzak_x = 0;
391   state->malzak_y = 0;
392}
393
380394static MACHINE_DRIVER_START( malzak )
381395
396   /* driver data */
397   MDRV_DRIVER_DATA(malzak_state)
398
382399   /* basic machine hardware */
383400   MDRV_CPU_ADD("maincpu", S2650, 3800000/4)
384401   MDRV_CPU_PROGRAM_MAP(malzak_map)
385402   MDRV_CPU_IO_MAP(malzak_io_map)
386403
404   MDRV_MACHINE_START(malzak)
405   MDRV_MACHINE_RESET(malzak)
406
387407   /* video hardware */
388408   MDRV_SCREEN_ADD("screen", RASTER)
389409   MDRV_SCREEN_REFRESH_RATE(50)
r6740r6741
396416   MDRV_PALETTE_LENGTH(128)
397417   MDRV_PALETTE_INIT(malzak)
398418
399//  MDRV_MACHINE_RESET(malzak)
419   MDRV_S2636_ADD("s2636_0", malzac_s2636_0_config)
420   MDRV_S2636_ADD("s2636_1", malzac_s2636_1_config)
400421
401   MDRV_S2636_ADD("s2636_0", s2636_0_config)
402   MDRV_S2636_ADD("s2636_1", s2636_1_config)
403
422   MDRV_SAA5050_ADD("saa5050", malzac_saa5050_intf)
404423   MDRV_VIDEO_UPDATE(malzak)
405424
406425   /* sound hardware */
r6740r6741
470489ROM_END
471490
472491
473GAME( 19??, malzak,   0,       malzak,  malzak,  0,        ROT0, "Kitronix", "Malzak", GAME_NOT_WORKING | GAME_NO_SOUND | GAME_IMPERFECT_GRAPHICS )
474GAME( 19??, malzak2, malzak,   malzak2, malzak2, 0,        ROT0, "Kitronix", "Malzak II", GAME_NOT_WORKING | GAME_NO_SOUND | GAME_IMPERFECT_GRAPHICS )
492GAME( 19??, malzak,   0,       malzak,  malzak,  0,        ROT0, "Kitronix", "Malzak", GAME_NOT_WORKING | GAME_NO_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
493GAME( 19??, malzak2, malzak,   malzak2, malzak2, 0,        ROT0, "Kitronix", "Malzak II", GAME_NOT_WORKING | GAME_NO_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
src/mame/drivers/midzeus.c
r6740r6741
11981198   ROM_LOAD32_WORD( "mk4_l2.u17", 0x0c00002, 0x200000, CRC(3a1a082c) SHA1(5f8e8ce760d8ebadd1240ef08f1382a37cf11d0b) )
11991199ROM_END
12001200
1201ROM_START( mk4b )
1202   ROM_REGION16_LE( 0x1000000, "dcs", ROMREGION_ERASEFF )   /* sound data */
1203   ROM_LOAD16_BYTE( "mk4_l1.u2", 0x000000, 0x200000, CRC(daac8ab5) SHA1(b93aa205868212077a9b6ac8e93205e1ebf8c05e) ) /* All sound roms were labeled as v1.0 & are M27C160 type */
1204   ROM_LOAD16_BYTE( "mk4_l1.u3", 0x400000, 0x200000, CRC(cb59413e) SHA1(f7e5c589a8f6a2e7dceee4881594e7403be4d4ad) )
1205   ROM_LOAD16_BYTE( "mk4_l1.u4", 0x800000, 0x200000, CRC(dee91696) SHA1(00a182a36a414744cd014fcfc53c2e1a66ab5189) )
1206   ROM_LOAD16_BYTE( "mk4_l1.u5", 0xc00000, 0x200000, CRC(44d072be) SHA1(8a636c2801d799dfb84e69607ade76d2b49cf09f) )
1207
1208   ROM_REGION32_LE( 0x1800000, "user1", 0 )
1209   ROM_LOAD32_WORD( "mk4_l1.u10", 0x0000000, 0x200000, CRC(6fcc86dd) SHA1(b3b2b463daf51450fbcd5d2922ac1b091bd91c4a) ) /* All roms were labeled as v1.0 */
1210   ROM_LOAD32_WORD( "mk4_l1.u11", 0x0000002, 0x200000, CRC(04895940) SHA1(55d368905f5986587c4e3da236401fdd5e2c269c) )
1211   ROM_LOAD32_WORD( "mk4_l1.u12", 0x0400000, 0x200000, CRC(323ddc5c) SHA1(4303c109c68a7cc15ff6fe91b6d34383b6066351) )
1212   ROM_LOAD32_WORD( "mk4_l1.u13", 0x0400002, 0x200000, CRC(0b95bdf0) SHA1(a25d48b33a861b5e52736720c7a79291fa837f78) )
1213   ROM_LOAD32_WORD( "mk4_l1.u14", 0x0800000, 0x200000, CRC(cb6816ef) SHA1(9c828c188d297aee0f211acc283035289e80b5a8) )
1214   ROM_LOAD32_WORD( "mk4_l1.u15", 0x0800002, 0x200000, CRC(cde47df7) SHA1(63383d983c03703b2f3f1973ce2a7553654836d4) )
1215   /* No U16 or U17 roms present in this version */
1216ROM_END
1217
12011218ROM_START( invasnab ) /* Version 5.0 Program roms, v4.0 Graphics roms, v2.0 Sound roms */
12021219   ROM_REGION16_LE( 0x1000000, "dcs", ROMREGION_ERASEFF )   /* sound data */
12031220   ROM_LOAD16_BYTE( "invasion2.u2", 0x000000, 0x200000, CRC(59d2e1d6) SHA1(994a4311ac4841d4341449c0c7480952b6f3855d) ) /* These four sound roms were labeled as v2.0 */
r6740r6741
14181435
14191436GAME(  1997, mk4,      0,        midzeus,  mk4,      mk4,      ROT0, "Midway", "Mortal Kombat 4 (version 3.0)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
14201437GAME(  1997, mk4a,     mk4,      midzeus,  mk4,      mk4,      ROT0, "Midway", "Mortal Kombat 4 (version 2.1)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
1438GAME(  1997, mk4b,     mk4,      midzeus,  mk4,      mk4,      ROT0, "Midway", "Mortal Kombat 4 (version 1.0)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
14211439GAME(  1999, invasnab, 0,        midzeus,  invasn,   invasn,   ROT0, "Midway", "Invasion - The Abductors (version 5.0)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
14221440GAME(  1999, invasnv4, invasnab, midzeus,  invasn,   invasn,   ROT0, "Midway", "Invasion - The Abductors (version 4.0)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
14231441GAMEL( 1999, crusnexo, 0,        midzeus2, crusnexo, crusnexo, ROT0, "Midway", "Cruis'n Exotica (version 2.4)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE, layout_crusnexo )
src/mame/drivers/norautp.c
r6740r6741
533533#include "cpu/z80/z80.h"
534534#include "cpu/i8085/i8085.h"
535535#include "machine/i8255a.h"
536#include "norautp.h"
536#include "includes/norautp.h"
537537
538538#include "noraut11.lh"
539539#include "noraut12.lh"
src/mame/drivers/fastfred.c
r6740r6741
88#include "driver.h"
99#include "cpu/z80/z80.h"
1010#include "deprecat.h"
11#include "fastfred.h"
11#include "includes/fastfred.h"
1212#include "sound/ay8910.h"
1313
1414
src/mame/drivers/xtheball.c
r6740r6741
3434static MACHINE_RESET( xtheball )
3535{
3636   tlc34076_reset(6);
37   ticket_dispenser_init(machine, 100, 1, 1);
3837}
3938
4039
r6740r6741
134133         switch (offset)
135134         {
136135            case 7:
137               ticket_dispenser_w(space, 0, data << 7);
136               ticket_dispenser_w(devtag_get_device(space->machine, "ticket"), 0, data << 7);
138137               break;
139138
140139            case 8:
r6740r6741
191190 *
192191 *************************************/
193192
194static READ16_HANDLER( port0_r )
195{
196   int result = input_port_read(space->machine, "DSW");
197   result ^= ticket_dispenser_r(space,0) >> 3;
198   return result;
199}
200
201
202193static READ16_HANDLER( analogx_r )
203194{
204195   return (input_port_read(space->machine, "ANALOGX") << 8) | 0x00ff;
r6740r6741
226217   AM_RANGE(0x02000000, 0x020fffff) AM_RAM AM_BASE(&vram_fg)
227218   AM_RANGE(0x03000000, 0x030000ff) AM_READWRITE(tlc34076_lsb_r, tlc34076_lsb_w)
228219   AM_RANGE(0x03040000, 0x030401ff) AM_WRITE(bit_controls_w)
229   AM_RANGE(0x03040080, 0x0304008f) AM_READ(port0_r)
220   AM_RANGE(0x03040080, 0x0304008f) AM_READ_PORT("DSW")
230221   AM_RANGE(0x03040100, 0x0304010f) AM_READ(analogx_r)
231222   AM_RANGE(0x03040110, 0x0304011f) AM_READ_PORT("COIN1")
232223   AM_RANGE(0x03040130, 0x0304013f) AM_READ_PORT("SERVICE2")
r6740r6741
251242
252243static INPUT_PORTS_START( xtheball )
253244   PORT_START("DSW")
254   PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNUSED )
245   PORT_BIT( 0x000f, IP_ACTIVE_LOW, IPT_UNUSED )
246   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket", ticket_dispenser_line_r)
247   PORT_BIT( 0x00e0, IP_ACTIVE_LOW, IPT_UNUSED )
255248   PORT_DIPNAME( 0x0700, 0x0000, "Target Tickets")
256249   PORT_DIPSETTING(      0x0000, "3" )
257250   PORT_DIPSETTING(      0x0100, "4" )
r6740r6741
350343   MDRV_MACHINE_RESET(xtheball)
351344   MDRV_NVRAM_HANDLER(generic_1fill)
352345
346   MDRV_TICKET_DISPENSER_ADD("ticket", 100, TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_HIGH)
347
353348   /* video hardware */
354349   MDRV_VIDEO_UPDATE(tms340x0)
355350
src/mame/drivers/maxaflex.c
r6740r6741
3131static UINT8 portB_in,portB_out,ddrB;
3232static UINT8 portC_in,portC_out,ddrC;
3333static UINT8 tdr,tcr;
34static emu_timer *mcu_timer;
34static const device_config *mcu_timer;
3535
3636/* Port A:
3737    0   (in)  DSW
r6740r6741
147147   ddrC = data;
148148}
149149
150static TIMER_CALLBACK( mcu_timer_proc )
150static TIMER_DEVICE_CALLBACK( mcu_timer_proc )
151151{
152152   if ( --tdr == 0x00 )
153153   {
154154      if ( (tcr & 0x40) == 0 )
155155      {
156156         //timer interrupt!
157         generic_pulse_irq_line(cputag_get_cpu(machine, "mcu"), M68705_INT_TIMER);
157         generic_pulse_irq_line(cputag_get_cpu(timer->machine, "mcu"), M68705_INT_TIMER);
158158      }
159159   }
160160}
r6740r6741
202202      }
203203
204204      period = attotime_mul(ATTOTIME_IN_HZ(3579545), divider);
205      timer_adjust_periodic( mcu_timer, period, 0, period);
205      timer_device_adjust_periodic( mcu_timer, period, 0, period);
206206   }
207207}
208208
r6740r6741
212212   portB_in = portB_out = ddrB   = 0;
213213   portC_in = portC_out = ddrC   = 0;
214214   tdr = tcr = 0;
215   mcu_timer = timer_alloc(machine, mcu_timer_proc , NULL);
215   mcu_timer = devtag_get_device(machine, "mcu_timer");
216216
217217   output_set_lamp_value(0, 0);
218218   output_set_lamp_value(1, 0);
r6740r6741
437437   MDRV_CPU_PROGRAM_MAP(mcu_mem)
438438
439439   MDRV_PIA6821_ADD("pia", atarixl_pia_interface)
440   MDRV_TIMER_ADD("mcu_timer", mcu_timer_proc)
440441
441442   /* video hardware */
442443   MDRV_SCREEN_ADD("screen", RASTER)
src/mame/drivers/news.c
r6740r6741
1515
1616#include "driver.h"
1717#include "cpu/z80/z80.h"
18#include "news.h"
18#include "includes/news.h"
1919#include "sound/okim6295.h"
2020
2121
src/mame/drivers/segaybd.c
r6740r6741
2424
2525#include "driver.h"
2626#include "cpu/z80/z80.h"
27#include "system16.h"
27#include "includes/system16.h"
2828#include "cpu/m68000/m68000.h"
2929#include "machine/segaic16.h"
3030#include "sound/2151intf.h"
r6740r6741
5555
5656static UINT16 *backupram;
5757
58static emu_timer *interrupt_timer;
58static const device_config *interrupt_timer;
5959
6060
6161
r6740r6741
133133
134134static int irq2_scanline = 170;
135135
136static TIMER_CALLBACK( scanline_callback )
136static TIMER_DEVICE_CALLBACK( scanline_callback )
137137{
138138   int scanline = param;
139139
r6740r6741
166166   }
167167
168168   /* update IRQs on the main CPU */
169   update_main_irqs(machine);
169   update_main_irqs(timer->machine);
170170
171171   /* come back at the next appropriate scanline */
172   timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline);
172   timer_device_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline, 0), scanline);
173173
174174#if TWEAK_IRQ2_SCANLINE
175175   if (scanline == 223)
r6740r6741
177177      int old = irq2_scanline;
178178
179179      /* Q = -10 scanlines, W = -1 scanline, E = +1 scanline, R = +10 scanlines */
180      if (input_code_pressed(machine, KEYCODE_Q)) { while (input_code_pressed(machine, KEYCODE_Q)) ; irq2_scanline -= 10; }
181      if (input_code_pressed(machine, KEYCODE_W)) { while (input_code_pressed(machine, KEYCODE_W)) ; irq2_scanline -= 1; }
182      if (input_code_pressed(machine, KEYCODE_E)) { while (input_code_pressed(machine, KEYCODE_E)) ; irq2_scanline += 1; }
183      if (input_code_pressed(machine, KEYCODE_R)) { while (input_code_pressed(machine, KEYCODE_R)) ; irq2_scanline += 10; }
180      if (input_code_pressed(timer->machine, KEYCODE_Q)) { while (input_code_pressed(timer->machine, KEYCODE_Q)) ; irq2_scanline -= 10; }
181      if (input_code_pressed(timer->machine, KEYCODE_W)) { while (input_code_pressed(timer->machine, KEYCODE_W)) ; irq2_scanline -= 1; }
182      if (input_code_pressed(timer->machine, KEYCODE_E)) { while (input_code_pressed(timer->machine, KEYCODE_E)) ; irq2_scanline += 1; }
183      if (input_code_pressed(timer->machine, KEYCODE_R)) { while (input_code_pressed(timer->machine, KEYCODE_R)) ; irq2_scanline += 10; }
184184      if (old != irq2_scanline)
185185         popmessage("scanline = %d", irq2_scanline);
186186   }
r6740r6741
188188}
189189
190190
191static MACHINE_RESET( yboard )
191static MACHINE_START( yboard )
192192{
193    interrupt_timer = timer_alloc(machine, scanline_callback, NULL);
194    timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 223, 0), 223);
195
196193   state_save_register_global_array(machine, misc_io_data);
197194   state_save_register_global_array(machine, analog_data);
198195   state_save_register_global(machine, vblank_irq_state);
r6740r6741
200197}
201198
202199
200static MACHINE_RESET( yboard )
201{
202    interrupt_timer = devtag_get_device(machine, "int_timer");
203    timer_device_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 223, 0), 223);
204}
203205
206
207
204208/*************************************
205209 *
206210 *  Sound comm and interrupts
r6740r6741
980984   MDRV_CPU_PROGRAM_MAP(sound_map)
981985   MDRV_CPU_IO_MAP(sound_portmap)
982986
987   MDRV_MACHINE_START(yboard)
983988   MDRV_MACHINE_RESET(yboard)
984989   MDRV_NVRAM_HANDLER(yboard)
985990   MDRV_QUANTUM_TIME(HZ(6000))
986991
992    MDRV_TIMER_ADD("int_timer", scanline_callback)
993
987994   /* video hardware */
988995   MDRV_SCREEN_ADD("screen", RASTER)
989996   MDRV_SCREEN_REFRESH_RATE(60)
src/mame/drivers/foodf.c
r6740r6741
7777#include "cpu/m68000/m68000.h"
7878#include "machine/atarigen.h"
7979#include "sound/pokey.h"
80#include "foodf.h"
80#include "includes/foodf.h"
8181
8282
8383#define MASTER_CLOCK      12096000
r6740r6741
111111}
112112
113113
114static TIMER_CALLBACK( scanline_update )
114static TIMER_DEVICE_CALLBACK( scanline_update )
115115{
116   foodf_state *state = (foodf_state *)machine->driver_data;
117116   int scanline = param;
118117
119118   /* WARNING: the timing of this is not perfectly accurate; it should fire on
r6740r6741
122121       mystery yet */
123122
124123   /* INT 1 is on 32V */
125   atarigen_scanline_int_gen(cputag_get_cpu(machine, "maincpu"));
124   atarigen_scanline_int_gen(cputag_get_cpu(timer->machine, "maincpu"));
126125
127126   /* advance to the next interrupt */
128127   scanline += 64;
r6740r6741
130129      scanline = 0;
131130
132131   /* set a timer for it */
133   timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline);
132   timer_device_adjust_oneshot(timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline, 0), scanline);
134133}
135134
136135
137136static MACHINE_START( foodf )
138137{
139138   foodf_state *state = (foodf_state *)machine->driver_data;
139   atarigen_init(machine);
140140   state_save_register_global(machine, state->whichport);
141   state->scanline_timer = timer_alloc(machine, scanline_update, NULL);
142141}
143142
144143
r6740r6741
146145{
147146   foodf_state *state = (foodf_state *)machine->driver_data;
148147   atarigen_interrupt_reset(&state->atarigen, update_interrupts);
149   timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
148   timer_device_adjust_oneshot(devtag_get_device(machine, "scan_timer"), video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
150149}
151150
152151
r6740r6741
366365   MDRV_NVRAM_HANDLER(generic_1fill)
367366   MDRV_WATCHDOG_VBLANK_INIT(8)
368367
368   MDRV_TIMER_ADD("scan_timer", scanline_update)
369
369370   /* video hardware */
370371   MDRV_GFXDECODE(foodf)
371372   MDRV_PALETTE_LENGTH(256)
src/mame/drivers/skyraid.c
r6740r6741
66
77#include "driver.h"
88#include "cpu/m6502/m6502.h"
9#include "skyraid.h"
9#include "includes/skyraid.h"
1010
1111extern UINT8* skyraid_alpha_num_ram;
1212extern UINT8* skyraid_pos_ram;
src/mame/drivers/aliens.c
r6740r6741
1010#include "driver.h"
1111#include "cpu/z80/z80.h"
1212#include "cpu/konami/konami.h" /* for the callback and the firq irq definition */
13#include "video/konamiic.h"
1413#include "sound/k007232.h"
1514#include "sound/2151intf.h"
16#include "konamipt.h"
15#include "video/konicdev.h"
16#include "includes/konamipt.h"
1717
1818/* prototypes */
1919static MACHINE_RESET( aliens );
2020static KONAMI_SETLINES_CALLBACK( aliens_banking );
2121
22extern void aliens_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color, int *flags, int *priority);
23extern void aliens_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask,int *shadow);
2224
2325VIDEO_START( aliens );
2426VIDEO_UPDATE( aliens );
r6740r6741
3032
3133static INTERRUPT_GEN( aliens_interrupt )
3234{
33   if (K051960_is_IRQ_enabled())
35   const device_config *k051960 = devtag_get_device(device->machine, "k051960");
36
37   if (k051960_is_irq_enabled(k051960))
3438      cpu_set_input_line(device, KONAMI_IRQ_LINE, HOLD_LINE);
3539}
3640
r6740r6741
5256
5357static WRITE8_HANDLER( aliens_coin_counter_w )
5458{
59   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
60
5561   /* bits 0-1 = coin counters */
5662   coin_counter_w(space->machine, 0,data & 0x01);
5763   coin_counter_w(space->machine, 1,data & 0x02);
r6740r6741
6066   palette_selected = data & 0x20;
6167
6268   /* bit 6 = enable char ROM reading through the video RAM */
63   K052109_set_RMRD_line((data & 0x40) ? ASSERT_LINE : CLEAR_LINE);
69   k052109_set_rmrd_line(k052109, (data & 0x40) ? ASSERT_LINE : CLEAR_LINE);
6470
6571   /* other bits unknown */
6672#if 0
r6740r6741
9096}
9197
9298
99static READ8_HANDLER( k052109_051960_r )
100{
101   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
102   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
103
104   if (k052109_get_rmrd_line(k052109) == CLEAR_LINE)
105   {
106      if (offset >= 0x3800 && offset < 0x3808)
107         return k051937_r(k051960, offset - 0x3800);
108      else if (offset < 0x3c00)
109         return k052109_r(k052109, offset);
110      else
111         return k051960_r(k051960, offset - 0x3c00);
112   }
113   else
114      return k052109_r(k052109, offset);
115}
116
117static WRITE8_HANDLER( k052109_051960_w )
118{
119   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
120   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
121
122   if (offset >= 0x3800 && offset < 0x3808)
123      k051937_w(k051960, offset - 0x3800, data);
124   else if (offset < 0x3c00)
125      k052109_w(k052109, offset, data);
126   else
127      k051960_w(k051960, offset - 0x3c00, data);
128}
129
93130static ADDRESS_MAP_START( aliens_map, ADDRESS_SPACE_PROGRAM, 8 )
94131   AM_RANGE(0x0000, 0x03ff) AM_READWRITE(bankedram_r, bankedram_w) AM_BASE(&ram)      /* palette + work RAM */
95132   AM_RANGE(0x0400, 0x1fff) AM_RAM
r6740r6741
101138   AM_RANGE(0x5f84, 0x5f84) AM_READ_PORT("DSW1")
102139   AM_RANGE(0x5f88, 0x5f88) AM_READWRITE(watchdog_reset_r, aliens_coin_counter_w)      /* coin counters */
103140   AM_RANGE(0x5f8c, 0x5f8c) AM_WRITE(aliens_sh_irqtrigger_w)                     /* cause interrupt on audio CPU */
104   AM_RANGE(0x4000, 0x7fff) AM_READWRITE(K052109_051960_r, K052109_051960_w)
141   AM_RANGE(0x4000, 0x7fff) AM_READWRITE(k052109_051960_r, k052109_051960_w)
105142   AM_RANGE(0x8000, 0xffff) AM_ROM                                          /* ROM e24_j02.bin */
106143ADDRESS_MAP_END
107144
r6740r6741
186223   aliens_snd_bankswitch_w
187224};
188225
226
227static const k052109_interface aliens_k052109_intf =
228{
229   "gfx1", 0,
230   NORMAL_PLANE_ORDER,
231   KONAMI_ROM_DEINTERLEAVE_2,
232   aliens_tile_callback
233};
234
235static const k051960_interface aliens_k051960_intf =
236{
237   "gfx2", 1,
238   NORMAL_PLANE_ORDER,
239   KONAMI_ROM_DEINTERLEAVE_2,
240   aliens_sprite_callback
241};
242
189243static MACHINE_DRIVER_START( aliens )
190244
191245   /* basic machine hardware */
r6740r6741
216270   MDRV_VIDEO_START(aliens)
217271   MDRV_VIDEO_UPDATE(aliens)
218272
273   MDRV_K052109_ADD("k052109", aliens_k052109_intf)
274   MDRV_K051960_ADD("k051960", aliens_k051960_intf)
275
219276   /* sound hardware */
220277   MDRV_SPEAKER_STANDARD_MONO("mono")
221278
r6740r6741
493550
494551static DRIVER_INIT( aliens )
495552{
496   konami_rom_deinterleave_2(machine, "gfx1");
497   konami_rom_deinterleave_2(machine, "gfx2");
498
499553   state_save_register_global(machine, palette_selected);
500554}
501555
src/mame/drivers/88games.c
r6740r6741
77#include "driver.h"
88#include "cpu/konami/konami.h"
99#include "cpu/z80/z80.h"
10#include "video/konamiic.h"
10#include "video/konicdev.h"
1111#include "sound/2151intf.h"
1212#include "sound/upd7759.h"
13#include "includes/88games.h"
1314
1415
15static MACHINE_RESET( 88games );
16static MACHINE_START( 88games );
17static KONAMI_SETLINES_CALLBACK( k88games_banking );
18
19static UINT8 *ram;
20static UINT8 *banked_rom;
2116static UINT8 *paletteram_1000;
22static int videobank;
2317
24extern int k88games_priority;
25VIDEO_START( 88games );
26VIDEO_UPDATE( 88games );
2718
19/*************************************
20 *
21 *  Memory handlers
22 *
23 *************************************/
2824
2925static INTERRUPT_GEN( k88games_interrupt )
3026{
31   if (K052109_is_IRQ_enabled())
27   _88games_state *state = (_88games_state *)device->machine->driver_data;
28
29   if (k052109_is_irq_enabled(state->k052109))
3230      irq0_line_hold(device);
3331}
3432
35static int zoomreadroms;
36
3733static READ8_HANDLER( bankedram_r )
3834{
39   if (videobank) return ram[offset];
35   _88games_state *state = (_88games_state *)space->machine->driver_data;
36
37   if (state->videobank)
38      return state->ram[offset];
4039   else
4140   {
42      if (zoomreadroms)
43         return K051316_rom_0_r(space,offset);
41      if (state->zoomreadroms)
42         return k051316_rom_r(state->k051316, offset);
4443      else
45         return K051316_0_r(space,offset);
44         return k051316_r(state->k051316, offset);
4645   }
4746}
4847
4948static WRITE8_HANDLER( bankedram_w )
5049{
51   if (videobank) ram[offset] = data;
52   else K051316_0_w(space,offset,data);
50   _88games_state *state = (_88games_state *)space->machine->driver_data;
51
52   if (state->videobank)
53      state->ram[offset] = data;
54   else
55      k051316_w(state->k051316, offset, data);
5356}
5457
5558static WRITE8_HANDLER( k88games_5f84_w )
5659{
60   _88games_state *state = (_88games_state *)space->machine->driver_data;
61
5762   /* bits 0/1 coin counters */
58   coin_counter_w(space->machine, 0,data & 0x01);
59   coin_counter_w(space->machine, 1,data & 0x02);
63   coin_counter_w(space->machine, 0, data & 0x01);
64   coin_counter_w(space->machine, 1, data & 0x02);
6065
6166   /* bit 2 enables ROM reading from the 051316 */
6267   /* also 5fce == 2 read roms, == 3 read ram */
63   zoomreadroms = data & 0x04;
68   state->zoomreadroms = data & 0x04;
6469
6570   if (data & 0xf8)
66      popmessage("5f84 = %02x",data);
71      popmessage("5f84 = %02x", data);
6772}
6873
6974static WRITE8_HANDLER( k88games_sh_irqtrigger_w )
7075{
71   cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff);
76   _88games_state *state = (_88games_state *)space->machine->driver_data;
77   cpu_set_input_line_and_vector(state->audiocpu, 0, HOLD_LINE, 0xff);
7278}
7379
74static UINT8 speech_chip[8];
80
7581static WRITE8_HANDLER( speech_control_w )
7682{
83   _88games_state *state = (_88games_state *)space->machine->driver_data;
7784   const device_config *upd;
7885
79   strcpy((char *)speech_chip, ( data & 4 ) ? "upd2" : "upd1");
86   state->speech_chip = (data & 4) ? 1 : 0;
87   upd = state->speech_chip ? state->upd_2 : state->upd_1;
8088
81   upd = devtag_get_device(space->machine, (char *)speech_chip);
82   upd7759_reset_w( upd, data & 2 );
83   upd7759_start_w( upd, data & 1 );
89   upd7759_reset_w(upd, data & 2);
90   upd7759_start_w(upd, data & 1);
8491}
8592
8693static WRITE8_HANDLER( speech_msg_w )
8794{
88   upd7759_port_w( devtag_get_device(space->machine, (char *)speech_chip), 0, data );
95   _88games_state *state = (_88games_state *)space->machine->driver_data;
96   const device_config *upd = state->speech_chip ? state->upd_2 : state->upd_1;
97
98   upd7759_port_w(upd, 0, data);
8999}
90100
101/* special handlers to combine 052109 & 051960 */
102static READ8_HANDLER( k052109_051960_r )
103{
104   _88games_state *state = (_88games_state *)space->machine->driver_data;
105
106   if (k052109_get_rmrd_line(state->k052109) == CLEAR_LINE)
107   {
108      if (offset >= 0x3800 && offset < 0x3808)
109         return k051937_r(state->k051960, offset - 0x3800);
110      else if (offset < 0x3c00)
111         return k052109_r(state->k052109, offset);
112      else
113         return k051960_r(state->k051960, offset - 0x3c00);
114   }
115   else
116      return k052109_r(state->k052109, offset);
117}
118
119static WRITE8_HANDLER( k052109_051960_w )
120{
121   _88games_state *state = (_88games_state *)space->machine->driver_data;
122
123   if (offset >= 0x3800 && offset < 0x3808)
124      k051937_w(state->k051960, offset - 0x3800, data);
125   else if (offset < 0x3c00)
126      k052109_w(state->k052109, offset, data);
127   else
128      k051960_w(state->k051960, offset - 0x3c00, data);
129}
130
131/*************************************
132 *
133 *  Address maps
134 *
135 *************************************/
136
91137static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
92   AM_RANGE(0x0000, 0x0fff) AM_RAM   AM_BASE(&banked_rom) /* banked ROM + palette RAM */
138   AM_RANGE(0x0000, 0x0fff) AM_RAM AM_BASE_MEMBER(_88games_state, banked_rom) /* banked ROM + palette RAM */
93139   AM_RANGE(0x1000, 0x1fff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_be_w) AM_BASE(&paletteram_1000)   /* banked ROM + palette RAM */
94140   AM_RANGE(0x2000, 0x2fff) AM_RAM
95141   AM_RANGE(0x3000, 0x37ff) AM_RAM AM_BASE_SIZE_GENERIC(nvram)
96   AM_RANGE(0x3800, 0x3fff) AM_READWRITE(bankedram_r, bankedram_w) AM_BASE(&ram)
142   AM_RANGE(0x3800, 0x3fff) AM_READWRITE(bankedram_r, bankedram_w) AM_BASE_MEMBER(_88games_state, ram)
97143   AM_RANGE(0x5f84, 0x5f84) AM_WRITE(k88games_5f84_w)
98144   AM_RANGE(0x5f88, 0x5f88) AM_WRITE(watchdog_reset_w)
99145   AM_RANGE(0x5f8c, 0x5f8c) AM_WRITE(soundlatch_w)
r6740r6741
103149   AM_RANGE(0x5f96, 0x5f96) AM_READ_PORT("IN2")
104150   AM_RANGE(0x5f97, 0x5f97) AM_READ_PORT("DSW1")
105151   AM_RANGE(0x5f9b, 0x5f9b) AM_READ_PORT("DSW2")
106   AM_RANGE(0x5fc0, 0x5fcf) AM_WRITE(K051316_ctrl_0_w)
107   AM_RANGE(0x4000, 0x7fff) AM_READWRITE(K052109_051960_r, K052109_051960_w)
152   AM_RANGE(0x5fc0, 0x5fcf) AM_DEVWRITE("k051316", k051316_ctrl_w)
153   AM_RANGE(0x4000, 0x7fff) AM_READWRITE(k052109_051960_r, k052109_051960_w)
108154   AM_RANGE(0x8000, 0xffff) AM_ROM
109155ADDRESS_MAP_END
110156
r6740r6741
119165
120166
121167
122/***************************************************************************
168/*************************************
169 *
170 *  Input ports
171 *
172 *************************************/
123173
124    Input Ports
125
126***************************************************************************/
127
128174static INPUT_PORTS_START( 88games )
129175   PORT_START("IN0")
130176   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
r6740r6741
219265INPUT_PORTS_END
220266
221267
268/*************************************
269 *
270 *  Machine driver
271 *
272 *************************************/
222273
274static KONAMI_SETLINES_CALLBACK( k88games_banking )
275{
276   _88games_state *state = (_88games_state *)device->machine->driver_data;
277   UINT8 *RAM = memory_region(device->machine, "maincpu");
278   int offs;
279
280   logerror("%04x: bank select %02x\n", cpu_get_pc(device), lines);
281
282   /* bits 0-2 select ROM bank for 0000-1fff */
283   /* bit 3: when 1, palette RAM at 1000-1fff */
284   /* bit 4: when 0, 051316 RAM at 3800-3fff; when 1, work RAM at 2000-3fff (NVRAM 3370-37ff) */
285   offs = 0x10000 + (lines & 0x07) * 0x2000;
286   memcpy(state->banked_rom, &RAM[offs], 0x1000);
287   if (lines & 0x08)
288   {
289      if (device->machine->generic.paletteram.u8 != paletteram_1000)
290      {
291         memcpy(paletteram_1000, device->machine->generic.paletteram.u8, 0x1000);
292         device->machine->generic.paletteram.u8 = paletteram_1000;
293      }
294   }
295   else
296   {
297      if (device->machine->generic.paletteram.u8 != &RAM[0x20000])
298      {
299         memcpy(&RAM[0x20000], device->machine->generic.paletteram.u8, 0x1000);
300         device->machine->generic.paletteram.u8 = &RAM[0x20000];
301      }
302      memcpy(paletteram_1000, &RAM[offs+0x1000], 0x1000);
303   }
304
305   state->videobank = lines & 0x10;
306
307   /* bit 5 = enable char ROM reading through the video RAM */
308   k052109_set_rmrd_line(state->k052109, (lines & 0x20) ? ASSERT_LINE : CLEAR_LINE);
309
310   /* bit 6 is unknown, 1 most of the time */
311
312   /* bit 7 controls layer priority */
313   state->k88games_priority = lines & 0x80;
314}
315
316static MACHINE_START( 88games )
317{
318   _88games_state *state = (_88games_state *)machine->driver_data;
319
320   state->audiocpu = devtag_get_device(machine, "audiocpu");
321   state->k052109 = devtag_get_device(machine, "k052109");
322   state->k051960 = devtag_get_device(machine, "k051960");
323   state->k051316 = devtag_get_device(machine, "k051316");
324   state->upd_1 = devtag_get_device(machine, "upd1");
325   state->upd_2 = devtag_get_device(machine, "upd2");
326
327   state_save_register_global(machine, state->videobank);
328   state_save_register_global(machine, state->zoomreadroms);
329   state_save_register_global(machine, state->speech_chip);
330   state_save_register_global_array(machine, state->layer_colorbase);
331   state_save_register_global(machine, state->k88games_priority);
332   state_save_register_global(machine, state->sprite_colorbase);
333   state_save_register_global(machine, state->zoom_colorbase);
334}
335
336static MACHINE_RESET( 88games )
337{
338   _88games_state *state = (_88games_state *)machine->driver_data;
339
340   konami_configure_set_lines(devtag_get_device(machine, "maincpu"), k88games_banking);
341   machine->generic.paletteram.u8 = &memory_region(machine, "maincpu")[0x20000];
342
343   state->videobank = 0;
344   state->zoomreadroms = 0;
345   state->speech_chip = 0;
346   state->k88games_priority = 0;
347   state->layer_colorbase[0] = 64;
348   state->layer_colorbase[1] = 0;
349   state->layer_colorbase[2] = 16;
350   state->sprite_colorbase = 32;
351   state->zoom_colorbase = 48;
352}
353
354static const k052109_interface _88games_k052109_intf =
355{
356   "gfx1", 0,
357   NORMAL_PLANE_ORDER,
358   KONAMI_ROM_DEINTERLEAVE_2,
359   _88games_tile_callback
360};
361
362static const k051960_interface _88games_k051960_intf =
363{
364   "gfx2", 1,
365   NORMAL_PLANE_ORDER,
366   KONAMI_ROM_DEINTERLEAVE_2,
367   _88games_sprite_callback
368};
369
370static const k051316_interface _88games_k051316_intf =
371{
372   "gfx3", 2,
373   4, FALSE, 0,
374   0, 0, 0,
375   _88games_zoom_callback
376};
377
223378static MACHINE_DRIVER_START( 88games )
224379
380   /* driver data */
381   MDRV_DRIVER_DATA(_88games_state)
382
225383   /* basic machine hardware */
226384   MDRV_CPU_ADD("maincpu", KONAMI, 3000000) /* ? */
227385   MDRV_CPU_PROGRAM_MAP(main_map)
r6740r6741
230388   MDRV_CPU_ADD("audiocpu", Z80, 3579545)
231389   MDRV_CPU_PROGRAM_MAP(sound_map)
232390
391   MDRV_MACHINE_START(88games)
233392   MDRV_MACHINE_RESET(88games)
393
234394   MDRV_NVRAM_HANDLER(generic_0fill)
235395
236396   /* video hardware */
r6740r6741
244404   MDRV_SCREEN_VISIBLE_AREA(13*8, (64-13)*8-1, 2*8, 30*8-1 )
245405   MDRV_PALETTE_LENGTH(2048)
246406
247   MDRV_VIDEO_START(88games)
407   MDRV_K052109_ADD("k052109", _88games_k052109_intf)
408   MDRV_K051960_ADD("k051960", _88games_k051960_intf)
409   MDRV_K051316_ADD("k051316", _88games_k051316_intf)
410
248411   MDRV_VIDEO_UPDATE(88games)
249412
250    MDRV_MACHINE_START(88games)
251
252413   /* sound hardware */
253414   MDRV_SPEAKER_STANDARD_MONO("mono")
254415
r6740r6741
265426
266427
267428
268/***************************************************************************
429/*************************************
430 *
431 *  ROM definition(s)
432 *
433 *************************************/
269434
270  Game ROMs
271
272***************************************************************************/
273
274435ROM_START( 88games )
275436   ROM_REGION( 0x21000, "maincpu", 0 ) /* code + banked roms + space for banked ram */
276    ROM_LOAD( "861m01.k18", 0x08000, 0x08000, CRC(4a4e2959) SHA1(95572686bef48b5c1ce1dedf0afc891d92aff00d) )
437   ROM_LOAD( "861m01.k18", 0x08000, 0x08000, CRC(4a4e2959) SHA1(95572686bef48b5c1ce1dedf0afc891d92aff00d) )
277438   ROM_LOAD( "861m02.k16", 0x10000, 0x10000, CRC(e19f15f6) SHA1(6c801b274e87eaff7f40148381ade5b38120cc12) )
278439
279440   ROM_REGION( 0x10000, "audiocpu", 0 ) /* Z80 code */
r6740r6741
434595ROM_END
435596
436597
598/*************************************
599 *
600 *  Game driver(s)
601 *
602 *************************************/
437603
438static KONAMI_SETLINES_CALLBACK( k88games_banking )
439{
440   UINT8 *RAM = memory_region(device->machine, "maincpu");
441   int offs;
442
443logerror("%04x: bank select %02x\n",cpu_get_pc(device),lines);
444
445   /* bits 0-2 select ROM bank for 0000-1fff */
446   /* bit 3: when 1, palette RAM at 1000-1fff */
447   /* bit 4: when 0, 051316 RAM at 3800-3fff; when 1, work RAM at 2000-3fff (NVRAM 3370-37ff) */
448   offs = 0x10000 + (lines & 0x07) * 0x2000;
449   memcpy(banked_rom,&RAM[offs],0x1000);
450   if (lines & 0x08)
451   {
452      if (device->machine->generic.paletteram.u8 != paletteram_1000)
453      {
454         memcpy(paletteram_1000,device->machine->generic.paletteram.u8,0x1000);
455         device->machine->generic.paletteram.u8 = paletteram_1000;
456      }
457   }
458   else
459   {
460      if (device->machine->generic.paletteram.u8 != &RAM[0x20000])
461      {
462         memcpy(&RAM[0x20000],device->machine->generic.paletteram.u8,0x1000);
463         device->machine->generic.paletteram.u8 = &RAM[0x20000];
464      }
465      memcpy(paletteram_1000,&RAM[offs+0x1000],0x1000);
466   }
467   videobank = lines & 0x10;
468
469   /* bit 5 = enable char ROM reading through the video RAM */
470   K052109_set_RMRD_line((lines & 0x20) ? ASSERT_LINE : CLEAR_LINE);
471
472   /* bit 6 is unknown, 1 most of the time */
473
474   /* bit 7 controls layer priority */
475   k88games_priority = lines & 0x80;
476}
477
478static MACHINE_RESET( 88games )
479{
480   konami_configure_set_lines(cputag_get_cpu(machine, "maincpu"), k88games_banking);
481   machine->generic.paletteram.u8 = &memory_region(machine, "maincpu")[0x20000];
482}
483
484static MACHINE_START( 88games )
485{
486    state_save_register_global(machine, videobank);
487    state_save_register_global(machine, zoomreadroms);
488    state_save_register_global_array(machine, speech_chip);
489}
490
491static DRIVER_INIT( 88games )
492{
493   konami_rom_deinterleave_2(machine, "gfx1");
494   konami_rom_deinterleave_2(machine, "gfx2");
495}
496
497
498
499GAME( 1988, 88games,  0,       88games, 88games, 88games, ROT0, "Konami", "'88 Games", GAME_SUPPORTS_SAVE )
500GAME( 1988, konami88, 88games, 88games, 88games, 88games, ROT0, "Konami", "Konami '88", GAME_SUPPORTS_SAVE )
501GAME( 1988, hypsptsp, 88games, 88games, 88games, 88games, ROT0, "Konami", "Hyper Sports Special (Japan)", GAME_SUPPORTS_SAVE )
604GAME( 1988, 88games,  0,       88games, 88games, 0, ROT0, "Konami", "'88 Games", GAME_SUPPORTS_SAVE )
605GAME( 1988, konami88, 88games, 88games, 88games, 0, ROT0, "Konami", "Konami '88", GAME_SUPPORTS_SAVE )
606GAME( 1988, hypsptsp, 88games, 88games, 88games, 0, ROT0, "Konami", "Hyper Sports Special (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/chinagat.c
r6740r6741
7878#include "sound/2203intf.h"
7979#include "sound/okim6295.h"
8080#include "sound/msm5205.h"
81#include "ddragon.h"
81#include "includes/ddragon.h"
8282
8383#define MAIN_CLOCK      XTAL_12MHz
8484#define PIXEL_CLOCK      MAIN_CLOCK / 2
src/mame/drivers/gauntlet.c
r6740r6741
124124#include "sound/tms5220.h"
125125#include "sound/2151intf.h"
126126#include "sound/pokey.h"
127#include "gauntlet.h"
127#include "includes/gauntlet.h"
128128
129129
130130
131131/*************************************
132132 *
133 *  Statics
134 *
135 *************************************/
136
137
138
139
140/*************************************
141 *
142133 *  Initialization & interrupts
143134 *
144135 *************************************/
r6740r6741
163154}
164155
165156
157static MACHINE_START( gauntlet )
158{
159   gauntlet_state *state = (gauntlet_state *)machine->driver_data;
160   atarigen_init(machine);
161
162   state_save_register_global(machine, state->sound_reset_val);
163}
164
165
166166static MACHINE_RESET( gauntlet )
167167{
168168   gauntlet_state *state = (gauntlet_state *)machine->driver_data;
r6740r6741
514514   MDRV_CPU_ADD("audiocpu", M6502, ATARI_CLOCK_14MHz/8)
515515   MDRV_CPU_PROGRAM_MAP(sound_map)
516516
517   MDRV_MACHINE_START(gauntlet)
517518   MDRV_MACHINE_RESET(gauntlet)
518519   MDRV_NVRAM_HANDLER(atarigen)
519520
src/mame/drivers/deniam.c
r6740r6741
4747#include "cpu/z80/z80.h"
4848#include "sound/okim6295.h"
4949#include "sound/3812intf.h"
50#include "deniam.h"
50#include "includes/deniam.h"
5151
5252
5353static WRITE16_HANDLER( sound_command_w )
src/mame/drivers/redalert.c
r6740r6741
9393
9494#include "driver.h"
9595#include "cpu/m6502/m6502.h"
96#include "redalert.h"
96#include "includes/redalert.h"
9797
9898
9999#define MAIN_PCB_CLOCK      (XTAL_12_5MHz)
src/mame/drivers/mcr3.c
r6740r6741
106106#include "deprecat.h"
107107#include "machine/z80ctc.h"
108108#include "audio/mcr.h"
109#include "mcr.h"
109#include "includes/mcr.h"
110110
111111#include "turbotag.lh"
112112
src/mame/drivers/taito_b.c
r6740r6741
169169
170170#include "driver.h"
171171#include "cpu/z80/z80.h"
172#include "taitoipt.h"
172#include "includes/taitoipt.h"
173173#include "cpu/m68000/m68000.h"
174174#include "video/taitoic.h"
175175#include "machine/eepromdev.h"
src/mame/drivers/mw8080bw.c
r6740r6741
147147#include "cpu/i8085/i8085.h"
148148#include "rendlay.h"
149149#include "machine/rescap.h"
150#include "mw8080bw.h"
151150#include "machine/mb14241.h"
151#include "includes/mw8080bw.h"
152152
153153#include "280zzzap.lh"
154154#include "clowns.lh"
r6740r6741
165165 *
166166 *************************************/
167167
168static UINT8 rev_shift_res;
169
170
171168static READ8_HANDLER( mw8080bw_shift_result_rev_r )
172169{
173   UINT8 ret = mb14241_0_shift_result_r(space, 0);
170   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
171   UINT8 ret = mb14241_shift_result_r(state->mb14241, 0);
174172
175173   return BITSWAP8(ret,0,1,2,3,4,5,6,7);
176174}
r6740r6741
178176
179177static READ8_HANDLER( mw8080bw_reversable_shift_result_r )
180178{
179   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
181180   UINT8 ret;
182181
183   if (rev_shift_res)
182   if (state->rev_shift_res)
184183   {
185184      ret = mw8080bw_shift_result_rev_r(space, 0);
186185   }
187186   else
188187   {
189      ret = mb14241_0_shift_result_r(space, 0);
188      ret = mb14241_shift_result_r(state->mb14241, 0);
190189   }
191190
192191   return ret;
r6740r6741
194193
195194static WRITE8_HANDLER( mw8080bw_reversable_shift_count_w)
196195{
197   mb14241_0_shift_count_w(space, offset, data);
196   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
197   mb14241_shift_count_w(state->mb14241, offset, data);
198198
199   rev_shift_res = data & 0x08;
199   state->rev_shift_res = data & 0x08;
200200}
201201
202202
r6740r6741
207207 *
208208 *************************************/
209209
210UINT8 *mw8080bw_ram;
211size_t mw8080bw_ram_size;
212
213
214210static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
215211   ADDRESS_MAP_GLOBAL_MASK(0x7fff)
216212   AM_RANGE(0x0000, 0x1fff) AM_ROM AM_WRITENOP
217   AM_RANGE(0x2000, 0x3fff) AM_MIRROR(0x4000) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size)
213   AM_RANGE(0x2000, 0x3fff) AM_MIRROR(0x4000) AM_RAM AM_BASE_SIZE_MEMBER(mw8080bw_state, main_ram, main_ram_size)
218214   AM_RANGE(0x4000, 0x5fff) AM_ROM AM_WRITENOP
219215ADDRESS_MAP_END
220216
r6740r6741
228224
229225MACHINE_DRIVER_START( mw8080bw_root )
230226
227   /* driver data */
228   MDRV_DRIVER_DATA(mw8080bw_state)
229
231230   /* basic machine hardware */
232231   MDRV_CPU_ADD("maincpu",8080,MW8080BW_CPU_CLOCK)
233232   MDRV_CPU_PROGRAM_MAP(main_map)
r6740r6741
335334   AM_RANGE(0x00, 0x00) AM_MIRROR(0x04) AM_READ(mw8080bw_shift_result_rev_r)
336335   AM_RANGE(0x01, 0x01) AM_MIRROR(0x04) AM_READ_PORT("IN0")
337336   AM_RANGE(0x02, 0x02) AM_MIRROR(0x04) AM_READ_PORT("IN1")
338   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_READ(mb14241_0_shift_result_r)
337   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_DEVREAD("mb14241", mb14241_shift_result_r)
339338
340339   AM_RANGE(0x01, 0x01) AM_WRITE(seawolf_explosion_lamp_w)
341340   AM_RANGE(0x02, 0x02) AM_WRITE(seawolf_periscope_lamp_w)
342   AM_RANGE(0x03, 0x03) AM_WRITE(mb14241_0_shift_data_w)
343   AM_RANGE(0x04, 0x04) AM_WRITE(mb14241_0_shift_count_w)
341   AM_RANGE(0x03, 0x03) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
342   AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_count_w)
344343   AM_RANGE(0x05, 0x05) AM_WRITE(seawolf_audio_w)
345344ADDRESS_MAP_END
346345
r6740r6741
413412   MDRV_CPU_IO_MAP(seawolf_io_map)
414413   /* there is no watchdog */
415414
415   /* add shifter */
416   MDRV_MB14241_ADD("mb14241")
417
416418   /* audio hardware */
417419   MDRV_IMPORT_FROM(seawolf_audio)
418420
r6740r6741
428430
429431static WRITE8_HANDLER( gunfight_io_w )
430432{
431   if (offset & 0x01)  gunfight_audio_w(space, 0, data);
433   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
432434
433   if (offset & 0x02)  mb14241_0_shift_count_w(space, 0, data);
435   if (offset & 0x01)
436      gunfight_audio_w(space, 0, data);
434437
435   if (offset & 0x04)  mb14241_0_shift_data_w(space, 0, data);
438   if (offset & 0x02)
439      mb14241_shift_count_w(state->mb14241, 0, data);
440
441   if (offset & 0x04)
442      mb14241_shift_data_w(state->mb14241, 0, data);
436443}
437444
438445
r6740r6741
441448   AM_RANGE(0x00, 0x00) AM_MIRROR(0x04) AM_READ_PORT("IN0")
442449   AM_RANGE(0x01, 0x01) AM_MIRROR(0x04) AM_READ_PORT("IN1")
443450   AM_RANGE(0x02, 0x02) AM_MIRROR(0x04) AM_READ_PORT("IN2")
444   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_READ(mb14241_0_shift_result_r)
451   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_DEVREAD("mb14241", mb14241_shift_result_r)
445452
446453   /* no decoder, just 3 AND gates */
447454   AM_RANGE(0x00, 0x07) AM_WRITE(gunfight_io_w)
r6740r6741
507514   MDRV_CPU_IO_MAP(gunfight_io_map)
508515   /* there is no watchdog */
509516
517   /* add shifter */
518   MDRV_MB14241_ADD("mb14241")
519
510520   /* audio hardware */
511521   MDRV_IMPORT_FROM(gunfight_audio)
512522
r6740r6741
617627
618628static WRITE8_HANDLER( tornbase_io_w )
619629{
620   if (offset & 0x01)  tornbase_audio_w(devtag_get_device(space->machine, "discrete"), 0, data);
630   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
621631
622   if (offset & 0x02)  mb14241_0_shift_count_w(space, 0, data);
632   if (offset & 0x01)
633      tornbase_audio_w(devtag_get_device(space->machine, "discrete"), 0, data);
623634
624   if (offset & 0x04)  mb14241_0_shift_data_w(space, 0, data);
635   if (offset & 0x02)
636      mb14241_shift_count_w(state->mb14241, 0, data);
637
638   if (offset & 0x04)
639      mb14241_shift_data_w(state->mb14241, 0, data);
625640}
626641
627642
r6740r6741
630645   AM_RANGE(0x00, 0x00) AM_MIRROR(0x04) AM_READ_PORT("IN0")
631646   AM_RANGE(0x01, 0x01) AM_MIRROR(0x04) AM_READ_PORT("IN1")
632647   AM_RANGE(0x02, 0x02) AM_MIRROR(0x04) AM_READ_PORT("IN2")
633   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_READ(mb14241_0_shift_result_r)
648   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_DEVREAD("mb14241", mb14241_shift_result_r)
634649
635650   /* no decoder, just 3 AND gates */
636651   AM_RANGE(0x00, 0x07) AM_WRITE(tornbase_io_w)
r6740r6741
730745   MDRV_CPU_IO_MAP(tornbase_io_map)
731746   /* there is no watchdog */
732747
748   /* add shifter */
749   MDRV_MB14241_ADD("mb14241")
750
733751   /* audio hardware */
734752   MDRV_IMPORT_FROM(tornbase_audio)
735753
r6740r6741
748766   AM_RANGE(0x00, 0x00) AM_MIRROR(0x04) AM_READ_PORT("IN0")
749767   AM_RANGE(0x01, 0x01) AM_MIRROR(0x04) AM_READ_PORT("IN1")
750768   AM_RANGE(0x02, 0x02) AM_MIRROR(0x04) AM_READ_PORT("IN2")
751   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_READ(mb14241_0_shift_result_r)
769   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_DEVREAD("mb14241", mb14241_shift_result_r)
752770
753771   AM_RANGE(0x02, 0x02) AM_WRITE(zzzap_audio_1_w)
754   AM_RANGE(0x03, 0x03) AM_WRITE(mb14241_0_shift_data_w)
755   AM_RANGE(0x04, 0x04) AM_WRITE(mb14241_0_shift_count_w)
772   AM_RANGE(0x03, 0x03) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
773   AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_count_w)
756774   AM_RANGE(0x05, 0x05) AM_WRITE(zzzap_audio_2_w)
757775   AM_RANGE(0x07, 0x07) AM_WRITE(watchdog_reset_w)
758776ADDRESS_MAP_END
r6740r6741
843861   MDRV_CPU_IO_MAP(zzzap_io_map)
844862   MDRV_WATCHDOG_TIME_INIT(NSEC(PERIOD_OF_555_MONOSTABLE_NSEC(RES_M(1), CAP_U(1)))) /* 1.1s */
845863
864   /* add shifter */
865   MDRV_MB14241_ADD("mb14241")
866
846867   /* audio hardware */
847868   /* MDRV_IMPORT_FROM(zzzap_audio) */
848869
r6740r6741
859880/* schematic says 12.5 Hz, but R/C values shown give 8.5Hz */
860881#define MAZE_555_B1_PERIOD      PERIOD_OF_555_ASTABLE(RES_K(33) /* R200 */, RES_K(68) /* R201 */, CAP_U(1) /* C201 */)
861882
862/* output of IC C1, pin 5 */
863static UINT8 maze_tone_timing_state;
864
865
866883static STATE_POSTLOAD( maze_update_discrete )
867884{
868   maze_write_discrete(devtag_get_device(machine, "discrete"), maze_tone_timing_state);
885   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
886   maze_write_discrete(devtag_get_device(machine, "discrete"), state->maze_tone_timing_state);
869887}
870888
871889
872890static TIMER_CALLBACK( maze_tone_timing_timer_callback )
873891{
874   maze_tone_timing_state = !maze_tone_timing_state;
875   maze_write_discrete(devtag_get_device(machine, "discrete"), maze_tone_timing_state);
892   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
893   state->maze_tone_timing_state = !state->maze_tone_timing_state;
894   maze_write_discrete(state->discrete, state->maze_tone_timing_state);
876895}
877896
878897
879898static MACHINE_START( maze )
880899{
900   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
901
881902   /* create astable timer for IC B1 */
882903   timer_pulse(machine, MAZE_555_B1_PERIOD, NULL, 0, maze_tone_timing_timer_callback);
883904
884905   /* initialize state of Tone Timing FF, IC C1 */
885   maze_tone_timing_state = 0;
906   state->maze_tone_timing_state = 0;
886907
887908   /* setup for save states */
888   state_save_register_global(machine, maze_tone_timing_state);
909   state_save_register_global(machine, state->maze_tone_timing_state);
889910   state_save_register_postload(machine, maze_update_discrete, NULL);
890911
891912   MACHINE_START_CALL(mw8080bw);
r6740r6741
970991
971992static MACHINE_START( boothill )
972993{
994   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
995
973996   /* setup for save states */
974   state_save_register_global(machine, rev_shift_res);
997   state_save_register_global(machine, state->rev_shift_res);
975998
976999   MACHINE_START_CALL(mw8080bw);
9771000}
r6740r6741
9851008   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_READ(mw8080bw_reversable_shift_result_r)
9861009
9871010   AM_RANGE(0x01, 0x01) AM_WRITE(mw8080bw_reversable_shift_count_w)
988   AM_RANGE(0x02, 0x02) AM_WRITE(mb14241_0_shift_data_w)
1011   AM_RANGE(0x02, 0x02) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
9891012   AM_RANGE(0x03, 0x03) AM_DEVWRITE("discrete", boothill_audio_w)
9901013   AM_RANGE(0x04, 0x04) AM_WRITE(watchdog_reset_w)
9911014   AM_RANGE(0x05, 0x05) AM_DEVWRITE("discrete", midway_tone_generator_lo_w)
r6740r6741
10321055   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
10331056   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
10341057
1035   PORT_START("MUSIC_ADJ")  /* 3 */
1058   PORT_START("MUSIC_ADJ")
10361059   PORT_ADJUSTER( 35, "Music Volume" )
10371060INPUT_PORTS_END
10381061
r6740r6741
10461069   MDRV_MACHINE_START(boothill)
10471070   MDRV_WATCHDOG_TIME_INIT(NSEC(PERIOD_OF_555_MONOSTABLE_NSEC(RES_K(270), CAP_U(10)))) /* 2.97s */
10481071
1072   /* add shifter */
1073   MDRV_MB14241_ADD("mb14241")
1074
10491075   /* audio hardware */
10501076   MDRV_IMPORT_FROM(boothill_audio)
10511077
r6740r6741
10611087
10621088static WRITE8_HANDLER( checkmat_io_w )
10631089{
1064   if (offset & 0x01)  checkmat_audio_w(devtag_get_device(space->machine, "discrete"), 0, data);
1090   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
10651091
1092   if (offset & 0x01)  checkmat_audio_w(state->discrete, 0, data);
1093
10661094   if (offset & 0x02)  watchdog_reset_w(space, 0, data);
10671095}
10681096
r6740r6741
11321160   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED )
11331161   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN1 )
11341162
1135   PORT_START("R309")  /* 4 */
1163   PORT_START("R309")
11361164   PORT_ADJUSTER( 50, "Boom Volume" )
11371165
1138   PORT_START("R411")  /* 5 */
1166   PORT_START("R411")
11391167   PORT_ADJUSTER( 50, "Tone Volume" )
11401168INPUT_PORTS_END
11411169
r6740r6741
11651193#define DESERTGU_DIP_SW_0_1_SET_2_TAG   ("DIPSW01SET2")
11661194
11671195
1168static UINT8 desertgu_controller_select;
1169
1170
11711196static MACHINE_START( desertgu )
11721197{
1198   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
1199
11731200   /* setup for save states */
1174   state_save_register_global(machine, desertgu_controller_select);
1201   state_save_register_global(machine, state->desertgun_controller_select);
11751202
11761203   MACHINE_START_CALL(mw8080bw);
11771204}
11781205
11791206
1180void desertgun_set_controller_select(UINT8 data)
1181{
1182   desertgu_controller_select = data;
1183}
1184
1185
11861207static CUSTOM_INPUT( desertgu_gun_input_r )
11871208{
1209   mw8080bw_state *state = (mw8080bw_state *)field->port->machine->driver_data;
11881210   UINT32 ret;
11891211
1190   if (desertgu_controller_select)
1212   if (state->desertgun_controller_select)
11911213      ret = input_port_read(field->port->machine, DESERTGU_GUN_X_PORT_TAG);
11921214   else
11931215      ret = input_port_read(field->port->machine, DESERTGU_GUN_Y_PORT_TAG);
r6740r6741
11981220
11991221static CUSTOM_INPUT( desertgu_dip_sw_0_1_r )
12001222{
1223   mw8080bw_state *state = (mw8080bw_state *)field->port->machine->driver_data;
12011224   UINT32 ret;
12021225
1203   if (desertgu_controller_select)
1226   if (state->desertgun_controller_select)
12041227      ret = input_port_read(field->port->machine, DESERTGU_DIP_SW_0_1_SET_2_TAG);
12051228   else
12061229      ret = input_port_read(field->port->machine, DESERTGU_DIP_SW_0_1_SET_1_TAG);
r6740r6741
12141237   AM_RANGE(0x00, 0x00) AM_MIRROR(0x04) AM_READ(mw8080bw_shift_result_rev_r)
12151238   AM_RANGE(0x01, 0x01) AM_MIRROR(0x04) AM_READ_PORT("IN0")
12161239   AM_RANGE(0x02, 0x02) AM_MIRROR(0x04) AM_READ_PORT("IN1")
1217   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_READ(mb14241_0_shift_result_r)
1240   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_DEVREAD("mb14241", mb14241_shift_result_r)
12181241
1219   AM_RANGE(0x01, 0x01) AM_WRITE(mb14241_0_shift_count_w)
1220   AM_RANGE(0x02, 0x02) AM_WRITE(mb14241_0_shift_data_w)
1242   AM_RANGE(0x01, 0x01) AM_DEVWRITE("mb14241", mb14241_shift_count_w)
1243   AM_RANGE(0x02, 0x02) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
12211244   AM_RANGE(0x03, 0x03) AM_DEVWRITE("discrete", desertgu_audio_1_w)
12221245   AM_RANGE(0x04, 0x04) AM_WRITE(watchdog_reset_w)
12231246   AM_RANGE(0x05, 0x05) AM_DEVWRITE("discrete", midway_tone_generator_lo_w)
r6740r6741
12841307   MDRV_MACHINE_START(desertgu)
12851308   MDRV_WATCHDOG_TIME_INIT(USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
12861309
1310   /* add shifter */
1311   MDRV_MB14241_ADD("mb14241")
1312
12871313   /* audio hardware */
12881314   MDRV_IMPORT_FROM(desertgu_audio)
12891315
r6740r6741
13341360   AM_RANGE(0x00, 0x00) AM_MIRROR(0x04) AM_READ_PORT("IN0")
13351361   AM_RANGE(0x01, 0x01) AM_MIRROR(0x04) AM_READ_PORT("IN1")
13361362   AM_RANGE(0x02, 0x02) AM_MIRROR(0x04) AM_READ_PORT("IN2")
1337   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_READ(mb14241_0_shift_result_r)
1363   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_DEVREAD("mb14241", mb14241_shift_result_r)
13381364
1339   AM_RANGE(0x01, 0x01) AM_WRITE(mb14241_0_shift_count_w)
1340   AM_RANGE(0x02, 0x02) AM_WRITE(mb14241_0_shift_data_w)
1365   AM_RANGE(0x01, 0x01) AM_DEVWRITE("mb14241", mb14241_shift_count_w)
1366   AM_RANGE(0x02, 0x02) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
13411367   AM_RANGE(0x03, 0x03) AM_DEVWRITE("discrete", dplay_audio_w)
13421368   AM_RANGE(0x04, 0x04) AM_WRITE(watchdog_reset_w)
13431369   AM_RANGE(0x05, 0x05) AM_DEVWRITE("discrete", midway_tone_generator_lo_w)
r6740r6741
14811507   MDRV_CPU_IO_MAP(dplay_io_map)
14821508   MDRV_WATCHDOG_TIME_INIT(USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
14831509
1510   /* add shifter */
1511   MDRV_MB14241_ADD("mb14241")
1512
14841513   /* audio hardware */
14851514   MDRV_IMPORT_FROM(dplay_audio)
14861515
r6740r6741
14961525
14971526static MACHINE_START( gmissile )
14981527{
1528   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
1529
14991530   /* setup for save states */
1500   state_save_register_global(machine, rev_shift_res);
1531   state_save_register_global(machine, state->rev_shift_res);
15011532
15021533   MACHINE_START_CALL(mw8080bw);
15031534}
r6740r6741
15111542   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_READ(mw8080bw_reversable_shift_result_r)
15121543
15131544   AM_RANGE(0x01, 0x01) AM_WRITE(mw8080bw_reversable_shift_count_w)
1514   AM_RANGE(0x02, 0x02) AM_WRITE(mb14241_0_shift_data_w)
1545   AM_RANGE(0x02, 0x02) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
15151546   AM_RANGE(0x03, 0x03) AM_WRITE(gmissile_audio_1_w)
15161547   AM_RANGE(0x04, 0x04) AM_WRITE(watchdog_reset_w)
15171548   AM_RANGE(0x05, 0x05) AM_WRITE(gmissile_audio_2_w)
r6740r6741
15731604   MDRV_MACHINE_START(gmissile)
15741605   MDRV_WATCHDOG_VBLANK_INIT(255) /* really based on a 60Hz clock source */
15751606
1607   /* add shifter */
1608   MDRV_MB14241_ADD("mb14241")
1609
15761610   /* audio hardware */
15771611   MDRV_IMPORT_FROM(gmissile_audio)
15781612
r6740r6741
15881622
15891623static MACHINE_START( m4 )
15901624{
1625   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
1626
15911627   /* setup for save states */
1592   state_save_register_global(machine, rev_shift_res);
1628   state_save_register_global(machine, state->rev_shift_res);
15931629
15941630   MACHINE_START_CALL(mw8080bw);
15951631}
r6740r6741
16031639   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_READ(mw8080bw_reversable_shift_result_r)
16041640
16051641   AM_RANGE(0x01, 0x01) AM_WRITE(mw8080bw_reversable_shift_count_w)
1606   AM_RANGE(0x02, 0x02) AM_WRITE(mb14241_0_shift_data_w)
1642   AM_RANGE(0x02, 0x02) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
16071643   AM_RANGE(0x03, 0x03) AM_WRITE(m4_audio_1_w)
16081644   AM_RANGE(0x04, 0x04) AM_WRITE(watchdog_reset_w)
16091645   AM_RANGE(0x05, 0x05) AM_WRITE(m4_audio_2_w)
r6740r6741
16631699   MDRV_MACHINE_START(m4)
16641700   MDRV_WATCHDOG_TIME_INIT(USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
16651701
1702   /* add shifter */
1703   MDRV_MB14241_ADD("mb14241")
1704
16661705   /* audio hardware */
16671706   MDRV_IMPORT_FROM(m4_audio)
16681707
r6740r6741
16801719#define CLOWNS_CONTROLLER_P2_TAG      ("CONTP2")
16811720
16821721
1683static UINT8 clowns_controller_select;
1684
1685
16861722static MACHINE_START( clowns )
16871723{
1724   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
1725
16881726   /* setup for save states */
1689   state_save_register_global(machine, clowns_controller_select);
1727   state_save_register_global(machine, state->clowns_controller_select);
16901728
16911729   MACHINE_START_CALL(mw8080bw);
16921730}
16931731
16941732
1695void clowns_set_controller_select(UINT8 data)
1696{
1697   clowns_controller_select = data;
1698}
1699
1700
17011733static CUSTOM_INPUT( clowns_controller_r )
17021734{
1735   mw8080bw_state *state = (mw8080bw_state *)field->port->machine->driver_data;
17031736   UINT32 ret;
17041737
1705   if (clowns_controller_select)
1738   if (state->clowns_controller_select)
17061739   {
17071740      ret = input_port_read(field->port->machine, CLOWNS_CONTROLLER_P2_TAG);
17081741   }
r6740r6741
17201753   AM_RANGE(0x00, 0x00) AM_MIRROR(0x04) AM_READ_PORT("IN0")
17211754   AM_RANGE(0x01, 0x01) AM_MIRROR(0x04) AM_READ_PORT("IN1")
17221755   AM_RANGE(0x02, 0x02) AM_MIRROR(0x04) AM_READ_PORT("IN2")
1723   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_READ(mb14241_0_shift_result_r)
1756   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_DEVREAD("mb14241", mb14241_shift_result_r)
17241757
1725   AM_RANGE(0x01, 0x01) AM_WRITE(mb14241_0_shift_count_w)
1726   AM_RANGE(0x02, 0x02) AM_WRITE(mb14241_0_shift_data_w)
1758   AM_RANGE(0x01, 0x01) AM_DEVWRITE("mb14241", mb14241_shift_count_w)
1759   AM_RANGE(0x02, 0x02) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
17271760   AM_RANGE(0x03, 0x03) AM_WRITE(clowns_audio_1_w)
17281761   AM_RANGE(0x04, 0x04) AM_WRITE(watchdog_reset_w)
17291762   AM_RANGE(0x05, 0x05) AM_DEVWRITE("discrete", midway_tone_generator_lo_w)
r6740r6741
18371870   MDRV_MACHINE_START(clowns)
18381871   MDRV_WATCHDOG_TIME_INIT(USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
18391872
1873   /* add shifter */
1874   MDRV_MB14241_ADD("mb14241")
1875
18401876   /* audio hardware */
18411877   MDRV_IMPORT_FROM(clowns_audio)
18421878
r6740r6741
18561892   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0")
18571893   AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1")
18581894   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2")
1859   AM_RANGE(0x03, 0x03) AM_READ(mb14241_0_shift_result_r)
1895   AM_RANGE(0x03, 0x03) AM_DEVREAD("mb14241", mb14241_shift_result_r)
18601896
1861   AM_RANGE(0x01, 0x01) AM_WRITE(mb14241_0_shift_count_w)
1862   AM_RANGE(0x02, 0x02) AM_WRITE(mb14241_0_shift_data_w)
1897   AM_RANGE(0x01, 0x01) AM_DEVWRITE("mb14241", mb14241_shift_count_w)
1898   AM_RANGE(0x02, 0x02) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
18631899   AM_RANGE(0x03, 0x03) AM_DEVWRITE("discrete", spacwalk_audio_1_w)
18641900   AM_RANGE(0x04, 0x04) AM_WRITE(watchdog_reset_w)
18651901   AM_RANGE(0x05, 0x05) AM_DEVWRITE("discrete", midway_tone_generator_lo_w)
r6740r6741
19291965   MDRV_MACHINE_START(clowns)
19301966   MDRV_WATCHDOG_TIME_INIT(USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
19311967
1968   /* add shifter */
1969   MDRV_MB14241_ADD("mb14241")
1970
19321971   /* audio hardware */
19331972   MDRV_IMPORT_FROM(spacwalk_audio)
19341973
r6740r6741
19441983
19451984static ADDRESS_MAP_START( shuffle_io_map, ADDRESS_SPACE_IO, 8 )
19461985   ADDRESS_MAP_GLOBAL_MASK(0xf)   /* yes, 4, and no mirroring on the read handlers */
1947   AM_RANGE(0x01, 0x01) AM_READ(mb14241_0_shift_result_r)
1986   AM_RANGE(0x01, 0x01) AM_DEVREAD("mb14241", mb14241_shift_result_r)
19481987   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN0")
19491988   AM_RANGE(0x03, 0x03) AM_READ(mw8080bw_shift_result_rev_r)
19501989   AM_RANGE(0x04, 0x04) AM_READ_PORT("IN1")
19511990   AM_RANGE(0x05, 0x05) AM_READ_PORT("IN2")
19521991   AM_RANGE(0x06, 0x06) AM_READ_PORT("IN3")
19531992
1954   AM_RANGE(0x01, 0x01) AM_MIRROR(0x08) AM_WRITE(mb14241_0_shift_count_w)
1955   AM_RANGE(0x02, 0x02) AM_MIRROR(0x08) AM_WRITE(mb14241_0_shift_data_w)
1993   AM_RANGE(0x01, 0x01) AM_MIRROR(0x08) AM_DEVWRITE("mb14241", mb14241_shift_count_w)
1994   AM_RANGE(0x02, 0x02) AM_MIRROR(0x08) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
19561995   AM_RANGE(0x04, 0x04) AM_MIRROR(0x08) AM_WRITE(watchdog_reset_w)
19571996   AM_RANGE(0x05, 0x05) AM_MIRROR(0x08) AM_DEVWRITE("discrete", shuffle_audio_1_w)
19581997   AM_RANGE(0x06, 0x06) AM_MIRROR(0x08) AM_DEVWRITE("discrete", shuffle_audio_2_w)
r6740r6741
20072046   MDRV_CPU_IO_MAP(shuffle_io_map)
20082047   MDRV_WATCHDOG_TIME_INIT(USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
20092048
2049   /* add shifter */
2050   MDRV_MB14241_ADD("mb14241")
2051
20102052   /* audio hardware */
20112053   MDRV_IMPORT_FROM(shuffle_audio)
20122054
r6740r6741
20252067   AM_RANGE(0x00, 0x00) AM_MIRROR(0x04) AM_READ_PORT("IN0")
20262068   AM_RANGE(0x01, 0x01) AM_MIRROR(0x04) AM_READ_PORT("IN1")
20272069   AM_RANGE(0x02, 0x02) AM_MIRROR(0x04) AM_READ_PORT("IN2")
2028   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_READ(mb14241_0_shift_result_r)
2070   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_DEVREAD("mb14241", mb14241_shift_result_r)
20292071
2030   AM_RANGE(0x01, 0x01) AM_WRITE(mb14241_0_shift_count_w)
2031   AM_RANGE(0x02, 0x02) AM_WRITE(mb14241_0_shift_data_w)
2072   AM_RANGE(0x01, 0x01) AM_DEVWRITE("mb14241", mb14241_shift_count_w)
2073   AM_RANGE(0x02, 0x02) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
20322074   AM_RANGE(0x03, 0x03) AM_WRITE(dogpatch_audio_w)
20332075   AM_RANGE(0x04, 0x04) AM_WRITE(watchdog_reset_w)
20342076   AM_RANGE(0x05, 0x05) AM_DEVWRITE("discrete", midway_tone_generator_lo_w)
r6740r6741
20922134   /* Midway boards of the era used the same circuit */
20932135   MDRV_WATCHDOG_TIME_INIT(USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
20942136
2137   /* add shifter */
2138   MDRV_MB14241_ADD("mb14241")
2139
20952140   /* audio hardware */
20962141   MDRV_IMPORT_FROM(dogpatch_audio)
20972142
r6740r6741
21092154#define SPCENCTR_STROBE_DUTY_CYCLE   (95)    /* % */
21102155
21112156
2112static UINT8 spcenctr_strobe_state;
2113static UINT8 spcenctr_trench_width;
2114static UINT8 spcenctr_trench_center;
2115static UINT8 spcenctr_trench_slope[16];  /* 16x4 bit RAM */
2116
2117
21182157static TIMER_DEVICE_CALLBACK( spcenctr_strobe_timer_callback )
21192158{
2120   output_set_value("STROBE", param && spcenctr_strobe_state);
2159   mw8080bw_state *state = (mw8080bw_state *)timer->machine->driver_data;
2160   output_set_value("STROBE", param && state->spcenctr_strobe_state);
21212161}
21222162
21232163
21242164static MACHINE_START( spcenctr )
21252165{
2166   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
2167
21262168   /* setup for save states */
2127   state_save_register_global(machine, spcenctr_strobe_state);
2128   state_save_register_global(machine, spcenctr_trench_width);
2129   state_save_register_global(machine, spcenctr_trench_center);
2130   state_save_register_global_array(machine, spcenctr_trench_slope);
2169   state_save_register_global(machine, state->spcenctr_strobe_state);
2170   state_save_register_global(machine, state->spcenctr_trench_width);
2171   state_save_register_global(machine, state->spcenctr_trench_center);
2172   state_save_register_global_array(machine, state->spcenctr_trench_slope);
21312173
21322174   MACHINE_START_CALL(mw8080bw);
21332175}
21342176
2135
2136void spcenctr_set_strobe_state(UINT8 data)
2177#if 0
2178UINT8 spcenctr_get_trench_width( *running_machine *machine )
21372179{
2138   spcenctr_strobe_state = data;
2180   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
2181   return state->spcenctr_trench_width;
21392182}
21402183
21412184
2142UINT8 spcenctr_get_trench_width(void)
2185UINT8 spcenctr_get_trench_center( *running_machine *machine )
21432186{
2144   return spcenctr_trench_width;
2187   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
2188   return state->spcenctr_trench_center;
21452189}
21462190
21472191
2148UINT8 spcenctr_get_trench_center(void)
2192UINT8 spcenctr_get_trench_slope( *running_machine *machine , UINT8 addr )
21492193{
2150   return spcenctr_trench_center;
2194   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
2195   return state->spcenctr_trench_slope[addr & 0x0f];
21512196}
2197#endif
21522198
2153
2154UINT8 spcenctr_get_trench_slope(UINT8 addr)
2155{
2156   return spcenctr_trench_slope[addr & 0x0f];
2157}
2158
2159
21602199static WRITE8_HANDLER( spcenctr_io_w )
21612200{                                    /* A7 A6 A5 A4 A3 A2 A1 A0 */
2201   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
2202
21622203   if ((offset & 0x07) == 0x02)
21632204      watchdog_reset_w(space, 0, data);      /*  -  -  -  -  -  0  1  0 */
21642205
21652206   else if ((offset & 0x5f) == 0x01)
2166      spcenctr_audio_1_w(devtag_get_device(space->machine, "discrete"), 0, data);   /*  -  0  -  0  0  0  0  1 */
2207      spcenctr_audio_1_w(state->discrete, 0, data);   /*  -  0  -  0  0  0  0  1 */
21672208
21682209   else if ((offset & 0x5f) == 0x09)
2169      spcenctr_audio_2_w(devtag_get_device(space->machine, "discrete"), 0, data);   /*  -  0  -  0  1  0  0  1 */
2210      spcenctr_audio_2_w(state->discrete, 0, data);   /*  -  0  -  0  1  0  0  1 */
21702211
21712212   else if ((offset & 0x5f) == 0x11)
2172      spcenctr_audio_3_w(devtag_get_device(space->machine, "discrete"), 0, data);   /*  -  0  -  1  0  0  0  1 */
2213      spcenctr_audio_3_w(state->discrete, 0, data);   /*  -  0  -  1  0  0  0  1 */
21732214
21742215   else if ((offset & 0x07) == 0x03)
21752216   {                                 /*  -  -  -  -  -  0  1  1 */
21762217      UINT8 addr = ((offset & 0xc0) >> 4) | ((offset & 0x18) >> 3);
2177      spcenctr_trench_slope[addr] = data;
2218      state->spcenctr_trench_slope[addr] = data;
21782219   }
21792220   else if ((offset & 0x07) == 0x04)
2180      spcenctr_trench_center = data;         /*  -  -  -  -  -  1  0  0 */
2221      state->spcenctr_trench_center = data;         /*  -  -  -  -  -  1  0  0 */
21812222
21822223   else if ((offset & 0x07) == 0x07)
2183      spcenctr_trench_width = data;         /*  -  -  -  -  -  1  1  1 */
2224      state->spcenctr_trench_width = data;         /*  -  -  -  -  -  1  1  1 */
21842225
21852226   else
21862227      logerror("%04x:  Unmapped I/O port write to %02x = %02x\n", cpu_get_pc(space->cpu), offset, data);
r6740r6741
22822323 *
22832324 *************************************/
22842325
2285static UINT16 phantom2_cloud_counter = 0;
22862326
2287
22882327static MACHINE_START( phantom2 )
22892328{
2329   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
2330
22902331   /* setup for save states */
2291   state_save_register_global(machine, phantom2_cloud_counter);
2332   state_save_register_global(machine, state->phantom2_cloud_counter);
22922333
22932334   MACHINE_START_CALL(mw8080bw);
22942335}
22952336
22962337
2297UINT16 phantom2_get_cloud_counter(void)
2298{
2299   return phantom2_cloud_counter;
2300}
2301
2302
2303void phantom2_set_cloud_counter(UINT16 data)
2304{
2305   phantom2_cloud_counter = data;
2306}
2307
2308
23092338static ADDRESS_MAP_START( phantom2_io_map, ADDRESS_SPACE_IO, 8 )
23102339   ADDRESS_MAP_GLOBAL_MASK(0x7)
23112340   AM_RANGE(0x00, 0x00) AM_MIRROR(0x04) AM_READ(mw8080bw_shift_result_rev_r)
23122341   AM_RANGE(0x01, 0x01) AM_MIRROR(0x04) AM_READ_PORT("IN0")
23132342   AM_RANGE(0x02, 0x02) AM_MIRROR(0x04) AM_READ_PORT("IN1")
2314   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_READ(mb14241_0_shift_result_r)
2343   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_DEVREAD("mb14241", mb14241_shift_result_r)
23152344
2316   AM_RANGE(0x01, 0x01) AM_WRITE(mb14241_0_shift_count_w)
2317   AM_RANGE(0x02, 0x02) AM_WRITE(mb14241_0_shift_data_w)
2345   AM_RANGE(0x01, 0x01) AM_DEVWRITE("mb14241", mb14241_shift_count_w)
2346   AM_RANGE(0x02, 0x02) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
23182347   AM_RANGE(0x04, 0x04) AM_WRITE(watchdog_reset_w)
23192348   AM_RANGE(0x05, 0x05) AM_WRITE(phantom2_audio_1_w)
23202349   AM_RANGE(0x06, 0x06) AM_WRITE(phantom2_audio_2_w)
r6740r6741
23702399   MDRV_VIDEO_UPDATE(phantom2)
23712400   MDRV_VIDEO_EOF(phantom2)
23722401
2402   /* add shifter */
2403   MDRV_MB14241_ADD("mb14241")
2404
23732405   /* audio hardware */
23742406   MDRV_IMPORT_FROM(phantom2_audio)
23752407
r6740r6741
23882420   /* ZV - not too sure why this is needed, I don't see
23892421       anything unusual on the schematics that would cause
23902422       the bits to flip */
2423   mw8080bw_state *state = (mw8080bw_state *)space->machine->driver_data;
23912424
2392   return ~mb14241_0_shift_result_r(space,0);
2425   return ~mb14241_shift_result_r(state->mb14241, 0);
23932426}
23942427
23952428static WRITE8_HANDLER( bowler_lights_1_w )
r6740r6741
24372470   AM_RANGE(0x05, 0x05) AM_READ_PORT("IN2")
24382471   AM_RANGE(0x06, 0x06) AM_READ_PORT("IN3")
24392472
2440   AM_RANGE(0x01, 0x01) AM_WRITE(mb14241_0_shift_count_w)
2441   AM_RANGE(0x02, 0x02) AM_WRITE(mb14241_0_shift_data_w)
2473   AM_RANGE(0x01, 0x01) AM_DEVWRITE("mb14241", mb14241_shift_count_w)
2474   AM_RANGE(0x02, 0x02) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
24422475   AM_RANGE(0x04, 0x04) AM_WRITE(watchdog_reset_w)
24432476   AM_RANGE(0x05, 0x05) AM_DEVWRITE("discrete", bowler_audio_1_w)
24442477   AM_RANGE(0x06, 0x06) AM_WRITE(bowler_audio_2_w)
r6740r6741
25012534   MDRV_CPU_IO_MAP(bowler_io_map)
25022535   MDRV_WATCHDOG_TIME_INIT(USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
25032536
2537   /* add shifter */
2538   MDRV_MB14241_ADD("mb14241")
2539
25042540   /* audio hardware */
25052541   MDRV_IMPORT_FROM(bowler_audio)
25062542
r6740r6741
25182554#define INVADERS_SW6_SW7_PORT_TAG      ("SW6SW7")
25192555#define INVADERS_SW5_PORT_TAG         ("SW5")
25202556
2521static UINT8 invaders_flip_screen = 0;
25222557
2523
25242558static MACHINE_START( invaders )
25252559{
2560   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
2561
25262562   /* setup for save states */
2527   state_save_register_global(machine, invaders_flip_screen);
2563   state_save_register_global(machine, state->invaders_flip_screen);
25282564
25292565   MACHINE_START_CALL(mw8080bw);
25302566}
25312567
25322568
2533UINT8 invaders_is_flip_screen(void)
2534{
2535   return invaders_flip_screen;
2536}
25372569
2538
2539void invaders_set_flip_screen(UINT8 data)
2540{
2541   invaders_flip_screen = data;
2542}
2543
2544
25452570static CUSTOM_INPUT( invaders_coin_input_r )
25462571{
25472572   UINT32 ret = input_port_read(field->port->machine, INVADERS_COIN_INPUT_PORT_TAG);
r6740r6741
26332658   AM_RANGE(0x00, 0x00) AM_MIRROR(0x04) AM_READ_PORT("IN0")
26342659   AM_RANGE(0x01, 0x01) AM_MIRROR(0x04) AM_READ_PORT("IN1")
26352660   AM_RANGE(0x02, 0x02) AM_MIRROR(0x04) AM_READ_PORT("IN2")
2636   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_READ(mb14241_0_shift_result_r)
2661   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_DEVREAD("mb14241", mb14241_shift_result_r)
26372662
2638   AM_RANGE(0x02, 0x02) AM_WRITE(mb14241_0_shift_count_w)
2663   AM_RANGE(0x02, 0x02) AM_DEVWRITE("mb14241", mb14241_shift_count_w)
26392664   AM_RANGE(0x03, 0x03) AM_DEVWRITE("discrete", invaders_audio_1_w)
2640   AM_RANGE(0x04, 0x04) AM_WRITE(mb14241_0_shift_data_w)
2665   AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
26412666   AM_RANGE(0x05, 0x05) AM_DEVWRITE("discrete", invaders_audio_2_w)
26422667   AM_RANGE(0x06, 0x06) AM_WRITE(watchdog_reset_w)
26432668ADDRESS_MAP_END
r6740r6741
27302755   /* video hardware */
27312756   MDRV_VIDEO_UPDATE(invaders)
27322757
2758   /* add shifter */
2759   MDRV_MB14241_ADD("mb14241")
2760
27332761   /* audio hardware */
27342762   MDRV_IMPORT_FROM(invaders_audio)
27352763
r6740r6741
27612789   AM_RANGE(0x00, 0x00) AM_MIRROR(0x04) AM_READ(mw8080bw_shift_result_rev_r)
27622790   AM_RANGE(0x01, 0x01) AM_MIRROR(0x04) AM_READ_PORT("IN0")
27632791   AM_RANGE(0x02, 0x02) AM_MIRROR(0x04) AM_READ_PORT("IN1")
2764   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_READ(mb14241_0_shift_result_r)
2792   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_DEVREAD("mb14241", mb14241_shift_result_r)
27652793
2766   AM_RANGE(0x01, 0x01) AM_WRITE(mb14241_0_shift_count_w)
2767   AM_RANGE(0x02, 0x02) AM_WRITE(mb14241_0_shift_data_w)
2794   AM_RANGE(0x01, 0x01) AM_DEVWRITE("mb14241", mb14241_shift_count_w)
2795   AM_RANGE(0x02, 0x02) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
27682796   AM_RANGE(0x03, 0x03) AM_DEVWRITE("discrete", blueshrk_audio_w)
27692797   AM_RANGE(0x04, 0x04) AM_WRITE(watchdog_reset_w)
27702798ADDRESS_MAP_END
r6740r6741
28062834   MDRV_CPU_IO_MAP(blueshrk_io_map)
28072835   MDRV_WATCHDOG_TIME_INIT(USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
28082836
2837   /* add shifter */
2838   MDRV_MB14241_ADD("mb14241")
2839
28092840   /* audio hardware */
28102841   MDRV_IMPORT_FROM(blueshrk_audio)
28112842
r6740r6741
28392870   AM_RANGE(0x00, 0x00) AM_MIRROR(0x04) AM_READ_PORT("IN0")
28402871   AM_RANGE(0x01, 0x01) AM_MIRROR(0x04) AM_READ_PORT("IN1")
28412872   AM_RANGE(0x02, 0x02) AM_MIRROR(0x04) AM_READ_PORT("IN2")
2842   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_READ(mb14241_0_shift_result_r)
2873   AM_RANGE(0x03, 0x03) AM_MIRROR(0x04) AM_DEVREAD("mb14241", mb14241_shift_result_r)
28432874
28442875   AM_RANGE(0x01, 0x01) AM_DEVWRITE("discrete", invad2ct_audio_3_w)
2845   AM_RANGE(0x02, 0x02) AM_WRITE(mb14241_0_shift_count_w)
2876   AM_RANGE(0x02, 0x02) AM_DEVWRITE("mb14241", mb14241_shift_count_w)
28462877   AM_RANGE(0x03, 0x03) AM_DEVWRITE("discrete", invad2ct_audio_1_w)
2847   AM_RANGE(0x04, 0x04) AM_WRITE(mb14241_0_shift_data_w)
2878   AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
28482879   AM_RANGE(0x05, 0x05) AM_DEVWRITE("discrete", invad2ct_audio_2_w)
28492880   AM_RANGE(0x06, 0x06) AM_WRITE(watchdog_reset_w)
28502881   AM_RANGE(0x07, 0x07) AM_DEVWRITE("discrete", invad2ct_audio_4_w)
r6740r6741
29042935   MDRV_CPU_IO_MAP(invad2ct_io_map)
29052936   MDRV_WATCHDOG_TIME_INIT(USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
29062937
2938   /* add shifter */
2939   MDRV_MB14241_ADD("mb14241")
2940
29072941   /* audio hardware */
29082942   MDRV_IMPORT_FROM(invad2ct_audio)
29092943
src/mame/drivers/vaportra.c
r6740r6741
1414#include "sound/2203intf.h"
1515#include "sound/2151intf.h"
1616#include "sound/okim6295.h"
17#include "deco16ic.h"
17#include "includes/deco16ic.h"
1818
1919VIDEO_START( vaportra );
2020VIDEO_UPDATE( vaportra );
src/mame/drivers/suna8.c
r6740r6741
569569   return 0x02;
570570}
571571
572static WRITE8_HANDLER( sranger_prot_w )
573{
574   /* check code at 0x2ce2 (in sranger), protection is so dire that I can't even exactly
575       estabilish if what I'm doing can be considered or not a kludge... -AS */
576   memory_write_byte(space,0xcd99,0xff);
577}
578
572579static ADDRESS_MAP_START( rranger_map, ADDRESS_SPACE_PROGRAM, 8 )
573580   AM_RANGE(0x0000, 0x7fff) AM_ROM                        // ROM
574581   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")                  // Banked ROM
r6740r6741
577584   AM_RANGE(0xc002, 0xc002) AM_READ_PORT("P1")               // P1 (Inputs)
578585   AM_RANGE(0xc003, 0xc003) AM_READ_PORT("P2")               // P2
579586   AM_RANGE(0xc004, 0xc004) AM_READ(rranger_soundstatus_r   )   // Latch Status?
580   AM_RANGE(0xc200, 0xc200) AM_NOP                        // Protection?
587   AM_RANGE(0xc200, 0xc200) AM_READNOP AM_WRITE(sranger_prot_w)// Protection?
581588   AM_RANGE(0xc280, 0xc280) AM_WRITENOP   // ? NMI Ack
582589   AM_RANGE(0xc280, 0xc280) AM_READ_PORT("DSW1")            // DSW 1
583590   AM_RANGE(0xc2c0, 0xc2c0) AM_READ_PORT("DSW2")            // DSW 2
r6740r6741
821828                                Spark Man
822829***************************************************************************/
823830
824/* Probably wrong: */
825static WRITE8_HANDLER( sparkman_nmi_w )
831/*
832Thrash protection code snippet:
833
8340B48: 3E 81         ld   a,$81
8350B4A: 32 BF C3      ld   ($C3BF),a
8360B4D: 21 10 D0      ld   hl,$C808
8370B50: 11 11 D0      ld   de,$C809
8380B53: ED 5F         ld   a,r  ;check this, pretty pointless
8390B55: 77            ld   (hl),a
8400B56: 01 80 00      ld   bc,$0080
8410B59: ED B0         ldir
8420B5B: 3E 18         ld   a,$18
8430B5D: 32 C4 C3      ld   ($C3C4),a
8440B60: 21 67 13      ld   hl,$0B67
8450B63: 22 00 D0      ld   ($C800),hl
8460B66: C9            ret
847
848*/
849
850static UINT8 suna8_trash_prot, *suna8_wram;
851
852/* This is a command-based protection. */
853static WRITE8_HANDLER( sparkman_cmd_prot_w )
826854{
827   suna8_nmi_enable = data & 0x01;
828   if (data & ~0x01)    logerror("CPU #0 - PC %04X: unknown nmi bits: %02X\n",cpu_get_pc(space->cpu),data);
855   switch(data)
856   {
857      case 0xa6: suna8_nmi_enable = 1; break;
858      case 0x00: suna8_nmi_enable = 0; break;
859      case 0x18: suna8_trash_prot = 0; break;
860      case 0x81: suna8_trash_prot = 1; break;
861      default: logerror("CPU #0 - PC %04X: unknown protection command: %02X\n",cpu_get_pc(space->cpu),data);
862   }
829863}
830864
865static WRITE8_HANDLER( suna8_wram_w )
866{
867   if(!suna8_trash_prot)
868      suna8_wram[offset] = data;
869}
870
831871/*
832872    7654 321-
833873    ---- ---0   Flip Screen
r6740r6741
853893*/
854894static WRITE8_HANDLER( sparkman_spritebank_w )
855895{
856   suna8_spritebank = (data >> 1) & 1;
896   if(data == 0xf7) //???
897      suna8_spritebank = 0;
898   else
899      suna8_spritebank = (data) & 1;
857900   if (data & ~0x02)    logerror("CPU #0 - PC %04X: unknown spritebank bits: %02X\n",cpu_get_pc(space->cpu),data);
858901}
859902
r6740r6741
888931   AM_RANGE(0xc200, 0xc200) AM_WRITE(sparkman_spritebank_w      )   // Sprite RAM Bank
889932   AM_RANGE(0xc280, 0xc280) AM_WRITE(sparkman_rombank_w      )   // ROM Bank (?mirrored up to c2ff?)
890933   AM_RANGE(0xc300, 0xc300) AM_WRITE(sparkman_flipscreen_w      )   // Flip Screen
891   AM_RANGE(0xc380, 0xc380) AM_WRITE(sparkman_nmi_w         )   // ? NMI related ?
934   AM_RANGE(0xc380, 0xc3ff) AM_WRITE(sparkman_cmd_prot_w      )   // Protection
892935   AM_RANGE(0xc400, 0xc400) AM_WRITE(sparkman_leds_w         )   // Leds + Coin Counter
893936   AM_RANGE(0xc500, 0xc500) AM_WRITE(soundlatch_w            )   // To Sound CPU
894937   AM_RANGE(0xc600, 0xc7ff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBxxxx_be_w) AM_BASE_GENERIC(paletteram   )   // Palette (Banked??)
895   AM_RANGE(0xc800, 0xdfff) AM_RAM                           // RAM
938   AM_RANGE(0xc800, 0xdfff) AM_RAM_WRITE(suna8_wram_w) AM_BASE(&suna8_wram)                        // RAM
896939   AM_RANGE(0xe000, 0xffff) AM_READWRITE(suna8_banked_spriteram_r, suna8_banked_spriteram_w   )   // Sprites (Banked)
897940ADDRESS_MAP_END
898941
r6740r6741
20802123   ROM_LOAD( "brickzon.011", 0x00000, 0x10000, CRC(6c54161a) SHA1(ea216d9f45b441acd56b9fed81a83e3bfe299fbd) )
20812124
20822125   ROM_REGION( 0xc0000, "gfx1", ROMREGION_INVERT )   /* Sprites */
2083   ROM_LOAD( "brickzon.002", 0x00000, 0x20000, CRC(241f0659) SHA1(71b577bf7097b3b367d068df42f991d515f9003a) )
2084   ROM_LOAD( "brickzon.001", 0x20000, 0x20000, CRC(6970ada9) SHA1(5cfe5dcf25af7aff67ee5d78eb963d598251025f) )
2085   ROM_LOAD( "brickzon.003", 0x40000, 0x20000, CRC(2e4f194b) SHA1(86da1a582ea274f2af96d3e3e2ac72bcaf3638cb) )
2086   ROM_LOAD( "brickzon.005", 0x60000, 0x20000, CRC(118f8392) SHA1(598fa4df3ae348ec9796cd6d90c3045bec546da3) )
2087   ROM_LOAD( "brickzon.004", 0x80000, 0x20000, CRC(2be5f335) SHA1(dc870a3c5303cb2ea1fea4a25f53db016ed5ecee) )
2088   ROM_LOAD( "brickzon.006", 0xa0000, 0x20000, CRC(bbf31081) SHA1(1fdbd0e0853082345225e18df340184a7a604b78) )
2126   ROM_LOAD( "brickzon.005", 0x00000, 0x20000, CRC(118f8392) SHA1(598fa4df3ae348ec9796cd6d90c3045bec546da3) )
2127   ROM_LOAD( "brickzon.004", 0x20000, 0x20000, CRC(2be5f335) SHA1(dc870a3c5303cb2ea1fea4a25f53db016ed5ecee) )
2128   ROM_LOAD( "brickzon.006", 0x40000, 0x20000, CRC(bbf31081) SHA1(1fdbd0e0853082345225e18df340184a7a604b78) )
2129   ROM_LOAD( "brickzon.002", 0x60000, 0x20000, CRC(241f0659) SHA1(71b577bf7097b3b367d068df42f991d515f9003a) )
2130   ROM_LOAD( "brickzon.001", 0x80000, 0x20000, CRC(6970ada9) SHA1(5cfe5dcf25af7aff67ee5d78eb963d598251025f) )
2131   ROM_LOAD( "brickzon.003", 0xa0000, 0x20000, CRC(2e4f194b) SHA1(86da1a582ea274f2af96d3e3e2ac72bcaf3638cb) )
20892132ROM_END
20902133
20912134ROM_START( brickzn3 )
r6740r6741
22712314}
22722315
22732316/* Working Games */
2274GAME( 1988, rranger,  0,        rranger,  rranger,  suna8,    ROT0,  "SunA (Sharp Image license)", "Rough Ranger (v2.0)", 0)
2317GAME( 1988, sranger,  0,        rranger,  rranger,  suna8,    ROT0,  "SunA", "Super Ranger (v2.0)", 0 )
2318GAME( 1988, rranger,  sranger,  rranger,  rranger,  suna8,    ROT0,  "SunA (Sharp Image license)", "Rough Ranger (v2.0, unprotected, bootleg?)", 0) //protection is patched out in this.
2319GAME( 1988, srangerb, sranger,  rranger,  rranger,  suna8,    ROT0,  "bootleg", "Super Ranger (bootleg)", 0 )
2320GAME( 1988, srangerw, sranger,  rranger,  rranger,  suna8,    ROT0,  "SunA (WDK license)", "Super Ranger (WDK)", 0 )
22752321GAME( 1988, hardhead, 0,        hardhead, hardhead, hardhead, ROT0,  "SunA", "Hard Head" , 0)
22762322GAME( 1988, hardheadb,hardhead, hardhead, hardhead, hardhedb, ROT0,  "bootleg", "Hard Head (bootleg)" , 0)
22772323GAME( 1988, pop_hh,   hardhead, hardhead, hardhead, hardhedb, ROT0,  "bootleg", "Popper (Hard Head bootleg)" , 0)
22782324GAME( 1991, hardhea2, 0,        hardhea2, hardhea2, hardhea2, ROT0,  "SunA", "Hard Head 2 (v2.0)" , 0 )
22792325
22802326/* Non Working Games */
2281GAME( 1988, sranger,  rranger,  rranger,  rranger,  suna8,    ROT0,  "SunA", "Super Ranger (v2.0)", GAME_NOT_WORKING )
2282GAME( 1988, srangerb, rranger,  rranger,  rranger,  suna8,    ROT0,  "bootleg", "Super Ranger (bootleg)", GAME_NOT_WORKING )
2283GAME( 1988, srangerw, rranger,  rranger,  rranger,  suna8,    ROT0,  "SunA (WDK license)", "Super Ranger (WDK)", GAME_NOT_WORKING )
22842327GAME( 1989, sparkman, 0,        sparkman, sparkman, sparkman, ROT0,  "SunA", "Spark Man (v 2.0)", GAME_NOT_WORKING )
22852328GAME( 1990, starfigh, 0,        starfigh, hardhea2, starfigh, ROT90, "SunA", "Star Fighter (v1)", GAME_NOT_WORKING )
22862329GAME( 1992, brickzn,  0,        brickzn,  brickzn,  brickzn,  ROT90, "SunA", "Brick Zone (v5.0)", GAME_NOT_WORKING )
src/mame/drivers/nova2001.c
r6740r6741
121121#include "cpu/z80/z80.h"
122122#include "deprecat.h"
123123#include "sound/ay8910.h"
124#include "nova2001.h"
124#include "includes/nova2001.h"
125125
126126#define MAIN_CLOCK XTAL_12MHz
127127
src/mame/drivers/mermaid.c
r6740r6741
117117#include "cpu/z80/z80.h"
118118#include "sound/ay8910.h"
119119
120extern UINT8* mermaid_videoram;
121extern UINT8* mermaid_colorram;
120122extern UINT8* mermaid_videoram2;
121123extern UINT8* mermaid_bg_scrollram;
122124extern UINT8* mermaid_fg_scrollram;
r6740r6741
161163   AM_RANGE(0x0000, 0x9fff) AM_ROM
162164   AM_RANGE(0xc000, 0xc7ff) AM_RAM
163165   AM_RANGE(0xc800, 0xcbff) AM_RAM_WRITE(mermaid_videoram2_w) AM_BASE(&mermaid_videoram2)
164   AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(mermaid_videoram_w) AM_BASE_GENERIC(videoram)
166   AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(mermaid_videoram_w) AM_BASE(&mermaid_videoram)
165167   AM_RANGE(0xd800, 0xd81f) AM_RAM_WRITE(mermaid_bg_scroll_w) AM_BASE(&mermaid_bg_scrollram)
166168   AM_RANGE(0xd840, 0xd85f) AM_RAM_WRITE(mermaid_fg_scroll_w) AM_BASE(&mermaid_fg_scrollram)
167169   AM_RANGE(0xd880, 0xd8bf) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
168   AM_RANGE(0xdc00, 0xdfff) AM_RAM_WRITE(mermaid_colorram_w) AM_BASE_GENERIC(colorram)
170   AM_RANGE(0xdc00, 0xdfff) AM_RAM_WRITE(mermaid_colorram_w) AM_BASE(&mermaid_colorram)
169171   AM_RANGE(0xe000, 0xe000) AM_READ_PORT("DSW")
170172   AM_RANGE(0xe000, 0xe001) AM_RAM AM_BASE(&mermaid_ay8910_enable)
171173   AM_RANGE(0xe002, 0xe002) AM_WRITENOP   // ???
src/mame/drivers/gaelco3d.c
r6740r6741
144144
145145#include "driver.h"
146146#include "cpu/m68000/m68000.h"
147#include "gaelco3d.h"
147#include "includes/gaelco3d.h"
148148#include "cpu/tms32031/tms32031.h"
149149#include "cpu/adsp2100/adsp2100.h"
150#include "machine/eeprom.h"
150#include "machine/eepromdev.h"
151151#include "sound/dmadac.h"
152152
153153#define   LOG            0
r6740r6741
164164static UINT8 analog_ports[4];
165165static UINT8 framenum;
166166
167static emu_timer *adsp_autobuffer_timer;
167static const device_config *adsp_autobuffer_timer;
168168static UINT16 *adsp_control_regs;
169169static UINT16 *adsp_fastram_base;
170170static UINT8 adsp_ireg;
r6740r6741
172172static const device_config *dmadac[SOUND_CHANNELS];
173173
174174static void adsp_tx_callback(const device_config *device, int port, INT32 data);
175static TIMER_CALLBACK( adsp_autobuffer_irq );
176175
177176
178177/*************************************
r6740r6741
181180 *
182181 *************************************/
183182
183static MACHINE_START( gaelco3d )
184{
185   /* Save state support */
186   state_save_register_global(machine, sound_data);
187   state_save_register_global(machine, sound_status);
188   state_save_register_global_array(machine, analog_ports);
189   state_save_register_global(machine, framenum);
190   state_save_register_global(machine, adsp_ireg);
191   state_save_register_global(machine, adsp_ireg_base);
192   state_save_register_global(machine, adsp_incs);
193   state_save_register_global(machine, adsp_size);
194}
195
196
184197static MACHINE_RESET( common )
185198{
186199   UINT16 *src;
r6740r6741
197210   }
198211
199212   /* allocate a timer for feeding the autobuffer */
200   adsp_autobuffer_timer = timer_alloc(machine, adsp_autobuffer_irq, NULL);
213   adsp_autobuffer_timer = devtag_get_device(machine, "adsp_timer");
201214
202215   memory_configure_bank(machine, "bank1", 0, 256, memory_region(machine, "user1"), 0x4000);
203216   memory_set_bank(machine, "bank1", 0);
r6740r6741
211224      sprintf(buffer, "dac%d", i + 1);
212225      dmadac[i] = devtag_get_device(machine, buffer);
213226   }
214
215   /* Save state support */
216   state_save_register_global(machine, sound_data);
217   state_save_register_global(machine, sound_status);
218   state_save_register_global_array(machine, analog_ports);
219   state_save_register_global(machine, framenum);
220   state_save_register_global(machine, adsp_ireg);
221   state_save_register_global(machine, adsp_ireg_base);
222   state_save_register_global(machine, adsp_incs);
223   state_save_register_global(machine, adsp_size);
224227}
225228
226229
r6740r6741
228231{
229232   MACHINE_RESET_CALL( common );
230233   tms_offset_xor = 0;
231   state_save_register_global(machine, tms_offset_xor);
232234}
233235
234236
r6740r6741
236238{
237239   MACHINE_RESET_CALL( common );
238240   tms_offset_xor = BYTE_XOR_BE(0);
239   state_save_register_global(machine, tms_offset_xor);
240241}
241242
242243
r6740r6741
267268 *
268269 *************************************/
269270
270static READ16_HANDLER( eeprom_data_r )
271static READ16_DEVICE_HANDLER( eeprom_data_r )
271272{
272273   UINT16 result = 0xffff;
273   if (eeprom_read_bit())
274   if (eepromdev_read_bit(device))
274275      result ^= 0x0004;
275276   if (LOG)
276277      logerror("eeprom_data_r(%02X)\n", result);
r6740r6741
278279}
279280
280281
281static WRITE16_HANDLER( eeprom_data_w )
282static WRITE16_DEVICE_HANDLER( eeprom_data_w )
282283{
283284   if (ACCESSING_BITS_0_7)
284      eeprom_write_bit(data & 0x01);
285      eepromdev_write_bit(device, data & 0x01);
285286}
286287
287288
288static WRITE16_HANDLER( eeprom_clock_w )
289static WRITE16_DEVICE_HANDLER( eeprom_clock_w )
289290{
290291   if (ACCESSING_BITS_0_7)
291      eeprom_set_clock_line((data & 0x01) ? ASSERT_LINE : CLEAR_LINE);
292      eepromdev_set_clock_line(device, (data & 0x01) ? ASSERT_LINE : CLEAR_LINE);
292293}
293294
294295
295static WRITE16_HANDLER( eeprom_cs_w )
296static WRITE16_DEVICE_HANDLER( eeprom_cs_w )
296297{
297298   if (ACCESSING_BITS_0_7)
298      eeprom_set_cs_line((data & 0x01) ? CLEAR_LINE : ASSERT_LINE);
299      eepromdev_set_cs_line(device, (data & 0x01) ? CLEAR_LINE : ASSERT_LINE);
299300}
300301
301302
r6740r6741
530531         if ((data & 0x0800) == 0)
531532         {
532533            dmadac_enable(&dmadac[0], SOUND_CHANNELS, 0);
533            timer_adjust_oneshot(adsp_autobuffer_timer, attotime_never, 0);
534            timer_device_adjust_oneshot(adsp_autobuffer_timer, attotime_never, 0);
534535         }
535536         break;
536537
r6740r6741
539540         if ((data & 0x0002) == 0)
540541         {
541542            dmadac_enable(&dmadac[0], SOUND_CHANNELS, 0);
542            timer_adjust_oneshot(adsp_autobuffer_timer, attotime_never, 0);
543            timer_device_adjust_oneshot(adsp_autobuffer_timer, attotime_never, 0);
543544         }
544545         break;
545546
r6740r6741
568569 *
569570 *************************************/
570571
571static TIMER_CALLBACK( adsp_autobuffer_irq )
572static TIMER_DEVICE_CALLBACK( adsp_autobuffer_irq )
572573{
573574   /* get the index register */
574   int reg = cpu_get_reg(cputag_get_cpu(machine, "adsp"), ADSP2100_I0 + adsp_ireg);
575   int reg = cpu_get_reg(cputag_get_cpu(timer->machine, "adsp"), ADSP2100_I0 + adsp_ireg);
575576
576577   /* copy the current data into the buffer */
577578// logerror("ADSP buffer: I%d=%04X incs=%04X size=%04X\n", adsp_ireg, reg, adsp_incs, adsp_size);
r6740r6741
588589      reg = adsp_ireg_base;
589590
590591      /* generate the (internal, thats why the pulse) irq */
591      generic_pulse_irq_line(cputag_get_cpu(machine, "adsp"), ADSP2105_IRQ1);
592      generic_pulse_irq_line(cputag_get_cpu(timer->machine, "adsp"), ADSP2105_IRQ1);
592593   }
593594
594595   /* store it */
595   cpu_set_reg(cputag_get_cpu(machine, "adsp"), ADSP2100_I0 + adsp_ireg, reg);
596   cpu_set_reg(cputag_get_cpu(timer->machine, "adsp"), ADSP2100_I0 + adsp_ireg, reg);
596597}
597598
598599
r6740r6741
647648         /* fire off a timer wich will hit every half-buffer */
648649         sample_period = attotime_div(attotime_mul(sample_period, adsp_size), SOUND_CHANNELS * adsp_incs);
649650
650         timer_adjust_periodic(adsp_autobuffer_timer, sample_period, 0, sample_period);
651         timer_device_adjust_periodic(adsp_autobuffer_timer, sample_period, 0, sample_period);
651652
652653         return;
653654      }
r6740r6741
659660   dmadac_enable(&dmadac[0], SOUND_CHANNELS, 0);
660661
661662   /* remove timer */
662   timer_adjust_oneshot(adsp_autobuffer_timer, attotime_never, 0);
663   timer_device_adjust_oneshot(adsp_autobuffer_timer, attotime_never, 0);
663664}
664665
665666
r6740r6741
741742   AM_RANGE(0x51003c, 0x51003d) AM_READ_PORT("IN3")
742743   AM_RANGE(0x510040, 0x510041) AM_WRITE(sound_data_w)
743744   AM_RANGE(0x510042, 0x510043) AM_READ(sound_status_r)
744   AM_RANGE(0x510100, 0x510101) AM_READ(eeprom_data_r)
745   AM_RANGE(0x510100, 0x510101) AM_DEVREAD("eeprom", eeprom_data_r)
745746   AM_RANGE(0x510100, 0x510101) AM_WRITE(irq_ack_w)
746747   AM_RANGE(0x51010a, 0x51010b) AM_WRITENOP      // very noisy when starting a new game
747   AM_RANGE(0x510110, 0x510113) AM_WRITE(eeprom_data_w)
748   AM_RANGE(0x510110, 0x510113) AM_DEVWRITE("eeprom", eeprom_data_w)
748749   AM_RANGE(0x510116, 0x510117) AM_WRITE(tms_control3_w)
749   AM_RANGE(0x510118, 0x51011b) AM_WRITE(eeprom_clock_w)
750   AM_RANGE(0x510120, 0x510123) AM_WRITE(eeprom_cs_w)
750   AM_RANGE(0x510118, 0x51011b) AM_DEVWRITE("eeprom", eeprom_clock_w)
751   AM_RANGE(0x510120, 0x510123) AM_DEVWRITE("eeprom", eeprom_cs_w)
751752   AM_RANGE(0x51012a, 0x51012b) AM_WRITE(tms_reset_w)
752753   AM_RANGE(0x510132, 0x510133) AM_WRITE(tms_irq_w)
753754   AM_RANGE(0x510146, 0x510147) AM_WRITE(led_0_w)
r6740r6741
768769   AM_RANGE(0x51003c, 0x51003f) AM_READ_PORT("IN3")
769770   AM_RANGE(0x510040, 0x510043) AM_READ16(sound_status_r, 0x0000ffff)
770771   AM_RANGE(0x510040, 0x510043) AM_WRITE16(sound_data_w, 0xffff0000)
771   AM_RANGE(0x510100, 0x510103) AM_READ16(eeprom_data_r, 0xffff0000)
772   AM_RANGE(0x510100, 0x510103) AM_DEVREAD16("eeprom", eeprom_data_r, 0xffff0000)
772773   AM_RANGE(0x510100, 0x510103) AM_WRITE16(irq_ack_w, 0xffff0000)
773774   AM_RANGE(0x510104, 0x510107) AM_WRITE(unknown_107_w)
774   AM_RANGE(0x510110, 0x510113) AM_WRITE16(eeprom_data_w, 0x0000ffff)
775   AM_RANGE(0x510110, 0x510113) AM_DEVWRITE16("eeprom", eeprom_data_w, 0x0000ffff)
775776   AM_RANGE(0x510114, 0x510117) AM_WRITE16(tms_control3_w, 0x0000ffff)
776   AM_RANGE(0x510118, 0x51011b) AM_WRITE16(eeprom_clock_w, 0x0000ffff)
777   AM_RANGE(0x510120, 0x510123) AM_WRITE16(eeprom_cs_w, 0x0000ffff)
777   AM_RANGE(0x510118, 0x51011b) AM_DEVWRITE16("eeprom", eeprom_clock_w, 0x0000ffff)
778   AM_RANGE(0x510120, 0x510123) AM_DEVWRITE16("eeprom", eeprom_cs_w, 0x0000ffff)
778779   AM_RANGE(0x510124, 0x510127) AM_WRITE(unknown_127_w)
779780   AM_RANGE(0x510128, 0x51012b) AM_WRITE16(tms_reset_w, 0x0000ffff)
780781   AM_RANGE(0x510130, 0x510133) AM_WRITE16(tms_irq_w, 0x0000ffff)
r6740r6741
804805   AM_RANGE(0x0000, 0x0001) AM_WRITE(adsp_rombank_w)
805806   AM_RANGE(0x0000, 0x1fff) AM_ROMBANK("bank1")
806807   AM_RANGE(0x2000, 0x2000) AM_READWRITE(sound_data_r, sound_status_w)
807   AM_RANGE(0x3800, 0x39ff) AM_RAM   AM_BASE(&adsp_fastram_base)   /* 512 words internal RAM */
808   AM_RANGE(0x3800, 0x39ff) AM_RAM AM_BASE(&adsp_fastram_base)   /* 512 words internal RAM */
808809   AM_RANGE(0x3fe0, 0x3fff) AM_WRITE(adsp_control_w) AM_BASE(&adsp_control_regs)
809810ADDRESS_MAP_END
810811
r6740r6741
966967   MDRV_CPU_PROGRAM_MAP(adsp_program_map)
967968   MDRV_CPU_DATA_MAP(adsp_data_map)
968969
970   MDRV_MACHINE_START(gaelco3d)
969971   MDRV_MACHINE_RESET(gaelco3d)
970   MDRV_NVRAM_HANDLER(93C66B)
971972
973   MDRV_EEPROM_93C66B_NODEFAULT_ADD("eeprom")
974
972975   MDRV_QUANTUM_TIME(HZ(6000))
973976
977   MDRV_TIMER_ADD("adsp_timer", adsp_autobuffer_irq)
978
974979   /* video hardware */
975980   MDRV_SCREEN_ADD("screen", RASTER)
976981   MDRV_SCREEN_REFRESH_RATE(60)
src/mame/drivers/avalnche.c
r6740r6741
3131#include "cpu/m6502/m6502.h"
3232#include "deprecat.h"
3333#include "sound/discrete.h"
34#include "avalnche.h"
34#include "includes/avalnche.h"
3535
3636#include "avalnche.lh"
3737
src/mame/drivers/gstriker.c
r6740r6741
3535#include "driver.h"
3636#include "cpu/z80/z80.h"
3737#include "cpu/m68000/m68000.h"
38#include "gstriker.h"
38#include "includes/gstriker.h"
3939#include "sound/2610intf.h"
4040
4141/*** README INFO **************************************************************
src/mame/drivers/snk.c
r6740r6741
260260
261261#include "driver.h"
262262#include "cpu/z80/z80.h"
263#include "snk.h"
263#include "includes/snk.h"
264264#include "sound/snkwave.h"
265265#include "sound/ay8910.h"
266266#include "sound/3526intf.h"
src/mame/drivers/namconb1.c
r6740r6741
271271#include "driver.h"
272272#include "cpu/m68000/m68000.h"
273273#include "deprecat.h"
274#include "namconb1.h"
275#include "namcos2.h"
276#include "namcoic.h"
274#include "includes/namconb1.h"
275#include "includes/namcos2.h"
276#include "includes/namcoic.h"
277277#include "sound/c352.h"
278278#include "cpu/m37710/m37710.h"
279279
src/mame/drivers/fcrash.c
r6740r6741
3535#include "driver.h"
3636#include "cpu/z80/z80.h"
3737#include "cpu/m68000/m68000.h"
38#include "cps1.h"
38#include "includes/cps1.h"
3939#include "sound/2203intf.h"
4040#include "sound/msm5205.h"
4141
4242
43static int sample_buffer1, sample_buffer2;
44static int sample_select1, sample_select2;
45
4643static WRITE16_HANDLER( fcrash_soundlatch_w )
4744{
45   cps_state *state = (cps_state *)space->machine->driver_data;
46
4847   if (ACCESSING_BITS_0_7)
4948   {
50      soundlatch_w(space,0,data & 0xff);
51      cputag_set_input_line(space->machine, "soundcpu", 0, HOLD_LINE);
49      soundlatch_w(space, 0, data & 0xff);
50      cpu_set_input_line(state->audiocpu, 0, HOLD_LINE);
5251   }
5352}
5453
5554static WRITE8_HANDLER( fcrash_snd_bankswitch_w )
5655{
57   UINT8 *RAM = memory_region(space->machine, "soundcpu");
58   int bankaddr;
56   cps_state *state = (cps_state *)space->machine->driver_data;
5957
60   sound_set_output_gain(devtag_get_device(space->machine, "msm1"), 0, (data & 0x08) ? 0.0 : 1.0);
61   sound_set_output_gain(devtag_get_device(space->machine, "msm2"), 0, (data & 0x10) ? 0.0 : 1.0);
58   sound_set_output_gain(state->msm_1, 0, (data & 0x08) ? 0.0 : 1.0);
59   sound_set_output_gain(state->msm_2, 0, (data & 0x10) ? 0.0 : 1.0);
6260
63   bankaddr = ((data & 7) * 0x4000);
64   memory_set_bankptr(space->machine, "bank1",&RAM[0x10000 + bankaddr]);
61   memory_set_bank(space->machine, "bank1", data & 0x07);
6562}
6663
67static void m5205_int1(const device_config *device)
64static void m5205_int1( const device_config *device )
6865{
69   msm5205_data_w(device, sample_buffer1 & 0x0F);
70   sample_buffer1 >>= 4;
71   sample_select1 ^= 1;
72   if (sample_select1 == 0)
73      cputag_set_input_line(device->machine, "soundcpu", INPUT_LINE_NMI, PULSE_LINE);
66   cps_state *state = (cps_state *)device->machine->driver_data;
67
68   msm5205_data_w(device, state->sample_buffer1 & 0x0f);
69   state->sample_buffer1 >>= 4;
70   state->sample_select1 ^= 1;
71   if (state->sample_select1 == 0)
72      cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
7473}
7574
76static void m5205_int2(const device_config *device)
75static void m5205_int2( const device_config *device )
7776{
78   msm5205_data_w(device, sample_buffer2 & 0x0F);
79   sample_buffer2 >>= 4;
80   sample_select2 ^= 1;
77   cps_state *state = (cps_state *)device->machine->driver_data;
78
79   msm5205_data_w(device, state->sample_buffer2 & 0x0f);
80   state->sample_buffer2 >>= 4;
81   state->sample_select2 ^= 1;
8182}
8283
8384
8485static WRITE8_HANDLER( fcrash_msm5205_0_data_w )
8586{
86    sample_buffer1 = data;
87   cps_state *state = (cps_state *)space->machine->driver_data;
88   state->sample_buffer1 = data;
8789}
8890
8991static WRITE8_HANDLER( fcrash_msm5205_1_data_w )
9092{
91    sample_buffer2 = data;
93   cps_state *state = (cps_state *)space->machine->driver_data;
94   state->sample_buffer2 = data;
9295}
9396
9497
r6740r6741
9699/* not verified */
97100#define CPS1_ROWSCROLL_OFFS     (0x20/2)    /* base of row scroll offsets in other RAM */
98101
99static void fcrash_update_transmasks(void)
102static void fcrash_update_transmasks( running_machine *machine )
100103{
104   cps_state *state = (cps_state *)machine->driver_data;
101105   int i;
102106   int priority[4];
103107
104   priority[0]=0x26;
105   priority[1]=0x30;
106   priority[2]=0x28;
107   priority[3]=0x32;
108   priority[0] = 0x26;
109   priority[1] = 0x30;
110   priority[2] = 0x28;
111   priority[3] = 0x32;
108112
109   for (i = 0;i < 4;i++)
113   for (i = 0; i < 4; i++)
110114   {
111115      int mask;
112116
113117      /* Get transparency registers */
114118      if (priority[i])
115         mask = cps1_cps_b_regs[priority[i]/2] ^ 0xffff;
116      else mask = 0xffff;   /* completely transparent if priority masks not defined (mercs, qad) */
119         mask = state->cps_b_regs[priority[i] / 2] ^ 0xffff;
120      else
121         mask = 0xffff;   /* completely transparent if priority masks not defined (mercs, qad) */
117122
118      tilemap_set_transmask(cps1_bg_tilemap[0],i,mask,0x8000);
119      tilemap_set_transmask(cps1_bg_tilemap[1],i,mask,0x8000);
120      tilemap_set_transmask(cps1_bg_tilemap[2],i,mask,0x8000);
123      tilemap_set_transmask(state->bg_tilemap[0], i, mask, 0x8000);
124      tilemap_set_transmask(state->bg_tilemap[1], i, mask, 0x8000);
125      tilemap_set_transmask(state->bg_tilemap[2], i, mask, 0x8000);
121126   }
122127}
123128
124static void fcrash_render_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
129static void fcrash_render_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
125130{
131   cps_state *state = (cps_state *)machine->driver_data;
126132   int pos;
127   int base=0x50c8/2;
133   int base = 0x50c8 / 2;
128134
129135   // sprite base registers need hooking up properly.. on fcrash it is NOT cps1_cps_a_regs[0]
130136   //  on kodb, it might still be, unless that's just a leftover and it writes somewhere else too
131//  if (cps1_cps_a_regs[0] & 0x00ff) base=0x10c8/2;
132//  printf("cps1_cps_a_regs %04x\n", cps1_cps_a_regs[0]);
137//  if (state->cps_a_regs[0] & 0x00ff) base = 0x10c8/2;
138//  printf("cps1_cps_a_regs %04x\n", state->cps_a_regs[0]);
133139
134   for (pos=0x1ffc;pos>=0x0000;pos-=4)
140   for (pos = 0x1ffc; pos >= 0x0000; pos -= 4)
135141   {
136142      int tileno;
137143      int xpos;
138144      int ypos;
139      int flipx,flipy;
145      int flipx, flipy;
140146      int colour;
141147
142      tileno = cps1_gfxram[base+pos];
143      xpos   = cps1_gfxram[base+pos+2];
144      ypos   = cps1_gfxram[base+pos-1]&0xff;
145      flipx  = cps1_gfxram[base+pos+1]&0x20;
146      flipy  = cps1_gfxram[base+pos+1]&0x40;
147      colour = cps1_gfxram[base+pos+1]&0x1f;
148      ypos = 256-ypos;
148      tileno = state->gfxram[base +pos];
149      xpos   = state->gfxram[base +pos + 2];
150      ypos   = state->gfxram[base +pos - 1] & 0xff;
151      flipx  = state->gfxram[base +pos + 1] & 0x20;
152      flipy  = state->gfxram[base +pos + 1] & 0x40;
153      colour = state->gfxram[base +pos + 1] & 0x1f;
154      ypos = 256 - ypos;
149155
150      pdrawgfx_transpen(bitmap,cliprect,machine->gfx[2],tileno,colour,flipx,flipy,xpos+49,ypos-16,machine->priority_bitmap,0x02,15);
156      pdrawgfx_transpen(bitmap, cliprect, machine->gfx[2], tileno, colour, flipx, flipy, xpos + 49, ypos - 16, machine->priority_bitmap, 0x02, 15);
151157
152158   }
153159
154160}
155161
156static void fcrash_render_layer(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int layer,int primask)
162static void fcrash_render_layer( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer, int primask )
157163{
164   cps_state *state = (cps_state *)machine->driver_data;
165
158166   switch (layer)
159167   {
160168      case 0:
161         fcrash_render_sprites(machine,bitmap,cliprect);
169         fcrash_render_sprites(machine, bitmap, cliprect);
162170         break;
163171      case 1:
164172      case 2:
165173      case 3:
166         tilemap_draw(bitmap,cliprect,cps1_bg_tilemap[layer-1],TILEMAP_DRAW_LAYER1,primask);
174         tilemap_draw(bitmap, cliprect, state->bg_tilemap[layer - 1], TILEMAP_DRAW_LAYER1, primask);
167175         break;
168176   }
169177}
170178
171static void fcrash_render_high_layer(bitmap_t *bitmap, const rectangle *cliprect, int layer)
179static void fcrash_render_high_layer( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer )
172180{
181   cps_state *state = (cps_state *)machine->driver_data;
182
173183   switch (layer)
174184   {
175185      case 0:
r6740r6741
178188      case 1:
179189      case 2:
180190      case 3:
181         tilemap_draw(NULL,cliprect,cps1_bg_tilemap[layer-1],TILEMAP_DRAW_LAYER0,1);
191         tilemap_draw(NULL, cliprect, state->bg_tilemap[layer - 1], TILEMAP_DRAW_LAYER0, 1);
182192         break;
183193   }
184194}
185195
186static void fcrash_build_palette(running_machine *machine)
196static void fcrash_build_palette( running_machine *machine )
187197{
198   cps_state *state = (cps_state *)machine->driver_data;
188199   int offset;
189200
190   for (offset = 0; offset < 32*6*16; offset++)
201   for (offset = 0; offset < 32 * 6 * 16; offset++)
191202   {
192      int palette = cps1_gfxram[0x14000/2 + offset];
203      int palette = state->gfxram[0x14000 / 2 + offset];
193204      int r, g, b, bright;
194205
195206      // from my understanding of the schematics, when the 'brightness'
196207      // component is set to 0 it should reduce brightness to 1/3
197208
198      bright = 0x0f + ((palette>>12)<<1);
209      bright = 0x0f + ((palette >> 12) << 1);
199210
200      r = ((palette>>8)&0x0f) * 0x11 * bright / 0x2d;
201      g = ((palette>>4)&0x0f) * 0x11 * bright / 0x2d;
202      b = ((palette>>0)&0x0f) * 0x11 * bright / 0x2d;
211      r = ((palette >> 8) & 0x0f) * 0x11 * bright / 0x2d;
212      g = ((palette >> 4) & 0x0f) * 0x11 * bright / 0x2d;
213      b = ((palette >> 0) & 0x0f) * 0x11 * bright / 0x2d;
203214
204215      palette_set_color (machine, offset, MAKE_RGB(r, g, b));
205216   }
r6740r6741
207218
208219static VIDEO_UPDATE( fcrash )
209220{
210   int layercontrol,l0,l1,l2,l3;
211   int videocontrol=cps1_cps_a_regs[0x22/2];
221   cps_state *state = (cps_state *)screen->machine->driver_data;
222   int layercontrol, l0, l1, l2, l3;
223   int videocontrol = state->cps_a_regs[0x22 / 2];
212224
213225
214226   flip_screen_set(screen->machine, videocontrol & 0x8000);
215227
216    layercontrol = cps1_cps_b_regs[0x20/2];
228    layercontrol = state->cps_b_regs[0x20 / 2];
217229
218230   /* Get video memory base registers */
219   cps1_get_video_base();
231   cps1_get_video_base(screen->machine);
220232
221233   /* Build palette */
222234   fcrash_build_palette(screen->machine);
223235
224   fcrash_update_transmasks();
236   fcrash_update_transmasks(screen->machine);
225237
226   tilemap_set_scrollx(cps1_bg_tilemap[0],0,cps1_scroll1x-62);
227   tilemap_set_scrolly(cps1_bg_tilemap[0],0,cps1_scroll1y);
238   tilemap_set_scrollx(state->bg_tilemap[0], 0, state->scroll1x - 62);
239   tilemap_set_scrolly(state->bg_tilemap[0], 0, state->scroll1y);
240
228241   if (videocontrol & 0x01)   /* linescroll enable */
229242   {
230      int scrly=-cps1_scroll2y;
243      int scrly = -state->scroll2y;
231244      int i;
232245      int otheroffs;
233246
234      tilemap_set_scroll_rows(cps1_bg_tilemap[1],1024);
247      tilemap_set_scroll_rows(state->bg_tilemap[1], 1024);
235248
236      otheroffs = cps1_cps_a_regs[CPS1_ROWSCROLL_OFFS];
249      otheroffs = state->cps_a_regs[CPS1_ROWSCROLL_OFFS];
237250
238      for (i = 0;i < 256;i++)
239         tilemap_set_scrollx(cps1_bg_tilemap[1],(i - scrly) & 0x3ff,cps1_scroll2x + cps1_other[(i + otheroffs) & 0x3ff]);
251      for (i = 0; i < 256; i++)
252         tilemap_set_scrollx(state->bg_tilemap[1], (i - scrly) & 0x3ff, state->scroll2x + state->other[(i + otheroffs) & 0x3ff]);
240253   }
241254   else
242255   {
243      tilemap_set_scroll_rows(cps1_bg_tilemap[1],1);
244      tilemap_set_scrollx(cps1_bg_tilemap[1],0,cps1_scroll2x-60);
256      tilemap_set_scroll_rows(state->bg_tilemap[1], 1);
257      tilemap_set_scrollx(state->bg_tilemap[1], 0, state->scroll2x - 60);
245258   }
246   tilemap_set_scrolly(cps1_bg_tilemap[1],0,cps1_scroll2y);
247   tilemap_set_scrollx(cps1_bg_tilemap[2],0,cps1_scroll3x-64);
248   tilemap_set_scrolly(cps1_bg_tilemap[2],0,cps1_scroll3y);
259   tilemap_set_scrolly(state->bg_tilemap[1], 0, state->scroll2y);
260   tilemap_set_scrollx(state->bg_tilemap[2], 0, state->scroll3x - 64);
261   tilemap_set_scrolly(state->bg_tilemap[2], 0, state->scroll3y);
249262
250263
251264   /* turn all tilemaps on regardless of settings in get_video_base() */
252265   /* write a custom get_video_base for this bootleg hardware? */
253   tilemap_set_enable(cps1_bg_tilemap[0],1);
254   tilemap_set_enable(cps1_bg_tilemap[1],1);
255   tilemap_set_enable(cps1_bg_tilemap[2],1);
266   tilemap_set_enable(state->bg_tilemap[0], 1);
267   tilemap_set_enable(state->bg_tilemap[1], 1);
268   tilemap_set_enable(state->bg_tilemap[2], 1);
256269
257270   /* Blank screen */
258   bitmap_fill(bitmap,cliprect,0xbff);
271   bitmap_fill(bitmap, cliprect, 0xbff);
259272
260273   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
261274   l0 = (layercontrol >> 0x06) & 03;
r6740r6741
263276   l2 = (layercontrol >> 0x0a) & 03;
264277   l3 = (layercontrol >> 0x0c) & 03;
265278
266   fcrash_render_layer(screen->machine,bitmap,cliprect,l0,0);
267   if (l1 == 0) fcrash_render_high_layer(bitmap,cliprect,l0);
268   fcrash_render_layer(screen->machine,bitmap,cliprect,l1,0);
269   if (l2 == 0) fcrash_render_high_layer(bitmap,cliprect,l1);
270   fcrash_render_layer(screen->machine,bitmap,cliprect,l2,0);
271   if (l3 == 0) fcrash_render_high_layer(bitmap,cliprect,l2);
272   fcrash_render_layer(screen->machine,bitmap,cliprect,l3,0);
279   fcrash_render_layer(screen->machine, bitmap, cliprect, l0, 0);
273280
281   if (l1 == 0)
282      fcrash_render_high_layer(screen->machine, bitmap, cliprect, l0);
274283
284   fcrash_render_layer(screen->machine, bitmap, cliprect, l1, 0);
285
286   if (l2 == 0)
287      fcrash_render_high_layer(screen->machine, bitmap, cliprect, l1);
288
289   fcrash_render_layer(screen->machine, bitmap, cliprect, l2, 0);
290
291   if (l3 == 0)
292      fcrash_render_high_layer(screen->machine, bitmap, cliprect, l2);
293
294   fcrash_render_layer(screen->machine, bitmap, cliprect, l3, 0);
295
275296   return 0;
276297}
277298
278299// doesn't have the scroll offsets like fcrash
279300static VIDEO_UPDATE( kodb )
280301{
281   int layercontrol,l0,l1,l2,l3;
282   int videocontrol=cps1_cps_a_regs[0x22/2];
302   cps_state *state = (cps_state *)screen->machine->driver_data;
303   int layercontrol, l0, l1, l2, l3;
304   int videocontrol = state->cps_a_regs[0x22 / 2];
283305
284
285306   flip_screen_set(screen->machine, videocontrol & 0x8000);
286307
287    layercontrol = cps1_cps_b_regs[0x20/2];
308    layercontrol = state->cps_b_regs[0x20 / 2];
288309
289310   /* Get video memory base registers */
290   cps1_get_video_base();
311   cps1_get_video_base(screen->machine);
291312
292313   /* Build palette */
293314   fcrash_build_palette(screen->machine);
294315
295   fcrash_update_transmasks();
316   fcrash_update_transmasks(screen->machine);
296317
297   tilemap_set_scrollx(cps1_bg_tilemap[0],0,cps1_scroll1x);
298   tilemap_set_scrolly(cps1_bg_tilemap[0],0,cps1_scroll1y);
318   tilemap_set_scrollx(state->bg_tilemap[0], 0, state->scroll1x);
319   tilemap_set_scrolly(state->bg_tilemap[0], 0, state->scroll1y);
320
299321   if (videocontrol & 0x01)   /* linescroll enable */
300322   {
301      int scrly=-cps1_scroll2y;
323      int scrly= -state->scroll2y;
302324      int i;
303325      int otheroffs;
304326
305      tilemap_set_scroll_rows(cps1_bg_tilemap[1],1024);
327      tilemap_set_scroll_rows(state->bg_tilemap[1], 1024);
306328
307      otheroffs = cps1_cps_a_regs[CPS1_ROWSCROLL_OFFS];
329      otheroffs = state->cps_a_regs[CPS1_ROWSCROLL_OFFS];
308330
309      for (i = 0;i < 256;i++)
310         tilemap_set_scrollx(cps1_bg_tilemap[1],(i - scrly) & 0x3ff,cps1_scroll2x + cps1_other[(i + otheroffs) & 0x3ff]);
331      for (i = 0; i < 256; i++)
332         tilemap_set_scrollx(state->bg_tilemap[1], (i - scrly) & 0x3ff, state->scroll2x + state->other[(i + otheroffs) & 0x3ff]);
311333   }
312334   else
313335   {
314      tilemap_set_scroll_rows(cps1_bg_tilemap[1],1);
315      tilemap_set_scrollx(cps1_bg_tilemap[1],0,cps1_scroll2x);
336      tilemap_set_scroll_rows(state->bg_tilemap[1], 1);
337      tilemap_set_scrollx(state->bg_tilemap[1], 0, state->scroll2x);
316338   }
317   tilemap_set_scrolly(cps1_bg_tilemap[1],0,cps1_scroll2y);
318   tilemap_set_scrollx(cps1_bg_tilemap[2],0,cps1_scroll3x);
319   tilemap_set_scrolly(cps1_bg_tilemap[2],0,cps1_scroll3y);
320339
340   tilemap_set_scrolly(state->bg_tilemap[1], 0, state->scroll2y);
341   tilemap_set_scrollx(state->bg_tilemap[2], 0, state->scroll3x);
342   tilemap_set_scrolly(state->bg_tilemap[2], 0, state->scroll3y);
321343
344
322345   /* turn all tilemaps on regardless of settings in get_video_base() */
323346   /* write a custom get_video_base for this bootleg hardware? */
324   tilemap_set_enable(cps1_bg_tilemap[0],1);
325   tilemap_set_enable(cps1_bg_tilemap[1],1);
326   tilemap_set_enable(cps1_bg_tilemap[2],1);
347   tilemap_set_enable(state->bg_tilemap[0], 1);
348   tilemap_set_enable(state->bg_tilemap[1], 1);
349   tilemap_set_enable(state->bg_tilemap[2], 1);
327350
328351   /* Blank screen */
329   bitmap_fill(bitmap,cliprect,0xbff);
352   bitmap_fill(bitmap, cliprect, 0xbff);
330353
331   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
354   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
332355   l0 = (layercontrol >> 0x06) & 03;
333356   l1 = (layercontrol >> 0x08) & 03;
334357   l2 = (layercontrol >> 0x0a) & 03;
335358   l3 = (layercontrol >> 0x0c) & 03;
336359
337   fcrash_render_layer(screen->machine,bitmap,cliprect,l0,0);
338   if (l1 == 0) fcrash_render_high_layer(bitmap,cliprect,l0);
339   fcrash_render_layer(screen->machine,bitmap,cliprect,l1,0);
340   if (l2 == 0) fcrash_render_high_layer(bitmap,cliprect,l1);
341   fcrash_render_layer(screen->machine,bitmap,cliprect,l2,0);
342   if (l3 == 0) fcrash_render_high_layer(bitmap,cliprect,l2);
343   fcrash_render_layer(screen->machine,bitmap,cliprect,l3,0);
360   fcrash_render_layer(screen->machine, bitmap, cliprect, l0, 0);
344361
362   if (l1 == 0)
363      fcrash_render_high_layer(screen->machine, bitmap, cliprect, l0);
345364
365   fcrash_render_layer(screen->machine, bitmap, cliprect, l1, 0);
366
367   if (l2 == 0)
368      fcrash_render_high_layer(screen->machine, bitmap, cliprect, l1);
369
370   fcrash_render_layer(screen->machine, bitmap, cliprect, l2, 0);
371
372   if (l3 == 0)
373      fcrash_render_high_layer(screen->machine, bitmap, cliprect, l2);
374
375   fcrash_render_layer(screen->machine, bitmap, cliprect, l3, 0);
376
346377   return 0;
347378}
348379
r6740r6741
350381static ADDRESS_MAP_START( fcrash_map, ADDRESS_SPACE_PROGRAM, 16 )
351382   AM_RANGE(0x000000, 0x1fffff) AM_ROM
352383   AM_RANGE(0x800030, 0x800031) AM_WRITE(cps1_coinctrl_w)
353   AM_RANGE(0x800100, 0x80013f) AM_RAM AM_BASE(&cps1_cps_a_regs)   /* CPS-A custom */
354   AM_RANGE(0x800140, 0x80017f) AM_RAM AM_BASE(&cps1_cps_b_regs)   /* CPS-B custom */
384   AM_RANGE(0x800100, 0x80013f) AM_RAM AM_BASE_MEMBER(cps_state, cps_a_regs)   /* CPS-A custom */
385   AM_RANGE(0x800140, 0x80017f) AM_RAM AM_BASE_MEMBER(cps_state, cps_b_regs)   /* CPS-B custom */
355386   AM_RANGE(0x880000, 0x880001) AM_READ_PORT("IN1")            /* Player input ports */
356387   AM_RANGE(0x880006, 0x880007) AM_WRITE(fcrash_soundlatch_w)      /* Sound command */
357388   AM_RANGE(0x880008, 0x88000f) AM_READ(cps1_dsw_r)            /* System input ports / Dip Switches */
358389   AM_RANGE(0x890000, 0x890001) AM_WRITENOP   // palette related?
359   AM_RANGE(0x900000, 0x92ffff) AM_RAM_WRITE(cps1_gfxram_w) AM_BASE(&cps1_gfxram) AM_SIZE(&cps1_gfxram_size)
390   AM_RANGE(0x900000, 0x92ffff) AM_RAM_WRITE(cps1_gfxram_w) AM_BASE_SIZE_MEMBER(cps_state, gfxram, gfxram_size)
360391   AM_RANGE(0xff0000, 0xffffff) AM_RAM
361392ADDRESS_MAP_END
362393
r6740r6741
381412   AM_RANGE(0x800020, 0x800021) AM_READNOP                  /* ? Used by Rockman ? not mapped according to PAL */
382413   AM_RANGE(0x800030, 0x800037) AM_WRITE(cps1_coinctrl_w)
383414   /* Forgotten Worlds has dial controls on B-board mapped at 800040-80005f. See DRIVER_INIT */
384   AM_RANGE(0x800100, 0x80013f) AM_WRITE(cps1_cps_a_w) AM_BASE(&cps1_cps_a_regs)   /* CPS-A custom */
385   AM_RANGE(0x800140, 0x80017f) AM_READWRITE(cps1_cps_b_r, cps1_cps_b_w) AM_BASE(&cps1_cps_b_regs)   /* CPS-B custom */
415   AM_RANGE(0x800100, 0x80013f) AM_WRITE(cps1_cps_a_w) AM_BASE_MEMBER(cps_state, cps_a_regs)   /* CPS-A custom */
416   AM_RANGE(0x800140, 0x80017f) AM_READWRITE(cps1_cps_b_r, cps1_cps_b_w) AM_BASE_MEMBER(cps_state, cps_b_regs)   /* CPS-B custom */
386417//  AM_RANGE(0x800180, 0x800187) AM_WRITE(cps1_soundlatch_w)    /* Sound command */
387418//  AM_RANGE(0x800188, 0x80018f) AM_WRITE(cps1_soundlatch2_w)   /* Sound timer fade */
388419   AM_RANGE(0x8001c0, 0x8001ff) AM_READWRITE(cps1_cps_b_r, cps1_cps_b_w)   /* mirror (SF2 revision "E" US 910228) */
389   AM_RANGE(0x900000, 0x92ffff) AM_RAM_WRITE(cps1_gfxram_w) AM_BASE(&cps1_gfxram) AM_SIZE(&cps1_gfxram_size)   /* SF2CE executes code from here */
420   AM_RANGE(0x900000, 0x92ffff) AM_RAM_WRITE(cps1_gfxram_w) AM_BASE_SIZE_MEMBER(cps_state, gfxram, gfxram_size)   /* SF2CE executes code from here */
390421   AM_RANGE(0xff0000, 0xffffff) AM_RAM
391422ADDRESS_MAP_END
392423
r6740r6741
633664   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
634665   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
635666
636   PORT_START("IN2")      /* Player 3 */
667   PORT_START("IN2")
637668   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(3)
638669   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(3)
639670   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(3)
r6740r6741
658689};
659690
660691
692static MACHINE_START( fcrash )
693{
694   cps_state *state = (cps_state *)machine->driver_data;
695   UINT8 *ROM = memory_region(machine, "maincpu");
696
697   memory_configure_bank(machine, "bank1", 0, 8, &ROM[0x10000], 0x4000);
698
699   state->maincpu = devtag_get_device(machine, "maincpu");
700   state->audiocpu = devtag_get_device(machine, "soundcpu");
701   state->msm_1 = devtag_get_device(machine, "msm1");
702   state->msm_2 = devtag_get_device(machine, "msm2");
703
704   state_save_register_global(machine, state->sample_buffer1);
705   state_save_register_global(machine, state->sample_buffer2);
706   state_save_register_global(machine, state->sample_select1);
707   state_save_register_global(machine, state->sample_select2);
708}
709
710static MACHINE_START( kodb )
711{
712   cps_state *state = (cps_state *)machine->driver_data;
713
714   state->maincpu = devtag_get_device(machine, "maincpu");
715   state->audiocpu = devtag_get_device(machine, "soundcpu");
716}
717
718static MACHINE_RESET( fcrash )
719{
720   cps_state *state = (cps_state *)machine->driver_data;
721
722   state->sample_buffer1 = 0;
723   state->sample_buffer2 = 0;
724   state->sample_select1 = 0;
725   state->sample_select2 = 0;
726}
727
661728static MACHINE_DRIVER_START( fcrash )
662729
730   /* driver data */
731   MDRV_DRIVER_DATA(cps_state)
732
663733   /* basic machine hardware */
664734   MDRV_CPU_ADD("maincpu", M68000, 10000000)
665735   MDRV_CPU_PROGRAM_MAP(fcrash_map)
r6740r6741
668738   MDRV_CPU_ADD("soundcpu", Z80, 24000000/6) /* ? */
669739   MDRV_CPU_PROGRAM_MAP(sound_map)
670740
741   MDRV_MACHINE_START(fcrash)
742   MDRV_MACHINE_RESET(fcrash)
743
671744   /* video hardware */
672745   MDRV_SCREEN_ADD("screen", RASTER)
673746   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
709782
710783static MACHINE_DRIVER_START( kodb )
711784
785   /* driver data */
786   MDRV_DRIVER_DATA(cps_state)
787
712788   /* basic machine hardware */
713789   MDRV_CPU_ADD("maincpu", M68000, 10000000)
714790   MDRV_CPU_PROGRAM_MAP(kodb_map)
715791   MDRV_CPU_VBLANK_INT("screen", cps1_interrupt)
716792
717//  MDRV_CPU_ADD("audiocpu", Z80, 3579545)
793//  MDRV_CPU_ADD("soundcpu", Z80, 3579545)
718794//  MDRV_CPU_PROGRAM_MAP(sub_map)
719795
796   MDRV_MACHINE_START(kodb)
797
720798   /* video hardware */
721799   MDRV_SCREEN_ADD("screen", RASTER)
722800   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
844922   ROM_LOAD( "2.ic19",      0x00000, 0x40000, CRC(a2db1575) SHA1(1a4a29e4b045af50700adf1665697feab12cc234) )
845923ROM_END
846924
847GAME( 1990, fcrash,   ffight,  fcrash,     fcrash,   cps1,     ROT0,   "[Capcom] (Playmark bootleg)", "Final Crash (bootleg of Final Fight)", 0 )
848GAME( 1991, kodb,     kod,     kodb,       kodb,     cps1,     ROT0,   "[Capcom] (Playmark bootleg)", "The King of Dragons (bootleg)", GAME_NOT_WORKING | GAME_NO_SOUND )   // 910731  "ETC"
925GAME( 1990, fcrash,   ffight,  fcrash,     fcrash,   cps1,     ROT0,   "[Capcom] (Playmark bootleg)", "Final Crash (bootleg of Final Fight)", GAME_SUPPORTS_SAVE )
926GAME( 1991, kodb,     kod,     kodb,       kodb,     cps1,     ROT0,   "[Capcom] (Playmark bootleg)", "The King of Dragons (bootleg)", GAME_NOT_WORKING | GAME_NO_SOUND | GAME_SUPPORTS_SAVE )   // 910731  "ETC"
src/mame/drivers/cosmic.c
r6740r6741
4242#include "cpu/z80/z80.h"
4343#include "sound/samples.h"
4444#include "sound/dac.h"
45#include "cosmic.h"
45#include "includes/cosmic.h"
4646
4747
4848/* Schematics show 12 triggers for discrete sound circuits */
src/mame/drivers/model2.c
r6740r6741
7272
7373static UINT32 model2_timervals[4], model2_timerorig[4];
7474static int      model2_timerrun[4];
75static emu_timer *model2_timers[4];
75static const device_config *model2_timers[4];
7676static int model2_ctrlmode;
7777static int analog_channel;
7878
r6740r6741
271271   if (model2_timerrun[offset])
272272   {
273273      // get elapsed time, convert to units of 25 MHz
274      UINT32 cur = attotime_to_double(attotime_mul(timer_timeelapsed(model2_timers[offset]), 25000000));
274      UINT32 cur = attotime_to_double(attotime_mul(timer_device_timeelapsed(model2_timers[offset]), 25000000));
275275
276276      // subtract units from starting value
277277      model2_timervals[offset] = model2_timerorig[offset] - cur;
r6740r6741
289289
290290   model2_timerorig[offset] = model2_timervals[offset];
291291   period = attotime_mul(ATTOTIME_IN_HZ(25000000), model2_timerorig[offset]);
292   timer_adjust_oneshot(model2_timers[offset], period, 0);
292   timer_device_adjust_oneshot(model2_timers[offset], period, 0);
293293   model2_timerrun[offset] = 1;
294294}
295295
296static TIMER_CALLBACK( model2_timer_cb )
296static TIMER_DEVICE_CALLBACK( model2_timer_cb )
297297{
298298   int tnum = (int)(FPTR)ptr;
299299   int bit = tnum + 2;
300300
301   timer_adjust_oneshot(model2_timers[tnum], attotime_never, 0);
301   timer_device_adjust_oneshot(model2_timers[tnum], attotime_never, 0);
302302
303303   model2_intreq |= (1<<bit);
304304   if (model2_intena & (1<<bit))
305305   {
306      cputag_set_input_line(machine, "maincpu", I960_IRQ2, ASSERT_LINE);
306      cputag_set_input_line(timer->machine, "maincpu", I960_IRQ2, ASSERT_LINE);
307307   }
308308
309309   model2_timervals[tnum] = 0;
r6740r6741
330330
331331   model2_timerrun[0] = model2_timerrun[1] = model2_timerrun[2] = model2_timerrun[3] = 0;
332332
333   model2_timers[0] = devtag_get_device(machine, "timer0");
334   model2_timers[1] = devtag_get_device(machine, "timer1");
335   model2_timers[2] = devtag_get_device(machine, "timer2");
336   model2_timers[3] = devtag_get_device(machine, "timer3");
333337   for (i=0; i<4; i++)
334   {
335      model2_timers[i] = timer_alloc(machine, model2_timer_cb, (void*)(FPTR)i);
336      timer_adjust_oneshot(model2_timers[i], attotime_never, 0);
337   }
338      timer_device_adjust_oneshot(model2_timers[i], attotime_never, 0);
338339}
339340
340341static MACHINE_RESET(model2o)
r6740r6741
18431844   MDRV_MACHINE_RESET(model2o)
18441845   MDRV_NVRAM_HANDLER( model2 )
18451846
1847   MDRV_TIMER_ADD("timer0", model2_timer_cb)
1848   MDRV_TIMER_PTR((FPTR)0)
1849   MDRV_TIMER_ADD("timer1", model2_timer_cb)
1850   MDRV_TIMER_PTR((FPTR)1)
1851   MDRV_TIMER_ADD("timer2", model2_timer_cb)
1852   MDRV_TIMER_PTR((FPTR)2)
1853   MDRV_TIMER_ADD("timer3", model2_timer_cb)
1854   MDRV_TIMER_PTR((FPTR)3)
1855
18461856   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK )
18471857
18481858   MDRV_SCREEN_ADD("screen", RASTER)
r6740r6741
18881898   MDRV_MACHINE_RESET(model2)
18891899   MDRV_NVRAM_HANDLER( model2 )
18901900
1901   MDRV_TIMER_ADD("timer0", model2_timer_cb)
1902   MDRV_TIMER_PTR((FPTR)0)
1903   MDRV_TIMER_ADD("timer1", model2_timer_cb)
1904   MDRV_TIMER_PTR((FPTR)1)
1905   MDRV_TIMER_ADD("timer2", model2_timer_cb)
1906   MDRV_TIMER_PTR((FPTR)2)
1907   MDRV_TIMER_ADD("timer3", model2_timer_cb)
1908   MDRV_TIMER_PTR((FPTR)3)
1909
18911910   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK )
18921911
18931912   MDRV_SCREEN_ADD("screen", RASTER)
r6740r6741
19381957   MDRV_MACHINE_RESET(model2b)
19391958   MDRV_NVRAM_HANDLER( model2 )
19401959
1960   MDRV_TIMER_ADD("timer0", model2_timer_cb)
1961   MDRV_TIMER_PTR((FPTR)0)
1962   MDRV_TIMER_ADD("timer1", model2_timer_cb)
1963   MDRV_TIMER_PTR((FPTR)1)
1964   MDRV_TIMER_ADD("timer2", model2_timer_cb)
1965   MDRV_TIMER_PTR((FPTR)2)
1966   MDRV_TIMER_ADD("timer3", model2_timer_cb)
1967   MDRV_TIMER_PTR((FPTR)3)
1968
19411969   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK )
19421970
19431971   MDRV_SCREEN_ADD("screen", RASTER)
r6740r6741
19722000   MDRV_MACHINE_RESET(model2c)
19732001   MDRV_NVRAM_HANDLER( model2 )
19742002
2003   MDRV_TIMER_ADD("timer0", model2_timer_cb)
2004   MDRV_TIMER_PTR((FPTR)0)
2005   MDRV_TIMER_ADD("timer1", model2_timer_cb)
2006   MDRV_TIMER_PTR((FPTR)1)
2007   MDRV_TIMER_ADD("timer2", model2_timer_cb)
2008   MDRV_TIMER_PTR((FPTR)2)
2009   MDRV_TIMER_ADD("timer3", model2_timer_cb)
2010   MDRV_TIMER_PTR((FPTR)3)
2011
19752012   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK )
19762013
19772014   MDRV_SCREEN_ADD("screen", RASTER)
src/mame/drivers/ataxx.c
r6740r6741
2929#include "cpu/i86/i86.h"
3030#include "machine/eeprom.h"
3131#include "cpu/z80/z80.h"
32#include "leland.h"
32#include "includes/leland.h"
3333#include "sound/2151intf.h"
3434
3535
src/mame/drivers/wiping.c
r6740r6741
8585
8686static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
8787   AM_RANGE(0x0000, 0x5fff) AM_ROM
88   AM_RANGE(0x8000, 0x83ff) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)      /* Fallthrough */
89   AM_RANGE(0x8400, 0x87ff) AM_BASE_GENERIC(colorram)
88   AM_RANGE(0x8000, 0x83ff) AM_BASE(&wiping_videoram)
89   AM_RANGE(0x8400, 0x87ff) AM_BASE(&wiping_colorram)
9090   AM_RANGE(0x8800, 0x88ff) AM_BASE_SIZE_GENERIC(spriteram)
9191   AM_RANGE(0x8000, 0x8bff) AM_RAM
9292   AM_RANGE(0x9000, 0x93ff) AM_READWRITE(shared1_r,shared1_w) AM_BASE(&sharedram1)
src/mame/drivers/popeye.c
r6740r6741
2121#include "sound/ay8910.h"
2222
2323
24extern UINT8 *popeye_videoram;
25extern UINT8 *popeye_colorram;
2426extern UINT8 *popeye_background_pos;
2527extern UINT8 *popeye_palettebank;
2628
r6740r6741
8688   AM_RANGE(0x8c03, 0x8c03) AM_RAM AM_BASE(&popeye_palettebank)
8789   AM_RANGE(0x8c04, 0x8e7f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
8890   AM_RANGE(0x8e80, 0x8fff) AM_RAM
89   AM_RANGE(0xa000, 0xa3ff) AM_WRITE(popeye_videoram_w) AM_BASE_GENERIC(videoram)
90   AM_RANGE(0xa400, 0xa7ff) AM_WRITE(popeye_colorram_w) AM_BASE_GENERIC(colorram)
91   AM_RANGE(0xa000, 0xa3ff) AM_WRITE(popeye_videoram_w) AM_BASE(&popeye_videoram)
92   AM_RANGE(0xa400, 0xa7ff) AM_WRITE(popeye_colorram_w) AM_BASE(&popeye_colorram)
9193   AM_RANGE(0xc000, 0xcfff) AM_WRITE(skyskipr_bitmap_w)
9294   AM_RANGE(0xe000, 0xe001) AM_READWRITE(protection_r,protection_w)
9395ADDRESS_MAP_END
r6740r6741
100102   AM_RANGE(0x8c03, 0x8c03) AM_RAM AM_BASE(&popeye_palettebank)
101103   AM_RANGE(0x8c04, 0x8e7f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
102104   AM_RANGE(0x8e80, 0x8fff) AM_RAM
103   AM_RANGE(0xa000, 0xa3ff) AM_WRITE(popeye_videoram_w) AM_BASE_GENERIC(videoram)
104   AM_RANGE(0xa400, 0xa7ff) AM_WRITE(popeye_colorram_w) AM_BASE_GENERIC(colorram)
105   AM_RANGE(0xa000, 0xa3ff) AM_WRITE(popeye_videoram_w) AM_BASE(&popeye_videoram)
106   AM_RANGE(0xa400, 0xa7ff) AM_WRITE(popeye_colorram_w) AM_BASE(&popeye_colorram)
105107   AM_RANGE(0xc000, 0xdfff) AM_WRITE(popeye_bitmap_w)
106108   AM_RANGE(0xe000, 0xe001) AM_READWRITE(protection_r,protection_w)
107109ADDRESS_MAP_END
r6740r6741
113115   AM_RANGE(0x8c03, 0x8c03) AM_RAM AM_BASE(&popeye_palettebank)
114116   AM_RANGE(0x8c04, 0x8e7f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
115117   AM_RANGE(0x8e80, 0x8fff) AM_RAM
116   AM_RANGE(0xa000, 0xa3ff) AM_WRITE(popeye_videoram_w) AM_BASE_GENERIC(videoram)
117   AM_RANGE(0xa400, 0xa7ff) AM_WRITE(popeye_colorram_w) AM_BASE_GENERIC(colorram)
118   AM_RANGE(0xa000, 0xa3ff) AM_WRITE(popeye_videoram_w) AM_BASE(&popeye_videoram)
119   AM_RANGE(0xa400, 0xa7ff) AM_WRITE(popeye_colorram_w) AM_BASE(&popeye_colorram)
118120   AM_RANGE(0xc000, 0xcfff) AM_WRITE(skyskipr_bitmap_w)
119121   AM_RANGE(0xe000, 0xe01f) AM_ROM
120122ADDRESS_MAP_END
src/mame/drivers/taxidrvr.c
r6740r6741
77#include "driver.h"
88#include "cpu/z80/z80.h"
99#include "machine/8255ppi.h"
10#include "taxidrvr.h"
10#include "includes/taxidrvr.h"
1111#include "sound/ay8910.h"
1212
1313
src/mame/drivers/compgolf.c
r6740r6741
1313#include "driver.h"
1414#include "cpu/m6809/m6809.h"
1515#include "sound/2203intf.h"
16#include "compgolf.h"
16#include "includes/compgolf.h"
1717
1818
1919/*************************************
src/mame/drivers/cps2.c
r6740r6741
591591#include "sound/qsound.h"
592592#include "sound/okim6295.h" // gigamn2 bootleg
593593
594#include "cps1.h"       /* External CPS1 definitions */
594#include "includes/cps1.h"       /* External CPS1 definitions */
595595
596/*
597Export this function so that the video routine can drive the
598Q-Sound hardware
599*/
600#ifdef UNUSED_FUNCTION
601WRITE16_HANDLER( cps2_qsound_sharedram_w )
602{
603    qsound_sharedram1_w(offset/2, data, 0xff00);
604}
605#endif
606596
607
608597/*************************************
609598 *
610599 *  Constants
r6740r6741
621610
622611/*************************************
623612 *
624 *  Global variables
625 *
626 *************************************/
627
628static int readpaddle;
629static int cps2networkpresent;
630
631
632/*************************************
633 *
634613 *  Interrupt generation
635614 *
636615 *************************************/
637616
638617static INTERRUPT_GEN( cps2_interrupt )
639618{
640   static int scancount;
619   cps_state *state = (cps_state *)device->machine->driver_data;
641620
642621   /* 2 is vblank, 4 is some sort of scanline interrupt, 6 is both at the same time. */
643
644   if(scancount >= 258)
622   if (state->scancount >= 258)
645623   {
646      scancount = -1;
647      cps1_scancalls = 0;
624      state->scancount = -1;
625      state->scancalls = 0;
648626   }
649   scancount++;
627   state->scancount++;
650628
651   if (cps1_cps_b_regs[0x10/2] & 0x8000)
652      cps1_cps_b_regs[0x10/2] = cps1_cps_b_regs[0x10/2] & 0x1ff;
653   if (cps1_cps_b_regs[0x12/2] & 0x8000)
654      cps1_cps_b_regs[0x12/2] = cps1_cps_b_regs[0x12/2] & 0x1ff;
629   if (state->cps_b_regs[0x10 / 2] & 0x8000)
630      state->cps_b_regs[0x10 / 2] &= 0x1ff;
655631
656//  popmessage("%04x %04x - %04x %04x",cps1_scanline1,cps1_scanline2,cps1_cps_b_regs[0x10/2],cps1_cps_b_regs[0x12/2]);
632   if (state->cps_b_regs[0x12 / 2] & 0x8000)
633      state->cps_b_regs[0x12 / 2] &= 0x1ff;
657634
635//  popmessage("%04x %04x - %04x %04x",state->scanline1,state->scanline2,state->cps_b_regs[0x10/2],state->cps_b_regs[0x12/2]);
636
658637   /* raster effects */
659   if(cps1_scanline1 == scancount || (cps1_scanline1 < scancount && !cps1_scancalls))
638   if (state->scanline1 == state->scancount || (state->scanline1 < state->scancount && !state->scancalls))
660639   {
661      cps1_cps_b_regs[0x10/2] = 0;
640      state->cps_b_regs[0x10/2] = 0;
662641      cpu_set_input_line(device, 4, HOLD_LINE);
663      cps2_set_sprite_priorities();
664      video_screen_update_partial(device->machine->primary_screen, 16 - 10 + scancount);   /* visarea.min_y - [first visible line?] + scancount */
665      cps1_scancalls++;
666//          popmessage("IRQ4 scancounter = %04i",scancount);
642      cps2_set_sprite_priorities(device->machine);
643      video_screen_update_partial(device->machine->primary_screen, 16 - 10 + state->scancount);   /* visarea.min_y - [first visible line?] + scancount */
644      state->scancalls++;
645//          popmessage("IRQ4 scancounter = %04i", state->scancount);
667646   }
668647
669648   /* raster effects */
670   if(cps1_scanline2 == scancount || (cps1_scanline2 < scancount && !cps1_scancalls))
649   if(state->scanline2 == state->scancount || (state->scanline2 < state->scancount && !state->scancalls))
671650   {
672      cps1_cps_b_regs[0x12/2] = 0;
651      state->cps_b_regs[0x12 / 2] = 0;
673652      cpu_set_input_line(device, 4, HOLD_LINE);
674      cps2_set_sprite_priorities();
675      video_screen_update_partial(device->machine->primary_screen, 16 - 10 + scancount);   /* visarea.min_y - [first visible line?] + scancount */
676      cps1_scancalls++;
653      cps2_set_sprite_priorities(device->machine);
654      video_screen_update_partial(device->machine->primary_screen, 16 - 10 + state->scancount);   /* visarea.min_y - [first visible line?] + scancount */
655      state->scancalls++;
677656//          popmessage("IRQ4 scancounter = %04i",scancount);
678657   }
679658
680   if(scancount == 240)  /* VBlank */
659   if (state->scancount == 240)  /* VBlank */
681660   {
682      cps1_cps_b_regs[0x10/2] = cps1_scanline1;
683      cps1_cps_b_regs[0x12/2] = cps1_scanline2;
661      state->cps_b_regs[0x10 / 2] = state->scanline1;
662      state->cps_b_regs[0x12 / 2] = state->scanline2;
684663      cpu_set_input_line(device, 2, HOLD_LINE);
685      if(cps1_scancalls)
664      if(state->scancalls)
686665      {
687         cps2_set_sprite_priorities();
666         cps2_set_sprite_priorities(device->machine);
688667         video_screen_update_partial(device->machine->primary_screen, 256);
689668      }
690      cps2_objram_latch();
669      cps2_objram_latch(device->machine);
691670   }
692   //popmessage("Raster calls = %i",cps1_scancalls);
671   //popmessage("Raster calls = %i", state->scancalls);
693672}
694673
695674
r6740r6741
710689
711690static WRITE16_HANDLER( cps2_eeprom_port_w )
712691{
692   cps_state *state = (cps_state *)space->machine->driver_data;
693
713694   if (ACCESSING_BITS_8_15)
714695   {
715696      /* bit 0 - Unused */
r6740r6741
737718      /* bit 7 - */
738719
739720           /* Z80 Reset */
740      if (cputag_get_cpu(space->machine, "audiocpu"))
741         cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_RESET, (data & 0x0008) ? CLEAR_LINE : ASSERT_LINE);
721      if (state->audiocpu != NULL)
722         cpu_set_input_line(state->audiocpu, INPUT_LINE_RESET, (data & 0x0008) ? CLEAR_LINE : ASSERT_LINE);
742723
743724      coin_counter_w(space->machine, 0, data & 0x0001);
744      if( (strncmp(space->machine->gamedrv->name,"pzloop2",8)==0) ||
745           (strncmp(space->machine->gamedrv->name,"pzloop2j",8)==0) )
725      if ((strncmp(space->machine->gamedrv->name, "pzloop2", 8) == 0) ||
726           (strncmp(space->machine->gamedrv->name, "pzloop2j", 8) == 0))
746727      {
747728         // Puzz Loop 2 uses coin counter 2 input to switch between stick and paddle controls
748         readpaddle = data & 0x0002;
729         state->readpaddle = data & 0x0002;
749730      }
750731      else
751732      {
752733         coin_counter_w(space->machine, 1, data & 0x0002);
753734      }
754735
755      if(strncmp(space->machine->gamedrv->name,"mmatrix",7)==0)      // Mars Matrix seems to require the coin lockout bit to be reversed
736      if (strncmp(space->machine->gamedrv->name, "mmatrix", 7) == 0)      // Mars Matrix seems to require the coin lockout bit to be reversed
756737      {
757         coin_lockout_w(space->machine, 0,data & 0x0010);
758         coin_lockout_w(space->machine, 1,data & 0x0020);
759         coin_lockout_w(space->machine, 2,data & 0x0040);
760         coin_lockout_w(space->machine, 3,data & 0x0080);
738         coin_lockout_w(space->machine, 0, data & 0x0010);
739         coin_lockout_w(space->machine, 1, data & 0x0020);
740         coin_lockout_w(space->machine, 2, data & 0x0040);
741         coin_lockout_w(space->machine, 3, data & 0x0080);
761742      }
762743      else
763744      {
764         coin_lockout_w(space->machine, 0,~data & 0x0010);
765         coin_lockout_w(space->machine, 1,~data & 0x0020);
766         coin_lockout_w(space->machine, 2,~data & 0x0040);
767         coin_lockout_w(space->machine, 3,~data & 0x0080);
745         coin_lockout_w(space->machine, 0, ~data & 0x0010);
746         coin_lockout_w(space->machine, 1, ~data & 0x0020);
747         coin_lockout_w(space->machine, 2, ~data & 0x0040);
748         coin_lockout_w(space->machine, 3, ~data & 0x0080);
768749      }
769750
770751      /*
771        set_led_status(space->machine, 0,data & 0x01);
772        set_led_status(space->machine, 1,data & 0x10);
773        set_led_status(space->machine, 2,data & 0x20);
752        set_led_status(space->machine, 0, data & 0x01);
753        set_led_status(space->machine, 1, data & 0x10);
754        set_led_status(space->machine, 2, data & 0x20);
774755        */
775756    }
776757}
r6740r6741
784765
785766static READ16_HANDLER( cps2_qsound_volume_r )
786767{
768   cps_state *state = (cps_state *)space->machine->driver_data;
769
787770   /* Extra adapter memory (0x660000-0x663fff) available when bit 14 = 0 */
788771   /* Network adapter (ssf2tb) present when bit 15 = 0 */
789772   /* Only game known to use both these so far is SSF2TB */
790773
791   if(cps2networkpresent)
774   if (state->cps2networkpresent)
792775      return 0x2021;
793776   else
794777      return 0xe021;
r6740r6741
808791
809792static READ16_HANDLER( joy_or_paddle_r )
810793{
811   if (readpaddle != 0)
794   cps_state *state = (cps_state *)space->machine->driver_data;
795
796   if (state->readpaddle != 0)
812797      return (input_port_read(space->machine, "IN0"));
813798   else
814799      return (input_port_read(space->machine, "PADDLE1") & 0xff) | (input_port_read(space->machine, "PADDLE2") << 8);
r6740r6741
823808
824809static ADDRESS_MAP_START( cps2_map, ADDRESS_SPACE_PROGRAM, 16 )
825810   AM_RANGE(0x000000, 0x3fffff) AM_ROM                                                         /* 68000 ROM */
826   AM_RANGE(0x400000, 0x40000b) AM_RAM AM_BASE(&cps2_output) AM_SIZE(&cps2_output_size)                  /* CPS2 object output */
811   AM_RANGE(0x400000, 0x40000b) AM_RAM AM_BASE_SIZE_MEMBER(cps_state, output, output_size)                  /* CPS2 object output */
827812   AM_RANGE(0x618000, 0x619fff) AM_READWRITE(qsound_sharedram1_r, qsound_sharedram1_w)                      /* Q RAM */
828813   AM_RANGE(0x662000, 0x662001) AM_RAM                                                         /* Network adapter related, accessed in SSF2TB */
829814   AM_RANGE(0x662008, 0x662009) AM_RAM                                                         /* Network adapter related, accessed in SSF2TB */
830815   AM_RANGE(0x662020, 0x662021) AM_RAM                                                         /* Network adapter related, accessed in SSF2TB */
831816   AM_RANGE(0x660000, 0x663fff) AM_RAM                                                         /* When bit 14 of 0x804030 equals 0 this space is available. Many games store highscores and other info here if available. */
832817   AM_RANGE(0x664000, 0x664001) AM_RAM                                                         /* Unknown - Only used if 0x660000-0x663fff available (could be RAM enable?) */
833   AM_RANGE(0x700000, 0x701fff) AM_WRITE(cps2_objram1_w) AM_BASE(&cps2_objram1)                          /* Object RAM, no game seems to use it directly */
834   AM_RANGE(0x708000, 0x709fff) AM_READWRITE(cps2_objram2_r, cps2_objram2_w) AM_BASE(&cps2_objram2)         /* Object RAM */
835   AM_RANGE(0x70a000, 0x70bfff) AM_READWRITE(cps2_objram2_r, cps2_objram2_w) AM_BASE(&cps2_objram2)         /* mirror */
836   AM_RANGE(0x70c000, 0x70dfff) AM_READWRITE(cps2_objram2_r, cps2_objram2_w) AM_BASE(&cps2_objram2)         /* mirror */
837   AM_RANGE(0x70e000, 0x70ffff) AM_READWRITE(cps2_objram2_r, cps2_objram2_w) AM_BASE(&cps2_objram2)         /* mirror */
838   AM_RANGE(0x800100, 0x80013f) AM_WRITE(cps1_cps_a_w) AM_BASE(&cps1_cps_a_regs)                        /* mirror (sfa) */
839   AM_RANGE(0x800140, 0x80017f) AM_READWRITE(cps1_cps_b_r, cps1_cps_b_w) AM_BASE(&cps1_cps_b_regs)          /* mirror (sfa) */
818   AM_RANGE(0x700000, 0x701fff) AM_WRITE(cps2_objram1_w) AM_BASE_MEMBER(cps_state, objram1)                          /* Object RAM, no game seems to use it directly */
819   AM_RANGE(0x708000, 0x709fff) AM_READWRITE(cps2_objram2_r, cps2_objram2_w) AM_BASE_MEMBER(cps_state, objram2)         /* Object RAM */
820   AM_RANGE(0x70a000, 0x70bfff) AM_READWRITE(cps2_objram2_r, cps2_objram2_w) AM_BASE_MEMBER(cps_state, objram2)         /* mirror */
821   AM_RANGE(0x70c000, 0x70dfff) AM_READWRITE(cps2_objram2_r, cps2_objram2_w) AM_BASE_MEMBER(cps_state, objram2)         /* mirror */
822   AM_RANGE(0x70e000, 0x70ffff) AM_READWRITE(cps2_objram2_r, cps2_objram2_w) AM_BASE_MEMBER(cps_state, objram2)         /* mirror */
823   AM_RANGE(0x800100, 0x80013f) AM_WRITE(cps1_cps_a_w) AM_BASE_MEMBER(cps_state, cps_a_regs)                        /* mirror (sfa) */
824   AM_RANGE(0x800140, 0x80017f) AM_READWRITE(cps1_cps_b_r, cps1_cps_b_w) AM_BASE_MEMBER(cps_state, cps_b_regs)          /* mirror (sfa) */
840825   AM_RANGE(0x804000, 0x804001) AM_READ_PORT("IN0")                                                 /* IN0 */
841826   AM_RANGE(0x804010, 0x804011) AM_READ_PORT("IN1")                                                 /* IN1 */
842827   AM_RANGE(0x804020, 0x804021) AM_READ_PORT("IN2")                                                 /* IN2 + EEPROM */
r6740r6741
845830   AM_RANGE(0x8040a0, 0x8040a1) AM_WRITENOP                                                         /* Unknown (reset once on startup) */
846831   AM_RANGE(0x8040b0, 0x8040b3) AM_READ(kludge_r)                                                /* unknown (xmcotaj hangs if this is 0) */
847832   AM_RANGE(0x8040e0, 0x8040e1) AM_WRITE(cps2_objram_bank_w)                                       /* bit 0 = Object ram bank swap */
848   AM_RANGE(0x804100, 0x80413f) AM_WRITE(cps1_cps_a_w) AM_BASE(&cps1_cps_a_regs)                         /* CPS-A custom */
833   AM_RANGE(0x804100, 0x80413f) AM_WRITE(cps1_cps_a_w) AM_BASE_MEMBER(cps_state, cps_a_regs)                     /* CPS-A custom */
849834   AM_RANGE(0x804140, 0x80417f) AM_READWRITE(cps1_cps_b_r, cps1_cps_b_w)                                   /* CPS-B custom */
850   AM_RANGE(0x900000, 0x92ffff) AM_RAM_WRITE(cps1_gfxram_w) AM_BASE(&cps1_gfxram) AM_SIZE(&cps1_gfxram_size)   /* Video RAM */
835   AM_RANGE(0x900000, 0x92ffff) AM_RAM_WRITE(cps1_gfxram_w) AM_BASE_SIZE_MEMBER(cps_state, gfxram, gfxram_size)   /* Video RAM */
851836   AM_RANGE(0xff0000, 0xffffff) AM_RAM                                                         /* RAM */
852837ADDRESS_MAP_END
853838
854839
855840static ADDRESS_MAP_START( dead_cps2_map, ADDRESS_SPACE_PROGRAM, 16 )
856841   AM_RANGE(0x000000, 0x3fffff) AM_ROM                                                         /* 68000 ROM */
857   AM_RANGE(0x400000, 0x40000b) AM_RAM AM_BASE(&cps2_output) AM_SIZE(&cps2_output_size)                  /* CPS2 object output */
842   AM_RANGE(0x400000, 0x40000b) AM_RAM AM_BASE_SIZE_MEMBER(cps_state, output, output_size)                  /* CPS2 object output */
858843   AM_RANGE(0x618000, 0x619fff) AM_READWRITE(qsound_sharedram1_r, qsound_sharedram1_w)                      /* Q RAM */
859844   AM_RANGE(0x662000, 0x662001) AM_RAM                                                         /* Network adapter related, accessed in SSF2TB */
860845   AM_RANGE(0x662008, 0x662009) AM_RAM                                                         /* Network adapter related, accessed in SSF2TB */
861846   AM_RANGE(0x662020, 0x662021) AM_RAM                                                         /* Network adapter related, accessed in SSF2TB */
862847   AM_RANGE(0x660000, 0x663fff) AM_RAM                                                         /* When bit 14 of 0x804030 equals 0 this space is available. Many games store highscores and other info here if available. */
863848   AM_RANGE(0x664000, 0x664001) AM_RAM                                                         /* Unknown - Only used if 0x660000-0x663fff available (could be RAM enable?) */
864   AM_RANGE(0x700000, 0x701fff) AM_WRITE(cps2_objram1_w) AM_BASE(&cps2_objram1)                          /* Object RAM, no game seems to use it directly */
865   AM_RANGE(0x708000, 0x709fff) AM_READWRITE(cps2_objram2_r, cps2_objram2_w) AM_BASE(&cps2_objram2)         /* Object RAM */
866   AM_RANGE(0x70a000, 0x70bfff) AM_READWRITE(cps2_objram2_r, cps2_objram2_w) AM_BASE(&cps2_objram2)         /* mirror */
867   AM_RANGE(0x70c000, 0x70dfff) AM_READWRITE(cps2_objram2_r, cps2_objram2_w) AM_BASE(&cps2_objram2)         /* mirror */
868   AM_RANGE(0x70e000, 0x70ffff) AM_READWRITE(cps2_objram2_r, cps2_objram2_w) AM_BASE(&cps2_objram2)         /* mirror */
869   AM_RANGE(0x800100, 0x80013f) AM_WRITE(cps1_cps_a_w) AM_BASE(&cps1_cps_a_regs)                        /* mirror (sfa) */
870   AM_RANGE(0x800140, 0x80017f) AM_READWRITE(cps1_cps_b_r, cps1_cps_b_w) AM_BASE(&cps1_cps_b_regs)          /* mirror (sfa) */
849   AM_RANGE(0x700000, 0x701fff) AM_WRITE(cps2_objram1_w) AM_BASE_MEMBER(cps_state, objram1)                          /* Object RAM, no game seems to use it directly */
850   AM_RANGE(0x708000, 0x709fff) AM_READWRITE(cps2_objram2_r, cps2_objram2_w) AM_BASE_MEMBER(cps_state, objram2)         /* Object RAM */
851   AM_RANGE(0x70a000, 0x70bfff) AM_READWRITE(cps2_objram2_r, cps2_objram2_w) AM_BASE_MEMBER(cps_state, objram2)         /* mirror */
852   AM_RANGE(0x70c000, 0x70dfff) AM_READWRITE(cps2_objram2_r, cps2_objram2_w) AM_BASE_MEMBER(cps_state, objram2)         /* mirror */
853   AM_RANGE(0x70e000, 0x70ffff) AM_READWRITE(cps2_objram2_r, cps2_objram2_w) AM_BASE_MEMBER(cps_state, objram2)         /* mirror */
854   AM_RANGE(0x800100, 0x80013f) AM_WRITE(cps1_cps_a_w) AM_BASE_MEMBER(cps_state, cps_a_regs)                        /* mirror (sfa) */
855   AM_RANGE(0x800140, 0x80017f) AM_READWRITE(cps1_cps_b_r, cps1_cps_b_w) AM_BASE_MEMBER(cps_state, cps_b_regs)          /* mirror (sfa) */
871856   AM_RANGE(0x804000, 0x804001) AM_READ_PORT("IN0")                                                 /* IN0 */
872857   AM_RANGE(0x804010, 0x804011) AM_READ_PORT("IN1")                                                 /* IN1 */
873858   AM_RANGE(0x804020, 0x804021) AM_READ_PORT("IN2")                                                 /* IN2 + EEPROM */
r6740r6741
876861   AM_RANGE(0x8040a0, 0x8040a1) AM_WRITENOP                                                         /* Unknown (reset once on startup) */
877862   AM_RANGE(0x8040b0, 0x8040b3) AM_READ(kludge_r)                                                /* unknown (xmcotaj hangs if this is 0) */
878863   AM_RANGE(0x8040e0, 0x8040e1) AM_WRITE(cps2_objram_bank_w)                                       /* bit 0 = Object ram bank swap */
879   AM_RANGE(0x804100, 0x80413f) AM_WRITE(cps1_cps_a_w) AM_BASE(&cps1_cps_a_regs)                         /* CPS-A custom */
864   AM_RANGE(0x804100, 0x80413f) AM_WRITE(cps1_cps_a_w) AM_BASE_MEMBER(cps_state, cps_a_regs)                         /* CPS-A custom */
880865   AM_RANGE(0x804140, 0x80417f) AM_READWRITE(cps1_cps_b_r, cps1_cps_b_w)                                   /* CPS-B custom */
881   AM_RANGE(0x900000, 0x92ffff) AM_RAM_WRITE(cps1_gfxram_w) AM_BASE(&cps1_gfxram) AM_SIZE(&cps1_gfxram_size)   /* Video RAM */
866   AM_RANGE(0x900000, 0x92ffff) AM_RAM_WRITE(cps1_gfxram_w) AM_BASE_SIZE_MEMBER(cps_state, gfxram, gfxram_size)   /* Video RAM */
882867   AM_RANGE(0xff0000, 0xffffef) AM_RAM                                                         /* RAM */
883   AM_RANGE(0xfffff0, 0xfffffb) AM_RAM AM_BASE(&cps2_output) AM_SIZE(&cps2_output_size)                  /* CPS2 output */
868   AM_RANGE(0xfffff0, 0xfffffb) AM_RAM AM_BASE_SIZE_MEMBER(cps_state, output, output_size)                  /* CPS2 output */
884869ADDRESS_MAP_END
885870
886871
r6740r6741
892877
893878/* 4 players and 4 buttons */
894879static INPUT_PORTS_START( cps2_4p4b )
895   PORT_START("IN0")      /* IN0 (0x00) */
880   PORT_START("IN0")      /* (0x00) */
896881   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
897882   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
898883   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
r6740r6741
910895   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
911896   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2)
912897
913   PORT_START("IN1")      /* IN1 (0x10) */
898   PORT_START("IN1")      /* (0x10) */
914899   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(3)
915900   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(3)
916901   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(3)
r6740r6741
928913   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(4)
929914   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(4)
930915
931   PORT_START("IN2")      /* IN2 (0x20) */
916   PORT_START("IN2")      /* (0x20) */
932917   PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
933918   PORT_SERVICE_NO_TOGGLE( 0x0002, IP_ACTIVE_LOW )
934919   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SERVICE1 )
r6740r6741
11981183 *
11991184 *************************************/
12001185
1186static MACHINE_START( cps2 )
1187{
1188   cps_state *state = (cps_state *)machine->driver_data;
1189
1190   state->maincpu = devtag_get_device(machine, "maincpu");
1191   state->audiocpu = devtag_get_device(machine, "audiocpu");
1192
1193   state_save_register_global(machine, state->scancount);
1194
1195   if (state->audiocpu != NULL)   // gigamn2 has no audiocpu
1196      memory_configure_bank(machine, "bank1", 0, (QSOUND_SIZE - 0x10000) / 0x4000, memory_region(machine, "audiocpu") + 0x10000, 0x4000);
1197}
1198
1199
12011200static MACHINE_DRIVER_START( cps2 )
12021201
1202   /* driver data */
1203   MDRV_DRIVER_DATA(cps_state)
1204
12031205   /* basic machine hardware */
12041206   MDRV_CPU_ADD("maincpu", M68000, XTAL_16MHz)
12051207   MDRV_CPU_PROGRAM_MAP(cps2_map)
r6740r6741
12091211   MDRV_CPU_PROGRAM_MAP(qsound_sub_map)
12101212   MDRV_CPU_PERIODIC_INT(irq0_line_hold, 251)   /* 251 is good (see 'mercy mercy mercy'section of sgemf attract mode for accurate sound sync */
12111213
1214   MDRV_MACHINE_START(cps2)
1215
12121216   MDRV_EEPROM_NODEFAULT_ADD("eeprom", cps2_eeprom_interface)
12131217
12141218   /* video hardware */
r6740r6741
33053309   ROM_LOAD16_WORD_SWAP( "ggw.12m",   0x400000, 0x400000, CRC(4bee4e8f) SHA1(c440b5a38359ec3b8002f39690b79bf78703f5d0) )
33063310ROM_END
33073311
3308
33093312ROM_START( hsf2 )
33103313   ROM_REGION( CODE_SIZE, "maincpu", 0 )      /* 68000 code */
3314   ROM_LOAD16_WORD_SWAP( "hs2.03u",  0x000000, 0x80000, CRC(b308151e) SHA1(afdfd3b049c6435e2291bc35d8c26ff5bff223d8) )
3315   ROM_LOAD16_WORD_SWAP( "hs2.04u",  0x080000, 0x80000, CRC(327aa49c) SHA1(6719cd6ecc2a4487fdbf5cbcd47e35fc43000607) )
3316   ROM_LOAD16_WORD_SWAP( "hs2.05",   0x100000, 0x80000, CRC(dde34a35) SHA1(f5be2d2916db6e86e0886d61d55bddf138273ebc) )
3317   ROM_LOAD16_WORD_SWAP( "hs2.06",   0x180000, 0x80000, CRC(f4e56dda) SHA1(c6490707c2a416ab88612c2d73abbe5853d8cb92) )
3318   ROM_LOAD16_WORD_SWAP( "hs2.07",   0x200000, 0x80000, CRC(ee4420fc) SHA1(06cf76660b0c794d2460c52d9fe8334fff51e9de) )
3319   ROM_LOAD16_WORD_SWAP( "hs2.08",   0x280000, 0x80000, CRC(c9441533) SHA1(bf178fac1f060fcce3ff9118333c8517dadc9429) )
3320   ROM_LOAD16_WORD_SWAP( "hs2.09",   0x300000, 0x80000, CRC(3fc638a8) SHA1(2a42877b26c8abc437da46225701f0bba6e40058) )
3321   ROM_LOAD16_WORD_SWAP( "hs2.10",   0x380000, 0x80000, CRC(20d0f9e4) SHA1(80a5eeef9472e327b0d4ee26434bad109a9434ea) )
3322
3323   ROM_REGION( 0x2000000, "gfx", 0 )
3324   ROMX_LOAD( "hs2.13m",   0x0000000, 0x800000, CRC(a6ecab17) SHA1(6749a4c8dc81f4b10f910c31c82cf6674e2a44eb) , ROM_GROUPWORD | ROM_SKIP(6) )
3325   ROMX_LOAD( "hs2.15m",   0x0000002, 0x800000, CRC(10a0ae4d) SHA1(701b4900fbc8bef20efa1a706891c8df4bf14641) , ROM_GROUPWORD | ROM_SKIP(6) )
3326   ROMX_LOAD( "hs2.17m",   0x0000004, 0x800000, CRC(adfa7726) SHA1(8d36ec125a8c91abfe5213893d794f8bc11c8acd) , ROM_GROUPWORD | ROM_SKIP(6) )
3327   ROMX_LOAD( "hs2.19m",   0x0000006, 0x800000, CRC(bb3ae322) SHA1(ecd289d7a0fe365fdd7c5527cb17796002beb553) , ROM_GROUPWORD | ROM_SKIP(6) )
3328
3329   ROM_REGION( QSOUND_SIZE, "audiocpu", 0 ) /* 64k for the audio CPU (+banks) */
3330   ROM_LOAD( "hs2.01",   0x00000, 0x08000, CRC(c1a13786) SHA1(c7392c7efb15ea4042e75bd9007e974293d8935d) )
3331   ROM_CONTINUE(         0x10000, 0x18000 )
3332   ROM_LOAD( "hs2.02",   0x28000, 0x20000, CRC(2d8794aa) SHA1(c634affdc2568020cce6af97b4fa79925d9943f3) )
3333
3334   ROM_REGION( 0x800000, "qsound", 0 ) /* QSound samples */
3335   ROM_LOAD16_WORD_SWAP( "hs2.11m",   0x000000, 0x800000, CRC(0e15c359) SHA1(176108b0d76d821a849324680aba0cd04b5016c1) )
3336ROM_END
3337
3338ROM_START( hsf2a )
3339   ROM_REGION( CODE_SIZE, "maincpu", 0 )      /* 68000 code */
33113340   ROM_LOAD16_WORD_SWAP( "hs2a.03",  0x000000, 0x80000, CRC(d50a17e0) SHA1(5d8d6d309260cc2d862aa080d44a72886ee08c77) )
33123341   ROM_LOAD16_WORD_SWAP( "hs2a.04",  0x080000, 0x80000, CRC(a27f42de) SHA1(7a355831b57a35e327b2618fd5dca11afed2a233) )
33133342   ROM_LOAD16_WORD_SWAP( "hs2.05",   0x100000, 0x80000, CRC(dde34a35) SHA1(f5be2d2916db6e86e0886d61d55bddf138273ebc) )
33143343   ROM_LOAD16_WORD_SWAP( "hs2.06",   0x180000, 0x80000, CRC(f4e56dda) SHA1(c6490707c2a416ab88612c2d73abbe5853d8cb92) )
3315   ROM_LOAD16_WORD_SWAP( "hs2a.07",  0x200000, 0x80000, CRC(ee4420fc) SHA1(06cf76660b0c794d2460c52d9fe8334fff51e9de) )
3344   ROM_LOAD16_WORD_SWAP( "hs2.07",   0x200000, 0x80000, CRC(ee4420fc) SHA1(06cf76660b0c794d2460c52d9fe8334fff51e9de) )
33163345   ROM_LOAD16_WORD_SWAP( "hs2.08",   0x280000, 0x80000, CRC(c9441533) SHA1(bf178fac1f060fcce3ff9118333c8517dadc9429) )
33173346   ROM_LOAD16_WORD_SWAP( "hs2.09",   0x300000, 0x80000, CRC(3fc638a8) SHA1(2a42877b26c8abc437da46225701f0bba6e40058) )
33183347   ROM_LOAD16_WORD_SWAP( "hs2.10",   0x380000, 0x80000, CRC(20d0f9e4) SHA1(80a5eeef9472e327b0d4ee26434bad109a9434ea) )
r6740r6741
33373366   ROM_LOAD16_WORD_SWAP( "hs2j.03",  0x000000, 0x80000, CRC(00738f73) SHA1(99947a621f21a88dc4c425d9bfbc30b3c5f76ecd) )
33383367   ROM_LOAD16_WORD_SWAP( "hs2j.04",  0x080000, 0x80000, CRC(40072c4a) SHA1(85b95bd3c907b4276a31777e092b8c40d3763257) )
33393368   ROM_LOAD16_WORD_SWAP( "hs2.05",   0x100000, 0x80000, CRC(dde34a35) SHA1(f5be2d2916db6e86e0886d61d55bddf138273ebc) )
3340   ROM_LOAD16_WORD_SWAP( "hs2.06",   0x180000, 0x80000, CRC(f4e56dda) SHA1(c6490707c2a416ab88612c2d73abbe5853d8cb92) )
3341   ROM_LOAD16_WORD_SWAP( "hs2j.07",  0x200000, 0x80000, CRC(09fe85b4) SHA1(b15b3ae28a6a395d26580dc8f4b506507792df38) )
3369   ROM_LOAD16_WORD_SWAP( "hs2.06",   0x180000, 0x80000, CRC(f4e56dda) SHA1(c6490707c2a416ab88612c2d73abbe5853d8cb92) ) /* Rom 07 needs to be verified, US & Asia 07 match */
3370   ROM_LOAD16_WORD_SWAP( "hs2j.07",  0x200000, 0x80000, BAD_DUMP CRC(09fe85b4) SHA1(b15b3ae28a6a395d26580dc8f4b506507792df38) ) /* 1 bit difference at 7C1AD EF <-> FF */
33423371   ROM_LOAD16_WORD_SWAP( "hs2.08",   0x280000, 0x80000, CRC(c9441533) SHA1(bf178fac1f060fcce3ff9118333c8517dadc9429) )
33433372   ROM_LOAD16_WORD_SWAP( "hs2.09",   0x300000, 0x80000, CRC(3fc638a8) SHA1(2a42877b26c8abc437da46225701f0bba6e40058) )
33443373   ROM_LOAD16_WORD_SWAP( "hs2.10",   0x380000, 0x80000, CRC(20d0f9e4) SHA1(80a5eeef9472e327b0d4ee26434bad109a9434ea) )
r6740r6741
75507579
75517580/*************************************
75527581 *
7553 *  Games initialisation
7582 *  Games initialization
75547583 *
75557584 *************************************/
75567585
75577586static DRIVER_INIT( cps2 )
75587587{
7588   cps_state *state = (cps_state *)machine->driver_data;
7589
75597590   /* Decrypt the game - see machine/cps2crpt.c */
75607591   DRIVER_INIT_CALL(cps2crpt);
7561   cps2networkpresent = 0;
75627592
7593   /* Initialize some video elements */
7594   DRIVER_INIT_CALL(cps2_video);
7595
7596   state->scancount = 0;
7597   state->cps2networkpresent = 0;
7598
75637599   cpu_set_clockscale(cputag_get_cpu(machine, "maincpu"), 0.7375f); /* RAM access waitstates etc. aren't emulated - slow the CPU to compensate */
75647600}
75657601
75667602static DRIVER_INIT( ssf2tb )
75677603{
7604   cps_state *state = (cps_state *)machine->driver_data;
7605
75687606   DRIVER_INIT_CALL(cps2);
7569   cps2networkpresent = 0;
75707607
7608   state->cps2networkpresent = 0;
7609
75717610   /* we don't emulate the network board, so don't say it's present for now, otherwise the game will
75727611       attempt to boot in tournament mode and fail */
7573   //cps2networkpresent = 1;
7612   //state->cps2networkpresent = 1;
75747613
75757614}
75767615
75777616static DRIVER_INIT ( pzloop2 )
75787617{
7618   cps_state *state = (cps_state *)machine->driver_data;
7619
75797620   DRIVER_INIT_CALL(cps2);
7621
7622   state->readpaddle = 0;
7623
7624   state_save_register_global(machine, state->readpaddle);
7625
75807626   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x804000, 0x804001, 0, 0, joy_or_paddle_r);
75817627}
75827628
7583static UINT16* gigamn2_dummyqsound_ram;
7584static READ16_HANDLER( gigamn2_dummyqsound_r ) { return gigamn2_dummyqsound_ram[offset]; };
7585static WRITE16_HANDLER( gigamn2_dummyqsound_w ) { gigamn2_dummyqsound_ram[offset] = data; };
7629static READ16_HANDLER( gigamn2_dummyqsound_r )
7630{
7631   cps_state *state = (cps_state *)space->machine->driver_data;
7632   return state->gigamn2_dummyqsound_ram[offset];
7633};
75867634
7635static WRITE16_HANDLER( gigamn2_dummyqsound_w )
7636{
7637   cps_state *state = (cps_state *)space->machine->driver_data;
7638   state->gigamn2_dummyqsound_ram[offset] = data;
7639};
7640
75877641static DRIVER_INIT( gigamn2 )
75887642{
7643   cps_state *state = (cps_state *)machine->driver_data;
75897644   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
75907645   UINT16 *rom = (UINT16 *)memory_region(machine, "maincpu");
75917646   int length = memory_region_length(machine, "maincpu");
75927647
75937648   DRIVER_INIT_CALL(cps2);
75947649
7595   gigamn2_dummyqsound_ram = auto_alloc_array(machine, UINT16, 0x20000/2);
7650   state->gigamn2_dummyqsound_ram = auto_alloc_array(machine, UINT16, 0x20000 / 2);
7651   state_save_register_global_pointer(machine, state->gigamn2_dummyqsound_ram, 0x20000 / 2);
7652
75967653   memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x618000, 0x619fff, 0, 0, gigamn2_dummyqsound_r, gigamn2_dummyqsound_w); // no qsound..
75977654   memory_set_decrypted_region(space, 0x000000, (length) - 1, &rom[length/4]);
7598   m68k_set_encrypted_opcode_range(cputag_get_cpu(machine, "maincpu"), 0, length);
7655   m68k_set_encrypted_opcode_range(devtag_get_device(machine, "maincpu"), 0, length);
75997656}
76007657
76017658
r6740r6741
76057662 *
76067663 *************************************/
76077664
7608GAME( 1993, ssf2,     0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II: The New Challengers (World 930911)", 0 )
7609GAME( 1993, ssf2u,    ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II: The New Challengers (USA 930911)", 0 )
7610GAME( 1993, ssf2a,    ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II: The New Challengers (Asia 931005)", 0 )
7611GAME( 1993, ssf2ar1,  ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II: The New Challengers (Asia 930914)", 0 )
7612GAME( 1993, ssf2j,    ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II: The New Challengers (Japan 931005)", 0 )
7613GAME( 1993, ssf2jr1,  ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II: The New Challengers (Japan 930911)", 0 )
7614GAME( 1993, ssf2jr2,  ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II: The New Challengers (Japan 930910)", 0 )
7615GAME( 1993, ssf2h,    ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II: The New Challengers (Hispanic 930911)", 0 )
7616GAME( 1993, ssf2tb,   ssf2,     cps2, cps2_2p6b, ssf2tb,   ROT0,   "Capcom", "Super Street Fighter II: The Tournament Battle (World 931119)", 0 )   // works, but not in tournament mode
7617GAME( 1993, ssf2tbr1, ssf2,     cps2, cps2_2p6b, ssf2tb,   ROT0,   "Capcom", "Super Street Fighter II: The Tournament Battle (World 930911)", 0 )   // works, but not in tournament mode
7618GAME( 1993, ssf2tbj,  ssf2,     cps2, cps2_2p6b, ssf2tb,   ROT0,   "Capcom", "Super Street Fighter II: The Tournament Battle (Japan 930911)", 0 )   // works, but not in tournament mode
7619GAME( 1993, ecofghtr, 0,        cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Eco Fighters (World 931203)", 0 )
7620GAME( 1993, ecofghtru,ecofghtr, cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Eco Fighters (USA 940215)", 0 )
7621GAME( 1993, ecofghtru1,ecofghtr,cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Eco Fighters (USA 931203)", 0 )
7622GAME( 1993, uecology, ecofghtr, cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Ultimate Ecology (Japan 931203)", 0 )
7623GAME( 1993, ecofghtra,ecofghtr, cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Eco Fighters (Asia 931203)", 0 )
7624GAME( 1993, ddtod,    0,        cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (Euro 940412)", 0 )
7625GAME( 1993, ddtodr1,  ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (Euro 940113)", 0 )
7626GAME( 1993, ddtodu,   ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (USA 940125)", 0 )
7627GAME( 1993, ddtodur1, ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (USA 940113)", 0 )
7628GAME( 1993, ddtodj,   ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (Japan 940412)", 0 )
7629GAME( 1993, ddtodjr1, ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (Japan 940125)", 0 )
7630GAME( 1993, ddtodjr2, ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (Japan 940113)", 0 )
7631GAME( 1993, ddtoda,   ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (Asia 940113)", 0 )
7632GAME( 1993, ddtodh,   ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (Hispanic 940412)", 0 )
7633GAME( 1993, ddtodhr1, ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (Hispanic 940125)", 0 )
7634GAME( 1994, ssf2t,    ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II Turbo (World 940223)", 0 )
7635GAME( 1994, ssf2ta,   ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II Turbo (Asia 940223)", 0 )
7636GAME( 1994, ssf2tu,   ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II Turbo (USA 940323)", 0 )
7637GAME( 1994, ssf2tur1, ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II Turbo (USA 940223)", 0 )
7638GAME( 1994, ssf2xj,   ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II X: Grand Master Challenge (Japan 940223)", 0 )
7639GAME( 1994, avsp,     0,        cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Alien vs. Predator (Euro 940520)", 0 )
7640GAME( 1994, avspu,    avsp,     cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Alien vs. Predator (USA 940520)", 0 )
7641GAME( 1994, avspj,    avsp,     cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Alien vs. Predator (Japan 940520)", 0 )
7642GAME( 1994, avspa,    avsp,     cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Alien vs. Predator (Asia 940520)", 0 )
7643GAME( 1994, avsph,    avsp,     cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Alien vs. Predator (Hispanic 940520)", 0 )
7644GAME( 1994, dstlk,    0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Darkstalkers: The Night Warriors (Euro 940705)", 0 )
7645GAME( 1994, dstlku,   dstlk,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Darkstalkers: The Night Warriors (USA 940818)", 0 )
7646GAME( 1994, dstlkur1, dstlk,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Darkstalkers: The Night Warriors (USA 940705)", 0 )
7647GAME( 1994, dstlka,   dstlk,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Darkstalkers: The Night Warriors (Asia 940705)", 0 )
7648GAME( 1994, dstlkh,   dstlk,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Darkstalkers: The Night Warriors (Hispanic 940818)", 0 )
7649GAME( 1994, vampj,    dstlk,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire: The Night Warriors (Japan 940705)", 0 )   // partial update set? Only rom 04 is "B" revision
7650GAME( 1994, vampja,   dstlk,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire: The Night Warriors (Japan 940705 alt)", 0 )
7651GAME( 1994, vampjr1,  dstlk,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire: The Night Warriors (Japan 940630)", 0 )
7652GAME( 1994, ringdest, 0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Ring of Destruction: Slammasters II (Euro 940902)", 0 )
7653GAME( 1994, smbomb,   ringdest, cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Muscle Bomber: The International Blowout (Japan 940831)", 0 )
7654GAME( 1994, smbombr1, ringdest, cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Muscle Bomber: The International Blowout (Japan 940808)", 0 )
7655GAME( 1994, armwar,   0,        cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Armored Warriors (Euro 941024)", 0 )
7656GAME( 1994, armwarr1, armwar,   cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Armored Warriors (Euro 941011)", 0 )
7657GAME( 1994, armwaru,  armwar,   cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Armored Warriors (USA 941024)", 0 )
7658GAME( 1994, armwaru1, armwar,   cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Armored Warriors (USA 940920)", 0 )
7659GAME( 1994, pgear,    armwar,   cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Powered Gear: Strategic Variant Armor Equipment (Japan 941024)", 0 )
7660GAME( 1994, pgearr1,  armwar,   cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Powered Gear: Strategic Variant Armor Equipment (Japan 940916)", 0 )
7661GAME( 1994, armwara,  armwar,   cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Armored Warriors (Asia 940920)", 0 )
7662GAME( 1994, xmcota,   0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Euro 950105)", 0 )
7663GAME( 1994, xmcotau,  xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (USA 950105)", 0 )
7664GAME( 1994, xmcotah,  xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Hispanic 950331)", 0 )
7665GAME( 1994, xmcotaj,  xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Japan 941222)", 0 )
7666GAME( 1994, xmcotaj1, xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Japan 941219)", 0 )
7667GAME( 1994, xmcotaj2, xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Japan 941217)", 0 )
7668GAME( 1994, xmcotajr, xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Japan 941208 rent version)", 0 )
7669GAME( 1994, xmcotaa,  xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Asia 941217)", 0 )
7670GAME( 1995, nwarr,    0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Night Warriors: Darkstalkers' Revenge (Euro 950316)", 0 )
7671GAME( 1995, nwarru,   nwarr,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Night Warriors: Darkstalkers' Revenge (USA 950406)", 0 )
7672GAME( 1995, nwarrh,   nwarr,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Night Warriors: Darkstalkers' Revenge (Hispanic 950403)", 0 )
7673GAME( 1995, nwarrb,   nwarr,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Night Warriors: Darkstalkers' Revenge (Brazil 950403)", 0 )
7674GAME( 1995, nwarra,   nwarr,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Night Warriors: Darkstalkers' Revenge (Asia 950302)", 0 )
7675GAME( 1995, vhuntj,   nwarr,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Hunter: Darkstalkers' Revenge (Japan 950316)", 0 )
7676GAME( 1995, vhuntjr1, nwarr,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Hunter: Darkstalkers' Revenge (Japan 950307)", 0 )
7677GAME( 1995, vhuntjr2, nwarr,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Hunter: Darkstalkers' Revenge (Japan 950302)", 0 )
7678GAME( 1995, cybots,   0,        cps2, cybots,    cps2,     ROT0,   "Capcom", "Cyberbots: Fullmetal Madness (Euro 950424)", 0 )
7679GAME( 1995, cybotsu,  cybots,   cps2, cybots,    cps2,     ROT0,   "Capcom", "Cyberbots: Fullmetal Madness (USA 950424)", 0 )
7680GAME( 1995, cybotsj,  cybots,   cps2, cybots,    cps2,     ROT0,   "Capcom", "Cyberbots: Fullmetal Madness (Japan 950420)", 0 )
7681GAME( 1995, sfa,      0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha: Warriors' Dreams (Euro 950727)", 0 )
7682GAME( 1995, sfar1,    sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha: Warriors' Dreams (Euro 950718)", 0 )
7683GAME( 1995, sfar2,    sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha: Warriors' Dreams (Euro 950627)", 0 )
7684GAME( 1995, sfar3,    sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha: Warriors' Dreams (Euro 950605)", 0 )
7685GAME( 1995, sfau,     sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha: Warriors' Dreams (USA 950627)", 0 )
7686GAME( 1995, sfza,     sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero (Asia 950627)", 0 )
7687GAME( 1995, sfzj,     sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero (Japan 950727)", 0 )
7688GAME( 1995, sfzjr1,   sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero (Japan 950627)", 0 )
7689GAME( 1995, sfzjr2,   sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero (Japan 950605)", 0 )
7690GAME( 1995, sfzh,     sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero (Hispanic 950627)", 0 )
7691GAME( 1995, sfzb,     sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero (Brazil 951109)", 0 )
7692GAME( 1995, sfzbr1,   sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero (Brazil 950727)", 0 )
7693GAME( 1995, mmancp2u, megaman,  cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Mega Man - The Power Battle (CPS2, USA 951006, SAMPLE Version)", 0 )
7694GAME( 1995, rmancp2j, megaman,  cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Rockman: The Power Battle (CPS2, Japan 950922)", 0 )
7695GAME( 1995, msh,      0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes (Euro 951024)", 0 )
7696GAME( 1995, mshu,     msh,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes (USA 951024)", 0 )
7697GAME( 1995, mshj,     msh,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes (Japan 951117)", 0 )
7698GAME( 1995, mshjr1,   msh,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes (Japan 951024)", 0 )
7699GAME( 1995, msha,     msh,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes (Asia 951024)", 0 )
7700GAME( 1995, mshh,     msh,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes (Hispanic 951117)", 0 )
7701GAME( 1995, mshb,     msh,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes (Brazil 951117)", 0 )
7702GAME( 1996, 19xx,     0,        cps2, cps2_2p2b, cps2,     ROT270, "Capcom", "19XX: The War Against Destiny (USA 951207)", 0 )
7703GAME( 1996, 19xxa,    19xx,     cps2, cps2_2p2b, cps2,     ROT270, "Capcom", "19XX: The War Against Destiny (Asia 951207)", 0 )
7704GAME( 1996, 19xxj,    19xx,     cps2, cps2_2p2b, cps2,     ROT270, "Capcom", "19XX: The War Against Destiny (Japan 951225)", 0 )
7705GAME( 1996, 19xxjr1,  19xx,     cps2, cps2_2p2b, cps2,     ROT270, "Capcom", "19XX: The War Against Destiny (Japan 951207)", 0 )
7706GAME( 1996, 19xxh,    19xx,     cps2, cps2_2p2b, cps2,     ROT270, "Capcom", "19XX: The War Against Destiny (Hispanic 951218)", 0 )
7707GAME( 1996, 19xxb,    19xx,     cps2, cps2_2p2b, cps2,     ROT270, "Capcom", "19XX: The War Against Destiny (Brazil 951218)", 0 )
7708GAME( 1996, ddsom,    0,        cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Euro 960619)", 0 )
7709GAME( 1996, ddsomr1,  ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Euro 960223)", 0 )
7710GAME( 1996, ddsomr2,  ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Euro 960209)", 0 )
7711GAME( 1996, ddsomr3,  ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Euro 960208)", 0 )
7712GAME( 1996, ddsomu,   ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (USA 960619)", 0 )
7713GAME( 1996, ddsomur1, ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (USA 960209)", 0 )
7714GAME( 1996, ddsomj,   ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Japan 960619)", 0 )
7715GAME( 1996, ddsomjr1, ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Japan 960206)", 0 )
7716GAME( 1996, ddsoma,   ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Asia 960619)", 0 )
7717GAME( 1996, ddsomh,   ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Hispanic 960223)", 0 )
7718GAME( 1996, ddsomb,   ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Brazil 960223)", 0 )
7719GAME( 1996, sfa2,     0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha 2 (Euro 960229)", 0 )
7720GAME( 1996, sfa2u,    sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha 2 (USA 960306)", 0 )
7721GAME( 1996, sfz2j,    sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 (Japan 960227)", 0 )
7722GAME( 1996, sfz2a,    sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 (Asia 960227)", 0 )
7723GAME( 1996, sfz2b,    sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 (Brazil 960531)", 0 )
7724GAME( 1996, sfz2br1,  sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 (Brazil 960304)", 0 )
7725GAME( 1996, sfz2h,    sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 (Hispanic 960304)", 0 )
7726GAME( 1996, sfz2n,    sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 (Oceania 960229)", 0 )
7727GAME( 1996, sfz2al,   0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 Alpha (Asia 960826)", 0 )
7728GAME( 1996, sfz2alj,  sfz2al,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 Alpha (Japan 960805)", 0 )
7729GAME( 1996, sfz2alh,  sfz2al,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 Alpha (Hispanic 960813)", 0 )
7730GAME( 1996, sfz2alb,  sfz2al,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 Alpha (Brazil 960813)", 0 )
7731GAME( 1996, spf2t,    0,        cps2, cps2_2p2b, cps2,     ROT0,   "Capcom", "Super Puzzle Fighter II Turbo (USA 960620)", 0 )
7732GAME( 1996, spf2xj,   spf2t,    cps2, cps2_2p2b, cps2,     ROT0,   "Capcom", "Super Puzzle Fighter II X (Japan 960531)", 0 )
7733GAME( 1996, spf2ta,   spf2t,    cps2, cps2_2p2b, cps2,     ROT0,   "Capcom", "Super Puzzle Fighter II Turbo (Asia 960529)", 0 )
7734GAME( 1996, spf2th,   spf2t,    cps2, cps2_2p2b, cps2,     ROT0,   "Capcom", "Super Puzzle Fighter II Turbo (Hispanic 960531)", 0 )
7735GAME( 1996, megaman2, 0,        cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Mega Man 2: The Power Fighters (USA 960708)", 0 )
7736GAME( 1996, megaman2a,megaman2, cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Mega Man 2: The Power Fighters (Asia 960708)", 0 )
7737GAME( 1996, rockman2j,megaman2, cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Rockman 2: The Power Fighters (Japan 960708)", 0 )
7738GAME( 1996, megaman2h,megaman2, cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Mega Man 2: The Power Fighters (Hispanic 960712)", 0 )
7739GAME( 1996, qndream,  0,        cps2, qndream,   cps2,     ROT0,   "Capcom", "Quiz Nanairo Dreams: Nijiirochou no Kiseki (Japan 960826)", 0 )
7740GAME( 1996, xmvsf,    0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Euro 961004)", 0 )
7741GAME( 1996, xmvsfr1,  xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Euro 960910)", 0 )
7742GAME( 1996, xmvsfu,   xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (USA 961023)", 0 )
7743GAME( 1996, xmvsfur1, xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (USA 961004)", 0 )
7744GAME( 1996, xmvsfj,   xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Japan 961004)", 0 )
7745GAME( 1996, xmvsfjr1, xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Japan 960910)", 0 )
7746GAME( 1996, xmvsfjr2, xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Japan 960909)", 0 )
7747GAME( 1996, xmvsfa,   xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Asia 961023)", 0 )
7748GAME( 1996, xmvsfar1, xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Asia 960919)", 0 )
7749GAME( 1996, xmvsfh,   xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Hispanic 961004)", 0 )
7750GAME( 1996, xmvsfb,   xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Brazil 961023)", 0 )
7751GAME( 1997, batcir,   0,        cps2, cps2_4p2b, cps2,     ROT0,   "Capcom", "Battle Circuit (Euro 970319)", 0 )
7752GAME( 1997, batcira,  batcir,   cps2, cps2_4p2b, cps2,     ROT0,   "Capcom", "Battle Circuit (Asia 970319)", 0 )
7753GAME( 1997, batcirj,  batcir,   cps2, cps2_4p2b, cps2,     ROT0,   "Capcom", "Battle Circuit (Japan 970319)", 0 )
7754GAME( 1997, vsav,     0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Savior: The Lord of Vampire (Euro 970519)", 0 )
7755GAME( 1997, vsavu,    vsav,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Savior: The Lord of Vampire (USA 970519)", 0 )
7756GAME( 1997, vsavj,    vsav,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Savior: The Lord of Vampire (Japan 970519)", 0 )
7757GAME( 1997, vsava,    vsav,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Savior: The Lord of Vampire (Asia 970519)", 0 )
7758GAME( 1997, vsavh,    vsav,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Savior: The Lord of Vampire (Hispanic 970519)", 0 )
7759GAME( 1997, mshvsf,   0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Euro 970625)", 0 )
7760GAME( 1997, mshvsfu,  mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (USA 970827)", 0 )
7761GAME( 1997, mshvsfu1, mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (USA 970625)", 0 )
7762GAME( 1997, mshvsfj,  mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Japan 970707)", 0 )
7763GAME( 1997, mshvsfj1, mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Japan 970702)", 0 )
7764GAME( 1997, mshvsfj2, mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Japan 970625)", 0 )
7765GAME( 1997, mshvsfh,  mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Hispanic 970625)", 0 )
7766GAME( 1997, mshvsfa,  mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Asia 970625)", 0 )
7767GAME( 1997, mshvsfa1, mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Asia 970620)", 0 )
7768GAME( 1997, mshvsfb,  mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Brazil 970827)", 0 )
7769GAME( 1997, mshvsfb1, mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Brazil 970625)", 0 )
7770GAME( 1997, csclub,   0,        cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Capcom Sports Club (Euro 971017)", 0 )
7771GAME( 1997, csclub1,  csclub,   cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Capcom Sports Club (Euro 970722)", 0 )
7772GAME( 1997, cscluba,  csclub,   cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Capcom Sports Club (Asia 970722)", 0 )
7773GAME( 1997, csclubj,  csclub,   cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Capcom Sports Club (Japan 970722)", 0 )
7774GAME( 1997, csclubh,  csclub,   cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Capcom Sports Club (Hispanic 970722)", 0 )
7775GAME( 1997, sgemf,    0,        cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Super Gem Fighter Mini Mix (USA 970904)", 0 )
7776GAME( 1997, pfghtj,   sgemf,    cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Pocket Fighter (Japan 970904)", 0 )
7777GAME( 1997, sgemfa,   sgemf,    cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Super Gem Fighter: Mini Mix (Asia 970904)", 0 )
7778GAME( 1997, sgemfh,   sgemf,    cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Super Gem Fighter: Mini Mix (Hispanic 970904)", 0 )
7779GAME( 1997, vhunt2,   0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Hunter 2: Darkstalkers Revenge (Japan 970929)", 0 )
7780GAME( 1997, vhunt2r1, vhunt2,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Hunter 2: Darkstalkers Revenge (Japan 970913)", 0 )
7781GAME( 1997, vsav2,    0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Savior 2: The Lord of Vampire (Japan 970913)", 0 )
7782GAME( 1998, mvsc,     0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Euro 980123)", 0 )
7783GAME( 1998, mvscr1,   mvsc,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Euro 980112)", 0 )
7784GAME( 1998, mvscu,    mvsc,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (USA 980123)", 0 )
7785GAME( 1998, mvscj,    mvsc,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Japan 980123)", 0 )
7786GAME( 1998, mvscjr1,  mvsc,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Japan 980112)", 0 )
7787GAME( 1998, mvsca,    mvsc,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Asia 980123)", 0 )
7788GAME( 1998, mvscar1,  mvsc,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Asia 980112)", 0 )
7789GAME( 1998, mvsch,    mvsc,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Hispanic 980123)", 0 )
7790GAME( 1998, mvscb,    mvsc,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Brazil 980123)", 0 )
7791GAME( 1998, sfa3,     0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha 3 (Euro 980904)", 0 )
7792GAME( 1998, sfa3u,    sfa3,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha 3 (USA 980904)", 0 )
7793GAME( 1998, sfa3ur1,  sfa3,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha 3 (USA 980629)", 0 )
7794GAME( 1998, sfa3b,    sfa3,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha 3 (Brazil 980629)", 0 )
7795GAME( 1998, sfz3j,    sfa3,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 3 (Japan 980904)", 0 )
7796GAME( 1998, sfz3jr1,  sfa3,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 3 (Japan 980727)", 0 )
7797GAME( 1998, sfz3jr2,  sfa3,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 3 (Japan 980629)", 0 )
7798GAME( 1998, sfz3a,    sfa3,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 3 (Asia 980904)", 0 )
7799GAME( 1998, sfz3ar1,  sfa3,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 3 (Asia 980701)", 0 )
7800GAME( 1999, jyangoku, 0,        cps2, cps2_1p2b, cps2,     ROT0,   "Capcom", "Jyangokushi: Haoh no Saihai (Japan 990527)", 0 )
7801GAME( 2004, hsf2,     0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Hyper Street Fighter 2: The Anniversary Edition (Asia 040202)", 0 )
7802GAME( 2004, hsf2j,    hsf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Hyper Street Fighter 2: The Anniversary Edition (Japan 031222)", 0 )
7665GAME( 1993, ssf2,       0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II: The New Challengers (World 930911)", GAME_SUPPORTS_SAVE )
7666GAME( 1993, ssf2u,      ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II: The New Challengers (USA 930911)", GAME_SUPPORTS_SAVE )
7667GAME( 1993, ssf2a,      ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II: The New Challengers (Asia 931005)", GAME_SUPPORTS_SAVE )
7668GAME( 1993, ssf2ar1,    ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II: The New Challengers (Asia 930914)", GAME_SUPPORTS_SAVE )
7669GAME( 1993, ssf2j,      ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II: The New Challengers (Japan 931005)", GAME_SUPPORTS_SAVE )
7670GAME( 1993, ssf2jr1,    ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II: The New Challengers (Japan 930911)", GAME_SUPPORTS_SAVE )
7671GAME( 1993, ssf2jr2,    ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II: The New Challengers (Japan 930910)", GAME_SUPPORTS_SAVE )
7672GAME( 1993, ssf2h,      ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II: The New Challengers (Hispanic 930911)", GAME_SUPPORTS_SAVE )
7673GAME( 1993, ssf2tb,     ssf2,     cps2, cps2_2p6b, ssf2tb,   ROT0,   "Capcom", "Super Street Fighter II: The Tournament Battle (World 931119)", GAME_SUPPORTS_SAVE )   // works, but not in tournament mode
7674GAME( 1993, ssf2tbr1,   ssf2,     cps2, cps2_2p6b, ssf2tb,   ROT0,   "Capcom", "Super Street Fighter II: The Tournament Battle (World 930911)", GAME_SUPPORTS_SAVE )   // works, but not in tournament mode
7675GAME( 1993, ssf2tbj,    ssf2,     cps2, cps2_2p6b, ssf2tb,   ROT0,   "Capcom", "Super Street Fighter II: The Tournament Battle (Japan 930911)", GAME_SUPPORTS_SAVE )   // works, but not in tournament mode
7676GAME( 1993, ecofghtr,   0,        cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Eco Fighters (World 931203)", GAME_SUPPORTS_SAVE )
7677GAME( 1993, ecofghtru,  ecofghtr, cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Eco Fighters (USA 940215)", GAME_SUPPORTS_SAVE )
7678GAME( 1993, ecofghtru1, ecofghtr, cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Eco Fighters (USA 931203)", GAME_SUPPORTS_SAVE )
7679GAME( 1993, uecology,   ecofghtr, cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Ultimate Ecology (Japan 931203)", GAME_SUPPORTS_SAVE )
7680GAME( 1993, ecofghtra,  ecofghtr, cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Eco Fighters (Asia 931203)", GAME_SUPPORTS_SAVE )
7681GAME( 1993, ddtod,      0,        cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (Euro 940412)", GAME_SUPPORTS_SAVE )
7682GAME( 1993, ddtodr1,    ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (Euro 940113)", GAME_SUPPORTS_SAVE )
7683GAME( 1993, ddtodu,     ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (USA 940125)", GAME_SUPPORTS_SAVE )
7684GAME( 1993, ddtodur1,   ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (USA 940113)", GAME_SUPPORTS_SAVE )
7685GAME( 1993, ddtodj,     ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (Japan 940412)", GAME_SUPPORTS_SAVE )
7686GAME( 1993, ddtodjr1,   ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (Japan 940125)", GAME_SUPPORTS_SAVE )
7687GAME( 1993, ddtodjr2,   ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (Japan 940113)", GAME_SUPPORTS_SAVE )
7688GAME( 1993, ddtoda,     ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (Asia 940113)", GAME_SUPPORTS_SAVE )
7689GAME( 1993, ddtodh,     ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (Hispanic 940412)", GAME_SUPPORTS_SAVE )
7690GAME( 1993, ddtodhr1,   ddtod,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Tower of Doom (Hispanic 940125)", GAME_SUPPORTS_SAVE )
7691GAME( 1994, ssf2t,      ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II Turbo (World 940223)", GAME_SUPPORTS_SAVE )
7692GAME( 1994, ssf2ta,     ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II Turbo (Asia 940223)", GAME_SUPPORTS_SAVE )
7693GAME( 1994, ssf2tu,     ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II Turbo (USA 940323)", GAME_SUPPORTS_SAVE )
7694GAME( 1994, ssf2tur1,   ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II Turbo (USA 940223)", GAME_SUPPORTS_SAVE )
7695GAME( 1994, ssf2xj,     ssf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Street Fighter II X: Grand Master Challenge (Japan 940223)", GAME_SUPPORTS_SAVE )
7696GAME( 1994, avsp,       0,        cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Alien vs. Predator (Euro 940520)", GAME_SUPPORTS_SAVE )
7697GAME( 1994, avspu,      avsp,     cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Alien vs. Predator (USA 940520)", GAME_SUPPORTS_SAVE )
7698GAME( 1994, avspj,      avsp,     cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Alien vs. Predator (Japan 940520)", GAME_SUPPORTS_SAVE )
7699GAME( 1994, avspa,      avsp,     cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Alien vs. Predator (Asia 940520)", GAME_SUPPORTS_SAVE )
7700GAME( 1994, avsph,      avsp,     cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Alien vs. Predator (Hispanic 940520)", GAME_SUPPORTS_SAVE )
7701GAME( 1994, dstlk,      0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Darkstalkers: The Night Warriors (Euro 940705)", GAME_SUPPORTS_SAVE )
7702GAME( 1994, dstlku,     dstlk,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Darkstalkers: The Night Warriors (USA 940818)", GAME_SUPPORTS_SAVE )
7703GAME( 1994, dstlkur1,   dstlk,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Darkstalkers: The Night Warriors (USA 940705)", GAME_SUPPORTS_SAVE )
7704GAME( 1994, dstlka,     dstlk,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Darkstalkers: The Night Warriors (Asia 940705)", GAME_SUPPORTS_SAVE )
7705GAME( 1994, dstlkh,     dstlk,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Darkstalkers: The Night Warriors (Hispanic 940818)", GAME_SUPPORTS_SAVE )
7706GAME( 1994, vampj,      dstlk,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire: The Night Warriors (Japan 940705)", GAME_SUPPORTS_SAVE )   // partial update set? Only rom 04 is "B" revision
7707GAME( 1994, vampja,     dstlk,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire: The Night Warriors (Japan 940705 alt)", GAME_SUPPORTS_SAVE )
7708GAME( 1994, vampjr1,    dstlk,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire: The Night Warriors (Japan 940630)", GAME_SUPPORTS_SAVE )
7709GAME( 1994, ringdest,   0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Ring of Destruction: Slammasters II (Euro 940902)", GAME_SUPPORTS_SAVE )
7710GAME( 1994, smbomb,     ringdest, cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Muscle Bomber: The International Blowout (Japan 940831)", GAME_SUPPORTS_SAVE )
7711GAME( 1994, smbombr1,   ringdest, cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Super Muscle Bomber: The International Blowout (Japan 940808)", GAME_SUPPORTS_SAVE )
7712GAME( 1994, armwar,     0,        cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Armored Warriors (Euro 941024)", GAME_SUPPORTS_SAVE )
7713GAME( 1994, armwarr1,   armwar,   cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Armored Warriors (Euro 941011)", GAME_SUPPORTS_SAVE )
7714GAME( 1994, armwaru,    armwar,   cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Armored Warriors (USA 941024)", GAME_SUPPORTS_SAVE )
7715GAME( 1994, armwaru1,   armwar,   cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Armored Warriors (USA 940920)", GAME_SUPPORTS_SAVE )
7716GAME( 1994, pgear,      armwar,   cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Powered Gear: Strategic Variant Armor Equipment (Japan 941024)", GAME_SUPPORTS_SAVE )
7717GAME( 1994, pgearr1,    armwar,   cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Powered Gear: Strategic Variant Armor Equipment (Japan 940916)", GAME_SUPPORTS_SAVE )
7718GAME( 1994, armwara,    armwar,   cps2, cps2_3p3b, cps2,     ROT0,   "Capcom", "Armored Warriors (Asia 940920)", GAME_SUPPORTS_SAVE )
7719GAME( 1994, xmcota,     0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Euro 950105)", GAME_SUPPORTS_SAVE )
7720GAME( 1994, xmcotau,    xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (USA 950105)", GAME_SUPPORTS_SAVE )
7721GAME( 1994, xmcotah,    xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Hispanic 950331)", GAME_SUPPORTS_SAVE )
7722GAME( 1994, xmcotaj,    xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Japan 941222)", GAME_SUPPORTS_SAVE )
7723GAME( 1994, xmcotaj1,   xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Japan 941219)", GAME_SUPPORTS_SAVE )
7724GAME( 1994, xmcotaj2,   xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Japan 941217)", GAME_SUPPORTS_SAVE )
7725GAME( 1994, xmcotajr,   xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Japan 941208 rent version)", GAME_SUPPORTS_SAVE )
7726GAME( 1994, xmcotaa,    xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Asia 941217)", GAME_SUPPORTS_SAVE )
7727GAME( 1995, nwarr,      0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Night Warriors: Darkstalkers' Revenge (Euro 950316)", GAME_SUPPORTS_SAVE )
7728GAME( 1995, nwarru,     nwarr,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Night Warriors: Darkstalkers' Revenge (USA 950406)", GAME_SUPPORTS_SAVE )
7729GAME( 1995, nwarrh,     nwarr,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Night Warriors: Darkstalkers' Revenge (Hispanic 950403)", GAME_SUPPORTS_SAVE )
7730GAME( 1995, nwarrb,     nwarr,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Night Warriors: Darkstalkers' Revenge (Brazil 950403)", GAME_SUPPORTS_SAVE )
7731GAME( 1995, nwarra,     nwarr,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Night Warriors: Darkstalkers' Revenge (Asia 950302)", GAME_SUPPORTS_SAVE )
7732GAME( 1995, vhuntj,     nwarr,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Hunter: Darkstalkers' Revenge (Japan 950316)", GAME_SUPPORTS_SAVE )
7733GAME( 1995, vhuntjr1,   nwarr,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Hunter: Darkstalkers' Revenge (Japan 950307)", GAME_SUPPORTS_SAVE )
7734GAME( 1995, vhuntjr2,   nwarr,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Hunter: Darkstalkers' Revenge (Japan 950302)", GAME_SUPPORTS_SAVE )
7735GAME( 1995, cybots,     0,        cps2, cybots,    cps2,     ROT0,   "Capcom", "Cyberbots: Fullmetal Madness (Euro 950424)", GAME_SUPPORTS_SAVE )
7736GAME( 1995, cybotsu,    cybots,   cps2, cybots,    cps2,     ROT0,   "Capcom", "Cyberbots: Fullmetal Madness (USA 950424)", GAME_SUPPORTS_SAVE )
7737GAME( 1995, cybotsj,    cybots,   cps2, cybots,    cps2,     ROT0,   "Capcom", "Cyberbots: Fullmetal Madness (Japan 950420)", GAME_SUPPORTS_SAVE )
7738GAME( 1995, sfa,        0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha: Warriors' Dreams (Euro 950727)", GAME_SUPPORTS_SAVE )
7739GAME( 1995, sfar1,      sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha: Warriors' Dreams (Euro 950718)", GAME_SUPPORTS_SAVE )
7740GAME( 1995, sfar2,      sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha: Warriors' Dreams (Euro 950627)", GAME_SUPPORTS_SAVE )
7741GAME( 1995, sfar3,      sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha: Warriors' Dreams (Euro 950605)", GAME_SUPPORTS_SAVE )
7742GAME( 1995, sfau,       sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha: Warriors' Dreams (USA 950627)", GAME_SUPPORTS_SAVE )
7743GAME( 1995, sfza,       sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero (Asia 950627)", GAME_SUPPORTS_SAVE )
7744GAME( 1995, sfzj,       sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero (Japan 950727)", GAME_SUPPORTS_SAVE )
7745GAME( 1995, sfzjr1,     sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero (Japan 950627)", GAME_SUPPORTS_SAVE )
7746GAME( 1995, sfzjr2,     sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero (Japan 950605)", GAME_SUPPORTS_SAVE )
7747GAME( 1995, sfzh,       sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero (Hispanic 950627)", GAME_SUPPORTS_SAVE )
7748GAME( 1995, sfzb,       sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero (Brazil 951109)", GAME_SUPPORTS_SAVE )
7749GAME( 1995, sfzbr1,     sfa,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero (Brazil 950727)", GAME_SUPPORTS_SAVE )
7750GAME( 1995, mmancp2u,   megaman,  cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Mega Man - The Power Battle (CPS2, USA 951006, SAMPLE Version)", GAME_SUPPORTS_SAVE )
7751GAME( 1995, rmancp2j,   megaman,  cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Rockman: The Power Battle (CPS2, Japan 950922)", GAME_SUPPORTS_SAVE )
7752GAME( 1995, msh,        0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes (Euro 951024)", GAME_SUPPORTS_SAVE )
7753GAME( 1995, mshu,       msh,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes (USA 951024)", GAME_SUPPORTS_SAVE )
7754GAME( 1995, mshj,       msh,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes (Japan 951117)", GAME_SUPPORTS_SAVE )
7755GAME( 1995, mshjr1,     msh,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes (Japan 951024)", GAME_SUPPORTS_SAVE )
7756GAME( 1995, msha,       msh,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes (Asia 951024)", GAME_SUPPORTS_SAVE )
7757GAME( 1995, mshh,       msh,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes (Hispanic 951117)", GAME_SUPPORTS_SAVE )
7758GAME( 1995, mshb,       msh,      cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes (Brazil 951117)", GAME_SUPPORTS_SAVE )
7759GAME( 1996, 19xx,       0,        cps2, cps2_2p2b, cps2,     ROT270, "Capcom", "19XX: The War Against Destiny (USA 951207)", GAME_SUPPORTS_SAVE )
7760GAME( 1996, 19xxa,      19xx,     cps2, cps2_2p2b, cps2,     ROT270, "Capcom", "19XX: The War Against Destiny (Asia 951207)", GAME_SUPPORTS_SAVE )
7761GAME( 1996, 19xxj,      19xx,     cps2, cps2_2p2b, cps2,     ROT270, "Capcom", "19XX: The War Against Destiny (Japan 951225)", GAME_SUPPORTS_SAVE )
7762GAME( 1996, 19xxjr1,    19xx,     cps2, cps2_2p2b, cps2,     ROT270, "Capcom", "19XX: The War Against Destiny (Japan 951207)", GAME_SUPPORTS_SAVE )
7763GAME( 1996, 19xxh,      19xx,     cps2, cps2_2p2b, cps2,     ROT270, "Capcom", "19XX: The War Against Destiny (Hispanic 951218)", GAME_SUPPORTS_SAVE )
7764GAME( 1996, 19xxb,      19xx,     cps2, cps2_2p2b, cps2,     ROT270, "Capcom", "19XX: The War Against Destiny (Brazil 951218)", GAME_SUPPORTS_SAVE )
7765GAME( 1996, ddsom,      0,        cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Euro 960619)", GAME_SUPPORTS_SAVE )
7766GAME( 1996, ddsomr1,    ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Euro 960223)", GAME_SUPPORTS_SAVE )
7767GAME( 1996, ddsomr2,    ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Euro 960209)", GAME_SUPPORTS_SAVE )
7768GAME( 1996, ddsomr3,    ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Euro 960208)", GAME_SUPPORTS_SAVE )
7769GAME( 1996, ddsomu,     ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (USA 960619)", GAME_SUPPORTS_SAVE )
7770GAME( 1996, ddsomur1,   ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (USA 960209)", GAME_SUPPORTS_SAVE )
7771GAME( 1996, ddsomj,     ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Japan 960619)", GAME_SUPPORTS_SAVE )
7772GAME( 1996, ddsomjr1,   ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Japan 960206)", GAME_SUPPORTS_SAVE )
7773GAME( 1996, ddsoma,     ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Asia 960619)", GAME_SUPPORTS_SAVE )
7774GAME( 1996, ddsomh,     ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Hispanic 960223)", GAME_SUPPORTS_SAVE )
7775GAME( 1996, ddsomb,     ddsom,    cps2, cps2_4p4b, cps2,     ROT0,   "Capcom", "Dungeons & Dragons: Shadow over Mystara (Brazil 960223)", GAME_SUPPORTS_SAVE )
7776GAME( 1996, sfa2,       0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha 2 (Euro 960229)", GAME_SUPPORTS_SAVE )
7777GAME( 1996, sfa2u,      sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha 2 (USA 960306)", GAME_SUPPORTS_SAVE )
7778GAME( 1996, sfz2j,      sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 (Japan 960227)", GAME_SUPPORTS_SAVE )
7779GAME( 1996, sfz2a,      sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 (Asia 960227)", GAME_SUPPORTS_SAVE )
7780GAME( 1996, sfz2b,      sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 (Brazil 960531)", GAME_SUPPORTS_SAVE )
7781GAME( 1996, sfz2br1,    sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 (Brazil 960304)", GAME_SUPPORTS_SAVE )
7782GAME( 1996, sfz2h,      sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 (Hispanic 960304)", GAME_SUPPORTS_SAVE )
7783GAME( 1996, sfz2n,      sfa2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 (Oceania 960229)", GAME_SUPPORTS_SAVE )
7784GAME( 1996, sfz2al,     0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 Alpha (Asia 960826)", GAME_SUPPORTS_SAVE )
7785GAME( 1996, sfz2alj,    sfz2al,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 Alpha (Japan 960805)", GAME_SUPPORTS_SAVE )
7786GAME( 1996, sfz2alh,    sfz2al,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 Alpha (Hispanic 960813)", GAME_SUPPORTS_SAVE )
7787GAME( 1996, sfz2alb,    sfz2al,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 2 Alpha (Brazil 960813)", GAME_SUPPORTS_SAVE )
7788GAME( 1996, spf2t,      0,        cps2, cps2_2p2b, cps2,     ROT0,   "Capcom", "Super Puzzle Fighter II Turbo (USA 960620)", GAME_SUPPORTS_SAVE )
7789GAME( 1996, spf2xj,     spf2t,    cps2, cps2_2p2b, cps2,     ROT0,   "Capcom", "Super Puzzle Fighter II X (Japan 960531)", GAME_SUPPORTS_SAVE )
7790GAME( 1996, spf2ta,     spf2t,    cps2, cps2_2p2b, cps2,     ROT0,   "Capcom", "Super Puzzle Fighter II Turbo (Asia 960529)", GAME_SUPPORTS_SAVE )
7791GAME( 1996, spf2th,     spf2t,    cps2, cps2_2p2b, cps2,     ROT0,   "Capcom", "Super Puzzle Fighter II Turbo (Hispanic 960531)", GAME_SUPPORTS_SAVE )
7792GAME( 1996, megaman2,   0,        cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Mega Man 2: The Power Fighters (USA 960708)", GAME_SUPPORTS_SAVE )
7793GAME( 1996, megaman2a,  megaman2, cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Mega Man 2: The Power Fighters (Asia 960708)", GAME_SUPPORTS_SAVE )
7794GAME( 1996, rockman2j,  megaman2, cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Rockman 2: The Power Fighters (Japan 960708)", GAME_SUPPORTS_SAVE )
7795GAME( 1996, megaman2h,  megaman2, cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Mega Man 2: The Power Fighters (Hispanic 960712)", GAME_SUPPORTS_SAVE )
7796GAME( 1996, qndream,    0,        cps2, qndream,   cps2,     ROT0,   "Capcom", "Quiz Nanairo Dreams: Nijiirochou no Kiseki (Japan 960826)", GAME_SUPPORTS_SAVE )
7797GAME( 1996, xmvsf,      0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Euro 961004)", GAME_SUPPORTS_SAVE )
7798GAME( 1996, xmvsfr1,    xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Euro 960910)", GAME_SUPPORTS_SAVE )
7799GAME( 1996, xmvsfu,     xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (USA 961023)", GAME_SUPPORTS_SAVE )
7800GAME( 1996, xmvsfur1,   xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (USA 961004)", GAME_SUPPORTS_SAVE )
7801GAME( 1996, xmvsfj,     xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Japan 961004)", GAME_SUPPORTS_SAVE )
7802GAME( 1996, xmvsfjr1,   xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Japan 960910)", GAME_SUPPORTS_SAVE )
7803GAME( 1996, xmvsfjr2,   xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Japan 960909)", GAME_SUPPORTS_SAVE )
7804GAME( 1996, xmvsfa,     xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Asia 961023)", GAME_SUPPORTS_SAVE )
7805GAME( 1996, xmvsfar1,   xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Asia 960919)", GAME_SUPPORTS_SAVE )
7806GAME( 1996, xmvsfh,     xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Hispanic 961004)", GAME_SUPPORTS_SAVE )
7807GAME( 1996, xmvsfb,     xmvsf,    cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men Vs. Street Fighter (Brazil 961023)", GAME_SUPPORTS_SAVE )
7808GAME( 1997, batcir,     0,        cps2, cps2_4p2b, cps2,     ROT0,   "Capcom", "Battle Circuit (Euro 970319)", GAME_SUPPORTS_SAVE )
7809GAME( 1997, batcira,    batcir,   cps2, cps2_4p2b, cps2,     ROT0,   "Capcom", "Battle Circuit (Asia 970319)", GAME_SUPPORTS_SAVE )
7810GAME( 1997, batcirj,    batcir,   cps2, cps2_4p2b, cps2,     ROT0,   "Capcom", "Battle Circuit (Japan 970319)", GAME_SUPPORTS_SAVE )
7811GAME( 1997, vsav,       0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Savior: The Lord of Vampire (Euro 970519)", GAME_SUPPORTS_SAVE )
7812GAME( 1997, vsavu,      vsav,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Savior: The Lord of Vampire (USA 970519)", GAME_SUPPORTS_SAVE )
7813GAME( 1997, vsavj,      vsav,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Savior: The Lord of Vampire (Japan 970519)", GAME_SUPPORTS_SAVE )
7814GAME( 1997, vsava,      vsav,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Savior: The Lord of Vampire (Asia 970519)", GAME_SUPPORTS_SAVE )
7815GAME( 1997, vsavh,      vsav,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Savior: The Lord of Vampire (Hispanic 970519)", GAME_SUPPORTS_SAVE )
7816GAME( 1997, mshvsf,     0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Euro 970625)", GAME_SUPPORTS_SAVE )
7817GAME( 1997, mshvsfu,    mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (USA 970827)", GAME_SUPPORTS_SAVE )
7818GAME( 1997, mshvsfu1,   mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (USA 970625)", GAME_SUPPORTS_SAVE )
7819GAME( 1997, mshvsfj,    mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Japan 970707)", GAME_SUPPORTS_SAVE )
7820GAME( 1997, mshvsfj1,   mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Japan 970702)", GAME_SUPPORTS_SAVE )
7821GAME( 1997, mshvsfj2,   mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Japan 970625)", GAME_SUPPORTS_SAVE )
7822GAME( 1997, mshvsfh,    mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Hispanic 970625)", GAME_SUPPORTS_SAVE )
7823GAME( 1997, mshvsfa,    mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Asia 970625)", GAME_SUPPORTS_SAVE )
7824GAME( 1997, mshvsfa1,   mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Asia 970620)", GAME_SUPPORTS_SAVE )
7825GAME( 1997, mshvsfb,    mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Brazil 970827)", GAME_SUPPORTS_SAVE )
7826GAME( 1997, mshvsfb1,   mshvsf,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Super Heroes Vs. Street Fighter (Brazil 970625)", GAME_SUPPORTS_SAVE )
7827GAME( 1997, csclub,     0,        cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Capcom Sports Club (Euro 971017)", GAME_SUPPORTS_SAVE )
7828GAME( 1997, csclub1,    csclub,   cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Capcom Sports Club (Euro 970722)", GAME_SUPPORTS_SAVE )
7829GAME( 1997, cscluba,    csclub,   cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Capcom Sports Club (Asia 970722)", GAME_SUPPORTS_SAVE )
7830GAME( 1997, csclubj,    csclub,   cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Capcom Sports Club (Japan 970722)", GAME_SUPPORTS_SAVE )
7831GAME( 1997, csclubh,    csclub,   cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Capcom Sports Club (Hispanic 970722)", GAME_SUPPORTS_SAVE )
7832GAME( 1997, sgemf,      0,        cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Super Gem Fighter Mini Mix (USA 970904)", GAME_SUPPORTS_SAVE )
7833GAME( 1997, pfghtj,     sgemf,    cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Pocket Fighter (Japan 970904)", GAME_SUPPORTS_SAVE )
7834GAME( 1997, sgemfa,     sgemf,    cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Super Gem Fighter: Mini Mix (Asia 970904)", GAME_SUPPORTS_SAVE )
7835GAME( 1997, sgemfh,     sgemf,    cps2, cps2_2p3b, cps2,     ROT0,   "Capcom", "Super Gem Fighter: Mini Mix (Hispanic 970904)", GAME_SUPPORTS_SAVE )
7836GAME( 1997, vhunt2,     0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Hunter 2: Darkstalkers Revenge (Japan 970929)", GAME_SUPPORTS_SAVE )
7837GAME( 1997, vhunt2r1,   vhunt2,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Hunter 2: Darkstalkers Revenge (Japan 970913)", GAME_SUPPORTS_SAVE )
7838GAME( 1997, vsav2,      0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Vampire Savior 2: The Lord of Vampire (Japan 970913)", GAME_SUPPORTS_SAVE )
7839GAME( 1998, mvsc,       0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Euro 980123)", GAME_SUPPORTS_SAVE )
7840GAME( 1998, mvscr1,     mvsc,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Euro 980112)", GAME_SUPPORTS_SAVE )
7841GAME( 1998, mvscu,      mvsc,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (USA 980123)", GAME_SUPPORTS_SAVE )
7842GAME( 1998, mvscj,      mvsc,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Japan 980123)", GAME_SUPPORTS_SAVE )
7843GAME( 1998, mvscjr1,    mvsc,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Japan 980112)", GAME_SUPPORTS_SAVE )
7844GAME( 1998, mvsca,      mvsc,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Asia 980123)", GAME_SUPPORTS_SAVE )
7845GAME( 1998, mvscar1,    mvsc,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Asia 980112)", GAME_SUPPORTS_SAVE )
7846GAME( 1998, mvsch,      mvsc,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Hispanic 980123)", GAME_SUPPORTS_SAVE )
7847GAME( 1998, mvscb,      mvsc,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Marvel Vs. Capcom: Clash of Super Heroes (Brazil 980123)", GAME_SUPPORTS_SAVE )
7848GAME( 1998, sfa3,       0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha 3 (Euro 980904)", GAME_SUPPORTS_SAVE )
7849GAME( 1998, sfa3u,      sfa3,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha 3 (USA 980904)", GAME_SUPPORTS_SAVE )
7850GAME( 1998, sfa3ur1,    sfa3,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha 3 (USA 980629)", GAME_SUPPORTS_SAVE )
7851GAME( 1998, sfa3b,      sfa3,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Alpha 3 (Brazil 980629)", GAME_SUPPORTS_SAVE )
7852GAME( 1998, sfz3j,      sfa3,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 3 (Japan 980904)", GAME_SUPPORTS_SAVE )
7853GAME( 1998, sfz3jr1,    sfa3,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 3 (Japan 980727)", GAME_SUPPORTS_SAVE )
7854GAME( 1998, sfz3jr2,    sfa3,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 3 (Japan 980629)", GAME_SUPPORTS_SAVE )
7855GAME( 1998, sfz3a,      sfa3,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 3 (Asia 980904)", GAME_SUPPORTS_SAVE )
7856GAME( 1998, sfz3ar1,    sfa3,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Street Fighter Zero 3 (Asia 980701)", GAME_SUPPORTS_SAVE )
7857GAME( 1999, jyangoku,   0,        cps2, cps2_1p2b, cps2,     ROT0,   "Capcom", "Jyangokushi: Haoh no Saihai (Japan 990527)", GAME_SUPPORTS_SAVE )
7858GAME( 2004, hsf2,       0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Hyper Street Fighter 2: The Anniversary Edition (USA 040202)", GAME_SUPPORTS_SAVE )
7859GAME( 2004, hsf2a,      hsf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Hyper Street Fighter 2: The Anniversary Edition (Asia 040202)", GAME_SUPPORTS_SAVE )
7860GAME( 2004, hsf2j,      hsf2,     cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Hyper Street Fighter 2: The Anniversary Edition (Japan 031222)", GAME_SUPPORTS_SAVE )
78037861
78047862/* Games released on CPS-2 hardware by Takumi */
78057863
7806GAME( 1999, gigawing, 0,        cps2, cps2_2p2b, cps2,     ROT0,   "Capcom, supported by Takumi", "Giga Wing (USA 990222)", 0 )
7807GAME( 1999, gigawingj,gigawing, cps2, cps2_2p2b, cps2,     ROT0,   "Capcom, supported by Takumi", "Giga Wing (Japan 990223)", 0 )
7808GAME( 1999, gigawinga,gigawing, cps2, cps2_2p2b, cps2,     ROT0,   "Capcom, supported by Takumi", "Giga Wing (Asia 990222)", 0 )
7809GAME( 1999, gigawingb,gigawing, cps2, cps2_2p2b, cps2,     ROT0,   "Capcom, supported by Takumi", "Giga Wing (Brazil 990222)", 0 )
7810GAME( 2000, mmatrix,  0,        cps2, cps2_2p1b, cps2,     ROT0,   "Capcom, supported by Takumi", "Mars Matrix: Hyper Solid Shooting (USA 000412)", 0 )
7811GAME( 2000, mmatrixj, mmatrix,  cps2, cps2_2p1b, cps2,     ROT0,   "Capcom, supported by Takumi", "Mars Matrix: Hyper Solid Shooting (Japan 000412)", 0 )
7864GAME( 1999, gigawing,   0,        cps2, cps2_2p2b, cps2,     ROT0,   "Capcom, supported by Takumi", "Giga Wing (USA 990222)", GAME_SUPPORTS_SAVE )
7865GAME( 1999, gigawingj,  gigawing, cps2, cps2_2p2b, cps2,     ROT0,   "Capcom, supported by Takumi", "Giga Wing (Japan 990223)", GAME_SUPPORTS_SAVE )
7866GAME( 1999, gigawinga,  gigawing, cps2, cps2_2p2b, cps2,     ROT0,   "Capcom, supported by Takumi", "Giga Wing (Asia 990222)", GAME_SUPPORTS_SAVE )
7867GAME( 1999, gigawingb,  gigawing, cps2, cps2_2p2b, cps2,     ROT0,   "Capcom, supported by Takumi", "Giga Wing (Brazil 990222)", GAME_SUPPORTS_SAVE )
7868GAME( 2000, mmatrix,    0,        cps2, cps2_2p1b, cps2,     ROT0,   "Capcom, supported by Takumi", "Mars Matrix: Hyper Solid Shooting (USA 000412)", GAME_SUPPORTS_SAVE )
7869GAME( 2000, mmatrixj,   mmatrix,  cps2, cps2_2p1b, cps2,     ROT0,   "Capcom, supported by Takumi", "Mars Matrix: Hyper Solid Shooting (Japan 000412)", GAME_SUPPORTS_SAVE )
78127870
78137871/* Games released on CPS-2 hardware by Mitchell */
78147872
7815GAME( 2000, mpang,    0,        cps2, cps2_2p1b, cps2,     ROT0,   "Mitchell, distributed by Capcom", "Mighty! Pang (Euro 001010)", 0 )
7816GAME( 2000, mpangr1,  mpang,    cps2, cps2_2p1b, cps2,     ROT0,   "Mitchell, distributed by Capcom", "Mighty! Pang (Euro 000925)", 0 )
7817GAME( 2000, mpangu,   mpang,    cps2, cps2_2p1b, cps2,     ROT0,   "Mitchell, distributed by Capcom", "Mighty! Pang (USA 001010)", 0 )
7818GAME( 2000, mpangj,   mpang,    cps2, cps2_2p1b, cps2,     ROT0,   "Mitchell, distributed by Capcom", "Mighty! Pang (Japan 001011)", 0 )
7819GAME( 2001, pzloop2,  0,        cps2, pzloop2,   pzloop2,  ROT0,   "Mitchell, distributed by Capcom", "Puzz Loop 2 (Euro 010302)", 0 )
7820GAME( 2001, pzloop2j, pzloop2,  cps2, pzloop2,   pzloop2,  ROT0,   "Mitchell, distributed by Capcom", "Puzz Loop 2 (Japan 010205)", 0 )
7821GAME( 2001, choko,    0,        cps2, choko,     cps2,     ROT0,   "Mitchell, distributed by Capcom", "Janpai Puzzle Choukou (Japan 010820)", 0 )
7873GAME( 2000, mpang,      0,        cps2, cps2_2p1b, cps2,     ROT0,   "Mitchell, distributed by Capcom", "Mighty! Pang (Euro 001010)", GAME_SUPPORTS_SAVE )
7874GAME( 2000, mpangr1,    mpang,    cps2, cps2_2p1b, cps2,     ROT0,   "Mitchell, distributed by Capcom", "Mighty! Pang (Euro 000925)", GAME_SUPPORTS_SAVE )
7875GAME( 2000, mpangu,     mpang,    cps2, cps2_2p1b, cps2,     ROT0,   "Mitchell, distributed by Capcom", "Mighty! Pang (USA 001010)", GAME_SUPPORTS_SAVE )
7876GAME( 2000, mpangj,     mpang,    cps2, cps2_2p1b, cps2,     ROT0,   "Mitchell, distributed by Capcom", "Mighty! Pang (Japan 001011)", GAME_SUPPORTS_SAVE )
7877GAME( 2001, pzloop2,    0,        cps2, pzloop2,   pzloop2,  ROT0,   "Mitchell, distributed by Capcom", "Puzz Loop 2 (Euro 010302)", GAME_SUPPORTS_SAVE )
7878GAME( 2001, pzloop2j,   pzloop2,  cps2, pzloop2,   pzloop2,  ROT0,   "Mitchell, distributed by Capcom", "Puzz Loop 2 (Japan 010205)", GAME_SUPPORTS_SAVE )
7879GAME( 2001, choko,      0,        cps2, choko,     cps2,     ROT0,   "Mitchell, distributed by Capcom", "Janpai Puzzle Choukou (Japan 010820)", GAME_SUPPORTS_SAVE )
78227880
78237881/* Games released on CPS-2 hardware by Eighting/Raizing */
78247882
7825GAME( 2000, dimahoo,  0,        cps2, cps2_2p3b, cps2,     ROT270, "Eighting/Raizing, distributed by Capcom", "Dimahoo (Euro 000121)", 0 )
7826GAME( 2000, dimahoou, dimahoo,  cps2, cps2_2p3b, cps2,     ROT270, "Eighting/Raizing, distributed by Capcom", "Dimahoo (USA 000121)", 0 )
7827GAME( 2000, gmahou,   dimahoo,  cps2, cps2_2p3b, cps2,     ROT270, "Eighting/Raizing, distributed by Capcom", "Great Mahou Daisakusen (Japan 000121)", 0 )
7828GAME( 2000, 1944,     0,        cps2, cps2_2p2b, cps2,     ROT0,   "Capcom, supported by Eighting/Raizing", "1944: The Loop Master (USA 000620)", 0 )
7829GAME( 2000, 1944j,    1944,     cps2, cps2_2p2b, cps2,     ROT0,   "Capcom, supported by Eighting/Raizing", "1944: The Loop Master (Japan 000620)", 0 )
7883GAME( 2000, dimahoo,    0,        cps2, cps2_2p3b, cps2,     ROT270, "Eighting/Raizing, distributed by Capcom", "Dimahoo (Euro 000121)", GAME_SUPPORTS_SAVE )
7884GAME( 2000, dimahoou,   dimahoo,  cps2, cps2_2p3b, cps2,     ROT270, "Eighting/Raizing, distributed by Capcom", "Dimahoo (USA 000121)", GAME_SUPPORTS_SAVE )
7885GAME( 2000, gmahou,     dimahoo,  cps2, cps2_2p3b, cps2,     ROT270, "Eighting/Raizing, distributed by Capcom", "Great Mahou Daisakusen (Japan 000121)", GAME_SUPPORTS_SAVE )
7886GAME( 2000, 1944,       0,        cps2, cps2_2p2b, cps2,     ROT0,   "Capcom, supported by Eighting/Raizing", "1944: The Loop Master (USA 000620)", GAME_SUPPORTS_SAVE )
7887GAME( 2000, 1944j,      1944,     cps2, cps2_2p2b, cps2,     ROT0,   "Capcom, supported by Eighting/Raizing", "1944: The Loop Master (Japan 000620)", GAME_SUPPORTS_SAVE )
78307888
78317889/* Games released on CPS-2 hardware by Cave */
78327890
7833GAME( 2001, progear,  0,        cps2, cps2_2p3b, cps2,     ROT0,   "Capcom, supported by Cave", "Progear (USA 010117)", 0 )
7834GAME( 2001, progearj, progear,  cps2, cps2_2p3b, cps2,     ROT0,   "Capcom, supported by Cave", "Progear no Arashi (Japan 010117)", 0 )
7835GAME( 2001, progeara, progear,  cps2, cps2_2p3b, cps2,     ROT0,   "Capcom, supported by Cave", "Progear (Asia 010117)", 0 )
7891GAME( 2001, progear,    0,        cps2, cps2_2p3b, cps2,     ROT0,   "Capcom, supported by Cave", "Progear (USA 010117)", GAME_SUPPORTS_SAVE )
7892GAME( 2001, progearj,   progear,  cps2, cps2_2p3b, cps2,     ROT0,   "Capcom, supported by Cave", "Progear no Arashi (Japan 010117)", GAME_SUPPORTS_SAVE )
7893GAME( 2001, progeara,   progear,  cps2, cps2_2p3b, cps2,     ROT0,   "Capcom, supported by Cave", "Progear (Asia 010117)", GAME_SUPPORTS_SAVE )
78367894
78377895/*
78387896 ------------------------
r6740r6741
81128170   ROM_LOAD16_WORD_SWAP( "hs2ad.04", 0x080000, 0x80000, CRC(0276b78a) SHA1(3f5502f77eb9889ca4658eb323579e05b35c9868) )
81138171   ROM_LOAD16_WORD_SWAP( "hs2.05",   0x100000, 0x80000, CRC(dde34a35) SHA1(f5be2d2916db6e86e0886d61d55bddf138273ebc) )
81148172   ROM_LOAD16_WORD_SWAP( "hs2.06",   0x180000, 0x80000, CRC(f4e56dda) SHA1(c6490707c2a416ab88612c2d73abbe5853d8cb92) )
8115   ROM_LOAD16_WORD_SWAP( "hs2a.07",  0x200000, 0x80000, CRC(ee4420fc) SHA1(06cf76660b0c794d2460c52d9fe8334fff51e9de) )
8173   ROM_LOAD16_WORD_SWAP( "hs2.07",   0x200000, 0x80000, CRC(ee4420fc) SHA1(06cf76660b0c794d2460c52d9fe8334fff51e9de) )
81168174   ROM_LOAD16_WORD_SWAP( "hs2.08",   0x280000, 0x80000, CRC(c9441533) SHA1(bf178fac1f060fcce3ff9118333c8517dadc9429) )
81178175   ROM_LOAD16_WORD_SWAP( "hs2.09",   0x300000, 0x80000, CRC(3fc638a8) SHA1(2a42877b26c8abc437da46225701f0bba6e40058) )
81188176   ROM_LOAD16_WORD_SWAP( "hs2.10",   0x380000, 0x80000, CRC(20d0f9e4) SHA1(80a5eeef9472e327b0d4ee26434bad109a9434ea) )
r6740r6741
87838841
87848842
87858843
8786GAME( 1993, ssf2ud,   ssf2,    dead_cps2, cps2_2p6b, cps2,   ROT0,   "bootleg", "Super Street Fighter II: The New Challengers (USA 930911 Phoenix Edition) (bootleg)", 0 )
8787GAME( 1993, ddtodd,   ddtod,   dead_cps2, cps2_4p4b, cps2,   ROT0,   "bootleg", "Dungeons & Dragons: Tower of Doom (Euro 940412 Phoenix Edition) (bootleg)", 0 )
8788GAME( 1994, armwar1d, armwar,  dead_cps2, cps2_3p3b, cps2,   ROT0,   "bootleg", "Armored Warriors (Euro 941011 Phoenix Edition) (bootleg)", 0 )
8789GAME( 1994, avspd,    avsp,    dead_cps2, cps2_3p3b, cps2,   ROT0,   "bootleg", "Alien vs. Predator (Euro 940520 Phoenix Edition) (bootleg)", 0 )
8790GAME( 1994, dstlku1d, dstlk,   dead_cps2, cps2_2p6b, cps2,   ROT0,   "bootleg", "Darkstalkers: The Night Warriors (USA 940705 Phoenix Edition) (bootleg)", 0 )
8791GAME( 1994, ringdstd, ringdest,dead_cps2, cps2_2p6b, cps2,   ROT0,   "bootleg", "Ring of Destruction: Slammasters II (Euro 940902 Phoenix Edition) (bootleg)", 0 )
8792GAME( 1994, xmcotad,  xmcota,  dead_cps2, cps2_2p6b, cps2,   ROT0,   "bootleg", "X-Men: Children of the Atom (Euro 950105 Phoenix Edition) (bootleg)", 0 )
8793GAME( 1995, nwarrud,  nwarr,   dead_cps2, cps2_2p6b, cps2,   ROT0,   "bootleg", "Night Warriors: Darkstalkers' Revenge (USA 950406 Phoenix Edition) (bootleg)", 0 )
8794GAME( 1995, sfad,     sfa,     dead_cps2, cps2_2p6b, cps2,   ROT0,   "bootleg", "Street Fighter Alpha: Warriors' Dreams (Euro 950727 Phoenix Edition) (bootleg)", 0 )
8795GAME( 1995, mshud,    msh,     dead_cps2, cps2_2p6b, cps2,   ROT0,   "bootleg", "Marvel Super Heroes (US 951024 Phoenix Edition) (bootleg)", 0 )
8796GAME( 1996, 19xxd,    19xx,    dead_cps2, cps2_2p2b, cps2,   ROT270, "bootleg", "19XX: The War Against Destiny (USA 951207 Phoenix Edition) (bootleg)", 0 )
8797GAME( 1996, sfz2ad,   sfa2,    dead_cps2, cps2_2p6b, cps2,   ROT0,   "bootleg", "Street Fighter Zero 2 (Asia 960227 Phoenix Edition) (bootleg)", 0 )
8798GAME( 1996, spf2xjd,  spf2t,   dead_cps2, cps2_2p2b, cps2,   ROT0,   "bootleg", "Super Puzzle Fighter II X (Japan 960531 Phoenix Edition) (bootleg)", 0 )
8799GAME( 1996, ddsomud,  ddsom,   dead_cps2, cps2_4p4b, cps2,   ROT0,   "bootleg", "Dungeons & Dragons: Shadow over Mystara (USA 960619 Phoenix Edition) (bootleg)", 0 )
8800GAME( 1996, gigamn2,  megaman2, gigamn2, cps2_2p3b, gigamn2,  ROT0,   "bootleg", "Giga Man 2: The Power Fighters (bootleg of Mega Man 2: The Power Fighters)", GAME_NOT_WORKING ) // flash roms aren't dumped, layer offsets different, different sound system
8801GAME( 1996, megamn2d, megaman2,dead_cps2, cps2_2p3b, cps2,   ROT0,   "bootleg", "Mega Man 2: The Power Fighters (USA 960708 Phoenix Edition) (bootleg)", 0 )
8802GAME( 1996, sfz2ald,  sfz2al,  dead_cps2, cps2_2p6b, cps2,   ROT0,   "bootleg", "Street Fighter Zero 2 Alpha (Asia 960826 Phoenix Edition) (bootleg)", 0 )
8803GAME( 1996, xmvsfu1d, xmvsf,   dead_cps2, cps2_2p6b, cps2,   ROT0,   "bootleg", "X-Men Vs. Street Fighter (USA 961004 Phoenix Edition) (bootleg)", 0 )
8804GAME( 1997, batcird,  batcir,  dead_cps2, cps2_4p2b, cps2,   ROT0,   "bootleg", "Battle Circuit (Euro 970319 Phoenix Edition) (bootleg)", 0 )
8805GAME( 1997, vsavd,    vsav,    dead_cps2, cps2_2p6b, cps2,   ROT0,   "bootleg", "Vampire Savior: The Lord of Vampire (Euro 970519 Phoenix Edition) (bootleg)", 0 )
8806GAME( 1998, mvscud,   mvsc,    dead_cps2, cps2_2p6b, cps2,   ROT0,   "bootleg", "Marvel Vs. Capcom: Clash of Super Heroes (USA 980123 Phoenix Edition) (bootleg)", 0 )
8807GAME( 1998, sfa3ud,   sfa3,    dead_cps2, cps2_2p6b, cps2,   ROT0,   "bootleg", "Street Fighter Alpha 3 (USA 980904 Phoenix Edition) (bootleg)", 0 )
8808GAME( 1999, gwingjd,  gigawing,dead_cps2, cps2_2p2b, cps2,   ROT0,   "bootleg", "Giga Wing (Japan 990223 Phoenix Edition) (bootleg)", 0 )
8809GAME( 2000, 1944d,    1944,    dead_cps2, cps2_2p2b, cps2,   ROT0,   "bootleg", "1944: The Loop Master (USA 000620 Phoenix Edition) (bootleg)", 0 )
8810GAME( 2001, progerjd, progear, dead_cps2, cps2_2p3b, cps2,   ROT0,   "bootleg", "Progear no Arashi (Japan 010117 Phoenix Edition) (bootleg)", 0 ) // doesn't display phoenix edition screen, hacked bootleg?
8811GAME( 2004, hsf2d,    hsf2,    dead_cps2, cps2_2p6b, cps2,   ROT0,   "bootleg", "Hyper Street Fighter II: The Anniversary Edition (Asia 040202 Phoenix Edition) (bootleg)", 0 )
8812GAME( 1993, ssf2tbd,  ssf2,    dead_cps2, cps2_2p6b, ssf2tb, ROT0,   "bootleg", "Super Street Fighter II: The Tournament Battle (World 931119 Phoenix Edition) (bootleg)", 0 )
8813GAME( 1994, ssf2xjd,  ssf2,    dead_cps2, cps2_2p6b, cps2,   ROT0,   "bootleg", "Super Street Fighter II X: Grand Master Challenge (Japan 940223 Phoenix Edition) (bootleg)", 0 )
8814GAME( 1997, sgemfd,   sgemf,   dead_cps2, cps2_2p3b, cps2,   ROT0,   "bootleg", "Super Gem Fighter Mini Mix (USA 970904 Phoenix Edition) (bootleg)", 0 )
8815GAME( 2000, mmatrixd, mmatrix, dead_cps2, cps2_2p1b, cps2,   ROT0,   "bootleg", "Mars Matrix: Hyper Solid Shooting (Japan 000412 Phoenix Edition) (bootleg)", 0 )
8816GAME( 2000, dimahoud, dimahoo, dead_cps2, cps2_2p3b, cps2,   ROT270, "bootleg", "Dimahoo (USA 000121 Phoenix Edition) (bootleg)", 0 )
8844GAME( 1993, ssf2ud,   ssf2,     dead_cps2, cps2_2p6b, cps2,    ROT0,   "bootleg", "Super Street Fighter II: The New Challengers (USA 930911 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8845GAME( 1993, ddtodd,   ddtod,    dead_cps2, cps2_4p4b, cps2,    ROT0,   "bootleg", "Dungeons & Dragons: Tower of Doom (Euro 940412 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8846GAME( 1994, armwar1d, armwar,   dead_cps2, cps2_3p3b, cps2,    ROT0,   "bootleg", "Armored Warriors (Euro 941011 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8847GAME( 1994, avspd,    avsp,     dead_cps2, cps2_3p3b, cps2,    ROT0,   "bootleg", "Alien vs. Predator (Euro 940520 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8848GAME( 1994, dstlku1d, dstlk,    dead_cps2, cps2_2p6b, cps2,    ROT0,   "bootleg", "Darkstalkers: The Night Warriors (USA 940705 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8849GAME( 1994, ringdstd, ringdest, dead_cps2, cps2_2p6b, cps2,    ROT0,   "bootleg", "Ring of Destruction: Slammasters II (Euro 940902 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8850GAME( 1994, xmcotad,  xmcota,   dead_cps2, cps2_2p6b, cps2,    ROT0,   "bootleg", "X-Men: Children of the Atom (Euro 950105 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8851GAME( 1995, nwarrud,  nwarr,    dead_cps2, cps2_2p6b, cps2,    ROT0,   "bootleg", "Night Warriors: Darkstalkers' Revenge (USA 950406 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8852GAME( 1995, sfad,     sfa,      dead_cps2, cps2_2p6b, cps2,    ROT0,   "bootleg", "Street Fighter Alpha: Warriors' Dreams (Euro 950727 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8853GAME( 1995, mshud,    msh,      dead_cps2, cps2_2p6b, cps2,    ROT0,   "bootleg", "Marvel Super Heroes (US 951024 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8854GAME( 1996, 19xxd,    19xx,     dead_cps2, cps2_2p2b, cps2,    ROT270, "bootleg", "19XX: The War Against Destiny (USA 951207 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8855GAME( 1996, sfz2ad,   sfa2,     dead_cps2, cps2_2p6b, cps2,    ROT0,   "bootleg", "Street Fighter Zero 2 (Asia 960227 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8856GAME( 1996, spf2xjd,  spf2t,    dead_cps2, cps2_2p2b, cps2,    ROT0,   "bootleg", "Super Puzzle Fighter II X (Japan 960531 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8857GAME( 1996, ddsomud,  ddsom,    dead_cps2, cps2_4p4b, cps2,    ROT0,   "bootleg", "Dungeons & Dragons: Shadow over Mystara (USA 960619 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8858GAME( 1996, gigamn2,  megaman2, gigamn2,   cps2_2p3b, gigamn2, ROT0,   "bootleg", "Giga Man 2: The Power Fighters (bootleg of Mega Man 2: The Power Fighters)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) // flash roms aren't dumped, layer offsets different, different sound system
8859GAME( 1996, megamn2d, megaman2, dead_cps2, cps2_2p3b, cps2,    ROT0,   "bootleg", "Mega Man 2: The Power Fighters (USA 960708 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8860GAME( 1996, sfz2ald,  sfz2al,   dead_cps2, cps2_2p6b, cps2,    ROT0,   "bootleg", "Street Fighter Zero 2 Alpha (Asia 960826 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8861GAME( 1996, xmvsfu1d, xmvsf,    dead_cps2, cps2_2p6b, cps2,    ROT0,   "bootleg", "X-Men Vs. Street Fighter (USA 961004 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8862GAME( 1997, batcird,  batcir,   dead_cps2, cps2_4p2b, cps2,    ROT0,   "bootleg", "Battle Circuit (Euro 970319 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8863GAME( 1997, vsavd,    vsav,     dead_cps2, cps2_2p6b, cps2,    ROT0,   "bootleg", "Vampire Savior: The Lord of Vampire (Euro 970519 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8864GAME( 1998, mvscud,   mvsc,     dead_cps2, cps2_2p6b, cps2,    ROT0,   "bootleg", "Marvel Vs. Capcom: Clash of Super Heroes (USA 980123 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8865GAME( 1998, sfa3ud,   sfa3,     dead_cps2, cps2_2p6b, cps2,    ROT0,   "bootleg", "Street Fighter Alpha 3 (USA 980904 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8866GAME( 1999, gwingjd,  gigawing, dead_cps2, cps2_2p2b, cps2,    ROT0,   "bootleg", "Giga Wing (Japan 990223 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8867GAME( 2000, 1944d,    1944,     dead_cps2, cps2_2p2b, cps2,    ROT0,   "bootleg", "1944: The Loop Master (USA 000620 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8868GAME( 2001, progerjd, progear,  dead_cps2, cps2_2p3b, cps2,    ROT0,   "bootleg", "Progear no Arashi (Japan 010117 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE ) // doesn't display phoenix edition screen, hacked bootleg?
8869GAME( 2004, hsf2d,    hsf2,     dead_cps2, cps2_2p6b, cps2,    ROT0,   "bootleg", "Hyper Street Fighter II: The Anniversary Edition (Asia 040202 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8870GAME( 1993, ssf2tbd,  ssf2,     dead_cps2, cps2_2p6b, ssf2tb,  ROT0,   "bootleg", "Super Street Fighter II: The Tournament Battle (World 931119 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8871GAME( 1994, ssf2xjd,  ssf2,     dead_cps2, cps2_2p6b, cps2,    ROT0,   "bootleg", "Super Street Fighter II X: Grand Master Challenge (Japan 940223 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8872GAME( 1997, sgemfd,   sgemf,    dead_cps2, cps2_2p3b, cps2,    ROT0,   "bootleg", "Super Gem Fighter Mini Mix (USA 970904 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8873GAME( 2000, mmatrixd, mmatrix,  dead_cps2, cps2_2p1b, cps2,    ROT0,   "bootleg", "Mars Matrix: Hyper Solid Shooting (Japan 000412 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
8874GAME( 2000, dimahoud, dimahoo,  dead_cps2, cps2_2p3b, cps2,    ROT270, "bootleg", "Dimahoo (USA 000121 Phoenix Edition) (bootleg)", GAME_SUPPORTS_SAVE )
src/mame/drivers/amaticmg.c
r6740r6741
422422//  AM_RANGE(0x0000, 0x0000) AM_RAM // AM_BASE_SIZE_GENERIC(nvram)
423423//  AM_RANGE(0x0000, 0x0000) AM_DEVWRITE("crtc", mc6845_address_w)
424424//  AM_RANGE(0x0000, 0x0000) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
425//  AM_RANGE(0x0000, 0x0000) AM_RAM_WRITE(amaticmg_videoram_w) AM_BASE_GENERIC(videoram)
426//  AM_RANGE(0x0000, 0x0000) AM_RAM_WRITE(amaticmg_colorram_w) AM_BASE_GENERIC(colorram)
425//  AM_RANGE(0x0000, 0x0000) AM_RAM_WRITE(amaticmg_videoram_w) AM_BASE(&amaticmg_videoram)
426//  AM_RANGE(0x0000, 0x0000) AM_RAM_WRITE(amaticmg_colorram_w) AM_BASE(&amaticmg_colorram)
427427ADDRESS_MAP_END
428428
429429static ADDRESS_MAP_START( amaticmg_portmap, ADDRESS_SPACE_IO, 8 )
src/mame/drivers/jpmimpct.c
r6740r6741
8181#include "cpu/m68000/m68000.h"
8282#include "cpu/tms34010/tms34010.h"
8383#include "sound/upd7759.h"
84#include "jpmimpct.h"
84#include "includes/jpmimpct.h"
8585#include "machine/meters.h"
8686
8787/*************************************
r6740r6741
9494static UINT8 duart_1_irq;
9595static UINT8 touch_cnt;
9696static UINT8 touch_data[3];
97static emu_timer *duart_1_timer;
9897
9998static int lamp_strobe;
10099static UINT8 Lamps[256];
101static TIMER_CALLBACK( duart_1_timer_event );
102100
103101
104102/*************************************
r6740r6741
166164 *
167165 *************************************/
168166
169static MACHINE_RESET( jpmimpct )
167static MACHINE_START( jpmimpct )
170168{
171   memset(&duart_1, 0, sizeof(duart_1));
172
173   duart_1_timer = timer_alloc(machine, duart_1_timer_event, NULL);
174
175   /* Reset states */
176   duart_1_irq = tms_irq = 0;
177   touch_cnt = 0;
178
179//  duart_1.IVR=0x0f;
180169   state_save_register_global(machine, tms_irq);
181170   state_save_register_global(machine, duart_1_irq);
182171   state_save_register_global(machine, touch_cnt);
r6740r6741
189178}
190179
191180
181static MACHINE_RESET( jpmimpct )
182{
183   memset(&duart_1, 0, sizeof(duart_1));
184
185   /* Reset states */
186   duart_1_irq = tms_irq = 0;
187   touch_cnt = 0;
188
189//  duart_1.IVR=0x0f;
190}
191
192
192193/*************************************
193194 *
194195 *  TMS34010 host interface
r6740r6741
234235 *  TxDB/TxDB: Data retrieval unit
235236 */
236237
237static TIMER_CALLBACK( duart_1_timer_event )
238static TIMER_DEVICE_CALLBACK( duart_1_timer_event )
238239{
239240   duart_1.tc = 0;
240241   duart_1.ISR |= 0x08;
241242
242243   duart_1_irq = 1;
243   update_irqs(machine);
244   update_irqs(timer->machine);
244245}
245246
246247static READ16_HANDLER( duart_1_r )
r6740r6741
291292      case 0xe:
292293      {
293294         attotime rate = attotime_mul(ATTOTIME_IN_HZ(MC68681_1_CLOCK), 16 * duart_1.CT);
294         timer_adjust_periodic(duart_1_timer, rate, 0, rate);
295         timer_device_adjust_periodic(devtag_get_device(space->machine, "duart_1_timer"), rate, 0, rate);
295296         break;
296297      }
297298      case 0xf:
r6740r6741
852853   MDRV_CPU_PROGRAM_MAP(tms_program_map)
853854
854855   MDRV_QUANTUM_TIME(HZ(30000))
856   MDRV_MACHINE_START(jpmimpct)
855857   MDRV_MACHINE_RESET(jpmimpct)
856858   MDRV_NVRAM_HANDLER(generic_0fill)
857859
860   MDRV_TIMER_ADD( "duart_1_timer", duart_1_timer_event)
861
858862   MDRV_SCREEN_ADD("screen", RASTER)
859863   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
860864   MDRV_SCREEN_RAW_PARAMS(40000000/4, 156*4, 0, 100*4, 328, 0, 300)
r6740r6741
11281132   }
11291133};
11301134
1131static MACHINE_RESET( impctawp )
1135static MACHINE_START( impctawp )
11321136{
1133   memset(&duart_1, 0, sizeof(duart_1));
1134
1135   duart_1_timer = timer_alloc(machine, duart_1_timer_event, NULL);
1136
1137   /* Reset states */
1138   duart_1_irq = 0;
1139
11401137   state_save_register_global(machine, duart_1_irq);
11411138   state_save_register_global(machine, touch_cnt);
11421139   state_save_register_global_array(machine, touch_data);
r6740r6741
11461143   state_save_register_global(machine, duart_1.IMR);
11471144   state_save_register_global(machine, duart_1.CT);
11481145
1149   ROC10937_init(0, MSC1937,0);
1150   ROC10937_reset(0);   /* reset display1 */
11511146   stepper_config(machine, 0, &starpoint_interface_48step);
11521147   stepper_config(machine, 1, &starpoint_interface_48step);
11531148   stepper_config(machine, 2, &starpoint_interface_48step);
r6740r6741
11561151   stepper_config(machine, 5, &starpoint_interface_48step);
11571152   stepper_config(machine, 6, &starpoint_interface_48step);
11581153}
1154
1155static MACHINE_RESET( impctawp )
1156{
1157   memset(&duart_1, 0, sizeof(duart_1));
1158
1159   /* Reset states */
1160   duart_1_irq = 0;
1161
1162   ROC10937_init(0, MSC1937,0);
1163   ROC10937_reset(0);   /* reset display1 */
1164}
11591165/*************************************
11601166 *
11611167 *  I/O handlers
r6740r6741
13201326
13211327   MDRV_QUANTUM_TIME(HZ(30000))
13221328
1329   MDRV_MACHINE_START(impctawp)
13231330   MDRV_MACHINE_RESET(impctawp)
13241331   MDRV_NVRAM_HANDLER(generic_0fill)
13251332
13261333   MDRV_PPI8255_ADD( "ppi8255_0", ppi8255_intf[0] )
13271334
1335   MDRV_TIMER_ADD( "duart_1_timer", duart_1_timer_event)
1336
13281337   MDRV_SPEAKER_STANDARD_MONO("mono")
13291338   MDRV_SOUND_ADD("upd",UPD7759, UPD7759_STANDARD_CLOCK)
13301339   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
src/mame/drivers/scramble.c
r6740r6741
3131#include "sound/ay8910.h"
3232#include "sound/dac.h"
3333#include "sound/flt_rc.h"
34#include "machine/7474.h"
3435#include "machine/8255ppi.h"
35#include "galaxold.h"
36#include "includes/galaxold.h"
3637
3738
3839
r6740r6741
12421243   MDRV_CPU_PROGRAM_MAP(scramble_sound_map)
12431244   MDRV_CPU_IO_MAP(scramble_sound_io_map)
12441245
1246   MDRV_7474_ADD("7474_9m_1", galaxold_7474_9m_1_callback)
1247   MDRV_7474_ADD("7474_9m_2", galaxold_7474_9m_2_callback)
1248   MDRV_7474_ADD("konami_7474", scramble_sh_7474_callback)
1249
1250   MDRV_TIMER_ADD("int_timer", galaxold_interrupt_timer)
1251
12451252   MDRV_MACHINE_RESET(scramble)
12461253
12471254   MDRV_PPI8255_ADD( "ppi8255_0", scramble_ppi_0_intf )
r6740r6741
14711478   MDRV_CPU_ADD("maincpu", Z80, 18432000/6)   /* 3.072 MHz */
14721479   MDRV_CPU_PROGRAM_MAP(ad2083_map)
14731480
1481   MDRV_7474_ADD("7474_9m_1", galaxold_7474_9m_1_callback)
1482   MDRV_7474_ADD("7474_9m_2", galaxold_7474_9m_2_callback)
1483   MDRV_7474_ADD("konami_7474", scramble_sh_7474_callback)
1484
1485   MDRV_TIMER_ADD("int_timer", galaxold_interrupt_timer)
1486
14741487   MDRV_MACHINE_RESET(galaxold)
14751488
14761489   /* video hardware */
src/mame/drivers/liberatr.c
r6740r6741
138138#include "deprecat.h"
139139#include "machine/atari_vg.h"
140140#include "sound/pokey.h"
141#include "liberatr.h"
141#include "includes/liberatr.h"
142142
143143#define MASTER_CLOCK 20000000 /* 20Mhz Main Clock Xtal */
144144
src/mame/drivers/tehkanwc.c
r6740r6741
9494#include "sound/msm5205.h"
9595#include "gridiron.lh"
9696
97extern UINT8 *tehkanwc_videoram;
98extern UINT8 *tehkanwc_colorram;
9799extern UINT8 *tehkanwc_videoram2;
98100
99101extern WRITE8_HANDLER( tehkanwc_videoram_w );
r6740r6741
232234   AM_RANGE(0x0000, 0xbfff) AM_ROM
233235   AM_RANGE(0xc000, 0xc7ff) AM_RAM
234236   AM_RANGE(0xc800, 0xcfff) AM_RAM AM_SHARE("share1")
235   AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(tehkanwc_videoram_w) AM_SHARE("share2") AM_BASE_GENERIC(videoram)
236   AM_RANGE(0xd400, 0xd7ff) AM_RAM_WRITE(tehkanwc_colorram_w) AM_SHARE("share3") AM_BASE_GENERIC(colorram)
237   AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(tehkanwc_videoram_w) AM_SHARE("share2") AM_BASE(&tehkanwc_videoram)
238   AM_RANGE(0xd400, 0xd7ff) AM_RAM_WRITE(tehkanwc_colorram_w) AM_SHARE("share3") AM_BASE(&tehkanwc_colorram)
237239   AM_RANGE(0xd800, 0xddff) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_be_w) AM_SHARE("share4") AM_BASE_GENERIC(paletteram)
238240   AM_RANGE(0xde00, 0xdfff) AM_RAM AM_SHARE("share5") /* unused part of the palette RAM, I think? Gridiron uses it */
239241   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(tehkanwc_videoram2_w) AM_SHARE("share6") AM_BASE(&tehkanwc_videoram2)
src/mame/drivers/bionicc.c
r6740r6741
5959#include "cpu/m68000/m68000.h"
6060#include "deprecat.h"
6161#include "sound/2151intf.h"
62#include "bionicc.h"
62#include "includes/bionicc.h"
6363
6464#define MASTER_CLOCK       XTAL_24MHz
6565#define EXO3_F0_CLK        XTAL_14_31818MHz
src/mame/drivers/citycon.c
r6740r6741
1111#include "cpu/m6809/m6809.h"
1212#include "sound/ay8910.h"
1313#include "sound/2203intf.h"
14#include "citycon.h"
14#include "includes/citycon.h"
1515
1616
1717static READ8_HANDLER( citycon_in_r )
src/mame/drivers/namcos21.c
r6740r6741
292292#include "cpu/m68000/m68000.h"
293293#include "cpu/m6805/m6805.h"
294294#include "deprecat.h"
295#include "namcos2.h"
295#include "includes/namcos2.h"
296296#include "cpu/m6809/m6809.h"
297297#include "cpu/tms32025/tms32025.h"
298#include "namcoic.h"
298#include "includes/namcoic.h"
299299#include "sound/2151intf.h"
300300#include "sound/c140.h"
301#include "namcos21.h"
301#include "includes/namcos21.h"
302302
303303#define PTRAM_SIZE 0x20000
304304
src/mame/drivers/pgm.c
r6740r6741
291291#include "cpu/arm7/arm7core.h"
292292#include "includes/pgm.h"
293293
294UINT16 *pgm_mainram;
294295
295UINT16 *pgm_mainram, *pgm_bg_videoram, *pgm_tx_videoram, *pgm_videoregs, *pgm_rowscrollram;
296static UINT16 *pgm_videoram;
297static UINT8 *z80_mainram;
298static UINT32 *arm7_shareram;
299static UINT32 *svg_shareram[2];   //for 5585G MACHINE
300static UINT32 kov2_latchdata_68k_w;
301static UINT32 kov2_latchdata_arm_w;
302
303
304296static WRITE16_HANDLER( pgm_videoram_w )
305297{
306   if (offset<0x4000/2)
298   pgm_state *state = (pgm_state *)space->machine->driver_data;
299
300   if (offset < 0x4000 / 2)
307301      pgm_bg_videoram_w(space, offset, data, mem_mask);
308   else if (offset<0x7000/2)
309      pgm_tx_videoram_w(space, offset-0x4000/2, data, mem_mask);
310   else COMBINE_DATA(&pgm_videoram[offset/2]);
302   else if (offset < 0x7000 / 2)
303      pgm_tx_videoram_w(space, offset - 0x4000 / 2, data, mem_mask);
304   else
305      COMBINE_DATA(&state->videoram[offset / 2]);
311306}
312307
313308static READ16_HANDLER ( z80_ram_r )
314309{
315   return (z80_mainram[offset*2] << 8)|z80_mainram[offset*2+1];
310   pgm_state *state = (pgm_state *)space->machine->driver_data;
311   return (state->z80_mainram[offset * 2] << 8) | state->z80_mainram[offset * 2 + 1];
316312}
317313
318314static READ32_HANDLER( arm7_latch_arm_r )
319315{
320   if (PGMARM7LOGERROR) logerror("ARM7: Latch read: %08x (%08x) (%06x)\n", kov2_latchdata_68k_w, mem_mask, cpu_get_pc(space->cpu) );
321   return kov2_latchdata_68k_w;
316   pgm_state *state = (pgm_state *)space->machine->driver_data;
317
318   if (PGMARM7LOGERROR)
319      logerror("ARM7: Latch read: %08x (%08x) (%06x)\n", state->kov2_latchdata_68k_w, mem_mask, cpu_get_pc(space->cpu));
320   return state->kov2_latchdata_68k_w;
322321}
323322
324323static WRITE32_HANDLER( arm7_latch_arm_w )
325324{
326   if (PGMARM7LOGERROR) logerror("ARM7: Latch write: %08x (%08x) (%06x)\n", data, mem_mask, cpu_get_pc(space->cpu) );
327   COMBINE_DATA(&kov2_latchdata_arm_w);
325   pgm_state *state = (pgm_state *)space->machine->driver_data;
326
327   if (PGMARM7LOGERROR)
328      logerror("ARM7: Latch write: %08x (%08x) (%06x)\n", data, mem_mask, cpu_get_pc(space->cpu));
329
330   COMBINE_DATA(&state->kov2_latchdata_arm_w);
328331}
329332
330333static READ32_HANDLER( arm7_shareram_r )
331334{
332   if (PGMARM7LOGERROR) logerror("ARM7: ARM7 Shared RAM Read: %04x = %08x (%08x) (%06x)\n", offset << 2, arm7_shareram[offset], mem_mask, cpu_get_pc(space->cpu) );
333   return arm7_shareram[offset];
335   pgm_state *state = (pgm_state *)space->machine->driver_data;
336
337   if (PGMARM7LOGERROR)
338      logerror("ARM7: ARM7 Shared RAM Read: %04x = %08x (%08x) (%06x)\n", offset << 2, state->arm7_shareram[offset], mem_mask, cpu_get_pc(space->cpu));
339   return state->arm7_shareram[offset];
334340}
335341
336342static WRITE32_HANDLER( arm7_shareram_w )
337343{
338   if (PGMARM7LOGERROR) logerror("ARM7: ARM7 Shared RAM Write: %04x = %08x (%08x) (%06x)\n", offset << 2, data, mem_mask, cpu_get_pc(space->cpu) );
339   COMBINE_DATA(&arm7_shareram[offset]);
344   pgm_state *state = (pgm_state *)space->machine->driver_data;
345
346   if (PGMARM7LOGERROR)
347      logerror("ARM7: ARM7 Shared RAM Write: %04x = %08x (%08x) (%06x)\n", offset << 2, data, mem_mask, cpu_get_pc(space->cpu));
348   COMBINE_DATA(&state->arm7_shareram[offset]);
340349}
341350
342351static READ16_HANDLER( arm7_latch_68k_r )
343352{
344   if (PGMARM7LOGERROR) logerror("M68K: Latch read: %04x (%04x) (%06x)\n", kov2_latchdata_arm_w & 0x0000ffff, mem_mask, cpu_get_pc(space->cpu) );
345   return kov2_latchdata_arm_w;
353   pgm_state *state = (pgm_state *)space->machine->driver_data;
354
355   if (PGMARM7LOGERROR)
356      logerror("M68K: Latch read: %04x (%04x) (%06x)\n", state->kov2_latchdata_arm_w & 0x0000ffff, mem_mask, cpu_get_pc(space->cpu));
357   return state->kov2_latchdata_arm_w;
346358}
347359
348360static WRITE16_HANDLER( arm7_latch_68k_w )
349361{
350   if (PGMARM7LOGERROR) logerror("M68K: Latch write: %04x (%04x) (%06x)\n", data & 0x0000ffff, mem_mask, cpu_get_pc(space->cpu) );
351   COMBINE_DATA(&kov2_latchdata_68k_w);
362   pgm_state *state = (pgm_state *)space->machine->driver_data;
352363
353   generic_pulse_irq_line(cputag_get_cpu(space->machine, "prot"), ARM7_FIRQ_LINE);
364   if (PGMARM7LOGERROR)
365      logerror("M68K: Latch write: %04x (%04x) (%06x)\n", data & 0x0000ffff, mem_mask, cpu_get_pc(space->cpu));
366   COMBINE_DATA(&state->kov2_latchdata_68k_w);
367
368   generic_pulse_irq_line(state->prot, ARM7_FIRQ_LINE);
354369   cpuexec_boost_interleave(space->machine, attotime_zero, ATTOTIME_IN_USEC(200));
355   cpu_spinuntil_time(space->cpu, cputag_clocks_to_attotime(space->machine, "prot", 200)); // give the arm time to respond (just boosting the interleave doesn't help)
370   cpu_spinuntil_time(space->cpu, cpu_clocks_to_attotime(state->prot, 200)); // give the arm time to respond (just boosting the interleave doesn't help)
356371}
357372
358373static READ16_HANDLER( arm7_ram_r )
359374{
360   UINT16 *share16 = (UINT16 *)arm7_shareram;
361   if (PGMARM7LOGERROR) logerror("M68K: ARM7 Shared RAM Read: %04x = %04x (%08x) (%06x)\n", BYTE_XOR_LE(offset), share16[BYTE_XOR_LE(offset)], mem_mask, cpu_get_pc(space->cpu) );
375   pgm_state *state = (pgm_state *)space->machine->driver_data;
376   UINT16 *share16 = (UINT16 *)state->arm7_shareram;
377
378   if (PGMARM7LOGERROR)
379      logerror("M68K: ARM7 Shared RAM Read: %04x = %04x (%08x) (%06x)\n", BYTE_XOR_LE(offset), share16[BYTE_XOR_LE(offset)], mem_mask, cpu_get_pc(space->cpu));
362380   return share16[BYTE_XOR_LE(offset)];
363381}
364382
365383static WRITE16_HANDLER( arm7_ram_w )
366384{
367   UINT16 *share16 = (UINT16 *)arm7_shareram;
368   if (PGMARM7LOGERROR) logerror("M68K: ARM7 Shared RAM Write: %04x = %04x (%04x) (%06x)\n", BYTE_XOR_LE(offset), data, mem_mask, cpu_get_pc(space->cpu) );
385   pgm_state *state = (pgm_state *)space->machine->driver_data;
386   UINT16 *share16 = (UINT16 *)state->arm7_shareram;
369387
388   if (PGMARM7LOGERROR)
389      logerror("M68K: ARM7 Shared RAM Write: %04x = %04x (%04x) (%06x)\n", BYTE_XOR_LE(offset), data, mem_mask, cpu_get_pc(space->cpu));
370390   COMBINE_DATA(&share16[BYTE_XOR_LE(offset)]);
371391}
372392
373393static WRITE16_HANDLER ( z80_ram_w )
374394{
395   pgm_state *state = (pgm_state *)space->machine->driver_data;
375396   int pc = cpu_get_pc(space->cpu);
376   if(ACCESSING_BITS_8_15)
377      z80_mainram[offset*2] = data >> 8;
378   if(ACCESSING_BITS_0_7)
379      z80_mainram[offset*2+1] = data;
380397
381   if(pc != 0xf12 && pc != 0xde2 && pc != 0x100c50 && pc != 0x100b20)
382      if (PGMLOGERROR) logerror("Z80: write %04x, %04x @ %04x (%06x)\n", offset*2, data, mem_mask, cpu_get_pc(space->cpu));
398   if (ACCESSING_BITS_8_15)
399      state->z80_mainram[offset * 2] = data >> 8;
400   if (ACCESSING_BITS_0_7)
401      state->z80_mainram[offset * 2 + 1] = data;
402
403   if (pc != 0xf12 && pc != 0xde2 && pc != 0x100c50 && pc != 0x100b20)
404      if (PGMLOGERROR)
405         logerror("Z80: write %04x, %04x @ %04x (%06x)\n", offset * 2, data, mem_mask, cpu_get_pc(space->cpu));
383406}
384407
385408static WRITE16_HANDLER ( z80_reset_w )
386409{
387   if (PGMLOGERROR) logerror("Z80: reset %04x @ %04x (%06x)\n", data, mem_mask, cpu_get_pc(space->cpu));
410   pgm_state *state = (pgm_state *)space->machine->driver_data;
388411
389   if(data == 0x5050)
412   if (PGMLOGERROR)
413      logerror("Z80: reset %04x @ %04x (%06x)\n", data, mem_mask, cpu_get_pc(space->cpu));
414
415   if (data == 0x5050)
390416   {
391      devtag_reset(space->machine, "ics");
392      cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_HALT, CLEAR_LINE);
393      cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_RESET, PULSE_LINE);
417      device_reset(state->ics);
418      cpu_set_input_line(state->soundcpu, INPUT_LINE_HALT, CLEAR_LINE);
419      cpu_set_input_line(state->soundcpu, INPUT_LINE_RESET, PULSE_LINE);
394420      if(0)
395421      {
396422         FILE *out;
397423         out = fopen("z80ram.bin", "wb");
398         fwrite(z80_mainram, 1, 65536, out);
424         fwrite(state->z80_mainram, 1, 65536, out);
399425         fclose(out);
400426      }
401427   }
r6740r6741
403429   {
404430      /* this might not be 100% correct, but several of the games (ddp2, puzzli2 etc. expect the z80 to be turned
405431           off during data uploads, they write here before the upload */
406      cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_HALT, ASSERT_LINE);
432      cpu_set_input_line(state->soundcpu, INPUT_LINE_HALT, ASSERT_LINE);
407433   }
408434}
409435
410436static WRITE16_HANDLER ( z80_ctrl_w )
411437{
412   if (PGMLOGERROR) logerror("Z80: ctrl %04x @ %04x (%06x)\n", data, mem_mask, cpu_get_pc(space->cpu));
438   if (PGMLOGERROR)
439      logerror("Z80: ctrl %04x @ %04x (%06x)\n", data, mem_mask, cpu_get_pc(space->cpu));
413440}
414441
415442static WRITE16_HANDLER ( m68k_l1_w )
416443{
444   pgm_state *state = (pgm_state *)space->machine->driver_data;
445
417446   if(ACCESSING_BITS_0_7)
418447   {
419      if (PGMLOGERROR) logerror("SL 1 m68.w %02x (%06x) IRQ\n", data & 0xff, cpu_get_pc(space->cpu));
448      if (PGMLOGERROR)
449         logerror("SL 1 m68.w %02x (%06x) IRQ\n", data & 0xff, cpu_get_pc(space->cpu));
420450      soundlatch_w(space, 0, data);
421      cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_NMI, PULSE_LINE );
451      cpu_set_input_line(state->soundcpu, INPUT_LINE_NMI, PULSE_LINE );
422452   }
423453}
424454
425455static WRITE8_HANDLER( z80_l3_w )
426456{
427   if (PGMLOGERROR) logerror("SL 3 z80.w %02x (%04x)\n", data, cpu_get_pc(space->cpu));
457   if (PGMLOGERROR)
458      logerror("SL 3 z80.w %02x (%04x)\n", data, cpu_get_pc(space->cpu));
428459   soundlatch3_w(space, 0, data);
429460}
430461
431static void sound_irq(const device_config *device, int level)
462static void sound_irq( const device_config *device, int level )
432463{
433   cputag_set_input_line(device->machine, "soundcpu", 0, level);
464   pgm_state *state = (pgm_state *)device->machine->driver_data;
465   cpu_set_input_line(state->soundcpu, 0, level);
434466}
435467
436static const ics2115_interface pgm_ics2115_interface = {
468static const ics2115_interface pgm_ics2115_interface =
469{
437470   sound_irq
438471};
439472
473
440474/* Calendar Emulation */
441475
442static UINT8 CalVal, CalMask, CalCom=0, CalCnt=0;
443
444static UINT8 bcd(UINT8 data)
476static UINT8 bcd( UINT8 data )
445477{
446478   return ((data / 10) << 4) | (data % 10);
447479}
448480
449481static READ16_HANDLER( pgm_calendar_r )
450482{
451   UINT8 calr;
452   calr = (CalVal & CalMask) ? 1 : 0;
453   CalMask <<= 1;
483   pgm_state *state = (pgm_state *)space->machine->driver_data;
484   UINT8 calr = (state->cal_val & state->cal_mask) ? 1 : 0;
485
486   state->cal_mask <<= 1;
454487   return calr;
455488}
456489
457490static WRITE16_HANDLER( pgm_calendar_w )
458491{
459   static mame_system_time systime;
492   pgm_state *state = (pgm_state *)space->machine->driver_data;
460493
461   mame_get_base_datetime(space->machine, &systime);
494   mame_get_base_datetime(space->machine, &state->systime);
462495
463   // initialize the time, otherwise it crashes
464   if( !systime.time )
465      mame_get_base_datetime(space->machine, &systime);
496   state->cal_com <<= 1;
497   state->cal_com |= data & 1;
498   ++state->cal_cnt;
466499
467   CalCom <<= 1;
468   CalCom |= data & 1;
469   ++CalCnt;
470   if(CalCnt==4)
500   if (state->cal_cnt == 4)
471501   {
472      CalMask = 1;
473      CalVal = 1;
474      CalCnt = 0;
475      switch(CalCom & 0xf)
502      state->cal_mask = 1;
503      state->cal_val = 1;
504      state->cal_cnt = 0;
505
506      switch (state->cal_com & 0xf)
476507      {
477508         case 1: case 3: case 5: case 7: case 9: case 0xb: case 0xd:
478            CalVal++;
509            state->cal_val++;
479510            break;
480511
481512         case 0:
482            CalVal=bcd(systime.local_time.weekday); //??
513            state->cal_val = bcd(state->systime.local_time.weekday); //??
483514            break;
484515
485516         case 2:  //Hours
486            CalVal=bcd(systime.local_time.hour);
517            state->cal_val = bcd(state->systime.local_time.hour);
487518            break;
488519
489520         case 4:  //Seconds
490            CalVal=bcd(systime.local_time.second);
521            state->cal_val = bcd(state->systime.local_time.second);
491522            break;
492523
493524         case 6:  //Month
494            CalVal=bcd(systime.local_time.month + 1); //?? not bcd in MVS
525            state->cal_val = bcd(state->systime.local_time.month + 1); //?? not bcd in MVS
495526            break;
496527
497528         case 8:
498            CalVal=0; //Controls blinking speed, maybe milliseconds
529            state->cal_val = 0; //Controls blinking speed, maybe milliseconds
499530            break;
500531
501532         case 0xa: //Day
502            CalVal=bcd(systime.local_time.mday);
533            state->cal_val = bcd(state->systime.local_time.mday);
503534            break;
504535
505536         case 0xc: //Minute
506            CalVal=bcd(systime.local_time.minute);
537            state->cal_val = bcd(state->systime.local_time.minute);
507538            break;
508539
509540         case 0xe:  //Year
510            CalVal=bcd(systime.local_time.year % 100);
541            state->cal_val = bcd(state->systime.local_time.year % 100);
511542            break;
512543
513544         case 0xf:  //Load Date
514            mame_get_base_datetime(space->machine, &systime);
545            mame_get_base_datetime(space->machine, &state->systime);
515546            break;
516547      }
517548   }
r6740r6741
542573
543574   AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */
544575
545//  AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE(&pgm_bg_videoram) /* Backgrounds */
546//  AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE(&pgm_tx_videoram) /* Text Layer */
547//  AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE(&pgm_rowscrollram)
548   AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE(&pgm_videoram) /* IGS023 VIDEO CHIP */
576//  AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */
577//  AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */
578//  AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE_MEMBER(pgm_state, rowscrollram)
579   AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE_MEMBER(pgm_state, videoram) /* IGS023 VIDEO CHIP */
549580   AM_RANGE(0xa00000, 0xa011ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
550   AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE(&pgm_videoregs) /* Video Regs inc. Zoom Table */
581   AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE_MEMBER(pgm_state, videoregs) /* Video Regs inc. Zoom Table */
551582
552583   AM_RANGE(0xc00002, 0xc00003) AM_READWRITE(soundlatch_word_r, m68k_l1_w)
553584   AM_RANGE(0xc00004, 0xc00005) AM_READWRITE(soundlatch2_word_r, soundlatch2_word_w)
r6740r6741
564595   AM_RANGE(0xc10000, 0xc1ffff) AM_READWRITE(z80_ram_r, z80_ram_w) /* Z80 Program */
565596ADDRESS_MAP_END
566597
567static UINT16 *killbld_sharedprotram;
568
569598static ADDRESS_MAP_START( killbld_mem, ADDRESS_SPACE_PROGRAM, 16)
570599   AM_RANGE(0x000000, 0x01ffff) AM_ROM   /* BIOS ROM */
571600   AM_RANGE(0x100000, 0x2fffff) AM_ROMBANK("bank1") /* Game ROM */
572   AM_RANGE(0x300000, 0x303fff) AM_RAM AM_BASE(&killbld_sharedprotram) // Shared with protection device
601   AM_RANGE(0x300000, 0x303fff) AM_RAM AM_BASE_MEMBER(pgm_state, sharedprotram) // Shared with protection device
573602
574603   AM_RANGE(0x700006, 0x700007) AM_WRITENOP // Watchdog?
575604
576605   AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */
577606
578//  AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE(&pgm_bg_videoram) /* Backgrounds */
579//  AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE(&pgm_tx_videoram) /* Text Layer */
580//  AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE(&pgm_rowscrollram)
581   AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE(&pgm_videoram) /* IGS023 VIDEO CHIP */
607//  AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */
608//  AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */
609//  AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE_MEMBER(pgm_state, rowscrollram)
610   AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE_MEMBER(pgm_state, videoram) /* IGS023 VIDEO CHIP */
582611   AM_RANGE(0xa00000, 0xa011ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
583   AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE(&pgm_videoregs) /* Video Regs inc. Zoom Table */
612   AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE_MEMBER(pgm_state, videoregs) /* Video Regs inc. Zoom Table */
584613
585614   AM_RANGE(0xc00002, 0xc00003) AM_READWRITE(soundlatch_word_r, m68k_l1_w)
586615   AM_RANGE(0xc00004, 0xc00005) AM_READWRITE(soundlatch2_word_r, soundlatch2_word_w)
r6740r6741
597626   AM_RANGE(0xc10000, 0xc1ffff) AM_READWRITE(z80_ram_r, z80_ram_w) /* Z80 Program */
598627ADDRESS_MAP_END
599628
600static UINT16 *olds_sharedprotram;
601
602629static ADDRESS_MAP_START( olds_mem, ADDRESS_SPACE_PROGRAM, 16)
603630   AM_RANGE(0x000000, 0x01ffff) AM_ROM   /* BIOS ROM */
604631   AM_RANGE(0x100000, 0x3fffff) AM_ROMBANK("bank1") /* Game ROM */
605   AM_RANGE(0x400000, 0x403fff) AM_RAM AM_BASE(&olds_sharedprotram) // Shared with protection device
632   AM_RANGE(0x400000, 0x403fff) AM_RAM AM_BASE_MEMBER(pgm_state, sharedprotram) // Shared with protection device
606633
607634   AM_RANGE(0x700006, 0x700007) AM_WRITENOP // Watchdog?
608635
609636   AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */
610637
611//  AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE(&pgm_bg_videoram) /* Backgrounds */
612//  AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE(&pgm_tx_videoram) /* Text Layer */
613//  AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE(&pgm_rowscrollram)
614   AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE(&pgm_videoram) /* IGS023 VIDEO CHIP */
638//  AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */
639//  AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */
640//  AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE_MEMBER(pgm_state, rowscrollram)
641   AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE_MEMBER(pgm_state, videoram) /* IGS023 VIDEO CHIP */
615642   AM_RANGE(0xa00000, 0xa011ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
616   AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE(&pgm_videoregs) /* Video Regs inc. Zoom Table */
643   AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE_MEMBER(pgm_state, videoregs) /* Video Regs inc. Zoom Table */
617644
618645   AM_RANGE(0xc00002, 0xc00003) AM_READWRITE(soundlatch_word_r, m68k_l1_w)
619646   AM_RANGE(0xc00004, 0xc00005) AM_READWRITE(soundlatch2_word_r, soundlatch2_word_w)
r6740r6741
638665
639666   AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */
640667
641//  AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE(&pgm_bg_videoram) /* Backgrounds */
642//  AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE(&pgm_tx_videoram) /* Text Layer */
643//  AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE(&pgm_rowscrollram)
644   AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE(&pgm_videoram) /* IGS023 VIDEO CHIP */
668//  AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */
669//  AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */
670//  AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE_MEMBER(pgm_state, rowscrollram)
671   AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE_MEMBER(pgm_state, videoram) /* IGS023 VIDEO CHIP */
645672   AM_RANGE(0xa00000, 0xa011ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
646   AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE(&pgm_videoregs) /* Video Regs inc. Zoom Table */
673   AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE_MEMBER(pgm_state, videoregs) /* Video Regs inc. Zoom Table */
647674
648675   AM_RANGE(0xc00002, 0xc00003) AM_READWRITE(soundlatch_word_r, m68k_l1_w)
649676   AM_RANGE(0xc00004, 0xc00005) AM_READWRITE(soundlatch2_word_r, soundlatch2_word_w)
r6740r6741
666693static ADDRESS_MAP_START( cavepgm_mem, ADDRESS_SPACE_PROGRAM, 16)
667694   AM_RANGE(0x000000, 0x07ffff) AM_ROM   /* larger BIOS ROM */
668695   AM_RANGE(0xfffffe, 0xffffff) AM_ROMBANK("bank1") /* Game ROM (unmapped for now, might not even have it) */
669   AM_RANGE(0x400000, 0x4fffff) AM_RAM AM_BASE(&olds_sharedprotram) // Shared with protection device
696   AM_RANGE(0x400000, 0x4fffff) AM_RAM AM_BASE_MEMBER(pgm_state, sharedprotram) // Shared with protection device
670697
671698   AM_RANGE(0x700006, 0x700007) AM_WRITENOP // Watchdog?
672699
673700   AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */
674701
675//  AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE(&pgm_bg_videoram) /* Backgrounds */
676//  AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE(&pgm_tx_videoram) /* Text Layer */
677//  AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE(&pgm_rowscrollram)
678   AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE(&pgm_videoram) /* IGS023 VIDEO CHIP */
702//  AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */
703//  AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */
704//  AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE_MEMBER(pgm_state, rowscrollram)
705   AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE_MEMBER(pgm_state, videoram) /* IGS023 VIDEO CHIP */
679706   AM_RANGE(0xa00000, 0xa011ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
680   AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE(&pgm_videoregs) /* Video Regs inc. Zoom Table */
707   AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE_MEMBER(pgm_state, videoregs) /* Video Regs inc. Zoom Table */
681708
682709   AM_RANGE(0xc00002, 0xc00003) AM_READWRITE(soundlatch_word_r, m68k_l1_w)
683710   AM_RANGE(0xc00004, 0xc00005) AM_READWRITE(soundlatch2_word_r, soundlatch2_word_w)
r6740r6741
696723#endif
697724
698725static ADDRESS_MAP_START( z80_mem, ADDRESS_SPACE_PROGRAM, 8 )
699   AM_RANGE(0x0000, 0xffff) AM_RAM AM_BASE(&z80_mainram)
726   AM_RANGE(0x0000, 0xffff) AM_RAM AM_BASE_MEMBER(pgm_state, z80_mainram)
700727ADDRESS_MAP_END
701728
702729static ADDRESS_MAP_START( z80_io, ADDRESS_SPACE_IO, 8 )
r6740r6741
712739   AM_RANGE(0x10000000, 0x100003ff) AM_RAM
713740   AM_RANGE(0x18000000, 0x1800ffff) AM_RAM
714741   AM_RANGE(0x38000000, 0x38000003) AM_READWRITE(arm7_latch_arm_r, arm7_latch_arm_w) /* 68k Latch */
715   AM_RANGE(0x48000000, 0x4800ffff) AM_READWRITE(arm7_shareram_r, arm7_shareram_w) AM_BASE(&arm7_shareram)
742   AM_RANGE(0x48000000, 0x4800ffff) AM_READWRITE(arm7_shareram_r, arm7_shareram_w) AM_BASE_MEMBER(pgm_state, arm7_shareram)
716743   AM_RANGE(0x50000000, 0x500003ff) AM_RAM
717744ADDRESS_MAP_END
718745
719746/* Kov Superheroes */
720747
721static UINT16 kovsh_highlatch_arm_w, kovsh_lowlatch_arm_w;
722static UINT16 kovsh_highlatch_68k_w, kovsh_lowlatch_68k_w;
723
724748static READ32_HANDLER( kovsh_arm7_protlatch_r )
725749{
750   pgm_state *state = (pgm_state *)space->machine->driver_data;
751
726752   timer_call_after_resynch(space->machine, NULL, 0, 0); // force resync
727753
728   return (kovsh_highlatch_68k_w << 16) | (kovsh_lowlatch_68k_w);
754   return (state->kovsh_highlatch_68k_w << 16) | (state->kovsh_lowlatch_68k_w);
729755}
730756
731757static WRITE32_HANDLER( kovsh_arm7_protlatch_w )
732758{
759   pgm_state *state = (pgm_state *)space->machine->driver_data;
760
733761   timer_call_after_resynch(space->machine, NULL, 0, 0); // force resync
734762
735763   if (ACCESSING_BITS_16_31)
736764   {
737      kovsh_highlatch_arm_w = data>>16;
738      kovsh_highlatch_68k_w = 0;
765      state->kovsh_highlatch_arm_w = data >> 16;
766      state->kovsh_highlatch_68k_w = 0;
739767   }
740768   if (ACCESSING_BITS_0_15)
741769   {
742      kovsh_lowlatch_arm_w = data;
743      kovsh_lowlatch_68k_w = 0;
770      state->kovsh_lowlatch_arm_w = data;
771      state->kovsh_lowlatch_68k_w = 0;
744772   }
745773}
746774
747775static READ16_HANDLER( kovsh_68k_protlatch_r )
748776{
777   pgm_state *state = (pgm_state *)space->machine->driver_data;
778
749779   timer_call_after_resynch(space->machine, NULL, 0, 0); // force resync
750780
751781   switch (offset)
752782   {
753      case 1: return kovsh_highlatch_arm_w;
754      case 0: return kovsh_lowlatch_arm_w;
783      case 1: return state->kovsh_highlatch_arm_w;
784      case 0: return state->kovsh_lowlatch_arm_w;
755785   }
756786   return -1;
757787}
758788
759789static WRITE16_HANDLER( kovsh_68k_protlatch_w )
760790{
791   pgm_state *state = (pgm_state *)space->machine->driver_data;
792
761793   timer_call_after_resynch(space->machine, NULL, 0, 0); // force resync
762794
763795   switch (offset)
764796   {
765797      case 1:
766         {
767            kovsh_highlatch_68k_w = data;
768         }
798         state->kovsh_highlatch_68k_w = data;
769799         break;
770800
771801      case 0:
772         {
773            kovsh_lowlatch_68k_w = data;
774         }
802         state->kovsh_lowlatch_68k_w = data;
775803         break;
776804   }
777805}
778806
779807static READ16_HANDLER( kovsh_arm7_ram_r )
780808{
781   UINT16 *share16 = (UINT16 *)arm7_shareram;
782   if (PGMARM7LOGERROR) logerror("M68K: ARM7 Shared RAM Read: %04x = %04x (%08x) (%06x)\n", BYTE_XOR_LE(offset), share16[BYTE_XOR_LE(offset)], mem_mask, cpu_get_pc(space->cpu) );
783   return share16[BYTE_XOR_LE(offset<<1)];
809   pgm_state *state = (pgm_state *)space->machine->driver_data;
810   UINT16 *share16 = (UINT16 *)state->arm7_shareram;
811
812   if (PGMARM7LOGERROR)
813      logerror("M68K: ARM7 Shared RAM Read: %04x = %04x (%08x) (%06x)\n", BYTE_XOR_LE(offset), share16[BYTE_XOR_LE(offset)], mem_mask, cpu_get_pc(space->cpu));
814   return share16[BYTE_XOR_LE(offset << 1)];
784815}
785816
786817static WRITE16_HANDLER( kovsh_arm7_ram_w )
787818{
788   UINT16 *share16 = (UINT16 *)arm7_shareram;
789   if (PGMARM7LOGERROR) logerror("M68K: ARM7 Shared RAM Write: %04x = %04x (%04x) (%06x)\n", BYTE_XOR_LE(offset), data, mem_mask, cpu_get_pc(space->cpu) );
819   pgm_state *state = (pgm_state *)space->machine->driver_data;
820   UINT16 *share16 = (UINT16 *)state->arm7_shareram;
790821
791   COMBINE_DATA(&share16[BYTE_XOR_LE(offset<<1)]);
822   if (PGMARM7LOGERROR)
823      logerror("M68K: ARM7 Shared RAM Write: %04x = %04x (%04x) (%06x)\n", BYTE_XOR_LE(offset), data, mem_mask, cpu_get_pc(space->cpu));
824   COMBINE_DATA(&share16[BYTE_XOR_LE(offset << 1)]);
792825}
793826
794827static ADDRESS_MAP_START( kovsh_mem, ADDRESS_SPACE_PROGRAM, 16)
r6740r6741
799832
800833   AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */
801834
802//  AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE(&pgm_bg_videoram) /* Backgrounds */
803//  AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE(&pgm_tx_videoram) /* Text Layer */
804//  AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE(&pgm_rowscrollram)
805   AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE(&pgm_videoram) /* IGS023 VIDEO CHIP */
835//  AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */
836//  AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */
837//  AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE_MEMBER(pgm_state, rowscrollram)
838   AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE_MEMBER(pgm_state, videoram) /* IGS023 VIDEO CHIP */
806839   AM_RANGE(0xa00000, 0xa011ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
807   AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE(&pgm_videoregs) /* Video Regs inc. Zoom Table */
840   AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE_MEMBER(pgm_state, videoregs) /* Video Regs inc. Zoom Table */
808841
809842   AM_RANGE(0xc00002, 0xc00003) AM_READWRITE(soundlatch_word_r, m68k_l1_w)
810843   AM_RANGE(0xc00004, 0xc00005) AM_READWRITE(soundlatch2_word_r, soundlatch2_word_w)
r6740r6741
823856   AM_RANGE(0x500000, 0x500005) AM_READWRITE(kovsh_68k_protlatch_r, kovsh_68k_protlatch_w) /* ARM7 Latch */
824857ADDRESS_MAP_END
825858
826static UINT32 kovsh_counter;
827859
828860static READ32_HANDLER( kovsh_arm7_unk_r )
829861{
830   return kovsh_counter++;
862   pgm_state *state = (pgm_state *)space->machine->driver_data;
863   return state->kovsh_counter++;
831864}
832865
833866static READ32_HANDLER( kovsh_exrom_r )
r6740r6741
839872   AM_RANGE(0x00000000, 0x00003fff) AM_ROM
840873   AM_RANGE(0x08100000, 0x083fffff) AM_READ(kovsh_exrom_r) // unpopulated, returns 0 to keep checksum happy
841874   AM_RANGE(0x10000000, 0x100003ff) AM_RAM // internal ram for asic
842   AM_RANGE(0x40000000, 0x40000003) AM_READ(kovsh_arm7_protlatch_r) AM_WRITE(kovsh_arm7_protlatch_w)
875   AM_RANGE(0x40000000, 0x40000003) AM_READWRITE(kovsh_arm7_protlatch_r, kovsh_arm7_protlatch_w)
843876   AM_RANGE(0x40000008, 0x4000000b) AM_WRITENOP // ?
844877   AM_RANGE(0x4000000c, 0x4000000f) AM_READ(kovsh_arm7_unk_r)
845   AM_RANGE(0x50800000, 0x5080003f) AM_READWRITE(arm7_shareram_r, arm7_shareram_w) AM_BASE(&arm7_shareram)
878   AM_RANGE(0x50800000, 0x5080003f) AM_READWRITE(arm7_shareram_r, arm7_shareram_w) AM_BASE_MEMBER(pgm_state, arm7_shareram)
846879   AM_RANGE(0x50000000, 0x500003ff) AM_RAM // uploads xor table to decrypt 68k rom here
847880ADDRESS_MAP_END
848881
849882
850883//5585G
851static unsigned char svg_ram_sel;
852884
853885static WRITE32_HANDLER( svg_arm7_ram_sel_w )
854886{
855   svg_ram_sel=data&1;
887   pgm_state *state = (pgm_state *)space->machine->driver_data;
888   state->svg_ram_sel = data & 1;
856889}
857890
858891static READ32_HANDLER( svg_arm7_shareram_r )
859892{
860   unsigned char ram_sel=svg_ram_sel&1;
861
862   return svg_shareram[ram_sel][offset];
893   pgm_state *state = (pgm_state *)space->machine->driver_data;
894   return state->svg_shareram[state->svg_ram_sel & 1][offset];
863895}
864896
865897static WRITE32_HANDLER( svg_arm7_shareram_w )
866898{
867   unsigned char ram_sel=svg_ram_sel&1;
868   COMBINE_DATA(&svg_shareram[ram_sel][offset]);
899   pgm_state *state = (pgm_state *)space->machine->driver_data;
900   COMBINE_DATA(&state->svg_shareram[state->svg_ram_sel & 1][offset]);
869901}
870902
871903static READ16_HANDLER( svg_m68k_ram_r )
872904{
873   unsigned char ram_sel=(svg_ram_sel&1)^1;
874   UINT16 *share16 = (UINT16 *)(svg_shareram[ram_sel]);
905   pgm_state *state = (pgm_state *)space->machine->driver_data;
906   int ram_sel = (state->svg_ram_sel & 1) ^ 1;
907   UINT16 *share16 = (UINT16 *)(state->svg_shareram[ram_sel & 1]);
908
875909   return share16[BYTE_XOR_LE(offset)];
876910}
877911
878912static WRITE16_HANDLER( svg_m68k_ram_w )
879913{
880   unsigned char ram_sel=(svg_ram_sel&1)^1;
881   UINT16 *share16 = (UINT16 *)(svg_shareram[ram_sel]);
914   pgm_state *state = (pgm_state *)space->machine->driver_data;
915   int ram_sel = (state->svg_ram_sel & 1) ^ 1;
916   UINT16 *share16 = (UINT16 *)(state->svg_shareram[ram_sel & 1]);
917
882918   COMBINE_DATA(&share16[BYTE_XOR_LE(offset)]);
883919}
884920
r6740r6741
889925
890926static WRITE16_HANDLER( svg_68k_nmi_w )
891927{
892   generic_pulse_irq_line(cputag_get_cpu(space->machine, "prot"), ARM7_FIRQ_LINE);
928   pgm_state *state = (pgm_state *)space->machine->driver_data;
929   generic_pulse_irq_line(state->prot, ARM7_FIRQ_LINE);
893930   cpuexec_boost_interleave(space->machine, attotime_zero, ATTOTIME_IN_USEC(200));
894   cpu_spinuntil_time(space->cpu, cputag_clocks_to_attotime(space->machine, "prot", 200)); // give the arm time to respond (just boosting the interleave doesn't help)
931   cpu_spinuntil_time(space->cpu, cpu_clocks_to_attotime(state->prot, 200)); // give the arm time to respond (just boosting the interleave doesn't help)
895932}
896933
897934static WRITE16_HANDLER( svg_latch_68k_w )
898935{
899   if (PGMARM7LOGERROR) logerror("M68K: Latch write: %04x (%04x) (%06x)\n", data & 0x0000ffff, mem_mask, cpu_get_pc(space->cpu) );
900   COMBINE_DATA(&kov2_latchdata_68k_w);
936   pgm_state *state = (pgm_state *)space->machine->driver_data;
937   if (PGMARM7LOGERROR)
938      logerror("M68K: Latch write: %04x (%04x) (%06x)\n", data & 0x0000ffff, mem_mask, cpu_get_pc(space->cpu));
939   COMBINE_DATA(&state->kov2_latchdata_68k_w);
901940}
902941
903942static ADDRESS_MAP_START( svg_68k_mem, ADDRESS_SPACE_PROGRAM, 16)
r6740r6741
908947
909948   AM_RANGE(0x800000, 0x81ffff) AM_RAM AM_MIRROR(0x0e0000) AM_BASE(&pgm_mainram) /* Main Ram */
910949
911//  AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE(&pgm_bg_videoram) /* Backgrounds */
912//  AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE(&pgm_tx_videoram) /* Text Layer */
913//  AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE(&pgm_rowscrollram)
914   AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE(&pgm_videoram) /* IGS023 VIDEO CHIP */
950//  AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(pgm_bg_videoram_w) AM_BASE_MEMBER(pgm_state, bg_videoram) /* Backgrounds */
951//  AM_RANGE(0x904000, 0x905fff) AM_RAM_WRITE(pgm_tx_videoram_w) AM_BASE_MEMBER(pgm_state, tx_videoram) /* Text Layer */
952//  AM_RANGE(0x907000, 0x9077ff) AM_RAM AM_BASE_MEMBER(pgm_state, rowscrollram)
953   AM_RANGE(0x900000, 0x907fff) AM_MIRROR(0x0f8000) AM_RAM_WRITE(pgm_videoram_w) AM_BASE_MEMBER(pgm_state, videoram) /* IGS023 VIDEO CHIP */
915954   AM_RANGE(0xa00000, 0xa011ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
916   AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE(&pgm_videoregs) /* Video Regs inc. Zoom Table */
955   AM_RANGE(0xb00000, 0xb0ffff) AM_RAM AM_BASE_MEMBER(pgm_state, videoregs) /* Video Regs inc. Zoom Table */
917956
918957   AM_RANGE(0xc00002, 0xc00003) AM_READWRITE(soundlatch_word_r, m68k_l1_w)
919958   AM_RANGE(0xc00004, 0xc00005) AM_READWRITE(soundlatch2_word_r, soundlatch2_word_w)
r6740r6741
12651304   is the source? maybe the protection device? */
12661305static INTERRUPT_GEN( drgw_interrupt )
12671306{
1268   if( cpu_getiloops(device) == 0 )
1307   if (cpu_getiloops(device) == 0)
12691308      cpu_set_input_line(device, 6, HOLD_LINE);
12701309   else
12711310      cpu_set_input_line(device, 4, HOLD_LINE);
12721311}
12731312
1274static MACHINE_RESET ( pgm )
1313static MACHINE_START( pgm )
12751314{
1315   pgm_state *state = (pgm_state *)machine->driver_data;
1316
1317   mame_get_base_datetime(machine, &state->systime);
1318
1319   state->soundcpu = devtag_get_device(machine, "soundcpu");
1320   state->prot = devtag_get_device(machine, "prot");
1321   state->ics = devtag_get_device(machine, "ics");
1322
1323   state_save_register_global(machine, state->cal_val);
1324   state_save_register_global(machine, state->cal_mask);
1325   state_save_register_global(machine, state->cal_com);
1326   state_save_register_global(machine, state->cal_cnt);
1327}
1328
1329static MACHINE_RESET( pgm )
1330{
1331   pgm_state *state = (pgm_state *)machine->driver_data;
1332
12761333   cputag_set_input_line(machine, "soundcpu", INPUT_LINE_HALT, ASSERT_LINE);
1334
1335   state->cal_val = 0;
1336   state->cal_mask = 0;
1337   state->cal_com = 0;
1338   state->cal_cnt = 0;
12771339}
12781340
12791341static MACHINE_DRIVER_START( pgm )
12801342
1343   /* driver data */
1344   MDRV_DRIVER_DATA(pgm_state)
1345
12811346   /* basic machine hardware */
12821347   MDRV_CPU_ADD("maincpu", M68000, 20000000) /* 20 mhz! verified on real board */
12831348   MDRV_CPU_PROGRAM_MAP(pgm_mem)
r6740r6741
12871352   MDRV_CPU_PROGRAM_MAP(z80_mem)
12881353   MDRV_CPU_IO_MAP(z80_io)
12891354
1290   MDRV_SPEAKER_STANDARD_MONO("mono")
1291   MDRV_SOUND_ADD("ics", ICS2115, 0)
1292   MDRV_SOUND_CONFIG(pgm_ics2115_interface)
1293   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 5.0)
1355   MDRV_MACHINE_START( pgm )
1356   MDRV_MACHINE_RESET( pgm )
1357   MDRV_NVRAM_HANDLER( pgm )
12941358
12951359   /* video hardware */
12961360   MDRV_SCREEN_ADD("screen", RASTER)
r6740r6741
13021366
13031367   MDRV_GFXDECODE(pgm)
13041368   MDRV_PALETTE_LENGTH(0x1200/2)
1305   MDRV_MACHINE_RESET ( pgm )
1306   MDRV_NVRAM_HANDLER ( pgm )
13071369
13081370   MDRV_VIDEO_START(pgm)
13091371   MDRV_VIDEO_EOF(pgm)
13101372   MDRV_VIDEO_UPDATE(pgm)
1373
1374   /*sound hardware */
1375   MDRV_SPEAKER_STANDARD_MONO("mono")
1376   MDRV_SOUND_ADD("ics", ICS2115, 0)
1377   MDRV_SOUND_CONFIG(pgm_ics2115_interface)
1378   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 5.0)
13111379MACHINE_DRIVER_END
13121380
13131381static MACHINE_DRIVER_START( drgw2 )
r6740r6741
13881456#endif
13891457
13901458
1391/*** Init Stuff **************************************************************/
1392
1393/* This function expands the 32x32 5-bit data into a format which is easier to
1394   decode in MAME */
1395
1396static void expand_32x32x5bpp(running_machine *machine)
1397{
1398   UINT8 *src    = memory_region       ( machine, "gfx1" );
1399   UINT8 *dst    = memory_region       ( machine, "gfx2" );
1400   size_t  srcsize = memory_region_length( machine, "gfx1" );
1401   int cnt, pix;
1402
1403   for (cnt = 0; cnt < srcsize/5 ; cnt ++)
1404   {
1405      pix =  ((src[0+5*cnt] >> 0)& 0x1f );                       dst[0+8*cnt]=pix;
1406      pix =  ((src[0+5*cnt] >> 5)& 0x07) | ((src[1+5*cnt] << 3) & 0x18);dst[1+8*cnt]=pix;
1407      pix =  ((src[1+5*cnt] >> 2)& 0x1f );                        dst[2+8*cnt]=pix;
1408      pix =  ((src[1+5*cnt] >> 7)& 0x01) | ((src[2+5*cnt] << 1) & 0x1e);dst[3+8*cnt]=pix;
1409      pix =  ((src[2+5*cnt] >> 4)& 0x0f) | ((src[3+5*cnt] << 4) & 0x10);dst[4+8*cnt]=pix;
1410      pix =  ((src[3+5*cnt] >> 1)& 0x1f );                       dst[5+8*cnt]=pix;
1411      pix =  ((src[3+5*cnt] >> 6)& 0x03) | ((src[4+5*cnt] << 2) & 0x1c);dst[6+8*cnt]=pix;
1412      pix =  ((src[4+5*cnt] >> 3)& 0x1f );                       dst[7+8*cnt]=pix;
1413   }
1414}
1415
1416/* This function expands the sprite colour data (in the A Roms) from 3 pixels
1417   in each word to a byte per pixel making it easier to use */
1418
1419UINT8 *pgm_sprite_a_region;
1420size_t   pgm_sprite_a_region_allocate;
1421
1422static void expand_colourdata(running_machine *machine)
1423{
1424   UINT8 *src    = memory_region       ( machine, "gfx3" );
1425   size_t  srcsize = memory_region_length( machine, "gfx3" );
1426   int cnt;
1427   size_t   needed = srcsize / 2 * 3;
1428
1429   /* work out how much ram we need to allocate to expand the sprites into
1430       and be able to mask the offset */
1431   pgm_sprite_a_region_allocate = 1;
1432   while (pgm_sprite_a_region_allocate < needed)
1433      pgm_sprite_a_region_allocate = pgm_sprite_a_region_allocate <<1;
1434
1435   pgm_sprite_a_region = auto_alloc_array(machine, UINT8, pgm_sprite_a_region_allocate);
1436
1437
1438   for (cnt = 0 ; cnt < srcsize/2 ; cnt++)
1439   {
1440      UINT16 colpack;
1441
1442      colpack = ((src[cnt*2]) | (src[cnt*2+1] << 8));
1443      pgm_sprite_a_region[cnt*3+0] = (colpack >> 0 ) & 0x1f;
1444      pgm_sprite_a_region[cnt*3+1] = (colpack >> 5 ) & 0x1f;
1445      pgm_sprite_a_region[cnt*3+2] = (colpack >> 10) & 0x1f;
1446   }
1447}
1448
1449static void pgm_basic_init(running_machine *machine)
1450{
1451   UINT8 *ROM = memory_region(machine, "maincpu");
1452   memory_set_bankptr(machine, "bank1",&ROM[0x100000]);
1453
1454   expand_32x32x5bpp(machine);
1455   expand_colourdata(machine);
1456
1457   pgm_bg_videoram = &pgm_videoram[0];
1458   pgm_tx_videoram = &pgm_videoram[0x4000/2];
1459   pgm_rowscrollram = &pgm_videoram[0x7000/2];
1460   kovsh_counter = 1;
1461}
1462
1463static DRIVER_INIT( pgm )
1464{
1465   pgm_basic_init(machine);
1466}
1467
1468/* Oriental Legend INIT */
1469
1470static DRIVER_INIT( orlegend )
1471{
1472   pgm_basic_init(machine);
1473
1474   memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xC0400e, 0xC0400f, 0, 0, pgm_asic3_r, pgm_asic3_w);
1475   memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xC04000, 0xC04001, 0, 0, pgm_asic3_reg_w);
1476}
1477
1478static void drgwld2_common_init(running_machine *machine)
1479{
1480   pgm_basic_init(machine);
1481   pgm_dw2_decrypt(machine);
1482   /*
1483    Info from Elsemi
1484    Here is how to "bypass" the dw2 hang protection, it fixes the mode
1485    select and after failing in the 2nd stage (probably there are other checks
1486    out there).
1487    */
1488   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xd80000, 0xd80003, 0, 0, dw2_d80000_r);
1489}
1490
1491static DRIVER_INIT( drgw2 )
1492{   /* incomplete? */
1493   UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu");
1494   drgwld2_common_init(machine);
1495   /* These ROM patches are not hacks, the protection device
1496       overlays the normal ROM code, this has been confirmed on a real PCB
1497       although some addresses may be missing */
1498   mem16[0x131098/2]=0x4e93;
1499   mem16[0x13113e/2]=0x4e93;
1500   mem16[0x1311ce/2]=0x4e93;
1501}
1502
1503static DRIVER_INIT( drgw2c )
1504{
1505   UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu");
1506   drgwld2_common_init(machine);
1507   /* These ROM patches are not hacks, the protection device
1508       overlays the normal ROM code, this has been confirmed on a real PCB
1509       although some addresses may be missing */
1510   mem16[0x1303bc/2]=0x4e93;
1511   mem16[0x130462/2]=0x4e93;
1512   mem16[0x1304F2/2]=0x4e93;
1513}
1514
1515static DRIVER_INIT( drgw2j )
1516{
1517   UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu");
1518   drgwld2_common_init(machine);
1519   /* These ROM patches are not hacks, the protection device
1520       overlays the normal ROM code, this has been confirmed on a real PCB
1521       although some addresses may be missing */
1522   mem16[0x1302C0/2]=0x4e93;
1523   mem16[0x130366/2]=0x4e93;
1524   mem16[0x1303F6/2]=0x4e93;
1525}
1526
1527static DRIVER_INIT( kov )
1528{
1529   pgm_basic_init(machine);
1530    pgm_kov_decrypt(machine);
1531}
1532
1533static DRIVER_INIT( pstar )
1534{
1535   pgm_basic_init(machine);
1536   pgm_pstar_decrypt(machine);
1537}
1538
1539static DRIVER_INIT( djlzz )
1540{
1541   pgm_basic_init(machine);
1542   pgm_djlzz_decrypt(machine);
1543}
1544
1545static DRIVER_INIT( kovsh )
1546{
1547   pgm_basic_init(machine);
1548   pgm_kovsh_decrypt(machine);
1549}
1550
1551static DRIVER_INIT( kovshp )
1552{
1553   pgm_basic_init(machine);
1554   pgm_kovshp_decrypt(machine);
1555}
1556
1557static DRIVER_INIT( oldsplus )
1558{
1559   pgm_basic_init(machine);
1560   pgm_oldsplus_decrypt(machine);
1561}
1562
1563static DRIVER_INIT( kov2 )
1564{
1565   pgm_basic_init(machine);
1566   pgm_kov2_decrypt(machine);
1567}
1568
1569static DRIVER_INIT( kov2p )
1570{
1571   pgm_basic_init(machine);
1572   pgm_kov2p_decrypt(machine);
1573}
1574
1575static DRIVER_INIT( martmast )
1576{
1577   pgm_basic_init(machine);
1578   pgm_mm_decrypt(machine);
1579}
1580
1581static DRIVER_INIT( ddp2 )
1582{
1583   pgm_basic_init(machine);
1584   pgm_ddp2_decrypt(machine);
1585}
1586
1587static void svg_basic_init(running_machine *machine)
1588{
1589   pgm_basic_init(machine);
1590   svg_shareram[0]=auto_alloc_array(machine, UINT32, 0x10000/4);
1591   svg_shareram[1]=auto_alloc_array(machine, UINT32, 0x10000/4);
1592   svg_ram_sel=0;
1593}
1594
1595static DRIVER_INIT( theglad )
1596{
1597   svg_basic_init(machine);
1598   pgm_theglad_decrypt(machine);
1599}
1600
1601static DRIVER_INIT( svg )
1602{
1603   svg_basic_init(machine);
1604   pgm_svg_decrypt(machine);
1605}
1606
1607static DRIVER_INIT( killbldp )
1608{
1609   svg_basic_init(machine);
1610   pgm_killbldp_decrypt(machine);
1611}
1612
1613static DRIVER_INIT( dmnfrnt )
1614{
1615   svg_basic_init(machine);
1616   pgm_dfront_decrypt(machine);
1617}
1618
1619static DRIVER_INIT( dw3 )
1620{
1621   pgm_basic_init(machine);
1622
1623//  memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xda0000, 0xdaffff, 0, 0, dw3_prot_r, dw3_prot_w);
1624
1625    pgm_dw3_decrypt(machine);
1626}
1627
1628/* Killing Blade uses some kind of DMA protection device which can copy data from a data rom.  The
1629   MCU appears to have an internal ROM as if you remove the data ROM then the shared ram is filled
1630   with a constant value.
1631
1632   The device can perform various decryption operations on the data it copies.  for now we're just
1633   using a dump of the shared RAM instead.  This will be improved later.
1634*/
1635
1636static int kb_cmd;
1637static int reg;
1638static int ptr=0;
1639
1640static WRITE16_HANDLER( killbld_prot_w )
1641{
1642//  mame_printf_debug("killbrd prot r\n");
1643//  return 0;
1644   offset&=0xf;
1645
1646   if(offset==0)
1647      kb_cmd=data;
1648   else //offset==2
1649   {
1650      logerror("%06X: ASIC25 W CMD %X  VAL %X",cpu_get_pc(space->cpu),kb_cmd,data);
1651      if(kb_cmd==0)
1652         reg=data;
1653      else if(kb_cmd==2)
1654      {
1655
1656         if(data==1)   //Execute cmd
1657         {
1658            UINT16 cmd=killbld_sharedprotram[0x200/2];
1659            //mame_printf_debug("command %04x\n",cmd);
1660            if(cmd==0x6d)   //Store values to asic ram
1661            {
1662               UINT32 p1=(killbld_sharedprotram[0x298/2] << 16) | killbld_sharedprotram[0x29a/2];
1663               UINT32 p2=(killbld_sharedprotram[0x29c/2] << 16) | killbld_sharedprotram[0x29e/2];
1664               static UINT32 Regs[0x10];
1665               if((p2&0xFFFF)==0x9)   //Set value
1666               {
1667                  int reg=(p2>>16)&0xFFFF;
1668                  if(reg&0x200)
1669                     Regs[reg&0xFF]=p1;
1670               }
1671               if((p2&0xFFFF)==0x6)   //Add value
1672               {
1673                  int src1=(p1>>16)&0xFF;
1674                  int src2=(p1>>0)&0xFF;
1675                  int dst=(p2>>16)&0xFF;
1676                  Regs[dst]=Regs[src2]-Regs[src1];
1677               }
1678               if((p2&0xFFFF)==0x1)   //Add Imm?
1679               {
1680                  int reg=(p2>>16)&0xFF;
1681                  int imm=(p1>>0)&0xFFFF;
1682                  Regs[reg]+=imm;
1683               }
1684               if((p2&0xFFFF)==0xa)   //Get value
1685               {
1686                  int reg=(p1>>16)&0xFF;
1687                  killbld_sharedprotram[0x29c/2] = (Regs[reg]>>16)&0xffff;
1688                  killbld_sharedprotram[0x29e/2] = Regs[reg]&0xffff;
1689               }
1690            }
1691            if(cmd==0x4f)   //memcpy with encryption / scrambling
1692            {
1693               UINT16 src=killbld_sharedprotram[0x290/2]>>1; // ?
1694               UINT32 dst=killbld_sharedprotram[0x292/2];
1695               UINT16 size=killbld_sharedprotram[0x294/2];
1696               UINT16 mode=killbld_sharedprotram[0x296/2];
1697
1698
1699            //  int a=1;
1700            //  if(src==0x580)
1701            //      int a=1;
1702               /*
1703                    P_SRC =0x300290 (offset from prot rom base)
1704                    P_DST =0x300292 (words from 0x300000)
1705                    P_SIZE=0x300294 (words)
1706                    P_MODE=0x300296
1707
1708                    Mode 5 direct
1709                    Mode 6 swap nibbles and bytes
1710
1711                    1,2,3 unk.
1712                    */
1713
1714               //mame_printf_debug("src %04x dst %04x size %04x mode %04x\n",src,dst,size,mode);
1715
1716               //if (src&1) mame_printf_debug("odd offset\n");
1717
1718               mode &=0xf;  // what are the other bits?
1719
1720               if (mode == 1 || mode == 2 || mode == 3)
1721               {
1722                  /* for now, cheat -- the scramble isn't understood, it might
1723                           be state based */
1724                  int x;
1725                  UINT16 *RAMDUMP = (UINT16*)memory_region(space->machine, "user2");
1726                  for (x=0;x<size;x++)
1727                  {
1728                     UINT16 dat;
1729
1730                     dat = RAMDUMP[dst+x];
1731                     killbld_sharedprotram[dst+x] = dat;
1732                  }
1733               }
1734               else if (mode == 5)
1735               {
1736                  /* mode 5 seems to be a straight copy */
1737                  int x;
1738                  UINT16 *RAMDUMP = (UINT16*)memory_region(space->machine, "user2");
1739                  UINT16 *PROTROM = (UINT16*)memory_region(space->machine, "user1");
1740                  for (x=0;x<size;x++)
1741                  {
1742                     UINT16 dat;
1743                     dat = PROTROM[src+x];
1744
1745                     if (RAMDUMP[dst+x] != dat)
1746                        mame_printf_debug("Mismatch! %04x %04x\n", RAMDUMP[dst+x], dat);
1747
1748                     killbld_sharedprotram[dst+x] = dat;
1749                  }
1750               }
1751               else if (mode == 6)
1752               {
1753                  /* mode 6 seems to swap bytes and nibbles */
1754                  int x;
1755                  UINT16 *RAMDUMP = (UINT16*)memory_region(space->machine, "user2");
1756                  UINT16 *PROTROM = (UINT16*)memory_region(space->machine, "user1");
1757                  for (x=0;x<size;x++)
1758                  {
1759                     UINT16 dat;
1760                     dat = PROTROM[src+x];
1761
1762                     dat = ((dat & 0xf000) >> 12)|
1763                          ((dat & 0x0f00) >> 4)|
1764                          ((dat & 0x00f0) << 4)|
1765                          ((dat & 0x000f) << 12);
1766
1767
1768                     if (RAMDUMP[dst+x] != dat)
1769                        mame_printf_debug("Mismatch! Mode 6 %04x %04x\n", RAMDUMP[dst+x], dat);
1770
1771                     killbld_sharedprotram[dst+x] = dat;
1772                  }
1773               }
1774               else
1775               {
1776                  mame_printf_debug("unknown copy mode!\n");
1777               }
1778               /* hack.. it jumps here but there isn't valid code even when we do
1779                       use what was in ram.. probably some more protection as the game
1780                       still doesn't behave 100% correctly :-/
1781
1782                       the code is copied in 'mode 3' but even the code put here on
1783                       the real ram dump is corrupt??? something _very_ strange is
1784                       going on.. maybe more rom overlays, or ram overlays too??
1785
1786                    */
1787               killbld_sharedprotram[0x2600/2]=0x4e75;
1788
1789
1790            }
1791            reg++;
1792         }
1793      }
1794      else if(kb_cmd==4)
1795         ptr=data;
1796      else if(kb_cmd==0x20)
1797         ptr++;
1798   }
1799}
1800
1801static READ16_HANDLER( killbld_prot_r )
1802{
1803//  mame_printf_debug("killbld prot w\n");
1804   UINT16 res ;
1805
1806   offset&=0xf;
1807   res=0;
1808
1809   if(offset==1)
1810   {
1811      if(kb_cmd==1)
1812      {
1813         res=reg&0x7f;
1814      }
1815      else if(kb_cmd==5)
1816      {
1817         UINT32 protvalue;
1818         protvalue = 0x89911400|input_port_read(space->machine, "Region");
1819         res=(protvalue>>(8*(ptr-1)))&0xff;
1820      }
1821   }
1822   logerror("%06X: ASIC25 R CMD %X  VAL %X",cpu_get_pc(space->cpu),kb_cmd,res);
1823   return res;
1824}
1825
1826static MACHINE_RESET( killbld )
1827{
1828   int i;
1829
1830   MACHINE_RESET_CALL(pgm);
1831
1832   /* fill the protection ram with a5 */
1833   for (i = 0;i < 0x4000/2;i++)
1834      killbld_sharedprotram[i] = 0xa5a5;
1835}
1836
1837
1838static DRIVER_INIT( killbld )
1839{
1840   UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu");
1841
1842   pgm_basic_init(machine);
1843    pgm_killbld_decrypt(machine);
1844
1845   /* this isn't a hack.. doing a rom dump while the game is running shows the
1846       rom space to look like this.. there may be more overlays / enables tho */
1847
1848   /* the game actually performs a CRC check of the rom during the 'Please Wait'
1849       screen, the checksum expected is that of the patched rom.  if the checksum
1850       fails the please wait screen doesn't last as long and the region supplied
1851       by the protection device is ignored and the attract sequence appears out
1852       of order */
1853   mem16[0x108a2c/2]=0xB6AA;
1854   mem16[0x108a30/2]=0x6610;
1855   mem16[0x108a32/2]=0x13c2;
1856   mem16[0x108a34/2]=0x0080;
1857   mem16[0x108a36/2]=0x9c76;
1858   mem16[0x108a38/2]=0x23c3;
1859   mem16[0x108a3a/2]=0x0080;
1860   mem16[0x108a3c/2]=0x9c78;
1861   mem16[0x108a3e/2]=0x1002;
1862   mem16[0x108a40/2]=0x6054;
1863   mem16[0x108a42/2]=0x5202;
1864   mem16[0x108a44/2]=0x0c02;
1865
1866   memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xd40000, 0xd40003, 0, 0, killbld_prot_r, killbld_prot_w);
1867}
1868
1869static DRIVER_INIT( puzzli2 )
1870{
1871   /* this protection emulation is wrong
1872     it uses an arm with no external rom
1873     an acts in a similar way to kov etc. */
1874
1875   UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu");
1876
1877   pgm_basic_init(machine);
1878
1879   memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x500000, 0x500003, 0, 0, ASIC28_r16, ASIC28_w16);
1880
1881   /* 0x4f0000 - ? is actually ram shared with the protection device,
1882      the protection device provides the region code */
1883   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x4f0000, 0x4fffff, 0, 0, sango_protram_r);
1884
1885    pgm_puzzli2_decrypt(machine);
1886
1887   /* protection related? */
1888   mem16[0x1548ec/2]=0x4e71;
1889   mem16[0x1548fc/2]=0x4e71;
1890   mem16[0x1549FA/2]=0x4e71;
1891   mem16[0x154A0A/2]=0x4e71;
1892   mem16[0x15496A/2]=0x4e71;
1893   mem16[0x14cee0/2]=0x4e71;
1894   mem16[0x1268c0/2]=0x4e71;
1895   mem16[0x1268c2/2]=0x4e71;
1896   mem16[0x1268c4/2]=0x4e71;
1897   mem16[0x154948/2]=0x4e71;
1898   mem16[0x13877a/2]=0x662c;
1899
1900   /* patch irq4 vector (irq4 should be disabled on this game? how?) */
1901//  mem16[0x100070/2]=0x0012;
1902//  mem16[0x100072/2]=0x5D78;
1903}
1904
1905static UINT16 olds_bs,olds_cmd3;
1906
1907static UINT32 olds_prot_addr( UINT16 addr)
1908{
1909   UINT32 mode = addr&0xff;
1910   UINT32 offset = addr >> 8;
1911   UINT32 realaddr;
1912
1913   switch(mode)
1914   {
1915      case 0:
1916      case 5:
1917      case 0xA:
1918         realaddr= 0x402A00+(offset<<2);
1919         break;
1920
1921      case 2:
1922      case 8:
1923         realaddr= 0x402E00+(offset<<2);
1924         break;
1925
1926      case 1:
1927         realaddr= 0x40307E;
1928         break;
1929
1930      case 3:
1931         realaddr= 0x403090;
1932         break;
1933
1934      case 4:
1935         realaddr= 0x40309A;
1936         break;
1937
1938      case 6:
1939         realaddr= 0x4030A4;
1940         break;
1941
1942      case 7:
1943         realaddr= 0x403000;
1944         break;
1945
1946      case 9:
1947         realaddr= 0x40306E;
1948         break;
1949
1950      default:
1951         realaddr= 0;
1952   }
1953   return realaddr;
1954}
1955
1956static UINT32 olds_read_reg( UINT16 addr)
1957{
1958   UINT32 protaddr = (olds_prot_addr(addr)-0x400000)/2;
1959   return olds_sharedprotram[protaddr]<<16|olds_sharedprotram[protaddr+1];
1960}
1961
1962static void olds_write_reg( UINT16 addr, UINT32 val)
1963{
1964   olds_sharedprotram[(olds_prot_addr(addr)-0x400000)/2]=val>>16;
1965   olds_sharedprotram[(olds_prot_addr(addr)-0x400000)/2+1]=val&0xffff;
1966}
1967
1968static MACHINE_RESET( olds )
1969{
1970   UINT16 *mem16 = (UINT16 *)memory_region(machine, "user2");
1971   int i;
1972
1973   MACHINE_RESET_CALL(pgm);
1974
1975   /* populate shared protection ram with data read from pcb .. */
1976
1977   for(i=0;i<0x4000/2;i++)
1978   {
1979      olds_sharedprotram[i] = mem16[i];
1980   }
1981
1982   //ROM:004008B4                 .word 0xFBA5
1983   for(i=0;i<0x4000/2;i++)
1984   {
1985      if(olds_sharedprotram[i]==(0xffff-i))
1986         olds_sharedprotram[i]=0x4e75;
1987   }
1988}
1989
1990static READ16_HANDLER( olds_r16 )
1991{
1992   UINT16 res ;
1993   res = 0;
1994
1995   if(offset == 1)
1996   {
1997      if(kb_cmd == 1)
1998         res = reg&0x7f;
1999      if(kb_cmd == 2)
2000         res = olds_bs|0x80;
2001      if(kb_cmd == 3)
2002         res = olds_cmd3;
2003      else if(kb_cmd == 5)
2004      {
2005         UINT32 protvalue = 0x900000 | input_port_read(space->machine, "Region"); // region from protection device.
2006         res = (protvalue>>(8 * (ptr-1))) & 0xff; // includes region 1 = taiwan , 2 = china, 3 = japan (title = orlegend special), 4 = korea, 5 = hongkong, 6 = world
2007
2008      }
2009   }
2010   logerror("%06X: ASIC25 R CMD %X  VAL %X\n",cpu_get_pc(space->cpu),kb_cmd,res);
2011   return res;
2012}
2013
2014static WRITE16_HANDLER( olds_w16 )
2015{
2016   if(offset==0)
2017      kb_cmd=data;
2018   else //offset==2
2019   {
2020      logerror("%06X: ASIC25 W CMD %X  VAL %X\n",cpu_get_pc(space->cpu),kb_cmd,data);
2021      if(kb_cmd==0)
2022         reg=data;
2023      else if(kb_cmd==2)   //a bitswap=
2024      {
2025         int reg=0;
2026         if(data&0x01)
2027            reg|=0x40;
2028         if(data&0x02)
2029            reg|=0x80;
2030         if(data&0x04)
2031            reg|=0x20;
2032         if(data&0x08)
2033            reg|=0x10;
2034         olds_bs=reg;
2035      }
2036      else if(kb_cmd==3)
2037      {
2038         UINT16 cmd=olds_sharedprotram[0x3026/2];
2039         switch(cmd)
2040         {
2041            case 0x11:
2042            case 0x12:
2043                  break;
2044            case 0x64:
2045               {
2046                  UINT16 cmd0 = olds_sharedprotram[0x3082/2];
2047                  UINT16 val0 = olds_sharedprotram[0x3050/2];   //CMD_FORMAT
2048                  {
2049                     if((cmd0&0xff)==0x2)
2050                        olds_write_reg(val0,olds_read_reg(val0)+0x10000);
2051                  }
2052                  break;
2053               }
2054
2055            default:
2056                  break;
2057         }
2058         olds_cmd3=((data>>4)+1)&0x3;
2059      }
2060      else if(kb_cmd==4)
2061         ptr=data;
2062      else if(kb_cmd==0x20)
2063        ptr++;
2064   }
2065}
2066
2067static READ16_HANDLER( olds_prot_swap_r16 )
2068{
2069
2070   if(cpu_get_pc(space->cpu)<0x100000)      //bios
2071      return pgm_mainram[0x178F4/2];
2072   else                  //game
2073      return pgm_mainram[0x178D8/2];
2074
2075}
2076
2077static DRIVER_INIT( olds )
2078{
2079   pgm_basic_init(machine);
2080
2081   memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xdcb400, 0xdcb403, 0, 0, olds_r16, olds_w16);
2082   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8178f4, 0x8178f5, 0, 0, olds_prot_swap_r16);
2083}
2084
20851459/*** Rom Loading *************************************************************/
20861460
20871461/* take note of "gfx2" needed for expanding the 32x32x5bpp data and
r6740r6741
41373511   ROM_LOAD( "w05602b032.bin",  0xc00000, 0x400000, CRC(0685166d) SHA1(64dac49abd2a46d5fb58c678027aa5e23d672dc4) )
41383512ROM_END
41393513
3514ROM_START( happy6 )
3515   ROM_REGION( 0x600000, "maincpu", 0 ) /* 68000 Code */
3516   ROM_LOAD16_WORD_SWAP( "pgm_p01s.rom", 0x000000, 0x020000, CRC(e42b166e) SHA1(2a9df9ec746b14b74fae48b1a438da14973702ea) )  // (BIOS)
3517   ROM_LOAD16_WORD_SWAP( "happy6in1_v100cn.u5",      0x100000, 0x080000, CRC(a25418e8) SHA1(acd7e7b69956cb4ce8e26c6420cb97bb4bf404e7) )
41403518
3519   /* CPU2 = Z80, romless, code uploaded by 68k */
3520
3521   ROM_REGION( 0x4000, "prot", 0 ) /* ARM protection ASIC - internal rom */
3522   // data before 0x188 is read-protected and cannot be read even with a trojan (as with most 2001/2+ IGS titles)
3523   ROM_LOAD( "happy6_igs027a.bin", 0x000000, 0x04000, NO_DUMP )
3524
3525   ROM_REGION( 0x800000, "user1", 0 ) /* Protection Data (encrypted external ARM data) */
3526   ROM_LOAD( "happy6in1_v101cn.u26", 0x000000, 0x400000, CRC(4a48ca1c) SHA1(3bebc091787903d45cb84c7302046602a903f59c) )
3527
3528   ROM_REGION( 0xc00000, "gfx1", 0 ) /* 8x8 Text Tiles + 32x32 BG Tiles */
3529   ROM_LOAD( "pgm_t01s.rom",  0x000000, 0x200000, CRC(1a7123a0) SHA1(cc567f577bfbf45427b54d6695b11b74f2578af3) ) // (BIOS)
3530   ROM_LOAD( "t01w64m.u29",0x400000, 0x800000, CRC(2d3feb8b) SHA1(9832b1c46b1ee73febf5c5c8913859f4e0581665) )
3531
3532   ROM_REGION( 0xc00000/5*8, "gfx2", ROMREGION_ERASEFF ) /* Region for 32x32 BG Tiles */
3533   /* 32x32 Tile Data is put here for easier Decoding */
3534
3535   ROM_REGION( 0x1c00000, "gfx3", 0 ) /* Sprite Colour Data */
3536   ROM_LOAD( "a01w64m.u5",  0x0000000, 0x0800000, CRC(bbaa3df3) SHA1(a72268d3989e96d571242279922291d0dc72db28) )
3537   ROM_LOAD( "a02w64m.u6",  0x0800000, 0x0800000, CRC(f8c9cd36) SHA1(d9613a83bcc2364492fa922fde1c4f0d07b3009c) )
3538
3539   ROM_REGION( 0x1000000, "gfx4", 0 ) /* Sprite Masks + Colour Indexes */
3540   ROM_LOAD( "b01w64m.u19",  0x0000000, 0x0800000, CRC(73f5f225) SHA1(507126fa96dcec967bdbc0978d79fbce9d25db37) )
3541
3542   ROM_REGION( 0x1000000, "ics", 0 ) /* Samples - (8 bit mono 11025Hz) - */
3543   ROM_LOAD( "pgm_m01s.rom",    0x000000, 0x200000, CRC(45ae7159) SHA1(d3ed3ff3464557fd0df6b069b2e431528b0ebfa8) ) // (BIOS)
3544   ROM_LOAD( "w01w64m.u17",  0x400000, 0x800000, CRC(7e23e2be) SHA1(5e920b8e480f00b6666292d4a56039b40af18141) )
3545ROM_END
3546
3547
3548
3549/*** Init Stuff **************************************************************/
3550
3551/* This function expands the 32x32 5-bit data into a format which is easier to
3552   decode in MAME */
3553
3554static void expand_32x32x5bpp(running_machine *machine)
3555{
3556   UINT8 *src = memory_region( machine, "gfx1" );
3557   UINT8 *dst = memory_region( machine, "gfx2" );
3558   size_t  srcsize = memory_region_length( machine, "gfx1" );
3559   int cnt, pix;
3560
3561   for (cnt = 0; cnt < srcsize/5 ; cnt ++)
3562   {
3563      pix = ((src[0 + 5 * cnt] >> 0)& 0x1f );
3564         dst[0 + 8 * cnt]=pix;
3565      pix = ((src[0 + 5 * cnt] >> 5)& 0x07) | ((src[1 + 5 * cnt] << 3) & 0x18);
3566         dst[1 + 8 * cnt]=pix;
3567      pix = ((src[1 + 5 * cnt] >> 2)& 0x1f );
3568         dst[2 + 8 * cnt]=pix;
3569      pix = ((src[1 + 5 * cnt] >> 7)& 0x01) | ((src[2 + 5 * cnt] << 1) & 0x1e);
3570         dst[3 + 8 * cnt]=pix;
3571      pix = ((src[2 + 5 * cnt] >> 4)& 0x0f) | ((src[3 + 5 * cnt] << 4) & 0x10);
3572         dst[4 + 8 * cnt]=pix;
3573      pix = ((src[3 + 5 * cnt] >> 1)& 0x1f );
3574         dst[5 + 8 * cnt]=pix;
3575      pix = ((src[3 + 5 * cnt] >> 6)& 0x03) | ((src[4 + 5 * cnt] << 2) & 0x1c);
3576         dst[6 + 8 * cnt]=pix;
3577      pix = ((src[4 + 5 * cnt] >> 3)& 0x1f );
3578         dst[7 + 8 * cnt]=pix;
3579   }
3580}
3581
3582/* This function expands the sprite colour data (in the A Roms) from 3 pixels
3583   in each word to a byte per pixel making it easier to use */
3584
3585static void expand_colourdata( running_machine *machine )
3586{
3587   pgm_state *state = (pgm_state *)machine->driver_data;
3588   UINT8 *src = memory_region( machine, "gfx3" );
3589   size_t srcsize = memory_region_length( machine, "gfx3" );
3590   int cnt;
3591   size_t needed = srcsize / 2 * 3;
3592
3593   /* work out how much ram we need to allocate to expand the sprites into
3594       and be able to mask the offset */
3595   state->sprite_a_region_size = 1;
3596   while (state->sprite_a_region_size < needed)
3597      state->sprite_a_region_size <<= 1;
3598
3599   state->sprite_a_region = auto_alloc_array(machine, UINT8, state->sprite_a_region_size);
3600
3601   for (cnt = 0 ; cnt < srcsize / 2 ; cnt++)
3602   {
3603      UINT16 colpack;
3604
3605      colpack = ((src[cnt * 2]) | (src[cnt * 2 + 1] << 8));
3606      state->sprite_a_region[cnt * 3 + 0] = (colpack >> 0 ) & 0x1f;
3607      state->sprite_a_region[cnt * 3 + 1] = (colpack >> 5 ) & 0x1f;
3608      state->sprite_a_region[cnt * 3 + 2] = (colpack >> 10) & 0x1f;
3609   }
3610}
3611
3612static void pgm_basic_init( running_machine *machine )
3613{
3614   pgm_state *state = (pgm_state *)machine->driver_data;
3615   UINT8 *ROM = memory_region(machine, "maincpu");
3616   memory_set_bankptr(machine, "bank1", &ROM[0x100000]);
3617
3618   expand_32x32x5bpp(machine);
3619   expand_colourdata(machine);
3620
3621   state->bg_videoram = &state->videoram[0];
3622   state->tx_videoram = &state->videoram[0x4000/2];
3623   state->rowscrollram = &state->videoram[0x7000/2];
3624}
3625
3626static DRIVER_INIT( pgm )
3627{
3628   pgm_basic_init(machine);
3629}
3630
3631/* Oriental Legend INIT */
3632
3633static DRIVER_INIT( orlegend )
3634{
3635   pgm_state *state = (pgm_state *)machine->driver_data;
3636   pgm_basic_init(machine);
3637
3638   memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xC0400e, 0xC0400f, 0, 0, pgm_asic3_r, pgm_asic3_w);
3639   memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xC04000, 0xC04001, 0, 0, pgm_asic3_reg_w);
3640
3641   state->asic3_reg = 0;
3642   state->asic3_latch[0] = 0;
3643   state->asic3_latch[1] = 0;
3644   state->asic3_latch[2] = 0;
3645   state->asic3_x = 0;
3646   state->asic3_y = 0;
3647   state->asic3_z = 0;
3648   state->asic3_h1 = 0;
3649   state->asic3_h2 = 0;
3650   state->asic3_hold = 0;
3651
3652   state_save_register_global(machine, state->asic3_reg);
3653   state_save_register_global_array(machine, state->asic3_latch);
3654   state_save_register_global(machine, state->asic3_x);
3655   state_save_register_global(machine, state->asic3_y);
3656   state_save_register_global(machine, state->asic3_z);
3657   state_save_register_global(machine, state->asic3_h1);
3658   state_save_register_global(machine, state->asic3_h2);
3659   state_save_register_global(machine, state->asic3_hold);
3660}
3661
3662static void drgwld2_common_init(running_machine *machine)
3663{
3664   pgm_basic_init(machine);
3665   pgm_dw2_decrypt(machine);
3666   /*
3667    Info from Elsemi
3668    Here is how to "bypass" the dw2 hang protection, it fixes the mode
3669    select and after failing in the 2nd stage (probably there are other checks
3670    out there).
3671    */
3672   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xd80000, 0xd80003, 0, 0, dw2_d80000_r);
3673}
3674
3675static DRIVER_INIT( drgw2 )
3676{   /* incomplete? */
3677   UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu");
3678   drgwld2_common_init(machine);
3679   /* These ROM patches are not hacks, the protection device
3680       overlays the normal ROM code, this has been confirmed on a real PCB
3681       although some addresses may be missing */
3682   mem16[0x131098 / 2] = 0x4e93;
3683   mem16[0x13113e / 2] = 0x4e93;
3684   mem16[0x1311ce / 2] = 0x4e93;
3685}
3686
3687static DRIVER_INIT( drgw2c )
3688{
3689   UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu");
3690   drgwld2_common_init(machine);
3691   /* These ROM patches are not hacks, the protection device
3692       overlays the normal ROM code, this has been confirmed on a real PCB
3693       although some addresses may be missing */
3694   mem16[0x1303bc / 2] = 0x4e93;
3695   mem16[0x130462 / 2] = 0x4e93;
3696   mem16[0x1304f2 / 2] = 0x4e93;
3697}
3698
3699static DRIVER_INIT( drgw2j )
3700{
3701   UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu");
3702   drgwld2_common_init(machine);
3703   /* These ROM patches are not hacks, the protection device
3704       overlays the normal ROM code, this has been confirmed on a real PCB
3705       although some addresses may be missing */
3706   mem16[0x1302c0 / 2] = 0x4e93;
3707   mem16[0x130366 / 2] = 0x4e93;
3708   mem16[0x1303f6 / 2] = 0x4e93;
3709}
3710
3711static void kovsh_latch_init( running_machine *machine )
3712{
3713   pgm_state *state = (pgm_state *)machine->driver_data;
3714
3715   state->kovsh_highlatch_arm_w = 0;
3716   state->kovsh_lowlatch_arm_w = 0;
3717   state->kovsh_highlatch_68k_w = 0;
3718   state->kovsh_lowlatch_68k_w = 0;
3719   state->kovsh_counter = 1;
3720
3721   state_save_register_global(machine, state->kovsh_highlatch_arm_w);
3722   state_save_register_global(machine, state->kovsh_lowlatch_arm_w);
3723   state_save_register_global(machine, state->kovsh_highlatch_68k_w);
3724   state_save_register_global(machine, state->kovsh_lowlatch_68k_w);
3725   state_save_register_global(machine, state->kovsh_counter);
3726}
3727
3728static DRIVER_INIT( kov )
3729{
3730   pgm_basic_init(machine);
3731    pgm_kov_decrypt(machine);
3732    kovsh_latch_init(machine);
3733}
3734
3735static DRIVER_INIT( pstar )
3736{
3737   pgm_state *state = (pgm_state *)machine->driver_data;
3738
3739   pgm_basic_init(machine);
3740   pgm_pstar_decrypt(machine);
3741    kovsh_latch_init(machine);
3742
3743   state->pstars_key = 0;
3744   state->pstars_int[0] = 0;
3745   state->pstars_int[1] = 0;
3746   state->pstars_val = 0;
3747   state->pstar_e7 = 0;
3748   state->pstar_b1 = 0;
3749   state->pstar_ce = 0;
3750   state->pstar_ram[0] = 0;
3751   state->pstar_ram[1] = 0;
3752   state->pstar_ram[2] = 0;
3753   memset(state->pstars_regs, 0, 16);
3754
3755   state_save_register_global(machine, state->pstars_key);
3756   state_save_register_global_array(machine, state->pstars_int);
3757   state_save_register_global_array(machine, state->pstars_regs);
3758   state_save_register_global(machine, state->pstars_val);
3759   state_save_register_global(machine, state->pstar_e7);
3760   state_save_register_global(machine, state->pstar_b1);
3761   state_save_register_global(machine, state->pstar_ce);
3762   state_save_register_global_array(machine, state->pstar_ram);
3763}
3764
3765static DRIVER_INIT( djlzz )
3766{
3767   pgm_basic_init(machine);
3768   pgm_djlzz_decrypt(machine);
3769    kovsh_latch_init(machine);
3770}
3771
3772static DRIVER_INIT( kovsh )
3773{
3774   pgm_basic_init(machine);
3775   pgm_kovsh_decrypt(machine);
3776    kovsh_latch_init(machine);
3777}
3778
3779static DRIVER_INIT( kovshp )
3780{
3781   pgm_basic_init(machine);
3782   pgm_kovshp_decrypt(machine);
3783    kovsh_latch_init(machine);
3784}
3785
3786static DRIVER_INIT( oldsplus )
3787{
3788   pgm_basic_init(machine);
3789   pgm_oldsplus_decrypt(machine);
3790    kovsh_latch_init(machine);
3791}
3792
3793static void kov2_latch_init( running_machine *machine )
3794{
3795   pgm_state *state = (pgm_state *)machine->driver_data;
3796
3797   state->kov2_latchdata_68k_w = 0;
3798   state->kov2_latchdata_arm_w = 0;
3799
3800   state_save_register_global(machine, state->kov2_latchdata_68k_w);
3801   state_save_register_global(machine, state->kov2_latchdata_arm_w);
3802}
3803
3804static DRIVER_INIT( kov2 )
3805{
3806   pgm_basic_init(machine);
3807   pgm_kov2_decrypt(machine);
3808    kov2_latch_init(machine);
3809}
3810
3811static DRIVER_INIT( kov2p )
3812{
3813   pgm_basic_init(machine);
3814   pgm_kov2p_decrypt(machine);
3815    kov2_latch_init(machine);
3816}
3817
3818static DRIVER_INIT( martmast )
3819{
3820   pgm_basic_init(machine);
3821   pgm_mm_decrypt(machine);
3822    kov2_latch_init(machine);
3823}
3824
3825static DRIVER_INIT( ddp2 )
3826{
3827   pgm_basic_init(machine);
3828   pgm_ddp2_decrypt(machine);
3829    kov2_latch_init(machine);
3830}
3831
3832static void svg_basic_init(running_machine *machine)
3833{
3834   pgm_state *state = (pgm_state *)machine->driver_data;
3835
3836   pgm_basic_init(machine);
3837   state->svg_shareram[0] = auto_alloc_array(machine, UINT32, 0x10000 / 4);
3838   state->svg_shareram[1] = auto_alloc_array(machine, UINT32, 0x10000 / 4);
3839   state->svg_ram_sel = 0;
3840
3841   state_save_register_global_pointer(machine, state->svg_shareram[0], 0x10000 / 4);
3842   state_save_register_global_pointer(machine, state->svg_shareram[1], 0x10000 / 4);
3843   state_save_register_global(machine, state->svg_ram_sel);
3844}
3845
3846static DRIVER_INIT( theglad )
3847{
3848   svg_basic_init(machine);
3849   pgm_theglad_decrypt(machine);
3850    kov2_latch_init(machine);
3851}
3852
3853static DRIVER_INIT( svg )
3854{
3855   svg_basic_init(machine);
3856   pgm_svg_decrypt(machine);
3857    kov2_latch_init(machine);
3858}
3859
3860static DRIVER_INIT( killbldp )
3861{
3862   svg_basic_init(machine);
3863   pgm_killbldp_decrypt(machine);
3864    kov2_latch_init(machine);
3865}
3866
3867static DRIVER_INIT( dmnfrnt )
3868{
3869   svg_basic_init(machine);
3870   pgm_dfront_decrypt(machine);
3871    kov2_latch_init(machine);
3872}
3873
3874static DRIVER_INIT( dw3 )
3875{
3876   pgm_basic_init(machine);
3877
3878//  memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xda0000, 0xdaffff, 0, 0, dw3_prot_r, dw3_prot_w);
3879
3880    pgm_dw3_decrypt(machine);
3881}
3882
3883/* Killing Blade uses some kind of DMA protection device which can copy data from a data rom.  The
3884   MCU appears to have an internal ROM as if you remove the data ROM then the shared ram is filled
3885   with a constant value.
3886
3887   The device can perform various decryption operations on the data it copies.  for now we're just
3888   using a dump of the shared RAM instead.  This will be improved later.
3889*/
3890
3891
3892static WRITE16_HANDLER( killbld_prot_w )
3893{
3894//  mame_printf_debug("killbrd prot r\n");
3895//  return 0;
3896   pgm_state *state = (pgm_state *)space->machine->driver_data;
3897   offset &= 0xf;
3898
3899   if (offset == 0)
3900      state->kb_cmd = data;
3901   else //offset==2
3902   {
3903      logerror("%06X: ASIC25 W CMD %X  VAL %X", cpu_get_pc(space->cpu), state->kb_cmd, data);
3904      if (state->kb_cmd == 0)
3905         state->kb_reg = data;
3906      else if (state->kb_cmd == 2)
3907      {
3908         if (data == 1)   //Execute cmd
3909         {
3910            UINT16 cmd = state->sharedprotram[0x200/2];
3911            //mame_printf_debug("command %04x\n", cmd);
3912            if (cmd == 0x6d)   //Store values to asic ram
3913            {
3914               UINT32 p1 = (state->sharedprotram[0x298/2] << 16) | state->sharedprotram[0x29a/2];
3915               UINT32 p2 = (state->sharedprotram[0x29c/2] << 16) | state->sharedprotram[0x29e/2];
3916
3917               if ((p2 & 0xffff) == 0x9)   //Set value
3918               {
3919                  int reg = (p2 >> 16) & 0xffff;
3920                  if (reg & 0x200)
3921                     state->kb_regs[reg & 0xff] = p1;
3922               }
3923               if ((p2 & 0xffff) == 0x6)   //Add value
3924               {
3925                  int src1 = (p1 >> 16) & 0xff;
3926                  int src2 = (p1 >> 0) & 0xff;
3927                  int dst = (p2 >> 16) & 0xff;
3928                  state->kb_regs[dst] = state->kb_regs[src2] - state->kb_regs[src1];
3929               }
3930               if ((p2 & 0xffff) == 0x1)   //Add Imm?
3931               {
3932                  int reg = (p2 >> 16) & 0xff;
3933                  int imm = (p1 >> 0) & 0xffff;
3934                  state->kb_regs[reg] += imm;
3935               }
3936               if ((p2 & 0xffff) == 0xa)   //Get value
3937               {
3938                  int reg = (p1 >> 16) & 0xFF;
3939                  state->sharedprotram[0x29c/2] = (state->kb_regs[reg] >> 16) & 0xffff;
3940                  state->sharedprotram[0x29e/2] = state->kb_regs[reg] & 0xffff;
3941               }
3942            }
3943            if(cmd == 0x4f)   //memcpy with encryption / scrambling
3944            {
3945               UINT16 src = state->sharedprotram[0x290 / 2] >> 1; // ?
3946               UINT32 dst = state->sharedprotram[0x292 / 2];
3947               UINT16 size = state->sharedprotram[0x294 / 2];
3948               UINT16 mode = state->sharedprotram[0x296 / 2];
3949
3950
3951            //  int a=1;
3952            //  if(src==0x580)
3953            //      int a=1;
3954               /*
3955                    P_SRC =0x300290 (offset from prot rom base)
3956                    P_DST =0x300292 (words from 0x300000)
3957                    P_SIZE=0x300294 (words)
3958                    P_MODE=0x300296
3959
3960                    Mode 5 direct
3961                    Mode 6 swap nibbles and bytes
3962
3963                    1,2,3 unk.
3964                    */
3965
3966               //mame_printf_debug("src %04x dst %04x size %04x mode %04x\n", src, dst, size, mode);
3967
3968               //if (src&1) mame_printf_debug("odd offset\n");
3969
3970               mode &=0xf;  // what are the other bits?
3971
3972               if (mode == 1 || mode == 2 || mode == 3)
3973               {
3974                  /* for now, cheat -- the scramble isn't understood, it might
3975                           be state based */
3976                  int x;
3977                  UINT16 *RAMDUMP = (UINT16*)memory_region(space->machine, "user2");
3978                  for (x = 0; x < size; x++)
3979                  {
3980                     UINT16 dat;
3981
3982                     dat = RAMDUMP[dst + x];
3983                     state->sharedprotram[dst + x] = dat;
3984                  }
3985               }
3986               else if (mode == 5)
3987               {
3988                  /* mode 5 seems to be a straight copy */
3989                  int x;
3990                  UINT16 *RAMDUMP = (UINT16*)memory_region(space->machine, "user2");
3991                  UINT16 *PROTROM = (UINT16*)memory_region(space->machine, "user1");
3992                  for (x = 0; x < size; x++)
3993                  {
3994                     UINT16 dat = PROTROM[src + x];
3995
3996                     if (RAMDUMP[dst + x] != dat)
3997                        mame_printf_debug("Mismatch! %04x %04x\n", RAMDUMP[dst + x], dat);
3998
3999                     state->sharedprotram[dst + x] = dat;
4000                  }
4001               }
4002               else if (mode == 6)
4003               {
4004                  /* mode 6 seems to swap bytes and nibbles */
4005                  int x;
4006                  UINT16 *RAMDUMP = (UINT16*)memory_region(space->machine, "user2");
4007                  UINT16 *PROTROM = (UINT16*)memory_region(space->machine, "user1");
4008                  for (x = 0; x < size; x++)
4009                  {
4010                     UINT16 dat = PROTROM[src + x];
4011
4012                     dat = ((dat & 0xf000) >> 12)|
4013                          ((dat & 0x0f00) >> 4)|
4014                          ((dat & 0x00f0) << 4)|
4015                          ((dat & 0x000f) << 12);
4016
4017                     if (RAMDUMP[dst + x] != dat)
4018                        mame_printf_debug("Mismatch! Mode 6 %04x %04x\n", RAMDUMP[dst + x], dat);
4019
4020                     state->sharedprotram[dst + x] = dat;
4021                  }
4022               }
4023               else
4024               {
4025                  mame_printf_debug("unknown copy mode!\n");
4026               }
4027               /* hack.. it jumps here but there isn't valid code even when we do
4028                       use what was in ram.. probably some more protection as the game
4029                       still doesn't behave 100% correctly :-/
4030
4031                       the code is copied in 'mode 3' but even the code put here on
4032                       the real ram dump is corrupt??? something _very_ strange is
4033                       going on.. maybe more rom overlays, or ram overlays too??
4034
4035                    */
4036               state->sharedprotram[0x2600 / 2] = 0x4e75;
4037
4038
4039            }
4040            state->kb_reg++;
4041         }
4042      }
4043      else if (state->kb_cmd == 4)
4044         state->kb_ptr = data;
4045      else if (state->kb_cmd == 0x20)
4046         state->kb_ptr++;
4047   }
4048}
4049
4050static READ16_HANDLER( killbld_prot_r )
4051{
4052//  mame_printf_debug("killbld prot w\n");
4053   pgm_state *state = (pgm_state *)space->machine->driver_data;
4054   UINT16 res ;
4055
4056   offset &= 0xf;
4057   res = 0;
4058
4059   if (offset == 1)
4060   {
4061      if (state->kb_cmd == 1)
4062      {
4063         res = state->kb_reg & 0x7f;
4064      }
4065      else if (state->kb_cmd == 5)
4066      {
4067         UINT32 protvalue = 0x89911400 | input_port_read(space->machine, "Region");
4068         res = (protvalue >> (8 * (state->kb_ptr - 1))) & 0xff;
4069      }
4070   }
4071   logerror("%06X: ASIC25 R CMD %X  VAL %X", cpu_get_pc(space->cpu), state->kb_cmd, res);
4072   return res;
4073}
4074
4075static MACHINE_RESET( killbld )
4076{
4077   pgm_state *state = (pgm_state *)machine->driver_data;
4078   int i;
4079
4080   MACHINE_RESET_CALL(pgm);
4081
4082   /* fill the protection ram with a5 */
4083   for (i = 0; i < 0x4000/2; i++)
4084      state->sharedprotram[i] = 0xa5a5;
4085}
4086
4087
4088static DRIVER_INIT( killbld )
4089{
4090   pgm_state *state = (pgm_state *)machine->driver_data;
4091   UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu");
4092
4093   pgm_basic_init(machine);
4094    pgm_killbld_decrypt(machine);
4095
4096   /* this isn't a hack.. doing a rom dump while the game is running shows the
4097       rom space to look like this.. there may be more overlays / enables tho */
4098
4099   /* the game actually performs a CRC check of the rom during the 'Please Wait'
4100       screen, the checksum expected is that of the patched rom.  if the checksum
4101       fails the please wait screen doesn't last as long and the region supplied
4102       by the protection device is ignored and the attract sequence appears out
4103       of order */
4104   mem16[0x108a2c / 2] = 0xb6aa;
4105   mem16[0x108a30 / 2] = 0x6610;
4106   mem16[0x108a32 / 2] = 0x13c2;
4107   mem16[0x108a34 / 2] = 0x0080;
4108   mem16[0x108a36 / 2] = 0x9c76;
4109   mem16[0x108a38 / 2] = 0x23c3;
4110   mem16[0x108a3a / 2] = 0x0080;
4111   mem16[0x108a3c / 2] = 0x9c78;
4112   mem16[0x108a3e / 2] = 0x1002;
4113   mem16[0x108a40 / 2] = 0x6054;
4114   mem16[0x108a42 / 2] = 0x5202;
4115   mem16[0x108a44 / 2] = 0x0c02;
4116
4117   memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xd40000, 0xd40003, 0, 0, killbld_prot_r, killbld_prot_w);
4118
4119   state->kb_cmd = 0;
4120   state->kb_reg = 0;
4121   state->kb_ptr = 0;
4122   memset(state->kb_regs, 0, 0x10);
4123
4124   state_save_register_global(machine, state->kb_cmd);
4125   state_save_register_global(machine, state->kb_reg);
4126   state_save_register_global(machine, state->kb_ptr);
4127   state_save_register_global_array(machine, state->kb_regs);
4128}
4129
4130static DRIVER_INIT( puzzli2 )
4131{
4132   /* this protection emulation is wrong
4133     it uses an arm with no external rom
4134     an acts in a similar way to kov etc. */
4135
4136   pgm_state *state = (pgm_state *)machine->driver_data;
4137   UINT16 *mem16 = (UINT16 *)memory_region(machine, "maincpu");
4138
4139   pgm_basic_init(machine);
4140    kovsh_latch_init(machine);
4141
4142   memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x500000, 0x500003, 0, 0, asic28_r, asic28_w);
4143
4144   /* 0x4f0000 - ? is actually ram shared with the protection device,
4145      the protection device provides the region code */
4146   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x4f0000, 0x4fffff, 0, 0, sango_protram_r);
4147
4148    pgm_puzzli2_decrypt(machine);
4149
4150   /* protection related? */
4151   mem16[0x1548ec / 2] = 0x4e71;
4152   mem16[0x1548fc / 2] = 0x4e71;
4153   mem16[0x1549fa / 2] = 0x4e71;
4154   mem16[0x154a0a / 2] = 0x4e71;
4155   mem16[0x15496a / 2] = 0x4e71;
4156   mem16[0x14cee0 / 2] = 0x4e71;
4157   mem16[0x1268c0 / 2] = 0x4e71;
4158   mem16[0x1268c2 / 2] = 0x4e71;
4159   mem16[0x1268c4 / 2] = 0x4e71;
4160   mem16[0x154948 / 2] = 0x4e71;
4161   mem16[0x13877a / 2] = 0x662c;
4162
4163   /* patch irq4 vector (irq4 should be disabled on this game? how?) */
4164//  mem16[0x100070 / 2] = 0x0012;
4165//  mem16[0x100072 / 2] = 0x5d78;
4166
4167   state->asic28_key = 0;
4168   state->asic28_rcnt = 0;
4169   memset(state->asic28_regs, 0, 10);
4170   memset(state->asic_params, 0, 256);
4171   memset(state->eoregs, 0, 16);
4172
4173   state_save_register_global(machine, state->asic28_key);
4174   state_save_register_global(machine, state->asic28_rcnt);
4175   state_save_register_global_array(machine, state->asic28_regs);
4176   state_save_register_global_array(machine, state->asic_params);
4177   state_save_register_global_array(machine, state->eoregs);
4178}
4179
4180static UINT32 olds_prot_addr( UINT16 addr )
4181{
4182   UINT32 mode = addr & 0xff;
4183   UINT32 offset = addr >> 8;
4184   UINT32 realaddr;
4185
4186   switch(mode)
4187   {
4188      case 0x0:
4189      case 0x5:
4190      case 0xa:
4191         realaddr = 0x402a00 + (offset << 2);
4192         break;
4193
4194      case 0x2:
4195      case 0x8:
4196         realaddr = 0x402e00 + (offset << 2);
4197         break;
4198
4199      case 0x1:
4200         realaddr = 0x40307e;
4201         break;
4202
4203      case 0x3:
4204         realaddr = 0x403090;
4205         break;
4206
4207      case 0x4:
4208         realaddr = 0x40309a;
4209         break;
4210
4211      case 0x6:
4212         realaddr = 0x4030a4;
4213         break;
4214
4215      case 0x7:
4216         realaddr = 0x403000;
4217         break;
4218
4219      case 0x9:
4220         realaddr = 0x40306e;
4221         break;
4222
4223      default:
4224         realaddr = 0;
4225   }
4226   return realaddr;
4227}
4228
4229static UINT32 olds_read_reg( running_machine *machine, UINT16 addr )
4230{
4231   pgm_state *state = (pgm_state *)machine->driver_data;
4232   UINT32 protaddr = (olds_prot_addr(addr) - 0x400000) / 2;
4233   return state->sharedprotram[protaddr] << 16 | state->sharedprotram[protaddr + 1];
4234}
4235
4236static void olds_write_reg( running_machine *machine, UINT16 addr, UINT32 val )
4237{
4238   pgm_state *state = (pgm_state *)machine->driver_data;
4239   state->sharedprotram[(olds_prot_addr(addr) - 0x400000) / 2]     = val >> 16;
4240   state->sharedprotram[(olds_prot_addr(addr) - 0x400000) / 2 + 1] = val & 0xffff;
4241}
4242
4243static MACHINE_RESET( olds )
4244{
4245   pgm_state *state = (pgm_state *)machine->driver_data;
4246   UINT16 *mem16 = (UINT16 *)memory_region(machine, "user2");
4247   int i;
4248
4249   MACHINE_RESET_CALL(pgm);
4250
4251   /* populate shared protection ram with data read from pcb .. */
4252   for (i = 0; i < 0x4000 / 2; i++)
4253   {
4254      state->sharedprotram[i] = mem16[i];
4255   }
4256
4257   //ROM:004008B4                 .word 0xFBA5
4258   for(i = 0; i < 0x4000 / 2; i++)
4259   {
4260      if (state->sharedprotram[i] == (0xffff - i))
4261         state->sharedprotram[i] = 0x4e75;
4262   }
4263}
4264
4265static READ16_HANDLER( olds_r )
4266{
4267   pgm_state *state = (pgm_state *)space->machine->driver_data;
4268   UINT16 res = 0;
4269
4270   if (offset == 1)
4271   {
4272      if (state->kb_cmd == 1)
4273         res = state->kb_reg & 0x7f;
4274      if (state->kb_cmd == 2)
4275         res = state->olds_bs | 0x80;
4276      if (state->kb_cmd == 3)
4277         res = state->olds_cmd3;
4278      else if (state->kb_cmd == 5)
4279      {
4280         UINT32 protvalue = 0x900000 | input_port_read(space->machine, "Region"); // region from protection device.
4281         res = (protvalue >> (8 * (state->kb_ptr - 1))) & 0xff; // includes region 1 = taiwan , 2 = china, 3 = japan (title = orlegend special), 4 = korea, 5 = hongkong, 6 = world
4282
4283      }
4284   }
4285   logerror("%06X: ASIC25 R CMD %X  VAL %X\n", cpu_get_pc(space->cpu), state->kb_cmd, res);
4286   return res;
4287}
4288
4289static WRITE16_HANDLER( olds_w )
4290{
4291   pgm_state *state = (pgm_state *)space->machine->driver_data;
4292   if (offset == 0)
4293      state->kb_cmd = data;
4294   else //offset==2
4295   {
4296      logerror("%06X: ASIC25 W CMD %X  VAL %X\n",cpu_get_pc(space->cpu), state->kb_cmd, data);
4297      if (state->kb_cmd == 0)
4298         state->kb_reg = data;
4299      else if(state->kb_cmd == 2)   //a bitswap=
4300      {
4301         int reg = 0;
4302         if (data & 0x01)
4303            reg |= 0x40;
4304         if (data & 0x02)
4305            reg |= 0x80;
4306         if (data & 0x04)
4307            reg |= 0x20;
4308         if (data & 0x08)
4309            reg |= 0x10;
4310         state->olds_bs = reg;
4311      }
4312      else if (state->kb_cmd == 3)
4313      {
4314         UINT16 cmd = state->sharedprotram[0x3026 / 2];
4315         switch (cmd)
4316         {
4317            case 0x11:
4318            case 0x12:
4319                  break;
4320            case 0x64:
4321               {
4322                  UINT16 cmd0 = state->sharedprotram[0x3082 / 2];
4323                  UINT16 val0 = state->sharedprotram[0x3050 / 2];   //CMD_FORMAT
4324                  {
4325                     if ((cmd0 & 0xff) == 0x2)
4326                        olds_write_reg(space->machine, val0, olds_read_reg(space->machine, val0) + 0x10000);
4327                  }
4328                  break;
4329               }
4330
4331            default:
4332                  break;
4333         }
4334         state->olds_cmd3 = ((data >> 4) + 1) & 0x3;
4335      }
4336      else if (state->kb_cmd == 4)
4337         state->kb_ptr = data;
4338      else if(state->kb_cmd == 0x20)
4339        state->kb_ptr++;
4340   }
4341}
4342
4343static READ16_HANDLER( olds_prot_swap_r )
4344{
4345   if (cpu_get_pc(space->cpu) < 0x100000)      //bios
4346      return pgm_mainram[0x178f4 / 2];
4347   else                  //game
4348      return pgm_mainram[0x178d8 / 2];
4349
4350}
4351
4352static DRIVER_INIT( olds )
4353{
4354   pgm_state *state = (pgm_state *)machine->driver_data;
4355   pgm_basic_init(machine);
4356
4357   memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xdcb400, 0xdcb403, 0, 0, olds_r, olds_w);
4358   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8178f4, 0x8178f5, 0, 0, olds_prot_swap_r);
4359
4360   state->kb_cmd = 0;
4361   state->kb_reg = 0;
4362   state->kb_ptr = 0;
4363   state->olds_bs = 0;
4364   state->olds_cmd3 = 0;
4365
4366   state_save_register_global(machine, state->kb_cmd);
4367   state_save_register_global(machine, state->kb_reg);
4368   state_save_register_global(machine, state->kb_ptr);
4369   state_save_register_global(machine, state->olds_bs);
4370   state_save_register_global(machine, state->olds_cmd3);
4371}
4372
41414373/*** GAME ********************************************************************/
41424374
4143GAME( 1997, pgm,      0,          pgm, pgm,      pgm,        ROT0,   "IGS", "PGM (Polygame Master) System BIOS", GAME_IS_BIOS_ROOT )
4375GAME( 1997, pgm,          0,         pgm,    pgm,      pgm,        ROT0,   "IGS", "PGM (Polygame Master) System BIOS", GAME_IS_BIOS_ROOT )
41444376
4145GAME( 1997, orlegend, pgm,        pgm, pgm,      orlegend,   ROT0,   "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 126)", GAME_IMPERFECT_SOUND  )
4146GAME( 1997, orlegende, orlegend,   pgm, pgm,      orlegend,   ROT0,   "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 112)", GAME_IMPERFECT_SOUND  )
4147GAME( 1997, orlegendc, orlegend,   pgm, pgm,      orlegend,   ROT0,   "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 112, Chinese Board)", GAME_IMPERFECT_SOUND  )
4148GAME( 1997, orlegend111c, orlegend,   pgm, pgm,      orlegend,   ROT0,   "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 111, Chinese Board)", GAME_IMPERFECT_SOUND  )
4149GAME( 1997, orlegend105k, orlegend,   pgm, orld105k, orlegend,   ROT0,   "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 105, Korean Board)", GAME_IMPERFECT_SOUND  )
4150GAME( 1997, drgw2c,   drgw2,    drgw2, pgm,      drgw2c,     ROT0,   "IGS", "Zhong Guo Long II (ver. 100C, China)", GAME_IMPERFECT_SOUND )
4151GAME( 1999, photoy2k, pgm,        kov, photoy2k, djlzz,      ROT0,   "IGS", "Photo Y2K (ver. 104)", GAME_IMPERFECT_SOUND ) /* region provided by protection device */
4152GAME( 1999, raf102j,  photoy2k,   kov, photoy2k, djlzz,      ROT0,   "IGS", "Real and Fake / Photo Y2K (ver. 102, Japanese Board)", GAME_IMPERFECT_SOUND ) /* region provided by protection device */
4153GAME( 1999, kovsh,    kov,        kov, sango,    kovsh,      ROT0,   "IGS", "Knights of Valour Super Heroes / Sangoku Senki Super Heroes (ver. 104)", GAME_IMPERFECT_SOUND )
4154GAME( 2000, kov2,     pgm,       kov2, sango,    kov2,       ROT0,   "IGS", "Knights of Valour 2 / Sangoku Senki 2 (ver. 100)", GAME_IMPERFECT_SOUND )
4155GAME( 2000, kov2106,  kov2,      kov2, sango,    kov2,       ROT0,   "IGS", "Knights of Valour 2 / Sangoku Senki 2 (ver. 106)", GAME_IMPERFECT_SOUND )
4156GAME( 2001, martmast, pgm,       kov2, sango,    martmast,   ROT0,   "IGS", "Martial Masters (ver. 102)", GAME_IMPERFECT_SOUND )
4157GAME( 2001, martmastc,martmast,  kov2, sango,    martmast,   ROT0,   "IGS", "Martial Masters (ver. 101, Chinese Board)", GAME_IMPERFECT_SOUND )
4377GAME( 1997, orlegend,     pgm,       pgm,     pgm,      orlegend,   ROT0,   "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 126)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
4378GAME( 1997, orlegende,    orlegend,  pgm,     pgm,      orlegend,   ROT0,   "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 112)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
4379GAME( 1997, orlegendc,    orlegend,  pgm,     pgm,      orlegend,   ROT0,   "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 112, Chinese Board)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
4380GAME( 1997, orlegend111c, orlegend,  pgm,     pgm,      orlegend,   ROT0,   "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 111, Chinese Board)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
4381GAME( 1997, orlegend105k, orlegend,  pgm,     orld105k, orlegend,   ROT0,   "IGS", "Oriental Legend / Xi You Shi E Zhuan (ver. 105, Korean Board)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
4382GAME( 1997, drgw2c,       drgw2,     drgw2,   pgm,      drgw2c,     ROT0,   "IGS", "Zhong Guo Long II (ver. 100C, China)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
4383GAME( 1999, photoy2k,     pgm,       kov,     photoy2k, djlzz,      ROT0,   "IGS", "Photo Y2K (ver. 104)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) /* region provided by protection device */
4384GAME( 1999, raf102j,      photoy2k,  kov,     photoy2k, djlzz,      ROT0,   "IGS", "Real and Fake / Photo Y2K (ver. 102, Japanese Board)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) /* region provided by protection device */
4385GAME( 1999, kovsh,        kov,       kov,     sango,    kovsh,      ROT0,   "IGS", "Knights of Valour Super Heroes / Sangoku Senki Super Heroes (ver. 104)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
4386GAME( 2000, kov2,         pgm,       kov2,    sango,    kov2,       ROT0,   "IGS", "Knights of Valour 2 / Sangoku Senki 2 (ver. 100)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
4387GAME( 2000, kov2106,      kov2,      kov2,    sango,    kov2,       ROT0,   "IGS", "Knights of Valour 2 / Sangoku Senki 2 (ver. 106)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
4388GAME( 2001, martmast,     pgm,       kov2,    sango,    martmast,   ROT0,   "IGS", "Martial Masters (ver. 102)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
4389GAME( 2001, martmastc,    martmast,  kov2,    sango,    martmast,   ROT0,   "IGS", "Martial Masters (ver. 101, Chinese Board)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
41584390
41594391/* Playable but maybe imperfect protection emulation */
4160GAME( 1997, drgw2,    pgm,       drgw2, pgm,     drgw2,      ROT0,   "IGS", "Dragon World II (ver. 110X, Export)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
4161GAME( 1997, drgw2j,   drgw2,     drgw2, pgm,     drgw2j,     ROT0,   "IGS", "Chuugokuryuu II (ver. 100J, Japan)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
4162GAME( 1998, killbldt, killbld, killbld, killbld, killbld,    ROT0,   "IGS", "The Killing Blade (ver. 109, Chinese Board)", GAME_IMPERFECT_SOUND ) // it's playable, but there are some things unclear about the protection
4163GAME( 1998, olds,     pgm,       olds, olds,     olds,       ROT0,   "IGS", "Oriental Legend Special / Xi You Shi E Zhuan Super (ver. 101, Korean Board)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
4164GAME( 1998, olds100,  olds,      olds, olds,     olds,       ROT0,   "IGS", "Oriental Legend Special / Xi You Shi E Zhuan Super (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
4165GAME( 1998, olds100a, olds,      olds, olds,     olds,       ROT0,   "IGS", "Oriental Legend Special / Xi You Shi E Zhuan Super (alt ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING  ) // grashes on some bosses, high score table etc.
4392GAME( 1997, drgw2,        pgm,       drgw2,   pgm,      drgw2,      ROT0,   "IGS", "Dragon World II (ver. 110X, Export)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
4393GAME( 1997, drgw2j,       drgw2,     drgw2,   pgm,      drgw2j,     ROT0,   "IGS", "Chuugokuryuu II (ver. 100J, Japan)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
4394GAME( 1998, killbldt,     killbld,   killbld, killbld,  killbld,    ROT0,   "IGS", "The Killing Blade (ver. 109, Chinese Board)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) // it's playable, but there are some things unclear about the protection
4395GAME( 1998, olds,         pgm,       olds,    olds,     olds,       ROT0,   "IGS", "Oriental Legend Special / Xi You Shi E Zhuan Super (ver. 101, Korean Board)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
4396GAME( 1998, olds100,      olds,      olds,    olds,     olds,       ROT0,   "IGS", "Oriental Legend Special / Xi You Shi E Zhuan Super (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
4397GAME( 1998, olds100a,     olds,      olds,    olds,     olds,       ROT0,   "IGS", "Oriental Legend Special / Xi You Shi E Zhuan Super (alt ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) // grashes on some bosses, high score table etc.
41664398
41674399/* not working */
4168GAME( 1998, drgw3,    pgm,        pgm, sango,    dw3,        ROT0,   "IGS", "Dragon World 3 (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
4169GAME( 1998, drgw3k,   drgw3,      pgm, sango,    dw3,        ROT0,   "IGS", "Dragon World 3 (ver. 106, Korean Board)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
4170GAME( 1998, killbld,  pgm,    killbld, killbld,  killbld,    ROT0,   "IGS", "The Killing Blade (ver. 104)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
4171GAME( 1999, kov,      pgm,        kov, sango,    kov,        ROT0,   "IGS", "Knights of Valour / Sangoku Senki (ver. 117)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4172GAME( 1999, kov115,   kov,        kov, sango,    kov,        ROT0,   "IGS", "Knights of Valour / Sangoku Senki (ver. 115)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4173GAME( 1999, kovj,     kov,        kov, sango,    kov,        ROT0,   "IGS", "Knights of Valour / Sangoku Senki (ver. 100, Japanese Board)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4174GAME( 1999, kovplus,  kov,        kov, sango,    kov,        ROT0,   "IGS", "Knights of Valour Plus / Sangoku Senki Plus (ver. 119)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4175GAME( 1999, kovplusa, kov,        kov, sango,    kov,        ROT0,   "IGS", "Knights of Valour Plus / Sangoku Senki Plus (alt ver. 119)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4176GAME( 1999, puzlstar, pgm,        kov, sango,    pstar,      ROT0,   "IGS", "Puzzle Star (ver. 100MG)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4177GAME( 2001, kov2p,    kov2,      kov2, sango,    kov2p,      ROT0,   "IGS", "Knights of Valour 2 Plus - Nine Dragons / Sangoku Senki 2 Plus - Nine Dragons (ver. M204XX)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4178GAME( 2001, kov2p205, kov2,      kov2, sango,    kov2p,      ROT0,   "IGS", "Knights of Valour 2 Plus - Nine Dragons / Sangoku Senki 2 Plus - Nine Dragons (ver. M205XX)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4179GAME( 2001, ddp2,     pgm,       kov2, ddp2,     ddp2,       ROT270, "IGS", "Bee Storm - DoDonPachi II (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4180GAME( 2001, ddp2a,    ddp2,      kov2, ddp2,     ddp2,       ROT270, "IGS", "Bee Storm - DoDonPachi II (ver. 102)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4181GAME( 2001, puzzli2,  pgm,        kov, sango,    puzzli2,    ROT0,   "IGS", "Puzzli 2 Super (ver. 200)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
4182GAME( 2002, dmnfrnt,  pgm,        svg, sango,    dmnfrnt,    ROT0,   "IGS", "Demon Front (ver. 102)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4183GAME( 2002, dmnfrnta, dmnfrnt,    svg, sango,    dmnfrnt,    ROT0,   "IGS", "Demon Front (ver. 105)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4184GAME( 2003, theglad,  pgm,        svg, sango,    theglad,    ROT0,   "IGS", "The Gladiator (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4185GAME( 2003, theglada, theglad,    svg, sango,    theglad,    ROT0,   "IGS", "The Gladiator (ver. 101)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4186GAME( 2004, oldsplus, pgm,        kov, olds,     oldsplus,   ROT0,   "IGS", "Oriental Legend Special Plus / Xi You Shi E Zhuan Super Plus", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4187GAME( 2004, kovshp,   kov,        kov, sango,    kovshp,     ROT0,   "IGS", "Knights of Valour Super Heroes Plus / Sangoku Senki Super Heroes Plus (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4188GAME( 2005, killbldp, pgm,        svg, sango,    killbldp,   ROT0,   "IGS", "The Killing Blade Plus (ver. 300)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4189GAME( 2005, svg,      pgm,        svg, sango,    svg,        ROT0,   "IGS", "S.V.G. - Spectral vs Generation (ver. 200)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING ) /* need internal rom of IGS027A */
4400GAME( 1998, drgw3,        pgm,       pgm,     sango,    dw3,        ROT0,   "IGS", "Dragon World 3 (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
4401GAME( 1998, drgw3k,       drgw3,     pgm,     sango,    dw3,        ROT0,   "IGS", "Dragon World 3 (ver. 106, Korean Board)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
4402GAME( 1998, killbld,      pgm,       killbld, killbld,  killbld,    ROT0,   "IGS", "The Killing Blade (ver. 104)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
4403GAME( 1999, kov,          pgm,       kov,     sango,    kov,        ROT0,   "IGS", "Knights of Valour / Sangoku Senki (ver. 117)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4404GAME( 1999, kov115,       kov,       kov,     sango,    kov,        ROT0,   "IGS", "Knights of Valour / Sangoku Senki (ver. 115)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4405GAME( 1999, kovj,         kov,       kov,     sango,    kov,        ROT0,   "IGS", "Knights of Valour / Sangoku Senki (ver. 100, Japanese Board)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4406GAME( 1999, kovplus,      kov,       kov,     sango,    kov,        ROT0,   "IGS", "Knights of Valour Plus / Sangoku Senki Plus (ver. 119)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4407GAME( 1999, kovplusa,     kov,       kov,     sango,    kov,        ROT0,   "IGS", "Knights of Valour Plus / Sangoku Senki Plus (alt ver. 119)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4408GAME( 1999, puzlstar,     pgm,       kov,     sango,    pstar,      ROT0,   "IGS", "Puzzle Star (ver. 100MG)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4409GAME( 2001, kov2p,        kov2,      kov2,    sango,    kov2p,      ROT0,   "IGS", "Knights of Valour 2 Plus - Nine Dragons / Sangoku Senki 2 Plus - Nine Dragons (ver. M204XX)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4410GAME( 2001, kov2p205,     kov2,      kov2,    sango,    kov2p,      ROT0,   "IGS", "Knights of Valour 2 Plus - Nine Dragons / Sangoku Senki 2 Plus - Nine Dragons (ver. M205XX)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4411GAME( 2001, ddp2,         pgm,       kov2,    ddp2,     ddp2,       ROT270, "IGS", "Bee Storm - DoDonPachi II (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4412GAME( 2001, ddp2a,        ddp2,      kov2,    ddp2,     ddp2,       ROT270, "IGS", "Bee Storm - DoDonPachi II (ver. 102)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4413GAME( 2001, puzzli2,      pgm,       kov,     sango,    puzzli2,    ROT0,   "IGS", "Puzzli 2 Super (ver. 200)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
4414GAME( 2002, dmnfrnt,      pgm,       svg,     sango,    dmnfrnt,    ROT0,   "IGS", "Demon Front (ver. 102)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4415GAME( 2002, dmnfrnta,     dmnfrnt,   svg,     sango,    dmnfrnt,    ROT0,   "IGS", "Demon Front (ver. 105)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4416GAME( 2003, theglad,      pgm,       svg,     sango,    theglad,    ROT0,   "IGS", "The Gladiator (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4417GAME( 2003, theglada,     theglad,   svg,     sango,    theglad,    ROT0,   "IGS", "The Gladiator (ver. 101)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4418GAME( 2004, oldsplus,     pgm,       kov,     olds,     oldsplus,   ROT0,   "IGS", "Oriental Legend Special Plus / Xi You Shi E Zhuan Super Plus", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4419GAME( 2004, kovshp,       kov,       kov,     sango,    kovshp,     ROT0,   "IGS", "Knights of Valour Super Heroes Plus / Sangoku Senki Super Heroes Plus (ver. 100)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4420GAME( 2005, killbldp,     pgm,       svg,     sango,    killbldp,   ROT0,   "IGS", "The Killing Blade Plus (ver. 300)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4421GAME( 2004, happy6,       pgm,       svg,     sango,    svg,        ROT0,   "IGS", "Happy 6-in-1 (ver. 101CN)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
4422GAME( 2005, svg,          pgm,       svg,     sango,    svg,        ROT0,   "IGS", "S.V.G. - Spectral vs Generation (ver. 200)", GAME_IMPERFECT_SOUND | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) /* need internal rom of IGS027A */
src/mame/drivers/gameplan.c
r6740r6741
7979#include "machine/6532riot.h"
8080#include "machine/6522via.h"
8181#include "sound/ay8910.h"
82#include "gameplan.h"
82#include "includes/gameplan.h"
8383
8484
8585
r6740r6741
988988   state->audiocpu = devtag_get_device(machine, "audiocpu");
989989   state->riot = devtag_get_device(machine, "riot");
990990   state->via_0 = devtag_get_device(machine, "via6522_0");
991   state->via_1 = devtag_get_device(machine, "via6522_1");
992   state->via_2 = devtag_get_device(machine, "via6522_2");
991993
992994   /* register for save states */
993995   state_save_register_global(machine, state->current_port);
src/mame/drivers/capbowl.c
r6740r6741
9090#include "driver.h"
9191#include "machine/ticket.h"
9292#include "cpu/m6809/m6809.h"
93#include "capbowl.h"
93#include "includes/capbowl.h"
9494#include "sound/2203intf.h"
9595#include "sound/dac.h"
9696
r6740r6741
329329   {
330330      AY8910_LEGACY_OUTPUT,
331331      AY8910_DEFAULT_LOADS,
332      DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, ticket_dispenser_r),
332      DEVCB_DEVICE_HANDLER("ticket", ticket_dispenser_r),
333333      DEVCB_NULL,
334334      DEVCB_NULL,
335      DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, ticket_dispenser_w),  /* Also a status LED. See memory map above */
335      DEVCB_DEVICE_HANDLER("ticket", ticket_dispenser_w),  /* Also a status LED. See memory map above */
336336   },
337337   firqhandler
338338};
r6740r6741
386386   MDRV_MACHINE_RESET(capbowl)
387387   MDRV_NVRAM_HANDLER(capbowl)
388388
389   MDRV_TICKET_DISPENSER_ADD("ticket", 100, TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_LOW)
390
389391   /* video hardware */
390392   MDRV_VIDEO_START(capbowl)
391393   MDRV_VIDEO_UPDATE(capbowl)
r6740r6741
511513 *
512514 *************************************/
513515
514static DRIVER_INIT( bowlrama )
515{
516   /* Initialize the ticket dispenser to 100 milliseconds */
517   /* (I'm not sure what the correct value really is) */
518   ticket_dispenser_init(machine, 100, TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_LOW);
519}
520
521516static DRIVER_INIT( capbowl )
522517{
523518   UINT8 *ROM = memory_region(machine, "maincpu");
524519
525520   /* configure ROM banks in 0x0000-0x3fff */
526521   memory_configure_bank(machine, "bank1", 0, 6, &ROM[0x10000], 0x4000);
527
528   DRIVER_INIT_CALL(bowlrama);
529522}
530523
531524
r6740r6741
540533GAME( 1988, capbowl3, capbowl, capbowl,  capbowl, capbowl,  ROT270, "Incredible Technologies", "Capcom Bowling (set 3)", 0 )
541534GAME( 1988, capbowl4, capbowl, capbowl,  capbowl, capbowl,  ROT270, "Incredible Technologies", "Capcom Bowling (set 4)", 0 )
542535GAME( 1989, clbowl,   capbowl, capbowl,  capbowl, capbowl,  ROT270, "Incredible Technologies", "Coors Light Bowling", 0 )
543GAME( 1991, bowlrama, 0,       bowlrama, capbowl, bowlrama, ROT270, "P&P Marketing", "Bowl-O-Rama", 0 )
536GAME( 1991, bowlrama, 0,       bowlrama, capbowl, 0,        ROT270, "P&P Marketing", "Bowl-O-Rama", 0 )
src/mame/drivers/cbasebal.c
r6740r6741
11/***************************************************************************
22
3  Capcom Baseball
3    Capcom Baseball
44
55
6  Somewhat similar to the "Mitchell hardware", but different enough to
7  deserve its own driver.
6    Somewhat similar to the "Mitchell hardware", but different enough to
7    deserve its own driver.
88
9TODO:
10- understand what bit 6 of input port 0x12 is
11- unknown bit 5 of bankswitch register
9    TODO:
10    - understand what bit 6 of input port 0x12 is
11    - unknown bit 5 of bankswitch register
1212
1313***************************************************************************/
1414
1515#include "driver.h"
1616#include "cpu/z80/z80.h"
17#include "includes/cps1.h"
18#include "machine/eeprom.h"
17#include "includes/cps1.h"   // needed for decoding functions only
18#include "includes/cbasebal.h"
19#include "machine/eepromdev.h"
1920#include "sound/okim6295.h"
2021#include "sound/2413intf.h"
2122
2223
23VIDEO_START( cbasebal );
24WRITE8_HANDLER( cbasebal_textram_w );
25READ8_HANDLER( cbasebal_textram_r );
26WRITE8_HANDLER( cbasebal_scrollram_w );
27READ8_HANDLER( cbasebal_scrollram_r );
28WRITE8_HANDLER( cbasebal_gfxctrl_w );
29WRITE8_HANDLER( cbasebal_scrollx_w );
30WRITE8_HANDLER( cbasebal_scrolly_w );
31VIDEO_UPDATE( cbasebal );
24/*************************************
25 *
26 *  Memory handlers
27 *
28 *************************************/
3229
33
34static UINT8 rambank;
35
3630static WRITE8_HANDLER( cbasebal_bankswitch_w )
3731{
32   cbasebal_state *state = (cbasebal_state *)space->machine->driver_data;
33
3834   /* bits 0-4 select ROM bank */
39//logerror("%04x: bankswitch %02x\n",cpu_get_pc(space->cpu),data);
35   //logerror("%04x: bankswitch %02x\n", cpu_get_pc(space->cpu), data);
4036   memory_set_bank(space->machine, "bank1", data & 0x1f);
4137
4238   /* bit 5 used but unknown */
4339
4440   /* bits 6-7 select RAM bank */
45   rambank = (data & 0xc0) >> 6;
41   state->rambank = (data & 0xc0) >> 6;
4642}
4743
4844
4945static READ8_HANDLER( bankedram_r )
5046{
51   if (rambank == 2)
52      return cbasebal_textram_r(space,offset);   /* VRAM */
53   else if (rambank == 1)
47   cbasebal_state *state = (cbasebal_state *)space->machine->driver_data;
48
49   switch (state->rambank)
5450   {
51   case 2:
52      return cbasebal_textram_r(space, offset);   /* VRAM */
53      break;
54   case 1:
5555      if (offset < 0x800)
5656         return space->machine->generic.paletteram.u8[offset];
57      else return 0;
57      else
58         return 0;
59      break;
60   default:
61      return cbasebal_scrollram_r(space, offset);   /* SCROLL */
62      break;
5863   }
59   else
60   {
61      return cbasebal_scrollram_r(space,offset);   /* SCROLL */
62   }
6364}
6465
6566static WRITE8_HANDLER( bankedram_w )
6667{
67   if (rambank == 2)
68      cbasebal_textram_w(space,offset,data);
69   else if (rambank == 1)
68   cbasebal_state *state = (cbasebal_state *)space->machine->driver_data;
69
70   switch (state->rambank)
7071   {
72   case 2:
73      cbasebal_textram_w(space, offset, data);
74      break;
75   case 1:
7176      if (offset < 0x800)
72         paletteram_xxxxBBBBRRRRGGGG_le_w(space,offset,data);
77         paletteram_xxxxBBBBRRRRGGGG_le_w(space, offset, data);
78      break;
79   default:
80      cbasebal_scrollram_w(space, offset, data);
81      break;
7382   }
74   else
75      cbasebal_scrollram_w(space,offset,data);
7683}
7784
7885static WRITE8_HANDLER( cbasebal_coinctrl_w )
7986{
80   coin_lockout_w(space->machine, 0,~data & 0x04);
81   coin_lockout_w(space->machine, 1,~data & 0x08);
82   coin_counter_w(space->machine, 0,data & 0x01);
83   coin_counter_w(space->machine, 1,data & 0x02);
87   coin_lockout_w(space->machine, 0, ~data & 0x04);
88   coin_lockout_w(space->machine, 1, ~data & 0x08);
89   coin_counter_w(space->machine, 0, data & 0x01);
90   coin_counter_w(space->machine, 1, data & 0x02);
8491}
8592
8693
94/*************************************
95 *
96 *  EEPROM
97 *
98 *************************************/
8799
88/***************************************************************************
89
90  EEPROM
91
92***************************************************************************/
93
94static const eeprom_interface eeprom_intf =
100static const eeprom_interface cbasebal_eeprom_intf =
95101{
96102   6,      /* address bits */
97103   16,      /* data bits */
r6740r6741
101107};
102108
103109
104static NVRAM_HANDLER( cbasebal )
105{
106   if (read_or_write)
107      eeprom_save(file);
108   else
109   {
110      eeprom_init(machine, &eeprom_intf);
110/*************************************
111 *
112 *  Address maps
113 *
114 *************************************/
111115
112      if (file)
113         eeprom_load(file);
114   }
115}
116
117static WRITE8_HANDLER( eeprom_cs_w )
118{
119   eeprom_set_cs_line(data ? CLEAR_LINE : ASSERT_LINE);
120}
121
122static WRITE8_HANDLER( eeprom_clock_w )
123{
124   eeprom_set_clock_line(data ? CLEAR_LINE : ASSERT_LINE);
125}
126
127static WRITE8_HANDLER( eeprom_serial_w )
128{
129   eeprom_write_bit(data);
130}
131
132
133
134116static ADDRESS_MAP_START( cbasebal_map, ADDRESS_SPACE_PROGRAM, 8 )
135117   AM_RANGE(0x0000, 0x7fff) AM_ROM
136118   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
137119   AM_RANGE(0xc000, 0xcfff) AM_READWRITE(bankedram_r, bankedram_w) AM_BASE_GENERIC(paletteram)   /* palette + vram + scrollram */
138120   AM_RANGE(0xe000, 0xfdff) AM_RAM      /* work RAM */
139   AM_RANGE(0xfe00, 0xffff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
121   AM_RANGE(0xfe00, 0xffff) AM_RAM AM_BASE_SIZE_MEMBER(cbasebal_state, spriteram, spriteram_size)
140122ADDRESS_MAP_END
141123
142124static ADDRESS_MAP_START( cbasebal_portmap, ADDRESS_SPACE_IO, 8 )
143125   ADDRESS_MAP_GLOBAL_MASK(0xff)
144126   AM_RANGE(0x00, 0x00) AM_WRITE(cbasebal_bankswitch_w)
145   AM_RANGE(0x01, 0x01) AM_WRITE(eeprom_cs_w)
146   AM_RANGE(0x02, 0x02) AM_WRITE(eeprom_clock_w)
147   AM_RANGE(0x03, 0x03) AM_WRITE(eeprom_serial_w)
127   AM_RANGE(0x01, 0x01) AM_WRITE_PORT("IO_01")
128   AM_RANGE(0x02, 0x02) AM_WRITE_PORT("IO_02")
129   AM_RANGE(0x03, 0x03) AM_WRITE_PORT("IO_03")
148130   AM_RANGE(0x05, 0x05) AM_DEVWRITE("oki", okim6295_w)
149131   AM_RANGE(0x06, 0x07) AM_DEVWRITE("ymsnd", ym2413_w)
150132   AM_RANGE(0x08, 0x09) AM_WRITE(cbasebal_scrollx_w)
r6740r6741
157139ADDRESS_MAP_END
158140
159141
142/*************************************
143 *
144 *  Input ports
145 *
146 *************************************/
147
160148static INPUT_PORTS_START( cbasebal )
161149   PORT_START("P1")
162150   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
186174   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
187175   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 )
188176   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_VBLANK )      /* ? */
189   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)
177   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
178
179   PORT_START( "IO_01" )
180   PORT_BIT( 0x00000010, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
181
182   PORT_START( "IO_02" )
183   PORT_BIT( 0x00000020, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
184
185   PORT_START( "IO_03" )
186   PORT_BIT( 0x00000040, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
190187INPUT_PORTS_END
191188
192189
193190
191/*************************************
192 *
193 *  Graphics definitions
194 *
195 *************************************/
194196
195197static const gfx_layout cbasebal_textlayout =
196198{
r6740r6741
236238GFXDECODE_END
237239
238240
241/*************************************
242 *
243 *  Machine driver
244 *
245 *************************************/
239246
247static MACHINE_START( cbasebal )
248{
249   cbasebal_state *state = (cbasebal_state *)machine->driver_data;
250
251   memory_configure_bank(machine, "bank1", 0, 32, memory_region(machine, "maincpu") + 0x10000, 0x4000);
252
253   state_save_register_global(machine, state->rambank);
254   state_save_register_global(machine, state->tilebank);
255   state_save_register_global(machine, state->spritebank);
256   state_save_register_global(machine, state->text_on);
257   state_save_register_global(machine, state->bg_on);
258   state_save_register_global(machine, state->obj_on);
259   state_save_register_global(machine, state->flipscreen);
260   state_save_register_global_array(machine, state->scroll_x);
261   state_save_register_global_array(machine, state->scroll_y);
262}
263
264static MACHINE_RESET( cbasebal )
265{
266   cbasebal_state *state = (cbasebal_state *)machine->driver_data;
267
268   state->rambank = 0;
269   state->tilebank = 0;
270   state->spritebank = 0;
271   state->text_on = 0;
272   state->bg_on = 0;
273   state->obj_on = 0;
274   state->flipscreen = 0;
275   state->scroll_x[0] = 0;
276   state->scroll_x[1] = 0;
277   state->scroll_y[0] = 0;
278   state->scroll_y[1] = 0;
279}
280
240281static MACHINE_DRIVER_START( cbasebal )
241282
283   /* driver data */
284   MDRV_DRIVER_DATA(cbasebal_state)
285
242286   /* basic machine hardware */
243287   MDRV_CPU_ADD("maincpu", Z80, 6000000)   /* ??? */
244288   MDRV_CPU_PROGRAM_MAP(cbasebal_map)
245289   MDRV_CPU_IO_MAP(cbasebal_portmap)
246290   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)   /* ??? */
247291
248   MDRV_NVRAM_HANDLER(cbasebal)
292   MDRV_MACHINE_START(cbasebal)
293   MDRV_MACHINE_RESET(cbasebal)
249294
295   MDRV_EEPROM_NODEFAULT_ADD("eeprom", cbasebal_eeprom_intf)
296
250297   /* video hardware */
251298   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
252299
r6740r6741
276323
277324
278325
326/*************************************
327 *
328 *  ROM definition(s)
329 *
330 *************************************/
331
279332ROM_START( cbasebal )
280333   ROM_REGION( 0x90000, "maincpu", 0 )
281334   ROM_LOAD( "cbj10.11j",    0x00000, 0x08000, CRC(bbff0acc) SHA1(db9e2c89e030255851789caaf85f24dc73609d9b) )
r6740r6741
304357ROM_END
305358
306359
360/*************************************
361 *
362 *  Driver initialization
363 *
364 *************************************/
365
307366static DRIVER_INIT( cbasebal )
308367{
309   memory_configure_bank(machine, "bank1", 0, 32, memory_region(machine, "maincpu") + 0x10000, 0x4000);
310368   pang_decode(machine);
311369}
312370
313371
314GAME( 1989, cbasebal, 0, cbasebal, cbasebal, cbasebal, ROT0, "Capcom", "Capcom Baseball (Japan)", 0 )
372/*************************************
373 *
374 *  Game driver(s)
375 *
376 *************************************/
377
378GAME( 1989, cbasebal, 0, cbasebal, cbasebal, cbasebal, ROT0, "Capcom", "Capcom Baseball (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/beathead.c
r6740r6741
101101#include "cpu/asap/asap.h"
102102#include "machine/atarigen.h"
103103#include "audio/atarijsa.h"
104#include "beathead.h"
104#include "includes/beathead.h"
105105
106106
107107
r6740r6741
135135
136136static void update_interrupts(running_machine *machine);
137137
138static TIMER_CALLBACK( scanline_callback )
138static TIMER_DEVICE_CALLBACK( scanline_callback )
139139{
140140   int scanline = param;
141141
142142   /* update the video */
143   video_screen_update_now(machine->primary_screen);
143   video_screen_update_now(timer->machine->primary_screen);
144144
145145   /* on scanline zero, clear any halt condition */
146146   if (scanline == 0)
147      cputag_set_input_line(machine, "maincpu", INPUT_LINE_HALT, CLEAR_LINE);
147      cputag_set_input_line(timer->machine, "maincpu", INPUT_LINE_HALT, CLEAR_LINE);
148148
149149   /* wrap around at 262 */
150150   scanline++;
r6740r6741
153153
154154   /* set the scanline IRQ */
155155   irq_state[2] = 1;
156   update_interrupts(machine);
156   update_interrupts(timer->machine);
157157
158158   /* set the timer for the next one */
159   timer_set(machine, double_to_attotime(attotime_to_double(video_screen_get_time_until_pos(machine->primary_screen, scanline, 0)) - hblank_offset), NULL, scanline, scanline_callback);
159   timer_device_adjust_oneshot(timer, double_to_attotime(attotime_to_double(video_screen_get_time_until_pos(timer->machine->primary_screen, scanline, 0)) - hblank_offset), scanline);
160160}
161161
162162
163static MACHINE_START( beathead )
164{
165   atarigen_init(machine);
166}
167
168
163169static MACHINE_RESET( beathead )
164170{
165171   beathead_state *state = (beathead_state *)machine->driver_data;
r6740r6741
175181
176182   /* compute the timing of the HBLANK interrupt and set the first timer */
177183   hblank_offset = attotime_to_double(video_screen_get_scan_period(machine->primary_screen)) * ((455. - 336. - 25.) / 455.);
178   timer_set(machine, double_to_attotime(attotime_to_double(video_screen_get_time_until_pos(machine->primary_screen, 0, 0)) - hblank_offset), NULL, 0, scanline_callback);
184   timer_device_adjust_oneshot(devtag_get_device(machine, "scan_timer"), double_to_attotime(attotime_to_double(video_screen_get_time_until_pos(machine->primary_screen, 0, 0)) - hblank_offset), 0);
179185
180186   /* reset IRQs */
181187   irq_line_state = CLEAR_LINE;
r6740r6741
416422   MDRV_CPU_ADD("maincpu", ASAP, ATARI_CLOCK_14MHz)
417423   MDRV_CPU_PROGRAM_MAP(main_map)
418424
425   MDRV_MACHINE_START(beathead)
419426   MDRV_MACHINE_RESET(beathead)
420427   MDRV_NVRAM_HANDLER(generic_1fill)
421428
429   MDRV_TIMER_ADD("scan_timer", scanline_callback)
430
422431   /* video hardware */
423432   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
424433
src/mame/drivers/st0016.c
r6740r6741
1414#include "deprecat.h"
1515#include "cpu/z80/z80.h"
1616#include "sound/st0016.h"
17#include "st0016.h"
17#include "includes/st0016.h"
1818
1919
2020
src/mame/drivers/cchasm.c
r6740r6741
2121#include "video/vector.h"
2222#include "machine/6840ptm.h"
2323#include "machine/z80ctc.h"
24#include "cchasm.h"
24#include "includes/cchasm.h"
2525
2626#define CCHASM_68K_CLOCK (XTAL_8MHz)
2727
src/mame/drivers/skyarmy.c
r6740r6741
3131
3232static TILE_GET_INFO( get_skyarmy_tile_info )
3333{
34        int code = skyarmy_videoram[tile_index];
35        int attr = skyarmy_colorram[tile_index];
34   int code = skyarmy_videoram[tile_index];
35   int attr = BITSWAP8(skyarmy_colorram[tile_index], 7, 6, 5, 4, 3, 0, 1, 2) & 7;
3636
37   /* bit 0 <-> bit 2 ????? */
38   switch(attr)
39   {
40      case 1: attr=4; break;
41      case 3: attr=6; break;
42      case 4: attr=1; break;
43      case 6: attr=3; break;
44   }
45
4637   SET_TILE_INFO( 0, code, attr, 0);
4738}
4839
4940static WRITE8_HANDLER( skyarmy_videoram_w )
5041{
51        skyarmy_videoram[offset] = data;
52        tilemap_mark_tile_dirty(skyarmy_tilemap,offset);
42   skyarmy_videoram[offset] = data;
43   tilemap_mark_tile_dirty(skyarmy_tilemap,offset);
5344}
5445
5546static WRITE8_HANDLER( skyarmy_colorram_w )
5647{
57        skyarmy_colorram[offset] = data;
58        tilemap_mark_tile_dirty(skyarmy_tilemap,offset);
48   skyarmy_colorram[offset] = data;
49   tilemap_mark_tile_dirty(skyarmy_tilemap,offset);
5950}
6051
6152static PALETTE_INIT( skyarmy )
r6740r6741
8879
8980static VIDEO_START( skyarmy )
9081{
91        skyarmy_tilemap = tilemap_create(machine, get_skyarmy_tile_info,tilemap_scan_rows,8,8,32,32);
92        tilemap_set_scroll_cols(skyarmy_tilemap,32);
82   skyarmy_tilemap = tilemap_create(machine, get_skyarmy_tile_info,tilemap_scan_rows,8,8,32,32);
83   tilemap_set_scroll_cols(skyarmy_tilemap,32);
9384}
9485
9586
9687static VIDEO_UPDATE( skyarmy )
9788{
9889   UINT8 *spriteram = screen->machine->generic.spriteram.u8;
99        int sx, sy, flipx, flipy, offs,pal;
100        int i;
101   for(i=0;i<0x20;i++)tilemap_set_scrolly( skyarmy_tilemap,i,skyarmy_scrollram[i]);
90   int sx, sy, flipx, flipy, offs,pal;
91   int i;
10292
103        tilemap_draw(bitmap,cliprect,skyarmy_tilemap,0,0);
93   for(i=0;i<0x20;i++)
94      tilemap_set_scrolly( skyarmy_tilemap,i,skyarmy_scrollram[i]);
10495
96   tilemap_draw(bitmap,cliprect,skyarmy_tilemap,0,0);
97
10598   for (offs = 0 ; offs < 0x40; offs+=4)
10699   {
100      pal = BITSWAP8(spriteram[offs+2], 7, 6, 5, 4, 3, 0, 1, 2) & 7;
107101
108      pal=spriteram[offs+2]&0x7;
109
110      switch(pal)
111      {
112       case 1: pal=4; break;
113       case 2: pal=2; break;
114        case 3: pal=6; break;
115         case 4: pal=1; break;
116         case 6: pal=3; break;
117      }
118102      sx = spriteram[offs+3];
119103      sy = 242-spriteram[offs];
120104      flipy = (spriteram[offs+1]&0x80)>>7;
121105      flipx = (spriteram[offs+1]&0x40)>>6;
106
122107      drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[1],
123      spriteram[offs+1]&0x3f,
124      pal,
125      flipx,flipy,
126      sx,sy,0);
108         spriteram[offs+1]&0x3f,
109         pal,
110         flipx,flipy,
111         sx,sy,0);
127112   }
113
128114   return 0;
129115}
130116
r6740r6741
132118
133119static INTERRUPT_GEN( skyarmy_nmi_source )
134120{
135    if(skyarmy_nmi) cpu_set_input_line(device,INPUT_LINE_NMI, PULSE_LINE)   ;
121   if(skyarmy_nmi) cpu_set_input_line(device,INPUT_LINE_NMI, PULSE_LINE);
136122}
137123
138124
139125static WRITE8_HANDLER( nmi_enable_w )
140126{
141        skyarmy_nmi=data&1;
127   skyarmy_nmi=data&1;
142128}
143129
144130
r6740r6741
209195static const gfx_layout charlayout =
210196{
211197   8,8,
212        256,
213        2,
214        { 0, 256*8*8 },
215        { 0, 1, 2, 3, 4, 5, 6, 7 },
216        { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
217        8*8
198   256,
199   2,
200   { 0, 256*8*8 },
201   { 0, 1, 2, 3, 4, 5, 6, 7 },
202   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
203   8*8
218204};
219205
220206static const gfx_layout spritelayout =
221207{
222        16,16,
223        32*2,
224        2,
225        { 0, 256*8*8 },
226        { 0, 1, 2, 3, 4, 5, 6, 7,
227          8*8+0, 8*8+1, 8*8+2, 8*8+3, 8*8+4, 8*8+5, 8*8+6, 8*8+7 },
228        { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
229         16*8,17*8,18*8,19*8,20*8,21*8,22*8,23*8 },
230        32*8
208   16,16,
209   32*2,
210   2,
211   { 0, 256*8*8 },
212   { 0, 1, 2, 3, 4, 5, 6, 7,
213     8*8+0, 8*8+1, 8*8+2, 8*8+3, 8*8+4, 8*8+5, 8*8+6, 8*8+7 },
214   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
215    16*8,17*8,18*8,19*8,20*8,21*8,22*8,23*8 },
216   32*8
231217};
232218
233219static GFXDECODE_START( skyarmy )
234        GFXDECODE_ENTRY( "gfx1", 0, charlayout,   0, 32 )
235        GFXDECODE_ENTRY( "gfx2", 0, spritelayout, 0, 32 )
220   GFXDECODE_ENTRY( "gfx1", 0, charlayout,   0, 8 )
221   GFXDECODE_ENTRY( "gfx2", 0, spritelayout, 0, 8 )
236222GFXDECODE_END
237223
238224static MACHINE_DRIVER_START( skyarmy )
r6740r6741
283269   ROM_LOAD( "a6.bin",  0x0000, 0x0020, CRC(c721220b) SHA1(61b3320fb616c0600d56840cb6438616c7e0c6eb) )
284270ROM_END
285271
286GAME( 1982, skyarmy, 0, skyarmy, skyarmy, 0, ROT90, "Shoei", "Sky Army", GAME_WRONG_COLORS )
272GAME( 1982, skyarmy, 0, skyarmy, skyarmy, 0, ROT90, "Shoei", "Sky Army", 0 )
287273
src/mame/drivers/qix.c
r6740r6741
224224#include "driver.h"
225225#include "cpu/m6805/m6805.h"
226226#include "rendlay.h"
227#include "qix.h"
227#include "includes/qix.h"
228228#include "cpu/m6809/m6809.h"
229229
230230#include "elecyoyo.lh"
src/mame/drivers/battlex.c
r6740r6741
4747#include "cpu/z80/z80.h"
4848#include "deprecat.h"
4949#include "sound/ay8910.h"
50#include "battlex.h"
50#include "includes/battlex.h"
5151
5252
5353/*************************************
src/mame/drivers/konamigq.c
r6740r6741
4949#include "cpu/m68000/m68000.h"
5050#include "cpu/mips/psx.h"
5151#include "includes/psx.h"
52#include "konamigx.h"
52#include "includes/konamigx.h"
5353#include "machine/eepromdev.h"
5454#include "machine/am53cf96.h"
5555#include "harddisk.h"
src/mame/drivers/cinemat.c
r6740r6741
3232#include "driver.h"
3333#include "video/vector.h"
3434#include "cpu/ccpu/ccpu.h"
35#include "cinemat.h"
35#include "includes/cinemat.h"
3636#include "rendlay.h"
3737
3838#include "armora.lh"
src/mame/drivers/toaplan2.c
r6740r6741
45404540   ROM_LOAD( "tp025-3.bin", 0x100000, 0x100000, CRC(7b16101e) SHA1(ae0119bbfa0937d18c4fbb0a3ef7cdc3b9fa6b56) )
45414541ROM_END
45424542
4543ROM_START( pipibibsa )
4544   ROM_REGION( 0x040000, "maincpu", 0 )         /* Main 68K code */
4545   ROM_LOAD16_BYTE( "tp025-1.alt.bin", 0x000000, 0x020000, CRC(3e522d98) SHA1(043dd76b99e130909e47063d4cc773177a2eaccf) )
4546   ROM_LOAD16_BYTE( "tp025-2.alt.bin", 0x000001, 0x020000, CRC(48370485) SHA1(9895e086c9a5eeec4f454cbc6098adb2f66d4e11) )
45434547
4548   ROM_REGION( 0x10000, "audiocpu", 0 )         /* Sound Z80 code */
4549   ROM_LOAD( "tp025-5.bin", 0x0000, 0x8000, CRC(bf8ffde5) SHA1(79c09cc9a0ea979f5af5a7e5ad671ea486f5f43e) )
4550
4551   ROM_REGION( 0x200000, "gfx1", 0 )
4552   ROM_LOAD( "tp025-4.bin", 0x000000, 0x100000, CRC(ab97f744) SHA1(c1620e614345dbd5c6567e4cb6f55c61b900d0ee) )
4553   ROM_LOAD( "tp025-3.bin", 0x100000, 0x100000, CRC(7b16101e) SHA1(ae0119bbfa0937d18c4fbb0a3ef7cdc3b9fa6b56) )
4554ROM_END
4555
45444556ROM_START( whoopee )
45454557   ROM_REGION( 0x040000, "maincpu", 0 )         /* Main 68K code */
45464558   ROM_LOAD16_BYTE( "whoopee.1", 0x000000, 0x020000, CRC(28882e7e) SHA1(8fcd278a7d005eb81cd9e461139c0c0f756a4fa4) )
r6740r6741
53955407
53965408GAME( 1992, truxton2, 0,        truxton2, truxton2, T2_noZ80, ROT270, "Toaplan", "Truxton II / Tatsujin Oh", GAME_SUPPORTS_SAVE )
53975409
5398GAME( 1991, pipibibs, 0,        pipibibs, pipibibs, T2_Z80,   ROT0,   "Toaplan", "Pipi & Bibis / Whoopee!! (Z80 sound cpu)", GAME_SUPPORTS_SAVE )
5399GAME( 1991, whoopee,  pipibibs, whoopee,  whoopee,  T2_Z80,   ROT0,   "Toaplan", "Whoopee!! / Pipi & Bibis", GAME_SUPPORTS_SAVE )
5410GAME( 1991, pipibibs, 0,        pipibibs, pipibibs, T2_Z80,   ROT0,   "Toaplan", "Pipi & Bibis / Whoopee!! (Z80 sound cpu, set 1)", GAME_SUPPORTS_SAVE )
5411GAME( 1991, pipibibsa,pipibibs, pipibibs, pipibibs, T2_Z80,   ROT0,   "Toaplan", "Pipi & Bibis / Whoopee!! (Z80 sound cpu, set 2)", GAME_SUPPORTS_SAVE )
5412GAME( 1991, whoopee,  pipibibs, whoopee,  whoopee,  T2_Z80,   ROT0,   "Toaplan", "Whoopee!! / Pipi & Bibis", GAME_SUPPORTS_SAVE ) // original Whoopee!! boards have a HD647180 instead
54005413GAME( 1991, pipibibi, pipibibs, pipibibi, pipibibi, pipibibi, ROT0,   "[Toaplan] Ryouta Kikaku", "Pipi & Bibis / Whoopee!! (bootleg?)", GAME_SUPPORTS_SAVE )
54015414
54025415GAME( 1992, fixeight, 0,        fixeight, fixeight, fixeight, ROT270, "Toaplan", "FixEight", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
src/mame/drivers/wecleman.c
r6740r6741
273273#include "cpu/z80/z80.h"
274274#include "cpu/m68000/m68000.h"
275275#include "deprecat.h"
276#include "video/konamiic.h"
276#include "video/konicdev.h"
277277#include "cpu/m6809/m6809.h"
278278#include "sound/2151intf.h"
279279#include "sound/k007232.h"
r6740r6741
305305VIDEO_UPDATE( hotchase );
306306VIDEO_START( hotchase );
307307
308extern void hotchase_zoom_callback_0(running_machine *machine, int *code,int *color,int *flags);
309extern void hotchase_zoom_callback_1(running_machine *machine, int *code,int *color,int *flags);
308310
309311/***************************************************************************
310312                            Common Routines
r6740r6741
564566                        Hot Chase Main CPU Handlers
565567***************************************************************************/
566568
567static READ16_HANDLER( hotchase_K051316_0_r )
568{
569   return K051316_0_r(space, offset) & 0xff;
570}
571
572static READ16_HANDLER( hotchase_K051316_1_r )
573{
574   return K051316_1_r(space, offset) & 0xff;
575}
576
577static WRITE16_HANDLER( hotchase_K051316_0_w )
578{
579   if (ACCESSING_BITS_0_7)      K051316_0_w(space, offset, data & 0xff);
580}
581
582static WRITE16_HANDLER( hotchase_K051316_1_w )
583{
584   if (ACCESSING_BITS_0_7)      K051316_1_w(space, offset, data & 0xff);
585}
586
587static WRITE16_HANDLER( hotchase_K051316_ctrl_0_w )
588{
589   if (ACCESSING_BITS_0_7)      K051316_ctrl_0_w(space, offset, data & 0xff);
590}
591
592static WRITE16_HANDLER( hotchase_K051316_ctrl_1_w )
593{
594   if (ACCESSING_BITS_0_7)      K051316_ctrl_1_w(space, offset, data & 0xff);
595}
596
597569static WRITE16_HANDLER( hotchase_soundlatch_w );
598570
599571static ADDRESS_MAP_START( hotchase_map, ADDRESS_SPACE_PROGRAM, 16 )
600572   AM_RANGE(0x000000, 0x03ffff) AM_ROM
601573   AM_RANGE(0x040000, 0x063fff) AM_RAM                              // RAM (weird size!?)
602574   AM_RANGE(0x080000, 0x080011) AM_RAM_WRITE(blitter_w) AM_BASE(&blitter_regs)   // Blitter
603   AM_RANGE(0x100000, 0x100fff) AM_READWRITE(hotchase_K051316_0_r, hotchase_K051316_0_w)   // Background
604   AM_RANGE(0x101000, 0x10101f) AM_WRITE(hotchase_K051316_ctrl_0_w)   // Background Ctrl
605   AM_RANGE(0x102000, 0x102fff) AM_READWRITE(hotchase_K051316_1_r, hotchase_K051316_1_w)   // Foreground
606   AM_RANGE(0x103000, 0x10301f) AM_WRITE(hotchase_K051316_ctrl_1_w)   // Foreground Ctrl
575   AM_RANGE(0x100000, 0x100fff) AM_DEVREADWRITE8("k051316_1", k051316_r, k051316_w, 0x00ff)   // Background
576   AM_RANGE(0x101000, 0x10101f) AM_DEVWRITE8("k051316_1", k051316_ctrl_w, 0x00ff)   // Background Ctrl
577   AM_RANGE(0x102000, 0x102fff) AM_DEVREADWRITE8("k051316_2", k051316_r, k051316_w, 0x00ff)   // Foreground
578   AM_RANGE(0x103000, 0x10301f) AM_DEVWRITE8("k051316_2", k051316_ctrl_w, 0x00ff)   // Foreground Ctrl
607579   AM_RANGE(0x110000, 0x111fff) AM_RAM_WRITE(hotchase_paletteram16_SBGRBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
608580   AM_RANGE(0x120000, 0x123fff) AM_RAM AM_SHARE("share1")               // Shared with sub CPU
609581   AM_RANGE(0x130000, 0x130fff) AM_RAM AM_BASE_GENERIC(spriteram)   // Sprites
r6740r6741
11351107   generic_pulse_irq_line(device, M6809_FIRQ_LINE);
11361108}
11371109
1110static const k051316_interface hotchase_k051316_intf_0 =
1111{
1112   "gfx2", 1,
1113   4, FALSE, 0,
1114   1, -0xb0 / 2, -16,
1115   hotchase_zoom_callback_0
1116};
1117
1118static const k051316_interface hotchase_k051316_intf_1 =
1119{
1120   "gfx3", 2,
1121   4, FALSE, 0,
1122   0, -0xb0 / 2, -16,
1123   hotchase_zoom_callback_1
1124};
1125
11381126static MACHINE_DRIVER_START( hotchase )
11391127
11401128   /* basic machine hardware */
r6740r6741
11671155   MDRV_VIDEO_START(hotchase)
11681156   MDRV_VIDEO_UPDATE(hotchase)
11691157
1158   MDRV_K051316_ADD("k051316_1", hotchase_k051316_intf_0)
1159   MDRV_K051316_ADD("k051316_2", hotchase_k051316_intf_1)
1160
11701161   /* sound hardware */
11711162   MDRV_SPEAKER_STANDARD_MONO("mono")
11721163
src/mame/drivers/crbaloon.c
r6740r6741
1616
1717#include "driver.h"
1818#include "cpu/z80/z80.h"
19#include "crbaloon.h"
19#include "includes/crbaloon.h"
2020
2121
2222static UINT8 *pc3092_data;
src/mame/drivers/funkybee.c
r6740r6741
7474#include "driver.h"
7575#include "cpu/z80/z80.h"
7676#include "sound/ay8910.h"
77#include "funkybee.h"
77#include "includes/funkybee.h"
7878
7979
8080static READ8_HANDLER( funkybee_input_port_0_r )
src/mame/drivers/btoads.c
r6740r6741
1010#include "cpu/z80/z80.h"
1111#include "cpu/tms34010/tms34010.h"
1212#include "video/tlc34076.h"
13#include "btoads.h"
13#include "includes/btoads.h"
1414#include "sound/bsmt2000.h"
1515
1616
src/mame/drivers/freekick.c
r6740r6741
3333#include "machine/8255ppi.h"
3434#include "machine/mc8123.h"
3535#include "sound/sn76496.h"
36#include "freekick.h"
36#include "includes/freekick.h"
3737
3838
3939/*************************************
src/mame/drivers/cischeat.c
r6740r6741
172172#include "cpu/m68000/m68000.h"
173173#include "sound/2151intf.h"
174174#include "sound/okim6295.h"
175#include "megasys1.h"
175#include "includes/megasys1.h"
176176#include "includes/cischeat.h"
177177
178178static UINT16 *rom_1, *rom_2, *rom_3;
src/mame/drivers/vicdual.c
r6740r6741
5454#include "driver.h"
5555#include "cpu/z80/z80.h"
5656#include "cpu/i8085/i8085.h"
57#include "vicdual.h"
57#include "includes/vicdual.h"
5858
5959#include "depthch.lh"
6060
r6740r6741
125125 *
126126 *************************************/
127127
128static int timer_started;
129static UINT32 timer_value;
130
131#define TIMER_HALF_PERIOD   ATTOTIME_IN_MSEC(4 / 2)   /* 4Mhz square wave */
132
133
134128static int get_vcounter(running_machine *machine)
135129{
136130   int vcounter = video_screen_get_vpos(machine->primary_screen);
r6740r6741
162156}
163157
164158
165static TIMER_CALLBACK( vicdual_timer_callback )
166{
167   timer_value = timer_value ^ 1;
168}
169
170
171159static CUSTOM_INPUT( vicdual_get_timer_value )
172160{
173   /* start the timer, if this is the first call */
174   if (!timer_started)
175   {
176      timer_started = 1;
177      timer_pulse(field->port->machine, TIMER_HALF_PERIOD, NULL, 0, vicdual_timer_callback);
178   }
179
180   return timer_value;
161   /* return the state of the timer (old code claims "4MHz square wave", but it was toggled once every 2msec, or 500Hz) */
162   return attotime_to_ticks(timer_get_time(field->port->machine), 500) & 1;
181163}
182164
183165
src/mame/drivers/xybots.c
r6740r6741
2121#include "cpu/m68000/m68000.h"
2222#include "machine/atarigen.h"
2323#include "audio/atarijsa.h"
24#include "xybots.h"
24#include "includes/xybots.h"
2525
2626
2727
r6740r6741
3939}
4040
4141
42static MACHINE_START( xybots )
43{
44   atarigen_init(machine);
45}
46
47
4248static MACHINE_RESET( xybots )
4349{
4450   xybots_state *state = (xybots_state *)machine->driver_data;
r6740r6741
193199   MDRV_CPU_PROGRAM_MAP(main_map)
194200   MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen)
195201
202   MDRV_MACHINE_START(xybots)
196203   MDRV_MACHINE_RESET(xybots)
197204   MDRV_NVRAM_HANDLER(atarigen)
198205
src/mame/drivers/speglsht.c
r6740r6741
107107#include "cpu/z80/z80.h"
108108#include "cpu/mips/r3000.h"
109109#include "sound/st0016.h"
110#include "st0016.h"
110#include "includes/st0016.h"
111111
112112READ8_HANDLER(st0016_dma_r);
113113static UINT8 *shared;
src/mame/drivers/magicfly.c
r6740r6741
405405*     Video Hardware     *
406406*************************/
407407
408static UINT8 *videoram;
409static UINT8 *colorram;
408410static tilemap *bg_tilemap;
409411
410412static WRITE8_HANDLER( magicfly_videoram_w )
411413{
412   space->machine->generic.videoram.u8[offset] = data;
414   videoram[offset] = data;
413415   tilemap_mark_tile_dirty(bg_tilemap, offset);
414416}
415417
416418static WRITE8_HANDLER( magicfly_colorram_w )
417419{
418   space->machine->generic.colorram.u8[offset] = data;
420   colorram[offset] = data;
419421   tilemap_mark_tile_dirty(bg_tilemap, offset);
420422}
421423
r6740r6741
430432    x--- ----   Mirrored from bit 3. The code check this one to boot the game.
431433
432434*/
433   int attr = machine->generic.colorram.u8[tile_index];
434   int code = machine->generic.videoram.u8[tile_index];
435   int attr = colorram[tile_index];
436   int code = videoram[tile_index];
435437   int bank = (attr & 0x10) >> 4;   /* bit 4 switch the gfx banks */
436438   int color = attr & 0x07;         /* bits 0-2 for color */
437439
438440    /* Seems that bit 7 is mirrored from bit 3 to have a normal boot */
439441    /* Boot only check the first color RAM offset */
440442
441   machine->generic.colorram.u8[0] = machine->generic.colorram.u8[0] | ((machine->generic.colorram.u8[0] & 0x08) << 4);   /* only for 1st offset */
442//  machine->generic.colorram.u8[tile_index] = attr | ((attr & 0x08) << 4);         /* for the whole color RAM */
443   colorram[0] = colorram[0] | ((colorram[0] & 0x08) << 4);   /* only for 1st offset */
444   //colorram[tile_index] = attr | ((attr & 0x08) << 4);         /* for the whole color RAM */
443445
444446   SET_TILE_INFO(bank, code, color, 0);
445447}
r6740r6741
460462    x--- ----   Mirrored from bit 2. The code check this one to boot the game.
461463
462464*/
463   int attr = machine->generic.colorram.u8[tile_index];
464   int code = machine->generic.videoram.u8[tile_index];
465   int attr = colorram[tile_index];
466   int code = videoram[tile_index];
465467   int bank = (attr & 0x10) >> 4;    /* bit 4 switch the gfx banks */
466468   int color = attr & 0x07;          /* bits 0-2 for color */
467469
468470    /* Seems that bit 7 is mirrored from bit 2 to have a normal boot */
469471    /* Boot only check the first color RAM offset */
470472
471   machine->generic.colorram.u8[0] = machine->generic.colorram.u8[0] | ((machine->generic.colorram.u8[0] & 0x04) << 5);   /* only for 1st offset */
472//  machine->generic.colorram.u8[tile_index] = attr | ((attr & 0x04) << 5);         /* for the whole color RAM */
473   colorram[0] = colorram[0] | ((colorram[0] & 0x04) << 5);   /* only for 1st offset */
474   //colorram[tile_index] = attr | ((attr & 0x04) << 5);         /* for the whole color RAM */
473475
474476   SET_TILE_INFO(bank, code, color, 0);
475477}
r6740r6741
556558   AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE_SIZE_GENERIC(nvram)    /* MK48Z02B NVRAM */
557559   AM_RANGE(0x0800, 0x0800) AM_DEVWRITE("crtc", mc6845_address_w)
558560   AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
559   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(magicfly_videoram_w) AM_BASE_GENERIC(videoram)   /* HM6116LP #1 (2K x 8) RAM (only 1st half used) */
560   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(magicfly_colorram_w) AM_BASE_GENERIC(colorram)   /* HM6116LP #2 (2K x 8) RAM (only 1st half used) */
561   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(magicfly_videoram_w) AM_BASE(&videoram)   /* HM6116LP #1 (2K x 8) RAM (only 1st half used) */
562   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(magicfly_colorram_w) AM_BASE(&colorram)   /* HM6116LP #2 (2K x 8) RAM (only 1st half used) */
561563   AM_RANGE(0x2800, 0x2800) AM_READ(mux_port_r)   /* multiplexed input port */
562564   AM_RANGE(0x3000, 0x3000) AM_WRITE(mux_port_w)   /* output port */
563565   AM_RANGE(0xc000, 0xffff) AM_ROM               /* ROM space */
src/mame/drivers/centiped.c
r6740r6741
422422#include "cpu/m6502/m6502.h"
423423#include "cpu/s2650/s2650.h"
424424#include "machine/atari_vg.h"
425#include "centiped.h"
425#include "includes/centiped.h"
426426#include "sound/ay8910.h"
427427#include "sound/sn76496.h"
428428#include "sound/pokey.h"
src/mame/drivers/wgp.c
r6740r6741
395395
396396#include "driver.h"
397397#include "cpu/z80/z80.h"
398#include "taitoipt.h"
398#include "includes/taitoipt.h"
399399#include "cpu/m68000/m68000.h"
400400#include "video/taitoic.h"
401401#include "audio/taitosnd.h"
src/mame/drivers/taitoair.c
r6740r6741
218218#include "driver.h"
219219#include "cpu/z80/z80.h"
220220#include "cpu/m68000/m68000.h"
221#include "taitoipt.h"
221#include "includes/taitoipt.h"
222222#include "audio/taitosnd.h"
223223#include "video/taitoic.h"
224224#include "cpu/tms32025/tms32025.h"
src/mame/drivers/tceptor.c
r6740r6741
1111#include "cpu/m6809/m6809.h"
1212#include "cpu/m6800/m6800.h"
1313#include "cpu/m68000/m68000.h"
14#include "namcoic.h"
14#include "includes/namcoic.h"
1515#include "sound/dac.h"
1616#include "sound/2151intf.h"
1717#include "sound/namco.h"
src/mame/drivers/gal3.c
r6740r6741
126126
127127#include "driver.h"
128128#include "cpu/m68000/m68000.h"
129#include "namcos2.h"
129#include "includes/namcos2.h"
130130#include "cpu/tms32025/tms32025.h"
131#include "namcoic.h"
131#include "includes/namcoic.h"
132132#include "sound/c140.h"
133#include "namcos21.h"
133#include "includes/namcos21.h"
134134#include "rendlay.h"
135135
136136static UINT32 *mpSharedRAM0;
src/mame/drivers/metro.c
r6740r6741
8787#include "cpu/h83002/h8.h"
8888#include "cpu/upd7810/upd7810.h"
8989#include "machine/eeprom.h"
90#include "video/konamiic.h"
90#include "video/konicdev.h"
9191#include "sound/2610intf.h"
9292#include "sound/2151intf.h"
9393#include "sound/2413intf.h"
r6740r6741
17051705   AM_RANGE(0x279700, 0x279713) AM_WRITEONLY AM_BASE(&metro_videoregs)               // Video Registers
17061706
17071707   AM_RANGE(0x400000, 0x43ffff) AM_RAM_WRITE(metro_K053936_w) AM_BASE(&metro_K053936_ram)   // 053936
1708   AM_RANGE(0x500000, 0x500fff) AM_WRITEONLY AM_BASE(&K053936_0_linectrl)            // 053936 line control
1709   AM_RANGE(0x600000, 0x60001f) AM_WRITEONLY AM_BASE(&K053936_0_ctrl)               // 053936 control
1708   AM_RANGE(0x500000, 0x500fff) AM_DEVWRITE("k053936", k053936_linectrl_w)            // 053936 line control
1709   AM_RANGE(0x600000, 0x60001f) AM_DEVWRITE("k053936", k053936_ctrl_w)            // 053936 control
17101710
17111711   AM_RANGE(0xe00000, 0xe00001) AM_READ_PORT("DSW0") AM_WRITENOP                  // Inputs
17121712   AM_RANGE(0xe00002, 0xe00003) AM_READ_PORT("DSW1") AM_WRITE(blzntrnd_sound_w)      //
r6740r6741
20482048   COINS
20492049
20502050   PORT_START("IN2")   // Strangely mapped in the 0xc00000-0xc1ffff range
2051    PORT_DIPNAME( 0x0001, 0x0001, "0" )
2052    PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
2053    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2054    PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
2055    PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
2056    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2057    PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
2058    PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
2059    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2060    PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
2061    PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
2062    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2063    PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
2064    PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
2065    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2066    PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
2067    PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
2068    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2069    PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
2070    PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
2071    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2051   PORT_DIPNAME( 0x0001, 0x0001, "0" )
2052   PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
2053   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2054   PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
2055   PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
2056   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2057   PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
2058   PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
2059   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2060   PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
2061   PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
2062   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2063   PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
2064   PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
2065   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2066   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
2067   PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
2068   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2069   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
2070   PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
2071   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
20722072   PORT_DIPNAME( 0x0080, 0x0080, "Debug Mode?" )
20732073   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
20742074   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2075    PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
2076    PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
2077    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2078    PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
2079    PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
2080    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2081    PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
2082    PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
2083    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2084    PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
2085    PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
2086    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2087    PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
2088    PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
2089    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2090    PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
2091    PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
2092    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2093    PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
2094    PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
2095    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2096    PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
2097    PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
2098    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2075   PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
2076   PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
2077   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2078   PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
2079   PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
2080   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2081   PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
2082   PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
2083   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2084   PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
2085   PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
2086   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2087   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
2088   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
2089   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2090   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
2091   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
2092   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2093   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
2094   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
2095   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
2096   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
2097   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
2098   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
20992099INPUT_PORTS_END
21002100
21012101/***************************************************************************
r6740r6741
42224222MACHINE_DRIVER_END
42234223
42244224
4225static const k053936_interface blzntrnd_k053936_intf =
4226{
4227   0, -69, -21
4228};
4229
42254230static MACHINE_DRIVER_START( blzntrnd )
42264231
42274232   /* basic machine hardware */
r6740r6741
42494254   MDRV_VIDEO_START(blzntrnd)
42504255   MDRV_VIDEO_UPDATE(metro)
42514256
4257   MDRV_K053936_ADD("k053936", blzntrnd_k053936_intf)
4258
42524259   /* sound hardware */
42534260   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
42544261
r6740r6741
42614268MACHINE_DRIVER_END
42624269
42634270/* like blzntrnd but new vidstart / gfxdecode for the different bg tilemap */
4271
4272static const k053936_interface gstrik2_k053936_intf =
4273{
4274   0, -69, -19
4275};
4276
42644277static MACHINE_DRIVER_START( gstrik2 )
42654278
42664279   /* basic machine hardware */
r6740r6741
42884301   MDRV_VIDEO_START(gstrik2)
42894302   MDRV_VIDEO_UPDATE(metro)
42904303
4304   MDRV_K053936_ADD("k053936", gstrik2_k053936_intf)
4305
42914306   /* sound hardware */
42924307   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
42934308
src/mame/drivers/angelkds.c
r6740r6741
130130#include "cpu/z80/z80.h"
131131#include "machine/segacrpt.h"
132132#include "sound/2203intf.h"
133#include "angelkds.h"
133#include "includes/angelkds.h"
134134
135135static READ8_HANDLER( angelkds_main_sound_r );
136136static WRITE8_HANDLER( angelkds_main_sound_w );
src/mame/drivers/jrpacman.c
r6740r6741
100100
101101#include "driver.h"
102102#include "cpu/z80/z80.h"
103#include "pacman.h"
103#include "includes/pacman.h"
104104#include "sound/namco.h"
105105
106106
r6740r6741
120120
121121static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
122122   AM_RANGE(0x0000, 0x3fff) AM_ROM
123   AM_RANGE(0x4000, 0x47ff) AM_RAM_WRITE(jrpacman_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
123   AM_RANGE(0x4000, 0x47ff) AM_RAM_WRITE(jrpacman_videoram_w) AM_BASE(&pacman_videoram)
124124   AM_RANGE(0x4800, 0x4fef) AM_RAM
125125   AM_RANGE(0x4ff0, 0x4fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
126126   AM_RANGE(0x5000, 0x503f) AM_READ_PORT("P1")
src/mame/drivers/namcond1.c
r6740r6741
6969#include "cpu/m68000/m68000.h"
7070#include "video/ygv608.h"
7171#include "cpu/h83002/h8.h"
72#include "namcond1.h"
72#include "includes/namcond1.h"
7373#include "sound/c352.h"
7474#include "machine/at28c16.h"
7575
src/mame/drivers/surpratk.c
r6740r6741
1010
1111#include "driver.h"
1212#include "cpu/konami/konami.h" /* for the callback and the firq irq definition */
13#include "video/konamiic.h"
13#include "video/konicdev.h"
1414#include "sound/2151intf.h"
15#include "konamipt.h"
15#include "includes/konamipt.h"
1616
1717/* prototypes */
1818static MACHINE_RESET( surpratk );
1919static KONAMI_SETLINES_CALLBACK( surpratk_banking );
20VIDEO_START( surpratk );
2120VIDEO_UPDATE( surpratk );
2221
22extern void surpratk_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
23extern void surpratk_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask);
2324
25
2426static int videobank;
2527static UINT8 *ram;
2628
2729static INTERRUPT_GEN( surpratk_interrupt )
2830{
29   if (K052109_is_IRQ_enabled()) cpu_set_input_line(device,0,HOLD_LINE);
31   const device_config *k052109 = devtag_get_device(device->machine, "k052109");
32   if (k052109_is_irq_enabled(k052109))
33      cpu_set_input_line(device,0,HOLD_LINE);
3034}
3135
3236static READ8_HANDLER( bankedram_r )
3337{
38   const device_config *k053244 = devtag_get_device(space->machine, "k053244");
3439   if (videobank & 0x02)
3540   {
3641      if (videobank & 0x04)
r6740r6741
3944         return space->machine->generic.paletteram.u8[offset];
4045   }
4146   else if (videobank & 0x01)
42      return K053245_r(space,offset);
47      return k053245_r(k053244, offset);
4348   else
4449      return ram[offset];
4550}
4651
4752static WRITE8_HANDLER( bankedram_w )
4853{
54   const device_config *k053244 = devtag_get_device(space->machine, "k053244");
4955   if (videobank & 0x02)
5056   {
5157      if (videobank & 0x04)
r6740r6741
5460         paletteram_xBBBBBGGGGGRRRRR_be_w(space,offset,data);
5561   }
5662   else if (videobank & 0x01)
57      K053245_w(space,offset,data);
63      k053245_w(k053244, offset, data);
5864   else
5965      ram[offset] = data;
6066}
r6740r6741
7076
7177static WRITE8_HANDLER( surpratk_5fc0_w )
7278{
79   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
7380   if ((data & 0xf4) != 0x10) logerror("%04x: 3fc0 = %02x\n",cpu_get_pc(space->cpu),data);
7481
7582   /* bit 0/1 = coin counters */
r6740r6741
7784   coin_counter_w(space->machine, 1,data & 0x02);
7885
7986   /* bit 3 = enable char ROM reading through the video RAM */
80   K052109_set_RMRD_line( ( data & 0x08 ) ? ASSERT_LINE : CLEAR_LINE );
87   k052109_set_rmrd_line(k052109, (data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
8188
8289   /* other bits unknown */
8390}
r6740r6741
94101   AM_RANGE(0x5f8e, 0x5f8e) AM_READ_PORT("DSW3")
95102   AM_RANGE(0x5f8f, 0x5f8f) AM_READ_PORT("DSW1")
96103   AM_RANGE(0x5f90, 0x5f90) AM_READ_PORT("DSW2")
97   AM_RANGE(0x5fa0, 0x5faf) AM_READWRITE(K053244_r, K053244_w)
98   AM_RANGE(0x5fb0, 0x5fbf) AM_WRITE(K053251_w)
104   AM_RANGE(0x5fa0, 0x5faf) AM_DEVREADWRITE("k053244", k053244_r, k053244_w)
105   AM_RANGE(0x5fb0, 0x5fbf) AM_DEVWRITE("k053251", k053251_w)
99106   AM_RANGE(0x5fc0, 0x5fc0) AM_READWRITE(watchdog_reset_r, surpratk_5fc0_w)
100107   AM_RANGE(0x5fd0, 0x5fd1) AM_DEVWRITE("ymsnd", ym2151_w)
101108   AM_RANGE(0x5fc4, 0x5fc4) AM_WRITE(surpratk_videobank_w)
102   AM_RANGE(0x4000, 0x7fff) AM_READWRITE(K052109_r, K052109_w)
109   AM_RANGE(0x4000, 0x7fff) AM_DEVREADWRITE("k052109", k052109_r, k052109_w)
103110   AM_RANGE(0x8000, 0xffff) AM_ROM               /* ROM */
104111ADDRESS_MAP_END
105112
r6740r6741
175182
176183
177184
185static const k052109_interface surpratk_k052109_intf =
186{
187   "gfx1", 0,
188   NORMAL_PLANE_ORDER,
189   KONAMI_ROM_DEINTERLEAVE_2,
190   surpratk_tile_callback
191};
192
193static const k05324x_interface surpratk_k05324x_intf =
194{
195   "gfx2", 1,
196   NORMAL_PLANE_ORDER,
197   0, 0,
198   KONAMI_ROM_DEINTERLEAVE_2,
199   surpratk_sprite_callback
200};
201
178202static MACHINE_DRIVER_START( surpratk )
179203
180204   /* basic machine hardware */
r6740r6741
196220
197221   MDRV_PALETTE_LENGTH(2048)
198222
199   MDRV_VIDEO_START(surpratk)
200223   MDRV_VIDEO_UPDATE(surpratk)
201224
225   MDRV_K052109_ADD("k052109", surpratk_k052109_intf)
226   MDRV_K053244_ADD("k053244", surpratk_k05324x_intf)
227   MDRV_K053251_ADD("k053251")
228
202229   /* sound hardware */
203230   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
204231
r6740r6741
285312   machine->generic.paletteram.u8 = &memory_region(machine, "maincpu")[0x48000];
286313}
287314
288static DRIVER_INIT( surpratk )
289{
290   konami_rom_deinterleave_2(machine, "gfx1");
291   konami_rom_deinterleave_2(machine, "gfx2");
292}
293315
294
295GAME( 1990, suratk,  0,      surpratk, surpratk, surpratk, ROT0, "Konami", "Surprise Attack (World ver. K)", 0 )
296GAME( 1990, suratka, suratk, surpratk, surpratk, surpratk, ROT0, "Konami", "Surprise Attack (Asia ver. L)", 0 )
297GAME( 1990, suratkj, suratk, surpratk, surpratk, surpratk, ROT0, "Konami", "Surprise Attack (Japan ver. M)", 0 )
316GAME( 1990, suratk,  0,      surpratk, surpratk, 0, ROT0, "Konami", "Surprise Attack (World ver. K)", 0 )
317GAME( 1990, suratka, suratk, surpratk, surpratk, 0, ROT0, "Konami", "Surprise Attack (Asia ver. L)", 0 )
318GAME( 1990, suratkj, suratk, surpratk, surpratk, 0, ROT0, "Konami", "Surprise Attack (Japan ver. M)", 0 )
src/mame/drivers/tagteam.c
r6740r6741
3030#include "sound/ay8910.h"
3131#include "sound/dac.h"
3232
33extern UINT8 *tagteam_videoram;
34extern UINT8 *tagteam_colorram;
35
3336extern WRITE8_HANDLER( tagteam_videoram_w );
3437extern WRITE8_HANDLER( tagteam_colorram_w );
3538extern READ8_HANDLER( tagteam_mirrorvideoram_r );
r6740r6741
6063   AM_RANGE(0x4000, 0x43ff) AM_READWRITE(tagteam_mirrorvideoram_r, tagteam_mirrorvideoram_w)
6164   AM_RANGE(0x4400, 0x47ff) AM_READWRITE(tagteam_mirrorcolorram_r, tagteam_mirrorcolorram_w)
6265   AM_RANGE(0x4800, 0x4fff) AM_READONLY
63   AM_RANGE(0x4800, 0x4bff) AM_WRITE(tagteam_videoram_w) AM_BASE_GENERIC(videoram)
64   AM_RANGE(0x4c00, 0x4fff) AM_WRITE(tagteam_colorram_w) AM_BASE_GENERIC(colorram)
66   AM_RANGE(0x4800, 0x4bff) AM_WRITE(tagteam_videoram_w) AM_BASE(&tagteam_videoram)
67   AM_RANGE(0x4c00, 0x4fff) AM_WRITE(tagteam_colorram_w) AM_BASE(&tagteam_colorram)
6568   AM_RANGE(0x8000, 0xffff) AM_ROM
6669ADDRESS_MAP_END
6770
src/mame/drivers/eolith.c
r6740r6741
6565
6666static int coin_counter_bit = 0;
6767
68#include "eolithsp.h"
68#include "includes/eolithsp.h"
6969
7070// It's configured for 512 bytes
7171static const eeprom_interface eeprom_interface_93C66 =
src/mame/drivers/chihiro.c
r6740r6741
3737#include "driver.h"
3838#include "cpu/i386/i386.h"
3939#include "video/generic.h"
40#include "naomibd.h"
40#include "includes/naomibd.h"
4141
4242static ADDRESS_MAP_START( xbox_map, ADDRESS_SPACE_PROGRAM, 32 )
4343   AM_RANGE(0x00000000, 0x0007ffff) AM_RAM
src/mame/drivers/commando.c
r6740r6741
4646#include "cpu/z80/z80.h"
4747#include "deprecat.h"
4848#include "sound/2203intf.h"
49#include "commando.h"
49#include "includes/commando.h"
5050
5151
5252/* Memory Maps */
src/mame/drivers/atarisy2.c
r6740r6741
126126#include "driver.h"
127127#include "cpu/m6502/m6502.h"
128128#include "cpu/t11/t11.h"
129#include "slapstic.h"
130#include "atarisy2.h"
129#include "includes/slapstic.h"
130#include "includes/atarisy2.h"
131131#include "sound/tms5220.h"
132132#include "sound/2151intf.h"
133133#include "sound/pokey.h"
r6740r6741
225225static MACHINE_START( atarisy2 )
226226{
227227   atarisy2_state *state = (atarisy2_state *)machine->driver_data;
228   atarigen_init(machine);
229
228230   state_save_register_global(machine, state->interrupt_enable);
229231   state_save_register_global(machine, state->tms5220_data);
230232   state_save_register_global(machine, state->tms5220_data_strobe);
src/mame/drivers/skydiver.c
r6740r6741
8989#include "driver.h"
9090#include "cpu/m6800/m6800.h"
9191#include "deprecat.h"
92#include "skydiver.h"
92#include "includes/skydiver.h"
9393#include "sound/discrete.h"
9494
9595#define MASTER_CLOCK (XTAL_12_096MHz)
src/mame/drivers/ninjakd2.c
r6740r6741
133133#include "sound/2203intf.h"
134134#include "sound/samples.h"
135135#include "machine/mc8123.h"
136#include "ninjakd2.h"
136#include "includes/ninjakd2.h"
137137
138138#define MAIN_CLOCK_12 XTAL_12MHz
139139#define MAIN_CLOCK_5  XTAL_5MHz
src/mame/drivers/warpwarp.c
r6740r6741
128128
129129#include "driver.h"
130130#include "cpu/i8085/i8085.h"
131#include "warpwarp.h"
131#include "includes/warpwarp.h"
132132#include "geebee.lh"
133133#include "sos.lh"
134134
src/mame/drivers/spacefb.c
r6740r6741
106106
107107#include "driver.h"
108108#include "cpu/z80/z80.h"
109#include "spacefb.h"
109#include "includes/spacefb.h"
110110#include "cpu/mcs48/mcs48.h"
111111#include "sound/dac.h"
112112
src/mame/drivers/m52.c
r6740r6741
4343***************************************************************************/
4444
4545#include "driver.h"
46#include "iremipt.h"
46#include "includes/iremipt.h"
4747#include "includes/iremz80.h"
4848#include "cpu/z80/z80.h"
4949
src/mame/drivers/wheelfir.c
r6740r6741
540540   PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
541541INPUT_PORTS_END
542542
543static emu_timer* frame_timer;
544static emu_timer* scanline_timer;
543static const device_config* frame_timer;
544static const device_config* scanline_timer;
545545
546static TIMER_CALLBACK( frame_timer_callback )
546static TIMER_DEVICE_CALLBACK( frame_timer_callback )
547547{
548548   /* callback */
549549}
r6740r6741
570570
571571}
572572
573static TIMER_CALLBACK( scanline_timer_callback )
573static TIMER_DEVICE_CALLBACK( scanline_timer_callback )
574574{
575   timer_call_after_resynch(machine, NULL, 0, 0);
575   timer_call_after_resynch(timer->machine, NULL, 0, 0);
576576
577577   if (scanline_counter != (total_scanlines - 1))
578578   {
579579      scanline_counter++;
580      cputag_set_input_line(machine, "maincpu", 5, HOLD_LINE); // raster IRQ, changes scroll values for road
581      timer_adjust_oneshot(scanline_timer, attotime_div(ATTOTIME_IN_HZ(60), total_scanlines), 0);
580      cputag_set_input_line(timer->machine, "maincpu", 5, HOLD_LINE); // raster IRQ, changes scroll values for road
581      timer_device_adjust_oneshot(timer, attotime_div(ATTOTIME_IN_HZ(60), total_scanlines), 0);
582582
583583      if (scanline_counter < 256)
584584      {
r6740r6741
587587
588588      if (scanline_counter == 256)
589589      {
590         cputag_set_input_line(machine, "maincpu", 3, HOLD_LINE); // vblank IRQ?
590         cputag_set_input_line(timer->machine, "maincpu", 3, HOLD_LINE); // vblank IRQ?
591591         toggle_bit = 0x8000; // must toggle..
592592      }
593593
r6740r6741
609609   scanline_counter = -1;
610610   bitmap_fill(wheelfir_tmp_bitmap[0], video_screen_get_visible_area(machine->primary_screen),0);
611611
612   timer_adjust_oneshot(frame_timer,  attotime_zero, 0);
613   timer_adjust_oneshot(scanline_timer,  attotime_zero, 0);
612   timer_device_adjust_oneshot(frame_timer,  attotime_zero, 0);
613   timer_device_adjust_oneshot(scanline_timer,  attotime_zero, 0);
614614}
615615
616616static MACHINE_RESET(wheelfir)
617617{
618   frame_timer = timer_alloc(machine, frame_timer_callback, NULL);
619   scanline_timer = timer_alloc(machine, scanline_timer_callback, NULL);
620   timer_adjust_oneshot(frame_timer, attotime_zero, 0);
621   timer_adjust_oneshot(scanline_timer,  attotime_zero, 0);
618   frame_timer = devtag_get_device(machine, "frame_timer");
619   scanline_timer = devtag_get_device(machine, "scan_timer");
620   timer_device_adjust_oneshot(frame_timer, attotime_zero, 0);
621   timer_device_adjust_oneshot(scanline_timer,  attotime_zero, 0);
622622   scanline_counter = -1;
623623}
624624
r6740r6741
640640
641641   MDRV_MACHINE_RESET (wheelfir)
642642
643   MDRV_TIMER_ADD("frame_timer", frame_timer_callback)
644   MDRV_TIMER_ADD("scan_timer", scanline_timer_callback)
643645
644646   MDRV_SCREEN_ADD("screen", RASTER)
645647   MDRV_SCREEN_REFRESH_RATE(60)
src/mame/drivers/nbmj8891.c
r6740r6741
4343
4444#include "driver.h"
4545#include "cpu/z80/z80.h"
46#include "nb1413m3.h"
46#include "includes/nb1413m3.h"
4747#include "sound/dac.h"
4848#include "sound/ay8910.h"
4949#include "sound/3812intf.h"
src/mame/drivers/liberate.c
r6740r6741
1818#include "cpu/m6502/m6502.h"
1919#include "sound/ay8910.h"
2020
21extern UINT8 *liberate_videoram;
22extern UINT8 *liberate_colorram;
23
2124PALETTE_INIT( liberate );
2225VIDEO_UPDATE( prosoccr );
2326VIDEO_UPDATE( prosport );
r6740r6741
5659      return ROM[offset];
5760
5861   /* Else the handler falls through to read the usual address */
59   if (offset<0x400) return space->machine->generic.colorram.u8[offset];
60   if (offset<0x800) return space->machine->generic.videoram.u8[offset-0x400];
62   if (offset<0x400) return liberate_colorram[offset];
63   if (offset<0x800) return liberate_videoram[offset-0x400];
6164   if (offset<0x1000) return space->machine->generic.spriteram.u8[offset-0x800];
6265   if (offset<0x2200) { logerror("%04x: Unmapped bank read %04x\n",cpu_get_pc(space->cpu),offset); return 0; }
6366   if (offset<0x2800) return scratchram[offset-0x2200];
r6740r6741
99102      return ROM[offset];
100103
101104   /* Else the handler falls through to read the usual address */
102   if (offset<0x400) return space->machine->generic.colorram.u8[offset];
103   if (offset<0x800) return space->machine->generic.videoram.u8[offset-0x400];
104   if (offset<0xc00) return space->machine->generic.colorram.u8[offset-0x800];
105   if (offset<0x400) return liberate_colorram[offset];
106   if (offset<0x800) return liberate_videoram[offset-0x400];
107   if (offset<0xc00) return liberate_colorram[offset-0x800];
105108   if (offset<0x1000) return space->machine->generic.spriteram.u8[offset-0xc00];
106109   if (offset<0x2200) { logerror("%04x: Unmapped bank read %04x\n",cpu_get_pc(space->cpu),offset); return 0; }
107110   if (offset<0x2800) return scratchram[offset-0x2200];
r6740r6741
246249   AM_RANGE(0x0400, 0x07ff) AM_RAM_WRITE(prosport_bg_vram_w) AM_BASE(&prosport_bg_vram)
247250   AM_RANGE(0x0800, 0x1fff) AM_READWRITE(prosport_charram_r,prosport_charram_w) //0x1e00-0x1fff isn't charram!
248251    AM_RANGE(0x2400, 0x2fff) AM_RAM
249   AM_RANGE(0x3000, 0x33ff) AM_RAM_WRITE(liberate_colorram_w) AM_BASE_GENERIC(colorram)
250   AM_RANGE(0x3400, 0x37ff) AM_RAM_WRITE(liberate_videoram_w) AM_BASE_GENERIC(videoram)
252   AM_RANGE(0x3000, 0x33ff) AM_RAM_WRITE(liberate_colorram_w) AM_BASE(&liberate_colorram)
253   AM_RANGE(0x3400, 0x37ff) AM_RAM_WRITE(liberate_videoram_w) AM_BASE(&liberate_videoram)
251254   AM_RANGE(0x3800, 0x3fff) AM_RAM AM_BASE_GENERIC(spriteram)
252255   AM_RANGE(0x8000, 0x800f) AM_WRITE(prosport_io_w)
253256   AM_RANGE(0x8000, 0x800f) AM_ROMBANK("bank1")
r6740r6741
258261   AM_RANGE(0x0000, 0x0fff) AM_RAM
259262   AM_RANGE(0x1000, 0x3fff) AM_ROM /* Mirror of main rom */
260263   AM_RANGE(0x4000, 0x7fff) AM_READ(deco16_bank_r)
261   AM_RANGE(0x4000, 0x43ff) AM_WRITE(liberate_colorram_w) AM_BASE_GENERIC(colorram)
262   AM_RANGE(0x4400, 0x47ff) AM_WRITE(liberate_videoram_w) AM_BASE_GENERIC(videoram)
264   AM_RANGE(0x4000, 0x43ff) AM_WRITE(liberate_colorram_w) AM_BASE(&liberate_colorram)
265   AM_RANGE(0x4400, 0x47ff) AM_WRITE(liberate_videoram_w) AM_BASE(&liberate_videoram)
263266   AM_RANGE(0x4800, 0x4fff) AM_WRITEONLY AM_BASE_GENERIC(spriteram)
264267   AM_RANGE(0x6200, 0x67ff) AM_RAM AM_BASE(&scratchram)
265268   AM_RANGE(0x8000, 0x800f) AM_WRITE(deco16_io_w)
r6740r6741
271274   AM_RANGE(0x0000, 0x0fff) AM_RAM
272275   AM_RANGE(0x1000, 0x3fff) AM_ROM /* Mirror of main rom */
273276   AM_RANGE(0x4000, 0x7fff) AM_READ(prosoccr_bank_r)
274   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0x800) AM_WRITE(liberate_colorram_w) AM_BASE_GENERIC(colorram)
275   AM_RANGE(0x4400, 0x47ff) AM_WRITE(liberate_videoram_w) AM_BASE_GENERIC(videoram)
277   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0x800) AM_WRITE(liberate_colorram_w) AM_BASE(&liberate_colorram)
278   AM_RANGE(0x4400, 0x47ff) AM_WRITE(liberate_videoram_w) AM_BASE(&liberate_videoram)
276279   AM_RANGE(0x4c00, 0x4fff) AM_WRITEONLY AM_BASE_GENERIC(spriteram)
277280   AM_RANGE(0x6200, 0x67ff) AM_RAM AM_BASE(&scratchram)
278281   AM_RANGE(0x8000, 0x97ff) AM_READWRITE(prosoccr_charram_r,prosoccr_charram_w)
r6740r6741
295298   AM_RANGE(0x0000, 0x0fff) AM_RAM
296299   AM_RANGE(0x1000, 0x3fff) AM_ROM /* Mirror of main rom */
297300   AM_RANGE(0x4000, 0x7fff) AM_READ(deco16_bank_r)
298   AM_RANGE(0x4000, 0x43ff) AM_WRITE(liberate_colorram_w) AM_BASE_GENERIC(colorram)
299   AM_RANGE(0x4400, 0x47ff) AM_WRITE(liberate_videoram_w) AM_BASE_GENERIC(videoram)
301   AM_RANGE(0x4000, 0x43ff) AM_WRITE(liberate_colorram_w) AM_BASE(&liberate_colorram)
302   AM_RANGE(0x4400, 0x47ff) AM_WRITE(liberate_videoram_w) AM_BASE(&liberate_videoram)
300303   AM_RANGE(0x4800, 0x4fff) AM_WRITEONLY AM_BASE_GENERIC(spriteram)
301304   AM_RANGE(0x6200, 0x67ff) AM_WRITEONLY AM_BASE(&scratchram)
302305   AM_RANGE(0xf000, 0xf00f) AM_WRITE(deco16_io_w)
src/mame/drivers/seta.c
r6740r6741
13011301#include "cpu/m68000/m68000.h"
13021302#include "cpu/m6502/m6502.h"
13031303#include "deprecat.h"
1304#include "seta.h"
1304#include "includes/seta.h"
13051305#include "machine/6821pia.h"
13061306#include "machine/6850acia.h"
13071307#include "machine/msm6242.h"
r6740r6741
74557455   cpu_set_input_line(device, 2, HOLD_LINE );
74567456}
74577457
7458static MACHINE_RESET( wrofaero ) { uPD71054_timer_init(machine); }
7458static MACHINE_START( wrofaero ) { uPD71054_timer_init(machine); }
74597459#endif   // __uPD71054_TIMER
74607460
74617461
r6740r6741
74797479#endif   // __uPD71054_TIMER
74807480
74817481#if   __uPD71054_TIMER
7482   MDRV_MACHINE_RESET( wrofaero )
7482   MDRV_MACHINE_START( wrofaero )
74837483#endif   // __uPD71054_TIMER
74847484
74857485   /* video hardware */
r6740r6741
75907590   MDRV_CPU_VBLANK_INT("screen", wrofaero_interrupt)
75917591
75927592#if   __uPD71054_TIMER
7593   MDRV_MACHINE_RESET( wrofaero )
7593   MDRV_MACHINE_START( wrofaero )
75947594#endif   // __uPD71054_TIMER
75957595
75967596   /* video hardware */
r6740r6741
77387738   MDRV_CPU_VBLANK_INT("screen", wrofaero_interrupt)
77397739
77407740#if   __uPD71054_TIMER
7741   MDRV_MACHINE_RESET( wrofaero )
7741   MDRV_MACHINE_START( wrofaero )
77427742#endif   // __uPD71054_TIMER
77437743
77447744   /* video hardware */
r6740r6741
77847784#endif   // __uPD71054_TIMER
77857785
77867786#if   __uPD71054_TIMER
7787   MDRV_MACHINE_RESET( wrofaero )
7787   MDRV_MACHINE_START( wrofaero )
77887788#endif   // __uPD71054_TIMER
77897789
77907790   /* video hardware */
r6740r6741
81548154#endif   // __uPD71054_TIMER
81558155
81568156#if   __uPD71054_TIMER
8157   MDRV_MACHINE_RESET( wrofaero )
8157   MDRV_MACHINE_START( wrofaero )
81588158#endif   // __uPD71054_TIMER
81598159
81608160   /* video hardware */
src/mame/drivers/laserbat.c
r6740r6741
684684static const s2636_interface s2636_1_config =
685685{
686686   "screen",
687   0xff,
687   0x100,
688688   0, -19
689689};
690690
691691static const s2636_interface s2636_2_config =
692692{
693693   "screen",
694   0xff,
694   0x100,
695695   0, -19
696696};
697697
698698static const s2636_interface s2636_3_config =
699699{
700700   "screen",
701   0xff,
701   0x100,
702702   0, -19
703703};
704704
src/mame/drivers/tp84.c
r6740r6741
6969#include "cpu/m6809/m6809.h"
7070#include "sound/sn76496.h"
7171#include "sound/flt_rc.h"
72#include "konamipt.h"
72#include "includes/konamipt.h"
7373
7474extern UINT8 *tp84_bg_videoram;
7575extern UINT8 *tp84_bg_colorram;
src/mame/drivers/naomi.c
r6740r6741
10491049#include "video/generic.h"
10501050#include "machine/eeprom.h"
10511051#include "machine/intelfsh.h"
1052#include "naomibd.h"
1053#include "naomi.h"
1052#include "includes/naomibd.h"
1053#include "includes/naomi.h"
10541054#include "cpu/sh4/sh4.h"
10551055#include "cpu/arm7/arm7core.h"
10561056#include "sound/aica.h"
1057#include "dc.h"
1057#include "includes/dc.h"
10581058
10591059#define CPU_CLOCK (200000000)
10601060static UINT32 *dc_sound_ram;
r6740r6741
19031903EPR-21577g - NAOMI BOOT ROM 2001 09/10  1.70 (USA)
19041904EPR-21577e - NAOMI BOOT ROM 2000 08/25  1.50 (USA)
19051905EPR-21577d - NAOMI BOOT ROM 1999 06/04  1.40 (USA)
1906EPR-21578h - NAOMI BOOT ROM 2002 07/08  1.8- (Export)
1907EPR-21578g - NAOMI BOOT ROM 2001 09/10  1.70 (Export)
19061908EPR-21578e - NAOMI BOOT ROM 2000 08/25  1.50 (Export)
19071909EPR-21578d - NAOMI BOOT ROM 1999 06/04  1.40 (Export)
19081910EPR-21578b - NAOMI BOOT ROM 1999 02/15  1.20 (Export)
19091911EPR-21579  - No known dump (Korea)
19101912EPR-21580  - No known dump (Australia)
1911EPR-22851  - NAOMI BOOT ROM 1999 08/30  1.35 (Multisystem 3 screen Ferrari F355)
19121913
19131914EPR-21577e & EPR-2178e differ by 7 bytes:
19141915
r6740r6741
19731974   ROM_LOAD16_WORD_SWAP_BIOS( 4, "epr-21576b.bin",  0x000000, 0x200000, CRC(755a6e07) SHA1(7e8b8ccfc063144d89668e7224dcd8a36c54f3b3) ) \
19741975   ROM_SYSTEM_BIOS( 5, "bios5", "epr-21576 (Japan)" ) \
19751976   ROM_LOAD16_WORD_SWAP_BIOS( 5, "epr-21576.bin", 0x000000, 0x200000, CRC(9dad3495) SHA1(5fb66f9a2b68d120f059c72758e65d34f461044a) ) \
1976   ROM_SYSTEM_BIOS( 6, "bios6", "epr-21578g (Export)" ) \
1977        ROM_LOAD16_WORD_SWAP_BIOS( 6, "epr-21578g.ic27", 0x000000, 0x200000, CRC(55413214) SHA1(bd2748365a9fc1821c9369aa7155d7c41c4df43e) ) \
1978   ROM_SYSTEM_BIOS( 7, "bios7", "epr-21578e (Export)" ) \
1979   ROM_LOAD16_WORD_SWAP_BIOS( 7, "epr-21578e.bin",  0x000000, 0x200000, CRC(087f09a3) SHA1(0418eb2cf9766f0b1b874a4e92528779e22c0a4a) ) \
1980   ROM_SYSTEM_BIOS( 8, "bios8", "epr-21578d (Export)" ) \
1981   ROM_LOAD16_WORD_SWAP_BIOS( 8, "epr-21578d.bin",  0x000000, 0x200000, CRC(dfd5f42a) SHA1(614a0db4743a5e5a206190d6786ade24325afbfd) ) \
1982   ROM_SYSTEM_BIOS( 9, "bios9", "epr-21578b (Export)" ) \
1983   ROM_LOAD16_WORD_SWAP_BIOS( 9, "epr-21578b.bin",  0x000000, 0x200000, CRC(6c9aad83) SHA1(555918de76d8dbee2a97d8a95297ef694b3e803f) ) \
1984   ROM_SYSTEM_BIOS( 10, "bios10", "epr-21577g (USA)" ) \
1985   ROM_LOAD16_WORD_SWAP_BIOS( 10, "epr-21577g.bin",  0x000000, 0x200000, CRC(25f64af7) SHA1(99f9e6cc0642319bd2da492611220540add573e8) ) \
1986   ROM_SYSTEM_BIOS( 11, "bios11", "epr-21577e (USA)" ) \
1987   ROM_LOAD16_WORD_SWAP_BIOS( 11, "epr-21577e.bin",  0x000000, 0x200000, CRC(cf36e97b) SHA1(b085305982e7572e58b03a9d35f17ae319c3bbc6) ) \
1988   ROM_SYSTEM_BIOS( 12, "bios12", "epr-21577d (USA)" ) \
1989   ROM_LOAD16_WORD_SWAP_BIOS( 12, "epr-21577d.bin",  0x000000, 0x200000, CRC(60ddcbbe) SHA1(58b15096d269d6df617ca1810b66b47deb184958) ) \
1990   ROM_SYSTEM_BIOS( 13, "bios13", "Naomi Dev BIOS" ) \
1991   ROM_LOAD16_WORD_SWAP_BIOS( 13,  "dcnaodev.bios", 0x000000, 0x080000, CRC(7a50fab9) SHA1(ef79f448e0bf735d1264ad4f051d24178822110f) ) /* This one comes from a dev / beta board. The eprom was a 27C4096 */
1977   ROM_SYSTEM_BIOS( 6, "bios6", "epr-21578h (Export)" ) \
1978   ROM_LOAD16_WORD_SWAP_BIOS( 6, "epr-21578h.ic27", 0x000000, 0x200000, CRC(7b452946) SHA1(8e9f153bbada24b37066dc45b64a7bf0d4f26a9b) ) \
1979   ROM_SYSTEM_BIOS( 7, "bios7", "epr-21578g (Export)" ) \
1980   ROM_LOAD16_WORD_SWAP_BIOS( 7, "epr-21578g.ic27", 0x000000, 0x200000, CRC(55413214) SHA1(bd2748365a9fc1821c9369aa7155d7c41c4df43e) ) \
1981   ROM_SYSTEM_BIOS( 8, "bios8", "epr-21578e (Export)" ) \
1982   ROM_LOAD16_WORD_SWAP_BIOS( 8, "epr-21578e.bin",  0x000000, 0x200000, CRC(087f09a3) SHA1(0418eb2cf9766f0b1b874a4e92528779e22c0a4a) ) \
1983   ROM_SYSTEM_BIOS( 9, "bios9", "epr-21578d (Export)" ) \
1984   ROM_LOAD16_WORD_SWAP_BIOS( 9, "epr-21578d.bin",  0x000000, 0x200000, CRC(dfd5f42a) SHA1(614a0db4743a5e5a206190d6786ade24325afbfd) ) \
1985   ROM_SYSTEM_BIOS( 10, "bios10", "epr-21578b (Export)" ) \
1986   ROM_LOAD16_WORD_SWAP_BIOS( 10, "epr-21578b.bin",  0x000000, 0x200000, CRC(6c9aad83) SHA1(555918de76d8dbee2a97d8a95297ef694b3e803f) ) \
1987   ROM_SYSTEM_BIOS( 11, "bios11", "epr-21577g (USA)" ) \
1988   ROM_LOAD16_WORD_SWAP_BIOS( 11, "epr-21577g.bin",  0x000000, 0x200000, CRC(25f64af7) SHA1(99f9e6cc0642319bd2da492611220540add573e8) ) \
1989   ROM_SYSTEM_BIOS( 12, "bios12", "epr-21577e (USA)" ) \
1990   ROM_LOAD16_WORD_SWAP_BIOS( 12, "epr-21577e.bin",  0x000000, 0x200000, CRC(cf36e97b) SHA1(b085305982e7572e58b03a9d35f17ae319c3bbc6) ) \
1991   ROM_SYSTEM_BIOS( 13, "bios13", "epr-21577d (USA)" ) \
1992   ROM_LOAD16_WORD_SWAP_BIOS( 13, "epr-21577d.bin",  0x000000, 0x200000, CRC(60ddcbbe) SHA1(58b15096d269d6df617ca1810b66b47deb184958) ) \
1993   ROM_SYSTEM_BIOS( 14, "bios14", "Naomi Dev BIOS" ) \
1994   ROM_LOAD16_WORD_SWAP_BIOS( 14,  "dcnaodev.bios", 0x000000, 0x080000, CRC(7a50fab9) SHA1(ef79f448e0bf735d1264ad4f051d24178822110f) ) /* This one comes from a dev / beta board. The eprom was a 27C4096 */
19921995
19931996// bios for House of the Dead 2
19941997#define HOTD2_BIOS \
r6740r6741
20202023   ROM_LOAD16_WORD_SWAP_BIOS( 2, "epr-21576h.bin",  0x000000, 0x200000, CRC(d4895685) SHA1(91424d481ff99a8d3f4c45cea6d3f0eada049a6d) ) \
20212024   ROM_SYSTEM_BIOS( 3, "bios3", "epr-21576d (Japan)" ) \
20222025   ROM_LOAD16_WORD_SWAP_BIOS( 3, "epr-21576d.bin",  0x000000, 0x200000, CRC(3b2afa7b) SHA1(d007e1d321c198a38c5baff86eb2ab84385d150a) ) \
2023   ROM_SYSTEM_BIOS( 4, "bios4", "epr-21578e (Export)" ) \
2024   ROM_LOAD16_WORD_SWAP_BIOS( 4, "epr-21578e.bin",  0x000000, 0x200000, CRC(087f09a3) SHA1(0418eb2cf9766f0b1b874a4e92528779e22c0a4a) ) \
2025   ROM_SYSTEM_BIOS( 5, "bios5", "epr-21578d (Export)" ) \
2026   ROM_LOAD16_WORD_SWAP_BIOS( 5, "epr-21578d.bin",  0x000000, 0x200000, CRC(dfd5f42a) SHA1(614a0db4743a5e5a206190d6786ade24325afbfd) ) \
2027   ROM_SYSTEM_BIOS( 6, "bios6", "epr-21577g (USA)" ) \
2028   ROM_LOAD16_WORD_SWAP_BIOS( 6, "epr-21577g.bin",  0x000000, 0x200000, CRC(25f64af7) SHA1(99f9e6cc0642319bd2da492611220540add573e8) ) \
2029   ROM_SYSTEM_BIOS( 7, "bios7", "epr-21577e (USA)" ) \
2030   ROM_LOAD16_WORD_SWAP_BIOS( 7, "epr-21577e.bin",  0x000000, 0x200000, CRC(cf36e97b) SHA1(b085305982e7572e58b03a9d35f17ae319c3bbc6) ) \
2031   ROM_SYSTEM_BIOS( 8, "bios8", "epr-21577d (USA)" ) \
2032   ROM_LOAD16_WORD_SWAP_BIOS( 8, "epr-21577d.bin",  0x000000, 0x200000, CRC(60ddcbbe) SHA1(58b15096d269d6df617ca1810b66b47deb184958) ) \
2026   ROM_SYSTEM_BIOS( 4, "bios4", "epr-21578h (Export)" ) \
2027   ROM_LOAD16_WORD_SWAP_BIOS( 4, "epr-21578h.ic27", 0x000000, 0x200000, CRC(7b452946) SHA1(8e9f153bbada24b37066dc45b64a7bf0d4f26a9b) ) \
2028   ROM_SYSTEM_BIOS( 5, "bios5", "epr-21578g (Export)" ) \
2029   ROM_LOAD16_WORD_SWAP_BIOS( 5, "epr-21578g.ic27", 0x000000, 0x200000, CRC(55413214) SHA1(bd2748365a9fc1821c9369aa7155d7c41c4df43e) ) \
2030   ROM_SYSTEM_BIOS( 6, "bios6", "epr-21578e (Export)" ) \
2031   ROM_LOAD16_WORD_SWAP_BIOS( 6, "epr-21578e.bin",  0x000000, 0x200000, CRC(087f09a3) SHA1(0418eb2cf9766f0b1b874a4e92528779e22c0a4a) ) \
2032   ROM_SYSTEM_BIOS( 7, "bios7", "epr-21578d (Export)" ) \
2033   ROM_LOAD16_WORD_SWAP_BIOS( 7, "epr-21578d.bin",  0x000000, 0x200000, CRC(dfd5f42a) SHA1(614a0db4743a5e5a206190d6786ade24325afbfd) ) \
2034   ROM_SYSTEM_BIOS( 8, "bios8", "epr-21577g (USA)" ) \
2035   ROM_LOAD16_WORD_SWAP_BIOS( 8, "epr-21577g.bin",  0x000000, 0x200000, CRC(25f64af7) SHA1(99f9e6cc0642319bd2da492611220540add573e8) ) \
2036   ROM_SYSTEM_BIOS( 9, "bios9", "epr-21577e (USA)" ) \
2037   ROM_LOAD16_WORD_SWAP_BIOS( 9, "epr-21577e.bin",  0x000000, 0x200000, CRC(cf36e97b) SHA1(b085305982e7572e58b03a9d35f17ae319c3bbc6) ) \
2038   ROM_SYSTEM_BIOS( 10, "bios10", "epr-21577d (USA)" ) \
2039   ROM_LOAD16_WORD_SWAP_BIOS( 10, "epr-21577d.bin",  0x000000, 0x200000, CRC(60ddcbbe) SHA1(58b15096d269d6df617ca1810b66b47deb184958) ) \
20332040   ROM_REGION( 0x200000, "user2", 0) \
20342041   ROM_LOAD16_WORD_SWAP( "fpr-23489c.ic14", 0x000000, 0x200000, CRC(bc38bea1) SHA1(b36fcc6902f397d9749e9d02de1bbb7a5e29d468) ) \
20352042
r6740r6741
20432050EPR-23607B - NAOMI BOOT ROM 2001 09/10  1.70 (USA)
20442051EPR-23608  - NAOMI BOOT ROM 2001 01/19  1.50 (Export)
20452052EPR-23608B - NAOMI BOOT ROM 2001 09/10  1.70 (Export)
2053EPR-23608C - NAOMI BOOT ROM 2002 07/08  1.8- (Export)
20462054
20472055EPR-23605B, EPR-23607B & EPR-23608B all differ by 8 bytes:
20482056
r6740r6741
20702078   ROM_LOAD16_WORD_SWAP_BIOS( 2, "epr-23605a.bin",   0x000000, 0x200000, CRC(7bc3fc2d) SHA1(a4a9531a7c66ff30046908cf71f6c7b6fb59c392) ) \
20712079   ROM_SYSTEM_BIOS( 3, "bios3", "epr-23605 (Japan)"  ) \
20722080   ROM_LOAD16_WORD_SWAP_BIOS( 3, "epr-23605.bin",    0x000000, 0x200000, CRC(5731e446) SHA1(787b0844fc408cf124c12405c095c59948709ea6) ) \
2073   ROM_SYSTEM_BIOS( 4, "bios4", "epr-23608b (Export)" ) \
2074   ROM_LOAD16_WORD_SWAP_BIOS( 4, "epr-23608b.bin",   0x000000, 0x200000, CRC(a554b1e3) SHA1(343b727a3619d1c75a9b6d4cc156a9050447f155) ) \
2075   ROM_SYSTEM_BIOS( 5, "bios5", "epr-23608 (Export)"  ) \
2076   ROM_LOAD16_WORD_SWAP_BIOS( 5, "epr-23608.bin",    0x000000, 0x200000, CRC(929cc3a6) SHA1(47d00c818de23f733a4a33b1bbc72eb8aa729246) ) \
2077   ROM_SYSTEM_BIOS( 6, "bios6", "epr-23607b (USA)" ) \
2078   ROM_LOAD16_WORD_SWAP_BIOS( 6, "epr-23607b.bin",   0x000000, 0x200000, CRC(f308c5e9) SHA1(5470ab1cee6afecbd8ca8cf40f8fbe4ec2cb1471) ) \
2079   ROM_SYSTEM_BIOS( 7, "bios7", "epr-23607 (USA)"  ) \
2080   ROM_LOAD16_WORD_SWAP_BIOS( 7, "epr-23607.bin",    0x000000, 0x200000, CRC(2b55add2) SHA1(547de5f97d3183c8cd069c4fa3c09f13d8b637d9) ) \
2081   ROM_SYSTEM_BIOS( 4, "bios4", "epr-23608c (Export)" ) \
2082   ROM_LOAD16_WORD_SWAP_BIOS( 4, "epr-23608c.bin",   0x000000, 0x200000, CRC(6ef1dd8e) SHA1(25ef957ec1c58fdaff5e89102002bca6c38832c5) ) \
2083   ROM_SYSTEM_BIOS( 5, "bios5", "epr-23608b (Export)" ) \
2084   ROM_LOAD16_WORD_SWAP_BIOS( 5, "epr-23608b.bin",   0x000000, 0x200000, CRC(a554b1e3) SHA1(343b727a3619d1c75a9b6d4cc156a9050447f155) ) \
2085   ROM_SYSTEM_BIOS( 6, "bios6", "epr-23608 (Export)"  ) \
2086   ROM_LOAD16_WORD_SWAP_BIOS( 6, "epr-23608.bin",    0x000000, 0x200000, CRC(929cc3a6) SHA1(47d00c818de23f733a4a33b1bbc72eb8aa729246) ) \
2087   ROM_SYSTEM_BIOS( 7, "bios7", "epr-23607b (USA)" ) \
2088   ROM_LOAD16_WORD_SWAP_BIOS( 7, "epr-23607b.bin",   0x000000, 0x200000, CRC(f308c5e9) SHA1(5470ab1cee6afecbd8ca8cf40f8fbe4ec2cb1471) ) \
2089   ROM_SYSTEM_BIOS( 8, "bios8", "epr-23607 (USA)"  ) \
2090   ROM_LOAD16_WORD_SWAP_BIOS( 8, "epr-23607.bin",    0x000000, 0x200000, CRC(2b55add2) SHA1(547de5f97d3183c8cd069c4fa3c09f13d8b637d9) ) \
20812091
20822092/* First half is BIOS, second half is game settings and is blanked/reprogrammed by the BIOS as necessary */
20832093#define AW_BIOS \
20842094   ROM_SYSTEM_BIOS( 0, "bios0", "Atomiswave BIOS" ) \
2085   ROM_LOAD16_WORD_SWAP_BIOS( 0, "bios.ic23_l",                         0x000000, 0x010000, BAD_DUMP CRC(e5693ce3) SHA1(1bde3ed87af64b0f675ebd47f12a53e1fc5709c1) ) /* Might be bad.. especially. bytes 0x0000, 0x6000, 0x8000 which gave different reads */
2095   ROM_LOAD16_WORD_SWAP_BIOS( 0, "bios.ic23_l", 0x000000, 0x010000, BAD_DUMP CRC(e5693ce3) SHA1(1bde3ed87af64b0f675ebd47f12a53e1fc5709c1) ) /* Might be bad.. especially. bytes 0x0000, 0x6000, 0x8000 which gave different reads */
20862096
20872097
20882098ROM_START( naomi )
src/mame/drivers/cheekyms.c
r6740r6741
99#include "driver.h"
1010#include "cpu/z80/z80.h"
1111#include "sound/dac.h"
12#include "cheekyms.h"
12#include "includes/cheekyms.h"
1313
1414
1515static INPUT_CHANGED( coin_inserted )
src/mame/drivers/asteroid.c
r6740r6741
189189#include "video/vector.h"
190190#include "video/avgdvg.h"
191191#include "machine/atari_vg.h"
192#include "asteroid.h"
192#include "includes/asteroid.h"
193193#include "sound/discrete.h"
194194#include "sound/pokey.h"
195195
src/mame/drivers/stv.c
r6740r6741
25742574
25752575/* to do, update bios idle skips so they work better with this arrangement.. */
25762576
2577static emu_timer *vblank_out_timer,*scan_timer,*t1_timer;
2577static const device_config *vblank_out_timer,*scan_timer,*t1_timer;
25782578static int h_sync,v_sync;
25792579static int cur_scan;
25802580
r6740r6741
25822582timer_0 = 0; \
25832583{ \
25842584   /*if(LOG_IRQ) logerror ("Interrupt: VBlank-OUT Vector 0x41 Level 0x0e\n");*/ \
2585   cputag_set_input_line_and_vector(machine, "maincpu", 0xe, (stv_irq.vblank_out) ? HOLD_LINE : CLEAR_LINE , 0x41); \
2585   cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xe, (stv_irq.vblank_out) ? HOLD_LINE : CLEAR_LINE , 0x41); \
25862586} \
25872587
25882588#define VBLANK_IN_IRQ \
r6740r6741
25952595timer_1 = stv_scu[37] & 0x1ff; \
25962596{ \
25972597   /*if(LOG_IRQ) logerror ("Interrupt: HBlank-In at scanline %04x, Vector 0x42 Level 0x0d\n",scanline);*/ \
2598   cputag_set_input_line_and_vector(machine, "maincpu", 0xd, (stv_irq.hblank_in) ? HOLD_LINE : CLEAR_LINE, 0x42); \
2598   cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xd, (stv_irq.hblank_in) ? HOLD_LINE : CLEAR_LINE, 0x42); \
25992599} \
26002600
26012601#define TIMER_0_IRQ \
26022602if(timer_0 == (stv_scu[36] & 0x3ff)) \
26032603{ \
26042604   /*if(LOG_IRQ) logerror ("Interrupt: Timer 0 at scanline %04x, Vector 0x43 Level 0x0c\n",scanline);*/ \
2605   cputag_set_input_line_and_vector(machine, "maincpu", 0xc, (stv_irq.timer_0) ? HOLD_LINE : CLEAR_LINE, 0x43 ); \
2605   cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xc, (stv_irq.timer_0) ? HOLD_LINE : CLEAR_LINE, 0x43 ); \
26062606} \
26072607
26082608#define TIMER_1_IRQ   \
r6740r6741
26112611   if(!(stv_scu[38] & 0x80)) \
26122612   { \
26132613      /*if(LOG_IRQ) logerror ("Interrupt: Timer 1 at point %04x, Vector 0x44 Level 0x0b\n",point);*/ \
2614      cputag_set_input_line_and_vector(machine, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \
2614      cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \
26152615   } \
26162616   else \
26172617   { \
26182618      if((timer_0) == (stv_scu[36] & 0x3ff)) \
26192619      { \
26202620         /*if(LOG_IRQ) logerror ("Interrupt: Timer 1 at point %04x, Vector 0x44 Level 0x0b\n",point);*/ \
2621         cputag_set_input_line_and_vector(machine, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \
2621         cputag_set_input_line_and_vector(timer->machine, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \
26222622      } \
26232623   } \
26242624} \
r6740r6741
26282628   cputag_set_input_line_and_vector(machine, "maincpu", 2, (stv_irq.vdp1_end) ? HOLD_LINE : CLEAR_LINE, 0x4d); \
26292629} \
26302630
2631static TIMER_CALLBACK( hblank_in_irq )
2631static TIMER_DEVICE_CALLBACK( hblank_in_irq )
26322632{
26332633   int scanline = param;
26342634
2635//  h = video_screen_get_height(machine->primary_screen);
2636//  w = video_screen_get_width(machine->primary_screen);
2635//  h = video_screen_get_height(timer->machine->primary_screen);
2636//  w = video_screen_get_width(timer->machine->primary_screen);
26372637
26382638   HBLANK_IN_IRQ;
26392639   TIMER_0_IRQ;
r6740r6741
26412641   if(scanline+1 < v_sync)
26422642   {
26432643      if(stv_irq.hblank_in || stv_irq.timer_0)
2644         timer_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline+1, h_sync), scanline+1);
2644         timer_device_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline+1, h_sync), scanline+1);
26452645      /*set the first Timer-1 event*/
26462646      cur_scan = scanline+1;
26472647      if(stv_irq.timer_1)
2648         timer_adjust_oneshot(t1_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline+1, timer_1), scanline+1);
2648         timer_device_adjust_oneshot(t1_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline+1, timer_1), scanline+1);
26492649   }
26502650
26512651   timer_0++;
26522652}
26532653
2654static TIMER_CALLBACK( timer1_irq )
2654static TIMER_DEVICE_CALLBACK( timer1_irq )
26552655{
26562656   int scanline = param;
26572657
26582658   TIMER_1_IRQ;
26592659
26602660   if(stv_irq.timer_1)
2661      timer_adjust_oneshot(t1_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline+1, timer_1), scanline+1);
2661      timer_device_adjust_oneshot(t1_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, scanline+1, timer_1), scanline+1);
26622662}
26632663
26642664static TIMER_CALLBACK( vdp1_irq )
r6740r6741
26662666   VDP1_IRQ;
26672667}
26682668
2669static TIMER_CALLBACK( vblank_out_irq )
2669static TIMER_DEVICE_CALLBACK( vblank_out_irq )
26702670{
26712671   VBLANK_OUT_IRQ;
26722672}
r6740r6741
26842684
26852685   /*Next V-Blank-OUT event*/
26862686   if(stv_irq.vblank_out)
2687      timer_adjust_oneshot(vblank_out_timer,video_screen_get_time_until_pos(device->machine->primary_screen, 0, 0), 0);
2687      timer_device_adjust_oneshot(vblank_out_timer,video_screen_get_time_until_pos(device->machine->primary_screen, 0, 0), 0);
26882688   /*Set the first Hblank-IN event*/
26892689   if(stv_irq.hblank_in || stv_irq.timer_0 || stv_irq.timer_1)
2690      timer_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(device->machine->primary_screen, 0, h_sync), 0);
2690      timer_device_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(device->machine->primary_screen, 0, h_sync), 0);
26912691
26922692   /*TODO: timing of this one (related to the VDP1 speed)*/
26932693   /*      (NOTE: value shouldn't be at h_sync/v_sync position (will break shienryu))*/
r6740r6741
27172717   stvcd_reset(machine);
27182718
27192719   /* set the first scanline 0 timer to go off */
2720   scan_timer = timer_alloc(machine, hblank_in_irq, NULL);
2721   t1_timer = timer_alloc(machine, timer1_irq,NULL);
2722   vblank_out_timer = timer_alloc(machine, vblank_out_irq,NULL);
2723   timer_adjust_oneshot(vblank_out_timer,video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
2724   timer_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(machine->primary_screen, 224, 352), 0);
2720   scan_timer = devtag_get_device(machine, "scan_timer");
2721   t1_timer = devtag_get_device(machine, "t1_timer");
2722   vblank_out_timer = devtag_get_device(machine, "vbout_timer");
2723   timer_device_adjust_oneshot(vblank_out_timer,video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
2724   timer_device_adjust_oneshot(scan_timer, video_screen_get_time_until_pos(machine->primary_screen, 224, 352), 0);
27252725}
27262726
27272727
r6740r6741
27442744   MDRV_MACHINE_RESET(stv)
27452745   MDRV_NVRAM_HANDLER(stv) /* Actually 93c45 */
27462746
2747   MDRV_TIMER_ADD("scan_timer", hblank_in_irq)
2748   MDRV_TIMER_ADD("t1_timer", timer1_irq)
2749   MDRV_TIMER_ADD("vbout_timer", vblank_out_irq)
2750   MDRV_TIMER_ADD("sector_timer", stv_sector_cb)
2751
27472752   /* video hardware */
27482753   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK)
27492754
r6740r6741
28002805
28012806#define STV_BIOS \
28022807   ROM_REGION( 0x080000, "maincpu", 0 ) /* SH2 code */ \
2803   ROM_SYSTEM_BIOS( 0, "jp",   "EPR-20091 (Japan 97/08/21)" ) \
2804   ROM_LOAD16_WORD_SWAP_BIOS( 0, "epr-20091.ic8",   0x000000, 0x080000, CRC(59ed40f4) SHA1(eff0f54c70bce05ff3a289bf30b1027e1c8cd117) ) \
2805   ROM_SYSTEM_BIOS( 1, "jp1",  "EPR-19730 (Japan 97/02/17)" ) \
2806   ROM_LOAD16_WORD_SWAP_BIOS( 1, "epr-19730.ic8",   0x000000, 0x080000, CRC(d0e0889d) SHA1(fae53107c894e0c41c49e191dbe706c9cd6e50bd) ) \
2807   ROM_SYSTEM_BIOS( 2, "jp2",  "EPR-17951A (Japan 95/04/25)" ) \
2808   ROM_LOAD16_WORD_SWAP_BIOS( 2, "epr-17951a.ic8",  0x000000, 0x080000, CRC(2672f9d8) SHA1(63cf4a6432f6c87952f9cf3ab0f977aed2367303) ) \
2809   ROM_SYSTEM_BIOS( 3, "jp3",  "EPR-17740 (Japan 95/01/31)" ) \
2810   ROM_LOAD16_WORD_SWAP_BIOS( 3, "epr-17740.ic8",   0x000000, 0x080000, CRC(5c5aa63d) SHA1(06860d96923b81afbc21e0ad32ee19487d8ff6e7) ) \
2811   ROM_SYSTEM_BIOS( 4, "euro", "EPR-17954A (Europe 95/04/25)" ) \
2812   ROM_LOAD16_WORD_SWAP_BIOS( 4, "epr-17954a.ic8",  0x000000, 0x080000, CRC(f7722da3) SHA1(af79cff317e5b57d49e463af16a9f616ed1eee08) ) \
2813   ROM_SYSTEM_BIOS( 5, "us",   "EPR-17952A (USA 95/04/25)" ) \
2814   ROM_LOAD16_WORD_SWAP_BIOS( 5, "epr-17952a.ic8",  0x000000, 0x080000, CRC(d1be2adf) SHA1(eaf1c3e5d602e1139d2090a78d7e19f04f916794) ) \
2815   ROM_SYSTEM_BIOS( 6, "tw",   "EPR-17953A (Taiwan 95/04/25)" ) \
2816   ROM_LOAD16_WORD_SWAP_BIOS( 6, "epr-17953a.ic8",  0x000000, 0x080000, CRC(a4c47570) SHA1(9efc73717ec8a13417e65c54344ded9fc25bf5ef) ) \
2817   ROM_SYSTEM_BIOS( 7, "debug","Debug (95/01/13)" ) \
2818   ROM_LOAD16_WORD_SWAP_BIOS( 7, "stv110.bin",      0x000000, 0x080000, CRC(3dfeda92) SHA1(8eb33192a57df5f3a1dfb57263054867c6b2db6d) ) \
2819   ROM_SYSTEM_BIOS( 8, "dev",  "Development (bios 1.061)" ) \
2820   ROM_LOAD16_WORD_SWAP_BIOS( 8, "stv1061.bin",     0x000000, 0x080000, CRC(728dbca3) SHA1(0ed2030177f0aa8285645c395ae9ad9f568ab1d6) ) \
2808   ROM_SYSTEM_BIOS( 0,  "jp",    "EPR-20091 (Japan 97/08/21)" ) \
2809   ROM_LOAD16_WORD_SWAP_BIOS( 0,  "epr-20091.ic8",   0x000000, 0x080000, CRC(59ed40f4) SHA1(eff0f54c70bce05ff3a289bf30b1027e1c8cd117) ) \
2810   ROM_SYSTEM_BIOS( 1,  "jp1",   "EPR-19730 (Japan 97/02/17)" ) \
2811   ROM_LOAD16_WORD_SWAP_BIOS( 1,  "epr-19730.ic8",   0x000000, 0x080000, CRC(d0e0889d) SHA1(fae53107c894e0c41c49e191dbe706c9cd6e50bd) ) \
2812   ROM_SYSTEM_BIOS( 2,  "jp2",   "EPR-17951A (Japan 95/04/25)" ) \
2813   ROM_LOAD16_WORD_SWAP_BIOS( 2,  "epr-17951a.ic8",  0x000000, 0x080000, CRC(2672f9d8) SHA1(63cf4a6432f6c87952f9cf3ab0f977aed2367303) ) \
2814   ROM_SYSTEM_BIOS( 3,  "jp3",   "STVB1.11J (Japan 95/02/20)" ) \
2815   ROM_LOAD16_WORD_SWAP_BIOS( 3,  "stvb111j.ic8",    0x000000, 0x080000, CRC(3e23c81f) SHA1(f9b282fd27693e9891843597b2e1823da3d23c7b) ) \
2816   ROM_SYSTEM_BIOS( 4,  "jp4",   "EPR-17740 (Japan 95/01/31)" ) \
2817   ROM_LOAD16_WORD_SWAP_BIOS( 4,  "epr-17740.ic8",   0x000000, 0x080000, CRC(5c5aa63d) SHA1(06860d96923b81afbc21e0ad32ee19487d8ff6e7) ) \
2818   ROM_SYSTEM_BIOS( 5,  "euro",  "EPR-17954A (Europe 95/04/25)" ) \
2819   ROM_LOAD16_WORD_SWAP_BIOS( 5,  "epr-17954a.ic8",  0x000000, 0x080000, CRC(f7722da3) SHA1(af79cff317e5b57d49e463af16a9f616ed1eee08) ) \
2820   ROM_SYSTEM_BIOS( 6,  "us",    "EPR-17952A (USA 95/04/25)" ) \
2821   ROM_LOAD16_WORD_SWAP_BIOS( 6,  "epr-17952a.ic8",  0x000000, 0x080000, CRC(d1be2adf) SHA1(eaf1c3e5d602e1139d2090a78d7e19f04f916794) ) \
2822   ROM_SYSTEM_BIOS( 7,  "tw",    "EPR-17953A (Taiwan 95/04/25)" ) \
2823   ROM_LOAD16_WORD_SWAP_BIOS( 7,  "epr-17953a.ic8",  0x000000, 0x080000, CRC(a4c47570) SHA1(9efc73717ec8a13417e65c54344ded9fc25bf5ef) ) \
2824   ROM_SYSTEM_BIOS( 8,  "tw1",   "STVB1.11T (Taiwan 95/02/20)" ) \
2825   ROM_LOAD16_WORD_SWAP_BIOS( 8,  "stvb111t.ic8",    0x000000, 0x080000, CRC(02daf123) SHA1(23185beb1ce9c09b8719e57d1adb7b28c8141fd5) ) \
2826   ROM_SYSTEM_BIOS( 9,  "debug", "Debug (95/01/13)" ) \
2827   ROM_LOAD16_WORD_SWAP_BIOS( 9,  "stv110.bin",      0x000000, 0x080000, CRC(3dfeda92) SHA1(8eb33192a57df5f3a1dfb57263054867c6b2db6d) ) \
2828   ROM_SYSTEM_BIOS( 10, "dev",   "Development (bios 1.061)" ) \
2829   ROM_LOAD16_WORD_SWAP_BIOS( 10, "stv1061.bin",     0x000000, 0x080000, CRC(728dbca3) SHA1(0ed2030177f0aa8285645c395ae9ad9f568ab1d6) ) \
28212830   \
28222831   ROM_REGION( 0x080000, "slave", 0 ) /* SH2 code */ \
28232832   ROM_COPY( "maincpu",0,0,0x080000) \
src/mame/drivers/bishi.c
r6740r6741
8888
8989#include "driver.h"
9090#include "deprecat.h"
91#include "video/konamiic.h"
91#include "video/konicdev.h"
9292#include "cpu/m68000/m68000.h"
9393#include "sound/ymz280b.h"
9494
9595VIDEO_START(bishi);
9696VIDEO_UPDATE(bishi);
9797
98extern void bishi_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags);
99
100
98101static UINT16 cur_control, cur_control2;
99102
100103static MACHINE_START( bishi )
r6740r6741
146149
147150static READ16_HANDLER( bishi_K056832_rom_r )
148151{
152   const device_config *k056832 = devtag_get_device(space->machine, "k056832");
149153   UINT16 ouroffs;
150154
151   ouroffs = (offset>>1)*8;
152   if (offset&1)
153   {
155   ouroffs = (offset >> 1) * 8;
156   if (offset & 1)
154157      ouroffs++;
155   }
156158
157159   if (cur_control2 & 0x1000)
158   {
159160      ouroffs += 4;
160   }
161161
162   return K056832_bishi_rom_word_r(space, ouroffs, mem_mask);
162   return k056832_bishi_rom_word_r(k056832, ouroffs, mem_mask);
163163}
164164
165165static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 )
r6740r6741
171171   AM_RANGE(0x800008, 0x800009) AM_READ_PORT("INPUTS")
172172   AM_RANGE(0x810000, 0x810003) AM_WRITE(control2_w)      // bank switch for K056832 character ROM test
173173   AM_RANGE(0x820000, 0x820001) AM_WRITENOP         // lamps (see lamp test in service menu)
174   AM_RANGE(0x830000, 0x83003f) AM_WRITE(K056832_word_w)
175   AM_RANGE(0x840000, 0x840007) AM_WRITE(K056832_b_word_w)   // VSCCS
176   AM_RANGE(0x850000, 0x85001f) AM_WRITE(K054338_word_w)   // CLTC
177   AM_RANGE(0x870000, 0x8700ff) AM_WRITE(K055555_word_w)   // PCU2
174   AM_RANGE(0x830000, 0x83003f) AM_DEVWRITE("k056832", k056832_word_w)
175   AM_RANGE(0x840000, 0x840007) AM_DEVWRITE("k056832", k056832_b_word_w)   // VSCCS
176   AM_RANGE(0x850000, 0x85001f) AM_DEVWRITE("k054338", k054338_word_w)   // CLTC
177   AM_RANGE(0x870000, 0x8700ff) AM_DEVWRITE("k055555", k055555_word_w)   // PCU2
178178   AM_RANGE(0x880000, 0x880003) AM_DEVREADWRITE8("ymz", ymz280b_r, ymz280b_w, 0xff00)
179   AM_RANGE(0xa00000, 0xa01fff) AM_READWRITE(K056832_ram_word_r, K056832_ram_word_w)   // Graphic planes
179   AM_RANGE(0xa00000, 0xa01fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w)   // Graphic planes
180180   AM_RANGE(0xb00000, 0xb03fff) AM_RAM_WRITE(paletteram16_xbgr_word_be_w) AM_BASE_GENERIC(paletteram)
181181   AM_RANGE(0xb04000, 0xb047ff) AM_READ(bishi_mirror_r)   // bug in the ram/rom test?
182182   AM_RANGE(0xc00000, 0xc01fff) AM_READ(bishi_K056832_rom_r)
r6740r6741
397397   sound_irq_gen
398398};
399399
400
401static const k056832_interface bishi_k056832_intf =
402{
403   "gfx1", 0,
404   K056832_BPP_8,
405   1, 0,
406   KONAMI_ROM_DEINTERLEAVE_NONE,
407   bishi_tile_callback, "none"
408};
409
410static const k054338_interface bishi_k054338_intf =
411{
412   "screen",
413   0,
414   "none"
415};
416
400417static MACHINE_DRIVER_START( bishi )
401418
402419   /* basic machine hardware */
r6740r6741
422439   MDRV_VIDEO_START(bishi)
423440   MDRV_VIDEO_UPDATE(bishi)
424441
442   MDRV_K056832_ADD("k056832", bishi_k056832_intf)
443   MDRV_K054338_ADD("k054338", bishi_k054338_intf)
444   MDRV_K055555_ADD("k055555")
445
425446   /* sound hardware */
426447   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
427448
src/mame/drivers/1942.c
r6740r6741
6767#include "cpu/z80/z80.h"
6868#include "deprecat.h"
6969#include "sound/ay8910.h"
70#include "1942.h"
70#include "includes/1942.h"
7171
7272
7373static WRITE8_HANDLER( c1942_bankswitch_w )
src/mame/drivers/poolshrk.c
r6740r6741
66
77#include "driver.h"
88#include "cpu/m6800/m6800.h"
9#include "poolshrk.h"
9#include "includes/poolshrk.h"
1010#include "sound/discrete.h"
1111
1212
src/mame/drivers/bloodbro.c
r6740r6741
566566   ROM_LOAD( "bb_08.bin",    0x00000, 0x20000, CRC(deb1b975) SHA1(08f2e9a0a23171201b71d381d091edcd3787c287) )
567567ROM_END
568568
569ROM_START( bloodbrob )
570   ROM_REGION( 0x80000, "maincpu", 0 )
571   ROM_LOAD16_BYTE( "bloodbros02.bin",    0x00001, 0x20000, CRC(204dca6e) SHA1(f04cb2116d699ac2deec2d55597beb5d7b3dc793) )
572   ROM_LOAD16_BYTE( "bloodbros01.bin",    0x00000, 0x20000, CRC(ac6719e7) SHA1(bcefd61ed5d2f5eeb4424243f03037c7d123b9f6) )
573   ROM_LOAD16_BYTE( "bb_04.bin",    0x40001, 0x20000, CRC(fd951c2c) SHA1(f4031bf303c67c82f2f78f7456f78382d8c1ac85) )
574   ROM_LOAD16_BYTE( "bb_03.bin",    0x40000, 0x20000, CRC(18d3c460) SHA1(93b86af1199f0fedeaf1fe64d27ffede4b819e42) )
575
576   ROM_REGION( 0x20000, "audiocpu", 0 )
577   ROM_LOAD( "bb_07.bin",    0x000000, 0x08000, CRC(411b94e8) SHA1(6968441f64212c0935afeca68f07deaadf86d614) )
578   ROM_CONTINUE(             0x010000, 0x08000 )
579   ROM_COPY( "audiocpu", 0, 0x018000, 0x08000 )
580
581   ROM_REGION( 0x20000, "gfx1", 0 )
582   ROM_LOAD( "bb_05.bin",    0x00000, 0x10000, CRC(04ba6d19) SHA1(7333075c3323756d51917418b5234d785a9bee00) )   /* characters */
583   ROM_LOAD( "bb_06.bin",    0x10000, 0x10000, CRC(7092e35b) SHA1(659d30b2e2fd9ffa34a47e98193c8f0a87ac1315) )
584
585   ROM_REGION( 0x100000, "gfx2", 0 )
586   ROM_LOAD( "bloodb.bk",   0x00000, 0x100000, CRC(1aa87ee6) SHA1(e7843c1e8a0f3a685f0b5d6e3a2eb3176c410847) )   /* Background+Foreground */
587
588   ROM_REGION( 0x100000, "gfx3", 0 )
589   ROM_LOAD( "bloodb.obj",   0x00000, 0x100000, CRC(d27c3952) SHA1(de7306432b682f238b911507ad7aa2fa8acbee80) )   /* sprites */
590
591   ROM_REGION( 0x40000, "oki", 0 )   /* ADPCM samples */
592   ROM_LOAD( "bb_08.bin",    0x00000, 0x20000, CRC(deb1b975) SHA1(08f2e9a0a23171201b71d381d091edcd3787c287) )
593ROM_END
594
595
569596ROM_START( weststry )
570597   ROM_REGION( 0x80000, "maincpu", 0 )   /* 64k for cpu code */
571598   ROM_LOAD16_BYTE( "ws13.bin",    0x00001, 0x20000, CRC(158e302a) SHA1(52cc1bf526424ff025a6b79f3fc7bba4b9bbfcbb) )
r6740r6741
655682
656683GAME( 1990, bloodbro, 0,        bloodbro, bloodbro, 0,        ROT0,   "Tad", "Blood Bros. (set 1)", GAME_NO_COCKTAIL )
657684GAME( 1990, bloodbroa,bloodbro, bloodbro, bloodbro, 0,        ROT0,   "Tad", "Blood Bros. (set 2)", GAME_NO_COCKTAIL )
685GAME( 1990, bloodbrob,bloodbro, bloodbro, bloodbro, 0,        ROT0,   "Tad", "Blood Bros. (set 3)", GAME_NO_COCKTAIL )
658686GAME( 1990, weststry, bloodbro, weststry, weststry, weststry, ROT0,   "bootleg", "West Story", GAME_NO_COCKTAIL | GAME_NO_SOUND )
659687GAME( 1990, skysmash, 0,        skysmash, skysmash, 0,        ROT270, "Nihon System", "Sky Smasher", 0 )
src/mame/drivers/vegaeo.c
r6740r6741
1616#include "cpu/e132xs/e132xs.h"
1717#include "deprecat.h"
1818#include "machine/at28c16.h"
19#include "eolithsp.h"
19#include "includes/eolithsp.h"
2020
2121static UINT32 *vega_vram;
2222static UINT8 vega_vbuffer = 0;
src/mame/drivers/galaxia.c
r6740r6741
234234static const s2636_interface s2636_0_config =
235235{
236236   "screen",
237   0xff,
237   0x100,
238238   3, -27
239239};
240240
241241static const s2636_interface s2636_1_config =
242242{
243243   "screen",
244   0xff,
244   0x100,
245245   3, -27
246246};
247247
248248static const s2636_interface s2636_2_config =
249249{
250250   "screen",
251   0xff,
251   0x100,
252252   3, -27
253253};
254254
src/mame/drivers/gridlee.c
r6740r6741
7979
8080#include "driver.h"
8181#include "cpu/m6809/m6809.h"
82#include "gridlee.h"
83#include "balsente.h"
82#include "includes/gridlee.h"
83#include "includes/balsente.h"
8484#include "sound/samples.h"
8585
8686
src/mame/drivers/realbrk.c
r6740r6741
4545#include "cpu/m68000/m68000.h"
4646#include "deprecat.h"
4747#include "machine/tmp68301.h"
48#include "realbrk.h"
48#include "includes/realbrk.h"
4949#include "sound/2413intf.h"
5050#include "sound/ymz280b.h"
5151
r6740r6741
680680   MDRV_CPU_PROGRAM_MAP(realbrk_mem)
681681   MDRV_CPU_VBLANK_INT("screen", realbrk_interrupt)
682682
683   MDRV_MACHINE_START( tmp68301 )
683684   MDRV_MACHINE_RESET( tmp68301 )
684685
685686   /* video hardware */
src/mame/drivers/carjmbre.c
r6740r6741
4545#include "driver.h"
4646#include "cpu/z80/z80.h"
4747#include "sound/ay8910.h"
48#include "carjmbre.h"
48#include "includes/carjmbre.h"
4949
5050/*************************************
5151 *
src/mame/drivers/superchs.c
r6740r6741
348348                 MACHINE DRIVERS
349349***********************************************************/
350350
351static MACHINE_RESET( superchs )
352{
353   taito_f3_soundsystem_reset(machine);
354
355   f3_68681_reset(machine);
356}
357
358351static const eeprom_interface superchs_eeprom_interface =
359352{
360353   6,            /* address bits */
r6740r6741
399392   MDRV_CPU_PROGRAM_MAP(superchs_map)
400393   MDRV_CPU_VBLANK_INT("screen", irq2_line_hold)/* VBL */
401394
402   TAITO_F3_SOUND_SYSTEM_CPU(16000000)
403
404395   MDRV_CPU_ADD("sub", M68000, 16000000)   /* 16 MHz */
405396   MDRV_CPU_PROGRAM_MAP(superchs_cpub_map)
406397   MDRV_CPU_VBLANK_INT("screen", irq4_line_hold)/* VBL */
407398
408399   MDRV_QUANTUM_TIME(HZ(480))   /* CPU slices - Need to interleave Cpu's 1 & 3 */
409400
410   MDRV_MACHINE_RESET(superchs)
411401   MDRV_NVRAM_HANDLER(superchs)
412402
413403   /* video hardware */
r6740r6741
425415   MDRV_VIDEO_UPDATE(superchs)
426416
427417   /* sound hardware */
428   TAITO_F3_SOUND_SYSTEM_ES5505(30476100/2)
418   MDRV_IMPORT_FROM(taito_f3_sound)
429419MACHINE_DRIVER_END
430420
431421/***************************************************************************/
src/mame/drivers/mainevt.c
r6740r6741
2323#include "driver.h"
2424#include "cpu/z80/z80.h"
2525#include "cpu/hd6309/hd6309.h"
26#include "video/konamiic.h"
26#include "video/konicdev.h"
2727#include "cpu/m6809/m6809.h"
2828#include "sound/2151intf.h"
2929#include "sound/k007232.h"
3030#include "sound/upd7759.h"
31#include "konamipt.h"
31#include "includes/konamipt.h"
3232
3333VIDEO_UPDATE( mainevt );
3434VIDEO_UPDATE( dv );
3535VIDEO_START( mainevt );
3636VIDEO_START( dv );
3737
38extern void mainevt_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
39extern void dv_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
40extern void mainevt_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask,int *shadow);
41extern void dv_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow);
3842
3943
4044static INTERRUPT_GEN( mainevt_interrupt )
4145{
42   if (K052109_is_IRQ_enabled())
46   const device_config *k052109 = devtag_get_device(device->machine, "k052109");
47
48   if (k052109_is_irq_enabled(k052109))
4349      irq0_line_hold(device);
4450}
4551
r6740r6741
6066
6167static WRITE8_HANDLER( mainevt_bankswitch_w )
6268{
69   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
6370   UINT8 *RAM = memory_region(space->machine, "maincpu");
6471   int bankaddress;
6572
r6740r6741
7178//  palette_selected = data & 0x20;
7279
7380   /* bit 6 = enable char ROM reading through the video RAM */
74   K052109_set_RMRD_line((data & 0x40) ? ASSERT_LINE : CLEAR_LINE);
81   k052109_set_rmrd_line(k052109, (data & 0x40) ? ASSERT_LINE : CLEAR_LINE);
7582
7683   /* bit 7 = NINITSET (unknown) */
7784
r6740r6741
139146   k007232_set_bank( device, bank_A, bank_B );
140147}
141148
149static READ8_HANDLER( k052109_051960_r )
150{
151   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
152   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
142153
154   if (k052109_get_rmrd_line(k052109) == CLEAR_LINE)
155   {
156      if (offset >= 0x3800 && offset < 0x3808)
157         return k051937_r(k051960, offset - 0x3800);
158      else if (offset < 0x3c00)
159         return k052109_r(k052109, offset);
160      else
161         return k051960_r(k051960, offset - 0x3c00);
162   }
163   else
164      return k052109_r(k052109, offset);
165}
166
167static WRITE8_HANDLER( k052109_051960_w )
168{
169   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
170   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
171
172   if (offset >= 0x3800 && offset < 0x3808)
173      k051937_w(k051960, offset - 0x3800, data);
174   else if (offset < 0x3c00)
175      k052109_w(k052109, offset, data);
176   else
177      k051960_w(k051960, offset - 0x3c00, data);
178}
179
180
143181static ADDRESS_MAP_START( mainevt_map, ADDRESS_SPACE_PROGRAM, 8 )
144182   AM_RANGE(0x1f80, 0x1f80) AM_WRITE(mainevt_bankswitch_w)
145183   AM_RANGE(0x1f84, 0x1f84) AM_WRITE(soundlatch_w)            /* probably */
r6740r6741
156194   AM_RANGE(0x1f9a, 0x1f9a) AM_READ_PORT("P4")
157195   AM_RANGE(0x1f9b, 0x1f9b) AM_READ_PORT("DSW2")
158196
159   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(K052109_051960_r,K052109_051960_w)
197   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(k052109_051960_r, k052109_051960_w)
160198
161199   AM_RANGE(0x4000, 0x5dff) AM_RAM
162200   AM_RANGE(0x5e00, 0x5fff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_be_w) AM_BASE_GENERIC(paletteram)
r6740r6741
178216   AM_RANGE(0x1f97, 0x1f97) AM_READ_PORT("DSW1")
179217   AM_RANGE(0x1f98, 0x1f98) AM_READ_PORT("DSW3")
180218   AM_RANGE(0x1f9b, 0x1f9b) AM_READ_PORT("DSW2")
181   AM_RANGE(0x1fa0, 0x1fbf) AM_READWRITE(K051733_r,K051733_w)
219   AM_RANGE(0x1fa0, 0x1fbf) AM_DEVREADWRITE("k051733", k051733_r, k051733_w)
182220
183   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(K052109_051960_r,K052109_051960_w)
221   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(k052109_051960_r, k052109_051960_w)
184222
185223   AM_RANGE(0x4000, 0x5dff) AM_RAM
186224   AM_RANGE(0x5e00, 0x5fff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_be_w) AM_BASE_GENERIC(paletteram)
r6740r6741
373411   volume_callback   /* external port callback */
374412};
375413
414static const k052109_interface mainevt_k052109_intf =
415{
416   "gfx1", 0,
417   NORMAL_PLANE_ORDER,
418   KONAMI_ROM_DEINTERLEAVE_2,
419   mainevt_tile_callback
420};
421
422static const k051960_interface mainevt_k051960_intf =
423{
424   "gfx2", 1,
425   NORMAL_PLANE_ORDER,
426   KONAMI_ROM_DEINTERLEAVE_2,
427   mainevt_sprite_callback
428};
429
376430static MACHINE_DRIVER_START( mainevt )
377431
378432   /* basic machine hardware */
r6740r6741
399453   MDRV_VIDEO_START(mainevt)
400454   MDRV_VIDEO_UPDATE(mainevt)
401455
456   MDRV_K052109_ADD("k052109", mainevt_k052109_intf)
457   MDRV_K051960_ADD("k051960", mainevt_k051960_intf)
458
402459   /* sound hardware */
403460   MDRV_SPEAKER_STANDARD_MONO("mono")
404461
r6740r6741
412469MACHINE_DRIVER_END
413470
414471
472static const k052109_interface dv_k052109_intf =
473{
474   "gfx1", 0,
475   NORMAL_PLANE_ORDER,
476   KONAMI_ROM_DEINTERLEAVE_2,
477   dv_tile_callback
478};
479
480static const k051960_interface dv_k051960_intf =
481{
482   "gfx2", 1,
483   NORMAL_PLANE_ORDER,
484   KONAMI_ROM_DEINTERLEAVE_2,
485   dv_sprite_callback
486};
487
415488static MACHINE_DRIVER_START( devstors )
416489
417490   /* basic machine hardware */
r6740r6741
438511   MDRV_VIDEO_START(dv)
439512   MDRV_VIDEO_UPDATE(dv)
440513
514   MDRV_K052109_ADD("k052109", dv_k052109_intf)
515   MDRV_K051960_ADD("k051960", dv_k051960_intf)
516   MDRV_K051733_ADD("k051733")
517
441518   /* sound hardware */
442519   MDRV_SPEAKER_STANDARD_MONO("mono")
443520
r6740r6741
684761
685762
686763
687static DRIVER_INIT( mainevt )
688{
689   konami_rom_deinterleave_2(machine, "gfx1");
690   konami_rom_deinterleave_2(machine, "gfx2");
691}
692
693
694
695GAME( 1988, mainevt,  0,        mainevt,  mainevt,  mainevt, ROT0,  "Konami", "The Main Event (4 Players ver. Y)", 0 )
696GAME( 1988, mainevto, mainevt,  mainevt,  mainevt,  mainevt, ROT0,  "Konami", "The Main Event (4 Players ver. F)", 0 )
697GAME( 1988, mainevt2p,mainevt,  mainevt,  mainev2p, mainevt, ROT0,  "Konami", "The Main Event (2 Players ver. X)", 0 )
698GAME( 1988, ringohja, mainevt,  mainevt,  mainev2p, mainevt, ROT0,  "Konami", "Ring no Ohja (Japan 2 Players ver. N)", 0 )
699GAME( 1988, devstors, 0,        devstors, devstors, mainevt, ROT90, "Konami", "Devastators (ver. Z)", 0 )
700GAME( 1988, devstors2,devstors, devstors, devstor2, mainevt, ROT90, "Konami", "Devastators (ver. X)", 0 )
701GAME( 1988, devstors3,devstors, devstors, devstors, mainevt, ROT90, "Konami", "Devastators (ver. V)", 0 )
702GAME( 1988, garuka,   devstors, devstors, devstor2, mainevt, ROT90, "Konami", "Garuka (Japan ver. W)", 0 )
764GAME( 1988, mainevt,  0,        mainevt,  mainevt,  0, ROT0,  "Konami", "The Main Event (4 Players ver. Y)", 0 )
765GAME( 1988, mainevto, mainevt,  mainevt,  mainevt,  0, ROT0,  "Konami", "The Main Event (4 Players ver. F)", 0 )
766GAME( 1988, mainevt2p,mainevt,  mainevt,  mainev2p, 0, ROT0,  "Konami", "The Main Event (2 Players ver. X)", 0 )
767GAME( 1988, ringohja, mainevt,  mainevt,  mainev2p, 0, ROT0,  "Konami", "Ring no Ohja (Japan 2 Players ver. N)", 0 )
768GAME( 1988, devstors, 0,        devstors, devstors, 0, ROT90, "Konami", "Devastators (ver. Z)", 0 )
769GAME( 1988, devstors2,devstors, devstors, devstor2, 0, ROT90, "Konami", "Devastators (ver. X)", 0 )
770GAME( 1988, devstors3,devstors, devstors, devstors, 0, ROT90, "Konami", "Devastators (ver. V)", 0 )
771GAME( 1988, garuka,   devstors, devstors, devstor2, 0, ROT90, "Konami", "Garuka (Japan ver. W)", 0 )
src/mame/drivers/deco156.c
r6740r6741
1414
1515#define DE156CPU ARM
1616#include "driver.h"
17#include "decocrpt.h"
18#include "deco32.h"
17#include "includes/decocrpt.h"
18#include "includes/deco32.h"
1919#include "machine/eepromdev.h"
2020#include "sound/okim6295.h"
2121#include "sound/ymz280b.h"
2222#include "cpu/arm/arm.h"
23#include "deco16ic.h"
23#include "includes/deco16ic.h"
2424
2525static int simpl156_bank_callback(const int bank)
2626{
src/mame/drivers/nbmj8688.c
r6740r6741
3232
3333#include "driver.h"
3434#include "cpu/z80/z80.h"
35#include "nb1413m3.h"
35#include "includes/nb1413m3.h"
3636#include "sound/dac.h"
3737#include "sound/ay8910.h"
3838#include "sound/3812intf.h"
src/mame/drivers/hitpoker.c
r6740r6741
4949
5050static UINT8 *hitpoker_sys_regs;
5151static UINT8 hitpoker_pic_data;
52static UINT8 *videoram;
53static UINT8 *paletteram;
54static UINT8 *colorram;
5255
5356#define CRTC_CLOCK XTAL_3_579545MHz
5457
5558static VIDEO_START(hitpoker)
5659{
57   machine->generic.videoram.u8 = auto_alloc_array(machine, UINT8, 0x35ff);
58   machine->generic.paletteram.u8 = auto_alloc_array(machine, UINT8, 0x1000);
59   machine->generic.colorram.u8 = auto_alloc_array(machine, UINT8, 0x2000);
60   videoram = auto_alloc_array(machine, UINT8, 0x35ff);
61   paletteram = auto_alloc_array(machine, UINT8, 0x1000);
62   colorram = auto_alloc_array(machine, UINT8, 0x2000);
6063}
6164
6265static VIDEO_UPDATE(hitpoker)
r6740r6741
7275      {
7376         int tile,color,gfx_bpp;
7477
75         tile = (((screen->machine->generic.videoram.u8[count]<<8)|(screen->machine->generic.videoram.u8[count+1])) & 0x3fff);
76         gfx_bpp = (screen->machine->generic.colorram.u8[count] & 0x80)>>7; //flag between 4 and 8 bpp
77         color = gfx_bpp ? ((screen->machine->generic.colorram.u8[count] & 0x70)>>4) : (screen->machine->generic.colorram.u8[count] & 0xf);
78         tile = (((videoram[count]<<8)|(videoram[count+1])) & 0x3fff);
79         gfx_bpp = (colorram[count] & 0x80)>>7; //flag between 4 and 8 bpp
80         color = gfx_bpp ? ((colorram[count] & 0x70)>>4) : (colorram[count] & 0xf);
7881
7982         drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[gfx_bpp],tile,color,0,0,x*8,y*8);
8083
r6740r6741
9093   UINT8 *ROM = memory_region(space->machine, "maincpu");
9194
9295   if(hitpoker_pic_data & 0x10)
93      return space->machine->generic.videoram.u8[offset];
96      return videoram[offset];
9497   else
9598      return ROM[offset+0x8000];
9699}
r6740r6741
100103//  UINT8 *ROM = memory_region(space->machine, "maincpu");
101104
102105//  if(hitpoker_sys_regs[0x00] & 0x10)
103   space->machine->generic.videoram.u8[offset] = data;
106   videoram[offset] = data;
104107}
105108
106109static READ8_HANDLER( hitpoker_cram_r )
r6740r6741
108111   UINT8 *ROM = memory_region(space->machine, "maincpu");
109112
110113   if(hitpoker_pic_data & 0x10)
111      return space->machine->generic.colorram.u8[offset];
114      return colorram[offset];
112115   else
113116      return ROM[offset+0xc000];
114117}
115118
116119static WRITE8_HANDLER( hitpoker_cram_w )
117120{
118   space->machine->generic.colorram.u8[offset] = data;
121   colorram[offset] = data;
119122}
120123
121124static READ8_HANDLER( hitpoker_paletteram_r )
r6740r6741
123126   UINT8 *ROM = memory_region(space->machine, "maincpu");
124127
125128   if(hitpoker_pic_data & 0x10)
126      return space->machine->generic.paletteram.u8[offset];
129      return paletteram[offset];
127130   else
128131      return ROM[offset+0xe000];
129132}
r6740r6741
131134static WRITE8_HANDLER( hitpoker_paletteram_w )
132135{
133136   int r,g,b,datax;
134   space->machine->generic.paletteram.u8[offset] = data;
137   paletteram[offset] = data;
135138   offset>>=1;
136   datax=256*space->machine->generic.paletteram.u8[offset*2]+space->machine->generic.paletteram.u8[offset*2+1];
139   datax=256*paletteram[offset*2]+paletteram[offset*2+1];
137140
138141   /* RGB565 */
139142   b = ((datax)&0xf800)>>11;
src/mame/drivers/taito_h.c
r6740r6741
143143#include "driver.h"
144144#include "cpu/z80/z80.h"
145145#include "cpu/m68000/m68000.h"
146#include "taitoipt.h"
146#include "includes/taitoipt.h"
147147#include "audio/taitosnd.h"
148148#include "video/taitoic.h"
149149#include "sound/2610intf.h"
src/mame/drivers/tail2nos.c
r6740r6741
1111
1212#include "driver.h"
1313#include "cpu/m68000/m68000.h"
14#include "video/konamiic.h"
14#include "video/konicdev.h"
1515#include "cpu/z80/z80.h"
1616#include "sound/2608intf.h"
1717
1818
1919extern UINT16 *tail2nos_bgvideoram;
20extern void tail2nos_zoom_callback(running_machine *machine, int *code,int *color,int *flags);
2021
2122WRITE16_HANDLER( tail2nos_bgvideoram_w );
2223READ16_HANDLER( tail2nos_zoomdata_r );
r6740r6741
4647   }
4748}
4849
50#if 0
4951static READ16_HANDLER( tail2nos_K051316_0_r )
5052{
5153   return K051316_0_r(space,offset);
r6740r6741
6264   if (ACCESSING_BITS_0_7)
6365      K051316_ctrl_0_w(space,offset,data & 0xff);
6466}
67#endif
6568
6669static WRITE8_DEVICE_HANDLER( sound_bankswitch_w )
6770{
r6740r6741
7376   AM_RANGE(0x200000, 0x27ffff) AM_ROMBANK("bank1")   /* extra ROM */
7477   AM_RANGE(0x2c0000, 0x2dffff) AM_ROMBANK("bank2")
7578   AM_RANGE(0x400000, 0x41ffff) AM_READWRITE(tail2nos_zoomdata_r, tail2nos_zoomdata_w)
76   AM_RANGE(0x500000, 0x500fff) AM_READWRITE(tail2nos_K051316_0_r, tail2nos_K051316_0_w)
77   AM_RANGE(0x510000, 0x51001f) AM_WRITE(tail2nos_K051316_ctrl_0_w)
79   AM_RANGE(0x500000, 0x500fff) AM_DEVREADWRITE8("k051316", k051316_r, k051316_w, 0x00ff)
80   AM_RANGE(0x510000, 0x51001f) AM_DEVWRITE8("k051316", k051316_ctrl_w, 0x00ff)
7881   AM_RANGE(0xff8000, 0xffbfff) AM_RAM                        /* work RAM */
7982   AM_RANGE(0xffc000, 0xffc2ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
8083   AM_RANGE(0xffc300, 0xffcfff) AM_RAM
r6740r6741
232235};
233236
234237
238static const k051316_interface tail2nos_k051316_intf =
239{
240   "gfx3", 2,
241   -4, TRUE, 0,
242   1, -89, -14,
243   tail2nos_zoom_callback
244};
235245
236246static MACHINE_DRIVER_START( tail2nos )
237247
r6740r6741
260270   MDRV_VIDEO_START(tail2nos)
261271   MDRV_VIDEO_UPDATE(tail2nos)
262272
273   MDRV_K051316_ADD("k051316", tail2nos_k051316_intf)
274
263275   /* sound hardware */
264276   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
265277
src/mame/drivers/mrjong.c
r6740r6741
4747#include "sound/sn76496.h"
4848
4949
50extern UINT8 *mrjong_videoram;
51extern UINT8 *mrjong_colorram;
52
5053extern WRITE8_HANDLER( mrjong_videoram_w );
5154extern WRITE8_HANDLER( mrjong_colorram_w );
5255extern WRITE8_HANDLER( mrjong_flipscreen_w );
r6740r6741
6063   AM_RANGE(0x0000, 0x7fff) AM_ROM
6164   AM_RANGE(0x8000, 0x87ff) AM_RAM
6265   AM_RANGE(0xa000, 0xa7ff) AM_RAM
63   AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(mrjong_videoram_w) AM_BASE_GENERIC(videoram)
64   AM_RANGE(0xe400, 0xe7ff) AM_RAM_WRITE(mrjong_colorram_w) AM_BASE_GENERIC(colorram)
66   AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(mrjong_videoram_w) AM_BASE(&mrjong_videoram)
67   AM_RANGE(0xe400, 0xe7ff) AM_RAM_WRITE(mrjong_colorram_w) AM_BASE(&mrjong_colorram)
6568ADDRESS_MAP_END
6669
6770static WRITE8_HANDLER( io_0x00_w )
src/mame/drivers/m79amb.c
r6740r6741
5555*/
5656
5757#include "driver.h"
58#include "m79amb.h"
58#include "includes/m79amb.h"
5959#include "cpu/i8085/i8085.h"
6060
6161static UINT8 *ramtek_videoram;
src/mame/drivers/koftball.c
r6740r6741
3636
3737static UINT16 *bmc_1_videoram, *bmc_2_videoram,*main_ram;
3838static tilemap *tilemap_1,*tilemap_2;
39static UINT8 *bmc_colorram;
3940static int clr_offset=0;
4041
4142static TILE_GET_INFO( get_t1_tile_info )
r6740r6741
7576
7677static WRITE16_HANDLER( bmc_RAMDAC_offset_w )
7778{
78      clr_offset=data*3;
79   clr_offset=data*3;
7980}
8081
8182static WRITE16_HANDLER( bmc_RAMDAC_color_w )
8283{
83      space->machine->generic.colorram.u8[clr_offset]=data;
84      palette_set_color_rgb(space->machine,clr_offset/3,pal6bit(space->machine->generic.colorram.u8[(clr_offset/3)*3]),pal6bit(space->machine->generic.colorram.u8[(clr_offset/3)*3+1]),pal6bit(space->machine->generic.colorram.u8[(clr_offset/3)*3+2]));
85      clr_offset=(clr_offset+1)%768;
84   bmc_colorram[clr_offset]=data;
85   palette_set_color_rgb(space->machine,clr_offset/3,pal6bit(bmc_colorram[(clr_offset/3)*3]),pal6bit(bmc_colorram[(clr_offset/3)*3+1]),pal6bit(bmc_colorram[(clr_offset/3)*3+2]));
86   clr_offset=(clr_offset+1)%768;
8687}
8788
8889static READ16_HANDLER( bmc_RAMDAC_color_r )
8990{
90      return space->machine->generic.colorram.u8[clr_offset];
91   return bmc_colorram[clr_offset];
9192}
9293
9394static READ16_HANDLER(random_number_r)
r6740r6741
271272#endif
272273static DRIVER_INIT(koftball)
273274{
274   machine->generic.colorram.u8=auto_alloc_array(machine, UINT8, 768);
275   bmc_colorram = auto_alloc_array(machine, UINT8, 768);
275276
276277#if NVRAM_HACK
277278   {
src/mame/drivers/victory.c
r6740r6741
9696
9797#include "driver.h"
9898#include "cpu/z80/z80.h"
99#include "exidy.h"
100#include "victory.h"
99#include "includes/exidy.h"
100#include "includes/victory.h"
101101
102102
103103
src/mame/drivers/wardner.c
r6740r6741
126126#include "driver.h"
127127#include "cpu/z80/z80.h"
128128#include "cpu/tms32010/tms32010.h"
129#include "twincobr.h"
129#include "includes/twincobr.h"
130130#include "sound/3812intf.h"
131131
132132
src/mame/drivers/cninja.c
r6740r6741
4343#include "driver.h"
4444#include "cpu/z80/z80.h"
4545#include "cpu/m68000/m68000.h"
46#include "cninja.h"
46#include "includes/cninja.h"
4747#include "cpu/h6280/h6280.h"
48#include "deco16ic.h"
49#include "decocrpt.h"
50#include "decoprot.h"
48#include "includes/deco16ic.h"
49#include "includes/decocrpt.h"
50#include "includes/decoprot.h"
5151#include "sound/2203intf.h"
5252#include "sound/2151intf.h"
5353#include "sound/okim6295.h"
5454
5555static int cninja_scanline, cninja_irq_mask;
56static emu_timer *raster_irq_timer;
56static const device_config *raster_irq_timer;
5757static UINT16 *cninja_ram;
5858
5959/**********************************************************************************/
r6740r6741
7070   cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
7171}
7272
73static TIMER_CALLBACK( interrupt_gen )
73static TIMER_DEVICE_CALLBACK( interrupt_gen )
7474{
7575   int scanline = param;
7676
r6740r6741
8585   deco16_raster_display_list[deco16_raster_display_position++] = deco16_pf34_control[3] & 0xffff;
8686   deco16_raster_display_list[deco16_raster_display_position++] = deco16_pf34_control[4] & 0xffff;
8787
88   cputag_set_input_line(machine, "maincpu", (cninja_irq_mask&0x10) ? 3 : 4, ASSERT_LINE);
89   timer_adjust_oneshot(raster_irq_timer, attotime_never, 0);
88   cputag_set_input_line(timer->machine, "maincpu", (cninja_irq_mask&0x10) ? 3 : 4, ASSERT_LINE);
89   timer_device_adjust_oneshot(raster_irq_timer, attotime_never, 0);
9090}
9191
9292static READ16_HANDLER( cninja_irq_r )
r6740r6741
122122   case 1: /* Raster IRQ scanline position, only valid for values between 1 & 239 (0 and 240-256 do NOT generate IRQ's) */
123123      cninja_scanline=data&0xff;
124124      if ((cninja_irq_mask&0x2)==0 && cninja_scanline>0 && cninja_scanline<240)
125         timer_adjust_oneshot(raster_irq_timer, video_screen_get_time_until_pos(space->machine->primary_screen, cninja_scanline, 0), cninja_scanline);
125         timer_device_adjust_oneshot(raster_irq_timer, video_screen_get_time_until_pos(space->machine->primary_screen, cninja_scanline, 0), cninja_scanline);
126126      else
127         timer_adjust_oneshot(raster_irq_timer,attotime_never,0);
127         timer_device_adjust_oneshot(raster_irq_timer,attotime_never,0);
128128      return;
129129
130130   case 2: /* VBL irq ack */
r6740r6741
180180   AM_RANGE(0x308000, 0x308fff) AM_WRITENOP /* Bootleg only */
181181ADDRESS_MAP_END
182182
183static WRITE16_HANDLER( cninjabl_soundlatch_w )
184{
185   // todo:
186}
187
188static ADDRESS_MAP_START( cninjabl_map, ADDRESS_SPACE_PROGRAM, 16 )
189   AM_RANGE(0x000000, 0x0bffff) AM_ROM
190
191   AM_RANGE(0x138000, 0x1387ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* bootleg sprite-ram (sprites rewritten here in new format) */
192
193   AM_RANGE(0x140000, 0x14000f) AM_WRITEONLY AM_BASE(&deco16_pf12_control)
194   AM_RANGE(0x144000, 0x144fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
195   AM_RANGE(0x146000, 0x146fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
196   AM_RANGE(0x14c000, 0x14c7ff) AM_WRITEONLY AM_BASE(&deco16_pf1_rowscroll)
197   AM_RANGE(0x14e000, 0x14e7ff) AM_RAM AM_BASE(&deco16_pf2_rowscroll)
198
199   AM_RANGE(0x150000, 0x15000f) AM_WRITEONLY AM_BASE(&deco16_pf34_control) // not used / incorrect on this
200   AM_RANGE(0x154000, 0x154fff) AM_RAM_WRITE(deco16_pf3_data_w) AM_BASE(&deco16_pf3_data)
201   AM_RANGE(0x156000, 0x156fff) AM_RAM_WRITE(deco16_pf4_data_w) AM_BASE(&deco16_pf4_data)
202   AM_RANGE(0x15c000, 0x15c7ff) AM_RAM AM_BASE(&deco16_pf3_rowscroll)
203   AM_RANGE(0x15e000, 0x15e7ff) AM_RAM AM_BASE(&deco16_pf4_rowscroll)
204
205   AM_RANGE(0x17ff22, 0x17ff23) AM_READ_PORT("DSW")
206   AM_RANGE(0x17ff28, 0x17ff29) AM_READ_PORT("IN1")
207   AM_RANGE(0x17ff2a, 0x17ff2b) AM_WRITE( cninjabl_soundlatch_w )
208   AM_RANGE(0x17ff2c, 0x17ff2d) AM_READ_PORT("IN0")
209
210   AM_RANGE(0x180000, 0x187fff) AM_RAM // more ram on bootleg?
211
212   AM_RANGE(0x190000, 0x190007) AM_READWRITE(cninja_irq_r, cninja_irq_w)
213   AM_RANGE(0x19c000, 0x19dfff) AM_RAM_WRITE(deco16_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
214
215   AM_RANGE(0x1b4000, 0x1b4001) AM_WRITE(buffer_spriteram16_w) /* DMA flag */
216ADDRESS_MAP_END
217
183218static ADDRESS_MAP_START( edrandy_map, ADDRESS_SPACE_PROGRAM, 16 )
184219   AM_RANGE(0x000000, 0x0fffff) AM_ROM
185220
r6740r6741
588623   16*8   /* every char takes 8 consecutive bytes */
589624};
590625
626static const gfx_layout charlayout_boot =
627{
628   8,8,
629   RGN_FRAC(1,1),
630   4,
631   { 16, 0, 24, 8 },
632   { 0, 1, 2, 3, 4, 5, 6, 7 },
633   { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
634   8*32
635};
636
591637static const gfx_layout spritelayout =
592638{
593639   16,16,
r6740r6741
634680   GFXDECODE_ENTRY( "gfx4", 0, spritelayout,768, 32 )   /* Sprites 16x16 */
635681GFXDECODE_END
636682
683static GFXDECODE_START( cninjabl )
684   GFXDECODE_ENTRY( "gfx1", 0, charlayout_boot,  0, 32 )   /* Characters 8x8 */
685   GFXDECODE_ENTRY( "gfx2", 0, spritelayout,0, 32 )   /* Tiles 16x16 */
686   GFXDECODE_ENTRY( "gfx3", 0, spritelayout,512, 64 )   /* Tiles 16x16 */
687   GFXDECODE_ENTRY( "gfx4", 0, spritelayout,768, 32 )   /* Sprites 16x16 */
688GFXDECODE_END
689
690
637691static GFXDECODE_START( robocop2 )
638692   GFXDECODE_ENTRY( "gfx1", 0, charlayout,    0, 32 )   /* Characters 8x8 */
639693   GFXDECODE_ENTRY( "gfx2", 0, tilelayout,    0, 32 )   /* Tiles 16x16 */
r6740r6741
654708
655709static MACHINE_RESET( cninja )
656710{
657   raster_irq_timer = timer_alloc(machine, interrupt_gen, NULL);
711   raster_irq_timer = devtag_get_device(machine, "raster_timer");
658712   cninja_scanline=0;
659713   cninja_irq_mask=0;
660714}
r6740r6741
700754
701755   MDRV_MACHINE_RESET(cninja)
702756
757   MDRV_TIMER_ADD("raster_timer", interrupt_gen)
758
703759   /* video hardware */
704760   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
705761
r6740r6741
748804
749805   MDRV_MACHINE_RESET(cninja)
750806
807   MDRV_TIMER_ADD("raster_timer", interrupt_gen)
808
751809   /* video hardware */
752810   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
753811
r6740r6741
781839   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60)
782840MACHINE_DRIVER_END
783841
842
843static MACHINE_DRIVER_START( cninjabl )
844
845   /* basic machine hardware */
846   MDRV_CPU_ADD("maincpu", M68000, 12000000)
847   MDRV_CPU_PROGRAM_MAP(cninjabl_map)
848   MDRV_CPU_VBLANK_INT("screen", irq5_line_hold)
849
850   MDRV_CPU_ADD("audiocpu", Z80, 3579545)
851   MDRV_CPU_PROGRAM_MAP(stoneage_s_map)
852
853   MDRV_MACHINE_RESET(cninja)
854
855   MDRV_TIMER_ADD("raster_timer", interrupt_gen)
856
857   /* video hardware */
858   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
859
860   MDRV_SCREEN_ADD("screen", RASTER)
861   MDRV_SCREEN_REFRESH_RATE(58)
862   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
863   MDRV_SCREEN_SIZE(32*8, 32*8)
864   MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1)
865
866   MDRV_GFXDECODE(cninjabl)
867   MDRV_PALETTE_LENGTH(2048)
868
869   MDRV_VIDEO_START(stoneage)
870   MDRV_VIDEO_UPDATE(cninja)
871   MDRV_VIDEO_EOF(cninja)
872
873   /* sound hardware */
874   MDRV_SPEAKER_STANDARD_MONO("mono")
875
876   MDRV_SOUND_ADD("ymsnd", YM2151, 32220000/9)
877   MDRV_SOUND_CONFIG(ym2151_interface2)
878   MDRV_SOUND_ROUTE(0, "mono", 0.45)
879   MDRV_SOUND_ROUTE(1, "mono", 0.45)
880
881   MDRV_SOUND_ADD("oki1", OKIM6295, 32220000/32)
882   MDRV_SOUND_CONFIG(okim6295_interface_pin7high)
883   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
884MACHINE_DRIVER_END
885
886
784887static MACHINE_DRIVER_START( edrandy )
785888
786889   /* basic machine hardware */
r6740r6741
793896
794897   MDRV_MACHINE_RESET(cninja)
795898
899   MDRV_TIMER_ADD("raster_timer", interrupt_gen)
900
796901   /* video hardware */
797902   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
798903
r6740r6741
841946
842947   MDRV_MACHINE_RESET(cninja)
843948
949   MDRV_TIMER_ADD("raster_timer", interrupt_gen)
950
844951   /* video hardware */
845952   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
846953
r6740r6741
11311238   ROM_REGION( 0x80000, "oki2", ROMREGION_ERASEFF )
11321239ROM_END
11331240
1241ROM_START( cninjabl )
1242   ROM_REGION( 0xc0000, "maincpu", 0 ) /* 68000 code */
1243   ROM_LOAD16_WORD_SWAP( "joe mac 3.68k", 0x00000, 0x80000,  CRC(dc931d80) SHA1(78103f74fb428c4735e77d99a143cdf28915ef26) )
1244   ROM_LOAD16_WORD_SWAP( "joe mac 4.68k", 0x80000, 0x40000,  CRC(e8dfe0b5) SHA1(f7f883c19023bc68146aea5eaf98d2fdd606d5e3) )
1245   ROM_IGNORE(0x40000) //  1xxxxxxxxxxxxxxxxxx = 0xFF
1246
1247   ROM_REGION( 0x10000, "audiocpu", 0 ) /* Z80 Sound CPU */
1248   ROM_LOAD( "joe mac 5.z80",  0x00000,  0x10000, CRC(d791b9d7) SHA1(7842ab7e960b692bdbcadf5c64f09ddd1a3fb861) ) // 1ST AND 2ND HALF IDENTICAL
1249
1250   ROM_REGION( 0x400000, "gfxtemp", 0 ) // the bootleg has the gfx in 2 roms
1251   ROM_LOAD16_BYTE( "joe mac 1.gfx",  0x00000,  0x200000,  CRC(17ea5931) SHA1(cb686dea0d960d35ab3709f1f592598c2d757045) )
1252   ROM_LOAD16_BYTE( "joe mac 2.gfx",  0x00001,  0x200000,  CRC(cc95317b) SHA1(ffa97dde954f73d8e0f6e55387b44f5bcc08242b) )
1253
1254   // split larger bootleg GFX roms into required regions
1255   ROM_REGION( 0x020000, "gfx1", ROMREGION_INVERT ) // chars
1256   ROM_COPY( "gfxtemp", 0x000000, 0x000000, 0x020000 )
1257
1258   ROM_REGION( 0x080000, "gfx2", ROMREGION_INVERT ) // tiles 3
1259   ROM_COPY( "gfxtemp", 0x080000, 0x000000, 0x080000 )
1260
1261   ROM_REGION( 0x100000, "gfx3", ROMREGION_INVERT ) // tiles 2
1262   ROM_COPY( "gfxtemp", 0x180000, 0x000000, 0x080000 )
1263   ROM_COPY( "gfxtemp", 0x100000, 0x080000, 0x080000 )
1264
1265   ROM_REGION( 0x200000, "gfx4", 0 ) // sprites
1266   ROM_COPY( "gfxtemp", 0x200000, 0x000000, 0x200000 )
1267
1268   ROM_REGION( 0x80000, "oki1", 0 ) /* Oki samples */
1269   ROM_LOAD( "joe mac 6.samples",  0x00000,  0x80000, CRC(dbecad83) SHA1(de34653606f12d2c606ff7d1cbce993521772884) ) // 1ST AND 2ND HALF IDENTICAL
1270ROM_END
1271
1272
11341273ROM_START( edrandy ) /* World ver 3 */
11351274   ROM_REGION( 0x100000, "maincpu", 0 ) /* 68000 code */
11361275     ROM_LOAD16_BYTE( "gg-00-2.k1", 0x00000, 0x20000, CRC(ce1ba964) SHA1(da21734721344eff41a64a7f2382d5c027a24782) )
r6740r6741
17151854GAME( 1991, cninja1,  cninja,  cninja,   cninja,  cninja,   ROT0, "Data East Corporation", "Caveman Ninja (World ver 1)", 0 )
17161855GAME( 1991, cninjau,  cninja,  cninja,   cninjau, cninja,   ROT0, "Data East Corporation", "Caveman Ninja (US ver 4)", 0 )
17171856GAME( 1991, joemac,   cninja,  cninja,   cninja,  cninja,   ROT0, "Data East Corporation", "Tatakae Genshizin Joe & Mac (Japan ver 1)", 0 )
1718GAME( 1991, stoneage, cninja,  stoneage, cninja,  stoneage, ROT0, "bootleg", "Stoneage", 0 )
1857GAME( 1991, stoneage, cninja,  stoneage, cninja,  stoneage, ROT0, "bootleg", "Stoneage (bootleg of Caveman Ninja)", 0 )
1858GAME( 1991, cninjabl, cninja,  cninjabl, cninja,  0,        ROT0, "bootleg", "Caveman Ninja (bootleg)", GAME_NOT_WORKING )
17191859GAME( 1991, robocop2, 0,       robocop2, robocop2,0,        ROT0, "Data East Corporation", "Robocop 2 (Euro/Asia v0.10)", 0 )
17201860GAME( 1991, robocop2u,robocop2,robocop2, robocop2,0,        ROT0, "Data East Corporation", "Robocop 2 (US v0.05)", 0 )
17211861GAME( 1991, robocop2j,robocop2,robocop2, robocop2,0,        ROT0, "Data East Corporation", "Robocop 2 (Japan v0.11)", 0 )
src/mame/drivers/dogfgt.c
r6740r6741
1010#include "driver.h"
1111#include "cpu/m6502/m6502.h"
1212#include "deprecat.h"
13#include "dogfgt.h"
13#include "includes/dogfgt.h"
1414#include "sound/ay8910.h"
1515
1616
src/mame/drivers/vigilant.c
r6740r6741
536536   MDRV_CPU_IO_MAP(sound_io_map)
537537   MDRV_CPU_VBLANK_INT_HACK(nmi_line_pulse,128)   /* clocked by V1 */
538538                        /* IRQs are generated by main Z80 and YM2151 */
539   MDRV_MACHINE_RESET(m72_sound)
539   MDRV_SOUND_START(m72)
540   MDRV_SOUND_RESET(m72)
540541
541542   /* video hardware */
542543   MDRV_SCREEN_ADD("screen", RASTER)
r6740r6741
579580   MDRV_CPU_IO_MAP(buccanrs_sound_io_map)
580581   MDRV_CPU_VBLANK_INT_HACK(nmi_line_pulse,128)   /* clocked by V1 */
581582                        /* IRQs are generated by main Z80 and YM2151 */
582   MDRV_MACHINE_RESET(m72_sound)
583   MDRV_SOUND_START(m72)
584   MDRV_SOUND_RESET(m72)
583585
584586   /* video hardware */
585587   MDRV_SCREEN_ADD("screen", RASTER)
r6740r6741
638640   MDRV_CPU_IO_MAP(sound_io_map)
639641   MDRV_CPU_VBLANK_INT_HACK(nmi_line_pulse,128)   /* clocked by V1 */
640642                        /* IRQs are generated by main Z80 and YM2151 */
641   MDRV_MACHINE_RESET(m72_sound)
643   MDRV_SOUND_START(m72)
644   MDRV_SOUND_RESET(m72)
642645
643646   /* video hardware */
644647   MDRV_SCREEN_ADD("screen", RASTER)
src/mame/drivers/nbmj8991.c
r6740r6741
3030
3131#include "driver.h"
3232#include "cpu/z80/z80.h"
33#include "nb1413m3.h"
33#include "includes/nb1413m3.h"
3434#include "sound/ay8910.h"
3535#include "sound/3812intf.h"
3636#include "sound/dac.h"
src/mame/drivers/canyon.c
r6740r6741
3838
3939#include "driver.h"
4040#include "cpu/m6502/m6502.h"
41#include "canyon.h"
41#include "includes/canyon.h"
4242#include "sound/discrete.h"
4343
4444
src/mame/drivers/midwunit.c
r6740r6741
8888#include "cpu/tms34010/tms34010.h"
8989#include "cpu/adsp2100/adsp2100.h"
9090#include "audio/dcs.h"
91#include "midwunit.h"
91#include "includes/midwunit.h"
9292
9393
9494#define PIXEL_CLOCK      (8000000)
src/mame/drivers/tecmosys.c
r6740r6741
184184#include "driver.h"
185185#include "cpu/z80/z80.h"
186186#include "machine/eeprom.h"
187#include "tecmosys.h"
187#include "includes/tecmosys.h"
188188#include "cpu/m68000/m68000.h"
189189#include "sound/okim6295.h"
190190#include "sound/262intf.h"
src/mame/drivers/snk6502.c
r6740r6741
268268#include "video/mc6845.h"
269269#include "sound/sn76477.h"
270270#include "sound/samples.h"
271#include "snk6502.h"
271#include "includes/snk6502.h"
272272
273273
274274#define MASTER_CLOCK   XTAL_11_289MHz
r6740r6741
284284
285285/* binary counter (1.4MHz update) */
286286static UINT8 sasuke_counter;
287static emu_timer *sasuke_timer;
288287
289static TIMER_CALLBACK( sasuke_update_counter )
288static TIMER_DEVICE_CALLBACK( sasuke_update_counter )
290289{
291290   sasuke_counter += 0x10;
292291}
r6740r6741
294293static void sasuke_start_counter(running_machine *machine)
295294{
296295   sasuke_counter = 0;
297
298   sasuke_timer = timer_alloc(machine, sasuke_update_counter, NULL);
299   timer_adjust_periodic(sasuke_timer, attotime_zero, 0, ATTOTIME_IN_HZ(MASTER_CLOCK / 8));   // 1.4 MHz
300296}
301297
302298
r6740r6741
326322static ADDRESS_MAP_START( sasuke_map, ADDRESS_SPACE_PROGRAM, 8 )
327323   AM_RANGE(0x0000, 0x03ff) AM_RAM
328324   AM_RANGE(0x0400, 0x07ff) AM_RAM_WRITE(snk6502_videoram2_w) AM_BASE(&snk6502_videoram2)
329   AM_RANGE(0x0800, 0x0bff) AM_RAM_WRITE(snk6502_videoram_w) AM_BASE_GENERIC(videoram)
330   AM_RANGE(0x0c00, 0x0fff) AM_RAM_WRITE(snk6502_colorram_w) AM_BASE_GENERIC(colorram)
325   AM_RANGE(0x0800, 0x0bff) AM_RAM_WRITE(snk6502_videoram_w) AM_BASE(&snk6502_videoram)
326   AM_RANGE(0x0c00, 0x0fff) AM_RAM_WRITE(snk6502_colorram_w) AM_BASE(&snk6502_colorram)
331327   AM_RANGE(0x1000, 0x1fff) AM_RAM_WRITE(snk6502_charram_w) AM_BASE(&snk6502_charram)
332328   AM_RANGE(0x3000, 0x3000) AM_DEVWRITE("crtc", mc6845_address_w)
333329   AM_RANGE(0x3001, 0x3001) AM_DEVWRITE("crtc", mc6845_register_w)
r6740r6741
345341static ADDRESS_MAP_START( satansat_map, ADDRESS_SPACE_PROGRAM, 8 )
346342   AM_RANGE(0x0000, 0x03ff) AM_RAM
347343   AM_RANGE(0x0400, 0x07ff) AM_RAM_WRITE(snk6502_videoram2_w) AM_BASE(&snk6502_videoram2)
348   AM_RANGE(0x0800, 0x0bff) AM_RAM_WRITE(snk6502_videoram_w) AM_BASE_GENERIC(videoram)
349   AM_RANGE(0x0c00, 0x0fff) AM_RAM_WRITE(snk6502_colorram_w) AM_BASE_GENERIC(colorram)
344   AM_RANGE(0x0800, 0x0bff) AM_RAM_WRITE(snk6502_videoram_w) AM_BASE(&snk6502_videoram)
345   AM_RANGE(0x0c00, 0x0fff) AM_RAM_WRITE(snk6502_colorram_w) AM_BASE(&snk6502_colorram)
350346   AM_RANGE(0x1000, 0x1fff) AM_RAM_WRITE(snk6502_charram_w) AM_BASE(&snk6502_charram)
351347   AM_RANGE(0x3000, 0x3000) AM_DEVWRITE("crtc", mc6845_address_w)
352348   AM_RANGE(0x3001, 0x3001) AM_DEVWRITE("crtc", mc6845_register_w)
r6740r6741
364360static ADDRESS_MAP_START( vanguard_map, ADDRESS_SPACE_PROGRAM, 8 )
365361   AM_RANGE(0x0000, 0x03ff) AM_RAM
366362   AM_RANGE(0x0400, 0x07ff) AM_RAM_WRITE(snk6502_videoram2_w) AM_BASE(&snk6502_videoram2)
367   AM_RANGE(0x0800, 0x0bff) AM_RAM_WRITE(snk6502_videoram_w) AM_BASE_GENERIC(videoram)
368   AM_RANGE(0x0c00, 0x0fff) AM_RAM_WRITE(snk6502_colorram_w) AM_BASE_GENERIC(colorram)
363   AM_RANGE(0x0800, 0x0bff) AM_RAM_WRITE(snk6502_videoram_w) AM_BASE(&snk6502_videoram)
364   AM_RANGE(0x0c00, 0x0fff) AM_RAM_WRITE(snk6502_colorram_w) AM_BASE(&snk6502_colorram)
369365   AM_RANGE(0x1000, 0x1fff) AM_RAM_WRITE(snk6502_charram_w) AM_BASE(&snk6502_charram)
370366   AM_RANGE(0x3000, 0x3000) AM_DEVWRITE("crtc", mc6845_address_w)
371367   AM_RANGE(0x3001, 0x3001) AM_DEVWRITE("crtc", mc6845_register_w)
r6740r6741
385381static ADDRESS_MAP_START( fantasy_map, ADDRESS_SPACE_PROGRAM, 8 )
386382   AM_RANGE(0x0000, 0x03ff) AM_RAM
387383   AM_RANGE(0x0400, 0x07ff) AM_RAM_WRITE(snk6502_videoram2_w) AM_BASE(&snk6502_videoram2)
388   AM_RANGE(0x0800, 0x0bff) AM_RAM_WRITE(snk6502_videoram_w) AM_BASE_GENERIC(videoram)
389   AM_RANGE(0x0c00, 0x0fff) AM_RAM_WRITE(snk6502_colorram_w) AM_BASE_GENERIC(colorram)
384   AM_RANGE(0x0800, 0x0bff) AM_RAM_WRITE(snk6502_videoram_w) AM_BASE(&snk6502_videoram)
385   AM_RANGE(0x0c00, 0x0fff) AM_RAM_WRITE(snk6502_colorram_w) AM_BASE(&snk6502_colorram)
390386   AM_RANGE(0x1000, 0x1fff) AM_RAM_WRITE(snk6502_charram_w) AM_BASE(&snk6502_charram)
391387   AM_RANGE(0x2000, 0x2000) AM_DEVWRITE("crtc", mc6845_address_w)
392388   AM_RANGE(0x2001, 0x2001) AM_DEVWRITE("crtc", mc6845_register_w)
r6740r6741
405401static ADDRESS_MAP_START( pballoon_map, ADDRESS_SPACE_PROGRAM, 8 )
406402   AM_RANGE(0x0000, 0x03ff) AM_RAM
407403   AM_RANGE(0x0400, 0x07ff) AM_RAM_WRITE(snk6502_videoram2_w) AM_BASE(&snk6502_videoram2)
408   AM_RANGE(0x0800, 0x0bff) AM_RAM_WRITE(snk6502_videoram_w) AM_BASE_GENERIC(videoram)
409   AM_RANGE(0x0c00, 0x0fff) AM_RAM_WRITE(snk6502_colorram_w) AM_BASE_GENERIC(colorram)
404   AM_RANGE(0x0800, 0x0bff) AM_RAM_WRITE(snk6502_videoram_w) AM_BASE(&snk6502_videoram)
405   AM_RANGE(0x0c00, 0x0fff) AM_RAM_WRITE(snk6502_colorram_w) AM_BASE(&snk6502_colorram)
410406   AM_RANGE(0x1000, 0x1fff) AM_RAM_WRITE(snk6502_charram_w) AM_BASE(&snk6502_charram)
411407   AM_RANGE(0x3000, 0x9fff) AM_ROM
412408   AM_RANGE(0xb000, 0xb000) AM_DEVWRITE("crtc", mc6845_address_w)
r6740r6741
847843
848844   MDRV_MC6845_ADD("crtc", MC6845, MASTER_CLOCK / 16, mc6845_intf)
849845
846   MDRV_TIMER_ADD_PERIODIC("sasuke_timer", sasuke_update_counter, HZ(MASTER_CLOCK / 8))   // 1.4 MHz
847
850848   // sound hardware
851849   MDRV_SPEAKER_STANDARD_MONO("mono")
852850
src/mame/drivers/polyplay.c
r6740r6741
9696static int channel2_const;
9797
9898/* timer handling */
99static TIMER_CALLBACK( polyplay_timer_callback );
100static emu_timer* polyplay_timer;
99static TIMER_DEVICE_CALLBACK( polyplay_timer_callback );
100static const device_config* polyplay_timer;
101101static WRITE8_HANDLER( polyplay_start_timer2 );
102102static WRITE8_HANDLER( polyplay_sound_channel );
103103
r6740r6741
123123   polyplay_set_channel2(0);
124124   polyplay_play_channel2(machine, 0);
125125
126   polyplay_timer = timer_alloc(machine, polyplay_timer_callback, NULL);
126   polyplay_timer = devtag_get_device(machine, "timer");
127127}
128128
129129
r6740r6741
234234static WRITE8_HANDLER( polyplay_start_timer2 )
235235{
236236   if (data == 0x03)
237      timer_adjust_oneshot(polyplay_timer, attotime_never, 0);
237      timer_device_adjust_oneshot(polyplay_timer, attotime_never, 0);
238238
239239   if (data == 0xb5)
240      timer_adjust_periodic(polyplay_timer, ATTOTIME_IN_HZ(40), 0, ATTOTIME_IN_HZ(40));
240      timer_device_adjust_periodic(polyplay_timer, ATTOTIME_IN_HZ(40), 0, ATTOTIME_IN_HZ(40));
241241}
242242
243243static READ8_HANDLER( polyplay_random_read )
r6740r6741
287287
288288   MDRV_MACHINE_RESET(polyplay)
289289
290   MDRV_TIMER_ADD("timer", polyplay_timer_callback)
291
292
290293   /* video hardware */
291294   MDRV_SCREEN_ADD("screen", RASTER)
292295   MDRV_SCREEN_REFRESH_RATE(50)
r6740r6741
354357ROM_END
355358
356359
357static TIMER_CALLBACK( polyplay_timer_callback )
360static TIMER_DEVICE_CALLBACK( polyplay_timer_callback )
358361{
359   cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, 0x4c);
362   cputag_set_input_line_and_vector(timer->machine, "maincpu", 0, HOLD_LINE, 0x4c);
360363}
361364
362365/* game driver */
src/mame/drivers/exidy440.c
r6740r6741
216216
217217#include "driver.h"
218218#include "cpu/m6809/m6809.h"
219#include "exidy440.h"
219#include "includes/exidy440.h"
220220
221221
222222/* constants */
src/mame/drivers/dassault.c
r6740r6741
124124#include "driver.h"
125125#include "cpu/m68000/m68000.h"
126126#include "cpu/h6280/h6280.h"
127#include "deco16ic.h"
127#include "includes/deco16ic.h"
128128#include "sound/2203intf.h"
129129#include "sound/2151intf.h"
130130#include "sound/okim6295.h"
src/mame/drivers/dambustr.c
r6740r6741
1616#include "cpu/z80/z80.h"
1717#include "includes/galaxian.h"
1818#include "includes/galaxold.h"
19#include "machine/7474.h"
1920
2021static int noise_data = 0;
2122
r6740r6741
187188
188189   MDRV_MACHINE_RESET(galaxold)
189190
191   MDRV_7474_ADD("7474_9m_1", galaxold_7474_9m_1_callback)
192   MDRV_7474_ADD("7474_9m_2", galaxold_7474_9m_2_callback)
193
194   MDRV_TIMER_ADD("int_timer", galaxold_interrupt_timer)
195
190196   /* video hardware */
191197   MDRV_SCREEN_ADD("screen", RASTER)
192198   MDRV_SCREEN_REFRESH_RATE(16000.0/132/2)
src/mame/drivers/tatsumi.c
r6740r6741
141141#include "cpu/z80/z80.h"
142142#include "cpu/nec/nec.h"
143143#include "cpu/m68000/m68000.h"
144#include "tatsumi.h"
144#include "includes/tatsumi.h"
145145#include "sound/2151intf.h"
146146#include "sound/okim6295.h"
147147
src/mame/drivers/supbtime.c
r6740r6741
2525#include "cpu/h6280/h6280.h"
2626#include "sound/2151intf.h"
2727#include "sound/okim6295.h"
28#include "deco16ic.h"
28#include "includes/deco16ic.h"
2929
3030VIDEO_START( supbtime );
3131VIDEO_UPDATE( supbtime );
src/mame/drivers/ggconnie.c
r6740r6741
4545   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
4646
4747   PORT_START("SWA")
48   PORT_DIPNAME(0x03, 0x03, "Coin Set")
49   PORT_DIPSETTING(0x03, DEF_STR(1C_1C))
50   PORT_DIPNAME(0x1c, 0x1c, "100 Yen -> Coin" )
48   PORT_DIPNAME(0x03, 0x03, "Coin Set")  PORT_DIPLOCATION("SWA:1,2")
49   PORT_DIPSETTING(0x03, DEF_STR(1C_1C) )
50   PORT_DIPNAME(0x1c, 0x1c, "100 Yen -> Coin" )  PORT_DIPLOCATION("SWA:3,4,5")
5151   PORT_DIPSETTING(0x00, "11 Coin")
5252   PORT_DIPSETTING(0x04, "12 Coin")
5353   PORT_DIPSETTING(0x08, "0 Coin")
r6740r6741
5656   PORT_DIPSETTING(0x14, "7 Coin")
5757   PORT_DIPSETTING(0x18, "8 Coin")
5858   PORT_DIPSETTING(0x1c, "10 Coin")
59   PORT_DIPUNUSED(0x20, IP_ACTIVE_LOW )
60   PORT_DIPUNUSED(0x40, IP_ACTIVE_LOW )
61   PORT_DIPUNUSED(0x80, IP_ACTIVE_LOW )
59   PORT_DIPUNUSED_DIPLOC( 0x20, 0x00, "SWA:6" )
60   PORT_DIPUNUSED_DIPLOC( 0x40, 0x00, "SWA:7" )
61   PORT_DIPUNUSED_DIPLOC( 0x80, 0x00, "SWA:8" )
6262
6363   PORT_START("SWB")
64   PORT_DIPNAME(0x07, 0x07, "Payout")
64   PORT_DIPNAME(0x07, 0x07, "Payout")  PORT_DIPLOCATION("SWB:1,2,3")
6565   PORT_DIPSETTING(0x00, "85%")
6666   PORT_DIPSETTING(0x01, "90%")
6767   PORT_DIPSETTING(0x02, "55%")
r6740r6741
7070   PORT_DIPSETTING(0x05, "70%")
7171   PORT_DIPSETTING(0x06, "75%")
7272   PORT_DIPSETTING(0x07, "80%")
73   PORT_DIPNAME(0x18, 0x18, DEF_STR(Difficulty))
73   PORT_DIPNAME(0x18, 0x18, DEF_STR(Difficulty))  PORT_DIPLOCATION("SWB:4,5")
7474   PORT_DIPSETTING(0x00, DEF_STR(Easy))
7575   PORT_DIPSETTING(0x08, DEF_STR(Very_Hard))
7676   PORT_DIPSETTING(0x10, DEF_STR(Hard))
7777   PORT_DIPSETTING(0x18, DEF_STR(Normal))
78   PORT_DIPNAME(0x20, 0x20, "Payout Info")
78   PORT_DIPNAME(0x20, 0x20, "Payout Info")  PORT_DIPLOCATION("SWB:6")
7979   PORT_DIPSETTING(0x00, DEF_STR(Off))
8080   PORT_DIPSETTING(0x20, DEF_STR(On))
81   PORT_DIPNAME(0xc0, 0xc0, "Rate")
81   PORT_DIPNAME(0xc0, 0xc0, "Rate")  PORT_DIPLOCATION("SWB:7,8")
8282   PORT_DIPSETTING(0x00, "Few" )
8383   PORT_DIPSETTING(0x40, "Most" )
8484   PORT_DIPSETTING(0x80, "More" )
8585   PORT_DIPSETTING(0xc0, DEF_STR(Normal))
8686
8787   PORT_START("SWC")
88   PORT_DIPNAME(0x03, 0x03, "Demo Sound" )
88   PORT_DIPNAME(0x03, 0x03, "Demo Sound" )  PORT_DIPLOCATION("SWC:1,2")
8989   PORT_DIPSETTING(0x00, DEF_STR(Off) )
9090   PORT_DIPSETTING(0x01, "3/1" )
9191   PORT_DIPSETTING(0x02, "2/1" )
9292   PORT_DIPSETTING(0x03, "1/1" )
93   PORT_DIPNAME(0x0c, 0x0c, "Start Time" )
93   PORT_DIPNAME(0x0c, 0x0c, "Start Time" )  PORT_DIPLOCATION("SWC:3,4")
9494   PORT_DIPSETTING(0x00, "4 sec" )
9595   PORT_DIPSETTING(0x04, "8 sec" )
9696   PORT_DIPSETTING(0x08, "6 sec" )
9797   PORT_DIPSETTING(0x0c, "5 sec" )
98   PORT_DIPUNUSED(0x10, IP_ACTIVE_LOW )
99   PORT_DIPUNUSED(0x20, IP_ACTIVE_LOW )
100   PORT_DIPNAME(0x40, 0x00, "RAM Clear" )
98   PORT_DIPUNUSED_DIPLOC( 0x10, 0x00, "SWC:5" )
99   PORT_DIPUNUSED_DIPLOC( 0x20, 0x00, "SWC:6" )
100   PORT_DIPNAME(0x40, 0x00, "RAM Clear" )  PORT_DIPLOCATION("SWC:7")
101101   PORT_DIPSETTING(0x40, DEF_STR(Off) )
102102   PORT_DIPSETTING(0x00, DEF_STR(On) )
103   PORT_SERVICE(0x80, IP_ACTIVE_LOW)
103   PORT_SERVICE(0x80, IP_ACTIVE_LOW)  PORT_DIPLOCATION("SWC:8")
104104
105105INPUT_PORTS_END
106106
r6740r6741
187187   DRIVER_INIT_CALL(pce);
188188}
189189
190GAME( 19??, ggconnie, 0, ggconnie, ggconnie, ggconnie, ROT0, "Capcom", "Go! Go! Connie chan Jaka Jaka Janken", GAME_NO_SOUND | GAME_NOT_WORKING )
190GAME( 1996, ggconnie, 0, ggconnie, ggconnie, ggconnie, ROT0, "Capcom", "Go! Go! Connie chan Jaka Jaka Janken", GAME_NO_SOUND | GAME_NOT_WORKING )
src/mame/drivers/toratora.c
r6740r6741
2323#include "sound/sn76477.h"
2424
2525
26static UINT8 *toratora_videoram;
27static size_t toratora_videoram_size;
26typedef struct _toratora_state toratora_state;
27struct _toratora_state
28{
29   /* memory pointers */
30   UINT8 *    videoram;
31   size_t     videoram_size;
2832
29static UINT8 clear_tv;
33   /* video-related */
34   int        timer;
35   UINT8      last;
36   UINT8      clear_tv;
3037
38   /* devices */
39   const device_config *maincpu;
40   const device_config *pia_u1;
41   const device_config *pia_u2;
42   const device_config *pia_u3;
43};
3144
3245
46
3347/*************************************
3448 *
3549 *  Input handling
3650 *
3751 *************************************/
3852
39static READ8_DEVICE_HANDLER( port_b_u3_r )
40{
41   logerror("%s: read DIP\n",cpuexec_describe_context(device->machine));
42   return input_port_read(device->machine, "DSW");
43}
44
45
4653static WRITE_LINE_DEVICE_HANDLER( cb2_u3_w )
4754{
4855   logerror("DIP tristate %sactive\n",(state & 1) ? "in" : "");
4956}
5057
5158
52
5359/*************************************
5460 *
5561 *  Video hardware
r6740r6741
5864
5965static VIDEO_UPDATE( toratora )
6066{
67   toratora_state *state = (toratora_state *)screen->machine->driver_data;
6168   offs_t offs;
6269
63   for (offs = 0; offs < toratora_videoram_size; offs++)
70   for (offs = 0; offs < state->videoram_size; offs++)
6471   {
6572      int i;
6673
6774      UINT8 y = offs >> 5;
6875      UINT8 x = offs << 3;
69      UINT8 data = toratora_videoram[offs];
76      UINT8 data = state->videoram[offs];
7077
7178      for (i = 0; i < 8; i++)
7279      {
r6740r6741
7885      }
7986
8087      /* the video system clears as it writes out the pixels */
81      if (clear_tv)
82         toratora_videoram[offs] = 0;
88      if (state->clear_tv)
89         state->videoram[offs] = 0;
8390   }
8491
85   clear_tv = 0;
92   state->clear_tv = 0;
8693
8794   return 0;
8895}
r6740r6741
9097
9198static WRITE8_HANDLER( clear_tv_w )
9299{
93   clear_tv = 1;
100   toratora_state *state = (toratora_state *)space->machine->driver_data;
101   state->clear_tv = 1;
94102}
95103
96104
97
98105/*************************************
99106 *
100107 *  Coin counter
r6740r6741
110117}
111118
112119
113
114120/*************************************
115121 *
116122 *  Interrupt generation
r6740r6741
119125
120126static WRITE_LINE_DEVICE_HANDLER( main_cpu_irq )
121127{
128   toratora_state *toratora = (toratora_state *)device->machine->driver_data;
122129   int combined_state = pia6821_get_irq_a(device) | pia6821_get_irq_b(device);
123130
124logerror("GEN IRQ: %x\n", combined_state);
125   cputag_set_input_line(device->machine, "maincpu", 0, combined_state ? ASSERT_LINE : CLEAR_LINE);
131   logerror("GEN IRQ: %x\n", combined_state);
132   cpu_set_input_line(toratora->maincpu, 0, combined_state ? ASSERT_LINE : CLEAR_LINE);
126133}
127134
128135
129
130
131
132static int timer;
133
134136static INTERRUPT_GEN( toratora_timer )
135137{
136   const device_config *pia = devtag_get_device(device->machine, "pia_u1");
137static UINT8 last = 0;
138   timer++;   /* timer counting at 16 Hz */
138   toratora_state *state = (toratora_state *)device->machine->driver_data;
139   state->timer++;   /* timer counting at 16 Hz */
139140
140141   /* also, when the timer overflows (16 seconds) watchdog would kick in */
141   if (timer & 0x100) popmessage("watchdog!");
142   if (state->timer & 0x100)
143      popmessage("watchdog!");
142144
143
144   if (last != (input_port_read(device->machine, "INPUT") & 0x0f))
145   if (state->last != (input_port_read(device->machine, "INPUT") & 0x0f))
145146   {
146      last = input_port_read(device->machine, "INPUT") & 0x0f;
147      state->last = input_port_read(device->machine, "INPUT") & 0x0f;
147148      generic_pulse_irq_line(device, 0);
148149   }
149   pia6821_set_input_a(pia, input_port_read(device->machine, "INPUT") & 0x0f, 0);
150
151   pia6821_ca1_w(pia, 0, input_port_read(device->machine, "INPUT") & 0x10);
152
153   pia6821_ca2_w(pia, 0, input_port_read(device->machine, "INPUT") & 0x20);
150   pia6821_set_input_a(state->pia_u1, input_port_read(device->machine, "INPUT") & 0x0f, 0);
151   pia6821_ca1_w(state->pia_u1, 0, input_port_read(device->machine, "INPUT") & 0x10);
152   pia6821_ca2_w(state->pia_u1, 0, input_port_read(device->machine, "INPUT") & 0x20);
154153}
155154
156155static READ8_HANDLER( timer_r )
157156{
158   return timer;
157   toratora_state *state = (toratora_state *)space->machine->driver_data;
158   return state->timer;
159159}
160160
161161static WRITE8_HANDLER( clear_timer_w )
162162{
163   timer = 0;
163   toratora_state *state = (toratora_state *)space->machine->driver_data;
164   state->timer = 0;
164165}
165166
166167
167
168168/*************************************
169169 *
170170 *  Audio hardware
r6740r6741
279279static const pia6821_interface pia_u3_intf =
280280{
281281   DEVCB_NULL,      /* port A in */
282   DEVCB_HANDLER(port_b_u3_r),      /* port B in */
282   DEVCB_INPUT_PORT("DSW"),      /* port B in */
283283   DEVCB_NULL,      /* line CA1 in */
284284   DEVCB_NULL,      /* line CB1 in */
285285   DEVCB_NULL,      /* line CA2 in */
r6740r6741
307307static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
308308   AM_RANGE(0x0000, 0x0fff) AM_RAM
309309   AM_RANGE(0x1000, 0x7fff) AM_ROM  /* not fully populated */
310   AM_RANGE(0x8000, 0x9fff) AM_RAM AM_BASE(&toratora_videoram) AM_SIZE(&toratora_videoram_size)
310   AM_RANGE(0x8000, 0x9fff) AM_RAM AM_BASE_SIZE_MEMBER(toratora_state, videoram, videoram_size)
311311   AM_RANGE(0xa000, 0xf047) AM_NOP
312312   AM_RANGE(0xf048, 0xf049) AM_NOP
313313   AM_RANGE(0xf04a, 0xf04a) AM_WRITE(clear_tv_w)   /* the read is mark *LEDEN, but not used */
r6740r6741
368368 *
369369 *************************************/
370370
371static MACHINE_START( toratora )
372{
373   toratora_state *state = (toratora_state *)machine->driver_data;
374
375   state->maincpu = devtag_get_device(machine, "maincpu");
376   state->pia_u1 = devtag_get_device(machine, "pia_u1");
377   state->pia_u2 = devtag_get_device(machine, "pia_u2");
378   state->pia_u3 = devtag_get_device(machine, "pia_u3");
379
380   state_save_register_global(machine, state->timer);
381   state_save_register_global(machine, state->last);
382   state_save_register_global(machine, state->clear_tv);
383}
384
385static MACHINE_RESET( toratora )
386{
387   toratora_state *state = (toratora_state *)machine->driver_data;
388
389   state->timer = 0xff;
390   state->last = 0;
391   state->clear_tv = 0;
392}
393
371394static MACHINE_DRIVER_START( toratora )
372395
396   /* driver data */
397   MDRV_DRIVER_DATA(toratora_state)
398
373399   /* basic machine hardware */
374400   MDRV_CPU_ADD("maincpu", M6800,500000)   /* ?????? game speed is entirely controlled by this */
375401   MDRV_CPU_PROGRAM_MAP(main_map)
r6740r6741
379405   MDRV_PIA6821_ADD("pia_u2", pia_u2_intf)
380406   MDRV_PIA6821_ADD("pia_u3", pia_u3_intf)
381407
408   MDRV_MACHINE_START(toratora)
409   MDRV_MACHINE_RESET(toratora)
410
382411   /* video hardware */
383412   MDRV_VIDEO_UPDATE(toratora)
384413
r6740r6741
427456 *
428457 *************************************/
429458
430GAME( 1980, toratora, 0, toratora, toratora, 0, ROT90, "GamePlan", "Tora Tora (prototype?)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND )
459GAME( 1980, toratora, 0, toratora, toratora, 0, ROT90, "GamePlan", "Tora Tora (prototype?)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
src/mame/drivers/segamsys.c
r6740r6741
16011601         }
16021602         else
16031603         {
1604            memory_install_read_bank(space, 0x0000, 0xbfff, 0, 0, "bank5");
1604            memory_install_rom(space, 0x0000, 0xbfff, 0, 0, sms_rom);
16051605            memory_unmap_write(space, 0x0000, 0xbfff, 0, 0);
16061606         }
16071607
r6740r6741
16741674
16751675   megatech_set_genz80_as_sms_standard_ports(machine,  tag);
16761676
1677   /* fixed rom bank area */
1678   sms_rom = memory_install_rom(cputag_get_address_space(machine, tag, ADDRESS_SPACE_PROGRAM), 0x0000, 0xbfff, 0, 0, NULL);
1679
1680   memcpy(sms_rom, memory_region(machine, "maincpu"), 0xc000);
1681
16771682   if (mapper == MAPPER_STANDARD )
16781683   {
1679      /* fixed rom bank area */
1680      sms_rom = auto_alloc_array(machine, UINT8, 0x400000);
1681      memory_install_read_bank(cputag_get_address_space(machine, tag, ADDRESS_SPACE_PROGRAM), 0x0000, 0xbfff, 0, 0, "bank5");
1682      memory_unmap_write(cputag_get_address_space(machine, tag, ADDRESS_SPACE_PROGRAM), 0x0000, 0xbfff, 0, 0);
1683      memory_set_bankptr(machine,  "bank5", sms_rom );
16841684
1685      memcpy(sms_rom, memory_region(machine, "maincpu"), 0x400000);
16861685
1687
16881686      memory_install_write8_handler(cputag_get_address_space(machine, tag, ADDRESS_SPACE_PROGRAM), 0xfffc, 0xffff, 0, 0, mt_sms_standard_rom_bank_w);
16891687
16901688   }
16911689   else if (mapper == MAPPER_CODEMASTERS )
16921690   {
1693      /* fixed rom bank area */
1694      sms_rom = auto_alloc_array(machine, UINT8, 0xc000);
1695      memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000, 0xbfff, 0, 0, "bank5");
1696      memory_unmap_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000, 0xbfff, 0, 0);
1697      memory_set_bankptr(machine,  "bank5", sms_rom );
1698
1699      memcpy(sms_rom, memory_region(machine, "maincpu"), 0xc000);
1700
17011691      memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000, 0x0000, 0, 0, codemasters_rom_bank_0000_w);
17021692      memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x4000, 0x4000, 0, 0, codemasters_rom_bank_4000_w);
17031693      memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0x8000, 0, 0, codemasters_rom_bank_8000_w);
src/mame/drivers/blmbycar.c
r6740r6741
2626#include "driver.h"
2727#include "cpu/m68000/m68000.h"
2828#include "sound/okim6295.h"
29#include "blmbycar.h"
29#include "includes/blmbycar.h"
3030
3131
3232/***************************************************************************
src/mame/drivers/gbusters.c
r6740r6741
1010#include "driver.h"
1111#include "cpu/z80/z80.h"
1212#include "cpu/konami/konami.h" /* for the callback and the firq irq definition */
13#include "video/konamiic.h"
13#include "video/konicdev.h"
1414#include "sound/2151intf.h"
1515#include "sound/k007232.h"
16#include "konamipt.h"
16#include "includes/konamipt.h"
1717
1818/* prototypes */
1919static MACHINE_RESET( gbusters );
2020static KONAMI_SETLINES_CALLBACK( gbusters_banking );
2121
22extern void gbusters_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags, int *priority);
23extern void gbusters_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow);
2224
2325extern int gbusters_priority;
2426
r6740r6741
3032
3133static INTERRUPT_GEN( gbusters_interrupt )
3234{
33   if (K052109_is_IRQ_enabled())
35   const device_config *k052109 = devtag_get_device(device->machine, "k052109");
36
37   if (k052109_is_irq_enabled(k052109))
3438      cpu_set_input_line(device, KONAMI_IRQ_LINE, HOLD_LINE);
3539}
3640
r6740r6741
5256
5357static WRITE8_HANDLER( gbusters_1f98_w )
5458{
59   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
5560
5661   /* bit 0 = enable char ROM reading through the video RAM */
57   K052109_set_RMRD_line((data & 0x01) ? ASSERT_LINE : CLEAR_LINE);
62   k052109_set_rmrd_line(k052109, (data & 0x01) ? ASSERT_LINE : CLEAR_LINE);
5863
5964   /* bit 7 used (during gfx rom tests), but unknown */
6065
r6740r6741
122127#endif
123128}
124129
130/* special handlers to combine 052109 & 051960 */
131static READ8_HANDLER( k052109_051960_r )
132{
133   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
134   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
135
136   if (k052109_get_rmrd_line(k052109) == CLEAR_LINE)
137   {
138      if (offset >= 0x3800 && offset < 0x3808)
139         return k051937_r(k051960, offset - 0x3800);
140      else if (offset < 0x3c00)
141         return k052109_r(k052109, offset);
142      else
143         return k051960_r(k051960, offset - 0x3c00);
144   }
145   else
146      return k052109_r(k052109, offset);
147}
148
149static WRITE8_HANDLER( k052109_051960_w )
150{
151   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
152   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
153
154   if (offset >= 0x3800 && offset < 0x3808)
155      k051937_w(k051960, offset - 0x3800, data);
156   else if (offset < 0x3c00)
157      k052109_w(k052109, offset, data);
158   else
159      k051960_w(k051960, offset - 0x3c00, data);
160}
161
162
125163static ADDRESS_MAP_START( gbusters_map, ADDRESS_SPACE_PROGRAM, 8 )
126164   AM_RANGE(0x1f80, 0x1f80) AM_WRITE(gbusters_coin_counter_w)                  /* coin counters */
127165   AM_RANGE(0x1f84, 0x1f84) AM_WRITE(soundlatch_w)                           /* sound code # */
r6740r6741
135173   AM_RANGE(0x1f95, 0x1f95) AM_READ_PORT("DSW2")
136174   AM_RANGE(0x1f98, 0x1f98) AM_WRITE(gbusters_1f98_w)                        /* enable gfx ROM read through VRAM */
137175   AM_RANGE(0x1f9c, 0x1f9c) AM_WRITE(gbusters_unknown_w)                     /* ??? */
138   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(K052109_051960_r, K052109_051960_w)      /* tiles + sprites (RAM H21, G21 & H6) */
176   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(k052109_051960_r, k052109_051960_w)      /* tiles + sprites (RAM H21, G21 & H6) */
139177   AM_RANGE(0x4000, 0x57ff) AM_RAM                                       /* RAM I12 */
140178   AM_RANGE(0x5800, 0x5fff) AM_READWRITE(bankedram_r, bankedram_w) AM_BASE(&ram)   /* palette + work RAM (RAM D16 & C16) */
141179   AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank1")                                 /* banked ROM */
r6740r6741
223261   volume_callback   /* external port callback */
224262};
225263
264static const k052109_interface gbusters_k052109_intf =
265{
266   "gfx1", 0,
267   NORMAL_PLANE_ORDER,
268   KONAMI_ROM_DEINTERLEAVE_2,
269   gbusters_tile_callback
270};
271
272static const k051960_interface gbusters_k051960_intf =
273{
274   "gfx2", 1,
275   NORMAL_PLANE_ORDER,
276   KONAMI_ROM_DEINTERLEAVE_2,
277   gbusters_sprite_callback
278};
279
226280static MACHINE_DRIVER_START( gbusters )
227281
228282   /* basic machine hardware */
r6740r6741
250304   MDRV_VIDEO_START(gbusters)
251305   MDRV_VIDEO_UPDATE(gbusters)
252306
307   MDRV_K052109_ADD("k052109", gbusters_k052109_intf)
308   MDRV_K051960_ADD("k051960", gbusters_k051960_intf)
309
253310   /* sound hardware */
254311   MDRV_SPEAKER_STANDARD_MONO("mono")
255312
r6740r6741
373430}
374431
375432
376static DRIVER_INIT( gbusters )
377{
378   konami_rom_deinterleave_2(machine, "gfx1");
379   konami_rom_deinterleave_2(machine, "gfx2");
380}
381
382
383
384GAME( 1988, gbusters, 0,        gbusters, gbusters, gbusters, ROT90, "Konami", "Gang Busters (set 1)", 0 ) /* N02 & J03 program roms */
385GAME( 1988, gbustersa,gbusters, gbusters, gbusters, gbusters, ROT90, "Konami", "Gang Busters (set 2)", 0 ) /* unknown region program roms */
386GAME( 1988, crazycop, gbusters, gbusters, gbusters, gbusters, ROT90, "Konami", "Crazy Cop (Japan)", 0 )    /* M02 & J03 program roms */
433GAME( 1988, gbusters, 0,        gbusters, gbusters, 0, ROT90, "Konami", "Gang Busters (set 1)", 0 ) /* N02 & J03 program roms */
434GAME( 1988, gbustersa,gbusters, gbusters, gbusters, 0, ROT90, "Konami", "Gang Busters (set 2)", 0 ) /* unknown region program roms */
435GAME( 1988, crazycop, gbusters, gbusters, gbusters, 0, ROT90, "Konami", "Crazy Cop (Japan)", 0 )    /* M02 & J03 program roms */
src/mame/drivers/bogeyman.c
r6740r6741
1515#include "deprecat.h"
1616#include "cpu/m6502/m6502.h"
1717#include "sound/ay8910.h"
18#include "bogeyman.h"
18#include "includes/bogeyman.h"
1919
2020
2121/* Read/Write Handlers */
src/mame/drivers/m72.c
r6740r6741
8888#include "audio/m72.h"
8989#include "sound/dac.h"
9090#include "sound/2151intf.h"
91#include "iremipt.h"
92#include "m72.h"
91#include "includes/iremipt.h"
92#include "includes/m72.h"
9393#include "cpu/mcs51/mcs51.h"
9494
9595#define MASTER_CLOCK      XTAL_32MHz
r6740r6741
110110static MACHINE_START( m72 )
111111{
112112   scanline_timer = timer_alloc(machine, m72_scanline_interrupt, NULL);
113
114   state_save_register_global(machine, mcu_sample_addr);
115   state_save_register_global(machine, mcu_snd_cmd_latch);
113116}
114117
115118static TIMER_CALLBACK( synch_callback )
r6740r6741
124127   mcu_sample_addr = 0;
125128   mcu_snd_cmd_latch = 0;
126129
127   MACHINE_RESET_CALL(m72_sound);
128
129   state_save_register_global(machine, mcu_sample_addr);
130   state_save_register_global(machine, mcu_snd_cmd_latch);
131
132130   timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
133131   timer_call_after_resynch(machine,  NULL, 0, synch_callback);
134132}
r6740r6741
136134static MACHINE_RESET( xmultipl )
137135{
138136   m72_irq_base = 0x08;
139   MACHINE_RESET_CALL(m72_sound);
140137   timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
141138}
142139
143140static MACHINE_RESET( kengo )
144141{
145142   m72_irq_base = 0x18;
146   MACHINE_RESET_CALL(m72_sound);
147143   timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 0, 0), 0);
148144}
149145
r6740r6741
17961792   MDRV_MACHINE_START(m72)
17971793   MDRV_MACHINE_RESET(m72)
17981794
1795   MDRV_SOUND_START(m72)
1796   MDRV_SOUND_RESET(m72)
1797
17991798   /* video hardware */
18001799   MDRV_GFXDECODE(m72)
18011800   MDRV_PALETTE_LENGTH(512)
r6740r6741
18301829   MDRV_MACHINE_START(m72)
18311830   MDRV_MACHINE_RESET(m72)
18321831
1832   MDRV_SOUND_START(m72)
1833   MDRV_SOUND_RESET(m72)
1834
18331835   /* video hardware */
18341836   MDRV_GFXDECODE(m72)
18351837   MDRV_PALETTE_LENGTH(512)
r6740r6741
18901892   MDRV_MACHINE_START(m72)
18911893   MDRV_MACHINE_RESET(xmultipl)
18921894
1895   MDRV_SOUND_START(m72)
1896   MDRV_SOUND_RESET(m72)
1897
18931898   /* video hardware */
18941899   MDRV_GFXDECODE(m72)
18951900   MDRV_PALETTE_LENGTH(512)
r6740r6741
19311936   MDRV_MACHINE_START(m72)
19321937   MDRV_MACHINE_RESET(xmultipl)
19331938
1939   MDRV_SOUND_START(m72)
1940   MDRV_SOUND_RESET(m72)
1941
19341942   /* video hardware */
19351943   MDRV_GFXDECODE(m72)
19361944   MDRV_PALETTE_LENGTH(512)
r6740r6741
19721980   MDRV_MACHINE_START(m72)
19731981   MDRV_MACHINE_RESET(xmultipl)
19741982
1983   MDRV_SOUND_START(m72)
1984   MDRV_SOUND_RESET(m72)
1985
19751986   /* video hardware */
19761987   MDRV_GFXDECODE(rtype2)
19771988   MDRV_PALETTE_LENGTH(512)
r6740r6741
20122023   MDRV_MACHINE_START(m72)
20132024   MDRV_MACHINE_RESET(xmultipl)
20142025
2026   MDRV_SOUND_START(m72)
2027   MDRV_SOUND_RESET(m72)
2028
20152029   /* video hardware */
20162030   MDRV_GFXDECODE(m72)
20172031   MDRV_PALETTE_LENGTH(512)
r6740r6741
20532067   MDRV_MACHINE_START(m72)
20542068   MDRV_MACHINE_RESET(m72)
20552069
2070   MDRV_SOUND_START(m72)
2071   MDRV_SOUND_RESET(m72)
2072
20562073   /* video hardware */
20572074   MDRV_GFXDECODE(rtype2)
20582075   MDRV_PALETTE_LENGTH(512)
r6740r6741
20932110   MDRV_MACHINE_START(m72)
20942111   MDRV_MACHINE_RESET(m72)
20952112
2113   MDRV_SOUND_START(m72)
2114   MDRV_SOUND_RESET(m72)
2115
20962116   /* video hardware */
20972117   MDRV_GFXDECODE(majtitle)
20982118   MDRV_PALETTE_LENGTH(512)
r6740r6741
21332153   MDRV_MACHINE_START(m72)
21342154   MDRV_MACHINE_RESET(xmultipl)
21352155
2156   MDRV_SOUND_START(m72)
2157   MDRV_SOUND_RESET(m72)
2158
21362159   /* video hardware */
21372160   MDRV_GFXDECODE(rtype2)
21382161   MDRV_PALETTE_LENGTH(512)
r6740r6741
21742197   MDRV_MACHINE_START(m72)
21752198   MDRV_MACHINE_RESET(xmultipl)
21762199
2200   MDRV_SOUND_START(m72)
2201   MDRV_SOUND_RESET(m72)
2202
21772203   /* video hardware */
21782204   MDRV_GFXDECODE(rtype2)
21792205   MDRV_PALETTE_LENGTH(512)
r6740r6741
22152241   MDRV_MACHINE_START(m72)
22162242   MDRV_MACHINE_RESET(m72)
22172243
2244   MDRV_SOUND_START(m72)
2245   MDRV_SOUND_RESET(m72)
2246
22182247   /* video hardware */
22192248   MDRV_GFXDECODE(rtype2)
22202249   MDRV_PALETTE_LENGTH(512)
r6740r6741
22552284   MDRV_MACHINE_START(m72)
22562285   MDRV_MACHINE_RESET(kengo)
22572286
2287   MDRV_SOUND_START(m72)
2288   MDRV_SOUND_RESET(m72)
2289
22582290   /* video hardware */
22592291   MDRV_GFXDECODE(rtype2)
22602292   MDRV_PALETTE_LENGTH(512)
src/mame/drivers/crgolf.c
r6740r6741
3131
3232#include "driver.h"
3333#include "cpu/z80/z80.h"
34#include "crgolf.h"
34#include "includes/crgolf.h"
3535#include "sound/ay8910.h"
3636#include "sound/msm5205.h"
3737
src/mame/drivers/rmhaihai.c
r6740r6741
3434#include "sound/msm5205.h"
3535
3636static int gfxbank;
37static UINT8 *videoram;
38static UINT8 *colorram;
3739static tilemap *bg_tilemap;
3840
3941static WRITE8_HANDLER( rmhaihai_videoram_w )
4042{
41   space->machine->generic.videoram.u8[offset] = data;
43   videoram[offset] = data;
4244   tilemap_mark_tile_dirty(bg_tilemap, offset);
4345}
4446
4547static WRITE8_HANDLER( rmhaihai_colorram_w )
4648{
47   space->machine->generic.colorram.u8[offset] = data;
49   colorram[offset] = data;
4850   tilemap_mark_tile_dirty(bg_tilemap, offset);
4951}
5052
5153static TILE_GET_INFO( get_bg_tile_info )
5254{
53   int attr = machine->generic.colorram.u8[tile_index];
54   int code = machine->generic.videoram.u8[tile_index] + (gfxbank << 12) + ((attr & 0x07) << 8) + ((attr & 0x80) << 4);
55   int attr = colorram[tile_index];
56   int code = videoram[tile_index] + (gfxbank << 12) + ((attr & 0x07) << 8) + ((attr & 0x80) << 4);
5557   int color = (gfxbank << 5) + (attr >> 3);
5658
5759   SET_TILE_INFO(0, code, color, 0);
r6740r6741
174176static ADDRESS_MAP_START( rmhaihai_map, ADDRESS_SPACE_PROGRAM, 8 )
175177   AM_RANGE(0x0000, 0x9fff) AM_ROM
176178   AM_RANGE(0xa000, 0xa7ff) AM_RAM
177   AM_RANGE(0xa800, 0xafff) AM_RAM_WRITE(rmhaihai_colorram_w) AM_BASE_GENERIC(colorram)
178   AM_RANGE(0xb000, 0xb7ff) AM_RAM_WRITE(rmhaihai_videoram_w) AM_BASE_GENERIC(videoram)
179   AM_RANGE(0xa800, 0xafff) AM_RAM_WRITE(rmhaihai_colorram_w) AM_BASE(&colorram)
180   AM_RANGE(0xb000, 0xb7ff) AM_RAM_WRITE(rmhaihai_videoram_w) AM_BASE(&videoram)
179181   AM_RANGE(0xb83c, 0xb83c) AM_WRITENOP   // ??
180182   AM_RANGE(0xbc00, 0xbc00) AM_WRITENOP   // ??
181183   AM_RANGE(0xc000, 0xdfff) AM_ROM
r6740r6741
199201   AM_RANGE(0x0000, 0x7fff) AM_ROM
200202   AM_RANGE(0x8000, 0x9fff) AM_ROMBANK("bank1")
201203   AM_RANGE(0xa000, 0xa7ff) AM_RAM
202   AM_RANGE(0xa800, 0xafff) AM_RAM_WRITE(rmhaihai_colorram_w) AM_BASE_GENERIC(colorram)
203   AM_RANGE(0xb000, 0xb7ff) AM_RAM_WRITE(rmhaihai_videoram_w) AM_BASE_GENERIC(videoram)
204   AM_RANGE(0xa800, 0xafff) AM_RAM_WRITE(rmhaihai_colorram_w) AM_BASE(&colorram)
205   AM_RANGE(0xb000, 0xb7ff) AM_RAM_WRITE(rmhaihai_videoram_w) AM_BASE(&videoram)
204206   AM_RANGE(0xc000, 0xdfff) AM_ROMBANK("bank2")
205207   AM_RANGE(0xe000, 0xffff) AM_ROM
206208ADDRESS_MAP_END
src/mame/drivers/topspeed.c
r6740r6741
231231
232232#include "driver.h"
233233#include "cpu/z80/z80.h"
234#include "taitoipt.h"
234#include "includes/taitoipt.h"
235235#include "cpu/m68000/m68000.h"
236236#include "video/taitoic.h"
237237#include "audio/taitosnd.h"
src/mame/drivers/fantland.c
r6740r6741
5151#include "sound/3526intf.h"
5252#include "sound/dac.h"
5353#include "sound/msm5205.h"
54#include "fantland.h"
54#include "includes/fantland.h"
5555
5656/***************************************************************************
5757
src/mame/drivers/atarig1.c
r6740r6741
2222#include "cpu/m68000/m68000.h"
2323#include "audio/atarijsa.h"
2424#include "video/atarirle.h"
25#include "atarig1.h"
25#include "includes/atarig1.h"
2626
2727
2828
r6740r6741
4343static MACHINE_START( atarig1 )
4444{
4545   atarig1_state *state = (atarig1_state *)machine->driver_data;
46   atarigen_init(machine);
4647   state_save_register_global(machine, state->which_input);
4748}
4849
src/mame/drivers/toobin.c
r6740r6741
2121#include "cpu/m68000/m68000.h"
2222#include "machine/atarigen.h"
2323#include "audio/atarijsa.h"
24#include "toobin.h"
24#include "includes/toobin.h"
2525
2626#define MASTER_CLOCK      XTAL_32MHz
2727
r6740r6741
4242}
4343
4444
45static MACHINE_START( toobin )
46{
47   atarigen_init(machine);
48}
49
50
4551static MACHINE_RESET( toobin )
4652{
4753   toobin_state *state = (toobin_state *)machine->driver_data;
r6740r6741
224230   MDRV_CPU_ADD("maincpu", M68010, MASTER_CLOCK/4)
225231   MDRV_CPU_PROGRAM_MAP(main_map)
226232
233   MDRV_MACHINE_START(toobin)
227234   MDRV_MACHINE_RESET(toobin)
228235   MDRV_NVRAM_HANDLER(atarigen)
229236   MDRV_WATCHDOG_VBLANK_INIT(8)
src/mame/drivers/thunderx.c
r6740r6741
1111#include "driver.h"
1212#include "cpu/z80/z80.h"
1313#include "cpu/konami/konami.h" /* for the callback and the firq irq definition */
14#include "video/konamiic.h"
14#include "video/konicdev.h"
1515#include "sound/2151intf.h"
1616#include "sound/k007232.h"
17#include "konamipt.h"
17#include "includes/konamipt.h"
1818
1919static MACHINE_RESET( scontra );
2020static MACHINE_RESET( thunderx );
r6740r6741
2626
2727static UINT8 thunderx_1f98_data = 0;
2828
29extern void thunderx_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
30extern void thunderx_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask,int *shadow);
31
32
2933/***************************************************************************/
3034
3135static INTERRUPT_GEN( scontra_interrupt )
3236{
33   if (K052109_is_IRQ_enabled())
37   const device_config *k052109 = devtag_get_device(device->machine, "k052109");
38
39   if (k052109_is_irq_enabled(k052109))
3440      cpu_set_input_line(device, KONAMI_IRQ_LINE, HOLD_LINE);
3541}
3642
r6740r6741
296302
297303static WRITE8_HANDLER( thunderx_1f98_w )
298304{
299// logerror("%04x: 1f98_w %02x\n",cpu_get_pc(space->cpu),data);
305   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
300306
307   // logerror("%04x: 1f98_w %02x\n",cpu_get_pc(space->cpu),data);
308
301309   /* bit 0 = enable char ROM reading through the video RAM */
302   K052109_set_RMRD_line((data & 0x01) ? ASSERT_LINE : CLEAR_LINE);
310   k052109_set_rmrd_line(k052109, (data & 0x01) ? ASSERT_LINE : CLEAR_LINE);
303311
304312   /* bit 1 = PMC-BK */
305313   pmcbank = (data & 0x02) >> 1;
r6740r6741
369377   k007232_set_bank( device, bank_A, bank_B );
370378}
371379
380static READ8_HANDLER( k052109_051960_r )
381{
382   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
383   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
384
385   if (k052109_get_rmrd_line(k052109) == CLEAR_LINE)
386   {
387      if (offset >= 0x3800 && offset < 0x3808)
388         return k051937_r(k051960, offset - 0x3800);
389      else if (offset < 0x3c00)
390         return k052109_r(k052109, offset);
391      else
392         return k051960_r(k051960, offset - 0x3c00);
393   }
394   else
395      return k052109_r(k052109, offset);
396}
397
398static WRITE8_HANDLER( k052109_051960_w )
399{
400   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
401   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
402
403   if (offset >= 0x3800 && offset < 0x3808)
404      k051937_w(k051960, offset - 0x3800, data);
405   else if (offset < 0x3c00)
406      k052109_w(k052109, offset, data);
407   else
408      k051960_w(k051960, offset - 0x3c00, data);
409}
410
372411/***************************************************************************/
373412
374413static ADDRESS_MAP_START( scontra_map, ADDRESS_SPACE_PROGRAM, 8 )
r6740r6741
383422   AM_RANGE(0x1f94, 0x1f94) AM_READ_PORT("DSW1")
384423   AM_RANGE(0x1f95, 0x1f95) AM_READ_PORT("DSW2")
385424   AM_RANGE(0x1f98, 0x1f98) AM_WRITE(thunderx_1f98_w)
386   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(K052109_051960_r, K052109_051960_w)      /* video RAM + sprite RAM */
425   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(k052109_051960_r, k052109_051960_w)      /* video RAM + sprite RAM */
387426
388427   AM_RANGE(0x4000, 0x57ff) AM_RAM
389428   AM_RANGE(0x5800, 0x5fff) AM_READWRITE(scontra_bankedram_r, scontra_bankedram_w) AM_BASE(&ram)         /* palette + work RAM */
r6740r6741
403442   AM_RANGE(0x1f94, 0x1f94) AM_READ_PORT("DSW1")
404443   AM_RANGE(0x1f95, 0x1f95) AM_READ_PORT("DSW2")
405444   AM_RANGE(0x1f98, 0x1f98) AM_READWRITE(thunderx_1f98_r, thunderx_1f98_w) /* registers */
406   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(K052109_051960_r, K052109_051960_w)
445   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(k052109_051960_r, k052109_051960_w)
407446
408447   AM_RANGE(0x4000, 0x57ff) AM_RAM
409448   AM_RANGE(0x5800, 0x5fff) AM_READWRITE(thunderx_bankedram_r, thunderx_bankedram_w) AM_BASE(&ram)         /* palette + work RAM + unknown RAM */
r6740r6741
574613
575614
576615
616static const k052109_interface thunderx_k052109_intf =
617{
618   "gfx1", 0,
619   NORMAL_PLANE_ORDER,
620   KONAMI_ROM_DEINTERLEAVE_2,
621   thunderx_tile_callback
622};
623
624static const k051960_interface thunderx_k051960_intf =
625{
626   "gfx2", 1,
627   NORMAL_PLANE_ORDER,
628   KONAMI_ROM_DEINTERLEAVE_2,
629   thunderx_sprite_callback
630};
631
577632static MACHINE_DRIVER_START( scontra )
578633
579634   /* basic machine hardware */
r6740r6741
601656   MDRV_VIDEO_START(scontra)
602657   MDRV_VIDEO_UPDATE(scontra)
603658
659   MDRV_K052109_ADD("k052109", thunderx_k052109_intf)
660   MDRV_K051960_ADD("k051960", thunderx_k051960_intf)
661
604662   /* sound hardware */
605663   MDRV_SPEAKER_STANDARD_MONO("mono")
606664
r6740r6741
642700   MDRV_VIDEO_START(scontra)
643701   MDRV_VIDEO_UPDATE(scontra)
644702
703   MDRV_K052109_ADD("k052109", thunderx_k052109_intf)
704   MDRV_K051960_ADD("k051960", thunderx_k051960_intf)
705
645706   /* sound hardware */
646707   MDRV_SPEAKER_STANDARD_MONO("mono")
647708
r6740r6741
931992   pmcram = &RAM[0x28800];
932993}
933994
934static DRIVER_INIT( scontra )
935{
936   konami_rom_deinterleave_2(machine, "gfx1");
937   konami_rom_deinterleave_2(machine, "gfx2");
938}
939
940
941
942GAME( 1988, scontra,  0,        scontra,  scontra,  scontra, ROT90, "Konami", "Super Contra", 0 )
943GAME( 1988, scontraj, scontra,  scontra,  scontra,  scontra, ROT90, "Konami", "Super Contra (Japan)", 0 )
944GAME( 1988, thunderx, 0,        thunderx, thunderx, scontra, ROT0,  "Konami", "Thunder Cross (set 1)", 0 )
945GAME( 1988, thunderxa,thunderx, thunderx, thunderx, scontra, ROT0,  "Konami", "Thunder Cross (set 2)", 0 )
946GAME( 1988, thunderxb,thunderx, thunderx, thunderx, scontra, ROT0,  "Konami", "Thunder Cross (set 3)", 0 )
947GAME( 1988, thunderxj,thunderx, thunderx, thnderxj, scontra, ROT0,  "Konami", "Thunder Cross (Japan)", 0 )
948//GAME( 1988, thndrxja, thunderx, thunderx, thndrxja, scontra, ROT0,  "Konami", "Thunder Cross (Japan, newer revision)", 0 )
995GAME( 1988, scontra,  0,        scontra,  scontra,  0, ROT90, "Konami", "Super Contra", 0 )
996GAME( 1988, scontraj, scontra,  scontra,  scontra,  0, ROT90, "Konami", "Super Contra (Japan)", 0 )
997GAME( 1988, thunderx, 0,        thunderx, thunderx, 0, ROT0,  "Konami", "Thunder Cross (set 1)", 0 )
998GAME( 1988, thunderxa,thunderx, thunderx, thunderx, 0, ROT0,  "Konami", "Thunder Cross (set 2)", 0 )
999GAME( 1988, thunderxb,thunderx, thunderx, thunderx, 0, ROT0,  "Konami", "Thunder Cross (set 3)", 0 )
1000GAME( 1988, thunderxj,thunderx, thunderx, thnderxj, 0, ROT0,  "Konami", "Thunder Cross (Japan)", 0 )
1001//GAME( 1988, thndrxja, thunderx, thunderx, thndrxja, 0, ROT0,  "Konami", "Thunder Cross (Japan, newer revision)", 0 )
src/mame/drivers/videopin.c
r6740r6741
1212
1313#include "driver.h"
1414#include "cpu/m6502/m6502.h"
15#include "videopin.h"
15#include "includes/videopin.h"
1616#include "videopin.lh"
1717#include "sound/discrete.h"
1818
src/mame/drivers/tumbleb.c
r6740r6741
312312#include "cpu/z80/z80.h"
313313#include "cpu/m68000/m68000.h"
314314#include "cpu/h6280/h6280.h"
315#include "decocrpt.h"
315#include "includes/decocrpt.h"
316316#include "sound/2151intf.h"
317317#include "sound/3812intf.h"
318318#include "sound/okim6295.h"
src/mame/drivers/ultratnk.c
r6740r6741
66
77#include "driver.h"
88#include "cpu/m6502/m6502.h"
9#include "ultratnk.h"
9#include "includes/ultratnk.h"
1010#include "audio/sprint4.h"
1111
1212#define MASTER_CLOCK    12096000
src/mame/drivers/olibochu.c
r6740r6741
5656#include "deprecat.h"
5757#include "sound/ay8910.h"
5858
59static UINT8 *videoram;
60static UINT8 *colorram;
5961static tilemap *bg_tilemap;
6062
6163static PALETTE_INIT( olibochu )
r6740r6741
9799
98100static WRITE8_HANDLER( olibochu_videoram_w )
99101{
100   space->machine->generic.videoram.u8[offset] = data;
102   videoram[offset] = data;
101103   tilemap_mark_tile_dirty(bg_tilemap, offset);
102104}
103105
104106static WRITE8_HANDLER( olibochu_colorram_w )
105107{
106   space->machine->generic.colorram.u8[offset] = data;
108   colorram[offset] = data;
107109   tilemap_mark_tile_dirty(bg_tilemap, offset);
108110}
109111
r6740r6741
120122
121123static TILE_GET_INFO( get_bg_tile_info )
122124{
123   int attr = machine->generic.colorram.u8[tile_index];
124   int code = machine->generic.videoram.u8[tile_index] + ((attr & 0x20) << 3);
125   int attr = colorram[tile_index];
126   int code = videoram[tile_index] + ((attr & 0x20) << 3);
125127   int color = (attr & 0x1f) + 0x20;
126128   int flags = ((attr & 0x40) ? TILE_FLIPX : 0) | ((attr & 0x80) ? TILE_FLIPY : 0);
127129
r6740r6741
220222
221223static ADDRESS_MAP_START( olibochu_map, ADDRESS_SPACE_PROGRAM, 8 )
222224   AM_RANGE(0x0000, 0x7fff) AM_ROM
223   AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(olibochu_videoram_w) AM_BASE_GENERIC(videoram)
224   AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(olibochu_colorram_w) AM_BASE_GENERIC(colorram)
225   AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(olibochu_videoram_w) AM_BASE(&videoram)
226   AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(olibochu_colorram_w) AM_BASE(&colorram)
225227   AM_RANGE(0x9000, 0x903f) AM_RAM //???
226228   AM_RANGE(0x9800, 0x983f) AM_RAM //???
227229   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")
src/mame/drivers/m90.c
r6740r6741
2828#include "cpu/z80/z80.h"
2929#include "cpu/nec/nec.h"
3030#include "deprecat.h"
31#include "iremipt.h"
31#include "includes/iremipt.h"
3232#include "machine/irem_cpu.h"
3333#include "audio/m72.h"
3434#include "sound/dac.h"
r6740r6741
710710   MDRV_CPU_VBLANK_INT_HACK(nmi_line_pulse,128)   /* clocked by V1? (Vigilante) */
711711                        /* IRQs are generated by main Z80 and YM2151 */
712712
713   MDRV_MACHINE_RESET(m72_sound)
713   MDRV_SOUND_START(m72)
714   MDRV_SOUND_RESET(m72)
714715
715716   /* video hardware */
716717   MDRV_SCREEN_ADD("screen", RASTER)
r6740r6741
790791   MDRV_CPU_IO_MAP(m90_sound_cpu_io_map)
791792   MDRV_CPU_VBLANK_INT_HACK(nmi_line_pulse,128)   /* clocked by V1? (Vigilante) */
792793                        /* IRQs are generated by main Z80 and YM2151 */
793   MDRV_MACHINE_RESET(m72_sound)
794   MDRV_SOUND_START(m72)
795   MDRV_SOUND_RESET(m72)
794796
795797   /* video hardware */
796798   MDRV_SCREEN_ADD("screen", RASTER)
r6740r6741
834836   MDRV_CPU_IO_MAP(bbmanw_sound_io_map)
835837   MDRV_CPU_VBLANK_INT_HACK(nmi_line_pulse,128)   /* clocked by V1? (Vigilante) */
836838                        /* IRQs are generated by main Z80 and YM2151 */
837   MDRV_MACHINE_RESET(m72_sound)
839   MDRV_SOUND_START(m72)
840   MDRV_SOUND_RESET(m72)
838841
839842   /* video hardware */
840843   MDRV_SCREEN_ADD("screen", RASTER)
r6740r6741
903906   MDRV_CPU_IO_MAP(m90_sound_cpu_io_map)
904907   MDRV_CPU_VBLANK_INT_HACK(nmi_line_pulse,128)   /* clocked by V1? (Vigilante) */
905908                        /* IRQs are generated by main Z80 and YM2151 */
906   MDRV_MACHINE_RESET(m72_sound)
909   MDRV_SOUND_START(m72)
910   MDRV_SOUND_RESET(m72)
907911
908912   /* video hardware */
909913   MDRV_SCREEN_ADD("screen", RASTER)
src/mame/drivers/phoenix.c
r6740r6741
3434#include "sound/tms36xx.h"
3535#include "cpu/i8085/i8085.h"
3636#include "sound/ay8910.h"
37#include "phoenix.h"
37#include "includes/phoenix.h"
3838
3939
4040static ADDRESS_MAP_START( phoenix_memory_map, ADDRESS_SPACE_PROGRAM, 8 )
src/mame/drivers/dday.c
r6740r6741
5252#include "driver.h"
5353#include "cpu/z80/z80.h"
5454#include "sound/ay8910.h"
55#include "dday.h"
55#include "includes/dday.h"
5656
5757
5858static ADDRESS_MAP_START( dday_map, ADDRESS_SPACE_PROGRAM, 8 )
r6740r6741
353353ROM_END
354354
355355
356GAME( 1982, dday,  0,    dday, dday,  0, ROT0, "Olympia", "D-Day", GAME_IMPERFECT_COLORS )
357GAME( 1982, ddayc, dday, dday, ddayc, 0, ROT0, "Olympia (Centuri license)", "D-Day (Centuri)", GAME_IMPERFECT_COLORS )
356GAME( 1982, dday,  0,    dday, dday,  0, ROT0, "Olympia", "D-Day", GAME_IMPERFECT_COLORS | GAME_SUPPORTS_SAVE )
357GAME( 1982, ddayc, dday, dday, ddayc, 0, ROT0, "Olympia (Centuri license)", "D-Day (Centuri)", GAME_IMPERFECT_COLORS | GAME_SUPPORTS_SAVE )
src/mame/drivers/cyberbal.c
r6740r6741
2626#include "sound/dac.h"
2727#include "rendlay.h"
2828#include "audio/atarijsa.h"
29#include "cyberbal.h"
29#include "includes/cyberbal.h"
3030
3131
3232/*************************************
r6740r6741
4343}
4444
4545
46static MACHINE_START( cyberbal )
47{
48   cyberbal_state *state = (cyberbal_state *)machine->driver_data;
49   atarigen_init(machine);
50
51   state_save_register_global(machine, state->fast_68k_int);
52   state_save_register_global(machine, state->io_68k_int);
53   state_save_register_global(machine, state->sound_data_from_68k);
54   state_save_register_global(machine, state->sound_data_from_6502);
55   state_save_register_global(machine, state->sound_data_from_68k_ready);
56   state_save_register_global(machine, state->sound_data_from_6502_ready);
57}
58
59
4660static MACHINE_RESET( cyberbal )
4761{
4862   cyberbal_state *state = (cyberbal_state *)machine->driver_data;
r6740r6741
436450
437451   MDRV_QUANTUM_TIME(HZ(600))
438452
453   MDRV_MACHINE_START(cyberbal)
439454   MDRV_MACHINE_RESET(cyberbal)
440455   MDRV_NVRAM_HANDLER(atarigen)
441456
r6740r6741
483498   MDRV_CPU_PROGRAM_MAP(cyberb2p_map)
484499   MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen)
485500
501   MDRV_MACHINE_START(cyberbal)
486502   MDRV_MACHINE_RESET(cyberb2p)
487503   MDRV_NVRAM_HANDLER(atarigen)
488504
src/mame/drivers/lockon.c
r6740r6741
1414#include "cpu/nec/nec.h"
1515#include "sound/2203intf.h"
1616#include "sound/flt_vol.h"
17#include "lockon.h"
17#include "includes/lockon.h"
1818
1919#define V30_GND_ADDR   ((lockon_ctrl_reg & 0x3) << 16)
2020#define V30_OBJ_ADDR   ((lockon_ctrl_reg & 0x18) << 13)
src/mame/drivers/gijoe.c
r6740r6741
3838
3939#include "driver.h"
4040#include "cpu/m68000/m68000.h"
41#include "video/konamiic.h"
41#include "video/konicdev.h"
4242#include "cpu/z80/z80.h"
43#include "machine/eeprom.h"
43#include "machine/eepromdev.h"
4444#include "sound/k054539.h"
45#include "konamipt.h"
45#include "includes/konamipt.h"
4646
4747VIDEO_START( gijoe );
4848VIDEO_UPDATE( gijoe );
4949
50extern void gijoe_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask);
51extern void gijoe_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags);
52
5053static UINT16 *gijoe_workram;
5154static UINT16 cur_control2;
52static int init_eeprom_count;
5355static emu_timer *dmadelay_timer;
5456
5557static const eeprom_interface eeprom_intf =
r6740r6741
6365   "0100110000000" /* unlock command */
6466};
6567
66static NVRAM_HANDLER( gijoe )
67{
68   if (read_or_write)
69      eeprom_save(file);
70   else
71   {
72      eeprom_init(machine, &eeprom_intf);
7368
74      if (file)
75      {
76         init_eeprom_count = 0;
77         eeprom_load(file);
78      }
79      else
80         init_eeprom_count = 2720;
81   }
82}
83
84static READ16_HANDLER( control1_r )
85{
86   int res;
87
88   /* bit 8  is EEPROM data */
89   /* bit 9  is EEPROM ready */
90   /* bit 11 is service button */
91   res = input_port_read(space->machine, "START");
92
93   if (init_eeprom_count)
94   {
95      init_eeprom_count--;
96      res &= 0xf7ff;
97   }
98
99   return res;
100}
101
10269static READ16_HANDLER( control2_r )
10370{
10471   return cur_control2;
r6740r6741
10673
10774static WRITE16_HANDLER( control2_w )
10875{
109   if(ACCESSING_BITS_0_7) {
76   const device_config *k053246 = devtag_get_device(space->machine, "k053246");
77   if(ACCESSING_BITS_0_7)
78   {
11079      /* bit 0  is data */
11180      /* bit 1  is cs (active low) */
11281      /* bit 2  is clock (active high) */
11382      /* bit 3  (unknown: coin) */
11483      /* bit 5  is enable irq 6 */
11584      /* bit 7  (unknown: enable irq 5?) */
85      input_port_write(space->machine, "EEPROMOUT", data, 0xff);
11686
117      eeprom_write_bit(data & 0x01);
118      eeprom_set_cs_line((data & 0x02) ? CLEAR_LINE : ASSERT_LINE);
119      eeprom_set_clock_line((data & 0x04) ? ASSERT_LINE : CLEAR_LINE);
12087      cur_control2 = data;
12188
12289      /* bit 6 = enable sprite ROM reading */
123      K053246_set_OBJCHA_line((data & 0x0040) ? ASSERT_LINE : CLEAR_LINE);
90      k053246_set_objcha_line(k053246, (data & 0x0040) ? ASSERT_LINE : CLEAR_LINE);
12491   }
12592}
12693
12794static void gijoe_objdma(running_machine *machine)
12895{
96   const device_config *k053246 = devtag_get_device(machine, "k053246");
12997   UINT16 *src_head, *src_tail, *dst_head, *dst_tail;
13098
13199   src_head = machine->generic.spriteram.u16;
132100   src_tail = machine->generic.spriteram.u16 + 255*8;
133   K053247_export_config(&dst_head, 0, 0, 0, 0);
101   k053247_get_ram(k053246, &dst_head);
134102   dst_tail = dst_head + 255*8;
135103
136104   for (; src_head<=src_tail; src_head+=8)
r6740r6741
156124
157125static INTERRUPT_GEN( gijoe_interrupt )
158126{
127   const device_config *k053246 = devtag_get_device(device->machine, "k053246");
128   const device_config *k056832 = devtag_get_device(device->machine, "k056832");
129
159130   // global interrupt masking (*this game only)
160   if (!K056832_is_IRQ_enabled(0)) return;
131   if (!k056832_is_irq_enabled(k056832, 0))
132      return;
161133
162   if (K053246_is_IRQ_enabled())
134   if (k053246_is_irq_enabled(k053246))
163135   {
164136      gijoe_objdma(device->machine);
165137
r6740r6741
174146
175147static WRITE16_HANDLER( sound_cmd_w )
176148{
177   if(ACCESSING_BITS_0_7) {
149   if(ACCESSING_BITS_0_7)
150   {
178151      data &= 0xff;
179152      soundlatch_w(space, 0, data);
180153   }
r6740r6741
206179static ADDRESS_MAP_START( gijoe_map, ADDRESS_SPACE_PROGRAM, 16 )
207180   AM_RANGE(0x000000, 0x0fffff) AM_ROM
208181   AM_RANGE(0x100000, 0x100fff) AM_RAM AM_BASE_GENERIC(spriteram)                        // Sprites
209   AM_RANGE(0x110000, 0x110007) AM_WRITE(K053246_word_w)
210   AM_RANGE(0x120000, 0x121fff) AM_READWRITE(K056832_ram_word_r, K056832_ram_word_w)      // Graphic planes
211   AM_RANGE(0x122000, 0x123fff) AM_READWRITE(K056832_ram_word_r, K056832_ram_word_w)      // Graphic planes mirror read
212   AM_RANGE(0x130000, 0x131fff) AM_READ(K056832_rom_word_r)                         // Passthrough to tile roms
213   AM_RANGE(0x160000, 0x160007) AM_WRITE(K056832_b_word_w)                           // VSCCS (board dependent)
182   AM_RANGE(0x110000, 0x110007) AM_DEVWRITE("k053246", k053246_word_w)
183   AM_RANGE(0x120000, 0x121fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w)      // Graphic planes
184   AM_RANGE(0x122000, 0x123fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w)      // Graphic planes mirror read
185   AM_RANGE(0x130000, 0x131fff) AM_DEVREAD("k056832", k056832_rom_word_r)                         // Passthrough to tile roms
186   AM_RANGE(0x160000, 0x160007) AM_DEVWRITE("k056832", k056832_b_word_w)                           // VSCCS (board dependent)
214187   AM_RANGE(0x170000, 0x170001) AM_WRITENOP                                    // Watchdog
215188   AM_RANGE(0x180000, 0x18ffff) AM_RAM AM_BASE(&gijoe_workram)               // Main RAM.  Spec. 180000-1803ff, 180400-187fff
216189   AM_RANGE(0x190000, 0x190fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
217   AM_RANGE(0x1a0000, 0x1a001f) AM_WRITE(K053251_lsb_w)
218   AM_RANGE(0x1b0000, 0x1b003f) AM_WRITE(K056832_word_w)
190   AM_RANGE(0x1a0000, 0x1a001f) AM_DEVWRITE("k053251", k053251_lsb_w)
191   AM_RANGE(0x1b0000, 0x1b003f) AM_DEVWRITE("k056832", k056832_word_w)
219192   AM_RANGE(0x1c000c, 0x1c000d) AM_WRITE(sound_cmd_w)
220193   AM_RANGE(0x1c0014, 0x1c0015) AM_READ(sound_status_r)
221194   AM_RANGE(0x1c0000, 0x1c001f) AM_RAM
r6740r6741
223196   AM_RANGE(0x1e0000, 0x1e0001) AM_READ_PORT("P1_P2")
224197   AM_RANGE(0x1e0002, 0x1e0003) AM_READ_PORT("P3_P4")
225198   AM_RANGE(0x1e4000, 0x1e4001) AM_READ_PORT("SYSTEM")
226   AM_RANGE(0x1e4002, 0x1e4003) AM_READ(control1_r)
199   AM_RANGE(0x1e4002, 0x1e4003) AM_READ_PORT("START")
227200   AM_RANGE(0x1e8000, 0x1e8001) AM_READWRITE(control2_r, control2_w)
228   AM_RANGE(0x1f0000, 0x1f0001) AM_READ(K053246_word_r)
201   AM_RANGE(0x1f0000, 0x1f0001) AM_DEVREAD("k053246", k053246_word_r)
229202#if JOE_DEBUG
230   AM_RANGE(0x110000, 0x110007) AM_READ(K053246_reg_word_r)
231   AM_RANGE(0x160000, 0x160007) AM_READ(K056832_b_word_r)
232   AM_RANGE(0x1a0000, 0x1a001f) AM_READ(K053251_lsb_r)
233   AM_RANGE(0x1b0000, 0x1b003f) AM_READ(K056832_word_r)
203   AM_RANGE(0x110000, 0x110007) AM_DEVREAD("k053246", k053246_reg_word_r)
204   AM_RANGE(0x160000, 0x160007) AM_DEVREAD("k056832", k056832_b_word_r)
205   AM_RANGE(0x1a0000, 0x1a001f) AM_DEVREAD("k053251", k053251_lsb_r)
206   AM_RANGE(0x1b0000, 0x1b003f) AM_DEVREAD("k056832", k056832_word_r)
234207#endif
235208ADDRESS_MAP_END
236209
r6740r6741
248221   PORT_BIT( 0x0002, IP_ACTIVE_LOW,  IPT_START2 )
249222   PORT_BIT( 0x0004, IP_ACTIVE_LOW,  IPT_START3 )
250223   PORT_BIT( 0x0008, IP_ACTIVE_LOW,  IPT_START4 )
251   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   // EEPROM data
224   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
252225   PORT_BIT( 0x0200, IP_ACTIVE_LOW,  IPT_SPECIAL )   // EEPROM ready (always 1)
253226   PORT_SERVICE_NO_TOGGLE( 0x0800, IP_ACTIVE_LOW )
254227
228   PORT_START( "EEPROMOUT" )
229   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
230   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
231   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
232
255233   PORT_START("SYSTEM")
256234   PORT_BIT( 0x0001, IP_ACTIVE_LOW,  IPT_COIN1 )
257235   PORT_BIT( 0x0002, IP_ACTIVE_LOW,  IPT_COIN2 )
r6740r6741
288266   sound_nmi
289267};
290268
269static const k056832_interface gijoe_k056832_intf =
270{
271   "gfx1", 0,
272   K056832_BPP_4,
273   1, 0,
274   KONAMI_ROM_DEINTERLEAVE_2,
275   gijoe_tile_callback, "none"
276};
277
278static const k053247_interface gijoe_k053247_intf =
279{
280   "screen",
281   "gfx2", 1,
282   NORMAL_PLANE_ORDER,
283   -37, 20,
284   KONAMI_ROM_DEINTERLEAVE_4,
285   gijoe_sprite_callback
286};
287
291288static MACHINE_DRIVER_START( gijoe )
292289
293290   /* basic machine hardware */
r6740r6741
299296   MDRV_CPU_PROGRAM_MAP(sound_map)
300297
301298   MDRV_MACHINE_START(gijoe)
302   MDRV_NVRAM_HANDLER(gijoe)
303299
300   MDRV_EEPROM_NODEFAULT_ADD("eeprom", eeprom_intf)
301
304302   /* video hardware */
305303   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_UPDATE_BEFORE_VBLANK)
306304
r6740r6741
316314   MDRV_VIDEO_START(gijoe)
317315   MDRV_VIDEO_UPDATE(gijoe)
318316
317   MDRV_K056832_ADD("k056832", gijoe_k056832_intf)
318   MDRV_K053246_ADD("k053246", gijoe_k053247_intf)
319   MDRV_K053251_ADD("k053251")
320
319321   /* sound hardware */
320322   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
321323
r6740r6741
398400   ROM_LOAD( "069a04", 0x000000, 0x200000, CRC(11d6dcd6) SHA1(04cbff9f61cd8641db538db809ddf20da29fd5ac) )
399401ROM_END
400402
401static DRIVER_INIT( gijoe )
402{
403   konami_rom_deinterleave_2(machine, "gfx1");
404   konami_rom_deinterleave_4(machine, "gfx2");
405}
406403
407GAME( 1992, gijoe,  0,     gijoe, gijoe, gijoe, ROT0, "Konami", "GI Joe (World)", 0)
408GAME( 1992, gijoeu, gijoe, gijoe, gijoe, gijoe, ROT0, "Konami", "GI Joe (US)", 0)
409GAME( 1992, gijoej, gijoe, gijoe, gijoe, gijoe, ROT0, "Konami", "GI Joe (Japan)", 0)
404GAME( 1992, gijoe,  0,     gijoe, gijoe, 0, ROT0, "Konami", "GI Joe (World)", 0)
405GAME( 1992, gijoeu, gijoe, gijoe, gijoe, 0, ROT0, "Konami", "GI Joe (US)", 0)
406GAME( 1992, gijoej, gijoe, gijoe, gijoe, 0, ROT0, "Konami", "GI Joe (Japan)", 0)
src/mame/drivers/gei.c
r6740r6741
140140   set_led_status(device->machine, 9,data & 0x08);
141141
142142   /* bit 5 - ticket out in trivia games */
143   ticket_dispenser_w(space, 0, (data & 0x20)<< 2);
143   ticket_dispenser_w(devtag_get_device(device->machine, "ticket"), 0, (data & 0x20)<< 2);
144144
145145   /* bit 6 enables NMI */
146146   interrupt_enable_w(space, 0, data & 0x40);
r6740r6741
501501   PORT_START("IN0")
502502   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2)
503503   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(2)
504   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(ticket_dispenser_0_port_r, 0)      /* ticket status */
504   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket", ticket_dispenser_line_r)      /* ticket status */
505505   PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
506506   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
507507   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
609609   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_IMPULSE(2) PORT_CONDITION("DSWA", 0x40, PORTCOND_EQUALS, 0x00) PORT_NAME ("Start in no coins mode")
610610   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(2) PORT_CONDITION("DSWA", 0x40, PORTCOND_EQUALS, 0x40)
611611   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_CONDITION("DSWA", 0x40, PORTCOND_EQUALS, 0x00)
612   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(ticket_dispenser_0_port_r, 0)      /* ticket status */
612   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket", ticket_dispenser_line_r)      /* ticket status */
613613   PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
614614   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
615615   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
786786   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_IMPULSE(2) PORT_CONDITION("DSWA", 0x40, PORTCOND_EQUALS, 0x00) PORT_NAME ("Start in no coins mode")
787787   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(2) PORT_CONDITION("DSWA", 0x40, PORTCOND_EQUALS, 0x40)
788788   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_CONDITION("DSWA", 0x40, PORTCOND_EQUALS, 0x00)
789   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(ticket_dispenser_0_port_r, 0)      /* ticket status */
789   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket", ticket_dispenser_line_r)      /* ticket status */
790790   PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
791791   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
792792   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
892892   PORT_MODIFY("IN0")
893893   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2)
894894   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(2)
895   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(ticket_dispenser_0_port_r, 0)      /* ticket status */
895   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket", ticket_dispenser_line_r)      /* ticket status */
896896   PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
897897   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
898898   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
992992   }
993993};
994994
995static MACHINE_RESET( getrivia )
996{
997   ticket_dispenser_init(machine, 100, 1, 1);
998}
999
1000static MACHINE_RESET( gselect )
1001{
1002}
1003
1004995static MACHINE_DRIVER_START( getrivia )
1005996   MDRV_CPU_ADD("maincpu",Z80,4000000) /* 4 MHz */
1006997   MDRV_CPU_PROGRAM_MAP(getrivia_map)
r6740r6741
10171008   MDRV_PALETTE_LENGTH(8)
10181009   MDRV_PALETTE_INIT(gei)
10191010
1020   MDRV_MACHINE_RESET(getrivia)
10211011   MDRV_NVRAM_HANDLER(generic_0fill)
10221012
10231013   MDRV_VIDEO_START(generic_bitmapped)
r6740r6741
10251015
10261016   MDRV_PPI8255_ADD( "ppi8255_0", getrivia_ppi8255_intf[0] )
10271017   MDRV_PPI8255_ADD( "ppi8255_1", getrivia_ppi8255_intf[1] )
1018   MDRV_TICKET_DISPENSER_ADD("ticket", 100, TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_HIGH)
10281019
10291020   /* sound hardware */
10301021   MDRV_SPEAKER_STANDARD_MONO("mono")
r6740r6741
10481039   /* basic machine hardware */
10491040   MDRV_IMPORT_FROM(getrivia)
10501041
1042   MDRV_DEVICE_REMOVE("ticket")
1043
10511044   MDRV_CPU_MODIFY("maincpu")
10521045   MDRV_CPU_PROGRAM_MAP(gselect_map)
10531046
1054   MDRV_MACHINE_RESET(gselect)
1055
10561047   MDRV_PPI8255_RECONFIG( "ppi8255_0", gselect_ppi8255_intf[0] )
10571048   MDRV_PPI8255_RECONFIG( "ppi8255_1", gselect_ppi8255_intf[1] )
10581049MACHINE_DRIVER_END
r6740r6741
10621053   /* basic machine hardware */
10631054   MDRV_IMPORT_FROM(getrivia)
10641055
1056   MDRV_DEVICE_REMOVE("ticket")
1057
10651058   MDRV_CPU_MODIFY("maincpu")
10661059   MDRV_CPU_PROGRAM_MAP(gselect_map)
10671060
1068   MDRV_MACHINE_RESET(gselect)
10691061   MDRV_PPI8255_RECONFIG( "ppi8255_0", gselect_ppi8255_intf[0] )
10701062MACHINE_DRIVER_END
10711063
src/mame/drivers/segas32.c
r6740r6741
319319#include "cpu/v60/v60.h"
320320#include "cpu/nec/nec.h"
321321#include "rendlay.h"
322#include "segas32.h"
322#include "includes/segas32.h"
323323#include "machine/eeprom.h"
324324#include "sound/2612intf.h"
325325#include "sound/rf5c68.h"
r6740r6741
376376
377377/* V60 interrupt controller */
378378static UINT8 v60_irq_control[0x10];
379static emu_timer *v60_irq_timer[2];
379static const device_config *v60_irq_timer[2];
380380
381381/* sound interrupt controller */
382382static UINT8 sound_irq_control[4];
r6740r6741
403403 *************************************/
404404
405405static void signal_v60_irq(running_machine *machine, int data);
406static TIMER_CALLBACK( signal_v60_irq_callback );
407406static void signal_sound_irq(running_machine *machine, int which);
408407
409408
r6740r6741
420419   memset(v60_irq_control, 0xff, sizeof(v60_irq_control));
421420
422421   /* allocate timers */
423   v60_irq_timer[0] = timer_alloc(machine, signal_v60_irq_callback, NULL);
424   v60_irq_timer[1] = timer_alloc(machine, signal_v60_irq_callback, NULL);
422   v60_irq_timer[0] = devtag_get_device(machine, "v60_irq0");
423   v60_irq_timer[1] = devtag_get_device(machine, "v60_irq1");
425424
426425   /* clear IRQ lines */
427426   cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE);
r6740r6741
467466}
468467
469468
470static TIMER_CALLBACK( signal_v60_irq_callback )
469static TIMER_DEVICE_CALLBACK( signal_v60_irq_callback )
471470{
472   signal_v60_irq(machine, param);
471   signal_v60_irq(timer->machine, param);
473472}
474473
475474
r6740r6741
509508         if (duration)
510509         {
511510            attotime period = attotime_make(0, attotime_to_attoseconds(ATTOTIME_IN_HZ(TIMER_0_CLOCK)) * duration);
512            timer_adjust_oneshot(v60_irq_timer[0], period, MAIN_IRQ_TIMER0);
511            timer_device_adjust_oneshot(v60_irq_timer[0], period, MAIN_IRQ_TIMER0);
513512         }
514513         break;
515514
r6740r6741
520519         if (duration)
521520         {
522521            attotime period = attotime_make(0, attotime_to_attoseconds(ATTOTIME_IN_HZ(TIMER_1_CLOCK)) * duration);
523            timer_adjust_oneshot(v60_irq_timer[1], period, MAIN_IRQ_TIMER1);
522            timer_device_adjust_oneshot(v60_irq_timer[1], period, MAIN_IRQ_TIMER1);
524523         }
525524         break;
526525
r6740r6741
21902189   MDRV_MACHINE_RESET(system32)
21912190   MDRV_NVRAM_HANDLER(system32)
21922191
2192   MDRV_TIMER_ADD("v60_irq0", signal_v60_irq_callback)
2193   MDRV_TIMER_ADD("v60_irq1", signal_v60_irq_callback)
2194
21932195   /* video hardware */
21942196   MDRV_GFXDECODE(segas32)
21952197   MDRV_PALETTE_LENGTH(0x4000)
r6740r6741
22442246   MDRV_MACHINE_RESET(system32)
22452247   MDRV_NVRAM_HANDLER(system32)
22462248
2249   MDRV_TIMER_ADD("v60_irq0", signal_v60_irq_callback)
2250   MDRV_TIMER_ADD("v60_irq1", signal_v60_irq_callback)
2251
22472252   /* video hardware */
22482253   MDRV_GFXDECODE(segas32)
22492254   MDRV_PALETTE_LENGTH(0x8000)
src/mame/drivers/slapfght.c
r6740r6741
413413   AM_RANGE(0x8000, 0x87ff) AM_RAM
414414   AM_RANGE(0x8800, 0x880f) AM_RAM AM_SHARE("share1")
415415   AM_RANGE(0x8810, 0x8fff) AM_RAMBANK("bank1") /* Shared RAM with sound CPU */
416   AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(slapfight_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
417   AM_RANGE(0x9800, 0x9fff) AM_RAM_WRITE(slapfight_colorram_w) AM_BASE_GENERIC(colorram)
416   AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(slapfight_videoram_w) AM_BASE(&slapfight_videoram)
417   AM_RANGE(0x9800, 0x9fff) AM_RAM_WRITE(slapfight_colorram_w) AM_BASE(&slapfight_colorram)
418418   AM_RANGE(0xa000, 0xa7ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
419419ADDRESS_MAP_END
420420
r6740r6741
423423   AM_RANGE(0xc000, 0xc7ff) AM_RAM
424424   AM_RANGE(0xc800, 0xc80f) AM_RAM AM_SHARE("share1")
425425   AM_RANGE(0xc810, 0xcfff) AM_RAM
426   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(slapfight_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
427   AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(slapfight_colorram_w) AM_BASE_GENERIC(colorram)
426   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(slapfight_videoram_w) AM_BASE(&slapfight_videoram)
427   AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(slapfight_colorram_w) AM_BASE(&slapfight_colorram)
428428   AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
429429   AM_RANGE(0xe800, 0xe800) AM_WRITEONLY AM_BASE(&slapfight_scrollx_lo)
430430   AM_RANGE(0xe801, 0xe801) AM_WRITEONLY AM_BASE(&slapfight_scrollx_hi)
431431   AM_RANGE(0xe802, 0xe802) AM_WRITEONLY AM_BASE(&slapfight_scrolly)
432   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(slapfight_fixram_w) AM_BASE(&slapfight_videoram) AM_SIZE(&slapfight_videoram_size)
433   AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(slapfight_fixcol_w) AM_BASE(&slapfight_colorram)
432   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(slapfight_fixram_w) AM_BASE(&slapfight_fixvideoram)
433   AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(slapfight_fixcol_w) AM_BASE(&slapfight_fixcolorram)
434434ADDRESS_MAP_END
435435
436436static ADDRESS_MAP_START( slapfght_map, ADDRESS_SPACE_PROGRAM, 8 )
r6740r6741
439439   AM_RANGE(0xc000, 0xc7ff) AM_RAM
440440   AM_RANGE(0xc800, 0xc80f) AM_RAM AM_SHARE("share1")
441441   AM_RANGE(0xc810, 0xcfff) AM_RAM
442   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(slapfight_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
443   AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(slapfight_colorram_w) AM_BASE_GENERIC(colorram)
442   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(slapfight_videoram_w) AM_BASE(&slapfight_videoram)
443   AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(slapfight_colorram_w) AM_BASE(&slapfight_colorram)
444444   AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
445445   AM_RANGE(0xe800, 0xe800) AM_WRITEONLY AM_BASE(&slapfight_scrollx_lo)
446446   AM_RANGE(0xe801, 0xe801) AM_WRITEONLY AM_BASE(&slapfight_scrollx_hi)
447447   AM_RANGE(0xe802, 0xe802) AM_WRITEONLY AM_BASE(&slapfight_scrolly)
448448//  AM_RANGE(0xe803, 0xe803) AM_READ(mcu_r) // MCU lives here
449   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(slapfight_fixram_w) AM_BASE(&slapfight_videoram) AM_SIZE(&slapfight_videoram_size)
450   AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(slapfight_fixcol_w) AM_BASE(&slapfight_colorram)
449   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(slapfight_fixram_w) AM_BASE(&slapfight_fixvideoram)
450   AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(slapfight_fixcol_w) AM_BASE(&slapfight_fixcolorram)
451451ADDRESS_MAP_END
452452
453453static ADDRESS_MAP_START( slapbtuk_map, ADDRESS_SPACE_PROGRAM, 8 )
r6740r6741
456456   AM_RANGE(0xc000, 0xc7ff) AM_RAM
457457   AM_RANGE(0xc800, 0xc80f) AM_RAM AM_SHARE("share1")
458458   AM_RANGE(0xc810, 0xcfff) AM_RAM
459   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(slapfight_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
460   AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(slapfight_colorram_w) AM_BASE_GENERIC(colorram)
459   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(slapfight_videoram_w) AM_BASE(&slapfight_videoram)
460   AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(slapfight_colorram_w) AM_BASE(&slapfight_colorram)
461461   AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
462462   AM_RANGE(0xe800, 0xe800) AM_WRITEONLY AM_BASE(&slapfight_scrollx_hi)
463463   AM_RANGE(0xe802, 0xe802) AM_WRITEONLY AM_BASE(&slapfight_scrolly)
464464   AM_RANGE(0xe803, 0xe803) AM_WRITEONLY AM_BASE(&slapfight_scrollx_lo)
465465//  AM_RANGE(0xe803, 0xe803) AM_READ(getstar_e803_r)
466466   AM_RANGE(0xec00, 0xefff) AM_ROM // it reads a copy of the logo from here!
467   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(slapfight_fixram_w) AM_BASE(&slapfight_videoram) AM_SIZE(&slapfight_videoram_size)
468   AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(slapfight_fixcol_w) AM_BASE(&slapfight_colorram)
467   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(slapfight_fixram_w) AM_BASE(&slapfight_fixvideoram)
468   AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(slapfight_fixcol_w) AM_BASE(&slapfight_fixcolorram)
469469ADDRESS_MAP_END
470470
471471static ADDRESS_MAP_START( slapfght_io_map, ADDRESS_SPACE_IO, 8 )
src/mame/drivers/badlands.c
r6740r6741
165165#include "cpu/z80/z80.h"
166166#include "cpu/m68000/m68000.h"
167167#include "cpu/m6502/m6502.h"
168#include "badlands.h"
168#include "includes/badlands.h"
169169#include "sound/2151intf.h"
170170
171171
r6740r6741
196196}
197197
198198
199static MACHINE_START( badlands )
200{
201   badlands_state *state = (badlands_state *)machine->driver_data;
202
203   atarigen_init(machine);
204
205   state_save_register_global_array(machine, state->pedal_value);
206}
207
208
199209static MACHINE_RESET( badlands )
200210{
201211   badlands_state *state = (badlands_state *)machine->driver_data;
r6740r6741
504514   MDRV_CPU_ADD("audiocpu", M6502, ATARI_CLOCK_14MHz/8)
505515   MDRV_CPU_PROGRAM_MAP(audio_map)
506516
517   MDRV_MACHINE_START(badlands)
507518   MDRV_MACHINE_RESET(badlands)
508519   MDRV_NVRAM_HANDLER(atarigen)
509520
r6740r6741
713724//  MDRV_CPU_ADD("audiocpu", Z80, 2800000/8)
714725//  MDRV_CPU_PROGRAM_MAP(bootleg_soundmap)
715726
727   MDRV_MACHINE_START(badlands)
716728   MDRV_MACHINE_RESET(badlandb)
717729   MDRV_NVRAM_HANDLER(atarigen)
718730
src/mame/drivers/psikyosh.c
r6740r6741
275275#include "machine/eeprom.h"
276276#include "sound/ymf278b.h"
277277
278#include "psikyosh.h"
278#include "includes/psikyosh.h"
279279
280280#define ROMTEST 1 /* Does necessary stuff to perform rom test, uses RAM as it doesn't dispose of GFX after decoding */
281281
r6740r6741
288288
289289static int use_factory_eeprom;
290290
291UINT32 *psikyosh_bgram, *psikyosh_zoomram, *psikyosh_vidregs;
292static UINT32 *psh_ram;
293
294291static const gfx_layout layout_16x16x4 =
295292{
296293   16,16,
r6740r6741
433430// bit 0 controls game speed on readback, mechanism is a little weird
434431static WRITE32_HANDLER( psikyosh_irqctrl_w )
435432{
433   psikyosh_state *state = (psikyosh_state *)space->machine->driver_data;
436434   if (!(data & 0x00c00000))
437435   {
438      cputag_set_input_line(space->machine, "maincpu", 4, CLEAR_LINE);
436      cpu_set_input_line(state->maincpu, 4, CLEAR_LINE);
439437   }
440438}
441439
442440static WRITE32_HANDLER( paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w )
443441{
444   int r,g,b;
445   COMBINE_DATA(&space->machine->generic.paletteram.u32[offset]); /* is this ok .. */
442   psikyosh_state *state = (psikyosh_state *)space->machine->driver_data;
443   int r, g, b;
444   COMBINE_DATA(&state->paletteram[offset]); /* is this ok .. */
446445
447   b = ((space->machine->generic.paletteram.u32[offset] & 0x0000ff00) >>8);
448   g = ((space->machine->generic.paletteram.u32[offset] & 0x00ff0000) >>16);
449   r = ((space->machine->generic.paletteram.u32[offset] & 0xff000000) >>24);
446   b = ((state->paletteram[offset] & 0x0000ff00) >>8);
447   g = ((state->paletteram[offset] & 0x00ff0000) >>16);
448   r = ((state->paletteram[offset] & 0xff000000) >>24);
450449
451   palette_set_color(space->machine,offset,MAKE_RGB(r,g,b));
450   palette_set_color(space->machine, offset, MAKE_RGB(r, g, b));
452451}
453452
454453static WRITE32_HANDLER( psikyosh_vidregs_w )
455454{
456   COMBINE_DATA(&psikyosh_vidregs[offset]);
455   psikyosh_state *state = (psikyosh_state *)space->machine->driver_data;
456   COMBINE_DATA(&state->vidregs[offset]);
457457
458458#if ROMTEST
459   if(offset==4) /* Configure bank for gfx test */
459   if (offset == 4) /* Configure bank for gfx test */
460460   {
461461      if (ACCESSING_BITS_0_15)   // Bank
462      {
463         UINT8 *ROM = memory_region(space->machine, "gfx1");
464         memory_set_bankptr(space->machine, "bank2",&ROM[0x20000 * (psikyosh_vidregs[offset]&0xfff)]); /* Bank comes from vidregs */
465      }
462         memory_set_bank(space->machine, "bank2", state->vidregs[offset] & 0xfff);
466463   }
467464#endif
468465}
469466
470467#if ROMTEST
471static UINT32 sample_offs = 0;
472
473468static READ32_HANDLER( psh_sample_r ) /* Send sample data for test */
474469{
470   psikyosh_state *state = (psikyosh_state *)space->machine->driver_data;
475471   UINT8 *ROM = memory_region(space->machine, "ymf");
476472
477   return ROM[sample_offs++]<<16;
473   return ROM[state->sample_offs++] << 16;
478474}
479475#endif
480476
r6740r6741
483479   AM_RANGE(0x00000000, 0x000fffff) AM_ROM               // program ROM (1 meg)
484480   AM_RANGE(0x02000000, 0x021fffff) AM_ROMBANK("bank1") // data ROM
485481   AM_RANGE(0x03000000, 0x03003fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)   // sprites (might be a bit longer)
486   AM_RANGE(0x03004000, 0x0300ffff) AM_RAM AM_BASE(&psikyosh_bgram) // backgrounds
487   AM_RANGE(0x03040000, 0x03044fff) AM_RAM_WRITE(paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w) AM_BASE_GENERIC(paletteram) // palette..
488   AM_RANGE(0x03050000, 0x030501ff) AM_RAM AM_BASE(&psikyosh_zoomram) // a gradient sometimes ...
482   AM_RANGE(0x03004000, 0x0300ffff) AM_RAM AM_BASE_MEMBER(psikyosh_state, bgram) // backgrounds
483   AM_RANGE(0x03040000, 0x03044fff) AM_RAM_WRITE(paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w) AM_BASE_MEMBER(psikyosh_state, paletteram) // palette..
484   AM_RANGE(0x03050000, 0x030501ff) AM_RAM AM_BASE_MEMBER(psikyosh_state, zoomram) // a gradient sometimes ...
489485   AM_RANGE(0x0305ffdc, 0x0305ffdf) AM_READNOP AM_WRITE(psikyosh_irqctrl_w) // also writes to this address - might be vblank reads?
490   AM_RANGE(0x0305ffe0, 0x0305ffff) AM_RAM_WRITE(psikyosh_vidregs_w) AM_BASE(&psikyosh_vidregs) //  video registers
486   AM_RANGE(0x0305ffe0, 0x0305ffff) AM_RAM_WRITE(psikyosh_vidregs_w) AM_BASE_MEMBER(psikyosh_state, vidregs) //  video registers
491487   AM_RANGE(0x05000000, 0x05000003) AM_DEVREAD8("ymf", ymf278b_r, 0xffffffff) // read YMF status
492488   AM_RANGE(0x05000000, 0x05000007) AM_DEVWRITE8("ymf", ymf278b_w, 0xffffffff)
493489   AM_RANGE(0x05800000, 0x05800003) AM_READ_PORT("INPUTS")
494   AM_RANGE(0x05800004, 0x05800007) AM_READWRITE(psh_eeprom_r,psh_eeprom_w)
495   AM_RANGE(0x06000000, 0x060fffff) AM_RAM   AM_BASE(&psh_ram) // main RAM (1 meg)
490   AM_RANGE(0x05800004, 0x05800007) AM_READWRITE(psh_eeprom_r, psh_eeprom_w)
491   AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_BASE_MEMBER(psikyosh_state, ram) // main RAM (1 meg)
496492
497493#if ROMTEST
498494   AM_RANGE(0x05000004, 0x05000007) AM_READ(psh_sample_r) // data for rom tests (Used to verify Sample rom)
r6740r6741
508504   AM_RANGE(0x03100000, 0x03100003) AM_DEVREAD8("ymf", ymf278b_r, 0xffffffff)
509505   AM_RANGE(0x03100000, 0x03100007) AM_DEVWRITE8("ymf", ymf278b_w, 0xffffffff)
510506   AM_RANGE(0x04000000, 0x04003fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
511   AM_RANGE(0x04004000, 0x0400ffff) AM_RAM AM_BASE(&psikyosh_bgram) // backgrounds
512   AM_RANGE(0x04040000, 0x04044fff) AM_RAM_WRITE(paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w) AM_BASE_GENERIC(paletteram)
513   AM_RANGE(0x04050000, 0x040501ff) AM_RAM AM_BASE(&psikyosh_zoomram)
507   AM_RANGE(0x04004000, 0x0400ffff) AM_RAM AM_BASE_MEMBER(psikyosh_state, bgram) // backgrounds
508   AM_RANGE(0x04040000, 0x04044fff) AM_RAM_WRITE(paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w) AM_BASE_MEMBER(psikyosh_state, paletteram)
509   AM_RANGE(0x04050000, 0x040501ff) AM_RAM AM_BASE_MEMBER(psikyosh_state, zoomram)
514510   AM_RANGE(0x0405ffdc, 0x0405ffdf) AM_READNOP AM_WRITE(psikyosh_irqctrl_w) // also writes to this address - might be vblank reads?
515   AM_RANGE(0x0405ffe0, 0x0405ffff) AM_RAM_WRITE(psikyosh_vidregs_w) AM_BASE(&psikyosh_vidregs) // video registers
511   AM_RANGE(0x0405ffe0, 0x0405ffff) AM_RAM_WRITE(psikyosh_vidregs_w) AM_BASE_MEMBER(psikyosh_state, vidregs) // video registers
516512   AM_RANGE(0x05000000, 0x0507ffff) AM_ROMBANK("bank1") // data ROM
517   AM_RANGE(0x06000000, 0x060fffff) AM_RAM  AM_BASE(&psh_ram)
513   AM_RANGE(0x06000000, 0x060fffff) AM_RAM  AM_BASE_MEMBER(psikyosh_state, ram)
518514
519515#if ROMTEST
520516   AM_RANGE(0x03100004, 0x03100007) AM_READ(psh_sample_r) // data for rom tests (Used to verify Sample rom)
r6740r6741
523519ADDRESS_MAP_END
524520
525521
526static void irqhandler(const device_config *device, int linestate)
527{
528   if (linestate)
529      cputag_set_input_line(device->machine, "maincpu", 12, ASSERT_LINE);
530   else
531      cputag_set_input_line(device->machine, "maincpu", 12, CLEAR_LINE);
532}
533
534static const ymf278b_interface ymf278b_config =
535{
536   irqhandler
537};
538
539static MACHINE_DRIVER_START( psikyo3v1 )
540   /* basic machine hardware */
541   MDRV_CPU_ADD("maincpu", SH2, MASTER_CLOCK/2)
542   MDRV_CPU_PROGRAM_MAP(ps3v1_map)
543   MDRV_CPU_VBLANK_INT("screen", psikyosh_interrupt)
544
545   MDRV_NVRAM_HANDLER(93C56)
546
547   /* video hardware */
548   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM ) /* If using alpha */
549
550   MDRV_SCREEN_ADD("screen", RASTER)
551   MDRV_SCREEN_REFRESH_RATE(60)
552   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
553   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
554   MDRV_SCREEN_SIZE(64*8, 32*8)
555   MDRV_SCREEN_VISIBLE_AREA(0, 40*8-1, 0, 28*8-1)
556
557   MDRV_GFXDECODE(psikyosh)
558   MDRV_PALETTE_LENGTH(0x5000/4)
559
560   MDRV_VIDEO_START(psikyosh)
561   MDRV_VIDEO_EOF(psikyosh)
562   MDRV_VIDEO_UPDATE(psikyosh)
563
564   /* sound hardware */
565   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
566
567   MDRV_SOUND_ADD("ymf", YMF278B, MASTER_CLOCK/2)
568   MDRV_SOUND_CONFIG(ymf278b_config)
569   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0)
570   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0)
571MACHINE_DRIVER_END
572
573static MACHINE_DRIVER_START( psikyo5 )
574   /* basic machine hardware */
575   MDRV_IMPORT_FROM(psikyo3v1)
576
577   MDRV_CPU_MODIFY("maincpu")
578   MDRV_CPU_PROGRAM_MAP(ps5_map)
579MACHINE_DRIVER_END
580
581static MACHINE_DRIVER_START( psikyo5_240 )
582   /* basic machine hardware */
583   MDRV_IMPORT_FROM(psikyo3v1)
584
585   MDRV_CPU_MODIFY("maincpu")
586   MDRV_CPU_PROGRAM_MAP(ps5_map)
587
588   /* It probably has a register to change visarea */
589   MDRV_SCREEN_MODIFY("screen")
590   MDRV_SCREEN_VISIBLE_AREA(0, 40*8-1, 0, 30*8-1)
591MACHINE_DRIVER_END
592
593522static INPUT_PORTS_START( common )
594523   PORT_START("INPUTS")
595524   PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_COIN1 )
r6740r6741
762691INPUT_PORTS_END
763692
764693
694static void irqhandler(const device_config *device, int linestate)
695{
696   psikyosh_state *state = (psikyosh_state *)device->machine->driver_data;
697   cpu_set_input_line(state->maincpu, 12, linestate ? ASSERT_LINE : CLEAR_LINE);
698}
699
700static const ymf278b_interface ymf278b_config =
701{
702   irqhandler
703};
704
705
706static MACHINE_START( psikyosh )
707{
708   psikyosh_state *state = (psikyosh_state *)machine->driver_data;
709
710   state->maincpu = devtag_get_device(machine, "maincpu");
711
712#if ROMTEST
713   memory_configure_bank(machine, "bank2", 0, 0x1000, memory_region(machine, "gfx1"), 0x20000);
714
715   state->sample_offs = 0;
716   state_save_register_global(machine, state->sample_offs);
717#endif
718}
719
720
721static MACHINE_DRIVER_START( psikyo3v1 )
722
723   /* driver data */
724   MDRV_DRIVER_DATA(psikyosh_state)
725
726   /* basic machine hardware */
727   MDRV_CPU_ADD("maincpu", SH2, MASTER_CLOCK/2)
728   MDRV_CPU_PROGRAM_MAP(ps3v1_map)
729   MDRV_CPU_VBLANK_INT("screen", psikyosh_interrupt)
730
731   MDRV_MACHINE_START(psikyosh)
732
733   MDRV_NVRAM_HANDLER(93C56)
734
735   /* video hardware */
736   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM ) /* If using alpha */
737
738   MDRV_SCREEN_ADD("screen", RASTER)
739   MDRV_SCREEN_REFRESH_RATE(60)
740   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
741   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
742   MDRV_SCREEN_SIZE(64*8, 32*8)
743   MDRV_SCREEN_VISIBLE_AREA(0, 40*8-1, 0, 28*8-1)
744
745   MDRV_GFXDECODE(psikyosh)
746   MDRV_PALETTE_LENGTH(0x5000/4)
747
748   MDRV_VIDEO_START(psikyosh)
749   MDRV_VIDEO_EOF(psikyosh)
750   MDRV_VIDEO_UPDATE(psikyosh)
751
752   /* sound hardware */
753   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
754
755   MDRV_SOUND_ADD("ymf", YMF278B, MASTER_CLOCK/2)
756   MDRV_SOUND_CONFIG(ymf278b_config)
757   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0)
758   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0)
759MACHINE_DRIVER_END
760
761static MACHINE_DRIVER_START( psikyo5 )
762   /* basic machine hardware */
763   MDRV_IMPORT_FROM(psikyo3v1)
764
765   MDRV_CPU_MODIFY("maincpu")
766   MDRV_CPU_PROGRAM_MAP(ps5_map)
767MACHINE_DRIVER_END
768
769static MACHINE_DRIVER_START( psikyo5_240 )
770   /* basic machine hardware */
771   MDRV_IMPORT_FROM(psikyo3v1)
772
773   MDRV_CPU_MODIFY("maincpu")
774   MDRV_CPU_PROGRAM_MAP(ps5_map)
775
776   /* It probably has a register to change visarea */
777   MDRV_SCREEN_MODIFY("screen")
778   MDRV_SCREEN_VISIBLE_AREA(0, 40*8-1, 0, 30*8-1)
779MACHINE_DRIVER_END
780
781
765782/* PS3 */
766783
767784ROM_START( soldivid )
r6740r6741
10671084
10681085static DRIVER_INIT( soldivid )
10691086{
1070   sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
1087   sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
10711088   use_factory_eeprom = eeprom_0;
10721089}
10731090
10741091static DRIVER_INIT( s1945ii )
10751092{
1076   sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
1093   sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
10771094   use_factory_eeprom = eeprom_DEFAULT;
10781095}
10791096
r6740r6741
10811098{
10821099   UINT8 *RAM = memory_region(machine, "maincpu");
10831100   memory_set_bankptr(machine, "bank1", &RAM[0x100000]);
1084   sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
1101   sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
10851102   use_factory_eeprom = eeprom_DARAKU;
10861103}
10871104
10881105static DRIVER_INIT( sbomberb )
10891106{
1090   sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
1107   sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
10911108   use_factory_eeprom = eeprom_DEFAULT;
10921109}
10931110
r6740r6741
10951112{
10961113   UINT8 *RAM = memory_region(machine, "maincpu");
10971114   memory_set_bankptr(machine, "bank1", &RAM[0x100000]);
1098   sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
1115   sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
10991116   use_factory_eeprom = eeprom_DEFAULT;
11001117}
11011118
r6740r6741
11031120{
11041121   UINT8 *RAM = memory_region(machine, "maincpu");
11051122   memory_set_bankptr(machine, "bank1", &RAM[0x100000]);
1106   sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
1123   sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
11071124   use_factory_eeprom = eeprom_S1945III;
11081125}
11091126
11101127static DRIVER_INIT( dragnblz )
11111128{
1112   sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
1129   sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
11131130   use_factory_eeprom = eeprom_DRAGNBLZ;
11141131}
11151132
11161133static DRIVER_INIT( gnbarich )
11171134{
1118   sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
1135   sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
11191136   use_factory_eeprom = eeprom_GNBARICH;
11201137}
11211138
11221139static DRIVER_INIT( tgm2 )
11231140{
1124   sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
1141   sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
11251142   use_factory_eeprom = eeprom_USER1;
11261143}
11271144
11281145static DRIVER_INIT( mjgtaste )
11291146{
1130   sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
1147   sh2drc_set_options(devtag_get_device(machine, "maincpu"), SH2DRC_FASTEST_OPTIONS);
11311148   use_factory_eeprom = eeprom_MJGTASTE;
11321149   /* needs to install mahjong controls too (can select joystick in test mode tho) */
11331150}
src/mame/drivers/boogwing.c
r6740r6741
8181#include "driver.h"
8282#include "cpu/m68000/m68000.h"
8383#include "cpu/h6280/h6280.h"
84#include "decocrpt.h"
85#include "deco16ic.h"
86#include "decoprot.h"
84#include "includes/decocrpt.h"
85#include "includes/deco16ic.h"
86#include "includes/decoprot.h"
8787#include "sound/2151intf.h"
8888#include "sound/okim6295.h"
8989
src/mame/drivers/offtwall.c
r6740r6741
2020#include "driver.h"
2121#include "cpu/m68000/m68000.h"
2222#include "audio/atarijsa.h"
23#include "offtwall.h"
23#include "includes/offtwall.h"
2424
2525
2626
r6740r6741
4545 *
4646 *************************************/
4747
48static MACHINE_START( offtwall )
49{
50   atarigen_init(machine);
51}
52
53
4854static MACHINE_RESET( offtwall )
4955{
5056   offtwall_state *state = (offtwall_state *)machine->driver_data;
r6740r6741
404410   MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2)
405411   MDRV_CPU_PROGRAM_MAP(main_map)
406412
413   MDRV_MACHINE_START(offtwall)
407414   MDRV_MACHINE_RESET(offtwall)
408415   MDRV_NVRAM_HANDLER(atarigen)
409416
src/mame/drivers/neodrvr.c
r6740r6741
72277227
72287228static DRIVER_INIT ( kof98 )
72297229{
7230   DRIVER_INIT_CALL(neogeo);
72307231   kof98_decrypt_68k(machine);
7231   DRIVER_INIT_CALL(neogeo);
72327232   install_kof98_protection(machine);
72337233}
72347234
r6740r6741
72407240
72417241static DRIVER_INIT( kof99 )
72427242{
7243   neogeo_state *state = (neogeo_state *)machine->driver_data;
7244   DRIVER_INIT_CALL(neogeo);
72437245   kof99_decrypt_68k(machine);
7244   neogeo_fixed_layer_bank_type = 1;
7246   state->fixed_layer_bank_type = 1;
72457247   kof99_neogeo_gfx_decrypt(machine, 0x00);
7246   DRIVER_INIT_CALL(neogeo);
72477248   kof99_install_protection(machine);
72487249}
72497250
72507251static DRIVER_INIT( kof99n )
72517252{
7252   neogeo_fixed_layer_bank_type = 1;
7253   neogeo_state *state = (neogeo_state *)machine->driver_data;
7254   DRIVER_INIT_CALL(neogeo);
7255   state->fixed_layer_bank_type = 1;
72537256   kof99_neogeo_gfx_decrypt(machine, 0x00);
7254   DRIVER_INIT_CALL(neogeo);
72557257}
72567258
72577259static DRIVER_INIT( garou )
72587260{
7261   neogeo_state *state = (neogeo_state *)machine->driver_data;
7262   DRIVER_INIT_CALL(neogeo);
72597263   garou_decrypt_68k(machine);
7260   neogeo_fixed_layer_bank_type = 1;
7264   state->fixed_layer_bank_type = 1;
72617265   kof99_neogeo_gfx_decrypt(machine, 0x06);
7262   DRIVER_INIT_CALL(neogeo);
72637266   garou_install_protection(machine);
72647267}
72657268
72667269static DRIVER_INIT( garouo )
72677270{
7271   neogeo_state *state = (neogeo_state *)machine->driver_data;
7272   DRIVER_INIT_CALL(neogeo);
72687273   garouo_decrypt_68k(machine);
7269   neogeo_fixed_layer_bank_type = 1;
7274   state->fixed_layer_bank_type = 1;
72707275   kof99_neogeo_gfx_decrypt(machine, 0x06);
7271   DRIVER_INIT_CALL(neogeo);
72727276   garouo_install_protection(machine);
72737277}
72747278
72757279static DRIVER_INIT( garoubl )
72767280{
7281   DRIVER_INIT_CALL(neogeo);
72777282   neogeo_bootleg_sx_decrypt(machine, 2);
72787283   neogeo_bootleg_cx_decrypt(machine);
7279   DRIVER_INIT_CALL(neogeo);
72807284}
72817285
72827286static DRIVER_INIT( mslug3 )
72837287{
7288   neogeo_state *state = (neogeo_state *)machine->driver_data;
7289   DRIVER_INIT_CALL(neogeo);
72847290   mslug3_decrypt_68k(machine);
7285   neogeo_fixed_layer_bank_type = 1;
7291   state->fixed_layer_bank_type = 1;
72867292   kof99_neogeo_gfx_decrypt(machine, 0xad);
7287   DRIVER_INIT_CALL(neogeo);
72887293   mslug3_install_protection(machine);
72897294}
72907295
72917296static DRIVER_INIT( mslug3h )
72927297{
7293   neogeo_fixed_layer_bank_type = 1;
7298   neogeo_state *state = (neogeo_state *)machine->driver_data;
7299   DRIVER_INIT_CALL(neogeo);
7300   state->fixed_layer_bank_type = 1;
72947301   kof99_neogeo_gfx_decrypt(machine, 0xad);
7295   DRIVER_INIT_CALL(neogeo);
72967302}
72977303
72987304static DRIVER_INIT( mslug3b6 )
72997305{
7306   DRIVER_INIT_CALL(neogeo);
73007307   neogeo_bootleg_sx_decrypt(machine, 2);
73017308   cmc42_neogeo_gfx_decrypt(machine, 0xad);
7302   DRIVER_INIT_CALL(neogeo);
73037309}
73047310
73057311static DRIVER_INIT( kof2000 )
73067312{
7313   neogeo_state *state = (neogeo_state *)machine->driver_data;
7314   DRIVER_INIT_CALL(neogeo);
73077315   kof2000_decrypt_68k(machine);
7308   neogeo_fixed_layer_bank_type = 2;
7316   state->fixed_layer_bank_type = 2;
73097317   neogeo_cmc50_m1_decrypt(machine);
73107318   kof2000_neogeo_gfx_decrypt(machine, 0x00);
7311   DRIVER_INIT_CALL(neogeo);
73127319   kof2000_install_protection(machine);
73137320}
73147321
73157322static DRIVER_INIT( kof2000n )
73167323{
7317   neogeo_fixed_layer_bank_type = 2;
7324   neogeo_state *state = (neogeo_state *)machine->driver_data;
7325   DRIVER_INIT_CALL(neogeo);
7326   state->fixed_layer_bank_type = 2;
73187327   neogeo_cmc50_m1_decrypt(machine);
73197328   kof2000_neogeo_gfx_decrypt(machine, 0x00);
7320   DRIVER_INIT_CALL(neogeo);
73217329}
73227330
73237331static DRIVER_INIT( kof2001 )
73247332{
7325   neogeo_fixed_layer_bank_type = 1;
7333   neogeo_state *state = (neogeo_state *)machine->driver_data;
7334   DRIVER_INIT_CALL(neogeo);
7335   state->fixed_layer_bank_type = 1;
73267336   kof2000_neogeo_gfx_decrypt(machine, 0x1e);
73277337   neogeo_cmc50_m1_decrypt(machine);
7328   DRIVER_INIT_CALL(neogeo);
73297338}
73307339
73317340static DRIVER_INIT( cthd2003 )
73327341{
7342   DRIVER_INIT_CALL(neogeo);
73337343   decrypt_cthd2003(machine);
7334    DRIVER_INIT_CALL(neogeo);
73357344   patch_cthd2003(machine);
73367345}
73377346
73387347static DRIVER_INIT ( ct2k3sp )
73397348{
7349   DRIVER_INIT_CALL(neogeo);
73407350   decrypt_ct2k3sp(machine);
7341   DRIVER_INIT_CALL(neogeo);
73427351   patch_cthd2003(machine);
73437352}
73447353
73457354static DRIVER_INIT ( ct2k3sa )
73467355{
7356   DRIVER_INIT_CALL(neogeo);
73477357   decrypt_ct2k3sa(machine);
7348   DRIVER_INIT_CALL(neogeo);
73497358   patch_ct2k3sa(machine);
73507359}
73517360
73527361static DRIVER_INIT( mslug4 )
73537362{
7354   neogeo_fixed_layer_bank_type = 1; /* USA violent content screen is wrong -- not a bug, confirmed on real hardware! */
7363   neogeo_state *state = (neogeo_state *)machine->driver_data;
7364   DRIVER_INIT_CALL(neogeo);
7365   state->fixed_layer_bank_type = 1; /* USA violent content screen is wrong -- not a bug, confirmed on real hardware! */
73557366   neogeo_cmc50_m1_decrypt(machine);
73567367   kof2000_neogeo_gfx_decrypt(machine, 0x31);
7357   DRIVER_INIT_CALL(neogeo);
73587368   neo_pcm2_snk_1999(machine, 8);
73597369}
73607370
73617371static DRIVER_INIT( ms4plus )
73627372{
7373   DRIVER_INIT_CALL(neogeo);
73637374   cmc50_neogeo_gfx_decrypt(machine, 0x31);
73647375   neo_pcm2_snk_1999(machine, 8);
73657376   neogeo_cmc50_m1_decrypt(machine);
7366   DRIVER_INIT_CALL(neogeo);
73677377}
73687378
73697379static DRIVER_INIT( ganryu )
73707380{
7371   neogeo_fixed_layer_bank_type = 1;
7381   neogeo_state *state = (neogeo_state *)machine->driver_data;
7382   DRIVER_INIT_CALL(neogeo);
7383   state->fixed_layer_bank_type = 1;
73727384   kof99_neogeo_gfx_decrypt(machine, 0x07);
7373   DRIVER_INIT_CALL(neogeo);
73747385}
73757386
73767387static DRIVER_INIT( s1945p )
73777388{
7378   neogeo_fixed_layer_bank_type = 1;
7389   neogeo_state *state = (neogeo_state *)machine->driver_data;
7390   DRIVER_INIT_CALL(neogeo);
7391   state->fixed_layer_bank_type = 1;
73797392   kof99_neogeo_gfx_decrypt(machine, 0x05);
7380   DRIVER_INIT_CALL(neogeo);
73817393}
73827394
73837395static DRIVER_INIT( preisle2 )
73847396{
7385   neogeo_fixed_layer_bank_type = 1;
7397   neogeo_state *state = (neogeo_state *)machine->driver_data;
7398   DRIVER_INIT_CALL(neogeo);
7399   state->fixed_layer_bank_type = 1;
73867400   kof99_neogeo_gfx_decrypt(machine, 0x9f);
7387   DRIVER_INIT_CALL(neogeo);
73887401}
73897402
73907403static DRIVER_INIT( bangbead )
73917404{
7392   neogeo_fixed_layer_bank_type = 1;
7405   neogeo_state *state = (neogeo_state *)machine->driver_data;
7406   DRIVER_INIT_CALL(neogeo);
7407   state->fixed_layer_bank_type = 1;
73937408   kof99_neogeo_gfx_decrypt(machine, 0xf8);
7394   DRIVER_INIT_CALL(neogeo);
73957409}
73967410
73977411static DRIVER_INIT( nitd )
73987412{
7399   neogeo_fixed_layer_bank_type = 1;
7413   neogeo_state *state = (neogeo_state *)machine->driver_data;
7414   DRIVER_INIT_CALL(neogeo);
7415   state->fixed_layer_bank_type = 1;
74007416   kof99_neogeo_gfx_decrypt(machine, 0xff);
7401   DRIVER_INIT_CALL(neogeo);
74027417}
74037418
74047419static DRIVER_INIT( zupapa )
74057420{
7406   neogeo_fixed_layer_bank_type = 1;
7421   neogeo_state *state = (neogeo_state *)machine->driver_data;
7422   DRIVER_INIT_CALL(neogeo);
7423   state->fixed_layer_bank_type = 1;
74077424   kof99_neogeo_gfx_decrypt(machine, 0xbd);
7408   DRIVER_INIT_CALL(neogeo);
74097425}
74107426
74117427static DRIVER_INIT( sengoku3 )
74127428{
7413   neogeo_fixed_layer_bank_type = 1;
7429   neogeo_state *state = (neogeo_state *)machine->driver_data;
7430   DRIVER_INIT_CALL(neogeo);
7431   state->fixed_layer_bank_type = 1;
74147432   kof99_neogeo_gfx_decrypt(machine, 0xfe);
7415   DRIVER_INIT_CALL(neogeo);
74167433}
74177434
74187435static DRIVER_INIT( rotd )
74197436{
7437   neogeo_state *state = (neogeo_state *)machine->driver_data;
7438   DRIVER_INIT_CALL(neogeo);
74207439   neo_pcm2_snk_1999(machine, 16);
7421   neogeo_fixed_layer_bank_type = 1;
7440   state->fixed_layer_bank_type = 1;
74227441   neogeo_cmc50_m1_decrypt(machine);
74237442   kof2000_neogeo_gfx_decrypt(machine, 0x3f);
7424   DRIVER_INIT_CALL(neogeo);
74257443}
74267444
74277445static DRIVER_INIT( kof2002 )
74287446{
7447   DRIVER_INIT_CALL(neogeo);
74297448   kof2002_decrypt_68k(machine);
74307449   neo_pcm2_swap(machine, 0);
74317450   neogeo_cmc50_m1_decrypt(machine);
74327451   kof2000_neogeo_gfx_decrypt(machine, 0xec);
7433   DRIVER_INIT_CALL(neogeo);
74347452}
74357453
74367454static DRIVER_INIT( kof2002b )
74377455{
7456   DRIVER_INIT_CALL(neogeo);
74387457   kof2002_decrypt_68k(machine);
74397458   neo_pcm2_swap(machine, 0);
74407459   neogeo_cmc50_m1_decrypt(machine);
74417460   kof2002b_gfx_decrypt(machine, memory_region(machine, "sprites"),0x4000000);
74427461   kof2002b_gfx_decrypt(machine, memory_region(machine, "fixed"),0x20000);
7443   DRIVER_INIT_CALL(neogeo);
74447462}
74457463
74467464static DRIVER_INIT( kf2k2pls )
74477465{
7466   DRIVER_INIT_CALL(neogeo);
74487467   kof2002_decrypt_68k(machine);
74497468   neo_pcm2_swap(machine, 0);
74507469   neogeo_cmc50_m1_decrypt(machine);
74517470   cmc50_neogeo_gfx_decrypt(machine, 0xec);
7452   DRIVER_INIT_CALL(neogeo);
74537471}
74547472
74557473static DRIVER_INIT( kf2k2mp )
74567474{
7475   DRIVER_INIT_CALL(neogeo);
74577476   kf2k2mp_decrypt(machine);
74587477   neo_pcm2_swap(machine, 0);
74597478   neogeo_cmc50_m1_decrypt(machine);
74607479   neogeo_bootleg_sx_decrypt(machine, 2);
74617480   cmc50_neogeo_gfx_decrypt(machine, 0xec);
7462   DRIVER_INIT_CALL(neogeo);
74637481}
74647482
74657483static DRIVER_INIT( kf2k2mp2 )
74667484{
7485   DRIVER_INIT_CALL(neogeo);
74677486   kf2k2mp2_px_decrypt(machine);
74687487   neo_pcm2_swap(machine, 0);
74697488   neogeo_cmc50_m1_decrypt(machine);
74707489   neogeo_bootleg_sx_decrypt(machine, 1);
74717490   cmc50_neogeo_gfx_decrypt(machine, 0xec);
7472   DRIVER_INIT_CALL(neogeo);
74737491}
74747492
74757493static DRIVER_INIT( kof10th )
74767494{
7495   DRIVER_INIT_CALL(neogeo);
74777496   decrypt_kof10th(machine);
7478   DRIVER_INIT_CALL(neogeo);
74797497   install_kof10th_protection(machine);
74807498}
74817499
74827500static DRIVER_INIT( kf10thep )
74837501{
7502   DRIVER_INIT_CALL(neogeo);
74847503   decrypt_kf10thep(machine);
7485   DRIVER_INIT_CALL(neogeo);
74867504}
74877505
74887506static DRIVER_INIT( kf2k5uni )
74897507{
7508   DRIVER_INIT_CALL(neogeo);
74907509   decrypt_kf2k5uni(machine);
7491   DRIVER_INIT_CALL(neogeo);
74927510}
74937511
74947512static DRIVER_INIT( kof2k4se )
74957513{
7514   DRIVER_INIT_CALL(neogeo);
74967515   decrypt_kof2k4se_68k(machine);
7497   DRIVER_INIT_CALL(neogeo);
74987516}
74997517
75007518static DRIVER_INIT( matrim )
75017519{
7520   neogeo_state *state = (neogeo_state *)machine->driver_data;
7521   DRIVER_INIT_CALL(neogeo);
75027522   matrim_decrypt_68k(machine);
75037523   neo_pcm2_swap(machine, 1);
7504   neogeo_fixed_layer_bank_type = 2;
7524   state->fixed_layer_bank_type = 2;
75057525   neogeo_cmc50_m1_decrypt(machine);
75067526   kof2000_neogeo_gfx_decrypt(machine, 0x6a);
7507   DRIVER_INIT_CALL(neogeo);
75087527}
75097528
75107529static DRIVER_INIT( matrimbl )
75117530{
7531   neogeo_state *state = (neogeo_state *)machine->driver_data;
7532   DRIVER_INIT_CALL(neogeo);
75127533   matrim_decrypt_68k(machine);
7513   neogeo_fixed_layer_bank_type = 2;
7534   state->fixed_layer_bank_type = 2;
75147535   matrimbl_decrypt(machine);
75157536   neogeo_sfix_decrypt(machine); /* required for text layer */
7516   DRIVER_INIT_CALL(neogeo);
75177537}
75187538
75197539static DRIVER_INIT( pnyaa )
75207540{
7541   neogeo_state *state = (neogeo_state *)machine->driver_data;
7542   DRIVER_INIT_CALL(neogeo);
75217543   neo_pcm2_snk_1999(machine, 4);
7522   neogeo_fixed_layer_bank_type = 1;
7544   state->fixed_layer_bank_type = 1;
75237545   neogeo_cmc50_m1_decrypt(machine);
75247546   kof2000_neogeo_gfx_decrypt(machine, 0x2e);
7525   DRIVER_INIT_CALL(neogeo);
75267547}
75277548
75287549static DRIVER_INIT( mslug5 )
75297550{
7551   neogeo_state *state = (neogeo_state *)machine->driver_data;
7552   DRIVER_INIT_CALL(neogeo);
75307553   mslug5_decrypt_68k(machine);
75317554   neo_pcm2_swap(machine, 2);
7532   neogeo_fixed_layer_bank_type = 1;
7555   state->fixed_layer_bank_type = 1;
75337556   neogeo_cmc50_m1_decrypt(machine);
75347557   kof2000_neogeo_gfx_decrypt(machine, 0x19);
7535   DRIVER_INIT_CALL(neogeo);
75367558   install_pvc_protection(machine);
75377559}
75387560
75397561static TIMER_CALLBACK( ms5pcb_bios_timer_callback )
75407562{
75417563   int harddip3 = input_port_read(machine, "HARDDIP") & 1;
7542   memory_set_bankptr(machine, NEOGEO_BANK_BIOS, memory_region(machine, "mainbios")+0x20000+harddip3*0x20000);
7564   memory_set_bankptr(machine, NEOGEO_BANK_BIOS, memory_region(machine, "mainbios") + 0x20000 + harddip3 * 0x20000);
75437565}
75447566
75457567static DRIVER_INIT( ms5pcb )
75467568{
7569   neogeo_state *state = (neogeo_state *)machine->driver_data;
7570   DRIVER_INIT_CALL(neogeo);
7571
75477572   /* start a timer that will check the BIOS select DIP every second */
75487573   timer_set(machine, attotime_zero, NULL, 0, ms5pcb_bios_timer_callback);
75497574   timer_pulse(machine, ATTOTIME_IN_MSEC(1000), NULL, 0, ms5pcb_bios_timer_callback);
r6740r6741
75527577   svcpcb_gfx_decrypt(machine);
75537578   neogeo_cmc50_m1_decrypt(machine);
75547579   kof2000_neogeo_gfx_decrypt(machine, 0x19);
7555   neogeo_fixed_layer_bank_type = 2;
7580   state->fixed_layer_bank_type = 2;
75567581   svcpcb_s1data_decrypt(machine);
75577582   neo_pcm2_swap(machine, 2);
7558   DRIVER_INIT_CALL(neogeo);
75597583   install_pvc_protection(machine);
75607584}
75617585
75627586static DRIVER_INIT( ms5plus )
75637587{
7588   neogeo_state *state = (neogeo_state *)machine->driver_data;
7589   DRIVER_INIT_CALL(neogeo);
75647590   cmc50_neogeo_gfx_decrypt(machine, 0x19);
75657591   neo_pcm2_swap(machine, 2);
75667592   neogeo_bootleg_sx_decrypt(machine, 1);
7567   neogeo_fixed_layer_bank_type = 1;
7593   state->fixed_layer_bank_type = 1;
75687594   neogeo_cmc50_m1_decrypt(machine);
7569   DRIVER_INIT_CALL(neogeo);
75707595   install_ms5plus_protection(machine);
75717596}
75727597
75737598static TIMER_CALLBACK( svcpcb_bios_timer_callback )
75747599{
75757600   int harddip3 = input_port_read(machine, "HARDDIP") & 1;
7576   memory_set_bankptr(machine, NEOGEO_BANK_BIOS, memory_region(machine, "mainbios")+0x20000+harddip3*0x20000);
7601   memory_set_bankptr(machine, NEOGEO_BANK_BIOS, memory_region(machine, "mainbios") + 0x20000 + harddip3 * 0x20000);
75777602}
75787603
75797604static DRIVER_INIT( svcpcb )
75807605{
7606   neogeo_state *state = (neogeo_state *)machine->driver_data;
7607   DRIVER_INIT_CALL(neogeo);
7608
75817609   /* start a timer that will check the BIOS select DIP every second */
75827610   timer_set(machine, attotime_zero, NULL, 0, svcpcb_bios_timer_callback);
75837611   timer_pulse(machine, ATTOTIME_IN_MSEC(1000), NULL, 0, svcpcb_bios_timer_callback);
r6740r6741
75887616   kof2000_neogeo_gfx_decrypt(machine, 0x57);
75897617   svcpcb_s1data_decrypt(machine);
75907618   neo_pcm2_swap(machine, 3);
7591   neogeo_fixed_layer_bank_type = 2;
7592   DRIVER_INIT_CALL(neogeo);
7619   state->fixed_layer_bank_type = 2;
75937620   install_pvc_protection(machine);
75947621}
75957622
75967623static DRIVER_INIT( svc )
75977624{
7625   neogeo_state *state = (neogeo_state *)machine->driver_data;
7626   DRIVER_INIT_CALL(neogeo);
75987627   svc_px_decrypt(machine);
75997628   neo_pcm2_swap(machine, 3);
7600   neogeo_fixed_layer_bank_type = 2;
7629   state->fixed_layer_bank_type = 2;
76017630   neogeo_cmc50_m1_decrypt(machine);
76027631   kof2000_neogeo_gfx_decrypt(machine, 0x57);
7603   DRIVER_INIT_CALL(neogeo);
76047632   install_pvc_protection(machine);
76057633}
76067634
76077635static DRIVER_INIT( svcboot )
76087636{
7637   DRIVER_INIT_CALL(neogeo);
76097638   svcboot_px_decrypt(machine);
76107639   svcboot_cx_decrypt(machine);
7611   DRIVER_INIT_CALL(neogeo);
76127640   install_pvc_protection(machine);
76137641}
76147642
76157643static DRIVER_INIT( svcplus )
76167644{
7645   DRIVER_INIT_CALL(neogeo);
76177646   svcplus_px_decrypt(machine);
76187647   svcboot_cx_decrypt(machine);
76197648   neogeo_bootleg_sx_decrypt(machine, 1);
76207649   svcplus_px_hack(machine);
7621   DRIVER_INIT_CALL(neogeo);
76227650}
76237651
76247652static DRIVER_INIT( svcplusa )
76257653{
7654   DRIVER_INIT_CALL(neogeo);
76267655   svcplusa_px_decrypt(machine);
76277656   svcboot_cx_decrypt(machine);
76287657   svcplus_px_hack(machine);
7629   DRIVER_INIT_CALL(neogeo);
76307658}
76317659
76327660static DRIVER_INIT( svcsplus )
76337661{
7662   DRIVER_INIT_CALL(neogeo);
76347663   svcsplus_px_decrypt(machine);
76357664   neogeo_bootleg_sx_decrypt(machine, 2);
76367665   svcboot_cx_decrypt(machine);
76377666   svcsplus_px_hack(machine);
7638   DRIVER_INIT_CALL(neogeo);
76397667   install_pvc_protection(machine);
76407668}
76417669
76427670static DRIVER_INIT( samsho5 )
76437671{
7672   neogeo_state *state = (neogeo_state *)machine->driver_data;
7673   DRIVER_INIT_CALL(neogeo);
76447674   samsho5_decrypt_68k(machine);
76457675   neo_pcm2_swap(machine, 4);
7646   neogeo_fixed_layer_bank_type = 1;
7676   state->fixed_layer_bank_type = 1;
76477677   neogeo_cmc50_m1_decrypt(machine);
76487678   kof2000_neogeo_gfx_decrypt(machine, 0x0f);
7649   DRIVER_INIT_CALL(neogeo);
76507679}
76517680
76527681static DRIVER_INIT( samsho5b )
76537682{
7683   DRIVER_INIT_CALL(neogeo);
76547684   samsho5b_px_decrypt(machine);
76557685   samsho5b_vx_decrypt(machine);
76567686   neogeo_bootleg_sx_decrypt(machine, 1);
76577687   neogeo_bootleg_cx_decrypt(machine);
7658   DRIVER_INIT_CALL(neogeo);
76597688}
76607689
76617690static DRIVER_INIT( kf2k3pcb )
76627691{
7692   neogeo_state *state = (neogeo_state *)machine->driver_data;
7693   DRIVER_INIT_CALL(neogeo);
76637694   kf2k3pcb_decrypt_68k(machine);
76647695   kf2k3pcb_gfx_decrypt(machine);
76657696   kof2003biosdecode(machine);
r6740r6741
76717702   {
76727703      int i;
76737704      UINT8* rom = memory_region(machine, "audiocpu");
7674      for (i=0;i<0x90000;i++)
7705      for (i = 0; i < 0x90000; i++)
76757706      {
76767707         rom[i] = BITSWAP8(rom[i], 5, 6, 1, 4, 3, 0, 7, 2);
76777708      }
r6740r6741
76817712   kof2000_neogeo_gfx_decrypt(machine, 0x9d);
76827713   kf2k3pcb_decrypt_s1data(machine);
76837714   neo_pcm2_swap(machine, 5);
7684   neogeo_fixed_layer_bank_type = 2;
7685   DRIVER_INIT_CALL(neogeo);
7715   state->fixed_layer_bank_type = 2;
76867716   install_pvc_protection(machine);
7687   memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc7ffff, 0, 0, "bank6" );  // 512k bios
7717   memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc7ffff, 0, 0, "bios" );  // 512k bios
76887718}
76897719
76907720static DRIVER_INIT( kof2003 )
76917721{
7722   neogeo_state *state = (neogeo_state *)machine->driver_data;
7723   DRIVER_INIT_CALL(neogeo);
76927724   kof2003_decrypt_68k(machine);
76937725   neo_pcm2_swap(machine, 5);
7694   neogeo_fixed_layer_bank_type = 2;
7726   state->fixed_layer_bank_type = 2;
76957727   neogeo_cmc50_m1_decrypt(machine);
76967728   kof2000_neogeo_gfx_decrypt(machine, 0x9d);
7697   DRIVER_INIT_CALL(neogeo);
76987729   install_pvc_protection(machine);
76997730}
77007731
77017732static DRIVER_INIT( kof2003h )
77027733{
7734   neogeo_state *state = (neogeo_state *)machine->driver_data;
7735   DRIVER_INIT_CALL(neogeo);
77037736   kof2003h_decrypt_68k(machine);
77047737   neo_pcm2_swap(machine, 5);
7705   neogeo_fixed_layer_bank_type = 2;
7738   state->fixed_layer_bank_type = 2;
77067739   neogeo_cmc50_m1_decrypt(machine);
77077740   kof2000_neogeo_gfx_decrypt(machine, 0x9d);
7708   DRIVER_INIT_CALL(neogeo);
77097741   install_pvc_protection(machine);
77107742}
77117743
77127744static DRIVER_INIT( kf2k3bl )
77137745{
7746   DRIVER_INIT_CALL(neogeo);
77147747   cmc50_neogeo_gfx_decrypt(machine, 0x9d);
77157748   neo_pcm2_swap(machine, 5);
77167749   neogeo_bootleg_sx_decrypt(machine, 1);
7717   DRIVER_INIT_CALL(neogeo);
77187750   kf2k3bl_install_protection(machine);
77197751}
77207752
77217753static DRIVER_INIT( kf2k3pl )
77227754{
7755   DRIVER_INIT_CALL(neogeo);
77237756   cmc50_neogeo_gfx_decrypt(machine, 0x9d);
77247757   neo_pcm2_swap(machine, 5);
77257758   kf2k3pl_px_decrypt(machine);
77267759   neogeo_bootleg_sx_decrypt(machine, 1);
7727   DRIVER_INIT_CALL(neogeo);
77287760   kf2k3pl_install_protection(machine);
77297761}
77307762
77317763static DRIVER_INIT( kf2k3upl )
77327764{
7765   DRIVER_INIT_CALL(neogeo);
77337766   cmc50_neogeo_gfx_decrypt(machine, 0x9d);
77347767   neo_pcm2_swap(machine, 5);
77357768   kf2k3upl_px_decrypt(machine);
77367769   neogeo_bootleg_sx_decrypt(machine, 2);
7737   DRIVER_INIT_CALL(neogeo);
77387770   kf2k3upl_install_protection(machine);
77397771}
77407772
77417773static DRIVER_INIT( samsh5sp )
77427774{
7775   neogeo_state *state = (neogeo_state *)machine->driver_data;
7776   DRIVER_INIT_CALL(neogeo);
77437777   samsh5sp_decrypt_68k(machine);
77447778   neo_pcm2_swap(machine, 6);
7745   neogeo_fixed_layer_bank_type = 1;
7779   state->fixed_layer_bank_type = 1;
77467780   neogeo_cmc50_m1_decrypt(machine);
77477781   kof2000_neogeo_gfx_decrypt(machine, 0x0d);
7748   DRIVER_INIT_CALL(neogeo);
77497782}
77507783
77517784static DRIVER_INIT( jockeygp )
77527785{
7753   neogeo_fixed_layer_bank_type = 1;
7786   neogeo_state *state = (neogeo_state *)machine->driver_data;
7787   DRIVER_INIT_CALL(neogeo);
7788   state->fixed_layer_bank_type = 1;
77547789   neogeo_cmc50_m1_decrypt(machine);
77557790   kof2000_neogeo_gfx_decrypt(machine, 0xac);
77567791
r6740r6741
77597794
77607795//  memory_install_read_port(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x280000, 0x280001, 0, 0, "IN5");
77617796//  memory_install_read_port(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x2c0000, 0x2c0001, 0, 0, "IN6");
7762
7763   DRIVER_INIT_CALL(neogeo);
77647797}
77657798
77667799static DRIVER_INIT( vliner )
r6740r6741
77967829/***********************************************************************/
77977830
77987831
7799/*    YEAR  NAME      PARENT    MACHINE   INPUT     INIT      MONITOR  */
7800GAME( 1990, neogeo,   0,        neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Neo-Geo", GAME_IS_BIOS_ROOT )
7832/*    YEAR  NAME       PARENT    MACHINE   INPUT     INIT      MONITOR  */
7833GAME( 1990, neogeo,    0,        neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Neo-Geo", GAME_IS_BIOS_ROOT | GAME_SUPPORTS_SAVE )
78017834
78027835/* SNK */
7803GAME( 1990, nam1975,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "NAM-1975", 0 )
7804GAME( 1990, bstars,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Baseball Stars Professional (set 1)", 0 )
7805GAME( 1990, bstarsh,  bstars,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Baseball Stars Professional (set 2)", 0 )
7806GAME( 1990, tpgolf,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Top Player's Golf", 0 )
7807GAME( 1990, mahretsu, neogeo,   neogeo,   mjneogeo, neogeo,   ROT0, "SNK", "Mahjong Kyoretsuden", 0 )
7808GAME( 1990, ridhero,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Riding Hero (set 1)", 0 )
7809GAME( 1990, ridheroh, ridhero,  neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Riding Hero (set 2)", 0 )
7810GAME( 1991, alpham2,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Alpha Mission II / ASO II - Last Guardian", 0 )
7811GAME( 1990, cyberlip, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Cyber-Lip", 0 )
7812GAME( 1990, superspy, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The Super Spy", 0 )
7813GAME( 1992, mutnat,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Mutation Nation", 0 )
7814GAME( 1991, kotm,     neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "King of the Monsters (set 1)", 0 )
7815GAME( 1991, kotmh,    kotm,     neogeo,   neogeo,   neogeo,   ROT0, "SNK", "King of the Monsters (set 2)", 0 )
7816GAME( 1991, sengoku,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Sengoku / Sengoku Denshou (set 1)", 0 )
7817GAME( 1991, sengokh,  sengoku,  neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Sengoku / Sengoku Denshou (set 2)", 0 )
7818GAME( 1991, burningf, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Burning Fight (set 1)", 0 )
7819GAME( 1991, burningfh,burningf, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Burning Fight (set 2)", 0 )
7820GAME( 1990, lbowling, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "League Bowling", 0 )
7821GAME( 1991, gpilots,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Ghost Pilots (set 1)", 0 )
7822GAME( 1991, gpilotsh, gpilots,  neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Ghost Pilots (set 2)", 0 )
7823GAME( 1990, joyjoy,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Puzzled / Joy Joy Kid", 0 )
7824GAME( 1991, quizdais, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Quiz Daisousa Sen - The Last Count Down", 0 )
7825GAME( 1992, lresort,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Last Resort", 0 )
7826GAME( 1991, eightman, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK / Pallas", "Eight Man", 0 )
7827GAME( 1991, legendos, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Legend of Success Joe / Ashitano Joe Densetsu", 0 )
7828GAME( 1991, 2020bb,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK / Pallas", "2020 Super Baseball (set 1)", 0 )
7829GAME( 1991, 2020bba,  2020bb,   neogeo,   neogeo,   neogeo,   ROT0, "SNK / Pallas", "2020 Super Baseball (set 2)", 0 )
7830GAME( 1991, 2020bbh,  2020bb,   neogeo,   neogeo,   neogeo,   ROT0, "SNK / Pallas", "2020 Super Baseball (set 3)", 0 )
7831GAME( 1991, socbrawl, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Soccer Brawl (set 1)", 0 )
7832GAME( 1991, socbrawla, socbrawl, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Soccer Brawl (set 2)", 0 )
7833GAME( 1991, fatfury1, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Fatal Fury - King of Fighters / Garou Densetsu - shukumei no tatakai", 0 )
7834GAME( 1991, roboarmy, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Robo Army", 0 )
7835//GAME( 1991, roboarma, roboarmy, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Robo Army (set 2)", 0 )
7836GAME( 1992, fbfrenzy, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Football Frenzy", 0 )
7837GAME( 1992, kotm2,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "King of the Monsters 2 - The Next Thing", 0 )
7838GAME( 1993, sengoku2, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Sengoku 2 / Sengoku Denshou 2", 0 )
7839GAME( 1992, bstars2,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Baseball Stars 2", 0 )
7840GAME( 1992, quizdai2, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Quiz Meitantei Neo & Geo - Quiz Daisousa Sen part 2", 0 )
7841GAME( 1993, 3countb,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "3 Count Bout / Fire Suplex", 0 )
7842GAME( 1992, aof,      neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Art of Fighting / Ryuuko no Ken", 0 )
7843GAME( 1993, samsho,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Samurai Shodown / Samurai Spirits (set 1)", 0 )
7844GAME( 1993, samshoh,  samsho,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Samurai Shodown / Samurai Spirits (set 2)", 0 )
7845GAME( 1994, tophuntr, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Top Hunter - Roddy & Cathy (set 1)", 0 )
7846GAME( 1994, tophuntrh,tophuntr, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Top Hunter - Roddy & Cathy (set 2)", 0 )
7847GAME( 1992, fatfury2, neogeo,   neogeo,   neogeo,   fatfury2, ROT0, "SNK", "Fatal Fury 2 / Garou Densetsu 2 - arata-naru tatakai", 0 )
7848GAME( 1992, ssideki,  neogeo,   neogeo,   neogeo,   fatfury2, ROT0, "SNK", "Super Sidekicks / Tokuten Ou", 0 )
7849GAME( 1994, kof94,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '94", 0 )
7850GAME( 1994, aof2,     neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Art of Fighting 2 / Ryuuko no Ken 2 (set 1)", 0 )
7851GAME( 1994, aof2a,    aof2,     neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Art of Fighting 2 / Ryuuko no Ken 2 (set 2)", 0 )
7852GAME( 1993, fatfursp, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Fatal Fury Special / Garou Densetsu Special (set 1)", 0 )
7853GAME( 1993, fatfursa, fatfursp, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Fatal Fury Special / Garou Densetsu Special (set 2)", 0 )
7854GAME( 1995, savagere, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Savage Reign / Fu'un Mokushiroku - kakutou sousei", 0 )
7855GAME( 1994, ssideki2, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Super Sidekicks 2 - The World Championship / Tokuten Ou 2 - real fight football", 0 )
7856GAME( 1994, samsho2,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Samurai Shodown II / Shin Samurai Spirits - Haohmaru jigokuhen", 0 )
7857GAME( 1994, samsho2k, samsho2,  neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Saulabi Spirits / Jin Saulabi Tu Hon (Korean release of Samurai Shodown II)", 0 ) // official or hack?
7858GAME( 1995, fatfury3, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Fatal Fury 3 - Road to the Final Victory / Garou Densetsu 3 - haruka-naru tatakai", 0 )
7859GAME( 1995, ssideki3, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Super Sidekicks 3 - The Next Glory / Tokuten Ou 3 - eikoue no michi", 0 )
7860GAME( 1995, kof95,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '95 (set 1)", 0 )
7861GAME( 1995, kof95h,   kof95,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '95 (set 2)", 0 )
7862GAME( 1995, samsho3,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Samurai Shodown III / Samurai Spirits - Zankurou Musouken (set 1)", 0 )
7863GAME( 1995, samsho3h, samsho3,  neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Samurai Shodown III / Samurai Spirits - Zankurou Musouken (set 2)", 0 )
7864GAME( 1995, fswords,  samsho3,  neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Fighters Swords (Korean release of Samurai Shodown III)", 0 )
7865GAME( 1995, rbff1,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Real Bout Fatal Fury / Real Bout Garou Densetsu", 0 )
7866GAME( 1995, rbff1a,   rbff1,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Real Bout Fatal Fury / Real Bout Garou Densetsu (bug fix revision)", 0 )
7867GAME( 1996, aof3,     neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Art of Fighting 3 - The Path of the Warrior / Art of Fighting - Ryuuko no Ken Gaiden", 0 )
7868GAME( 1996, aof3k,    aof3,     neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Art of Fighting 3 - The Path of the Warrior (Korean release)", 0 ) // no Japanese title / mode
7869GAME( 1996, kof96,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '96 (set 1)", 0 )
7870GAME( 1996, kof96h,   kof96,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '96 (set 2)", 0 )
7871GAME( 1996, ssideki4, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Ultimate 11 - The SNK Football Championship / Tokuten Ou - Honoo no Libero, The", 0 )
7872GAME( 1996, kizuna,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Kizuna Encounter - Super Tag Battle / Fu'un Super Tag Battle", 0 )
7873GAME( 1996, samsho4,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Samurai Shodown IV - Amakusa's Revenge / Samurai Spirits - Amakusa Kourin", 0 )
7874GAME( 1996, samsho4k, samsho4,  neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Pae Wang Jeon Seol / Legend of a Warrior (Korean censored Samurai Shodown IV)", 0 )
7875GAME( 1996, rbffspec, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Real Bout Fatal Fury Special / Real Bout Garou Densetsu Special", 0 )
7876GAME( 1997, kof97,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '97 (set 1)", 0 )
7877GAME( 1997, kof97h,   kof97,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '97 (set 2)", 0 )
7878GAME( 1997, kof97pls, kof97,    neogeo,   neogeo,   neogeo,   ROT0, "bootleg", "The King of Fighters '97 Plus (bootleg)", 0 )
7879GAME( 1997, kog,      kof97,    neogeo,   kog,      kog,      ROT0, "bootleg", "King of Gladiator (The King of Fighters '97 bootleg)", GAME_NOT_WORKING) // protected bootleg
7880GAME( 1997, lastblad, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Last Blade / Bakumatsu Roman - Gekka no Kenshi, The (set 1)", 0 )
7881GAME( 1997, lastbladh,lastblad, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Last Blade / Bakumatsu Roman - Gekka no Kenshi, The (set 2)", 0 )
7882GAME( 1997, lastsold, lastblad, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The Last Soldier (Korean release of The Last Blade)", 0 )
7883GAME( 1997, irrmaze,  neogeo,   neogeo,   irrmaze,  neogeo,   ROT0, "SNK / Saurus", "The Irritating Maze / Ultra Denryu Iraira Bou", 0 )
7884GAME( 1998, rbff2,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Real Bout Fatal Fury 2 - The Newcomers / Real Bout Garou Densetsu 2 - the newcomers (set 1)", 0 )
7885GAME( 1998, rbff2h,   rbff2,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Real Bout Fatal Fury 2 - The Newcomers / Real Bout Garou Densetsu 2 - the newcomers (set 2)", 0 )
7886GAME( 1998, rbff2k,   rbff2,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Real Bout Fatal Fury 2 - The Newcomers (Korean release)", 0 ) // no Japanese title / mode
7887GAME( 1998, mslug2,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Metal Slug 2 - Super Vehicle-001/II", 0 )
7888GAME( 1998, kof98,    neogeo,   neogeo,   neogeo,   kof98,    ROT0, "SNK", "The King of Fighters '98 - The Slugfest / King of Fighters '98 - dream match never ends", 0 )
7889GAME( 1998, kof98k,   kof98,    neogeo,   neogeo,   kof98,    ROT0, "SNK", "The King of Fighters '98 - The Slugfest / King of Fighters '98 - dream match never ends (Korean board)", 0 )
7890GAME( 1998, kof98n,   kof98,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '98 - The Slugfest / King of Fighters '98 - dream match never ends (not encrypted)", 0 )
7891GAME( 1998, lastbld2, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Last Blade 2 / Bakumatsu Roman - Dai Ni Maku Gekka no Kenshi, The", 0 )
7892GAME( 1998, neocup98, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Neo-Geo Cup '98 - The Road to the Victory", 0 )
7893GAME( 1999, mslugx,   neogeo,   neogeo,   neogeo,   mslugx,   ROT0, "SNK", "Metal Slug X - Super Vehicle-001", 0 )
7894GAME( 1999, kof99,    neogeo,   neogeo,   neogeo,   kof99,    ROT0, "SNK", "The King of Fighters '99 - Millennium Battle (set 1)" , 0 ) /* Encrypted Code & GFX */
7895GAME( 1999, kof99a,   kof99,    neogeo,   neogeo,   kof99,    ROT0, "SNK", "The King of Fighters '99 - Millennium Battle (set 2)" , 0 ) /* Encrypted Code & GFX, crashes going into attract demo */
7896GAME( 1999, kof99e,   kof99,    neogeo,   neogeo,   kof99,    ROT0, "SNK", "The King of Fighters '99 - Millennium Battle (earlier)" , 0 ) /* Encrypted Code & GFX */
7897GAME( 1999, kof99n,   kof99,    neogeo,   neogeo,   kof99n,   ROT0, "SNK", "The King of Fighters '99 - Millennium Battle (not encrypted)" , 0 )   /* Encrypted GFX */
7898GAME( 1999, kof99p,   kof99,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '99 - Millennium Battle (prototype)", 0 )
7899GAME( 1999, garou,    neogeo,   neogeo,   neogeo,   garou,    ROT0, "SNK", "Garou - Mark of the Wolves (set 1)" , 0 ) /* Encrypted Code & GFX */
7900GAME( 1999, garouo,   garou,    neogeo,   neogeo,   garouo,   ROT0, "SNK", "Garou - Mark of the Wolves (set 2)" , 0 ) /* Encrypted Code & GFX */
7901GAME( 1999, garoup,   garou,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Garou - Mark of the Wolves (prototype)", 0 )
7902GAME( 1999, garoubl,  garou,    neogeo,   neogeo,   garoubl,  ROT0, "bootleg", "Garou - Mark of the Wolves (bootleg)", 0 ) /* Bootleg of garoup */
7903GAME( 2000, mslug3,   neogeo,   neogeo,   neogeo,   mslug3,   ROT0, "SNK", "Metal Slug 3" , 0 ) /* Encrypted Code & GFX */
7904GAME( 2000, mslug3h,  mslug3,   neogeo,   neogeo,   mslug3h,  ROT0, "SNK", "Metal Slug 3 (not encrypted)" , 0 ) /* Encrypted GFX */
7905GAME( 2000, mslug3b6, mslug3,   neogeo,   neogeo,   mslug3b6, ROT0, "bootleg", "Metal Slug 6 (Metal Slug 3 bootleg)", 0 ) /* real Metal Slug 6 is an Atomiswave HW game, see atomswav.c ;-) */
7906GAME( 2000, kof2000,  neogeo,   neogeo,   neogeo,   kof2000,  ROT0, "SNK", "The King of Fighters 2000" , 0 ) /* Encrypted Code & GFX */
7907GAME( 2000, kof2000n, kof2000,  neogeo,   neogeo,   kof2000n, ROT0, "SNK", "The King of Fighters 2000 (not encrypted)" , 0 ) /* Encrypted GFX */
7908GAME( 2001, zupapa,   neogeo,   neogeo,   neogeo,   zupapa,   ROT0, "SNK", "Zupapa!" , 0 )   /* Encrypted GFX */
7909GAME( 2001, sengoku3, neogeo,   neogeo,   neogeo,   sengoku3, ROT0, "Noise Factory / SNK", "Sengoku 3 / Sengoku Densho 2001" , 0 )   /* Encrypted GFX */
7910GAME( 2001, kof2001,  neogeo,   neogeo,   neogeo,   kof2001,  ROT0, "Eolith / SNK", "The King of Fighters 2001 (set 1)" , 0 ) /* Encrypted GFX */
7911GAME( 2001, kof2001h, kof2001,  neogeo,   neogeo,   kof2001,  ROT0, "Eolith / SNK", "The King of Fighters 2001 (set 2)" , 0 ) /* Encrypted GFX */
7912GAME( 2003, cthd2003, kof2001,  neogeo,   neogeo,   cthd2003, ROT0, "bootleg", "Crouching Tiger Hidden Dragon 2003 (The King of Fighters 2001 bootleg)", 0 ) /* Protected Hack / Bootleg of kof2001 */
7913GAME( 2003, ct2k3sp,  kof2001,  neogeo,   neogeo,   ct2k3sp,  ROT0, "bootleg", "Crouching Tiger Hidden Dragon 2003 Super Plus (The King of Fighters 2001 bootleg)", 0 ) /* Protected Hack / Bootleg of kof2001 */
7914GAME( 2003, ct2k3sa,  kof2001,  neogeo,   neogeo,   ct2k3sa,  ROT0, "bootleg", "Crouching Tiger Hidden Dragon 2003 Super Plus alternate (The King of Fighters 2001 bootleg)", 0 ) /* Hack / Bootleg of kof2001 */
7915GAME( 2002, kof2002,  neogeo,   neogeo,   neogeo,   kof2002,  ROT0, "Eolith / Playmore", "The King of Fighters 2002" , 0 ) /* Encrypted GFX */
7916GAME( 2002, kof2002b, kof2002,  neogeo,   neogeo,   kof2002b, ROT0, "bootleg", "The King of Fighters 2002 (bootleg)", 0 )
7917GAME( 2002, kf2k2pls, kof2002,  neogeo,   neogeo,   kf2k2pls, ROT0, "bootleg", "The King of Fighters 2002 Plus (bootleg set 1)" , 0 ) /* Encrypted GFX */
7918GAME( 2002, kf2k2pla, kof2002,  neogeo,   neogeo,   kf2k2pls, ROT0, "bootleg", "The King of Fighters 2002 Plus (bootleg set 2)" , 0 ) /* Encrypted GFX */
7919GAME( 2002, kf2k2mp,  kof2002,  neogeo,   neogeo,   kf2k2mp,  ROT0, "bootleg", "The King of Fighters 2002 Magic Plus (bootleg)" , 0 ) /* Encrypted GFX */
7920GAME( 2002, kf2k2mp2, kof2002,  neogeo,   neogeo,   kf2k2mp2, ROT0, "bootleg", "The King of Fighters 2002 Magic Plus II (bootleg)" , 0 ) /* Encrypted GFX */
7921GAME( 2002, kof10th,  kof2002,  neogeo,   neogeo,   kof10th,  ROT0, "bootleg", "The King of Fighters 10th Anniversary (The King of Fighters 2002 bootleg)", 0 ) // fake SNK copyright
7922GAME( 2005, kf10thep, kof2002,  neogeo,   neogeo,   kf10thep, ROT0, "bootleg", "The King of Fighters 10th Anniversary Extra Plus (The King of Fighters 2002 bootleg)", 0 ) // fake SNK copyright
7923GAME( 2004, kf2k5uni, kof2002,  neogeo,   neogeo,   kf2k5uni, ROT0, "bootleg", "The King of Fighters 10th Anniversary 2005 Unique (The King of Fighters 2002 bootleg)", 0 ) // fake SNK copyright
7924GAME( 2004, kof2k4se, kof2002,  neogeo,   neogeo,   kof2k4se, ROT0, "bootleg", "The King of Fighters Special Edition 2004 (The King of Fighters 2002 bootleg)", 0 ) /* Hack / Bootleg of kof2002 */
7925GAME( 2003, mslug5,   neogeo,   neogeo,   neogeo,   mslug5,   ROT0, "SNK Playmore", "Metal Slug 5", 0 )
7926GAME( 2003, mslug5h,  mslug5,   neogeo,   neogeo,   mslug5,   ROT0, "SNK Playmore", "Metal Slug 5 (AES Cart)", 0 ) /* Also found in later MVS carts */
7927GAME( 2003, ms5pcb,   0,        neogeo,   ms5pcb,   ms5pcb,   ROT0, "SNK Playmore", "Metal Slug 5 (JAMMA PCB)", 0 )
7928GAME( 2003, ms5plus,  mslug5,   neogeo,   neogeo,   ms5plus,  ROT0, "bootleg", "Metal Slug 5 Plus (bootleg)",0 )
7929GAME( 2003, svcpcb,   0,        neogeo,   svcpcb,   svcpcb,   ROT0, "SNK Playmore", "SNK vs. CAPCOM SVC CHAOS (JAMMA PCB, set 1)", 0 ) // not a clone of neogeo because it's NOT a neogeo cart.
7930GAME( 2003, svcpcba,  svcpcb,   neogeo,   svcpcb,   svcpcb,   ROT0, "SNK Playmore", "SNK vs. CAPCOM SVC CHAOS (JAMMA PCB, set 2)" , 0 ) /* Encrypted Code */
7931GAME( 2003, svc,      neogeo,   neogeo,   neogeo,   svc,      ROT0, "SNK Playmore", "SNK vs. CAPCOM SVC CHAOS", 0 )
7932GAME( 2003, svcboot,  svc,      neogeo,   neogeo,   svcboot,  ROT0, "bootleg", "SNK vs. CAPCOM SVC CHAOS (bootleg)", 0 )
7933GAME( 2003, svcplus,  svc,      neogeo,   neogeo,   svcplus,  ROT0, "bootleg", "SNK vs. CAPCOM SVC CHAOS Plus (bootleg set 1)", 0 )
7934GAME( 2003, svcplusa, svc,      neogeo,   neogeo,   svcplusa, ROT0, "bootleg", "SNK vs. CAPCOM SVC CHAOS Plus (bootleg set 2)", 0 )
7935GAME( 2003, svcsplus, svc,      neogeo,   neogeo,   svcsplus, ROT0, "bootleg", "SNK vs. CAPCOM SVC CHAOS Super Plus (bootleg)", 0 )
7936GAME( 2003, samsho5,  neogeo,   neogeo,   neogeo,   samsho5,  ROT0, "Yuki Enterprise / SNK Playmore", "Samurai Shodown V / Samurai Spirits Zero (set 1)", 0 )
7937GAME( 2003, samsho5h, samsho5,  neogeo,   neogeo,   samsho5,  ROT0, "Yuki Enterprise / SNK Playmore", "Samurai Shodown V / Samurai Spirits Zero (set 2)", 0 )
7938GAME( 2003, samsho5b, samsho5,  neogeo,   neogeo,   samsho5b, ROT0, "bootleg", "Samurai Shodown V / Samurai Spirits Zero (bootleg)", 0 ) // different program scrambling
7939GAME( 2003, kf2k3pcb, 0,        neogeo,   neogeo,   kf2k3pcb, ROT0, "SNK Playmore", "The King of Fighters 2003 (Japan, JAMMA PCB)", 0 ) // not a clone of neogeo because it's NOT a neogeo cart.
7940GAME( 2003, kof2003,  neogeo,   neogeo,   neogeo,   kof2003,  ROT0, "SNK Playmore", "The King of Fighters 2003 (set 1)", 0 )
7941GAME( 2003, kof2003h, kof2003,  neogeo,   neogeo,   kof2003h, ROT0, "SNK Playmore", "The King of Fighters 2003 (set 2)", 0 )
7942GAME( 2003, kf2k3bl,  kof2003,  neogeo,   neogeo,   kf2k3bl , ROT0, "bootleg", "The King of Fighters 2003 (bootleg set 1)", 0 ) // zooming is wrong because its a bootleg of the pcb version on a cart (unless it was a bootleg pcb with the new bios?)
7943GAME( 2003, kf2k3bla, kof2003,  neogeo,   neogeo,   kf2k3pl,  ROT0, "bootleg", "The King of Fighters 2003 (bootleg set 2)", 0 ) // zooming is wrong because its a bootleg of the pcb version on a cart
7944GAME( 2003, kf2k3pl,  kof2003,  neogeo,   neogeo,   kf2k3pl,  ROT0, "bootleg", "The King of Fighters 2004 Plus / Hero (The King of Fighters 2003 bootleg)", 0 ) // zooming is wrong because its a bootleg of the pcb version on a cart
7945GAME( 2003, kf2k3upl, kof2003,  neogeo,   neogeo,   kf2k3upl, ROT0, "bootleg", "The King of Fighters 2004 Ultra Plus (The King of Fighters 2003 bootleg)", 0 ) // zooming is wrong because its a bootleg of the pcb version on a cart
7946GAME( 2003, samsh5sp, neogeo,   neogeo,   neogeo,   samsh5sp, ROT0, "Yuki Enterprise / SNK Playmore", "Samurai Shodown V Special / Samurai Spirits Zero Special (set 1, uncensored)", 0 )
7947GAME( 2003, samsh5sph,samsh5sp, neogeo,   neogeo,   samsh5sp, ROT0, "Yuki Enterprise / SNK Playmore", "Samurai Shodown V Special / Samurai Spirits Zero Special (set 2, censored)", 0 )
7948GAME( 2003, samsh5spn,samsh5sp, neogeo,   neogeo,   samsh5sp, ROT0, "Yuki Enterprise / SNK Playmore", "Samurai Shodown V Special / Samurai Spirits Zero Special (set 3, less censored)", 0 )
7836GAME( 1990, nam1975,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "NAM-1975", GAME_SUPPORTS_SAVE )
7837GAME( 1990, bstars,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Baseball Stars Professional (set 1)", GAME_SUPPORTS_SAVE )
7838GAME( 1990, bstarsh,   bstars,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Baseball Stars Professional (set 2)", GAME_SUPPORTS_SAVE )
7839GAME( 1990, tpgolf,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Top Player's Golf", GAME_SUPPORTS_SAVE )
7840GAME( 1990, mahretsu,  neogeo,   neogeo,   mjneogeo, neogeo,   ROT0, "SNK", "Mahjong Kyoretsuden", GAME_SUPPORTS_SAVE )
7841GAME( 1990, ridhero,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Riding Hero (set 1)", GAME_SUPPORTS_SAVE )
7842GAME( 1990, ridheroh,  ridhero,  neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Riding Hero (set 2)", GAME_SUPPORTS_SAVE )
7843GAME( 1991, alpham2,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Alpha Mission II / ASO II - Last Guardian", GAME_SUPPORTS_SAVE )
7844GAME( 1990, cyberlip,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Cyber-Lip", GAME_SUPPORTS_SAVE )
7845GAME( 1990, superspy,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The Super Spy", GAME_SUPPORTS_SAVE )
7846GAME( 1992, mutnat,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Mutation Nation", GAME_SUPPORTS_SAVE )
7847GAME( 1991, kotm,      neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "King of the Monsters (set 1)", GAME_SUPPORTS_SAVE )
7848GAME( 1991, kotmh,     kotm,     neogeo,   neogeo,   neogeo,   ROT0, "SNK", "King of the Monsters (set 2)", GAME_SUPPORTS_SAVE )
7849GAME( 1991, sengoku,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Sengoku / Sengoku Denshou (set 1)", GAME_SUPPORTS_SAVE )
7850GAME( 1991, sengokh,   sengoku,  neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Sengoku / Sengoku Denshou (set 2)", GAME_SUPPORTS_SAVE )
7851GAME( 1991, burningf,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Burning Fight (set 1)", GAME_SUPPORTS_SAVE )
7852GAME( 1991, burningfh, burningf, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Burning Fight (set 2)", GAME_SUPPORTS_SAVE )
7853GAME( 1990, lbowling,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "League Bowling", GAME_SUPPORTS_SAVE )
7854GAME( 1991, gpilots,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Ghost Pilots (set 1)", GAME_SUPPORTS_SAVE )
7855GAME( 1991, gpilotsh,  gpilots,  neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Ghost Pilots (set 2)", GAME_SUPPORTS_SAVE )
7856GAME( 1990, joyjoy,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Puzzled / Joy Joy Kid", GAME_SUPPORTS_SAVE )
7857GAME( 1991, quizdais,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Quiz Daisousa Sen - The Last Count Down", GAME_SUPPORTS_SAVE )
7858GAME( 1992, lresort,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Last Resort", GAME_SUPPORTS_SAVE )
7859GAME( 1991, eightman,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK / Pallas", "Eight Man", GAME_SUPPORTS_SAVE )
7860GAME( 1991, legendos,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Legend of Success Joe / Ashitano Joe Densetsu", GAME_SUPPORTS_SAVE )
7861GAME( 1991, 2020bb,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK / Pallas", "2020 Super Baseball (set 1)", GAME_SUPPORTS_SAVE )
7862GAME( 1991, 2020bba,   2020bb,   neogeo,   neogeo,   neogeo,   ROT0, "SNK / Pallas", "2020 Super Baseball (set 2)", GAME_SUPPORTS_SAVE )
7863GAME( 1991, 2020bbh,   2020bb,   neogeo,   neogeo,   neogeo,   ROT0, "SNK / Pallas", "2020 Super Baseball (set 3)", GAME_SUPPORTS_SAVE )
7864GAME( 1991, socbrawl,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Soccer Brawl (set 1)", GAME_SUPPORTS_SAVE )
7865GAME( 1991, socbrawla, socbrawl, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Soccer Brawl (set 2)", GAME_SUPPORTS_SAVE )
7866GAME( 1991, fatfury1,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Fatal Fury - King of Fighters / Garou Densetsu - shukumei no tatakai", GAME_SUPPORTS_SAVE )
7867GAME( 1991, roboarmy,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Robo Army", GAME_SUPPORTS_SAVE )
7868//GAME( 1991, roboarma,  roboarmy, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Robo Army (set 2)", GAME_SUPPORTS_SAVE )
7869GAME( 1992, fbfrenzy,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Football Frenzy", GAME_SUPPORTS_SAVE )
7870GAME( 1992, kotm2,     neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "King of the Monsters 2 - The Next Thing", GAME_SUPPORTS_SAVE )
7871GAME( 1993, sengoku2,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Sengoku 2 / Sengoku Denshou 2", GAME_SUPPORTS_SAVE )
7872GAME( 1992, bstars2,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Baseball Stars 2", GAME_SUPPORTS_SAVE )
7873GAME( 1992, quizdai2,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Quiz Meitantei Neo & Geo - Quiz Daisousa Sen part 2", GAME_SUPPORTS_SAVE )
7874GAME( 1993, 3countb,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "3 Count Bout / Fire Suplex", GAME_SUPPORTS_SAVE )
7875GAME( 1992, aof,       neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Art of Fighting / Ryuuko no Ken", GAME_SUPPORTS_SAVE )
7876GAME( 1993, samsho,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Samurai Shodown / Samurai Spirits (set 1)", GAME_SUPPORTS_SAVE )
7877GAME( 1993, samshoh,   samsho,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Samurai Shodown / Samurai Spirits (set 2)", GAME_SUPPORTS_SAVE )
7878GAME( 1994, tophuntr,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Top Hunter - Roddy & Cathy (set 1)", GAME_SUPPORTS_SAVE )
7879GAME( 1994, tophuntrh, tophuntr, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Top Hunter - Roddy & Cathy (set 2)", GAME_SUPPORTS_SAVE )
7880GAME( 1992, fatfury2,  neogeo,   neogeo,   neogeo,   fatfury2, ROT0, "SNK", "Fatal Fury 2 / Garou Densetsu 2 - arata-naru tatakai", GAME_SUPPORTS_SAVE )
7881GAME( 1992, ssideki,   neogeo,   neogeo,   neogeo,   fatfury2, ROT0, "SNK", "Super Sidekicks / Tokuten Ou", GAME_SUPPORTS_SAVE )
7882GAME( 1994, kof94,     neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '94", GAME_SUPPORTS_SAVE )
7883GAME( 1994, aof2,      neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Art of Fighting 2 / Ryuuko no Ken 2 (set 1)", GAME_SUPPORTS_SAVE )
7884GAME( 1994, aof2a,     aof2,     neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Art of Fighting 2 / Ryuuko no Ken 2 (set 2)", GAME_SUPPORTS_SAVE )
7885GAME( 1993, fatfursp,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Fatal Fury Special / Garou Densetsu Special (set 1)", GAME_SUPPORTS_SAVE )
7886GAME( 1993, fatfursa,  fatfursp, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Fatal Fury Special / Garou Densetsu Special (set 2)", GAME_SUPPORTS_SAVE )
7887GAME( 1995, savagere,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Savage Reign / Fu'un Mokushiroku - kakutou sousei", GAME_SUPPORTS_SAVE )
7888GAME( 1994, ssideki2,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Super Sidekicks 2 - The World Championship / Tokuten Ou 2 - real fight football", GAME_SUPPORTS_SAVE )
7889GAME( 1994, samsho2,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Samurai Shodown II / Shin Samurai Spirits - Haohmaru jigokuhen", GAME_SUPPORTS_SAVE )
7890GAME( 1994, samsho2k,  samsho2,  neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Saulabi Spirits / Jin Saulabi Tu Hon (Korean release of Samurai Shodown II)", GAME_SUPPORTS_SAVE ) // official or hack?
7891GAME( 1995, fatfury3,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Fatal Fury 3 - Road to the Final Victory / Garou Densetsu 3 - haruka-naru tatakai", GAME_SUPPORTS_SAVE )
7892GAME( 1995, ssideki3,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Super Sidekicks 3 - The Next Glory / Tokuten Ou 3 - eikoue no michi", GAME_SUPPORTS_SAVE )
7893GAME( 1995, kof95,     neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '95 (set 1)", GAME_SUPPORTS_SAVE )
7894GAME( 1995, kof95h,    kof95,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '95 (set 2)", GAME_SUPPORTS_SAVE )
7895GAME( 1995, samsho3,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Samurai Shodown III / Samurai Spirits - Zankurou Musouken (set 1)", GAME_SUPPORTS_SAVE )
7896GAME( 1995, samsho3h,  samsho3,  neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Samurai Shodown III / Samurai Spirits - Zankurou Musouken (set 2)", GAME_SUPPORTS_SAVE )
7897GAME( 1995, fswords,   samsho3,  neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Fighters Swords (Korean release of Samurai Shodown III)", GAME_SUPPORTS_SAVE )
7898GAME( 1995, rbff1,     neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Real Bout Fatal Fury / Real Bout Garou Densetsu", GAME_SUPPORTS_SAVE )
7899GAME( 1995, rbff1a,    rbff1,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Real Bout Fatal Fury / Real Bout Garou Densetsu (bug fix revision)", GAME_SUPPORTS_SAVE )
7900GAME( 1996, aof3,      neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Art of Fighting 3 - The Path of the Warrior / Art of Fighting - Ryuuko no Ken Gaiden", GAME_SUPPORTS_SAVE )
7901GAME( 1996, aof3k,     aof3,     neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Art of Fighting 3 - The Path of the Warrior (Korean release)", GAME_SUPPORTS_SAVE ) // no Japanese title / mode
7902GAME( 1996, kof96,     neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '96 (set 1)", GAME_SUPPORTS_SAVE )
7903GAME( 1996, kof96h,    kof96,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '96 (set 2)", GAME_SUPPORTS_SAVE )
7904GAME( 1996, ssideki4,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Ultimate 11 - The SNK Football Championship / Tokuten Ou - Honoo no Libero, The", GAME_SUPPORTS_SAVE )
7905GAME( 1996, kizuna,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Kizuna Encounter - Super Tag Battle / Fu'un Super Tag Battle", GAME_SUPPORTS_SAVE )
7906GAME( 1996, samsho4,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Samurai Shodown IV - Amakusa's Revenge / Samurai Spirits - Amakusa Kourin", GAME_SUPPORTS_SAVE )
7907GAME( 1996, samsho4k,  samsho4,  neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Pae Wang Jeon Seol / Legend of a Warrior (Korean censored Samurai Shodown IV)", GAME_SUPPORTS_SAVE )
7908GAME( 1996, rbffspec,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Real Bout Fatal Fury Special / Real Bout Garou Densetsu Special", GAME_SUPPORTS_SAVE )
7909GAME( 1997, kof97,     neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '97 (set 1)", GAME_SUPPORTS_SAVE )
7910GAME( 1997, kof97h,    kof97,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '97 (set 2)", GAME_SUPPORTS_SAVE )
7911GAME( 1997, kof97pls,  kof97,    neogeo,   neogeo,   neogeo,   ROT0, "bootleg", "The King of Fighters '97 Plus (bootleg)", GAME_SUPPORTS_SAVE )
7912GAME( 1997, kog,       kof97,    neogeo,   kog,      kog,      ROT0, "bootleg", "King of Gladiator (The King of Fighters '97 bootleg)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) // protected bootleg
7913GAME( 1997, lastblad,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Last Blade / Bakumatsu Roman - Gekka no Kenshi, The (set 1)", GAME_SUPPORTS_SAVE )
7914GAME( 1997, lastbladh, lastblad, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Last Blade / Bakumatsu Roman - Gekka no Kenshi, The (set 2)", GAME_SUPPORTS_SAVE )
7915GAME( 1997, lastsold,  lastblad, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The Last Soldier (Korean release of The Last Blade)", GAME_SUPPORTS_SAVE )
7916GAME( 1997, irrmaze,   neogeo,   neogeo,   irrmaze,  neogeo,   ROT0, "SNK / Saurus", "The Irritating Maze / Ultra Denryu Iraira Bou", GAME_SUPPORTS_SAVE )
7917GAME( 1998, rbff2,     neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Real Bout Fatal Fury 2 - The Newcomers / Real Bout Garou Densetsu 2 - the newcomers (set 1)", GAME_SUPPORTS_SAVE )
7918GAME( 1998, rbff2h,    rbff2,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Real Bout Fatal Fury 2 - The Newcomers / Real Bout Garou Densetsu 2 - the newcomers (set 2)", GAME_SUPPORTS_SAVE )
7919GAME( 1998, rbff2k,    rbff2,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Real Bout Fatal Fury 2 - The Newcomers (Korean release)", GAME_SUPPORTS_SAVE ) // no Japanese title / mode
7920GAME( 1998, mslug2,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Metal Slug 2 - Super Vehicle-001/II", GAME_SUPPORTS_SAVE )
7921GAME( 1998, kof98,     neogeo,   neogeo,   neogeo,   kof98,    ROT0, "SNK", "The King of Fighters '98 - The Slugfest / King of Fighters '98 - dream match never ends", GAME_SUPPORTS_SAVE )
7922GAME( 1998, kof98k,    kof98,    neogeo,   neogeo,   kof98,    ROT0, "SNK", "The King of Fighters '98 - The Slugfest / King of Fighters '98 - dream match never ends (Korean board)", GAME_SUPPORTS_SAVE )
7923GAME( 1998, kof98n,    kof98,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '98 - The Slugfest / King of Fighters '98 - dream match never ends (not encrypted)", GAME_SUPPORTS_SAVE )
7924GAME( 1998, lastbld2,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Last Blade 2 / Bakumatsu Roman - Dai Ni Maku Gekka no Kenshi, The", GAME_SUPPORTS_SAVE )
7925GAME( 1998, neocup98,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Neo-Geo Cup '98 - The Road to the Victory", GAME_SUPPORTS_SAVE )
7926GAME( 1999, mslugx,    neogeo,   neogeo,   neogeo,   mslugx,   ROT0, "SNK", "Metal Slug X - Super Vehicle-001", GAME_SUPPORTS_SAVE )
7927GAME( 1999, kof99,     neogeo,   neogeo,   neogeo,   kof99,    ROT0, "SNK", "The King of Fighters '99 - Millennium Battle (set 1)" , GAME_SUPPORTS_SAVE ) /* Encrypted Code & GFX */
7928GAME( 1999, kof99a,    kof99,    neogeo,   neogeo,   kof99,    ROT0, "SNK", "The King of Fighters '99 - Millennium Battle (set 2)" , GAME_SUPPORTS_SAVE ) /* Encrypted Code & GFX, crashes going into attract demo */
7929GAME( 1999, kof99e,    kof99,    neogeo,   neogeo,   kof99,    ROT0, "SNK", "The King of Fighters '99 - Millennium Battle (earlier)" , GAME_SUPPORTS_SAVE ) /* Encrypted Code & GFX */
7930GAME( 1999, kof99n,    kof99,    neogeo,   neogeo,   kof99n,   ROT0, "SNK", "The King of Fighters '99 - Millennium Battle (not encrypted)" , GAME_SUPPORTS_SAVE )   /* Encrypted GFX */
7931GAME( 1999, kof99p,    kof99,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '99 - Millennium Battle (prototype)", GAME_SUPPORTS_SAVE )
7932GAME( 1999, garou,     neogeo,   neogeo,   neogeo,   garou,    ROT0, "SNK", "Garou - Mark of the Wolves (set 1)" , GAME_SUPPORTS_SAVE ) /* Encrypted Code & GFX */
7933GAME( 1999, garouo,    garou,    neogeo,   neogeo,   garouo,   ROT0, "SNK", "Garou - Mark of the Wolves (set 2)" , GAME_SUPPORTS_SAVE ) /* Encrypted Code & GFX */
7934GAME( 1999, garoup,    garou,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Garou - Mark of the Wolves (prototype)", GAME_SUPPORTS_SAVE )
7935GAME( 1999, garoubl,   garou,    neogeo,   neogeo,   garoubl,  ROT0, "bootleg", "Garou - Mark of the Wolves (bootleg)", GAME_SUPPORTS_SAVE ) /* Bootleg of garoup */
7936GAME( 2000, mslug3,    neogeo,   neogeo,   neogeo,   mslug3,   ROT0, "SNK", "Metal Slug 3" , GAME_SUPPORTS_SAVE ) /* Encrypted Code & GFX */
7937GAME( 2000, mslug3h,   mslug3,   neogeo,   neogeo,   mslug3h,  ROT0, "SNK", "Metal Slug 3 (not encrypted)" , GAME_SUPPORTS_SAVE ) /* Encrypted GFX */
7938GAME( 2000, mslug3b6,  mslug3,   neogeo,   neogeo,   mslug3b6, ROT0, "bootleg", "Metal Slug 6 (Metal Slug 3 bootleg)", GAME_SUPPORTS_SAVE ) /* real Metal Slug 6 is an Atomiswave HW game, see atomswav.c ;-) */
7939GAME( 2000, kof2000,   neogeo,   neogeo,   neogeo,   kof2000,  ROT0, "SNK", "The King of Fighters 2000" , GAME_SUPPORTS_SAVE ) /* Encrypted Code & GFX */
7940GAME( 2000, kof2000n,  kof2000,  neogeo,   neogeo,   kof2000n, ROT0, "SNK", "The King of Fighters 2000 (not encrypted)" , GAME_SUPPORTS_SAVE ) /* Encrypted GFX */
7941GAME( 2001, zupapa,    neogeo,   neogeo,   neogeo,   zupapa,   ROT0, "SNK", "Zupapa!" , GAME_SUPPORTS_SAVE )   /* Encrypted GFX */
7942GAME( 2001, sengoku3,  neogeo,   neogeo,   neogeo,   sengoku3, ROT0, "Noise Factory / SNK", "Sengoku 3 / Sengoku Densho 2001" , GAME_SUPPORTS_SAVE )   /* Encrypted GFX */
7943GAME( 2001, kof2001,   neogeo,   neogeo,   neogeo,   kof2001,  ROT0, "Eolith / SNK", "The King of Fighters 2001 (set 1)" , GAME_SUPPORTS_SAVE ) /* Encrypted GFX */
7944GAME( 2001, kof2001h,  kof2001,  neogeo,   neogeo,   kof2001,  ROT0, "Eolith / SNK", "The King of Fighters 2001 (set 2)" , GAME_SUPPORTS_SAVE ) /* Encrypted GFX */
7945GAME( 2003, cthd2003,  kof2001,  neogeo,   neogeo,   cthd2003, ROT0, "bootleg", "Crouching Tiger Hidden Dragon 2003 (The King of Fighters 2001 bootleg)", GAME_SUPPORTS_SAVE ) /* Protected Hack / Bootleg of kof2001 */
7946GAME( 2003, ct2k3sp,   kof2001,  neogeo,   neogeo,   ct2k3sp,  ROT0, "bootleg", "Crouching Tiger Hidden Dragon 2003 Super Plus (The King of Fighters 2001 bootleg)", GAME_SUPPORTS_SAVE ) /* Protected Hack / Bootleg of kof2001 */
7947GAME( 2003, ct2k3sa,   kof2001,  neogeo,   neogeo,   ct2k3sa,  ROT0, "bootleg", "Crouching Tiger Hidden Dragon 2003 Super Plus alternate (The King of Fighters 2001 bootleg)", GAME_SUPPORTS_SAVE ) /* Hack / Bootleg of kof2001 */
7948GAME( 2002, kof2002,   neogeo,   neogeo,   neogeo,   kof2002,  ROT0, "Eolith / Playmore", "The King of Fighters 2002" , GAME_SUPPORTS_SAVE ) /* Encrypted GFX */
7949GAME( 2002, kof2002b,  kof2002,  neogeo,   neogeo,   kof2002b, ROT0, "bootleg", "The King of Fighters 2002 (bootleg)", GAME_SUPPORTS_SAVE )
7950GAME( 2002, kf2k2pls,  kof2002,  neogeo,   neogeo,   kf2k2pls, ROT0, "bootleg", "The King of Fighters 2002 Plus (bootleg set 1)" , GAME_SUPPORTS_SAVE ) /* Encrypted GFX */
7951GAME( 2002, kf2k2pla,  kof2002,  neogeo,   neogeo,   kf2k2pls, ROT0, "bootleg", "The King of Fighters 2002 Plus (bootleg set 2)" , GAME_SUPPORTS_SAVE ) /* Encrypted GFX */
7952GAME( 2002, kf2k2mp,   kof2002,  neogeo,   neogeo,   kf2k2mp,  ROT0, "bootleg", "The King of Fighters 2002 Magic Plus (bootleg)" , GAME_SUPPORTS_SAVE ) /* Encrypted GFX */
7953GAME( 2002, kf2k2mp2,  kof2002,  neogeo,   neogeo,   kf2k2mp2, ROT0, "bootleg", "The King of Fighters 2002 Magic Plus II (bootleg)" , GAME_SUPPORTS_SAVE ) /* Encrypted GFX */
7954GAME( 2002, kof10th,   kof2002,  neogeo,   neogeo,   kof10th,  ROT0, "bootleg", "The King of Fighters 10th Anniversary (The King of Fighters 2002 bootleg)", GAME_SUPPORTS_SAVE ) // fake SNK copyright
7955GAME( 2005, kf10thep,  kof2002,  neogeo,   neogeo,   kf10thep, ROT0, "bootleg", "The King of Fighters 10th Anniversary Extra Plus (The King of Fighters 2002 bootleg)", GAME_SUPPORTS_SAVE ) // fake SNK copyright
7956GAME( 2004, kf2k5uni,  kof2002,  neogeo,   neogeo,   kf2k5uni, ROT0, "bootleg", "The King of Fighters 10th Anniversary 2005 Unique (The King of Fighters 2002 bootleg)", GAME_SUPPORTS_SAVE ) // fake SNK copyright
7957GAME( 2004, kof2k4se,  kof2002,  neogeo,   neogeo,   kof2k4se, ROT0, "bootleg", "The King of Fighters Special Edition 2004 (The King of Fighters 2002 bootleg)", GAME_SUPPORTS_SAVE ) /* Hack / Bootleg of kof2002 */
7958GAME( 2003, mslug5,    neogeo,   neogeo,   neogeo,   mslug5,   ROT0, "SNK Playmore", "Metal Slug 5", GAME_SUPPORTS_SAVE )
7959GAME( 2003, mslug5h,   mslug5,   neogeo,   neogeo,   mslug5,   ROT0, "SNK Playmore", "Metal Slug 5 (AES Cart)", GAME_SUPPORTS_SAVE ) /* Also found in later MVS carts */
7960GAME( 2003, ms5pcb,    0,        neogeo,   ms5pcb,   ms5pcb,   ROT0, "SNK Playmore", "Metal Slug 5 (JAMMA PCB)", GAME_SUPPORTS_SAVE )
7961GAME( 2003, ms5plus,   mslug5,   neogeo,   neogeo,   ms5plus,  ROT0, "bootleg", "Metal Slug 5 Plus (bootleg)", GAME_SUPPORTS_SAVE )
7962GAME( 2003, svcpcb,    0,        neogeo,   svcpcb,   svcpcb,   ROT0, "SNK Playmore", "SNK vs. CAPCOM SVC CHAOS (JAMMA PCB, set 1)", GAME_SUPPORTS_SAVE ) // not a clone of neogeo because it's NOT a neogeo cart.
7963GAME( 2003, svcpcba,   svcpcb,   neogeo,   svcpcb,   svcpcb,   ROT0, "SNK Playmore", "SNK vs. CAPCOM SVC CHAOS (JAMMA PCB, set 2)" , GAME_SUPPORTS_SAVE ) /* Encrypted Code */
7964GAME( 2003, svc,       neogeo,   neogeo,   neogeo,   svc,      ROT0, "SNK Playmore", "SNK vs. CAPCOM SVC CHAOS", GAME_SUPPORTS_SAVE )
7965GAME( 2003, svcboot,   svc,      neogeo,   neogeo,   svcboot,  ROT0, "bootleg", "SNK vs. CAPCOM SVC CHAOS (bootleg)", GAME_SUPPORTS_SAVE )
7966GAME( 2003, svcplus,   svc,      neogeo,   neogeo,   svcplus,  ROT0, "bootleg", "SNK vs. CAPCOM SVC CHAOS Plus (bootleg set 1)", GAME_SUPPORTS_SAVE )
7967GAME( 2003, svcplusa,  svc,      neogeo,   neogeo,   svcplusa, ROT0, "bootleg", "SNK vs. CAPCOM SVC CHAOS Plus (bootleg set 2)", GAME_SUPPORTS_SAVE )
7968GAME( 2003, svcsplus,  svc,      neogeo,   neogeo,   svcsplus, ROT0, "bootleg", "SNK vs. CAPCOM SVC CHAOS Super Plus (bootleg)", GAME_SUPPORTS_SAVE )
7969GAME( 2003, samsho5,   neogeo,   neogeo,   neogeo,   samsho5,  ROT0, "Yuki Enterprise / SNK Playmore", "Samurai Shodown V / Samurai Spirits Zero (set 1)", GAME_SUPPORTS_SAVE )
7970GAME( 2003, samsho5h,  samsho5,  neogeo,   neogeo,   samsho5,  ROT0, "Yuki Enterprise / SNK Playmore", "Samurai Shodown V / Samurai Spirits Zero (set 2)", GAME_SUPPORTS_SAVE )
7971GAME( 2003, samsho5b,  samsho5,  neogeo,   neogeo,   samsho5b, ROT0, "bootleg", "Samurai Shodown V / Samurai Spirits Zero (bootleg)", GAME_SUPPORTS_SAVE ) // different program scrambling
7972GAME( 2003, kf2k3pcb,  0,        neogeo,   neogeo,   kf2k3pcb, ROT0, "SNK Playmore", "The King of Fighters 2003 (Japan, JAMMA PCB)", GAME_SUPPORTS_SAVE ) // not a clone of neogeo because it's NOT a neogeo cart.
7973GAME( 2003, kof2003,   neogeo,   neogeo,   neogeo,   kof2003,  ROT0, "SNK Playmore", "The King of Fighters 2003 (set 1)", GAME_SUPPORTS_SAVE )
7974GAME( 2003, kof2003h,  kof2003,  neogeo,   neogeo,   kof2003h, ROT0, "SNK Playmore", "The King of Fighters 2003 (set 2)", GAME_SUPPORTS_SAVE )
7975GAME( 2003, kf2k3bl,   kof2003,  neogeo,   neogeo,   kf2k3bl , ROT0, "bootleg", "The King of Fighters 2003 (bootleg set 1)", GAME_SUPPORTS_SAVE ) // zooming is wrong because its a bootleg of the pcb version on a cart (unless it was a bootleg pcb with the new bios?)
7976GAME( 2003, kf2k3bla,  kof2003,  neogeo,   neogeo,   kf2k3pl,  ROT0, "bootleg", "The King of Fighters 2003 (bootleg set 2)", GAME_SUPPORTS_SAVE ) // zooming is wrong because its a bootleg of the pcb version on a cart
7977GAME( 2003, kf2k3pl,   kof2003,  neogeo,   neogeo,   kf2k3pl,  ROT0, "bootleg", "The King of Fighters 2004 Plus / Hero (The King of Fighters 2003 bootleg)", GAME_SUPPORTS_SAVE ) // zooming is wrong because its a bootleg of the pcb version on a cart
7978GAME( 2003, kf2k3upl,  kof2003,  neogeo,   neogeo,   kf2k3upl, ROT0, "bootleg", "The King of Fighters 2004 Ultra Plus (The King of Fighters 2003 bootleg)", GAME_SUPPORTS_SAVE ) // zooming is wrong because its a bootleg of the pcb version on a cart
7979GAME( 2003, samsh5sp,  neogeo,   neogeo,   neogeo,   samsh5sp, ROT0, "Yuki Enterprise / SNK Playmore", "Samurai Shodown V Special / Samurai Spirits Zero Special (set 1, uncensored)", GAME_SUPPORTS_SAVE )
7980GAME( 2003, samsh5sph, samsh5sp, neogeo,   neogeo,   samsh5sp, ROT0, "Yuki Enterprise / SNK Playmore", "Samurai Shodown V Special / Samurai Spirits Zero Special (set 2, censored)", GAME_SUPPORTS_SAVE )
7981GAME( 2003, samsh5spn, samsh5sp, neogeo,   neogeo,   samsh5sp, ROT0, "Yuki Enterprise / SNK Playmore", "Samurai Shodown V Special / Samurai Spirits Zero Special (set 3, less censored)", GAME_SUPPORTS_SAVE )
79497982
79507983/* there are other bootlegs kof96ep, kf2k1pls etc.? -- work out which should be supported */
79517984
79527985/* Alpha Denshi Co. / ADK (changed name in 1993) */
7953GAME( 1990, maglord,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Magician Lord (set 1)", 0 )
7954GAME( 1990, maglordh, maglord,  neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Magician Lord (set 2)", 0 )
7955GAME( 1990, ncombat,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Ninja Combat (set 1)", 0 )
7956GAME( 1990, ncombath, ncombat,  neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Ninja Combat (set 2)", 0 )
7957GAME( 1990, bjourney, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Blue's Journey / Raguy", 0 )
7958GAME( 1991, crsword,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Crossed Swords", 0 )
7959GAME( 1991, trally,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Thrash Rally", 0 )
7960GAME( 1992, ncommand, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Ninja Commando", 0 )
7961GAME( 1992, wh1,      neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "World Heroes (set 1)", 0 )
7962GAME( 1992, wh1h,     wh1,      neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "World Heroes (set 2)", 0 )
7963GAME( 1992, wh1ha,    wh1,      neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "World Heroes (set 3)", 0 )
7964GAME( 1993, wh2,      neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "ADK",              "World Heroes 2", 0 )
7965GAME( 1994, wh2j,     neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "ADK / SNK",        "World Heroes 2 Jet (set 1)", 0 )
7966GAME( 1994, wh2jh,    wh2j,     neogeo,   neogeo,   neogeo,   ROT0, "ADK / SNK",        "World Heroes 2 Jet (set 2)", 0 )
7967GAME( 1994, aodk,     neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "ADK / SNK",        "Aggressors of Dark Kombat / Tsuukai GANGAN Koushinkyoku", 0 )
7968GAME( 1995, whp,      neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "ADK / SNK",        "World Heroes Perfect", 0 )
7969GAME( 1995, mosyougi, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "ADK / SNK",        "Syougi No Tatsujin - Master of Syougi", 0 )
7970GAME( 1996, overtop,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "ADK",              "Over Top", 0 )
7971GAME( 1996, ninjamas, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "ADK / SNK",        "Ninja Master's - haoh-ninpo-cho", 0 )
7972GAME( 1996, twinspri, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "ADK",              "Twinkle Star Sprites", 0 )
7973GAME( 1996, zintrckb, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "hack / bootleg",   "Zintrick / Oshidashi Zentrix (hack / bootleg)", 0 )
7986GAME( 1990, maglord,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Magician Lord (set 1)", GAME_SUPPORTS_SAVE )
7987GAME( 1990, maglordh,  maglord,  neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Magician Lord (set 2)", GAME_SUPPORTS_SAVE )
7988GAME( 1990, ncombat,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Ninja Combat (set 1)", GAME_SUPPORTS_SAVE )
7989GAME( 1990, ncombath,  ncombat,  neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Ninja Combat (set 2)", GAME_SUPPORTS_SAVE )
7990GAME( 1990, bjourney,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Blue's Journey / Raguy", GAME_SUPPORTS_SAVE )
7991GAME( 1991, crsword,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Crossed Swords", GAME_SUPPORTS_SAVE )
7992GAME( 1991, trally,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Thrash Rally", GAME_SUPPORTS_SAVE )
7993GAME( 1992, ncommand,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "Ninja Commando", GAME_SUPPORTS_SAVE )
7994GAME( 1992, wh1,       neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "World Heroes (set 1)", GAME_SUPPORTS_SAVE )
7995GAME( 1992, wh1h,      wh1,      neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "World Heroes (set 2)", GAME_SUPPORTS_SAVE )
7996GAME( 1992, wh1ha,     wh1,      neogeo,   neogeo,   neogeo,   ROT0, "Alpha Denshi Co.", "World Heroes (set 3)", GAME_SUPPORTS_SAVE )
7997GAME( 1993, wh2,       neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "ADK",              "World Heroes 2", GAME_SUPPORTS_SAVE )
7998GAME( 1994, wh2j,      neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "ADK / SNK",        "World Heroes 2 Jet (set 1)", GAME_SUPPORTS_SAVE )
7999GAME( 1994, wh2jh,     wh2j,     neogeo,   neogeo,   neogeo,   ROT0, "ADK / SNK",        "World Heroes 2 Jet (set 2)", GAME_SUPPORTS_SAVE )
8000GAME( 1994, aodk,      neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "ADK / SNK",        "Aggressors of Dark Kombat / Tsuukai GANGAN Koushinkyoku", GAME_SUPPORTS_SAVE )
8001GAME( 1995, whp,       neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "ADK / SNK",        "World Heroes Perfect", GAME_SUPPORTS_SAVE )
8002GAME( 1995, mosyougi,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "ADK / SNK",        "Syougi No Tatsujin - Master of Syougi", GAME_SUPPORTS_SAVE )
8003GAME( 1996, overtop,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "ADK",              "Over Top", GAME_SUPPORTS_SAVE )
8004GAME( 1996, ninjamas,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "ADK / SNK",        "Ninja Master's - haoh-ninpo-cho", GAME_SUPPORTS_SAVE )
8005GAME( 1996, twinspri,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "ADK",              "Twinkle Star Sprites", GAME_SUPPORTS_SAVE )
8006GAME( 1996, zintrckb,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "hack / bootleg",   "Zintrick / Oshidashi Zentrix (hack / bootleg)", GAME_SUPPORTS_SAVE )
79748007
79758008/* Aicom (was a part of Sammy) / Yumekobo (changed name in 1996) */
7976GAME( 1992, viewpoin, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Sammy / Aicom", "Viewpoint", 0 )
7977GAME( 1994, janshin,  neogeo,   neogeo,   mjneogeo, neogeo,   ROT0, "Aicom", "Jyanshin Densetsu - Quest of Jongmaster", 0 )
7978GAME( 1995, pulstar,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Aicom", "Pulstar", 0 )
7979GAME( 1998, blazstar, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Yumekobo", "Blazing Star", 0 )
7980GAME( 1999, preisle2, neogeo,   neogeo,   neogeo,   preisle2, ROT0, "Yumekobo", "Prehistoric Isle 2" , 0 ) /* Encrypted GFX */
8009GAME( 1992, viewpoin,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Sammy / Aicom", "Viewpoint", GAME_SUPPORTS_SAVE )
8010GAME( 1994, janshin,   neogeo,   neogeo,   mjneogeo, neogeo,   ROT0, "Aicom", "Jyanshin Densetsu - Quest of Jongmaster", GAME_SUPPORTS_SAVE )
8011GAME( 1995, pulstar,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Aicom", "Pulstar", GAME_SUPPORTS_SAVE )
8012GAME( 1998, blazstar,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Yumekobo", "Blazing Star", GAME_SUPPORTS_SAVE )
8013GAME( 1999, preisle2,  neogeo,   neogeo,   neogeo,   preisle2, ROT0, "Yumekobo", "Prehistoric Isle 2" , GAME_SUPPORTS_SAVE ) /* Encrypted GFX */
79818014
79828015/* Data East Corporation */
7983GAME( 1993, spinmast, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Data East Corporation", "Spin Master / Miracle Adventure", 0 )
7984GAME( 1994, wjammers, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Data East Corporation", "Windjammers / Flying Power Disc", 0 )
7985GAME( 1994, karnovr,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Data East Corporation", "Karnov's Revenge / Fighter's History Dynamite", 0 )
7986GAME( 1994, strhoop,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Data East Corporation", "Street Hoop / Street Slam / Dunk Dream", 0 )
7987GAME( 1996, ghostlop, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Data East Corporation", "Ghostlop (prototype)", 0 )
7988GAME( 1996, magdrop2, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Data East Corporation", "Magical Drop II", 0 )
7989GAME( 1997, magdrop3, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Data East Corporation", "Magical Drop III", 0 )
8016GAME( 1993, spinmast,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Data East Corporation", "Spin Master / Miracle Adventure", GAME_SUPPORTS_SAVE )
8017GAME( 1994, wjammers,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Data East Corporation", "Windjammers / Flying Power Disc", GAME_SUPPORTS_SAVE )
8018GAME( 1994, karnovr,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Data East Corporation", "Karnov's Revenge / Fighter's History Dynamite", GAME_SUPPORTS_SAVE )
8019GAME( 1994, strhoop,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Data East Corporation", "Street Hoop / Street Slam / Dunk Dream", GAME_SUPPORTS_SAVE )
8020GAME( 1996, ghostlop,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Data East Corporation", "Ghostlop (prototype)", GAME_SUPPORTS_SAVE )
8021GAME( 1996, magdrop2,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Data East Corporation", "Magical Drop II", GAME_SUPPORTS_SAVE )
8022GAME( 1997, magdrop3,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Data East Corporation", "Magical Drop III", GAME_SUPPORTS_SAVE )
79908023
79918024/* Eleven */
7992GAME( 2000, nitd,     neogeo,   neogeo,   neogeo,   nitd,     ROT0, "Eleven / Gavaking", "Nightmare in the Dark" , 0 ) /* Encrypted GFX */
7993GAME( 2001, nitdbl,   nitd,     neogeo,   neogeo,   neogeo,   ROT0, "bootleg", "Nightmare in the Dark (bootleg)" , 0 )
8025GAME( 2000, nitd,      neogeo,   neogeo,   neogeo,   nitd,     ROT0, "Eleven / Gavaking", "Nightmare in the Dark" , GAME_SUPPORTS_SAVE ) /* Encrypted GFX */
8026GAME( 2001, nitdbl,    nitd,     neogeo,   neogeo,   neogeo,   ROT0, "bootleg", "Nightmare in the Dark (bootleg)" , GAME_SUPPORTS_SAVE )
79948027
79958028/* Face */
7996GAME( 1994, gururin,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Face", "Gururin", 0 )
7997GAME( 1997, miexchng, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Face", "Money Puzzle Exchanger / Money Idol Exchanger", 0 )
8029GAME( 1994, gururin,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Face", "Gururin", GAME_SUPPORTS_SAVE )
8030GAME( 1997, miexchng,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Face", "Money Puzzle Exchanger / Money Idol Exchanger", GAME_SUPPORTS_SAVE )
79988031
79998032/* Hudson Soft */
8000GAME( 1994, panicbom, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Eighting / Hudson", "Panic Bomber", 0 )
8001GAME( 1995, kabukikl, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Hudson", "Far East of Eden - Kabuki Klash / Tengai Makyou - Shin Den", 0 )
8002GAME( 1997, neobombe, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Hudson", "Neo Bomberman", 0 )
8033GAME( 1994, panicbom,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Eighting / Hudson", "Panic Bomber", GAME_SUPPORTS_SAVE )
8034GAME( 1995, kabukikl,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Hudson", "Far East of Eden - Kabuki Klash / Tengai Makyou - Shin Den", GAME_SUPPORTS_SAVE )
8035GAME( 1997, neobombe,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Hudson", "Neo Bomberman", GAME_SUPPORTS_SAVE )
80038036
80048037/* Monolith Corp. */
8005GAME( 1990, minasan,  neogeo,   neogeo,   mjneogeo, neogeo,   ROT0, "Monolith Corp.", "Minnasanno Okagesamadesu", 0 )
8006GAME( 1991, bakatono, neogeo,   neogeo,   mjneogeo, neogeo,   ROT0, "Monolith Corp.", "Bakatonosama Mahjong Manyuki", 0 )
8038GAME( 1990, minasan,   neogeo,   neogeo,   mjneogeo, neogeo,   ROT0, "Monolith Corp.", "Minnasanno Okagesamadesu", GAME_SUPPORTS_SAVE )
8039GAME( 1991, bakatono,  neogeo,   neogeo,   mjneogeo, neogeo,   ROT0, "Monolith Corp.", "Bakatonosama Mahjong Manyuki", GAME_SUPPORTS_SAVE )
80078040
80088041/* Nazca (later acquired by SNK) */
8009GAME( 1996, turfmast, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Nazca", "Neo Turf Masters / Big Tournament Golf", 0 )
8010GAME( 1996, mslug,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Nazca", "Metal Slug - Super Vehicle-001", 0 )
8042GAME( 1996, turfmast,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Nazca", "Neo Turf Masters / Big Tournament Golf", GAME_SUPPORTS_SAVE )
8043GAME( 1996, mslug,     neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Nazca", "Metal Slug - Super Vehicle-001", GAME_SUPPORTS_SAVE )
80118044
80128045/* NMK */
8013GAME( 1994, zedblade, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "NMK", "Zed Blade / Operation Ragnarok", 0 )
8046GAME( 1994, zedblade, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "NMK", "Zed Blade / Operation Ragnarok", GAME_SUPPORTS_SAVE )
80148047
80158048/* Psikyo */
8016GAME( 1999, s1945p,   neogeo,   neogeo,   neogeo,   s1945p,   ROT0, "Psikyo", "Strikers 1945 Plus" , 0 )   /* Encrypted GFX */
8049GAME( 1999, s1945p,    neogeo,   neogeo,   neogeo,   s1945p,   ROT0, "Psikyo", "Strikers 1945 Plus" , GAME_SUPPORTS_SAVE )   /* Encrypted GFX */
80178050
80188051/* Saurus */
8019GAME( 1995, quizkof,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Saurus", "Quiz King of Fighters", 0 )
8020GAME( 1995, stakwin,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Saurus", "Stakes Winner / Stakes Winner - GI kinzen seihae no michi", 0 )
8021GAME( 1996, ragnagrd, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Saurus", "Ragnagard / Shin-Oh-Ken", 0 )
8022GAME( 1996, pgoal,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Saurus", "Pleasure Goal / Futsal - 5 on 5 Mini Soccer", 0 )
8023GAME( 1996, stakwin2, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Saurus", "Stakes Winner 2", 0 )
8024GAME( 1997, shocktro, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Saurus", "Shock Troopers (set 1)", 0 )
8025GAME( 1997, shocktra, shocktro, neogeo,   neogeo,   neogeo,   ROT0, "Saurus", "Shock Troopers (set 2)", 0 )
8026GAME( 1998, shocktr2, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Saurus", "Shock Troopers - 2nd Squad", 0 )
8027GAME( 1998, lans2004, shocktr2, neogeo,   neogeo,   lans2004, ROT0, "bootleg", "Lansquenet 2004 (Shock Troopers - 2nd Squad bootleg)", 0 )
8052GAME( 1995, quizkof,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Saurus", "Quiz King of Fighters", GAME_SUPPORTS_SAVE )
8053GAME( 1995, stakwin,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Saurus", "Stakes Winner / Stakes Winner - GI kinzen seihae no michi", GAME_SUPPORTS_SAVE )
8054GAME( 1996, ragnagrd,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Saurus", "Ragnagard / Shin-Oh-Ken", GAME_SUPPORTS_SAVE )
8055GAME( 1996, pgoal,     neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Saurus", "Pleasure Goal / Futsal - 5 on 5 Mini Soccer", GAME_SUPPORTS_SAVE )
8056GAME( 1996, stakwin2,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Saurus", "Stakes Winner 2", GAME_SUPPORTS_SAVE )
8057GAME( 1997, shocktro,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Saurus", "Shock Troopers (set 1)", GAME_SUPPORTS_SAVE )
8058GAME( 1997, shocktra,  shocktro, neogeo,   neogeo,   neogeo,   ROT0, "Saurus", "Shock Troopers (set 2)", GAME_SUPPORTS_SAVE )
8059GAME( 1998, shocktr2,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Saurus", "Shock Troopers - 2nd Squad", GAME_SUPPORTS_SAVE )
8060GAME( 1998, lans2004,  shocktr2, neogeo,   neogeo,   lans2004, ROT0, "bootleg", "Lansquenet 2004 (Shock Troopers - 2nd Squad bootleg)", GAME_SUPPORTS_SAVE )
80288061
80298062/* Sunsoft */
8030GAME( 1995, galaxyfg, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Sunsoft", "Galaxy Fight - Universal Warriors", 0 )
8031GAME( 1996, wakuwak7, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Sunsoft", "Waku Waku 7", 0 )
8063GAME( 1995, galaxyfg,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Sunsoft", "Galaxy Fight - Universal Warriors", GAME_SUPPORTS_SAVE )
8064GAME( 1996, wakuwak7,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Sunsoft", "Waku Waku 7", GAME_SUPPORTS_SAVE )
80328065
80338066/* Taito */
8034GAME( 1994, pbobblen, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Taito", "Puzzle Bobble / Bust-A-Move (Neo-Geo) (set 1)", 0 )
8035GAME( 1994, pbobblenb,pbobblen, neogeo,   neogeo,   neogeo,   ROT0, "Taito", "Puzzle Bobble / Bust-A-Move (Neo-Geo) (bootleg)", 0 )
8036GAME( 1999, pbobbl2n, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Taito (SNK license)", "Puzzle Bobble 2 / Bust-A-Move Again (Neo-Geo)", 0 )
8037GAME( 2003, pnyaa,    neogeo,   neogeo,   neogeo,   pnyaa,    ROT0, "Aiky / Taito", "Pochi and Nyaa", 0 )
8067GAME( 1994, pbobblen,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Taito", "Puzzle Bobble / Bust-A-Move (Neo-Geo) (set 1)", GAME_SUPPORTS_SAVE )
8068GAME( 1994, pbobblenb, pbobblen, neogeo,   neogeo,   neogeo,   ROT0, "Taito", "Puzzle Bobble / Bust-A-Move (Neo-Geo) (bootleg)", GAME_SUPPORTS_SAVE )
8069GAME( 1999, pbobbl2n,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Taito (SNK license)", "Puzzle Bobble 2 / Bust-A-Move Again (Neo-Geo)", GAME_SUPPORTS_SAVE )
8070GAME( 2003, pnyaa,     neogeo,   neogeo,   neogeo,   pnyaa,    ROT0, "Aiky / Taito", "Pochi and Nyaa", GAME_SUPPORTS_SAVE )
80388071
80398072/* Takara */
8040GAME( 1995, marukodq, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Takara", "Chibi Marukochan Deluxe Quiz", 0 )
8073GAME( 1995, marukodq, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Takara", "Chibi Marukochan Deluxe Quiz", GAME_SUPPORTS_SAVE )
80418074
80428075/* Technos Japan */
8043GAME( 1995, doubledr, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Technos Japan", "Double Dragon (Neo-Geo)", 0 )
8044GAME( 1995, gowcaizr, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Technos Japan", "Voltage Fighter - Gowcaizer / Choujin Gakuen Gowcaizer", 0 )
8045GAME( 1996, sdodgeb,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Technos Japan", "Super Dodge Ball / Kunio no Nekketsu Toukyuu Densetsu", 0 )
8076GAME( 1995, doubledr,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Technos Japan", "Double Dragon (Neo-Geo)", GAME_SUPPORTS_SAVE )
8077GAME( 1995, gowcaizr,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Technos Japan", "Voltage Fighter - Gowcaizer / Choujin Gakuen Gowcaizer", GAME_SUPPORTS_SAVE )
8078GAME( 1996, sdodgeb,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Technos Japan", "Super Dodge Ball / Kunio no Nekketsu Toukyuu Densetsu", GAME_SUPPORTS_SAVE )
80468079
80478080/* Tecmo */
8048GAME( 1996, tws96,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Tecmo", "Tecmo World Soccer '96", 0 )
8081GAME( 1996, tws96,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Tecmo", "Tecmo World Soccer '96", GAME_SUPPORTS_SAVE )
80498082
80508083/* Viccom */
8051GAME( 1994, fightfev, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Viccom", "Fight Fever (set 1)", 0 )
8052GAME( 1994, fightfeva, fightfev, neogeo,   neogeo,   neogeo,   ROT0, "Viccom", "Fight Fever (set 2)", 0 )
8084GAME( 1994, fightfev,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Viccom", "Fight Fever (set 1)", GAME_SUPPORTS_SAVE )
8085GAME( 1994, fightfeva, fightfev, neogeo,   neogeo,   neogeo,   ROT0, "Viccom", "Fight Fever (set 2)", GAME_SUPPORTS_SAVE )
80538086
80548087/* Video System Co. */
8055GAME( 1994, pspikes2, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Video System Co.", "Power Spikes II", 0 )
8056GAME( 1994, sonicwi2, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Video System Co.", "Aero Fighters 2 / Sonic Wings 2", 0 )
8057GAME( 1995, sonicwi3, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Video System Co.", "Aero Fighters 3 / Sonic Wings 3", 0 )
8058GAME( 1997, popbounc, neogeo,   neogeo,   popbounc, neogeo,   ROT0, "Video System Co.", "Pop 'n Bounce / Gapporin", 0 )
8088GAME( 1994, pspikes2,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Video System Co.", "Power Spikes II", GAME_SUPPORTS_SAVE )
8089GAME( 1994, sonicwi2,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Video System Co.", "Aero Fighters 2 / Sonic Wings 2", GAME_SUPPORTS_SAVE )
8090GAME( 1995, sonicwi3,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Video System Co.", "Aero Fighters 3 / Sonic Wings 3", GAME_SUPPORTS_SAVE )
8091GAME( 1997, popbounc,  neogeo,   neogeo,   popbounc, neogeo,   ROT0, "Video System Co.", "Pop 'n Bounce / Gapporin", GAME_SUPPORTS_SAVE )
80598092
80608093/* Visco */
8061GAME( 1992, androdun, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Andro Dunos", 0 )
8062GAME( 1995, puzzledp, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Taito (Visco license)", "Puzzle De Pon!", 0 )
8063GAME( 1996, neomrdo,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Neo Mr. Do!", 0 )
8064GAME( 1995, goalx3,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Goal! Goal! Goal!", 0 )
8065GAME( 1996, neodrift, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Neo Drift Out - New Technology", 0 )
8066GAME( 1996, breakers, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Breakers", 0 )
8067GAME( 1997, puzzldpr, puzzledp, neogeo,   neogeo,   neogeo,   ROT0, "Taito (Visco license)", "Puzzle De Pon! R!", 0 )
8068GAME( 1998, breakrev, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Breakers Revenge", 0 )
8069GAME( 1998, flipshot, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Battle Flip Shot", 0 )
8070GAME( 1999, ctomaday, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Captain Tomaday", 0 )
8071GAME( 1999, ganryu,   neogeo,   neogeo,   neogeo,   ganryu,   ROT0, "Visco", "Ganryu / Musashi Ganryuki" , 0 )   /* Encrypted GFX */
8072GAME( 2000, bangbead, neogeo,   neogeo,   neogeo,   bangbead, ROT0, "Visco", "Bang Bead", 0 )
8073//GAME( 2000, bangbedp, bangbead, neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Bang Bead (prototype)", 0 )
8094GAME( 1992, androdun,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Andro Dunos", GAME_SUPPORTS_SAVE )
8095GAME( 1995, puzzledp,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Taito (Visco license)", "Puzzle De Pon!", GAME_SUPPORTS_SAVE )
8096GAME( 1996, neomrdo,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Neo Mr. Do!", GAME_SUPPORTS_SAVE )
8097GAME( 1995, goalx3,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Goal! Goal! Goal!", GAME_SUPPORTS_SAVE )
8098GAME( 1996, neodrift,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Neo Drift Out - New Technology", GAME_SUPPORTS_SAVE )
8099GAME( 1996, breakers,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Breakers", GAME_SUPPORTS_SAVE )
8100GAME( 1997, puzzldpr,  puzzledp, neogeo,   neogeo,   neogeo,   ROT0, "Taito (Visco license)", "Puzzle De Pon! R!", GAME_SUPPORTS_SAVE )
8101GAME( 1998, breakrev,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Breakers Revenge", GAME_SUPPORTS_SAVE )
8102GAME( 1998, flipshot,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Battle Flip Shot", GAME_SUPPORTS_SAVE )
8103GAME( 1999, ctomaday,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Captain Tomaday", GAME_SUPPORTS_SAVE )
8104GAME( 1999, ganryu,    neogeo,   neogeo,   neogeo,   ganryu,   ROT0, "Visco", "Ganryu / Musashi Ganryuki" , GAME_SUPPORTS_SAVE )   /* Encrypted GFX */
8105GAME( 2000, bangbead,  neogeo,   neogeo,   neogeo,   bangbead, ROT0, "Visco", "Bang Bead", GAME_SUPPORTS_SAVE )
8106//GAME( 2000, bangbedp,  bangbead, neogeo,   neogeo,   neogeo,   ROT0, "Visco", "Bang Bead (prototype)", GAME_SUPPORTS_SAVE )
80748107
80758108/* Mega Enterprise */
8076GAME( 2002, mslug4,   neogeo,   neogeo,   neogeo,   mslug4,   ROT0, "Mega / Playmore", "Metal Slug 4 (set 1)", 0 )
8077GAME( 2002, mslug4h,  mslug4,   neogeo,   neogeo,   mslug4,   ROT0, "Mega / Playmore", "Metal Slug 4 (set 2)", 0 )
8078GAME( 2002, ms4plus,  mslug4,   neogeo,   neogeo,   ms4plus,  ROT0, "bootleg", "Metal Slug 4 Plus (bootleg)", 0 )
8109GAME( 2002, mslug4,    neogeo,   neogeo,   neogeo,   mslug4,   ROT0, "Mega / Playmore", "Metal Slug 4 (set 1)", GAME_SUPPORTS_SAVE )
8110GAME( 2002, mslug4h,   mslug4,   neogeo,   neogeo,   mslug4,   ROT0, "Mega / Playmore", "Metal Slug 4 (set 2)", GAME_SUPPORTS_SAVE )
8111GAME( 2002, ms4plus,   mslug4,   neogeo,   neogeo,   ms4plus,  ROT0, "bootleg", "Metal Slug 4 Plus (bootleg)", GAME_SUPPORTS_SAVE )
80798112
80808113/* Evoga */
8081GAME( 2002, rotd,     neogeo,   neogeo,   neogeo,   rotd,     ROT0, "Evoga / Playmore", "Rage of the Dragons", 0 )
8114GAME( 2002, rotd,      neogeo,   neogeo,   neogeo,   rotd,     ROT0, "Evoga / Playmore", "Rage of the Dragons", GAME_SUPPORTS_SAVE )
80828115
80838116/* Atlus */
8084GAME( 2002, matrim,   neogeo,   neogeo,   neogeo,   matrim,   ROT0, "Noise Factory / Atlus", "Matrimelee / Shin Gouketsuji Ichizoku Toukon", 0 )
8085GAME( 2002, matrimbl, matrim,   neogeo,   neogeo,   matrimbl, ROT0, "bootleg", "Matrimelee / Shin Gouketsuji Ichizoku Toukon (bootleg)", 0 )
8117GAME( 2002, matrim,    neogeo,   neogeo,   neogeo,   matrim,   ROT0, "Noise Factory / Atlus", "Matrimelee / Shin Gouketsuji Ichizoku Toukon", GAME_SUPPORTS_SAVE )
8118GAME( 2002, matrimbl,  matrim,   neogeo,   neogeo,   matrimbl, ROT0, "bootleg", "Matrimelee / Shin Gouketsuji Ichizoku Toukon (bootleg)", GAME_SUPPORTS_SAVE )
80868119
80878120/* BrezzaSoft */
8088GAME( 2001, jockeygp, neogeo,   neogeo,   jockeygp, jockeygp, ROT0, "Sun Amusement / BrezzaSoft", "Jockey Grand Prix", 0 )
8089GAME( 2001, vliner,   neogeo,   neogeo,   vliner,   vliner,   ROT0, "Dyna / BrezzaSoft", "V-Liner (set 1)", 0 )
8090GAME( 2001, vlinero,  vliner,   neogeo,   vliner,   vliner,   ROT0, "Dyna / BrezzaSoft", "V-Liner (set 2)", 0 )
8121GAME( 2001, jockeygp,  neogeo,   neogeo,   jockeygp, jockeygp, ROT0, "Sun Amusement / BrezzaSoft", "Jockey Grand Prix", GAME_SUPPORTS_SAVE )
8122GAME( 2001, vliner,    neogeo,   neogeo,   vliner,   vliner,   ROT0, "Dyna / BrezzaSoft", "V-Liner (set 1)", GAME_SUPPORTS_SAVE )
8123GAME( 2001, vlinero,   vliner,   neogeo,   vliner,   vliner,   ROT0, "Dyna / BrezzaSoft", "V-Liner (set 2)", GAME_SUPPORTS_SAVE )
80918124
80928125/* Kyle Hodgetts */
8093GAME( 2000, diggerma, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Kyle Hodgetts", "Digger Man (prototype)", 0 )
8126GAME( 2000, diggerma, neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "Kyle Hodgetts", "Digger Man (prototype)", GAME_SUPPORTS_SAVE )
80948127
80958128/* Neo Print */
8096GAME( 1998, 98best44, 0,        neogeo,   neogeo,   neogeo,   ROT0, "SNK", "'98 NeoPri Best 44 (Neo Print)", GAME_NOT_WORKING )
8097
8129GAME( 1998, 98best44,  0,        neogeo,   neogeo,   neogeo,   ROT0, "SNK", "'98 NeoPri Best 44 (Neo Print)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
src/mame/drivers/halleys.c
r6740r6741
159159
160160#include "driver.h"
161161#include "cpu/z80/z80.h"
162#include "taitoipt.h"
162#include "includes/taitoipt.h"
163163#include "deprecat.h"
164164#include "cpu/m6809/m6809.h"
165165#include "sound/ay8910.h"
src/mame/drivers/djmain.c
r6740r6741
6868#include "cpu/m68000/m68000.h"
6969#include "machine/idectrl.h"
7070#include "sound/k054539.h"
71#include "video/konamiic.h"
71#include "video/konicdev.h"
7272
7373
7474extern UINT32 *djmain_obj_ram;
7575
7676VIDEO_UPDATE( djmain );
7777VIDEO_START( djmain );
78extern void djmain_tile_callback(running_machine* machine, int layer, int *code, int *color, int *flags);
7879
7980
8081static int sndram_bank;
r6740r6741
245246
246247static READ32_HANDLER( v_rom_r )
247248{
249   const device_config *k056832 = devtag_get_device(space->machine, "k056832");
248250   UINT8 *mem8 = memory_region(space->machine, "gfx2");
249   int bank = K056832_word_r(space, 0x34/2, 0xffff);
251   int bank = k056832_word_r(k056832, 0x34/2, 0xffff);
250252
251253   offset *= 2;
252254
r6740r6741
474476   AM_RANGE(0x480000, 0x48443f) AM_RAM_WRITE(paletteram32_w)      // COLOR RAM
475477                                AM_BASE_GENERIC(paletteram)
476478   AM_RANGE(0x500000, 0x57ffff) AM_READWRITE(sndram_r, sndram_w)            // SOUND RAM
477   AM_RANGE(0x580000, 0x58003f) AM_READWRITE(K056832_long_r, K056832_long_w)      // VIDEO REG (tilemap)
479   AM_RANGE(0x580000, 0x58003f) AM_DEVREADWRITE("k056832", k056832_long_r, k056832_long_w)      // VIDEO REG (tilemap)
478480   AM_RANGE(0x590000, 0x590007) AM_WRITE(unknown590000_w)               // ??
479   AM_RANGE(0x5a0000, 0x5a005f) AM_WRITE(K055555_long_w)               // 055555: priority encoder
481   AM_RANGE(0x5a0000, 0x5a005f) AM_DEVWRITE("k055555", k055555_long_w)               // 055555: priority encoder
480482   AM_RANGE(0x5b0000, 0x5b04ff) AM_READWRITE16(dual539_r, dual539_w, 0xffffffff)            // SOUND regs
481483   AM_RANGE(0x5c0000, 0x5c0003) AM_READ8(inp1_r, 0xffffffff)  //  DSW3,BTN3,BTN2,BTN1  // input port control (buttons and DIP switches)
482484   AM_RANGE(0x5c8000, 0x5c8003) AM_READ8(inp2_r, 0xffffffff)  //  DSW1,DSW2,UNK2,UNK1  // input port control (DIP switches)
r6740r6741
490492   AM_RANGE(0x802000, 0x802fff) AM_WRITE(unknown802000_w)               // ??
491493   AM_RANGE(0x803000, 0x80309f) AM_READWRITE(obj_ctrl_r, obj_ctrl_w)         // OBJECT REGS
492494   AM_RANGE(0x803800, 0x803fff) AM_READ(obj_rom_r)                  // OBJECT ROM readthrough (for POST)
493   AM_RANGE(0xc00000, 0xc01fff) AM_READWRITE(K056832_ram_long_r, K056832_ram_long_w)   // VIDEO RAM (tilemap) (beatmania)
495   AM_RANGE(0xc00000, 0xc01fff) AM_DEVREADWRITE("k056832", k056832_ram_long_r, k056832_ram_long_w)   // VIDEO RAM (tilemap) (beatmania)
494496   AM_RANGE(0xc02000, 0xc02047) AM_WRITE(unknownc02000_w)               // ??
495497   AM_RANGE(0xd00000, 0xd0000f) AM_DEVREADWRITE("ide", ide_std_r, ide_std_w)            // IDE control regs (hiphopmania)
496498   AM_RANGE(0xd4000c, 0xd4000f) AM_DEVREADWRITE("ide", ide_alt_r, ide_alt_w)            // IDE status control reg (hiphopmania)
497   AM_RANGE(0xe00000, 0xe01fff) AM_READWRITE(K056832_ram_long_r, K056832_ram_long_w)   // VIDEO RAM (tilemap) (hiphopmania)
499   AM_RANGE(0xe00000, 0xe01fff) AM_DEVREADWRITE("k056832", k056832_ram_long_r, k056832_ram_long_w)   // VIDEO RAM (tilemap) (hiphopmania)
498500   AM_RANGE(0xf00000, 0xf0000f) AM_DEVREADWRITE("ide", ide_std_r, ide_std_w)            // IDE control regs (beatmania)
499501   AM_RANGE(0xf4000c, 0xf4000f) AM_DEVREADWRITE("ide", ide_alt_r, ide_alt_w)            // IDE status control reg (beatmania)
500502ADDRESS_MAP_END
r6740r6741
14741476 *
14751477 *************************************/
14761478
1479static const k056832_interface djmain_k056832_intf =
1480{
1481   "gfx2", 1,
1482   K056832_BPP_4dj,
1483   1, 1,
1484   KONAMI_ROM_DEINTERLEAVE_NONE,
1485   djmain_tile_callback, "none"
1486};
1487
14771488static MACHINE_DRIVER_START( djmain )
14781489
14791490   /* basic machine hardware */
r6740r6741
15011512   MDRV_VIDEO_START(djmain)
15021513   MDRV_VIDEO_UPDATE(djmain)
15031514
1515   MDRV_K056832_ADD("k056832", djmain_k056832_intf)
1516   MDRV_K055555_ADD("k055555")
1517
15041518   /* sound hardware */
15051519   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
15061520
src/mame/drivers/namcoic.c
r6740r6741
11#include "driver.h"
2#include "namcos2.h" /* for game-specific hacks */
3#include "namcoic.h"
2#include "includes/namcos2.h" /* for game-specific hacks */
3#include "includes/namcoic.h"
44
55/**************************************************************************************/
66static int mPalXOR;      /* XOR'd with palette select register; needed for System21 */
src/mame/drivers/segas16a.c
r6740r6741
147147#include "cpu/z80/z80.h"
148148#include "cpu/m68000/m68000.h"
149149#include "cpu/mcs51/mcs51.h"
150#include "system16.h"
150#include "includes/system16.h"
151151#include "machine/8255ppi.h"
152152#include "machine/fd1089.h"
153153#include "machine/i8243.h"
src/mame/drivers/snookr10.c
r6740r6741
368368
369369
370370/* from video */
371extern UINT8 *snookr10_videoram;
372extern UINT8 *snookr10_colorram;
373
371374WRITE8_HANDLER( snookr10_videoram_w );
372375WRITE8_HANDLER( snookr10_colorram_w );
373376PALETTE_INIT( snookr10 );
r6740r6741
514517   AM_RANGE(0x3004, 0x3004) AM_READ(dsw_port_1_r)      /* complement of DS1, bit 7 */
515518   AM_RANGE(0x5000, 0x5000) AM_WRITE(output_port_0_w)   /* OUT0 */
516519   AM_RANGE(0x5001, 0x5001) AM_WRITE(output_port_1_w)   /* OUT1 */
517   AM_RANGE(0x6000, 0x6fff) AM_RAM_WRITE(snookr10_videoram_w) AM_BASE_GENERIC(videoram)
518   AM_RANGE(0x7000, 0x7fff) AM_RAM_WRITE(snookr10_colorram_w) AM_BASE_GENERIC(colorram)
520   AM_RANGE(0x6000, 0x6fff) AM_RAM_WRITE(snookr10_videoram_w) AM_BASE(&snookr10_videoram)
521   AM_RANGE(0x7000, 0x7fff) AM_RAM_WRITE(snookr10_colorram_w) AM_BASE(&snookr10_colorram)
519522   AM_RANGE(0x8000, 0xffff) AM_ROM
520523ADDRESS_MAP_END
521524
r6740r6741
528531   AM_RANGE(0x4003, 0x4003) AM_READ_PORT("SW1")      /* DS1 */
529532   AM_RANGE(0x5000, 0x5000) AM_WRITE(output_port_0_w)   /* OUT0 */
530533   AM_RANGE(0x5001, 0x5001) AM_WRITE(output_port_1_w)   /* OUT1 */
531   AM_RANGE(0x6000, 0x6fff) AM_RAM_WRITE(snookr10_videoram_w) AM_BASE_GENERIC(videoram)
532   AM_RANGE(0x7000, 0x7fff) AM_RAM_WRITE(snookr10_colorram_w) AM_BASE_GENERIC(colorram)
534   AM_RANGE(0x6000, 0x6fff) AM_RAM_WRITE(snookr10_videoram_w) AM_BASE(&snookr10_videoram)
535   AM_RANGE(0x7000, 0x7fff) AM_RAM_WRITE(snookr10_colorram_w) AM_BASE(&snookr10_colorram)
533536   AM_RANGE(0x8000, 0xffff) AM_ROM
534537ADDRESS_MAP_END
535538
src/mame/drivers/neogeo.c
r6740r6741
193193
194194#include "driver.h"
195195#include "cpu/m68000/m68000.h"
196#include "neogeo.h"
196#include "includes/neogeo.h"
197197#include "machine/pd4990a.h"
198198#include "cpu/z80/z80.h"
199199#include "sound/2610intf.h"
r6740r6741
201201#include "neogeo.lh"
202202
203203
204#define LOG_VIDEO_SYSTEM      (0)
205#define LOG_CPU_COMM         (0)
206#define LOG_MAIN_CPU_BANKING   (0)
207#define LOG_AUDIO_CPU_BANKING   (0)
204#define LOG_VIDEO_SYSTEM         (0)
205#define LOG_CPU_COMM             (0)
206#define LOG_MAIN_CPU_BANKING     (0)
207#define LOG_AUDIO_CPU_BANKING    (0)
208208
209209
210
211210/*************************************
212211 *
213212 *  Global variables
214213 *
215214 *************************************/
216215
217static UINT8 display_position_interrupt_control;
218static UINT32 display_counter;
219static UINT32 vblank_interrupt_pending;
220static UINT32 display_position_interrupt_pending;
221static UINT32 irq3_pending;
222static emu_timer *display_position_interrupt_timer;
223static emu_timer *display_position_vblank_timer;
224static emu_timer *vblank_interrupt_timer;
225
226static UINT8 controller_select;
227
228216static UINT8 *memcard_data;
229
230static UINT32 main_cpu_bank_address;
231static UINT8 main_cpu_vector_table_source;
232
233static UINT8 audio_result;
234static UINT8 audio_cpu_banks[4];
235static UINT8 audio_cpu_rom_source;
236static UINT8 audio_cpu_rom_source_last;
237
238217static UINT16 *save_ram;
239static UINT8 save_ram_unlocked;
240218
241static UINT8 output_data;
242static UINT8 output_latch;
243static UINT8 el_value;
244static UINT8 led1_value;
245static UINT8 led2_value;
246219
247
248
249220/*************************************
250221 *
251222 *  Forward declerations
r6740r6741
253224 *************************************/
254225
255226static void set_output_latch(running_machine *machine, UINT8 data);
256static void set_output_data(UINT8 data);
227static void set_output_data(running_machine *machine, UINT8 data);
257228
258229
259
260230/*************************************
261231 *
262232 *  Main CPU interrupt generation
263233 *
264234 *************************************/
265235
266#define IRQ2CTRL_ENABLE            (0x10)
267#define IRQ2CTRL_LOAD_RELATIVE      (0x20)
268#define IRQ2CTRL_AUTOLOAD_VBLANK   (0x40)
269#define IRQ2CTRL_AUTOLOAD_REPEAT   (0x80)
236#define IRQ2CTRL_ENABLE             (0x10)
237#define IRQ2CTRL_LOAD_RELATIVE      (0x20)
238#define IRQ2CTRL_AUTOLOAD_VBLANK    (0x40)
239#define IRQ2CTRL_AUTOLOAD_REPEAT    (0x80)
270240
271241
272static void adjust_display_position_interrupt_timer(running_machine *machine)
242static void adjust_display_position_interrupt_timer( running_machine *machine )
273243{
274   if ((display_counter + 1) != 0)
244   neogeo_state *state = (neogeo_state *)machine->driver_data;
245
246   if ((state->display_counter + 1) != 0)
275247   {
276      attotime period = attotime_mul(ATTOTIME_IN_HZ(NEOGEO_PIXEL_CLOCK), display_counter + 1);
277      if (LOG_VIDEO_SYSTEM) logerror("adjust_display_position_interrupt_timer  current y: %02x  current x: %02x   target y: %x  target x: %x\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen), (display_counter + 1) / NEOGEO_HTOTAL, (display_counter + 1) % NEOGEO_HTOTAL);
248      attotime period = attotime_mul(ATTOTIME_IN_HZ(NEOGEO_PIXEL_CLOCK), state->display_counter + 1);
249      if (LOG_VIDEO_SYSTEM) logerror("adjust_display_position_interrupt_timer  current y: %02x  current x: %02x   target y: %x  target x: %x\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen), (state->display_counter + 1) / NEOGEO_HTOTAL, (state->display_counter + 1) % NEOGEO_HTOTAL);
278250
279      timer_adjust_oneshot(display_position_interrupt_timer, period, 0);
251      timer_adjust_oneshot(state->display_position_interrupt_timer, period, 0);
280252   }
281253}
282254
283255
284void neogeo_set_display_position_interrupt_control(UINT16 data)
256void neogeo_set_display_position_interrupt_control( running_machine *machine, UINT16 data )
285257{
286   display_position_interrupt_control = data;
258   neogeo_state *state = (neogeo_state *)machine->driver_data;
259   state->display_position_interrupt_control = data;
287260}
288261
289262
290void neogeo_set_display_counter_msb(const address_space *space, UINT16 data)
263void neogeo_set_display_counter_msb( const address_space *space, UINT16 data )
291264{
292   display_counter = (display_counter & 0x0000ffff) | ((UINT32)data << 16);
265   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
293266
294   if (LOG_VIDEO_SYSTEM) logerror("PC %06x: set_display_counter %08x\n", cpu_get_pc(space->cpu), display_counter);
267   state->display_counter = (state->display_counter & 0x0000ffff) | ((UINT32)data << 16);
268
269   if (LOG_VIDEO_SYSTEM) logerror("PC %06x: set_display_counter %08x\n", cpu_get_pc(space->cpu), state->display_counter);
295270}
296271
297272
298void neogeo_set_display_counter_lsb(const address_space *space, UINT16 data)
273void neogeo_set_display_counter_lsb( const address_space *space, UINT16 data )
299274{
300   display_counter = (display_counter & 0xffff0000) | data;
275   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
301276
302   if (LOG_VIDEO_SYSTEM) logerror("PC %06x: set_display_counter %08x\n", cpu_get_pc(space->cpu), display_counter);
277   state->display_counter = (state->display_counter & 0xffff0000) | data;
303278
304   if (display_position_interrupt_control & IRQ2CTRL_LOAD_RELATIVE)
279   if (LOG_VIDEO_SYSTEM) logerror("PC %06x: set_display_counter %08x\n", cpu_get_pc(space->cpu), state->display_counter);
280
281   if (state->display_position_interrupt_control & IRQ2CTRL_LOAD_RELATIVE)
305282   {
306283      if (LOG_VIDEO_SYSTEM) logerror("AUTOLOAD_RELATIVE ");
307284       adjust_display_position_interrupt_timer(space->machine);
r6740r6741
309286}
310287
311288
312static void update_interrupts(running_machine *machine)
289static void update_interrupts( running_machine *machine )
313290{
314   cputag_set_input_line(machine, "maincpu", 1, vblank_interrupt_pending ? ASSERT_LINE : CLEAR_LINE);
315   cputag_set_input_line(machine, "maincpu", 2, display_position_interrupt_pending ? ASSERT_LINE : CLEAR_LINE);
316   cputag_set_input_line(machine, "maincpu", 3, irq3_pending ? ASSERT_LINE : CLEAR_LINE);
291   neogeo_state *state = (neogeo_state *)machine->driver_data;
292
293   cputag_set_input_line(machine, "maincpu", 1, state->vblank_interrupt_pending ? ASSERT_LINE : CLEAR_LINE);
294   cputag_set_input_line(machine, "maincpu", 2, state->display_position_interrupt_pending ? ASSERT_LINE : CLEAR_LINE);
295   cputag_set_input_line(machine, "maincpu", 3, state->irq3_pending ? ASSERT_LINE : CLEAR_LINE);
317296}
318297
319298
320void neogeo_acknowledge_interrupt(running_machine *machine, UINT16 data)
299void neogeo_acknowledge_interrupt( running_machine *machine, UINT16 data )
321300{
322   if (data & 0x01) irq3_pending = 0;
323   if (data & 0x02) display_position_interrupt_pending = 0;
324   if (data & 0x04) vblank_interrupt_pending = 0;
301   neogeo_state *state = (neogeo_state *)machine->driver_data;
325302
303   if (data & 0x01)
304      state->irq3_pending = 0;
305   if (data & 0x02)
306      state->display_position_interrupt_pending = 0;
307   if (data & 0x04)
308      state->vblank_interrupt_pending = 0;
309
326310   update_interrupts(machine);
327311}
328312
329313
330314static TIMER_CALLBACK( display_position_interrupt_callback )
331315{
316   neogeo_state *state = (neogeo_state *)machine->driver_data;
317
332318   if (LOG_VIDEO_SYSTEM) logerror("--- Scanline @ %d,%d\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen));
333   if (display_position_interrupt_control & IRQ2CTRL_ENABLE)
319
320   if (state->display_position_interrupt_control & IRQ2CTRL_ENABLE)
334321   {
335322      if (LOG_VIDEO_SYSTEM) logerror("*** Scanline interrupt (IRQ2) ***  y: %02x  x: %02x\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen));
336      display_position_interrupt_pending = 1;
323      state->display_position_interrupt_pending = 1;
337324
338325      update_interrupts(machine);
339326   }
340327
341   if (display_position_interrupt_control & IRQ2CTRL_AUTOLOAD_REPEAT)
328   if (state->display_position_interrupt_control & IRQ2CTRL_AUTOLOAD_REPEAT)
342329   {
343330      if (LOG_VIDEO_SYSTEM) logerror("AUTOLOAD_REPEAT ");
344331      adjust_display_position_interrupt_timer(machine);
r6740r6741
348335
349336static TIMER_CALLBACK( display_position_vblank_callback )
350337{
351   if (display_position_interrupt_control & IRQ2CTRL_AUTOLOAD_VBLANK)
338   neogeo_state *state = (neogeo_state *)machine->driver_data;
339
340   if (state->display_position_interrupt_control & IRQ2CTRL_AUTOLOAD_VBLANK)
352341   {
353342      if (LOG_VIDEO_SYSTEM) logerror("AUTOLOAD_VBLANK ");
354343      adjust_display_position_interrupt_timer(machine);
355344   }
356345
357346   /* set timer for next screen */
358   timer_adjust_oneshot(display_position_vblank_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0);
347   timer_adjust_oneshot(state->display_position_vblank_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0);
359348}
360349
361350
362351static TIMER_CALLBACK( vblank_interrupt_callback )
363352{
364   const device_config *upd4990a = devtag_get_device(machine, "upd4990a");
353   neogeo_state *state = (neogeo_state *)machine->driver_data;
365354
366355   if (LOG_VIDEO_SYSTEM) logerror("+++ VBLANK @ %d,%d\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen));
367356
368357   /* add a timer tick to the pd4990a */
369   upd4990a_addretrace(upd4990a);
358   upd4990a_addretrace(state->upd4990a);
370359
371   vblank_interrupt_pending = 1;
360   state->vblank_interrupt_pending = 1;
372361
373362   update_interrupts(machine);
374363
375364   /* set timer for next screen */
376   timer_adjust_oneshot(vblank_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, 0), 0);
365   timer_adjust_oneshot(state->vblank_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, 0), 0);
377366}
378367
379368
380static void create_interrupt_timers(running_machine *machine)
369static void create_interrupt_timers( running_machine *machine )
381370{
382   display_position_interrupt_timer = timer_alloc(machine, display_position_interrupt_callback, NULL);
383   display_position_vblank_timer = timer_alloc(machine, display_position_vblank_callback, NULL);
384   vblank_interrupt_timer = timer_alloc(machine, vblank_interrupt_callback, NULL);
371   neogeo_state *state = (neogeo_state *)machine->driver_data;
372   state->display_position_interrupt_timer = timer_alloc(machine, display_position_interrupt_callback, NULL);
373   state->display_position_vblank_timer = timer_alloc(machine, display_position_vblank_callback, NULL);
374   state->vblank_interrupt_timer = timer_alloc(machine, vblank_interrupt_callback, NULL);
385375}
386376
387377
388static void start_interrupt_timers(running_machine *machine)
378static void start_interrupt_timers( running_machine *machine )
389379{
390   timer_adjust_oneshot(vblank_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, 0), 0);
391   timer_adjust_oneshot(display_position_vblank_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0);
380   neogeo_state *state = (neogeo_state *)machine->driver_data;
381   timer_adjust_oneshot(state->vblank_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, 0), 0);
382   timer_adjust_oneshot(state->display_position_vblank_timer, video_screen_get_time_until_pos(machine->primary_screen, NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0);
392383}
393384
394385
r6740r6741
401392
402393static void audio_cpu_irq(const device_config *device, int assert)
403394{
404   cputag_set_input_line(device->machine, "audiocpu", 0, assert ? ASSERT_LINE : CLEAR_LINE);
395   neogeo_state *state = (neogeo_state *)device->machine->driver_data;
396   cpu_set_input_line(state->audiocpu, 0, assert ? ASSERT_LINE : CLEAR_LINE);
405397}
406398
407399
408400static void audio_cpu_assert_nmi(running_machine *machine)
409401{
410   cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, ASSERT_LINE);
402   neogeo_state *state = (neogeo_state *)machine->driver_data;
403   cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, ASSERT_LINE);
411404}
412405
413406
414407static WRITE8_HANDLER( audio_cpu_clear_nmi_w )
415408{
416   cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, CLEAR_LINE);
409   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
410   cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, CLEAR_LINE);
417411}
418412
419413
r6740r6741
424418 *
425419 *************************************/
426420
427static void select_controller(UINT8 data)
421static void select_controller( running_machine *machine, UINT8 data )
428422{
429   controller_select = data;
423   neogeo_state *state = (neogeo_state *)machine->driver_data;
424   state->controller_select = data;
430425}
431426
432427
433428static CUSTOM_INPUT( multiplexed_controller_r )
434429{
430   neogeo_state *state = (neogeo_state *)field->port->machine->driver_data;
435431   int port = (FPTR)param;
436432
437433   static const char *const cntrl[2][2] =
r6740r6741
439435         { "IN0-0", "IN0-1" }, { "IN1-0", "IN1-1" }
440436      };
441437
442   return input_port_read_safe(field->port->machine, cntrl[port][controller_select & 0x01], 0x00);
438   return input_port_read_safe(field->port->machine, cntrl[port][state->controller_select & 0x01], 0x00);
443439}
444440
445441
446442static CUSTOM_INPUT( mahjong_controller_r )
447443{
444   neogeo_state *state = (neogeo_state *)field->port->machine->driver_data;
448445   UINT32 ret;
449446
450447/*
r6740r6741
454451cpu #0 (PC=00C18D6C): unmapped memory word write to 00380000 = 0009 & 00FF
455452cpu #0 (PC=00C18C40): unmapped memory word write to 00380000 = 0000 & 00FF
456453*/
457   switch (controller_select)
454   switch (state->controller_select)
458455   {
459456   default:
460457   case 0x00: ret = 0x0000; break; /* nothing? */
r6740r6741
470467
471468static WRITE16_HANDLER( io_control_w )
472469{
473   const device_config *upd4990a = devtag_get_device(space->machine, "upd4990a");
474
470   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
475471   switch (offset)
476472   {
477   case 0x00: select_controller(data & 0x00ff); break;
473   case 0x00: select_controller(space->machine, data & 0x00ff); break;
478474   case 0x18: set_output_latch(space->machine, data & 0x00ff); break;
479   case 0x20: set_output_data(data & 0x00ff); break;
480   case 0x28: upd4990a_control_16_w(upd4990a, 0, data, mem_mask); break;
475   case 0x20: set_output_data(space->machine, data & 0x00ff); break;
476   case 0x28: upd4990a_control_16_w(state->upd4990a, 0, data, mem_mask); break;
481477//  case 0x30: break; // coin counters
482478//  case 0x31: break; // coin counters
483479//  case 0x32: break; // coin lockout
r6740r6741
499495
500496READ16_HANDLER( neogeo_unmapped_r )
501497{
502   static UINT8 recurse = 0;
498   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
503499   UINT16 ret;
504500
505501   /* unmapped memory returns the last word on the data bus, which is almost always the opcode
506502       of the next instruction due to prefetch */
507503
508504   /* prevent recursion */
509   if (recurse)
505   if (state->recurse)
510506      ret = 0xffff;
511507   else
512508   {
513      recurse = 1;
509      state->recurse = 1;
514510      ret = memory_read_word(space, cpu_get_pc(space->cpu));
515      recurse = 0;
511      state->recurse = 0;
516512   }
517513
518514   return ret;
r6740r6741
528524
529525static CUSTOM_INPUT( get_calendar_status )
530526{
531   const device_config *upd4990a = devtag_get_device(field->port->machine, "upd4990a");
532   return (upd4990a_databit_r(upd4990a, 0) << 1) | upd4990a_testbit_r(upd4990a, 0);
527   neogeo_state *state = (neogeo_state *)field->port->machine->driver_data;
528   return (upd4990a_databit_r(state->upd4990a, 0) << 1) | upd4990a_testbit_r(state->upd4990a, 0);
533529}
534530
535531
r6740r6741
556552}
557553
558554
559static void set_save_ram_unlock(UINT8 data)
555static void set_save_ram_unlock( running_machine *machine, UINT8 data )
560556{
561   save_ram_unlocked = data;
557   neogeo_state *state = (neogeo_state *)machine->driver_data;
558   state->save_ram_unlocked = data;
562559}
563560
564561
565562static WRITE16_HANDLER( save_ram_w )
566563{
567   if (save_ram_unlocked)
564   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
565
566   if (state->save_ram_unlocked)
568567      COMBINE_DATA(&save_ram[offset]);
569568}
570569
r6740r6741
669668
670669static WRITE8_HANDLER( audio_result_w )
671670{
672   if (LOG_CPU_COMM && (audio_result != data)) logerror(" AUD CPU PC   %04x: audio_result_w %02x\n", cpu_get_pc(space->cpu), data);
671   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
673672
674   audio_result = data;
673   if (LOG_CPU_COMM && (state->audio_result != data)) logerror(" AUD CPU PC   %04x: audio_result_w %02x\n", cpu_get_pc(space->cpu), data);
674
675   state->audio_result = data;
675676}
676677
677678
678679static CUSTOM_INPUT( get_audio_result )
679680{
680   UINT32 ret = audio_result;
681   neogeo_state *state = (neogeo_state *)field->port->machine->driver_data;
682   UINT32 ret = state->audio_result;
681683
682684//  if (LOG_CPU_COMM) logerror("MAIN CPU PC %06x: audio_result_r %02x\n", cpu_get_pc(cputag_get_cpu(field->port->machine, "maincpu")), ret);
683685
r6740r6741
692694 *
693695 *************************************/
694696
695static void _set_main_cpu_vector_table_source(running_machine *machine)
697static void _set_main_cpu_vector_table_source( running_machine *machine )
696698{
697   memory_set_bank(machine, NEOGEO_BANK_VECTORS, main_cpu_vector_table_source);
699   neogeo_state *state = (neogeo_state *)machine->driver_data;
700   memory_set_bank(machine, NEOGEO_BANK_VECTORS, state->main_cpu_vector_table_source);
698701}
699702
700703
701static void set_main_cpu_vector_table_source(running_machine *machine, UINT8 data)
704static void set_main_cpu_vector_table_source( running_machine *machine, UINT8 data )
702705{
703   main_cpu_vector_table_source = data;
706   neogeo_state *state = (neogeo_state *)machine->driver_data;
707   state->main_cpu_vector_table_source = data;
704708
705709   _set_main_cpu_vector_table_source(machine);
706710}
707711
708712
709static void _set_main_cpu_bank_address(running_machine *machine)
713static void _set_main_cpu_bank_address( running_machine *machine )
710714{
711   memory_set_bankptr(machine, NEOGEO_BANK_CARTRIDGE, &memory_region(machine, "maincpu")[main_cpu_bank_address]);
715   neogeo_state *state = (neogeo_state *)machine->driver_data;
716   memory_set_bankptr(machine, NEOGEO_BANK_CARTRIDGE, &memory_region(machine, "maincpu")[state->main_cpu_bank_address]);
712717}
713718
714719
715void neogeo_set_main_cpu_bank_address(const address_space *space, UINT32 bank_address)
720void neogeo_set_main_cpu_bank_address( const address_space *space, UINT32 bank_address )
716721{
722   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
723
717724   if (LOG_MAIN_CPU_BANKING) logerror("MAIN CPU PC %06x: neogeo_set_main_cpu_bank_address %06x\n", cpu_get_pc(space->cpu), bank_address);
718725
719   main_cpu_bank_address = bank_address;
726   state->main_cpu_bank_address = bank_address;
720727
721728   _set_main_cpu_bank_address(space->machine);
722729}
r6740r6741
744751}
745752
746753
747static void main_cpu_banking_init(running_machine *machine)
754static void main_cpu_banking_init( running_machine *machine )
748755{
749756   const address_space *mainspace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
750757
r6740r6741
767774 *
768775 *************************************/
769776
770static void set_audio_cpu_banking(running_machine *machine)
777static void set_audio_cpu_banking( running_machine *machine )
771778{
779   neogeo_state *state = (neogeo_state *)machine->driver_data;
772780   int region;
773781
774782   for (region = 0; region < 4; region++)
775      memory_set_bank(machine, NEOGEO_BANK_AUDIO_CPU_CART_BANK + region, audio_cpu_banks[region]);
783      memory_set_bank(machine, NEOGEO_BANK_AUDIO_CPU_CART_BANK + region, state->audio_cpu_banks[region]);
776784}
777785
778786
779static void audio_cpu_bank_select(const address_space *space, int region, UINT8 bank)
787static void audio_cpu_bank_select( const address_space *space, int region, UINT8 bank )
780788{
789   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
790
781791   if (LOG_AUDIO_CPU_BANKING) logerror("Audio CPU PC %03x: audio_cpu_bank_select: Region: %d   Bank: %02x\n", cpu_get_pc(space->cpu), region, bank);
782792
783   audio_cpu_banks[region] = bank;
793   state->audio_cpu_banks[region] = bank;
784794
785795   set_audio_cpu_banking(space->machine);
786796}
r6740r6741
818828}
819829
820830
821static void _set_audio_cpu_rom_source(const address_space *space)
831static void _set_audio_cpu_rom_source( const address_space *space )
822832{
833   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
834
823835/*  if (!memory_region(machine, "audiobios"))   */
824      audio_cpu_rom_source = 1;
836      state->audio_cpu_rom_source = 1;
825837
826   memory_set_bank(space->machine, NEOGEO_BANK_AUDIO_CPU_MAIN_BANK, audio_cpu_rom_source);
838   memory_set_bank(space->machine, NEOGEO_BANK_AUDIO_CPU_MAIN_BANK, state->audio_cpu_rom_source);
827839
828840   /* reset CPU if the source changed -- this is a guess */
829   if (audio_cpu_rom_source != audio_cpu_rom_source_last)
841   if (state->audio_cpu_rom_source != state->audio_cpu_rom_source_last)
830842   {
831      audio_cpu_rom_source_last = audio_cpu_rom_source;
843      state->audio_cpu_rom_source_last = state->audio_cpu_rom_source;
832844
833845      cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_RESET, PULSE_LINE);
834846
835      if (LOG_AUDIO_CPU_BANKING) logerror("Audio CPU PC %03x: selectign %s ROM\n", cpu_get_pc(space->cpu), audio_cpu_rom_source ? "CARTRIDGE" : "BIOS");
847      if (LOG_AUDIO_CPU_BANKING) logerror("Audio CPU PC %03x: selectign %s ROM\n", cpu_get_pc(space->cpu), state->audio_cpu_rom_source ? "CARTRIDGE" : "BIOS");
836848   }
837849}
838850
839851
840static void set_audio_cpu_rom_source(const address_space *space, UINT8 data)
852static void set_audio_cpu_rom_source( const address_space *space, UINT8 data )
841853{
842   audio_cpu_rom_source = data;
854   neogeo_state *state = (neogeo_state *)space->machine->driver_data;
855   state->audio_cpu_rom_source = data;
843856
844857   _set_audio_cpu_rom_source(space);
845858}
846859
847860
848static void audio_cpu_banking_init(running_machine *machine)
861static void audio_cpu_banking_init( running_machine *machine )
849862{
863   neogeo_state *state = (neogeo_state *)machine->driver_data;
850864   int region;
851865   int bank;
852866   UINT8 *rgn;
r6740r6741
872886
873887   /* set initial audio banks --
874888       how does this really work, or is it even neccessary? */
875   audio_cpu_banks[0] = 0x1e;
876   audio_cpu_banks[1] = 0x0e;
877   audio_cpu_banks[2] = 0x06;
878   audio_cpu_banks[3] = 0x02;
889   state->audio_cpu_banks[0] = 0x1e;
890   state->audio_cpu_banks[1] = 0x0e;
891   state->audio_cpu_banks[2] = 0x06;
892   state->audio_cpu_banks[3] = 0x02;
879893
880894   set_audio_cpu_banking(machine);
881895
882   audio_cpu_rom_source_last = 0;
896   state->audio_cpu_rom_source_last = 0;
883897   set_audio_cpu_rom_source(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0);
884898}
885899
r6740r6741
904918      case 0x01: set_main_cpu_vector_table_source(space->machine, bit);
905919               set_audio_cpu_rom_source(space, bit); /* this is a guess */
906920               break;
907      case 0x05: neogeo_set_fixed_layer_source(bit); break;
908      case 0x06: set_save_ram_unlock(bit); break;
921      case 0x05: neogeo_set_fixed_layer_source(space->machine, bit); break;
922      case 0x06: set_save_ram_unlock(space->machine, bit); break;
909923      case 0x07: neogeo_set_palette_bank(space->machine, bit); break;
910924
911925      case 0x02: /* unknown - HC32 middle pin 1 */
r6740r6741
972986 *
973987 *************************************/
974988
975static void set_outputs(void)
989static void set_outputs( running_machine *machine )
976990{
991   neogeo_state *state = (neogeo_state *)machine->driver_data;
977992   static const UINT8 led_map[0x10] =
978993      { 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x58,0x4c,0x62,0x69,0x78,0x00 };
979994
980995   /* EL */
981   output_set_digit_value(0, led_map[el_value]);
996   output_set_digit_value(0, led_map[state->el_value]);
982997
983998   /* LED1 */
984   output_set_digit_value(1, led_map[led1_value >> 4]);
985   output_set_digit_value(2, led_map[led1_value & 0x0f]);
999   output_set_digit_value(1, led_map[state->led1_value >> 4]);
1000   output_set_digit_value(2, led_map[state->led1_value & 0x0f]);
9861001
9871002   /* LED2 */
988   output_set_digit_value(3, led_map[led2_value >> 4]);
989   output_set_digit_value(4, led_map[led2_value & 0x0f]);
1003   output_set_digit_value(3, led_map[state->led2_value >> 4]);
1004   output_set_digit_value(4, led_map[state->led2_value & 0x0f]);
9901005}
9911006
9921007
993static void set_output_latch(running_machine *machine, UINT8 data)
1008static void set_output_latch( running_machine *machine, UINT8 data )
9941009{
1010   neogeo_state *state = (neogeo_state *)machine->driver_data;
1011
9951012   /* looks like the LEDs are set on the
9961013       falling edge */
997    UINT8 falling_bits = output_latch & ~data;
1014   UINT8 falling_bits = state->output_latch & ~data;
9981015
999    if (falling_bits & 0x08)
1000       el_value = 16 - (output_data & 0x0f);
1016   if (falling_bits & 0x08)
1017      state->el_value = 16 - (state->output_data & 0x0f);
10011018
1002    if (falling_bits & 0x10)
1003       led1_value = ~output_data;
1019   if (falling_bits & 0x10)
1020      state->led1_value = ~state->output_data;
10041021
1005    if (falling_bits & 0x20)
1006       led2_value = ~output_data;
1022   if (falling_bits & 0x20)
1023      state->led2_value = ~state->output_data;
10071024
10081025     if (falling_bits & 0xc7)
10091026      logerror("%s  Unmaped LED write.  Data: %x\n", cpuexec_describe_context(machine), falling_bits);
10101027
1011   output_latch = data;
1028   state->output_latch = data;
10121029
1013   set_outputs();
1030   set_outputs(machine);
10141031}
10151032
10161033
1017static void set_output_data(UINT8 data)
1034static void set_output_data( running_machine *machine, UINT8 data )
10181035{
1019   output_data = data;
1036   neogeo_state *state = (neogeo_state *)machine->driver_data;
1037   state->output_data = data;
10201038}
10211039
10221040
r6740r6741
10331051   _set_main_cpu_vector_table_source(machine);
10341052   set_audio_cpu_banking(machine);
10351053   _set_audio_cpu_rom_source(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM));
1036   set_outputs();
1054   set_outputs(machine);
10371055}
10381056
10391057static MACHINE_START( neogeo )
10401058{
1059   neogeo_state *state = (neogeo_state *)machine->driver_data;
1060
10411061   /* set the BIOS bank */
10421062   memory_set_bankptr(machine, NEOGEO_BANK_BIOS, memory_region(machine, "mainbios"));
10431063
r6740r6741
10531073   memcard_data = auto_alloc_array_clear(machine, UINT8, MEMCARD_SIZE);
10541074
10551075   /* start with an IRQ3 - but NOT on a reset */
1056   irq3_pending = 1;
1076   state->irq3_pending = 1;
10571077
1078   /* get devices */
1079   state->maincpu = devtag_get_device(machine, "maincpu");
1080   state->audiocpu = devtag_get_device(machine, "audiocpu");
1081   state->upd4990a = devtag_get_device(machine, "upd4990a");
1082
10581083   /* register state save */
1059   state_save_register_global(machine, display_position_interrupt_control);
1060   state_save_register_global(machine, display_counter);
1061   state_save_register_global(machine, vblank_interrupt_pending);
1062   state_save_register_global(machine, display_position_interrupt_pending);
1063   state_save_register_global(machine, irq3_pending);
1064   state_save_register_global(machine, audio_result);
1065   state_save_register_global(machine, controller_select);
1066   state_save_register_global(machine, main_cpu_bank_address);
1067   state_save_register_global(machine, main_cpu_vector_table_source);
1068   state_save_register_global_array(machine, audio_cpu_banks);
1069   state_save_register_global(machine, audio_cpu_rom_source);
1070   state_save_register_global(machine, audio_cpu_rom_source_last);
1071   state_save_register_global(machine, save_ram_unlocked);
1084   state_save_register_global(machine, state->display_position_interrupt_control);
1085   state_save_register_global(machine, state->display_counter);
1086   state_save_register_global(machine, state->vblank_interrupt_pending);
1087   state_save_register_global(machine, state->display_position_interrupt_pending);
1088   state_save_register_global(machine, state->irq3_pending);
1089   state_save_register_global(machine, state->audio_result);
1090   state_save_register_global(machine, state->controller_select);
1091   state_save_register_global(machine, state->main_cpu_bank_address);
1092   state_save_register_global(machine, state->main_cpu_vector_table_source);
1093   state_save_register_global_array(machine, state->audio_cpu_banks);
1094   state_save_register_global(machine, state->audio_cpu_rom_source);
1095   state_save_register_global(machine, state->audio_cpu_rom_source_last);
1096   state_save_register_global(machine, state->save_ram_unlocked);
10721097   state_save_register_global_pointer(machine, memcard_data, 0x800);
1073   state_save_register_global(machine, output_data);
1074   state_save_register_global(machine, output_latch);
1075   state_save_register_global(machine, el_value);
1076   state_save_register_global(machine, led1_value);
1077   state_save_register_global(machine, led2_value);
1098   state_save_register_global(machine, state->output_data);
1099   state_save_register_global(machine, state->output_latch);
1100   state_save_register_global(machine, state->el_value);
1101   state_save_register_global(machine, state->led1_value);
1102   state_save_register_global(machine, state->led2_value);
1103   state_save_register_global(machine, state->recurse);
10781104
10791105   state_save_register_postload(machine, neogeo_postload, NULL);
10801106}
r6740r6741
10891115
10901116static MACHINE_RESET( neogeo )
10911117{
1118   neogeo_state *state = (neogeo_state *)machine->driver_data;
10921119   offs_t offs;
10931120   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
10941121
10951122   /* reset system control registers */
10961123   for (offs = 0; offs < 8; offs++)
10971124      system_control_w(space, offs, 0, 0x00ff);
1125
10981126   device_reset(cputag_get_cpu(machine, "maincpu"));
10991127
1100   neogeo_reset_rng();
1128   neogeo_reset_rng(machine);
11011129
11021130   start_interrupt_timers(machine);
11031131
11041132   /* trigger the IRQ3 that was set by MACHINE_START */
11051133   update_interrupts(machine);
1134
1135   state->recurse = 0;
11061136}
11071137
11081138
r6740r6741
13091339
13101340static MACHINE_DRIVER_START( neogeo )
13111341
1342   /* driver data */
1343   MDRV_DRIVER_DATA(neogeo_state)
1344
13121345   /* basic machine hardware */
13131346   MDRV_CPU_ADD("maincpu", M68000, NEOGEO_MAIN_CPU_CLOCK)
13141347   MDRV_CPU_PROGRAM_MAP(main_map)
r6740r6741
13561389
13571390static DRIVER_INIT( neogeo )
13581391{
1392   neogeo_state *state = (neogeo_state *)machine->driver_data;
1393   state->fixed_layer_bank_type = 0;
13591394}
13601395
13611396
src/mame/drivers/segahang.c
r6740r6741
1717#include "cpu/z80/z80.h"
1818#include "cpu/mcs51/mcs51.h"
1919#include "deprecat.h"
20#include "system16.h"
20#include "includes/system16.h"
2121#include "machine/segaic16.h"
2222#include "machine/fd1089.h"
2323#include "machine/8255ppi.h"
src/mame/drivers/carrera.c
r6740r6741
3838 There is also a 'Bomberman' title in the GFX roms, unused from what I can see.
3939
4040TODO:
41- Needs a reference for the colors.
41- Are colors 100% correct? Needs a reference to be sure.
4242- There are reel gfxs on the roms (near the end), left-over or there's a way to enable it?
43  Update: if you trigger a normal irq 0 instead of a NMI the game will change into a proper 8 liner game without inputs. Investigate on it...
4344
4445*/
4546
r6740r6741
274275static PALETTE_INIT(carrera)
275276{
276277   int br_bit0, br_bit1, bit0, bit1, r, g, b;
277   int i;
278   int   i;
278279
279   for (i = 0; i < 0x20; ++i)
280   for (i = 0; i < 0x40; ++i)
280281   {
281      br_bit0 = (color_prom[0] >> 0) & 0x01;
282      br_bit1 = (color_prom[0] >> 1) & 0x01;
282      br_bit0 = (color_prom[0] >> 6) & 0x01;
283      br_bit1 = (color_prom[0] >> 7) & 0x01;
283284
284      bit0 = (color_prom[0] >> 2) & 0x01;
285      bit0 = (color_prom[0] >> 0) & 0x01;
285286      bit1 = (color_prom[0] >> 3) & 0x01;
286287      b = 0x0e * br_bit0 + 0x1f * br_bit1 + 0x43 * bit0 + 0x8f * bit1;
287      bit0 = (color_prom[0] >> 4) & 0x01;
288      bit0 = (color_prom[0] >> 1) & 0x01;
289      bit1 = (color_prom[0] >> 4) & 0x01;
290      g = 0x0e * br_bit0 + 0x1f * br_bit1 + 0x43 * bit0 + 0x8f * bit1;
291      bit0 = (color_prom[0] >> 2) & 0x01;
288292      bit1 = (color_prom[0] >> 5) & 0x01;
289      g = 0x0e * br_bit0 + 0x1f * br_bit1 + 0x43 * bit0 + 0x8f * bit1;
290      bit0 = (color_prom[0] >> 6) & 0x01;
291      bit1 = (color_prom[0] >> 7) & 0x01;
292293      r = 0x0e * br_bit0 + 0x1f * br_bit1 + 0x43 * bit0 + 0x8f * bit1;
293294
294295      palette_set_color(machine, i, MAKE_RGB(r, g, b));
r6740r6741
360361ROM_END
361362
362363
363GAME( 19??, carrera, 0, carrera, carrera,0, ROT0, "BS Electronics", "Carrera (Version 6.7)", GAME_WRONG_COLORS )
364GAME( 19??, carrera, 0, carrera, carrera,0, ROT0, "BS Electronics", "Carrera (Version 6.7)", 0 )
364365
src/mame/drivers/ultraman.c
r6740r6741
1212#include "driver.h"
1313#include "cpu/z80/z80.h"
1414#include "cpu/m68000/m68000.h"
15#include "video/konamiic.h"
15#include "video/konicdev.h"
1616#include "sound/2151intf.h"
1717#include "sound/okim6295.h"
1818
r6740r6741
2222VIDEO_START( ultraman );
2323VIDEO_UPDATE( ultraman );
2424
25extern void ultraman_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow);
26extern void ultraman_zoom_callback_0(running_machine *machine, int *code,int *color,int *flags);
27extern void ultraman_zoom_callback_1(running_machine *machine, int *code,int *color,int *flags);
28extern void ultraman_zoom_callback_2(running_machine *machine, int *code,int *color,int *flags);
2529
2630
27static READ16_HANDLER( ultraman_K051937_r )
28{
29   return K051937_r(space, offset);
30}
31
32static READ16_HANDLER( ultraman_K051960_r )
33{
34   return K051960_r(space, offset);
35}
36
37static READ16_HANDLER( ultraman_K051316_0_r )
38{
39   return K051316_0_r(space, offset);
40}
41
42static READ16_HANDLER( ultraman_K051316_1_r )
43{
44   return K051316_1_r(space, offset);
45}
46
47static READ16_HANDLER( ultraman_K051316_2_r )
48{
49   return K051316_2_r(space, offset);
50}
51
52static WRITE16_HANDLER( ultraman_K051316_0_w )
53{
54   if (ACCESSING_BITS_0_7)
55      K051316_0_w(space, offset, data & 0xff);
56}
57
58static WRITE16_HANDLER( ultraman_K051316_1_w )
59{
60   if (ACCESSING_BITS_0_7)
61      K051316_1_w(space, offset, data & 0xff);
62}
63
64static WRITE16_HANDLER( ultraman_K051316_2_w )
65{
66   if (ACCESSING_BITS_0_7)
67      K051316_2_w(space, offset, data & 0xff);
68}
69
70static WRITE16_HANDLER( ultraman_K051316_ctrl_0_w )
71{
72   if (ACCESSING_BITS_0_7)
73      K051316_ctrl_0_w(space, offset, data & 0xff);
74}
75
76static WRITE16_HANDLER( ultraman_K051316_ctrl_1_w )
77{
78   if (ACCESSING_BITS_0_7)
79      K051316_ctrl_1_w(space, offset, data & 0xff);
80
81}
82
83static WRITE16_HANDLER( ultraman_K051316_ctrl_2_w )
84{
85   if (ACCESSING_BITS_0_7)
86      K051316_ctrl_2_w(space, offset, data & 0xff);
87}
88
89static WRITE16_HANDLER( ultraman_K051937_w )
90{
91   if (ACCESSING_BITS_0_7)
92      K051937_w(space, offset, data & 0xff);
93}
94
95static WRITE16_HANDLER( ultraman_K051960_w )
96{
97   if (ACCESSING_BITS_0_7)
98      K051960_w(space, offset, data & 0xff);
99}
100
10131static WRITE16_HANDLER( sound_cmd_w )
10232{
10333   if (ACCESSING_BITS_0_7)
r6740r6741
11141}
11242
11343
114
11544static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 )
11645   AM_RANGE(0x000000, 0x03ffff) AM_ROM
11746   AM_RANGE(0x080000, 0x08ffff) AM_RAM
r6740r6741
12554   AM_RANGE(0x1c0020, 0x1c0021) AM_WRITE(sound_cmd_w)
12655   AM_RANGE(0x1c0028, 0x1c0029) AM_WRITE(sound_irq_trigger_w)
12756   AM_RANGE(0x1c0030, 0x1c0031) AM_WRITE(watchdog_reset16_w)
128   AM_RANGE(0x204000, 0x204fff) AM_READWRITE(ultraman_K051316_0_r, ultraman_K051316_0_w)   /* K051316 #0 RAM */
129   AM_RANGE(0x205000, 0x205fff) AM_READWRITE(ultraman_K051316_1_r, ultraman_K051316_1_w)   /* K051316 #1 RAM */
130   AM_RANGE(0x206000, 0x206fff) AM_READWRITE(ultraman_K051316_2_r, ultraman_K051316_2_w)   /* K051316 #2 RAM */
131   AM_RANGE(0x207f80, 0x207f9f) AM_WRITE(ultraman_K051316_ctrl_0_w   )   /* K051316 #0 registers */
132   AM_RANGE(0x207fa0, 0x207fbf) AM_WRITE(ultraman_K051316_ctrl_1_w   )   /* K051316 #1 registers */
133   AM_RANGE(0x207fc0, 0x207fdf) AM_WRITE(ultraman_K051316_ctrl_2_w   )   /* K051316 #2 registers */
134   AM_RANGE(0x304000, 0x30400f) AM_READWRITE(ultraman_K051937_r, ultraman_K051937_w)      /* Sprite control */
135   AM_RANGE(0x304800, 0x304fff) AM_READWRITE(ultraman_K051960_r, ultraman_K051960_w)      /* Sprite RAM */
57   AM_RANGE(0x204000, 0x204fff) AM_DEVREADWRITE8("k051316_1", k051316_r, k051316_w, 0x00ff)   /* K051316 #0 RAM */
58   AM_RANGE(0x205000, 0x205fff) AM_DEVREADWRITE8("k051316_2", k051316_r, k051316_w, 0x00ff)   /* K051316 #1 RAM */
59   AM_RANGE(0x206000, 0x206fff) AM_DEVREADWRITE8("k051316_3", k051316_r, k051316_w, 0x00ff)   /* K051316 #2 RAM */
60   AM_RANGE(0x207f80, 0x207f9f) AM_DEVWRITE8("k051316_1", k051316_ctrl_w, 0x00ff)   /* K051316 #0 registers */
61   AM_RANGE(0x207fa0, 0x207fbf) AM_DEVWRITE8("k051316_2", k051316_ctrl_w, 0x00ff)   /* K051316 #1 registers */
62   AM_RANGE(0x207fc0, 0x207fdf) AM_DEVWRITE8("k051316_3", k051316_ctrl_w, 0x00ff)   /* K051316 #2 registers */
63   AM_RANGE(0x304000, 0x30400f) AM_DEVREADWRITE8("k051960", k051937_r, k051937_w, 0x00ff)      /* Sprite control */
64   AM_RANGE(0x304800, 0x304fff) AM_DEVREADWRITE8("k051960", k051960_r, k051960_w, 0x00ff)      /* Sprite RAM */
13665ADDRESS_MAP_END
13766
13867static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
r6740r6741
239168INPUT_PORTS_END
240169
241170
171static const k051960_interface ultraman_k051960_intf =
172{
173   "gfx1", 0,
174   NORMAL_PLANE_ORDER,
175   KONAMI_ROM_DEINTERLEAVE_2,
176   ultraman_sprite_callback
177};
242178
179static const k051316_interface ultraman_k051316_intf_0 =
180{
181   "gfx2", 1,
182   4, FALSE, 0,
183   0, 8, 0,
184   ultraman_zoom_callback_0
185};
243186
187static const k051316_interface ultraman_k051316_intf_1 =
188{
189   "gfx3", 2,
190   4, FALSE, 0,
191   0, 8, 0,
192   ultraman_zoom_callback_1
193};
194
195static const k051316_interface ultraman_k051316_intf_2 =
196{
197   "gfx4", 3,
198   4, TRUE, 0,
199   0, 8, 0,
200   ultraman_zoom_callback_2
201};
202
244203static MACHINE_DRIVER_START( ultraman )
245204
246205   /* basic machine hardware */
r6740r6741
269228   MDRV_VIDEO_START(ultraman)
270229   MDRV_VIDEO_UPDATE(ultraman)
271230
231   MDRV_K051960_ADD("k051960", ultraman_k051960_intf)
232   MDRV_K051316_ADD("k051316_1", ultraman_k051316_intf_0)
233   MDRV_K051316_ADD("k051316_2", ultraman_k051316_intf_1)
234   MDRV_K051316_ADD("k051316_3", ultraman_k051316_intf_2)
235
272236   /* sound hardware */
273237   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
274238
r6740r6741
322286ROM_END
323287
324288
325
326static DRIVER_INIT( ultraman )
327{
328   konami_rom_deinterleave_2(machine, "gfx1");
329}
330
331
332GAME( 1991, ultraman, 0, ultraman, ultraman, ultraman, ROT0, "Banpresto/Bandai", "Ultraman (Japan)", 0 )
289GAME( 1991, ultraman, 0, ultraman, ultraman, 0, ROT0, "Banpresto/Bandai", "Ultraman (Japan)", 0 )
src/mame/drivers/blueprnt.c
r6740r6741
5656#include "deprecat.h"
5757#include "cpu/z80/z80.h"
5858#include "sound/ay8910.h"
59#include "blueprnt.h"
59#include "includes/blueprnt.h"
6060
6161/*************************************
6262 *
src/mame/drivers/taito_f2.c
r6740r6741
294294
295295#include "driver.h"
296296#include "cpu/z80/z80.h"
297#include "taitoipt.h"
297#include "includes/taitoipt.h"
298298#include "cpu/m68000/m68000.h"
299299#include "video/taitoic.h"
300300#include "audio/taitosnd.h"
301#include "taito_f2.h"
301#include "includes/taito_f2.h"
302302#include "sound/2203intf.h"
303303#include "sound/2610intf.h"
304304#include "sound/okim6295.h"
src/mame/drivers/pandoras.c
r6740r6741
2727#include "cpu/mcs48/mcs48.h"
2828#include "sound/ay8910.h"
2929#include "sound/dac.h"
30#include "konamipt.h"
31#include "pandoras.h"
30#include "includes/konamipt.h"
31#include "includes/pandoras.h"
3232
3333
3434#define MASTER_CLOCK      XTAL_18_432MHz
35#define SOUND_CLOCK         XTAL_14_31818MHz
3536
3637
3738static INTERRUPT_GEN( pandoras_master_interrupt )
r6740r6741
362363   MDRV_CPU_PROGRAM_MAP(pandoras_slave_map)
363364   MDRV_CPU_VBLANK_INT("screen", pandoras_slave_interrupt)
364365
365   MDRV_CPU_ADD("audiocpu", Z80, MASTER_CLOCK/8)
366   MDRV_CPU_ADD("audiocpu", Z80, SOUND_CLOCK/8)
366367   MDRV_CPU_PROGRAM_MAP(pandoras_sound_map)
367368
368   MDRV_CPU_ADD("mcu", I8039, MASTER_CLOCK/2)
369   MDRV_CPU_ADD("mcu", I8039, SOUND_CLOCK/2)
369370   MDRV_CPU_PROGRAM_MAP(pandoras_i8039_map)
370371   MDRV_CPU_IO_MAP(pandoras_i8039_io_map)
371372
r6740r6741
392393   /* sound hardware */
393394   MDRV_SPEAKER_STANDARD_MONO("mono")
394395
395   MDRV_SOUND_ADD("aysnd", AY8910, MASTER_CLOCK/8)
396   MDRV_SOUND_ADD("aysnd", AY8910, SOUND_CLOCK/8)
396397   MDRV_SOUND_CONFIG(ay8910_config)
397398   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
398399
src/mame/drivers/gottlieb.c
r6740r6741
202202#include "sound/samples.h"
203203#include "sound/sp0250.h"
204204#include "streams.h"
205#include "gottlieb.h"
205#include "includes/gottlieb.h"
206206
207207
208208#define LOG_AUDIO_DECODE   (0)
src/mame/drivers/ddragon.c
r6740r6741
7777#include "sound/2151intf.h"
7878#include "sound/okim6295.h"
7979#include "sound/msm5205.h"
80#include "ddragon.h"
80#include "includes/ddragon.h"
8181
8282
8383#define MAIN_CLOCK      XTAL_12MHz
src/mame/drivers/asterix.c
r6740r6741
1111
1212#include "driver.h"
1313#include "cpu/m68000/m68000.h"
14#include "video/konamiic.h"
1514#include "cpu/z80/z80.h"
16#include "machine/eeprom.h"
15#include "machine/eepromdev.h"
1716#include "sound/2151intf.h"
1817#include "sound/k053260.h"
19#include "konamipt.h"
18#include "video/konicdev.h"
19#include "includes/konamipt.h"
2020
21VIDEO_START( asterix );
2221VIDEO_UPDATE( asterix );
2322WRITE16_HANDLER( asterix_spritebank_w );
2423
24extern void asterix_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags);
25extern void asterix_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask);
26
2527static UINT8 cur_control2;
26static int init_eeprom_count;
2728
2829static const eeprom_interface eeprom_intf =
2930{
r6740r6741
3637   "1100110000000" /* unlock command */
3738};
3839
39static NVRAM_HANDLER( asterix )
40{
41   if (read_or_write)
42      eeprom_save(file);
43   else
44   {
45      eeprom_init(machine, &eeprom_intf);
46
47      if (file)
48      {
49         init_eeprom_count = 0;
50         eeprom_load(file);
51      }
52      else
53         init_eeprom_count = 10;
54   }
55}
56
57static READ16_HANDLER( control1_r )
58{
59   int res;
60
61   /* bit 8  is EEPROM data */
62   /* bit 9  is EEPROM ready */
63   /* bit 10 is service button */
64   res = input_port_read(space->machine, "IN1");
65
66   if (init_eeprom_count)
67   {
68      init_eeprom_count--;
69      res &= 0xfbff;
70   }
71
72   return res;
73}
74
75
76
7740#if 0
7841static READ16_HANDLER( control2_r )
7942{
r6740r6741
8346
8447static WRITE16_HANDLER( control2_w )
8548{
49   const device_config *k056832 = devtag_get_device(space->machine, "k056832");
50
8651   if (ACCESSING_BITS_0_7)
8752   {
8853      cur_control2 = data;
8954      /* bit 0 is data */
9055      /* bit 1 is cs (active low) */
9156      /* bit 2 is clock (active high) */
57      input_port_write(space->machine, "EEPROMOUT", data, 0xff);
9258
93      eeprom_write_bit(data & 0x01);
94      eeprom_set_cs_line((data & 0x02) ? CLEAR_LINE : ASSERT_LINE);
95      eeprom_set_clock_line((data & 0x04) ? ASSERT_LINE : CLEAR_LINE);
96
9759      /* bit 5 is select tile bank */
98      K056832_set_tile_bank((data & 0x20) >> 5);
60      k056832_set_tile_bank(k056832, (data & 0x20) >> 5);
9961   }
10062}
10163
10264static INTERRUPT_GEN( asterix_interrupt )
10365{
66   const device_config *k056832 = devtag_get_device(device->machine, "k056832");
67
10468   // global interrupt masking
105   if (!K056832_is_IRQ_enabled(0)) return;
69   if (!k056832_is_irq_enabled(k056832, 0)) return;
10670
10771   cpu_set_input_line(device, 5, HOLD_LINE); /* ??? All irqs have the same vector, and the
10872                                              mask used is 0 or 7 */
r6740r6741
179143static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 )
180144   AM_RANGE(0x000000, 0x0fffff) AM_ROM
181145   AM_RANGE(0x100000, 0x107fff) AM_RAM
182   AM_RANGE(0x180000, 0x1807ff) AM_READWRITE(K053245_word_r, K053245_word_w)
146   AM_RANGE(0x180000, 0x1807ff) AM_DEVREADWRITE("k053244", k053245_word_r, k053245_word_w)
183147   AM_RANGE(0x180800, 0x180fff) AM_RAM                        // extra RAM, or mirror for the above?
184   AM_RANGE(0x200000, 0x20000f) AM_READWRITE(K053244_word_r, K053244_word_w)
148   AM_RANGE(0x200000, 0x20000f) AM_DEVREADWRITE("k053244", k053244_word_r, k053244_word_w)
185149   AM_RANGE(0x280000, 0x280fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
186   AM_RANGE(0x300000, 0x30001f) AM_READWRITE(K053244_lsb_r, K053244_lsb_w)
150   AM_RANGE(0x300000, 0x30001f) AM_DEVREADWRITE("k053244", k053244_lsb_r, k053244_lsb_w)
187151   AM_RANGE(0x380000, 0x380001) AM_READ_PORT("IN0")
188   AM_RANGE(0x380002, 0x380003) AM_READ(control1_r)
152   AM_RANGE(0x380002, 0x380003) AM_READ_PORT("IN1")
189153   AM_RANGE(0x380100, 0x380101) AM_WRITE(control2_w)
190154   AM_RANGE(0x380200, 0x380203) AM_DEVREADWRITE8("konami", asterix_sound_r, k053260_w, 0x00ff)
191155   AM_RANGE(0x380300, 0x380301) AM_WRITE(sound_irq_w)
192156   AM_RANGE(0x380400, 0x380401) AM_WRITE(asterix_spritebank_w)
193   AM_RANGE(0x380500, 0x38051f) AM_WRITE(K053251_lsb_w)
157   AM_RANGE(0x380500, 0x38051f) AM_DEVWRITE("k053251", k053251_lsb_w)
194158   AM_RANGE(0x380600, 0x380601) AM_NOP                        // Watchdog
195   AM_RANGE(0x380700, 0x380707) AM_WRITE(K056832_b_word_w)
159   AM_RANGE(0x380700, 0x380707) AM_DEVWRITE("k056832", k056832_b_word_w)
196160   AM_RANGE(0x380800, 0x380803) AM_WRITE(protection_w)
197   AM_RANGE(0x400000, 0x400fff) AM_READWRITE(K056832_ram_half_word_r, K056832_ram_half_word_w)
198   AM_RANGE(0x420000, 0x421fff) AM_READ(K056832_old_rom_word_r)   // Passthrough to tile roms
199   AM_RANGE(0x440000, 0x44003f) AM_WRITE(K056832_word_w)
161   AM_RANGE(0x400000, 0x400fff) AM_DEVREADWRITE("k056832", k056832_ram_half_word_r, k056832_ram_half_word_w)
162   AM_RANGE(0x420000, 0x421fff) AM_DEVREAD("k056832", k056832_old_rom_word_r)   // Passthrough to tile roms
163   AM_RANGE(0x440000, 0x44003f) AM_DEVWRITE("k056832", k056832_word_w)
200164ADDRESS_MAP_END
201165
202166static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
r6740r6741
220184
221185   PORT_START("IN1")
222186   KONAMI16_LSB(2, IPT_UNKNOWN, IPT_START2)
223   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   // EEPROM data
187   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
224188   PORT_BIT( 0x0200, IP_ACTIVE_LOW,  IPT_UNUSED )   // EEPROM ready (always 1)
225189   PORT_SERVICE_NO_TOGGLE(0x0400, IP_ACTIVE_LOW )
226190   PORT_BIT( 0xf800, IP_ACTIVE_HIGH, IPT_UNKNOWN )
191
192   PORT_START( "EEPROMOUT" )
193   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
194   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
195   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
227196INPUT_PORTS_END
228197
198
199static const k056832_interface asterix_k056832_intf =
200{
201   "gfx1", 0,
202   K056832_BPP_4,
203   1, 1,
204   KONAMI_ROM_DEINTERLEAVE_2,
205   asterix_tile_callback, "none"
206};
207
208static const k05324x_interface asterix_k05324x_intf =
209{
210   "gfx2", 1,
211   NORMAL_PLANE_ORDER,
212   -3, -1,
213   KONAMI_ROM_DEINTERLEAVE_2,
214   asterix_sprite_callback
215};
216
229217static MACHINE_DRIVER_START( asterix )
230218
231219   /* basic machine hardware */
r6740r6741
236224   MDRV_CPU_ADD("audiocpu", Z80, 8000000)
237225   MDRV_CPU_PROGRAM_MAP(sound_map)
238226
239   MDRV_NVRAM_HANDLER(asterix)
227   MDRV_EEPROM_NODEFAULT_ADD("eeprom", eeprom_intf)
240228
241229   /* video hardware */
242230   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS)
r6740r6741
249237   MDRV_SCREEN_VISIBLE_AREA(14*8, (64-14)*8-1, 2*8, 30*8-1 )
250238   MDRV_PALETTE_LENGTH(2048)
251239
252   MDRV_VIDEO_START(asterix)
253240   MDRV_VIDEO_UPDATE(asterix)
254241
242   MDRV_K056832_ADD("k056832", asterix_k056832_intf)
243   MDRV_K053244_ADD("k053244", asterix_k05324x_intf)
244   MDRV_K053251_ADD("k053251")
245
255246   /* sound hardware */
256247   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
257248
r6740r6741
356347
357348static DRIVER_INIT( asterix )
358349{
359   konami_rom_deinterleave_2(machine, "gfx1");
360   konami_rom_deinterleave_2(machine, "gfx2");
361
362350#if 0
363351   *(UINT16 *)(memory_region(machine, "maincpu") + 0x07f34) = 0x602a;
364352   *(UINT16 *)(memory_region(machine, "maincpu") + 0x00008) = 0x0400;
src/mame/drivers/goldnpkr.c
r6740r6741
630630*     Video Hardware     *
631631*************************/
632632
633static UINT8 *videoram;
634static UINT8 *colorram;
633635static tilemap *bg_tilemap;
634636
635637static WRITE8_HANDLER( goldnpkr_videoram_w )
636638{
637   space->machine->generic.videoram.u8[offset] = data;
639   videoram[offset] = data;
638640   tilemap_mark_tile_dirty(bg_tilemap, offset);
639641}
640642
641643static WRITE8_HANDLER( goldnpkr_colorram_w )
642644{
643   space->machine->generic.colorram.u8[offset] = data;
645   colorram[offset] = data;
644646   tilemap_mark_tile_dirty(bg_tilemap, offset);
645647}
646648
r6740r6741
654656    xx-- ----   unused.
655657*/
656658
657   int attr = machine->generic.colorram.u8[tile_index];
658   int code = ((attr & 1) << 8) | machine->generic.videoram.u8[tile_index];
659   int attr = colorram[tile_index];
660   int code = ((attr & 1) << 8) | videoram[tile_index];
659661   int bank = (attr & 0x02) >> 1;   /* bit 1 switch the gfx banks */
660662    int color = (attr & 0x3c) >> 2;   /* bits 2-3-4-5 for color */
661663
r6740r6741
898900   AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
899901   AM_RANGE(0x0844, 0x0847) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
900902   AM_RANGE(0x0848, 0x084b) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
901   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE_GENERIC(videoram)
902   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE_GENERIC(colorram)
903   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE(&videoram)
904   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE(&colorram)
903905   AM_RANGE(0x4000, 0x7fff) AM_ROM
904906ADDRESS_MAP_END
905907
r6740r6741
910912   AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
911913   AM_RANGE(0x0844, 0x0847) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
912914   AM_RANGE(0x0848, 0x084b) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
913   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE_GENERIC(videoram)
914   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE_GENERIC(colorram)
915   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE(&videoram)
916   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE(&colorram)
915917   AM_RANGE(0x2000, 0x3fff) AM_ROM
916918ADDRESS_MAP_END
917919
r6740r6741
922924   AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
923925   AM_RANGE(0x0844, 0x0847) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
924926   AM_RANGE(0x0848, 0x084b) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
925   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE_GENERIC(videoram)
926   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE_GENERIC(colorram)
927   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(goldnpkr_videoram_w) AM_BASE(&videoram)
928   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(goldnpkr_colorram_w) AM_BASE(&colorram)
927929   AM_RANGE(0x2000, 0x2000) AM_READ_PORT("SW2")
928930//  AM_RANGE(0x2108, 0x210b) AM_NOP /* unknown 40-pin device */
929931   AM_RANGE(0x4000, 0x7fff) AM_ROM
src/mame/drivers/hyhoo.c
r6740r6741
2323
2424#include "driver.h"
2525#include "cpu/z80/z80.h"
26#include "nb1413m3.h"
26#include "includes/nb1413m3.h"
2727#include "sound/ay8910.h"
2828#include "sound/dac.h"
2929
src/mame/drivers/moo.c
r6740r6741
4242***************************************************************************/
4343
4444#include "driver.h"
45#include "video/konamiic.h"
4645#include "cpu/m68000/m68000.h"
4746#include "cpu/z80/z80.h"
48#include "machine/eeprom.h"
47#include "machine/eepromdev.h"
4948#include "sound/2151intf.h"
5049#include "sound/okim6295.h"
5150#include "sound/k054539.h"
52#include "konamipt.h"
51#include "video/konicdev.h"
52#include "includes/konamipt.h"
5353
5454VIDEO_START(moo);
5555VIDEO_UPDATE(moo);
5656
57static int init_eeprom_count, init_nosound_count, game_type;
57static int init_nosound_count, game_type;
5858static UINT16 *workram;
5959static UINT16 protram[16];
6060static UINT16 cur_control2;
6161
62extern void moo_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags);
63extern void moo_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask);
6264
65
6366static const eeprom_interface eeprom_intf =
6467{
6568   7,         /* address bits */
r6740r6741
7174   "0100110000000"    /* unlock command */
7275};
7376
74static NVRAM_HANDLER( moo )
75{
76   if (read_or_write)
77      eeprom_save(file);
78   else
79   {
80      eeprom_init(machine, &eeprom_intf);
81
82      if (file)
83      {
84         init_eeprom_count = 0;
85         eeprom_load(file);
86      }
87      else
88         init_eeprom_count = 10;
89   }
90}
91
92static READ16_HANDLER( control1_r )
93{
94   int res;
95
96   /* bit 0 is EEPROM data */
97   /* bit 1 is EEPROM ready */
98   /* bit 3 is service button */
99   /* bits 4-7 are DIP switches */
100   res = input_port_read(space->machine, "IN1");
101
102   if (init_eeprom_count)
103   {
104      init_eeprom_count--;
105      res &= 0xf7;
106   }
107
108   return res;
109}
110
11177static READ16_HANDLER( control2_r )
11278{
11379   return cur_control2;
r6740r6741
12389   /* bit 10 is watchdog */
12490   /* bit 11 is enable irq 4 (unconfirmed) */
12591
92   const device_config *k053246 = devtag_get_device(space->machine, "k053246");
93
12694   COMBINE_DATA(&cur_control2);
12795
128   eeprom_write_bit(cur_control2 & 0x01);
129   eeprom_set_cs_line((cur_control2 & 0x02) ? CLEAR_LINE : ASSERT_LINE);
130   eeprom_set_clock_line((cur_control2 & 0x04) ? ASSERT_LINE : CLEAR_LINE);
96   input_port_write(space->machine, "EEPROMOUT", cur_control2, 0xff);
13197
13298   if (data & 0x100)
133   {
134      K053246_set_OBJCHA_line(ASSERT_LINE);
135   }
99      k053246_set_objcha_line(k053246, ASSERT_LINE);
136100   else
137   {
138      K053246_set_OBJCHA_line(CLEAR_LINE);
139   }
101      k053246_set_objcha_line(k053246, CLEAR_LINE);
140102}
141103
142104
143105static void moo_objdma(running_machine *machine, int type)
144106{
145   int counter, num_inactive;
107   int num_inactive;
146108   UINT16 *src, *dst, zmask;
109   const device_config *k053246 = devtag_get_device(machine, "k053246");
110   int counter = k053247_get_dy(k053246);
147111
148   K053247_export_config(&dst, 0, 0, 0, &counter);
112   k053247_get_ram(k053246, &dst);
149113   src = machine->generic.spriteram.u16;
150114   num_inactive = counter = 256;
151115
r6740r6741
173137
174138static INTERRUPT_GEN(moo_interrupt)
175139{
176   if (K053246_is_IRQ_enabled())
140   const device_config *k053246 = devtag_get_device(device->machine, "k053246");
141
142   if (k053246_is_irq_enabled(k053246))
177143   {
178144      moo_objdma(device->machine, game_type);
179145
r6740r6741
234200/* of RAM, but they put 0x10000 there. The CPU can access them all. */
235201static READ16_HANDLER( K053247_scattered_word_r )
236202{
203   const device_config *k053246 = devtag_get_device(device->machine, "k053246");
204
237205   if (offset & 0x0078)
238206      return space->machine->generic.spriteram.u16[offset];
239207   else
240208   {
241209      offset = (offset & 0x0007) | ((offset & 0x7f80) >> 4);
242      return K053247_word_r(space,offset,mem_mask);
210      return k053247_word_r(k053246, offset, mem_mask);
243211   }
244212}
245213
246214static WRITE16_HANDLER( K053247_scattered_word_w )
247215{
216   const device_config *k053246 = devtag_get_device(device->machine, "k053246");
217
248218   if (offset & 0x0078)
249219      COMBINE_DATA(space->machine->generic.spriteram.u16+offset);
250220   else
251221   {
252222      offset = (offset & 0x0007) | ((offset & 0x7f80) >> 4);
253223
254      K053247_word_w(space,offset,data,mem_mask);
224      k053247_word_w(k053246, offset, data, mem_mask);
255225   }
256226}
257227
r6740r6741
297267
298268static ADDRESS_MAP_START( moo_map, ADDRESS_SPACE_PROGRAM, 16 )
299269   AM_RANGE(0x000000, 0x07ffff) AM_ROM
300   AM_RANGE(0x0c0000, 0x0c003f) AM_WRITE(K056832_word_w)
301   AM_RANGE(0x0c2000, 0x0c2007) AM_WRITE(K053246_word_w)
270   AM_RANGE(0x0c0000, 0x0c003f) AM_DEVWRITE("k056832", k056832_word_w)
271   AM_RANGE(0x0c2000, 0x0c2007) AM_DEVWRITE("k053246", k053246_word_w)
302272
303   AM_RANGE(0x0c4000, 0x0c4001) AM_READ(K053246_word_r)
304   AM_RANGE(0x0ca000, 0x0ca01f) AM_WRITE(K054338_word_w)      /* K054338 alpha blending engine */
305   AM_RANGE(0x0cc000, 0x0cc01f) AM_WRITE(K053251_lsb_w)
273   AM_RANGE(0x0c4000, 0x0c4001) AM_DEVREAD("k053246", k053246_word_r)
274   AM_RANGE(0x0ca000, 0x0ca01f) AM_DEVWRITE("k054338", k054338_word_w)      /* K054338 alpha blending engine */
275   AM_RANGE(0x0cc000, 0x0cc01f) AM_DEVWRITE("k053251", k053251_lsb_w)
306276   AM_RANGE(0x0ce000, 0x0ce01f) AM_WRITE(moo_prot_w)
307277   AM_RANGE(0x0d0000, 0x0d001f) AM_WRITEONLY               /* CCU regs (ignored) */
308278   AM_RANGE(0x0d4000, 0x0d4001) AM_WRITE(sound_irq_w)
r6740r6741
310280   AM_RANGE(0x0d600e, 0x0d600f) AM_WRITE(sound_cmd2_w)
311281   AM_RANGE(0x0d6014, 0x0d6015) AM_READ(sound_status_r)
312282   AM_RANGE(0x0d6000, 0x0d601f) AM_RAM                     /* sound regs fall through */
313   AM_RANGE(0x0d8000, 0x0d8007) AM_WRITE(K056832_b_word_w)      /* VSCCS regs */
283   AM_RANGE(0x0d8000, 0x0d8007) AM_DEVWRITE("k056832", k056832_b_word_w)      /* VSCCS regs */
314284   AM_RANGE(0x0da000, 0x0da001) AM_READ_PORT("P1_P3")
315285   AM_RANGE(0x0da002, 0x0da003) AM_READ_PORT("P2_P4")
316286   AM_RANGE(0x0dc000, 0x0dc001) AM_READ_PORT("IN0")
317   AM_RANGE(0x0dc002, 0x0dc003) AM_READ(control1_r)
318   AM_RANGE(0x0de000, 0x0de001) AM_READWRITE(control2_r,control2_w)
287   AM_RANGE(0x0dc002, 0x0dc003) AM_READ_PORT("IN1")
288   AM_RANGE(0x0de000, 0x0de001) AM_READWRITE(control2_r, control2_w)
319289   AM_RANGE(0x100000, 0x17ffff) AM_ROM
320290   AM_RANGE(0x180000, 0x18ffff) AM_RAM   AM_BASE(&workram)      /* Work RAM */
321291   AM_RANGE(0x190000, 0x19ffff) AM_RAM AM_BASE_GENERIC(spriteram)   /* Sprite RAM */
322   AM_RANGE(0x1a0000, 0x1a1fff) AM_READWRITE(K056832_ram_word_r,K056832_ram_word_w)   /* Graphic planes */
323   AM_RANGE(0x1a2000, 0x1a3fff) AM_READWRITE(K056832_ram_word_r,K056832_ram_word_w)   /* Graphic planes mirror */
324   AM_RANGE(0x1b0000, 0x1b1fff) AM_READ(K056832_rom_word_r)   /* Passthrough to tile roms */
292   AM_RANGE(0x1a0000, 0x1a1fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w)   /* Graphic planes */
293   AM_RANGE(0x1a2000, 0x1a3fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w)   /* Graphic planes mirror */
294   AM_RANGE(0x1b0000, 0x1b1fff) AM_DEVREAD("k056832", k056832_rom_word_r)   /* Passthrough to tile roms */
325295   AM_RANGE(0x1c0000, 0x1c1fff) AM_RAM_WRITE(paletteram16_xrgb_word_be_w) AM_BASE_GENERIC(paletteram)
326296#if MOO_DEBUG
327   AM_RANGE(0x0c0000, 0x0c003f) AM_READ(K056832_word_r)
328   AM_RANGE(0x0c2000, 0x0c2007) AM_READ(K053246_reg_word_r)
329   AM_RANGE(0x0ca000, 0x0ca01f) AM_READ(K054338_word_r)
330   AM_RANGE(0x0cc000, 0x0cc01f) AM_READ(K053251_lsb_r)
297   AM_RANGE(0x0c0000, 0x0c003f) AM_DEVREAD("k056832", k056832_word_r)
298   AM_RANGE(0x0c2000, 0x0c2007) AM_DEVREAD("k053246", k053246_reg_word_r)
299   AM_RANGE(0x0ca000, 0x0ca01f) AM_DEVREAD("k054338", k054338_word_r)
300   AM_RANGE(0x0cc000, 0x0cc01f) AM_DEVREAD("k053251", k053251_lsb_r)
331301   AM_RANGE(0x0d0000, 0x0d001f) AM_RAM
332   AM_RANGE(0x0d8000, 0x0d8007) AM_READ(K056832_b_word_r)
302   AM_RANGE(0x0d8000, 0x0d8007) AM_DEVREAD("k056832", k056832_b_word_r)
333303#endif
334304ADDRESS_MAP_END
335305
336306static ADDRESS_MAP_START( moobl_map, ADDRESS_SPACE_PROGRAM, 16 )
337307   AM_RANGE(0x000000, 0x07ffff) AM_ROM
338   AM_RANGE(0x0c0000, 0x0c003f) AM_WRITE(K056832_word_w)
339   AM_RANGE(0x0c2000, 0x0c2007) AM_WRITE(K053246_word_w)
308   AM_RANGE(0x0c0000, 0x0c003f) AM_DEVWRITE("k056832", k056832_word_w)
309   AM_RANGE(0x0c2000, 0x0c2007) AM_DEVWRITE("k053246", k053246_word_w)
340310   AM_RANGE(0x0c2f00, 0x0c2f01) AM_READNOP                  /* heck if I know, but it's polled constantly */
341   AM_RANGE(0x0c4000, 0x0c4001) AM_READ(K053246_word_r)
342   AM_RANGE(0x0ca000, 0x0ca01f) AM_WRITE(K054338_word_w)       /* K054338 alpha blending engine */
343   AM_RANGE(0x0cc000, 0x0cc01f) AM_WRITE(K053251_lsb_w)
311   AM_RANGE(0x0c4000, 0x0c4001) AM_DEVREAD("k053246", k053246_word_r)
312   AM_RANGE(0x0ca000, 0x0ca01f) AM_DEVWRITE("k054338", k054338_word_w)       /* K054338 alpha blending engine */
313   AM_RANGE(0x0cc000, 0x0cc01f) AM_DEVWRITE("k053251", k053251_lsb_w)
344314   AM_RANGE(0x0d0000, 0x0d001f) AM_WRITEONLY                  /* CCU regs (ignored) */
345315   AM_RANGE(0x0d6ffc, 0x0d6ffd) AM_DEVWRITE("oki", moobl_oki_bank_w)
346316   AM_RANGE(0x0d6ffe, 0x0d6fff) AM_DEVREADWRITE8("oki", okim6295_r,okim6295_w, 0x00ff)
347   AM_RANGE(0x0d8000, 0x0d8007) AM_WRITE(K056832_b_word_w)     /* VSCCS regs */
317   AM_RANGE(0x0d8000, 0x0d8007) AM_DEVWRITE("k056832", k056832_b_word_w)     /* VSCCS regs */
348318   AM_RANGE(0x0da000, 0x0da001) AM_READ_PORT("P1_P3")
349319   AM_RANGE(0x0da002, 0x0da003) AM_READ_PORT("P2_P4")
350320   AM_RANGE(0x0dc000, 0x0dc001) AM_READ_PORT("IN0")
351   AM_RANGE(0x0dc002, 0x0dc003) AM_READ(control1_r)
352   AM_RANGE(0x0de000, 0x0de001) AM_READWRITE(control2_r,control2_w)
321   AM_RANGE(0x0dc002, 0x0dc003) AM_READ_PORT("IN1")
322   AM_RANGE(0x0de000, 0x0de001) AM_READWRITE(control2_r, control2_w)
353323   AM_RANGE(0x100000, 0x17ffff) AM_ROM
354324   AM_RANGE(0x180000, 0x18ffff) AM_RAM AM_BASE(&workram)       /* Work RAM */
355325   AM_RANGE(0x190000, 0x19ffff) AM_RAM AM_BASE_GENERIC(spriteram)     /* Sprite RAM */
356   AM_RANGE(0x1a0000, 0x1a1fff) AM_READWRITE(K056832_ram_word_r,K056832_ram_word_w) /* Graphic planes */
357   AM_RANGE(0x1a2000, 0x1a3fff) AM_READWRITE(K056832_ram_word_r,K056832_ram_word_w)   /* Graphic planes mirror */
358   AM_RANGE(0x1b0000, 0x1b1fff) AM_READ(K056832_rom_word_r)   /* Passthrough to tile roms */
326   AM_RANGE(0x1a0000, 0x1a1fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w) /* Graphic planes */
327   AM_RANGE(0x1a2000, 0x1a3fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w)   /* Graphic planes mirror */
328   AM_RANGE(0x1b0000, 0x1b1fff) AM_DEVREAD("k056832", k056832_rom_word_r)   /* Passthrough to tile roms */
359329   AM_RANGE(0x1c0000, 0x1c1fff) AM_RAM_WRITE(paletteram16_xrgb_word_be_w) AM_BASE_GENERIC(paletteram)
360330ADDRESS_MAP_END
361331
r6740r6741
364334   AM_RANGE(0x080000, 0x08ffff) AM_RAM
365335   AM_RANGE(0x090000, 0x09ffff) AM_RAM AM_BASE_GENERIC(spriteram)   /* Sprite RAM */
366336   AM_RANGE(0x0a0000, 0x0affff) AM_RAM                     /* extra sprite RAM? */
367   AM_RANGE(0x0c0000, 0x0c003f) AM_WRITE(K056832_word_w)
368   AM_RANGE(0x0c2000, 0x0c2007) AM_WRITE(K053246_word_w)
369   AM_RANGE(0x0c4000, 0x0c4001) AM_READ(K053246_word_r)
370   AM_RANGE(0x0ca000, 0x0ca01f) AM_WRITE(K054338_word_w)      /* K054338 alpha blending engine */
371   AM_RANGE(0x0cc000, 0x0cc01f) AM_WRITE(K053251_lsb_w)
337   AM_RANGE(0x0c0000, 0x0c003f) AM_DEVWRITE("k056832", k056832_word_w)
338   AM_RANGE(0x0c2000, 0x0c2007) AM_DEVWRITE("k053246", k053246_word_w)
339   AM_RANGE(0x0c4000, 0x0c4001) AM_DEVREAD("k053246", k053246_word_r)
340   AM_RANGE(0x0ca000, 0x0ca01f) AM_DEVWRITE("k054338", k054338_word_w)      /* K054338 alpha blending engine */
341   AM_RANGE(0x0cc000, 0x0cc01f) AM_DEVWRITE("k053251", k053251_lsb_w)
372342   AM_RANGE(0x0ce000, 0x0ce01f) AM_WRITE(moo_prot_w)
373343   AM_RANGE(0x0d0000, 0x0d001f) AM_WRITEONLY               /* CCU regs (ignored) */
374   AM_RANGE(0x0d2000, 0x0d20ff) AM_READWRITE(K054000_lsb_r,K054000_lsb_w)
344   AM_RANGE(0x0d2000, 0x0d20ff) AM_DEVREADWRITE("k054000", k054000_lsb_r, k054000_lsb_w)
375345   AM_RANGE(0x0d4000, 0x0d4001) AM_WRITE(sound_irq_w)
376346   AM_RANGE(0x0d600c, 0x0d600d) AM_WRITE(sound_cmd1_w)
377347   AM_RANGE(0x0d600e, 0x0d600f) AM_WRITE(sound_cmd2_w)
378348   AM_RANGE(0x0d6014, 0x0d6015) AM_READ(sound_status_r)
379349   AM_RANGE(0x0d6000, 0x0d601f) AM_RAM                     /* sound regs fall through */
380   AM_RANGE(0x0d8000, 0x0d8007) AM_WRITE(K056832_b_word_w)      /* VSCCS regs */
350   AM_RANGE(0x0d8000, 0x0d8007) AM_DEVWRITE("k056832", k056832_b_word_w)      /* VSCCS regs */
381351   AM_RANGE(0x0da000, 0x0da001) AM_READ_PORT("P1_P3")
382352   AM_RANGE(0x0da002, 0x0da003) AM_READ_PORT("P2_P4")
383353   AM_RANGE(0x0dc000, 0x0dc001) AM_READ_PORT("IN0")
384   AM_RANGE(0x0dc002, 0x0dc003) AM_READ(control1_r)
385   AM_RANGE(0x0de000, 0x0de001) AM_READWRITE(control2_r,control2_w)
386   AM_RANGE(0x180000, 0x181fff) AM_READWRITE(K056832_ram_word_r,K056832_ram_word_w)   /* Graphic planes */
387   AM_RANGE(0x182000, 0x183fff) AM_READWRITE(K056832_ram_word_r,K056832_ram_word_w)   /* Graphic planes mirror */
354   AM_RANGE(0x0dc002, 0x0dc003) AM_READ_PORT("IN1")
355   AM_RANGE(0x0de000, 0x0de001) AM_READWRITE(control2_r, control2_w)
356   AM_RANGE(0x180000, 0x181fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w)   /* Graphic planes */
357   AM_RANGE(0x182000, 0x183fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w)   /* Graphic planes mirror */
388358   AM_RANGE(0x184000, 0x187fff) AM_RAM                     /* extra tile RAM? */
389   AM_RANGE(0x190000, 0x191fff) AM_READ(K056832_rom_word_r)   /* Passthrough to tile roms */
359   AM_RANGE(0x190000, 0x191fff) AM_DEVREAD("k056832", k056832_rom_word_r)   /* Passthrough to tile roms */
390360   AM_RANGE(0x1b0000, 0x1b3fff) AM_RAM_WRITE(paletteram16_xrgb_word_be_w) AM_BASE_GENERIC(paletteram)
391361   AM_RANGE(0x200000, 0x23ffff) AM_ROM                     /* data */
392362#if MOO_DEBUG
393   AM_RANGE(0x0c0000, 0x0c003f) AM_READ(K056832_word_r)
394   AM_RANGE(0x0c2000, 0x0c2007) AM_READ(K053246_reg_word_r)
395   AM_RANGE(0x0ca000, 0x0ca01f) AM_READ(K054338_word_r)
396   AM_RANGE(0x0cc000, 0x0cc01f) AM_READ(K053251_lsb_r)
363   AM_RANGE(0x0c0000, 0x0c003f) AM_DEVREAD("k056832", k056832_word_r)
364   AM_RANGE(0x0c2000, 0x0c2007) AM_DEVREAD("k053246", k053246_reg_word_r)
365   AM_RANGE(0x0ca000, 0x0ca01f) AM_DEVREAD("k054338", k054338_word_r)
366   AM_RANGE(0x0cc000, 0x0cc01f) AM_DEVREAD("k053251", k053251_lsb_r)
397367   AM_RANGE(0x0d0000, 0x0d001f) AM_RAM
398   AM_RANGE(0x0d8000, 0x0d8007) AM_READ(K056832_b_word_r)
368   AM_RANGE(0x0d8000, 0x0d8007) AM_DEVREAD("k056832", k056832_b_word_r)
399369#endif
400370ADDRESS_MAP_END
401371
r6740r6741
423393   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE4 )
424394
425395   PORT_START("IN1")
426   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
396   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
427397   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM ready (always 1) */
428398   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
429399   PORT_SERVICE_NO_TOGGLE(0x08, IP_ACTIVE_LOW)
r6740r6741
438408   PORT_DIPSETTING(    0x40, "3")
439409   PORT_DIPSETTING(    0x80, "4")
440410
411   PORT_START( "EEPROMOUT" )
412   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
413   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
414   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
415
441416   PORT_START("P1_P3")
442417   KONAMI16_LSB( 1, IPT_UNKNOWN, IPT_START1 )
443418   KONAMI16_MSB( 3, IPT_UNKNOWN, IPT_START3 )
r6740r6741
473448}
474449
475450
451static const k056832_interface moo_k056832_intf =
452{
453   "gfx1", 0,
454   K056832_BPP_4,
455   1, 0,
456   KONAMI_ROM_DEINTERLEAVE_2,
457   moo_tile_callback, "none"
458};
459
460static const k053247_interface moo_k053247_intf =
461{
462   "screen",
463   "gfx2", 1,
464   NORMAL_PLANE_ORDER,
465   -48+1, 23,
466   KONAMI_ROM_DEINTERLEAVE_4,
467   moo_sprite_callback
468};
469
470static const k053247_interface bucky_k053247_intf =
471{
472   "screen",
473   "gfx2", 1,
474   NORMAL_PLANE_ORDER,
475   -48, 23,
476   KONAMI_ROM_DEINTERLEAVE_4,
477   moo_sprite_callback
478};
479
480static const k054338_interface moo_k054338_intf =
481{
482   "screen",
483   0,
484   "none"
485};
486
487
476488static MACHINE_DRIVER_START( moo )
477489
478490   /* basic machine hardware */
r6740r6741
486498   MDRV_MACHINE_START(moo)
487499   MDRV_MACHINE_RESET(moo)
488500
489   MDRV_NVRAM_HANDLER(moo)
501   MDRV_EEPROM_NODEFAULT_ADD("eeprom", eeprom_intf)
490502
491503   /* video hardware */
492504   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_AFTER_VBLANK)
r6740r6741
503515   MDRV_VIDEO_START(moo)
504516   MDRV_VIDEO_UPDATE(moo)
505517
518   MDRV_K053247_ADD("k053246", moo_k053247_intf)
519   MDRV_K056832_ADD("k056832", moo_k056832_intf)
520   MDRV_K053251_ADD("k053251")
521   MDRV_K054338_ADD("k054338", moo_k054338_intf)
522
506523   /* sound hardware */
507524   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
508525
r6740r6741
524541
525542   MDRV_MACHINE_START(moo)
526543   MDRV_MACHINE_RESET(moo)
527   MDRV_NVRAM_HANDLER(moo)
528544
545   MDRV_EEPROM_NODEFAULT_ADD("eeprom", eeprom_intf)
546
529547   /* video hardware */
530548   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_AFTER_VBLANK)
531549
r6740r6741
541559   MDRV_VIDEO_START(moo)
542560   MDRV_VIDEO_UPDATE(moo)
543561
562   MDRV_K053247_ADD("k053246", moo_k053247_intf)
563   MDRV_K056832_ADD("k056832", moo_k056832_intf)
564   MDRV_K053251_ADD("k053251")
565   MDRV_K054338_ADD("k054338", moo_k054338_intf)
566
544567   /* sound hardware */
545568   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
546569
r6740r6741
556579   MDRV_CPU_MODIFY("maincpu")
557580   MDRV_CPU_PROGRAM_MAP(bucky_map)
558581
582   MDRV_K054000_ADD("k054000")
583
584   MDRV_DEVICE_REMOVE("k053246")
585   MDRV_K053247_ADD("k053246", bucky_k053247_intf)      // diff x offset
586
559587   /* video hardware */
560588   MDRV_PALETTE_LENGTH(4096)
561589MACHINE_DRIVER_END
r6740r6741
749777   ROM_LOAD( "173a10.b8",  0x000000, 0x200000, CRC(42fb0a0c) SHA1(d68c932cfabdec7896698b433525fe47ef4698d0) )
750778   ROM_LOAD( "173a11.a8",  0x200000, 0x200000, CRC(b0d747c4) SHA1(0cf1ee1b9a35ded31a81c321df2a076f7b588971) )
751779   ROM_LOAD( "173a12.b10", 0x400000, 0x200000, CRC(0fc2ad24) SHA1(6eda1043ee1266b8ba938a03a90bc7787210a936) )
752   ROM_LOAD( "173a13.a10", 0x600000, 0x200000, CRC(4cf85439) SHA1(8c298bf0e659a830a1830a1180f4ce71215ade45) )
780   ROM_LOAD(    "173a13.a10", 0x600000, 0x200000, CRC(4cf85439) SHA1(8c298bf0e659a830a1830a1180f4ce71215ade45) )
753781
754782   ROM_REGION( 0x400000, "konami", 0 )
755783   /* K054539 samples */
r6740r6741
760788
761789static DRIVER_INIT( moo )
762790{
763   konami_rom_deinterleave_2(machine, "gfx1");
764   konami_rom_deinterleave_4(machine, "gfx2");
765
766791   game_type = (!strcmp(machine->gamedrv->name, "bucky") || !strcmp(machine->gamedrv->name, "buckyua"));
767792}
768793
src/mame/drivers/taito_l.c
r6740r6741
5252
5353#include "driver.h"
5454#include "deprecat.h"
55#include "taitoipt.h"
55#include "includes/taitoipt.h"
5656#include "cpu/z80/z80.h"
5757#include "audio/taitosnd.h"
5858#include "sound/2203intf.h"
r6740r6741
136136   }
137137}
138138
139static void machine_init(running_machine *machine)
139static MACHINE_START( taito_l )
140140{
141   int i;
142
143141   taitol_rambanks = auto_alloc_array(machine, UINT8, 0x1000*12);
144142   palette_ram = auto_alloc_array(machine, UINT8, 0x1000);
145143   empty_ram = auto_alloc_array(machine, UINT8, 0x1000);
144}
146145
146static void machine_reset(running_machine *machine)
147{
148   int i;
149
147150   for(i=0;i<3;i++)
148151      irq_adr_table[i] = 0;
149152
r6740r6741
178181
179182static MACHINE_RESET( fhawk )
180183{
181   machine_init(machine);
184   machine_reset(machine);
182185   porte0_tag = NULL;
183186   porte1_tag = NULL;
184187   portf0_tag = NULL;
r6740r6741
187190
188191static MACHINE_RESET( raimais )
189192{
190   machine_init(machine);
193   machine_reset(machine);
191194   porte0_tag = NULL;
192195   porte1_tag = NULL;
193196   portf0_tag = NULL;
r6740r6741
196199
197200static MACHINE_RESET( champwr )
198201{
199   machine_init(machine);
202   machine_reset(machine);
200203   porte0_tag = NULL;
201204   porte1_tag = NULL;
202205   portf0_tag = NULL;
r6740r6741
206209
207210static MACHINE_RESET( kurikint )
208211{
209   machine_init(machine);
212   machine_reset(machine);
210213   porte0_tag = NULL;
211214   porte1_tag = NULL;
212215   portf0_tag = NULL;
r6740r6741
215218
216219static MACHINE_RESET( evilston )
217220{
218   machine_init(machine);
221   machine_reset(machine);
219222   porte0_tag = NULL;
220223   porte1_tag = NULL;
221224   portf0_tag = NULL;
r6740r6741
224227
225228static MACHINE_RESET( puzznic )
226229{
227   machine_init(machine);
230   machine_reset(machine);
228231   porte0_tag = "DSWA";
229232   porte1_tag = "DSWB";
230233   portf0_tag = "IN0";
r6740r6741
233236
234237static MACHINE_RESET( plotting )
235238{
236   machine_init(machine);
239   machine_reset(machine);
237240   porte0_tag = "DSWA";
238241   porte1_tag = "DSWB";
239242   portf0_tag = "IN0";
r6740r6741
242245
243246static MACHINE_RESET( palamed )
244247{
245   machine_init(machine);
248   machine_reset(machine);
246249   porte0_tag = "DSWA";
247250   porte1_tag = NULL;
248251   portf0_tag = "DSWB";
r6740r6741
251254
252255static MACHINE_RESET( cachat )
253256{
254   machine_init(machine);
257   machine_reset(machine);
255258   porte0_tag = "DSWA";
256259   porte1_tag = NULL;
257260   portf0_tag = "DSWB";
r6740r6741
260263
261264static MACHINE_RESET( horshoes )
262265{
263   machine_init(machine);
266   machine_reset(machine);
264267   porte0_tag = "DSWA";
265268   porte1_tag = "DSWB";
266269   portf0_tag = "IN0";
r6740r6741
19651968
19661969   MDRV_QUANTUM_TIME(HZ(6000))
19671970
1971   MDRV_MACHINE_START(taito_l)
19681972   MDRV_MACHINE_RESET(fhawk)
19691973
19701974   /* video hardware */
r6740r6741
20612065
20622066   MDRV_QUANTUM_TIME(HZ(6000))
20632067
2068   MDRV_MACHINE_START(taito_l)
20642069   MDRV_MACHINE_RESET(kurikint)
20652070
20662071   /* video hardware */
r6740r6741
21062111   MDRV_CPU_PROGRAM_MAP(plotting_map)
21072112   MDRV_CPU_VBLANK_INT_HACK(vbl_interrupt,3)
21082113
2114   MDRV_MACHINE_START(taito_l)
21092115   MDRV_MACHINE_RESET(plotting)
21102116
21112117   /* video hardware */
r6740r6741
22012207
22022208   MDRV_QUANTUM_TIME(HZ(6000))
22032209
2210   MDRV_MACHINE_START(taito_l)
22042211   MDRV_MACHINE_RESET(evilston)
22052212
22062213   /* video hardware */
src/mame/drivers/eolith16.c
r6740r6741
1414#include "deprecat.h"
1515#include "machine/eepromdev.h"
1616#include "sound/okim6295.h"
17#include "eolithsp.h"
17#include "includes/eolithsp.h"
1818
1919static UINT16 *vram;
2020static int vbuffer = 0;
src/mame/drivers/groundfx.c
r6740r6741
115115                EPROM
116116**********************************************************/
117117
118static const UINT8 default_eeprom[128]=
119{
120   0x62,0x11,0x00,0x00,0x00,0x00,0x01,0x00,0x80,0x80,0x30,0x05,0x00,0x00,0x96,0x14,
121   0x17,0x70,0x35,0xcd,0x75,0x30,0x24,0xaa,0x75,0x30,0x51,0xd9,0x75,0x30,0x2d,0x2b,
122   0x75,0x30,0x51,0xb9,0x00,0x00,0xe0,0xa0,0x17,0x70,0x35,0xcd,0x75,0x30,0x24,0xaa,
123   0x75,0x30,0x51,0xd9,0x75,0x30,0x2d,0x2b,0x75,0x30,0x51,0xb9,0x00,0x00,0xff,0xff,
124   0x17,0x70,0x35,0xcd,0x75,0x30,0x24,0xaa,0x75,0x30,0x51,0xd9,0x75,0x30,0x2d,0x2b,
125   0x75,0x30,0x51,0xb9,0xff,0xff,0xff,0xff,0x17,0x70,0x35,0xcd,0x75,0x30,0x24,0xaa,
126   0x75,0x30,0x51,0xd9,0x75,0x30,0x2d,0x2b,0x75,0x30,0x51,0xb9,0xff,0xff,0xff,0xff,
127   0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
128};
129
130118static const eeprom_interface groundfx_eeprom_interface =
131119{
132120   6,            /* address bits */
r6740r6741
353341                 MACHINE DRIVERS
354342***********************************************************/
355343
356static MACHINE_RESET( groundfx )
357{
358   taito_f3_soundsystem_reset(machine);
359   f3_68681_reset(machine);
360}
361
362344static INTERRUPT_GEN( groundfx_interrupt )
363345{
364346   frame_counter^=1;
r6740r6741
372354   MDRV_CPU_PROGRAM_MAP(groundfx_map)
373355   MDRV_CPU_VBLANK_INT("screen", groundfx_interrupt)
374356
375   TAITO_F3_SOUND_SYSTEM_CPU(16000000)
357   MDRV_EEPROM_NODEFAULT_ADD("eeprom", groundfx_eeprom_interface)
376358
377   MDRV_MACHINE_RESET(groundfx)
378//  MDRV_NVRAM_HANDLER(groundfx)
379   MDRV_EEPROM_ADD("eeprom", groundfx_eeprom_interface, 128, default_eeprom)
380
381359   /* video hardware */
382360   MDRV_SCREEN_ADD("screen", RASTER)
383361   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
393371   MDRV_VIDEO_UPDATE(groundfx)
394372
395373   /* sound hardware */
396   TAITO_F3_SOUND_SYSTEM_ES5505(30476100/2)
374   MDRV_IMPORT_FROM(taito_f3_sound)
397375MACHINE_DRIVER_END
398376
399377/***************************************************************************
r6740r6741
434412   ROM_REGION16_BE( 0x1000000, "ensoniq.0", ROMREGION_ERASE00 )
435413   ROM_LOAD16_BYTE( "d51-01.73", 0x000000, 0x200000, CRC(92f09155) SHA1(8015e1997818bb480174394eb43840bf26679bcf) )   /* Ensoniq samples */
436414   ROM_LOAD16_BYTE( "d51-02.74", 0xc00000, 0x200000, CRC(20a9428f) SHA1(c9033d02a49c72f704808f5f899101617d5814e5) )
415
416   ROM_REGION16_BE( 0x80, "eeprom", 0 )
417   ROM_LOAD( "93c46.164", 0x0000, 0x0080, CRC(6f58851d) SHA1(33bd4478f097dca6b5d222adb89699c6d35ed009) )
437418ROM_END
438419
439420
src/mame/drivers/tickee.c
r6740r6741
3838static int palette_bank;
3939static UINT8 gunx[2];
4040
41
42
4143/*************************************
4244 *
4345 *  Compute X/Y coordinates
r6740r6741
7375}
7476
7577
76
77
78
7978static TIMER_CALLBACK( clear_gun_interrupt )
8079{
8180   /* clear the IRQ on the next scanline? */
r6740r6741
108107
109108
110109
111
112110/*************************************
113111 *
114112 *  Video startup
r6740r6741
123121}
124122
125123
124
126125/*************************************
127126 *
128127 *  Video update
r6740r6741
173172   }
174173   else
175174   {
176
177175      /* copy the non-blanked portions of this scanline */
178176      for (x = params->heblnk; x < params->hsblnk; x += 2)
179177      {
r6740r6741
181179         dest[x + 0] = pens[pixels & 0xff];
182180         dest[x + 1] = pens[pixels >> 8];
183181      }
184
185182   }
186183}
187184
r6740r6741
196193{
197194   beamxadd = 50;
198195   beamyadd = 0;
199   ticket_dispenser_init(machine, 100, 0, 1);
200196   tlc34076_reset(6);
201197}
202198
r6740r6741
227223   return tickee_vram[offset];
228224}
229225
226
230227void rapidfir_to_shiftreg(const address_space *space, UINT32 address, UINT16 *shiftreg)
231228{
232229   if (address < 0x800000)
r6740r6741
240237      memcpy(&tickee_vram[TOWORD(address)], shiftreg, TOBYTE(0x2000));
241238}
242239
243/*************************************
244 *
245 *  Miscellaneous control bits
246 *
247 *************************************/
248240
249static READ8_DEVICE_HANDLER( port1_r )
250{
251   const address_space *space = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
252   return input_port_read(device->machine, "IN0") | (ticket_dispenser_0_r(space, 0) >> 5) | (ticket_dispenser_1_r(space, 0) >> 6);
253}
254241
255static READ8_DEVICE_HANDLER( port2_r )
256{
257   const address_space *space = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
258   return input_port_read(device->machine, "IN2") | (ticket_dispenser_0_r(space, 0) >> 5) | (ticket_dispenser_1_r(space, 0) >> 6);
259}
260
261
262
263242/*************************************
264243 *
265244 *  Miscellaneous control bits
r6740r6741
281260
282261   if (offset == 3)
283262   {
284      ticket_dispenser_0_w(space, 0, (data & 8) << 4);
285      ticket_dispenser_1_w(space, 0, (data & 4) << 5);
263      ticket_dispenser_w(devtag_get_device(space->machine, "ticket1"), 0, (data & 8) << 4);
264      ticket_dispenser_w(devtag_get_device(space->machine, "ticket2"), 0, (data & 4) << 5);
286265   }
287266
288267   if (olddata != tickee_control[offset])
r6740r6741
291270
292271
293272
294
295273/*************************************
296274 *
297275 *  Unknowns
r6740r6741
303281   return 0xffff;
304282}
305283
284
306285static READ16_HANDLER( rapidfir_gun1_r )
307286{
308287   return gunx[0];
r6740r6741
320299   return 0xff7f;
321300}
322301
302
323303static WRITE16_HANDLER( rapidfir_control_w )
324304{
325305   /* other bits like control on tickee? */
r6740r6741
327307      palette_bank = data & 1;
328308}
329309
310
311
330312/*************************************
331313 *
332314 *  Sound
r6740r6741
342324         break;
343325
344326      case 0x2d:
345         okim6295_set_bank_base(device, 0x50000);
327         okim6295_set_bank_base(device, 0x40000);
346328         break;
347329
348330      case 0x1c:
r6740r6741
359341   }
360342}
361343
344
345
362346/*************************************
363347 *
364348 *  Memory maps
r6740r6741
398382   AM_RANGE(0xff000000, 0xffffffff) AM_ROM AM_REGION("user1", 0)
399383ADDRESS_MAP_END
400384
385
401386/* newer hardware */
402387static ADDRESS_MAP_START( rapidfir_map, ADDRESS_SPACE_PROGRAM, 16 )
403388   AM_RANGE(0x00000000, 0x007fffff) AM_RAM AM_BASE(&tickee_vram)
r6740r6741
423408ADDRESS_MAP_END
424409
425410
411
426412/*************************************
427413 *
428414 *  Input ports
r6740r6741
455441
456442   PORT_START("IN0")
457443   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
458   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL )   /* right ticket status */
459   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL )   /* left ticket status */
444   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket2", ticket_dispenser_line_r) /* right ticket status */
445   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket1", ticket_dispenser_line_r)   /* left ticket status */
460446   PORT_BIT( 0xf8, IP_ACTIVE_LOW, IPT_UNUSED )
461447
462448   PORT_START("IN1")
r6740r6741
485471   PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(70) PORT_KEYDELTA(10) PORT_PLAYER(2)
486472INPUT_PORTS_END
487473
474
488475static INPUT_PORTS_START( ghoshunt )
489476   PORT_START("DSW")
490477   PORT_DIPNAME( 0x01, 0x01, "Messages in Play")
r6740r6741
512499
513500   PORT_START("IN0")
514501   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
515   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL )   /* right ticket status */
516   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL )   /* left ticket status */
502   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket2", ticket_dispenser_line_r)   /* right ticket status */
503   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket1", ticket_dispenser_line_r)   /* left ticket status */
517504   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
518505   PORT_BIT( 0xd8, IP_ACTIVE_LOW, IPT_UNUSED )
519506
r6740r6741
528515
529516   PORT_START("IN2")
530517   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
531   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL )   /* right ticket status */
532   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL )   /* left ticket status */
518   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket2", ticket_dispenser_line_r)   /* right ticket status */
519   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket1", ticket_dispenser_line_r)   /* left ticket status */
533520   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
534521   PORT_BIT( 0xd8, IP_ACTIVE_LOW, IPT_UNUSED )
535522
r6740r6741
546533   PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(70) PORT_KEYDELTA(10) PORT_PLAYER(2)
547534INPUT_PORTS_END
548535
536
549537static INPUT_PORTS_START( rapidfir )
550538   PORT_START("IN0")
551539   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
r6740r6741
627615{
628616   AY8910_LEGACY_OUTPUT,
629617   AY8910_DEFAULT_LOADS,
630   DEVCB_HANDLER(port1_r),
631   DEVCB_HANDLER(port2_r),
618   DEVCB_INPUT_PORT("IN0"),
619   DEVCB_INPUT_PORT("IN2"),
632620   DEVCB_NULL,
633621   DEVCB_NULL
634622};
r6740r6741
667655};
668656
669657
658
670659/*************************************
671660 *
672661 *  Machine drivers
r6740r6741
683672   MDRV_MACHINE_RESET(tickee)
684673   MDRV_NVRAM_HANDLER(generic_1fill)
685674
675   MDRV_TICKET_DISPENSER_ADD("ticket1", 100, TICKET_MOTOR_ACTIVE_LOW, TICKET_STATUS_ACTIVE_HIGH)
676   MDRV_TICKET_DISPENSER_ADD("ticket2", 100, TICKET_MOTOR_ACTIVE_LOW, TICKET_STATUS_ACTIVE_HIGH)
677
686678   /* video hardware */
687679   MDRV_VIDEO_START(tickee)
688680   MDRV_VIDEO_UPDATE(tms340x0)
r6740r6741
703695   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
704696MACHINE_DRIVER_END
705697
698
706699static MACHINE_DRIVER_START( ghoshunt )
707700   MDRV_IMPORT_FROM(tickee)
708701
r6740r6741
711704   MDRV_CPU_PROGRAM_MAP(ghoshunt_map)
712705MACHINE_DRIVER_END
713706
707
714708static MACHINE_DRIVER_START( rapidfir )
715709
716710   /* basic machine hardware */
r6740r6741
737731   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
738732MACHINE_DRIVER_END
739733
734
735
740736/*************************************
741737 *
742738 *  ROM definitions
r6740r6741
941937ROM_END
942938
943939
940
944941/*************************************
945942 *
946943 *  Game drivers
src/mame/drivers/srmp5.c
r6740r6741
3939#include "cpu/z80/z80.h"
4040#include "cpu/mips/r3000.h"
4141#include "sound/st0016.h"
42#include "st0016.h"
42#include "includes/st0016.h"
4343
4444#define DEBUG_CHAR
4545static UINT32 databank;
src/mame/drivers/m92.c
r6740r6741
195195
196196#include "driver.h"
197197#include "cpu/nec/nec.h"
198#include "m92.h"
199#include "iremipt.h"
198#include "includes/m92.h"
199#include "includes/iremipt.h"
200200#include "machine/irem_cpu.h"
201201#include "sound/2151intf.h"
202202#include "sound/iremga20.h"
src/mame/drivers/m58.c
r6740r6741
1111
1212#include "driver.h"
1313#include "cpu/z80/z80.h"
14#include "iremipt.h"
14#include "includes/iremipt.h"
1515#include "includes/iremz80.h"
1616
1717#define MASTER_CLOCK      XTAL_18_432MHz
src/mame/drivers/fcombat.c
r6740r6741
3131#include "driver.h"
3232#include "cpu/z80/z80.h"
3333#include "sound/ay8910.h"
34#include "fcombat.h"
34#include "includes/fcombat.h"
3535
3636
3737static INPUT_CHANGED( coin_inserted )
src/mame/drivers/wwfwfest.c
r6740r6741
4040#include "driver.h"
4141#include "cpu/m68000/m68000.h"
4242#include "cpu/z80/z80.h"
43#include "wwfwfest.h"
43#include "includes/wwfwfest.h"
4444#include "sound/2151intf.h"
4545#include "sound/okim6295.h"
4646
src/mame/drivers/fuukifg2.c
r6740r6741
4040#include "sound/2203intf.h"
4141#include "sound/3812intf.h"
4242#include "sound/okim6295.h"
43#include "fuukifg2.h"
43#include "includes/fuukifg2.h"
4444
4545
4646/***************************************************************************
src/mame/drivers/pkscram.c
r6740r6741
2525static UINT16* pkscramble_bgtilemap_ram;
2626
2727static tilemap *fg_tilemap, *md_tilemap, *bg_tilemap;
28static emu_timer *scanline_timer;
28static const device_config *scanline_timer;
2929
3030static WRITE16_HANDLER( pkscramble_fgtilemap_w )
3131{
r6740r6741
191191   SET_TILE_INFO(0,tile,color,0);
192192}
193193
194static TIMER_CALLBACK( scanline_callback )
194static TIMER_DEVICE_CALLBACK( scanline_callback )
195195{
196196   if (param == interrupt_scanline)
197197   {
198198       if (out & 0x2000)
199          cputag_set_input_line(machine, "maincpu", 1, ASSERT_LINE);
200      timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, param + 1, 0), param+1);
199          cputag_set_input_line(timer->machine, "maincpu", 1, ASSERT_LINE);
200      timer_device_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, param + 1, 0), param+1);
201201      interrupt_line_active = 1;
202202   }
203203   else
204204   {
205205      if (interrupt_line_active)
206          cputag_set_input_line(machine, "maincpu", 1, CLEAR_LINE);
207      timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, interrupt_scanline, 0), interrupt_scanline);
206          cputag_set_input_line(timer->machine, "maincpu", 1, CLEAR_LINE);
207      timer_device_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, interrupt_scanline, 0), interrupt_scanline);
208208      interrupt_line_active = 0;
209209   }
210210}
r6740r6741
259259   irqhandler
260260};
261261
262static MACHINE_START( pkscramble)
263{
264   state_save_register_global(machine, out);
265   state_save_register_global(machine, interrupt_line_active);
266}
267
262268static MACHINE_RESET( pkscramble)
263269{
264270   out = 0;
265271   interrupt_line_active=0;
266   scanline_timer = timer_alloc(machine, scanline_callback, NULL);
267   timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, interrupt_scanline, 0), interrupt_scanline);
268
269   state_save_register_global(machine, out);
270   state_save_register_global(machine, interrupt_line_active);
272   scanline_timer = devtag_get_device(machine, "scan_timer");
273   timer_device_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, interrupt_scanline, 0), interrupt_scanline);
271274}
272275
273276static MACHINE_DRIVER_START( pkscramble )
r6740r6741
278281
279282   MDRV_NVRAM_HANDLER(generic_0fill)
280283
284   MDRV_MACHINE_START(pkscramble)
281285   MDRV_MACHINE_RESET(pkscramble)
282286
287   MDRV_TIMER_ADD("scan_timer", scanline_callback)
288
283289   /* video hardware */
284290   MDRV_SCREEN_ADD("screen", RASTER)
285291   MDRV_SCREEN_REFRESH_RATE(60)
src/mame/drivers/mcr.c
r6740r6741
290290#include "machine/z80sio.h"
291291#include "audio/mcr.h"
292292#include "sound/samples.h"
293#include "mcr.h"
293#include "includes/mcr.h"
294294
295295
296296static UINT8 input_mux;
src/mame/drivers/matmania.c
r6740r6741
5858   AM_RANGE(0x0780, 0x07df) AM_WRITEONLY AM_BASE_SIZE_GENERIC(spriteram)
5959   AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE(&matmania_videoram2) AM_SIZE(&matmania_videoram2_size)
6060   AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE(&matmania_colorram2)
61   AM_RANGE(0x2000, 0x21ff) AM_RAM AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
62   AM_RANGE(0x2200, 0x23ff) AM_RAM AM_BASE_GENERIC(colorram)
61   AM_RANGE(0x2000, 0x21ff) AM_RAM AM_BASE(&matmania_videoram) AM_SIZE(&matmania_videoram_size)
62   AM_RANGE(0x2200, 0x23ff) AM_RAM AM_BASE(&matmania_colorram)
6363   AM_RANGE(0x2400, 0x25ff) AM_RAM AM_BASE(&matmania_videoram3) AM_SIZE(&matmania_videoram3_size)
6464   AM_RANGE(0x2600, 0x27ff) AM_RAM AM_BASE(&matmania_colorram3)
6565   AM_RANGE(0x3000, 0x3000) AM_READ_PORT("IN0") AM_WRITEONLY AM_BASE(&matmania_pageselect)
r6740r6741
7575   AM_RANGE(0x0780, 0x07df) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
7676   AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE(&matmania_videoram2) AM_SIZE(&matmania_videoram2_size)
7777   AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE(&matmania_colorram2)
78   AM_RANGE(0x2000, 0x21ff) AM_RAM AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
79   AM_RANGE(0x2200, 0x23ff) AM_RAM AM_BASE_GENERIC(colorram)
78   AM_RANGE(0x2000, 0x21ff) AM_RAM AM_BASE(&matmania_videoram) AM_SIZE(&matmania_videoram_size)
79   AM_RANGE(0x2200, 0x23ff) AM_RAM AM_BASE(&matmania_colorram)
8080   AM_RANGE(0x2400, 0x25ff) AM_RAM AM_BASE(&matmania_videoram3) AM_SIZE(&matmania_videoram3_size)
8181   AM_RANGE(0x2600, 0x27ff) AM_RAM AM_BASE(&matmania_colorram3)
8282   AM_RANGE(0x3000, 0x3000) AM_READ_PORT("IN0") AM_WRITEONLY AM_BASE(&matmania_pageselect)
src/mame/drivers/dcheese.c
r6740r6741
3434#include "machine/eepromdev.h"
3535#include "machine/ticket.h"
3636#include "sound/bsmt2000.h"
37#include "dcheese.h"
37#include "includes/dcheese.h"
3838
3939
4040#define MAIN_OSC   14318180
r6740r6741
131131   if (ACCESSING_BITS_0_7)
132132   {
133133      input_port_write(space->machine, "EEPROMOUT", data, 0xff);
134      ticket_dispenser_w(space, 0, (data & 1) << 7);
134      ticket_dispenser_w(devtag_get_device(space->machine, "ticket"), 0, (data & 1) << 7);
135135   }
136136}
137137
r6740r6741
270270
271271   PORT_START("240000")
272272   PORT_BIT( 0x001f, IP_ACTIVE_LOW, IPT_UNKNOWN )      /* low 5 bits read as a unit */
273   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(ticket_dispenser_0_port_r, NULL)
273   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket", ticket_dispenser_line_r)
274274   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_SPECIAL )      /* sound->main buffer status (0=empty) */
275275   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(sound_latch_state_r, NULL)
276276   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNUSED )
r6740r6741
319319
320320   PORT_START("240000")
321321   PORT_BIT( 0x001f, IP_ACTIVE_LOW, IPT_UNKNOWN )      /* low 5 bits read as a unit */
322   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(ticket_dispenser_0_port_r, NULL)
322   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket", ticket_dispenser_line_r)
323323   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_SPECIAL )      /* sound->main buffer status (0=empty) */
324324   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(sound_latch_state_r, NULL)
325325   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNUSED )
r6740r6741
366366
367367   PORT_START("240000")
368368   PORT_BIT( 0x001f, IP_ACTIVE_LOW, IPT_UNKNOWN )      /* low 5 bits read as a unit */
369   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(ticket_dispenser_0_port_r, NULL)
369   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket", ticket_dispenser_line_r)
370370   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_SPECIAL )      /* sound->main buffer status (0=empty) */
371371   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(sound_latch_state_r, NULL)
372372   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNUSED )
r6740r6741
422422   MDRV_MACHINE_START(dcheese)
423423
424424   MDRV_EEPROM_93C46_NODEFAULT_ADD("eeprom")
425   MDRV_TICKET_DISPENSER_ADD("ticket", 200, TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_LOW)
425426
426427   /* video hardware */
427428   MDRV_SCREEN_ADD("screen", RASTER)
r6740r6741
801802
802803/*************************************
803804 *
804 *  Driver configuration
805 *
806 *************************************/
807
808static DRIVER_INIT( dcheese )
809{
810   ticket_dispenser_init(machine, 200, TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_LOW);
811}
812
813
814
815/*************************************
816 *
817805 *  Game driver(s)
818806 *
819807 *************************************/
820808
821GAME( 1993, dcheese,  0,       dcheese, dcheese, dcheese, ROT90, "HAR", "Double Cheese", GAME_SUPPORTS_SAVE )
822GAME( 1993, lottof2,  0,       dcheese, lottof2, dcheese, ROT0,  "HAR", "Lotto Fun 2", GAME_SUPPORTS_SAVE )
823GAME( 1993, cecmatch, 0,       fredmem, fredmem, dcheese, ROT0,  "Coastal Amusements", "ChuckECheese's Match Game", GAME_SUPPORTS_SAVE )
824GAME( 1994, fredmem,  0,       fredmem, fredmem, dcheese, ROT0,  "Coastal Amusements", "Fred Flintstones' Memory Match (World?, Ticket version, 3/17/95)", GAME_SUPPORTS_SAVE )
825GAME( 1994, fredmemus,fredmem, fredmem, fredmem, dcheese, ROT0,  "Coastal Amusements", "Fred Flintstones' Memory Match (US, High Score version, 3/10/95)", GAME_SUPPORTS_SAVE )
826GAME( 1994, fredmemuk,fredmem, fredmem, fredmem, dcheese, ROT0,  "Coastal Amusements", "Fred Flintstones' Memory Match (UK, 3/17/95)", GAME_SUPPORTS_SAVE )
827GAME( 1994, fredmemj, fredmem, fredmem, fredmem, dcheese, ROT0,  "Coastal Amusements", "Fred Flintstones' Memory Match (Japan, High Score version, 3/20/95)", GAME_SUPPORTS_SAVE )
828GAME( 1994, fredmemc, fredmem, fredmem, fredmem, dcheese, ROT0,  "Coastal Amusements", "Fred Flintstones' Memory Match (Mandarin Chinese, 3/17/95)", GAME_SUPPORTS_SAVE )
829GAME( 1994, fredmesp, fredmem, fredmem, fredmem, dcheese, ROT0,  "Coastal Amusements", "Fred Flintstones' Memory Match (Spanish, 3/17/95)", GAME_SUPPORTS_SAVE )
809GAME( 1993, dcheese,   0,       dcheese, dcheese, 0, ROT90, "HAR", "Double Cheese", GAME_SUPPORTS_SAVE )
810GAME( 1993, lottof2,   0,       dcheese, lottof2, 0, ROT0,  "HAR", "Lotto Fun 2", GAME_SUPPORTS_SAVE )
811GAME( 1993, cecmatch,  0,       fredmem, fredmem, 0, ROT0,  "Coastal Amusements", "ChuckECheese's Match Game", GAME_SUPPORTS_SAVE )
812GAME( 1994, fredmem,   0,       fredmem, fredmem, 0, ROT0,  "Coastal Amusements", "Fred Flintstones' Memory Match (World?, Ticket version, 3/17/95)", GAME_SUPPORTS_SAVE )
813GAME( 1994, fredmemus, fredmem, fredmem, fredmem, 0, ROT0,  "Coastal Amusements", "Fred Flintstones' Memory Match (US, High Score version, 3/10/95)", GAME_SUPPORTS_SAVE )
814GAME( 1994, fredmemuk, fredmem, fredmem, fredmem, 0, ROT0,  "Coastal Amusements", "Fred Flintstones' Memory Match (UK, 3/17/95)", GAME_SUPPORTS_SAVE )
815GAME( 1994, fredmemj,  fredmem, fredmem, fredmem, 0, ROT0,  "Coastal Amusements", "Fred Flintstones' Memory Match (Japan, High Score version, 3/20/95)", GAME_SUPPORTS_SAVE )
816GAME( 1994, fredmemc,  fredmem, fredmem, fredmem, 0, ROT0,  "Coastal Amusements", "Fred Flintstones' Memory Match (Mandarin Chinese, 3/17/95)", GAME_SUPPORTS_SAVE )
817GAME( 1994, fredmesp,  fredmem, fredmem, fredmem, 0, ROT0,  "Coastal Amusements", "Fred Flintstones' Memory Match (Spanish, 3/17/95)", GAME_SUPPORTS_SAVE )
src/mame/drivers/chqflag.c
r6740r6741
1515#include "deprecat.h"
1616#include "cpu/z80/z80.h"
1717#include "cpu/konami/konami.h"
18#include "video/konamiic.h"
18#include "video/konicdev.h"
1919#include "sound/2151intf.h"
2020#include "sound/k007232.h"
2121
2222#include "chqflag.lh"
2323
24static int K051316_readroms;
24static int k051316_readroms;
2525
2626static WRITE8_DEVICE_HANDLER( k007232_extvolume_w );
2727
r6740r6741
2929VIDEO_START( chqflag );
3030VIDEO_UPDATE( chqflag );
3131
32extern void chqflag_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow);
33extern void chqflag_zoom_callback_0(running_machine *machine, int *code,int *color,int *flags);
34extern void chqflag_zoom_callback_1(running_machine *machine, int *code,int *color,int *flags);
3235
3336static INTERRUPT_GEN( chqflag_interrupt )
3437{
38   const device_config *k051960 = devtag_get_device(device->machine, "k051960");
3539   if (cpu_getiloops(device) == 0)
3640   {
37      if (K051960_is_IRQ_enabled())
41      if (k051960_is_irq_enabled(k051960))
3842         cpu_set_input_line(device, KONAMI_IRQ_LINE, HOLD_LINE);
3943   }
4044   else if (cpu_getiloops(device) % 2)
4145   {
42      if (K051960_is_NMI_enabled())
46      if (k051960_is_nmi_enabled(k051960))
4347         cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
4448   }
4549}
4650
4751static WRITE8_HANDLER( chqflag_bankswitch_w )
4852{
53   const device_config *k051316_1 = devtag_get_device(space->machine, "k051316_1");
4954   int bankaddress;
5055   UINT8 *RAM = memory_region(space->machine, "maincpu");
5156
r6740r6741
6065      memory_install_write8_handler(space, 0x1800, 0x1fff, 0, 0, paletteram_xBBBBBGGGGGRRRRR_be_w);
6166      memory_set_bankptr(space->machine, "bank5", space->machine->generic.paletteram.v);
6267
63      if (K051316_readroms)
64         memory_install_readwrite8_handler(space, 0x1000, 0x17ff, 0, 0, K051316_rom_0_r, K051316_0_w);   /* 051316 #1 (ROM test) */
68      if (k051316_readroms)
69         memory_install_readwrite8_device_handler(space, k051316_1, 0x1000, 0x17ff, 0, 0, k051316_rom_r, k051316_w);   /* 051316 #1 (ROM test) */
6570      else
66         memory_install_readwrite8_handler(space, 0x1000, 0x17ff, 0, 0, K051316_0_r, K051316_0_w);      /* 051316 #1 */
71         memory_install_readwrite8_device_handler(space, k051316_1, 0x1000, 0x17ff, 0, 0, k051316_r, k051316_w);      /* 051316 #1 */
6772   }
6873   else
6974   {
r6740r6741
7681
7782static WRITE8_HANDLER( chqflag_vreg_w )
7883{
84   const device_config *k051316_2 = devtag_get_device(space->machine, "k051316_2");
7985   static int last;
8086
8187   /* bits 0 & 1 = coin counters */
82   coin_counter_w(space->machine, 1,data & 0x01);
83   coin_counter_w(space->machine, 0,data & 0x02);
88   coin_counter_w(space->machine, 1, data & 0x01);
89   coin_counter_w(space->machine, 0, data & 0x02);
8490
8591   /* bit 4 = enable rom reading thru K051316 #1 & #2 */
86   K051316_readroms = (data & 0x10);
87   if (K051316_readroms)
88      memory_install_read8_handler(space, 0x2800, 0x2fff, 0, 0, K051316_rom_1_r);   /* 051316 (ROM test) */
92   k051316_readroms = (data & 0x10);
93   if (k051316_readroms)
94      memory_install_read8_device_handler(space, k051316_2, 0x2800, 0x2fff, 0, 0, k051316_rom_r);   /* 051316 (ROM test) */
8995   else
90      memory_install_read8_handler(space, 0x2800, 0x2fff, 0, 0, K051316_1_r);      /* 051316 */
96      memory_install_read8_device_handler(space, k051316_2, 0x2800, 0x2fff, 0, 0, k051316_r);      /* 051316 */
9197
9298   /* Bits 3-7 probably control palette dimming in a similar way to TMNT2/Sunset Riders, */
9399   /* however I don't have enough evidence to determine the exact behaviour. */
r6740r6741
152158   AM_RANGE(0x0000, 0x0fff) AM_RAM                                    /* RAM */
153159   AM_RANGE(0x1000, 0x17ff) AM_RAMBANK("bank1")                        /* banked RAM (RAM/051316 (chip 1)) */
154160   AM_RANGE(0x1800, 0x1fff) AM_RAMBANK("bank2")                        /* palette + RAM */
155   AM_RANGE(0x2000, 0x2007) AM_READWRITE(K051937_r, K051937_w)               /* Sprite control registers */
156   AM_RANGE(0x2400, 0x27ff) AM_READWRITE(K051960_r, K051960_w)               /* Sprite RAM */
157   AM_RANGE(0x2800, 0x2fff) AM_READ_BANK("bank3") AM_WRITE(K051316_1_w)      /* 051316 zoom/rotation (chip 2) */
161   AM_RANGE(0x2000, 0x2007) AM_DEVREADWRITE("k051960", k051937_r, k051937_w)               /* Sprite control registers */
162   AM_RANGE(0x2400, 0x27ff) AM_DEVREADWRITE("k051960", k051960_r, k051960_w)               /* Sprite RAM */
163   AM_RANGE(0x2800, 0x2fff) AM_READ_BANK("bank3") AM_DEVWRITE("k051316_2", k051316_w)      /* 051316 zoom/rotation (chip 2) */
158164   AM_RANGE(0x3000, 0x3000) AM_WRITE(soundlatch_w)                        /* sound code # */
159165   AM_RANGE(0x3001, 0x3001) AM_WRITE(chqflag_sh_irqtrigger_w)               /* cause interrupt on audio CPU */
160166   AM_RANGE(0x3002, 0x3002) AM_WRITE(chqflag_bankswitch_w)                  /* bankswitch control */
r6740r6741
164170   AM_RANGE(0x3201, 0x3201) AM_READ_PORT("IN0")                        /* DIPSW #3, SW 4 */
165171   AM_RANGE(0x3203, 0x3203) AM_READ_PORT("DSW2")                        /* DIPSW #2 */
166172   AM_RANGE(0x3300, 0x3300) AM_WRITE(watchdog_reset_w)                     /* watchdog timer */
167   AM_RANGE(0x3400, 0x341f) AM_READWRITE(K051733_r, K051733_w)               /* 051733 (protection) */
168   AM_RANGE(0x3500, 0x350f) AM_WRITE(K051316_ctrl_0_w)                     /* 051316 control registers (chip 1) */
169   AM_RANGE(0x3600, 0x360f) AM_WRITE(K051316_ctrl_1_w)                     /* 051316 control registers (chip 2) */
173   AM_RANGE(0x3400, 0x341f) AM_DEVREADWRITE("k051733", k051733_r, k051733_w)               /* 051733 (protection) */
174   AM_RANGE(0x3500, 0x350f) AM_DEVWRITE("k051316_1", k051316_ctrl_w)                     /* 051316 control registers (chip 1) */
175   AM_RANGE(0x3600, 0x360f) AM_DEVWRITE("k051316_2", k051316_ctrl_w)                     /* 051316 control registers (chip 2) */
170176   AM_RANGE(0x3700, 0x3700) AM_WRITE(select_analog_ctrl_w)                  /* select accelerator/wheel */
171177   AM_RANGE(0x3701, 0x3701) AM_READ_PORT("IN2")                        /* Brake + Shift + ? */
172178   AM_RANGE(0x3702, 0x3702) AM_READWRITE(analog_read_r, select_analog_ctrl_w)   /* accelerator/wheel */
r6740r6741
326332   volume_callback1
327333};
328334
335static const k051960_interface chqflag_k051960_intf =
336{
337   "gfx1", 0,
338   NORMAL_PLANE_ORDER,
339   KONAMI_ROM_DEINTERLEAVE_2,
340   chqflag_sprite_callback
341};
342
343static const k051316_interface chqflag_k051316_intf_1 =
344{
345   "gfx2", 1,
346   4, FALSE, 0,
347   0, 7, 0,
348   chqflag_zoom_callback_0
349};
350
351static const k051316_interface chqflag_k051316_intf_2 =
352{
353   "gfx3", 2,
354   8, TRUE, 0xc0,
355   1, 0, 0,
356   chqflag_zoom_callback_1
357};
358
329359static MACHINE_DRIVER_START( chqflag )
330360
331361   /* basic machine hardware */
r6740r6741
353383   MDRV_VIDEO_START(chqflag)
354384   MDRV_VIDEO_UPDATE(chqflag)
355385
386   MDRV_K051960_ADD("k051960", chqflag_k051960_intf)
387   MDRV_K051316_ADD("k051316_1", chqflag_k051316_intf_1)
388   MDRV_K051316_ADD("k051316_2", chqflag_k051316_intf_2)
389   MDRV_K051733_ADD("k051733")
390
356391   /* sound hardware */
357392   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
358393
r6740r6741
384419   ROM_REGION( 0x10000, "audiocpu", 0 )   /* 64k for the SOUND CPU */
385420   ROM_LOAD( "717e01",      0x000000, 0x008000, CRC(966b8ba8) SHA1(ab7448cb61fa5922b1d8ae5f0d0f42d734ed4f93) )
386421
387    ROM_REGION( 0x100000, "gfx1", 0 )   /* graphics (addressable by the main CPU) */
422   ROM_REGION( 0x100000, "gfx1", 0 )   /* graphics (addressable by the main CPU) */
388423   ROM_LOAD( "717e04",      0x000000, 0x080000, CRC(1a50a1cc) SHA1(bc16fab84c637ed124e37b115ddc0149560b727d) )   /* sprites */
389424   ROM_LOAD( "717e05",      0x080000, 0x080000, CRC(46ccb506) SHA1(3ed1f54744fc5cdc0f48e42f250c366267a8199a) )   /* sprites */
390425
r6740r6741
414449   ROM_REGION( 0x10000, "audiocpu", 0 )   /* 64k for the SOUND CPU */
415450   ROM_LOAD( "717e01",      0x000000, 0x008000, CRC(966b8ba8) SHA1(ab7448cb61fa5922b1d8ae5f0d0f42d734ed4f93) )
416451
417    ROM_REGION( 0x100000, "gfx1", 0 )   /* graphics (addressable by the main CPU) */
452   ROM_REGION( 0x100000, "gfx1", 0 )   /* graphics (addressable by the main CPU) */
418453   ROM_LOAD( "717e04",      0x000000, 0x080000, CRC(1a50a1cc) SHA1(bc16fab84c637ed124e37b115ddc0149560b727d) )   /* sprites */
419454   ROM_LOAD( "717e05",      0x080000, 0x080000, CRC(46ccb506) SHA1(3ed1f54744fc5cdc0f48e42f250c366267a8199a) )   /* sprites */
420455
r6740r6741
439474static DRIVER_INIT( chqflag )
440475{
441476   UINT8 *RAM = memory_region(machine, "maincpu");
442
443   konami_rom_deinterleave_2(machine, "gfx1");
444477   machine->generic.paletteram.u8 = &RAM[0x58000];
445478}
446479
src/mame/drivers/brkthru.c
r6740r6741
5353#include "cpu/m6809/m6809.h"
5454#include "sound/2203intf.h"
5555#include "sound/3526intf.h"
56#include "brkthru.h"
56#include "includes/brkthru.h"
5757
5858
5959#define MASTER_CLOCK      XTAL_12MHz
src/mame/drivers/tourtabl.c
r6740r6741
1313#include "video/tia.h"
1414
1515
16#define MASTER_CLOCK   3579575
16#define MASTER_CLOCK   XTAL_3_579545MHz
1717
1818
1919static WRITE8_DEVICE_HANDLER( tourtabl_led_w )
src/mame/drivers/trvmadns.c
r6740r6741
7777
7878   if((data & 0xf0) == 0xa0)
7979   {
80      /* FIXME: selects GFX char RAM bank here */
8081   }
8182   else if((data & 0xf0) == 0x80 || (data & 0xf0) == 0x90)
8283   {
r6740r6741
146147   gfx_element_mark_dirty(space->machine->gfx[0], offset/16);
147148}
148149
149#ifdef UNUSED_FUNCTION
150//WRONG!
151150static WRITE8_HANDLER( trvmadns_palette_w )
152151{
153   int r, g, b;
154
152   int r,g,b,datax;
155153   space->machine->generic.paletteram.u8[offset] = data;
154   offset>>=1;
155   datax=space->machine->generic.paletteram.u8[offset*2+1]+256*space->machine->generic.paletteram.u8[offset*2];
156156
157   r = space->machine->generic.paletteram.u8[offset & ~1] & 0xf;
158   g = (space->machine->generic.paletteram.u8[offset | 1] & 0xf0) >> 4;
159   b = space->machine->generic.paletteram.u8[offset | 1] & 0xf;
157   b = (((datax & 0x0007)>>0) | ((datax & 0x0200)>>6)) ^ 0xf;
158   r = (((datax & 0x0038)>>3) | ((datax & 0x0400)>>7)) ^ 0xf;
159   g = (((datax & 0x01c0)>>6) | ((datax & 0x0800)>>8)) ^ 0xf;
160160
161   palette_set_color_rgb(space->machine, offset >> 1, pal4bit(r), pal4bit(g), pal4bit(b));
161   palette_set_color_rgb(space->machine, offset, pal4bit(r), pal4bit(g), pal4bit(b));
162162}
163#endif
164163
164
165165static WRITE8_HANDLER( w2 )
166166{
167167/*  static int old = -1;
r6740r6741
202202   AM_RANGE(0x7000, 0x7fff) AM_ROMBANK("bank2")
203203   AM_RANGE(0x6000, 0x7fff) AM_WRITE(trvmadns_gfxram_w) AM_BASE(&trvmadns_gfxram)
204204   AM_RANGE(0x8000, 0x87ff) AM_RAM
205   AM_RANGE(0xc000, 0xc01f) AM_RAM_WRITE(paletteram_xxxxBBBBRRRRGGGG_le_w) AM_BASE_GENERIC(paletteram)
206   AM_RANGE(0xa000, 0xbfff) AM_RAM_WRITE(trvmadns_tileram_w) AM_BASE(&trvmadns_tileram)
205   AM_RANGE(0xa000, 0xa7ff) AM_RAM_WRITE(trvmadns_tileram_w) AM_BASE(&trvmadns_tileram)
206   AM_RANGE(0xc000, 0xc01f) AM_RAM_WRITE(trvmadns_palette_w) AM_BASE_GENERIC(paletteram)
207207   AM_RANGE(0xe000, 0xe000) AM_WRITE(w2)//NOP
208208   AM_RANGE(0xe004, 0xe004) AM_WRITE(w3)//NOP
209209ADDRESS_MAP_END
r6740r6741
251251   color = (attr & 0x18) >> 3;
252252   flag = TILE_FLIPXY((attr & 0x06) >> 1);
253253
254   if((~attr & 0x20) || (~attr & 0x40))
255      flag |= TILE_FORCE_LAYER0;
254//  if((~attr & 0x20) || (~attr & 0x40))
255//      flag |= TILE_FORCE_LAYER0;
256256
257257   //0x20? tile transparent pen 1?
258258   //0x40? tile transparent pen 1?
259259
260260   SET_TILE_INFO(0,tile,color,flag);
261
262   tileinfo->category = (attr & 0x20)>>5;
261263}
262264
263265static VIDEO_START( trvmadns )
264266{
265267   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
266268
267   tilemap_set_transparent_pen(bg_tilemap,1);
269//  tilemap_set_transparent_pen(fg_tilemap,1);
268270
269271   gfx_element_set_source(machine->gfx[0], trvmadns_gfxram);
270272}
271273
272274static VIDEO_UPDATE( trvmadns )
273275{
276   int x,y,count;
277   const gfx_element *gfx = screen->machine->gfx[0];
278
274279   bitmap_fill(bitmap,cliprect,0xd);
275280
276   tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
281   count = 0;
277282
283   for (y=0;y<32;y++)
284   {
285      for (x=0;x<32;x++)
286      {
287         int attr = trvmadns_tileram[count*2+0];
288         int tile = trvmadns_tileram[count*2+1] | ((attr & 0x01) << 8);
289         int color = (attr & 0x18) >> 3;
290         int flipx = attr & 4;
291         int flipy = attr & 2;
292
293         if(!(attr & 0x20))
294            drawgfx_opaque(bitmap,cliprect,gfx,tile,color,flipx,flipy,(x*8),(y*8));
295         count++;
296      }
297   }
298
299   count = 0;
300
301   for (y=0;y<32;y++)
302   {
303      for (x=0;x<32;x++)
304      {
305         int attr = trvmadns_tileram[count*2+0];
306         int tile = trvmadns_tileram[count*2+1] | ((attr & 0x01) << 8);
307         int color = (attr & 0x18) >> 3;
308         int flipx = attr & 4;
309         int flipy = attr & 2;
310
311         if(attr & 0x20)
312            drawgfx_transpen(bitmap,cliprect,gfx,tile,color,flipx,flipy,(x*8),(y*8),1);
313         count++;
314      }
315   }
316
278317   return 0;
279318}
280319
src/mame/drivers/cloud9.c
r6740r6741
9393#include "driver.h"
9494#include "cpu/m6502/m6502.h"
9595#include "sound/pokey.h"
96#include "cloud9.h"
96#include "includes/cloud9.h"
9797
9898
9999#define MASTER_CLOCK          (10000000)
src/mame/drivers/backfire.c
r6740r6741
1212
1313#define DE156CPU ARM
1414#include "driver.h"
15#include "decocrpt.h"
16#include "deco32.h"
15#include "includes/decocrpt.h"
16#include "includes/deco32.h"
1717#include "machine/eeprom.h"
1818#include "sound/okim6295.h"
1919#include "sound/ymz280b.h"
2020#include "cpu/arm/arm.h"
21#include "deco16ic.h"
21#include "includes/deco16ic.h"
2222#include "rendlay.h"
2323
2424static UINT32 *backfire_spriteram32_1;
src/mame/drivers/sidepckt.c
r6740r6741
2020#include "sound/3526intf.h"
2121
2222/* from video */
23extern UINT8 *sidepckt_videoram;
24extern UINT8 *sidepckt_colorram;
25
2326PALETTE_INIT( sidepckt );
2427VIDEO_START( sidepckt );
2528VIDEO_UPDATE( sidepckt );
r6740r6741
127130
128131static ADDRESS_MAP_START( sidepckt_map, ADDRESS_SPACE_PROGRAM, 8 )
129132   AM_RANGE(0x0000, 0x0fff) AM_RAM
130   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(sidepckt_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
133   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(sidepckt_videoram_w) AM_BASE(&sidepckt_videoram)
131134   AM_RANGE(0x1400, 0x17ff) AM_RAM // ???
132   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(sidepckt_colorram_w) AM_BASE_GENERIC(colorram)
135   AM_RANGE(0x1800, 0x1bff) AM_RAM_WRITE(sidepckt_colorram_w) AM_BASE(&sidepckt_colorram)
133136   AM_RANGE(0x1c00, 0x1fff) AM_RAM // ???
134137   AM_RANGE(0x2000, 0x20ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
135138   AM_RANGE(0x2100, 0x24ff) AM_RAM // ???
src/mame/drivers/starwars.c
r6740r6741
2828#include "video/avgdvg.h"
2929#include "sound/tms5220.h"
3030#include "sound/pokey.h"
31#include "starwars.h"
32#include "slapstic.h"
31#include "includes/starwars.h"
32#include "includes/slapstic.h"
3333
3434#define MASTER_CLOCK (12096000)
3535#define CLOCK_3KHZ  (MASTER_CLOCK / 4096)
src/mame/drivers/exerion.c
r6740r6741
1515
1616#include "driver.h"
1717#include "cpu/z80/z80.h"
18#include "exerion.h"
18#include "includes/exerion.h"
1919#include "sound/ay8910.h"
2020
2121
src/mame/drivers/segas18.c
r6740r6741
3333#include "cpu/mcs51/mcs51.h"
3434#include "deprecat.h"
3535#include "machine/segaic16.h"
36#include "system16.h"
37#include "genesis.h"
36#include "includes/system16.h"
37#include "includes/genesis.h"
3838#include "sound/2612intf.h"
3939#include "sound/rf5c68.h"
4040
src/mame/drivers/coolridr.c
r6740r6741
2222
2323This game runs on SYSTEM-H1 hardware. Only one known game exists on this
2424PCB and this is it. The hardware seems overly complex for a 2D bike
25racing game? This might have been an experimental design transitioning
26between Model 1 and Model 2 or a step up from ST-V's 2D to pseudo 3D/2.5D?
27The design of the PCB is very similar to vanilla Model 2
25racing game? The design of the PCB is very similar to vanilla Model 2
2826(i.e. Daytona etc). However instead of fully custom-badged chips,
29many of the custom chips are off-the-shelf Hitachi gate-arrays.
27many of the custom chips are off-the-shelf Hitachi/Toshiba gate-arrays.
3028
3129
3230PCB Layouts
r6740r6741
6058                JP9 set to 1-2
6159                JP10-12 open (no jumpers) but JP12 pin 2 tied to JP10 pin 1
6260      IC*     - IC29-IC32 are 27C4002 EPROM
63                All other ROMs are 42 pin DIP 16M mask ROM
61                IC1-IC10 are DIP42 32M mask ROM
62                IC11-IC18 are DIP42 16M mask ROM
6463
6564
6665SYSTEM-H1 COMMUNICATION-BD
r6740r6741
7069|                 CN2              |
7170|       74F74   74F245  MB84256    |
7271|       74F373  74F245  MB84256    |
73|MB89273A         CN1              |
72|MB89237A         CN1              |
7473|                                  |
7574|       74F138 74F04   74F125      |
7675|                                  |
r6740r6741
8483|       LED               CN3      |
8584|----------------------------------|
8685Notes: (All IC's shown)
87      CN1/2 - Connectors joining to CPU board
88      CN3   - Connector joining to Filter board
89      RX/TX - Optical cable connections for network (not used)
90      JP*   - 3x 2-pin jumpers. JP1 shorted, other jumpers open
86      CN1/2   - Connectors joining to CPU board
87      CN3     - Connector joining to Filter board
88      RX/TX   - Optical cable connections for network (not used)
89      JP*     - 3x 2-pin jumpers. JP1 shorted, other jumpers open
90      MB84256 - Fujitsu MB84256 32k x8 SRAM (NDIP28)
91      MB89374 - Fujitsu MB89374 Data Link Controller (SDIP42)
92      MB89237A- Fujitsu MB89237A 8-Bit Proprietary Microcontroller (?) (DIP40)
93      SN75179 - Texas Instruments SN75179 Differential Driver and Receiver Pair (DIP8)
9194
9295
9396SYSTEM-H1 CPU BD
r6740r6741
197200      M5M411860   - Mitsubishi M5M411860TP435SF00-7 DRAM with fast page mode, 64k-words x 18 bits per word (maybe?) (TSOP42)
198201      TC55328     - Toshiba TC55328AJ-15 32k x8 SRAM (SOJ24)
199202      PAL1        - GAL16V8B also marked '315-5803' (DIP20)
200      PAL2        - GAL16V8B also marked '315-5804' (DIP20)
203      PAL2        - GAL16V8B also marked '315-5864' (DIP20)
201204      Sega Custom - 315-5648 (QFP64, x4)
202205                    315-5691 also marked 'HG62S0791R17F' (QFP208)
203206                    315-5692 also marked 'HG51B152FD' (QFP256)
r6740r6741
208211                    315-5697 (QFP208)
209212                    315-5698 (QFP144)
210213
214*******************************************************************************************************
211215
216Note: This hardware appears to have been designed as a test-bed for a new RLE based compression system
217      used by the zooming sprites.  It is possible that Sega planned on using this for ST-V, but
218      decided against it. Video/CPU part numbers give an interesting insight, since video hardware #
219      sits between Model 1 & Model 2.
220
221                 Year on
222      System      PCB     PCB #      PALs
223      ---------------------------------------------------------
224      System32    1990    837-7428   315-5441 315-5442
225      SysMulti32  1992    837-8676   315-5596
226      Model 1     1992    837-8886   315-5546 315-5483 315-5484
227      Model 2     1994    837-10071  315-5737 315-5741
228      Model 2A    1994    837-10848  315-5737 315-5815
229      STV         1994    837-10934  315-5833
230
231      H1 (CPU)    1994    837-10389  315-5800 315-5801 315-5802
232      H1 (Video)  1994    837-9621   315-5803 315-5864
233
212234******************************************************************************************************/
213235
214236#include "driver.h"
r6740r6741
10881110   ROM_REGION( 0x100000, "sub", 0 ) /* SH1 */
10891111   ROM_LOAD16_WORD_SWAP( "ep17662.12", 0x000000, 0x020000,  CRC(50d66b1f) SHA1(f7b7f2f5b403a13b162f941c338a3e1207762a0b) )
10901112
1091   /* these 10 interleave somehow?? */
1092   ROM_REGION( 0x1600000, "gfx5", ROMREGION_ERASEFF ) /* Other Roms */
1113   /* these are compressed sprite data */
1114   ROM_REGION( 0x2800000, "gfx5", ROMREGION_ERASEFF )
10931115   /* logical interleaving according to the readme? */
1094   ROM_LOAD32_WORD_SWAP( "mp17640.1", 0x0000002, 0x0200000, CRC(5ecd98c7) SHA1(22027c1e9e6195d27f29a5779695d8597f68809e) )
1095   ROM_LOAD32_WORD_SWAP( "mp17645.6", 0x0000000, 0x0200000, CRC(00954173) SHA1(863f32565296448ef10992dc3c0480411eb2b193) )
1096   ROM_LOAD32_WORD_SWAP( "mp17641.2", 0x0400002, 0x0200000, CRC(a59b0605) SHA1(c93f84fd58f1942b40b7a55058e02a18a3dec3af) )
1097   ROM_LOAD32_WORD_SWAP( "mp17646.7", 0x0400000, 0x0200000, CRC(7ae4d92e) SHA1(8a0eaa5dce112289ac5d16ad5dc7f5895e71e87b) )
1098   ROM_LOAD32_WORD_SWAP( "mp17642.3", 0x0800002, 0x0200000, CRC(5f8a1827) SHA1(23179d751777436f2a4f652132001d5e425d8cd5) )
1099   ROM_LOAD32_WORD_SWAP( "mp17647.8", 0x0800000, 0x0200000, CRC(082faee8) SHA1(c047b8475517f96f481c09471a77aa0d103631d6) )
1100   ROM_LOAD32_WORD_SWAP( "mp17643.4", 0x0c00002, 0x0200000, CRC(44a05dd0) SHA1(32aa86f8761ec6ffceb63979c44828603c244e7d) )
1101   ROM_LOAD32_WORD_SWAP( "mp17648.9", 0x0c00000, 0x0200000, CRC(0791802f) SHA1(acad55bbd22c7e955a729c8abed9509fc6f10927) )
1102   ROM_LOAD32_WORD_SWAP( "mp17644.5", 0x1000002, 0x0200000, CRC(be2763c5) SHA1(1044b0a73e334337b0b9ac958df59480aedfb942) )
1103   ROM_LOAD32_WORD_SWAP( "mp17649.10",0x1000000, 0x0200000, CRC(567fbc0a) SHA1(3999c99b26f13d97ac1c58de00a44049ee7775fd) )
1104
1105/*  ROMX_LOAD( "mp17640.1", 0x0000000, 0x0200000, CRC(5ecd98c7) SHA1(22027c1e9e6195d27f29a5779695d8597f68809e), ROM_SKIP(9) )
1106    ROMX_LOAD( "mp17641.2", 0x0000001, 0x0200000, CRC(a59b0605) SHA1(c93f84fd58f1942b40b7a55058e02a18a3dec3af), ROM_SKIP(9) )
1107    ROMX_LOAD( "mp17642.3", 0x0000002, 0x0200000, CRC(5f8a1827) SHA1(23179d751777436f2a4f652132001d5e425d8cd5), ROM_SKIP(9) )
1108    ROMX_LOAD( "mp17643.4", 0x0000003, 0x0200000, CRC(44a05dd0) SHA1(32aa86f8761ec6ffceb63979c44828603c244e7d), ROM_SKIP(9) )
1109    ROMX_LOAD( "mp17644.5", 0x0000004, 0x0200000, CRC(be2763c5) SHA1(1044b0a73e334337b0b9ac958df59480aedfb942), ROM_SKIP(9) )
1110    ROMX_LOAD( "mp17645.6", 0x0000005, 0x0200000, CRC(00954173) SHA1(863f32565296448ef10992dc3c0480411eb2b193), ROM_SKIP(9) )
1111    ROMX_LOAD( "mp17646.7", 0x0000006, 0x0200000, CRC(7ae4d92e) SHA1(8a0eaa5dce112289ac5d16ad5dc7f5895e71e87b), ROM_SKIP(9) )
1112    ROMX_LOAD( "mp17647.8", 0x0000007, 0x0200000, CRC(082faee8) SHA1(c047b8475517f96f481c09471a77aa0d103631d6), ROM_SKIP(9) )
1113    ROMX_LOAD( "mp17648.9", 0x0000008, 0x0200000, CRC(0791802f) SHA1(acad55bbd22c7e955a729c8abed9509fc6f10927), ROM_SKIP(9) )
1114    ROMX_LOAD( "mp17649.10",0x0000009, 0x0200000, CRC(567fbc0a) SHA1(3999c99b26f13d97ac1c58de00a44049ee7775fd), ROM_SKIP(9) )*/
1116   ROM_LOAD32_WORD_SWAP( "mpr-17640.ic1", 0x0000002, 0x0400000, CRC(981e3e69) SHA1(d242055e0359ec4b5fac4676b2f974fbc974cc68) )
1117   ROM_LOAD32_WORD_SWAP( "mpr-17645.ic6", 0x0000000, 0x0400000, CRC(56968d07) SHA1(e88c3d66ea05affb4681a25d155f097bd1b5a84b) )
1118   ROM_LOAD32_WORD_SWAP( "mpr-17641.ic2", 0x0800002, 0x0400000, CRC(fccc3dae) SHA1(0df7fd8b1110ba9063dc4dc40301267229cb9a35) )
1119   ROM_LOAD32_WORD_SWAP( "mpr-17646.ic7", 0x0800000, 0x0400000, CRC(b77eb2ad) SHA1(b832c0f1798aca39adba840d56ae96a75346670a) )
1120   ROM_LOAD32_WORD_SWAP( "mpr-17642.ic3", 0x1000002, 0x0400000, CRC(1a5bcc73) SHA1(a7df04c0a326323ea185db5f55b3e0449d76c535) )
1121   ROM_LOAD32_WORD_SWAP( "mpr-17647.ic8", 0x1000000, 0x0400000, CRC(9dd9330c) SHA1(c91a7f497c1f4bd283bd683b06dff88893724d51) )
1122   ROM_LOAD32_WORD_SWAP( "mpr-17643.ic4", 0x1800002, 0x0400000, CRC(5100f23b) SHA1(659c2300399ff1cbd24fb1eb18cfd6c26e06fd96) )
1123   ROM_LOAD32_WORD_SWAP( "mpr-17648.ic9", 0x1800000, 0x0400000, CRC(bf184cce) SHA1(62c004ea279f9a649d21426369336c2e1f9d24da) )
1124   ROM_LOAD32_WORD_SWAP( "mpr-17644.ic5", 0x2000002, 0x0400000, CRC(80199c79) SHA1(e525d8ee9f9176101629853e50cca73b02b16a38) )
1125   ROM_LOAD32_WORD_SWAP( "mpr-17649.ic10",0x2000000, 0x0400000, CRC(618c47ae) SHA1(5b69ad36fcf8e70d34c3b2fc71412ce953c5ceb3) )
11151126ROM_END
11161127
11171128/*TODO: there must be an irq line with custom vector located somewhere that writes to here...*/
src/mame/drivers/nitedrvr.c
r6740r6741
3838#include "cpu/m6502/m6502.h"
3939#include "machine/rescap.h"
4040#include "sound/discrete.h"
41#include "nitedrvr.h"
41#include "includes/nitedrvr.h"
4242
4343/* Memory Map */
4444
r6740r6741
136136
137137static MACHINE_DRIVER_START( nitedrvr )
138138   // basic machine hardware
139   MDRV_CPU_ADD("maincpu", M6502, 12096000/12) // 1 MHz
139   MDRV_CPU_ADD("maincpu", M6502, XTAL_12_096MHz/12) // 1 MHz
140140   MDRV_CPU_PROGRAM_MAP(nitedrvr_map)
141141   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
142142   MDRV_WATCHDOG_VBLANK_INIT(3)
r6740r6741
144144   MDRV_MACHINE_START(nitedrvr)
145145   MDRV_MACHINE_RESET(nitedrvr)
146146
147   MDRV_TIMER_ADD_PERIODIC("crash_timer", nitedrvr_crash_toggle_callback, NSEC(PERIOD_OF_555_ASTABLE_NSEC(RES_K(180), 330, CAP_U(1))))
148
147149   // video hardware
148150
149151   MDRV_SCREEN_ADD("screen", RASTER)
src/mame/drivers/rainbow.c
r6740r6741
320320#include "driver.h"
321321#include "cpu/z80/z80.h"
322322#include "cpu/m68000/m68000.h"
323#include "taitoipt.h"
323#include "includes/taitoipt.h"
324324#include "video/taitoic.h"
325325#include "audio/taitosnd.h"
326326#include "sound/2203intf.h"
src/mame/drivers/rungun.c
r6740r6741
3737
3838#include "driver.h"
3939
40#include "video/konamiic.h"
40#include "video/konicdev.h"
4141#include "cpu/m68000/m68000.h"
4242#include "cpu/z80/z80.h"
43#include "machine/eeprom.h"
43#include "machine/eepromdev.h"
4444#include "sound/k054539.h"
45#include "konamipt.h"
45#include "includes/konamipt.h"
4646
4747VIDEO_START( rng );
4848VIDEO_UPDATE( rng );
r6740r6741
5252WRITE16_HANDLER( rng_936_videoram_w );
5353
5454extern UINT16 *rng_936_videoram;
55extern void rng_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask);
5556
5657static UINT16 *rng_sysreg;
57static int init_eeprom_count;
5858static int rng_z80_control;
5959static int rng_sound_status;
6060
r6740r6741
6969   "0100110000000" /* unlock command */
7070};
7171
72static NVRAM_HANDLER( rungun )
73{
74   if (read_or_write)
75      eeprom_save(file);
76   else
77   {
78      eeprom_init(machine, &eeprom_intf);
79
80      if (file)
81      {
82         init_eeprom_count = 0;
83         eeprom_load(file);
84      }
85      else
86         init_eeprom_count = 10;
87   }
88}
89
9072static READ16_HANDLER( rng_sysregs_r )
9173{
9274   UINT16 data = 0;
r6740r6741
9577   {
9678      case 0x00/2:
9779         if (input_port_read(space->machine, "DSW") & 0x20)
98            return(input_port_read(space->machine, "P1") | input_port_read(space->machine, "P3")<<8);
80            return(input_port_read(space->machine, "P1") | input_port_read(space->machine, "P3") << 8);
9981         else
10082         {
10183            data = input_port_read(space->machine, "P1") & input_port_read(space->machine, "P3");
102            return(data<<8 | data);
84            return(data << 8 | data);
10385         }
10486
10587      case 0x02/2:
10688         if (input_port_read(space->machine, "DSW") & 0x20)
107            return(input_port_read(space->machine, "P2") | input_port_read(space->machine, "P4")<<8);
89            return(input_port_read(space->machine, "P2") | input_port_read(space->machine, "P4") << 8);
10890         else
10991         {
11092            data = input_port_read(space->machine, "P2") & input_port_read(space->machine, "P4");
111            return(data<<8 | data);
93            return(data << 8 | data);
11294         }
11395
11496      case 0x04/2:
r6740r6741
123105         if (ACCESSING_BITS_0_7)
124106         {
125107            data = input_port_read(space->machine, "DSW");
126
127            if (init_eeprom_count)
128            {
129               init_eeprom_count--;
130               data &= 0xf7;
131            }
132108         }
133109         return((rng_sysreg[0x06/2] & 0xff00) | data);
134110   }
r6740r6741
138114
139115static WRITE16_HANDLER( rng_sysregs_w )
140116{
117   const device_config *k055673 = devtag_get_device(space->machine, "k055673");
141118   COMBINE_DATA(rng_sysreg + offset);
142119
143120   switch (offset)
r6740r6741
153130            */
154131         if (ACCESSING_BITS_0_7)
155132         {
156            eeprom_write_bit((data & 0x01) ? 1 : 0);
157            eeprom_set_cs_line((data & 0x02) ? CLEAR_LINE : ASSERT_LINE);
158            eeprom_set_clock_line((data & 0x04) ? ASSERT_LINE : CLEAR_LINE);
133            input_port_write(space->machine, "EEPROMOUT", data, 0xff);
159134         }
160135
161136         if (!(data & 0x40))
r6740r6741
169144                bit 2 : OBJCHA
170145                bit 3 : enable IRQ 5
171146            */
172         K053246_set_OBJCHA_line((data & 0x04) ? ASSERT_LINE : CLEAR_LINE);
147         k053246_set_objcha_line(k055673, (data & 0x04) ? ASSERT_LINE : CLEAR_LINE);
173148      break;
174149   }
175150}
r6740r6741
212187   AM_RANGE(0x380000, 0x39ffff) AM_RAM                                 // work RAM
213188   AM_RANGE(0x400000, 0x43ffff) AM_READNOP   // AM_READ( K053936_0_rom_r )       // '936 ROM readback window
214189   AM_RANGE(0x480000, 0x48001f) AM_READWRITE(rng_sysregs_r,rng_sysregs_w) AM_BASE(&rng_sysreg)
215   AM_RANGE(0x4c0000, 0x4c001f) AM_READ(K053252_word_r)                  // CCU (for scanline and vblank polling)
190   AM_RANGE(0x4c0000, 0x4c001f) AM_DEVREAD("k053252", k053252_word_r)                  // CCU (for scanline and vblank polling)
216191   AM_RANGE(0x540000, 0x540001) AM_WRITE(sound_irq_w)
217192   AM_RANGE(0x58000c, 0x58000d) AM_WRITE(sound_cmd1_w)
218193   AM_RANGE(0x58000e, 0x58000f) AM_WRITE(sound_cmd2_w)
219194   AM_RANGE(0x580014, 0x580015) AM_READ(sound_status_msb_r)
220195   AM_RANGE(0x580000, 0x58001f) AM_RAM                                 // sound regs read/write fall-through
221   AM_RANGE(0x5c0000, 0x5c000d) AM_READ(K053246_word_r)                  // 246A ROM readback window
222   AM_RANGE(0x5c0010, 0x5c001f) AM_WRITE(K053247_reg_word_w)
223   AM_RANGE(0x600000, 0x600fff) AM_READWRITE(K053247_word_r,K053247_word_w)   // OBJ RAM
196   AM_RANGE(0x5c0000, 0x5c000d) AM_DEVREAD("k055673", k053246_word_r)                  // 246A ROM readback window
197   AM_RANGE(0x5c0010, 0x5c001f) AM_DEVWRITE("k055673", k053247_reg_word_w)
198   AM_RANGE(0x600000, 0x600fff) AM_DEVREADWRITE("k055673", k053247_word_r, k053247_word_w)   // OBJ RAM
224199   AM_RANGE(0x601000, 0x601fff) AM_RAM                                 // communication? second monitor buffer?
225   AM_RANGE(0x640000, 0x640007) AM_WRITE(K053246_word_w)                  // '246A registers
226   AM_RANGE(0x680000, 0x68001f) AM_WRITEONLY AM_BASE(&K053936_0_ctrl)         // '936 registers
200   AM_RANGE(0x640000, 0x640007) AM_DEVWRITE("k055673", k053246_word_w)                  // '246A registers
201   AM_RANGE(0x680000, 0x68001f) AM_DEVWRITE("k053936", k053936_ctrl_w)         // '936 registers
227202   AM_RANGE(0x6c0000, 0x6cffff) AM_RAM_WRITE(rng_936_videoram_w) AM_BASE(&rng_936_videoram)   // PSAC2 ('936) RAM (34v + 35v)
228   AM_RANGE(0x700000, 0x7007ff) AM_RAM AM_BASE(&K053936_0_linectrl)         // PSAC "Line RAM"
203   AM_RANGE(0x700000, 0x7007ff) AM_DEVREADWRITE("k053936", k053936_linectrl_r, k053936_linectrl_w)         // PSAC "Line RAM"
229204   AM_RANGE(0x740000, 0x741fff) AM_READWRITE(rng_ttl_ram_r,rng_ttl_ram_w)      // text plane RAM
230205   AM_RANGE(0x7c0000, 0x7c0001) AM_WRITENOP                           // watchdog
231206#if RNG_DEBUG
232   AM_RANGE(0x5c0010, 0x5c001f) AM_READ(K053247_reg_word_r)
233   AM_RANGE(0x640000, 0x640007) AM_READ(K053246_reg_word_r)
207   AM_RANGE(0x5c0010, 0x5c001f) AM_DEVREAD("k055673", k053247_reg_word_r)
208   AM_RANGE(0x640000, 0x640007) AM_DEVREAD("k055673", k053246_reg_word_r)
234209#endif
235210ADDRESS_MAP_END
236211
r6740r6741
277252ADDRESS_MAP_END
278253
279254
280static const k054539_interface k054539_config =
281{
282   "shared"
283};
255static INPUT_PORTS_START( rng )
256   PORT_START("SYSTEM")
257   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
258   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
259   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
260   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN4 )
261   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE1 )
262   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE2 )
263   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE3 )
264   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE4 )
265   PORT_DIPNAME( 0x0100, 0x0000, "Freeze" )
266   PORT_DIPSETTING( 0x0000, DEF_STR( Off ) )
267   PORT_DIPSETTING( 0x0100, DEF_STR( On ) )
268   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )
269   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
270   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
284271
272   PORT_START("DSW")
273   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
274   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM ready (always 1) */
275   PORT_SERVICE_NO_TOGGLE( 0x08, IP_ACTIVE_LOW )
276   PORT_DIPNAME( 0x10, 0x00, "Monitors" )
277   PORT_DIPSETTING(    0x00, "1" )
278   PORT_DIPSETTING(    0x10, "2" )
279   PORT_DIPNAME( 0x20, 0x00, "Number of players" )
280   PORT_DIPSETTING(    0x00, "2" )
281   PORT_DIPSETTING(    0x20, "4" )
282   PORT_DIPNAME( 0x40, 0x00, "Sound Output" )
283   PORT_DIPSETTING(    0x40, DEF_STR( Mono ) )
284   PORT_DIPSETTING(    0x00, DEF_STR( Stereo ) )
285   PORT_DIPNAME( 0x04, 0x04, "Bit2 (Unknown)" )
286   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
287   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
288   PORT_DIPNAME( 0x80, 0x80, "Bit7 (Unknown)" )
289   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
290   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
291
292   PORT_START( "EEPROMOUT" )
293   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
294   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
295   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
296
297   PORT_START("P1")
298   KONAMI8_B123_START(1)
299
300   PORT_START("P2")
301   KONAMI8_B123_START(2)
302
303   PORT_START("P3")
304   KONAMI8_B123_START(3)
305
306   PORT_START("P4")
307   KONAMI8_B123_START(4)
308INPUT_PORTS_END
309
310
311
285312/**********************************************************************************/
286313
287314static const gfx_layout bglayout =
r6740r6741
301328   GFXDECODE_ENTRY( "gfx1", 0, bglayout, 0x0000, 64 )
302329GFXDECODE_END
303330
331
332
333static const k054539_interface k054539_config =
334{
335   "shared"
336};
337
338
339static const k053936_interface rng_k053936_intf =
340{
341   0, 34, 9
342};
343
344static const k053247_interface rng_k055673_intf =
345{
346   "screen",
347   "gfx2", 1,
348   K055673_LAYOUT_RNG,
349   -8, 15,
350   KONAMI_ROM_DEINTERLEAVE_NONE,   // there is some interleave in VIDEO_START...
351   rng_sprite_callback
352};
353
354
304355static MACHINE_DRIVER_START( rng )
305356
306357   /* basic machine hardware */
r6740r6741
317368   MDRV_GFXDECODE(rungun)
318369
319370   MDRV_MACHINE_RESET(rng)
320   MDRV_NVRAM_HANDLER(rungun)
321371
372   MDRV_EEPROM_NODEFAULT_ADD("eeprom", eeprom_intf)
373
322374   /* video hardware */
323375   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_BEFORE_VBLANK)
324376
r6740r6741
334386   MDRV_VIDEO_START(rng)
335387   MDRV_VIDEO_UPDATE(rng)
336388
389   MDRV_K053936_ADD("k053936", rng_k053936_intf)
390   MDRV_K055673_ADD("k055673", rng_k055673_intf)
391   MDRV_K053252_ADD("k053252")
392
337393   /* sound hardware */
338394   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
339395
r6740r6741
348404   MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)
349405MACHINE_DRIVER_END
350406
351static INPUT_PORTS_START( rng )
352   PORT_START("SYSTEM")
353   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
354   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
355   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
356   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN4 )
357   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE1 )
358   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE2 )
359   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE3 )
360   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE4 )
361   PORT_DIPNAME( 0x0100, 0x0000, "Freeze" )
362   PORT_DIPSETTING( 0x0000, DEF_STR( Off ) )
363   PORT_DIPSETTING( 0x0100, DEF_STR( On ) )
364   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN )
365   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
366   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
367407
368   PORT_START("DSW")
369   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
370   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM ready (always 1) */
371   PORT_SERVICE_NO_TOGGLE( 0x08, IP_ACTIVE_LOW )
372   PORT_DIPNAME( 0x10, 0x00, "Monitors" )
373   PORT_DIPSETTING(    0x00, "1" )
374   PORT_DIPSETTING(    0x10, "2" )
375   PORT_DIPNAME( 0x20, 0x00, "Number of players" )
376   PORT_DIPSETTING(    0x00, "2" )
377   PORT_DIPSETTING(    0x20, "4" )
378   PORT_DIPNAME( 0x40, 0x00, "Sound Output" )
379   PORT_DIPSETTING(    0x40, DEF_STR( Mono ) )
380   PORT_DIPSETTING(    0x00, DEF_STR( Stereo ) )
381   PORT_DIPNAME( 0x04, 0x04, "Bit2 (Unknown)" )
382   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
383   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
384   PORT_DIPNAME( 0x80, 0x80, "Bit7 (Unknown)" )
385   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
386   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
387
388   PORT_START("P1")
389   KONAMI8_B123_START(1)
390
391   PORT_START("P2")
392   KONAMI8_B123_START(2)
393
394   PORT_START("P3")
395   KONAMI8_B123_START(3)
396
397   PORT_START("P4")
398   KONAMI8_B123_START(4)
399INPUT_PORTS_END
400
401
402408ROM_START( rungun )
403409   /* main program Europe Version AA  1993, 10.8 */
404410   ROM_REGION( 0x300000, "maincpu", 0)
r6740r6741
597603
598604   memset(rng_sysreg, 0, 0x20);
599605
600   init_eeprom_count = 0;
601606   rng_z80_control = 0;
602607   rng_sound_status = 0;
603608}
src/mame/drivers/eprom.c
r6740r6741
2626#include "driver.h"
2727#include "cpu/m68000/m68000.h"
2828#include "audio/atarijsa.h"
29#include "eprom.h"
29#include "includes/eprom.h"
3030
3131
3232
r6740r6741
4949}
5050
5151
52static MACHINE_RESET( klaxp )
52static MACHINE_START( eprom )
5353{
54   atarigen_init(machine);
55}
56
57
58static MACHINE_RESET( eprom )
59{
5460   eprom_state *state = (eprom_state *)machine->driver_data;
5561
5662   atarigen_eeprom_reset(&state->atarigen);
5763   atarigen_interrupt_reset(&state->atarigen, update_interrupts);
5864   atarigen_scanline_timer_reset(machine->primary_screen, eprom_scanline_update, 8);
5965   atarijsa_reset();
60   atarigen_init_save_state(machine);
6166}
6267
6368
64static MACHINE_RESET( eprom )
65{
66   eprom_state *state = (eprom_state *)machine->driver_data;
67   MACHINE_RESET_CALL(klaxp);
68   state_save_register_global_pointer(machine, state->sync_data, 2);
69}
7069
71
72
7370/*************************************
7471 *
7572 *  I/O handling
r6740r6741
422419
423420   MDRV_QUANTUM_TIME(HZ(6000))
424421
422   MDRV_MACHINE_START(eprom)
425423   MDRV_MACHINE_RESET(eprom)
426424   MDRV_NVRAM_HANDLER(atarigen)
427425
r6740r6741
454452
455453   MDRV_QUANTUM_TIME(HZ(600))
456454
457   MDRV_MACHINE_RESET(klaxp)
455   MDRV_MACHINE_START(eprom)
456   MDRV_MACHINE_RESET(eprom)
458457   MDRV_NVRAM_HANDLER(atarigen)
459458
460459   /* video hardware */
r6740r6741
486485
487486   MDRV_QUANTUM_TIME(HZ(600))
488487
488   MDRV_MACHINE_START(eprom)
489489   MDRV_MACHINE_RESET(eprom)
490490   MDRV_NVRAM_HANDLER(atarigen)
491491
src/mame/drivers/chinsan.c
r6740r6741
4747#include "sound/2203intf.h"
4848#include "sound/msm5205.h"
4949
50static UINT8* chinsan_video;
51static UINT8 chinsan_port_select;
50typedef struct _chinsan_state chinsan_state;
51struct _chinsan_state
52{
53   /* memory pointers */
54   UINT8 *  video;
5255
53static UINT32 adpcm_pos;
54static UINT8 adpcm_idle,adpcm_data;
56   /* misc */
57   UINT8    port_select;
58   UINT32   adpcm_pos;
59   UINT8    adpcm_idle, adpcm_data;
60   UINT8    trigger;
61};
5562
56static VIDEO_START(chinsan)
63
64/*************************************
65 *
66 *  Video emulation
67 *
68 *************************************/
69
70static PALETTE_INIT( chinsan )
5771{
72   UINT8 *src = memory_region( machine, "color_proms" );
73   int i;
74
75   for (i = 0; i < 0x100; i++)
76      palette_set_color_rgb(machine, i, pal4bit(src[i + 0x200]), pal4bit(src[i + 0x100]), pal4bit(src[i + 0x000]));
5877}
5978
60static VIDEO_UPDATE(chinsan)
79static VIDEO_START( chinsan )
6180{
62   int y,x, count;
81}
82
83static VIDEO_UPDATE( chinsan )
84{
85   chinsan_state *state = (chinsan_state *)screen->machine->driver_data;
86   int y, x, count;
6387   count = 0;
64   for(y=0;y<32;y++)
88   for (y = 0; y < 32; y++)
6589   {
66      for (x=0;x<64;x++)
90      for (x = 0; x < 64; x++)
6791      {
68         int tileno,colour;
69         tileno = chinsan_video[count] | (chinsan_video[count+0x800]<<8);
70         colour = chinsan_video[count+0x1000]>>3;
92         int tileno, colour;
93         tileno = state->video[count] | (state->video[count + 0x800] << 8);
94         colour = state->video[count + 0x1000] >> 3;
7195         drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0],tileno,colour,0,0,x*8,y*8);
7296         count++;
7397      }
r6740r6741
78102
79103
80104
81static MACHINE_RESET( chinsan )
82{
83   memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "maincpu") + 0x10000, 0x4000);
105/*************************************
106 *
107 *  Memory handlers
108 *
109 *************************************/
84110
85   adpcm_idle = 1;
86}
87
88
89static WRITE8_HANDLER(ctrl_w)
111static WRITE8_HANDLER( ctrl_w )
90112{
91113   memory_set_bank(space->machine, "bank1", data >> 6);
92114}
93115
94116static WRITE8_DEVICE_HANDLER( ym_port_w1 )
95117{
96   logerror("ym_write port 1 %02x\n",data);
118   logerror("ym_write port 1 %02x\n", data);
97119}
98120
99121
100122static WRITE8_DEVICE_HANDLER( ym_port_w2 )
101123{
102   logerror("ym_write port 2 %02x\n",data);
124   logerror("ym_write port 2 %02x\n", data);
103125}
104126
105127
r6740r6741
117139
118140static WRITE8_HANDLER( chinsan_port00_w )
119141{
142   chinsan_state *state = (chinsan_state *)space->machine->driver_data;
120143
121   chinsan_port_select = data;
144   state->port_select = data;
122145
123146   if (
124      (data!=0x40) &&
125      (data!=0x4f) &&
126      (data!=0x53) &&
127      (data!=0x57) &&
128      (data!=0x5b) &&
129      (data!=0x5d) &&
130      (data!=0x5e))
131      logerror("write port 00 %02x\n",data);
147      (data != 0x40) &&
148      (data != 0x4f) &&
149      (data != 0x53) &&
150      (data != 0x57) &&
151      (data != 0x5b) &&
152      (data != 0x5d) &&
153      (data != 0x5e))
154      logerror("write port 00 %02x\n", data);
132155
133156}
134157
135158static READ8_HANDLER( chinsan_input_port_0_r )
136159{
160   chinsan_state *state = (chinsan_state *)space->machine->driver_data;
137161
138162   //return 0xff; // the inputs don't seem to work, so just return ff for now
139163
140   switch (chinsan_port_select)
164   switch (state->port_select)
141165   {
142166      /* i doubt these are both really the same.. */
143167      case 0x40:
r6740r6741
160184         return input_port_read(space->machine, "MAHJONG_P2_6");
161185   }
162186
163   printf("chinsan_input_port_0_r unk_r %02x\n", chinsan_port_select);
187   printf("chinsan_input_port_0_r unk_r %02x\n", state->port_select);
164188   return mame_rand(space->machine);
165189}
166190
167191static READ8_HANDLER( chinsan_input_port_1_r )
168192{
169   switch (chinsan_port_select)
193   chinsan_state *state = (chinsan_state *)space->machine->driver_data;
194
195   switch (state->port_select)
170196   {
171197      /* i doubt these are both really the same.. */
172198      case 0x40:
r6740r6741
189215         return input_port_read(space->machine, "MAHJONG_P1_6");
190216   }
191217
192   printf("chinsan_input_port_1_r unk_r %02x\n", chinsan_port_select);
218   printf("chinsan_input_port_1_r unk_r %02x\n", state->port_select);
193219   return mame_rand(space->machine);
194220}
195221
196222static WRITE8_DEVICE_HANDLER( chin_adpcm_w )
197223{
198   adpcm_pos = (data & 0xff) * 0x100;
199   adpcm_idle = 0;
200   msm5205_reset_w(device,0);
224   chinsan_state *state = (chinsan_state *)device->machine->driver_data;
225   state->adpcm_pos = (data & 0xff) * 0x100;
226   state->adpcm_idle = 0;
227   msm5205_reset_w(device, 0);
201228}
202229
230/*************************************
231 *
232 *  Address maps
233 *
234 *************************************/
235
203236static ADDRESS_MAP_START( chinsan_map, ADDRESS_SPACE_PROGRAM, 8 )
204237   AM_RANGE(0x0000, 0x7fff) AM_ROM
205238   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
206239   AM_RANGE(0xc000, 0xdfff) AM_RAM
207   AM_RANGE(0xe000, 0xf7ff) AM_RAM AM_BASE(&chinsan_video)
240   AM_RANGE(0xe000, 0xf7ff) AM_RAM AM_BASE_MEMBER(chinsan_state, video)
208241ADDRESS_MAP_END
209242
210243static ADDRESS_MAP_START( chinsan_io, ADDRESS_SPACE_IO, 8 )
r6740r6741
218251ADDRESS_MAP_END
219252
220253
254/*************************************
255 *
256 *  Input ports
257 *
258 *************************************/
259
221260static INPUT_PORTS_START( chinsan )
222261   PORT_START("DSW1")
223262   PORT_DIPNAME( 0x01, 0x01, "DSW1" )
r6740r6741
457496
458497
459498
499/*************************************
500 *
501 *  Graphics definitions
502 *
503 *************************************/
504
460505static const gfx_layout tiles8x8_layout =
461506{
462507   8,8,
r6740r6741
472517   GFXDECODE_ENTRY( "gfx1", 0, tiles8x8_layout, 0, 32 )
473518GFXDECODE_END
474519
475static void chin_adpcm_int(const device_config *device)
520/*************************************
521 *
522 *  Sound interface
523 *
524 *************************************/
525
526static void chin_adpcm_int( const device_config *device )
476527{
477   static UINT8 trigger;
528   chinsan_state *state = (chinsan_state *)device->machine->driver_data;
478529
479   if (adpcm_pos >= 0x10000 || adpcm_idle)
530   if (state->adpcm_pos >= 0x10000 || state->adpcm_idle)
480531   {
481      //adpcm_idle = 1;
482      msm5205_reset_w(device,1);
483      trigger = 0;
532      //state->adpcm_idle = 1;
533      msm5205_reset_w(device, 1);
534      state->trigger = 0;
484535   }
485536   else
486537   {
487538      UINT8 *ROM = memory_region(device->machine, "adpcm");
488539
489      adpcm_data = ((trigger ? (ROM[adpcm_pos] & 0x0f) : (ROM[adpcm_pos] & 0xf0)>>4) );
490      msm5205_data_w(device,adpcm_data & 0xf);
491      trigger^=1;
492      if(trigger == 0)
540      state->adpcm_data = ((state->trigger ? (ROM[state->adpcm_pos] & 0x0f) : (ROM[state->adpcm_pos] & 0xf0) >> 4));
541      msm5205_data_w(device, state->adpcm_data & 0xf);
542      state->trigger ^= 1;
543      if(state->trigger == 0)
493544      {
494         adpcm_pos++;
495         if((ROM[adpcm_pos] & 0xff) == 0x70)
496            adpcm_idle = 1;
545         state->adpcm_pos++;
546         if ((ROM[state->adpcm_pos] & 0xff) == 0x70)
547            state->adpcm_idle = 1;
497548      }
498549   }
499550}
r6740r6741
504555   MSM5205_S64_4B   /* 8kHz */
505556};
506557
507static PALETTE_INIT( chinsan )
558/*************************************
559 *
560 *  Machine driver
561 *
562 *************************************/
563
564static MACHINE_START( chinsan )
508565{
509   UINT8 *src = memory_region( machine, "color_proms" );
510   int i;
566   chinsan_state *state = (chinsan_state *)machine->driver_data;
511567
512   for (i=0;i<0x100;i++)
513   {
514      palette_set_color_rgb(machine,i,pal4bit(src[i+0x200]),pal4bit(src[i+0x100]),pal4bit(src[i+0x000]));
515   }
568   memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "maincpu") + 0x10000, 0x4000);
569
570   state_save_register_global(machine, state->adpcm_idle);
571   state_save_register_global(machine, state->port_select);
572   state_save_register_global(machine, state->adpcm_pos);
573   state_save_register_global(machine, state->adpcm_data);
574   state_save_register_global(machine, state->trigger);
516575}
517576
577static MACHINE_RESET( chinsan )
578{
579   chinsan_state *state = (chinsan_state *)machine->driver_data;
580
581   state->adpcm_idle = 1;
582   state->port_select = 0;
583   state->adpcm_pos = 0;
584   state->adpcm_data = 0;
585   state->trigger = 0;
586}
587
588
518589static MACHINE_DRIVER_START( chinsan )
590
591   /* driver data */
592   MDRV_DRIVER_DATA(chinsan_state)
593
519594   /* basic machine hardware */
520595   MDRV_CPU_ADD("maincpu", Z80,10000000/2)       /* ? MHz */
521596   MDRV_CPU_PROGRAM_MAP(chinsan_map)
522597   MDRV_CPU_IO_MAP(chinsan_io)
523598   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
524599
600   MDRV_MACHINE_START( chinsan )
525601   MDRV_MACHINE_RESET( chinsan )
526602
527603   /* video hardware */
r6740r6741
539615   MDRV_VIDEO_START(chinsan)
540616   MDRV_VIDEO_UPDATE(chinsan)
541617
542   // sound hardware
618   /* sound hardware */
543619   MDRV_SPEAKER_STANDARD_MONO("mono")
544620
545621   MDRV_SOUND_ADD("ymsnd", YM2203, 1500000) /* ? Mhz */
r6740r6741
556632
557633
558634
635/*************************************
636 *
637 *  ROM definition(s)
638 *
639 *************************************/
640
559641ROM_START( chinsan )
560642   ROM_REGION( 0x20000, "maincpu", 0 ) /* encrypted code / data */
561643   ROM_LOAD( "mm00.7d", 0x00000, 0x08000, CRC(f7a4414f) SHA1(f65223b2928f610ab97fda2f2c008806cf2420e5) )
r6740r6741
583665ROM_END
584666
585667
668/*************************************
669 *
670 *  Driver initialization
671 *
672 *************************************/
673
586674static DRIVER_INIT( chinsan )
587675{
588676   mc8123_decrypt_rom(machine, "maincpu", "user1", "bank1", 4);
589677}
590678
591679
592GAME( 1987, chinsan,  0,    chinsan, chinsan, chinsan, ROT0, "Sanritsu", "Ganbare Chinsan Ooshoubu (MC-8123A, 317-5012)", 0 )
680/*************************************
681 *
682 *  Game driver(s)
683 *
684 *************************************/
685
686GAME( 1987, chinsan,  0,    chinsan, chinsan, chinsan, ROT0, "Sanritsu", "Ganbare Chinsan Ooshoubu (MC-8123A, 317-5012)", GAME_SUPPORTS_SAVE )
src/mame/drivers/ultrsprt.c
r6740r6741
1212#include "cpu/m68000/m68000.h"
1313#include "cpu/powerpc/ppc.h"
1414#include "sound/k054539.h"
15#include "machine/eeprom.h"
15#include "machine/eepromdev.h"
1616#include "machine/konppc.h"
17#include "machine/konamiic.h"
17#include "sound/k056800.h"
1818
19
1920static UINT32 *vram;
2021static UINT32 *workram;
2122
r6740r6741
6566static WRITE32_HANDLER( eeprom_w )
6667{
6768   if (ACCESSING_BITS_24_31)
68   {
69      eeprom_write_bit((data & 0x01000000) ? 1 : 0);
70      eeprom_set_clock_line((data & 0x02000000) ? CLEAR_LINE : ASSERT_LINE);
71      eeprom_set_cs_line((data & 0x04000000) ? CLEAR_LINE : ASSERT_LINE);
72   }
69      input_port_write(space->machine, "EEPROMOUT", data, 0xffffffff);
7370}
7471
7572static CUSTOM_INPUT( analog_ctrl_r )
r6740r6741
10097   AM_RANGE(0x70000000, 0x70000003) AM_READWRITE(eeprom_r, eeprom_w)
10198   AM_RANGE(0x70000020, 0x70000023) AM_READ_PORT("P1")
10299   AM_RANGE(0x70000040, 0x70000043) AM_READ_PORT("P2")
103   AM_RANGE(0x70000080, 0x70000087) AM_WRITE(K056800_host_w)
104   AM_RANGE(0x70000088, 0x7000008f) AM_READ(K056800_host_r)
100   AM_RANGE(0x70000080, 0x70000087) AM_DEVWRITE("k056800", k056800_host_w)
101   AM_RANGE(0x70000088, 0x7000008f) AM_DEVREAD("k056800", k056800_host_r)
105102   AM_RANGE(0x700000e0, 0x700000e3) AM_WRITE(int_ack_w)
106103   AM_RANGE(0x7f000000, 0x7f01ffff) AM_RAM AM_BASE(&workram)
107104   AM_RANGE(0x7f700000, 0x7f703fff) AM_RAM_WRITE(palette_w) AM_BASE_GENERIC(paletteram)
r6740r6741
114111
115112static READ16_HANDLER( K056800_68k_r )
116113{
114   const device_config *k056800 = devtag_get_device(space->machine, "k056800");
117115   UINT16 r = 0;
118116
119117   if (ACCESSING_BITS_8_15)
120      r |= K056800_sound_r(space, (offset*2)+0, 0xffff) << 8;
118      r |= k056800_sound_r(k056800, (offset*2)+0, 0xffff) << 8;
121119
122120   if (ACCESSING_BITS_0_7)
123      r |= K056800_sound_r(space, (offset*2)+1, 0xffff) << 0;
121      r |= k056800_sound_r(k056800, (offset*2)+1, 0xffff) << 0;
124122
125123   return r;
126124}
127125
128126static WRITE16_HANDLER( K056800_68k_w )
129127{
128   const device_config *k056800 = devtag_get_device(space->machine, "k056800");
129
130130   if (ACCESSING_BITS_8_15)
131      K056800_sound_w(space, (offset*2)+0, (data >> 8) & 0xff, 0x00ff);
131      k056800_sound_w(k056800, (offset*2)+0, (data >> 8) & 0xff, 0x00ff);
132132
133133   if (ACCESSING_BITS_0_7)
134      K056800_sound_w(space, (offset*2)+1, (data >> 0) & 0xff, 0x00ff);
134      k056800_sound_w(k056800, (offset*2)+1, (data >> 0) & 0xff, 0x00ff);
135135}
136136
137137static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 16 )
r6740r6741
160160   PORT_BIT( 0x10000000, IP_ACTIVE_HIGH, IPT_START2 )
161161
162162   PORT_START("SERVICE")
163   PORT_BIT( 0x02000000, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)
163   PORT_BIT( 0x02000000, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
164164   PORT_SERVICE_NO_TOGGLE( 0x08000000, IP_ACTIVE_LOW )
165165
166   PORT_START( "EEPROMOUT" )
167   PORT_BIT( 0x01000000, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
168   PORT_BIT( 0x02000000, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
169   PORT_BIT( 0x04000000, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
170
166171   PORT_START("STICKX1")
167172   PORT_BIT( 0xfff, 0x800, IPT_AD_STICK_X ) PORT_MINMAX(0x000,0xfff) PORT_SENSITIVITY(70) PORT_KEYDELTA(10) PORT_PLAYER(1)
168173
r6740r6741
176181   PORT_BIT( 0xfff, 0x800, IPT_AD_STICK_Y ) PORT_MINMAX(0x000,0xfff) PORT_SENSITIVITY(70) PORT_KEYDELTA(10) PORT_REVERSE PORT_PLAYER(2)
177182INPUT_PORTS_END
178183
179static NVRAM_HANDLER(ultrsprt)
180{
181   if (read_or_write)
182   {
183      eeprom_save(file);
184   }
185   else
186   {
187      eeprom_init(machine, &eeprom_interface_93C46);
188      if (file)
189      {
190         eeprom_load(file);
191      }
192   }
193}
194184
195185static INTERRUPT_GEN( ultrsprt_vblank )
196186{
197187   cpu_set_input_line(device, INPUT_LINE_IRQ1, ASSERT_LINE);
198188}
199189
190static void sound_irq_callback(running_machine *machine, int irq)
191{
192   if (irq == 0)
193      /*generic_pulse_irq_line(cputag_get_cpu(machine, "audiocpu"), INPUT_LINE_IRQ5)*/;
194   else
195      cputag_set_input_line(machine, "audiocpu", INPUT_LINE_IRQ6, HOLD_LINE);
196}
200197
198static const k056800_interface ultrsprt_k056800_interface =
199{
200   sound_irq_callback
201};
202
203
201204static MACHINE_DRIVER_START( ultrsprt )
202205   /* basic machine hardware */
203206   MDRV_CPU_ADD("maincpu", PPC403GA, 25000000)      /* PowerPC 403GA 25MHz */
r6740r6741
210213
211214   MDRV_QUANTUM_TIME(HZ(12000))
212215
213   MDRV_NVRAM_HANDLER(ultrsprt)
216   MDRV_EEPROM_93C46_NODEFAULT_ADD("eeprom")
214217   MDRV_MACHINE_START(ultrsprt)
215218
216219    /* video hardware */
r6740r6741
226229   MDRV_VIDEO_UPDATE(ultrsprt)
227230
228231   /* sound hardware */
232   MDRV_K056800_ADD("k056800", ultrsprt_k056800_interface)
233
229234   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
230235
231236   MDRV_SOUND_ADD("konami", K054539, 48000)
r6740r6741
233238   MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)
234239MACHINE_DRIVER_END
235240
236static void sound_irq_callback(running_machine *machine, int irq)
237{
238   if (irq == 0)
239      /*generic_pulse_irq_line(cputag_get_cpu(machine, "audiocpu"), INPUT_LINE_IRQ5)*/;
240   else
241      cputag_set_input_line(machine, "audiocpu", INPUT_LINE_IRQ6, HOLD_LINE);
242}
243241
244static DRIVER_INIT( ultrsprt )
245{
246   K056800_init(machine, sound_irq_callback);
247}
248
249242/*****************************************************************************/
250243
251244ROM_START( fiveside )
r6740r6741
263256   ROM_LOAD("479_a07.bin", 0x080000, 0x80000, CRC(75835df8) SHA1(105b95c16f2ce6902c2e4c9c2fd9f2f7a848c546))
264257ROM_END
265258
266GAME(1995, fiveside, 0, ultrsprt, ultrsprt, ultrsprt, ROT90, "Konami", "Five a Side Soccer (ver UAA)", GAME_IMPERFECT_SOUND)
259GAME(1995, fiveside, 0, ultrsprt, ultrsprt, 0, ROT90, "Konami", "Five a Side Soccer (ver UAA)", GAME_IMPERFECT_SOUND)
src/mame/drivers/midyunit.c
r6740r6741
116116#include "cpu/tms34010/tms34010.h"
117117#include "audio/williams.h"
118118#include "sound/okim6295.h"
119#include "midyunit.h"
119#include "includes/midyunit.h"
120120
121121
122122/* master clocks vary based on game */
src/mame/drivers/bzone.c
r6740r6741
207207#include "machine/mathbox.h"
208208#include "machine/atari_vg.h"
209209#include "rendlay.h"
210#include "bzone.h"
210#include "includes/bzone.h"
211211
212212#include "sound/pokey.h"
213213
src/mame/drivers/mhavoc.c
r6740r6741
190190#include "video/vector.h"
191191#include "sound/tms5220.h"
192192#include "sound/pokey.h"
193#include "mhavoc.h"
193#include "includes/mhavoc.h"
194194
195195/*************************************
196196 *
r6740r6741
480480   MDRV_CPU_ADD("gamma", M6502, MHAVOC_CLOCK_1_25M)   /* 1.25 MHz */
481481   MDRV_CPU_PROGRAM_MAP(gamma_map)
482482
483   MDRV_MACHINE_START(mhavoc)
483484   MDRV_MACHINE_RESET(mhavoc)
484485   MDRV_NVRAM_HANDLER(generic_1fill)
485486
487   MDRV_TIMER_ADD_PERIODIC("5k_timer", mhavoc_cpu_irq_clock, HZ(MHAVOC_CLOCK_5K))
488
486489   /* video hardware */
487490   MDRV_SCREEN_ADD("screen", VECTOR)
488491   MDRV_SCREEN_REFRESH_RATE(50)
src/mame/drivers/twinkle.c
r6740r6741
241241
242242/* RTC */
243243
244static UINT8 xram[ 4096 ];
245
246static NVRAM_HANDLER(twinkle)
247{
248   if (read_or_write)
249   {
250      rtc65271_file_save(file);
251   }
252   else
253   {
254      if (file != NULL)
255      {
256         rtc65271_file_load(machine, file);
257      }
258   }
259
260   NVRAM_HANDLER_CALL(i2cmem_0);
261}
262
263244static UINT32 twinkle_unknown;
264245
265246static WRITE32_HANDLER( twinkle_unknown_w )
r6740r6741
657638   AM_RANGE(0x1f260000, 0x1f260003) AM_WRITE(serial_w)
658639   AM_RANGE(0x1f270000, 0x1f270003) AM_WRITE(security_w)
659640   AM_RANGE(0x1f280000, 0x1f280003) AM_READ(security_r)
660   AM_RANGE(0x1f290000, 0x1f29007f) AM_READWRITE8(rtc65271_rtc_r, rtc65271_rtc_w, 0x00ff00ff)
661   AM_RANGE(0x1f2a0000, 0x1f2a007f) AM_READWRITE8(rtc65271_xram_r, rtc65271_xram_w, 0x00ff00ff)
641   AM_RANGE(0x1f290000, 0x1f29007f) AM_DEVREADWRITE8("rtc", rtc65271_rtc_r, rtc65271_rtc_w, 0x00ff00ff)
642   AM_RANGE(0x1f2a0000, 0x1f2a007f) AM_DEVREADWRITE8("rtc", rtc65271_xram_r, rtc65271_xram_w, 0x00ff00ff)
662643   AM_RANGE(0x1f2b0000, 0x1f2b00ff) AM_WRITE(twinkle_output_w)
663644   AM_RANGE(0x1f800000, 0x1f8003ff) AM_RAM /* scratchpad */
664645   AM_RANGE(0x1f801000, 0x1f801007) AM_WRITENOP
r6740r6741
894875   psx_dma_install_read_handler(5, scsi_dma_read);
895876   psx_dma_install_write_handler(5, scsi_dma_write);
896877
897   rtc65271_init(machine, xram, NULL);
898
899878   i2cmem_init( machine, 0, I2CMEM_SLAVE_ADDRESS, 0, memory_region_length( machine, "user2" ), memory_region( machine, "user2" ) );
900879   i2cmem_write( machine, 0, I2CMEM_E0, 0 );
901880   i2cmem_write( machine, 0, I2CMEM_E1, 0 );
r6740r6741
936915   MDRV_WATCHDOG_TIME_INIT(MSEC(1200)) /* check TD pin on LTC1232 */
937916
938917   MDRV_MACHINE_RESET( twinkle )
939   MDRV_NVRAM_HANDLER( twinkle )
918   MDRV_NVRAM_HANDLER( i2cmem_0 )
940919
941920   MDRV_IDE_CONTROLLER_ADD("ide", ide_interrupt)
921   MDRV_RTC65271_ADD("rtc", NULL)
942922
943923   /* video hardware */
944924   MDRV_SCREEN_ADD("mainscreen", RASTER)
src/mame/drivers/spool99.c
r6740r6741
9494
9595static UINT8 *spool99_main;
9696static tilemap *sc0_tilemap;
97static UINT8 *spool99_cram;
98static UINT8 *spool99_vram;
9799
98100static TILE_GET_INFO( get_spool99_tile_info )
99101{
100   int code = ((machine->generic.videoram.u8[tile_index*2+1]<<8) | (machine->generic.videoram.u8[tile_index*2+0]));
101   int color = machine->generic.colorram.u8[tile_index*2+0];
102   int code = ((spool99_vram[tile_index*2+1]<<8) | (spool99_vram[tile_index*2+0]));
103   int color = spool99_cram[tile_index*2+0];
102104
103105   SET_TILE_INFO(
104106         0,
r6740r6741
120122
121123static WRITE8_HANDLER( spool99_vram_w )
122124{
123   space->machine->generic.videoram.u8[offset] = data;
125   spool99_vram[offset] = data;
124126   tilemap_mark_tile_dirty(sc0_tilemap,offset/2);
125127}
126128
127129static WRITE8_HANDLER( spool99_cram_w )
128130{
129   space->machine->generic.colorram.u8[offset] = data;
131   spool99_cram[offset] = data;
130132   tilemap_mark_tile_dirty(sc0_tilemap,offset/2);
131133}
132134
r6740r6741
193195   AM_RANGE(0xb000, 0xb3ff) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_le_w) AM_BASE_GENERIC(paletteram) // palette
194196
195197   AM_RANGE(0xb800, 0xdfff) AM_RAM
196   AM_RANGE(0xe000, 0xefff) AM_RAM_WRITE(spool99_vram_w) AM_BASE_GENERIC(videoram)
197   AM_RANGE(0xf000, 0xffff) AM_RAM_WRITE(spool99_cram_w) AM_BASE_GENERIC(colorram)
198   AM_RANGE(0xe000, 0xefff) AM_RAM_WRITE(spool99_vram_w) AM_BASE(&spool99_vram)
199   AM_RANGE(0xf000, 0xffff) AM_RAM_WRITE(spool99_cram_w) AM_BASE(&spool99_cram)
198200ADDRESS_MAP_END
199201
200202
src/mame/drivers/simpl156.c
r6740r6741
8989*/
9090
9191#include "driver.h"
92#include "decocrpt.h"
93#include "deco32.h"
92#include "includes/decocrpt.h"
93#include "includes/deco32.h"
9494#include "cpu/arm/arm.h"
9595#include "machine/eeprom.h"
9696#include "sound/okim6295.h"
97#include "deco16ic.h"
97#include "includes/deco16ic.h"
9898
9999static UINT32 *simpl156_systemram;
100100static const UINT8 *simpl156_default_eeprom;
src/mame/drivers/artmagic.c
r6740r6741
2525#include "cpu/m68000/m68000.h"
2626#include "cpu/tms34010/tms34010.h"
2727#include "video/tlc34076.h"
28#include "artmagic.h"
28#include "includes/artmagic.h"
2929#include "sound/okim6295.h"
3030
3131
r6740r6741
9494   tms_irq = hack_irq = 0;
9595   update_irq_state(machine);
9696   tlc34076_reset(6);
97   tlc34076_state_save(machine);
9897}
9998
10099
src/mame/drivers/twincobr.c
r6740r6741
191191#include "cpu/z80/z80.h"
192192#include "cpu/m68000/m68000.h"
193193#include "cpu/tms32010/tms32010.h"
194#include "twincobr.h"
194#include "includes/twincobr.h"
195195#include "sound/3812intf.h"
196196
197197
src/mame/drivers/hexion.c
r6740r6741
8383#include "deprecat.h"
8484#include "sound/okim6295.h"
8585#include "sound/k051649.h"
86#include "konamipt.h"
86#include "includes/konamipt.h"
8787
8888VIDEO_START( hexion );
8989VIDEO_UPDATE( hexion );
src/mame/drivers/battlnts.c
r6740r6741
11/***************************************************************************
22
3Konami Battlantis Hardware
3    Konami Battlantis Hardware
44
5Supports:
6 GX765 - Rack 'em Up/The Hustler (c) 1987 Konami
7 GX777 - Battlantis (c) 1987 Konami
5    Supports:
6     GX765 - Rack 'em Up/The Hustler (c) 1987 Konami
7     GX777 - Battlantis (c) 1987 Konami
88
9Preliminary driver by: Manuel Abadia <manu@teleline.es>
9    Preliminary driver by: Manuel Abadia <manu@teleline.es>
1010
1111***************************************************************************/
1212
1313#include "driver.h"
1414#include "cpu/hd6309/hd6309.h"
1515#include "cpu/z80/z80.h"
16#include "video/konamiic.h"
1716#include "sound/3812intf.h"
18#include "konamipt.h"
17#include "video/konicdev.h"
18#include "includes/konamipt.h"
19#include "includes/battlnts.h"
1920
20/* from video */
21WRITE8_HANDLER( battlnts_spritebank_w );
22VIDEO_START( battlnts );
23VIDEO_UPDATE( battlnts );
2421
22/*************************************
23 *
24 *  Memory handlers
25 *
26 *************************************/
27
2528static INTERRUPT_GEN( battlnts_interrupt )
2629{
27   if (K007342_is_INT_enabled())
30   battlnts_state *state = (battlnts_state *)device->machine->driver_data;
31   if (k007342_is_int_enabled(state->k007342))
2832      cpu_set_input_line(device, HD6309_IRQ_LINE, HOLD_LINE);
2933}
3034
3135static WRITE8_HANDLER( battlnts_sh_irqtrigger_w )
3236{
33   cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff);
37   battlnts_state *state = (battlnts_state *)space->machine->driver_data;
38   cpu_set_input_line_and_vector(state->audiocpu, 0, HOLD_LINE, 0xff);
3439}
3540
3641static WRITE8_HANDLER( battlnts_bankswitch_w )
3742{
38   UINT8 *RAM = memory_region(space->machine, "maincpu");
39   UINT32 bankaddress;
40
4143   /* bits 6 & 7 = bank number */
42   bankaddress = 0x10000 + ((data & 0xc0) >> 6) * 0x4000;
43   memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]);
44   memory_set_bank(space->machine, "bank1", (data & 0xc0) >> 6);
4445
4546   /* bits 4 & 5 = coin counters */
46   coin_counter_w(space->machine, 0,data & 0x10);
47   coin_counter_w(space->machine, 1,data & 0x20);
47   coin_counter_w(space->machine, 0, data & 0x10);
48   coin_counter_w(space->machine, 1, data & 0x20);
4849
4950   /* other bits unknown */
5051}
5152
53
54/*************************************
55 *
56 *  Address maps
57 *
58 *************************************/
59
5260static ADDRESS_MAP_START( battlnts_map, ADDRESS_SPACE_PROGRAM, 8 )
53   AM_RANGE(0x0000, 0x1fff) AM_READWRITE(K007342_r, K007342_w)   /* Color RAM + Video RAM */
54   AM_RANGE(0x2000, 0x21ff) AM_READWRITE(K007420_r, K007420_w)   /* Sprite RAM */
55   AM_RANGE(0x2200, 0x23ff) AM_READWRITE(K007342_scroll_r, K007342_scroll_w)      /* Scroll RAM */
61   AM_RANGE(0x0000, 0x1fff) AM_DEVREADWRITE("k007342", k007342_r, k007342_w)   /* Color RAM + Video RAM */
62   AM_RANGE(0x2000, 0x21ff) AM_DEVREADWRITE("k007420", k007420_r, k007420_w)   /* Sprite RAM */
63   AM_RANGE(0x2200, 0x23ff) AM_DEVREADWRITE("k007342", k007342_scroll_r, k007342_scroll_w)      /* Scroll RAM */
5664   AM_RANGE(0x2400, 0x24ff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_be_w) AM_BASE_GENERIC(paletteram)/* palette */
57   AM_RANGE(0x2600, 0x2607) AM_WRITE(K007342_vreg_w)          /* Video Registers */
65   AM_RANGE(0x2600, 0x2607) AM_DEVWRITE("k007342", k007342_vreg_w)          /* Video Registers */
5866   AM_RANGE(0x2e00, 0x2e00) AM_READ_PORT("DSW1")
5967   AM_RANGE(0x2e01, 0x2e01) AM_READ_PORT("P2")
6068   AM_RANGE(0x2e02, 0x2e02) AM_READ_PORT("P1")
r6740r6741
7785   AM_RANGE(0xe000, 0xe000) AM_READ(soundlatch_r)         /* soundlatch_r */
7886ADDRESS_MAP_END
7987
80/***************************************************************************
88/*************************************
89 *
90 *  Input ports
91 *
92 *************************************/
8193
82    Input Ports
83
84***************************************************************************/
85
8694static INPUT_PORTS_START( battlnts )
8795   PORT_START("DSW1")
8896   KONAMI_COINAGE_LOC(DEF_STR( Free_Play ), "No Coin B", SW1)
r6740r6741
158166INPUT_PORTS_END
159167
160168
169/*************************************
170 *
171 *  Graphics definitions
172 *
173 *************************************/
174
161175static const gfx_layout charlayout =
162176{
163177   8,8,         /* 8 x 8 characters */
r6740r6741
186200   GFXDECODE_ENTRY( "gfx2", 0, spritelayout, 4*16, 1 ) /* colors 64-79 */
187201GFXDECODE_END
188202
189/***************************************************************************
190203
191    Machine Driver
204/*************************************
205 *
206 *  Machine driver
207 *
208 *************************************/
192209
193***************************************************************************/
210static const k007342_interface bladestl_k007342_intf =
211{
212   0,   battlnts_tile_callback   /* gfx_num (for tile creation), callback */
213};
194214
215static const k007420_interface bladestl_k007420_intf =
216{
217   0x3ff,    battlnts_sprite_callback   /* banklimit, callback */
218};
219
220
221static MACHINE_START( battlnts )
222{
223   battlnts_state *state = (battlnts_state *)machine->driver_data;
224   UINT8 *ROM = memory_region(machine, "maincpu");
225
226   memory_configure_bank(machine, "bank1", 0, 4, &ROM[0x10000], 0x4000);
227
228   state->audiocpu = devtag_get_device(machine, "audiocpu");
229   state->k007342 = devtag_get_device(machine, "k007342");
230   state->k007420 = devtag_get_device(machine, "k007420");
231
232   state_save_register_global(machine, state->spritebank);
233   state_save_register_global_array(machine, state->layer_colorbase);
234}
235
236static MACHINE_RESET( battlnts )
237{
238   battlnts_state *state = (battlnts_state *)machine->driver_data;
239
240   state->layer_colorbase[0] = 0;
241   state->layer_colorbase[1] = 0;
242   state->spritebank = 0;
243}
244
195245static MACHINE_DRIVER_START( battlnts )
196246
247   /* driver data */
248   MDRV_DRIVER_DATA(battlnts_state)
249
197250   /* basic machine hardware */
198251   MDRV_CPU_ADD("maincpu", HD6309, XTAL_24MHz / 2 /* 3000000*4? */)
199252   MDRV_CPU_PROGRAM_MAP(battlnts_map)
r6740r6741
202255   MDRV_CPU_ADD("audiocpu", Z80, XTAL_24MHz / 6 /* 3579545? */)
203256   MDRV_CPU_PROGRAM_MAP(battlnts_sound_map)
204257
258   MDRV_MACHINE_START(battlnts)
259   MDRV_MACHINE_RESET(battlnts)
260
205261   /* video hardware */
206262   MDRV_SCREEN_ADD("screen", RASTER)
207263   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
212268   MDRV_GFXDECODE(battlnts)
213269   MDRV_PALETTE_LENGTH(128)
214270
215   MDRV_VIDEO_START(battlnts)
216271   MDRV_VIDEO_UPDATE(battlnts)
217272
273   MDRV_K007342_ADD("k007342", bladestl_k007342_intf)
274   MDRV_K007420_ADD("k007420", bladestl_k007420_intf)
275
218276   /* sound hardware */
219277   MDRV_SPEAKER_STANDARD_MONO("mono")
220278
r6740r6741
226284MACHINE_DRIVER_END
227285
228286
229/***************************************************************************
287/*************************************
288 *
289 *  ROM definition(s)
290 *
291 *************************************/
230292
231  Game ROMs
232
233***************************************************************************/
234
235293ROM_START( battlnts )
236294   ROM_REGION( 0x20000, "maincpu", 0 ) /* code + banked roms */
237295   ROM_LOAD( "777_g02.7e", 0x08000, 0x08000, CRC(dbd8e17e) SHA1(586a22b714011c67a915c4a350ceca19ff875635) ) /* fixed ROM */
r6740r6741
308366ROM_END
309367
310368
369/*************************************
370 *
371 *  Driver initialization
372 *
373 *************************************/
374
311375/*
312376    This recursive function doesn't use additional memory
313377    (it could be easily converted into an iterative one).
314378    It's called shuffle because it mimics the shuffling of a deck of cards.
315379*/
316static void shuffle(UINT8 *buf,int len)
380static void shuffle( UINT8 *buf, int len )
317381{
318382   int i;
319383   UINT8 t;
320384
321   if (len == 2) return;
385   if (len == 2)
386      return;
322387
323   if (len % 4) fatalerror("shuffle() - not modulo 4");   /* must not happen */
388   if (len % 4)
389      fatalerror("shuffle() - not modulo 4");   /* must not happen */
324390
325391   len /= 2;
326392
327   for (i = 0;i < len/2;i++)
393   for (i = 0; i < len / 2; i++)
328394   {
329      t = buf[len/2 + i];
330      buf[len/2 + i] = buf[len + i];
395      t = buf[len / 2 + i];
396      buf[len / 2 + i] = buf[len + i];
331397      buf[len + i] = t;
332398   }
333399
334   shuffle(buf,len);
335   shuffle(buf + len,len);
400   shuffle(buf, len);
401   shuffle(buf + len, len);
336402}
337403
338404
339405static DRIVER_INIT( rackemup )
340406{
341407   /* rearrange char ROM */
342   shuffle(memory_region(machine, "gfx1"),memory_region_length(machine, "gfx1"));
408   shuffle(memory_region(machine, "gfx1"), memory_region_length(machine, "gfx1"));
343409}
344410
345411
346412
347GAME( 1987, battlnts, 0,        battlnts, battlnts, 0,        ROT90, "Konami", "Battlantis", 0 )
348GAME( 1987, battlntsj,battlnts, battlnts, battlnts, 0,        ROT90, "Konami", "Battlantis (Japan)", 0 )
349GAME( 1987, rackemup, 0,        battlnts, thehustj, rackemup, ROT90, "Konami", "Rack 'em Up", GAME_NO_COCKTAIL )
350GAME( 1987, thehustl, rackemup, battlnts, thehustj, 0,        ROT90, "Konami", "The Hustler (Japan version M)", GAME_NO_COCKTAIL )
351GAME( 1987, thehustlj,rackemup, battlnts, thehustj, 0,        ROT90, "Konami", "The Hustler (Japan version J)", GAME_NO_COCKTAIL )
413/*************************************
414 *
415 *  Game driver(s)
416 *
417 *************************************/
418
419GAME( 1987, battlnts,  0,        battlnts, battlnts, 0,        ROT90, "Konami", "Battlantis", GAME_SUPPORTS_SAVE )
420GAME( 1987, battlntsj, battlnts, battlnts, battlnts, 0,        ROT90, "Konami", "Battlantis (Japan)", GAME_SUPPORTS_SAVE )
421GAME( 1987, rackemup,  0,        battlnts, thehustj, rackemup, ROT90, "Konami", "Rack 'em Up", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
422GAME( 1987, thehustl,  rackemup, battlnts, thehustj, 0,        ROT90, "Konami", "The Hustler (Japan version M)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
423GAME( 1987, thehustlj, rackemup, battlnts, thehustj, 0,        ROT90, "Konami", "The Hustler (Japan version J)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
src/mame/drivers/galpani2.c
r6740r6741
2323#include "cpu/m68000/m68000.h"
2424#include "deprecat.h"
2525#include "machine/eeprom.h"
26#include "kaneko16.h"
26#include "includes/kaneko16.h"
2727#include "sound/okim6295.h"
2828
2929/***************************************************************************
src/mame/drivers/sprint2.c
r6740r6741
1919
2020#include "driver.h"
2121#include "cpu/m6502/m6502.h"
22#include "sprint2.h"
22#include "includes/sprint2.h"
2323#include "sound/discrete.h"
2424
2525#define GAME_IS_SPRINT1   (game == 1)
src/mame/drivers/exterm.c
r6740r6741
6565#include "cpu/m6502/m6502.h"
6666#include "sound/dac.h"
6767#include "sound/2151intf.h"
68#include "exterm.h"
68#include "includes/exterm.h"
6969
7070
7171
r6740r6741
7878static UINT8 aimpos[2];
7979static UINT8 trackball_old[2];
8080
81static emu_timer *sound_nmi_timer;
8281static UINT8 master_sound_latch;
8382static UINT8 slave_sound_latch;
8483static UINT8 sound_control;
r6740r6741
8887
8988/*************************************
9089 *
91 *  Prototypes
92 *
93 *************************************/
94
95static TIMER_CALLBACK( master_sound_nmi_callback );
96
97
98
99/*************************************
100 *
101 *  System init
102 *
103 *************************************/
104
105static MACHINE_RESET( exterm )
106{
107   sound_nmi_timer = timer_alloc(machine, master_sound_nmi_callback, NULL);
108}
109
110
111
112/*************************************
113 *
11490 *  Master/slave communications
11591 *
11692 *************************************/
r6740r6741
232208 *
233209 *************************************/
234210
235static TIMER_CALLBACK( master_sound_nmi_callback )
211static TIMER_DEVICE_CALLBACK( master_sound_nmi_callback )
236212{
237213   /* bit 0 of the sound control determines if the NMI is actually delivered */
238214   if (sound_control & 0x01)
239      cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
215      cputag_set_input_line(timer->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
240216}
241217
242218
r6740r6741
253229   /* this value is latched into up-counters, which are clocked at the */
254230   /* input clock / 256 */
255231   attotime nmi_rate = attotime_mul(ATTOTIME_IN_HZ(4000000), 4096 * (256 - data));
256   timer_adjust_periodic(sound_nmi_timer, nmi_rate, 0, nmi_rate);
232   timer_device_adjust_periodic(devtag_get_device(space->machine, "snd_nmi_timer"), nmi_rate, 0, nmi_rate);
257233}
258234
259235
r6740r6741
488464
489465   MDRV_QUANTUM_TIME(HZ(6000))
490466
491   MDRV_MACHINE_RESET(exterm)
492467   MDRV_NVRAM_HANDLER(generic_0fill)
493468
469   MDRV_TIMER_ADD("snd_nmi_timer", master_sound_nmi_callback)
470
494471   /* video hardware */
495472   MDRV_PALETTE_LENGTH(2048+32768)
496473
src/mame/drivers/dragrace.c
r6740r6741
77#include "driver.h"
88#include "cpu/m6800/m6800.h"
99#include "deprecat.h"
10#include "dragrace.h"
10#include "includes/dragrace.h"
1111#include "sound/discrete.h"
1212
1313
14static TIMER_CALLBACK( dragrace_frame_callback )
14static TIMER_DEVICE_CALLBACK( dragrace_frame_callback )
1515{
16   dragrace_state *state = (dragrace_state *)machine->driver_data;
16   dragrace_state *state = (dragrace_state *)timer->machine->driver_data;
1717   int i;
1818   static const char *const portnames[] = { "P1", "P2" };
1919
2020   for (i = 0; i < 2; i++)
2121   {
22      switch (input_port_read(machine, portnames[i]))
22      switch (input_port_read(timer->machine, portnames[i]))
2323      {
2424      case 0x01: state->gear[i] = 1; break;
2525      case 0x02: state->gear[i] = 2; break;
r6740r6741
3030   }
3131
3232   /* watchdog is disabled during service mode */
33   watchdog_enable(machine, input_port_read(machine, "IN0") & 0x20);
33   watchdog_enable(timer->machine, input_port_read(timer->machine, "IN0") & 0x20);
3434}
3535
3636
r6740r6741
328328{
329329   dragrace_state *state = (dragrace_state *)machine->driver_data;
330330
331   timer_pulse(machine, video_screen_get_frame_period(machine->primary_screen), NULL, 0, dragrace_frame_callback);
332
333331   state->misc_flags = 0;
334332   state->gear[0] = 0;
335333   state->gear[1] = 0;
r6740r6741
349347   MDRV_MACHINE_START(dragrace)
350348   MDRV_MACHINE_RESET(dragrace)
351349
350   MDRV_TIMER_ADD_PERIODIC("frame_timer", dragrace_frame_callback, HZ(60))
351
352352   /* video hardware */
353353   MDRV_SCREEN_ADD("screen", RASTER)
354354   MDRV_SCREEN_REFRESH_RATE(60)
src/mame/drivers/seibuspi.c
r6740r6741
888888   return 0xffffffff;
889889}
890890
891static WRITE32_HANDLER( ds2404_reset_w )
892{
893   if( ACCESSING_BITS_0_7 ) {
894      DS2404_1W_reset_w(space, offset, data);
895   }
896}
897
898static READ32_HANDLER( ds2404_data_r )
899{
900   if( ACCESSING_BITS_0_7 ) {
901      return DS2404_data_r(space, offset);
902   }
903   return 0;
904}
905
906static WRITE32_HANDLER( ds2404_data_w )
907{
908   if( ACCESSING_BITS_0_7 ) {
909      DS2404_data_w(space, offset, data);
910   }
911}
912
913static WRITE32_HANDLER( ds2404_clk_w )
914{
915   if( ACCESSING_BITS_0_7 ) {
916      DS2404_clk_w(space, offset, data);
917   }
918}
919
920891static WRITE32_HANDLER( eeprom_w )
921892{
922893   const device_config *oki2 = devtag_get_device(space->machine, "oki2");
r6740r6741
10901061   AM_RANGE(0x00000680, 0x00000683) AM_WRITE(sound_fifo_w)
10911062   AM_RANGE(0x00000684, 0x00000687) AM_READ(sound_fifo_status_r)
10921063   AM_RANGE(0x00000684, 0x00000687) AM_WRITENOP            /* Unknown */
1093   AM_RANGE(0x000006d0, 0x000006d3) AM_WRITE(ds2404_reset_w)
1094   AM_RANGE(0x000006d4, 0x000006d7) AM_WRITE(ds2404_data_w)
1095   AM_RANGE(0x000006d8, 0x000006db) AM_WRITE(ds2404_clk_w)
1096   AM_RANGE(0x000006dc, 0x000006df) AM_READ(ds2404_data_r)
1064   AM_RANGE(0x000006d0, 0x000006d3) AM_DEVWRITE8("ds2404", ds2404_1w_reset_w, 0x000000ff)
1065   AM_RANGE(0x000006d4, 0x000006d7) AM_DEVWRITE8("ds2404", ds2404_data_w, 0x000000ff)
1066   AM_RANGE(0x000006d8, 0x000006db) AM_DEVWRITE8("ds2404", ds2404_clk_w, 0x000000ff)
1067   AM_RANGE(0x000006dc, 0x000006df) AM_DEVREAD8("ds2404", ds2404_data_r, 0x000000ff)
10971068   AM_RANGE(0x00000800, 0x0003ffff) AM_RAM AM_BASE(&spimainram)
10981069   AM_RANGE(0x00200000, 0x003fffff) AM_ROM AM_SHARE("share2")
10991070   AM_RANGE(0x00a00000, 0x013fffff) AM_READ(soundrom_r)
r6740r6741
18221793
18231794static NVRAM_HANDLER( spi )
18241795{
1825   if( read_or_write ) {
1826      DS2404_save(file);
1827   } else {
1828      DS2404_init(machine, 1995, 1, 1);
1829
1830      if(file) {
1831         DS2404_load(file);
1832      }
1833   }
1834
18351796   nvram_handler_intelflash(machine, 0, file, read_or_write);
18361797   nvram_handler_intelflash(machine, 1, file, read_or_write);
18371798}
r6740r6741
18741835
18751836/* SPI */
18761837
1838static MACHINE_START( spi )
1839{
1840   z80_rom = auto_alloc_array(machine, UINT8, 0x40000);
1841}
1842
18771843static MACHINE_RESET( spi )
18781844{
18791845   int i;
r6740r6741
18891855   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x00000688, 0x0000068b, 0, 0, z80_prg_fifo_w);
18901856   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000068c, 0x0000068f, 0, 0, z80_enable_w);
18911857
1892   z80_rom = auto_alloc_array(machine, UINT8, 0x40000);
18931858   memory_set_bankptr(machine, "bank4", z80_rom);
18941859   memory_set_bankptr(machine, "bank5", z80_rom);
18951860
r6740r6741
19231888
19241889   MDRV_QUANTUM_TIME(HZ(12000))
19251890
1891   MDRV_MACHINE_START(spi)
19261892   MDRV_MACHINE_RESET(spi)
19271893   MDRV_NVRAM_HANDLER(spi)
19281894
1895   MDRV_DS2404_ADD("ds2404", 1995, 1, 1)
1896
19291897    /* video hardware */
19301898   MDRV_SCREEN_ADD("screen", RASTER)
19311899   MDRV_SCREEN_REFRESH_RATE(54)
r6740r6741
19481916   MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)
19491917MACHINE_DRIVER_END
19501918
1919static MACHINE_START( sxx2f )
1920{
1921   z80_rom = auto_alloc_array(machine, UINT8, 0x40000);
1922}
1923
19511924static MACHINE_RESET( sxx2f )
19521925{
19531926   UINT8 *rom = memory_region(machine, "soundcpu");
19541927
1955   z80_rom = auto_alloc_array(machine, UINT8, 0x40000);
19561928   memory_set_bankptr(machine, "bank4", z80_rom);
19571929   memory_set_bankptr(machine, "bank5", z80_rom);
19581930
r6740r6741
19601932
19611933   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000068c, 0x0000068f, 0, 0, eeprom_w);
19621934   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x00000680, 0x00000683, 0, 0, sb_coin_r);
1935
19631936   cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"), spi_irq_callback);
19641937
19651938   sb_coin_latch = 0;
r6740r6741
19691942
19701943   MDRV_IMPORT_FROM(spi)
19711944
1945   MDRV_MACHINE_START(sxx2f)
19721946   MDRV_MACHINE_RESET(sxx2f)
19731947   MDRV_NVRAM_HANDLER(sxx2f)
19741948
r6740r6741
19881962   MDRV_SOUND_ROUTE(0, "lspeaker", 1.0)
19891963   MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)
19901964
1965   MDRV_MACHINE_START(sxx2f)
19911966   MDRV_MACHINE_RESET(sxx2f)
19921967   MDRV_NVRAM_HANDLER(sxx2f)
19931968
src/mame/drivers/coolpool.c
r6740r6741
5454#define NVRAM_UNLOCK_SEQ_LEN (ARRAY_LENGTH(nvram_unlock_seq))
5555static UINT16 nvram_write_seq[NVRAM_UNLOCK_SEQ_LEN];
5656static UINT8 nvram_write_enable;
57static emu_timer *nvram_write_timer;
5857
5958
6059
6160/*************************************
6261 *
63 *  Prototypes
64 *
65 *************************************/
66
67static TIMER_CALLBACK( nvram_write_timeout );
68
69
70
71
72/*************************************
73 *
7462 *  Video updates
7563 *
7664 *************************************/
r6740r6741
148136static MACHINE_RESET( amerdart )
149137{
150138   nvram_write_enable = 0;
151   nvram_write_timer = timer_alloc(machine, nvram_write_timeout, NULL);
152139}
153140
154141
r6740r6741
156143{
157144   tlc34076_reset(6);
158145   nvram_write_enable = 0;
159   nvram_write_timer = timer_alloc(machine, nvram_write_timeout, NULL);
160146}
161147
162148
r6740r6741
167153 *
168154 *************************************/
169155
170static TIMER_CALLBACK( nvram_write_timeout )
156static TIMER_DEVICE_CALLBACK( nvram_write_timeout )
171157{
172158   nvram_write_enable = 0;
173159}
r6740r6741
183169   if (!memcmp(nvram_unlock_seq, nvram_write_seq, sizeof(nvram_unlock_seq)))
184170   {
185171      nvram_write_enable = 1;
186      timer_adjust_oneshot(nvram_write_timer, ATTOTIME_IN_MSEC(1000), 0);
172      timer_device_adjust_oneshot(devtag_get_device(space->machine, "nvram_timer"), ATTOTIME_IN_MSEC(1000), 0);
187173   }
188174}
189175
r6740r6741
695681   MDRV_MACHINE_RESET(amerdart)
696682   MDRV_NVRAM_HANDLER(generic_0fill)
697683
684   MDRV_TIMER_ADD("nvram_timer", nvram_write_timeout)
685
698686   /* video hardware */
699687   MDRV_VIDEO_UPDATE(tms340x0)
700688
r6740r6741
724712   MDRV_MACHINE_RESET(coolpool)
725713   MDRV_NVRAM_HANDLER(generic_0fill)
726714
715   MDRV_TIMER_ADD("nvram_timer", nvram_write_timeout)
716
727717   /* video hardware */
728718   MDRV_VIDEO_UPDATE(tms340x0)
729719
src/mame/drivers/midtunit.c
r6740r6741
2424#include "cpu/adsp2100/adsp2100.h"
2525#include "audio/williams.h"
2626#include "audio/dcs.h"
27#include "midtunit.h"
27#include "includes/midtunit.h"
2828
2929
3030#define CPU_CLOCK      (50000000)
src/mame/drivers/drmicro.c
r6740r6741
1212#include "cpu/z80/z80.h"
1313#include "sound/msm5205.h"
1414#include "sound/sn76496.h"
15#include "drmicro.h"
15#include "includes/drmicro.h"
1616
1717#define MCLK 18432000
1818
src/mame/drivers/niyanpai.c
r6740r6741
3737#include "cpu/m68000/m68000.h"
3838#include "machine/m68kfmly.h"
3939#include "machine/z80ctc.h"
40#include "nb1413m3.h"
40#include "includes/nb1413m3.h"
4141#include "sound/dac.h"
4242#include "sound/3812intf.h"
4343#include "cpu/z80/z80daisy.h"
src/mame/drivers/suprnova.c
r6740r6741
449449/* start old driver code */
450450
451451
452static TIMER_CALLBACK( interrupt_callback )
452static TIMER_DEVICE_CALLBACK( interrupt_callback )
453453{
454   cputag_set_input_line(machine, "maincpu", param, HOLD_LINE);
454   cputag_set_input_line(timer->machine, "maincpu", param, HOLD_LINE);
455455}
456456
457457static MACHINE_RESET(skns)
458458{
459   timer_pulse(machine, ATTOTIME_IN_MSEC(2), NULL, 15, interrupt_callback);
460   timer_pulse(machine, ATTOTIME_IN_MSEC(8), NULL, 11, interrupt_callback);
461   timer_pulse(machine, cputag_clocks_to_attotime(machine, "maincpu", 1824), NULL, 9, interrupt_callback);
462
463459   memory_set_bankptr(machine, "bank1",memory_region(machine, "user1"));
464460}
465461
r6740r6741
842838   MDRV_MACHINE_RESET(skns)
843839   MDRV_NVRAM_HANDLER(generic_1fill)
844840
841   MDRV_TIMER_ADD_PERIODIC("int15_timer", interrupt_callback, MSEC(2))
842   MDRV_TIMER_PARAM(15)
843   MDRV_TIMER_ADD_PERIODIC("int11_timer", interrupt_callback, MSEC(8))
844   MDRV_TIMER_PARAM(11)
845   MDRV_TIMER_ADD_PERIODIC("int9_timer", interrupt_callback, HZ(28638000/1824))
846   MDRV_TIMER_PARAM(9)
847
845848   MDRV_VIDEO_ATTRIBUTES(VIDEO_ALWAYS_UPDATE)
846849
847850   MDRV_SCREEN_ADD("screen", RASTER)
src/mame/drivers/namcofl.c
r6740r6741
158158#include "driver.h"
159159#include "deprecat.h"
160160#include "machine/eeprom.h"
161#include "namconb1.h"
162#include "namcos2.h"
163#include "namcoic.h"
161#include "includes/namconb1.h"
162#include "includes/namcos2.h"
163#include "includes/namcoic.h"
164164#include "cpu/i960/i960.h"
165165#include "cpu/m37710/m37710.h"
166166#include "sound/c352.h"
src/mame/drivers/luckgrln.c
r6740r6741
7575
7676#include "driver.h"
7777#include "cpu/z180/z180.h"
78#include "video/mc6845.h"
7879
7980
8081static ADDRESS_MAP_START( mainmap, ADDRESS_SPACE_PROGRAM, 8 )
r6740r6741
8788
8889static ADDRESS_MAP_START( portmap, ADDRESS_SPACE_IO, 8 )
8990   ADDRESS_MAP_GLOBAL_MASK(0xff) // i think
90   AM_RANGE( 0x0000, 0x003f ) AM_RAM // Z180 internal regs
91   AM_RANGE(0x0000, 0x003f) AM_RAM // Z180 internal regs
92   AM_RANGE(0x00b0, 0x00b0) AM_DEVWRITE("crtc", mc6845_address_w)
93   AM_RANGE(0x00b1, 0x00b1) AM_DEVWRITE("crtc", mc6845_register_w)
9194ADDRESS_MAP_END
9295
9396
r6740r6741
120123   return 0;
121124}
122125
126static const mc6845_interface mc6845_intf =
127{
128   "screen",   /* screen we are acting on */
129   8,         /* number of pixels per video memory address */
130   NULL,      /* before pixel update callback */
131   NULL,      /* row update callback */
132   NULL,      /* after pixel update callback */
133   DEVCB_NULL,   /* callback for display state changes */
134   DEVCB_NULL,   /* callback for cursor state changes */
135   DEVCB_NULL,   /* HSYNC callback */
136   DEVCB_NULL,   /* VSYNC callback */
137   NULL      /* update address callback */
138};
139
123140static MACHINE_DRIVER_START( luckgrln )
124141   MDRV_CPU_ADD("maincpu", Z180,8000000)
125142   MDRV_CPU_PROGRAM_MAP(mainmap)
126143   MDRV_CPU_IO_MAP(portmap)
127144   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
128145
146   MDRV_MC6845_ADD("crtc", H46505, 6000000/4, mc6845_intf)   /* unknown clock, hand tuned to get ~60 fps */
147
148
129149   MDRV_SCREEN_ADD("screen", RASTER)
130150   MDRV_SCREEN_REFRESH_RATE(60)
131151   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
src/mame/drivers/volfied.c
r6740r6741
5050#include "driver.h"
5151#include "cpu/z80/z80.h"
5252#include "cpu/m68000/m68000.h"
53#include "taitoipt.h"
53#include "includes/taitoipt.h"
5454#include "video/taitoic.h"
5555#include "audio/taitosnd.h"
5656#include "sound/2203intf.h"
src/mame/drivers/dribling.c
r6740r6741
2828#include "driver.h"
2929#include "cpu/z80/z80.h"
3030#include "machine/8255ppi.h"
31#include "dribling.h"
31#include "includes/dribling.h"
3232
3333
3434
src/mame/drivers/megadriv.c
r6740r6741
163163static int megadrive_max_hposition;
164164
165165
166static emu_timer* frame_timer;
167static emu_timer* scanline_timer;
168static emu_timer* irq6_on_timer;
169static emu_timer* irq4_on_timer;
166static const device_config* frame_timer;
167static const device_config* scanline_timer;
168static const device_config* irq6_on_timer;
169static const device_config* irq4_on_timer;
170170static bitmap_t* render_bitmap;
171171//emu_timer* vblankirq_off_timer;
172172
r6740r6741
14311431   for (i=0; i<3; i++)
14321432   {
14331433      io_timeout[i] = timer_alloc(machine, io_timeout_timer_callback, (void*)(FPTR)i);
1434      io_stage[i] = -1;
14351434   }
14361435}
14371436
r6740r6741
16501649{
16511650   const input_port_token *ipt = machine->gamedrv->ipt;
16521651
1652   if (ipt == INPUT_PORTS_NAME(megadri6))
1653      init_megadri6_io(machine);
1654
1655   if (ipt == INPUT_PORTS_NAME(ssf2ghw))
1656      init_megadri6_io(machine);
1657}
1658
1659static void megadrive_reset_io(running_machine *machine)
1660{
1661   int i;
1662
16531663   megadrive_io_data_regs[0] = 0x7f;
16541664   megadrive_io_data_regs[1] = 0x7f;
16551665   megadrive_io_data_regs[2] = 0x7f;
r6740r6741
16601670   megadrive_io_tx_regs[1] = 0xff;
16611671   megadrive_io_tx_regs[2] = 0xff;
16621672
1663   if (ipt == INPUT_PORTS_NAME(megadri6))
1664      init_megadri6_io(machine);
1665
1666   if (ipt == INPUT_PORTS_NAME(ssf2ghw))
1667      init_megadri6_io(machine);
1673   for (i=0; i<3; i++)
1674   {
1675      io_stage[i] = -1;
1676   }
16681677}
16691678
16701679/************* 6 buttons version **************************/
r6740r6741
38383847//  int xxx;
38393848   /* reference */
38403849
3841//  time_elapsed_since_crap = timer_timeelapsed(frame_timer);
3850//  time_elapsed_since_crap = timer_device_timeelapsed(frame_timer);
38423851//  xxx = cputag_attotime_to_clocks(screen->machine, "maincpu", time_elapsed_since_crap);
38433852//  mame_printf_debug("update cycles %d, %08x %08x\n",xxx, (UINT32)(time_elapsed_since_crap.attoseconds>>32),(UINT32)(time_elapsed_since_crap.attoseconds&0xffffffff));
38443853
r6740r6741
38473856
38483857
38493858
3850static TIMER_CALLBACK( frame_timer_callback )
3859static TIMER_DEVICE_CALLBACK( frame_timer_callback )
38513860{
38523861   /* callback */
38533862}
r6740r6741
53835392   attotime time_elapsed_since_scanline_timer;
53845393   UINT16 value4;
53855394
5386   time_elapsed_since_scanline_timer = timer_timeelapsed(scanline_timer);
5395   time_elapsed_since_scanline_timer = timer_device_timeelapsed(scanline_timer);
53875396
53885397   if (time_elapsed_since_scanline_timer.attoseconds<(ATTOSECONDS_PER_SECOND/megadriv_framerate /megadrive_total_scanlines))
53895398   {
r6740r6741
56715680
56725681static int irq4counter;
56735682
5674static emu_timer* render_timer;
5683static const device_config* render_timer;
56755684
5676static TIMER_CALLBACK( render_timer_callback )
5685static TIMER_DEVICE_CALLBACK( render_timer_callback )
56775686{
56785687   if (genesis_scanline_counter>=0 && genesis_scanline_counter<megadrive_visible_scanlines)
56795688   {
5680      genesis_render_scanline(machine, genesis_scanline_counter);
5689      genesis_render_scanline(timer->machine, genesis_scanline_counter);
56815690   }
56825691}
56835692
56845693
5685static TIMER_CALLBACK( scanline_timer_callback )
5694static TIMER_DEVICE_CALLBACK( scanline_timer_callback )
56865695{
56875696   /* This function is called at the very start of every scanline starting at the very
56885697       top-left of the screen.  The first scanline is scanline 0 (we set scanline to -1 in
56895698       VIDEO_EOF) */
56905699
5691   timer_call_after_resynch(machine, NULL, 0, 0);
5700   timer_call_after_resynch(timer->machine, NULL, 0, 0);
56925701   /* Compensate for some rounding errors
56935702
56945703       When the counter reaches 261 we should have reached the end of the frame, however due
r6740r6741
57005709   {
57015710      genesis_scanline_counter++;
57025711//      mame_printf_debug("scanline %d\n",genesis_scanline_counter);
5703      timer_adjust_oneshot(scanline_timer, attotime_div(ATTOTIME_IN_HZ(megadriv_framerate), megadrive_total_scanlines), 0);
5704      timer_adjust_oneshot(render_timer, ATTOTIME_IN_USEC(1), 0);
5712      timer_device_adjust_oneshot(scanline_timer, attotime_div(ATTOTIME_IN_HZ(megadriv_framerate), megadrive_total_scanlines), 0);
5713      timer_device_adjust_oneshot(render_timer, ATTOTIME_IN_USEC(1), 0);
57055714
57065715      if (genesis_scanline_counter==megadrive_irq6_scanline )
57075716      {
57085717      //  mame_printf_debug("x %d",genesis_scanline_counter);
5709         timer_adjust_oneshot(irq6_on_timer,  ATTOTIME_IN_USEC(6), 0);
5718         timer_device_adjust_oneshot(irq6_on_timer,  ATTOTIME_IN_USEC(6), 0);
57105719         megadrive_irq6_pending = 1;
57115720         megadrive_vblank_flag = 1;
57125721
r6740r6741
57435752
57445753            if (MEGADRIVE_REG0_IRQ4_ENABLE)
57455754            {
5746               timer_adjust_oneshot(irq4_on_timer,  ATTOTIME_IN_USEC(1), 0);
5755               timer_device_adjust_oneshot(irq4_on_timer,  ATTOTIME_IN_USEC(1), 0);
57475756               //mame_printf_debug("irq4 on scanline %d reload %d\n",genesis_scanline_counter,MEGADRIVE_REG0A_HINT_VALUE);
57485757            }
57495758         }
r6740r6741
57545763         else irq4counter=MEGADRIVE_REG0A_HINT_VALUE;
57555764      }
57565765
5757      //if (genesis_scanline_counter==0) timer_adjust_oneshot(irq4_on_timer,  ATTOTIME_IN_USEC(2), 0);
5766      //if (genesis_scanline_counter==0) timer_device_adjust_oneshot(irq4_on_timer,  ATTOTIME_IN_USEC(2), 0);
57585767
57595768
57605769
57615770
5762      if (cputag_get_cpu(machine, "genesis_snd_z80") != NULL)
5771      if (cputag_get_cpu(timer->machine, "genesis_snd_z80") != NULL)
57635772      {
57645773         if (genesis_scanline_counter == megadrive_z80irq_scanline)
57655774         {
57665775            if ((genz80.z80_has_bus == 1) && (genz80.z80_is_reset == 0))
5767               cputag_set_input_line(machine, "genesis_snd_z80", 0, HOLD_LINE);
5776               cputag_set_input_line(timer->machine, "genesis_snd_z80", 0, HOLD_LINE);
57685777         }
57695778         if (genesis_scanline_counter == megadrive_z80irq_scanline + 1)
57705779         {
5771            cputag_set_input_line(machine, "genesis_snd_z80", 0, CLEAR_LINE);
5780            cputag_set_input_line(timer->machine, "genesis_snd_z80", 0, CLEAR_LINE);
57725781         }
57735782      }
57745783
r6740r6741
57805789
57815790}
57825791
5783static TIMER_CALLBACK( irq6_on_callback )
5792static TIMER_DEVICE_CALLBACK( irq6_on_callback )
57845793{
57855794   //mame_printf_debug("irq6 active on %d\n",genesis_scanline_counter);
57865795
57875796   {
57885797//      megadrive_irq6_pending = 1;
57895798      if (MEGADRIVE_REG01_IRQ6_ENABLE || genesis_always_irq6)
5790         cputag_set_input_line(machine, "maincpu", 6, HOLD_LINE);
5799         cputag_set_input_line(timer->machine, "maincpu", 6, HOLD_LINE);
57915800   }
57925801}
57935802
5794static TIMER_CALLBACK( irq4_on_callback )
5803static TIMER_DEVICE_CALLBACK( irq4_on_callback )
57955804{
57965805   //mame_printf_debug("irq4 active on %d\n",genesis_scanline_counter);
5797   cputag_set_input_line(machine, "maincpu", 4, HOLD_LINE);
5806   cputag_set_input_line(timer->machine, "maincpu", 4, HOLD_LINE);
57985807}
57995808
58005809/*****************************************************************************************/
r6740r6741
58035812static int hazemdchoice_megadrive_region_pal;
58045813static int hazemdchoice_megadriv_framerate;
58055814
5815MACHINE_START( megadriv )
5816{
5817   megadrive_init_io(machine);
5818}
5819
58065820MACHINE_RESET( megadriv )
58075821{
58085822   /* default state of z80 = reset, with bus */
r6740r6741
58535867
58545868   megadrive_imode = 0;
58555869
5856   megadrive_init_io(machine);
5870   megadrive_reset_io(machine);
58575871
5858   frame_timer = timer_alloc(machine, frame_timer_callback, NULL);
5859   scanline_timer = timer_alloc(machine, scanline_timer_callback, NULL);
5860   render_timer = timer_alloc(machine, render_timer_callback, NULL);
5872   frame_timer = devtag_get_device(machine, "frame_timer");
5873   scanline_timer = devtag_get_device(machine, "scanline_timer");
5874   render_timer = devtag_get_device(machine, "render_timer");
58615875
5862   irq6_on_timer = timer_alloc(machine, irq6_on_callback, NULL);
5863   irq4_on_timer = timer_alloc(machine, irq4_on_callback, NULL);
5876   irq6_on_timer = devtag_get_device(machine, "irq6_timer");
5877   irq4_on_timer = devtag_get_device(machine, "irq4_timer");
58645878
5865   timer_adjust_oneshot(frame_timer, attotime_zero, 0);
5866   timer_adjust_oneshot(scanline_timer, attotime_zero, 0);
5879   timer_device_adjust_oneshot(frame_timer, attotime_zero, 0);
5880   timer_device_adjust_oneshot(scanline_timer, attotime_zero, 0);
58675881
58685882   if (genesis_other_hacks)
58695883   {
r6740r6741
59025916
59035917void megadriv_stop_scanline_timer(void)
59045918{
5905   timer_adjust_oneshot(scanline_timer,  attotime_never, 0);
5919   timer_device_adjust_oneshot(scanline_timer,  attotime_never, 0);
59065920}
59075921
59085922/*
r6740r6741
60146028   //  /* reference */
60156029      frametime = ATTOSECONDS_PER_SECOND/megadriv_framerate;
60166030
6017      //time_elapsed_since_crap = timer_timeelapsed(frame_timer);
6031      //time_elapsed_since_crap = timer_device_timeelapsed(frame_timer);
60186032      //xxx = cputag_attotime_to_clocks(machine, "maincpu",time_elapsed_since_crap);
60196033      //mame_printf_debug("---------- cycles %d, %08x %08x\n",xxx, (UINT32)(time_elapsed_since_crap.attoseconds>>32),(UINT32)(time_elapsed_since_crap.attoseconds&0xffffffff));
60206034      //mame_printf_debug("---------- framet %d, %08x %08x\n",xxx, (UINT32)(frametime>>32),(UINT32)(frametime&0xffffffff));
6021      timer_adjust_oneshot(frame_timer,  attotime_zero, 0);
6035      timer_device_adjust_oneshot(frame_timer,  attotime_zero, 0);
60226036   }
60236037
6024   timer_adjust_oneshot(scanline_timer,  attotime_zero, 0);
6038   timer_device_adjust_oneshot(scanline_timer,  attotime_zero, 0);
60256039
60266040}
60276041
r6740r6741
60546068#endif
60556069
60566070
6071MACHINE_DRIVER_START( megadriv_timers )
6072   MDRV_TIMER_ADD("frame_timer", frame_timer_callback)
6073   MDRV_TIMER_ADD("scanline_timer", scanline_timer_callback)
6074   MDRV_TIMER_ADD("render_timer", render_timer_callback)
6075   MDRV_TIMER_ADD("irq6_timer", irq6_on_callback)
6076   MDRV_TIMER_ADD("irq4_timer", irq4_on_callback)
6077MACHINE_DRIVER_END
6078
6079
60576080MACHINE_DRIVER_START( megadriv )
60586081   MDRV_CPU_ADD("maincpu", M68000, MASTER_CLOCK_NTSC / 7) /* 7.67 MHz */
60596082   MDRV_CPU_PROGRAM_MAP(megadriv_map)
r6740r6741
60646087   MDRV_CPU_IO_MAP(megadriv_z80_io_map)
60656088   /* IRQ handled via the timers */
60666089
6090   MDRV_MACHINE_START(megadriv)
60676091   MDRV_MACHINE_RESET(megadriv)
60686092
6093   MDRV_IMPORT_FROM(megadriv_timers)
6094
60696095   MDRV_SCREEN_ADD("megadriv", RASTER)
60706096   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB15)
60716097   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
61086134   MDRV_CPU_IO_MAP(megadriv_z80_io_map)
61096135   /* IRQ handled via the timers */
61106136
6137   MDRV_MACHINE_START(megadriv)
61116138   MDRV_MACHINE_RESET(megadriv)
61126139
6140   MDRV_IMPORT_FROM(megadriv_timers)
6141
61136142   MDRV_SCREEN_ADD("megadriv", RASTER)
61146143   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB15)
61156144   MDRV_SCREEN_REFRESH_RATE(50)
src/mame/drivers/itech32.c
r6740r6741
352352#include "cpu/m68000/m68000.h"
353353#include "machine/6522via.h"
354354#include "machine/ticket.h"
355#include "itech32.h"
355#include "includes/itech32.h"
356356#include "sound/es5506.h"
357357#include "machine/timekpr.h"
358358#include "devconv.h"
r6740r6741
468468   sound_data = 0;
469469   sound_return = 0;
470470   sound_int_state = 0;
471
472   /* reset the ticket dispenser */
473   ticket_dispenser_init(machine, 200, TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_HIGH);
474471}
475472
476473
r6740r6741
735732   set_led_status(space->machine, 1, data & 0x01);
736733   set_led_status(space->machine, 2, data & 0x02);
737734   set_led_status(space->machine, 3, data & 0x04);
738   ticket_dispenser_w(space, 0, (data & 0x10) << 3);
735   ticket_dispenser_w(devtag_get_device(device->machine, "ticket"), 0, (data & 0x10) << 3);
739736   coin_counter_w(space->machine, 0, (data & 0x20) >> 5);
740737}
741738
r6740r6741
754751   /* bit 4 controls the ticket dispenser */
755752   /* bit 5 controls the coin counter */
756753   /* bit 6 controls the diagnostic sound LED */
757   ticket_dispenser_w(space, 0, (data & 0x10) << 3);
754   ticket_dispenser_w(devtag_get_device(device->machine, "ticket"), 0, (data & 0x10) << 3);
758755   coin_counter_w(space->machine, 0, (data & 0x20) >> 5);
759756}
760757
r6740r6741
17381735   MDRV_MACHINE_RESET(itech32)
17391736   MDRV_NVRAM_HANDLER(itech32)
17401737
1738   MDRV_TICKET_DISPENSER_ADD("ticket", 200, TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_HIGH)
1739
17411740   /* video hardware */
17421741   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
17431742   MDRV_PALETTE_LENGTH(8192)
r6740r6741
41234122 *
41244123 *************************************/
41254124
4126GAME( 1992, timekill, 0,        timekill, timekill, timekill, ROT0, "Strata/Incredible Technologies", "Time Killers (v1.32)", 0 )
4125GAME( 1992, timekill,    0,        timekill, timekill, timekill, ROT0, "Strata/Incredible Technologies", "Time Killers (v1.32)", 0 )
41274126GAME( 1992, timekill131, timekill, timekill, timekill, timekill, ROT0, "Strata/Incredible Technologies", "Time Killers (v1.31)", 0 )
4128GAME( 1993, hardyard, 0,        bloodstm, hardyard, hardyard, ROT0, "Strata/Incredible Technologies", "Hard Yardage (v1.20)", 0 )
4129GAME( 1993, hardyard10, hardyard, bloodstm, hardyard, hardyard, ROT0, "Strata/Incredible Technologies", "Hard Yardage (v1.00)", 0 )
4130GAME( 1994, bloodstm, 0,        bloodstm, bloodstm, bloodstm, ROT0, "Strata/Incredible Technologies", "Blood Storm (v2.22)", 0 )
4131GAME( 1994, bloodstm22, bloodstm, bloodstm, bloodstm, bloodstm, ROT0, "Strata/Incredible Technologies", "Blood Storm (v2.20)", 0 )
4132GAME( 1994, bloodstm21, bloodstm, bloodstm, bloodstm, bloodstm, ROT0, "Strata/Incredible Technologies", "Blood Storm (v2.10)", 0 )
4133GAME( 1994, bloodstm11, bloodstm, bloodstm, bloodstm, bloodstm, ROT0, "Strata/Incredible Technologies", "Blood Storm (v1.10)", 0 )
4134GAME( 1994, pairs,    0,        bloodstm, pairs,    bloodstm, ROT0, "Strata/Incredible Technologies", "Pairs (V1.2, 09/30/94)", 0 )
4135GAME( 1994, pairsa,   pairs,    bloodstm, pairs,    bloodstm, ROT0, "Strata/Incredible Technologies", "Pairs (09/07/94)", 0 )
4136GAME( 1994, hotmemry, pairs,    bloodstm, pairs,    bloodstm, ROT0, "Tuning/Incredible Technologies", "Hot Memory (V1.2, Germany)", 0 )
4137GAME( 1994, drivedge, 0,        drivedge, drivedge, drivedge, ROT0, "Strata/Incredible Technologies", "Driver's Edge", GAME_IMPERFECT_GRAPHICS )
4138GAME( 1995, wcbowl,   0,        sftm,     wcbowln,  wcbowln,  ROT0, "Incredible Technologies",        "World Class Bowling (v1.66)" , 0) /* PIC 16C54 labeled as ITBWL-3 */
4139GAME( 1995, wcbowl165, wcbowl,   sftm,     shufbowl, wcbowln,  ROT0, "Incredible Technologies",        "World Class Bowling (v1.65)" , 0) /* PIC 16C54 labeled as ITBWL-3 */
4140GAME( 1995, wcbowl161, wcbowl,   sftm,     shufbowl, wcbowln,  ROT0, "Incredible Technologies",        "World Class Bowling (v1.61)" , 0) /* PIC 16C54 labeled as ITBWL-3 */
4141GAME( 1995, wcbowl16,  wcbowl,   sftm,     shufbowl, wcbowln,  ROT0, "Incredible Technologies",        "World Class Bowling (v1.6)" , 0) /* PIC 16C54 labeled as ITBWL-3 */
4142GAME( 1995, wcbowl15,  wcbowl,   bloodstm, wcbowl,   wcbowl,   ROT0, "Incredible Technologies",        "World Class Bowling (v1.5)" , 0) /* PIC 16C54 labeled as ITBWL-1 */
4143GAME( 1995, wcbowl13,  wcbowl,   bloodstm, wcbowl,   wcbowl,   ROT0, "Incredible Technologies",        "World Class Bowling (v1.3)" , 0) /* PIC 16C54 labeled as ITBWL-1 */
4144GAME( 1995, wcbowl12,  wcbowl,   bloodstm, wcbowl,   wcbowl,   ROT0, "Incredible Technologies",        "World Class Bowling (v1.2)" , 0) /* PIC 16C54 labeled as ITBWL-1 */
4145GAME( 1995, sftm,     0,        sftm,     sftm,     sftm,     ROT0, "Capcom/Incredible Technologies", "Street Fighter: The Movie (v1.12)" , 0) /* PIC 16C54 labeled as ITSF-1 */
4146GAME( 1995, sftm111,  sftm,     sftm,     sftm,     sftm110,  ROT0, "Capcom/Incredible Technologies", "Street Fighter: The Movie (v1.11)" , 0) /* PIC 16C54 labeled as ITSF-1 */
4147GAME( 1995, sftm110,  sftm,     sftm,     sftm,     sftm110,  ROT0, "Capcom/Incredible Technologies", "Street Fighter: The Movie (v1.10)" , 0) /* PIC 16C54 labeled as ITSF-1 */
4148GAME( 1995, sftmj,    sftm,     sftm,     sftm,     sftm,     ROT0, "Capcom/Incredible Technologies", "Street Fighter: The Movie (v1.12N, Japan)" , 0) /* PIC 16C54 labeled as ITSF-1 */
4149GAME( 1997, shufshot, 0,        sftm,     shufshot, shufshot, ROT0, "Strata/Incredible Technologies", "Shuffleshot (v1.40)" , 0) /* PIC 16C54 labeled as ITSHF-1 */
4127GAME( 1993, hardyard,    0,        bloodstm, hardyard, hardyard, ROT0, "Strata/Incredible Technologies", "Hard Yardage (v1.20)", 0 )
4128GAME( 1993, hardyard10,  hardyard, bloodstm, hardyard, hardyard, ROT0, "Strata/Incredible Technologies", "Hard Yardage (v1.00)", 0 )
4129GAME( 1994, bloodstm,    0,        bloodstm, bloodstm, bloodstm, ROT0, "Strata/Incredible Technologies", "Blood Storm (v2.22)", 0 )
4130GAME( 1994, bloodstm22,  bloodstm, bloodstm, bloodstm, bloodstm, ROT0, "Strata/Incredible Technologies", "Blood Storm (v2.20)", 0 )
4131GAME( 1994, bloodstm21,  bloodstm, bloodstm, bloodstm, bloodstm, ROT0, "Strata/Incredible Technologies", "Blood Storm (v2.10)", 0 )
4132GAME( 1994, bloodstm11,  bloodstm, bloodstm, bloodstm, bloodstm, ROT0, "Strata/Incredible Technologies", "Blood Storm (v1.10)", 0 )
4133GAME( 1994, pairs,       0,        bloodstm, pairs,    bloodstm, ROT0, "Strata/Incredible Technologies", "Pairs (V1.2, 09/30/94)", 0 )
4134GAME( 1994, pairsa,      pairs,    bloodstm, pairs,    bloodstm, ROT0, "Strata/Incredible Technologies", "Pairs (09/07/94)", 0 )
4135GAME( 1994, hotmemry,    pairs,    bloodstm, pairs,    bloodstm, ROT0, "Tuning/Incredible Technologies", "Hot Memory (V1.2, Germany)", 0 )
4136GAME( 1994, drivedge,    0,        drivedge, drivedge, drivedge, ROT0, "Strata/Incredible Technologies", "Driver's Edge", GAME_IMPERFECT_GRAPHICS )
4137GAME( 1995, wcbowl,      0,        sftm,     wcbowln,  wcbowln,  ROT0, "Incredible Technologies",        "World Class Bowling (v1.66)" , 0) /* PIC 16C54 labeled as ITBWL-3 */
4138GAME( 1995, wcbowl165,   wcbowl,   sftm,     shufbowl, wcbowln,  ROT0, "Incredible Technologies",        "World Class Bowling (v1.65)" , 0) /* PIC 16C54 labeled as ITBWL-3 */
4139GAME( 1995, wcbowl161,   wcbowl,   sftm,     shufbowl, wcbowln,  ROT0, "Incredible Technologies",        "World Class Bowling (v1.61)" , 0) /* PIC 16C54 labeled as ITBWL-3 */
4140GAME( 1995, wcbowl16,    wcbowl,   sftm,     shufbowl, wcbowln,  ROT0, "Incredible Technologies",        "World Class Bowling (v1.6)" , 0) /* PIC 16C54 labeled as ITBWL-3 */
4141GAME( 1995, wcbowl15,    wcbowl,   bloodstm, wcbowl,   wcbowl,   ROT0, "Incredible Technologies",        "World Class Bowling (v1.5)" , 0) /* PIC 16C54 labeled as ITBWL-1 */
4142GAME( 1995, wcbowl13,    wcbowl,   bloodstm, wcbowl,   wcbowl,   ROT0, "Incredible Technologies",        "World Class Bowling (v1.3)" , 0) /* PIC 16C54 labeled as ITBWL-1 */
4143GAME( 1995, wcbowl12,    wcbowl,   bloodstm, wcbowl,   wcbowl,   ROT0, "Incredible Technologies",        "World Class Bowling (v1.2)" , 0) /* PIC 16C54 labeled as ITBWL-1 */
4144GAME( 1995, sftm,        0,        sftm,     sftm,     sftm,     ROT0, "Capcom/Incredible Technologies", "Street Fighter: The Movie (v1.12)" , 0) /* PIC 16C54 labeled as ITSF-1 */
4145GAME( 1995, sftm111,     sftm,     sftm,     sftm,     sftm110,  ROT0, "Capcom/Incredible Technologies", "Street Fighter: The Movie (v1.11)" , 0) /* PIC 16C54 labeled as ITSF-1 */
4146GAME( 1995, sftm110,     sftm,     sftm,     sftm,     sftm110,  ROT0, "Capcom/Incredible Technologies", "Street Fighter: The Movie (v1.10)" , 0) /* PIC 16C54 labeled as ITSF-1 */
4147GAME( 1995, sftmj,       sftm,     sftm,     sftm,     sftm,     ROT0, "Capcom/Incredible Technologies", "Street Fighter: The Movie (v1.12N, Japan)" , 0) /* PIC 16C54 labeled as ITSF-1 */
4148GAME( 1997, shufshot,    0,        sftm,     shufshot, shufshot, ROT0, "Strata/Incredible Technologies", "Shuffleshot (v1.40)" , 0) /* PIC 16C54 labeled as ITSHF-1 */
41504149GAME( 1997, shufshot139, shufshot, sftm,     shufshot, shufshot, ROT0, "Strata/Incredible Technologies", "Shuffleshot (v1.39)" , 0) /* PIC 16C54 labeled as ITSHF-1 */
41514150GAME( 1997, shufshot137, shufshot, sftm,     shufbowl, shufshot, ROT0, "Strata/Incredible Technologies", "Shuffleshot (v1.37)" , 0) /* PIC 16C54 labeled as ITSHF-1 */
4152GAME( 1997, wcbowl140, wcbowldx, tourny,   wcbowldx, wcbowlt,  ROT0, "Incredible Technologies",        "World Class Bowling Tournament (v1.40)" , 0) /* PIC 16C54 labeled as ITBWL-3 */
4153GAME( 1999, wcbowldx, 0,        sftm,     wcbowldx, shufshot, ROT0, "Incredible Technologies",        "World Class Bowling Deluxe (v2.00)" , 0) /* PIC 16C54 labeled as ITBWL-4 */
4151GAME( 1997, wcbowl140,   wcbowldx, tourny,   wcbowldx, wcbowlt,  ROT0, "Incredible Technologies",        "World Class Bowling Tournament (v1.40)" , 0) /* PIC 16C54 labeled as ITBWL-3 */
4152GAME( 1999, wcbowldx,    0,        sftm,     wcbowldx, shufshot, ROT0, "Incredible Technologies",        "World Class Bowling Deluxe (v2.00)" , 0) /* PIC 16C54 labeled as ITBWL-4 */
41544153
41554154/*
41564155    The following naming conventions are used:
src/mame/drivers/megadriv.h
r6740r6741
1717INPUT_PORTS_EXTERN( ssf2ghw );
1818INPUT_PORTS_EXTERN( megdsvp );
1919
20MACHINE_DRIVER_EXTERN( megadriv_timers );
21
2022MACHINE_DRIVER_EXTERN( megdsvppal );
2123MACHINE_DRIVER_EXTERN( megadriv );
2224MACHINE_DRIVER_EXTERN( megadpal );
r6740r6741
5355extern UINT8 megadrive_io_data_regs[3];
5456extern UINT8 megadrive_io_ctrl_regs[3];
5557
58MACHINE_START( megadriv );
5659MACHINE_RESET( megadriv );
5760VIDEO_START( megadriv );
5861VIDEO_UPDATE( megadriv );
src/mame/drivers/sspeedr.c
r6740r6741
134134   PORT_BIT( 0x1f, 0x00, IPT_POSITIONAL_V ) PORT_POSITIONS(30) PORT_REMAP_TABLE(sspeedr_controller_table + 2) PORT_SENSITIVITY(25) PORT_KEYDELTA(20)
135135
136136   PORT_START("DSW")
137   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coinage ) )
137   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coinage ) )  PORT_DIPLOCATION("SW1:1,2")
138138   PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
139139   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
140140   PORT_DIPSETTING(    0x03, DEF_STR( 2C_3C ) )
141141   PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
142   PORT_DIPNAME( 0x0C, 0x08, "Play Time" )
142   PORT_DIPNAME( 0x0C, 0x08, "Play Time" )  PORT_DIPLOCATION("SW1:3,4")
143143   PORT_DIPSETTING(    0x00, "60 seconds")
144144   PORT_DIPSETTING(    0x04, "70 seconds")
145145   PORT_DIPSETTING(    0x08, "80 seconds")
146146   PORT_DIPSETTING(    0x0C, "90 seconds")
147   PORT_DIPNAME( 0x10, 0x00, "Extended Play" )
147   PORT_DIPNAME( 0x10, 0x00, "Extended Play" )  PORT_DIPLOCATION("SW1:5")
148148   PORT_DIPSETTING(    0x00, "20 seconds" )
149149   PORT_DIPSETTING(    0x10, "30 seconds" )
150   PORT_DIPNAME( 0xE0, 0x20, DEF_STR( Service_Mode ) )
150   PORT_DIPNAME( 0xE0, 0x20, DEF_STR( Service_Mode ) )  PORT_DIPLOCATION("SW1:6,7,8")
151151   PORT_DIPSETTING(    0x20, "Play Mode" )
152152   PORT_DIPSETTING(    0xA0, "RAM/ROM Test" )
153153   PORT_DIPSETTING(    0xE0, "Accelerator Adjustment" )
r6740r6741
189189static MACHINE_DRIVER_START( sspeedr )
190190
191191   /* basic machine hardware */
192   MDRV_CPU_ADD("maincpu", Z80, 19968000 / 8)
192   MDRV_CPU_ADD("maincpu", Z80, XTAL_19_968MHz/8)
193193   MDRV_CPU_PROGRAM_MAP(sspeedr_map)
194194   MDRV_CPU_IO_MAP(sspeedr_io_map)
195195   MDRV_CPU_VBLANK_INT("screen", irq0_line_assert)
src/mame/drivers/ashnojoe.c
r6740r6741
7777#include "cpu/m68000/m68000.h"
7878#include "sound/2203intf.h"
7979#include "sound/msm5205.h"
80#include "ashnojoe.h"
80#include "includes/ashnojoe.h"
8181
8282static READ16_HANDLER(fake_4a00a_r)
8383{
src/mame/drivers/mouser.c
r6740r6741
2121static UINT8 mouser_nmi_enable;
2222
2323/* From "video/mouser.c" */
24extern UINT8 *mouser_videoram;
25extern UINT8 *mouser_colorram;
26
2427PALETTE_INIT( mouser );
2528WRITE8_HANDLER( mouser_flip_screen_x_w );
2629WRITE8_HANDLER( mouser_flip_screen_y_w );
r6740r6741
5760   AM_RANGE(0x0000, 0x5fff) AM_ROM
5861   AM_RANGE(0x6000, 0x6bff) AM_RAM
5962   AM_RANGE(0x8800, 0x88ff) AM_WRITENOP /* unknown */
60   AM_RANGE(0x9000, 0x93ff) AM_RAM AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
63   AM_RANGE(0x9000, 0x93ff) AM_RAM AM_BASE(&mouser_videoram)
6164   AM_RANGE(0x9800, 0x9cff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
62   AM_RANGE(0x9c00, 0x9fff) AM_RAM AM_BASE_GENERIC(colorram)
65   AM_RANGE(0x9c00, 0x9fff) AM_RAM AM_BASE(&mouser_colorram)
6366   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("P1") AM_WRITE(mouser_nmi_enable_w) /* bit 0 = NMI Enable */
6467   AM_RANGE(0xa001, 0xa001) AM_WRITE(mouser_flip_screen_x_w)
6568   AM_RANGE(0xa002, 0xa002) AM_WRITE(mouser_flip_screen_y_w)
src/mame/drivers/undrfire.c
r6740r6741
717717                 MACHINE DRIVERS
718718***********************************************************/
719719
720static MACHINE_RESET( undrfire )
721{
722   taito_f3_soundsystem_reset(machine);
723
724   f3_68681_reset(machine);
725}
726
727
728720static INTERRUPT_GEN( undrfire_interrupt )
729721{
730722   frame_counter^=1;
r6740r6741
738730   MDRV_CPU_PROGRAM_MAP(undrfire_map)
739731   MDRV_CPU_VBLANK_INT("screen", undrfire_interrupt)
740732
741   TAITO_F3_SOUND_SYSTEM_CPU(16000000)
742
743   MDRV_MACHINE_RESET(undrfire)
744733   MDRV_NVRAM_HANDLER(undrfire)
745734
746735   /* video hardware */
r6740r6741
758747   MDRV_VIDEO_UPDATE(undrfire)
759748
760749   /* sound hardware */
761   TAITO_F3_SOUND_SYSTEM_ES5505(30476100/2)
750   MDRV_IMPORT_FROM(taito_f3_sound)
762751MACHINE_DRIVER_END
763752
764753
r6740r6741
769758   MDRV_CPU_PROGRAM_MAP(cbombers_cpua_map)
770759   MDRV_CPU_VBLANK_INT("screen", irq4_line_hold)
771760
772   TAITO_F3_SOUND_SYSTEM_CPU(16000000)
773
774761   MDRV_CPU_ADD("sub", M68000, 16000000)   /* 16 MHz */
775762   MDRV_CPU_PROGRAM_MAP(cbombers_cpub_map)
776763   MDRV_CPU_VBLANK_INT("screen", irq4_line_hold)
777764
778765   MDRV_QUANTUM_TIME(HZ(480))   /* CPU slices - Need to interleave Cpu's 1 & 3 */
779766
780   MDRV_MACHINE_RESET(undrfire)
781767   MDRV_NVRAM_HANDLER(undrfire)
782768
783769   /* video hardware */
r6740r6741
796782   MDRV_VIDEO_UPDATE(cbombers)
797783
798784   /* sound hardware */
799   TAITO_F3_SOUND_SYSTEM_ES5505(30476100/2)
785   MDRV_IMPORT_FROM(taito_f3_sound)
800786MACHINE_DRIVER_END
801787
802788
src/mame/drivers/grchamp.c
r6740r6741
4444#include "driver.h"
4545#include "cpu/z80/z80.h"
4646#include "sound/ay8910.h"
47#include "grchamp.h"
47#include "includes/grchamp.h"
4848
4949#include "grchamp.lh"
5050
src/mame/drivers/gaiden.c
r6740r6741
129129#include "sound/2203intf.h"
130130#include "sound/2151intf.h"
131131#include "sound/okim6295.h"
132#include "gaiden.h"
132#include "includes/gaiden.h"
133133
134134static WRITE16_HANDLER( gaiden_sound_command_w )
135135{
src/mame/drivers/aleck64.c
r6740r6741
184184
185185static ADDRESS_MAP_START( n64_map, ADDRESS_SPACE_PROGRAM, 32 )
186186   AM_RANGE(0x00000000, 0x007fffff) AM_RAM   AM_BASE(&rdram)            // RDRAM
187   AM_RANGE(0x04000000, 0x04000fff) AM_RAM AM_SHARE("share1")               // RSP DMEM
188   AM_RANGE(0x04001000, 0x04001fff) AM_RAM AM_SHARE("share2")               // RSP IMEM
187   AM_RANGE(0x04000000, 0x04000fff) AM_RAM AM_SHARE("dmem")               // RSP DMEM
188   AM_RANGE(0x04001000, 0x04001fff) AM_RAM AM_SHARE("imem")               // RSP IMEM
189189   AM_RANGE(0x04040000, 0x040fffff) AM_READWRITE(n64_sp_reg_r, n64_sp_reg_w)   // RSP
190190   AM_RANGE(0x04100000, 0x041fffff) AM_READWRITE(n64_dp_reg_r, n64_dp_reg_w)   // RDP
191191   AM_RANGE(0x04300000, 0x043fffff) AM_READWRITE(n64_mi_reg_r, n64_mi_reg_w)   // MIPS Interface
r6740r6741
204204ADDRESS_MAP_END
205205
206206static ADDRESS_MAP_START( rsp_map, ADDRESS_SPACE_PROGRAM, 32 )
207   AM_RANGE(0x04000000, 0x04000fff) AM_RAM AM_BASE(&rsp_dmem) AM_SHARE("share1")
208   AM_RANGE(0x04001000, 0x04001fff) AM_RAM AM_BASE(&rsp_imem) AM_SHARE("share2")
207   AM_RANGE(0x00000000, 0x00000fff) AM_RAM AM_SHARE("dmem")
208   AM_RANGE(0x00001000, 0x00001fff) AM_RAM AM_SHARE("imem")
209   AM_RANGE(0x04000000, 0x04000fff) AM_RAM AM_BASE(&rsp_dmem) AM_SHARE("dmem")
210   AM_RANGE(0x04001000, 0x04001fff) AM_RAM AM_BASE(&rsp_imem) AM_SHARE("imem")
209211ADDRESS_MAP_END
210212
211213static INPUT_PORTS_START( aleck64 )
src/mame/drivers/astrof.c
r6740r6741
5858
5959#include "driver.h"
6060#include "cpu/m6502/m6502.h"
61#include "astrof.h"
61#include "includes/astrof.h"
6262
6363
6464#define MASTER_CLOCK        (XTAL_10_595MHz)
src/mame/drivers/finalizr.c
r6740r6741
1717#include "cpu/mcs48/mcs48.h"
1818#include "sound/sn76496.h"
1919#include "sound/dac.h"
20#include "konamipt.h"
21#include "finalizr.h"
20#include "includes/konamipt.h"
21#include "includes/finalizr.h"
2222
2323
2424static INTERRUPT_GEN( finalizr_interrupt )
src/mame/drivers/shuuz.c
r6740r6741
1919
2020#include "driver.h"
2121#include "cpu/m68000/m68000.h"
22#include "shuuz.h"
22#include "includes/shuuz.h"
2323#include "sound/okim6295.h"
2424
2525
r6740r6741
6363 *
6464 *************************************/
6565
66static MACHINE_START( shuuz )
67{
68   atarigen_init(machine);
69}
70
71
6672static MACHINE_RESET( shuuz )
6773{
6874   shuuz_state *state = (shuuz_state *)machine->driver_data;
r6740r6741
259265   MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2)
260266   MDRV_CPU_PROGRAM_MAP(main_map)
261267
268   MDRV_MACHINE_START(shuuz)
262269   MDRV_MACHINE_RESET(shuuz)
263270   MDRV_NVRAM_HANDLER(atarigen)
264271
src/mame/drivers/cowrace.c
r6740r6741
1212#include "sound/2203intf.h"
1313
1414static tilemap *tmap;
15static UINT8 *colorram;
16static UINT8 *videoram;
1517
1618static WRITE8_HANDLER( cowrace_videoram_w )
1719{
18   space->machine->generic.videoram.u8[offset] = data;
20   videoram[offset] = data;
1921   tilemap_mark_tile_dirty(tmap, offset);
2022}
2123
2224static WRITE8_HANDLER( cowrace_colorram_w )
2325{
24   space->machine->generic.colorram.u8[offset] = data;
26   colorram[offset] = data;
2527   tilemap_mark_tile_dirty(tmap, offset);
2628}
2729
2830static TILE_GET_INFO( get_tile_info )
2931{
30   UINT16 code = machine->generic.videoram.u8[ tile_index ] + (machine->generic.colorram.u8[ tile_index ] << 8) ;
31   UINT8 color = 0;//(machine->generic.colorram.u8[ tile_index ] & 0x3e)>>1;
32   UINT16 code = videoram[ tile_index ] + (colorram[ tile_index ] << 8) ;
33   UINT8 color = 0;//(colorram[ tile_index ] & 0x3e)>>1;
3234
3335   SET_TILE_INFO(1, code & 0x1ff, color, TILE_FLIPYX( 0 ));;
3436}
r6740r6741
9092
9193   AM_RANGE(0x0000, 0x2fff) AM_ROM
9294   AM_RANGE(0x3000, 0x33ff) AM_RAM
93   AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(cowrace_videoram_w) AM_BASE_GENERIC(videoram)
94   AM_RANGE(0x5000, 0x53ff) AM_RAM_WRITE(cowrace_colorram_w) AM_BASE_GENERIC(colorram)
95   AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(cowrace_videoram_w) AM_BASE(&videoram)
96   AM_RANGE(0x5000, 0x53ff) AM_RAM_WRITE(cowrace_colorram_w) AM_BASE(&colorram)
9597ADDRESS_MAP_END
9698
9799static ADDRESS_MAP_START( io_map_cowrace, ADDRESS_SPACE_IO, 8 )
src/mame/drivers/segaorun.c
r6740r6741
11/***************************************************************************
2
32    Sega Out Run hardware
4
53****************************************************************************
64
75    Known bugs:
r6740r6741
119        * verify analog input min/max
1210        * verify protection
1311
12--
13
14Guru's Outrun & Super Hang On Board Notes:
15
16Outrun & Super Hang On
17Sega, 1986, 1987
18
19PCB Layouts
20-----------
21
22CPU Board: The CPU board used on Outrun and Super Hang On is identical. Only the ROMs are changed,
23all other chips including PALs/PLDs and custom chips are the same.
24The non-encrypted versions are documented below as they are easy to repair and that version is used to
25resurrect dead FD1089/1094 versions :-)
26
27171-5376-01
28837-6063-01 SEGA 1986
29Sticker: 837-6278-02 (for Super Hang On)
30Sticker: 834-6277-02 SUPER HANG ON
31Sticker: 834-6065-02 OUT RUN
32Sticker: 834-6065-04 OUT RUN (REV B)
33|-----------------------------------------------------------------------------------|
34|                        IC71   TMM2115                      J     5.5V_0.1F        |
35|                               TMM2115       16MHz                                 |
36|                        IC70     |--------|          MF6CN-50                    N |
37|                                 |315-5218|          MF6CN-50   4066  LM324        |
38|                        IC69     |        |                                        |
39|                                 |--------|          MP7633JN                    P |
40|                        IC68                                                       |
41|                                          Z80A              TL084               LED|
42|                        IC67              IC88    315-5224           |-----------| |
43|                                       TMM2115              YM3012   |SEGA       | |
44|                        IC66                      YM2151             |315-5195   | |
45| 315-5222 315-5155 315-5155            40MHz      MB3771             |           | |
46| IC11          IC47                                                  |           | |
47|                                                                     |-----------| |
48|                           315-5225 315-5226                                       |
49|                           |---------------------|         |---------------------| |
50|          315-5223A        |        68000        |         |        68000        | |
51|                           |---------------------|         |---------------------| |
52|                                                                                   |
53|                                                                                   |
54|                                                                                   |
55|                                                                                   |
56|                               IC58        IC76                IC118       IC133   |
57|                                                                                   |
58|                               IC57        IC75                IC117       IC132   |
59|           TMM2115   TMM2115                                                       |
60|                               IC56        IC74                IC116       IC131   |
61|           TMM2115   TMM2115                                                       |
62|                               TMM2063     TMM2063             TMM2063     TMM2063 |
63|                                                                                   |
64|                               TMM2063     TMM2063             TMM2062     TMM2063 |
65|                                                                                   |
66|                                                                                   |
67|         A                         B                                 C             |
68|-----------------------------------------------------------------------------------|
69Notes:
70      68000     - Clock Input 10.000MHz [40/4]
71      Z80A      - Clock Input 4.000MHz [16/4]
72      YM2151    - Yamaha YM2151 FM Operator Type M (OPM) Sound Generator IC. Clock Input 4.000MHz [16/4]
73      YM3012    - Yamaha YM3012 2-Channel Serial Input Floating Point Digital to Analog Convertor (DIP16)
74      TMM2063   - Toshiba TMM2063 8kx8 SRAM (NDIP28)
75      TMM2115   - Toshiba TMM2115 2kx8 SRAM (NDIP24)
76      TL084     - Texas Instruments TL084 Quad JFET-Input General-Purpose Operational Amplifier (DIP14)
77      LM324     - National Semiconductor LM324 Low Power Quad Operational Amplifier (DIP14)
78      MP7633JN  - Exar Corporation MP7633JN 15V CMOS 10-Bit Multiplying Digital-to-Analog Converter (DIP16)
79                  Also equivalent to National Semiconductor DAC1022LCN and AD7520JN / AD7530JN
80      MF6CN-50  - National Semiconductor MF6CN-50 6th Order Switched Capacitor Butterworth Lowpass Filter (DIP14)
81      5.5V_0.1F - 0.1 Farad Super Cap for Capacitor Backed RAM
82      4066      - NEC D74HC4066 Quad Bilateral Switch (DIP14)
83      MB3771    - Fujitsu MB3771 Master Reset IC (DIP8)
84      J         - 10 Pin Connector for 5V Input and GND
85      N         - 6 Pin Connector for Unamplified Stereo Sound Output
86      P         - 4 Pin Connector (not used)
87      A/B/C     - 50 Pin Connectors (x3) for joining CPU Board to Video Board
88      315-5155  - Sega custom PAL (Road Bit Extraction) (DIP20)
89      315-5195  - Sega Memory Mapper IC (in PGA package)
90      315-5218  - Sega PCM Sound Controller IC (QFP100).
91                  Clock input 16.000MHz on pin 80
92                  Clock outputs: pin 2 - 4.000MHz, pin 80 - 500.000kHz, pin 89 - 62.500KHz
93      315-5222  - Signetics PLS153N (Road Mixing) (DIP20)
94      315-5223A - Signetics CK2605 (DIP20)
95      315-5224  - Signetics CK2605 (DIP20)
96      315-5225  - MMI PAL16R4 (DIP20)
97      315-5226  - MMI PAL16R4 (DIP20)
98
99      Measurements
100      ------------
101      OSC1 - 39.99967MHz
102      OSC2 - 16.00019MHz
103
104
105      ROMs (EPR/MPR)
106      ----
107                     IC88  IC66  IC67  IC68  IC69  IC70  IC71  IC47  IC11  IC58  IC57  IC56  IC76  IC75  IC74  IC118  IC117  IC116  IC133  IC132  IC131
108      -------------------------------------------------------------------------------------------------------------------------------------------------
109      Out Run        10187 10193 10192 10191 10190 10189 10188 10186 10185 10329 10330 -     10327 10328 -     10382  10383  -      10380  10381  -
110      Super Hang On  10649 10643 10644 10645 10646 -     -     10642 -     10790 10791 -     10792 10793 -     10884  10885  -      10886  10887  -
111      -------------------------------------------------------------------------------------------------------------------------------------------------
112
113
114Video Board: (Used only on Super Hang On)
115
116171-5480
117837-6279 SEGA 1987
118Sticker: 837-6279-03
119|-----------------------------------------------------------------------------------|
120|10675.8 10676.7 10677.6 10678.5 10679.4 10680.3 10681.2 IC1  LED  CN6       CN5    |
121|                                                                                   |
122|                                                                               DSWB|
123|                                                                                   |
124|10682.16 10683.15 10684.14 10685.13 10686.12 10687.11 10688.10 IC9                 |
125|JP3 JP1                                                                        DSWA|
126|JP4 JP2                                                                            |
127|                                                                TLP521-4           |
128|315-5251           315-5213          TMM2018  TMM2018           TLP521-4           |
129|      |-----------|                                             TLP521-4           |
130|      | SEGA      |                                             TLP521-4           |
131|      | 315-5196  |                                                                |
132|      |           |                                                   ULN2003      |
133|      |           |                                                     D4051      |
134|      |-----------|                                                             CN4|
135|                                                                                   |
136|                                                                                   |
137|                                                                                   |
138|                                                                                   |
139|                                                                                   |
140|  TMM2018  TMM2018  TMM2018  TMM2018                                               |
141|JP5                                                                                |
142|JP6  10650.56 10651.55 10652.54                                                    |
143|                                  D42832   TMM2115                           DAP601|
144|                                                                             DAP601|
145|25.1748MHz                                                                 ADC0804 |
146|      |-----------|                                                                |
147|   JP7| SEGA      |               D42832   TMM2115                                 |
148|      | 315-5197  |                                                                |
149|JP8   |           |                                               |----------|     |
150|      |           |                                               | SEGA     |     |
151|      |-----------|               TMM2115  TMM2115                | 315-5242 |     |
152|                                                                  |----------|     |
153|         A                         B                                 C             |
154|-----------------------------------------------------------------------------------|
155Notes:
156      D42832   - NEC D42832 32kx8 SRAM (DIP28)
157      TMM2018  - Toshiba TMM2018 2kx8 SRAM (NDIP24)
158      TMM2115  - Toshiba TMM2115 2kx8 SRAM (NDIP24)
159      TLP521-4 - Toshiba TLP521-4 Photocoupler Gallium Arsenide Infrared Diode & Photo???Transistor (DIP16)
160      ADC0804  - National Semiconductor ADC0804 8-Bit Microprocessor Compatible A/D Converter (DIP20)
161      ULN2003  - NEC uPA2003 7 High-Voltage, High-Current Darlington Transistor Arrays (DIP16)
162      D4051    - NEC D4051 Single 8-Channel, Dual 4-Channel, Triple 2-Channel Analog Multiplexer/Demultiplexer with Logic Level Conversion (DIP16)
163      DAP601   - Diotec Semiconductor DAP601 Small Signal Diode Array IC (SIP7)
164      CN4      - 50 Pin Connector for Controls/Inputs/Outputs
165      CN5      - 6 Pin Connector for Video Output (RGB/Sync/GND)
166      CN6      - 10 Pin Connector for 5V Input and GND
167      A/B/C    - 50 Pin Connectors (x3) for joining Video Board to CPU Board
168      315-5196 - Sega Custom Sprite Generator (PGA package)
169      315-5197 - Sega Custom Tilemap Generator (PGA package)
170      315-5213 - MMI PAL16R6 (sprite-related) (DIP20)
171      315-5242 - Sega Custom Color Encoder (wide custom DIP32 ceramic package with surface mount caps/resistors/transistors and a QFP44 IC)
172      315-5251 - Signetics CK2605 (DIP20)
173      JPx      - 0-Ohm Resistors for ROM Configuration
174                 JP1: 512 populated
175                 JP2: 1M  populated from lower hole to JP4 upper hole (i.e. diagonally across both JP2 and JP4)
176                 JP3: 1M  not populated
177                 JP4: 512, see JP2
178                 JP5: 256 populated
179                 JP6: 512 not populated
180                 JP7: 512 not populated
181                 JP8: 256 populated
182      106xx.xx   ROMs, 1065x = 27C256, all other 106xx.xx are 27C512
183      IC1/9    - DIP28 sockets not populated
184
185      Measurements
186      ------------
187      VSync - 60.0543Hz
188      HSync - 15.6740kHz
189      OSC1  - 25.1747MHz
190
191
192Video Board: (Used only on Out Run)
193
194171-5377-01
195837-6064 SEGA 1986
196|-----------------------------------------------------------------------------------|
197|HM65256 HM65256 HM65256 HM65256                              LED   K         H     |
198|                HM65256 HM65256 HM65256 HM65256  TMM2063                           |
199|                                                 TMM2063                       DSWB|
200|                                                                                   |
201|HM65256 HM65256 HM65256 HM65256                                                    |
202|                HM65256 HM65256 HM65256 HM65256                                DSWA|
203|                                                                                   |
204|                                                                                   |
205|                   25.1748MHz  TMM2018               TMM2015             2401      |
206| |-----------|                 TMM2018               HM65256             2401      |
207| | SEGA      |                                       TMM2015             2401      |
208| | 315-5211  |                                       HM65256             2401      |
209| |           |                                                                     |
210| |           |                                                                     |
211| |-----------|                                                                    G|
212|               315-5227A                                                           |
213|   R1    R2     R3                                                                 |
214|                                                                                   |
215|IC12 IC16 IC20 IC24 IC28 IC32 IC36 IC40 IC44                                       |
216|                                                |-----------|       315-5228       |
217|                                                | SEGA      |                      |
218|                                                | 315-5197  |                      |
219|IC11 IC15 IC19 IC23 IC27 IC31 IC35 IC39 IC43    |           |             UPD2003  |
220|                                                |           |             UPD2003 F|
221|                                                |-----------|             UPD2003  |
222|                                                     R11 R12 R13                   |
223|IC10 IC14 IC18 IC22 IC26 IC30 IC34 IC38 IC42  IC102 IC103 IC104                    |
224|                                                                                   |
225|                                                                      8255         |
226|                                                                                   |
227|IC9  IC13 IC17 IC21 IC25 IC29 IC33 IC37 IC41  IC99  IC100 IC101            DAP601  |
228|                                                                           DAP601 D|
229|                                                                           ADC0804 |
230|         A                         B                                 C     4051    |
231|-----------------------------------------------------------------------------------|
232Notes:
233      HM65256  - Hitachi HM65256 or uPD42832 32kx8 SRAM (DIP28)
234      TMM2063  - Toshiba TMM2063 8kx8 SRAM (NDIP28)
235      TMM2018  - Toshiba TMM2018 2kx8 SRAM (NDIP24)
236      TMM2015  - Toshiba TMM2015 2kx8 SRAM (NDIP24)
237      ADC0804  - National Semiconductor ADC0804 8-Bit Microprocessor Compatible A/D Converter (DIP20)
238      ULN2003  - NEC uPA2003 7 High-Voltage, High-Current Darlington Transistor Arrays (DIP16)
239      D4051    - NEC D4051 Single 8-Channel, Dual 4-Channel, Triple 2-Channel Analog Multiplexer/Demultiplexer with Logic Level Conversion (DIP16)
240      DAP601   - Diotec Semiconductor DAP601 Small Signal Diode Array IC (SIP7)
241      8255     - NEC D8255AC-2 Programmable Peripheral Interface Adapter (DIP40)
242      2401     - NEC 2401 (or Sharp PC817) 4-Channel Type Photocoupler (DIP16)
243      G        - 50 Pin Connector for Controls/Inputs/Outputs
244      H        - 6 Pin Connector for Video Output (RGB/Sync/GND)
245      K        - 10 Pin Connector for 5V Input and GND
246      A/B/C    - 50 Pin Connectors (x3) for joining Video Board to CPU Board
247      F        - 26 Pin Connector
248      D        - 20 Pin Connector
249      315-5197 - Sega Custom Tilemap Generator (PGA package)
250      315-5211 - Sega Custom Sprite Generator (PGA package)
251      315-5227A- Signetics CK2678 (DIP20)
252      315-5228 - Signetics CK2605 (DIP20)
253      R1/2/3   - 0-Ohm Resistors for ROM Configuration (for IC9 - IC44)
254                 For 831000 mask ROMs: R1 populated, R2 & R3 not populated
255                 For 27C256 EPROMs: R1 not populated, R2 & R3 populated
256                 Other possible configurations unknown
257      R11/12/13- 0-Ohm Resistors for ROM Configuration (for IC99 - IC104)
258                 For 27C256 EPROMs: R11 & R13 populated, R12 not populated
259                 Other possible configurations unknown
260      ICxx     - DIP28 sockets
261
262      Measurements
263      ------------
264      VSync - 60.0543Hz
265      HSync - 15.6740kHz
266      OSC1  - 25.1747MHz
267
14268***************************************************************************/
15269
270
16271#include "driver.h"
17272#include "cpu/z80/z80.h"
18#include "system16.h"
273#include "includes/system16.h"
19274#include "machine/fd1089.h"
20275#include "machine/segaic16.h"
21276#include "machine/8255ppi.h"
r6740r6741
26281#include "outrun.lh"
27282
28283
29#define MASTER_CLOCK         (50000000)
30#define SOUND_CLOCK          (16000000)
31#define MASTER_CLOCK_25MHz   (25174800)   /* super hang-on only */
284#define MASTER_CLOCK         (XTAL_40MHz)
285#define SOUND_CLOCK          (XTAL_16MHz)
286#define MASTER_CLOCK_25MHz   (XTAL_25_1748MHz)   /* super hang-on only */
32287
33288
34289
src/mame/drivers/videopkr.c
r6740r6741
276276static UINT16 p1, p2;
277277static UINT8 t0_latch;
278278static UINT16 n_offs;
279static emu_timer *t1_timer;
280279
281280static UINT8 vp_sound_p2;
282281static UINT8 p24_data;
r6740r6741
856855}
857856
858857
859static TIMER_CALLBACK(sound_t1_callback)
858static TIMER_DEVICE_CALLBACK(sound_t1_callback)
860859{
861860   if (te_40103 == 1)
862861   {
r6740r6741
864863
865864      if (dc_40103 == 0)
866865      {
867         cputag_set_input_line(machine, "soundcpu", 0, ASSERT_LINE);
866         cputag_set_input_line(timer->machine, "soundcpu", 0, ASSERT_LINE);
868867      }
869868   }
870869}
r6740r6741
11361135   p1 = 0xff;
11371136   ant_cio = 0;
11381137   count0 = 0;
1139   t1_timer = timer_alloc(machine, sound_t1_callback, NULL);
1140   timer_adjust_periodic(t1_timer, attotime_zero, 0, ATTOTIME_IN_HZ(50));   /* 50Hz. */
11411138}
11421139
11431140static const ay8910_interface ay8910_config =
r6740r6741
11701167   MDRV_MACHINE_START(videopkr)
11711168   MDRV_NVRAM_HANDLER(videopkr)
11721169
1170   MDRV_TIMER_ADD_PERIODIC("t1_timer", sound_t1_callback, HZ(50))
1171
11731172   /* video hardware */
11741173   MDRV_SCREEN_ADD("screen", RASTER)
11751174   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
src/mame/drivers/koikoi.c
r6740r6741
88
99TODO:
1010- map missing inputs (temp mapped to z-x-left shift)
11- is there (still..) some kind of protection ? timers looks weird (2nd player timer is frozen)
12- colors (afaik color(?) prom outputs are connected to one of pals), might help to have a screenshot of the original thing.
11- is there (still..) some kind of protection ? timers looks weird (2nd player timer is frozen) (this seems fixed now -AS)
12- colors (afaik color(?) prom outputs are connected to one of pals), Missing color prom apparently.
1313
1414
1515Basic hw is...
r6740r6741
7878   SET_TILE_INFO( 0, code, color, flip);
7979}
8080
81static PALETTE_INIT( koikoi ) //wrong
81static PALETTE_INIT( koikoi )
8282{
8383   int i;
8484
85   for (i = 0; i < 0x100; i++)
85   /* allocate the colortable */
86   machine->colortable = colortable_alloc(machine, 0x10);
87
88   /* create a lookup table for the palette */
89   for (i = 0; i < 0x10; i++)
8690   {
87      int bit0, bit1, bit2, bit3, r, g, b;
91      int bit0, bit1, bit2;
92      int r, g, b;
8893
94      /* red component */
95      bit0 = (color_prom[i] >> 0) & 0x01;
96      bit1 = (color_prom[i] >> 1) & 0x01;
97      bit2 = (color_prom[i] >> 2) & 0x01;
98      r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
99
100      /* green component */
89101      bit0 = (color_prom[i] >> 3) & 0x01;
90      bit1 = (color_prom[i] >> 2) & 0x01;
91      bit2 = (color_prom[i] >> 1) & 0x01;
92      bit3 = (color_prom[i] >> 0) & 0x01;
102      bit1 = (color_prom[i] >> 4) & 0x01;
103      bit2 = (color_prom[i] >> 5) & 0x01;
104      g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
93105
94      r = bit0 * 0xaa + bit3 * 0x55;
95      g = bit1 * 0xaa + bit3 * 0x55;
96      b = bit2 * 0xaa + bit3 * 0x55;
106      /* blue component */
107      bit0 = 0;
108      bit1 = (color_prom[i] >> 6) & 0x01;
109      bit2 = (color_prom[i] >> 7) & 0x01;
110      b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
97111
98      palette_set_color(machine, i, MAKE_RGB(r, g, b));
112      colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b));
99113   }
114
115   /* color_prom now points to the beginning of the lookup table */
116   color_prom += 0x20;
117
118   /* characters/sprites */
119   for (i = 0; i < 0x100; i++)
120   {
121      UINT8 ctabentry = color_prom[i] & 0x0f;
122      colortable_entry_set_value(machine->colortable, i, ctabentry);
123   }
100124}
101125
102126static VIDEO_START(koikoi)
r6740r6741
165189
166190static WRITE8_DEVICE_HANDLER( unknown_w )
167191{
168   //unknown... could be input select (player 1 or 2 = fd/fe or ef/df(??) )
192   //xor'ed mux select, player 1 = 1,2,4,8, player 2 = 0x10, 0x20, 0x40, 0x80
169193}
170194
171195static READ8_HANDLER( io_r )
r6740r6741
202226
203227static ADDRESS_MAP_START( koikoi_io_map, ADDRESS_SPACE_IO, 8 )
204228   ADDRESS_MAP_GLOBAL_MASK(0xff)
205   AM_RANGE(0x02, 0x02) AM_WRITENOP //unknown , many writes
229   AM_RANGE(0x02, 0x02) AM_WRITENOP //watchdog
206230   AM_RANGE(0x03, 0x03) AM_DEVREAD("aysnd", ay8910_r)
207231   AM_RANGE(0x06, 0x07) AM_DEVWRITE("aysnd", ay8910_data_address_w)
208232ADDRESS_MAP_END
r6740r6741
263287
264288/*************************************
265289 *
266 *  Graphics definitions
290 *  Graphic definitions
267291 *
268292 *************************************/
269293
r6740r6741
272296   8, 8,
273297   RGN_FRAC(1,3),
274298   3,
275   { RGN_FRAC(0,3), RGN_FRAC(2,3), RGN_FRAC(1,3) },
276   //{ RGN_FRAC(2,3), RGN_FRAC(0,3), RGN_FRAC(1,3) },
299   { RGN_FRAC(2,3), RGN_FRAC(1,3), RGN_FRAC(0,3) },
277300   { 0, 1, 2, 3, 4, 5, 6, 7 },
278301   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
279302   8*8
r6740r6741
384407   ROM_LOAD( "ic26", 0x1000, 0x1000, CRC(79cb1e93) SHA1(4d08b3d88727b437673f7a51d47396f19bbc3caa) )
385408   ROM_LOAD( "ic18", 0x2000, 0x1000, CRC(c209362d) SHA1(0620c19fe72e8407db0f487b6413c5d45ac8046c) )
386409
387   ROM_REGION( 0x0100, "proms", 0 )
388   ROM_LOAD( "prom.ic23", 0x000, 0x100,  CRC(f1d169a6) SHA1(5ee4b1dfe61e8b97a90cc113ba234298189f1a73) )
410   ROM_REGION( 0x0120, "proms", 0 )
411   ROM_LOAD( "prom.x",    0x000, 0x020,  NO_DUMP )
412   ROM_LOAD( "prom.ic23", 0x020, 0x100,  CRC(f1d169a6) SHA1(5ee4b1dfe61e8b97a90cc113ba234298189f1a73) )
389413
390414   ROM_REGION( 0x0a00, "plds", 0 )
391415   ROM_LOAD( "pal16r8-10_pink.ic9",   0x0000, 0x0104, CRC(9f8fdb95) SHA1(cdcdb1a6baef18961cf6c75fba0c3aba47f3edbb) )
src/mame/drivers/hexa.c
r6740r6741
4949#include "driver.h"
5050#include "cpu/z80/z80.h"
5151#include "sound/ay8910.h"
52#include "hexa.h"
52#include "includes/hexa.h"
5353
5454
5555static ADDRESS_MAP_START( hexa_map, ADDRESS_SPACE_PROGRAM, 8 )
r6740r6741
7777   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 )
7878
7979   PORT_START("DSW")
80   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )
80   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )  PORT_DIPLOCATION("SW1:1,2")
8181   PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
8282   PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
8383   PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
8484   PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
85   PORT_DIPNAME( 0x04, 0x00, "Naughty Pics" )
85   PORT_DIPNAME( 0x04, 0x00, "Naughty Pics" )  PORT_DIPLOCATION("SW1:3")
8686   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
8787   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
88   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Flip_Screen ) )
88   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Flip_Screen ) )  PORT_DIPLOCATION("SW1:4")
8989   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
9090   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
91   PORT_DIPNAME( 0x30, 0x30, "Difficulty?" )
91   PORT_DIPNAME( 0x30, 0x30, "Difficulty?" )  PORT_DIPLOCATION("SW1:5,6")
9292   PORT_DIPSETTING(    0x30, "Easy?" )
9393   PORT_DIPSETTING(    0x20, "Medium?" )
9494   PORT_DIPSETTING(    0x10, "Hard?" )
9595   PORT_DIPSETTING(    0x00, "Hardest?" )
96   PORT_DIPNAME( 0x40, 0x40, "Pobys" )
96   PORT_DIPNAME( 0x40, 0x40, "Pobys" )  PORT_DIPLOCATION("SW1:7")
9797   PORT_DIPSETTING(    0x40, "2" )
9898   PORT_DIPSETTING(    0x00, "4" )
99   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Demo_Sounds ) )
99   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Demo_Sounds ) )  PORT_DIPLOCATION("SW1:8")
100100   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
101101   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
102102INPUT_PORTS_END
r6740r6741
154154   MDRV_DRIVER_DATA(hexa_state)
155155
156156   /* basic machine hardware */
157   MDRV_CPU_ADD("maincpu", Z80, 4000000)      /* 4 MHz ??????? */
157   MDRV_CPU_ADD("maincpu", Z80, XTAL_12MHz/2)   /* Imported from arkanoid - correct? */
158158   MDRV_CPU_PROGRAM_MAP(hexa_map)
159159   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
160160
r6740r6741
178178
179179   /* sound hardware */
180180   MDRV_SPEAKER_STANDARD_MONO("mono")
181   MDRV_SOUND_ADD("aysnd", AY8910, 1500000)
181   MDRV_SOUND_ADD("aysnd", AY8910, XTAL_12MHz/4/2)   /* Imported from arkanoid - correct? */
182182   MDRV_SOUND_CONFIG(ay8910_config)
183183   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
184184MACHINE_DRIVER_END
src/mame/drivers/gticlub.c
r6740r6741
224224#include "cpu/powerpc/ppc.h"
225225#include "cpu/sharc/sharc.h"
226226#include "machine/konppc.h"
227#include "machine/konamiic.h"
228227#include "sound/rf5c400.h"
229228#include "video/voodoo.h"
230229#include "video/gticlub.h"
231230#include "rendlay.h"
231#include "sound/k056800.h"
232232
233233static UINT32 *work_ram;
234234
r6740r6741
614614   AM_RANGE(0x7e000000, 0x7e003fff) AM_READWRITE8(sysreg_r, sysreg_w, 0xffffffff)
615615   AM_RANGE(0x7e008000, 0x7e009fff) AM_READWRITE8(K056230_r, K056230_w, 0xffffffff)
616616   AM_RANGE(0x7e00a000, 0x7e00bfff) AM_READWRITE(lanc_ram_r, lanc_ram_w) AM_BASE(&lanc_ram)
617   AM_RANGE(0x7e00c000, 0x7e00c007) AM_WRITE(K056800_host_w)
618   AM_RANGE(0x7e00c000, 0x7e00c007) AM_READ(K056800_host_r)      // Hang Pilot
619   AM_RANGE(0x7e00c008, 0x7e00c00f) AM_READ(K056800_host_r)
617   AM_RANGE(0x7e00c000, 0x7e00c007) AM_DEVWRITE("k056800", k056800_host_w)
618   AM_RANGE(0x7e00c000, 0x7e00c007) AM_DEVREAD("k056800", k056800_host_r)      // Hang Pilot
619   AM_RANGE(0x7e00c008, 0x7e00c00f) AM_DEVREAD("k056800", k056800_host_r)
620620   AM_RANGE(0x7f000000, 0x7f3fffff) AM_ROM AM_REGION("user2", 0)   /* Data ROM */
621621   AM_RANGE(0x7f800000, 0x7f9fffff) AM_ROM AM_SHARE("share2")
622622   AM_RANGE(0x7fe00000, 0x7fffffff) AM_ROM AM_REGION("user1", 0) AM_SHARE("share2")   /* Program ROM */
r6740r6741
627627static ADDRESS_MAP_START( sound_memmap, ADDRESS_SPACE_PROGRAM, 16 )
628628   AM_RANGE(0x000000, 0x07ffff) AM_ROM
629629   AM_RANGE(0x200000, 0x20ffff) AM_RAM
630   AM_RANGE(0x300000, 0x30000f) AM_READWRITE(K056800_sound_r, K056800_sound_w)
630   AM_RANGE(0x300000, 0x30000f) AM_DEVREADWRITE("k056800", k056800_sound_r, k056800_sound_w)
631631   AM_RANGE(0x400000, 0x400fff) AM_DEVREADWRITE("rfsnd", rf5c400_r, rf5c400_w)      /* Ricoh RF5C400 */
632632   AM_RANGE(0x580000, 0x580001) AM_WRITENOP
633633   AM_RANGE(0x600000, 0x600001) AM_WRITENOP
r6740r6741
694694   eeprom_handler(machine, file, read_or_write);
695695}
696696
697
698697static INPUT_PORTS_START( gticlub )
699698   PORT_START("IN0")
700699   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 )      // View switch
r6740r6741
898897   BOOT_MODE_EPROM
899898};
900899
900
901static TIMER_CALLBACK( irq_off )
902{
903   cputag_set_input_line(machine, "audiocpu", param, CLEAR_LINE);
904}
905
906static void sound_irq_callback( running_machine *machine, int irq )
907{
908   int line = (irq == 0) ? INPUT_LINE_IRQ1 : INPUT_LINE_IRQ2;
909
910   cputag_set_input_line(machine, "audiocpu", line, ASSERT_LINE);
911   timer_set(machine, ATTOTIME_IN_USEC(1), NULL, line, irq_off);
912}
913
914static const k056800_interface gticlub_k056800_interface =
915{
916   sound_irq_callback
917};
918
901919static MACHINE_RESET( gticlub )
902920{
903921   cputag_set_input_line(machine, "dsp", INPUT_LINE_RESET, ASSERT_LINE);
r6740r6741
935953   MDRV_VIDEO_START(gticlub)
936954   MDRV_VIDEO_UPDATE(gticlub)
937955
956   MDRV_K056800_ADD("k056800", gticlub_k056800_interface)
957
938958   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
939959
940960   MDRV_SOUND_ADD("rfsnd", RF5C400, 64000000/4)
r6740r6741
10011021   MDRV_VIDEO_START(hangplt)
10021022   MDRV_VIDEO_UPDATE(hangplt)
10031023
1024   MDRV_K056800_ADD("k056800", gticlub_k056800_interface)
1025
10041026   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
10051027
10061028   MDRV_SOUND_ADD("rfsnd", RF5C400, 64000000/4)
r6740r6741
12011223   ROM_LOAD32_WORD( "685a14.12w", 0x000000, 0x400000, CRC(87437739) SHA1(0d45637af40938a54d5efd29c125b0fafd55f9a4) )
12021224ROM_END
12031225
1204static TIMER_CALLBACK( irq_off )
1205{
1206   cputag_set_input_line(machine, "audiocpu", param, CLEAR_LINE);
1207}
1208
1209static void sound_irq_callback(running_machine *machine, int irq)
1210{
1211   int line = (irq == 0) ? INPUT_LINE_IRQ1 : INPUT_LINE_IRQ2;
1212   cputag_set_input_line(machine, "audiocpu", line, ASSERT_LINE);
1213   timer_set(machine, ATTOTIME_IN_USEC(1), NULL, line, irq_off);
1214}
1215
12161226static DRIVER_INIT(gticlub)
12171227{
12181228   init_konami_cgboard(machine, 1, CGBOARD_TYPE_GTICLUB);
r6740r6741
12221232
12231233   K001005_preprocess_texture_data(memory_region(machine, "gfx1"), memory_region_length(machine, "gfx1"), 1);
12241234
1225   K056800_init(machine, sound_irq_callback);
1226
12271235   adc1038_init(machine);
12281236}
12291237
r6740r6741
12371245   sharc_dataram_1 = auto_alloc_array(machine, UINT32, 0x100000/4);
12381246   gticlub_led_reg0 = gticlub_led_reg1 = 0x7f;
12391247
1240   K056800_init(machine, sound_irq_callback);
12411248   K033906_init(machine);
12421249
12431250   adc1038_init(machine);
src/mame/drivers/namcona1.c
r6740r6741
161161#include "driver.h"
162162#include "cpu/m68000/m68000.h"
163163#include "deprecat.h"
164#include "namcona1.h"
164#include "includes/namcona1.h"
165165#include "sound/c140.h"
166166#include "cpu/m37710/m37710.h"
167167
src/mame/drivers/bsktball.c
r6740r6741
2626#include "driver.h"
2727#include "cpu/m6502/m6502.h"
2828#include "deprecat.h"
29#include "bsktball.h"
29#include "includes/bsktball.h"
3030#include "sound/discrete.h"
3131
3232
src/mame/drivers/acefruit.c
r6740r6741
1313
1414#include "sidewndr.lh"
1515
16static UINT8 *colorram;
17static UINT8 *videoram;
18
1619static void acefruit_update_irq(running_machine *machine, int vpos )
1720{
1821   int col;
r6740r6741
2124   for( col = 0; col < 32; col++ )
2225   {
2326      int tile_index = ( col * 32 ) + row;
24      int color = machine->generic.colorram.u8[ tile_index ];
27      int color = colorram[ tile_index ];
2528
2629      switch( color )
2730      {
r6740r6741
7376      for( col = 0; col < 32; col++ )
7477      {
7578         int tile_index = ( col * 32 ) + row;
76         int code = screen->machine->generic.videoram.u8[ tile_index ];
77         int color = screen->machine->generic.colorram.u8[ tile_index ];
79         int code = videoram[ tile_index ];
80         int color = colorram[ tile_index ];
7881
7982         if( color < 0x4 )
8083         {
r6740r6741
197200
198201static WRITE8_HANDLER( acefruit_colorram_w )
199202{
200   space->machine->generic.colorram.u8[ offset ] = data & 0xf;
203   colorram[ offset ] = data & 0xf;
201204}
202205
203206static WRITE8_HANDLER( acefruit_coin_w )
r6740r6741
256259static ADDRESS_MAP_START( acefruit_map, ADDRESS_SPACE_PROGRAM, 8 )
257260   AM_RANGE(0x0000, 0x1fff) AM_ROM
258261   AM_RANGE(0x2000, 0x20ff) AM_RAM AM_BASE_SIZE_GENERIC(nvram)
259   AM_RANGE(0x4000, 0x43ff) AM_RAM AM_BASE_GENERIC(videoram)
260   AM_RANGE(0x4400, 0x47ff) AM_RAM_WRITE(acefruit_colorram_w) AM_BASE_GENERIC(colorram)
262   AM_RANGE(0x4000, 0x43ff) AM_RAM AM_BASE(&videoram)
263   AM_RANGE(0x4400, 0x47ff) AM_RAM_WRITE(acefruit_colorram_w) AM_BASE(&colorram)
261264   AM_RANGE(0x8000, 0x8000) AM_READ_PORT("IN0")
262265   AM_RANGE(0x8001, 0x8001) AM_READ_PORT("IN1")
263266   AM_RANGE(0x8002, 0x8002) AM_READ_PORT("IN2")
src/mame/drivers/appoooh.c
r6740r6741
163163
164164#include "driver.h"
165165#include "cpu/z80/z80.h"
166#include "appoooh.h"
166#include "includes/appoooh.h"
167167#include "machine/segacrpt.h"      // needed for robowres_decode
168168#include "sound/msm5205.h"
169169#include "sound/sn76496.h"
src/mame/drivers/goldstar.c
r6740r6741
110110
111111static int dataoffset=0;
112112
113extern UINT8 *goldstar_fg_atrram;
114extern UINT8 *goldstar_fg_vidram;
113115extern UINT8 *goldstar_reel1_scroll, *goldstar_reel2_scroll, *goldstar_reel3_scroll;
114116
115117
r6740r6741
168170   AM_RANGE(0x0000, 0xb7ff) AM_ROM
169171   AM_RANGE(0xb800, 0xbfff) AM_RAM AM_BASE(&nvram) AM_SIZE(&nvram_size)
170172   AM_RANGE(0xc000, 0xc7ff) AM_ROM
171   AM_RANGE(0xc800, 0xcfff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE_GENERIC(videoram)
172   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE_GENERIC(colorram)
173   AM_RANGE(0xc800, 0xcfff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE(&goldstar_fg_vidram)
174   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE(&goldstar_fg_atrram)
173175   AM_RANGE(0xd800, 0xd9ff) AM_RAM_WRITE( goldstar_reel1_ram_w ) AM_BASE(&goldstar_reel1_ram)
174176   AM_RANGE(0xe000, 0xe1ff) AM_RAM_WRITE( goldstar_reel2_ram_w ) AM_BASE(&goldstar_reel2_ram)
175177   AM_RANGE(0xe800, 0xe9ff) AM_RAM_WRITE( goldstar_reel3_ram_w ) AM_BASE(&goldstar_reel3_ram)
r6740r6741
211213   AM_RANGE(0x0000, 0xb7ff) AM_ROM
212214   AM_RANGE(0xb800, 0xbfff) AM_RAM AM_BASE(&nvram) AM_SIZE(&nvram_size)
213215   AM_RANGE(0xc000, 0xc7ff) AM_ROM
214   AM_RANGE(0xc800, 0xcfff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE_GENERIC(videoram)
215   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE_GENERIC(colorram)
216   AM_RANGE(0xc800, 0xcfff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE(&goldstar_fg_vidram)
217   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE(&goldstar_fg_atrram)
216218   AM_RANGE(0xd800, 0xd9ff) AM_RAM_WRITE(goldstar_reel1_ram_w) AM_BASE(&goldstar_reel1_ram)
217219   AM_RANGE(0xe000, 0xe1ff) AM_RAM_WRITE(goldstar_reel2_ram_w) AM_BASE(&goldstar_reel2_ram)
218220   AM_RANGE(0xe800, 0xe9ff) AM_RAM_WRITE(goldstar_reel3_ram_w) AM_BASE(&goldstar_reel3_ram)
r6740r6741
285287   AM_RANGE(0xd000, 0xd7ff) AM_RAM AM_BASE(&nvram) AM_SIZE(&nvram_size)
286288
287289
288   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE_GENERIC(videoram)
289   AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE_GENERIC(colorram)
290   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE(&goldstar_fg_vidram)
291   AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE(&goldstar_fg_atrram)
290292
291293   AM_RANGE(0xf000, 0xf1ff) AM_RAM_WRITE( goldstar_reel1_ram_w ) AM_BASE(&goldstar_reel1_ram)
292294   AM_RANGE(0xf200, 0xf3ff) AM_RAM_WRITE( goldstar_reel2_ram_w ) AM_BASE(&goldstar_reel2_ram)
r6740r6741
307309   AM_RANGE(0xd800, 0xdfff) AM_RAM AM_BASE(&nvram) AM_SIZE(&nvram_size)
308310
309311
310   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE_GENERIC(videoram)
311   AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE_GENERIC(colorram)
312   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE(&goldstar_fg_vidram)
313   AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE(&goldstar_fg_atrram)
312314
313315   AM_RANGE(0xf000, 0xf1ff) AM_RAM_WRITE( goldstar_reel1_ram_w ) AM_BASE(&goldstar_reel1_ram)
314316   AM_RANGE(0xf200, 0xf3ff) AM_RAM_WRITE( goldstar_reel2_ram_w ) AM_BASE(&goldstar_reel2_ram)
r6740r6741
381383static ADDRESS_MAP_START( lucky8_map, ADDRESS_SPACE_PROGRAM, 8 )
382384   AM_RANGE(0x0000, 0x7fff) AM_ROM
383385   AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE(&nvram) AM_SIZE(&nvram_size)
384   AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE_GENERIC(videoram)
385   AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE_GENERIC(colorram)
386   AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE(&goldstar_fg_vidram)
387   AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE(&goldstar_fg_atrram)
386388   AM_RANGE(0x9800, 0x99ff) AM_RAM_WRITE(goldstar_reel1_ram_w) AM_BASE(&goldstar_reel1_ram)
387389   AM_RANGE(0xa000, 0xa1ff) AM_RAM_WRITE(goldstar_reel2_ram_w) AM_BASE(&goldstar_reel2_ram)
388390   AM_RANGE(0xa800, 0xa9ff) AM_RAM_WRITE(goldstar_reel3_ram_w) AM_BASE(&goldstar_reel3_ram)
r6740r6741
403405static ADDRESS_MAP_START( kkojnoli_map, ADDRESS_SPACE_PROGRAM, 8 )
404406   AM_RANGE(0x0000, 0x7fff) AM_ROM
405407   AM_RANGE(0x8000, 0x87ff) AM_RAM   /* definitelly no NVRAM */
406   AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE_GENERIC(videoram)
407   AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE_GENERIC(colorram)
408   AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE(&goldstar_fg_vidram)
409   AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE(&goldstar_fg_atrram)
408410   AM_RANGE(0x9800, 0x99ff) AM_RAM_WRITE(goldstar_reel1_ram_w) AM_BASE(&goldstar_reel1_ram)
409411   AM_RANGE(0xa000, 0xa1ff) AM_RAM_WRITE(goldstar_reel2_ram_w) AM_BASE(&goldstar_reel2_ram)
410412   AM_RANGE(0xa800, 0xa9ff) AM_RAM_WRITE(goldstar_reel3_ram_w) AM_BASE(&goldstar_reel3_ram)
r6740r6741
442444static ADDRESS_MAP_START( ladylinr_map, ADDRESS_SPACE_PROGRAM, 8 )
443445   AM_RANGE(0x0000, 0x7fff) AM_ROM
444446   AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE(&nvram) AM_SIZE(&nvram_size)
445   AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE_GENERIC(videoram)
446   AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE_GENERIC(colorram)
447   AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE(&goldstar_fg_vidram)
448   AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE(&goldstar_fg_atrram)
447449   AM_RANGE(0x9800, 0x99ff) AM_RAM_WRITE(goldstar_reel1_ram_w) AM_BASE(&goldstar_reel1_ram)
448450   AM_RANGE(0xa000, 0xa1ff) AM_RAM_WRITE(goldstar_reel2_ram_w) AM_BASE(&goldstar_reel2_ram)
449451   AM_RANGE(0xa800, 0xa9ff) AM_RAM_WRITE(goldstar_reel3_ram_w) AM_BASE(&goldstar_reel3_ram)
r6740r6741
463465static ADDRESS_MAP_START( wcat3_map, ADDRESS_SPACE_PROGRAM, 8 )
464466   AM_RANGE(0x0000, 0x7fff) AM_ROM
465467   AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE(&nvram) AM_SIZE(&nvram_size)
466   AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE_GENERIC(videoram)
467   AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE_GENERIC(colorram)
468   AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE(&goldstar_fg_vidram)
469   AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE(&goldstar_fg_atrram)
468470   AM_RANGE(0x9800, 0x99ff) AM_RAM_WRITE(goldstar_reel1_ram_w) AM_BASE(&goldstar_reel1_ram)
469471   AM_RANGE(0xa000, 0xa1ff) AM_RAM_WRITE(goldstar_reel2_ram_w) AM_BASE(&goldstar_reel2_ram)
470472   AM_RANGE(0xa800, 0xa9ff) AM_RAM_WRITE(goldstar_reel3_ram_w) AM_BASE(&goldstar_reel3_ram)
r6740r6741
500502   AM_RANGE(0xd800, 0xdfff) AM_RAM
501503
502504
503   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE_GENERIC(videoram)
504   AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE_GENERIC(colorram)
505   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(goldstar_fg_vidram_w) AM_BASE(&goldstar_fg_vidram)
506   AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(goldstar_fg_atrram_w) AM_BASE(&goldstar_fg_atrram)
505507
506508   AM_RANGE(0xf000, 0xf1ff) AM_RAM_WRITE( goldstar_reel1_ram_w ) AM_BASE(&goldstar_reel1_ram)
507509   AM_RANGE(0xf200, 0xf3ff) AM_RAM_WRITE( goldstar_reel2_ram_w ) AM_BASE(&goldstar_reel2_ram)
src/mame/drivers/dbz.c
r6740r6741
5353#include "driver.h"
5454#include "deprecat.h"
5555
56#include "video/konamiic.h"
56#include "video/konicdev.h"
5757#include "cpu/m68000/m68000.h"
5858#include "cpu/z80/z80.h"
5959#include "sound/2151intf.h"
r6740r6741
7272VIDEO_START(dbz);
7373VIDEO_UPDATE(dbz);
7474
75extern void dbz_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask);
76extern void dbz_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags);
77
78
7579static INTERRUPT_GEN( dbz_interrupt )
7680{
81   const device_config *k053246 = devtag_get_device(device->machine, "k053246");
82
7783   switch (cpu_getiloops(device))
7884   {
7985      case 0:
r6740r6741
8187         break;
8288
8389      case 1:
84         if (K053246_is_IRQ_enabled())
90         if (k053246_is_irq_enabled(k053246))
8591            cpu_set_input_line(device, M68K_IRQ_4, HOLD_LINE);
8692         break;
8793   }
r6740r6741
96102
97103static WRITE16_HANDLER( dbzcontrol_w )
98104{
105   const device_config *k053246 = devtag_get_device(space->machine, "k053246");
99106   /* bit 10 = enable '246 readback */
100107
101108   COMBINE_DATA(&dbz_control);
102109
103110   if (data & 0x400)
104111   {
105      K053246_set_OBJCHA_line(ASSERT_LINE);
112      k053246_set_objcha_line(k053246, ASSERT_LINE);
106113   }
107114   else
108115   {
109      K053246_set_OBJCHA_line(CLEAR_LINE);
116      k053246_set_objcha_line(k053246, CLEAR_LINE);
110117   }
111118
112119   coin_counter_w(space->machine, 0, data & 1);
r6740r6741
134141static ADDRESS_MAP_START( dbz_map, ADDRESS_SPACE_PROGRAM, 16 )
135142   AM_RANGE(0x000000, 0x0fffff) AM_ROM
136143   AM_RANGE(0x480000, 0x48ffff) AM_RAM
137   AM_RANGE(0x490000, 0x491fff) AM_READWRITE(K056832_ram_word_r, K056832_ram_word_w)   // '157 RAM is mirrored twice
138   AM_RANGE(0x492000, 0x493fff) AM_READWRITE(K056832_ram_word_r, K056832_ram_word_w)
139   AM_RANGE(0x498000, 0x49ffff) AM_READ(K056832_rom_word_8000_r)   // code near a60 in dbz2, subroutine at 730 in dbz
140   AM_RANGE(0x4a0000, 0x4a0fff) AM_READWRITE(K053247_word_r, K053247_word_w)
144   AM_RANGE(0x490000, 0x491fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w)   // '157 RAM is mirrored twice
145   AM_RANGE(0x492000, 0x493fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w)
146   AM_RANGE(0x498000, 0x49ffff) AM_DEVREAD("k056832", k056832_rom_word_8000_r)   // code near a60 in dbz2, subroutine at 730 in dbz
147   AM_RANGE(0x4a0000, 0x4a0fff) AM_DEVREADWRITE("k053246", k053247_word_r, k053247_word_w)
141148   AM_RANGE(0x4a1000, 0x4a3fff) AM_RAM
142149   AM_RANGE(0x4a8000, 0x4abfff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram) // palette
143   AM_RANGE(0x4c0000, 0x4c0001) AM_READ(K053246_word_r)
144   AM_RANGE(0x4c0000, 0x4c0007) AM_WRITE(K053246_word_w)
145   AM_RANGE(0x4c4000, 0x4c4007) AM_WRITE(K053246_word_w)
146   AM_RANGE(0x4c8000, 0x4c8007) AM_WRITE(K056832_b_word_w)
147   AM_RANGE(0x4cc000, 0x4cc03f) AM_WRITE(K056832_word_w)
148   AM_RANGE(0x4d0000, 0x4d001f) AM_WRITEONLY AM_BASE(&K053936_0_ctrl)
149   AM_RANGE(0x4d4000, 0x4d401f) AM_WRITEONLY AM_BASE(&K053936_1_ctrl)
150   AM_RANGE(0x4c0000, 0x4c0001) AM_DEVREAD("k053246", k053246_word_r)
151   AM_RANGE(0x4c0000, 0x4c0007) AM_DEVWRITE("k053246", k053246_word_w)
152   AM_RANGE(0x4c4000, 0x4c4007) AM_DEVWRITE("k053246", k053246_word_w)
153   AM_RANGE(0x4c8000, 0x4c8007) AM_DEVWRITE("k056832", k056832_b_word_w)
154   AM_RANGE(0x4cc000, 0x4cc03f) AM_DEVWRITE("k056832", k056832_word_w)
155   AM_RANGE(0x4d0000, 0x4d001f) AM_DEVWRITE("k053936_1", k053936_ctrl_w)
156   AM_RANGE(0x4d4000, 0x4d401f) AM_DEVWRITE("k053936_2", k053936_ctrl_w)
150157   AM_RANGE(0x4e0000, 0x4e0001) AM_READ_PORT("P1_P2")
151158   AM_RANGE(0x4e0002, 0x4e0003) AM_READ_PORT("SYSTEM_DSW1")
152159   AM_RANGE(0x4e4000, 0x4e4001) AM_READ_PORT("DSW2")
r6740r6741
155162   AM_RANGE(0x4f0000, 0x4f0001) AM_WRITE(dbz_sound_command_w)
156163   AM_RANGE(0x4f4000, 0x4f4001) AM_WRITE(dbz_sound_cause_nmi)
157164   AM_RANGE(0x4f8000, 0x4f801f) AM_WRITENOP      // 251 #1
158   AM_RANGE(0x4fc000, 0x4fc01f) AM_WRITE(K053251_lsb_w)   // 251 #2
165   AM_RANGE(0x4fc000, 0x4fc01f) AM_DEVWRITE("k053251", k053251_lsb_w)   // 251 #2
159166
160167   AM_RANGE(0x500000, 0x501fff) AM_RAM_WRITE(dbz_bg2_videoram_w) AM_BASE(&dbz_bg2_videoram)
161168   AM_RANGE(0x508000, 0x509fff) AM_RAM_WRITE(dbz_bg1_videoram_w) AM_BASE(&dbz_bg1_videoram)
162   AM_RANGE(0x510000, 0x513fff) AM_RAM AM_BASE(&K053936_0_linectrl) // ?? guess, it might not be
163   AM_RANGE(0x518000, 0x51bfff) AM_RAM AM_BASE(&K053936_1_linectrl) // ?? guess, it might not be
169   AM_RANGE(0x510000, 0x513fff) AM_DEVREADWRITE("k053936_1", k053936_linectrl_r, k053936_linectrl_w) // ?? guess, it might not be
170   AM_RANGE(0x518000, 0x51bfff) AM_DEVREADWRITE("k053936_2", k053936_linectrl_r, k053936_linectrl_w) // ?? guess, it might not be
164171   AM_RANGE(0x600000, 0x6fffff) AM_READNOP          // PSAC 1 ROM readback window
165172   AM_RANGE(0x700000, 0x7fffff) AM_READNOP          // PSAC 2 ROM readback window
166173ADDRESS_MAP_END
r6740r6741
318325
319326/**********************************************************************************/
320327
328static const k056832_interface dbz_k056832_intf =
329{
330   "gfx1", 2,
331   K056832_BPP_4,
332   1, 1,
333   KONAMI_ROM_DEINTERLEAVE_2,
334   dbz_tile_callback, "none"
335};
336
337static const k053247_interface dbz_k053246_intf =
338{
339   "screen",
340   "gfx2", 3,
341   NORMAL_PLANE_ORDER,
342   -52, 16,
343   KONAMI_ROM_DEINTERLEAVE_NONE,
344   dbz_sprite_callback
345};
346
347/* both k053936 use the same wrap/offs */
348static const k053936_interface dbz_k053936_intf =
349{
350   1, -46, -16
351};
352
353
321354static MACHINE_DRIVER_START( dbz )
322355
323356   /* basic machine hardware */
r6740r6741
345378   MDRV_VIDEO_UPDATE(dbz)
346379   MDRV_PALETTE_LENGTH(0x4000/2)
347380
381   MDRV_K056832_ADD("k056832", dbz_k056832_intf)
382   MDRV_K053246_ADD("k053246", dbz_k053246_intf)
383   MDRV_K053251_ADD("k053251")
384   MDRV_K053936_ADD("k053936_1", dbz_k053936_intf)
385   MDRV_K053936_ADD("k053936_2", dbz_k053936_intf)
386
348387   /* sound hardware */
349388   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
350389
r6740r6741
441480{
442481   UINT16 *ROM;
443482
444   konami_rom_deinterleave_2(machine, "gfx1");
445
446483   ROM = (UINT16 *)memory_region(machine, "maincpu");
447484
448485   // nop out dbz1's mask rom test
r6740r6741
460497   ROM[0x990/2] = 0x4e71;
461498}
462499
463static DRIVER_INIT( dbz2 )
464{
465   konami_rom_deinterleave_2(machine, "gfx1");
466}
467
468500GAME( 1993, dbz,  0, dbz, dbz,  dbz,  ROT0, "Banpresto", "Dragonball Z", GAME_IMPERFECT_GRAPHICS )
469GAME( 1994, dbz2, 0, dbz, dbz2, dbz2, ROT0, "Banpresto", "Dragonball Z 2 - Super Battle", GAME_IMPERFECT_GRAPHICS )
501GAME( 1994, dbz2, 0, dbz, dbz2, 0,    ROT0, "Banpresto", "Dragonball Z 2 - Super Battle", GAME_IMPERFECT_GRAPHICS )
src/mame/drivers/20pacgal.c
r6740r6741
4040#include "machine/eepromdev.h"
4141#include "sound/namco.h"
4242#include "sound/dac.h"
43#include "20pacgal.h"
43#include "includes/20pacgal.h"
4444
4545
4646/*************************************
src/mame/drivers/seicross.c
r6740r6741
4848#include "sound/ay8910.h"
4949#include "sound/dac.h"
5050
51extern UINT8 *seicross_videoram;
52extern UINT8 *seicross_colorram;
5153extern UINT8 *seicross_row_scroll;
5254
5355extern WRITE8_HANDLER( seicross_videoram_w );
r6740r6741
121123   AM_RANGE(0x0000, 0x77ff) AM_ROM
122124   AM_RANGE(0x7800, 0x7fff) AM_RAM AM_SHARE("share1")
123125   AM_RANGE(0x8820, 0x887f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
124   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(seicross_videoram_w) AM_BASE_GENERIC(videoram)   /* video RAM */
126   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(seicross_videoram_w) AM_BASE(&seicross_videoram)   /* video RAM */
125127   AM_RANGE(0x9800, 0x981f) AM_RAM AM_BASE(&seicross_row_scroll)
126128   AM_RANGE(0x9880, 0x989f) AM_WRITEONLY AM_BASE_SIZE_GENERIC(spriteram2)
127   AM_RANGE(0x9c00, 0x9fff) AM_RAM_WRITE(seicross_colorram_w) AM_BASE_GENERIC(colorram)
129   AM_RANGE(0x9c00, 0x9fff) AM_RAM_WRITE(seicross_colorram_w) AM_BASE(&seicross_colorram)
128130   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")      /* IN0 */
129131   AM_RANGE(0xa800, 0xa800) AM_READ_PORT("IN1")      /* IN1 */
130132   AM_RANGE(0xb000, 0xb000) AM_READ_PORT("TEST")      /* test */
src/mame/drivers/system16.c
r6740r6741
8888
8989#include "driver.h"
9090#include "cpu/z80/z80.h"
91#include "system16.h"
91#include "includes/system16.h"
9292#include "cpu/m68000/m68000.h"
9393#include "sound/msm5205.h"
9494#include "sound/2151intf.h"
src/mame/drivers/pengo.c
r6740r6741
6464#include "driver.h"
6565#include "cpu/z80/z80.h"
6666#include "machine/segacrpt.h"
67#include "pacman.h"
67#include "includes/pacman.h"
6868#include "sound/namco.h"
6969
7070
r6740r6741
9898
9999static ADDRESS_MAP_START( pengo_map, ADDRESS_SPACE_PROGRAM, 8 )
100100   AM_RANGE(0x0000, 0x7fff) AM_ROM
101   AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram) /* video and color RAM, scratchpad RAM, sprite codes */
102   AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_GENERIC(colorram)
101   AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram) /* video and color RAM, scratchpad RAM, sprite codes */
102   AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram)
103103   AM_RANGE(0x8800, 0x8fef) AM_RAM
104104   AM_RANGE(0x8ff0, 0x8fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
105105   AM_RANGE(0x9000, 0x901f) AM_DEVWRITE("namco", pacman_sound_w) AM_BASE(&pacman_soundregs)
r6740r6741
121121
122122static ADDRESS_MAP_START( jrpacmbl_map, ADDRESS_SPACE_PROGRAM, 8 )
123123   AM_RANGE(0x0000, 0x7fff) AM_ROM
124   AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(jrpacman_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
124   AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(jrpacman_videoram_w) AM_BASE(&pacman_videoram)
125125   AM_RANGE(0x8800, 0x8fef) AM_RAM
126126   AM_RANGE(0x8ff0, 0x8fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
127127   AM_RANGE(0x9000, 0x901f) AM_DEVWRITE("namco", pacman_sound_w) AM_BASE(&pacman_soundregs)
src/mame/drivers/simpsons.c
r6740r6741
6969#include "driver.h"
7070#include "cpu/konami/konami.h" /* for the callback and the firq irq definition */
7171#include "cpu/z80/z80.h"
72#include "video/konamiic.h"
72#include "video/konicdev.h"
73#include "machine/eepromdev.h"
7374#include "sound/2151intf.h"
7475#include "sound/k053260.h"
7576#include "includes/simpsons.h"
76#include "konamipt.h"
77#include "includes/konamipt.h"
7778
7879
7980/***************************************************************************
r6740r6741
8586static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
8687   AM_RANGE(0x0000, 0x0fff) AM_RAM
8788   AM_RANGE(0x1f80, 0x1f80) AM_READ_PORT("COIN")
88   AM_RANGE(0x1f81, 0x1f81) AM_READ(simpsons_eeprom_r)
89   AM_RANGE(0x1f81, 0x1f81) AM_READ_PORT("TEST")
8990   AM_RANGE(0x1f90, 0x1f90) AM_READ_PORT("P1")
9091   AM_RANGE(0x1f91, 0x1f91) AM_READ_PORT("P2")
9192   AM_RANGE(0x1f92, 0x1f92) AM_READ_PORT("P3")
9293   AM_RANGE(0x1f93, 0x1f93) AM_READ_PORT("P4")
93   AM_RANGE(0x1fa0, 0x1fa7) AM_WRITE(K053246_w)
94   AM_RANGE(0x1fb0, 0x1fbf) AM_WRITE(K053251_w)
94   AM_RANGE(0x1fa0, 0x1fa7) AM_DEVWRITE("k053246", k053246_w)
95   AM_RANGE(0x1fb0, 0x1fbf) AM_DEVWRITE("k053251", k053251_w)
9596   AM_RANGE(0x1fc0, 0x1fc0) AM_WRITE(simpsons_coin_counter_w)
9697   AM_RANGE(0x1fc2, 0x1fc2) AM_WRITE(simpsons_eeprom_w)
9798   AM_RANGE(0x1fc4, 0x1fc4) AM_READ(simpsons_sound_interrupt_r)
9899   AM_RANGE(0x1fc6, 0x1fc7) AM_DEVREADWRITE("konami", simpsons_sound_r, k053260_w)
99   AM_RANGE(0x1fc8, 0x1fc9) AM_READ(K053246_r)
100   AM_RANGE(0x1fc8, 0x1fc9) AM_DEVREAD("k053246", k053246_r)
100101   AM_RANGE(0x1fca, 0x1fca) AM_READ(watchdog_reset_r)
101102   AM_RANGE(0x2000, 0x3fff) AM_RAMBANK("bank4")
102   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(K052109_r, K052109_w)
103   AM_RANGE(0x0000, 0x3fff) AM_DEVREADWRITE("k052109", k052109_r, k052109_w)
103104   AM_RANGE(0x4000, 0x5fff) AM_RAM
104105   AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank1")
105106   AM_RANGE(0x8000, 0xffff) AM_ROM
r6740r6741
174175
175176   PORT_START("TEST")
176177   PORT_SERVICE_NO_TOGGLE( 0x01, IP_ACTIVE_LOW )
177   PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNKNOWN )
178   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
179   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )   // eeprom ack
180   PORT_BIT( 0xce, IP_ACTIVE_LOW, IPT_UNKNOWN )
181
182   PORT_START( "EEPROMOUT" )
183   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
184   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
185   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
178186INPUT_PORTS_END
179187
180188static INPUT_PORTS_START( simpsn2p )
r6740r6741
200208   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) //SERVICE3 Unused
201209   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) //SERVICE4 Unused
202210
203   PORT_START("TEST") /* IN5 */
211   PORT_START("TEST")
204212   PORT_SERVICE_NO_TOGGLE( 0x01, IP_ACTIVE_LOW )
205   PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNKNOWN )
213   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
214   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )   // eeprom ack
215   PORT_BIT( 0xce, IP_ACTIVE_LOW, IPT_UNKNOWN )
216
217   PORT_START( "EEPROMOUT" )
218   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
219   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
220   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
206221INPUT_PORTS_END
207222
208223
r6740r6741
215230
216231static void simpsons_objdma(running_machine *machine)
217232{
233   const device_config *k053246 = devtag_get_device(machine, "k053246");
218234   int counter, num_inactive;
219235   UINT16 *src, *dst;
220236
221   K053247_export_config(&dst, 0, 0, 0, &counter);
237   k053247_get_ram(k053246, &dst);
238   counter = k053247_get_dy(k053246);
239
222240   src = machine->generic.spriteram.u16;
223241   num_inactive = counter = 256;
224242
r6740r6741
242260      cputag_set_input_line(machine, "maincpu", KONAMI_FIRQ_LINE, HOLD_LINE);
243261}
244262
263
245264static INTERRUPT_GEN( simpsons_irq )
246265{
247   if (K053246_is_IRQ_enabled())
266   const device_config *k053246 = devtag_get_device(device->machine, "k053246");
267   const device_config *k052109 = devtag_get_device(device->machine, "k052109");
268
269   if (k053246_is_irq_enabled(k053246))
248270   {
249271      simpsons_objdma(device->machine);
250
251272      // 32+256us delay at 8MHz dotclock; artificially shortened since actual V-blank length is unknown
252273      timer_set(device->machine, ATTOTIME_IN_USEC(30), NULL, 0, dmaend_callback);
253274   }
254275
255   if (K052109_is_IRQ_enabled())
276   if (k052109_is_irq_enabled(k052109))
256277      cpu_set_input_line(device, KONAMI_IRQ_LINE, HOLD_LINE);
257278}
258279
280static const k052109_interface simpsons_k052109_intf =
281{
282   "gfx1", 0,
283   NORMAL_PLANE_ORDER,
284   KONAMI_ROM_DEINTERLEAVE_2,
285   simpsons_tile_callback
286};
287
288static const k053247_interface simpsons_k053246_intf =
289{
290   "screen",
291   "gfx2", 1,
292   NORMAL_PLANE_ORDER,
293   53, 23,
294   KONAMI_ROM_DEINTERLEAVE_4,
295   simpsons_sprite_callback
296};
297
298static const eeprom_interface eeprom_intf =
299{
300   7,            /* address bits */
301   8,            /* data bits */
302   "011000",      /*  read command */
303   "011100",      /* write command */
304   0,            /* erase command */
305   "0100000000000",/* lock command */
306   "0100110000000" /* unlock command */
307};
308
259309static MACHINE_DRIVER_START( simpsons )
260310
261311   /* basic machine hardware */
r6740r6741
268318                        /* NMIs are generated by the 053260 */
269319
270320   MDRV_MACHINE_RESET(simpsons)
271   MDRV_NVRAM_HANDLER(simpsons)
272321
322   MDRV_EEPROM_NODEFAULT_ADD("eeprom", eeprom_intf)
323
273324   /* video hardware */
274325   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_AFTER_VBLANK)
275326
r6740r6741
282333
283334   MDRV_PALETTE_LENGTH(2048)
284335
285   MDRV_VIDEO_START(simpsons)
286336   MDRV_VIDEO_UPDATE(simpsons)
287337
338   MDRV_K052109_ADD("k052109", simpsons_k052109_intf)
339   MDRV_K053246_ADD("k053246", simpsons_k053246_intf)
340   MDRV_K053251_ADD("k053251")
341
288342   /* sound hardware */
289343   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
290344
r6740r6741
475529
476530***************************************************************************/
477531
478static DRIVER_INIT( simpsons )
479{
480   konami_rom_deinterleave_2(machine, "gfx1");
481   konami_rom_deinterleave_4(machine, "gfx2");
482}
483
484532// the region warning, if one exists, is shown after the high-score screen in attract mode
485GAME( 1991, simpsons,    0,        simpsons, simpsons, simpsons, ROT0, "Konami", "The Simpsons (4 Players World, set 1)", 0 )
486GAME( 1991, simpsons4pa, simpsons, simpsons, simpsons, simpsons, ROT0, "Konami", "The Simpsons (4 Players World, set 2)", 0 )
487GAME( 1991, simpsons2p,  simpsons, simpsons, simpsn2p, simpsons, ROT0, "Konami", "The Simpsons (2 Players World, set 1)", 0 )
488GAME( 1991, simpsons2p2, simpsons, simpsons, simpsons, simpsons, ROT0, "Konami", "The Simpsons (2 Players World, set 2)", 0 )
489GAME( 1991, simpsons2pa, simpsons, simpsons, simpsn2p, simpsons, ROT0, "Konami", "The Simpsons (2 Players Asia)", 0 )
490GAME( 1991, simpsons2pj, simpsons, simpsons, simpsn2p, simpsons, ROT0, "Konami", "The Simpsons (2 Players Japan)", 0 )
533GAME( 1991, simpsons,    0,        simpsons, simpsons, 0, ROT0, "Konami", "The Simpsons (4 Players World, set 1)", 0 )
534GAME( 1991, simpsons4pa, simpsons, simpsons, simpsons, 0, ROT0, "Konami", "The Simpsons (4 Players World, set 2)", 0 )
535GAME( 1991, simpsons2p,  simpsons, simpsons, simpsn2p, 0, ROT0, "Konami", "The Simpsons (2 Players World, set 1)", 0 )
536GAME( 1991, simpsons2p2, simpsons, simpsons, simpsons, 0, ROT0, "Konami", "The Simpsons (2 Players World, set 2)", 0 )
537GAME( 1991, simpsons2pa, simpsons, simpsons, simpsn2p, 0, ROT0, "Konami", "The Simpsons (2 Players Asia)", 0 )
538GAME( 1991, simpsons2pj, simpsons, simpsons, simpsn2p, 0, ROT0, "Konami", "The Simpsons (2 Players Japan)", 0 )
src/mame/drivers/actfancr.c
r6740r6741
2828#include "sound/2203intf.h"
2929#include "sound/3812intf.h"
3030#include "sound/okim6295.h"
31#include "actfancr.h"
31#include "includes/actfancr.h"
3232
3333
3434/******************************************************************************/
src/mame/drivers/model1.c
r6740r6741
628628#include "cpu/v60/v60.h"
629629#include "deprecat.h"
630630#include "machine/eeprom.h"
631#include "system16.h"
631#include "includes/system16.h"
632632#include "video/segaic24.h"
633633#include "cpu/m68000/m68000.h"
634634#include "cpu/mb86233/mb86233.h"
r6740r6741
14571457   MDRV_CPU_ADD("audiocpu", M68000, 10000000)   // verified on real h/w
14581458   MDRV_CPU_PROGRAM_MAP(model1_snd)
14591459
1460   MDRV_MACHINE_START(model1)
14601461   MDRV_MACHINE_RESET(model1)
14611462   MDRV_NVRAM_HANDLER(generic_0fill)
14621463
r6740r6741
15001501   MDRV_CPU_CONFIG(model1_vr_tgp_config)
15011502   MDRV_CPU_PROGRAM_MAP(model1_vr_tgp_map)
15021503
1504   MDRV_MACHINE_START(model1)
15031505   MDRV_MACHINE_RESET(model1_vr)
15041506   MDRV_NVRAM_HANDLER(generic_0fill)
15051507
src/mame/drivers/polepos.c
r6740r6741
228228#include "sound/samples.h"
229229#include "audio/namco52.h"
230230#include "audio/namco54.h"
231#include "polepos.h"
231#include "includes/polepos.h"
232232#include "sound/tms5220.h"
233233
234234#include "polepos.lh"
src/mame/drivers/tank8.c
r6740r6741
66
77#include "driver.h"
88#include "cpu/m6800/m6800.h"
9#include "tank8.h"
9#include "includes/tank8.h"
1010#include "sound/discrete.h"
1111
1212static int collision_index;
src/mame/drivers/cps1.c
r6740r6741
239239#include "sound/qsound.h"
240240#include "sound/msm5205.h"
241241
242#include "includes/cps1.h"       /* External CPS1 definitions */
242243
243#include "cps1.h"       /* External CPS1 definitions */
244244
245
245246READ16_HANDLER( cps1_dsw_r )
246247{
247248   static const char *const dswname[] = { "IN0", "DSWA", "DSWB", "DSWC" };
r6740r6741
256257   return (in << 8) | in;
257258}
258259
259static int dial[2];
260
261260static READ16_HANDLER( forgottn_dial_0_r )
262261{
263   return ((input_port_read(space->machine, "DIAL0") - dial[0]) >> (8*offset)) & 0xff;
262   cps_state *state = (cps_state *)space->machine->driver_data;
263   return ((input_port_read(space->machine, "DIAL0") - state->dial[0]) >> (8 * offset)) & 0xff;
264264}
265265
266266static READ16_HANDLER( forgottn_dial_1_r )
267267{
268   return ((input_port_read(space->machine, "DIAL1") - dial[1]) >> (8*offset)) & 0xff;
268   cps_state *state = (cps_state *)space->machine->driver_data;
269   return ((input_port_read(space->machine, "DIAL1") - state->dial[1]) >> (8 * offset)) & 0xff;
269270}
270271
271272static WRITE16_HANDLER( forgottn_dial_0_reset_w )
272273{
273   dial[0] = input_port_read(space->machine, "DIAL0");
274   cps_state *state = (cps_state *)space->machine->driver_data;
275   state->dial[0] = input_port_read(space->machine, "DIAL0");
274276}
275277
276278static WRITE16_HANDLER( forgottn_dial_1_reset_w )
277279{
278   dial[1] = input_port_read(space->machine, "DIAL1");
280   cps_state *state = (cps_state *)space->machine->driver_data;
281   state->dial[1] = input_port_read(space->machine, "DIAL1");
279282}
280283
281284
282285static WRITE8_HANDLER( cps1_snd_bankswitch_w )
283286{
284   UINT8 *RAM = memory_region(space->machine, "audiocpu");
285   int bankaddr;
286
287   bankaddr = ((data & 1) * 0x4000);
288   memory_set_bankptr(space->machine, "bank1",&RAM[0x10000 + bankaddr]);
287   memory_set_bank(space->machine, "bank1", data & 0x01);
289288}
290289
291290static WRITE8_DEVICE_HANDLER( cps1_oki_pin7_w )
r6740r6741
296295static WRITE16_HANDLER( cps1_soundlatch_w )
297296{
298297   if (ACCESSING_BITS_0_7)
299      soundlatch_w(space,0,data & 0xff);
298      soundlatch_w(space, 0, data & 0xff);
300299}
301300
302301static WRITE16_HANDLER( cps1_soundlatch2_w )
303302{
304303   if (ACCESSING_BITS_0_7)
305      soundlatch2_w(space,0,data & 0xff);
304      soundlatch2_w(space, 0, data & 0xff);
306305}
307306
308307WRITE16_HANDLER( cps1_coinctrl_w )
309308{
310309   if (ACCESSING_BITS_8_15)
311310   {
312      coin_counter_w(space->machine, 0,data & 0x0100);
313      coin_counter_w(space->machine, 1,data & 0x0200);
314      coin_lockout_w(space->machine, 0,~data & 0x0400);
315      coin_lockout_w(space->machine, 1,~data & 0x0800);
311      coin_counter_w(space->machine, 0, data & 0x0100);
312      coin_counter_w(space->machine, 1, data & 0x0200);
313      coin_lockout_w(space->machine, 0, ~data & 0x0400);
314      coin_lockout_w(space->machine, 1, ~data & 0x0800);
316315
317316      // bit 15 = CPS-A custom reset?
318317   }
r6740r6741
322321{
323322   if (ACCESSING_BITS_0_7)
324323   {
325      coin_counter_w(space->machine, 2,data & 0x01);
326      coin_lockout_w(space->machine, 2,~data & 0x02);
327      coin_counter_w(space->machine, 3,data & 0x04);
328      coin_lockout_w(space->machine, 3,~data & 0x08);
324      coin_counter_w(space->machine, 2, data & 0x01);
325      coin_lockout_w(space->machine, 2, ~data & 0x02);
326      coin_counter_w(space->machine, 3, data & 0x04);
327      coin_lockout_w(space->machine, 3, ~data & 0x08);
329328    }
330329}
331330
r6740r6741
343342*
344343********************************************************************/
345344
346static UINT8 *qsound_sharedram1,*qsound_sharedram2;
347345
348346static INTERRUPT_GEN( cps1_qsound_interrupt )
349347{
r6740r6741
355353{
356354   UINT8 *rom = memory_region(space->machine, "user1");
357355
358   if (rom) return rom[offset] | 0xff00;
356   if (rom)
357      return rom[offset] | 0xff00;
359358   else
360359   {
361      popmessage("%06x: read sound ROM byte %04x",cpu_get_pc(space->cpu),offset);
360      popmessage("%06x: read sound ROM byte %04x", cpu_get_pc(space->cpu), offset);
362361      return 0;
363362   }
364363}
365364
366365READ16_HANDLER( qsound_sharedram1_r )
367366{
368   return qsound_sharedram1[offset] | 0xff00;
367   cps_state *state = (cps_state *)space->machine->driver_data;
368   return state->qsound_sharedram1[offset] | 0xff00;
369369}
370370
371371WRITE16_HANDLER( qsound_sharedram1_w )
372372{
373   cps_state *state = (cps_state *)space->machine->driver_data;
374
373375   if (ACCESSING_BITS_0_7)
374      qsound_sharedram1[offset] = data;
376      state->qsound_sharedram1[offset] = data;
375377}
376378
377379static READ16_HANDLER( qsound_sharedram2_r )
378380{
379   return qsound_sharedram2[offset] | 0xff00;
381   cps_state *state = (cps_state *)space->machine->driver_data;
382   return state->qsound_sharedram2[offset] | 0xff00;
380383}
381384
382385static WRITE16_HANDLER( qsound_sharedram2_w )
383386{
387   cps_state *state = (cps_state *)space->machine->driver_data;
388
384389   if (ACCESSING_BITS_0_7)
385      qsound_sharedram2[offset] = data;
390      state->qsound_sharedram2[offset] = data;
386391}
387392
388393static WRITE8_HANDLER( qsound_banksw_w )
389394{
390   /*
391    Z80 bank register for music note data. It's odd that it isn't encrypted
392    though.
393    */
394   UINT8 *RAM = memory_region(space->machine, "audiocpu");
395   int bankaddress=0x10000+((data&0x0f)*0x4000);
396   if (bankaddress >= memory_region_length(space->machine, "audiocpu"))
395   /* Z80 bank register for music note data. It's odd that it isn't encrypted though. */
396   int bank = data & 0x0f;
397   if ((0x10000 + (bank * 0x4000)) >= memory_region_length(space->machine, "audiocpu"))
397398   {
398399      logerror("WARNING: Q sound bank overflow (%02x)\n", data);
399      bankaddress=0x10000;
400      bank = 0;
400401   }
401   memory_set_bankptr(space->machine, "bank1", &RAM[bankaddress]);
402
403   memory_set_bank(space->machine, "bank1", bank);
402404}
403405
404406
r6740r6741
432434};
433435#endif
434436
435// FIXME: these are still needed by pang3
436static READ16_HANDLER( cps1_eeprom_port_r )
437{
438   const device_config *eeprom = devtag_get_device(space->machine, "eeprom");
439   return eepromdev_read_bit(eeprom);
440}
441437
442static WRITE16_HANDLER( cps1_eeprom_port_w )
443{
444   if (ACCESSING_BITS_0_7)
445   {
446      /*
447        bit 0 = data
448        bit 6 = clock
449        bit 7 = cs
450        */
451      input_port_write(space->machine, "EEPROMOUT", data, 0xff);
452   }
453}
454
455
456
457438/*
458439PAL PRG1 (16P8B @ 12H):
459440
r6740r6741
569550   AM_RANGE(0x800020, 0x800021) AM_READNOP                  /* ? Used by Rockman ? not mapped according to PAL */
570551   AM_RANGE(0x800030, 0x800037) AM_WRITE(cps1_coinctrl_w)
571552   /* Forgotten Worlds has dial controls on B-board mapped at 800040-80005f. See DRIVER_INIT */
572   AM_RANGE(0x800100, 0x80013f) AM_WRITE(cps1_cps_a_w) AM_BASE(&cps1_cps_a_regs)   /* CPS-A custom */
553   AM_RANGE(0x800100, 0x80013f) AM_WRITE(cps1_cps_a_w) AM_BASE_MEMBER(cps_state, cps_a_regs)   /* CPS-A custom */
573554   /* CPS-B custom is mapped by a PAL on B-board. SF2 revision "E" US 910228 has it a a different
574555       address, see DRIVER_INIT */
575   AM_RANGE(0x800140, 0x80017f) AM_READWRITE(cps1_cps_b_r, cps1_cps_b_w) AM_BASE(&cps1_cps_b_regs)
556   AM_RANGE(0x800140, 0x80017f) AM_READWRITE(cps1_cps_b_r, cps1_cps_b_w) AM_BASE_MEMBER(cps_state, cps_b_regs)
576557   AM_RANGE(0x800180, 0x800187) AM_WRITE(cps1_soundlatch_w)   /* Sound command */
577558   AM_RANGE(0x800188, 0x80018f) AM_WRITE(cps1_soundlatch2_w)   /* Sound timer fade */
578   AM_RANGE(0x900000, 0x92ffff) AM_RAM_WRITE(cps1_gfxram_w) AM_BASE(&cps1_gfxram) AM_SIZE(&cps1_gfxram_size)   /* SF2CE executes code from here */
559   AM_RANGE(0x900000, 0x92ffff) AM_RAM_WRITE(cps1_gfxram_w) AM_BASE_SIZE_MEMBER(cps_state, gfxram, gfxram_size)   /* SF2CE executes code from here */
579560   AM_RANGE(0xff0000, 0xffffff) AM_RAM
580561ADDRESS_MAP_END
581562
r6740r6741
620601   AM_RANGE(0x800000, 0x800007) AM_READ_PORT("IN1")         /* Player input ports */
621602   AM_RANGE(0x800018, 0x80001f) AM_READ(cps1_dsw_r)         /* System input ports / Dip Switches */
622603   AM_RANGE(0x800030, 0x800037) AM_WRITE(cps1_coinctrl_w)
623   AM_RANGE(0x800100, 0x80013f) AM_WRITE(cps1_cps_a_w) AM_BASE(&cps1_cps_a_regs)   /* CPS-A custom */
624   AM_RANGE(0x800140, 0x80017f) AM_READWRITE(cps1_cps_b_r, cps1_cps_b_w) AM_BASE(&cps1_cps_b_regs)   /* CPS-B custom (mapped by LWIO/IOB1 PAL on B-board) */
625   AM_RANGE(0x900000, 0x92ffff) AM_RAM_WRITE(cps1_gfxram_w) AM_BASE(&cps1_gfxram) AM_SIZE(&cps1_gfxram_size)   /* SF2CE executes code from here */
604   AM_RANGE(0x800100, 0x80013f) AM_WRITE(cps1_cps_a_w) AM_BASE_MEMBER(cps_state, cps_a_regs)   /* CPS-A custom */
605   AM_RANGE(0x800140, 0x80017f) AM_READWRITE(cps1_cps_b_r, cps1_cps_b_w) AM_BASE_MEMBER(cps_state, cps_b_regs)   /* CPS-B custom (mapped by LWIO/IOB1 PAL on B-board) */
606   AM_RANGE(0x900000, 0x92ffff) AM_RAM_WRITE(cps1_gfxram_w) AM_BASE_SIZE_MEMBER(cps_state, gfxram, gfxram_size)   /* SF2CE executes code from here */
626607   AM_RANGE(0xf00000, 0xf0ffff) AM_READ(qsound_rom_r)         /* Slammasters protection */
627608   AM_RANGE(0xf18000, 0xf19fff) AM_READWRITE(qsound_sharedram1_r, qsound_sharedram1_w)  /* Q RAM */
628609   AM_RANGE(0xf1c000, 0xf1c001) AM_READ_PORT("IN2")         /* Player 3 controls (later games) */
r6740r6741
636617ADDRESS_MAP_START( qsound_sub_map, ADDRESS_SPACE_PROGRAM, 8 )   // used by cps2.c too
637618   AM_RANGE(0x0000, 0x7fff) AM_ROM
638619   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")   /* banked (contains music data) */
639   AM_RANGE(0xc000, 0xcfff) AM_RAM AM_BASE(&qsound_sharedram1)
620   AM_RANGE(0xc000, 0xcfff) AM_RAM AM_BASE_MEMBER(cps_state, qsound_sharedram1)
640621   AM_RANGE(0xd000, 0xd002) AM_DEVWRITE("qsound", qsound_w)
641622   AM_RANGE(0xd003, 0xd003) AM_WRITE(qsound_banksw_w)
642623   AM_RANGE(0xd007, 0xd007) AM_DEVREAD("qsound", qsound_r)
643   AM_RANGE(0xf000, 0xffff) AM_RAM AM_BASE(&qsound_sharedram2)
624   AM_RANGE(0xf000, 0xffff) AM_RAM AM_BASE_MEMBER(cps_state, qsound_sharedram2)
644625ADDRESS_MAP_END
645626
646627/***********************************************************
r6740r6741
27582739
27592740static void cps1_irq_handler_mus(const device_config *device, int irq)
27602741{
2761   cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE);
2742   cps_state *state = (cps_state *)device->machine->driver_data;
2743   cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE);
27622744}
27632745
27642746static const ym2151_interface ym2151_config =
r6740r6741
27772759*
27782760********************************************************************/
27792761
2762static MACHINE_START( common )
2763{
2764   cps_state *state = (cps_state *)machine->driver_data;
2765
2766   state->maincpu = devtag_get_device(machine, "maincpu");
2767   state->audiocpu = devtag_get_device(machine, "audiocpu");
2768}
2769
2770static MACHINE_START( cps1 )
2771{
2772   MACHINE_START_CALL(common);
2773   memory_configure_bank(machine, "bank1", 0, 2, memory_region(machine, "audiocpu") + 0x10000, 0x4000);
2774}
2775
2776static MACHINE_START( qsound )
2777{
2778   MACHINE_START_CALL(common);
2779   memory_configure_bank(machine, "bank1", 0, 6, memory_region(machine, "audiocpu") + 0x10000, 0x4000);
2780}
2781
27802782static MACHINE_DRIVER_START( cps1_10MHz )
27812783
2784   /* driver data */
2785   MDRV_DRIVER_DATA(cps_state)
2786
27822787   /* basic machine hardware */
27832788   MDRV_CPU_ADD("maincpu", M68000, XTAL_10MHz )   /* verified on pcb */
27842789   MDRV_CPU_PROGRAM_MAP(main_map)
r6740r6741
27872792   MDRV_CPU_ADD("audiocpu", Z80, XTAL_3_579545MHz)  /* verified on pcb */
27882793   MDRV_CPU_PROGRAM_MAP(sub_map)
27892794
2795   MDRV_MACHINE_START(cps1)
2796
27902797   /* video hardware */
27912798   MDRV_SCREEN_ADD("screen", RASTER)
27922799   MDRV_SCREEN_REFRESH_RATE(59.61) /* verified on one of the input gates of the 74ls08@4J on GNG romboard 88620-b-2 */
r6740r6741
28462853   MDRV_CPU_PROGRAM_MAP(qsound_sub_map)
28472854   MDRV_CPU_PERIODIC_INT(irq0_line_hold, 250)   /* ?? */
28482855
2856   MDRV_MACHINE_START(qsound)
2857
28492858   MDRV_EEPROM_NODEFAULT_ADD("eeprom", qsound_eeprom_interface)
28502859
28512860   /* sound hardware */
r6740r6741
28642873
28652874static MACHINE_DRIVER_START( cpspicb )
28662875
2876   /* driver data */
2877   MDRV_DRIVER_DATA(cps_state)
2878
28672879   /* basic machine hardware */
28682880   MDRV_CPU_ADD("maincpu", M68000, 12000000)
28692881   MDRV_CPU_PROGRAM_MAP(main_map)
r6740r6741
28722884   MDRV_CPU_ADD("audiocpu", PIC16C57, 12000000)
28732885   MDRV_CPU_FLAGS(CPU_DISABLE) /* no valid dumps .. */
28742886
2887   MDRV_MACHINE_START(common)
2888
28752889   /* video hardware */
28762890   MDRV_SCREEN_ADD("screen", RASTER)
28772891   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
29392953
29402954static MACHINE_DRIVER_START( sf2mdt )
29412955
2956   /* driver data */
2957   MDRV_DRIVER_DATA(cps_state)
2958
29422959   /* basic machine hardware */
29432960   MDRV_CPU_ADD("maincpu", M68000, 12000000)
29442961   MDRV_CPU_PROGRAM_MAP(main_map)
r6740r6741
29472964   MDRV_CPU_ADD("audiocpu", Z80, 3579545)
29482965   MDRV_CPU_PROGRAM_MAP(sf2mdt_z80map)
29492966
2967   MDRV_MACHINE_START(common)
2968
29502969   /* video hardware */
29512970   MDRV_SCREEN_ADD("screen", RASTER)
29522971   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
30223041
30233042static MACHINE_DRIVER_START( knightsb )
30243043
3044   /* driver data */
3045   MDRV_DRIVER_DATA(cps_state)
3046
30253047   /* basic machine hardware */
30263048   MDRV_CPU_ADD("maincpu", M68000, 24000000 / 2)
30273049   MDRV_CPU_PROGRAM_MAP(main_map)
r6740r6741
30303052   MDRV_CPU_ADD("audiocpu", Z80, 29821000 / 8)
30313053   MDRV_CPU_PROGRAM_MAP(sf2mdt_z80map)
30323054
3055   MDRV_MACHINE_START(common)
3056
30333057   /* video hardware */
30343058   MDRV_SCREEN_ADD("screen", RASTER)
30353059   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
86038627
86048628static DRIVER_INIT( forgottn )
86058629{
8630   cps_state *state = (cps_state *)machine->driver_data;
8631
86068632   /* Forgotten Worlds has a NEC uPD4701AC on the B-board handling dial inputs from the CN-MOWS connector. */
86078633   /* The memory mapping is handled by PAL LWIO */
86088634   memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x800040, 0x800041, 0, 0, forgottn_dial_0_reset_w);
86098635   memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x800048, 0x800049, 0, 0, forgottn_dial_1_reset_w);
8610   memory_install_read16_handler (cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x800052, 0x800055, 0, 0, forgottn_dial_0_r);
8611   memory_install_read16_handler (cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x80005a, 0x80005d, 0, 0, forgottn_dial_1_r);
8636   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x800052, 0x800055, 0, 0, forgottn_dial_0_r);
8637   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x80005a, 0x80005d, 0, 0, forgottn_dial_1_r);
86128638
8639   state_save_register_global_array(machine, state->dial);
8640
8641   state->dial[0] = 0;
8642   state->dial[1] = 0;
8643
86138644   DRIVER_INIT_CALL(cps1);
86148645}
86158646
r6740r6741
86268657static DRIVER_INIT( sf2hack )
86278658{
86288659   /* some SF2 hacks have some inputs wired to the LSB instead of MSB */
8629   memory_install_read16_handler (cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x800018, 0x80001f, 0, 0, cps1_hack_dsw_r);
8660   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x800018, 0x80001f, 0, 0, cps1_hack_dsw_r);
86308661
86318662   DRIVER_INIT_CALL(cps1);
86328663}
r6740r6741
86598690{
86608691   /* Pang 3 is the only non-QSound game to have an EEPROM. */
86618692   /* It is mapped in the CPS-B address range so probably is on the C-board. */
8662   memory_install_readwrite16_handler (cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x80017a, 0x80017b, 0, 0, cps1_eeprom_port_r, cps1_eeprom_port_w);
8693   memory_install_readwrite_port(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x80017a, 0x80017b, 0, 0, "EEPROMIN", "EEPROMOUT");
86638694
86648695   DRIVER_INIT_CALL(cps1);
86658696}
r6740r6741
86678698static DRIVER_INIT( pang3j )
86688699{
86698700   UINT16 *rom = (UINT16 *)memory_region(machine, "maincpu");
8670   int A,src,dst;
8701   int A, src, dst;
86718702
8672   for (A = 0x80000;A < 0x100000;A += 2)
8703   for (A = 0x80000; A < 0x100000; A += 2)
86738704   {
86748705      /* only the low 8 bits of each word are encrypted */
8675      src = rom[A/2];
8706      src = rom[A / 2];
86768707      dst = src & 0xff00;
86778708      if ( src & 0x01) dst ^= 0x04;
86788709      if ( src & 0x02) dst ^= 0x21;
r6740r6741
87038734
87048735   for( i = 0; i < gfx_size; i += 8 )
87058736   {
8706      tmp = rom[i+1];
8707      rom[i+1] = rom[i+4];
8708      rom[i+4] = tmp;
8709      tmp = rom[i+3];
8710      rom[i+3] = rom[i+6];
8711      rom[i+6] = tmp;
8737      tmp = rom[i + 1];
8738      rom[i + 1] = rom[i + 4];
8739      rom[i + 4] = tmp;
8740      tmp = rom[i + 3];
8741      rom[i + 3] = rom[i + 6];
8742      rom[i + 6] = tmp;
87128743   }
87138744   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x70c01a, 0x70c01b, 0, 0, sf2mdt_r);
87148745   memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x70c01c, 0x70c01d, 0, 0, sf2mdt_r);
r6740r6741
87208751}
87218752
87228753
8723GAME( 1988, forgottn, 0,        cps1_10MHz, forgottn, forgottn, ROT0,   "Capcom", "Forgotten Worlds (World)", 0 )
8724GAME( 1988, forgottnu,forgottn, cps1_10MHz, forgottn, forgottn, ROT0,   "Capcom", "Forgotten Worlds (US)", 0 )
8725GAME( 1988, lostwrld, forgottn, cps1_10MHz, forgottn, forgottn, ROT0,   "Capcom", "Lost Worlds (Japan)", 0 )
8726GAME( 1988, lostwrldo,forgottn, cps1_10MHz, forgottn, forgottn, ROT0,   "Capcom", "Lost Worlds (Japan Old Ver.)", 0 )
8727GAME( 1988, ghouls,   0,        cps1_10MHz, ghouls,   cps1,     ROT0,   "Capcom", "Ghouls'n Ghosts (World)" , 0)            // Wed.26.10.1988 in the ROMS
8728GAME( 1988, ghoulsu,  ghouls,   cps1_10MHz, ghoulsu,  cps1,     ROT0,   "Capcom", "Ghouls'n Ghosts (US)" , 0)               // Wed.26.10.1988 in the ROMS
8729GAME( 1988, daimakai, ghouls,   cps1_10MHz, daimakai, cps1,     ROT0,   "Capcom", "Dai Makai-Mura (Japan)" , 0)               // Wed.26.10.1988 in the ROMS
8730GAME( 1988, daimakair,ghouls,   cps1_10MHz, daimakai, cps1,     ROT0,   "Capcom", "Dai Makai-Mura (Japan Resale Ver.)" , 0)      // still Wed.26.10.1988 in the ROMS...
8731GAME( 1989, strider,  0,        cps1_10MHz, strider,  cps1,     ROT0,   "Capcom", "Strider (US set 1)", 0 )
8732GAME( 1989, striderua,strider,  cps1_10MHz, stridrua, cps1,     ROT0,   "Capcom", "Strider (US set 2)", 0 )
8733GAME( 1989, striderj, strider,  cps1_10MHz, strider,  cps1,     ROT0,   "Capcom", "Strider Hiryu (Japan)", 0 )
8734GAME( 1989, striderjr,strider,  cps1_10MHz, strider,  cps1,     ROT0,   "Capcom", "Strider Hiryu (Japan Resale Ver.)", 0 )
8735GAME( 1989, dynwar,   0,        cps1_10MHz, dynwar,   cps1,     ROT0,   "Capcom", "Dynasty Wars (US set 1)", 0 )            // (c) Capcom U.S.A.
8736GAME( 1989, dynwaru,  dynwar,   cps1_10MHz, dynwar,   cps1,     ROT0,   "Capcom", "Dynasty Wars (US set 2)", 0 )            // (c) Capcom U.S.A.
8737GAME( 1989, dynwarj,  dynwar,   cps1_10MHz, dynwar,   cps1,     ROT0,   "Capcom", "Tenchi wo Kurau (Japan)", 0 )
8738GAME( 1989, willow,   0,        cps1_10MHz, willow,   cps1,     ROT0,   "Capcom", "Willow (US)", 0 )
8739GAME( 1989, willowj,  willow,   cps1_10MHz, willow,   cps1,     ROT0,   "Capcom", "Willow (Japan, Japanese)" , 0)            // Japan "warning"
8740GAME( 1989, willowje, willow,   cps1_10MHz, willow,   cps1,     ROT0,   "Capcom", "Willow (Japan, English)", 0 )            // (c) Capcom U.S.A. but Japan "warning"
8741GAME( 1989, unsquad,  0,        cps1_10MHz, unsquad,  cps1,     ROT0,   "Capcom", "U.N. Squadron (US)", 0 )
8742GAME( 1989, area88,   unsquad,  cps1_10MHz, unsquad,  cps1,     ROT0,   "Capcom", "Area 88 (Japan)", 0 )
8743GAME( 1989, ffight,   0,        cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (World)", 0 )
8744GAME( 1989, ffightu,  ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (US)", 0 )
8745GAME( 1989, ffightua, ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (US 900112)", 0 )
8746GAME( 1989, ffightub, ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (US 900613)", 0 )
8747GAME( 1989, ffightj,  ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (Japan)", 0 )
8748GAME( 1989, ffightj1, ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (Japan 900305)", 0 )
8749GAME( 1989, ffightj2, ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (Japan 900112)", 0 )
8750GAME( 1990, 1941,     0,        cps1_10MHz, 1941,     cps1,     ROT270, "Capcom", "1941 - Counter Attack (World)", 0 )
8751GAME( 1990, 1941j,    1941,     cps1_10MHz, 1941,     cps1,     ROT270, "Capcom", "1941 - Counter Attack (Japan)", 0 )
8752GAME( 1990, mercs,    0,        cps1_10MHz, mercs,    cps1,     ROT270, "Capcom", "Mercs (World 900302)" , 0)               // "ETC"
8753GAME( 1990, mercsu,   mercs,    cps1_10MHz, mercs,    cps1,     ROT270, "Capcom", "Mercs (US 900302)", 0 )
8754GAME( 1990, mercsua,  mercs,    cps1_10MHz, mercs,    cps1,     ROT270, "Capcom", "Mercs (US 900608)", 0 )
8755GAME( 1990, mercsj,   mercs,    cps1_10MHz, mercs,    cps1,     ROT270, "Capcom", "Senjou no Ookami II (Japan 900302)", 0 )
8756GAME( 1990, mtwins,   0,        cps1_10MHz, mtwins,   cps1,     ROT0,   "Capcom", "Mega Twins (World 900619)", 0 )            // "ETC" - (c) Capcom U.S.A. with World "warning"
8757GAME( 1990, chikij,   mtwins,   cps1_10MHz, mtwins,   cps1,     ROT0,   "Capcom", "Chiki Chiki Boys (Japan 900619)", 0 )
8758GAME( 1990, msword,   0,        cps1_10MHz, msword,   cps1,     ROT0,   "Capcom", "Magic Sword - Heroic Fantasy (World 900725)" , 0)   // 25.07.1990  "Other Country"
8759GAME( 1990, mswordr1, msword,   cps1_10MHz, msword,   cps1,     ROT0,   "Capcom", "Magic Sword - Heroic Fantasy (World 900623)" , 0)   // 23.06.1990  "Other Country"
8760GAME( 1990, mswordu,  msword,   cps1_10MHz, msword,   cps1,     ROT0,   "Capcom", "Magic Sword - Heroic Fantasy (US 900725)" , 0)      // 25.07.1990  "U.S.A."
8761GAME( 1990, mswordj,  msword,   cps1_10MHz, msword,   cps1,     ROT0,   "Capcom", "Magic Sword (Japan 900623)" , 0)                  // 23.06.1990  "Japan"
8762GAME( 1990, cawing,   0,        cps1_10MHz, cawing,   cps1,     ROT0,   "Capcom", "Carrier Air Wing (World 901012)" , 0)         // "ETC"
8763GAME( 1990, cawingr1, cawing,   cps1_10MHz, cawing,   cps1,     ROT0,   "Capcom", "Carrier Air Wing (World 901009)" , 0)         // "ETC"
8764GAME( 1990, cawingu,  cawing,   cps1_10MHz, cawing,   cps1,     ROT0,   "Capcom", "Carrier Air Wing (US 901012)", 0 )
8765GAME( 1990, cawingj,  cawing,   cps1_10MHz, cawing,   cps1,     ROT0,   "Capcom", "U.S. Navy (Japan 901012)", 0 )
8766GAME( 1990, nemo,     0,        cps1_10MHz, nemo,     cps1,     ROT0,   "Capcom", "Nemo (World 901130)" , 0)                  // "ETC"
8767GAME( 1990, nemoj,    nemo,     cps1_10MHz, nemo,     cps1,     ROT0,   "Capcom", "Nemo (Japan 901120)", 0 )
8768GAME( 1991, sf2,      0,        cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (World 910522)" , 0)   // "ETC"
8769GAME( 1991, sf2eb,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (World 910214)" , 0)   // "ETC"
8770GAME( 1992, sf2ebbl,  sf2,      cps1_10MHz, sf2hack,  sf2hack,  ROT0,   "bootleg","Street Fighter II - The World Warrior (World 910214, TAB Austria bootleg)", 0 )
8771GAME( 1991, sf2ua,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910206)", 0 )
8772GAME( 1991, sf2ub,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910214)", 0 )
8773GAME( 1991, sf2ud,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910318)", 0 )
8774GAME( 1991, sf2ue,    sf2,      cps1_10MHz, sf2,      sf2ue,    ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910228)", 0 )
8775GAME( 1991, sf2uf,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910411)", 0 )
8776GAME( 1991, sf2ui,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910522)", 0 )
8777GAME( 1991, sf2uk,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 911101)", 0 )
8778GAME( 1991, sf2j,     sf2,      cps1_10MHz, sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (Japan 911210)", 0 )
8779GAME( 1991, sf2ja,    sf2,      cps1_10MHz, sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (Japan 910214)", 0 )
8780GAME( 1991, sf2jc,    sf2,      cps1_10MHz, sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (Japan 910306)", 0 )
8781GAME( 1991, sf2qp1,   sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II - The World Warrior (Quicken Pt-I, bootleg)" , 0)      // 910214
8782GAME( 1991, 3wonders, 0,        cps1_10MHz, 3wonders, cps1,     ROT0,   "Capcom", "Three Wonders (World 910520)" , 0)               // "ETC"
8783GAME( 1991, 3wondersu,3wonders, cps1_10MHz, 3wonders, cps1,     ROT0,   "Capcom", "Three Wonders (US 910520)", 0 )
8784GAME( 1991, wonder3,  3wonders, cps1_10MHz, 3wonders, cps1,     ROT0,   "Capcom", "Wonder 3 (Japan 910520)", 0 )
8785GAME( 1991, 3wondersh,3wonders, cps1_10MHz, 3wonders, cps1,     ROT0,   "bootleg","Three Wonders (hack?)", 0 )
8786GAME( 1991, kod,      0,        cps1_10MHz, kod,      cps1,     ROT0,   "Capcom", "The King of Dragons (World 910711)" , 0)            // "ETC"
8787GAME( 1991, kodu,     kod,      cps1_10MHz, kodj,     cps1,     ROT0,   "Capcom", "The King of Dragons (US 910910)", 0 )
8788GAME( 1991, kodj,     kod,      cps1_10MHz, kodj,     cps1,     ROT0,   "Capcom", "The King of Dragons (Japan 910805)", 0 )
8789GAME( 1991, captcomm, 0,        cps1_10MHz, captcomm, cps1,     ROT0,   "Capcom", "Captain Commando (World 911014)" , 0)            // "OTHER COUNTRY"
8790GAME( 1991, captcommu,captcomm, cps1_10MHz, captcomm, cps1,     ROT0,   "Capcom", "Captain Commando (US 910928)", 0 )
8791GAME( 1991, captcommj,captcomm, cps1_10MHz, captcomm, cps1,     ROT0,   "Capcom", "Captain Commando (Japan 911202)", 0 )
8792GAME( 1991, captcommb,captcomm, cps1_10MHz, captcomm, cps1,     ROT0,   "bootleg","Captain Commando (bootleg)", GAME_NOT_WORKING )
8793GAME( 1991, knights,  0,        cps1_10MHz, knights,  cps1,     ROT0,   "Capcom", "Knights of the Round (World 911127)" , 0)         // "ETC"
8794GAME( 1991, knightsu, knights,  cps1_10MHz, knights,  cps1,     ROT0,   "Capcom", "Knights of the Round (US 911127)", 0 )
8795GAME( 1991, knightsj, knights,  cps1_10MHz, knights,  cps1,     ROT0,   "Capcom", "Knights of the Round (Japan 911127)", 0 )
8796GAME( 1991, knightsb, knights,  knightsb,   knights,  cps1,     ROT0,   "bootleg", "Knights of the Round (World 911127, bootleg)" , GAME_NOT_WORKING)
8797GAME( 1992, sf2ce,    0,        cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (World 920313)" , 0)   // "ETC"
8798GAME( 1992, sf2ceua,  sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (US 920313)", 0 )
8799GAME( 1992, sf2ceub,  sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (US 920513)", 0 )
8800GAME( 1992, sf2ceuc,  sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (US 920803)", 0 )
8801GAME( 1992, sf2cej,   sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (Japan 920513)", 0 )
8802GAME( 1992, sf2rb,    sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Rainbow set 1, bootleg)" , 0)   // 920322 - based on World version
8803GAME( 1992, sf2rb2,   sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Rainbow set 2, bootleg)" , 0)   // 920322 - based on World version
8804GAME( 1992, sf2rb3,   sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Rainbow set 3, bootleg)" , 0)
8805GAME( 1992, sf2red,   sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Red Wave, bootleg)" , 0)      // 920313 - based on World version
8806GAME( 1992, sf2v004,  sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II! - Champion Edition (V004, bootleg)", 0 )         // "102092" !!! - based on (heavily modified) World version
8807GAME( 1992, sf2acc,   sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Accelerator!, bootleg)" , 0)  // 920313 - based on USA version
8808GAME( 1992, sf2accp2, sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Accelerator Pt.II, bootleg)" , 0)  // 920313 - based on USA version
8809GAME( 1992, sf2dkot2, sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Double K.O. Turbo II, bootleg)" , 0)  // 902140 - ???
8810GAME( 1992, sf2m1,    sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M1, bootleg)", GAME_NOT_WORKING )
8811GAME( 1992, sf2m2,    sf2ce,    cps1_12MHz, sf2m2,    sf2hack,  ROT0,   "bootleg","Street Fighter II' - Champion Edition (M2, bootleg)", 0 )
8812GAME( 1992, sf2m3,    sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M3, bootleg)", GAME_NOT_WORKING )
8813GAME( 1992, sf2m4,    sf2ce,    cps1_12MHz, sf2m4,    sf2hack,  ROT0,   "bootleg","Street Fighter II' - Champion Edition (M4, bootleg)", 0 )
8814GAME( 1992, sf2m5,    sf2ce,    cps1_12MHz, sf2hack,  sf2hack,  ROT0,   "bootleg","Street Fighter II' - Champion Edition (M5, bootleg)", 0 )
8815GAME( 1992, sf2m6,    sf2ce,    cps1_12MHz, sf2hack,  sf2hack,  ROT0,   "bootleg","Street Fighter II' - Champion Edition (M6, bootleg)", 0 )
8816GAME( 1992, sf2m7,    sf2ce,    cps1_12MHz, sf2hack,  sf2hack,  ROT0,   "bootleg","Street Fighter II' - Champion Edition (M7, bootleg)", 0 )
8817GAME( 1992, sf2yyc,   sf2ce,    cps1_12MHz, sf2hack,  sf2hack,  ROT0,   "bootleg","Street Fighter II' - Champion Edition (YYC, bootleg)", 0 )
8818GAME( 1992, sf2koryu, sf2ce,    cps1_12MHz, sf2hack,  sf2hack,  ROT0,   "bootleg","Street Fighter II' - Champion Edition (Xiang Long, Chinese bootleg)", 0 )
8819GAME( 1992, sf2mdt,   sf2ce,    sf2mdt,     sf2hack,  sf2mdt,   ROT0,   "bootleg","Street Fighter II' - Champion Edition (Magic Delta Turbo, bootleg)", GAME_NOT_WORKING|GAME_NO_SOUND ); // heavily modified, different sound & gfx hardware
8820GAME( 1992, varth,    0,        cps1_12MHz, varth,    cps1,     ROT270, "Capcom", "Varth - Operation Thunderstorm (World 920714)" , 0)      // "ETC"    12MHz verified
8821GAME( 1992, varthr1,  varth,    cps1_12MHz, varth,    cps1,     ROT270, "Capcom", "Varth - Operation Thunderstorm (World 920612)" , 0)      // "ETC"
8822GAME( 1992, varthu,   varth,    cps1_12MHz, varth,    cps1,     ROT270, "Capcom (Romstar license)", "Varth - Operation Thunderstorm (US 920612)", 0 )
8823GAME( 1992, varthj,   varth,    cps1_12MHz, varth,    cps1,     ROT270, "Capcom", "Varth - Operation Thunderstorm (Japan 920714)", 0 )
8824GAME( 1992, cworld2j, 0,        cps1_12MHz, cworld2j, cps1,     ROT0,   "Capcom", "Capcom World 2 (Japan 920611)", 0 )
8825GAME( 1992, sf2hf,    sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Hyper Fighting (World 921209)", 0 )
8826GAME( 1992, sf2t,     sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Hyper Fighting (US 921209)", 0 )
8827GAME( 1992, sf2tj,    sf2ce,    cps1_12MHz, sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II' Turbo - Hyper Fighting (Japan 921209)", 0 )
8828GAME( 1992, qad,      0,        cps1_12MHz, qad,      cps1,     ROT0,   "Capcom", "Quiz & Dragons (US 920701)", 0 )   // 12MHz verified
8829GAME( 1994, qadj,     qad,      cps1_12MHz, qadj,     cps1,     ROT0,   "Capcom", "Quiz & Dragons (Japan 940921)", 0 )
8830GAME( 1995, qtono2,   0,        cps1_12MHz, qtono2,   cps1,     ROT0,   "Capcom", "Quiz Tonosama no Yabou 2 Zenkoku-ban (Japan 950123)", 0 )
8831GAME( 1995, megaman,  0,        cps1_12MHz, megaman,  cps1,     ROT0,   "Capcom", "Mega Man - The Power Battle (CPS1 Asia 951006)", 0 )
8832GAME( 1995, rockmanj, megaman,  cps1_12MHz, rockmanj, cps1,     ROT0,   "Capcom", "Rockman - The Power Battle (CPS1 Japan 950922)", 0 )
8833GAME( 1992, wof,      0,        qsound,     wof,      wof,      ROT0,   "Capcom", "Warriors of Fate (World 921002)" , 0)            // "ETC"
8834GAME( 1992, wofa,     wof,      qsound,     wof,      wof,      ROT0,   "Capcom", "Sangokushi II (Asia 921005)" , 0)               // World "warning"
8835GAME( 1992, wofu,     wof,      qsound,     wof,      wof,      ROT0,   "Capcom", "Warriors of Fate (US 921031)" , 0)               // World "warning"
8836GAME( 1992, wofj,     wof,      qsound,     wof,      wof,      ROT0,   "Capcom", "Tenchi wo Kurau II - Sekiheki no Tatakai (Japan 921031)", 0 )
8837GAME( 1999, wofhfh,   wof,      wofhfh,     wofhfh,   cps1,     ROT0,   "bootleg","Sangokushi II: Huo Fenghuang (Chinese bootleg)", 0 )
8838GAME( 1993, dino,     0,        qsound,     dino,     dino,     ROT0,   "Capcom", "Cadillacs and Dinosaurs (World 930201)" , 0)         // "ETC"
8839GAME( 1993, dinou,    dino,     qsound,     dino,     dino,     ROT0,   "Capcom", "Cadillacs and Dinosaurs (US 930201)", 0 )
8840GAME( 1993, dinoj,    dino,     qsound,     dino,     dino,     ROT0,   "Capcom", "Cadillacs Kyouryuu-Shinseiki (Japan 930201)", 0 )
8841GAME( 1993, dinopic,  dino,     cpspicb,    dinopic,  dino,     ROT0,   "bootleg", "Cadillacs and Dinosaurs (bootleg with PIC16c57, set 1)", GAME_NOT_WORKING )
8842GAME( 1993, dinopic2, dino,     cpspicb,    dinopic,  dino,     ROT0,   "bootleg", "Cadillacs and Dinosaurs (bootleg with PIC16c57, set 2)", GAME_NOT_WORKING )
8843GAME( 1993, punisher, 0,        qsound,     punisher, punisher, ROT0,   "Capcom", "The Punisher (World 930422)" , 0)               // "ETC"
8844GAME( 1993, punisheru,punisher, qsound,     punisher, punisher, ROT0,   "Capcom", "The Punisher (US 930422)", 0 )
8845GAME( 1993, punisherj,punisher, qsound,     punisher, punisher, ROT0,   "Capcom", "The Punisher (Japan 930422)", 0 )
8846GAME( 1993, punipic,  punisher, cpspicb,    punipic,  punisher, ROT0,   "Capcom", "The Punisher (bootleg with PIC16c57, set 1)" , GAME_NOT_WORKING)
8847GAME( 1993, punipic2, punisher, cpspicb,    punipic,  punisher, ROT0,   "Capcom", "The Punisher (bootleg with PIC16c57, set 2)" , GAME_NOT_WORKING)
8848GAME( 1993, punipic3, punisher, cpspicb,    punipic,  punisher, ROT0,   "Capcom", "The Punisher (bootleg with PIC16c57, set 3)" , GAME_NOT_WORKING)
8754GAME( 1988, forgottn, 0,        cps1_10MHz, forgottn, forgottn, ROT0,   "Capcom", "Forgotten Worlds (World)", GAME_SUPPORTS_SAVE )
8755GAME( 1988, forgottnu,forgottn, cps1_10MHz, forgottn, forgottn, ROT0,   "Capcom", "Forgotten Worlds (US)", GAME_SUPPORTS_SAVE )
8756GAME( 1988, lostwrld, forgottn, cps1_10MHz, forgottn, forgottn, ROT0,   "Capcom", "Lost Worlds (Japan)", GAME_SUPPORTS_SAVE )
8757GAME( 1988, lostwrldo,forgottn, cps1_10MHz, forgottn, forgottn, ROT0,   "Capcom", "Lost Worlds (Japan Old Ver.)", GAME_SUPPORTS_SAVE )
8758GAME( 1988, ghouls,   0,        cps1_10MHz, ghouls,   cps1,     ROT0,   "Capcom", "Ghouls'n Ghosts (World)", GAME_SUPPORTS_SAVE )      // Wed.26.10.1988 in the ROMS
8759GAME( 1988, ghoulsu,  ghouls,   cps1_10MHz, ghoulsu,  cps1,     ROT0,   "Capcom", "Ghouls'n Ghosts (US)", GAME_SUPPORTS_SAVE )         // Wed.26.10.1988 in the ROMS
8760GAME( 1988, daimakai, ghouls,   cps1_10MHz, daimakai, cps1,     ROT0,   "Capcom", "Dai Makai-Mura (Japan)", GAME_SUPPORTS_SAVE )         // Wed.26.10.1988 in the ROMS
8761GAME( 1988, daimakair,ghouls,   cps1_10MHz, daimakai, cps1,     ROT0,   "Capcom", "Dai Makai-Mura (Japan Resale Ver.)", GAME_SUPPORTS_SAVE )   // still Wed.26.10.1988 in the ROMS...
8762GAME( 1989, strider,  0,        cps1_10MHz, strider,  cps1,     ROT0,   "Capcom", "Strider (US set 1)", GAME_SUPPORTS_SAVE )
8763GAME( 1989, striderua,strider,  cps1_10MHz, stridrua, cps1,     ROT0,   "Capcom", "Strider (US set 2)", GAME_SUPPORTS_SAVE )
8764GAME( 1989, striderj, strider,  cps1_10MHz, strider,  cps1,     ROT0,   "Capcom", "Strider Hiryu (Japan)", GAME_SUPPORTS_SAVE )
8765GAME( 1989, striderjr,strider,  cps1_10MHz, strider,  cps1,     ROT0,   "Capcom", "Strider Hiryu (Japan Resale Ver.)", GAME_SUPPORTS_SAVE )
8766GAME( 1989, dynwar,   0,        cps1_10MHz, dynwar,   cps1,     ROT0,   "Capcom", "Dynasty Wars (US set 1)", GAME_SUPPORTS_SAVE )      // (c) Capcom U.S.A.
8767GAME( 1989, dynwaru,  dynwar,   cps1_10MHz, dynwar,   cps1,     ROT0,   "Capcom", "Dynasty Wars (US set 2)", GAME_SUPPORTS_SAVE )      // (c) Capcom U.S.A.
8768GAME( 1989, dynwarj,  dynwar,   cps1_10MHz, dynwar,   cps1,     ROT0,   "Capcom", "Tenchi wo Kurau (Japan)", GAME_SUPPORTS_SAVE )
8769GAME( 1989, willow,   0,        cps1_10MHz, willow,   cps1,     ROT0,   "Capcom", "Willow (US)", GAME_SUPPORTS_SAVE )
8770GAME( 1989, willowj,  willow,   cps1_10MHz, willow,   cps1,     ROT0,   "Capcom", "Willow (Japan, Japanese)", GAME_SUPPORTS_SAVE )      // Japan "warning"
8771GAME( 1989, willowje, willow,   cps1_10MHz, willow,   cps1,     ROT0,   "Capcom", "Willow (Japan, English)", GAME_SUPPORTS_SAVE )      // (c) Capcom U.S.A. but Japan "warning"
8772GAME( 1989, unsquad,  0,        cps1_10MHz, unsquad,  cps1,     ROT0,   "Capcom", "U.N. Squadron (US)", GAME_SUPPORTS_SAVE )
8773GAME( 1989, area88,   unsquad,  cps1_10MHz, unsquad,  cps1,     ROT0,   "Capcom", "Area 88 (Japan)", GAME_SUPPORTS_SAVE )
8774GAME( 1989, ffight,   0,        cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (World)", GAME_SUPPORTS_SAVE )
8775GAME( 1989, ffightu,  ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (US)", GAME_SUPPORTS_SAVE )
8776GAME( 1989, ffightua, ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (US 900112)", GAME_SUPPORTS_SAVE )
8777GAME( 1989, ffightub, ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (US 900613)", GAME_SUPPORTS_SAVE )
8778GAME( 1989, ffightj,  ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (Japan)", GAME_SUPPORTS_SAVE )
8779GAME( 1989, ffightj1, ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (Japan 900305)", GAME_SUPPORTS_SAVE )
8780GAME( 1989, ffightj2, ffight,   cps1_10MHz, ffight,   cps1,     ROT0,   "Capcom", "Final Fight (Japan 900112)", GAME_SUPPORTS_SAVE )
8781GAME( 1990, 1941,     0,        cps1_10MHz, 1941,     cps1,     ROT270, "Capcom", "1941 - Counter Attack (World)", GAME_SUPPORTS_SAVE )
8782GAME( 1990, 1941j,    1941,     cps1_10MHz, 1941,     cps1,     ROT270, "Capcom", "1941 - Counter Attack (Japan)", GAME_SUPPORTS_SAVE )
8783GAME( 1990, mercs,    0,        cps1_10MHz, mercs,    cps1,     ROT270, "Capcom", "Mercs (World 900302)", GAME_SUPPORTS_SAVE )               // "ETC"
8784GAME( 1990, mercsu,   mercs,    cps1_10MHz, mercs,    cps1,     ROT270, "Capcom", "Mercs (US 900302)", GAME_SUPPORTS_SAVE )
8785GAME( 1990, mercsua,  mercs,    cps1_10MHz, mercs,    cps1,     ROT270, "Capcom", "Mercs (US 900608)", GAME_SUPPORTS_SAVE )
8786GAME( 1990, mercsj,   mercs,    cps1_10MHz, mercs,    cps1,     ROT270, "Capcom", "Senjou no Ookami II (Japan 900302)", GAME_SUPPORTS_SAVE )
8787GAME( 1990, mtwins,   0,        cps1_10MHz, mtwins,   cps1,     ROT0,   "Capcom", "Mega Twins (World 900619)", GAME_SUPPORTS_SAVE )            // "ETC" - (c) Capcom U.S.A. with World "warning"
8788GAME( 1990, chikij,   mtwins,   cps1_10MHz, mtwins,   cps1,     ROT0,   "Capcom", "Chiki Chiki Boys (Japan 900619)", GAME_SUPPORTS_SAVE )
8789GAME( 1990, msword,   0,        cps1_10MHz, msword,   cps1,     ROT0,   "Capcom", "Magic Sword - Heroic Fantasy (World 900725)", GAME_SUPPORTS_SAVE )   // 25.07.1990  "Other Country"
8790GAME( 1990, mswordr1, msword,   cps1_10MHz, msword,   cps1,     ROT0,   "Capcom", "Magic Sword - Heroic Fantasy (World 900623)", GAME_SUPPORTS_SAVE )   // 23.06.1990  "Other Country"
8791GAME( 1990, mswordu,  msword,   cps1_10MHz, msword,   cps1,     ROT0,   "Capcom", "Magic Sword - Heroic Fantasy (US 900725)", GAME_SUPPORTS_SAVE )      // 25.07.1990  "U.S.A."
8792GAME( 1990, mswordj,  msword,   cps1_10MHz, msword,   cps1,     ROT0,   "Capcom", "Magic Sword (Japan 900623)", GAME_SUPPORTS_SAVE )                  // 23.06.1990  "Japan"
8793GAME( 1990, cawing,   0,        cps1_10MHz, cawing,   cps1,     ROT0,   "Capcom", "Carrier Air Wing (World 901012)", GAME_SUPPORTS_SAVE )      // "ETC"
8794GAME( 1990, cawingr1, cawing,   cps1_10MHz, cawing,   cps1,     ROT0,   "Capcom", "Carrier Air Wing (World 901009)", GAME_SUPPORTS_SAVE )      // "ETC"
8795GAME( 1990, cawingu,  cawing,   cps1_10MHz, cawing,   cps1,     ROT0,   "Capcom", "Carrier Air Wing (US 901012)", GAME_SUPPORTS_SAVE )
8796GAME( 1990, cawingj,  cawing,   cps1_10MHz, cawing,   cps1,     ROT0,   "Capcom", "U.S. Navy (Japan 901012)", GAME_SUPPORTS_SAVE )
8797GAME( 1990, nemo,     0,        cps1_10MHz, nemo,     cps1,     ROT0,   "Capcom", "Nemo (World 901130)", GAME_SUPPORTS_SAVE )   // "ETC"
8798GAME( 1990, nemoj,    nemo,     cps1_10MHz, nemo,     cps1,     ROT0,   "Capcom", "Nemo (Japan 901120)", GAME_SUPPORTS_SAVE )
8799GAME( 1991, sf2,      0,        cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (World 910522)", GAME_SUPPORTS_SAVE )   // "ETC"
8800GAME( 1991, sf2eb,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (World 910214)", GAME_SUPPORTS_SAVE )   // "ETC"
8801GAME( 1992, sf2ebbl,  sf2,      cps1_10MHz, sf2hack,  sf2hack,  ROT0,   "bootleg","Street Fighter II - The World Warrior (World 910214, TAB Austria bootleg)", GAME_SUPPORTS_SAVE )
8802GAME( 1991, sf2ua,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910206)", GAME_SUPPORTS_SAVE )
8803GAME( 1991, sf2ub,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910214)", GAME_SUPPORTS_SAVE )
8804GAME( 1991, sf2ud,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910318)", GAME_SUPPORTS_SAVE )
8805GAME( 1991, sf2ue,    sf2,      cps1_10MHz, sf2,      sf2ue,    ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910228)", GAME_SUPPORTS_SAVE )
8806GAME( 1991, sf2uf,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910411)", GAME_SUPPORTS_SAVE )
8807GAME( 1991, sf2ui,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910522)", GAME_SUPPORTS_SAVE )
8808GAME( 1991, sf2uk,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 911101)", GAME_SUPPORTS_SAVE )
8809GAME( 1991, sf2j,     sf2,      cps1_10MHz, sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (Japan 911210)", GAME_SUPPORTS_SAVE )
8810GAME( 1991, sf2ja,    sf2,      cps1_10MHz, sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (Japan 910214)", GAME_SUPPORTS_SAVE )
8811GAME( 1991, sf2jc,    sf2,      cps1_10MHz, sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (Japan 910306)", GAME_SUPPORTS_SAVE )
8812GAME( 1991, sf2qp1,   sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II - The World Warrior (Quicken Pt-I, bootleg)", GAME_SUPPORTS_SAVE )   // 910214
8813GAME( 1991, 3wonders, 0,        cps1_10MHz, 3wonders, cps1,     ROT0,   "Capcom", "Three Wonders (World 910520)", GAME_SUPPORTS_SAVE )      // "ETC"
8814GAME( 1991, 3wondersu,3wonders, cps1_10MHz, 3wonders, cps1,     ROT0,   "Capcom", "Three Wonders (US 910520)", GAME_SUPPORTS_SAVE )
8815GAME( 1991, wonder3,  3wonders, cps1_10MHz, 3wonders, cps1,     ROT0,   "Capcom", "Wonder 3 (Japan 910520)", GAME_SUPPORTS_SAVE )
8816GAME( 1991, 3wondersh,3wonders, cps1_10MHz, 3wonders, cps1,     ROT0,   "bootleg","Three Wonders (hack?)", GAME_SUPPORTS_SAVE )
8817GAME( 1991, kod,      0,        cps1_10MHz, kod,      cps1,     ROT0,   "Capcom", "The King of Dragons (World 910711)", GAME_SUPPORTS_SAVE )   // "ETC"
8818GAME( 1991, kodu,     kod,      cps1_10MHz, kodj,     cps1,     ROT0,   "Capcom", "The King of Dragons (US 910910)", GAME_SUPPORTS_SAVE )
8819GAME( 1991, kodj,     kod,      cps1_10MHz, kodj,     cps1,     ROT0,   "Capcom", "The King of Dragons (Japan 910805)", GAME_SUPPORTS_SAVE )
8820GAME( 1991, captcomm, 0,        cps1_10MHz, captcomm, cps1,     ROT0,   "Capcom", "Captain Commando (World 911014)", GAME_SUPPORTS_SAVE )   // "OTHER COUNTRY"
8821GAME( 1991, captcommu,captcomm, cps1_10MHz, captcomm, cps1,     ROT0,   "Capcom", "Captain Commando (US 910928)", GAME_SUPPORTS_SAVE )
8822GAME( 1991, captcommj,captcomm, cps1_10MHz, captcomm, cps1,     ROT0,   "Capcom", "Captain Commando (Japan 911202)", GAME_SUPPORTS_SAVE )
8823GAME( 1991, captcommb,captcomm, cps1_10MHz, captcomm, cps1,     ROT0,   "bootleg","Captain Commando (bootleg)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
8824GAME( 1991, knights,  0,        cps1_10MHz, knights,  cps1,     ROT0,   "Capcom", "Knights of the Round (World 911127)", GAME_SUPPORTS_SAVE )      // "ETC"
8825GAME( 1991, knightsu, knights,  cps1_10MHz, knights,  cps1,     ROT0,   "Capcom", "Knights of the Round (US 911127)", GAME_SUPPORTS_SAVE )
8826GAME( 1991, knightsj, knights,  cps1_10MHz, knights,  cps1,     ROT0,   "Capcom", "Knights of the Round (Japan 911127)", GAME_SUPPORTS_SAVE )
8827GAME( 1991, knightsb, knights,  knightsb,   knights,  cps1,     ROT0,   "bootleg", "Knights of the Round (World 911127, bootleg)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
8828GAME( 1992, sf2ce,    0,        cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (World 920313)", GAME_SUPPORTS_SAVE )   // "ETC"
8829GAME( 1992, sf2ceua,  sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (US 920313)", GAME_SUPPORTS_SAVE )
8830GAME( 1992, sf2ceub,  sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (US 920513)", GAME_SUPPORTS_SAVE )
8831GAME( 1992, sf2ceuc,  sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (US 920803)", GAME_SUPPORTS_SAVE )
8832GAME( 1992, sf2cej,   sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (Japan 920513)", GAME_SUPPORTS_SAVE )
8833GAME( 1992, sf2rb,    sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Rainbow set 1, bootleg)", GAME_SUPPORTS_SAVE )   // 920322 - based on World version
8834GAME( 1992, sf2rb2,   sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Rainbow set 2, bootleg)", GAME_SUPPORTS_SAVE )   // 920322 - based on World version
8835GAME( 1992, sf2rb3,   sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Rainbow set 3, bootleg)", GAME_SUPPORTS_SAVE )
8836GAME( 1992, sf2red,   sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Red Wave, bootleg)", GAME_SUPPORTS_SAVE )      // 920313 - based on World version
8837GAME( 1992, sf2v004,  sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II! - Champion Edition (V004, bootleg)", GAME_SUPPORTS_SAVE )         // "102092" !!! - based on (heavily modified) World version
8838GAME( 1992, sf2acc,   sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Accelerator!, bootleg)", GAME_SUPPORTS_SAVE )  // 920313 - based on USA version
8839GAME( 1992, sf2accp2, sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Accelerator Pt.II, bootleg)", GAME_SUPPORTS_SAVE )  // 920313 - based on USA version
8840GAME( 1992, sf2dkot2, sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Double K.O. Turbo II, bootleg)", GAME_SUPPORTS_SAVE )  // 902140 - ???
8841GAME( 1992, sf2m1,    sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M1, bootleg)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
8842GAME( 1992, sf2m2,    sf2ce,    cps1_12MHz, sf2m2,    sf2hack,  ROT0,   "bootleg","Street Fighter II' - Champion Edition (M2, bootleg)", GAME_SUPPORTS_SAVE )
8843GAME( 1992, sf2m3,    sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (M3, bootleg)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
8844GAME( 1992, sf2m4,    sf2ce,    cps1_12MHz, sf2m4,    sf2hack,  ROT0,   "bootleg","Street Fighter II' - Champion Edition (M4, bootleg)", GAME_SUPPORTS_SAVE )
8845GAME( 1992, sf2m5,    sf2ce,    cps1_12MHz, sf2hack,  sf2hack,  ROT0,   "bootleg","Street Fighter II' - Champion Edition (M5, bootleg)", GAME_SUPPORTS_SAVE )
8846GAME( 1992, sf2m6,    sf2ce,    cps1_12MHz, sf2hack,  sf2hack,  ROT0,   "bootleg","Street Fighter II' - Champion Edition (M6, bootleg)", GAME_SUPPORTS_SAVE )
8847GAME( 1992, sf2m7,    sf2ce,    cps1_12MHz, sf2hack,  sf2hack,  ROT0,   "bootleg","Street Fighter II' - Champion Edition (M7, bootleg)", GAME_SUPPORTS_SAVE )
8848GAME( 1992, sf2yyc,   sf2ce,    cps1_12MHz, sf2hack,  sf2hack,  ROT0,   "bootleg","Street Fighter II' - Champion Edition (YYC, bootleg)", GAME_SUPPORTS_SAVE )
8849GAME( 1992, sf2koryu, sf2ce,    cps1_12MHz, sf2hack,  sf2hack,  ROT0,   "bootleg","Street Fighter II' - Champion Edition (Xiang Long, Chinese bootleg)", GAME_SUPPORTS_SAVE )
8850GAME( 1992, sf2mdt,   sf2ce,    sf2mdt,     sf2hack,  sf2mdt,   ROT0,   "bootleg","Street Fighter II' - Champion Edition (Magic Delta Turbo, bootleg)", GAME_NOT_WORKING | GAME_NO_SOUND | GAME_SUPPORTS_SAVE ); // heavily modified, different sound & gfx hardware
8851GAME( 1992, varth,    0,        cps1_12MHz, varth,    cps1,     ROT270, "Capcom", "Varth - Operation Thunderstorm (World 920714)", GAME_SUPPORTS_SAVE )      // "ETC"    12MHz verified
8852GAME( 1992, varthr1,  varth,    cps1_12MHz, varth,    cps1,     ROT270, "Capcom", "Varth - Operation Thunderstorm (World 920612)", GAME_SUPPORTS_SAVE )      // "ETC"
8853GAME( 1992, varthu,   varth,    cps1_12MHz, varth,    cps1,     ROT270, "Capcom (Romstar license)", "Varth - Operation Thunderstorm (US 920612)", GAME_SUPPORTS_SAVE )
8854GAME( 1992, varthj,   varth,    cps1_12MHz, varth,    cps1,     ROT270, "Capcom", "Varth - Operation Thunderstorm (Japan 920714)", GAME_SUPPORTS_SAVE )
8855GAME( 1992, cworld2j, 0,        cps1_12MHz, cworld2j, cps1,     ROT0,   "Capcom", "Capcom World 2 (Japan 920611)", GAME_SUPPORTS_SAVE )
8856GAME( 1992, sf2hf,    sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Hyper Fighting (World 921209)", GAME_SUPPORTS_SAVE )
8857GAME( 1992, sf2t,     sf2ce,    cps1_12MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Hyper Fighting (US 921209)", GAME_SUPPORTS_SAVE )
8858GAME( 1992, sf2tj,    sf2ce,    cps1_12MHz, sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II' Turbo - Hyper Fighting (Japan 921209)", GAME_SUPPORTS_SAVE )
8859GAME( 1992, qad,      0,        cps1_12MHz, qad,      cps1,     ROT0,   "Capcom", "Quiz & Dragons (US 920701)", GAME_SUPPORTS_SAVE )   // 12MHz verified
8860GAME( 1994, qadj,     qad,      cps1_12MHz, qadj,     cps1,     ROT0,   "Capcom", "Quiz & Dragons (Japan 940921)", GAME_SUPPORTS_SAVE )
8861GAME( 1995, qtono2,   0,        cps1_12MHz, qtono2,   cps1,     ROT0,   "Capcom", "Quiz Tonosama no Yabou 2 Zenkoku-ban (Japan 950123)", GAME_SUPPORTS_SAVE )
8862GAME( 1995, megaman,  0,        cps1_12MHz, megaman,  cps1,     ROT0,   "Capcom", "Mega Man - The Power Battle (CPS1 Asia 951006)", GAME_SUPPORTS_SAVE )
8863GAME( 1995, rockmanj, megaman,  cps1_12MHz, rockmanj, cps1,     ROT0,   "Capcom", "Rockman - The Power Battle (CPS1 Japan 950922)", GAME_SUPPORTS_SAVE )
8864GAME( 1992, wof,      0,        qsound,     wof,      wof,      ROT0,   "Capcom", "Warriors of Fate (World 921002)", GAME_SUPPORTS_SAVE )      // "ETC"
8865GAME( 1992, wofa,     wof,      qsound,     wof,      wof,      ROT0,   "Capcom", "Sangokushi II (Asia 921005)", GAME_SUPPORTS_SAVE )      // World "warning"
8866GAME( 1992, wofu,     wof,      qsound,     wof,      wof,      ROT0,   "Capcom", "Warriors of Fate (US 921031)", GAME_SUPPORTS_SAVE )      // World "warning"
8867GAME( 1992, wofj,     wof,      qsound,     wof,      wof,      ROT0,   "Capcom", "Tenchi wo Kurau II - Sekiheki no Tatakai (Japan 921031)", GAME_SUPPORTS_SAVE )
8868GAME( 1999, wofhfh,   wof,      wofhfh,     wofhfh,   cps1,     ROT0,   "bootleg","Sangokushi II: Huo Fenghuang (Chinese bootleg)", GAME_SUPPORTS_SAVE )
8869GAME( 1993, dino,     0,        qsound,     dino,     dino,     ROT0,   "Capcom", "Cadillacs and Dinosaurs (World 930201)", GAME_SUPPORTS_SAVE )      // "ETC"
8870GAME( 1993, dinou,    dino,     qsound,     dino,     dino,     ROT0,   "Capcom", "Cadillacs and Dinosaurs (US 930201)", GAME_SUPPORTS_SAVE )
8871GAME( 1993, dinoj,    dino,     qsound,     dino,     dino,     ROT0,   "Capcom", "Cadillacs Kyouryuu-Shinseiki (Japan 930201)", GAME_SUPPORTS_SAVE )
8872GAME( 1993, dinopic,  dino,     cpspicb,    dinopic,  dino,     ROT0,   "bootleg", "Cadillacs and Dinosaurs (bootleg with PIC16c57, set 1)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
8873GAME( 1993, dinopic2, dino,     cpspicb,    dinopic,  dino,     ROT0,   "bootleg", "Cadillacs and Dinosaurs (bootleg with PIC16c57, set 2)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
8874GAME( 1993, punisher, 0,        qsound,     punisher, punisher, ROT0,   "Capcom", "The Punisher (World 930422)", GAME_SUPPORTS_SAVE )      // "ETC"
8875GAME( 1993, punisheru,punisher, qsound,     punisher, punisher, ROT0,   "Capcom", "The Punisher (US 930422)", GAME_SUPPORTS_SAVE )
8876GAME( 1993, punisherj,punisher, qsound,     punisher, punisher, ROT0,   "Capcom", "The Punisher (Japan 930422)", GAME_SUPPORTS_SAVE )
8877GAME( 1993, punipic,  punisher, cpspicb,    punipic,  punisher, ROT0,   "Capcom", "The Punisher (bootleg with PIC16c57, set 1)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
8878GAME( 1993, punipic2, punisher, cpspicb,    punipic,  punisher, ROT0,   "Capcom", "The Punisher (bootleg with PIC16c57, set 2)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
8879GAME( 1993, punipic3, punisher, cpspicb,    punipic,  punisher, ROT0,   "Capcom", "The Punisher (bootleg with PIC16c57, set 3)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
88498880
8850GAME( 1993, slammast, 0,        qsound,     slammast, slammast, ROT0,   "Capcom", "Saturday Night Slam Masters (World 930713)" , 0)      // "ETC"
8851GAME( 1993, slammastu,slammast, qsound,     slammast, slammast, ROT0,   "Capcom", "Saturday Night Slam Masters (US 930713)", 0 )
8852GAME( 1993, mbomberj, slammast, qsound,     slammast, slammast, ROT0,   "Capcom", "Muscle Bomber - The Body Explosion (Japan 930713)", 0 )
8853GAME( 1993, mbombrd,  0,        qsound,     slammast, slammast, ROT0,   "Capcom", "Muscle Bomber Duo - Ultimate Team Battle (World 931206)" , 0)  // "ETC"
8854GAME( 1993, mbombrdj, mbombrd,  qsound,     slammast, slammast, ROT0,   "Capcom", "Muscle Bomber Duo - Heat Up Warriors (Japan 931206)", 0 )
8881GAME( 1993, slammast, 0,        qsound,     slammast, slammast, ROT0,   "Capcom", "Saturday Night Slam Masters (World 930713)", GAME_SUPPORTS_SAVE )      // "ETC"
8882GAME( 1993, slammastu,slammast, qsound,     slammast, slammast, ROT0,   "Capcom", "Saturday Night Slam Masters (US 930713)", GAME_SUPPORTS_SAVE )
8883GAME( 1993, mbomberj, slammast, qsound,     slammast, slammast, ROT0,   "Capcom", "Muscle Bomber - The Body Explosion (Japan 930713)", GAME_SUPPORTS_SAVE )
8884GAME( 1993, mbombrd,  0,        qsound,     slammast, slammast, ROT0,   "Capcom", "Muscle Bomber Duo - Ultimate Team Battle (World 931206)", GAME_SUPPORTS_SAVE )  // "ETC"
8885GAME( 1993, mbombrdj, mbombrd,  qsound,     slammast, slammast, ROT0,   "Capcom", "Muscle Bomber Duo - Heat Up Warriors (Japan 931206)", GAME_SUPPORTS_SAVE )
88558886
8856GAME( 1994, pnickj,   0,        cps1_12MHz, pnickj,   cps1,     ROT0,   "Compile (Capcom license)", "Pnickies (Japan 940608)", 0 )
8887GAME( 1994, pnickj,   0,        cps1_12MHz, pnickj,   cps1,     ROT0,   "Compile (Capcom license)", "Pnickies (Japan 940608)", GAME_SUPPORTS_SAVE )
88578888/* Japanese version of Pang 3 is encrypted, Euro version is not */
8858GAME( 1995, pang3,    0,        pang3,      pang3,    pang3,    ROT0,   "Mitchell", "Pang! 3 (Euro 950511)", 0 )
8859GAME( 1995, pang3j,   pang3,    pang3,      pang3,    pang3j,   ROT0,   "Mitchell", "Pang! 3 (Japan 950511)", 0 )
8889GAME( 1995, pang3,    0,        pang3,      pang3,    pang3,    ROT0,   "Mitchell", "Pang! 3 (Euro 950511)", GAME_SUPPORTS_SAVE )
8890GAME( 1995, pang3j,   pang3,    pang3,      pang3,    pang3j,   ROT0,   "Mitchell", "Pang! 3 (Japan 950511)", GAME_SUPPORTS_SAVE )
src/mame/drivers/yunsun16.c
r6740r6741
8686***************************************************************************/
8787
8888#include "driver.h"
89#include "yunsun16.h"
89#include "includes/yunsun16.h"
9090#include "cpu/z80/z80.h"
9191#include "cpu/m68000/m68000.h"
9292#include "sound/okim6295.h"
src/mame/drivers/scobra.c
r6740r6741
3535#include "driver.h"
3636#include "cpu/z80/z80.h"
3737#include "machine/8255ppi.h"
38#include "galaxold.h"
38#include "machine/7474.h"
39#include "includes/galaxold.h"
3940#include "sound/ay8910.h"
4041
4142static const gfx_layout scobra_charlayout =
r6740r6741
859860   MDRV_CPU_PROGRAM_MAP(scobra_sound_map)
860861   MDRV_CPU_IO_MAP(scobra_sound_io_map)
861862
863   MDRV_7474_ADD("konami_7474", scramble_sh_7474_callback)
864
862865   MDRV_MACHINE_RESET(scramble)
863866
864867   MDRV_PPI8255_ADD( "ppi8255_0", scramble_ppi_0_intf )
865868   MDRV_PPI8255_ADD( "ppi8255_1", scramble_ppi_1_intf )
866869
870   MDRV_7474_ADD("7474_9m_1", galaxold_7474_9m_1_callback)
871   MDRV_7474_ADD("7474_9m_2", galaxold_7474_9m_2_callback)
872
873   MDRV_TIMER_ADD("int_timer", galaxold_interrupt_timer)
874
867875   /* video hardware */
868876   MDRV_SCREEN_ADD("screen", RASTER)
869877   MDRV_SCREEN_REFRESH_RATE(16000.0/132/2)
r6740r6741
983991   MDRV_CPU_PROGRAM_MAP(hustler_sound_map)
984992   MDRV_CPU_IO_MAP(hustler_sound_io_map)
985993
994   MDRV_7474_ADD("konami_7474", scramble_sh_7474_callback)
995
986996   MDRV_MACHINE_RESET(scramble)
987997
998   MDRV_7474_ADD("7474_9m_1", galaxold_7474_9m_1_callback)
999   MDRV_7474_ADD("7474_9m_2", galaxold_7474_9m_2_callback)
1000
1001   MDRV_TIMER_ADD("int_timer", galaxold_interrupt_timer)
1002
9881003   /* device config overrides */
9891004   MDRV_PPI8255_ADD( "ppi8255_0", scramble_ppi_0_intf )
9901005   MDRV_PPI8255_ADD( "ppi8255_1", scramble_ppi_1_intf )
src/mame/drivers/wiz.c
r6740r6741
239239   AM_RANGE(0xd840, 0xd85f) AM_BASE_GENERIC(spriteram2) AM_SIZE_GENERIC(spriteram)
240240   AM_RANGE(0xd000, 0xd85f) AM_RAM
241241   AM_RANGE(0xe000, 0xe3ff) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)   /* Fallthrough */
242   AM_RANGE(0xe400, 0xe7ff) AM_BASE_GENERIC(colorram)
242   AM_RANGE(0xe400, 0xe7ff) AM_RAM
243243   AM_RANGE(0xe800, 0xe83f) AM_BASE(&wiz_attributesram)
244244   AM_RANGE(0xe840, 0xe85f) AM_BASE_GENERIC(spriteram)
245245   AM_RANGE(0xe000, 0xe85f) AM_RAM
src/mame/drivers/stactics.c
r6740r6741
4242
4343#include "driver.h"
4444#include "cpu/i8085/i8085.h"
45#include "stactics.h"
45#include "includes/stactics.h"
4646#include "stactics.lh"
4747
4848
src/mame/drivers/lethalj.c
r6740r6741
140140
141141#include "driver.h"
142142#include "cpu/tms34010/tms34010.h"
143#include "lethalj.h"
143#include "includes/lethalj.h"
144144#include "machine/ticket.h"
145145#include "sound/okim6295.h"
146146
r6740r6741
159159 *
160160 *************************************/
161161
162static CUSTOM_INPUT( ticket_status )
163{
164   const address_space *space = cputag_get_address_space(field->port->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
165   return ticket_dispenser_0_r(space, 0) >> 7;
166}
167
168
169162static CUSTOM_INPUT( cclownz_paddle )
170163{
171164   int value = input_port_read(field->port->machine, "PADDLE");
r6740r6741
183176static WRITE16_HANDLER( ripribit_control_w )
184177{
185178   coin_counter_w(space->machine, 0, data & 1);
186   ticket_dispenser_0_w(space, 0, ((data >> 1) & 1) << 7);
179   ticket_dispenser_w(devtag_get_device(space->machine, "ticket"), 0, ((data >> 1) & 1) << 7);
187180   output_set_lamp_value(0, (data >> 2) & 1);
188181}
189182
190183
191184static WRITE16_HANDLER( cfarm_control_w )
192185{
193   ticket_dispenser_0_w(space, 0, ((data >> 0) & 1) << 7);
186   ticket_dispenser_w(devtag_get_device(space->machine, "ticket"), 0, ((data >> 0) & 1) << 7);
194187   output_set_lamp_value(0, (data >> 2) & 1);
195188   output_set_lamp_value(1, (data >> 3) & 1);
196189   output_set_lamp_value(2, (data >> 4) & 1);
r6740r6741
200193
201194static WRITE16_HANDLER( cclownz_control_w )
202195{
203   ticket_dispenser_0_w(space, 0, ((data >> 0) & 1) << 7);
196   ticket_dispenser_w(devtag_get_device(space->machine, "ticket"), 0, ((data >> 0) & 1) << 7);
204197   output_set_lamp_value(0, (data >> 2) & 1);
205198   output_set_lamp_value(1, (data >> 4) & 1);
206199   output_set_lamp_value(2, (data >> 5) & 1);
r6740r6741
411404   PORT_START("IN0")
412405   PORT_BIT( 0x000f, IP_ACTIVE_LOW, IPT_UNUSED )
413406   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
414   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(ticket_status, NULL)
407   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket", ticket_dispenser_line_r)
415408   PORT_BIT( 0xffc0, IP_ACTIVE_LOW, IPT_UNUSED )
416409
417410   PORT_START("IN1")
r6740r6741
498491   PORT_DIPSETTING(      0x0000, "10" )
499492
500493   PORT_START("IN1")
501   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(ticket_status, NULL)
494   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket", ticket_dispenser_line_r)
502495   PORT_BIT( 0x0006, IP_ACTIVE_LOW, IPT_UNUSED )
503496    PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
504497    PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
r6740r6741
549542
550543   PORT_START("IN1")
551544   PORT_BIT( 0x0f0f, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(cclownz_paddle, NULL)
552   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(ticket_status, NULL)
545   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket", ticket_dispenser_line_r)
553546   PORT_BIT( 0x0060, IP_ACTIVE_LOW, IPT_UNUSED )
554547    PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
555548   PORT_BIT( 0xf000, IP_ACTIVE_LOW, IPT_UNUSED )
r6740r6741
605598   MDRV_CPU_CONFIG(tms_config)
606599   MDRV_CPU_PROGRAM_MAP(lethalj_map)
607600
601   MDRV_TICKET_DISPENSER_ADD("ticket", 200, TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_HIGH)
602
608603   /* video hardware */
609604   MDRV_SCREEN_ADD("screen", RASTER)
610605   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
r6740r6741
906901
907902static DRIVER_INIT( ripribit )
908903{
909   ticket_dispenser_init(machine, 200, TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_HIGH);
910904   memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x04100010, 0x0410001f, 0, 0, ripribit_control_w);
911905}
912906
913907
914908static DRIVER_INIT( cfarm )
915909{
916   ticket_dispenser_init(machine, 200, TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_HIGH);
917910   memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x04100010, 0x0410001f, 0, 0, cfarm_control_w);
918911}
919912
920913
921914static DRIVER_INIT( cclownz )
922915{
923   ticket_dispenser_init(machine, 200, TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_HIGH);
924916   memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x04100010, 0x0410001f, 0, 0, cclownz_control_w);
925917}
926918
src/mame/drivers/itech8.c
r6740r6741
504504#include "machine/ticket.h"
505505#include "video/tms34061.h"
506506#include "video/tlc34076.h"
507#include "itech8.h"
507#include "includes/itech8.h"
508508#include "sound/2203intf.h"
509509#include "sound/2608intf.h"
510510#include "sound/3812intf.h"
r6740r6741
552552static const pia6821_interface pia_interface =
553553{
554554   DEVCB_NULL,      /* port A in */
555   DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, ticket_dispenser_r),   /* port B in */
555   DEVCB_DEVICE_LINE("ticket", ticket_dispenser_line_r),         /* port B in */
556556   DEVCB_NULL,      /* line CA1 in */
557557   DEVCB_NULL,      /* line CB1 in */
558558   DEVCB_NULL,      /* line CA2 in */
r6740r6741
680680      device_reset(cputag_get_cpu(machine, "maincpu"));
681681   }
682682
683   /* reset the ticket dispenser */
684   ticket_dispenser_init(machine, 200, TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_LOW);
685
686683   /* reset the palette chip */
687684   tlc34076_reset(6);
688685
r6740r6741
779776   /* bit 5 controls the coin counter */
780777   /* bit 6 controls the diagnostic sound LED */
781778   pia_portb_data = data;
782   ticket_dispenser_w(space, 0, (data & 0x10) << 3);
779   ticket_dispenser_w(devtag_get_device(space->machine, "ticket"), 0, (data & 0x10) << 3);
783780   coin_counter_w(space->machine, 0, (data & 0x20) >> 5);
784781}
785782
r6740r6741
793790   /* bit 6 controls the diagnostic sound LED */
794791   /* bit 7 controls the ticket dispenser */
795792   pia_portb_data = data;
796   ticket_dispenser_w(cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0, data & 0x80);
793   ticket_dispenser_w(devtag_get_device(device->machine, "ticket"), 0, data & 0x80);
797794   coin_counter_w(device->machine, 0, (data & 0x20) >> 5);
798795}
799796
r6740r6741
17301727   MDRV_MACHINE_RESET(itech8)
17311728   MDRV_NVRAM_HANDLER(itech8)
17321729
1730   MDRV_TICKET_DISPENSER_ADD("ticket", 200, TICKET_MOTOR_ACTIVE_HIGH, TICKET_STATUS_ACTIVE_LOW)
1731
17331732   /* video hardware */
17341733   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
17351734   MDRV_VIDEO_START(itech8)
src/mame/drivers/galaxian.c
r6740r6741
229229#include "driver.h"
230230#include "cpu/z80/z80.h"
231231#include "cpu/s2650/s2650.h"
232#include "galaxian.h"
232#include "includes/galaxian.h"
233233#include "machine/8255ppi.h"
234234#include "sound/ay8910.h"
235235#include "sound/sn76496.h"
src/mame/drivers/arcadecl.c
r6740r6741
6868
6969#include "driver.h"
7070#include "cpu/m68000/m68000.h"
71#include "arcadecl.h"
71#include "includes/arcadecl.h"
7272#include "sound/okim6295.h"
7373
7474
r6740r6741
103103 *
104104 *************************************/
105105
106static MACHINE_START( arcadecl )
107{
108   atarigen_init(machine);
109}
110
111
106112static MACHINE_RESET( arcadecl )
107113{
108114   rampart_state *state = (rampart_state *)machine->driver_data;
r6740r6741
324330   MDRV_CPU_PROGRAM_MAP(main_map)
325331   MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen)
326332
333   MDRV_MACHINE_START(arcadecl)
327334   MDRV_MACHINE_RESET(arcadecl)
328335   MDRV_NVRAM_HANDLER(atarigen)
329336
src/mame/drivers/suprslam.c
r6740r6741
8383#include "driver.h"
8484#include "cpu/z80/z80.h"
8585#include "cpu/m68000/m68000.h"
86#include "video/konamiic.h"
86#include "video/konicdev.h"
8787#include "sound/2610intf.h"
88#include "includes/suprslam.h"
8889
8990
90extern UINT16 *suprslam_screen_videoram, *suprslam_bg_videoram,*suprslam_sp_videoram, *suprslam_spriteram;
91
92/* in video */
93
94WRITE16_HANDLER( suprslam_screen_videoram_w );
95WRITE16_HANDLER( suprslam_bg_videoram_w );
96VIDEO_START( suprslam );
97VIDEO_UPDATE( suprslam );
98WRITE16_HANDLER (suprslam_bank_w);
99
100
10191/*** SOUND *******************************************************************/
10292
103static int pending_command;
104
10593static WRITE16_HANDLER( sound_command_w )
10694{
95   suprslam_state *state = (suprslam_state *)space->machine->driver_data;
10796   if (ACCESSING_BITS_0_7)
10897   {
109      pending_command = 1;
98      state->pending_command = 1;
11099      soundlatch_w(space, offset, data & 0xff);
111      cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
100      cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
112101   }
113102}
114103
115104#if 0
116105static READ16_HANDLER( pending_command_r )
117106{
107   suprslam_state *state = (suprslam_state *)space->machine->driver_data;
118108   return pending_command;
119109}
120110#endif
121111
122112static WRITE8_HANDLER( pending_command_clear_w )
123113{
124   pending_command = 0;
114   suprslam_state *state = (suprslam_state *)space->machine->driver_data;
115   state->pending_command = 0;
125116}
126117
127118static WRITE8_HANDLER( suprslam_sh_bankswitch_w )
r6740r6741
137128
138129static ADDRESS_MAP_START( suprslam_map, ADDRESS_SPACE_PROGRAM, 16 )
139130   AM_RANGE(0x000000, 0x0fffff) AM_ROM
140   AM_RANGE(0xfb0000, 0xfb1fff) AM_RAM AM_BASE(&suprslam_spriteram)
141   AM_RANGE(0xfc0000, 0xfcffff) AM_RAM AM_BASE(&suprslam_sp_videoram)
131   AM_RANGE(0xfb0000, 0xfb1fff) AM_RAM AM_BASE_MEMBER(suprslam_state, spriteram)
132   AM_RANGE(0xfc0000, 0xfcffff) AM_RAM AM_BASE_MEMBER(suprslam_state, sp_videoram)
142133   AM_RANGE(0xfd0000, 0xfdffff) AM_RAM
143   AM_RANGE(0xfe0000, 0xfe0fff) AM_RAM_WRITE(suprslam_screen_videoram_w) AM_BASE(&suprslam_screen_videoram)
144   AM_RANGE(0xff0000, 0xff1fff) AM_RAM_WRITE(suprslam_bg_videoram_w) AM_BASE(&suprslam_bg_videoram)
145//  AM_RANGE(0xff2000, 0xff203f) AM_RAM /* ?? */
146   AM_RANGE(0xff8000, 0xff8fff) AM_RAM AM_BASE(&K053936_0_linectrl)
134   AM_RANGE(0xfe0000, 0xfe0fff) AM_RAM_WRITE(suprslam_screen_videoram_w) AM_BASE_MEMBER(suprslam_state, screen_videoram)
135   AM_RANGE(0xff0000, 0xff1fff) AM_RAM_WRITE(suprslam_bg_videoram_w) AM_BASE_MEMBER(suprslam_state, bg_videoram)
136   AM_RANGE(0xff2000, 0xff203f) AM_RAM AM_BASE_MEMBER(suprslam_state,screen_vregs)
137//  AM_RANGE(0xff3000, 0xff3001) AM_WRITENOP // sprite buffer trigger?
138   AM_RANGE(0xff8000, 0xff8fff) AM_DEVREADWRITE("k053936", k053936_linectrl_r, k053936_linectrl_w)
147139   AM_RANGE(0xff9000, 0xff9001) AM_WRITE(sound_command_w)
148140   AM_RANGE(0xffa000, 0xffafff) AM_RAM_WRITE(paletteram16_xGGGGGBBBBBRRRRR_word_w) AM_BASE_GENERIC(paletteram)
149   AM_RANGE(0xffd000, 0xffd01f) AM_WRITEONLY AM_BASE(&K053936_0_ctrl)
141   AM_RANGE(0xffd000, 0xffd01f) AM_DEVWRITE("k053936", k053936_ctrl_w)
150142   AM_RANGE(0xffe000, 0xffe001) AM_WRITE(suprslam_bank_w)
151143   AM_RANGE(0xfff000, 0xfff001) AM_READ_PORT("P1")
152144   AM_RANGE(0xfff002, 0xfff003) AM_READ_PORT("P2")
153145   AM_RANGE(0xfff004, 0xfff005) AM_READ_PORT("SYSTEM")
154146   AM_RANGE(0xfff006, 0xfff007) AM_READ_PORT("DSW1")
155147   AM_RANGE(0xfff008, 0xfff009) AM_READ_PORT("DSW2")
148   AM_RANGE(0xfff00c, 0xfff00d) AM_WRITEONLY AM_BASE_MEMBER(suprslam_state, spr_ctrl)
156149ADDRESS_MAP_END
157150
158151static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
r6740r6741
287280
288281static void irqhandler(const device_config *device, int irq)
289282{
290   cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE);
283   suprslam_state *state = (suprslam_state *)device->machine->driver_data;
284   cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE);
291285}
292286
293287static const ym2610_interface ym2610_config =
r6740r6741
297291
298292/*** MACHINE DRIVER **********************************************************/
299293
294static const k053936_interface suprslam_k053936_intf =
295{
296   1, -45, -21   /* wrap, xoff, yoff */
297};
298
299static MACHINE_START( suprslam )
300{
301   suprslam_state *state = (suprslam_state *)machine->driver_data;
302
303   state->audiocpu = devtag_get_device(machine, "audiocpu");
304   state->k053936 = devtag_get_device(machine, "k053936");
305
306   state_save_register_global(machine, state->screen_bank);
307   state_save_register_global(machine, state->bg_bank);
308   state_save_register_global(machine, state->pending_command);
309}
310
311static MACHINE_RESET( suprslam )
312{
313   suprslam_state *state = (suprslam_state *)machine->driver_data;
314
315   state->screen_bank = 0;
316   state->bg_bank = 0;
317   state->pending_command = 0;
318}
319
300320static MACHINE_DRIVER_START( suprslam )
321   MDRV_DRIVER_DATA(suprslam_state)
322
301323   MDRV_CPU_ADD("maincpu", M68000, 16000000)
302324   MDRV_CPU_PROGRAM_MAP(suprslam_map)
303325   MDRV_CPU_VBLANK_INT("screen", irq1_line_hold)
r6740r6741
306328   MDRV_CPU_PROGRAM_MAP(sound_map)
307329   MDRV_CPU_IO_MAP(sound_io_map)
308330
331   MDRV_MACHINE_START(suprslam)
332   MDRV_MACHINE_RESET(suprslam)
333
309334   MDRV_GFXDECODE(suprslam)
310335
311336   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK)
r6740r6741
322347   MDRV_VIDEO_START(suprslam)
323348   MDRV_VIDEO_UPDATE(suprslam)
324349
350   MDRV_K053936_ADD("k053936", suprslam_k053936_intf)
351
325352   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
326353
327354   MDRV_SOUND_ADD("ymsnd", YM2610, 8000000)
r6740r6741
365392
366393/*** GAME DRIVERS ************************************************************/
367394
368GAME( 1995, suprslam, 0, suprslam, suprslam, 0, ROT0, "Banpresto / Toei Animation", "Super Slams", GAME_IMPERFECT_GRAPHICS )
395GAME( 1995, suprslam, 0, suprslam, suprslam, 0, ROT0, "Banpresto / Toei Animation", "Super Slams", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
src/mame/drivers/calomega.c
r6740r6741
643643
644644
645645/* from video */
646extern UINT8 *calomega_videoram;
647extern UINT8 *calomega_colorram;
646648WRITE8_HANDLER( calomega_videoram_w );
647649WRITE8_HANDLER( calomega_colorram_w );
648650PALETTE_INIT( calomega );
r6740r6741
762764   AM_RANGE(0x08c8, 0x08cb) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
763765   AM_RANGE(0x08d0, 0x08d0) AM_DEVREADWRITE("acia6850_0", acia6850_stat_r, acia6850_ctrl_w)
764766   AM_RANGE(0x08d1, 0x08d1) AM_DEVREADWRITE("acia6850_0", acia6850_data_r, acia6850_data_w)
765   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(calomega_videoram_w) AM_BASE_GENERIC(videoram)
766   AM_RANGE(0x1400, 0x17ff) AM_RAM_WRITE(calomega_colorram_w) AM_BASE_GENERIC(colorram)
767   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(calomega_videoram_w) AM_BASE(&calomega_videoram)
768   AM_RANGE(0x1400, 0x17ff) AM_RAM_WRITE(calomega_colorram_w) AM_BASE(&calomega_colorram)
767769   AM_RANGE(0x1800, 0x3fff) AM_ROM
768770ADDRESS_MAP_END
769771
r6740r6741
775777   AM_RANGE(0x0881, 0x0881) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
776778   AM_RANGE(0x08c4, 0x08c7) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
777779   AM_RANGE(0x08c8, 0x08cb) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
778   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(calomega_videoram_w) AM_BASE_GENERIC(videoram)
779   AM_RANGE(0x1400, 0x17ff) AM_RAM_WRITE(calomega_colorram_w) AM_BASE_GENERIC(colorram)
780   AM_RANGE(0x1000, 0x13ff) AM_RAM_WRITE(calomega_videoram_w) AM_BASE(&calomega_videoram)
781   AM_RANGE(0x1400, 0x17ff) AM_RAM_WRITE(calomega_colorram_w) AM_BASE(&calomega_colorram)
780782   AM_RANGE(0x1800, 0xffff) AM_ROM
781783ADDRESS_MAP_END
782784
r6740r6741
788790   AM_RANGE(0x1081, 0x1081) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
789791   AM_RANGE(0x10c4, 0x10c7) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
790792   AM_RANGE(0x10c8, 0x10cb) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w)
791   AM_RANGE(0x2000, 0x23ff) AM_RAM_WRITE(calomega_videoram_w) AM_BASE_GENERIC(videoram)
792   AM_RANGE(0x2400, 0x27ff) AM_RAM_WRITE(calomega_colorram_w) AM_BASE_GENERIC(colorram)
793   AM_RANGE(0x2000, 0x23ff) AM_RAM_WRITE(calomega_videoram_w) AM_BASE(&calomega_videoram)
794   AM_RANGE(0x2400, 0x27ff) AM_RAM_WRITE(calomega_colorram_w) AM_BASE(&calomega_colorram)
793795   AM_RANGE(0x2800, 0xffff) AM_ROM
794796ADDRESS_MAP_END
795797
src/mame/drivers/atetris.c
r6740r6741
4949
5050#include "driver.h"
5151#include "cpu/m6502/m6502.h"
52#include "slapstic.h"
53#include "atetris.h"
52#include "includes/slapstic.h"
53#include "includes/atetris.h"
5454#include "sound/sn76496.h"
5555#include "sound/pokey.h"
5656#include "state.h"
src/mame/drivers/4roses.c
r6740r6741
178178#include "sound/ay8910.h"
179179
180180/* from video */
181extern UINT8 *funworld_videoram;
182extern UINT8 *funworld_colorram;
183
181184WRITE8_HANDLER( funworld_videoram_w );
182185WRITE8_HANDLER( funworld_colorram_w );
183186PALETTE_INIT( funworld );
r6740r6741
197200
198201static ADDRESS_MAP_START( 4roses_map, ADDRESS_SPACE_PROGRAM, 8 )
199202   AM_RANGE(0x0000, 0x07ff) AM_RAM   // AM_BASE_SIZE_GENERIC(nvram)
200   AM_RANGE(0x6000, 0x6fff) AM_RAM_WRITE(funworld_videoram_w) AM_BASE_GENERIC(videoram)
201   AM_RANGE(0x7000, 0x7fff) AM_RAM_WRITE(funworld_colorram_w) AM_BASE_GENERIC(colorram)
203   AM_RANGE(0x6000, 0x6fff) AM_RAM_WRITE(funworld_videoram_w) AM_BASE(&funworld_videoram)
204   AM_RANGE(0x7000, 0x7fff) AM_RAM_WRITE(funworld_colorram_w) AM_BASE(&funworld_colorram)
202205   AM_RANGE(0x8000, 0xffff) AM_ROM
203206ADDRESS_MAP_END
204207
src/mame/drivers/shaolins.c
r6740r6741
1414
1515UINT8 shaolins_nmi_enable;
1616
17extern UINT8 *shaolins_videoram;
18extern UINT8 *shaolins_colorram;
1719WRITE8_HANDLER( shaolins_videoram_w );
1820WRITE8_HANDLER( shaolins_colorram_w );
1921WRITE8_HANDLER( shaolins_palettebank_w );
r6740r6741
5658   AM_RANGE(0x2800, 0x2bff) AM_RAM                     /* RAM BANK 2 */
5759   AM_RANGE(0x3000, 0x30ff) AM_RAM                     /* RAM BANK 1 */
5860   AM_RANGE(0x3100, 0x33ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
59   AM_RANGE(0x3800, 0x3bff) AM_RAM_WRITE(shaolins_colorram_w) AM_BASE_GENERIC(colorram)
60   AM_RANGE(0x3c00, 0x3fff) AM_RAM_WRITE(shaolins_videoram_w) AM_BASE_GENERIC(videoram)
61   AM_RANGE(0x3800, 0x3bff) AM_RAM_WRITE(shaolins_colorram_w) AM_BASE(&shaolins_colorram)
62   AM_RANGE(0x3c00, 0x3fff) AM_RAM_WRITE(shaolins_videoram_w) AM_BASE(&shaolins_videoram)
6163   AM_RANGE(0x4000, 0x5fff) AM_ROM                     /* Machine checks for extra rom */
6264   AM_RANGE(0x6000, 0xffff) AM_ROM
6365ADDRESS_MAP_END
src/mame/drivers/bmcbowl.c
r6740r6741
112112
113113static UINT16 *bmcbowl_vid1;
114114static UINT16 *bmcbowl_vid2;
115static UINT8 *bmc_colorram;
115116
116117static UINT8 *stats_ram;
117118static size_t   stats_ram_size;
r6740r6741
197198
198199static WRITE16_HANDLER( bmc_RAMDAC_offset_w )
199200{
200      clr_offset=data*3;
201   clr_offset=data*3;
201202}
202203
203204static WRITE16_HANDLER( bmc_RAMDAC_color_w )
204205{
205      space->machine->generic.colorram.u8[clr_offset]=data;
206      palette_set_color_rgb(space->machine,clr_offset/3,pal6bit(space->machine->generic.colorram.u8[(clr_offset/3)*3]),pal6bit(space->machine->generic.colorram.u8[(clr_offset/3)*3+1]),pal6bit(space->machine->generic.colorram.u8[(clr_offset/3)*3+2]));
207      clr_offset=(clr_offset+1)%768;
206   bmc_colorram[clr_offset]=data;
207   palette_set_color_rgb(space->machine,clr_offset/3,pal6bit(bmc_colorram[(clr_offset/3)*3]),pal6bit(bmc_colorram[(clr_offset/3)*3+1]),pal6bit(bmc_colorram[(clr_offset/3)*3+2]));
208   clr_offset=(clr_offset+1)%768;
208209}
209210
210211static WRITE16_HANDLER( scroll_w )
r6740r6741
551552
552553static DRIVER_INIT(bmcbowl)
553554{
554   machine->generic.colorram.u8 = auto_alloc_array(machine, UINT8, 768);
555   bmc_colorram = auto_alloc_array(machine, UINT8, 768);
555556}
556557
557558GAME( 1994, bmcbowl,    0, bmcbowl,    bmcbowl,    bmcbowl, ROT0,  "BMC", "BMC Bowling", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
src/mame/drivers/leland.c
r6740r6741
4545#include "cpu/i86/i86.h"
4646#include "machine/eeprom.h"
4747#include "cpu/z80/z80.h"
48#include "leland.h"
48#include "includes/leland.h"
4949#include "sound/ay8910.h"
5050
5151
src/mame/drivers/lordgun.c
r6740r6741
3333#include "machine/eeprom.h"
3434#include "sound/3812intf.h"
3535#include "sound/okim6295.h"
36#include "lordgun.h"
36#include "includes/lordgun.h"
3737
3838
3939static UINT16 *lordgun_priority_ram, lordgun_priority;
src/mame/drivers/zerozone.c
r6740r6741
2828*********************************************************************************/
2929
3030#include "driver.h"
31#include "zerozone.h"
31#include "includes/zerozone.h"
3232#include "cpu/z80/z80.h"
3333#include "cpu/m68000/m68000.h"
3434#include "sound/okim6295.h"
src/mame/drivers/espial.c
r6740r6741
99
1010#include "driver.h"
1111#include "deprecat.h"
12#include "espial.h"
12#include "includes/espial.h"
1313#include "cpu/z80/z80.h"
1414#include "sound/ay8910.h"
1515
src/mame/drivers/toaplan1.c
r6740r6741
6565#include "cpu/z80/z80.h"
6666#include "cpu/m68000/m68000.h"
6767#include "cpu/tms32010/tms32010.h"
68#include "toaplan1.h"
68#include "includes/toaplan1.h"
6969#include "sound/3812intf.h"
7070
7171
src/mame/drivers/segag80r.c
r6740r6741
110110#include "machine/8255ppi.h"
111111#include "machine/segacrpt.h"
112112#include "audio/segasnd.h"
113#include "segag80r.h"
113#include "includes/segag80r.h"
114114#include "sound/dac.h"
115115#include "sound/sn76496.h"
116116#include "sound/samples.h"
src/mame/drivers/tmnt.c
r6740r6741
6666
6767#include "driver.h"
6868#include "deprecat.h"
69#include "video/konamiic.h"
70#include "machine/eeprom.h"
69#include "video/konicdev.h"
70#include "machine/eepromdev.h"
7171#include "cpu/m68000/m68000.h"
7272#include "cpu/z80/z80.h"
7373#include "sound/2151intf.h"
r6740r6741
7878#include "sound/k007232.h"
7979#include "sound/upd7759.h"
8080#include "includes/tmnt.h"
81#include "konamipt.h"
81#include "includes/konamipt.h"
8282
83
84extern void mia_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
85extern void cuebrick_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
86extern void tmnt_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
87extern void ssbl_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
88extern void blswhstl_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
89extern void mia_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow);
90extern void tmnt_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow);
91extern void punkshot_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask,int *shadow);
92extern void thndrx2_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask,int *shadow);
93extern void lgtnfght_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask);
94extern void blswhstl_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask);
95extern void prmrsocr_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask);
96
97WRITE16_HANDLER( ssriders_eeprom_w );   /* in video/tmnt.c */
98
8399static int tmnt_soundlatch;
84100static int cuebrick_snd_irqlatch, cuebrick_nvram_bank;
85101static UINT16 cuebrick_nvram[0x400*0x20];   // 32k paged in a 1k window
86102static INT16 *sampledata;
87103
104
88105static READ16_HANDLER( K052109_word_noA12_r )
89106{
107   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
108
90109   /* some games have the A12 line not connected, so the chip spans */
91110   /* twice the memory range, with mirroring */
92111   offset = ((offset & 0x3000) >> 1) | (offset & 0x07ff);
93   return K052109_word_r(space,offset,mem_mask);
112   return k052109_word_r(k052109, offset, mem_mask);
94113}
95114
96115static WRITE16_HANDLER( K052109_word_noA12_w )
97116{
117   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
118
98119   /* some games have the A12 line not connected, so the chip spans */
99120   /* twice the memory range, with mirroring */
100121   offset = ((offset & 0x3000) >> 1) | (offset & 0x07ff);
101   K052109_word_w(space,offset,data,mem_mask);
122   k052109_word_w(k052109, offset, data, mem_mask);
102123}
103124
104125static WRITE16_HANDLER( punkshot_K052109_word_w )
105126{
127   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
128
106129   /* it seems that a word write is supposed to affect only the MSB. The */
107130   /* "ROUND 1" text in punkshtj goes lost otherwise. */
108131   if (ACCESSING_BITS_8_15)
109      K052109_w(space,offset,(data >> 8) & 0xff);
132      k052109_w(k052109, offset, (data >> 8) & 0xff);
110133   else if (ACCESSING_BITS_0_7)
111      K052109_w(space,offset + 0x2000,data & 0xff);
134      k052109_w(k052109, offset + 0x2000, data & 0xff);
112135}
113136
114137static WRITE16_HANDLER( punkshot_K052109_word_noA12_w )
r6740r6741
116139   /* some games have the A12 line not connected, so the chip spans */
117140   /* twice the memory range, with mirroring */
118141   offset = ((offset & 0x3000) >> 1) | (offset & 0x07ff);
119   punkshot_K052109_word_w(space,offset,data,mem_mask);
142   punkshot_K052109_word_w(space, offset, data, mem_mask);
120143}
121144
122145
r6740r6741
125148/* A1, A5 and A6 don't go to the 053245. */
126149static READ16_HANDLER( K053245_scattered_word_r )
127150{
151   const device_config *k053245 = devtag_get_device(space->machine, "k053245");
152
128153   if (offset & 0x0031)
129154      return space->machine->generic.spriteram.u16[offset];
130155   else
131156   {
132157      offset = ((offset & 0x000e) >> 1) | ((offset & 0x1fc0) >> 3);
133      return K053245_word_r(space,offset,mem_mask);
158      return k053245_word_r(k053245, offset, mem_mask);
134159   }
135160}
136161
137162static WRITE16_HANDLER( K053245_scattered_word_w )
138163{
164   const device_config *k053245 = devtag_get_device(space->machine, "k053245");
165
139166   COMBINE_DATA(space->machine->generic.spriteram.u16 + offset);
140167
141168   if (!(offset & 0x0031))
142169   {
143170      offset = ((offset & 0x000e) >> 1) | ((offset & 0x1fc0) >> 3);
144      K053245_word_w(space,offset,data,mem_mask);
171      k053245_word_w(k053245, offset, data, mem_mask);
145172   }
146173}
147174
148175static READ16_HANDLER( K053244_word_noA1_r )
149176{
177   const device_config *k053245 = devtag_get_device(space->machine, "k053245");
178
150179   offset &= ~1;   /* handle mirror address */
151180
152   return K053244_r(space,offset + 1) | (K053244_r(space,offset) << 8);
181   return k053244_r(k053245, offset + 1) | (k053244_r(k053245, offset) << 8);
153182}
154183
155184static WRITE16_HANDLER( K053244_word_noA1_w )
156185{
186   const device_config *k053245 = devtag_get_device(space->machine, "k053245");
187
157188   offset &= ~1;   /* handle mirror address */
158189
159190   if (ACCESSING_BITS_8_15)
160      K053244_w(space,offset,(data >> 8) & 0xff);
191      k053244_w(k053245, offset, (data >> 8) & 0xff);
161192   if (ACCESSING_BITS_0_7)
162      K053244_w(space,offset + 1,data & 0xff);
193      k053244_w(k053245, offset + 1, data & 0xff);
163194}
164195
165196static INTERRUPT_GEN(cuebrick_interrupt)
r6740r6741
180211
181212static INTERRUPT_GEN( punkshot_interrupt )
182213{
183   if (K052109_is_IRQ_enabled()) irq4_line_hold(device);
214   const device_config *k052109 = devtag_get_device(device->machine, "k052109");
184215
216   if (k052109_is_irq_enabled(k052109))
217      irq4_line_hold(device);
185218}
186219
187220static INTERRUPT_GEN( lgtnfght_interrupt )
188221{
189   if (K052109_is_IRQ_enabled()) irq5_line_hold(device);
222   const device_config *k052109 = devtag_get_device(device->machine, "k052109");
190223
224   if (k052109_is_irq_enabled(k052109))
225      irq5_line_hold(device);
191226}
192227
193228
r6740r6741
328363}
329364
330365
331
332
333
334366static READ16_HANDLER( punkshot_kludge_r )
335367{
336368   /* I don't know what's going on here; at one point, the code reads location */
r6740r6741
344376/* protection simulation derived from a bootleg */
345377static READ16_HANDLER( ssriders_protection_r )
346378{
347    int data = memory_read_word(space, 0x105a0a);
348    int cmd = memory_read_word(space, 0x1058fc);
379   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
380   int data = memory_read_word(space, 0x105a0a);
381   int cmd = memory_read_word(space, 0x1058fc);
349382
350383   switch (cmd)
351384   {
r6740r6741
375408         data = -memory_read_word(space, 0x105818);
376409         data = ((data / 8 - 4) & 0x1f) * 0x40;
377410         data += ((memory_read_word(space, 0x105cb0) +
378                  256*K052109_r(space,0x1a01) + K052109_r(space,0x1a00) - 6) / 8 + 12) & 0x3f;
411                  256 * k052109_r(k052109, 0x1a01) + k052109_r(k052109, 0x1a00) - 6) / 8 + 12) & 0x3f;
379412         return data;
380413
381414      default:
r6740r6741
387420
388421static WRITE16_HANDLER( ssriders_protection_w )
389422{
423   const device_config *k053245 = devtag_get_device(space->machine, "k053245");
424
390425   if (offset == 1)
391426   {
392427      int logical_pri,hardware_pri;
r6740r6741
401436         {
402437            if ((memory_read_word(space, 0x180006 + 128*i) >> 8) == logical_pri)
403438            {
404               K053245_word_w(space,8*i,hardware_pri,0x00ff);
439               k053245_word_w(k053245, 8 * i, hardware_pri, 0x00ff);
405440               hardware_pri++;
406441            }
407442         }
r6740r6741
417452
418453***************************************************************************/
419454
420static int init_eeprom_count;
421
422
423455static const eeprom_interface eeprom_intf =
424456{
425457   7,            /* address bits */
r6740r6741
431463   "0100110000000" /* unlock command */
432464};
433465
434static NVRAM_HANDLER( eeprom )
435{
436   if (read_or_write)
437      eeprom_save(file);
438   else
439   {
440      eeprom_init(machine, &eeprom_intf);
441466
442      if (file)
443      {
444         init_eeprom_count = 0;
445         eeprom_load(file);
446      }
447      else
448         init_eeprom_count = 10;
449   }
450}
451
452467static READ16_HANDLER( blswhstl_coin_r )
453468{
454469   int res;
r6740r6741
457472   /* bit 3 is service button */
458473   /* bit 6 is ??? VBLANK? OBJMPX? */
459474   res = input_port_read(space->machine, "COINS");
460   if (init_eeprom_count)
461   {
462      init_eeprom_count--;
463      res &= 0xf7;
464   }
475
465476   toggle ^= 0x40;
466477   return res ^ toggle;
467478}
r6740r6741
476487   /* bit 2 is VBLANK (???) */
477488   /* bit 7 is service button */
478489   res = input_port_read(space->machine, "EEPROM");
479   if (init_eeprom_count)
480   {
481      init_eeprom_count--;
482      res &= 0x7f;
483   }
490
484491   toggle ^= 0x04;
485492   return res ^ toggle;
486493}
r6740r6741
495502   /* bit 2 is VBLANK (???) */
496503   /* bit 3 is service button */
497504   res = input_port_read(space->machine, "EEPROM");
498   if (init_eeprom_count)
499   {
500      init_eeprom_count--;
501      res &= 0xf7;
502   }
505
503506   toggle ^= 0x04;
504507   return res ^ toggle;
505508}
r6740r6741
511514      /* bit 0 is data */
512515      /* bit 1 is cs (active low) */
513516      /* bit 2 is clock (active high) */
514      eeprom_write_bit(data & 0x01);
515      eeprom_set_cs_line((data & 0x02) ? CLEAR_LINE : ASSERT_LINE);
516      eeprom_set_clock_line((data & 0x04) ? ASSERT_LINE : CLEAR_LINE);
517      input_port_write(space->machine, "EEPROMOUT", data, 0xff);
517518   }
518519}
519520
520WRITE16_HANDLER( ssriders_eeprom_w );   /* in video/tmnt.c */
521
522
523static const eeprom_interface thndrx2_eeprom_interface =
521static const eeprom_interface thndrx2_eeprom_intf =
524522{
525523   7,            /* address bits */
526524   8,            /* data bits */
r6740r6741
531529   "0100110000000" /* unlock command */
532530};
533531
534static NVRAM_HANDLER( thndrx2 )
535{
536   if (read_or_write)
537      eeprom_save(file);
538   else
539   {
540      eeprom_init(machine, &thndrx2_eeprom_interface);
541
542      if (file)
543      {
544         init_eeprom_count = 0;
545         eeprom_load(file);
546      }
547      else
548         init_eeprom_count = 10;
549   }
550}
551
552static READ16_HANDLER( thndrx2_in0_r )
553{
554   int res;
555
556   res = input_port_read(space->machine, "P1/COINS");
557   if (init_eeprom_count)
558   {
559      init_eeprom_count--;
560      res &= 0xf7ff;
561   }
562   return res;
563}
564
565532static READ16_HANDLER( thndrx2_eeprom_r )
566533{
567534   int res;
r6740r6741
578545
579546static WRITE16_HANDLER( thndrx2_eeprom_w )
580547{
548   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
581549   static int last;
582550
583551   if (ACCESSING_BITS_0_7)
r6740r6741
585553      /* bit 0 is data */
586554      /* bit 1 is cs (active low) */
587555      /* bit 2 is clock (active high) */
588      eeprom_write_bit(data & 0x01);
589      eeprom_set_cs_line((data & 0x02) ? CLEAR_LINE : ASSERT_LINE);
590      eeprom_set_clock_line((data & 0x04) ? ASSERT_LINE : CLEAR_LINE);
556      input_port_write(space->machine, "EEPROMOUT", data, 0xff);
591557
592558      /* bit 5 triggers IRQ on sound cpu */
593559      if (last == 0 && (data & 0x20) != 0)
r6740r6741
595561      last = data & 0x20;
596562
597563      /* bit 6 = enable char ROM reading through the video RAM */
598      K052109_set_RMRD_line((data & 0x40) ? ASSERT_LINE : CLEAR_LINE);
564      k052109_set_rmrd_line(k052109, (data & 0x40) ? ASSERT_LINE : CLEAR_LINE);
599565   }
600566}
601567
602
603static READ16_HANDLER( prmrsocr_IN0_r )
604{
605   /* bit 9 is service button */
606   int res;
607
608   res = input_port_read(space->machine, "P1/COINS");
609   if (init_eeprom_count)
610   {
611      init_eeprom_count--;
612      res &= 0xfdff;
613   }
614   return res;
615}
616
617568static WRITE16_HANDLER( prmrsocr_eeprom_w )
618569{
619570   if (ACCESSING_BITS_0_7)
r6740r6741
626577      /* bit 8 is data */
627578      /* bit 9 is cs (active low) */
628579      /* bit 10 is clock (active high) */
629      eeprom_write_bit(data & 0x0100);
630      eeprom_set_cs_line((data & 0x0200) ? CLEAR_LINE : ASSERT_LINE);
631      eeprom_set_clock_line((data & 0x0400) ? ASSERT_LINE : CLEAR_LINE);
580      input_port_write(space->machine, "EEPROMOUT", data, 0xffff);
632581   }
633582}
634583
r6740r6741
663612   AM_RANGE(0x0b0400, 0x0b0401) AM_WRITE(cuebrick_nvbank_w)
664613   AM_RANGE(0x0c0000, 0x0c0003) AM_DEVREADWRITE8("ymsnd", ym2151_r, ym2151_w, 0xff00)
665614   AM_RANGE(0x100000, 0x107fff) AM_READWRITE(K052109_word_noA12_r, K052109_word_noA12_w)
666   AM_RANGE(0x140000, 0x140007) AM_READWRITE(K051937_word_r, K051937_word_w)
667   AM_RANGE(0x140400, 0x1407ff) AM_READWRITE(K051960_word_r, K051960_word_w)
615   AM_RANGE(0x140000, 0x140007) AM_DEVREADWRITE("k051960", k051937_word_r, k051937_word_w)
616   AM_RANGE(0x140400, 0x1407ff) AM_DEVREADWRITE("k051960", k051960_word_r, k051960_word_w)
668617ADDRESS_MAP_END
669618
670619
r6740r6741
685634#endif
686635   AM_RANGE(0x100000, 0x107fff) AM_READWRITE(K052109_word_noA12_r, K052109_word_noA12_w)
687636//  AM_RANGE(0x10e800, 0x10e801) AM_WRITENOP ???
688   AM_RANGE(0x140000, 0x140007) AM_READWRITE(K051937_word_r, K051937_word_w)
689   AM_RANGE(0x140400, 0x1407ff) AM_READWRITE(K051960_word_r, K051960_word_w)
637   AM_RANGE(0x140000, 0x140007) AM_DEVREADWRITE("k051960", k051937_word_r, k051937_word_w)
638   AM_RANGE(0x140400, 0x1407ff) AM_DEVREADWRITE("k051960", k051960_word_r, k051960_word_w)
690639ADDRESS_MAP_END
691640
692641
r6740r6741
706655   AM_RANGE(0x0c0000, 0x0c0001) AM_WRITE(tmnt_priority_w)
707656   AM_RANGE(0x100000, 0x107fff) AM_READWRITE(K052109_word_noA12_r, K052109_word_noA12_w)
708657//  AM_RANGE(0x10e800, 0x10e801) AM_WRITENOP ???
709   AM_RANGE(0x140000, 0x140007) AM_READWRITE(K051937_word_r, K051937_word_w)
710   AM_RANGE(0x140400, 0x1407ff) AM_READWRITE(K051960_word_r, K051960_word_w)
658   AM_RANGE(0x140000, 0x140007) AM_DEVREADWRITE("k051960", k051937_word_r, k051937_word_w)
659   AM_RANGE(0x140400, 0x1407ff) AM_DEVREADWRITE("k051960", k051960_word_r, k051960_word_w)
711660ADDRESS_MAP_END
712661
713662
r6740r6741
722671   AM_RANGE(0x0a0020, 0x0a0021) AM_WRITE(punkshot_0a0020_w)
723672   AM_RANGE(0x0a0040, 0x0a0043) AM_DEVREAD8("konami", punkshot_sound_r, 0x00ff)   /* K053260 */
724673   AM_RANGE(0x0a0040, 0x0a0041) AM_DEVWRITE8("konami", k053260_w, 0x00ff)
725   AM_RANGE(0x0a0060, 0x0a007f) AM_WRITE(K053251_lsb_w)
674   AM_RANGE(0x0a0060, 0x0a007f) AM_DEVWRITE("k053251", k053251_lsb_w)
726675   AM_RANGE(0x0a0080, 0x0a0081) AM_WRITE(watchdog_reset16_w)
727676   AM_RANGE(0x100000, 0x107fff) AM_READWRITE(K052109_word_noA12_r, punkshot_K052109_word_noA12_w)
728   AM_RANGE(0x110000, 0x110007) AM_READWRITE(K051937_word_r, K051937_word_w)
729   AM_RANGE(0x110400, 0x1107ff) AM_READWRITE(K051960_word_r, K051960_word_w)
677   AM_RANGE(0x110000, 0x110007) AM_DEVREADWRITE("k051960", k051937_word_r, k051937_word_w)
678   AM_RANGE(0x110400, 0x1107ff) AM_DEVREADWRITE("k051960", k051960_word_r, k051960_word_w)
730679   AM_RANGE(0xfffffc, 0xffffff) AM_READ(punkshot_kludge_r)
731680ADDRESS_MAP_END
732681
r6740r6741
747696   AM_RANGE(0x0a0028, 0x0a0029) AM_WRITE(watchdog_reset16_w)
748697   AM_RANGE(0x0b0000, 0x0b3fff) AM_READWRITE(K053245_scattered_word_r, K053245_scattered_word_w) AM_BASE_GENERIC(spriteram)
749698   AM_RANGE(0x0c0000, 0x0c001f) AM_READWRITE(K053244_word_noA1_r, K053244_word_noA1_w)
750   AM_RANGE(0x0e0000, 0x0e001f) AM_WRITE(K053251_lsb_w)
699   AM_RANGE(0x0e0000, 0x0e001f) AM_DEVWRITE("k053251", k053251_lsb_w)
751700   AM_RANGE(0x100000, 0x107fff) AM_READWRITE(K052109_word_noA12_r, K052109_word_noA12_w)
752701ADDRESS_MAP_END
753702
r6740r6741
760709
761710static ADDRESS_MAP_START( blswhstl_main_map, ADDRESS_SPACE_PROGRAM, 16 )
762711   AM_RANGE(0x000000, 0x07ffff) AM_ROM
763   AM_RANGE(0x180000, 0x183fff) AM_READWRITE(K052109_word_r, K052109_word_w)
712   AM_RANGE(0x180000, 0x183fff) AM_DEVREADWRITE("k052109", k052109_word_r, k052109_word_w)
764713   AM_RANGE(0x204000, 0x207fff) AM_RAM   /* main RAM */
765714   AM_RANGE(0x300000, 0x303fff) AM_READWRITE(K053245_scattered_word_r, K053245_scattered_word_w) AM_BASE_GENERIC(spriteram)
766715   AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
767   AM_RANGE(0x500000, 0x50003f) AM_READWRITE(K054000_lsb_r, K054000_lsb_w)
716   AM_RANGE(0x500000, 0x50003f) AM_DEVREADWRITE("k054000", k054000_lsb_r, k054000_lsb_w)
768717   AM_RANGE(0x680000, 0x68001f) AM_READWRITE(K053244_word_noA1_r, K053244_word_noA1_w)
769718   AM_RANGE(0x700000, 0x700001) AM_READ_PORT("P1")
770719   AM_RANGE(0x700002, 0x700003) AM_READ_PORT("P2")
r6740r6741
776725   AM_RANGE(0x780600, 0x780603) AM_DEVREAD8("konami", punkshot_sound_r, 0x00ff)   /* K053260 */
777726   AM_RANGE(0x780600, 0x780601) AM_DEVWRITE8("konami", k053260_w, 0x00ff)
778727   AM_RANGE(0x780604, 0x780605) AM_WRITE(ssriders_soundkludge_w)
779   AM_RANGE(0x780700, 0x78071f) AM_WRITE(K053251_lsb_w)
728   AM_RANGE(0x780700, 0x78071f) AM_DEVWRITE("k053251", k053251_lsb_w)
780729ADDRESS_MAP_END
781730
782731
732static WRITE16_HANDLER( K053251_glfgreat_w )
733{
734   const device_config *k053251 = devtag_get_device(space->machine, "k053251");
735   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
736   int i;
737
738   if (ACCESSING_BITS_8_15)
739   {
740      k053251_w(k053251, offset, (data >> 8) & 0xff);
741
742      /* FIXME: in the old code k052109 tilemaps were tilemaps 2,3,4 for k053251
743        and got marked as dirty in the write above... how was the original hardware working?!? */
744      for (i = 0; i < 3; i++)
745      {
746         if (k053251_get_tmap_dirty(k053251, 2 + i))
747         {
748            k052109_tilemap_mark_dirty(k052109, i);
749            k053251_set_tmap_dirty(k053251, 2 + i, 0);
750         }
751      }
752   }
753}
754
783755static ADDRESS_MAP_START( glfgreat_main_map, ADDRESS_SPACE_PROGRAM, 16 )
784756   AM_RANGE(0x000000, 0x03ffff) AM_ROM
785757   AM_RANGE(0x100000, 0x103fff) AM_RAM   /* main RAM */
786758   AM_RANGE(0x104000, 0x107fff) AM_READWRITE(K053245_scattered_word_r, K053245_scattered_word_w) AM_BASE_GENERIC(spriteram)
787759   AM_RANGE(0x108000, 0x108fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
788   AM_RANGE(0x10c000, 0x10cfff) AM_RAM    AM_BASE(&K053936_0_linectrl)   /* 053936? */
760   AM_RANGE(0x10c000, 0x10cfff) AM_DEVREADWRITE("k053936", k053936_linectrl_r, k053936_linectrl_w)   /* 053936? */
789761   AM_RANGE(0x110000, 0x11001f) AM_WRITE(K053244_word_noA1_w)            /* duplicate! */
790   AM_RANGE(0x114000, 0x11401f) AM_READWRITE(K053244_lsb_r, K053244_lsb_w)   /* duplicate! */
791   AM_RANGE(0x118000, 0x11801f) AM_WRITEONLY AM_BASE(&K053936_0_ctrl)
792   AM_RANGE(0x11c000, 0x11c01f) AM_WRITE(K053251_msb_w)
762   AM_RANGE(0x114000, 0x11401f) AM_DEVREADWRITE("k053245", k053244_lsb_r, k053244_lsb_w)   /* duplicate! */
763   AM_RANGE(0x118000, 0x11801f) AM_DEVWRITE("k053936", k053936_ctrl_w)
764   AM_RANGE(0x11c000, 0x11c01f) AM_DEVWRITE("k053251", k053251_msb_w)
765   AM_RANGE(0x11c000, 0x11c01f) AM_WRITE(K053251_glfgreat_w)
793766   AM_RANGE(0x120000, 0x120001) AM_READ_PORT("P1/P2")
794767   AM_RANGE(0x120002, 0x120003) AM_READ_PORT("P3/P4")
795768   AM_RANGE(0x120004, 0x120005) AM_READ_PORT("COINS/DSW3")
r6740r6741
808781   AM_RANGE(0x100000, 0x103fff) AM_RAM   /* main RAM */
809782   AM_RANGE(0x104000, 0x107fff) AM_READWRITE(K053245_scattered_word_r, K053245_scattered_word_w) AM_BASE_GENERIC(spriteram)
810783   AM_RANGE(0x108000, 0x108fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
811   AM_RANGE(0x10c000, 0x10cfff) AM_RAM AM_BASE(&K053936_0_linectrl)
784   AM_RANGE(0x10c000, 0x10cfff) AM_DEVREADWRITE("k053936", k053936_linectrl_r, k053936_linectrl_w)
812785   AM_RANGE(0x110000, 0x11001f) AM_WRITE(K053244_word_noA1_w)            /* duplicate! */
813   AM_RANGE(0x114000, 0x11401f) AM_READWRITE(K053244_lsb_r, K053244_lsb_w)   /* duplicate! */
814   AM_RANGE(0x118000, 0x11801f) AM_WRITEONLY AM_BASE(&K053936_0_ctrl)
815   AM_RANGE(0x11c000, 0x11c01f) AM_WRITE(K053251_msb_w)
816   AM_RANGE(0x120000, 0x120001) AM_READ(prmrsocr_IN0_r)
786   AM_RANGE(0x114000, 0x11401f) AM_DEVREADWRITE("k053245", k053244_lsb_r, k053244_lsb_w)   /* duplicate! */
787   AM_RANGE(0x118000, 0x11801f) AM_DEVWRITE("k053936", k053936_ctrl_w)
788   AM_RANGE(0x11c000, 0x11c01f) AM_DEVWRITE("k053251", k053251_msb_w)
789   AM_RANGE(0x11c000, 0x11c01f) AM_WRITE(K053251_glfgreat_w)
790   AM_RANGE(0x120000, 0x120001) AM_READ_PORT("P1/COINS")
817791   AM_RANGE(0x120002, 0x120003) AM_READ_PORT("P2/EEPROM")
818792   AM_RANGE(0x12100c, 0x12100f) AM_WRITE(prmrsocr_sound_cmd_w)
819793   AM_RANGE(0x121014, 0x121015) AM_READ(prmrsocr_sound_r)
r6740r6741
839813
840814static void tmnt2_put_word(const address_space *space, UINT32 addr, UINT16 data)
841815{
816   const device_config *k053245 = devtag_get_device(space->machine, "k053245");
817
842818   UINT32 offs;
843819   if (addr >= 0x180000/2 && addr <= 0x183fff/2)
844820   {
r6740r6741
847823      if (!(offs & 0x0031))
848824      {
849825         offs = ((offs & 0x000e) >> 1) | ((offs & 0x1fc0) >> 3);
850         K053245_word_w(space, offs, data, 0xffff);
826         k053245_word_w(k053245, offs, data, 0xffff);
851827      }
852828   }
853829   else if (addr >= 0x104000/2 && addr <= 0x107fff/2) sunset_104000[addr-0x104000/2] = data;
r6740r6741
971947#else // for reference; do not remove
972948static WRITE16_HANDLER( tmnt2_1c0800_w )
973949{
974    COMBINE_DATA( tmnt2_1c0800 + offset);
975    if ( offset == 0x0008 && ( tmnt2_1c0800[0x8] & 0xff00 ) == 0x8200 )
950   COMBINE_DATA( tmnt2_1c0800 + offset);
951   if ( offset == 0x0008 && ( tmnt2_1c0800[0x8] & 0xff00 ) == 0x8200 )
976952   {
977953      UINT32 CellSrc;
978954      UINT32 CellVar;
r6740r6741
984960      dst = tmnt2_1c0800[0x02] | (tmnt2_1c0800[0x03] << 16 );
985961      CellSrc = tmnt2_1c0800[0x00] | (tmnt2_1c0800[0x01] << 16 );
986962//        if ( CellDest >= 0x180000 && CellDest < 0x183fe0 ) {
987        CellVar -= 0x104000;
963      CellVar -= 0x104000;
988964      src = (UINT16 *)(memory_region(space->machine, "maincpu") + CellSrc);
989965
990966      CellVar >>= 1;
991967
992968      memory_write_word(space,dst+0x00, 0x8000 | ((src[1] & 0xfc00) >> 2));   /* size, flip xy */
993        memory_write_word(space,dst+0x04, src[0]);   /* code */
994        memory_write_word(space,dst+0x18, (src[1] & 0x3ff) ^      /* color, mirror, priority */
969      memory_write_word(space,dst+0x04, src[0]);   /* code */
970      memory_write_word(space,dst+0x18, (src[1] & 0x3ff) ^      /* color, mirror, priority */
995971            (sunset_104000[CellVar + 0x00] & 0x0060));
996972
997973      /* base color modifier */
r6740r6741
10771053   AM_RANGE(0x5c0600, 0x5c0603) AM_DEVREAD8("konami", punkshot_sound_r, 0x00ff)   /* K053260 */
10781054   AM_RANGE(0x5c0600, 0x5c0601) AM_DEVWRITE8("konami", k053260_w, 0x00ff)
10791055   AM_RANGE(0x5c0604, 0x5c0605) AM_WRITE(ssriders_soundkludge_w)
1080   AM_RANGE(0x5c0700, 0x5c071f) AM_WRITE(K053251_lsb_w)
1081   AM_RANGE(0x600000, 0x603fff) AM_READWRITE(K052109_word_r, K052109_word_w)
1056   AM_RANGE(0x5c0700, 0x5c071f) AM_DEVWRITE("k053251", k053251_lsb_w)
1057   AM_RANGE(0x600000, 0x603fff) AM_DEVREADWRITE("k052109", k052109_word_r, k052109_word_w)
10821058ADDRESS_MAP_END
10831059
10841060
r6740r6741
11031079   AM_RANGE(0x5c0600, 0x5c0603) AM_DEVREAD8("konami", punkshot_sound_r, 0x00ff)   /* K053260 */
11041080   AM_RANGE(0x5c0600, 0x5c0601) AM_DEVWRITE8("konami", k053260_w, 0x00ff)
11051081   AM_RANGE(0x5c0604, 0x5c0605) AM_WRITE(ssriders_soundkludge_w)
1106   AM_RANGE(0x5c0700, 0x5c071f) AM_WRITE(K053251_lsb_w)
1107   AM_RANGE(0x600000, 0x603fff) AM_READWRITE(K052109_word_r, K052109_word_w)
1082   AM_RANGE(0x5c0700, 0x5c071f) AM_DEVWRITE("k053251", k053251_lsb_w)
1083   AM_RANGE(0x600000, 0x603fff) AM_DEVREADWRITE("k052109", k052109_word_r, k052109_word_w)
11081084ADDRESS_MAP_END
11091085
11101086
r6740r6741
11121088   AM_RANGE(0x000000, 0x0bffff) AM_ROM
11131089   AM_RANGE(0x104000, 0x107fff) AM_RAM   /* main RAM */
11141090   AM_RANGE(0x14c000, 0x14cfff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
1115   AM_RANGE(0x14e700, 0x14e71f) AM_WRITE(K053251_lsb_w)
1091   AM_RANGE(0x14e700, 0x14e71f) AM_DEVWRITE("k053251", k053251_lsb_w)
11161092   AM_RANGE(0x180000, 0x183fff) AM_READWRITE(K053245_scattered_word_r, K053245_scattered_word_w) AM_BASE_GENERIC(spriteram)
11171093   AM_RANGE(0x184000, 0x18ffff) AM_RAM
11181094   AM_RANGE(0x1c0300, 0x1c0301) AM_WRITE(ssriders_1c0300_w)
11191095   AM_RANGE(0x1c0400, 0x1c0401) AM_WRITENOP
11201096   AM_RANGE(0x5a0000, 0x5a001f) AM_READWRITE(K053244_word_noA1_r, K053244_word_noA1_w)
1121   AM_RANGE(0x600000, 0x603fff) AM_READWRITE(K052109_word_r, K052109_word_w)
1097   AM_RANGE(0x600000, 0x603fff) AM_DEVREADWRITE("k052109", k052109_word_r, k052109_word_w)
11221098   AM_RANGE(0x604020, 0x60402f) AM_WRITENOP   /* written every frame */
11231099   AM_RANGE(0x604200, 0x604201) AM_WRITENOP   /* watchdog */
11241100   AM_RANGE(0x6119e2, 0x6119e3) AM_WRITENOP   /* written a lot in some test menus (PC=18204) */
r6740r6741
11381114   AM_RANGE(0x000000, 0x03ffff) AM_ROM
11391115   AM_RANGE(0x100000, 0x103fff) AM_RAM   /* main RAM */
11401116   AM_RANGE(0x200000, 0x200fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
1141   AM_RANGE(0x300000, 0x30001f) AM_WRITE(K053251_lsb_w)
1117   AM_RANGE(0x300000, 0x30001f) AM_DEVWRITE("k053251", k053251_lsb_w)
11421118   AM_RANGE(0x400000, 0x400003) AM_DEVREAD8("konami", punkshot_sound_r, 0x00ff)   /* K053260 */
11431119   AM_RANGE(0x400000, 0x400001) AM_DEVWRITE8("konami", k053260_w, 0x00ff)
1144   AM_RANGE(0x500000, 0x50003f) AM_READWRITE(K054000_lsb_r, K054000_lsb_w)
1120   AM_RANGE(0x500000, 0x50003f) AM_DEVREADWRITE("k054000", k054000_lsb_r, k054000_lsb_w)
11451121   AM_RANGE(0x500100, 0x500101) AM_WRITE(thndrx2_eeprom_w)
1146   AM_RANGE(0x500200, 0x500201) AM_READ(thndrx2_in0_r)
1122   AM_RANGE(0x500200, 0x500201) AM_READ_PORT("P1/COINS")
11471123   AM_RANGE(0x500202, 0x500203) AM_READ(thndrx2_eeprom_r)
11481124   AM_RANGE(0x500300, 0x500301) AM_WRITENOP   /* watchdog reset? irq enable? */
11491125   AM_RANGE(0x600000, 0x607fff) AM_READWRITE(K052109_word_noA12_r, K052109_word_noA12_w)
1150   AM_RANGE(0x700000, 0x700007) AM_READWRITE(K051937_word_r, K051937_word_w)
1151   AM_RANGE(0x700400, 0x7007ff) AM_READWRITE(K051960_word_r, K051960_word_w)
1126   AM_RANGE(0x700000, 0x700007) AM_DEVREADWRITE("k051960", k051937_word_r, k051937_word_w)
1127   AM_RANGE(0x700400, 0x7007ff) AM_DEVREADWRITE("k051960", k051960_word_r, k051960_word_w)
11521128ADDRESS_MAP_END
11531129
11541130
r6740r6741
17381714   KONAMI16_LSB( 2, IPT_UNKNOWN, IPT_UNKNOWN )
17391715
17401716   PORT_START("EEPROM")
1741   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
1717   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
17421718   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM status? - always 1 */
17431719   PORT_BIT( 0xfc, IP_ACTIVE_LOW, IPT_UNKNOWN )
1720
1721   PORT_START( "EEPROMOUT" )
1722   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
1723   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
1724   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
17441725INPUT_PORTS_END
17451726
17461727static INPUT_PORTS_START( glfgreat )
r6740r6741
18291810   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED )
18301811
18311812   PORT_START("EEPROM")
1832   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
1813   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
18331814   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM status? - always 1 */
18341815   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* ?? TMNT2: OBJMPX */
18351816   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK )   /* ?? TMNT2: NVBLK */
18361817   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* ?? TMNT2: IPL0 */
18371818   PORT_BIT( 0x60, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
18381819   PORT_SERVICE_NO_TOGGLE( 0x80, IP_ACTIVE_LOW )
1820
1821   PORT_START( "EEPROMOUT" )
1822   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
1823   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
1824   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
18391825INPUT_PORTS_END
18401826
18411827static INPUT_PORTS_START( ssridr4p )
r6740r6741
18621848   KONAMI16_LSB( 4, IPT_UNKNOWN, IPT_UNKNOWN )
18631849
18641850   PORT_START("EEPROM")
1865   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
1851   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
18661852   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM status? - always 1 */
18671853   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* ?? TMNT2: OBJMPX */
18681854   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK )   /* ?? TMNT2: NVBLK */
18691855   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* ?? TMNT2: IPL0 */
18701856   PORT_BIT( 0x60, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
18711857   PORT_SERVICE_NO_TOGGLE( 0x80, IP_ACTIVE_LOW )
1858
1859   PORT_START( "EEPROMOUT" )
1860   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
1861   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
1862   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
18721863INPUT_PORTS_END
18731864
18741865/* Same as 'ssridr4p', but additional Start button for each player.
r6740r6741
18971888   KONAMI16_LSB( 4, IPT_UNKNOWN, IPT_START4 )
18981889
18991890   PORT_START("EEPROM")
1900   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
1891   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
19011892   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM status? - always 1 */
19021893   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* ?? TMNT2: OBJMPX */
19031894   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK )   /* ?? TMNT2: NVBLK */
19041895   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* ?? TMNT2: IPL0 */
19051896   PORT_BIT( 0x60, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
19061897   PORT_SERVICE_NO_TOGGLE( 0x80, IP_ACTIVE_LOW )
1898
1899   PORT_START( "EEPROMOUT" )
1900   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
1901   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
1902   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
19071903INPUT_PORTS_END
19081904
19091905/* Version for the bootleg, which has the service switch a little different */
r6740r6741
19311927   KONAMI16_LSB( 4, IPT_UNKNOWN, IPT_START4 )
19321928
19331929   PORT_START("EEPROM")
1934   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
1930   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
19351931   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM status? - always 1 */
19361932   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
19371933   PORT_SERVICE_NO_TOGGLE( 0x08, IP_ACTIVE_LOW )
19381934   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
19391935   PORT_BIT( 0x60, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
19401936   PORT_SERVICE_NO_TOGGLE( 0x80, IP_ACTIVE_LOW )
1937
1938   PORT_START( "EEPROMOUT" )
1939   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
1940   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
1941   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
19411942INPUT_PORTS_END
19421943
19431944static INPUT_PORTS_START( qgakumon )
r6740r6741
19781979   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
19791980
19801981   PORT_START("EEPROM")
1981   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
1982   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
19821983   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM status? - always 1 */
19831984   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* ?? TMNT2: OBJMPX */
19841985   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK )   /* ?? TMNT2: NVBLK (needs to be ACTIVE_HIGH to avoid problems) */
19851986   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* ?? TMNT2: IPL0 */
19861987   PORT_BIT( 0x60, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
19871988   PORT_SERVICE_NO_TOGGLE( 0x80, IP_ACTIVE_LOW )
1989
1990   PORT_START( "EEPROMOUT" )
1991   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
1992   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
1993   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
19881994INPUT_PORTS_END
19891995
19901996static INPUT_PORTS_START( thndrx2 )
r6740r6741
20012007
20022008   PORT_START("P2/EEPROM")
20032009   KONAMI16_LSB( 2, IPT_UNKNOWN, IPT_START2 )
2004   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
2010   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
20052011   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM status? - always 1 */
20062012   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
20072013   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* VBLK?? */
r6740r6741
20092015   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
20102016   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
20112017   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
2018
2019   PORT_START( "EEPROMOUT" )
2020   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
2021   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
2022   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
20122023INPUT_PORTS_END
20132024
20142025static INPUT_PORTS_START( prmrsocr )
r6740r6741
20332044
20342045   PORT_START("P2/EEPROM")
20352046   KONAMI16_LSB( 2, IPT_UNKNOWN, IPT_START2 )
2036   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
2047   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
20372048   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM status? - always 1 */
20382049   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_COIN2 )
20392050   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
20412052   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN )
20422053   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
20432054   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
2055
2056   PORT_START( "EEPROMOUT" )
2057   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
2058   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
2059   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
20442060INPUT_PORTS_END
20452061
20462062
r6740r6741
20722088   tmnt_decode_sample
20732089};
20742090
2091
2092/* 052109 interfaces */
2093static const k052109_interface cuebrick_k052109_intf =
2094{
2095   "gfx1", 0,
2096   NORMAL_PLANE_ORDER,
2097   KONAMI_ROM_SHUFFLE8,
2098   cuebrick_tile_callback
2099};
2100
2101static const k052109_interface mia_k052109_intf =
2102{
2103   "gfx1", 0,
2104   NORMAL_PLANE_ORDER,
2105   KONAMI_ROM_DEINTERLEAVE_2,
2106   mia_tile_callback
2107};
2108
2109static const k052109_interface tmnt_k052109_intf =
2110{
2111   "gfx1", 0,
2112   NORMAL_PLANE_ORDER,
2113   KONAMI_ROM_DEINTERLEAVE_2,
2114   tmnt_tile_callback
2115};
2116
2117static const k052109_interface glfgreat_k052109_intf =
2118{
2119   "gfx1", 1,
2120   NORMAL_PLANE_ORDER,
2121   KONAMI_ROM_SHUFFLE8,
2122   tmnt_tile_callback
2123};
2124
2125static const k052109_interface sunsetbl_k052109_intf =
2126{
2127   "gfx1", 0,
2128   NORMAL_PLANE_ORDER,
2129   KONAMI_ROM_DEINTERLEAVE_2,
2130   ssbl_tile_callback
2131};
2132
2133static const k052109_interface blswhstl_k052109_intf =
2134{
2135   "gfx1", 0,
2136   NORMAL_PLANE_ORDER,
2137   KONAMI_ROM_DEINTERLEAVE_2,
2138   blswhstl_tile_callback
2139};
2140
2141/* 053245 interfaces */
2142static const k05324x_interface lgtnfght_k05324x_intf =
2143{
2144   "gfx2", 1,
2145   NORMAL_PLANE_ORDER,
2146   0, 0,
2147   KONAMI_ROM_DEINTERLEAVE_2,
2148   lgtnfght_sprite_callback
2149};
2150
2151static const k05324x_interface prmrsocr_k05324x_intf =
2152{
2153   "gfx2", 2,
2154   NORMAL_PLANE_ORDER,
2155   0, 0,
2156   KONAMI_ROM_SHUFFLE8,
2157   prmrsocr_sprite_callback
2158};
2159
2160static const k05324x_interface blswhstl_k05324x_intf =
2161{
2162   "gfx2", 1,
2163   NORMAL_PLANE_ORDER,
2164   0, 0,
2165   KONAMI_ROM_DEINTERLEAVE_2,
2166   blswhstl_sprite_callback
2167};
2168
2169static const k05324x_interface glfgreat_k05324x_intf =
2170{
2171   "gfx2", 2,
2172   NORMAL_PLANE_ORDER,
2173   0, 0,
2174   KONAMI_ROM_SHUFFLE8,
2175   lgtnfght_sprite_callback
2176};
2177
2178/* 051960 interfaces */
2179static const k051960_interface cuebrick_k051960_intf =
2180{
2181   "gfx2", 1,
2182   REVERSE_PLANE_ORDER,
2183   KONAMI_ROM_SHUFFLE8,
2184   mia_sprite_callback
2185};
2186
2187static const k051960_interface mia_k051960_intf =
2188{
2189   "gfx2", 1,
2190   REVERSE_PLANE_ORDER,
2191   KONAMI_ROM_DEINTERLEAVE_2,
2192   mia_sprite_callback
2193};
2194
2195static const k051960_interface tmnt_k051960_intf =
2196{
2197   "gfx2", 1,
2198   REVERSE_PLANE_ORDER,
2199   KONAMI_ROM_DEINTERLEAVE_2,
2200   tmnt_sprite_callback
2201};
2202
2203static const k051960_interface punkshot_k051960_intf =
2204{
2205   "gfx2", 1,
2206   NORMAL_PLANE_ORDER,
2207   KONAMI_ROM_DEINTERLEAVE_2,
2208   punkshot_sprite_callback
2209};
2210
2211static const k051960_interface thndrx2_k051960_intf =
2212{
2213   "gfx2", 1,
2214   NORMAL_PLANE_ORDER,
2215   KONAMI_ROM_DEINTERLEAVE_2,
2216   thndrx2_sprite_callback
2217};
2218
2219
2220/* 053936 interfaces */
2221static const k053936_interface glfgreat_k053936_interface =
2222{
2223   1, 85, 0      /* wrap, xoff, yoff */
2224};
2225
2226static const k053936_interface prmrsocr_k053936_interface =
2227{
2228   0, 85, 1      /* wrap, xoff, yoff */
2229};
2230
2231
20752232static MACHINE_DRIVER_START( cuebrick )
20762233
20772234   /* basic machine hardware */
r6740r6741
20952252   MDRV_VIDEO_START(cuebrick)
20962253   MDRV_VIDEO_UPDATE(mia)
20972254
2255   MDRV_K052109_ADD("k052109", cuebrick_k052109_intf)
2256   MDRV_K051960_ADD("k051960", cuebrick_k051960_intf)
2257
20982258   /* sound hardware */
20992259   MDRV_SPEAKER_STANDARD_MONO("mono")
21002260
r6740r6741
21302290   MDRV_VIDEO_START(mia)
21312291   MDRV_VIDEO_UPDATE(mia)
21322292
2293   MDRV_K052109_ADD("k052109", mia_k052109_intf)
2294   MDRV_K051960_ADD("k051960", mia_k051960_intf)
2295
21332296   /* sound hardware */
21342297   MDRV_SPEAKER_STANDARD_MONO("mono")
21352298
r6740r6741
21792342   MDRV_VIDEO_START(tmnt)
21802343   MDRV_VIDEO_UPDATE(tmnt)
21812344
2345   MDRV_K052109_ADD("k052109", tmnt_k052109_intf)
2346   MDRV_K051960_ADD("k051960", tmnt_k051960_intf)
2347
21822348   /* sound hardware */
21832349   MDRV_SPEAKER_STANDARD_MONO("mono")
21842350
r6740r6741
22232389
22242390   MDRV_PALETTE_LENGTH(2048)
22252391
2226   MDRV_VIDEO_START(punkshot)
22272392   MDRV_VIDEO_UPDATE(punkshot)
22282393
2394   MDRV_K052109_ADD("k052109", tmnt_k052109_intf)
2395   MDRV_K051960_ADD("k051960", punkshot_k051960_intf)
2396   MDRV_K053251_ADD("k053251")
2397
22292398   /* sound hardware */
22302399   MDRV_SPEAKER_STANDARD_MONO("mono")
22312400
r6740r6741
22632432   MDRV_VIDEO_START(lgtnfght)
22642433   MDRV_VIDEO_UPDATE(lgtnfght)
22652434
2435   MDRV_K052109_ADD("k052109", tmnt_k052109_intf)
2436   MDRV_K053245_ADD("k053245", lgtnfght_k05324x_intf)
2437   MDRV_K053251_ADD("k053251")
2438
22662439   /* sound hardware */
22672440   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
22682441
r6740r6741
22872460   MDRV_CPU_PROGRAM_MAP(ssriders_audio_map)
22882461                        /* NMIs are generated by the 053260 */
22892462
2290   MDRV_NVRAM_HANDLER(eeprom)
2463   MDRV_EEPROM_NODEFAULT_ADD("eeprom", eeprom_intf)
22912464
22922465   /* video hardware */
22932466   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_AFTER_VBLANK)
r6740r6741
23012474
23022475   MDRV_PALETTE_LENGTH(2048)
23032476
2304   MDRV_VIDEO_START(blswhstl)
23052477   MDRV_VIDEO_UPDATE(lgtnfght)
23062478   MDRV_VIDEO_EOF( blswhstl )
23072479
2480   MDRV_K052109_ADD("k052109", blswhstl_k052109_intf)
2481   MDRV_K053245_ADD("k053245", blswhstl_k05324x_intf)
2482   MDRV_K053251_ADD("k053251")
2483   MDRV_K054000_ADD("k054000")
2484
23082485   /* sound hardware */
23092486   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
23102487
r6740r6741
23622539   MDRV_VIDEO_START(glfgreat)
23632540   MDRV_VIDEO_UPDATE(glfgreat)
23642541
2542   MDRV_K052109_ADD("k052109", glfgreat_k052109_intf)
2543   MDRV_K053245_ADD("k053245", glfgreat_k05324x_intf)
2544   MDRV_K053936_ADD("k053936", glfgreat_k053936_interface)
2545   MDRV_K053251_ADD("k053251")
2546
23652547   /* sound hardware */
23662548   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
23672549
r6740r6741
23942576   MDRV_CPU_PROGRAM_MAP(prmrsocr_audio_map)
23952577                        /* NMIs are generated by the 054539 */
23962578
2397   MDRV_NVRAM_HANDLER(thndrx2)
2579   MDRV_EEPROM_NODEFAULT_ADD("eeprom", thndrx2_eeprom_intf)
23982580
23992581   /* video hardware */
24002582   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_AFTER_VBLANK)
r6740r6741
24122594   MDRV_VIDEO_START(prmrsocr)
24132595   MDRV_VIDEO_UPDATE(glfgreat)
24142596
2597   MDRV_K052109_ADD("k052109", glfgreat_k052109_intf)
2598   MDRV_K053245_ADD("k053245", prmrsocr_k05324x_intf)
2599   MDRV_K053936_ADD("k053936", prmrsocr_k053936_interface)
2600   MDRV_K053251_ADD("k053251")
2601
24152602   /* sound hardware */
24162603   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
24172604
r6740r6741
24372624   MDRV_CPU_PROGRAM_MAP(ssriders_audio_map)
24382625                        /* NMIs are generated by the 053260 */
24392626
2440   MDRV_NVRAM_HANDLER(eeprom)
2627   MDRV_EEPROM_NODEFAULT_ADD("eeprom", eeprom_intf)
24412628
24422629   /* video hardware */
24432630   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_AFTER_VBLANK)
r6740r6741
24542641   MDRV_VIDEO_START(lgtnfght)
24552642   MDRV_VIDEO_UPDATE(tmnt2)
24562643
2644   MDRV_K052109_ADD("k052109", tmnt_k052109_intf)
2645   MDRV_K053245_ADD("k053245", lgtnfght_k05324x_intf)
2646   MDRV_K053251_ADD("k053251")
2647
24572648   /* sound hardware */
24582649   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
24592650
r6740r6741
24782669   MDRV_CPU_PROGRAM_MAP(ssriders_audio_map)
24792670                        /* NMIs are generated by the 053260 */
24802671
2481   MDRV_NVRAM_HANDLER(eeprom)
2672   MDRV_EEPROM_NODEFAULT_ADD("eeprom", eeprom_intf)
24822673
24832674   /* video hardware */
24842675   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_AFTER_VBLANK)
r6740r6741
24952686   MDRV_VIDEO_START(lgtnfght)
24962687   MDRV_VIDEO_UPDATE(tmnt2)
24972688
2689   MDRV_K052109_ADD("k052109", tmnt_k052109_intf)
2690   MDRV_K053245_ADD("k053245", lgtnfght_k05324x_intf)
2691   MDRV_K053251_ADD("k053251")
2692
24982693   /* sound hardware */
24992694   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
25002695
r6740r6741
25152710   MDRV_CPU_PROGRAM_MAP(sunsetbl_main_map)
25162711   MDRV_CPU_VBLANK_INT("screen", irq4_line_hold)
25172712
2518   MDRV_NVRAM_HANDLER(eeprom)
2713   MDRV_EEPROM_NODEFAULT_ADD("eeprom", eeprom_intf)
25192714
25202715   /* video hardware */
25212716   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_AFTER_VBLANK)
r6740r6741
25292724
25302725   MDRV_PALETTE_LENGTH(2048)
25312726
2532   MDRV_VIDEO_START(sunsetbl)
2727   MDRV_K052109_ADD("k052109", sunsetbl_k052109_intf)
2728   MDRV_K053245_ADD("k053245", lgtnfght_k05324x_intf)
2729   MDRV_K053251_ADD("k053251")
2730
25332731   MDRV_VIDEO_UPDATE(tmnt2)
25342732
25352733   /* sound hardware */
r6740r6741
25522750   MDRV_CPU_PROGRAM_MAP(thndrx2_audio_map)
25532751                        /* NMIs are generated by the 053260 */
25542752
2555   MDRV_NVRAM_HANDLER(thndrx2)
2753   MDRV_EEPROM_NODEFAULT_ADD("eeprom", thndrx2_eeprom_intf)
25562754
25572755   /* video hardware */
25582756   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS)
r6740r6741
25662764
25672765   MDRV_PALETTE_LENGTH(2048)
25682766
2569   MDRV_VIDEO_START(thndrx2)
25702767   MDRV_VIDEO_UPDATE(thndrx2)
25712768
2769   MDRV_K052109_ADD("k052109", tmnt_k052109_intf)
2770   MDRV_K051960_ADD("k051960", thndrx2_k051960_intf)
2771   MDRV_K053251_ADD("k053251")
2772   MDRV_K054000_ADD("k054000")
2773
25722774   /* sound hardware */
25732775   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
25742776
r6740r6741
36903892   ROM_LOAD( "101a06.1d",    0x0000, 0x200000, CRC(4f48e043) SHA1(f50e8642d9d3a028c243777640e7cd13da1abf86) )
36913893ROM_END
36923894
3693static DRIVER_INIT( gfx )
3694{
3695   konami_rom_deinterleave_2(machine, "gfx1");
3696   konami_rom_deinterleave_2(machine, "gfx2");
3697}
36983895
36993896static DRIVER_INIT( mia )
37003897{
r6740r6741
37043901   int bits[32];
37053902   UINT8 *temp;
37063903
3707
3708   DRIVER_INIT_CALL(gfx);
3709
37103904   /*
37113905        along with the normal byte reordering, TMNT also needs the bits to
37123906        be shuffled around because the ROMs are connected differently to the
r6740r6741
38003994   int bits[32];
38013995   UINT8 *temp;
38023996
3803
3804   DRIVER_INIT_CALL(gfx);
3805
38063997   /*
38073998        along with the normal byte reordering, TMNT also needs the bits to
38083999        be shuffled around because the ROMs are connected differently to the
r6740r6741
39004091   free(temp);
39014092}
39024093
3903static void shuffle(UINT8 *buf,int len)
3904{
3905   int i;
3906   UINT8 t;
3907
3908   if (len == 2) return;
3909
3910   if (len % 4) fatalerror("shuffle() - not modulo 4");   /* must not happen */
3911
3912   len /= 2;
3913
3914   for (i = 0;i < len/2;i++)
3915   {
3916      t = buf[len/2 + i];
3917      buf[len/2 + i] = buf[len + i];
3918      buf[len + i] = t;
3919   }
3920
3921   shuffle(buf,len);
3922   shuffle(buf + len,len);
3923}
3924
3925static DRIVER_INIT( glfgreat )
3926{
3927   /* ROMs are interleaved at byte level */
3928   shuffle(memory_region(machine, "gfx1"),memory_region_length(machine, "gfx1"));
3929   shuffle(memory_region(machine, "gfx2"),memory_region_length(machine, "gfx2"));
3930}
3931
39324094static DRIVER_INIT( cuebrick )
39334095{
39344096   machine->generic.nvram.u8 = (UINT8 *)cuebrick_nvram;
39354097   machine->generic.nvram_size = 0x400*0x20;
3936
3937   /* ROMs are interleaved at byte level */
3938   shuffle(memory_region(machine, "gfx1"),memory_region_length(machine, "gfx1"));
3939   shuffle(memory_region(machine, "gfx2"),memory_region_length(machine, "gfx2"));
39404098}
39414099
39424100GAME( 1989, cuebrick, 0,        cuebrick, cuebrick, cuebrick, ROT0,  "Konami", "Cue Brick (World version D)", 0 )
r6740r6741
39544112GAME( 1990, tmnt2pj,  tmnt,     tmnt,     tmnt2p,   tmnt,     ROT0,  "Konami", "Teenage Mutant Ninja Turtles (Japan 2 Players)", 0 )
39554113GAME( 1989, tmnt2po,  tmnt,     tmnt,     tmnt2p,   tmnt,     ROT0,  "Konami", "Teenage Mutant Ninja Turtles (Oceania 2 Players)", 0 )
39564114
3957GAME( 1990, punkshot, 0,        punkshot, punkshot, gfx,      ROT0,  "Konami", "Punk Shot (US 4 Players)", 0 )
3958GAME( 1990, punkshot2,punkshot, punkshot, punksht2, gfx,      ROT0,  "Konami", "Punk Shot (US 2 Players)", 0 )
3959GAME( 1990, punkshotj,punkshot, punkshot, punksht2, gfx,      ROT0,  "Konami", "Punk Shot (Japan 2 Players)", 0 )
4115GAME( 1990, punkshot, 0,        punkshot, punkshot, 0,      ROT0,  "Konami", "Punk Shot (US 4 Players)", 0 )
4116GAME( 1990, punkshot2,punkshot, punkshot, punksht2, 0,      ROT0,  "Konami", "Punk Shot (US 2 Players)", 0 )
4117GAME( 1990, punkshotj,punkshot, punkshot, punksht2, 0,      ROT0,  "Konami", "Punk Shot (Japan 2 Players)", 0 )
39604118
3961GAME( 1990, lgtnfght, 0,        lgtnfght, lgtnfght, gfx,      ROT90, "Konami", "Lightning Fighters (World)", 0 )
3962GAME( 1990, lgtnfghta,lgtnfght, lgtnfght, lgtnfght, gfx,      ROT90, "Konami", "Lightning Fighters (Asia)", 0 )
3963GAME( 1990, lgtnfghtu,lgtnfght, lgtnfght, lgtnfght, gfx,      ROT90, "Konami", "Lightning Fighters (US)", 0 )
3964GAME( 1990, trigon,   lgtnfght, lgtnfght, lgtnfght, gfx,      ROT90, "Konami", "Trigon (Japan)", 0 )
4119GAME( 1990, lgtnfght, 0,        lgtnfght, lgtnfght, 0,      ROT90, "Konami", "Lightning Fighters (World)", 0 )
4120GAME( 1990, lgtnfghta,lgtnfght, lgtnfght, lgtnfght, 0,      ROT90, "Konami", "Lightning Fighters (Asia)", 0 )
4121GAME( 1990, lgtnfghtu,lgtnfght, lgtnfght, lgtnfght, 0,      ROT90, "Konami", "Lightning Fighters (US)", 0 )
4122GAME( 1990, trigon,   lgtnfght, lgtnfght, lgtnfght, 0,      ROT90, "Konami", "Trigon (Japan)", 0 )
39654123
3966GAME( 1991, blswhstl, 0,        blswhstl, blswhstl, gfx,      ROT90, "Konami", "Bells & Whistles (Version L)", 0 )
3967GAME( 1991, detatwin, blswhstl, blswhstl, blswhstl, gfx,      ROT90, "Konami", "Detana!! Twin Bee (Japan ver. J)", 0 )
4124GAME( 1991, blswhstl, 0,        blswhstl, blswhstl, 0,      ROT90, "Konami", "Bells & Whistles (Version L)", 0 )
4125GAME( 1991, detatwin, blswhstl, blswhstl, blswhstl, 0,      ROT90, "Konami", "Detana!! Twin Bee (Japan ver. J)", 0 )
39684126
3969GAME( 1991, glfgreat, 0,        glfgreat, glfgreat, glfgreat, ROT0,  "Konami", "Golfing Greats", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
3970GAME( 1991, glfgreatj,glfgreat, glfgreat, glfgreat, glfgreat, ROT0,  "Konami", "Golfing Greats (Japan)", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4127GAME( 1991, glfgreat, 0,        glfgreat, glfgreat, 0, ROT0,  "Konami", "Golfing Greats", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4128GAME( 1991, glfgreatj,glfgreat, glfgreat, glfgreat, 0, ROT0,  "Konami", "Golfing Greats (Japan)", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
39714129
3972GAME( 1991, tmnt2,    0,        tmnt2,    ssridr4p, gfx,      ROT0,  "Konami", "Teenage Mutant Ninja Turtles - Turtles in Time (4 Players ver UAA)", 0 ) // ver. UAA
3973GAME( 1991, tmnt2a,   tmnt2,    tmnt2,    ssrid4ps, gfx,      ROT0,  "Konami", "Teenage Mutant Ninja Turtles - Turtles in Time (4 Players ver ADA)", 0 ) // ver. ADA
3974GAME( 1991, tmht22pe, tmnt2,    tmnt2,    ssriders, gfx,      ROT0,  "Konami", "Teenage Mutant Hero Turtles - Turtles in Time (2 Players ver EBA)",  0 ) // ver. EBA
3975GAME( 1991, tmnt22pu, tmnt2,    tmnt2,    ssriders, gfx,      ROT0,  "Konami", "Teenage Mutant Ninja Turtles - Turtles in Time (2 Players ver UDA)", 0 ) // ver. UDA
4130GAME( 1991, tmnt2,    0,        tmnt2,    ssridr4p, 0,      ROT0,  "Konami", "Teenage Mutant Ninja Turtles - Turtles in Time (4 Players ver UAA)", 0 ) // ver. UAA
4131GAME( 1991, tmnt2a,   tmnt2,    tmnt2,    ssrid4ps, 0,      ROT0,  "Konami", "Teenage Mutant Ninja Turtles - Turtles in Time (4 Players ver ADA)", 0 ) // ver. ADA
4132GAME( 1991, tmht22pe, tmnt2,    tmnt2,    ssriders, 0,      ROT0,  "Konami", "Teenage Mutant Hero Turtles - Turtles in Time (2 Players ver EBA)",  0 ) // ver. EBA
4133GAME( 1991, tmnt22pu, tmnt2,    tmnt2,    ssriders, 0,      ROT0,  "Konami", "Teenage Mutant Ninja Turtles - Turtles in Time (2 Players ver UDA)", 0 ) // ver. UDA
39764134
3977GAME( 1993, qgakumon, 0,        tmnt2,    qgakumon, gfx,      ROT0,  "Konami", "Quiz Gakumon no Susume (Japan ver. JA2 Type L)", 0 )
4135GAME( 1993, qgakumon, 0,        tmnt2,    qgakumon, 0,      ROT0,  "Konami", "Quiz Gakumon no Susume (Japan ver. JA2 Type L)", 0 )
39784136
3979GAME( 1991, ssriders,    0,        ssriders, ssridr4p, gfx,      ROT0,  "Konami", "Sunset Riders (4 Players ver EAC)", GAME_IMPERFECT_GRAPHICS )
3980GAME( 1991, ssridersebd, ssriders, ssriders, ssriders, gfx,      ROT0,  "Konami", "Sunset Riders (2 Players ver EBD)", GAME_IMPERFECT_GRAPHICS )
3981GAME( 1991, ssridersebc, ssriders, ssriders, ssriders, gfx,      ROT0,  "Konami", "Sunset Riders (2 Players ver EBC)", GAME_IMPERFECT_GRAPHICS )
3982GAME( 1991, ssridersuda, ssriders, ssriders, ssrid4ps, gfx,      ROT0,  "Konami", "Sunset Riders (4 Players ver UDA)", GAME_IMPERFECT_GRAPHICS )
3983GAME( 1991, ssriderseaa, ssriders, ssriders, ssrid4ps, gfx,      ROT0,  "Konami", "Sunset Riders (4 Players ver EAA)", GAME_IMPERFECT_GRAPHICS )
3984GAME( 1991, ssridersuac, ssriders, ssriders, ssridr4p, gfx,      ROT0,  "Konami", "Sunset Riders (4 Players ver UAC)", GAME_IMPERFECT_GRAPHICS )
3985GAME( 1991, ssridersubc, ssriders, ssriders, ssriders, gfx,      ROT0,  "Konami", "Sunset Riders (2 Players ver UBC)", GAME_IMPERFECT_GRAPHICS )
3986GAME( 1991, ssridersabd, ssriders, ssriders, ssriders, gfx,      ROT0,  "Konami", "Sunset Riders (2 Players ver ABD)", GAME_IMPERFECT_GRAPHICS )
3987GAME( 1991, ssridersadd, ssriders, ssriders, ssrid4ps, gfx,      ROT0,  "Konami", "Sunset Riders (4 Players ver ADD)", GAME_IMPERFECT_GRAPHICS )
3988GAME( 1991, ssridersjbd, ssriders, ssriders, ssriders, gfx,      ROT0,  "Konami", "Sunset Riders (2 Players ver JBD)", GAME_IMPERFECT_GRAPHICS )
3989GAME( 1991, ssridersb,   ssriders, sunsetbl, sunsetbl, gfx,      ROT0,  "Konami", "Sunset Riders (bootleg 4 Players ver ADD)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS )
4137GAME( 1991, ssriders,    0,        ssriders, ssridr4p, 0,      ROT0,  "Konami", "Sunset Riders (4 Players ver EAC)", GAME_IMPERFECT_GRAPHICS )
4138GAME( 1991, ssridersebd, ssriders, ssriders, ssriders, 0,      ROT0,  "Konami", "Sunset Riders (2 Players ver EBD)", GAME_IMPERFECT_GRAPHICS )
4139GAME( 1991, ssridersebc, ssriders, ssriders, ssriders, 0,      ROT0,  "Konami", "Sunset Riders (2 Players ver EBC)", GAME_IMPERFECT_GRAPHICS )
4140GAME( 1991, ssridersuda, ssriders, ssriders, ssrid4ps, 0,      ROT0,  "Konami", "Sunset Riders (4 Players ver UDA)", GAME_IMPERFECT_GRAPHICS )
4141GAME( 1991, ssriderseaa, ssriders, ssriders, ssrid4ps, 0,      ROT0,  "Konami", "Sunset Riders (4 Players ver EAA)", GAME_IMPERFECT_GRAPHICS )
4142GAME( 1991, ssridersuac, ssriders, ssriders, ssridr4p, 0,      ROT0,  "Konami", "Sunset Riders (4 Players ver UAC)", GAME_IMPERFECT_GRAPHICS )
4143GAME( 1991, ssridersubc, ssriders, ssriders, ssriders, 0,      ROT0,  "Konami", "Sunset Riders (2 Players ver UBC)", GAME_IMPERFECT_GRAPHICS )
4144GAME( 1991, ssridersabd, ssriders, ssriders, ssriders, 0,      ROT0,  "Konami", "Sunset Riders (2 Players ver ABD)", GAME_IMPERFECT_GRAPHICS )
4145GAME( 1991, ssridersadd, ssriders, ssriders, ssrid4ps, 0,      ROT0,  "Konami", "Sunset Riders (4 Players ver ADD)", GAME_IMPERFECT_GRAPHICS )
4146GAME( 1991, ssridersjbd, ssriders, ssriders, ssriders, 0,      ROT0,  "Konami", "Sunset Riders (2 Players ver JBD)", GAME_IMPERFECT_GRAPHICS )
4147GAME( 1991, ssridersb,   ssriders, sunsetbl, sunsetbl, 0,      ROT0,  "Konami", "Sunset Riders (bootleg 4 Players ver ADD)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS )
39904148
3991GAME( 1991, thndrx2,  0,        thndrx2,  thndrx2,  gfx,      ROT0,  "Konami", "Thunder Cross II (World)", 0 )
3992GAME( 1991, thndrx2a, thndrx2,  thndrx2,  thndrx2,  gfx,      ROT0,  "Konami", "Thunder Cross II (Asia)", 0 )
3993GAME( 1991, thndrx2j, thndrx2,  thndrx2,  thndrx2,  gfx,      ROT0,  "Konami", "Thunder Cross II (Japan)", 0 )
4149GAME( 1991, thndrx2,  0,        thndrx2,  thndrx2,  0,      ROT0,  "Konami", "Thunder Cross II (World)", 0 )
4150GAME( 1991, thndrx2a, thndrx2,  thndrx2,  thndrx2,  0,      ROT0,  "Konami", "Thunder Cross II (Asia)", 0 )
4151GAME( 1991, thndrx2j, thndrx2,  thndrx2,  thndrx2,  0,      ROT0,  "Konami", "Thunder Cross II (Japan)", 0 )
39944152
3995GAME( 1993, prmrsocr, 0,        prmrsocr, prmrsocr, glfgreat, ROT0,  "Konami", "Premier Soccer (ver EAB)", 0 )
3996GAME( 1993, prmrsocrj,prmrsocr, prmrsocr, prmrsocr, glfgreat, ROT0,  "Konami", "Premier Soccer (ver JAB)", 0 )
4153GAME( 1993, prmrsocr, 0,        prmrsocr, prmrsocr, 0, ROT0,  "Konami", "Premier Soccer (ver EAB)", 0 )
4154GAME( 1993, prmrsocrj,prmrsocr, prmrsocr, prmrsocr, 0, ROT0,  "Konami", "Premier Soccer (ver JAB)", 0 )
src/mame/drivers/mogura.c
r6740r6741
33#include "driver.h"
44#include "cpu/z80/z80.h"
55#include "sound/dac.h"
6#include "konamipt.h"
6#include "includes/konamipt.h"
77
88static UINT8 *mogura_tileram;
99static UINT8* mogura_gfxram;
src/mame/drivers/taitojc.c
r6740r6741
352352#include "driver.h"
353353#include "cpu/tms32051/tms32051.h"
354354#include "cpu/m68000/m68000.h"
355#include "taito_f3.h"
355#include "includes/taito_f3.h"
356356#include "cpu/mc68hc11/mc68hc11.h"
357357#include "sound/es5506.h"
358358#include "machine/eepromdev.h"
r6740r6741
12981298   memset(projection_data, 0, sizeof(projection_data));
12991299   memset(intersection_data, 0, sizeof(intersection_data));
13001300
1301   taito_f3_soundsystem_reset(machine);
1302
1303   f3_68681_reset(machine);
1304
13051301   // hold the TMS in reset until we have code
13061302   cputag_set_input_line(machine, "dsp", INPUT_LINE_RESET, ASSERT_LINE);
13071303}
r6740r6741
13291325   MDRV_CPU_VBLANK_INT("screen", taitojc_vblank)
13301326   MDRV_CPU_PERIODIC_INT(taitojc_int6, 1000)
13311327
1332   TAITO_F3_SOUND_SYSTEM_CPU(16000000)
1333
13341328   MDRV_CPU_ADD("sub", MC68HC11, 4000000) //MC68HC11M0
13351329   MDRV_CPU_PROGRAM_MAP(hc11_pgm_map)
13361330   MDRV_CPU_IO_MAP(hc11_io_map)
r6740r6741
13581352   MDRV_VIDEO_UPDATE(taitojc)
13591353
13601354   /* sound hardware */
1361   TAITO_F3_SOUND_SYSTEM_ES5505(30476100/2)
1355   MDRV_IMPORT_FROM(taito_f3_sound)
13621356MACHINE_DRIVER_END
13631357
13641358static DRIVER_INIT( taitojc )
src/mame/drivers/berzerk.c
r6740r6741
1010
1111#include "driver.h"
1212#include "cpu/z80/z80.h"
13#include "exidy.h"
13#include "includes/exidy.h"
1414#include "machine/74181.h"
1515#include "sound/s14001a.h"
1616#include "video/resnet.h"
src/mame/drivers/suprridr.c
r6740r6741
8181
8282#include "driver.h"
8383#include "cpu/z80/z80.h"
84#include "suprridr.h"
84#include "includes/suprridr.h"
8585#include "sound/ay8910.h"
8686
8787static UINT8 nmi_enable;
src/mame/drivers/spy.c
r6740r6741
2020#include "driver.h"
2121#include "cpu/z80/z80.h"
2222#include "cpu/m6809/m6809.h"
23#include "video/konamiic.h"
23#include "video/konicdev.h"
2424#include "sound/3812intf.h"
2525#include "sound/k007232.h"
26#include "konamipt.h"
26#include "includes/konamipt.h"
2727
2828VIDEO_START( spy );
2929VIDEO_UPDATE( spy );
3030
3131static UINT8 *pmcram;
3232
33extern void spy_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
34extern void spy_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask,int *shadow);
3335
36
3437static INTERRUPT_GEN( spy_interrupt )
3538{
36   if (K052109_is_IRQ_enabled())
39   const device_config *k052109 = devtag_get_device(device->machine, "k052109");
40   if (k052109_is_irq_enabled(k052109))
3741      cpu_set_input_line(device, 0, HOLD_LINE);
3842}
3943
r6740r6741
248252
249253static WRITE8_HANDLER( spy_3f90_w )
250254{
255   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
251256   extern int spy_video_enable;
252257   static int old;
253258
r6740r6741
290295    ********************************************************************/
291296
292297   /* bits 0/1 = coin counters */
293   coin_counter_w(space->machine, 0,data & 0x01);
294   coin_counter_w(space->machine, 1,data & 0x02);
298   coin_counter_w(space->machine, 0, data & 0x01);
299   coin_counter_w(space->machine, 1, data & 0x02);
295300
296301   /* bit 2 = enable char ROM reading through the video RAM */
297   K052109_set_RMRD_line((data & 0x04) ? ASSERT_LINE : CLEAR_LINE);
302   k052109_set_rmrd_line(k052109, (data & 0x04) ? ASSERT_LINE : CLEAR_LINE);
298303
299304   /* bit 3 = disable video */
300305   spy_video_enable = ~(data & 0x08);
r6740r6741
351356
352357
353358
359static READ8_HANDLER( k052109_051960_r )
360{
361   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
362   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
363
364   if (k052109_get_rmrd_line(k052109) == CLEAR_LINE)
365   {
366      if (offset >= 0x3800 && offset < 0x3808)
367         return k051937_r(k051960, offset - 0x3800);
368      else if (offset < 0x3c00)
369         return k052109_r(k052109, offset);
370      else
371         return k051960_r(k051960, offset - 0x3c00);
372   }
373   else
374      return k052109_r(k052109, offset);
375}
376
377static WRITE8_HANDLER( k052109_051960_w )
378{
379   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
380   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
381
382   if (offset >= 0x3800 && offset < 0x3808)
383      k051937_w(k051960, offset - 0x3800, data);
384   else if (offset < 0x3c00)
385      k052109_w(k052109, offset, data);
386   else
387      k051960_w(k051960, offset - 0x3c00, data);
388}
389
354390static ADDRESS_MAP_START( spy_map, ADDRESS_SPACE_PROGRAM, 8 )
355391   AM_RANGE(0x0000, 0x07ff) AM_READWRITE(spy_bankedram1_r,spy_bankedram1_w) AM_BASE(&ram)
356392   AM_RANGE(0x0800, 0x1aff) AM_RAM
r6740r6741
364400   AM_RANGE(0x3fd2, 0x3fd2) AM_READ_PORT("P2")
365401   AM_RANGE(0x3fd3, 0x3fd3) AM_READ_PORT("DSW1")
366402   AM_RANGE(0x3fe0, 0x3fe0) AM_READ_PORT("DSW2")
367   AM_RANGE(0x2000, 0x5fff) AM_READWRITE(K052109_051960_r,K052109_051960_w)
403   AM_RANGE(0x2000, 0x5fff) AM_READWRITE(k052109_051960_r, k052109_051960_w)
368404   AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank1")
369405   AM_RANGE(0x8000, 0xffff) AM_ROM
370406ADDRESS_MAP_END
r6740r6741
373409   AM_RANGE(0x0000, 0x7fff) AM_ROM
374410   AM_RANGE(0x8000, 0x87ff) AM_RAM
375411   AM_RANGE(0x9000, 0x9000) AM_WRITE(sound_bank_w)
376   AM_RANGE(0xa000, 0xa00d) AM_DEVREADWRITE("konami1", k007232_r,k007232_w)
377   AM_RANGE(0xb000, 0xb00d) AM_DEVREADWRITE("konami2", k007232_r,k007232_w)
412   AM_RANGE(0xa000, 0xa00d) AM_DEVREADWRITE("konami1", k007232_r, k007232_w)
413   AM_RANGE(0xb000, 0xb00d) AM_DEVREADWRITE("konami2", k007232_r, k007232_w)
378414   AM_RANGE(0xc000, 0xc001) AM_DEVREADWRITE("ymsnd", ym3812_r,ym3812_w)
379415   AM_RANGE(0xd000, 0xd000) AM_READ(soundlatch_r)
380416ADDRESS_MAP_END
r6740r6741
468504
469505
470506
507static const k052109_interface spy_k052109_intf =
508{
509   "gfx1", 0,
510   NORMAL_PLANE_ORDER,
511   KONAMI_ROM_DEINTERLEAVE_2,
512   spy_tile_callback
513};
514
515static const k051960_interface spy_k051960_intf =
516{
517   "gfx2", 1,
518   NORMAL_PLANE_ORDER,
519   KONAMI_ROM_DEINTERLEAVE_2,
520   spy_sprite_callback
521};
522
471523static MACHINE_DRIVER_START( spy )
472524
473525   /* basic machine hardware */
r6740r6741
494546   MDRV_VIDEO_START(spy)
495547   MDRV_VIDEO_UPDATE(spy)
496548
549   MDRV_K052109_ADD("k052109", spy_k052109_intf)
550   MDRV_K051960_ADD("k051960", spy_k051960_intf)
551
497552   /* sound hardware */
498553   MDRV_SPEAKER_STANDARD_MONO("mono")
499554
r6740r6741
574629ROM_END
575630
576631
577
578static void gfx_untangle(running_machine *machine)
579{
580   konami_rom_deinterleave_2(machine, "gfx1");
581   konami_rom_deinterleave_2(machine, "gfx2");
582}
583
584632static DRIVER_INIT( spy )
585633{
586634   machine->generic.paletteram.u8 = &memory_region(machine, "maincpu")[0x28000];
587   pmcram =     &memory_region(machine, "maincpu")[0x28800];
588   gfx_untangle(machine);
635   pmcram = &memory_region(machine, "maincpu")[0x28800];
589636}
590637
591638
src/mame/drivers/psikyo.c
r6740r6741
6666#include "sound/2610intf.h"
6767#include "sound/ymf278b.h"
6868#include "sound/okim6295.h"
69#include "includes/psikyo.h"
6970
7071
71/* Variables defined in video */
72
73extern UINT32 *psikyo_vram_0, *psikyo_vram_1, *psikyo_vregs;
74extern int psikyo_ka302c_banking;
75extern UINT32* psikyo_bootleg_spritebuffer;
76
77/* Functions defined in video */
78
79WRITE32_HANDLER( psikyo_vram_0_w );
80WRITE32_HANDLER( psikyo_vram_1_w );
81
82VIDEO_START( psikyo );
83VIDEO_EOF( psikyo );
84VIDEO_UPDATE( psikyo );
85VIDEO_START( sngkace );
86VIDEO_UPDATE( psikyo_bootleg );
87
88extern void psikyo_switch_banks( int tmap, int bank );
89
90/* Variables only used here */
91
92static UINT8 psikyo_soundlatch;
93static int z80_nmi, mcu_status;
94
95static MACHINE_RESET( psikyo )
96{
97   z80_nmi = mcu_status = 0;
98}
99
100
10172/***************************************************************************
10273
10374
r6740r6741
10879
10980static CUSTOM_INPUT( z80_nmi_r )
11081{
82   psikyo_state *state = (psikyo_state *)field->port->machine->driver_data;
11183   int ret = 0x00;
11284
113   if (z80_nmi)
85   if (state->z80_nmi)
11486   {
11587      ret = 0x01;
11688
r6740r6741
12597
12698static CUSTOM_INPUT( mcu_status_r )
12799{
100   psikyo_state *state = (psikyo_state *)field->port->machine->driver_data;
128101   int ret = 0x00;
129102
130103   /* Don't know exactly what this bit is, but s1945 and tengai
r6740r6741
141114
142115        Interestingly, s1945jn has the code that spins on this bit,
143116        but said code is never reached.  Prototype? */
144   if (mcu_status)
117   if (state->mcu_status)
145118      ret = 0x01;
146119
147   mcu_status = !mcu_status;   /* hack */
120   state->mcu_status = !state->mcu_status;   /* hack */
148121
149122   return ret;
150123}
151124
152125static READ32_HANDLER( sngkace_input_r )
153126{
154   switch(offset)
127   switch (offset)
155128   {
156129      case 0x0:   return input_port_read(space->machine, "P1_P2");
157130      case 0x1:   return input_port_read(space->machine, "DSW");
158131      case 0x2:   return input_port_read(space->machine, "COIN");
159132      default:   logerror("PC %06X - Read input %02X !\n", cpu_get_pc(space->cpu), offset * 2);
160               return 0;
133            return 0;
161134   }
162135}
163136
164137static READ32_HANDLER( gunbird_input_r )
165138{
166   switch(offset)
139   switch (offset)
167140   {
168141      case 0x0:   return input_port_read(space->machine, "P1_P2");
169142      case 0x1:   return input_port_read(space->machine, "DSW");
170      default:   logerror("PC %06X - Read input %02X !\n", cpu_get_pc(space->cpu), offset*2);
171               return 0;
143      default:   logerror("PC %06X - Read input %02X !\n", cpu_get_pc(space->cpu), offset * 2);
144            return 0;
172145   }
173146}
174147
175148
176149static TIMER_CALLBACK( psikyo_soundlatch_callback )
177150{
178   psikyo_soundlatch = param;
179   cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, ASSERT_LINE);
180   z80_nmi = 1;
151   psikyo_state *state = (psikyo_state *)machine->driver_data;
152   state->soundlatch = param;
153   cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, ASSERT_LINE);
154   state->z80_nmi = 1;
181155}
182156
183157static WRITE32_HANDLER( psikyo_soundlatch_w )
r6740r6741
214188   0x00, 0x00, 0x32, 0x90, 0x00, 0x00, 0xac, 0x64, 0x00, 0x00, 0x2b, 0xc0
215189};
216190
217static UINT8 s1945_mcu_direction, s1945_mcu_latch1, s1945_mcu_latch2, s1945_mcu_inlatch, s1945_mcu_index;
218static UINT8 s1945_mcu_latching, s1945_mcu_mode, s1945_mcu_control, s1945_mcu_bctrl;
219static const UINT8 *s1945_mcu_table;
220
221static void s1945_mcu_init(const UINT8 *mcu_table)
222{
223   s1945_mcu_direction = 0x00;
224   s1945_mcu_inlatch = 0xff;
225   s1945_mcu_latch1 = 0xff;
226   s1945_mcu_latch2 = 0xff;
227   s1945_mcu_latching = 0x5;
228   s1945_mcu_control = 0xff;
229   s1945_mcu_index = 0;
230   s1945_mcu_mode = 0;
231   s1945_mcu_table = mcu_table;
232   s1945_mcu_bctrl = 0x00;
233}
234
235191static WRITE32_HANDLER( s1945_mcu_w )
236192{
193   psikyo_state *state = (psikyo_state *)space->machine->driver_data;
194
237195   // Accesses are always bytes, so resolve it
238196   int suboff;
239   for(suboff=0; suboff < 3; suboff++)
240      if((0xff << (8*suboff)) & mem_mask)
197
198   for (suboff = 0; suboff < 3; suboff++)
199      if ((0xff << (8 * suboff)) & mem_mask)
241200         break;
242   data >>= 8*suboff;
243   offset = offset*4+4+(3-suboff);
201   data >>= 8 * suboff;
202   offset = offset * 4 + 4 + (3 - suboff);
244203
245   switch(offset) {
204   switch (offset)
205   {
246206   case 0x06:
247      s1945_mcu_inlatch = data;
207      state->s1945_mcu_inlatch = data;
248208      break;
249209   case 0x08:
250      s1945_mcu_control = data;
210      state->s1945_mcu_control = data;
251211      break;
252212   case 0x09:
253      s1945_mcu_direction = data;
213      state->s1945_mcu_direction = data;
254214      break;
255215   case 0x07:
256      psikyo_switch_banks(1, (data >> 6) & 3);
257      psikyo_switch_banks(0, (data >> 4) & 3);
258      s1945_mcu_bctrl = data;
216      psikyo_switch_banks(space->machine, 1, (data >> 6) & 3);
217      psikyo_switch_banks(space->machine, 0, (data >> 4) & 3);
218      state->s1945_mcu_bctrl = data;
259219      break;
260220   case 0x0b:
261      switch(data | (s1945_mcu_direction ? 0x100 : 0)) {
221      switch (data | (state->s1945_mcu_direction ? 0x100 : 0))
222      {
262223      case 0x11c:
263         s1945_mcu_latching = 5;
264         s1945_mcu_index = s1945_mcu_inlatch;
224         state->s1945_mcu_latching = 5;
225         state->s1945_mcu_index = state->s1945_mcu_inlatch;
265226         break;
266227      case 0x013:
267//          logerror("MCU: Table read index %02x\n", s1945_mcu_index);
268         s1945_mcu_latching = 1;
269         s1945_mcu_latch1 = s1945_mcu_table[s1945_mcu_index];
228//          logerror("MCU: Table read index %02x\n", state->s1945_mcu_index);
229         state->s1945_mcu_latching = 1;
230         state->s1945_mcu_latch1 = state->s1945_mcu_table[state->s1945_mcu_index];
270231         break;
271232      case 0x113:
272         s1945_mcu_mode = s1945_mcu_inlatch;
273         if(s1945_mcu_mode == 1) {
274            s1945_mcu_latching &= ~1;
275            s1945_mcu_latch2 = 0x55;
276         } else {
233         state->s1945_mcu_mode = state->s1945_mcu_inlatch;
234         if (state->s1945_mcu_mode == 1)
235         {
236            state->s1945_mcu_latching &= ~1;
237            state->s1945_mcu_latch2 = 0x55;
238         }
239         else
240         {
277241            // Go figure.
278            s1945_mcu_latching &= ~1;
279            s1945_mcu_latching |= 2;
242            state->s1945_mcu_latching &= ~1;
243            state->s1945_mcu_latching |= 2;
280244         }
281         s1945_mcu_latching &= ~4;
282         s1945_mcu_latch1 = s1945_mcu_inlatch;
245         state->s1945_mcu_latching &= ~4;
246         state->s1945_mcu_latch1 = state->s1945_mcu_inlatch;
283247         break;
284248      case 0x010:
285249      case 0x110:
286         s1945_mcu_latching |= 4;
250         state->s1945_mcu_latching |= 4;
287251         break;
288252      default:
289//          logerror("MCU: function %02x, direction %02x, latch1 %02x, latch2 %02x (%x)\n", data, s1945_mcu_direction, s1945_mcu_latch1, s1945_mcu_latch2, cpu_get_pc(space->cpu));
253//          logerror("MCU: function %02x, direction %02x, latch1 %02x, latch2 %02x (%x)\n", data, state->s1945_mcu_direction, state->s1945_mcu_latch1, state->s1945_mcu_latch2, cpu_get_pc(space->cpu));
290254         break;
291255      }
292256      break;
r6740r6741
298262
299263static READ32_HANDLER( s1945_mcu_r )
300264{
301   switch(offset) {
302   case 0: {
265   psikyo_state *state = (psikyo_state *)space->machine->driver_data;
266
267   switch (offset)
268   {
269   case 0:
270      {
303271      UINT32 res;
304      if(s1945_mcu_control & 16) {
305         res = s1945_mcu_latching & 4 ? 0x0000ff00 : s1945_mcu_latch1 << 8;
306         s1945_mcu_latching |= 4;
307      } else {
308         res = s1945_mcu_latching & 1 ? 0x0000ff00 : s1945_mcu_latch2 << 8;
309         s1945_mcu_latching |= 1;
272      if (state->s1945_mcu_control & 16)
273      {
274         res = state->s1945_mcu_latching & 4 ? 0x0000ff00 : state->s1945_mcu_latch1 << 8;
275         state->s1945_mcu_latching |= 4;
310276      }
311      res |= s1945_mcu_bctrl & 0xf0;
277      else
278      {
279         res = state->s1945_mcu_latching & 1 ? 0x0000ff00 : state->s1945_mcu_latch2 << 8;
280         state->s1945_mcu_latching |= 1;
281      }
282      res |= state->s1945_mcu_bctrl & 0xf0;
312283      return res;
313284   }
314285   case 1:
315      return (s1945_mcu_latching << 24) | 0x08000000;
286      return (state->s1945_mcu_latching << 24) | 0x08000000;
316287   }
317288   return 0;
318289}
319290
320291static READ32_HANDLER( s1945_input_r )
321292{
322   switch(offset)
293   switch (offset)
323294   {
324295      case 0x0:   return input_port_read(space->machine, "P1_P2");
325      case 0x1:   return (input_port_read(space->machine, "DSW") & 0xffff000f) | s1945_mcu_r(space, offset-1, mem_mask);
326      case 0x2:   return s1945_mcu_r(space, offset-1, mem_mask);
327      default:   logerror("PC %06X - Read input %02X !\n", cpu_get_pc(space->cpu), offset*2);
296      case 0x1:   return (input_port_read(space->machine, "DSW") & 0xffff000f) | s1945_mcu_r(space, offset - 1, mem_mask);
297      case 0x2:   return s1945_mcu_r(space, offset - 1, mem_mask);
298      default:   logerror("PC %06X - Read input %02X !\n", cpu_get_pc(space->cpu), offset * 2);
328299               return 0;
329300   }
330301}
r6740r6741
341312static WRITE32_HANDLER( paletteram32_xRRRRRGGGGGBBBBB_dword_w )
342313{
343314   if (ACCESSING_BITS_16_31)
344      paletteram16_xRRRRRGGGGGBBBBB_word_w(space, offset*2, data >> 16, mem_mask >> 16);
315      paletteram16_xRRRRRGGGGGBBBBB_word_w(space, offset * 2, data >> 16, mem_mask >> 16);
345316   if (ACCESSING_BITS_0_15)
346      paletteram16_xRRRRRGGGGGBBBBB_word_w(space, offset*2+1, data, mem_mask);
317      paletteram16_xRRRRRGGGGGBBBBB_word_w(space, offset * 2 + 1, data, mem_mask);
347318}
348319
349320static ADDRESS_MAP_START( psikyo_map, ADDRESS_SPACE_PROGRAM, 32 )
350321   AM_RANGE(0x000000, 0x0fffff) AM_ROM                                          // ROM (not all used)
351322   AM_RANGE(0x400000, 0x401fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)      // Sprites, buffered by two frames (list buffered + fb buffered)
352323   AM_RANGE(0x600000, 0x601fff) AM_RAM_WRITE(paletteram32_xRRRRRGGGGGBBBBB_dword_w) AM_BASE_GENERIC(paletteram)   // Palette
353   AM_RANGE(0x800000, 0x801fff) AM_RAM_WRITE(psikyo_vram_0_w) AM_BASE(&psikyo_vram_0)      // Layer 0
354   AM_RANGE(0x802000, 0x803fff) AM_RAM_WRITE(psikyo_vram_1_w) AM_BASE(&psikyo_vram_1)      // Layer 1
355   AM_RANGE(0x804000, 0x807fff) AM_RAM AM_BASE(&psikyo_vregs)                        // RAM + Vregs
324   AM_RANGE(0x800000, 0x801fff) AM_RAM_WRITE(psikyo_vram_0_w) AM_BASE_MEMBER(psikyo_state, vram_0)      // Layer 0
325   AM_RANGE(0x802000, 0x803fff) AM_RAM_WRITE(psikyo_vram_1_w) AM_BASE_MEMBER(psikyo_state, vram_1)      // Layer 1
326   AM_RANGE(0x804000, 0x807fff) AM_RAM AM_BASE_MEMBER(psikyo_state, vregs)                     // RAM + Vregs
356327//  AM_RANGE(0xc00000, 0xc0000b) AM_READ(psikyo_input_r)                                    // Depends on board, see DRIVER_INIT
357328//  AM_RANGE(0xc00004, 0xc0000b) AM_WRITE(s1945_mcu_w)                                      // MCU on sh404, see DRIVER_INIT
358329//  AM_RANGE(0xc00010, 0xc00013) AM_WRITE(psikyo_soundlatch_w)                              // Depends on board, see DRIVER_INIT
r6740r6741
361332
362333READ32_DEVICE_HANDLER( s1945bl_oki_r )
363334{
364   UINT8 dat = okim6295_r(device,0);
335   UINT8 dat = okim6295_r(device, 0);
365336   return dat << 24;
366337}
367338
368339static WRITE32_DEVICE_HANDLER( s1945bl_oki_w )
369340{
370341   if (ACCESSING_BITS_24_31)
371   {
372      okim6295_w(device,0,data>>24);
373   }
342      okim6295_w(device, 0, data >> 24);
343
374344   if (ACCESSING_BITS_16_23)
375345   {
376346      // not at all sure about this, it seems to write 0 too often
377      UINT8 bank = (data & 0x00ff0000)>>16;
378      if (bank<4)
379         memory_set_bankptr(device->machine, "okibank", memory_region(device->machine,"oki")+0x30000+0x10000*bank);
347      UINT8 bank = (data & 0x00ff0000) >> 16;
348      if (bank < 4)
349         memory_set_bank(device->machine, "okibank", bank);
380350   }
351
381352   if (ACCESSING_BITS_8_15)
382   {
383      printf("ACCESSING_BITS_8_15 ?? %08x %08x\n",data&0x00ff0000,mem_mask);
384   }
353      printf("ACCESSING_BITS_8_15 ?? %08x %08x\n", data & 0x00ff0000, mem_mask);
354
385355   if (ACCESSING_BITS_0_7)
386   {
387      printf("ACCESSING_BITS_0_7 ?? %08x %08x\n",data&0x00ff0000,mem_mask);
388   }
356      printf("ACCESSING_BITS_0_7 ?? %08x %08x\n", data & 0x00ff0000, mem_mask);
389357}
390358
391359static ADDRESS_MAP_START( s1945bl_oki_map, 0, 8 )
r6740r6741
395363
396364static ADDRESS_MAP_START( psikyo_bootleg_map, ADDRESS_SPACE_PROGRAM, 32 )
397365   AM_RANGE(0x000000, 0x0fffff) AM_ROM                                          // ROM (not all used)
398   AM_RANGE(0x200000, 0x200fff) AM_RAM AM_BASE(&psikyo_bootleg_spritebuffer)            // RAM (it copies the spritelist here, the HW probably doesn't have automatic buffering like the originals?
366   AM_RANGE(0x200000, 0x200fff) AM_RAM AM_BASE_MEMBER(psikyo_state, bootleg_spritebuffer)            // RAM (it copies the spritelist here, the HW probably doesn't have automatic buffering like the originals?
399367
400368   AM_RANGE(0x400000, 0x401fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)      // Sprites, buffered by two frames (list buffered + fb buffered)
401369   AM_RANGE(0x600000, 0x601fff) AM_RAM_WRITE(paletteram32_xRRRRRGGGGGBBBBB_dword_w) AM_BASE_GENERIC(paletteram)   // Palette
402   AM_RANGE(0x800000, 0x801fff) AM_RAM_WRITE(psikyo_vram_0_w) AM_BASE(&psikyo_vram_0)      // Layer 0
403   AM_RANGE(0x802000, 0x803fff) AM_RAM_WRITE(psikyo_vram_1_w) AM_BASE(&psikyo_vram_1)      // Layer 1
404   AM_RANGE(0x804000, 0x807fff) AM_RAM AM_BASE(&psikyo_vregs)                        // RAM + Vregs
370   AM_RANGE(0x800000, 0x801fff) AM_RAM_WRITE(psikyo_vram_0_w) AM_BASE_MEMBER(psikyo_state, vram_0)      // Layer 0
371   AM_RANGE(0x802000, 0x803fff) AM_RAM_WRITE(psikyo_vram_1_w) AM_BASE_MEMBER(psikyo_state, vram_1)      // Layer 1
372   AM_RANGE(0x804000, 0x807fff) AM_RAM AM_BASE_MEMBER(psikyo_state, vregs)                        // RAM + Vregs
405373//  AM_RANGE(0xc00000, 0xc0000b) AM_READ(psikyo_input_r)                                    // Depends on board, see DRIVER_INIT
406374//  AM_RANGE(0xc00004, 0xc0000b) AM_WRITE(s1945_mcu_w)                                      // MCU on sh404, see DRIVER_INIT
407375//  AM_RANGE(0xc00010, 0xc00013) AM_WRITE(psikyo_soundlatch_w)                              // Depends on board, see DRIVER_INIT
r6740r6741
422390
423391static void sound_irq( const device_config *device, int irq )
424392{
425   cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE);
393   psikyo_state *state = (psikyo_state *)device->machine->driver_data;
394   cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE);
426395}
427396
428397static READ8_HANDLER( psikyo_soundlatch_r )
429398{
430   return psikyo_soundlatch;
399   psikyo_state *state = (psikyo_state *)space->machine->driver_data;
400   return state->soundlatch;
431401}
432402
433403static WRITE8_HANDLER( psikyo_clear_nmi_w )
434404{
435   cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, CLEAR_LINE);
436   z80_nmi = 0;
405   psikyo_state *state = (psikyo_state *)space->machine->driver_data;
406   cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, CLEAR_LINE);
407   state->z80_nmi = 0;
437408}
438409
439410
r6740r6741
443414
444415static WRITE8_HANDLER( sngkace_sound_bankswitch_w )
445416{
446   UINT8 *RAM = memory_region(space->machine, "audiocpu");
447   int bank = data & 3;
448   memory_set_bankptr(space->machine, "bank1", &RAM[bank * 0x8000 + 0x10000]);
417   memory_set_bank(space->machine, "bank1", data & 0x03);
449418}
450419
451420static ADDRESS_MAP_START( sngkace_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
r6740r6741
469438
470439static WRITE8_HANDLER( gunbird_sound_bankswitch_w )
471440{
472   UINT8 *RAM = memory_region(space->machine, "audiocpu");
473   int bank = (data >> 4) & 3;
474
475   /* The banked rom is seen at 8200-ffff, so the last 0x200 bytes
476       of the rom not reachable. */
477
478   memory_set_bankptr(space->machine, "bank1", &RAM[bank * 0x8000 + 0x10000 + 0x200]);
441   memory_set_bank(space->machine, "bank1", (data >> 4) & 0x03);
479442}
480443
481444static ADDRESS_MAP_START( gunbird_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
r6740r6741
513476
514477***************************************************************************/
515478
516#define PSIKYO_PORT_PLAYER1 \
517   PORT_BIT(  0x01000000, IP_ACTIVE_LOW, IPT_START1 ) \
518   PORT_BIT(  0x02000000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) \
519   PORT_BIT(  0x04000000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) \
520   PORT_BIT(  0x08000000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) \
521   PORT_BIT(  0x10000000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1) \
522   PORT_BIT(  0x20000000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1) \
523   PORT_BIT(  0x40000000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1) \
524   PORT_BIT(  0x80000000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
479static INPUT_PORTS_START( psikyo_common )
480   PORT_START("P1_P2")      /* c00000&1 */
481   PORT_BIT( 0x0000ffff, IP_ACTIVE_LOW, IPT_UNUSED )   // these depends by the games
482   PORT_BIT( 0x00010000, IP_ACTIVE_LOW, IPT_START2 )
483   PORT_BIT( 0x00020000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
484   PORT_BIT( 0x00040000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
485   PORT_BIT( 0x00080000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
486   PORT_BIT( 0x00100000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
487   PORT_BIT( 0x00200000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
488   PORT_BIT( 0x00400000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
489   PORT_BIT( 0x00800000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
490   PORT_BIT( 0x01000000, IP_ACTIVE_LOW, IPT_START1 )
491   PORT_BIT( 0x02000000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
492   PORT_BIT( 0x04000000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
493   PORT_BIT( 0x08000000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
494   PORT_BIT( 0x10000000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
495   PORT_BIT( 0x20000000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
496   PORT_BIT( 0x40000000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
497   PORT_BIT( 0x80000000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
525498
526#define PSIKYO_PORT_PLAYER2 \
527   PORT_BIT(  0x00010000, IP_ACTIVE_LOW, IPT_START2 ) \
528   PORT_BIT(  0x00020000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) \
529   PORT_BIT(  0x00040000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) \
530   PORT_BIT(  0x00080000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) \
531   PORT_BIT(  0x00100000, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2) \
532   PORT_BIT(  0x00200000, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2) \
533   PORT_BIT(  0x00400000, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2) \
534   PORT_BIT(  0x00800000, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
499   PORT_START("DSW")      /* c00004 -> c00007 */
500   PORT_BIT( 0x0000ffff, IP_ACTIVE_LOW, IPT_UNUSED )   // these depends by the games
501   PORT_DIPNAME( 0x00010000, 0x00010000, DEF_STR( Flip_Screen ) )
502   PORT_DIPSETTING(          0x00010000, DEF_STR( Off ) )
503   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
504   PORT_DIPNAME( 0x00020000, 0x00000000, DEF_STR( Demo_Sounds ) )
505   PORT_DIPSETTING(          0x00020000, DEF_STR( Off ) )
506   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
507   PORT_DIPNAME( 0x000c0000, 0x000c0000, DEF_STR( Difficulty ) )
508   PORT_DIPSETTING(          0x00080000, DEF_STR( Easy ) )
509   PORT_DIPSETTING(          0x000c0000, DEF_STR( Normal ) )
510   PORT_DIPSETTING(          0x00040000, DEF_STR( Hard ) )
511   PORT_DIPSETTING(          0x00000000, DEF_STR( Hardest ) )
512   PORT_DIPNAME( 0x00300000, 0x00300000, DEF_STR( Lives ) )
513   PORT_DIPSETTING(          0x00200000, "1" )
514   PORT_DIPSETTING(          0x00100000, "2" )
515   PORT_DIPSETTING(          0x00300000, "3" )
516   PORT_DIPSETTING(          0x00000000, "4" )
517   PORT_DIPNAME( 0x00400000, 0x00400000, DEF_STR( Bonus_Life ) )
518   PORT_DIPSETTING(          0x00400000, "400K" )
519   PORT_DIPSETTING(          0x00000000, "600K" )
520   PORT_SERVICE( 0x00800000, IP_ACTIVE_LOW )
521   PORT_DIPNAME( 0x01000000, 0x01000000, "Credits/Coinage" )   // [Free Play] on all for free play
522   PORT_DIPSETTING(          0x01000000, "A+B/A&B" )
523   PORT_DIPSETTING(          0x00000000, "A&B/A [Free Play]" )
524   PORT_DIPNAME( 0x0e000000, 0x0e000000, DEF_STR( Coin_A ) )
525   PORT_DIPSETTING(          0x0a000000, DEF_STR( 3C_1C ) )
526   PORT_DIPSETTING(          0x0c000000, DEF_STR( 2C_1C ) )
527   PORT_DIPSETTING(          0x0e000000, DEF_STR( 1C_1C ) )
528   PORT_DIPSETTING(          0x08000000, DEF_STR( 1C_2C ) )
529   PORT_DIPSETTING(          0x06000000, DEF_STR( 1C_3C ) )
530   PORT_DIPSETTING(          0x04000000, DEF_STR( 1C_4C ) )
531   PORT_DIPSETTING(          0x02000000, DEF_STR( 1C_5C ) )
532   PORT_DIPSETTING(          0x00000000, "1C 6C [Free Play]" )
533   PORT_DIPNAME( 0x70000000, 0x70000000, DEF_STR( Coin_B ) )
534   PORT_DIPSETTING(          0x50000000, DEF_STR( 3C_1C ) )
535   PORT_DIPSETTING(          0x60000000, DEF_STR( 2C_1C ) )
536   PORT_DIPSETTING(          0x70000000, DEF_STR( 1C_1C ) )
537   PORT_DIPSETTING(          0x40000000, DEF_STR( 1C_2C ) )
538   PORT_DIPSETTING(          0x30000000, DEF_STR( 1C_3C ) )
539   PORT_DIPSETTING(          0x20000000, DEF_STR( 1C_4C ) )
540   PORT_DIPSETTING(          0x10000000, DEF_STR( 1C_5C ) )
541   PORT_DIPSETTING(          0x00000000, "1C 6C [Free Play]" )
542   PORT_DIPNAME( 0x80000000, 0x80000000, "2C Start, 1C Continue" )
543   PORT_DIPSETTING(          0x80000000, DEF_STR( Off ) )
544   PORT_DIPSETTING(          0x00000000, "On [Free Play]" ) // Forces 1C_1C
545INPUT_PORTS_END
535546
536547
537548
r6740r6741
540551***************************************************************************/
541552
542553static INPUT_PORTS_START( samuraia )
543   PORT_START("P1_P2")      /* c00000&1 */
544   PORT_BIT( 0x0000ffff, IP_ACTIVE_LOW, IPT_UNUSED )
545   PSIKYO_PORT_PLAYER2
546   PSIKYO_PORT_PLAYER1
554   PORT_INCLUDE(psikyo_common)
547555
548556   PORT_START("COIN")
549557   PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_VBLANK  )   // vblank
r6740r6741
571579   PORT_SERVICE_NO_TOGGLE( 0x00200000, IP_ACTIVE_LOW )
572580   PORT_BIT( 0x00400000, IP_ACTIVE_LOW, IPT_TILT )
573581   PORT_BIT( 0x00800000, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(z80_nmi_r, NULL)   // From Sound CPU
574   PORT_BIT( 0x01000000, IP_ACTIVE_LOW, IPT_UNKNOWN )   // unused?
575   PORT_BIT( 0x02000000, IP_ACTIVE_LOW, IPT_UNKNOWN )
576   PORT_BIT( 0x04000000, IP_ACTIVE_LOW, IPT_UNKNOWN )
577   PORT_BIT( 0x08000000, IP_ACTIVE_LOW, IPT_UNKNOWN )
578   PORT_BIT( 0x10000000, IP_ACTIVE_LOW, IPT_UNKNOWN )
579   PORT_BIT( 0x20000000, IP_ACTIVE_LOW, IPT_UNKNOWN )
580   PORT_BIT( 0x40000000, IP_ACTIVE_LOW, IPT_UNKNOWN )
581   PORT_BIT( 0x80000000, IP_ACTIVE_LOW, IPT_UNKNOWN )
582   PORT_BIT( 0xff000000, IP_ACTIVE_LOW, IPT_UNKNOWN )   // unused?
582583
583   PORT_START("DSW")      /* c00004 -> c00007 */
584   PORT_MODIFY("DSW")      /* c00004 -> c00007 */
584585   /***********************************************
585586
586587    This Dip port is bit based:
r6740r6741
600601   PORT_DIPSETTING(          0x000000df, "Korea" )
601602   PORT_DIPSETTING(          0x000000bf, "Hong Kong" )
602603   PORT_DIPSETTING(          0x0000007f, "Taiwan" )
603   PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_UNKNOWN )   // unused?
604   PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_UNKNOWN )
605   PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_UNKNOWN )
606   PORT_BIT( 0x00000800, IP_ACTIVE_LOW, IPT_UNKNOWN )
607   PORT_BIT( 0x00001000, IP_ACTIVE_LOW, IPT_UNKNOWN )
608   PORT_BIT( 0x00002000, IP_ACTIVE_LOW, IPT_UNKNOWN )
609   PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN )
610   PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN )
611
612   PORT_DIPNAME( 0x00010000, 0x00010000, DEF_STR( Flip_Screen ) )
613   PORT_DIPSETTING(          0x00010000, DEF_STR( Off ) )
614   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
615   PORT_DIPNAME( 0x00020000, 0x00000000, DEF_STR( Demo_Sounds ) )
616   PORT_DIPSETTING(          0x00020000, DEF_STR( Off ) )
617   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
618   PORT_DIPNAME( 0x000c0000, 0x000c0000, DEF_STR( Difficulty ) )
619   PORT_DIPSETTING(          0x00080000, DEF_STR( Easy ) )
620   PORT_DIPSETTING(          0x000c0000, DEF_STR( Normal ) )
621   PORT_DIPSETTING(          0x00040000, DEF_STR( Hard ) )
622   PORT_DIPSETTING(          0x00000000, DEF_STR( Hardest ) )
623   PORT_DIPNAME( 0x00300000, 0x00300000, DEF_STR( Lives ) )
624   PORT_DIPSETTING(          0x00200000, "1" )
625   PORT_DIPSETTING(          0x00100000, "2" )
626   PORT_DIPSETTING(          0x00300000, "3" )
627   PORT_DIPSETTING(          0x00000000, "4" )
628   PORT_DIPNAME( 0x00400000, 0x00400000, DEF_STR( Bonus_Life ) )
629   PORT_DIPSETTING(          0x00400000, "400K" )
630   PORT_DIPSETTING(          0x00000000, "600K" )
631   PORT_SERVICE( 0x00800000, IP_ACTIVE_LOW )
632   PORT_DIPNAME( 0x01000000, 0x01000000, "Credits/Coinage" )   // [Free Play] on all for free play
633   PORT_DIPSETTING(          0x01000000, "A+B/A&B" )
634   PORT_DIPSETTING(          0x00000000, "A&B/A [Free Play]" )
635   PORT_DIPNAME( 0x0e000000, 0x0e000000, DEF_STR( Coin_A ) )
636   PORT_DIPSETTING(          0x0a000000, DEF_STR( 3C_1C ) )
637   PORT_DIPSETTING(          0x0c000000, DEF_STR( 2C_1C ) )
638   PORT_DIPSETTING(          0x0e000000, DEF_STR( 1C_1C ) )
639   PORT_DIPSETTING(          0x08000000, DEF_STR( 1C_2C ) )
640   PORT_DIPSETTING(          0x06000000, DEF_STR( 1C_3C ) )
641   PORT_DIPSETTING(          0x04000000, DEF_STR( 1C_4C ) )
642   PORT_DIPSETTING(          0x02000000, DEF_STR( 1C_5C ) )
643   PORT_DIPSETTING(          0x00000000, "1C 6C [Free Play]" )
644   PORT_DIPNAME( 0x70000000, 0x70000000, DEF_STR( Coin_B ) )
645   PORT_DIPSETTING(          0x50000000, DEF_STR( 3C_1C ) )
646   PORT_DIPSETTING(          0x60000000, DEF_STR( 2C_1C ) )
647   PORT_DIPSETTING(          0x70000000, DEF_STR( 1C_1C ) )
648   PORT_DIPSETTING(          0x40000000, DEF_STR( 1C_2C ) )
649   PORT_DIPSETTING(          0x30000000, DEF_STR( 1C_3C ) )
650   PORT_DIPSETTING(          0x20000000, DEF_STR( 1C_4C ) )
651   PORT_DIPSETTING(          0x10000000, DEF_STR( 1C_5C ) )
652   PORT_DIPSETTING(          0x00000000, "1C 6C [Free Play]" )
653   PORT_DIPNAME( 0x80000000, 0x80000000, "2C Start, 1C Continue" )
654   PORT_DIPSETTING(          0x80000000, DEF_STR( Off ) )
655   PORT_DIPSETTING(          0x00000000, "On [Free Play]" ) // Forces 1C_1C
604   PORT_BIT( 0x0000ff00, IP_ACTIVE_LOW, IPT_UNKNOWN )   // unused?
656605INPUT_PORTS_END
657606
658607static INPUT_PORTS_START( sngkace )
r6740r6741
689638***************************************************************************/
690639
691640static INPUT_PORTS_START( btlkroad )
692   PORT_START("P1_P2")         /* c00000 -> c00003 */
641   PORT_INCLUDE(psikyo_common)
642
643   PORT_MODIFY("P1_P2")         /* c00000 -> c00003 */
693644   PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_COIN1 )
694645   PORT_BIT( 0x00000002, IP_ACTIVE_LOW, IPT_COIN2 )
695646   PORT_BIT( 0x00000004, IP_ACTIVE_HIGH, IPT_SPECIAL )
r6740r6741
706657   PORT_BIT( 0x00002000, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(1)
707658   PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(1)
708659   PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1)
709   PSIKYO_PORT_PLAYER2
710   PSIKYO_PORT_PLAYER1
711660
712   PORT_START("DSW")      /* c00004 -> c00007 */
661   PORT_MODIFY("DSW")      /* c00004 -> c00007 */
713662   /***********************************************
714663
715664    Bit 0 1 2 3
r6740r6741
759708   PORT_DIPSETTING(          0x00008000, DEF_STR( Off ) )
760709   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
761710
762   PORT_DIPNAME( 0x00010000, 0x00010000, DEF_STR( Flip_Screen ) )
763   PORT_DIPSETTING(          0x00010000, DEF_STR( Off ) )
764   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
765   PORT_DIPNAME( 0x00020000, 0x00000000, DEF_STR( Demo_Sounds ) )
766   PORT_DIPSETTING(          0x00020000, DEF_STR( Off ) )
767   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
768   PORT_DIPNAME( 0x000c0000, 0x000c0000, DEF_STR( Difficulty ) )
769   PORT_DIPSETTING(          0x00080000, DEF_STR( Easy ) )
770   PORT_DIPSETTING(          0x000c0000, DEF_STR( Normal ) )
771   PORT_DIPSETTING(          0x00040000, DEF_STR( Hard ) )
772   PORT_DIPSETTING(          0x00000000, DEF_STR( Hardest ) )
773711   PORT_DIPNAME( 0x00100000, 0x00100000, "Unknown 2-4" )   // used
774712   PORT_DIPSETTING(          0x00100000, DEF_STR( Off ) )
775713   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
r6740r6741
779717   PORT_DIPNAME( 0x00400000, 0x00400000, "Use DSW 3 (Debug)" )
780718   PORT_DIPSETTING(          0x00400000, DEF_STR( Off ) )
781719   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
782   PORT_SERVICE( 0x00800000, IP_ACTIVE_LOW )
783   PORT_DIPNAME( 0x01000000, 0x01000000, "Credits/Coinage" )   // [Free Play] on all for free play
784   PORT_DIPSETTING(          0x01000000, "A+B/A&B" )
785   PORT_DIPSETTING(          0x00000000, "A&B/A [Free Play]" )
786   PORT_DIPNAME( 0x0e000000, 0x0e000000, DEF_STR( Coin_A ) )
787   PORT_DIPSETTING(          0x0a000000, DEF_STR( 3C_1C ) )
788   PORT_DIPSETTING(          0x0c000000, DEF_STR( 2C_1C ) )
789   PORT_DIPSETTING(          0x0e000000, DEF_STR( 1C_1C ) )
790   PORT_DIPSETTING(          0x08000000, DEF_STR( 1C_2C ) )
791   PORT_DIPSETTING(          0x06000000, DEF_STR( 1C_3C ) )
792   PORT_DIPSETTING(          0x04000000, DEF_STR( 1C_4C ) )
793   PORT_DIPSETTING(          0x02000000, DEF_STR( 1C_5C ) )
794   PORT_DIPSETTING(          0x00000000, "1C 6C [Free Play]" )
795   PORT_DIPNAME( 0x70000000, 0x70000000, DEF_STR( Coin_B ) )
796   PORT_DIPSETTING(          0x50000000, DEF_STR( 3C_1C ) )
797   PORT_DIPSETTING(          0x60000000, DEF_STR( 2C_1C ) )
798   PORT_DIPSETTING(          0x70000000, DEF_STR( 1C_1C ) )
799   PORT_DIPSETTING(          0x40000000, DEF_STR( 1C_2C ) )
800   PORT_DIPSETTING(          0x30000000, DEF_STR( 1C_3C ) )
801   PORT_DIPSETTING(          0x20000000, DEF_STR( 1C_4C ) )
802   PORT_DIPSETTING(          0x10000000, DEF_STR( 1C_5C ) )
803   PORT_DIPSETTING(          0x00000000, "1C 6C [Free Play]" )
804   PORT_DIPNAME( 0x80000000, 0x80000000, "2C Start, 1C Continue" )
805   PORT_DIPSETTING(          0x80000000, DEF_STR( Off ) )
806   PORT_DIPSETTING(          0x00000000, "On [Free Play]" ) // Forces 1C_1C
807720INPUT_PORTS_END
808721
809722
r6740r6741
812725***************************************************************************/
813726
814727static INPUT_PORTS_START( gunbird )
815   PORT_START("P1_P2")         /* c00000 -> c00003 */
728   PORT_INCLUDE(psikyo_common)
729
730   PORT_MODIFY("P1_P2")         /* c00000 -> c00003 */
816731   PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_COIN1 )
817732   PORT_BIT( 0x00000002, IP_ACTIVE_LOW, IPT_COIN2 )
818733   PORT_BIT( 0x00000004, IP_ACTIVE_HIGH, IPT_SPECIAL )
r6740r6741
821736   PORT_SERVICE_NO_TOGGLE( 0x00000020, IP_ACTIVE_LOW )
822737   PORT_BIT( 0x00000040, IP_ACTIVE_LOW, IPT_TILT )
823738   PORT_BIT( 0x00000080, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(z80_nmi_r, NULL)   // From Sound CPU
824   PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_UNKNOWN )
825   PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_UNKNOWN )
826   PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_UNKNOWN )
827   PORT_BIT( 0x00000800, IP_ACTIVE_LOW, IPT_UNKNOWN )
828   PORT_BIT( 0x00001000, IP_ACTIVE_LOW, IPT_UNKNOWN )
829   PORT_BIT( 0x00002000, IP_ACTIVE_LOW, IPT_UNKNOWN )
830   PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN )
831   PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN )
832   PSIKYO_PORT_PLAYER2
833   PSIKYO_PORT_PLAYER1
739   PORT_BIT( 0x0000ff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
834740
835   PORT_START("DSW")      /* c00004 -> c00007 */
741   PORT_MODIFY("DSW")      /* c00004 -> c00007 */
836742   /***********************************************
837743
838744    This Dip port is bit based:
r6740r6741
870776   PORT_BIT( 0x00002000, IP_ACTIVE_LOW, IPT_UNKNOWN )
871777   PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN )
872778   PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN )   // tested!
873
874   PORT_DIPNAME( 0x00010000, 0x00010000, DEF_STR( Flip_Screen ) )
875   PORT_DIPSETTING(          0x00010000, DEF_STR( Off ) )
876   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
877   PORT_DIPNAME( 0x00020000, 0x00000000, DEF_STR( Demo_Sounds ) )
878   PORT_DIPSETTING(          0x00020000, DEF_STR( Off ) )
879   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
880   PORT_DIPNAME( 0x000c0000, 0x000c0000, DEF_STR( Difficulty ) )
881   PORT_DIPSETTING(          0x00080000, DEF_STR( Easy ) )
882   PORT_DIPSETTING(          0x000c0000, DEF_STR( Normal ) )
883   PORT_DIPSETTING(          0x00040000, DEF_STR( Hard ) )
884   PORT_DIPSETTING(          0x00000000, DEF_STR( Hardest ) )
885   PORT_DIPNAME( 0x00300000, 0x00300000, DEF_STR( Lives ) )
886   PORT_DIPSETTING(          0x00200000, "1" )
887   PORT_DIPSETTING(          0x00100000, "2" )
888   PORT_DIPSETTING(          0x00300000, "3" )
889   PORT_DIPSETTING(          0x00000000, "4" )
890   PORT_DIPNAME( 0x00400000, 0x00400000, DEF_STR( Bonus_Life ) )
891   PORT_DIPSETTING(          0x00400000, "400K" )
892   PORT_DIPSETTING(          0x00000000, "600K" )
893   PORT_SERVICE( 0x00800000, IP_ACTIVE_LOW )
894   PORT_DIPNAME( 0x01000000, 0x01000000, "Credits/Coinage" )   // [Free Play] on all for free play
895   PORT_DIPSETTING(          0x01000000, "A+B/A&B" )
896   PORT_DIPSETTING(          0x00000000, "A&B/A [Free Play]" )
897   PORT_DIPNAME( 0x0e000000, 0x0e000000, DEF_STR( Coin_A ) )
898   PORT_DIPSETTING(          0x0a000000, DEF_STR( 3C_1C ) )
899   PORT_DIPSETTING(          0x0c000000, DEF_STR( 2C_1C ) )
900   PORT_DIPSETTING(          0x0e000000, DEF_STR( 1C_1C ) )
901   PORT_DIPSETTING(          0x08000000, DEF_STR( 1C_2C ) )
902   PORT_DIPSETTING(          0x06000000, DEF_STR( 1C_3C ) )
903   PORT_DIPSETTING(          0x04000000, DEF_STR( 1C_4C ) )
904   PORT_DIPSETTING(          0x02000000, DEF_STR( 1C_5C ) )
905   PORT_DIPSETTING(          0x00000000, "1C 6C [Free Play]" )
906   PORT_DIPNAME( 0x70000000, 0x70000000, DEF_STR( Coin_B ) )
907   PORT_DIPSETTING(          0x50000000, DEF_STR( 3C_1C ) )
908   PORT_DIPSETTING(          0x60000000, DEF_STR( 2C_1C ) )
909   PORT_DIPSETTING(          0x70000000, DEF_STR( 1C_1C ) )
910   PORT_DIPSETTING(          0x40000000, DEF_STR( 1C_2C ) )
911   PORT_DIPSETTING(          0x30000000, DEF_STR( 1C_3C ) )
912   PORT_DIPSETTING(          0x20000000, DEF_STR( 1C_4C ) )
913   PORT_DIPSETTING(          0x10000000, DEF_STR( 1C_5C ) )
914   PORT_DIPSETTING(          0x00000000, "1C 6C [Free Play]" )
915   PORT_DIPNAME( 0x80000000, 0x80000000, "2C Start, 1C Continue" )
916   PORT_DIPSETTING(          0x80000000, DEF_STR( Off ) )
917   PORT_DIPSETTING(          0x00000000, "On [Free Play]" ) // Forces 1C_1C
918779INPUT_PORTS_END
919780
920781static INPUT_PORTS_START( gunbirdj )
r6740r6741
933794***************************************************************************/
934795
935796static INPUT_PORTS_START( s1945 )
936   PORT_START("P1_P2")         /* c00000 -> c00003 */
797   PORT_INCLUDE(psikyo_common)
798
799   PORT_MODIFY("P1_P2")         /* c00000 -> c00003 */
937800   PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_COIN1 )
938801   PORT_BIT( 0x00000002, IP_ACTIVE_LOW, IPT_COIN2 )
939802   PORT_BIT( 0x00000004, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(mcu_status_r, NULL)
r6740r6741
942805   PORT_SERVICE_NO_TOGGLE( 0x00000020, IP_ACTIVE_LOW )
943806   PORT_BIT( 0x00000040, IP_ACTIVE_LOW, IPT_TILT )
944807   PORT_BIT( 0x00000080, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(z80_nmi_r, NULL)   // From Sound CPU
945   PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_UNKNOWN )
946   PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_UNKNOWN )
947   PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_UNKNOWN )
948   PORT_BIT( 0x00000800, IP_ACTIVE_LOW, IPT_UNKNOWN )
949   PORT_BIT( 0x00001000, IP_ACTIVE_LOW, IPT_UNKNOWN )
950   PORT_BIT( 0x00002000, IP_ACTIVE_LOW, IPT_UNKNOWN )
951   PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN )
952   PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN )
953   PSIKYO_PORT_PLAYER2
954   PSIKYO_PORT_PLAYER1
808   PORT_BIT( 0x0000ff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
955809
956   PORT_START("DSW")      /* c00004 -> c00007 */
810   PORT_MODIFY("DSW")      /* c00004 -> c00007 */
957811   /***********************************************
958812
959813    This Dip port is bit based:
r6740r6741
993847   PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN )
994848   PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN )   // tested!
995849
996   PORT_DIPNAME( 0x00010000, 0x00010000, DEF_STR( Flip_Screen ) )
997   PORT_DIPSETTING(          0x00010000, DEF_STR( Off ) )
998   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
999   PORT_DIPNAME( 0x00020000, 0x00000000, DEF_STR( Demo_Sounds ) )
1000   PORT_DIPSETTING(          0x00020000, DEF_STR( Off ) )
1001   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
1002   PORT_DIPNAME( 0x000c0000, 0x000c0000, DEF_STR( Difficulty ) )
1003   PORT_DIPSETTING(          0x00080000, DEF_STR( Easy ) )
1004   PORT_DIPSETTING(          0x000c0000, DEF_STR( Normal ) )
1005   PORT_DIPSETTING(          0x00040000, DEF_STR( Hard ) )
1006   PORT_DIPSETTING(          0x00000000, DEF_STR( Hardest ) )
1007   PORT_DIPNAME( 0x00300000, 0x00300000, DEF_STR( Lives ) )
1008   PORT_DIPSETTING(          0x00200000, "1" )
1009   PORT_DIPSETTING(          0x00100000, "2" )
1010   PORT_DIPSETTING(          0x00300000, "3" )
1011   PORT_DIPSETTING(          0x00000000, "4" )
1012850   PORT_DIPNAME( 0x00400000, 0x00400000, DEF_STR( Bonus_Life ) )
1013851   PORT_DIPSETTING(          0x00400000, "600K" )
1014852   PORT_DIPSETTING(          0x00000000, "800K" )
1015   PORT_SERVICE( 0x00800000, IP_ACTIVE_LOW )
1016   PORT_DIPNAME( 0x01000000, 0x01000000, "Credits/Coinage" )   // No freeplay for s1945
1017   PORT_DIPSETTING(          0x01000000, "A+B/A&B" )
1018   PORT_DIPSETTING(          0x00000000, "A&B/A" )
1019853   PORT_DIPNAME( 0x0e000000, 0x0e000000, DEF_STR( Coin_A ) )
1020854   PORT_DIPSETTING(          0x0a000000, DEF_STR( 3C_1C ) )
1021855   PORT_DIPSETTING(          0x0c000000, DEF_STR( 2C_1C ) )
r6740r6741
1084918***************************************************************************/
1085919
1086920static INPUT_PORTS_START( tengai )
1087   PORT_START("P1_P2")         /* c00000 -> c00003 */
921   PORT_INCLUDE(psikyo_common)
922
923   PORT_MODIFY("P1_P2")         /* c00000 -> c00003 */
1088924   PORT_BIT( 0x00000001, IP_ACTIVE_LOW, IPT_COIN1 )
1089925   PORT_BIT( 0x00000002, IP_ACTIVE_LOW, IPT_COIN2 )
1090926   PORT_BIT( 0x00000004, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(mcu_status_r, NULL)
r6740r6741
1093929   PORT_SERVICE_NO_TOGGLE( 0x00000020, IP_ACTIVE_LOW )
1094930   PORT_BIT( 0x00000040, IP_ACTIVE_LOW, IPT_TILT )
1095931   PORT_BIT( 0x00000080, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(z80_nmi_r, NULL)   // From Sound CPU
1096   PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_UNKNOWN )
1097   PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_UNKNOWN )
1098   PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_UNKNOWN )
1099   PORT_BIT( 0x00000800, IP_ACTIVE_LOW, IPT_UNKNOWN )
1100   PORT_BIT( 0x00001000, IP_ACTIVE_LOW, IPT_UNKNOWN )
1101   PORT_BIT( 0x00002000, IP_ACTIVE_LOW, IPT_UNKNOWN )
1102   PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN )
1103   PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN )
1104   PSIKYO_PORT_PLAYER2
1105   PSIKYO_PORT_PLAYER1
932   PORT_BIT( 0x0000ff00, IP_ACTIVE_LOW, IPT_UNKNOWN )
1106933
1107   PORT_START("DSW")      /* c00004 -> c00007 */
934   PORT_MODIFY("DSW")      /* c00004 -> c00007 */
1108935   /***********************************************
1109936
1110937    This Dip port is bit based:
r6740r6741
1136963   PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN )
1137964   PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN )   // tested!
1138965
1139   PORT_DIPNAME( 0x00010000, 0x00010000, DEF_STR( Flip_Screen ) )
1140   PORT_DIPSETTING(          0x00010000, DEF_STR( Off ) )
1141   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
1142   PORT_DIPNAME( 0x00020000, 0x00000000, DEF_STR( Demo_Sounds ) )
1143   PORT_DIPSETTING(          0x00020000, DEF_STR( Off ) )
1144   PORT_DIPSETTING(          0x00000000, DEF_STR( On ) )
1145   PORT_DIPNAME( 0x000c0000, 0x000c0000, DEF_STR( Difficulty ) )
1146   PORT_DIPSETTING(          0x00080000, DEF_STR( Easy ) )
1147   PORT_DIPSETTING(          0x000c0000, DEF_STR( Normal ) )
1148   PORT_DIPSETTING(          0x00040000, DEF_STR( Hard ) )
1149   PORT_DIPSETTING(          0x00000000, DEF_STR( Hardest ) )
1150   PORT_DIPNAME( 0x00300000, 0x00300000, DEF_STR( Lives ) )
1151   PORT_DIPSETTING(          0x00200000, "1" )
1152   PORT_DIPSETTING(          0x00100000, "2" )
1153   PORT_DIPSETTING(          0x00300000, "3" )
1154   PORT_DIPSETTING(          0x00000000, "4" )
1155966   PORT_DIPNAME( 0x00400000, 0x00400000, DEF_STR( Bonus_Life ) )
1156967   PORT_DIPSETTING(          0x00400000, "600K" )
1157968   PORT_DIPSETTING(          0x00000000, "800K" )
1158   PORT_SERVICE( 0x00800000, IP_ACTIVE_LOW )
1159   PORT_DIPNAME( 0x01000000, 0x01000000, "Credits/Coinage" )   // [Free Play] on all for free play
1160   PORT_DIPSETTING(          0x01000000, "A+B/A&B" )
1161   PORT_DIPSETTING(          0x00000000, "A&B/A [Free Play]" )
1162   PORT_DIPNAME( 0x0e000000, 0x0e000000, DEF_STR( Coin_A ) )
1163   PORT_DIPSETTING(          0x0a000000, DEF_STR( 3C_1C ) )
1164   PORT_DIPSETTING(          0x0c000000, DEF_STR( 2C_1C ) )
1165   PORT_DIPSETTING(          0x0e000000, DEF_STR( 1C_1C ) )
1166   PORT_DIPSETTING(          0x08000000, DEF_STR( 1C_2C ) )
1167   PORT_DIPSETTING(          0x06000000, DEF_STR( 1C_3C ) )
1168   PORT_DIPSETTING(          0x04000000, DEF_STR( 1C_4C ) )
1169   PORT_DIPSETTING(          0x02000000, DEF_STR( 1C_5C ) )
1170   PORT_DIPSETTING(          0x00000000, "1C 6C [Free Play]" )
1171   PORT_DIPNAME( 0x70000000, 0x70000000, DEF_STR( Coin_B ) )
1172   PORT_DIPSETTING(          0x50000000, DEF_STR( 3C_1C ) )
1173   PORT_DIPSETTING(          0x60000000, DEF_STR( 2C_1C ) )
1174   PORT_DIPSETTING(          0x70000000, DEF_STR( 1C_1C ) )
1175   PORT_DIPSETTING(          0x40000000, DEF_STR( 1C_2C ) )
1176   PORT_DIPSETTING(          0x30000000, DEF_STR( 1C_3C ) )
1177   PORT_DIPSETTING(          0x20000000, DEF_STR( 1C_4C ) )
1178   PORT_DIPSETTING(          0x10000000, DEF_STR( 1C_5C ) )
1179   PORT_DIPSETTING(          0x00000000, "1C 6C [Free Play]" )
1180   PORT_DIPNAME( 0x80000000, 0x80000000, "2C Start, 1C Continue" )
1181   PORT_DIPSETTING(          0x80000000, DEF_STR( Off ) )
1182   PORT_DIPSETTING(          0x00000000, "On [Free Play]" ) // Forces 1C_1C
1183969INPUT_PORTS_END
1184970
1185971static INPUT_PORTS_START( tengaij )
r6740r6741
12381024
12391025***************************************************************************/
12401026
1027static MACHINE_START( psikyo )
1028{
1029   psikyo_state *state = (psikyo_state *)machine->driver_data;
1030
1031   state->audiocpu = devtag_get_device(machine, "audiocpu");
1032
1033   state_save_register_global(machine, state->soundlatch);
1034   state_save_register_global(machine, state->z80_nmi);
1035   state_save_register_global(machine, state->mcu_status);
1036   state_save_register_global(machine, state->tilemap_0_bank);
1037   state_save_register_global(machine, state->tilemap_1_bank);
1038}
1039
1040static MACHINE_RESET( psikyo )
1041{
1042   psikyo_state *state = (psikyo_state *)machine->driver_data;
1043
1044   state->soundlatch = 0;
1045   state->z80_nmi = 0;
1046   state->mcu_status = 0;
1047}
1048
1049
12411050/***************************************************************************
12421051                            Samurai Ace / Sengoku Aces
12431052***************************************************************************/
r6740r6741
12501059
12511060static MACHINE_DRIVER_START( sngkace )
12521061
1062   /* driver data */
1063   MDRV_DRIVER_DATA(psikyo_state)
1064
12531065   /* basic machine hardware */
12541066   MDRV_CPU_ADD("maincpu", M68EC020, XTAL_32MHz/2) /* verified on pcb */
12551067   MDRV_CPU_PROGRAM_MAP(psikyo_map)
r6740r6741
12591071   MDRV_CPU_PROGRAM_MAP(sngkace_sound_map)
12601072   MDRV_CPU_IO_MAP(sngkace_sound_io_map)
12611073
1074   MDRV_MACHINE_START(psikyo)
12621075   MDRV_MACHINE_RESET(psikyo)
12631076
12641077   /* video hardware */
r6740r6741
13011114
13021115static MACHINE_DRIVER_START( gunbird )
13031116
1117   /* driver data */
1118   MDRV_DRIVER_DATA(psikyo_state)
1119
13041120   /* basic machine hardware */
13051121   MDRV_CPU_ADD("maincpu", M68EC020, 16000000)
13061122   MDRV_CPU_PROGRAM_MAP(psikyo_map)
r6740r6741
13101126   MDRV_CPU_PROGRAM_MAP(gunbird_sound_map)
13111127   MDRV_CPU_IO_MAP(gunbird_sound_io_map)
13121128
1129   MDRV_MACHINE_START(psikyo)
13131130   MDRV_MACHINE_RESET(psikyo)
13141131
13151132   /* video hardware */
r6740r6741
13401157
13411158static MACHINE_DRIVER_START( s1945bl ) /* Bootleg hardware based on the unprotected Japanese Strikers 1945 set */
13421159
1160   /* driver data */
1161   MDRV_DRIVER_DATA(psikyo_state)
1162
13431163   /* basic machine hardware */
13441164   MDRV_CPU_ADD("maincpu", M68EC020, 16000000)
13451165   MDRV_CPU_PROGRAM_MAP(psikyo_bootleg_map)
13461166   MDRV_CPU_VBLANK_INT("screen", irq1_line_hold)
13471167
1168   MDRV_MACHINE_START(psikyo)
13481169   MDRV_MACHINE_RESET(psikyo)
13491170
13501171   /* video hardware */
r6740r6741
13781199***************************************************************************/
13791200
13801201
1381static void irqhandler(const device_config *device, int linestate)
1202static void irqhandler( const device_config *device, int linestate )
13821203{
1383   if (linestate)
1384      cputag_set_input_line(device->machine, "audiocpu", 0, ASSERT_LINE);
1385   else
1386      cputag_set_input_line(device->machine, "audiocpu", 0, CLEAR_LINE);
1204   psikyo_state *state = (psikyo_state *)device->machine->driver_data;
1205   cpu_set_input_line(state->audiocpu, 0, linestate ? ASSERT_LINE : CLEAR_LINE);
13871206}
13881207
13891208static const ymf278b_interface ymf278b_config =
r6740r6741
13931212
13941213static MACHINE_DRIVER_START( s1945 )
13951214
1215   /* driver data */
1216   MDRV_DRIVER_DATA(psikyo_state)
1217
13961218   /* basic machine hardware */
13971219   MDRV_CPU_ADD("maincpu", M68EC020, 16000000)
13981220   MDRV_CPU_PROGRAM_MAP(psikyo_map)
r6740r6741
14041226
14051227   /* MCU should go here */
14061228
1229   MDRV_MACHINE_START(psikyo)
14071230   MDRV_MACHINE_RESET(psikyo)
14081231
14091232   /* video hardware */
r6740r6741
15081331
15091332ROM_END
15101333
1511static DRIVER_INIT( sngkace )
1512{
1513   {
1514      UINT8 *RAM   =   memory_region(machine, "ymsnd");
1515      int len      =   memory_region_length(machine, "ymsnd");
1516      int i;
15171334
1518      /* Bit 6&7 of the samples are swapped. Naughty, naughty... */
1519      for (i = 0; i < len; i++)
1520      {
1521         int x = RAM[i];
1522         RAM[i] = ((x & 0x40) << 1) | ((x & 0x80) >> 1) | (x & 0x3f);
1523      }
1524   }
1525
1526   /* input ports */
1527   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, sngkace_input_r);
1528
1529   /* sound latch */
1530   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, psikyo_soundlatch_w);
1531
1532   psikyo_ka302c_banking = 0; // SH201B doesn't have any gfx banking
1533
1534   /* Enable other regions */
1535#if 0
1536   if (!strcmp(machine->gamedrv->name,"sngkace"))
1537   {
1538      UINT8 *ROM   =   memory_region(machine, "maincpu");
1539      ROM[0x995] = 0x4e;
1540      ROM[0x994] = 0x71;
1541      ROM[0x997] = 0x4e;
1542      ROM[0x996] = 0x71;
1543
1544   }
1545#endif
1546}
1547
1548
15491335/***************************************************************************
15501336
15511337                                Gun Bird (Korea)
r6740r6741
16891475
16901476ROM_END
16911477
1692
1693
1694static DRIVER_INIT( gunbird )
1695{
1696   /* input ports */
1697   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, gunbird_input_r);
1698
1699   /* sound latch */
1700   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, psikyo_soundlatch_w);
1701
1702   psikyo_ka302c_banking = 1;
1703}
1704
1705
17061478/***************************************************************************
17071479
17081480                            Strikers 1945 (Japan, unprotected)
r6740r6741
17741546   ROM_LOAD( "27c512",  0x000000, 0x010000, CRC(0da8db45) SHA1(7d5bd71c5b0b28ff74c732edd7c662f46f2ab25b) )
17751547ROM_END
17761548
1777static DRIVER_INIT( s1945jn )
1778{
1779   /* input ports */
1780   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, gunbird_input_r);
1781
1782   /* sound latch */
1783   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w);
1784
1785   psikyo_ka302c_banking = 1;
1786}
1787
1788
17891549/***************************************************************************
17901550
17911551Strikers 1945
r6740r6741
19811741
19821742ROM_END
19831743
1984static DRIVER_INIT( s1945 )
1985{
1986   /* input ports */
1987   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, s1945_input_r);
19881744
1989   /* sound latch */
1990   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w);
1991
1992   /* protection and tile bank switching */
1993   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00004, 0xc0000b, 0, 0, s1945_mcu_w);
1994   s1945_mcu_init(s1945_table);
1995
1996   psikyo_ka302c_banking = 0; // Banking is controlled by mcu
1997}
1998
1999static DRIVER_INIT( s1945a )
2000{
2001   /* input ports */
2002   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, s1945_input_r);
2003
2004   /* sound latch */
2005   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w);
2006
2007   /* protection and tile bank switching */
2008   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00004, 0xc0000b, 0, 0, s1945_mcu_w);
2009   s1945_mcu_init(s1945a_table);
2010
2011   psikyo_ka302c_banking = 0; // Banking is controlled by mcu
2012}
2013
2014static DRIVER_INIT( s1945j )
2015{
2016   /* input ports*/
2017   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, s1945_input_r);
2018
2019   /* sound latch */
2020   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w);
2021
2022   /* protection and tile bank switching */
2023   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00004, 0xc0000b, 0, 0, s1945_mcu_w);
2024   s1945_mcu_init(s1945j_table);
2025
2026   psikyo_ka302c_banking = 0; // Banking is controlled by mcu
2027}
2028
2029
20301745/***************************************************************************
20311746
20321747                                Tengai (World) / Sengoku Blade (Japan)
r6740r6741
21081823
21091824ROM_END
21101825
1826/***************************************************************************
1827
1828
1829                                Driver Initialization
1830
1831
1832***************************************************************************/
1833
1834static DRIVER_INIT( sngkace )
1835{
1836   psikyo_state *state = (psikyo_state *)machine->driver_data;
1837
1838   {
1839      UINT8 *RAM = memory_region(machine, "ymsnd");
1840      int len = memory_region_length(machine, "ymsnd");
1841      int i;
1842
1843      /* Bit 6&7 of the samples are swapped. Naughty, naughty... */
1844      for (i = 0; i < len; i++)
1845      {
1846         int x = RAM[i];
1847         RAM[i] = ((x & 0x40) << 1) | ((x & 0x80) >> 1) | (x & 0x3f);
1848      }
1849   }
1850
1851   /* input ports */
1852   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, sngkace_input_r);
1853
1854   /* sound latch */
1855   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, psikyo_soundlatch_w);
1856
1857   state->ka302c_banking = 0; // SH201B doesn't have any gfx banking
1858
1859   /* setup audiocpu banks */
1860   memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "audiocpu") + 0x10000, 0x8000);
1861
1862   /* Enable other regions */
1863#if 0
1864   if (!strcmp(machine->gamedrv->name,"sngkace"))
1865   {
1866      UINT8 *ROM   =   memory_region(machine, "maincpu");
1867      ROM[0x995] = 0x4e;
1868      ROM[0x994] = 0x71;
1869      ROM[0x997] = 0x4e;
1870      ROM[0x996] = 0x71;
1871
1872   }
1873#endif
1874}
1875
1876static void s1945_mcu_init( running_machine *machine )
1877{
1878   psikyo_state *state = (psikyo_state *)machine->driver_data;
1879   state->s1945_mcu_direction = 0x00;
1880   state->s1945_mcu_inlatch = 0xff;
1881   state->s1945_mcu_latch1 = 0xff;
1882   state->s1945_mcu_latch2 = 0xff;
1883   state->s1945_mcu_latching = 0x5;
1884   state->s1945_mcu_control = 0xff;
1885   state->s1945_mcu_index = 0;
1886   state->s1945_mcu_mode = 0;
1887   state->s1945_mcu_bctrl = 0x00;
1888
1889   state_save_register_global(machine, state->s1945_mcu_direction);
1890   state_save_register_global(machine, state->s1945_mcu_inlatch);
1891   state_save_register_global(machine, state->s1945_mcu_latch1);
1892   state_save_register_global(machine, state->s1945_mcu_latch2);
1893   state_save_register_global(machine, state->s1945_mcu_latching);
1894   state_save_register_global(machine, state->s1945_mcu_control);
1895   state_save_register_global(machine, state->s1945_mcu_index);
1896   state_save_register_global(machine, state->s1945_mcu_mode);
1897   state_save_register_global(machine, state->s1945_mcu_bctrl);
1898}
1899
21111900static DRIVER_INIT( tengai )
21121901{
1902   psikyo_state *state = (psikyo_state *)machine->driver_data;
1903
21131904   /* input ports */
21141905   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, s1945_input_r);
21151906
r6740r6741
21181909
21191910   /* protection */
21201911   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00004, 0xc0000b, 0, 0, s1945_mcu_w);
2121   s1945_mcu_init(0);
21221912
2123   psikyo_ka302c_banking = 0; // Banking is controlled by mcu
1913   s1945_mcu_init(machine);
1914   state->s1945_mcu_table = 0;
1915
1916   state->ka302c_banking = 0; // Banking is controlled by mcu
1917
1918   /* setup audiocpu banks */
1919   /* The banked rom is seen at 8200-ffff, so the last 0x200 bytes of the rom not reachable. */
1920   memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "audiocpu") + 0x10000 + 0x200, 0x8000);
21241921}
21251922
1923static DRIVER_INIT( gunbird )
1924{
1925   psikyo_state *state = (psikyo_state *)machine->driver_data;
1926
1927   /* input ports */
1928   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, gunbird_input_r);
1929
1930   /* sound latch */
1931   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, psikyo_soundlatch_w);
1932
1933   state->ka302c_banking = 1;
1934
1935   /* setup audiocpu banks */
1936   /* The banked rom is seen at 8200-ffff, so the last 0x200 bytes of the rom not reachable. */
1937   memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "audiocpu") + 0x10000 + 0x200, 0x8000);
1938}
1939
1940
1941static DRIVER_INIT( s1945 )
1942{
1943   psikyo_state *state = (psikyo_state *)machine->driver_data;
1944
1945   /* input ports */
1946   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, s1945_input_r);
1947
1948   /* sound latch */
1949   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w);
1950
1951   /* protection and tile bank switching */
1952   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00004, 0xc0000b, 0, 0, s1945_mcu_w);
1953
1954   s1945_mcu_init(machine);
1955   state->s1945_mcu_table = s1945_table;
1956
1957   state->ka302c_banking = 0; // Banking is controlled by mcu
1958
1959   /* setup audiocpu banks */
1960   /* The banked rom is seen at 8200-ffff, so the last 0x200 bytes of the rom not reachable. */
1961   memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "audiocpu") + 0x10000 + 0x200, 0x8000);
1962}
1963
1964static DRIVER_INIT( s1945a )
1965{
1966   psikyo_state *state = (psikyo_state *)machine->driver_data;
1967
1968   /* input ports */
1969   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, s1945_input_r);
1970
1971   /* sound latch */
1972   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w);
1973
1974   /* protection and tile bank switching */
1975   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00004, 0xc0000b, 0, 0, s1945_mcu_w);
1976
1977   s1945_mcu_init(machine);
1978   state->s1945_mcu_table = s1945a_table;
1979
1980   state->ka302c_banking = 0; // Banking is controlled by mcu
1981
1982   /* setup audiocpu banks */
1983   /* The banked rom is seen at 8200-ffff, so the last 0x200 bytes of the rom not reachable. */
1984   memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "audiocpu") + 0x10000 + 0x200, 0x8000);
1985}
1986
1987static DRIVER_INIT( s1945j )
1988{
1989   psikyo_state *state = (psikyo_state *)machine->driver_data;
1990
1991   /* input ports*/
1992   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, s1945_input_r);
1993
1994   /* sound latch */
1995   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w);
1996
1997   /* protection and tile bank switching */
1998   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00004, 0xc0000b, 0, 0, s1945_mcu_w);
1999
2000   s1945_mcu_init(machine);
2001   state->s1945_mcu_table = s1945j_table;
2002
2003   state->ka302c_banking = 0; // Banking is controlled by mcu
2004
2005   /* setup audiocpu banks */
2006   /* The banked rom is seen at 8200-ffff, so the last 0x200 bytes of the rom not reachable. */
2007   memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "audiocpu") + 0x10000 + 0x200, 0x8000);
2008}
2009
2010static DRIVER_INIT( s1945jn )
2011{
2012   psikyo_state *state = (psikyo_state *)machine->driver_data;
2013
2014   /* input ports */
2015   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, gunbird_input_r);
2016
2017   /* sound latch */
2018   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w);
2019
2020   state->ka302c_banking = 1;
2021
2022   /* setup audiocpu banks */
2023   /* The banked rom is seen at 8200-ffff, so the last 0x200 bytes of the rom not reachable. */
2024   memory_configure_bank(machine, "bank1", 0, 4, memory_region(machine, "audiocpu") + 0x10000 + 0x200, 0x8000);
2025}
2026
21262027static DRIVER_INIT( s1945bl )
21272028{
2128   DRIVER_INIT_CALL( s1945jn );
2029   psikyo_state *state = (psikyo_state *)machine->driver_data;
21292030
2130   memory_set_bankptr(machine, "okibank", memory_region(machine,"oki")+0x30000);
2031   /* input ports */
2032   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00000, 0xc0000b, 0, 0, gunbird_input_r);
2033
2034   /* sound latch */
2035   memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc00010, 0xc00013, 0, 0, s1945_soundlatch_w);
2036
2037   state->ka302c_banking = 1;
2038
2039   memory_configure_bank(machine, "okibank", 0, 4, memory_region(machine, "oki") + 0x30000, 0x10000);
2040   memory_set_bank(machine, "okibank", 0);
21312041}
21322042
21332043
r6740r6741
21402050***************************************************************************/
21412051
21422052/* Working Games */
2143GAME( 1993, samuraia, 0,        sngkace,  samuraia, sngkace,  ROT270, "Psikyo", "Samurai Aces (World)", 0) // Banpresto?
2144GAME( 1993, sngkace,  samuraia, sngkace,  sngkace,  sngkace,  ROT270, "Psikyo", "Sengoku Ace (Japan)", 0) // Banpresto?
2145GAME( 1994, gunbird,  0,        gunbird,  gunbird,  gunbird,  ROT270, "Psikyo", "Gunbird (World)", 0 )
2146GAME( 1994, gunbirdk, gunbird,  gunbird,  gunbirdj, gunbird,  ROT270, "Psikyo", "Gunbird (Korea)", 0 )
2147GAME( 1994, gunbirdj, gunbird,  gunbird,  gunbirdj, gunbird,  ROT270, "Psikyo", "Gunbird (Japan)", 0 )
2148GAME( 1994, btlkroad, 0,        gunbird,  btlkroad, gunbird,  ROT0,   "Psikyo", "Battle K-Road", 0 )
2149GAME( 1995, s1945,    0,        s1945,    s1945,    s1945,    ROT270, "Psikyo", "Strikers 1945 (World)", 0 )
2150GAME( 1995, s1945a,   s1945,    s1945,    s1945a,   s1945a,   ROT270, "Psikyo", "Strikers 1945 (Japan / World)", 0) // Region dip - 0x0f=Japan, anything else=World
2151GAME( 1995, s1945j,   s1945,    s1945,    s1945j,   s1945j,   ROT270, "Psikyo", "Strikers 1945 (Japan)", 0 )
2152GAME( 1995, s1945jn,  s1945,    gunbird,  s1945j,   s1945jn,  ROT270, "Psikyo", "Strikers 1945 (Japan, unprotected)", 0 )
2153GAME( 1995, s1945k,   s1945,    s1945,    s1945j,   s1945,    ROT270, "Psikyo", "Strikers 1945 (Korea)", 0 )
2154GAME( 1995, s1945bl,  s1945,    s1945bl,  s1945bl,  s1945bl,  ROT270, "Psikyo", "Strikers 1945 (Hong Kong, bootleg)", 0 )
2155GAME( 1996, tengai,   0,        s1945,    tengai,   tengai,   ROT0,   "Psikyo", "Tengai (World)", 0 )
2156GAME( 1996, tengaij,  tengai,   s1945,    tengaij,  tengai,   ROT0,   "Psikyo", "Sengoku Blade: Sengoku Ace Episode II / Tengai", 0 ) // Region dip - 0x0f=Japan, anything else=World
2053GAME( 1993, samuraia, 0,        sngkace,  samuraia, sngkace,  ROT270, "Psikyo", "Samurai Aces (World)", GAME_SUPPORTS_SAVE ) // Banpresto?
2054GAME( 1993, sngkace,  samuraia, sngkace,  sngkace,  sngkace,  ROT270, "Psikyo", "Sengoku Ace (Japan)", GAME_SUPPORTS_SAVE ) // Banpresto?
2055GAME( 1994, gunbird,  0,        gunbird,  gunbird,  gunbird,  ROT270, "Psikyo", "Gunbird (World)", GAME_SUPPORTS_SAVE )
2056GAME( 1994, gunbirdk, gunbird,  gunbird,  gunbirdj, gunbird,  ROT270, "Psikyo", "Gunbird (Korea)", GAME_SUPPORTS_SAVE )
2057GAME( 1994, gunbirdj, gunbird,  gunbird,  gunbirdj, gunbird,  ROT270, "Psikyo", "Gunbird (Japan)", GAME_SUPPORTS_SAVE )
2058GAME( 1994, btlkroad, 0,        gunbird,  btlkroad, gunbird,  ROT0,   "Psikyo", "Battle K-Road", GAME_SUPPORTS_SAVE )
2059GAME( 1995, s1945,    0,        s1945,    s1945,    s1945,    ROT270, "Psikyo", "Strikers 1945 (World)", GAME_SUPPORTS_SAVE )
2060GAME( 1995, s1945a,   s1945,    s1945,    s1945a,   s1945a,   ROT270, "Psikyo", "Strikers 1945 (Japan / World)", GAME_SUPPORTS_SAVE ) // Region dip - 0x0f=Japan, anything else=World
2061GAME( 1995, s1945j,   s1945,    s1945,    s1945j,   s1945j,   ROT270, "Psikyo", "Strikers 1945 (Japan)", GAME_SUPPORTS_SAVE )
2062GAME( 1995, s1945jn,  s1945,    gunbird,  s1945j,   s1945jn,  ROT270, "Psikyo", "Strikers 1945 (Japan, unprotected)", GAME_SUPPORTS_SAVE )
2063GAME( 1995, s1945k,   s1945,    s1945,    s1945j,   s1945,    ROT270, "Psikyo", "Strikers 1945 (Korea)", GAME_SUPPORTS_SAVE )
2064GAME( 1995, s1945bl,  s1945,    s1945bl,  s1945bl,  s1945bl,  ROT270, "Psikyo", "Strikers 1945 (Hong Kong, bootleg)", GAME_SUPPORTS_SAVE )
2065GAME( 1996, tengai,   0,        s1945,    tengai,   tengai,   ROT0,   "Psikyo", "Tengai (World)", GAME_SUPPORTS_SAVE )
2066GAME( 1996, tengaij,  tengai,   s1945,    tengaij,  tengai,   ROT0,   "Psikyo", "Sengoku Blade: Sengoku Ace Episode II / Tengai", GAME_SUPPORTS_SAVE ) // Region dip - 0x0f=Japan, anything else=World
src/mame/drivers/esd16.c
r6740r6741
4747#include "machine/eepromdev.h"
4848#include "sound/okim6295.h"
4949#include "sound/3812intf.h"
50#include "esd16.h"
50#include "includes/esd16.h"
5151
5252
5353/***************************************************************************
src/mame/drivers/iqblock.c
r6740r6741
5454#include "cpu/z180/z180.h"
5555#include "deprecat.h"
5656#include "machine/8255ppi.h"
57#include "iqblock.h"
57#include "includes/iqblock.h"
5858#include "sound/2413intf.h"
5959
6060static UINT8 *rambase;
src/mame/drivers/cb2001.c
r6740r6741
4040
4141#include "driver.h"
4242#include "cpu/nec/nec.h"
43#include "sound/ay8910.h"
44#include "machine/8255ppi.h"
4345
4446#define xxxx 0x90 /* Unknown */
4547
4648static const UINT8 cb2001_decryption_table[256] = {
47   0xe8,xxxx,xxxx,xxxx,xxxx,0x61,xxxx,xxxx, xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, /* 00 */
48//  pppp                     ????
49   xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, 0x32,xxxx,0xa0,xxxx,0x3a,xxxx,xxxx,0x1f, /* 10 */
50//                                           pppp     ????       pppp           ????
51   xxxx,0x8e,xxxx,0x0f,xxxx,0x49,0xbc,xxxx, xxxx,xxxx,xxxx,0x75,xxxx,xxxx,xxxx,xxxx, /* 20 */
52//       !!!!      ????      ???? ????                      pppp
53   0x9d,xxxx,xxxx,xxxx,xxxx,xxxx,0xbe,xxxx, xxxx,xxxx,0x74,xxxx,xxxx,0xa6,0xbf,xxxx, /* 30 */
54//  ????                          pppp                 ????           ???? ????
49   0xe8,xxxx,0x94,xxxx,0x80,0x61,0x12,xxxx, 0x3c,xxxx,xxxx,0x23,xxxx,xxxx,xxxx,xxxx, /* 00 */
50//    pppp      ????      pppp ???? pppp       pppp           p?p?
51   xxxx,xxxx,xxxx,0x27,0x1c,xxxx,xxxx,xxxx, 0x32,xxxx,0xa0,0xd3,0x3a,0x14,0x89,xxxx, /* 10 */
52//                   pppp pppp                 pppp      ???? pppp pppp pppp pppp ????
53   xxxx,0x8e,xxxx,0x0f,xxxx,0x49,0xb5,xxxx, xxxx,xxxx,xxxx,0x75,xxxx,xxxx,xxxx,xxxx, /* 20 */
54//         !!!!      pppp      ???? pppp                      pppp
55   0x9d,xxxx,xxxx,xxxx,xxxx,xxxx,0xbe,xxxx, xxxx,xxxx,0x74,xxxx,xxxx,0xa6,0xbf,0x74, /* 30 */
56//    ????                          pppp                 ????           ???? ???? pppp
5557   xxxx,0xea,xxxx,xxxx,xxxx,0xb0,xxxx,xxxx, xxxx,0xa2,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, /* 40 */
56//       !!!!                gggg                 ????
57   xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,0x42,xxxx, xxxx,xxxx,xxxx,xxxx,0xeb,xxxx,xxxx,xxxx, /* 50 */
58//                                ????                           ????
59   xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, xxxx,0xa5,xxxx,xxxx,xxxx,xxxx,0xba,xxxx, /* 60 */
60//                                                ????                     gggg
61   0xc3,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, 0x72,xxxx,0xf2,xxxx,xxxx,xxxx,xxxx,xxxx, /* 70 */
62//  pppp                                     ????      ????
63   xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,0x34, xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, /* 80 */
64//                                     ????
58//         !!!!                gggg                 pppp
59   xxxx,xxxx,0x2c,xxxx,xxxx,xxxx,0x42,0xc0, xxxx,xxxx,xxxx,xxxx,0xeb,xxxx,xxxx,xxxx, /* 50 */
60//              pppp                ???? pppp                      pppp
61   xxxx,xxxx,xxxx,xxxx,0x22,xxxx,xxxx,xxxx, xxxx,0xa5,xxxx,xxxx,xxxx,0xbb,0xba,xxxx, /* 60 */
62//                        pppp                      ????                pppp gggg
63   0xc3,xxxx,0x02,xxxx,xxxx,xxxx,0x24,xxxx, 0x72,xxxx,0xf2,xxxx,xxxx,0x43,xxxx,xxxx, /* 70 */
64//    pppp      pppp                pppp       pppp      ????           pppp
65   xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,0x34, xxxx,xxxx,0x59,xxxx,0x73,xxxx,0x2a,xxxx, /* 80 */
66//                                       ????            pppp      pppp      ????
6567   xxxx,xxxx,0xe9,xxxx,xxxx,0xbe,xxxx,xxxx, xxxx,xxxx,xxxx,xxxx,0xb9,xxxx,xxxx,xxxx, /* 90 */
66//            ????           ????                                pppp
67   xxxx,xxxx,xxxx,0x06,0xaa,0x9c,xxxx,0xb8, xxxx,xxxx,0xfc,xxxx,xxxx,xxxx,xxxx,xxxx, /* A0 */
68//                 ???? ???? ????      !!!!            ????
69   xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, xxxx,xxxx,xxxx,xxxx,0x1e,xxxx,0x07,0xcf, /* B0 */
70//                                                               ????      ???? ????
71   xxxx,xxxx,0xee,xxxx,xxxx,0xe2,xxxx,xxxx, xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,0xa4,xxxx, /* C0 */
72//            ????           pppp                                          ????
73   xxxx,xxxx,0x46,xxxx,0x60,xxxx,xxxx,xxxx, 0x88,xxxx,xxxx,xxxx,xxxx,0xfa,0xc7,xxxx, /* D0 */
74//              pppp      ????                 pppp                     ???? !!!!
68//              ????           p?p?                                pppp
69   xxxx,xxxx,xxxx,0x06,0xaa,0x9c,xxxx,0xb8, xxxx,xxxx,0xfc,xxxx,0x51,xxxx,xxxx,0x1a, /* A0 */
70//                   ???? ???? ????      !!!!            ????      pppp           pppp
71   0x75,xxxx,0xb4,xxxx,xxxx,xxxx,xxxx,xxxx, xxxx,xxxx,0x03,xxxx,xxxx,xxxx,0x07,0xcf, /* B0 */
72//    ????      pppp                                     pppp      ????      ???? ????
73   xxxx,0xec,0xee,xxxx,xxxx,0xe2,xxxx,xxxx, xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,0x2e,xxxx, /* C0 */
74//         pppp ????           pppp                                          pppp
75   xxxx,xxxx,0x46,xxxx,0x60,xxxx,xxxx,0x47, 0x88,xxxx,xxxx,xxxx,xxxx,0xfa,0xc7,0x8b, /* D0 */
76//              pppp      ????           pppp  pppp                     ???? !!!! pppp
7577   0x8a,xxxx,xxxx,0xc6,xxxx,xxxx,xxxx,xxxx, xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, /* E0 */
76//  ????           !!!!
77   xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, /* F0 */
78//
78//    pppp           !!!!
79   xxxx,xxxx,0xfe,xxxx,xxxx,xxxx,xxxx,xxxx, xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx, /* F0 */
80//              pppp
7981};
8082
81/* robiza notes:
83/* robiza's notes:
8284
85cmast91 and cmv4 seems similar to this cb2001:
86
87cmast91:                      cb2001:
880067 ld a,$07                 e0130 mov al,7h
890069 out ($23),a              e0132 mov dw,23h
90                              e0135 out dw,al
91
92006b ld a,$3f                 e0136 mov al,3fh
93006d out ($22),a              e0138 mov dw,22h
94                              e013b out dw,al
95
96006f ld a,$9b                 e0124 mov al,0ffh
970071 out ($13),a              e0126 mov dw,13h
98                              e0129 out dw,al
99
100-------------------------------------------------
101
102cmv4                          cb2001                     (en -> de)
103
104.                             e025f mov dw,2h
10502b2 in a,($06)               e0262 in al,dw             (c1 -> ec)
106.                             e0263 xor al,d0h
107.                             e0265 and l,c0h
10802b4 bit 6,a                  e0267 test1 al,6h          (23 -> 0f)
10902b6 jp z,$41e2               e026b be e0270
110.                             e026d br e39fe
11102b9 bit 7,a                  e0270 test1 al,7h
11202bb jp z,$41e2               e0274 be e0279
11302be call $0ab2               .
114.                             e0276 br e6120
11502c1 ld bc,$8000              e0279 mov cw,8000h
116
117029f ld b,$fc
11802a1 call $0c38               e0239 call 0e30b8h
11902a4 ld hl,$d023              e023d mov ix,90h           (36 -> be)
12002a7 call $2b2d               e0240 call 0e32a6h
121  2b2d ld a,$01                 e32a6 mov al,1h
122  2b2f or a                     e32a8 and al,al
123  2b30 add a,(hl)               e32aa add al,b ptr [ix]
124  2b31 daa                      e32ac daa                (13 -> 27) not sure
125  2b32 ld (hl),a                e32ad mov b ptr [ix],al
126  2b33 push bc                  e32af push cw            (ac -> 51)
127  2b34 ld b,$03                 e32b0 mov cw,3h          (9c -> b9)
128  2b36 dec hl                   e32b3                               inc ix or dec ix?
129  2b37 ld a,(hl)                e32b4 mov al,b ptr [ix]  (e0 -> 8a)
130  2b38 adc a,$00                e32b6 adc al,0h          (1d -> 14)
131  2b3a daa                      e32b8 daa
132  2b3b ld (hl),a                e32b9 mov b ptr [ix],al
133  2b3c djnz $2b36               e32bb dbnz e32b3h        (c5 -> e2)
134  2b3e pop bc                   e32bd pop cw             (8a -> 59)
135  2b3f ret                      e32be ret
136
137  2b40-2b4b                     e32bf-e32d1              (06 -> 12) (d7 -> 4f dec iy or 47 inc iy)
138  2b4c-2b57                     e32d2-e32e4              (af -> 1a)
139  .                             e32e5-                   (8e -> 2a) (14 -> 1c)
140
14102aa ld a,$01                 e0243 mov al,1h
14202ac ld ($d618),a             e0245 mov [72dh],al
14302af call $4a8e               e0248 call 0e66cbh
144  4a8e ld a,($d618)             e66cb mov al,[72dh]      (1a -> a0)
145  4a91 and a                    e66ce and al,al          (64 -> 22)
146  4a92 jr z,$4abe               e66d0 be e6703           (3f -> 74)
147  4a94 cp $02                   e66d2 cmp al,2h          (08 -> 3c)
148  4a96 jr nz,$4aa6              e66d4 bne e66e9          (2b -> 75)
149  4a98 ld a,$0d                 e66d6 mov al,0dh         (45 -> b0)
150  .                             e66d8 mov dw,23h         (6e -> ba)
151  4a9a out ($03),a              e66db out dw,al          (c2 -> ee)
152  4a9c ld a,$00                 e66dc mov al,00h
153  .                             e66de mov dw,22h
154  4a9e out ($02),a              e66e1 out dw,al
155  4aa0 xor a                    e66e2 xor al,al          (18 -> 32)
156  4aa1 ld ($d618),al            e66e4 mov [72dh],al      (49 -> a2)
157  4aa4 jr $4abe                 e66e7 br 0e6703h         (5c -> eb)
158
159  4aa6 add a,a                  e66e9 add al,al          (72 -> 02)
160  4aa7 ld e,a                   .
161  4aa8 ld d,$00                 e66eb mov ah,00h         (b2 -> b4)
162  4aaa ld hl,$4b62              e66ed mov bw,67cbh       (6d -> bb)
163  4aad add lh,de                e66f0 add bw,aw          (ba -> 03)
164  4aae ld e,(hl)                .
165  4aaf inc hl                   .
166  4abo ld d,(hl)                .
167  4ab1 ex de,hl                 e66f2 mov bw,w ptr ss[bw](df -> 8b)prefix not sure about prefix
168  4ab2 xor a                    .
169  4ab3 ld ($d618),a             e66f5 mov b ptr[72dh],ah (d8 -> 88)
170  4ab6 ld ($d619),a             e66f9 mov b ptr[72eh],ah
171  4ab9 ld ($d61a),hl            e66fd mov w ptr[72fh],bw (1e -> 89)
172  4abc jr $4ac9                 e6701 br 0e6712h
173
174  4abe ld a,($d619)             e6703 mov al,[72eh]
175  4ac1 and a                    e6706 and al,al
176  4ac2 jr z,$4ac9               e6708 be 0e6712h
177  4ac4 dec a                    e670a dec al             (f2 -> fe)
178  4ac5 ld ($d619),a             e670c mov [72eh],al
179  .                             e670f be 0e6712h
180  4ac8 ret nz                   e6711 ret                (70 -> c3)
181
182  4ac9 ld hl,($d61a)            e6712 mov bw,w ptr[72fh]
183  .                             e6716 or bw,bw                      ??? (0b -> 23) ???
184  .                             e6718 bne 0e671bh
185  .                             e671a ret
186  4acc ld a,(hl)                e671b mov al,b ptr ps[bw](ce -> 2e) (e0 -> 8a) not sure about the prefix
187  4acd inc hl                   e671e inc bw             (7d -> 43)
188  4ace cp $f0                   e671f cmp al,0f0h
189  4ad0 jr nc,$4b14              e6721 bnc 0e676fh        (8c -> 73)
190
191  4add sub $50                  e672f sub al,50h         (52 -> 2c)
192  4adf cp $50                   e6731 cmp al,50h
193  4ae1 jr c,$4ae7               e6733 bc 0e6739          (78 -> 72)
194  4ae3 ld b,$04                 e6735 mov ch,4h          (26 -> b5)
195  4ae5 sub $50                  e6737 sub al,50h
196  4ae7 ld c,a                   e6739 mov cl,al
197  4ae8 and $0f                  e673b and al,0fh         (76 -> 24)
198  4aea add a,a                  e673d add al,al
199  4aeb ld e,a                   .
200  4aec ld d,$00                 e673f mov ah,0h
201  4aee ld hl,$4b42              e6741 mov bw,67ab
202  4af1 add hl,de                e6744 add bw,aw
203  4af2 ld e,(hl)                e6746 mov bw,w ptr ps[bw]           not sure the prefix
204  4af3 inc hl                   .
205  4af4 ld d,(hl)                .
206  4af5 ld a,c                   .
207  4af6 and $f0                  e6749 and cl,f0h         (04 -> 80)
208  4af8 jr z,$4b05               e674c be 0e6753
209  4afa rrca                     .
210  4afb rrca                     .
211  4afc rrca                     .
212  4afd rrca                     e674e ror cl,4h          (57 -> c0)
213  4afe srl d                    .
214  4b00 rr e                     e6751 shr bw,cl          (1b -> d3)
215  4b02 dec a                    .
216  4b03 jr nz,$4afe              .
217  4b05 ld a,b                   e6753 mov al,ch
218  .                             e6755 mov dw,23h
219  4b06 out ($03),a              e6758 out dw,al
220
221
222
223
224-------------------------------------------------
225
8322656 -> ????
84227
852285c -> conditional jmp for sure
r6740r6741
142285ADDRESS_MAP_END
143286
144287static ADDRESS_MAP_START( cb2001_io, ADDRESS_SPACE_IO, 16 )
288//  ADDRESS_MAP_GLOBAL_MASK(0x00ff)
289   AM_RANGE(0x00, 0x03) AM_DEVREADWRITE8("ppi8255_0", ppi8255_r, ppi8255_w, 0xffff)   /* Input Ports */
290   AM_RANGE(0x10, 0x13) AM_DEVREADWRITE8("ppi8255_1", ppi8255_r, ppi8255_w, 0xffff)   /* DIP switches */
291   AM_RANGE(0x20, 0x21) AM_DEVREAD8("aysnd", ay8910_r, 0x00ff)
292   AM_RANGE(0x22, 0x23) AM_DEVWRITE8("aysnd", ay8910_data_address_w, 0xffff)
145293ADDRESS_MAP_END
146294
147295static INPUT_PORTS_START( cb2001 )
296   PORT_START("IN0")
297   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
298   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
299   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SLOT_STOP2 ) PORT_NAME("Stop 2 / Big")
300   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SLOT_STOP1 ) PORT_NAME("Stop 1 / D-UP")
301   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SLOT_STOP_ALL ) PORT_NAME("Stop All / Take")
302   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_GAMBLE_BET )
303   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SLOT_STOP3 ) PORT_NAME("Stop 3 / Small / Info")
304   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 ) PORT_NAME("Start")
305
306   PORT_START("IN1")
307   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
308   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
309   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(2)   /* Coin B */
310   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
311   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN4 ) PORT_IMPULSE(2)   /* Coin D */
312   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN3 ) PORT_IMPULSE(2)   /* Coin C */
313   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_GAMBLE_KEYIN )
314   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2)   /* Coin A */
315
316   PORT_START("IN2")
317   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
318   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
319   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
320   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
321   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_GAMBLE_KEYOUT ) PORT_NAME("Key Out / Attendant")
322   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
323   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_GAMBLE_SERVICE ) PORT_NAME("Settings")
324   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_GAMBLE_BOOK ) PORT_NAME("Stats")
325
326   PORT_START("DSW1")
327   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )   PORT_DIPLOCATION("DSW1:1")   /* OK */
328   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
329   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
330   PORT_DIPNAME( 0x02, 0x02, "Hopper Out Switch" )   PORT_DIPLOCATION("DSW1:2")   /* OK */
331   PORT_DIPSETTING(    0x02, "Active Low" )
332   PORT_DIPSETTING(    0x00, "Active High" )
333   PORT_DIPNAME( 0x04, 0x04, "Payout Mode" )      PORT_DIPLOCATION("DSW1:3")   /* OK */
334   PORT_DIPSETTING(    0x04, "Payout Switch" )
335   PORT_DIPSETTING(    0x00, "Automatic" )
336   PORT_DIPNAME( 0x08, 0x00, "W-UP '7'" )         PORT_DIPLOCATION("DSW1:4")   /* not checked */
337   PORT_DIPSETTING(    0x08, "Loss" )
338   PORT_DIPSETTING(    0x00, "Even" )
339   PORT_DIPNAME( 0x10, 0x00, "W-UP Pay Rate" )      PORT_DIPLOCATION("DSW1:5")   /* OK */
340   PORT_DIPSETTING(    0x00, "80%" )
341   PORT_DIPSETTING(    0x10, "90%" )
342   PORT_DIPNAME( 0x20, 0x00, "W-UP Game" )         PORT_DIPLOCATION("DSW1:6")   /* OK */
343   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
344   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
345   PORT_DIPNAME( 0xc0, 0xc0, "Bet Max" )         PORT_DIPLOCATION("DSW1:7,8")   /* OK */
346   PORT_DIPSETTING(    0x00, "16" )
347   PORT_DIPSETTING(    0x40, "32" )
348   PORT_DIPSETTING(    0x80, "64" )
349   PORT_DIPSETTING(    0xc0, "96" )
350
351   PORT_START("DSW2")
352   PORT_DIPNAME( 0x07, 0x00, "Main Game Pay Rate" )   PORT_DIPLOCATION("DSW2:1,2,3")   /* OK */
353   PORT_DIPSETTING(    0x07, "35%" )
354   PORT_DIPSETTING(    0x06, "40%" )
355   PORT_DIPSETTING(    0x05, "45%" )
356   PORT_DIPSETTING(    0x04, "50%" )
357   PORT_DIPSETTING(    0x03, "55%" )
358   PORT_DIPSETTING(    0x02, "60%" )
359   PORT_DIPSETTING(    0x01, "65%" )
360   PORT_DIPSETTING(    0x00, "70%" )
361   PORT_DIPNAME( 0x18, 0x00, "Hopper Limit" )         PORT_DIPLOCATION("DSW2:4,5")   /* OK */
362   PORT_DIPSETTING(    0x18, "300" )
363   PORT_DIPSETTING(    0x10, "500" )
364   PORT_DIPSETTING(    0x08, "1000" )
365   PORT_DIPSETTING(    0x00, "Unlimited" )
366   PORT_DIPNAME( 0x20, 0x00, "100 Odds Sound" )      PORT_DIPLOCATION("DSW2:6")   /* not checked */
367   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
368   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
369   PORT_DIPNAME( 0x40, 0x40, "Key-In Type" )         PORT_DIPLOCATION("DSW2:7")   /* OK */
370   PORT_DIPSETTING(    0x40, "A-Type" )
371   PORT_DIPSETTING(    0x00, "B-Type" )
372   PORT_DIPNAME( 0x80, 0x00, "Center Super 7 Bet Limit" )   PORT_DIPLOCATION("DSW2:8")   /* related with DSW 4-6 */
373   PORT_DIPSETTING(    0x80, "Unlimited" )
374   PORT_DIPSETTING(    0x00, "Limited" )
375
376   PORT_START("DSW3")
377   PORT_DIPNAME( 0x03, 0x03, "Key In Rate" ) PORT_DIPLOCATION("DSW3:1,2")   /* OK */
378   PORT_DIPSETTING(    0x00, "1 Coin/10 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40) /* A-Type */
379   PORT_DIPSETTING(    0x01, "1 Coin/20 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40)
380   PORT_DIPSETTING(    0x02, "1 Coin/50 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40)
381   PORT_DIPSETTING(    0x03, "1 Coin/100 Credits" ) PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x40)
382   PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )     PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00) /* B-Type */
383   PORT_DIPSETTING(    0x01, "1 Coin/10 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00)
384   PORT_DIPSETTING(    0x02, "1 Coin/25 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00)
385   PORT_DIPSETTING(    0x03, "1 Coin/50 Credits" )  PORT_CONDITION("DSW2",0x40,PORTCOND_EQUALS,0x00)
386   PORT_DIPNAME( 0x0c, 0x0c, "Coin A Rate" ) PORT_DIPLOCATION("DSW3:3,4")   /* OK */
387   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
388   PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
389   PORT_DIPSETTING(    0x08, DEF_STR( 1C_5C ) )
390   PORT_DIPSETTING(    0x0c, "1 Coin/10 Credits" )
391   PORT_DIPNAME( 0x30, 0x30, "Coin D Rate" ) PORT_DIPLOCATION("DSW3:5,6")   /* OK */
392   PORT_DIPSETTING(    0x30, DEF_STR( 5C_1C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10) /* C-Type */
393   PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10)
394   PORT_DIPSETTING(    0x10, DEF_STR( 1C_1C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10)
395   PORT_DIPSETTING(    0x00, DEF_STR( 1C_2C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x10)
396   PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )    PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00) /* D-Type */
397   PORT_DIPSETTING(    0x10, "1 Coin/10 Credits" ) PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00)
398   PORT_DIPSETTING(    0x20, "1 Coin/25 Credits" ) PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00)
399   PORT_DIPSETTING(    0x30, "1 Coin/50 Credits" ) PORT_CONDITION("DSW4",0x10,PORTCOND_EQUALS,0x00)
400   PORT_DIPNAME( 0xc0, 0xc0, "Coin C Rate" ) PORT_DIPLOCATION("DSW3:7,8")   /* OK */
401   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
402   PORT_DIPSETTING(    0x40, DEF_STR( 1C_2C ) )
403   PORT_DIPSETTING(    0x80, DEF_STR( 1C_5C ) )
404   PORT_DIPSETTING(    0xc0, "1 Coin/10 Credits" )
405
406   PORT_START("DSW4")
407   PORT_DIPNAME( 0x07, 0x07, "Credit Limit" )            PORT_DIPLOCATION("DSW4:1,2,3")   /* not checked */
408   PORT_DIPSETTING(    0x07, "5,000" )
409   PORT_DIPSETTING(    0x06, "10,000" )
410   PORT_DIPSETTING(    0x05, "20,000" )
411   PORT_DIPSETTING(    0x04, "30,000" )
412   PORT_DIPSETTING(    0x03, "40,000" )
413   PORT_DIPSETTING(    0x02, "50,000" )
414   PORT_DIPSETTING(    0x01, "100,000" )
415   PORT_DIPSETTING(    0x00, "Unlimited" )
416   PORT_DIPNAME( 0x08, 0x08, "Display Of Payout Limit" ) PORT_DIPLOCATION("DSW4:4") /* not working */
417   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
418   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
419   PORT_DIPNAME( 0x10, 0x10, "Type Of Coin D" )          PORT_DIPLOCATION("DSW4:5")   /* OK */
420   PORT_DIPSETTING(    0x10, "C-Type" )
421   PORT_DIPSETTING(    0x00, "D-Type" )
422   PORT_DIPNAME( 0x20, 0x20, "Min. Bet For Bonus Play" ) PORT_DIPLOCATION("DSW4:6")   /* OK */
423   PORT_DIPSETTING(    0x20, "16 Bet" )
424   PORT_DIPSETTING(    0x00, "8 Bet" )
425   PORT_DIPNAME( 0x40, 0x40, "Reel Speed" )              PORT_DIPLOCATION("DSW4:7")   /* OK */
426   PORT_DIPSETTING(    0x40, DEF_STR( Low ) )
427   PORT_DIPSETTING(    0x00, DEF_STR( High ) )
428   PORT_DIPNAME( 0x80, 0x80, "Hopper Out By Coin A" )    PORT_DIPLOCATION("DSW4:8")   /* not checked */
429   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
430   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
431
432   PORT_START("DSW5")
433   PORT_DIPNAME( 0x01, 0x00, "Display Of Doll On Demo" )          PORT_DIPLOCATION("DSW5:1")   /* not working */
434   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
435   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
436   PORT_DIPNAME( 0x06, 0x06, "Coin In Limit" )                    PORT_DIPLOCATION("DSW5:2,3")   /* not checked */
437   PORT_DIPSETTING(    0x06, "1,000" )
438   PORT_DIPSETTING(    0x04, "5,000" )
439   PORT_DIPSETTING(    0x02, "10,000" )
440   PORT_DIPSETTING(    0x00, "20,000" )
441   PORT_DIPNAME( 0x18, 0x18, "Condition For 3 Kind Of Bonus" )    PORT_DIPLOCATION("DSW5:4,5")   /* not checked */
442   PORT_DIPSETTING(    0x18, "12-7-1" )
443   PORT_DIPSETTING(    0x10, "9-5-1" )
444   PORT_DIPSETTING(    0x08, "6-3-1" )
445   PORT_DIPSETTING(    0x00, "3-2-1" )
446   PORT_DIPNAME( 0x20, 0x00, "Display Of Doll At All Fr. Bonus" ) PORT_DIPLOCATION("DSW5:6")   /* not checked */
447   PORT_DIPSETTING(    0x20, DEF_STR( Low ) )
448   PORT_DIPSETTING(    0x00, DEF_STR( High ) )
449   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )                 PORT_DIPLOCATION("DSW5:7")   /* listed as unused */
450   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
451   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
452   PORT_DIPNAME( 0x80, 0x80, "Test Mode For Disp. Of Doll" )      PORT_DIPLOCATION("DSW5:8")   /* not working */
453   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
454   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
455
148456INPUT_PORTS_END
149457
150458static INTERRUPT_GEN( vblank_irq )
r6740r6741
200508   }
201509}
202510
511static const ppi8255_interface cb2001_ppi8255_intf[2] =
512{
513   {   /* A, B & C set as input */
514      DEVCB_INPUT_PORT("IN0"),   /* Port A read */
515      DEVCB_INPUT_PORT("IN1"),   /* Port B read */
516      DEVCB_INPUT_PORT("IN2"),   /* Port C read */
517      DEVCB_NULL,               /* Port A write */
518      DEVCB_NULL,               /* Port B write */
519      DEVCB_NULL               /* Port C write */
520   },
521   {   /* A, B & C set as input */
522      DEVCB_INPUT_PORT("DSW1"),   /* Port A read */
523      DEVCB_INPUT_PORT("DSW2"),   /* Port B read */
524      DEVCB_INPUT_PORT("DSW3"),   /* Port C read */
525      DEVCB_NULL,               /* Port A write */
526      DEVCB_NULL,               /* Port B write */
527      DEVCB_NULL               /* Port C write */
528   }
529};
203530
531static const ay8910_interface cb2001_ay8910_config =
532{
533   AY8910_LEGACY_OUTPUT,
534   AY8910_DEFAULT_LOADS,
535   DEVCB_INPUT_PORT("DSW4"),
536   DEVCB_INPUT_PORT("DSW5"),
537   DEVCB_NULL,
538   DEVCB_NULL
539};
540
204541static const nec_config cb2001_config = { cb2001_decryption_table, };
205542static MACHINE_DRIVER_START( cb2001 )
206543   MDRV_CPU_ADD("maincpu", V30, 20000000) // CPU91A-011-0016JK004; encrypted cpu like nec v25/35 used in some irem game
r6740r6741
209546   MDRV_CPU_IO_MAP(cb2001_io)
210547   MDRV_CPU_VBLANK_INT("screen", vblank_irq)
211548
549   MDRV_PPI8255_ADD( "ppi8255_0", cb2001_ppi8255_intf[0] )
550   MDRV_PPI8255_ADD( "ppi8255_1", cb2001_ppi8255_intf[1] )
551
212552   MDRV_GFXDECODE(cb2001)
213553
214554   MDRV_PALETTE_INIT( cb2001 )
r6740r6741
224564
225565   MDRV_VIDEO_START(cb2001)
226566   MDRV_VIDEO_UPDATE(cb2001)
567
568   /* sound hardware */
569   MDRV_SPEAKER_STANDARD_MONO("mono")
570   MDRV_SOUND_ADD("aysnd", AY8910, 1500000) // wrong
571   MDRV_SOUND_CONFIG(cb2001_ay8910_config)
572   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
227573MACHINE_DRIVER_END
228574
229575
src/mame/drivers/funkyjet.c
r6740r6741
9393#include "sound/2151intf.h"
9494#include "sound/okim6295.h"
9595
96#include "decocrpt.h"
97#include "decoprot.h"
98#include "deco16ic.h"
96#include "includes/decocrpt.h"
97#include "includes/decoprot.h"
98#include "includes/deco16ic.h"
9999
100100VIDEO_START( funkyjet );
101101VIDEO_UPDATE( funkyjet );
src/mame/drivers/xexex.c
r6740r6741
6464#include "driver.h"
6565#include "cpu/m68000/m68000.h"
6666#include "deprecat.h"
67#include "video/konamiic.h"
67#include "video/konicdev.h"
6868#include "cpu/z80/z80.h"
69#include "machine/eeprom.h"
69#include "machine/eepromdev.h"
7070#include "sound/k054539.h"
7171#include "sound/2151intf.h"
7272#include "sound/flt_vol.h"
73#include "konamipt.h"
73#include "includes/konamipt.h"
7474
7575VIDEO_START( xexex );
7676VIDEO_UPDATE( xexex );
7777void xexex_set_alpha(int on);
7878
79extern void xexex_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask);
80extern void xexex_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags);
81
7982static MACHINE_START( xexex );
8083static MACHINE_RESET( xexex );
8184
8285static UINT16 *xexex_workram;
8386static UINT16 cur_control2;
84static int init_eeprom_count;
8587static INT32 cur_sound_region, xexex_strip0x1a;
8688static int suspension_active, resume_trigger;
8789static emu_timer *dmadelay_timer;
r6740r6741
99101   "0100110000000" /* unlock command */
100102};
101103
102static NVRAM_HANDLER( xexex )
103{
104   if (read_or_write)
105      eeprom_save(file);
106   else
107   {
108      eeprom_init(machine, &eeprom_intf);
109
110      if (file)
111      {
112         init_eeprom_count = 0;
113         eeprom_load(file);
114      }
115      else
116         init_eeprom_count = 10;
117   }
118}
119
120
121104#if 0 // (for reference; do not remove)
122105
123106/* the interface with the 053247 is weird. The chip can address only 0x1000 bytes */
r6740r6741
125108/* A1, A5 and A6 don't go to the 053247. */
126109static READ16_HANDLER( K053247_scattered_word_r )
127110{
111   const device_config *k053246 = devtag_get_device(space->machine, "k053246");
112
128113   if (offset & 0x0031)
129114      return space->machine->generic.spriteram.u16[offset];
130115   else
131116   {
132117      offset = ((offset & 0x000e) >> 1) | ((offset & 0x3fc0) >> 3);
133      return K053247_word_r(offset,mem_mask);
118      return k053247_word_r(k053246, offset, mem_mask);
134119   }
135120}
136121
137122static WRITE16_HANDLER( K053247_scattered_word_w )
138123{
124   const device_config *k053246 = devtag_get_device(space->machine, "k053246");
125
139126   if (offset & 0x0031)
140127      COMBINE_DATA(space->machine->generic.spriteram.u16+offset);
141128   else
142129   {
143130      offset = ((offset & 0x000e) >> 1) | ((offset & 0x3fc0) >> 3);
144      K053247_word_w(offset,data,mem_mask);
131      k053247_word_w(k053246, offset, data, mem_mask);
145132   }
146133}
147134
r6740r6741
150137
151138static void xexex_objdma(running_machine *machine, int limiter)
152139{
140   const device_config *k053246 = devtag_get_device(machine, "k053246");
153141   int counter, num_inactive;
154142   UINT16 *src, *dst;
155143
156144   counter = frame;
157145   frame = video_screen_get_frame_number(machine->primary_screen);
158   if (limiter && counter == frame) return; // make sure we only do DMA transfer once per frame
146   if (limiter && counter == frame)
147      return; // make sure we only do DMA transfer once per frame
159148
160   K053247_export_config(&dst, 0, 0, 0, &counter);
149   k053247_get_ram(k053246, &dst);
150   counter = k053247_get_dy(k053246);
161151   src = machine->generic.spriteram.u16;
162152   num_inactive = counter = 256;
163153
r6740r6741
201191}
202192
203193
204static READ16_HANDLER( control1_r )
194static void parse_control2( running_machine *machine )
205195{
206   int res;
196   const device_config *k053246 = devtag_get_device(machine, "k053246");
207197
208   /* bit 0 is EEPROM data */
209   /* bit 1 is EEPROM ready */
210   /* bit 3 is service button */
211   res = input_port_read(space->machine, "EEPROM");
212
213   if (init_eeprom_count)
214   {
215      init_eeprom_count--;
216      res &= 0xf7;
217   }
218
219   return res;
220}
221
222static void parse_control2(void)
223{
224198   /* bit 0  is data */
225199   /* bit 1  is cs (active low) */
226200   /* bit 2  is clock (active high) */
227201   /* bit 5  is enable irq 6 */
228202   /* bit 6  is enable irq 5 */
229203   /* bit 11 is watchdog */
204   input_port_write(machine, "EEPROMOUT", cur_control2, 0xff);
230205
231   eeprom_write_bit(cur_control2 & 0x01);
232   eeprom_set_cs_line((cur_control2 & 0x02) ? CLEAR_LINE : ASSERT_LINE);
233   eeprom_set_clock_line((cur_control2 & 0x04) ? ASSERT_LINE : CLEAR_LINE);
234
235206   /* bit 8 = enable sprite ROM reading */
236   K053246_set_OBJCHA_line((cur_control2 & 0x0100) ? ASSERT_LINE : CLEAR_LINE);
207   k053246_set_objcha_line(k053246, (cur_control2 & 0x0100) ? ASSERT_LINE : CLEAR_LINE);
237208
238209   /* bit 9 = disable alpha channel on K054157 plane 0 (under investigation) */
239210   xexex_set_alpha(!(cur_control2 & 0x200));
r6740r6741
247218static WRITE16_HANDLER( control2_w )
248219{
249220   COMBINE_DATA(&cur_control2);
250   parse_control2();
221   parse_control2(space->machine);
251222}
252223
253224
r6740r6741
305276   if (cur_control2 & 0x0040)
306277   {
307278      // foul-proof (CPU0 could be deactivated while we wait)
308      if (suspension_active) { suspension_active = 0; cpuexec_trigger(machine, resume_trigger); }
279      if (suspension_active)
280      {
281         suspension_active = 0;
282         cpuexec_trigger(machine, resume_trigger);
283      }
309284
310285      // IRQ 5 is the "object DMA end interrupt" and shouldn't be triggered
311286      // if object data isn't ready for DMA within the frame.
r6740r6741
315290
316291static INTERRUPT_GEN( xexex_interrupt )
317292{
318   if (suspension_active) { suspension_active = 0; cpuexec_trigger(device->machine, resume_trigger); }
293   const device_config *k053246 = devtag_get_device(device->machine, "k053246");
319294
295   if (suspension_active)
296   {
297      suspension_active = 0;
298      cpuexec_trigger(device->machine, resume_trigger);
299   }
300
320301   switch (cpu_getiloops(device))
321302   {
322303      case 0:
r6740r6741
326307      break;
327308
328309      case 1:
329         if (K053246_is_IRQ_enabled())
310         if (k053246_is_irq_enabled(k053246))
330311         {
331312            // OBJDMA starts at the beginning of V-blank
332313            xexex_objdma(device->machine, 0);
r6740r6741
354335
355336   AM_RANGE(0x090000, 0x097fff) AM_RAM AM_BASE_GENERIC(spriteram)         // K053247 sprite RAM
356337   AM_RANGE(0x098000, 0x09ffff) AM_READWRITE(spriteram16_mirror_r, spriteram16_mirror_w)   // K053247 sprite RAM mirror read
357   AM_RANGE(0x0c0000, 0x0c003f) AM_WRITE(K056832_word_w)            // VACSET (K054157)
358   AM_RANGE(0x0c2000, 0x0c2007) AM_WRITE(K053246_word_w)            // OBJSET1
359   AM_RANGE(0x0c4000, 0x0c4001) AM_READ(K053246_word_r)            // Passthrough to sprite roms
360   AM_RANGE(0x0c6000, 0x0c7fff) AM_READWRITE(K053250_0_ram_r, K053250_0_ram_w)   // K053250 "road" RAM
361   AM_RANGE(0x0c8000, 0x0c800f) AM_READWRITE(K053250_0_r, K053250_0_w)
362   AM_RANGE(0x0ca000, 0x0ca01f) AM_WRITE(K054338_word_w)            // CLTC
363   AM_RANGE(0x0cc000, 0x0cc01f) AM_WRITE(K053251_lsb_w)            // priority encoder
364   AM_RANGE(0x0d0000, 0x0d001f) AM_WRITE(K053252_word_w)            // CCU
338   AM_RANGE(0x0c0000, 0x0c003f) AM_DEVWRITE("k056832", k056832_word_w)            // VACSET (K054157)
339   AM_RANGE(0x0c2000, 0x0c2007) AM_DEVWRITE("k053246", k053246_word_w)            // OBJSET1
340   AM_RANGE(0x0c4000, 0x0c4001) AM_DEVREAD("k053246", k053246_word_r)            // Passthrough to sprite roms
341   AM_RANGE(0x0c6000, 0x0c7fff) AM_DEVREADWRITE("k053250", k053250_ram_r, k053250_ram_w)   // K053250 "road" RAM
342   AM_RANGE(0x0c8000, 0x0c800f) AM_DEVREADWRITE("k053250", k053250_r, k053250_w)
343   AM_RANGE(0x0ca000, 0x0ca01f) AM_DEVWRITE("k054338", k054338_word_w)            // CLTC
344   AM_RANGE(0x0cc000, 0x0cc01f) AM_DEVWRITE("k053251", k053251_lsb_w)            // priority encoder
345   AM_RANGE(0x0d0000, 0x0d001f) AM_DEVWRITE("k053252", k053252_word_w)            // CCU
365346   AM_RANGE(0x0d4000, 0x0d4001) AM_WRITE(sound_irq_w)
366347   AM_RANGE(0x0d600c, 0x0d600d) AM_WRITE(sound_cmd1_w)
367348   AM_RANGE(0x0d600e, 0x0d600f) AM_WRITE(sound_cmd2_w)
368349   AM_RANGE(0x0d6014, 0x0d6015) AM_READ(sound_status_r)
369350   AM_RANGE(0x0d6000, 0x0d601f) AM_RAM                           // sound regs fall through
370   AM_RANGE(0x0d8000, 0x0d8007) AM_WRITE(K056832_b_word_w)            // VSCCS regs
351   AM_RANGE(0x0d8000, 0x0d8007) AM_DEVWRITE("k056832", k056832_b_word_w)            // VSCCS regs
371352   AM_RANGE(0x0da000, 0x0da001) AM_READ_PORT("P1")
372353   AM_RANGE(0x0da002, 0x0da003) AM_READ_PORT("P2")
373354   AM_RANGE(0x0dc000, 0x0dc001) AM_READ_PORT("SYSTEM")
374   AM_RANGE(0x0dc002, 0x0dc003) AM_READ(control1_r)
355   AM_RANGE(0x0dc002, 0x0dc003) AM_READ_PORT("EEPROM")
375356   AM_RANGE(0x0de000, 0x0de001) AM_READWRITE(control2_r, control2_w)
376357   AM_RANGE(0x100000, 0x17ffff) AM_ROM
377   AM_RANGE(0x180000, 0x181fff) AM_READWRITE(K056832_ram_word_r, K056832_ram_word_w)
378   AM_RANGE(0x182000, 0x183fff) AM_READWRITE(K056832_ram_word_r, K056832_ram_word_w)
379   AM_RANGE(0x190000, 0x191fff) AM_READ(K056832_rom_word_r)      // Passthrough to tile roms
380   AM_RANGE(0x1a0000, 0x1a1fff) AM_READ(K053250_0_rom_r)
358   AM_RANGE(0x180000, 0x181fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w)
359   AM_RANGE(0x182000, 0x183fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w)
360   AM_RANGE(0x190000, 0x191fff) AM_DEVREAD("k056832", k056832_rom_word_r)      // Passthrough to tile roms
361   AM_RANGE(0x1a0000, 0x1a1fff) AM_DEVREAD("k053250", k053250_rom_r)
381362   AM_RANGE(0x1b0000, 0x1b1fff) AM_RAM_WRITE(paletteram16_xrgb_word_be_w) AM_BASE_GENERIC(paletteram)
382363
383364#if XE_DEBUG
384   AM_RANGE(0x0c0000, 0x0c003f) AM_READ(K056832_word_r)
385   AM_RANGE(0x0c2000, 0x0c2007) AM_READ(K053246_reg_word_r)
386   AM_RANGE(0x0ca000, 0x0ca01f) AM_READ(K054338_word_r)
387   AM_RANGE(0x0cc000, 0x0cc01f) AM_READ(K053251_lsb_r)
388   AM_RANGE(0x0d0000, 0x0d001f) AM_READ(K053252_word_r)
389   AM_RANGE(0x0d8000, 0x0d8007) AM_READ(K056832_b_word_r)
365   AM_RANGE(0x0c0000, 0x0c003f) AM_DEVREAD("k056832", k056832_word_r)
366   AM_RANGE(0x0c2000, 0x0c2007) AM_DEVREAD("k053246", k053246_reg_word_r)
367   AM_RANGE(0x0ca000, 0x0ca01f) AM_DEVREAD("k054338", k054338_word_r)
368   AM_RANGE(0x0cc000, 0x0cc01f) AM_DEVREAD("k053251", k053251_lsb_r)
369   AM_RANGE(0x0d0000, 0x0d001f) AM_DEVREAD("k053252", k053252_word_r)
370   AM_RANGE(0x0d8000, 0x0d8007) AM_DEVREAD("k056832", k056832_b_word_r)
390371#endif
391372
392373ADDRESS_MAP_END
r6740r6741
424405   KONAMI16_LSB(2, IPT_UNKNOWN, IPT_START2 )
425406
426407   PORT_START("EEPROM")
427   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
408   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
428409   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM ready (always 1) */
429410   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
430411   PORT_SERVICE_NO_TOGGLE( 0x08, IP_ACTIVE_LOW )
431412   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNKNOWN )
413
414   PORT_START( "EEPROMOUT" )
415   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
416   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
417   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
432418INPUT_PORTS_END
433419
434420
r6740r6741
439425   ym_set_mixing
440426};
441427
428static const k054338_interface xexex_k054338_intf =
429{
430   "screen",
431   0,
432   "none"
433};
434
435
436static const k053250_interface xexex_k053250_intf =
437{
438   "screen",
439   "gfx3",
440   -5, -16
441};
442
443static const k056832_interface xexex_k056832_intf =
444{
445   "gfx1", 0,
446   K056832_BPP_4,
447   1, 0,
448   KONAMI_ROM_DEINTERLEAVE_2,
449   xexex_tile_callback, "none"
450};
451
452static const k053247_interface xexex_k053246_intf =
453{
454   "screen",
455   "gfx2", 1,
456   NORMAL_PLANE_ORDER,
457   -48, 32,
458   KONAMI_ROM_DEINTERLEAVE_4,
459   xexex_sprite_callback
460};
461
442462static MACHINE_DRIVER_START( xexex )
443463
444464   /* basic machine hardware */
r6740r6741
455475
456476   MDRV_MACHINE_START(xexex)
457477   MDRV_MACHINE_RESET(xexex)
458   MDRV_NVRAM_HANDLER(xexex)
459478
479   MDRV_EEPROM_NODEFAULT_ADD("eeprom", eeprom_intf)
480
460481   /* video hardware */
461482   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_BEFORE_VBLANK)
462483
r6740r6741
473494   MDRV_VIDEO_START(xexex)
474495   MDRV_VIDEO_UPDATE(xexex)
475496
497   MDRV_K056832_ADD("k056832", xexex_k056832_intf)
498   MDRV_K053246_ADD("k053246", xexex_k053246_intf)
499   MDRV_K053250_ADD("k053250", xexex_k053250_intf)
500   MDRV_K053251_ADD("k053251")
501   MDRV_K053252_ADD("k053252")
502   MDRV_K054338_ADD("k054338", xexex_k054338_intf)
503
476504   /* sound hardware */
477505   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
478506
r6740r6741
599627
600628static STATE_POSTLOAD( xexex_postload )
601629{
602   parse_control2();
630   parse_control2(machine);
603631   reset_sound_region(machine);
604632}
605633
r6740r6741
610638   state_save_register_postload(machine, xexex_postload, NULL);
611639
612640   resume_trigger = 1000;
613   init_eeprom_count = 0;
614641
615642   dmadelay_timer = timer_alloc(machine, dmaend_callback, NULL);
616643}
r6740r6741
625652//      *(UINT16 *)(memory_region(machine, "maincpu") + 0x00008) = 0x5500;
626653      xexex_strip0x1a = 1;
627654   }
628
629   konami_rom_deinterleave_2(machine, "gfx1");
630   konami_rom_deinterleave_4(machine, "gfx2");
631   K053250_unpack_pixels(machine, "gfx3");
632655}
633656
634657GAME( 1991, xexex,  0,     xexex, xexex, xexex, ROT0, "Konami", "Xexex (ver EAA)", 0 )
src/mame/drivers/skullxbo.c
r6740r6741
2020#include "driver.h"
2121#include "cpu/m68000/m68000.h"
2222#include "audio/atarijsa.h"
23#include "skullxbo.h"
23#include "includes/skullxbo.h"
2424
2525
2626
r6740r6741
7070}
7171
7272
73static MACHINE_START( skullxbo )
74{
75   atarigen_init(machine);
76}
77
78
7379static MACHINE_RESET( skullxbo )
7480{
7581   skullxbo_state *state = (skullxbo_state *)machine->driver_data;
r6740r6741
255261   MDRV_CPU_PROGRAM_MAP(main_map)
256262   MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen)
257263
264   MDRV_MACHINE_START(skullxbo)
258265   MDRV_MACHINE_RESET(skullxbo)
259266   MDRV_NVRAM_HANDLER(atarigen)
260267
src/mame/drivers/sliver.c
r6740r6741
9090static int tmp_counter;
9191static int clr_offset=0;
9292
93static UINT8 *colorram;
9394static bitmap_t *sliver_bitmap_fg;
9495static bitmap_t *sliver_bitmap_bg;
9596
r6740r6741
183184
184185static WRITE16_HANDLER( sliver_RAMDAC_color_w )
185186{
186   space->machine->generic.colorram.u8[clr_offset]=data;
187   colorram[clr_offset]=data;
187188   clr_offset=(clr_offset+1)%768;
188189}
189190
r6740r6741
214215   if(y<0 ||x<0 || x>383 || y> 255) return;
215216   addr*=3;
216217
217   b=machine->generic.colorram.u8[addr]<<2;
218   g=machine->generic.colorram.u8[addr+1]<<2;
219   r=machine->generic.colorram.u8[addr+2]<<2;
218   b=colorram[addr]<<2;
219   g=colorram[addr+1]<<2;
220   r=colorram[addr+2]<<2;
220221
221222   if (sliver_bitmap_fg->bpp == 32)
222223   {
r6740r6741
590591static DRIVER_INIT(sliver)
591592{
592593   jpeg_addr = -1;
593   machine->generic.colorram.u8=auto_alloc_array(machine, UINT8, 256*3);
594   colorram=auto_alloc_array(machine, UINT8, 256*3);
594595}
595596
596597GAME( 1996, sliver, 0,        sliver, sliver, sliver, ROT0,  "Hollow Corp", "Sliver", GAME_IMPERFECT_GRAPHICS )
src/mame/drivers/epos.c
r6740r6741
3232#include "cpu/z80/z80.h"
3333#include "machine/8255ppi.h"
3434#include "sound/ay8910.h"
35#include "epos.h"
35#include "includes/epos.h"
3636
3737static WRITE8_HANDLER( dealer_decrypt_rom )
3838{
src/mame/drivers/spiders.c
r6740r6741
194194#include "video/mc6845.h"
195195#include "machine/6821pia.h"
196196#include "machine/74123.h"
197#include "spiders.h"
197#include "includes/spiders.h"
198198
199199
200200#define MAIN_CPU_MASTER_CLOCK   (11200000)
src/mame/drivers/subsino.c
r6740r6741
33                        -= Subsino's Gambling Games =-
44
55                     driver by   Luca Elia (l.elia@tin.it)
6            additional work by   David Haywood and Angelo Salese
67
78CPU:    Z180 (in a black box)
89GFX:    1 Tilemap (8x8 tiles, no scrolling)
r6740r6741
1011SOUND:  M6295, YM2413 or YM3812
1112OTHER:  Battery
1213
13Preliminary driver, only "Super Rider" works since it has valid z180 code.
14Note that e.g. "Shark Party" has snippets of valid code (6f - ff).
15
1614To enter test mode in smoto, keep F2 pressed during boot.
1715
1816***************************************************************************/
r6740r6741
2826                                Video Hardware
2927***************************************************************************/
3028
29static UINT8 *videoram;
30static UINT8 *colorram;
3131static tilemap *tmap;
3232static int tiles_offset;
3333
r6740r6741
4040
4141static WRITE8_HANDLER( subsino_videoram_w )
4242{
43   space->machine->generic.videoram.u8[offset] = data;
43   videoram[offset] = data;
4444   tilemap_mark_tile_dirty(tmap, offset);
4545}
4646
4747static WRITE8_HANDLER( subsino_colorram_w )
4848{
49   space->machine->generic.colorram.u8[offset] = data;
49   colorram[offset] = data;
5050   tilemap_mark_tile_dirty(tmap, offset);
5151}
5252
5353static TILE_GET_INFO( get_tile_info )
5454{
55   UINT16 code = machine->generic.videoram.u8[ tile_index ] + (machine->generic.colorram.u8[ tile_index ] << 8);
55   UINT16 code = videoram[ tile_index ] + (colorram[ tile_index ] << 8);
5656   UINT16 color = (code >> 8) & 0x0f;
5757   code = ((code & 0xf000) >> 4) + ((code & 0xff) >> 0);
5858   code += tiles_offset;
r6740r6741
7575
7676static PALETTE_INIT( subsino_2proms )
7777{
78   // To be done (only 2 roms?)
78   int i,r,g,b,val;
79   int bit0,bit1,bit2;
80
81   for (i = 0; i < 256; i++)
82   {
83      val = (color_prom[i+0x100]) | (color_prom[i+0x000]<<4);
84
85      bit0 = 0;
86      bit1 = (val >> 6) & 0x01;
87      bit2 = (val >> 7) & 0x01;
88      b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
89      bit0 = (val >> 3) & 0x01;
90      bit1 = (val >> 4) & 0x01;
91      bit2 = (val >> 5) & 0x01;
92      g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
93      bit0 = (val >> 0) & 0x01;
94      bit1 = (val >> 1) & 0x01;
95      bit2 = (val >> 2) & 0x01;
96      r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
97
98      palette_set_color(machine, i, MAKE_RGB(r, g, b));
99   }
79100}
80101
81102static PALETTE_INIT( subsino_3proms )
82103{
83   int i;
104   int i,r,g,b,val;
105   int bit0,bit1,bit2;
106
84107   for (i = 0; i < 256; i++)
85      palette_set_color_rgb(machine,i,   pal2bit(color_prom[i+0x200]),
86                                 pal3bit(color_prom[i+0x100]),
87                                 pal3bit(color_prom[i+0x000])   );
108   {
109      val = (color_prom[i+0x000]) | (color_prom[i+0x100]<<3) | (color_prom[i+0x200]<<6);
110
111      bit0 = 0;
112      bit1 = (val >> 7) & 0x01;
113      bit2 = (val >> 6) & 0x01;
114      b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
115      bit0 = (val >> 5) & 0x01;
116      bit1 = (val >> 4) & 0x01;
117      bit2 = (val >> 3) & 0x01;
118      g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
119      bit0 = (val >> 2) & 0x01;
120      bit1 = (val >> 1) & 0x01;
121      bit2 = (val >> 0) & 0x01;
122      r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
123
124      palette_set_color(machine, i, MAKE_RGB(r, g, b));
125   }
88126}
89127
90128/***************************************************************************
r6740r6741
126164
127165   AM_RANGE( 0x0d01b, 0x0d01b ) AM_WRITE( subsino_tiles_offset_w )
128166
129   AM_RANGE( 0x0e000, 0x0e7ff ) AM_RAM_WRITE( subsino_colorram_w ) AM_BASE_GENERIC( colorram )
130   AM_RANGE( 0x0e800, 0x0efff ) AM_RAM_WRITE( subsino_videoram_w ) AM_BASE_GENERIC( videoram )
167   AM_RANGE( 0x0e000, 0x0e7ff ) AM_RAM_WRITE( subsino_colorram_w ) AM_BASE( &colorram )
168   AM_RANGE( 0x0e800, 0x0efff ) AM_RAM_WRITE( subsino_videoram_w ) AM_BASE( &videoram )
131169ADDRESS_MAP_END
132170
133171
172static ADDRESS_MAP_START( sharkpy_map, ADDRESS_SPACE_PROGRAM, 8 )
173   AM_RANGE( 0x09800, 0x09fff ) AM_RAM
174
175   AM_RANGE( 0x09000, 0x09000 ) AM_READ_PORT( "DSW1" )
176   AM_RANGE( 0x09001, 0x09001 ) AM_READ_PORT( "DSW2" )
177   AM_RANGE( 0x09002, 0x09002 ) AM_READ_PORT( "DSW3" )
178
179   AM_RANGE( 0x09004, 0x09004 ) AM_READ_PORT( "DSW4" )
180   AM_RANGE( 0x09005, 0x09005 ) AM_READ_PORT( "INA" )
181   AM_RANGE( 0x09006, 0x09006 ) AM_READ_PORT( "INB" )
182
183   AM_RANGE( 0x09009, 0x09009 ) AM_WRITE( subsino_out_b_w )
184   AM_RANGE( 0x0900a, 0x0900a ) AM_WRITE( subsino_out_a_w )
185
186   AM_RANGE( 0x0900c, 0x0900c ) AM_READ_PORT( "INC" )
187
188   AM_RANGE( 0x09016, 0x09017 ) AM_DEVWRITE( "ymsnd", ym3812_w )
189
190   AM_RANGE( 0x09018, 0x09018 ) AM_DEVWRITE( "oki", okim6295_w )
191
192   AM_RANGE( 0x0901b, 0x0901b ) AM_WRITE( subsino_tiles_offset_w )
193
194   AM_RANGE( 0x07800, 0x07fff ) AM_RAM
195   AM_RANGE( 0x08000, 0x087ff ) AM_RAM_WRITE( subsino_colorram_w ) AM_BASE( &colorram )
196   AM_RANGE( 0x08800, 0x08fff ) AM_RAM_WRITE( subsino_videoram_w ) AM_BASE( &videoram )
197
198   AM_RANGE( 0x00000, 0x13fff ) AM_ROM //overlap unmapped regions
199ADDRESS_MAP_END
200
201static ADDRESS_MAP_START( victor21_map, ADDRESS_SPACE_PROGRAM, 8 )
202   AM_RANGE( 0x09800, 0x09fff ) AM_RAM
203
204   AM_RANGE( 0x09002, 0x09002 ) AM_READ_PORT( "INC" )
205   AM_RANGE( 0x09004, 0x09004 ) AM_READ_PORT( "INA" )
206   AM_RANGE( 0x09005, 0x09005 ) AM_READ_PORT( "INB" )
207
208   AM_RANGE( 0x09006, 0x09006 ) AM_READ_PORT( "DSW1" )
209   AM_RANGE( 0x09007, 0x09007 ) AM_READ_PORT( "DSW2" )
210   AM_RANGE( 0x09008, 0x09008 ) AM_READ_PORT( "DSW3" )
211
212//  AM_RANGE( 0x09009, 0x09009 ) AM_WRITE( subsino_out_b_w )
213//  AM_RANGE( 0x0900a, 0x0900a ) AM_WRITE( subsino_out_a_w )
214
215//  AM_RANGE( 0x0900b, 0x0900b ) //"flash" status, bit 0
216//  AM_RANGE( 0x0900c, 0x0900c ) AM_READ_PORT( "INC" )
217
218   AM_RANGE( 0x0900e, 0x0900f ) AM_DEVWRITE( "ymsnd", ym2413_w )
219
220//  AM_RANGE( 0x09018, 0x09018 ) AM_DEVWRITE( "oki", okim6295_w )
221
222   AM_RANGE( 0x0900d, 0x0900d ) AM_WRITE( subsino_tiles_offset_w )
223
224   AM_RANGE( 0x07800, 0x07fff ) AM_RAM
225   AM_RANGE( 0x08000, 0x087ff ) AM_RAM_WRITE( subsino_videoram_w ) AM_BASE( &videoram )
226   AM_RANGE( 0x08800, 0x08fff ) AM_RAM_WRITE( subsino_colorram_w ) AM_BASE( &colorram )
227
228   AM_RANGE( 0x00000, 0x8fff ) AM_ROM //overlap unmapped regions
229   AM_RANGE( 0x10000, 0x13fff ) AM_ROM
230ADDRESS_MAP_END
231
232
233/*
234Victor 5 has a protection device that calculates the combinations of the screen.
2350x00 = you lose
2360x01 = royal flush
2370x02 = 5 of a kind
238 ...
2390x0a = jacks of better
240
2410xd9 is asked at the POST, game refuses to run otherwise.
242
243The fun thing is that the main CPU actually calculates the combinations then it routes to this port
244thru packet writes, 0xd* starts the packet, 0xe* ends the packet.
245I'm fairly sure that this thing can do a lot more, the POST check makes me think that 0xd9 is actually a result of a RNG.
246For now we'll emulate the bare minimum to let this game to work, obviously we need tests/tracing on the real board to understand
247what it is exactly and what it can possibly do.
248*/
249
250static UINT8 flash_val,flash_packet,flash_packet_start;
251
252static READ8_HANDLER( flash_r )
253{
254//  printf("R %02x\n",flash_val);
255
256   if(flash_val == 0xff)
257      return 0xd9;
258   else if(flash_val <= 0xa)
259      return flash_val;
260   else if(flash_val == 0x92)
261      return 0xeb; //protected GFXs in Cross Bingo
262   else
263      return 0xd9;
264}
265
266static WRITE8_HANDLER( flash_w )
267{
268   switch(flash_packet_start)
269   {
270      case 0:
271         flash_packet = data;
272         if((flash_packet & 0xf8) == 0xd0)
273            flash_packet_start = 1; //start of packet
274         break;
275      case 1:
276         flash_packet = data;
277         if((flash_packet & 0xf8) == 0xe0)
278            flash_packet_start = 0; //end of packet
279         else
280            flash_val = data;
281         break;
282   }
283}
284
134285static ADDRESS_MAP_START( victor5_map, ADDRESS_SPACE_PROGRAM, 8 )
135   AM_RANGE( 0x00000, 0x0bfff ) AM_ROM
136   AM_RANGE( 0x0c000, 0x0cfff ) AM_RAM
137   AM_RANGE( 0x0e000, 0x0e7ff ) AM_RAM_WRITE( subsino_colorram_w ) AM_BASE_GENERIC( colorram )
138   AM_RANGE( 0x0e800, 0x0efff ) AM_RAM_WRITE( subsino_videoram_w ) AM_BASE_GENERIC( videoram )
286   AM_IMPORT_FROM( victor21_map )
287   AM_RANGE( 0x0900a, 0x0900a ) AM_READWRITE( flash_r, flash_w )
139288ADDRESS_MAP_END
140289
141290
291static READ8_HANDLER( hwcheck_r )
292{
293   /* Wants this at POST otherwise an "Hardware Error" occurs. */
294   return 0x55;
295}
296
297static ADDRESS_MAP_START( crsbingo_map, ADDRESS_SPACE_PROGRAM, 8 )
298   AM_RANGE( 0x09800, 0x09fff ) AM_RAM
299
300   AM_RANGE( 0x09000, 0x09000 ) AM_READ_PORT( "SW1" )
301   AM_RANGE( 0x09001, 0x09001 ) AM_READ_PORT( "SW2" )
302   AM_RANGE( 0x09002, 0x09002 ) AM_READ_PORT( "INA" )
303   AM_RANGE( 0x09003, 0x09003 ) AM_READ_PORT( "INB" )
304   AM_RANGE( 0x09004, 0x09004 ) AM_READ_PORT( "INC" )
305
306   AM_RANGE( 0x09008, 0x09008 ) AM_READ_PORT( "SW4" )
307   AM_RANGE( 0x09009, 0x09009 ) AM_READ_PORT( "SW3" ) AM_WRITE( subsino_out_b_w )
308   AM_RANGE( 0x0900a, 0x0900a ) AM_READ( hwcheck_r )
309
310   AM_RANGE( 0x09010, 0x09010 ) AM_READWRITE( flash_r, flash_w )
311//  AM_RANGE( 0x09011, 0x09011 ) //"flash" status, bit 0
312//  AM_RANGE( 0x0900c, 0x0900c ) AM_READ_PORT( "INC" )
313   AM_RANGE( 0x0900c, 0x0900d ) AM_DEVWRITE( "ymsnd", ym2413_w )
314
315//  AM_RANGE( 0x09018, 0x09018 ) AM_DEVWRITE( "oki", okim6295_w )
316
317//  AM_RANGE( 0x0900d, 0x0900d ) AM_WRITE( subsino_tiles_offset_w )
318
319   AM_RANGE( 0x07800, 0x07fff ) AM_RAM
320   AM_RANGE( 0x08000, 0x087ff ) AM_RAM_WRITE( subsino_videoram_w ) AM_BASE( &videoram )
321   AM_RANGE( 0x08800, 0x08fff ) AM_RAM_WRITE( subsino_colorram_w ) AM_BASE( &colorram )
322
323   AM_RANGE( 0x00000, 0x8fff ) AM_ROM //overlap unmapped regions
324
325   AM_RANGE( 0x10000, 0x13fff ) AM_ROM //overlap unmapped regions
326
327ADDRESS_MAP_END
328
329
142330static ADDRESS_MAP_START( subsino_iomap, ADDRESS_SPACE_IO, 8 )
143331   AM_RANGE( 0x0000, 0x003f ) AM_RAM // internal regs
144332ADDRESS_MAP_END
r6740r6741
221409INPUT_PORTS_END
222410
223411static INPUT_PORTS_START( victor5 )
412
413   PORT_START( "DSW1" )
414   PORT_DIPNAME( 0x01, 0x01, "DSW1" )
415   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
416   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
417   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
418   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
419   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
420   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
421   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
422   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
423   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
424   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
425   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
426   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
427   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
428   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
429   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
430   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
431   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
432   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
433   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
434   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
435   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
436   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
437   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
438
439   PORT_START( "DSW2" )
440   PORT_DIPNAME( 0x01, 0x01, "DSW2" )
441   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
442   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
443   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
444   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
445   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
446   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
447   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
448   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
449   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
450   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
451   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
452   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
453   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
454   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
455   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
456   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
457   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
458   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
459   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
460   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
461   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
462   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
463   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
464
465   PORT_START( "DSW3" )
466   PORT_DIPNAME( 0x01, 0x01, "DSW3" )
467   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
468   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
469   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
470   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
471   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
472   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
473   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
474   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
475   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
476   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
477   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
478   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
479   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
480   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
481   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
482   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
483   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
484   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
485   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
486   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
487   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
488   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
489   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
490
491   PORT_START( "INA" )
492   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_POKER_HOLD1 )
493   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_POKER_HOLD2 )
494   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_POKER_HOLD3 ) PORT_NAME("Hold 3 / Half Take")
495   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_POKER_HOLD4 ) PORT_NAME("Hold 4 / Small")
496   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_POKER_HOLD5 ) PORT_NAME("Hold 5 / Big")
497   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_GAMBLE_DEAL )
498   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_POKER_BET )
499   PORT_DIPNAME( 0x80, 0x80, "INA" )
500   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
501   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
502
503   PORT_START( "INB" )
504   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )   // coin
505   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )   // coin
506   PORT_DIPNAME( 0x04, 0x04, "INB" )
507   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
508   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
509   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
510   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
511   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
512   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
513   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
514   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
515   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
516   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
517   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
518   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
519   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
520   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
521   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
522   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
523   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
524
525   PORT_START( "INC" )
526   PORT_DIPNAME( 0x01, 0x01, "INC" )
527   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
528   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
529   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
530   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
531   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
532   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
533   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
534   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
535   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
536   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
537   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
538   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
539   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
540   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
541   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
542   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
543   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
544   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
545   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
546   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
547   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
548   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
549   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
224550INPUT_PORTS_END
225551
552static INPUT_PORTS_START( victor21 )
553
554   PORT_START( "DSW1" )
555   PORT_DIPNAME( 0x01, 0x01, "DSW1" )
556   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
557   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
558   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
559   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
560   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
561   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
562   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
563   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
564   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
565   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
566   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
567   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
568   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
569   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
570   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
571   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
572   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
573   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
574   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
575   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
576   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
577   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
578   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
579
580   PORT_START( "DSW2" )
581   PORT_DIPNAME( 0x01, 0x01, "DSW2" )
582   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
583   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
584   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
585   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
586   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
587   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
588   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
589   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
590   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
591   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
592   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
593   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
594   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
595   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
596   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
597   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
598   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
599   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
600   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
601   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
602   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
603   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
604   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
605
606   PORT_START( "DSW3" )
607   PORT_DIPNAME( 0x01, 0x01, "DSW3" )
608   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
609   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
610   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
611   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
612   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
613   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
614   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
615   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
616   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
617   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
618   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
619   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
620   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
621   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
622   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
623   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
624   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
625   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
626   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
627   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
628   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
629   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
630   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
631
632   PORT_START( "INA" )
633   PORT_DIPNAME( 0x01, 0x01, "INA" )
634   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
635   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
636   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_GAMBLE_HALF ) PORT_NAME("Split")
637   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
638   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
639   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
640   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_GAMBLE_DEAL ) PORT_NAME("Deal / Hit")
641   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_POKER_BET )
642   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_GAMBLE_STAND )
643   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
644   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
645   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
646   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_GAMBLE_D_UP )
647
648   PORT_START( "INB" )
649   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )   // coin
650   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )   // coin
651   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )   // coin
652   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN4 )   // coin
653   PORT_SERVICE_NO_TOGGLE( 0x10, IP_ACTIVE_LOW )   // test
654   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 )   PORT_NAME("Win Rate")
655   PORT_DIPNAME( 0x40, 0x40, "INB" )
656   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
657   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
658   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
659   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
660   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
661
662   PORT_START( "INC" )
663   PORT_DIPNAME( 0x01, 0x01, "INC" )
664   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
665   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
666   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
667   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
668   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
669   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE2 )   PORT_NAME("Reset")
670   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
671   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
672   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
673   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
674   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
675   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
676   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
677   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
678   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
679   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
680   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
681   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
682   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
683   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
684   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
685INPUT_PORTS_END
686
226687static INPUT_PORTS_START( crsbingo )
688
689   PORT_START( "SW1" )
690   PORT_DIPNAME( 0x01, 0x01, "SW1" )
691   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
692   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
693   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
694   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
695   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
696   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
697   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
698   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
699   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
700   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
701   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
702   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
703   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
704   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
705   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
706   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
707   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
708   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
709   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
710   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
711   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
712   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
713   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
714
715   PORT_START( "SW2" )
716   PORT_DIPNAME( 0x01, 0x01, "SW2" )
717   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
718   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
719   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
720   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
721   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
722   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
723   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
724   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
725   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
726   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
727   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
728   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
729   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
730   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
731   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
732   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
733   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
734   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
735   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
736   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
737   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
738   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
739   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
740
741   PORT_START( "SW3" )
742   PORT_DIPNAME( 0x01, 0x01, "SW3" )
743   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
744   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
745   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
746   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
747   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
748   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
749   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
750   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
751   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
752   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
753   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
754   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
755   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
756   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
757   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
758   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
759   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
760   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
761   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
762   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
763   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
764   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
765   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
766
767   PORT_START( "SW4" )
768   PORT_DIPNAME( 0x01, 0x01, "SW4" )
769   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
770   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
771   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
772   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
773   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
774   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
775   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
776   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
777   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
778   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
779   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
780   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
781   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
782   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
783   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
784   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
785   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
786   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
787   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
788   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
789   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
790   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
791   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
792
793   PORT_START( "INA" )
794   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_POKER_HOLD1 )
795   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_POKER_HOLD2 )
796   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_POKER_HOLD3 ) PORT_NAME("Hold 3 / Half Take")
797   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_POKER_HOLD4 ) PORT_NAME("Hold 4 / Small")
798   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_POKER_HOLD5 ) PORT_NAME("Hold 5 / Big")
799   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_GAMBLE_DEAL )
800   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_POKER_BET )
801   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
802   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
803   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
804
805   PORT_START( "INB" )
806   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )   // coin
807   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )   // coin
808   PORT_DIPNAME( 0x04, 0x04, "INB" )
809   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
810   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
811   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
812   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
813   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
814   PORT_SERVICE_NO_TOGGLE( 0x10, IP_ACTIVE_LOW )   // test
815   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
816   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
817   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
818   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
819   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
820   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
821   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
822   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
823   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
824
825   PORT_START( "INC" )
826   PORT_DIPNAME( 0x01, 0x01, "INC" )
827   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
828   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
829   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
830   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
831   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
832   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
833   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
834   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
835   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
836   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
837   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
838   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
839   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
840   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
841   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
842   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
843   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
844   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
845   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
846   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
847   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
848   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
849   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
227850INPUT_PORTS_END
228851
852
229853/***************************************************************************
230854                                Graphics Layout
231855***************************************************************************/
r6740r6741
246870   8, 8,
247871   RGN_FRAC(1, 4),
248872   4,
249   { RGN_FRAC(0,4),RGN_FRAC(1,4),RGN_FRAC(2,4),RGN_FRAC(3,4) },
873   { RGN_FRAC(2,4),RGN_FRAC(3,4),RGN_FRAC(0,4),RGN_FRAC(1,4) },
250874   { STEP8(0,1) },
251875   { STEP8(0,8) },
252876   8*8
r6740r6741
265889                                Machine Drivers
266890***************************************************************************/
267891
268static MACHINE_DRIVER_START( victor5 )
892static MACHINE_DRIVER_START( victor21 )
269893   /* basic machine hardware */
270894   MDRV_CPU_ADD("maincpu", Z180, XTAL_12MHz / 3)   // 4 MHz?
271   MDRV_CPU_PROGRAM_MAP(victor5_map)
895   MDRV_CPU_PROGRAM_MAP(victor21_map)
272896   MDRV_CPU_IO_MAP(subsino_iomap)
273897
274898   /* video hardware */
r6740r6741
282906   MDRV_GFXDECODE(subsino_depth3)
283907
284908   MDRV_PALETTE_LENGTH(0x100)
285//  MDRV_PALETTE_INIT(subsino_3proms)   // no proms?
909   MDRV_PALETTE_INIT(subsino_2proms)
286910
287911   MDRV_VIDEO_START(subsino)
288912   MDRV_VIDEO_UPDATE(subsino)
r6740r6741
298922   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
299923MACHINE_DRIVER_END
300924
301static MACHINE_DRIVER_START( victor21 )
925/* same but with an additional protection. */
926static MACHINE_DRIVER_START( victor5 )
302927
303928   /* basic machine hardware */
304   MDRV_IMPORT_FROM( victor5 )
305   MDRV_PALETTE_INIT(subsino_2proms)
929   MDRV_IMPORT_FROM( victor21 )
930   MDRV_CPU_MODIFY("maincpu")
931   MDRV_CPU_PROGRAM_MAP(victor5_map)
306932MACHINE_DRIVER_END
307933
308934
r6740r6741
339965   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
340966MACHINE_DRIVER_END
341967
968static MACHINE_DRIVER_START( sharkpy )
969   MDRV_IMPORT_FROM(srider)
342970
971   /* basic machine hardware */
972   MDRV_CPU_MODIFY("maincpu")
973   MDRV_CPU_PROGRAM_MAP(sharkpy_map)
974MACHINE_DRIVER_END
975
343976static MACHINE_DRIVER_START( crsbingo )
344977   /* basic machine hardware */
345978   MDRV_CPU_ADD("maincpu", Z180, XTAL_12MHz / 3)   // Unknown CPU and clock
346   MDRV_CPU_PROGRAM_MAP(victor5_map)
979   MDRV_CPU_PROGRAM_MAP(crsbingo_map)
347980   MDRV_CPU_IO_MAP(subsino_iomap)
348981
349982   /* video hardware */
r6740r6741
3671000
3681001   MDRV_SOUND_ADD("ymsnd", YM2413, XTAL_3_579545MHz)   // unknown clock
3691002   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
370
371   // no OKI
3721003MACHINE_DRIVER_END
3731004
3741005/***************************************************************************
r6740r6741
4111042***************************************************************************/
4121043
4131044ROM_START( victor5 )
414   ROM_REGION( 0x10000, "maincpu", 0 )
415   ROM_LOAD( "1.u1", 0x00000, 0x10000, CRC(e3ada2fc) SHA1(eddb460dcb80a29fbbe3ed6c4733c75b892baf52) )
1045   ROM_REGION( 0x14000, "maincpu", 0 )
1046   ROM_LOAD( "1.u1", 0x10000, 0x4000, CRC(e3ada2fc) SHA1(eddb460dcb80a29fbbe3ed6c4733c75b892baf52) )
1047   ROM_CONTINUE(0x0000,0xc000)
4161048
4171049   ROM_REGION( 0x18000, "tilemap", 0 )
418   ROM_LOAD( "2.u24", 0x00000, 0x8000, CRC(1229e951) SHA1(1e548625bb60e2d6f52a376a0dea9e5709f94135) )
1050   ROM_LOAD( "2.u24", 0x10000, 0x8000, CRC(1229e951) SHA1(1e548625bb60e2d6f52a376a0dea9e5709f94135) )
4191051   ROM_LOAD( "3.u23", 0x08000, 0x8000, CRC(2d89bbf1) SHA1(d7fda0174a835e88b330dfd09bdb604bfe4c2e44) )
420   ROM_LOAD( "4.u22", 0x10000, 0x8000, CRC(ecf840a1) SHA1(9ecf522afb23e3557d37effc3c8568e8a14dad1a) )
1052   ROM_LOAD( "4.u22", 0x00000, 0x8000, CRC(ecf840a1) SHA1(9ecf522afb23e3557d37effc3c8568e8a14dad1a) )
4211053
4221054   ROM_REGION( 0x40000, "oki", ROMREGION_ERASE )
4231055   // rom socket is empty
1056
1057   ROM_REGION( 0x200, "proms", 0 ) //missing proms in this set, we'll use the same as Victor 21 for now.
1058   ROM_LOAD( "74s287.u35", 0x000, 0x100, BAD_DUMP CRC(40094bed) SHA1(b25d96126b3f7bd06bf76dc9958f8669f83abdb7) )
1059   ROM_LOAD( "74s287.u36", 0x100, 0x100, BAD_DUMP CRC(9ca021c5) SHA1(6a1d8d4f958d36e4a676dc4f4aee83d637933bc3) )
4241060ROM_END
4251061
4261062/***************************************************************************
r6740r6741
4601096***************************************************************************/
4611097
4621098ROM_START( victor21 )
463   ROM_REGION( 0x10000, "maincpu", 0 )
464   ROM_LOAD( "1.u1", 0x00000, 0x10000, CRC(43999b2d) SHA1(7ce26fd332ffe35fd826a1a6166b228d4bc370b8) )
1099   ROM_REGION( 0x14000, "maincpu", 0 )
1100   ROM_LOAD( "1.u1", 0x10000, 0x4000, CRC(43999b2d) SHA1(7ce26fd332ffe35fd826a1a6166b228d4bc370b8) )
1101   ROM_CONTINUE(0x0000,0xc000)
4651102
4661103   ROM_REGION( 0x18000, "tilemap", 0 )
467   ROM_LOAD( "2.u24", 0x00000, 0x8000, CRC(f1181b93) SHA1(53cd4d2ce13973495b51d911a4745a69a9784983) )
1104   ROM_LOAD( "2.u24", 0x10000, 0x8000, CRC(f1181b93) SHA1(53cd4d2ce13973495b51d911a4745a69a9784983) )
4681105   ROM_LOAD( "3.u25", 0x08000, 0x8000, CRC(437abb27) SHA1(bd3790807d60a41d58e07f60fb990553076d6e96) )
469   ROM_LOAD( "4.u26", 0x10000, 0x8000, CRC(e2f66eee) SHA1(ece924fe626f21fd7d31faabf19225d80e2bcfd3) )
1106   ROM_LOAD( "4.u26", 0x00000, 0x8000, CRC(e2f66eee) SHA1(ece924fe626f21fd7d31faabf19225d80e2bcfd3) )
4701107
4711108   ROM_REGION( 0x40000, "oki", ROMREGION_ERASE )
4721109   // rom socket is empty
r6740r6741
5171154***************************************************************************/
5181155
5191156ROM_START( sharkpy )
520   ROM_REGION( 0x10000, "maincpu", 0 )
521   ROM_LOAD( "shark_n.1.u18", 0x00000, 0x10000, CRC(25aeac2f) SHA1(d94e3e5cfffd150ac48e1463493a8323f42e7a89) )
1157   ROM_REGION( 0x14000, "maincpu", 0 )
1158   ROM_LOAD( "shark_n.1.u18", 0x0a000, 0x6000, CRC(25aeac2f) SHA1(d94e3e5cfffd150ac48e1463493a8323f42e7a89) ) // is this mapped correctly? - used during gameplay?
1159   ROM_CONTINUE(0x0000, 0xa000)
5221160
1161
5231162   ROM_REGION( 0x40000, "tilemap", 0 )
524   ROM_LOAD( "shark_n.2.u17", 0x00000, 0x08000, CRC(c27f3d0a) SHA1(77c8eb0322c5b9c89777cb080d26ecf9abe01ae7) )
1163   ROM_LOAD( "shark_n.3.u16", 0x00000, 0x08000, CRC(a7a715ce) SHA1(38b93e05377d9cb816688f5070e847480f195c6b) )
5251164   ROM_CONTINUE(              0x10000, 0x08000 )
5261165   ROM_CONTINUE(              0x08000, 0x08000 )
5271166   ROM_CONTINUE(              0x18000, 0x08000 )
528   ROM_LOAD( "shark_n.3.u16", 0x20000, 0x08000, CRC(a7a715ce) SHA1(38b93e05377d9cb816688f5070e847480f195c6b) )
1167   ROM_LOAD( "shark_n.2.u17", 0x20000, 0x08000, CRC(c27f3d0a) SHA1(77c8eb0322c5b9c89777cb080d26ecf9abe01ae7) )
5291168   ROM_CONTINUE(              0x30000, 0x08000 )
5301169   ROM_CONTINUE(              0x28000, 0x08000 )
5311170   ROM_CONTINUE(              0x38000, 0x08000 )
r6740r6741
5381177   ROM_LOAD( "n82s129an.u12", 0x100, 0x100, CRC(5a7a25ed) SHA1(eebd679195e6ea50f64f3c46cd06ee21a1550491) )
5391178   ROM_LOAD( "n82s129an.u13", 0x200, 0x100, CRC(0ef5f218) SHA1(a02cf266661385aa078563bd83240d36549c1cf0) )
5401179ROM_END
541
5421180/***************************************************************************
5431181
5441182Shark Party (alt)
r6740r6741
5791217
5801218***************************************************************************/
5811219
1220
5821221ROM_START( sharkpya )
583   ROM_REGION( 0x10000, "maincpu", 0 )
584   ROM_LOAD( "shark1.6.u18", 0x00000, 0x10000, CRC(365312a0) SHA1(de8370b1f35e8d071185d2e5f2fbd2fdf74c55ac) )
1222   ROM_REGION( 0x14000, "maincpu", 0 )
1223   ROM_LOAD( "shark1.6.u18", 0x0a000, 0x6000, CRC(365312a0) SHA1(de8370b1f35e8d071185d2e5f2fbd2fdf74c55ac) )
1224   ROM_CONTINUE(0x0000, 0xa000)
5851225
5861226   ROM_REGION( 0x40000, "tilemap", 0 )
587   ROM_LOAD( "shark_n.2.u17", 0x00000, 0x08000, CRC(c27f3d0a) SHA1(77c8eb0322c5b9c89777cb080d26ecf9abe01ae7) )
1227   ROM_LOAD( "shark_n.3.u16", 0x00000, 0x08000, CRC(a7a715ce) SHA1(38b93e05377d9cb816688f5070e847480f195c6b) )
5881228   ROM_CONTINUE(              0x10000, 0x08000 )
5891229   ROM_CONTINUE(              0x08000, 0x08000 )
5901230   ROM_CONTINUE(              0x18000, 0x08000 )
591   ROM_LOAD( "shark_n.3.u16", 0x20000, 0x08000, CRC(a7a715ce) SHA1(38b93e05377d9cb816688f5070e847480f195c6b) )
1231   ROM_LOAD( "shark_n.2.u17", 0x20000, 0x08000, CRC(c27f3d0a) SHA1(77c8eb0322c5b9c89777cb080d26ecf9abe01ae7) )
5921232   ROM_CONTINUE(              0x30000, 0x08000 )
5931233   ROM_CONTINUE(              0x28000, 0x08000 )
5941234   ROM_CONTINUE(              0x38000, 0x08000 )
r6740r6741
7781418***************************************************************************/
7791419
7801420ROM_START( crsbingo )
781   ROM_REGION( 0x10000, "maincpu", 0 )
782   ROM_LOAD( "1.u36", 0x00000, 0x10000, CRC(c5aff4eb) SHA1(74f06d7735975657fca9be5fff9e7d53f38fcd02) )
1421   ROM_REGION( 0x14000, "maincpu", 0 )
1422   ROM_LOAD( "1.u36", 0x10000, 0x4000, CRC(c5aff4eb) SHA1(74f06d7735975657fca9be5fff9e7d53f38fcd02) )
1423   ROM_CONTINUE(0x0000,0xc000)
7831424
7841425   ROM_REGION( 0x20000, "tilemap", 0 )
7851426   ROM_LOAD( "2.u4",  0x00000, 0x10000, CRC(ce527722) SHA1(f3759cefab902259eb25f8d4be2fcafc1afd90b9) )
r6740r6741
7891430   ROM_LOAD( "82s129.u13", 0x000, 0x100, CRC(89c06859) SHA1(b98d5335f36ea3842086677aca47b605030d442f) )
7901431   ROM_LOAD( "82s129.u14", 0x100, 0x100, CRC(eaddb54f) SHA1(51fbf31e910a93315204a892d10bcf982a6ed099) )
7911432
1433   ROM_REGION( 0x40000, "oki", ROMREGION_ERASE00 )
1434
7921435   ROM_REGION( 0x155 * 2, "plds", 0 )
7931436   ROM_LOAD( "18cv8.u22", 0x000, 0x155, BAD_DUMP CRC(996e8f59) SHA1(630d9b91f6e8eda781061e2a8ff6fb0fecaf034c) )
7941437   ROM_LOAD( "18cv8.u29", 0x155, 0x155, BAD_DUMP CRC(996e8f59) SHA1(630d9b91f6e8eda781061e2a8ff6fb0fecaf034c) )
7951438ROM_END
7961439
1440/****************************
1441 Decryption
1442****************************/
7971443
798GAME( 1990, victor5,  0,        victor5,  victor5,  0,        ROT0, "Subsino", "Victor 5",                  GAME_NOT_WORKING )
799GAME( 1990, victor21, 0,        victor21, victor5,  0,        ROT0, "Subsino", "Victor 21",                 GAME_NOT_WORKING )
800GAME( 1991, crsbingo, 0,        crsbingo, crsbingo, 0,        ROT0, "Subsino", "Cross Bingo",               GAME_NOT_WORKING )
801GAME( 1993, sharkpy,  0,        srider,   smoto,    0,        ROT0, "Subsino", "Shark Party",               GAME_NOT_WORKING )
802GAME( 1993, sharkpya, sharkpy,  srider,   smoto,    0,        ROT0, "Subsino", "Shark Party (alt)",         GAME_NOT_WORKING )
803GAME( 1996, smoto20,  0,        srider,   smoto,    smoto20,  ROT0, "Subsino", "Super Rider (Italy, v2.0)", GAME_WRONG_COLORS )
804GAME( 1996, smoto16,  smoto20,  srider,   smoto,    smoto16,  ROT0, "Subsino", "Super Moto (Italy, v1.6)",  GAME_WRONG_COLORS )
1444#if 0
1445void dump_decrypted(running_machine* machine, UINT8* decrypt)
1446{
1447    FILE *fp;
1448    char filename[256];
1449    sprintf(filename,"dat_%s", machine->gamedrv->name);
1450    fp=fopen(filename, "w+b");
1451    if (fp)
1452    {
1453        fwrite(decrypt, 0x10000, 1, fp);
1454        fclose(fp);
1455    }
1456}
1457#endif
1458
1459static DRIVER_INIT( victor5 )
1460{
1461   unsigned char xors[8] = { 0x99, 0x99, 0x33, 0x44, 0xBB, 0x88, 0x88, 0xBB };
1462
1463   int i;
1464   UINT8 *decrypt = auto_alloc_array(machine, UINT8, 0x10000);
1465   UINT8* region = memory_region(machine,"maincpu");
1466   for (i=0;i<0x10000;i++)
1467   {
1468      if (i<0xc000)
1469      {
1470         decrypt[i] = region[i]^xors[i&7];
1471
1472         if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0);
1473         if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i],7,6,5,0,3,2,1,4);
1474         if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4);
1475         if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4);
1476         if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i],3,2,1,0,7,6,5,4);
1477         if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i],7,6,5,0,3,2,1,4);
1478         if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i],3,6,1,0,7,2,5,4);
1479         if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,4,3,6,5,0);
1480
1481
1482      }
1483      else
1484      {
1485         decrypt[i] = region[i];
1486      }
1487   }
1488
1489//  dump_decrypted(machine, decrypt);
1490
1491   memcpy(region, decrypt, 0x10000);
1492}
1493
1494
1495static DRIVER_INIT( victor21 )
1496{
1497   unsigned char xors[8] = { 0x44, 0xBB, 0x66, 0x44, 0xAA, 0x55, 0x88, 0x22 };
1498
1499
1500
1501   int i;
1502   UINT8 *decrypt = auto_alloc_array(machine, UINT8, 0x10000);
1503   UINT8* region = memory_region(machine,"maincpu");
1504   for (i=0;i<0x10000;i++)
1505   {
1506      if (i<0xc000)
1507      {
1508         decrypt[i] = region[i]^xors[i&7];
1509
1510         if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4);
1511         if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i],3,6,1,4,7,2,5,0);
1512         if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i],3,2,1,4,7,6,5,0);
1513         if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0);
1514         if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0);
1515         if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i],3,6,5,0,7,2,1,4);
1516         if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i],7,6,5,4,3,2,1,0);
1517         if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i],3,2,1,4,7,6,5,0);
1518
1519      }
1520      else
1521      {
1522         decrypt[i] = region[i];
1523      }
1524   }
1525
1526//  dump_decrypted(machine, decrypt);
1527
1528   memcpy(region, decrypt, 0x10000);
1529}
1530
1531static DRIVER_INIT( crsbingo )
1532{
1533   unsigned char xors[8] = { 0x44, 0x33, 0x33, 0x22, 0x55, 0xEE, 0xBB, 0x11 };
1534
1535   int i;
1536   UINT8 *decrypt = auto_alloc_array(machine, UINT8, 0x10000);
1537   UINT8* region = memory_region(machine,"maincpu");
1538   for (i=0;i<0x10000;i++)
1539   {
1540      if (i<0xc000)
1541      {
1542         decrypt[i] = region[i]^xors[i&7]^0xff;
1543
1544         if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0);
1545         if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4);
1546         if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i],3,2,5,0,7,6,1,4);
1547         if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,0,3,6,1,4);
1548         if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i],7,6,5,0,3,2,1,4);
1549         if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,4,3,6,5,0);
1550         if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,0,3,6,5,4);
1551         if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i],3,2,1,0,7,6,5,4);
1552      }
1553      else
1554      {
1555         decrypt[i] = region[i];
1556      }
1557   }
1558
1559//  dump_decrypted(machine, decrypt);
1560
1561   memcpy(region, decrypt, 0x10000);
1562}
1563
1564
1565static DRIVER_INIT( sharkpy )
1566{
1567   unsigned char xors[8] = { 0x33, 0x55, 0x99, 0x55, 0x11, 0xCC, 0x00, 0x00 };
1568   int i;
1569   UINT8 *decrypt = auto_alloc_array(machine, UINT8, 0x10000);
1570   UINT8* region = memory_region(machine,"maincpu");
1571   for (i=0;i<0x10000;i++)
1572   {
1573      if (i<0xa000)
1574      {
1575         decrypt[i] = region[i]^xors[i&7]^0xff;
1576         if ((i&7) == 0) decrypt[i] = BITSWAP8(decrypt[i],3,2,1,0,7,6,5,4);
1577         if ((i&7) == 1) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0);
1578         if ((i&7) == 2) decrypt[i] = BITSWAP8(decrypt[i],7,2,1,4,3,6,5,0);
1579         if ((i&7) == 3) decrypt[i] = BITSWAP8(decrypt[i],3,6,1,0,7,2,5,4);
1580         if ((i&7) == 4) decrypt[i] = BITSWAP8(decrypt[i],7,2,5,4,3,6,1,0);
1581         if ((i&7) == 5) decrypt[i] = BITSWAP8(decrypt[i],3,2,5,4,7,6,1,0);
1582         if ((i&7) == 6) decrypt[i] = BITSWAP8(decrypt[i],7,6,1,4,3,2,5,0);
1583         if ((i&7) == 7) decrypt[i] = BITSWAP8(decrypt[i],3,6,1,4,7,2,5,0);
1584      }
1585      else
1586      {
1587         decrypt[i] = region[i];
1588      }
1589   }
1590
1591//  dump_decrypted(machine, decrypt);
1592
1593   memcpy(region, decrypt, 0x10000);
1594}
1595
1596
1597GAME( 1990, victor21, 0,        victor21, victor21, victor21, ROT0, "Subsino / Buffy", "Victor 21",                 0 )
1598GAME( 1991, victor5,  0,        victor5,  victor5,  victor5,  ROT0, "Subsino",         "Victor 5",                  0 ) // board sticker says Victor 5, in-game says G.E.A with no manufacturer info?
1599GAME( 1991, crsbingo, 0,        crsbingo, crsbingo, crsbingo, ROT0, "Subsino",         "Poker Carnival",            0 ) // alt version of Cross Bingo?
1600GAME( 1996, sharkpy,  0,        sharkpy,  smoto,    sharkpy,  ROT0, "Subsino",         "Shark Party (Italy, v1.3)", 0 ) // missing POST messages?
1601GAME( 1996, sharkpya, sharkpy,  sharkpy,  smoto,    sharkpy,  ROT0, "Subsino",         "Shark Party (Italy, v1.6)", 0 ) // missing POST messages?
1602GAME( 1996, smoto20,  0,        srider,   smoto,    smoto20,  ROT0, "Subsino",         "Super Rider (Italy, v2.0)", 0 )
1603GAME( 1996, smoto16,  smoto20,  srider,   smoto,    smoto16,  ROT0, "Subsino",         "Super Moto (Italy, v1.6)",  0 )
src/mame/drivers/jchan.c
r6740r6741
172172#include "deprecat.h"
173173#include "sound/ymz280b.h"
174174#include "includes/suprnova.h"
175#include "kaneko16.h"
175#include "includes/kaneko16.h"
176176
177177static bitmap_t *sprite_bitmap_1;
178178static bitmap_t *sprite_bitmap_2;
src/mame/drivers/bankp.c
r6740r6741
9494#include "driver.h"
9595#include "cpu/z80/z80.h"
9696#include "sound/sn76496.h"
97#include "bankp.h"
97#include "includes/bankp.h"
9898
9999
100100/*************************************
src/mame/drivers/tankbust.c
r6740r6741
2525VIDEO_UPDATE( tankbust );
2626
2727extern UINT8 *tankbust_txtram;
28extern UINT8 *tankbust_videoram;
29extern UINT8 *tankbust_colorram;
2830
2931WRITE8_HANDLER( tankbust_background_videoram_w );
3032READ8_HANDLER ( tankbust_background_videoram_r );
r6740r6741
196198   AM_RANGE(0x0000, 0x5fff) AM_ROM
197199   AM_RANGE(0x6000, 0x9fff) AM_ROMBANK("bank1")
198200   AM_RANGE(0xa000, 0xbfff) AM_ROMBANK("bank2")
199   AM_RANGE(0xc000, 0xc7ff) AM_READWRITE(tankbust_background_videoram_r, tankbust_background_videoram_w) AM_BASE_GENERIC(videoram)
200   AM_RANGE(0xc800, 0xcfff) AM_READWRITE(tankbust_background_colorram_r, tankbust_background_colorram_w) AM_BASE_GENERIC(colorram)
201   AM_RANGE(0xc000, 0xc7ff) AM_READWRITE(tankbust_background_videoram_r, tankbust_background_videoram_w) AM_BASE(&tankbust_videoram)
202   AM_RANGE(0xc800, 0xcfff) AM_READWRITE(tankbust_background_colorram_r, tankbust_background_colorram_w) AM_BASE(&tankbust_colorram)
201203   AM_RANGE(0xd000, 0xd7ff) AM_READWRITE(tankbust_txtram_r, tankbust_txtram_w) AM_BASE(&tankbust_txtram)
202204   AM_RANGE(0xd800, 0xd8ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
203205   AM_RANGE(0xe000, 0xe007) AM_READWRITE(debug_output_area_r, tankbust_e0xx_w)
src/mame/drivers/pastelg.c
r6740r6741
2222
2323#include "driver.h"
2424#include "cpu/z80/z80.h"
25#include "nb1413m3.h"
25#include "includes/nb1413m3.h"
2626#include "sound/ay8910.h"
2727#include "sound/dac.h"
2828
src/mame/drivers/galastrm.c
r6740r6741
283283                 MACHINE DRIVERS
284284***********************************************************/
285285
286static MACHINE_RESET( galastrm )
287{
288   taito_f3_soundsystem_reset(machine);
289   f3_68681_reset(machine);
290}
291
292
293286static const UINT8 default_eeprom[128]={
294287   0x45,0x58,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x28,0x00,0x01,0x00,0x00,0x00,0xfa,
295288   0x00,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
r6740r6741
333326   MDRV_CPU_PROGRAM_MAP(galastrm_map)
334327   MDRV_CPU_VBLANK_INT("screen", galastrm_interrupt) /* VBL */
335328
336   TAITO_F3_SOUND_SYSTEM_CPU(16000000)
337
338   MDRV_MACHINE_RESET(galastrm)
339329   MDRV_NVRAM_HANDLER(galastrm)
340330
341331   /* video hardware */
r6740r6741
353343   MDRV_VIDEO_UPDATE(galastrm)
354344
355345   /* sound hardware */
356   TAITO_F3_SOUND_SYSTEM_ES5505(30476100/2)
346   MDRV_IMPORT_FROM(taito_f3_sound)
357347MACHINE_DRIVER_END
358348
359349/***************************************************************************/
src/mame/drivers/namcos22.c
r6740r6741
11401140#include "driver.h"
11411141#include "cpu/m68000/m68000.h"
11421142#include "deprecat.h"
1143#include "namcos22.h"
1143#include "includes/namcos22.h"
11441144#include "cpu/tms32025/tms32025.h"
11451145#include "cpu/m37710/m37710.h"
11461146#include "sound/c352.h"
src/mame/drivers/galaxold.c
r6740r6741
350350#include "driver.h"
351351#include "cpu/z80/z80.h"
352352#include "cpu/s2650/s2650.h"
353#include "galaxold.h"
353#include "includes/galaxold.h"
354#include "machine/7474.h"
354355#include "sound/ay8910.h"
355356#include "sound/sn76496.h"
356357#include "sound/dac.h"
r6740r6741
21082109
21092110   MDRV_MACHINE_RESET(galaxold)
21102111
2112   MDRV_7474_ADD("7474_9m_1", galaxold_7474_9m_1_callback)
2113   MDRV_7474_ADD("7474_9m_2", galaxold_7474_9m_2_callback)
2114
2115   MDRV_TIMER_ADD("int_timer", galaxold_interrupt_timer)
2116
21112117   /* video hardware */
21122118   MDRV_GFXDECODE(galaxian)
21132119   MDRV_PALETTE_LENGTH(32+2+64)      /* 32 for the characters, 2 for the bullets, 64 for the stars */
src/mame/drivers/atarisy1.c
r6740r6741
173173#include "cpu/m6502/m6502.h"
174174#include "machine/atarigen.h"
175175#include "machine/6522via.h"
176#include "atarisy1.h"
176#include "includes/atarisy1.h"
177177#include "sound/tms5220.h"
178178#include "sound/2151intf.h"
179179#include "sound/pokey.h"
180180
181181
182182
183static TIMER_CALLBACK( delayed_joystick_int );
184
185
186
187183/*************************************
188184 *
189185 *  Initialization & interrupts
r6740r6741
200196}
201197
202198
199static MACHINE_START( atarisy1 )
200{
201   atarisy1_state *state = (atarisy1_state *)machine->driver_data;
202   atarigen_init(machine);
203
204   state_save_register_global(machine, state->joystick_int);
205   state_save_register_global(machine, state->joystick_int_enable);
206   state_save_register_global(machine, state->joystick_value);
207   state_save_register_global(machine, state->tms5220_out_data);
208   state_save_register_global(machine, state->tms5220_in_data);
209   state_save_register_global(machine, state->tms5220_ctl);
210}
211
212
203213static MACHINE_RESET( atarisy1 )
204214{
205215   atarisy1_state *state = (atarisy1_state *)machine->driver_data;
r6740r6741
212222
213223   /* reset the joystick parameters */
214224   state->joystick_value = 0;
215   state->joystick_timer = timer_alloc(machine, delayed_joystick_int, NULL);
225   state->joystick_timer = devtag_get_device(machine, "joystick_timer");
216226   state->joystick_int = 0;
217227   state->joystick_int_enable = 0;
218228}
r6740r6741
225235 *
226236 *************************************/
227237
228static TIMER_CALLBACK( delayed_joystick_int )
238static TIMER_DEVICE_CALLBACK( delayed_joystick_int )
229239{
230   atarisy1_state *state = (atarisy1_state *)machine->driver_data;
240   atarisy1_state *state = (atarisy1_state *)timer->machine->driver_data;
231241   state->joystick_value = param;
232242   state->joystick_int = 1;
233   atarigen_update_interrupts(machine);
243   atarigen_update_interrupts(timer->machine);
234244}
235245
236246
r6740r6741
257267
258268   /* clear any existing interrupt and set a timer for a new one */
259269   state->joystick_int = 0;
260   timer_adjust_oneshot(state->joystick_timer, ATTOTIME_IN_USEC(50), newval);
270   timer_device_adjust_oneshot(state->joystick_timer, ATTOTIME_IN_USEC(50), newval);
261271   atarigen_update_interrupts(space->machine);
262272
263273   return state->joystick_value;
r6740r6741
753763   MDRV_CPU_ADD("audiocpu", M6502, ATARI_CLOCK_14MHz/8)
754764   MDRV_CPU_PROGRAM_MAP(sound_map)
755765
766   MDRV_MACHINE_START(atarisy1)
756767   MDRV_MACHINE_RESET(atarisy1)
757768   MDRV_NVRAM_HANDLER(atarigen)
758769
770   MDRV_TIMER_ADD("joystick_timer", delayed_joystick_int)
771   MDRV_TIMER_ADD("scan_timer", atarisy1_int3_callback)
772   MDRV_TIMER_ADD("int3off_timer", atarisy1_int3off_callback)
773   MDRV_TIMER_ADD("yreset_timer", atarisy1_reset_yscroll_callback)
774
759775   /* video hardware */
760776   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
761777   MDRV_GFXDECODE(atarisy1)
src/mame/drivers/sprint8.c
r6740r6741
2626}
2727
2828
29static TIMER_CALLBACK( input_callback )
29static TIMER_DEVICE_CALLBACK( input_callback )
3030{
3131   static UINT8 dial[8];
3232   static const char *const dialnames[] = { "DIAL1", "DIAL2", "DIAL3", "DIAL4", "DIAL5", "DIAL6", "DIAL7", "DIAL8" };
r6740r6741
3535
3636   for (i = 0; i < 8; i++)
3737   {
38      UINT8 val = input_port_read(machine, dialnames[i]) >> 4;
38      UINT8 val = input_port_read(timer->machine, dialnames[i]) >> 4;
3939
4040      signed char delta = (val - dial[i]) & 15;
4141
r6740r6741
5959{
6060   collision_reset = 0;
6161   collision_index = 0;
62
63   timer_pulse(machine, video_screen_get_frame_period(machine->primary_screen), NULL, 0, input_callback);
6462}
6563
6664
r6740r6741
462460
463461   MDRV_MACHINE_RESET(sprint8)
464462
463   MDRV_TIMER_ADD_PERIODIC("input_timer", input_callback, HZ(60))
464
465465   /* video hardware */
466466   MDRV_SCREEN_ADD("screen", RASTER)
467467   MDRV_SCREEN_REFRESH_RATE(60)
src/mame/drivers/dec0.c
r6740r6741
4747#include "cpu/m6502/m6502.h"
4848#include "cpu/h6280/h6280.h"
4949#include "cpu/z80/z80.h"
50#include "dec0.h"
50#include "includes/dec0.h"
5151#include "sound/2203intf.h"
5252#include "sound/3812intf.h"
5353#include "sound/okim6295.h"
src/mame/drivers/ssv.c
r6740r6741
185185#include "deprecat.h"
186186#include "machine/eeprom.h"
187187#include "sound/es5506.h"
188#include "seta.h"
188#include "includes/seta.h"
189189
190190/***************************************************************************
191191
src/mame/drivers/janshi.c
r6740r6741
2828*/
2929
3030#include "driver.h"
31#include "news.h"
31#include "includes/news.h"
3232#include "cpu/z80/z80.h"
3333#include "sound/okim6295.h"
3434
src/mame/drivers/atarig42.c
r6740r6741
1717
1818***************************************************************************/
1919
20
2120#include "driver.h"
2221#include "cpu/m68000/m68000.h"
2322#include "machine/asic65.h"
2423#include "audio/atarijsa.h"
2524#include "video/atarirle.h"
26#include "atarig42.h"
25#include "includes/atarig42.h"
2726
2827
2928/*************************************
r6740r6741
4039}
4140
4241
42static MACHINE_START( atarig42 )
43{
44   atarig42_state *state = (atarig42_state *)machine->driver_data;
45   atarigen_init(machine);
46
47   state_save_register_global(machine, state->analog_data);
48   state_save_register_global(machine, state->sloop_bank);
49   state_save_register_global(machine, state->sloop_next_bank);
50   state_save_register_global(machine, state->sloop_offset);
51   state_save_register_global(machine, state->sloop_state);
52}
53
54
4355static MACHINE_RESET( atarig42 )
4456{
4557   atarig42_state *state = (atarig42_state *)machine->driver_data;
r6740r6741
511523   /* ASIC65 */
512524   MDRV_IMPORT_FROM(asic65)
513525
526   MDRV_MACHINE_START(atarig42)
514527   MDRV_MACHINE_RESET(atarig42)
515528   MDRV_NVRAM_HANDLER(atarigen)
516529
src/mame/drivers/cop01.c
r6740r6741
5353#include "cpu/z80/z80.h"
5454#include "sound/ay8910.h"
5555#include "sound/3526intf.h"
56#include "cop01.h"
56#include "includes/cop01.h"
5757
5858
5959#define MIGHTGUY_HACK    0
src/mame/drivers/vindictr.c
r6740r6741
2020#include "driver.h"
2121#include "cpu/m68000/m68000.h"
2222#include "audio/atarijsa.h"
23#include "vindictr.h"
23#include "includes/vindictr.h"
2424
2525
2626
r6740r6741
3838}
3939
4040
41static MACHINE_START( vindictr )
42{
43   atarigen_init(machine);
44}
45
46
4147static MACHINE_RESET( vindictr )
4248{
4349   vindictr_state *state = (vindictr_state *)machine->driver_data;
r6740r6741
194200   MDRV_CPU_ADD("maincpu", M68010, ATARI_CLOCK_14MHz/2)
195201   MDRV_CPU_PROGRAM_MAP(main_map)
196202
203   MDRV_MACHINE_START(vindictr)
197204   MDRV_MACHINE_RESET(vindictr)
198205   MDRV_NVRAM_HANDLER(atarigen)
199206
src/mame/drivers/circusc.c
r6740r6741
5454#include "sound/dac.h"
5555#include "sound/sn76496.h"
5656#include "sound/discrete.h"
57#include "circusc.h"
57#include "includes/circusc.h"
5858
5959
6060static MACHINE_START( circusc )
src/mame/drivers/mikie.c
r6740r6741
2020#include "cpu/z80/z80.h"
2121#include "cpu/m6809/m6809.h"
2222#include "sound/sn76496.h"
23#include "konamipt.h"
23#include "includes/konamipt.h"
2424
25extern UINT8 *mikie_videoram;
26extern UINT8 *mikie_colorram;
27
2528extern WRITE8_HANDLER( mikie_videoram_w );
2629extern WRITE8_HANDLER( mikie_colorram_w );
2730extern WRITE8_HANDLER( mikie_palettebank_w );
r6740r6741
8184   AM_RANGE(0x2501, 0x2501) AM_READ_PORT("DSW1")
8285   AM_RANGE(0x2800, 0x288f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
8386   AM_RANGE(0x2890, 0x37ff) AM_RAM
84   AM_RANGE(0x3800, 0x3bff) AM_RAM_WRITE(mikie_colorram_w) AM_BASE_GENERIC(colorram)
85   AM_RANGE(0x3c00, 0x3fff) AM_RAM_WRITE(mikie_videoram_w) AM_BASE_GENERIC(videoram)
87   AM_RANGE(0x3800, 0x3bff) AM_RAM_WRITE(mikie_colorram_w) AM_BASE(&mikie_colorram)
88   AM_RANGE(0x3c00, 0x3fff) AM_RAM_WRITE(mikie_videoram_w) AM_BASE(&mikie_videoram)
8689   AM_RANGE(0x4000, 0x5fff) AM_ROM   // Machine checks for extra rom
8790   AM_RANGE(0x6000, 0xffff) AM_ROM
8891ADDRESS_MAP_END
src/mame/drivers/midvunit.c
r6740r6741
2424#include "audio/dcs.h"
2525#include "machine/idectrl.h"
2626#include "machine/midwayic.h"
27#include "midvunit.h"
27#include "includes/midvunit.h"
2828
2929
3030#define CPU_CLOCK      50000000
r6740r6741
4141static UINT16 last_port0;
4242static UINT8 shifter_state;
4343
44static emu_timer *timer[2];
44static const device_config *timer[2];
4545static double timer_rate;
4646
4747static UINT32 *tms32031_control;
r6740r6741
7676   memcpy(ram_base, memory_region(machine, "user1"), 0x20000*4);
7777   device_reset(cputag_get_cpu(machine, "maincpu"));
7878
79   timer[0] = timer_alloc(machine, NULL, NULL);
80   timer[1] = timer_alloc(machine, NULL, NULL);
79   timer[0] = devtag_get_device(machine, "timer0");
80   timer[1] = devtag_get_device(machine, "timer1");
8181}
8282
8383
r6740r6741
8989   memcpy(ram_base, memory_region(machine, "user1"), 0x20000*4);
9090   device_reset(cputag_get_cpu(machine, "maincpu"));
9191
92   timer[0] = timer_alloc(machine, NULL, NULL);
93   timer[1] = timer_alloc(machine, NULL, NULL);
92   timer[0] = devtag_get_device(machine, "timer0");
93   timer[1] = devtag_get_device(machine, "timer1");
9494
9595   devtag_reset(machine, "ide");
9696}
r6740r6741
261261   {
262262      /* timer is clocked at 100ns */
263263      int which = (offset >> 4) & 1;
264      INT32 result = attotime_to_double(attotime_mul(timer_timeelapsed(timer[which]), timer_rate));
264      INT32 result = attotime_to_double(attotime_mul(timer_device_timeelapsed(timer[which]), timer_rate));
265265//      logerror("%06X:tms32031_control_r(%02X) = %08X\n", cpu_get_pc(space->cpu), offset, result);
266266      return result;
267267   }
r6740r6741
288288      int which = (offset >> 4) & 1;
289289//  logerror("%06X:tms32031_control_w(%02X) = %08X\n", cpu_get_pc(space->cpu), offset, data);
290290      if (data & 0x40)
291         timer_adjust_oneshot(timer[which], attotime_never, 0);
291         timer_device_adjust_oneshot(timer[which], attotime_never, 0);
292292
293293      /* bit 0x200 selects internal clocking, which is 1/2 the main CPU clock rate */
294294      if (data & 0x200)
r6740r6741
10281028   MDRV_MACHINE_RESET(midvunit)
10291029   MDRV_NVRAM_HANDLER(generic_1fill)
10301030
1031   MDRV_TIMER_ADD("timer0", NULL)
1032   MDRV_TIMER_ADD("timer1", NULL)
1033
10311034   /* video hardware */
10321035   MDRV_PALETTE_LENGTH(32768)
10331036
src/mame/drivers/opwolf.c
r6740r6741
277277#include "driver.h"
278278#include "cpu/z80/z80.h"
279279#include "cpu/m68000/m68000.h"
280#include "taitoipt.h"
280#include "includes/taitoipt.h"
281281#include "video/taitoic.h"
282282#include "audio/taitosnd.h"
283283#include "sound/2151intf.h"
src/mame/drivers/firebeat.c
r6740r6741
130130   UINT32 visible_area;
131131} GCU_REGS;
132132
133static UINT8 xram[4096];
134133static UINT8 extend_board_irq_enable;
135134static UINT8 extend_board_irq_active;
136135
r6740r6741
12811280}
12821281
12831282/*****************************************************************************/
1284/* Epson RTC-65271 Real-time Clock/NVRAM */
12851283
1286static READ32_HANDLER( rtc_r )
1287{
1288   int reg = offset * 4;
1289   UINT32 r = 0;
1290
1291   if (ACCESSING_BITS_24_31)
1292   {
1293      r |= rtc65271_r((reg >> 8) & 0x1, (reg & 0xff) + 0) << 24;
1294   }
1295   if (ACCESSING_BITS_16_23)
1296   {
1297      r |= rtc65271_r((reg >> 8) & 0x1, (reg & 0xff) + 1) << 16;
1298   }
1299   if (ACCESSING_BITS_8_15)
1300   {
1301      r |= rtc65271_r((reg >> 8) & 0x1, (reg & 0xff) + 2) << 8;
1302   }
1303   if (ACCESSING_BITS_0_7)
1304   {
1305      r |= rtc65271_r((reg >> 8) & 0x1, (reg & 0xff) + 3) << 0;
1306   }
1307
1308   return r;
1309}
1310
1311static WRITE32_HANDLER( rtc_w )
1312{
1313   int reg = offset * 4;
1314   if (ACCESSING_BITS_24_31)
1315   {
1316      rtc65271_w((reg >> 8) & 0x1, (reg & 0xff) + 0, (data >> 24) & 0xff);
1317   }
1318   if (ACCESSING_BITS_16_23)
1319   {
1320      rtc65271_w((reg >> 8) & 0x1, (reg & 0xff) + 1, (data >> 16) & 0xff);
1321   }
1322   if (ACCESSING_BITS_8_15)
1323   {
1324      rtc65271_w((reg >> 8) & 0x1, (reg & 0xff) + 2, (data >> 8) & 0xff);
1325   }
1326   if (ACCESSING_BITS_0_7)
1327   {
1328      rtc65271_w((reg >> 8) & 0x1, (reg & 0xff) + 3, (data >> 0) & 0xff);
1329   }
1330}
1331
1332/*****************************************************************************/
1333
13341284static const int cab_data[2] = { 0x0, 0x8 };
13351285static const int kbm_cab_data[2] = { 0x2, 0x8 };
13361286static const int ppd_cab_data[2] = { 0x1, 0x9 };
r6740r6741
17531703   AM_RANGE(0x7d400000, 0x7d5fffff) AM_READWRITE(flashram_r, flashram_w)
17541704   AM_RANGE(0x7d800000, 0x7dbfffff) AM_READWRITE(soundflash_r, soundflash_w)
17551705   AM_RANGE(0x7dc00000, 0x7dc0000f) AM_READWRITE(comm_uart_r, comm_uart_w)
1756   AM_RANGE(0x7e000000, 0x7e00013f) AM_READWRITE(rtc_r, rtc_w)
1706   AM_RANGE(0x7e000000, 0x7e00003f) AM_DEVREADWRITE8("rtc", rtc65271_rtc_r, rtc65271_rtc_w, 0xffffffff)
1707   AM_RANGE(0x7e000100, 0x7e00013f) AM_DEVREADWRITE8("rtc", rtc65271_xram_r, rtc65271_xram_w, 0xffffffff)
17571708   AM_RANGE(0x7e800000, 0x7e8000ff) AM_READWRITE(gcu0_r, gcu0_w)
17581709   AM_RANGE(0x7e800100, 0x7e8001ff) AM_READWRITE(gcu1_r, gcu1_w)
17591710   AM_RANGE(0x7fe00000, 0x7fe0000f) AM_READWRITE(atapi_command_r, atapi_command_w)
r6740r6741
17971748   nvram_handler_intelflash(machine, 0, file, read_or_write);
17981749   nvram_handler_intelflash(machine, 1, file, read_or_write);
17991750   nvram_handler_intelflash(machine, 2, file, read_or_write);
1800
1801   if (read_or_write)
1802   {
1803      rtc65271_file_save(file);
1804   }
1805   else
1806   {
1807      rtc65271_init(machine, xram, NULL);
1808
1809      if (file != NULL)
1810      {
1811         rtc65271_file_load(machine, file);
1812      }
1813   }
18141751}
18151752
18161753static INPUT_PORTS_START(ppp)
r6740r6741
19861923   MDRV_MACHINE_RESET(firebeat)
19871924   MDRV_NVRAM_HANDLER(firebeat)
19881925
1926   MDRV_RTC65271_ADD("rtc", NULL)
1927
19891928    /* video hardware */
19901929   MDRV_SCREEN_ADD("screen", RASTER)
19911930   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
20241963   MDRV_MACHINE_RESET(firebeat)
20251964   MDRV_NVRAM_HANDLER(firebeat)
20261965
1966   MDRV_RTC65271_ADD("rtc", NULL)
1967
20271968    /* video hardware */
20281969   MDRV_PALETTE_LENGTH(32768)
20291970   MDRV_PALETTE_INIT(RRRRR_GGGGG_BBBBB)
r6740r6741
22412182   intelflash_init(machine, 1, FLASH_FUJITSU_29F016A, NULL);
22422183   intelflash_init(machine, 2, FLASH_FUJITSU_29F016A, NULL);
22432184
2244   rtc65271_init(machine, xram, NULL);
2245
22462185   pc16552d_init(machine, 0, 19660800, comm_uart_irq_callback, 0);      // Network UART
22472186   pc16552d_init(machine, 1, 24000000, midi_uart_irq_callback, 0);      // MIDI UART
22482187
src/mame/drivers/bagman.c
r6740r6741
172172static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
173173   AM_RANGE(0x0000, 0x5fff) AM_ROM
174174   AM_RANGE(0x6000, 0x67ff) AM_RAM
175   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(bagman_videoram_w) AM_BASE_GENERIC(videoram)
176   AM_RANGE(0x9800, 0x9bff) AM_RAM_WRITE(bagman_colorram_w) AM_BASE_GENERIC(colorram)
175   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(bagman_videoram_w) AM_BASE(&bagman_videoram)
176   AM_RANGE(0x9800, 0x9bff) AM_RAM_WRITE(bagman_colorram_w) AM_BASE(&bagman_colorram)
177177   AM_RANGE(0x9c00, 0x9fff) AM_WRITENOP   /* written to, but unused */
178178   AM_RANGE(0xa000, 0xa000) AM_READ(bagman_pal16r6_r)
179179   //AM_RANGE(0xa800, 0xa805) AM_READ(bagman_ls259_r) /*just for debugging purposes*/
r6740r6741
201201static ADDRESS_MAP_START( pickin_map, ADDRESS_SPACE_PROGRAM, 8 )
202202   AM_RANGE(0x0000, 0x5fff) AM_ROM
203203   AM_RANGE(0x7000, 0x77ff) AM_RAM
204   AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(bagman_videoram_w) AM_BASE_GENERIC(videoram)
205   AM_RANGE(0x9800, 0x9bff) AM_RAM_WRITE(bagman_colorram_w) AM_BASE_GENERIC(colorram)
204   AM_RANGE(0x8800, 0x8bff) AM_RAM_WRITE(bagman_videoram_w) AM_BASE(&bagman_videoram)
205   AM_RANGE(0x9800, 0x9bff) AM_RAM_WRITE(bagman_colorram_w) AM_BASE(&bagman_colorram)
206206   AM_RANGE(0x9800, 0x981f) AM_WRITEONLY AM_BASE_SIZE_GENERIC(spriteram)   /* hidden portion of color RAM */
207207                           /* here only to initialize the pointer, */
208208                           /* writes are handled by bagman_colorram_w */
src/mame/drivers/tattack.c
r6740r6741
2222#include "cpu/z80/z80.h"
2323
2424
25static UINT8 *videoram;
26static UINT8 *colorram;
2527static tilemap *tmap;
2628
2729static TILE_GET_INFO( get_tile_info )
2830{
29   int code = machine->generic.videoram.u8[tile_index];
30   int color=machine->generic.colorram.u8[tile_index];
31   int code = videoram[tile_index];
32   int color = colorram[tile_index];
3133
3234   if((color&1 ) || (color>15) )
3335      logerror("COLOR %i\n",color);
r6740r6741
5658static ADDRESS_MAP_START( mem, ADDRESS_SPACE_PROGRAM, 8 )
5759   AM_RANGE(0x0000, 0x0fff) AM_ROM
5860//  AM_RANGE(0x4000, 0x4000) AM_READNOP $315
59   AM_RANGE(0x5000, 0x53ff) AM_RAM AM_BASE_GENERIC(videoram)
60   AM_RANGE(0x7000, 0x73ff) AM_RAM AM_BASE_GENERIC(colorram)   // color map ? something else .. only bits 1-3 are used
61   AM_RANGE(0x5000, 0x53ff) AM_RAM AM_BASE(&videoram)
62   AM_RANGE(0x7000, 0x73ff) AM_RAM AM_BASE(&colorram)   // color map ? something else .. only bits 1-3 are used
6163   AM_RANGE(0x6000, 0x6000) AM_READ_PORT("DSW2")
6264   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("DSW1")      // dsw ? something else ?
6365   AM_RANGE(0xc000, 0xc000) AM_READ_PORT("INPUTS") AM_WRITENOP
src/mame/drivers/cbuster.c
r6740r6741
2222#include "sound/2203intf.h"
2323#include "sound/2151intf.h"
2424#include "sound/okim6295.h"
25#include "deco16ic.h"
25#include "includes/deco16ic.h"
2626
2727VIDEO_START( twocrude );
2828VIDEO_UPDATE( twocrude );
src/mame/drivers/cvs.c
r6740r6741
9595#include "sound/dac.h"
9696#include "sound/tms5110.h"
9797#include "video/s2636.h"
98#include "cvs.h"
98#include "includes/cvs.h"
9999
100100
101101/* Turn to 1 so all inputs are always available (this shall only be a debug feature) */
r6740r6741
106106#define LOG(x) do { if (VERBOSE) logerror x; } while (0)
107107
108108
109
110109/*************************************
111110 *
112 *  Global variables
113 *
114 *************************************/
115
116UINT8 *cvs_color_ram;
117UINT8 *cvs_video_ram;
118UINT8 *cvs_bullet_ram;
119UINT8 *cvs_palette_ram;
120static UINT8 *cvs_character_ram;
121UINT8 *cvs_fo_state;
122
123static emu_timer *cvs_393hz_timer;
124static UINT8 cvs_393hz_clock;
125static UINT8 *cvs_4_bit_dac_data;
126static UINT8 *cvs_tms5110_ctl_data;
127static UINT8 *dac3_state;
128
129static UINT8 character_banking_mode;
130static UINT16 character_ram_page_start;
131static UINT16 speech_rom_bit_address;
132
133
134
135
136UINT8 cvs_get_character_banking_mode(void)
137{
138   return character_banking_mode;
139}
140
141
142
143/*************************************
144 *
145111 *  Multiplexed memory access
146112 *
147113 *************************************/
148114
149115READ8_HANDLER( cvs_video_or_color_ram_r )
150116{
151   if (*cvs_fo_state)
152      return cvs_video_ram[offset];
117    cvs_state *state = (cvs_state *)space->machine->driver_data;
118
119   if (*state->fo_state)
120      return state->video_ram[offset];
153121   else
154      return cvs_color_ram[offset];
122      return state->color_ram[offset];
155123}
156124
157125WRITE8_HANDLER( cvs_video_or_color_ram_w )
158126{
159   if (*cvs_fo_state)
160      cvs_video_ram[offset] = data;
127    cvs_state *state = (cvs_state *)space->machine->driver_data;
128
129   if (*state->fo_state)
130      state->video_ram[offset] = data;
161131   else
162      cvs_color_ram[offset] = data;
132      state->color_ram[offset] = data;
163133}
164134
165135
166136READ8_HANDLER( cvs_bullet_ram_or_palette_r )
167137{
168   if (*cvs_fo_state)
169      return cvs_palette_ram[offset & 0x0f];
138    cvs_state *state = (cvs_state *)space->machine->driver_data;
139
140   if (*state->fo_state)
141      return state->palette_ram[offset & 0x0f];
170142   else
171      return cvs_bullet_ram[offset];
143      return state->bullet_ram[offset];
172144}
173145
174146WRITE8_HANDLER( cvs_bullet_ram_or_palette_w )
175147{
176   if (*cvs_fo_state)
177      cvs_palette_ram[offset & 0x0f] = data;
148    cvs_state *state = (cvs_state *)space->machine->driver_data;
149
150   if (*state->fo_state)
151      state->palette_ram[offset & 0x0f] = data;
178152   else
179      cvs_bullet_ram[offset] = data;
153      state->bullet_ram[offset] = data;
180154}
181155
182156
183157READ8_HANDLER( cvs_s2636_0_or_character_ram_r )
184158{
185   const device_config *s2636_0 = devtag_get_device(space->machine, "s2636_0");
159    cvs_state *state = (cvs_state *)space->machine->driver_data;
186160
187   if (*cvs_fo_state)
188      return cvs_character_ram[(0 * 0x800) | 0x400 | character_ram_page_start | offset];
161   if (*state->fo_state)
162      return state->character_ram[(0 * 0x800) | 0x400 | state->character_ram_page_start | offset];
189163   else
190      return s2636_work_ram_r(s2636_0, offset);
164      return s2636_work_ram_r(state->s2636_0, offset);
191165}
192166
193167WRITE8_HANDLER( cvs_s2636_0_or_character_ram_w )
194168{
195   const device_config *s2636_0 = devtag_get_device(space->machine, "s2636_0");
169    cvs_state *state = (cvs_state *)space->machine->driver_data;
196170
197   if (*cvs_fo_state)
171   if (*state->fo_state)
198172   {
199      offset |= (0 * 0x800) | 0x400 | character_ram_page_start;
200      cvs_character_ram[offset] = data;
201      gfx_element_mark_dirty(space->machine->gfx[1], (offset/8) % 256);
173      offset |= (0 * 0x800) | 0x400 | state->character_ram_page_start;
174      state->character_ram[offset] = data;
175      gfx_element_mark_dirty(space->machine->gfx[1], (offset / 8) % 256);
202176   }
203177   else
204      s2636_work_ram_w(s2636_0, offset, data);
178      s2636_work_ram_w(state->s2636_0, offset, data);
205179}
206180
207181
208182READ8_HANDLER( cvs_s2636_1_or_character_ram_r )
209183{
210   const device_config *s2636_1 = devtag_get_device(space->machine, "s2636_1");
184    cvs_state *state = (cvs_state *)space->machine->driver_data;
211185
212   if (*cvs_fo_state)
213      return cvs_character_ram[(1 * 0x800) | 0x400 | character_ram_page_start | offset];
186   if (*state->fo_state)
187      return state->character_ram[(1 * 0x800) | 0x400 | state->character_ram_page_start | offset];
214188   else
215      return s2636_work_ram_r(s2636_1, offset);
189      return s2636_work_ram_r(state->s2636_1, offset);
216190}
217191
218192WRITE8_HANDLER( cvs_s2636_1_or_character_ram_w )
219193{
220   const device_config *s2636_1 = devtag_get_device(space->machine, "s2636_1");
194    cvs_state *state = (cvs_state *)space->machine->driver_data;
221195
222   if (*cvs_fo_state)
196   if (*state->fo_state)
223197   {
224      offset |= (1 * 0x800) | 0x400 | character_ram_page_start;
225      cvs_character_ram[offset] = data;
226      gfx_element_mark_dirty(space->machine->gfx[1], (offset/8) % 256);
198      offset |= (1 * 0x800) | 0x400 | state->character_ram_page_start;
199      state->character_ram[offset] = data;
200      gfx_element_mark_dirty(space->machine->gfx[1], (offset / 8) % 256);
227201   }
228202   else
229      s2636_work_ram_w(s2636_1, offset, data);
203      s2636_work_ram_w(state->s2636_1, offset, data);
230204}
231205
232206
233207READ8_HANDLER( cvs_s2636_2_or_character_ram_r )
234208{
235   const device_config *s2636_2 = devtag_get_device(space->machine, "s2636_2");
209    cvs_state *state = (cvs_state *)space->machine->driver_data;
236210
237   if (*cvs_fo_state)
238      return cvs_character_ram[(2 * 0x800) | 0x400 | character_ram_page_start | offset];
211   if (*state->fo_state)
212      return state->character_ram[(2 * 0x800) | 0x400 | state->character_ram_page_start | offset];
239213   else
240      return s2636_work_ram_r(s2636_2, offset);
214      return s2636_work_ram_r(state->s2636_2, offset);
241215}
242216
243217WRITE8_HANDLER( cvs_s2636_2_or_character_ram_w )
244218{
245   const device_config *s2636_2 = devtag_get_device(space->machine, "s2636_2");
219    cvs_state *state = (cvs_state *)space->machine->driver_data;
246220
247   if (*cvs_fo_state)
221   if (*state->fo_state)
248222   {
249      offset |= (2 * 0x800) | 0x400 | character_ram_page_start;
250      cvs_character_ram[offset] = data;
251      gfx_element_mark_dirty(space->machine->gfx[1], (offset/8) % 256);
223      offset |= (2 * 0x800) | 0x400 | state->character_ram_page_start;
224      state->character_ram[offset] = data;
225      gfx_element_mark_dirty(space->machine->gfx[1], (offset / 8) % 256);
252226   }
253227   else
254      s2636_work_ram_w(s2636_2, offset, data);
228      s2636_work_ram_w(state->s2636_2, offset, data);
255229}
256230
257231
r6740r6741
267241   cpu_set_input_line_vector(device, 0, 0x03);
268242   generic_pulse_irq_line(device, 0);
269243
270   cvs_scroll_stars();
244   cvs_scroll_stars(device->machine);
271245}
272246
273247
274static void cvs_slave_cpu_interrupt(running_machine *machine, const char *cpu, int state)
248static void cvs_slave_cpu_interrupt( const device_config *cpu, int state )
275249{
276   cpu_set_input_line_vector(cputag_get_cpu(machine, cpu), 0, 0x03);
277   //cputag_set_input_line(machine, cpu, 0, state ? ASSERT_LINE : CLEAR_LINE);
278   cputag_set_input_line(machine, cpu, 0, state ? HOLD_LINE : CLEAR_LINE);
250   cpu_set_input_line_vector(cpu, 0, 0x03);
251   //cpu_set_input_line(cpu, 0, state ? ASSERT_LINE : CLEAR_LINE);
252   cpu_set_input_line(cpu, 0, state ? HOLD_LINE : CLEAR_LINE);
279253}
280254
281255
r6740r6741
288262
289263static READ8_HANDLER( cvs_input_r )
290264{
265    cvs_state *state = (cvs_state *)space->machine->driver_data;
291266   UINT8 ret = 0;
292267
293268   /* the upper 4 bits of the address is used to select the character banking attributes */
294   character_banking_mode = (offset >> 4) & 0x03;
295   character_ram_page_start = (offset << 2) & 0x300;
269   state->character_banking_mode = (offset >> 4) & 0x03;
270   state->character_ram_page_start = (offset << 2) & 0x300;
296271
297272   /* the lower 4 (or 3?) bits select the port to read */
298273   switch (offset & 0x0f)   /* might be 0x07 */
r6740r6741
319294#if 0
320295static READ8_HANDLER( cvs_393hz_clock_r )
321296{
322     return cvs_393hz_clock ? 0x80 : 0;
297    cvs_state *state = (cvs_state *)space->machine->driver_data;
298    return state->cvs_393hz_clock ? 0x80 : 0;
323299}
324300#endif
325301
r6740r6741
330306
331307static TIMER_CALLBACK( cvs_393hz_timer_cb )
332308{
333   const device_config *dac3 = devtag_get_device(machine, "dac3");
334   cvs_393hz_clock = !cvs_393hz_clock;
309   cvs_state *state = (cvs_state *)machine->driver_data;
310   state->cvs_393hz_clock = !state->cvs_393hz_clock;
335311
336312   /* quasar.c games use this timer but have no dac3! */
337   if (dac3 != NULL)
313   if (state->dac3 != NULL)
338314   {
339      if (dac3_state[2])
340         dac_w(dac3, 0, cvs_393hz_clock * 0xff);
315      if (state->dac3_state[2])
316         dac_w(state->dac3, 0, state->cvs_393hz_clock * 0xff);
341317   }
342318}
343319
344320
345321static void start_393hz_timer(running_machine *machine)
346322{
347   cvs_393hz_timer = timer_alloc(machine, cvs_393hz_timer_cb, NULL);
348   timer_adjust_periodic(cvs_393hz_timer, ATTOTIME_IN_HZ(30*393), 0, ATTOTIME_IN_HZ(30*393));
323   cvs_state *state = (cvs_state *)machine->driver_data;
324   state->cvs_393hz_timer = timer_alloc(machine, cvs_393hz_timer_cb, NULL);
325   timer_adjust_periodic(state->cvs_393hz_timer, ATTOTIME_IN_HZ(30*393), 0, ATTOTIME_IN_HZ(30*393));
349326}
350327
351328
r6740r6741
358335
359336static WRITE8_DEVICE_HANDLER( cvs_4_bit_dac_data_w )
360337{
338   cvs_state *state = (cvs_state *)device->machine->driver_data;
361339   UINT8 dac_value;
362340   static int old_data[4] = {0,0,0,0};
363341
r6740r6741
366344      LOG(("4BIT: %02x %02x\n", offset, data));
367345      old_data[offset] = data;
368346   }
369   cvs_4_bit_dac_data[offset] = data >> 7;
347   state->cvs_4_bit_dac_data[offset] = data >> 7;
370348
371349   /* merge into D0-D3 */
372   dac_value = (cvs_4_bit_dac_data[0] << 0) |
373             (cvs_4_bit_dac_data[1] << 1) |
374             (cvs_4_bit_dac_data[2] << 2) |
375             (cvs_4_bit_dac_data[3] << 3);
350   dac_value = (state->cvs_4_bit_dac_data[0] << 0) |
351             (state->cvs_4_bit_dac_data[1] << 1) |
352             (state->cvs_4_bit_dac_data[2] << 2) |
353             (state->cvs_4_bit_dac_data[3] << 3);
376354
377355   /* scale up to a full byte and output */
378356   dac_data_w(device, (dac_value << 4) | dac_value);
r6740r6741
380358
381359static WRITE8_DEVICE_HANDLER( cvs_unknown_w )
382360{
361   cvs_state *state = (cvs_state *)device->machine->driver_data;
362
383363   /* offset 2 is used in 8ball
384364     * offset 0 is used in spacefrt
385365     * offset 3 is used in darkwar
r6740r6741
387367     * offset 1 is not used (no trace in disassembly)
388368     */
389369
390   if (data != dac3_state[offset])
370   if (data != state->dac3_state[offset])
391371   {
392372      if (offset != 2)
393373         popmessage("Unknown: %02x %02x\n", offset, data);
394      dac3_state[offset] = data;
374      state->dac3_state[offset] = data;
395375   }
396376}
397377
r6740r6741
405385
406386static WRITE8_HANDLER( cvs_speech_rom_address_lo_w )
407387{
388   cvs_state *state = (cvs_state *)space->machine->driver_data;
389
408390   /* assuming that d0-d2 are cleared here */
409   speech_rom_bit_address = (speech_rom_bit_address & 0xf800) | (data << 3);
410   LOG(("%04x : CVS: Speech Lo %02x Address = %04x\n", cpu_get_pc(space->cpu), data, speech_rom_bit_address >> 3));
391   state->speech_rom_bit_address = (state->speech_rom_bit_address & 0xf800) | (data << 3);
392   LOG(("%04x : CVS: Speech Lo %02x Address = %04x\n", cpu_get_pc(space->cpu), data, state->speech_rom_bit_address >> 3));
411393}
412394
413395static WRITE8_HANDLER( cvs_speech_rom_address_hi_w )
414396{
415   speech_rom_bit_address = (speech_rom_bit_address & 0x07ff) | (data << 11);
416   LOG(("%04x : CVS: Speech Hi %02x Address = %04x\n", cpu_get_pc(space->cpu), data, speech_rom_bit_address >> 3));
397   cvs_state *state = (cvs_state *)space->machine->driver_data;
398   state->speech_rom_bit_address = (state->speech_rom_bit_address & 0x07ff) | (data << 11);
399   LOG(("%04x : CVS: Speech Hi %02x Address = %04x\n", cpu_get_pc(space->cpu), data, state->speech_rom_bit_address >> 3));
417400}
418401
419402
420403static READ8_HANDLER( cvs_speech_command_r )
421404{
405   cvs_state *state = (cvs_state *)space->machine->driver_data;
406
422407   /* FIXME: this was by observation on board ???
423408     *          -bit 7 is TMS status (active LO) */
424   return ((tms5110_ctl_r(devtag_get_device(space->machine, "tms"), 0) ^ 1) << 7) | (soundlatch_r(space, 0) & 0x7f);
409   return ((tms5110_ctl_r(state->tms, 0) ^ 1) << 7) | (soundlatch_r(space, 0) & 0x7f);
425410}
426411
427412
428413static WRITE8_DEVICE_HANDLER( cvs_tms5110_ctl_w )
429414{
415   cvs_state *state = (cvs_state *)device->machine->driver_data;
430416   UINT8 ctl;
431417   /*
432418     * offset 0: CS ?
433419     */
434   cvs_tms5110_ctl_data[offset] = (~data >> 7) & 0x01;
420   state->tms5110_ctl_data[offset] = (~data >> 7) & 0x01;
435421
436422   ctl = 0 |                        /* CTL1 */
437        (cvs_tms5110_ctl_data[1] << 1) |   /* CTL2 */
438        (cvs_tms5110_ctl_data[2] << 2) |   /* CTL4 */
439        (cvs_tms5110_ctl_data[1] << 3);   /* CTL8 */
423        (state->tms5110_ctl_data[1] << 1) |   /* CTL2 */
424        (state->tms5110_ctl_data[2] << 2) |   /* CTL4 */
425        (state->tms5110_ctl_data[1] << 3);   /* CTL8 */
440426
441427   LOG(("CVS: Speech CTL = %04x %02x %02x\n",  ctl, offset, data));
442428   tms5110_ctl_w(device, 0, ctl);
r6740r6741
451437}
452438
453439
454static int speech_rom_read_bit(const device_config *device)
440static int speech_rom_read_bit( const device_config *device )
455441{
442   cvs_state *state = (cvs_state *)device->machine->driver_data;
456443   running_machine *machine = device->machine;
457444   UINT8 *ROM = memory_region(machine, "speechdata");
458445   int bit;
459446
460447   /* before reading the bit, clamp the address to the region length */
461   speech_rom_bit_address = speech_rom_bit_address & ((memory_region_length(machine, "speechdata") * 8) - 1);
462   bit = (ROM[speech_rom_bit_address >> 3] >> (speech_rom_bit_address & 0x07)) & 0x01;
448   state->speech_rom_bit_address = state->speech_rom_bit_address & ((memory_region_length(machine, "speechdata") * 8) - 1);
449   bit = (ROM[state->speech_rom_bit_address >> 3] >> (state->speech_rom_bit_address & 0x07)) & 0x01;
463450
464451   /* prepare for next bit */
465   speech_rom_bit_address = speech_rom_bit_address + 1;
452   state->speech_rom_bit_address = state->speech_rom_bit_address + 1;
466453
467454   return bit;
468455}
r6740r6741
484471
485472static WRITE8_HANDLER( audio_command_w )
486473{
474   cvs_state *state = (cvs_state *)space->machine->driver_data;
475
487476   LOG(("data %02x\n", data));
488477   /* cause interrupt on audio CPU if bit 7 set */
489478   soundlatch_w(space, 0, data);
490   cvs_slave_cpu_interrupt(space->machine, "audiocpu", data & 0x80 ? 1 : 0);
479   cvs_slave_cpu_interrupt(state->audiocpu, data & 0x80 ? 1 : 0);
491480}
492481
493482
494483
495484/*************************************
496485 *
497 *  Machine initialization
498 *
499 *************************************/
500
501MACHINE_START( cvs )
502{
503   /* allocate memory */
504   cvs_color_ram = auto_alloc_array(machine, UINT8, 0x400);
505   cvs_palette_ram = auto_alloc_array(machine, UINT8, 0x10);
506   cvs_character_ram = auto_alloc_array(machine, UINT8, 3 * 0x800);  /* only half is used, but
507                                                    by allocating twice the amount,
508                                                    we can use the same gfx_layout */
509
510   if (machine->gfx[1] != NULL)
511      gfx_element_set_source(machine->gfx[1], cvs_character_ram);
512
513   start_393hz_timer(machine);
514
515   /* register state save */
516   state_save_register_global_pointer(machine, cvs_color_ram, 0x400);
517   state_save_register_global_pointer(machine, cvs_palette_ram, 0x10);
518   state_save_register_global_pointer(machine, cvs_character_ram, 3 * 0x800);
519   state_save_register_global(machine, character_banking_mode);
520   state_save_register_global(machine, character_ram_page_start);
521   state_save_register_global(machine, speech_rom_bit_address);
522   state_save_register_global(machine, cvs_393hz_clock);
523}
524
525
526
527/*************************************
528 *
529486 *  Main CPU memory/IO handlers
530487 *
531488 *************************************/
r6740r6741
533490static ADDRESS_MAP_START( cvs_main_cpu_map, ADDRESS_SPACE_PROGRAM, 8 )
534491   ADDRESS_MAP_GLOBAL_MASK(0x7fff)
535492   AM_RANGE(0x0000, 0x13ff) AM_ROM
536   AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_READWRITE(cvs_bullet_ram_or_palette_r, cvs_bullet_ram_or_palette_w) AM_BASE(&cvs_bullet_ram)
493   AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_READWRITE(cvs_bullet_ram_or_palette_r, cvs_bullet_ram_or_palette_w) AM_BASE_MEMBER(cvs_state, bullet_ram)
537494   AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_READWRITE(cvs_s2636_2_or_character_ram_r, cvs_s2636_2_or_character_ram_w)
538495   AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_READWRITE(cvs_s2636_1_or_character_ram_r, cvs_s2636_1_or_character_ram_w)
539496   AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_READWRITE(cvs_s2636_0_or_character_ram_r, cvs_s2636_0_or_character_ram_w)
540   AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_READWRITE(cvs_video_or_color_ram_r, cvs_video_or_color_ram_w) AM_BASE(&cvs_video_ram)
497   AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_READWRITE(cvs_video_or_color_ram_r, cvs_video_or_color_ram_w) AM_BASE_MEMBER(cvs_state, video_ram)
541498   AM_RANGE(0x1c00, 0x1fff) AM_MIRROR(0x6000) AM_RAM
542499   AM_RANGE(0x2000, 0x33ff) AM_ROM
543500   AM_RANGE(0x4000, 0x53ff) AM_ROM
r6740r6741
550507   AM_RANGE(S2650_DATA_PORT, S2650_DATA_PORT) AM_READWRITE(cvs_collision_clear, cvs_video_fx_w)
551508   AM_RANGE(S2650_CTRL_PORT, S2650_CTRL_PORT) AM_READWRITE(cvs_collision_r, audio_command_w)
552509   AM_RANGE(S2650_SENSE_PORT, S2650_SENSE_PORT) AM_READ_PORT("SENSE")
553   AM_RANGE(S2650_FO_PORT, S2650_FO_PORT) AM_RAM AM_BASE(&cvs_fo_state)
510   AM_RANGE(S2650_FO_PORT, S2650_FO_PORT) AM_RAM AM_BASE_MEMBER(cvs_state, fo_state)
554511ADDRESS_MAP_END
555512
556513
r6740r6741
567524   AM_RANGE(0x1000, 0x107f) AM_RAM
568525   AM_RANGE(0x1800, 0x1800) AM_READ(soundlatch_r)
569526   AM_RANGE(0x1840, 0x1840) AM_DEVWRITE("dac1", dac_w)
570   AM_RANGE(0x1880, 0x1883) AM_DEVWRITE("dac2", cvs_4_bit_dac_data_w) AM_BASE(&cvs_4_bit_dac_data)
571   AM_RANGE(0x1884, 0x1887) AM_DEVWRITE("dac3", cvs_unknown_w)   AM_BASE(&dac3_state)   /* ???? not connected to anything */
527   AM_RANGE(0x1880, 0x1883) AM_DEVWRITE("dac2", cvs_4_bit_dac_data_w) AM_BASE_MEMBER(cvs_state, cvs_4_bit_dac_data)
528   AM_RANGE(0x1884, 0x1887) AM_DEVWRITE("dac3", cvs_unknown_w)   AM_BASE_MEMBER(cvs_state, dac3_state)   /* ???? not connected to anything */
572529ADDRESS_MAP_END
573530
574531
r6740r6741
591548   AM_RANGE(0x1d00, 0x1d00) AM_WRITE(cvs_speech_rom_address_lo_w)
592549   AM_RANGE(0x1d40, 0x1d40) AM_WRITE(cvs_speech_rom_address_hi_w)
593550   AM_RANGE(0x1d80, 0x1d80) AM_READ(cvs_speech_command_r)
594   AM_RANGE(0x1ddc, 0x1dde) AM_DEVWRITE("tms", cvs_tms5110_ctl_w) AM_BASE(&cvs_tms5110_ctl_data)
551   AM_RANGE(0x1ddc, 0x1dde) AM_DEVWRITE("tms", cvs_tms5110_ctl_w) AM_BASE_MEMBER(cvs_state, tms5110_ctl_data)
595552   AM_RANGE(0x1ddf, 0x1ddf) AM_DEVWRITE("tms", cvs_tms5110_pdc_w)
596553ADDRESS_MAP_END
597554
r6740r6741
620577   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
621578   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
622579
623   PORT_START("IN1")   /* Dunno */
580   PORT_START("IN1")
624581   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL        /* "Green button" */
625582   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 )                      /* "Green button" */
626583   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_COCKTAIL
r6740r6741
630587   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
631588   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
632589
633   PORT_START("IN2")   /* Dunno */
590   PORT_START("IN2")
634591   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE1 )           /* not sure it's SERVICE1 : it uses "Coin B" coinage and doesn't say "CREDIT" */
635592   PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNKNOWN )
636593
637   PORT_START("IN3")   /* Dunno */
594   PORT_START("IN3")
638595   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
639596   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
640597   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )   PORT_COCKTAIL
r6740r6741
644601   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
645602   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
646603
647   PORT_START("DSW3")   /* SW BANK 3 */
604   PORT_START("DSW3")
648605   PORT_DIPUNUSED( 0x01, IP_ACTIVE_HIGH )                  /* can't tell if it's ACTIVE_HIGH or ACTIVE_LOW */
649606   PORT_DIPUNUSED( 0x02, IP_ACTIVE_HIGH )                  /* can't tell if it's ACTIVE_HIGH or ACTIVE_LOW */
650607   PORT_DIPUNUSED( 0x04, IP_ACTIVE_HIGH )                  /* can't tell if it's ACTIVE_HIGH or ACTIVE_LOW */
r6740r6741
654611   PORT_DIPSETTING(    0x10, DEF_STR( Cocktail ) )
655612   PORT_DIPUNUSED( 0x20, IP_ACTIVE_HIGH )                  /* can't tell if it's ACTIVE_HIGH or ACTIVE_LOW */
656613
657   PORT_START("DSW2")   /* SW BANK 2 */
614   PORT_START("DSW2")
658615   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coin_A ) )
659616   PORT_DIPSETTING(    0x03, DEF_STR( 4C_1C ) )
660617   PORT_DIPSETTING(    0x01, DEF_STR( 3C_1C ) )
r6740r6741
670627   PORT_DIPSETTING(    0x10, "5" )
671628   PORT_DIPUNUSED( 0x20, IP_ACTIVE_HIGH )                  /* can't tell if it's ACTIVE_HIGH or ACTIVE_LOW */
672629
673   PORT_START("SENSE")   /* SENSE */
630   PORT_START("SENSE")
674631   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )
675632INPUT_PORTS_END
676633
r6740r6741
909866static INPUT_PORTS_START( heartatk )
910867   PORT_INCLUDE(cvs_registration)
911868
912    /* DSW3 bits 2 and 3 stored at 0x1c61 (0, 2, 1, 3) - code at 0x0c52
869   /* DSW3 bits 2 and 3 stored at 0x1c61 (0, 2, 1, 3) - code at 0x0c52
913870       read back code at 0x2197 but untested value : bonus life always at 100000 */
914871
915872   /* DSW2 bit 5 stored at 0x1e76 - code at 0x0c5c - read back code at 0x00e4 */
r6740r6741
1026983static const s2636_interface s2636_0_config =
1027984{
1028985   "screen",
1029   0xff,
986   0x100,
1030987   CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET
1031988};
1032989
1033990static const s2636_interface s2636_1_config =
1034991{
1035992   "screen",
1036   0xff,
993   0x100,
1037994   CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET
1038995};
1039996
1040997static const s2636_interface s2636_2_config =
1041998{
1042999   "screen",
1043   0xff,
1000   0x100,
10441001   CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET
10451002};
10461003
10471004
1005MACHINE_START( cvs )
1006{
1007   cvs_state *state = (cvs_state *)machine->driver_data;
1008
1009   /* allocate memory */
1010   state->color_ram = auto_alloc_array(machine, UINT8, 0x400);
1011   state->palette_ram = auto_alloc_array(machine, UINT8, 0x10);
1012   state->character_ram = auto_alloc_array(machine, UINT8, 3 * 0x800);  /* only half is used, but
1013                                                    by allocating twice the amount,
1014                                                    we can use the same gfx_layout */
1015
1016   if (machine->gfx[1] != NULL)
1017      gfx_element_set_source(machine->gfx[1], state->character_ram);
1018
1019   start_393hz_timer(machine);
1020
1021   /* set devices */
1022   state->maincpu = devtag_get_device(machine, "maincpu");
1023   state->audiocpu = devtag_get_device(machine, "audiocpu");
1024   state->speech = devtag_get_device(machine, "speech");
1025   state->dac3 = devtag_get_device(machine, "dac3");
1026   state->tms = devtag_get_device(machine, "tms");
1027   state->s2636_0 = devtag_get_device(machine, "s2636_0");
1028   state->s2636_1 = devtag_get_device(machine, "s2636_1");
1029   state->s2636_2 = devtag_get_device(machine, "s2636_2");
1030
1031   /* register state save */
1032   state_save_register_global_pointer(machine, state->color_ram, 0x400);
1033   state_save_register_global_pointer(machine, state->palette_ram, 0x10);
1034   state_save_register_global_pointer(machine, state->character_ram, 3 * 0x800);
1035   state_save_register_global(machine, state->character_banking_mode);
1036   state_save_register_global(machine, state->character_ram_page_start);
1037   state_save_register_global(machine, state->speech_rom_bit_address);
1038   state_save_register_global(machine, state->cvs_393hz_clock);
1039   state_save_register_global(machine, state->collision_register);
1040   state_save_register_global(machine, state->total_stars);
1041   state_save_register_global(machine, state->stars_on);
1042   state_save_register_global(machine, state->scroll_reg);
1043   state_save_register_global(machine, state->stars_scroll);
1044}
1045
1046MACHINE_RESET( cvs )
1047{
1048   cvs_state *state = (cvs_state *)machine->driver_data;
1049
1050   state->character_banking_mode = 0;
1051   state->character_ram_page_start = 0;
1052   state->speech_rom_bit_address = 0;
1053   state->cvs_393hz_clock = 0;
1054   state->collision_register = 0;
1055   state->total_stars = 0;
1056   state->stars_on = 0;
1057   state->scroll_reg = 0;
1058   state->stars_scroll = 0;
1059}
1060
1061
10481062static MACHINE_DRIVER_START( cvs )
10491063
1064   /* driver data */
1065   MDRV_DRIVER_DATA(cvs_state)
1066
10501067   /* basic machine hardware */
10511068   MDRV_CPU_ADD("maincpu", S2650, 894886.25)
10521069   MDRV_CPU_PROGRAM_MAP(cvs_main_cpu_map)
r6740r6741
10621079   MDRV_CPU_IO_MAP(cvs_speech_cpu_io_map)
10631080
10641081   MDRV_MACHINE_START(cvs)
1082   MDRV_MACHINE_RESET(cvs)
10651083
10661084   /* video hardware */
10671085   MDRV_VIDEO_ATTRIBUTES(VIDEO_ALWAYS_UPDATE)
r6740r6741
16851703 *
16861704 *************************************/
16871705
1688GAME( 1981, cosmos,   0,        cvs,     cosmos,   0,        ROT90, "Century Electronics", "Cosmos", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND )
1689GAME( 1981, darkwar,  0,        cvs,     darkwar,  0,        ROT90, "Century Electronics", "Dark Warrior", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1690GAME( 1981, spacefrt, 0,        cvs,     spacefrt, 0,        ROT90, "Century Electronics", "Space Fortress (CVS)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND )
1691GAME( 1982, 8ball,    0,        cvs,     8ball,    0,        ROT90, "Century Electronics", "Video Eight Ball", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1692GAME( 1982, 8ball1,   8ball,    cvs,     8ball,    0,        ROT90, "Century Electronics", "Video Eight Ball (Rev.1)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1693GAME( 1982, logger,   0,        cvs,     logger,   0,        ROT90, "Century Electronics", "Logger", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1694GAME( 1982, dazzler,  0,        cvs,     dazzler,  0,        ROT90, "Century Electronics", "Dazzler", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1695GAME( 1982, wallst,   0,        cvs,     wallst,   0,        ROT90, "Century Electronics", "Wall Street", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1696GAME( 1982, radarzon, 0,        cvs,     radarzon, 0,        ROT90, "Century Electronics", "Radar Zone", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1697GAME( 1982, radarzon1,radarzon, cvs,     radarzon, 0,        ROT90, "Century Electronics", "Radar Zone (Rev.1)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1698GAME( 1982, radarzont,radarzon, cvs,     radarzon, 0,        ROT90, "Century Electronics (Tuni Electro Service Inc)", "Radar Zone (Tuni)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1699GAME( 1982, outline,  radarzon, cvs,     radarzon, 0,        ROT90, "Century Electronics", "Outline", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1700GAME( 1982, goldbug,  0,        cvs,     goldbug,  0,        ROT90, "Century Electronics", "Gold Bug", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1701GAME( 1982, diggerc,  0,        cvs,     diggerc,  0,        ROT90, "Century Electronics", "Digger (CVS)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1702GAME( 1983, heartatk, 0,        cvs,     heartatk, 0,        ROT90, "Century Electronics", "Heart Attack", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1703GAME( 1983, hunchbak, 0,        cvs,     hunchbak, 0,        ROT90, "Century Electronics", "Hunchback (set 1)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1704GAME( 1983, hunchbaka,hunchbak, cvs,     hunchbak, hunchbka, ROT90, "Century Electronics", "Hunchback (set 2)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1705GAME( 1983, superbik, 0,        cvs,     superbik, superbik, ROT90, "Century Electronics", "Superbike", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1706GAME( 1983, raiders,  0,        cvs,     raiders,  raiders,  ROT90, "Century Electronics", "Raiders", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1707GAME( 1983, hero,     0,        cvs,     hero,     hero,     ROT90, "Seatongrove Ltd",     "Hero", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1708GAME( 1984, huncholy, 0,        cvs,     huncholy, huncholy, ROT90, "Seatongrove Ltd",     "Hunchback Olympic", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND)
1706GAME( 1981, cosmos,    0,        cvs,     cosmos,   0,        ROT90, "Century Electronics", "Cosmos", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1707GAME( 1981, darkwar,   0,        cvs,     darkwar,  0,        ROT90, "Century Electronics", "Dark Warrior", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1708GAME( 1981, spacefrt,  0,        cvs,     spacefrt, 0,        ROT90, "Century Electronics", "Space Fortress (CVS)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1709GAME( 1982, 8ball,     0,        cvs,     8ball,    0,        ROT90, "Century Electronics", "Video Eight Ball", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1710GAME( 1982, 8ball1,    8ball,    cvs,     8ball,    0,        ROT90, "Century Electronics", "Video Eight Ball (Rev.1)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1711GAME( 1982, logger,    0,        cvs,     logger,   0,        ROT90, "Century Electronics", "Logger", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1712GAME( 1982, dazzler,   0,        cvs,     dazzler,  0,        ROT90, "Century Electronics", "Dazzler", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1713GAME( 1982, wallst,    0,        cvs,     wallst,   0,        ROT90, "Century Electronics", "Wall Street", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1714GAME( 1982, radarzon,  0,        cvs,     radarzon, 0,        ROT90, "Century Electronics", "Radar Zone", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1715GAME( 1982, radarzon1, radarzon, cvs,     radarzon, 0,        ROT90, "Century Electronics", "Radar Zone (Rev.1)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1716GAME( 1982, radarzont, radarzon, cvs,     radarzon, 0,        ROT90, "Century Electronics (Tuni Electro Service Inc)", "Radar Zone (Tuni)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1717GAME( 1982, outline,   radarzon, cvs,     radarzon, 0,        ROT90, "Century Electronics", "Outline", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1718GAME( 1982, goldbug,   0,        cvs,     goldbug,  0,        ROT90, "Century Electronics", "Gold Bug", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1719GAME( 1982, diggerc,   0,        cvs,     diggerc,  0,        ROT90, "Century Electronics", "Digger (CVS)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1720GAME( 1983, heartatk,  0,        cvs,     heartatk, 0,        ROT90, "Century Electronics", "Heart Attack", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1721GAME( 1983, hunchbak,  0,        cvs,     hunchbak, 0,        ROT90, "Century Electronics", "Hunchback (set 1)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1722GAME( 1983, hunchbaka, hunchbak, cvs,     hunchbak, hunchbka, ROT90, "Century Electronics", "Hunchback (set 2)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1723GAME( 1983, superbik,  0,        cvs,     superbik, superbik, ROT90, "Century Electronics", "Superbike", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1724GAME( 1983, raiders,   0,        cvs,     raiders,  raiders,  ROT90, "Century Electronics", "Raiders", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1725GAME( 1983, hero,      0,        cvs,     hero,     hero,     ROT90, "Seatongrove Ltd",     "Hero", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1726GAME( 1984, huncholy,  0,        cvs,     huncholy, huncholy, ROT90, "Seatongrove Ltd",     "Hunchback Olympic", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
src/mame/drivers/turbo.c
r6740r6741
147147#include "driver.h"
148148#include "cpu/z80/z80.h"
149149#include "machine/8255ppi.h"
150#include "turbo.h"
150#include "includes/turbo.h"
151151#include "machine/segacrpt.h"
152152#include "sound/samples.h"
153153
src/mame/drivers/trvquest.c
r6740r6741
3838#include "cpu/m6809/m6809.h"
3939#include "machine/6522via.h"
4040#include "sound/ay8910.h"
41#include "gameplan.h"
41#include "includes/gameplan.h"
4242
4343static READ8_HANDLER( trvquest_question_r )
4444{
r6740r6741
4949
5050static WRITE8_DEVICE_HANDLER( trvquest_coin_w )
5151{
52   coin_counter_w(device->machine, 0,~data & 1);
52   coin_counter_w(device->machine, 0, ~data & 1);
5353}
5454
5555static WRITE8_DEVICE_HANDLER( trvquest_misc_w )
r6740r6741
148148
149149static TIMER_CALLBACK( via_irq_delayed )
150150{
151   cputag_set_input_line(machine, "maincpu", 0, param);
151   gameplan_state *state = (gameplan_state *)machine->driver_data;
152   cpu_set_input_line(state->maincpu, 0, param);
152153}
153154
154static void via_irq(const device_config *device, int state)
155static void via_irq( const device_config *device, int state )
155156{
156157   // from gameplan.c
157158
r6740r6741
162163}
163164
164165
165static input_port_value input_port_read_indexed(running_machine *machine, int portnum)
166{
167   const input_port_config *port = input_port_by_index(&machine->portlist, portnum);
168   return input_port_read_direct(port);
169}
170
171static READ8_DEVICE_HANDLER( via_input_port_0_r ) { return input_port_read_indexed(device->machine, 0); }
172static READ8_DEVICE_HANDLER( via_input_port_1_r ) { return input_port_read_indexed(device->machine, 1); }
173static READ8_DEVICE_HANDLER( via_input_port_2_r ) { return input_port_read_indexed(device->machine, 2); }
174static READ8_DEVICE_HANDLER( via_input_port_3_r ) { return input_port_read_indexed(device->machine, 3); }
175
176166static const via6522_interface via_1_interface =
177167{
178   /*inputs : A/B         */ DEVCB_HANDLER(via_input_port_0_r), DEVCB_HANDLER(via_input_port_1_r),
168   /*inputs : A/B         */ DEVCB_INPUT_PORT("IN0"), DEVCB_INPUT_PORT("IN1"),
179169   /*inputs : CA/B1,CA/B2 */ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
180170   /*outputs: A/B         */ DEVCB_NULL, DEVCB_NULL,
181171   /*outputs: CA/B1,CA/B2 */ DEVCB_NULL, DEVCB_NULL, DEVCB_HANDLER(trvquest_coin_w), DEVCB_NULL,
r6740r6741
184174
185175static const via6522_interface via_2_interface =
186176{
187   /*inputs : A/B         */ DEVCB_HANDLER(via_input_port_2_r), DEVCB_HANDLER(via_input_port_3_r),
177   /*inputs : A/B         */ DEVCB_INPUT_PORT("UNK"), DEVCB_INPUT_PORT("DSW"),
188178   /*inputs : CA/B1,CA/B2 */ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
189179   /*outputs: A/B         */ DEVCB_NULL, DEVCB_NULL,
190180   /*outputs: CA/B1,CA/B2 */ DEVCB_NULL, DEVCB_NULL, DEVCB_HANDLER(trvquest_misc_w), DEVCB_NULL,
r6740r6741
194184
195185static MACHINE_START( trvquest )
196186{
187   gameplan_state *state = (gameplan_state *)machine->driver_data;
188
189   state->maincpu = devtag_get_device(machine, "maincpu");
190   state->via_0 = devtag_get_device(machine, "via6522_0");
191   state->via_1 = devtag_get_device(machine, "via6522_1");
192   state->via_2 = devtag_get_device(machine, "via6522_2");
193
194   /* register for save states */
195   state_save_register_global(machine, state->video_x);
196   state_save_register_global(machine, state->video_y);
197   state_save_register_global(machine, state->video_command);
198   state_save_register_global(machine, state->video_data);
197199}
198200
199201static MACHINE_RESET( trvquest )
200202{
203   gameplan_state *state = (gameplan_state *)machine->driver_data;
204
205   state->video_x = 0;
206   state->video_y = 0;
207   state->video_command = 0;
208   state->video_data = 0;
201209}
202210
203211static INTERRUPT_GEN( trvquest_interrupt )
204212{
205   const device_config *via_2 = devtag_get_device(device->machine, "via6522_2");
206   via_ca1_w(via_2, 0, 1);
207   via_ca1_w(via_2, 0, 0);
213   gameplan_state *state = (gameplan_state *)device->machine->driver_data;
214   via_ca1_w(state->via_2, 0, 1);
215   via_ca1_w(state->via_2, 0, 0);
208216}
209217
210218static MACHINE_DRIVER_START( trvquest )
src/mame/drivers/tnzs.c
r6740r6741
621621
622622#include "driver.h"
623623#include "cpu/z80/z80.h"
624#include "taitoipt.h"
624#include "includes/taitoipt.h"
625625#include "cpu/mcs48/mcs48.h"
626626#include "sound/2203intf.h"
627627#include "sound/dac.h"
src/mame/drivers/rohga.c
r6740r6741
107107#include "driver.h"
108108#include "cpu/m68000/m68000.h"
109109#include "cpu/h6280/h6280.h"
110#include "decocrpt.h"
111#include "decoprot.h"
112#include "deco16ic.h"
110#include "includes/decocrpt.h"
111#include "includes/decoprot.h"
112#include "includes/deco16ic.h"
113113#include "sound/2151intf.h"
114114#include "sound/okim6295.h"
115115
src/mame/drivers/plygonet.c
r6740r6741
8080*/
8181
8282#include "driver.h"
83#include "video/konamiic.h"
83#include "video/konicdev.h"
8484#include "cpu/m68000/m68000.h"
8585#include "cpu/z80/z80.h"
8686#include "cpu/dsp56k/dsp56k.h"
8787#include "sound/k054539.h"
88#include "machine/eeprom.h"
88#include "machine/eepromdev.h"
8989
9090VIDEO_START( polygonet );
9191VIDEO_UPDATE( polygonet );
r6740r6741
9595READ32_HANDLER( polygonet_roz_ram_r );
9696WRITE32_HANDLER( polygonet_roz_ram_w );
9797
98static int init_eeprom_count;
99
10098/* 68k-side shared ram */
10199static UINT32* shared_ram;
102100
r6740r6741
121119   "0100110000000" /* unlock command */
122120};
123121
124static NVRAM_HANDLER( polygonet )
122static READ32_DEVICE_HANDLER( polygonet_eeprom_r )
125123{
126   if (read_or_write)
127      eeprom_save(file);
128   else
129   {
130      eeprom_init(machine, &eeprom_intf);
131
132      if (file)
133      {
134         init_eeprom_count = 0;
135         eeprom_load(file);
136      }
137      else
138         init_eeprom_count = 10;
139   }
140}
141
142static READ32_HANDLER( polygonet_eeprom_r )
143{
144124   if (ACCESSING_BITS_0_15)
145125   {
146      return 0x0200 | (eeprom_read_bit()<<8);
126      return 0x0200 | (eepromdev_read_bit(device) << 8);
147127   }
148128   else
149129   {
150      UINT8 lowInputBits = input_port_read(space->machine, "IN1");
151      UINT8 highInputBits = input_port_read(space->machine, "IN0");
130      UINT8 lowInputBits = input_port_read(device->machine, "IN1");
131      UINT8 highInputBits = input_port_read(device->machine, "IN0");
152132      return ((highInputBits << 24) | (lowInputBits << 16));
153133   }
154134
r6740r6741
161141{
162142   if (ACCESSING_BITS_24_31)
163143   {
164      eeprom_write_bit((data & 0x01000000) ? ASSERT_LINE : CLEAR_LINE);
165      eeprom_set_cs_line((data & 0x02000000) ? CLEAR_LINE : ASSERT_LINE);
166      eeprom_set_clock_line((data & 0x04000000) ? ASSERT_LINE : CLEAR_LINE);
144      input_port_write(space->machine, "EEPROMOUT", data, 0xffffffff);
167145      return;
168146   }
169147
r6740r6741
542520static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 32 )
543521   AM_RANGE(0x000000, 0x1fffff) AM_ROM
544522   AM_RANGE(0x200000, 0x21ffff) AM_RAM_WRITE(plygonet_palette_w) AM_BASE_GENERIC(paletteram)
545   AM_RANGE(0x400000, 0x40001f) AM_RAM AM_BASE((UINT32**)&K053936_0_ctrl)
523   AM_RANGE(0x400000, 0x40001f) AM_DEVREADWRITE16("k053936", k053936_ctrl_r, k053936_ctrl_w, 0xffffffff)
546524   AM_RANGE(0x440000, 0x440fff) AM_READWRITE(polygonet_roz_ram_r, polygonet_roz_ram_w)
547   AM_RANGE(0x480000, 0x4bffff) AM_READ(polygonet_eeprom_r)
525   AM_RANGE(0x480000, 0x4bffff) AM_DEVREAD("eeprom", polygonet_eeprom_r)
548526   AM_RANGE(0x4C0000, 0x4fffff) AM_WRITE(polygonet_eeprom_w)
549527   AM_RANGE(0x500000, 0x503fff) AM_RAM_WRITE(shared_ram_write) AM_BASE(&shared_ram)
550528   AM_RANGE(0x504000, 0x504003) AM_WRITE(dsp_w_lines)
r6740r6741
652630   //cputag_set_input_line(machine, "dsp", DSP56K_IRQ_MODB, CLEAR_LINE);
653631}
654632
633static const k053936_interface polygonet_k053936_intf =
634{
635   0, 0, 0   /* wrap, xoff, yoff */
636};
637
655638static MACHINE_DRIVER_START( plygonet )
656639   MDRV_CPU_ADD("maincpu", M68EC020, 16000000)   /* 16 MHz (xtal is 32.0 MHz) */
657640   MDRV_CPU_PROGRAM_MAP(main_map)
r6740r6741
668651   MDRV_MACHINE_START(polygonet)
669652
670653   MDRV_GFXDECODE(plygonet)
671   MDRV_NVRAM_HANDLER(polygonet)
672654
655   MDRV_EEPROM_NODEFAULT_ADD("eeprom", eeprom_intf)
656
673657   /* TODO: TEMPORARY!  UNTIL A MORE LOCALIZED SYNC CAN BE MADE */
674658   MDRV_QUANTUM_TIME(HZ(1200000))
675659
r6740r6741
686670   MDRV_VIDEO_START(polygonet)
687671   MDRV_VIDEO_UPDATE(polygonet)
688672
673   MDRV_K053936_ADD("k053936", polygonet_k053936_intf)
674
689675   /* sound hardware */
690676   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
691677
r6740r6741
722708   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
723709   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
724710   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
711
712   PORT_START( "EEPROMOUT" )
713   PORT_BIT( 0x01000000, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
714   PORT_BIT( 0x02000000, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
715   PORT_BIT( 0x04000000, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
725716INPUT_PORTS_END
726717
727718static INPUT_PORTS_START( polynetw )
r6740r6741
744735   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) PORT_PLAYER(1)
745736   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
746737   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
738
739   PORT_START( "EEPROMOUT" )
740   PORT_BIT( 0x01000000, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
741   PORT_BIT( 0x02000000, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
742   PORT_BIT( 0x04000000, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
747743INPUT_PORTS_END
748744
749745
r6740r6741
765761   dsp56k_update_handler = memory_set_direct_update_handler(cputag_get_address_space(machine, "dsp", ADDRESS_SPACE_PROGRAM), plygonet_dsp56k_direct_handler);
766762
767763    /* save states */
768   state_save_register_global(machine, init_eeprom_count);
769764   state_save_register_global_pointer(machine, dsp56k_bank00_ram,    2 * 8 * dsp56k_bank00_size);
770765   state_save_register_global_pointer(machine, dsp56k_bank01_ram,    2 * 8 * dsp56k_bank01_size);
771766   state_save_register_global_pointer(machine, dsp56k_bank02_ram,    2 * 8 * dsp56k_bank02_size);
src/mame/drivers/batman.c
r6740r6741
2020#include "driver.h"
2121#include "cpu/m68000/m68000.h"
2222#include "audio/atarijsa.h"
23#include "batman.h"
23#include "includes/batman.h"
2424
2525
2626
r6740r6741
3838}
3939
4040
41static MACHINE_START( batman )
42{
43   batman_state *state = (batman_state *)machine->driver_data;
44   atarigen_init(machine);
45
46   state_save_register_global(machine, state->latch_data);
47   state_save_register_global(machine, state->alpha_tile_bank);
48}
49
50
4151static MACHINE_RESET( batman )
4252{
4353   batman_state *state = (batman_state *)machine->driver_data;
r6740r6741
4757   atarivc_reset(machine->primary_screen, state->atarigen.atarivc_eof_data, 2);
4858   atarigen_scanline_timer_reset(machine->primary_screen, batman_scanline_update, 8);
4959   atarijsa_reset();
50   atarigen_init_save_state(machine);
51   state_save_register_global(machine, state->latch_data);
5260}
5361
5462
r6740r6741
231239   MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz)
232240   MDRV_CPU_PROGRAM_MAP(main_map)
233241
242   MDRV_MACHINE_START(batman)
234243   MDRV_MACHINE_RESET(batman)
235244   MDRV_NVRAM_HANDLER(atarigen)
236245
src/mame/drivers/nemesis.c
r6740r6741
5050#include "sound/k007232.h"
5151#include "sound/k051649.h"
5252#include "includes/nemesis.h"
53#include "konamipt.h"
53#include "includes/konamipt.h"
5454
5555int nemesis_irq_on = 0;
5656int nemesis_irq2_on = 0;
src/mame/drivers/warriorb.c
r6740r6741
145145
146146#include "driver.h"
147147#include "cpu/z80/z80.h"
148#include "taitoipt.h"
148#include "includes/taitoipt.h"
149149#include "rendlay.h"
150150#include "cpu/m68000/m68000.h"
151151#include "video/taitoic.h"
src/mame/drivers/bombjack.c
r6740r6741
9898#include "driver.h"
9999#include "cpu/z80/z80.h"
100100#include "sound/ay8910.h"
101#include "bombjack.h"
101#include "includes/bombjack.h"
102102
103103
104104static TIMER_CALLBACK( soundlatch_callback )
src/mame/drivers/trucocl.c
r6740r6741
3737#include "sound/dac.h"
3838
3939/* from video */
40extern UINT8 *trucocl_videoram;
41extern UINT8 *trucocl_colorram;
42
4043WRITE8_HANDLER( trucocl_videoram_w );
4144WRITE8_HANDLER( trucocl_colorram_w );
4245PALETTE_INIT( trucocl );
r6740r6741
8891
8992static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
9093   AM_RANGE(0x0000, 0x3fff) AM_ROM
91   AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(trucocl_videoram_w) AM_BASE_GENERIC(videoram)
92   AM_RANGE(0x4400, 0x47ff) AM_RAM_WRITE(trucocl_colorram_w) AM_BASE_GENERIC(colorram)
94   AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(trucocl_videoram_w) AM_BASE(&trucocl_videoram)
95   AM_RANGE(0x4400, 0x47ff) AM_RAM_WRITE(trucocl_colorram_w) AM_BASE(&trucocl_colorram)
9396   AM_RANGE(0x4c00, 0x4fff) AM_RAM
9497   AM_RANGE(0x5000, 0x5000) AM_WRITE(irq_enable_w)
9598   AM_RANGE(0x5000, 0x503f) AM_READ_PORT("IN0")
src/mame/drivers/unico.c
r6740r6741
2525#include "driver.h"
2626#include "cpu/m68000/m68000.h"
2727#include "machine/eeprom.h"
28#include "unico.h"
28#include "includes/unico.h"
2929#include "sound/2151intf.h"
3030#include "sound/3812intf.h"
3131#include "sound/okim6295.h"
src/mame/drivers/blockhl.c
r6740r6741
2222#include "driver.h"
2323#include "cpu/z80/z80.h"
2424#include "cpu/konami/konami.h" /* for the callback and the firq irq definition */
25#include "video/konamiic.h"
25#include "video/konicdev.h"
2626#include "sound/2151intf.h"
27#include "konamipt.h"
27#include "includes/konamipt.h"
2828
2929/* prototypes */
3030static MACHINE_RESET( blockhl );
3131static KONAMI_SETLINES_CALLBACK( blockhl_banking );
3232
33extern void blockhl_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color, int *flags, int *priority);
34extern void blockhl_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow);
3335
3436VIDEO_START( blockhl );
3537VIDEO_UPDATE( blockhl );
r6740r6741
4042
4143static INTERRUPT_GEN( blockhl_interrupt )
4244{
43   if (K052109_is_IRQ_enabled() && rombank == 0)   /* kludge to prevent crashes */
45   const device_config *k052109 = devtag_get_device(device->machine, "k052109");
46
47   if (k052109_is_irq_enabled(k052109) && rombank == 0)   /* kludge to prevent crashes */
4448      cpu_set_input_line(device, KONAMI_IRQ_LINE, HOLD_LINE);
4549}
4650
r6740r6741
6670}
6771
6872
73/* special handlers to combine 052109 & 051960 */
74static READ8_HANDLER( k052109_051960_r )
75{
76   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
77   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
6978
79   if (k052109_get_rmrd_line(k052109) == CLEAR_LINE)
80   {
81      if (offset >= 0x3800 && offset < 0x3808)
82         return k051937_r(k051960, offset - 0x3800);
83      else if (offset < 0x3c00)
84         return k052109_r(k052109, offset);
85      else
86         return k051960_r(k051960, offset - 0x3c00);
87   }
88   else
89      return k052109_r(k052109, offset);
90}
91
92static WRITE8_HANDLER( k052109_051960_w )
93{
94   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
95   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
96
97   if (offset >= 0x3800 && offset < 0x3808)
98      k051937_w(k051960, offset - 0x3800, data);
99   else if (offset < 0x3c00)
100      k052109_w(k052109, offset, data);
101   else
102      k051960_w(k051960, offset - 0x3c00, data);
103}
104
105
70106static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
71107   AM_RANGE(0x1f84, 0x1f84) AM_WRITE(soundlatch_w)
72108   AM_RANGE(0x1f88, 0x1f88) AM_WRITE(blockhl_sh_irqtrigger_w)
r6740r6741
76112   AM_RANGE(0x1f96, 0x1f96) AM_READ_PORT("P2")
77113   AM_RANGE(0x1f97, 0x1f97) AM_READ_PORT("DSW1")
78114   AM_RANGE(0x1f98, 0x1f98) AM_READ_PORT("DSW2")
79   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(K052109_051960_r, K052109_051960_w)
115   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(k052109_051960_r, k052109_051960_w)
80116   AM_RANGE(0x4000, 0x57ff) AM_RAM
81117   AM_RANGE(0x5800, 0x5fff) AM_READWRITE(bankedram_r, bankedram_w) AM_BASE(&ram)
82118   AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank1")
r6740r6741
146182
147183***************************************************************************/
148184
185static const k052109_interface blockhl_k052109_intf =
186{
187   "gfx1", 0,
188   NORMAL_PLANE_ORDER,
189   KONAMI_ROM_DEINTERLEAVE_2,
190   blockhl_tile_callback
191};
192
193static const k051960_interface blockhl_k051960_intf =
194{
195   "gfx2", 1,
196   NORMAL_PLANE_ORDER,
197   KONAMI_ROM_DEINTERLEAVE_2,
198   blockhl_sprite_callback
199};
200
149201static MACHINE_DRIVER_START( blockhl )
150202
151203   /* basic machine hardware */
r6740r6741
173225   MDRV_VIDEO_START(blockhl)
174226   MDRV_VIDEO_UPDATE(blockhl)
175227
228   MDRV_K052109_ADD("k052109", blockhl_k052109_intf)
229   MDRV_K051960_ADD("k051960", blockhl_k051960_intf)
230
176231   /* sound hardware */
177232   MDRV_SPEAKER_STANDARD_MONO("mono")
178233
r6740r6741
245300
246301static KONAMI_SETLINES_CALLBACK( blockhl_banking )
247302{
303   const device_config *k052109 = devtag_get_device(device->machine, "k052109");
248304   UINT8 *RAM = memory_region(device->machine, "maincpu");
249305   int offs;
250306
r6740r6741
261317   palette_selected = ~lines & 0x20;
262318
263319   /* bit 6 = enable char ROM reading through the video RAM */
264   K052109_set_RMRD_line( ( lines & 0x40 ) ? ASSERT_LINE : CLEAR_LINE );
320   k052109_set_rmrd_line(k052109, (lines & 0x40) ? ASSERT_LINE : CLEAR_LINE);
265321
266322   /* bit 7 used but unknown */
267323
r6740r6741
280336}
281337
282338
283static DRIVER_INIT( blockhl )
284{
285   konami_rom_deinterleave_2(machine, "gfx1");
286   konami_rom_deinterleave_2(machine, "gfx2");
287}
288
289
290GAME( 1989, blockhl, 0,       blockhl, blockhl, blockhl, ROT0, "Konami", "Block Hole", 0 )
291GAME( 1989, quarth,  blockhl, blockhl, blockhl, blockhl, ROT0, "Konami", "Quarth (Japan)", 0 )
339GAME( 1989, blockhl, 0,       blockhl, blockhl, 0, ROT0, "Konami", "Block Hole", 0 )
340GAME( 1989, quarth,  blockhl, blockhl, blockhl, 0, ROT0, "Konami", "Quarth (Japan)", 0 )
src/mame/drivers/segag80v.c
r6740r6741
139139#include "audio/segasnd.h"
140140#include "video/vector.h"
141141#include "includes/segag80r.h"
142#include "segag80v.h"
142#include "includes/segag80v.h"
143143
144144
145145/*************************************
src/mame/drivers/bottom9.c
r6740r6741
1616#include "cpu/z80/z80.h"
1717#include "deprecat.h"
1818#include "cpu/m6809/m6809.h"
19#include "video/konamiic.h"
19#include "video/konicdev.h"
2020#include "sound/k007232.h"
21#include "konamipt.h"
21#include "includes/konamipt.h"
2222
2323extern int bottom9_video_enable;
2424
2525VIDEO_START( bottom9 );
2626VIDEO_UPDATE( bottom9 );
2727
28extern void bottom9_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
29extern void bottom9_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow);
30extern void bottom9_zoom_callback(running_machine *machine, int *code,int *color,int *flags);
2831
2932
3033static INTERRUPT_GEN( bottom9_interrupt )
3134{
32   if (K052109_is_IRQ_enabled())
35   const device_config *k052109 = devtag_get_device(device->machine, "k052109");
36   if (k052109_is_irq_enabled(k052109))
3337      cpu_set_input_line(device, 0, HOLD_LINE);
3438}
3539
3640
37static int zoomreadroms,K052109_selected;
41static int zoomreadroms, k052109_selected;
3842
43static READ8_HANDLER( k052109_051960_r )
44{
45   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
46   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
47
48   if (k052109_get_rmrd_line(k052109) == CLEAR_LINE)
49   {
50      if (offset >= 0x3800 && offset < 0x3808)
51         return k051937_r(k051960, offset - 0x3800);
52      else if (offset < 0x3c00)
53         return k052109_r(k052109, offset);
54      else
55         return k051960_r(k051960, offset - 0x3c00);
56   }
57   else
58      return k052109_r(k052109, offset);
59}
60
61static WRITE8_HANDLER( k052109_051960_w )
62{
63   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
64   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
65
66   if (offset >= 0x3800 && offset < 0x3808)
67      k051937_w(k051960, offset - 0x3800, data);
68   else if (offset < 0x3c00)
69      k052109_w(k052109, offset, data);
70   else
71      k051960_w(k051960, offset - 0x3c00, data);
72}
73
3974static READ8_HANDLER( bottom9_bankedram1_r )
4075{
41   if (K052109_selected)
42      return K052109_051960_r(space,offset);
76   const device_config *k051316 = devtag_get_device(space->machine, "k051316");
77
78   if (k052109_selected)
79      return k052109_051960_r(space, offset);
4380   else
4481   {
4582      if (zoomreadroms)
46         return K051316_rom_0_r(space,offset);
83         return k051316_rom_r(k051316, offset);
4784      else
48         return K051316_0_r(space,offset);
85         return k051316_r(k051316,offset);
4986   }
5087}
5188
5289static WRITE8_HANDLER( bottom9_bankedram1_w )
5390{
54   if (K052109_selected) K052109_051960_w(space,offset,data);
55   else K051316_0_w(space,offset,data);
91   const device_config *k051316 = devtag_get_device(space->machine, "k051316");
92
93   if (k052109_selected)
94      k052109_051960_w(space, offset, data);
95   else
96      k051316_w(k051316, offset, data);
5697}
5798
5899static READ8_HANDLER( bottom9_bankedram2_r )
59100{
60   if (K052109_selected) return K052109_051960_r(space,offset + 0x2000);
61   else return space->machine->generic.paletteram.u8[offset];
101   if (k052109_selected)
102      return k052109_051960_r(space, offset + 0x2000);
103   else
104      return space->machine->generic.paletteram.u8[offset];
62105}
63106
64107static WRITE8_HANDLER( bottom9_bankedram2_w )
65108{
66   if (K052109_selected) K052109_051960_w(space,offset + 0x2000,data);
67   else paletteram_xBBBBBGGGGGRRRRR_be_w(space,offset,data);
109   if (k052109_selected)
110      k052109_051960_w(space, offset + 0x2000, data);
111   else
112      paletteram_xBBBBBGGGGGRRRRR_be_w(space, offset, data);
68113}
69114
70115static WRITE8_HANDLER( bankswitch_w )
r6740r6741
73118   int offs;
74119
75120   /* bit 0 = RAM bank */
76if ((data & 1) == 0) popmessage("bankswitch RAM bank 0");
121   if ((data & 1) == 0)
122      popmessage("bankswitch RAM bank 0");
77123
78124   /* bit 1-4 = ROM bank */
79   if (data & 0x10) offs = 0x20000 + (data & 0x06) * 0x1000;
80   else offs = 0x10000 + (data & 0x0e) * 0x1000;
125   if (data & 0x10)
126      offs = 0x20000 + (data & 0x06) * 0x1000;
127   else
128      offs = 0x10000 + (data & 0x0e) * 0x1000;
129
81130   memory_set_bankptr(space->machine, "bank1",&RAM[offs]);
82131}
83132
84133static WRITE8_HANDLER( bottom9_1f90_w )
85134{
135   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
136
86137   /* bits 0/1 = coin counters */
87   coin_counter_w(space->machine, 0,data & 0x01);
88   coin_counter_w(space->machine, 1,data & 0x02);
138   coin_counter_w(space->machine, 0, data & 0x01);
139   coin_counter_w(space->machine, 1, data & 0x02);
89140
90141   /* bit 2 = enable char ROM reading through the video RAM */
91   K052109_set_RMRD_line((data & 0x04) ? ASSERT_LINE : CLEAR_LINE);
142   k052109_set_rmrd_line(k052109, (data & 0x04) ? ASSERT_LINE : CLEAR_LINE);
92143
93144   /* bit 3 = disable video */
94145   bottom9_video_enable = ~data & 0x08;
r6740r6741
97148   zoomreadroms = data & 0x10;
98149
99150   /* bit 5 = RAM bank */
100   K052109_selected = data & 0x20;
151   k052109_selected = data & 0x20;
101152}
102153
103154static WRITE8_HANDLER( bottom9_sh_irqtrigger_w )
r6740r6741
143194   AM_RANGE(0x1fd2, 0x1fd2) AM_READ_PORT("P2")
144195   AM_RANGE(0x1fd3, 0x1fd3) AM_READ_PORT("DSW1")
145196   AM_RANGE(0x1fe0, 0x1fe0) AM_READ_PORT("DSW2")
146   AM_RANGE(0x1ff0, 0x1fff) AM_WRITE(K051316_ctrl_0_w)
197   AM_RANGE(0x1ff0, 0x1fff) AM_DEVWRITE("k051316", k051316_ctrl_w)
147198   AM_RANGE(0x2000, 0x27ff) AM_READWRITE(bottom9_bankedram2_r, bottom9_bankedram2_w) AM_BASE_GENERIC(paletteram)
148   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(K052109_051960_r, K052109_051960_w)
199   AM_RANGE(0x0000, 0x3fff) AM_READWRITE(k052109_051960_r, k052109_051960_w)
149200   AM_RANGE(0x4000, 0x5fff) AM_RAM
150201   AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank1")
151202   AM_RANGE(0x8000, 0xffff) AM_ROM
r6740r6741
256307
257308
258309
310static const k052109_interface bottom9_k052109_intf =
311{
312   "gfx1", 0,
313   NORMAL_PLANE_ORDER,
314   KONAMI_ROM_DEINTERLEAVE_2,
315   bottom9_tile_callback
316};
317
318static const k051960_interface bottom9_k051960_intf =
319{
320   "gfx2", 1,
321   NORMAL_PLANE_ORDER,
322   KONAMI_ROM_DEINTERLEAVE_2,
323   bottom9_sprite_callback
324};
325
326static const k051316_interface bottom9_k051316_intf =
327{
328   "gfx3", 2,
329   4, FALSE, 0,
330   0, 0, 0,
331   bottom9_zoom_callback
332};
333
259334static MACHINE_DRIVER_START( bottom9 )
260335
261336   /* basic machine hardware */
r6740r6741
282357   MDRV_VIDEO_START(bottom9)
283358   MDRV_VIDEO_UPDATE(bottom9)
284359
360   MDRV_K052109_ADD("k052109", bottom9_k052109_intf)
361   MDRV_K051960_ADD("k051960", bottom9_k051960_intf)
362   MDRV_K051316_ADD("k051316", bottom9_k051316_intf)
363
285364   /* sound hardware */
286365   MDRV_SPEAKER_STANDARD_MONO("mono")
287366
r6740r6741
306385ROM_START( bottom9 )
307386   ROM_REGION( 0x28000, "maincpu", 0 ) /* code + banked roms */
308387   ROM_LOAD( "891n03.k17",   0x10000, 0x10000, CRC(8b083ff3) SHA1(045fef944b192e4bb147fa0f28680c0602af7377) )
309    ROM_LOAD( "891-t02.k15",  0x20000, 0x08000, CRC(2c10ced2) SHA1(ecd43825a67b495cade94a454c96a19143d87760) )
310    ROM_CONTINUE(             0x08000, 0x08000 )
388   ROM_LOAD( "891-t02.k15",  0x20000, 0x08000, CRC(2c10ced2) SHA1(ecd43825a67b495cade94a454c96a19143d87760) )
389   ROM_CONTINUE(             0x08000, 0x08000 )
311390
312391   ROM_REGION( 0x10000, "audiocpu", 0 ) /* Z80 code */
313392   ROM_LOAD( "891j01.g8",    0x0000, 0x8000, CRC(31b0a0a8) SHA1(8e047f81c19f25de97fa22e70dcfe9e06bfae699) )
r6740r6741
363442ROM_START( bottom9n )
364443   ROM_REGION( 0x28000, "maincpu", 0 ) /* code + banked roms */
365444   ROM_LOAD( "891n03.k17",   0x10000, 0x10000, CRC(8b083ff3) SHA1(045fef944b192e4bb147fa0f28680c0602af7377) )
366    ROM_LOAD( "891n02.k15",   0x20000, 0x08000, CRC(d44d9ed4) SHA1(2a12bcfba81ab7e074569e2ad2da6a237a1c0ce5) )
367    ROM_CONTINUE(             0x08000, 0x08000 )
445   ROM_LOAD( "891n02.k15",   0x20000, 0x08000, CRC(d44d9ed4) SHA1(2a12bcfba81ab7e074569e2ad2da6a237a1c0ce5) )
446   ROM_CONTINUE(             0x08000, 0x08000 )
368447
369448   ROM_REGION( 0x10000, "audiocpu", 0 ) /* Z80 code */
370449   ROM_LOAD( "891j01.g8",    0x0000, 0x8000, CRC(31b0a0a8) SHA1(8e047f81c19f25de97fa22e70dcfe9e06bfae699) )
r6740r6741
420499ROM_START( mstadium )
421500   ROM_REGION( 0x28000, "maincpu", 0 ) /* code + banked roms */
422501   ROM_LOAD( "891-403.k17",   0x10000, 0x10000, CRC(1c00c4e8) SHA1(8a3400a8df44f21616422e5af3bca84d0f390f63) )
423    ROM_LOAD( "891-402.k15",   0x20000, 0x08000, CRC(b850bbce) SHA1(a64300d1b1068e59eb59c427946c9bff164e2da8) )
424    ROM_CONTINUE(             0x08000, 0x08000 )
502   ROM_LOAD( "891-402.k15",   0x20000, 0x08000, CRC(b850bbce) SHA1(a64300d1b1068e59eb59c427946c9bff164e2da8) )
503   ROM_CONTINUE(             0x08000, 0x08000 )
425504
426505   ROM_REGION( 0x10000, "audiocpu", 0 ) /* Z80 code */
427506   ROM_LOAD( "891w01.g8",    0x0000, 0x8000, CRC(edec565a) SHA1(69cba0d00c6ef76c4ce2b553e3fd15de8abbbf31) )
r6740r6741
476555
477556
478557
479static DRIVER_INIT( bottom9 )
480{
481   konami_rom_deinterleave_2(machine, "gfx1");
482   konami_rom_deinterleave_2(machine, "gfx2");
483}
484
485
486
487GAME( 1989, bottom9,  0,       bottom9, bottom9,  bottom9, ROT0, "Konami", "Bottom of the Ninth (version T)", 0 )
488GAME( 1989, bottom9n, bottom9, bottom9, bottom9,  bottom9, ROT0, "Konami", "Bottom of the Ninth (version N)", 0 )
489GAME( 1989, mstadium, bottom9, bottom9, mstadium, bottom9, ROT0, "Konami", "Main Stadium (Japan)", 0 )
558GAME( 1989, bottom9,  0,       bottom9, bottom9,  0, ROT0, "Konami", "Bottom of the Ninth (version T)", 0 )
559GAME( 1989, bottom9n, bottom9, bottom9, bottom9,  0, ROT0, "Konami", "Bottom of the Ninth (version N)", 0 )
560GAME( 1989, mstadium, bottom9, bottom9, mstadium, 0, ROT0, "Konami", "Main Stadium (Japan)", 0 )
src/mame/drivers/m62.c
r6740r6741
7070#include "driver.h"
7171#include "cpu/z80/z80.h"
7272#include "includes/iremz80.h"
73#include "iremipt.h"
73#include "includes/iremipt.h"
7474
7575
7676/* Lode Runner 2 seems to have a simple protection on the bank switching */
src/mame/drivers/megazone.c
r6740r6741
1414#include "sound/ay8910.h"
1515#include "sound/dac.h"
1616#include "sound/flt_rc.h"
17#include "konamipt.h"
17#include "includes/konamipt.h"
1818
1919extern UINT8 *megazone_scrollx;
2020extern UINT8 *megazone_scrolly;
2121
22extern UINT8 *megazone_videoram;
2223extern UINT8 *megazone_videoram2;
24extern UINT8 *megazone_colorram;
2325extern UINT8 *megazone_colorram2;
26extern size_t megazone_videoram_size;
2427extern size_t megazone_videoram2_size;
2528
2629static int i8039_status;
r6740r6741
98101   AM_RANGE(0x0800, 0x0800) AM_WRITE(watchdog_reset_w)
99102   AM_RANGE(0x1000, 0x1000) AM_WRITEONLY AM_BASE(&megazone_scrolly)
100103   AM_RANGE(0x1800, 0x1800) AM_WRITEONLY AM_BASE(&megazone_scrollx)
101   AM_RANGE(0x2000, 0x23ff) AM_RAM AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
104   AM_RANGE(0x2000, 0x23ff) AM_RAM AM_BASE(&megazone_videoram) AM_SIZE(&megazone_videoram_size)
102105   AM_RANGE(0x2400, 0x27ff) AM_RAM AM_BASE(&megazone_videoram2) AM_SIZE(&megazone_videoram2_size)
103   AM_RANGE(0x2800, 0x2bff) AM_RAM AM_BASE_GENERIC(colorram)
106   AM_RANGE(0x2800, 0x2bff) AM_RAM AM_BASE(&megazone_colorram)
104107   AM_RANGE(0x2c00, 0x2fff) AM_RAM AM_BASE(&megazone_colorram2)
105108   AM_RANGE(0x3000, 0x33ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
106109   AM_RANGE(0x3800, 0x3fff) AM_RAM AM_SHARE("share1")
src/mame/drivers/galaga.c
r6740r6741
893893      bosco_latch_w(space,i,0);
894894}
895895
896static MACHINE_RESET( bosco )
897{
898   /* Reset all latches */
899   bosco_latch_reset(machine);
900
901   timer_adjust_oneshot(cpu3_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 64, 0), 64);
902}
903
904896static MACHINE_RESET( galaga )
905897{
906898   /* Reset all latches */
r6740r6741
909901   timer_adjust_oneshot(cpu3_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 64, 0), 64);
910902}
911903
912static MACHINE_RESET( xevious )
913{
914   /* Reset all latches */
915   bosco_latch_reset(machine);
916
917   timer_adjust_oneshot(cpu3_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 64, 0), 64);
918}
919
920904static MACHINE_RESET( battles )
921905{
922   /* Reset all latches */
923   bosco_latch_reset(machine);
924
906   MACHINE_RESET_CALL(galaga);
925907   battles_customio_init(machine);
926
927   timer_adjust_oneshot(cpu3_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 64, 0), 64);
928908}
929909
930static MACHINE_RESET( digdug )
931{
932   /* Reset all latches */
933   bosco_latch_reset(machine);
934910
935   timer_adjust_oneshot(cpu3_interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, 64, 0), 64);
936}
937
938
939
940911/* the same memory map is used by all three CPUs; all RAM areas are shared */
941912static ADDRESS_MAP_START( bosco_map, ADDRESS_SPACE_PROGRAM, 8 )
942913   AM_RANGE(0x0000, 0x3fff) AM_ROM AM_WRITENOP         /* the only area different for each CPU */
r6740r6741
16351606   MDRV_QUANTUM_TIME(HZ(6000))   /* 100 CPU slices per frame - an high value to ensure proper */
16361607                     /* synchronization of the CPUs */
16371608   MDRV_MACHINE_START(galaga)
1638   MDRV_MACHINE_RESET(bosco)
1609   MDRV_MACHINE_RESET(galaga)
16391610
16401611   /* video hardware */
16411612   MDRV_SCREEN_ADD("screen", RASTER)
r6740r6741
17581729   MDRV_QUANTUM_TIME(HZ(60000))   /* 1000 CPU slices per frame - an high value to ensure proper */
17591730                     /* synchronization of the CPUs */
17601731   MDRV_MACHINE_START(galaga)
1761   MDRV_MACHINE_RESET(xevious)
1732   MDRV_MACHINE_RESET(galaga)
17621733
17631734   /* video hardware */
17641735   MDRV_SCREEN_ADD("screen", RASTER)
r6740r6741
18011772   MDRV_CPU_PROGRAM_MAP(battles_mem4)
18021773   MDRV_CPU_VBLANK_INT("screen", battles_interrupt_4)
18031774
1775   MDRV_TIMER_ADD("battles_nmi", battles_nmi_generate)
1776
18041777   MDRV_MACHINE_RESET(battles)
18051778
18061779   /* video hardware */
r6740r6741
18371810   MDRV_QUANTUM_TIME(HZ(6000))   /* 100 CPU slices per frame - an high value to ensure proper */
18381811                     /* synchronization of the CPUs */
18391812   MDRV_MACHINE_START(galaga)
1840   MDRV_MACHINE_RESET(digdug)
1813   MDRV_MACHINE_RESET(galaga)
18411814
18421815   MDRV_ATARIVGEAROM_ADD("earom")
18431816
src/mame/drivers/macs.c
r6740r6741
5858#include "driver.h"
5959#include "cpu/z80/z80.h"
6060#include "sound/st0016.h"
61#include "st0016.h"
61#include "includes/st0016.h"
6262
6363
6464
src/mame/drivers/sbowling.c
r6740r6741
206206
207207static INPUT_PORTS_START( sbowling )
208208   PORT_START("IN0")
209   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN )
210   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
211   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
212   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
209213   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_COIN1   )
210214   PORT_BIT( 0x20, IP_ACTIVE_HIGH,   IPT_TILT )
215   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
216   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
211217
212218   PORT_START("IN1")
213219   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN2 )
220   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
221   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
222   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
223   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 )
224   PORT_BIT( 0x20, IP_ACTIVE_HIGH,   IPT_UNKNOWN )
214225   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START1 )
215226   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START2 )
216227
r6740r6741
221232   PORT_BIT( 0xff, 0, IPT_TRACKBALL_X ) PORT_SENSITIVITY(30) PORT_KEYDELTA(30) PORT_REVERSE
222233
223234   PORT_START("DSW0")   /* coin slots: A 4 LSB, B 4 MSB */
224   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
225   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
226   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
227   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
228   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
229   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
230   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
231   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
232   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
233   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
234   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
235   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
236   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
237   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
238   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
239   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
240   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
241   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
242   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
243   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
244   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
245   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
246   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
247   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
235   PORT_DIPNAME( 0x0f, 0x00, DEF_STR( Coin_A ) )  PORT_DIPLOCATION("SW1:!1,!2,!3,!4")
236   PORT_DIPSETTING(    0x0f, DEF_STR( 9C_1C ) )
237   PORT_DIPSETTING(    0x0e, DEF_STR( 8C_1C ) )
238   PORT_DIPSETTING(    0x0d, DEF_STR( 7C_1C ) )
239   PORT_DIPSETTING(    0x0c, DEF_STR( 6C_1C ) )
240   PORT_DIPSETTING(    0x0b, DEF_STR( 5C_1C ) )
241   PORT_DIPSETTING(    0x0a, DEF_STR( 4C_1C ) )
242   PORT_DIPSETTING(    0x09, DEF_STR( 3C_1C ) )
243   PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
244   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
245   PORT_DIPSETTING(    0x01, DEF_STR( 1C_2C ) )
246   PORT_DIPSETTING(    0x02, DEF_STR( 1C_3C ) )
247   PORT_DIPSETTING(    0x03, DEF_STR( 1C_4C ) )
248   PORT_DIPSETTING(    0x04, DEF_STR( 1C_5C ) )
249   PORT_DIPSETTING(    0x05, DEF_STR( 1C_6C ) )
250   PORT_DIPSETTING(    0x06, DEF_STR( 1C_7C ) )
251   PORT_DIPSETTING(    0x07, DEF_STR( 1C_8C ) )
248252
253   PORT_DIPNAME( 0xf0, 0x00, DEF_STR( Coin_B ) )  PORT_DIPLOCATION("SW1:!5,!6,!7,!8")
254   PORT_DIPSETTING(    0xf0, DEF_STR( 9C_1C ) )
255   PORT_DIPSETTING(    0xe0, DEF_STR( 8C_1C ) )
256   PORT_DIPSETTING(    0xd0, DEF_STR( 7C_1C ) )
257   PORT_DIPSETTING(    0xc0, DEF_STR( 6C_1C ) )
258   PORT_DIPSETTING(    0xb0, DEF_STR( 5C_1C ) )
259   PORT_DIPSETTING(    0xa0, DEF_STR( 4C_1C ) )
260   PORT_DIPSETTING(    0x90, DEF_STR( 3C_1C ) )
261   PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
262   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
263   PORT_DIPSETTING(    0x10, DEF_STR( 1C_2C ) )
264   PORT_DIPSETTING(    0x20, DEF_STR( 1C_3C ) )
265   PORT_DIPSETTING(    0x30, DEF_STR( 1C_4C ) )
266   PORT_DIPSETTING(    0x40, DEF_STR( 1C_5C ) )
267   PORT_DIPSETTING(    0x50, DEF_STR( 1C_6C ) )
268   PORT_DIPSETTING(    0x60, DEF_STR( 1C_7C ) )
269   PORT_DIPSETTING(    0x70, DEF_STR( 1C_8C ) )
270
249271   PORT_START("DSW1")
250   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ) )
272   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ) )  PORT_DIPLOCATION("SW2:!1")
251273   PORT_DIPSETTING(    0x01, DEF_STR( Upright ) )
252274   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
253   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
254   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
255   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
256   PORT_DIPNAME( 0x04, 0x04, "Year Display" )
275   PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x00, "SW2:!2" )
276   PORT_DIPNAME( 0x04, 0x00, "Year Display" )  PORT_DIPLOCATION("SW2:!3")
257277   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
258278   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
259   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
260   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
261   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
262   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
263   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
264   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
265   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
266   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
267   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
268   PORT_DIPNAME( 0x40, 0x00, "Ball Controll Check" )
279   PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x00, "SW2:!4" )
280   PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x00, "SW2:!5" )
281   PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x00, "SW2:!6" )
282   PORT_DIPNAME( 0x40, 0x00, "Ball Control Check" )  PORT_DIPLOCATION("SW2:!7")
269283   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
270284   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
271   PORT_DIPNAME( 0x80, 0x00, "Video Test" )
285   PORT_DIPNAME( 0x80, 0x00, "Video Test" )  PORT_DIPLOCATION("SW2:!8")
272286   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
273287   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
274288INPUT_PORTS_END
r6740r6741
330344
331345static MACHINE_DRIVER_START( sbowling )
332346
333   MDRV_CPU_ADD("maincpu", 8080, 19968000/10 )
347   MDRV_CPU_ADD("maincpu", 8080, XTAL_19_968MHz/10)   /* ? */
334348   MDRV_CPU_PROGRAM_MAP(main_map)
335349   MDRV_CPU_IO_MAP(port_map)
336350   MDRV_CPU_VBLANK_INT_HACK(sbw_interrupt, 2)
r6740r6741
351365   /* sound hardware */
352366   MDRV_SPEAKER_STANDARD_MONO("mono")
353367
354   MDRV_SOUND_ADD("aysnd", AY8910, 19968000 / 16)
355   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.12)
368   MDRV_SOUND_ADD("aysnd", AY8910, XTAL_19_968MHz/16)   /* ? */
369   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.33)
356370MACHINE_DRIVER_END
357371
358372ROM_START( sbowling )
src/mame/drivers/8080bw.c
r6740r6741
8989#include "driver.h"
9090#include "cpu/m6800/m6800.h"
9191#include "cpu/i8085/i8085.h"
92#include "machine/mb14241.h"
9293#include "sound/speaker.h"
9394#include "deprecat.h"
94#include "8080bw.h"
95#include "mw8080bw.h"
96#include "machine/mb14241.h"
95#include "includes/mw8080bw.h"
9796
9897#include "invrvnge.lh"
9998#include "shuttlei.lh"
r6740r6741
106105
107106static MACHINE_START( extra_8080bw )
108107{
109    MACHINE_START_CALL(extra_8080bw_sh);
110    MACHINE_START_CALL(extra_8080bw_vh);
111    MACHINE_START_CALL(mw8080bw);
108   MACHINE_START_CALL(extra_8080bw_sh);
109   MACHINE_START_CALL(extra_8080bw_vh);
110   MACHINE_START_CALL(mw8080bw);
112111}
113112
114113/*******************************************************/
r6740r6741
203202/*******************************************************/
204203
205204static ADDRESS_MAP_START( invadpt2_io_map, ADDRESS_SPACE_IO, 8 )
206    AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0")
207    AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1")
208    AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_WRITE(mb14241_0_shift_count_w)
209    AM_RANGE(0x03, 0x03) AM_READWRITE(mb14241_0_shift_result_r, invadpt2_sh_port_1_w)
210    AM_RANGE(0x04, 0x04) AM_WRITE(mb14241_0_shift_data_w)
211    AM_RANGE(0x05, 0x05) AM_WRITE(invadpt2_sh_port_2_w)
212    AM_RANGE(0x06, 0x06) AM_WRITE(watchdog_reset_w)
205   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0")
206   AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1")
207   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_DEVWRITE("mb14241", mb14241_shift_count_w)
208   AM_RANGE(0x03, 0x03) AM_DEVREAD("mb14241", mb14241_shift_result_r) AM_WRITE(invadpt2_sh_port_1_w)
209   AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
210   AM_RANGE(0x05, 0x05) AM_WRITE(invadpt2_sh_port_2_w)
211   AM_RANGE(0x06, 0x06) AM_WRITE(watchdog_reset_w)
213212ADDRESS_MAP_END
214213
215214static INPUT_PORTS_START( invadpt2 )
r6740r6741
240239
241240static MACHINE_DRIVER_START( invadpt2 )
242241
243    /* basic machine hardware */
244    MDRV_IMPORT_FROM(mw8080bw_root)
245    MDRV_CPU_MODIFY("maincpu")
246    MDRV_CPU_IO_MAP(invadpt2_io_map)
247    MDRV_MACHINE_START(extra_8080bw)
242   /* basic machine hardware */
243   MDRV_IMPORT_FROM(mw8080bw_root)
244   MDRV_CPU_MODIFY("maincpu")
245   MDRV_CPU_IO_MAP(invadpt2_io_map)
246   MDRV_MACHINE_START(extra_8080bw)
248247
249    /* 60 Hz signal clocks two LS161. Ripple carry will */
250    /* reset circuit, if LS161 not cleared before.      */
251    MDRV_WATCHDOG_VBLANK_INIT(255)
248   /* 60 Hz signal clocks two LS161. Ripple carry will */
249   /* reset circuit, if LS161 not cleared before.      */
250   MDRV_WATCHDOG_VBLANK_INIT(255)
252251
252   /* add shifter */
253   MDRV_MB14241_ADD("mb14241")
254
253255   /* video hardware */
254256   MDRV_VIDEO_UPDATE(invadpt2)
255257
256    /* sound hardware */
258   /* sound hardware */
257259   MDRV_IMPORT_FROM(invaders_samples_audio)
258260
259261MACHINE_DRIVER_END
r6740r6741
267269static ADDRESS_MAP_START( spcewars_io_map, ADDRESS_SPACE_IO, 8 )
268270   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0")
269271   AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1")
270   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_WRITE(mb14241_0_shift_count_w)
271   AM_RANGE(0x03, 0x03) AM_READWRITE(mb14241_0_shift_result_r, spcewars_sh_port_w)
272   AM_RANGE(0x04, 0x04) AM_WRITE(mb14241_0_shift_data_w)
272   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_DEVWRITE("mb14241", mb14241_shift_count_w)
273   AM_RANGE(0x03, 0x03) AM_DEVREAD("mb14241", mb14241_shift_result_r) AM_WRITE(spcewars_sh_port_w)
274   AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
273275   AM_RANGE(0x05, 0x05) AM_WRITE(invadpt2_sh_port_2_w)
274276ADDRESS_MAP_END
275277
r6740r6741
300302   MDRV_IMPORT_FROM(mw8080bw_root)
301303   MDRV_CPU_MODIFY("maincpu")
302304   MDRV_CPU_IO_MAP(spcewars_io_map)
303    MDRV_MACHINE_START(extra_8080bw)
305   MDRV_MACHINE_START(extra_8080bw)
304306
307   /* add shifter */
308   MDRV_MB14241_ADD("mb14241")
309
305310   /* sound hardware */
306311   MDRV_IMPORT_FROM(invaders_samples_audio)
307312
r6740r6741
368373
369374static MACHINE_DRIVER_START( astropal )
370375
371    /* basic machine hardware */
372    MDRV_IMPORT_FROM(invaders)
373    MDRV_CPU_MODIFY("maincpu")
376   /* basic machine hardware */
377   MDRV_IMPORT_FROM(invaders)
378   MDRV_CPU_MODIFY("maincpu")
374379   MDRV_CPU_IO_MAP(astropal_io_map)
375380
376381MACHINE_DRIVER_END
r6740r6741
383388
384389static ADDRESS_MAP_START( cosmo_map, ADDRESS_SPACE_PROGRAM, 8 )
385390   AM_RANGE(0x0000, 0x1fff) AM_ROM
386   AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size)
391   AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE_SIZE_MEMBER(mw8080bw_state, main_ram, main_ram_size)
387392   AM_RANGE(0x4000, 0x57ff) AM_ROM
388   AM_RANGE(0x5c00, 0x5fff) AM_RAM AM_BASE(&c8080bw_colorram)
393   AM_RANGE(0x5c00, 0x5fff) AM_RAM AM_BASE_MEMBER(mw8080bw_state, colorram)
389394ADDRESS_MAP_END
390395
391396/* at least one of these MWA8_NOPs must be sound related */
r6740r6741
393398   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0") AM_WRITENOP
394399   AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1") AM_WRITENOP
395400   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_WRITENOP
396    AM_RANGE(0x03, 0x03) AM_WRITE(invadpt2_sh_port_1_w)
397    AM_RANGE(0x05, 0x05) AM_WRITE(cosmo_sh_port_2_w)
401   AM_RANGE(0x03, 0x03) AM_WRITE(invadpt2_sh_port_1_w)
402   AM_RANGE(0x05, 0x05) AM_WRITE(cosmo_sh_port_2_w)
398403   AM_RANGE(0x06, 0x06) AM_WRITE(watchdog_reset_w)
399404   AM_RANGE(0x07, 0x07) AM_WRITENOP
400405ADDRESS_MAP_END
r6740r6741
418423
419424static MACHINE_DRIVER_START( cosmo )
420425
421    /* basic machine hardware */
422    MDRV_IMPORT_FROM(mw8080bw_root)
423    MDRV_CPU_MODIFY("maincpu")
426   /* basic machine hardware */
427   MDRV_IMPORT_FROM(mw8080bw_root)
428   MDRV_CPU_MODIFY("maincpu")
424429   MDRV_CPU_PROGRAM_MAP(cosmo_map)
425430   MDRV_CPU_IO_MAP(cosmo_io_map)
426    MDRV_MACHINE_START(extra_8080bw)
431   MDRV_MACHINE_START(extra_8080bw)
427432
428    /* video hardware */
433   /* video hardware */
429434   MDRV_VIDEO_UPDATE(cosmo)
430435
431    /* sound hardware */
436   /* sound hardware */
432437   MDRV_IMPORT_FROM(invaders_samples_audio)
433438
434439MACHINE_DRIVER_END
r6740r6741
492497static ADDRESS_MAP_START( invrvnge_io_map, ADDRESS_SPACE_IO, 8 )
493498   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0")
494499   AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1")
495   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_WRITE(mb14241_0_shift_count_w)
496   AM_RANGE(0x03, 0x03) AM_READWRITE(mb14241_0_shift_result_r, invrvnge_sh_port_w)
497   AM_RANGE(0x04, 0x04) AM_WRITE(mb14241_0_shift_data_w)
500   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_DEVWRITE("mb14241", mb14241_shift_count_w)
501   AM_RANGE(0x03, 0x03) AM_DEVREAD("mb14241", mb14241_shift_result_r) AM_WRITE(invrvnge_sh_port_w)
502   AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
498503ADDRESS_MAP_END
499504
500505
r6740r6741
546551   MDRV_CPU_MODIFY("maincpu")
547552   MDRV_CPU_IO_MAP(invrvnge_io_map)
548553
554   /* add shifter */
555   MDRV_MB14241_ADD("mb14241")
556
549557   /* sound hardware */
550558   MDRV_IMPORT_FROM(invaders_samples_audio)
551559
r6740r6741
573581   PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x00, "SW1:1" )
574582   PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x00, "SW1:2" )
575583   PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x00, "SW1:3" )
576    PORT_DIPNAME( 0x80, 0x00, DEF_STR(Coinage) )      PORT_DIPLOCATION("SW1:8")
577    PORT_DIPSETTING(    0x00, "1 Coin/1 Or 2 Players" )
578    PORT_DIPSETTING(    0x80, "1 Coin/1 Player  2 Coins/2 Players" )   /* Irrelevant, causes bugs */
584   PORT_DIPNAME( 0x80, 0x00, DEF_STR(Coinage) )      PORT_DIPLOCATION("SW1:8")
585   PORT_DIPSETTING(    0x00, "1 Coin/1 Or 2 Players" )
586   PORT_DIPSETTING(    0x80, "1 Coin/1 Player  2 Coins/2 Players" )   /* Irrelevant, causes bugs */
579587
580588   /* Dummy port for cocktail mode (not used) */
581589   PORT_MODIFY(CABINET_PORT_TAG)
r6740r6741
623631static ADDRESS_MAP_START( lrescue_io_map, ADDRESS_SPACE_IO, 8 )
624632   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0")
625633   AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1")
626   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_WRITE(mb14241_0_shift_count_w)
627   AM_RANGE(0x03, 0x03) AM_READWRITE(mb14241_0_shift_result_r, lrescue_sh_port_1_w)
628   AM_RANGE(0x04, 0x04) AM_WRITE(mb14241_0_shift_data_w)
634   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_DEVWRITE("mb14241", mb14241_shift_count_w)
635   AM_RANGE(0x03, 0x03) AM_DEVREAD("mb14241", mb14241_shift_result_r) AM_WRITE(lrescue_sh_port_1_w)
636   AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
629637   AM_RANGE(0x05, 0x05) AM_WRITE(lrescue_sh_port_2_w)
630638ADDRESS_MAP_END
631639
r6740r6741
648656   MDRV_IMPORT_FROM(mw8080bw_root)
649657   MDRV_CPU_MODIFY("maincpu")
650658   MDRV_CPU_IO_MAP(lrescue_io_map)
651    MDRV_MACHINE_START(extra_8080bw)
659   MDRV_MACHINE_START(extra_8080bw)
652660
661   /* add shifter */
662   MDRV_MB14241_ADD("mb14241")
663
653664   /* video hardware */
654665   MDRV_VIDEO_UPDATE(invadpt2)
655666
r6740r6741
753764
754765static ADDRESS_MAP_START( rollingc_map, ADDRESS_SPACE_PROGRAM, 8 )
755766   AM_RANGE(0x0000, 0x1fff) AM_ROM
756   AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size)
767   AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE_SIZE_MEMBER(mw8080bw_state, main_ram, main_ram_size)
757768   AM_RANGE(0x4000, 0x5fff) AM_ROM
758   AM_RANGE(0xa000, 0xbfff) AM_MIRROR(0x00e0) AM_RAM AM_BASE(&c8080bw_colorram)
769   AM_RANGE(0xa000, 0xbfff) AM_MIRROR(0x00e0) AM_RAM AM_BASE_MEMBER(mw8080bw_state, colorram)
759770   AM_RANGE(0xe400, 0xffff) AM_RAM
760771ADDRESS_MAP_END
761772
r6740r6741
763774static ADDRESS_MAP_START( rollingc_io_map, ADDRESS_SPACE_IO, 8 )
764775   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0") AM_WRITE(rollingc_sh_port_w)
765776   AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1")
766   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_WRITE(mb14241_0_shift_count_w)
767   AM_RANGE(0x03, 0x03) AM_READ(mb14241_0_shift_result_r)
768   AM_RANGE(0x04, 0x04) AM_WRITE(mb14241_0_shift_data_w)
777   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_DEVWRITE("mb14241", mb14241_shift_count_w)
778   AM_RANGE(0x03, 0x03) AM_DEVREAD("mb14241", mb14241_shift_result_r)
779   AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
769780ADDRESS_MAP_END
770781
771782
r6740r6741
795806   MDRV_CPU_PROGRAM_MAP(rollingc_map)
796807   MDRV_CPU_IO_MAP(rollingc_io_map)
797808
809   /* add shifter */
810   MDRV_MB14241_ADD("mb14241")
811
798812   /* video hardware */
799813   MDRV_VIDEO_UPDATE(rollingc)
800814
r6740r6741
813827
814828static ADDRESS_MAP_START( schaser_map, ADDRESS_SPACE_PROGRAM, 8 )
815829   AM_RANGE(0x0000, 0x1fff) AM_ROM
816   AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size)
830   AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE_SIZE_MEMBER(mw8080bw_state, main_ram, main_ram_size)
817831   AM_RANGE(0x4000, 0x5fff) AM_ROM
818   AM_RANGE(0xc000, 0xdfff) AM_MIRROR(0x0060) AM_RAM AM_BASE(&c8080bw_colorram)
832   AM_RANGE(0xc000, 0xdfff) AM_MIRROR(0x0060) AM_RAM AM_BASE_MEMBER(mw8080bw_state, colorram)
819833ADDRESS_MAP_END
820834
821835
822836static ADDRESS_MAP_START( schaser_io_map, ADDRESS_SPACE_IO, 8 )
823837   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0")
824838   AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1")
825   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_WRITE(mb14241_0_shift_count_w)
826   AM_RANGE(0x03, 0x03) AM_READWRITE(mb14241_0_shift_result_r, schaser_sh_port_1_w)
827   AM_RANGE(0x04, 0x04) AM_WRITE(mb14241_0_shift_data_w)
839   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_DEVWRITE("mb14241", mb14241_shift_count_w)
840   AM_RANGE(0x03, 0x03) AM_DEVREAD("mb14241", mb14241_shift_result_r) AM_WRITE(schaser_sh_port_1_w)
841   AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
828842   AM_RANGE(0x05, 0x05) AM_WRITE(schaser_sh_port_2_w)
829843   AM_RANGE(0x06, 0x06) AM_WRITE(watchdog_reset_w)
830844ADDRESS_MAP_END
r6740r6741
886900   PORT_ADJUSTER( 70, "VR3 - Dot Volume" )
887901INPUT_PORTS_END
888902
903MACHINE_START( schaser )
904{
905   MACHINE_START_CALL(schaser_sh);
906   MACHINE_START_CALL(extra_8080bw_vh);
907   MACHINE_START_CALL(mw8080bw);
908}
909
910MACHINE_RESET( schaser )
911{
912   MACHINE_RESET_CALL(schaser_sh);
913   MACHINE_RESET_CALL(mw8080bw);
914}
915
889916static MACHINE_DRIVER_START( schaser )
890917
891918   /* basic machine hardware */
892919   MDRV_IMPORT_FROM(mw8080bw_root)
893   MDRV_CPU_REPLACE("maincpu",8080,1996800)        /* 19.968MHz / 10 */
920   MDRV_CPU_REPLACE("maincpu",8080,1996800)       /* 19.968MHz / 10 */
894921   MDRV_CPU_PROGRAM_MAP(schaser_map)
895922   MDRV_CPU_IO_MAP(schaser_io_map)
896923   MDRV_WATCHDOG_VBLANK_INIT(255)
897924   MDRV_MACHINE_START(schaser)
898925   MDRV_MACHINE_RESET(schaser)
899926
927   /* add shifter */
928   MDRV_MB14241_ADD("mb14241")
929
900930   /* video hardware */
901931   MDRV_VIDEO_UPDATE(schaser)
902932
r6740r6741
923953static ADDRESS_MAP_START( schasrcv_io_map, ADDRESS_SPACE_IO, 8 )
924954   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0")
925955   AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1")
926   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_WRITE(mb14241_0_shift_count_w)
927   AM_RANGE(0x03, 0x03) AM_READWRITE(mb14241_0_shift_result_r, schasrcv_sh_port_1_w)
928   AM_RANGE(0x04, 0x04) AM_WRITE(mb14241_0_shift_data_w)
956   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_DEVWRITE("mb14241", mb14241_shift_count_w)
957   AM_RANGE(0x03, 0x03) AM_DEVREAD("mb14241", mb14241_shift_result_r) AM_WRITE(schasrcv_sh_port_1_w)
958   AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
929959   AM_RANGE(0x05, 0x05) AM_WRITE(schasrcv_sh_port_2_w)
930960ADDRESS_MAP_END
931961
r6740r6741
961991   MDRV_CPU_MODIFY("maincpu")
962992   MDRV_CPU_PROGRAM_MAP(schaser_map)
963993   MDRV_CPU_IO_MAP(schasrcv_io_map)
964    MDRV_MACHINE_START(extra_8080bw)
994   MDRV_MACHINE_START(extra_8080bw)
965995
996   /* add shifter */
997   MDRV_MB14241_ADD("mb14241")
998
966999   /* video hardware */
9671000   MDRV_VIDEO_UPDATE(schasrcv)
9681001
r6740r6741
9811014/*                                                     */
9821015/*******************************************************/
9831016
984static UINT8 sfl_int = 0;
985
9861017static CUSTOM_INPUT( sflush_80_r )
9871018{
988   sfl_int ^= 1;   /* vblank flag ? */
1019   mw8080bw_state *state = (mw8080bw_state *)field->port->machine->driver_data;
1020   state->sfl_int ^= 1;   /* vblank flag ? */
9891021
990   return sfl_int;
1022   return state->sfl_int;
9911023}
9921024
9931025static MACHINE_START( sflush )
9941026{
995    state_save_register_global(machine, sfl_int);
1027   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
1028   state_save_register_global(machine, state->sfl_int);
9961029
997    MACHINE_START_CALL(mw8080bw);
1030   MACHINE_START_CALL(mw8080bw);
9981031}
9991032
10001033static ADDRESS_MAP_START( sflush_map, ADDRESS_SPACE_PROGRAM, 8 )
10011034   AM_RANGE(0x0000, 0x1fff) AM_RAM
1002   AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size)
1035   AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE_SIZE_MEMBER(mw8080bw_state, main_ram, main_ram_size)
10031036   AM_RANGE(0x8008, 0x8008) AM_READ_PORT("PADDLE")
1004   AM_RANGE(0x8009, 0x8009) AM_READ(mb14241_0_shift_result_r)
1037   AM_RANGE(0x8009, 0x8009) AM_DEVREAD("mb14241", mb14241_shift_result_r)
10051038   AM_RANGE(0x800a, 0x800a) AM_READ_PORT("IN2")
10061039   AM_RANGE(0x800b, 0x800b) AM_READ_PORT("IN0")
1007   AM_RANGE(0x8018, 0x8018) AM_WRITE(mb14241_0_shift_data_w)
1008   AM_RANGE(0x8019, 0x8019) AM_WRITE(mb14241_0_shift_count_w)
1040   AM_RANGE(0x8018, 0x8018) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
1041   AM_RANGE(0x8019, 0x8019) AM_DEVWRITE("mb14241", mb14241_shift_count_w)
10091042   AM_RANGE(0x801a, 0x801a) AM_WRITENOP
10101043   AM_RANGE(0x801c, 0x801c) AM_WRITENOP
10111044   AM_RANGE(0x801d, 0x801d) AM_WRITENOP
1012   AM_RANGE(0xa000, 0xbfff) AM_MIRROR(0x0060) AM_RAM AM_BASE(&c8080bw_colorram)
1045   AM_RANGE(0xa000, 0xbfff) AM_MIRROR(0x0060) AM_RAM AM_BASE_MEMBER(mw8080bw_state, colorram)
10131046   AM_RANGE(0xd800, 0xffff) AM_ROM
10141047ADDRESS_MAP_END
10151048
1016static MACHINE_DRIVER_START( sflush )
10171049
1018   /* basic machine hardware */
1019   MDRV_IMPORT_FROM(mw8080bw_root)
1020   MDRV_CPU_REPLACE("maincpu",M6800,2000000)        /* ?? */
1021   MDRV_CPU_PROGRAM_MAP(sflush_map)
1022   MDRV_CPU_VBLANK_INT_HACK(irq0_line_pulse,2)
1023    MDRV_MACHINE_START(sflush)
1024
1025   /* video hardware */
1026   MDRV_VIDEO_UPDATE(sflush)
1027
1028MACHINE_DRIVER_END
1029
10301050static INPUT_PORTS_START( sflush )
10311051   PORT_START("IN0")
10321052   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )
r6740r6741
10561076INPUT_PORTS_END
10571077
10581078
1079static MACHINE_DRIVER_START( sflush )
10591080
1081   /* basic machine hardware */
1082   MDRV_IMPORT_FROM(mw8080bw_root)
1083   MDRV_CPU_REPLACE("maincpu",M6800,2000000)       /* ?? */
1084   MDRV_CPU_PROGRAM_MAP(sflush_map)
1085   MDRV_CPU_VBLANK_INT_HACK(irq0_line_pulse,2)
1086   MDRV_MACHINE_START(sflush)
1087
1088   /* add shifter */
1089   MDRV_MB14241_ADD("mb14241")
1090
1091   /* video hardware */
1092   MDRV_VIDEO_UPDATE(sflush)
1093
1094MACHINE_DRIVER_END
1095
1096
10601097/*******************************************************/
10611098/*                                                     */
10621099/* Taito "Lupin III"                                   */
r6740r6741
10661103static ADDRESS_MAP_START( lupin3_io_map, ADDRESS_SPACE_IO, 8 )
10671104   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0")
10681105   AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1")
1069   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_WRITE(mb14241_0_shift_count_w)
1070   AM_RANGE(0x03, 0x03) AM_READWRITE(mb14241_0_shift_result_r, lupin3_sh_port_1_w)
1071   AM_RANGE(0x04, 0x04) AM_WRITE(mb14241_0_shift_data_w)
1106   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_DEVWRITE("mb14241", mb14241_shift_count_w)
1107   AM_RANGE(0x03, 0x03) AM_DEVREAD("mb14241", mb14241_shift_result_r) AM_WRITE(lupin3_sh_port_1_w)
1108   AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
10721109   AM_RANGE(0x05, 0x05) AM_WRITE(lupin3_sh_port_2_w)
10731110   AM_RANGE(0x06, 0x06) AM_WRITE(watchdog_reset_w)
10741111ADDRESS_MAP_END
r6740r6741
11531190   MDRV_IMPORT_FROM(mw8080bw_root)
11541191   MDRV_CPU_MODIFY("maincpu")
11551192   MDRV_CPU_IO_MAP(lupin3_io_map)
1156    MDRV_MACHINE_START(extra_8080bw)
1193   MDRV_MACHINE_START(extra_8080bw)
11571194
1195   /* add shifter */
1196   MDRV_MB14241_ADD("mb14241")
1197
11581198   /* video hardware */
11591199   MDRV_VIDEO_UPDATE(indianbt)
11601200
r6740r6741
11701210   MDRV_CPU_MODIFY("maincpu")
11711211   MDRV_CPU_PROGRAM_MAP(schaser_map)
11721212   MDRV_CPU_IO_MAP(lupin3_io_map)
1173    MDRV_MACHINE_START(extra_8080bw)
1213   MDRV_MACHINE_START(extra_8080bw)
11741214
1215   /* add shifter */
1216   MDRV_MB14241_ADD("mb14241")
1217
11751218   /* video hardware */
11761219   MDRV_VIDEO_UPDATE(lupin3)
11771220
r6740r6741
11871230/*                                                     */
11881231/*******************************************************/
11891232
1190static UINT8 polaris_cloud_speed;
1191static UINT8 polaris_cloud_pos;
1192
1193
11941233static INTERRUPT_GEN( polaris_interrupt )
11951234{
1196   polaris_cloud_speed++;
1235   mw8080bw_state *state = (mw8080bw_state *)device->machine->driver_data;
1236   state->polaris_cloud_speed++;
11971237
1198   if (polaris_cloud_speed >= 4)   /* every 4 frames - this was verified against real machine */
1238   if (state->polaris_cloud_speed >= 4)   /* every 4 frames - this was verified against real machine */
11991239   {
1200      polaris_cloud_speed = 0;
1201
1202      polaris_cloud_pos++;
1240      state->polaris_cloud_speed = 0;
1241      state->polaris_cloud_pos++;
12031242   }
12041243}
12051244
1206
1207UINT8 polaris_get_cloud_pos(void)
1208{
1209   return polaris_cloud_pos;
1210}
1211
12121245static MACHINE_START( polaris )
12131246{
1214    state_save_register_global(machine, polaris_cloud_speed);
1215    state_save_register_global(machine, polaris_cloud_pos);
1247   mw8080bw_state *state = (mw8080bw_state *)machine->driver_data;
1248   state_save_register_global(machine, state->polaris_cloud_speed);
1249   state_save_register_global(machine, state->polaris_cloud_pos);
12161250
1217    MACHINE_START_CALL(mw8080bw);
1251   MACHINE_START_CALL(mw8080bw);
12181252}
12191253
12201254// Port 5 is used to reset the watchdog timer.
r6740r6741
12241258// It sounds better then the actual circuit used.
12251259// Probably an unfinished feature.
12261260static ADDRESS_MAP_START( polaris_io_map, ADDRESS_SPACE_IO, 8 )
1227   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0") AM_WRITE(mb14241_0_shift_count_w)
1261   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0") AM_DEVWRITE("mb14241", mb14241_shift_count_w)
12281262   AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1")
12291263   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_DEVWRITE("discrete", polaris_sh_port_1_w)
1230   AM_RANGE(0x03, 0x03) AM_READWRITE(mb14241_0_shift_result_r, mb14241_0_shift_data_w)
1264   AM_RANGE(0x03, 0x03) AM_DEVREADWRITE("mb14241", mb14241_shift_result_r, mb14241_shift_data_w)
12311265   AM_RANGE(0x04, 0x04) AM_DEVWRITE("discrete", polaris_sh_port_2_w)
12321266   AM_RANGE(0x05, 0x05) AM_WRITE(watchdog_reset_w)
12331267   AM_RANGE(0x06, 0x06) AM_DEVWRITE("discrete", polaris_sh_port_3_w)
r6740r6741
12921326
12931327   /* basic machine hardware */
12941328   MDRV_IMPORT_FROM(mw8080bw_root)
1295   MDRV_CPU_REPLACE("maincpu",8080,1996800)        /* 19.968MHz / 10 */
1329   MDRV_CPU_REPLACE("maincpu",8080,1996800)       /* 19.968MHz / 10 */
12961330   MDRV_CPU_PROGRAM_MAP(schaser_map)
12971331   MDRV_CPU_IO_MAP(polaris_io_map)
12981332   MDRV_WATCHDOG_VBLANK_INIT(255)
12991333   MDRV_CPU_VBLANK_INT("screen", polaris_interrupt)
1300    MDRV_MACHINE_START(polaris)
1334   MDRV_MACHINE_START(polaris)
13011335
1336   /* add shifter */
1337   MDRV_MB14241_ADD("mb14241")
1338
13021339   /* video hardware */
13031340   MDRV_VIDEO_UPDATE(polaris)
13041341
r6740r6741
13961433static ADDRESS_MAP_START( ballbomb_io_map, ADDRESS_SPACE_IO, 8 )
13971434   AM_RANGE(0x00, 0x00) AM_READ_PORT("IN0")
13981435   AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1")
1399   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_WRITE(mb14241_0_shift_count_w)
1400   AM_RANGE(0x03, 0x03) AM_READWRITE(mb14241_0_shift_result_r, ballbomb_sh_port_1_w)
1401   AM_RANGE(0x04, 0x04) AM_WRITE(mb14241_0_shift_data_w)
1436   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_DEVWRITE("mb14241", mb14241_shift_count_w)
1437   AM_RANGE(0x03, 0x03) AM_DEVREAD("mb14241", mb14241_shift_result_r) AM_WRITE(ballbomb_sh_port_1_w)
1438   AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
14021439   AM_RANGE(0x05, 0x05) AM_WRITE(ballbomb_sh_port_2_w)
14031440ADDRESS_MAP_END
14041441
r6740r6741
14201457   MDRV_IMPORT_FROM(mw8080bw_root)
14211458   MDRV_CPU_MODIFY("maincpu")
14221459   MDRV_CPU_IO_MAP(ballbomb_io_map)
1423    MDRV_MACHINE_START(extra_8080bw)
1460   MDRV_MACHINE_START(extra_8080bw)
14241461
1462   /* add shifter */
1463   MDRV_MB14241_ADD("mb14241")
1464
14251465   /* video hardware */
14261466   MDRV_VIDEO_UPDATE(ballbomb)
14271467
r6740r6741
14391479
14401480static ADDRESS_MAP_START( yosakdon_map, ADDRESS_SPACE_PROGRAM, 8 )
14411481   AM_RANGE(0x0000, 0x1fff) AM_ROM
1442   AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size)
1482   AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE_SIZE_MEMBER(mw8080bw_state, main_ram, main_ram_size)
14431483   AM_RANGE(0x4000, 0x43ff) AM_WRITEONLY /* what's this? */
14441484ADDRESS_MAP_END
14451485
r6740r6741
14951535   MDRV_CPU_MODIFY("maincpu")
14961536   MDRV_CPU_PROGRAM_MAP(yosakdon_map)
14971537   MDRV_CPU_IO_MAP(yosakdon_io_map)
1498    MDRV_MACHINE_START(extra_8080bw)
1538   MDRV_MACHINE_START(extra_8080bw)
14991539
15001540   /* sound hardware */
15011541   MDRV_IMPORT_FROM(invaders_samples_audio)
r6740r6741
15771617static ADDRESS_MAP_START( indianbt_io_map, ADDRESS_SPACE_IO, 8 )
15781618   AM_RANGE(0x00, 0x00) AM_READ(indianbt_r)
15791619   AM_RANGE(0x01, 0x01) AM_READ_PORT("IN0")
1580   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_WRITE(mb14241_0_shift_count_w)
1581   AM_RANGE(0x03, 0x03) AM_READWRITE(mb14241_0_shift_result_r, indianbt_sh_port_1_w)
1582   AM_RANGE(0x04, 0x04) AM_WRITE(mb14241_0_shift_data_w)
1620   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_DEVWRITE("mb14241", mb14241_shift_count_w)
1621   AM_RANGE(0x03, 0x03) AM_DEVREAD("mb14241", mb14241_shift_result_r) AM_WRITE(indianbt_sh_port_1_w)
1622   AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
15831623   AM_RANGE(0x05, 0x05) AM_WRITE(indianbt_sh_port_2_w)
15841624   AM_RANGE(0x06, 0x06) AM_WRITENOP /* sound ? */
15851625   AM_RANGE(0x07, 0x07) AM_DEVWRITE("discrete", indianbt_sh_port_3_w)
r6740r6741
15921632   MDRV_IMPORT_FROM(mw8080bw_root)
15931633   MDRV_CPU_MODIFY("maincpu")
15941634   MDRV_CPU_IO_MAP(indianbt_io_map)
1595    MDRV_MACHINE_START(extra_8080bw)
1635   MDRV_MACHINE_START(extra_8080bw)
15961636
1637   /* add shifter */
1638   MDRV_MB14241_ADD("mb14241")
1639
15971640   /* video hardware */
15981641   MDRV_VIDEO_UPDATE(indianbt)
15991642
r6740r6741
16191662
16201663static ADDRESS_MAP_START( steelwkr_io_map, ADDRESS_SPACE_IO, 8 )
16211664   AM_RANGE(0x01, 0x01) AM_READ_PORT("IN1")
1622   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_WRITE(mb14241_0_shift_count_w)
1623   AM_RANGE(0x03, 0x03) AM_READWRITE(mb14241_0_shift_result_r, invadpt2_sh_port_1_w)
1624   AM_RANGE(0x04, 0x04) AM_WRITE(mb14241_0_shift_data_w)
1665   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") AM_DEVWRITE("mb14241", mb14241_shift_count_w)
1666   AM_RANGE(0x03, 0x03) AM_DEVREAD("mb14241", mb14241_shift_result_r) AM_WRITE(invadpt2_sh_port_1_w)
1667   AM_RANGE(0x04, 0x04) AM_DEVWRITE("mb14241", mb14241_shift_data_w)
16251668   AM_RANGE(0x05, 0x05) AM_WRITE(invadpt2_sh_port_2_w)
16261669   AM_RANGE(0x06, 0x06) AM_WRITE(steelwkr_sh_port_3_w)
16271670ADDRESS_MAP_END
r6740r6741
16651708   MDRV_CPU_IO_MAP(steelwkr_io_map)
16661709   MDRV_MACHINE_START(extra_8080bw)
16671710
1711   /* add shifter */
1712   MDRV_MB14241_ADD("mb14241")
1713
16681714   /* video hardware */
16691715   MDRV_VIDEO_UPDATE(invadpt2)
16701716
r6740r6741
17761822
17771823static ADDRESS_MAP_START( shuttlei_map, ADDRESS_SPACE_PROGRAM, 8 )
17781824   AM_RANGE(0x0000, 0x1fff) AM_ROM
1779   AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size)
1825   AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE_SIZE_MEMBER(mw8080bw_state, main_ram, main_ram_size)
17801826   AM_RANGE(0x4000, 0x43ff) AM_RAM AM_SHARE("share1") // shuttlei
17811827   AM_RANGE(0x6000, 0x63ff) AM_RAM AM_SHARE("share1") // skylove (is it mirrored, or different PCB hookup?)
17821828ADDRESS_MAP_END
r6740r6741
17971843   MDRV_CPU_MODIFY("maincpu")
17981844   MDRV_CPU_PROGRAM_MAP(shuttlei_map)
17991845   MDRV_CPU_IO_MAP(shuttlei_io_map)
1800    MDRV_MACHINE_START(extra_8080bw)
1846   MDRV_MACHINE_START(extra_8080bw)
18011847
18021848   /* video hardware */
18031849   MDRV_SCREEN_MODIFY("screen")
r6740r6741
18511897static ADDRESS_MAP_START( darthvdr_map, ADDRESS_SPACE_PROGRAM, 8 )
18521898   AM_RANGE(0x0000, 0x17ff) AM_ROM
18531899   AM_RANGE(0x1800, 0x1fff) AM_RAM
1854   AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE(&mw8080bw_ram) AM_SIZE(&mw8080bw_ram_size)
1900   AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE_SIZE_MEMBER(mw8080bw_state, main_ram, main_ram_size)
18551901ADDRESS_MAP_END
18561902
18571903static ADDRESS_MAP_START( darthvdr_io_map, ADDRESS_SPACE_IO, 8 )
r6740r6741
18811927   PORT_START("P2")
18821928   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START2 )
18831929   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
1884    PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_PLAYER(2)
1885    PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_PLAYER(2)
1930   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_PLAYER(2)
1931   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_PLAYER(2)
18861932   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
18871933   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
18881934   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
r6740r6741
19021948
19031949static MACHINE_DRIVER_START( darthvdr )
19041950
1905    /* basic machine hardware */
1951   /* basic machine hardware */
19061952   MDRV_IMPORT_FROM(mw8080bw_root)
19071953   MDRV_CPU_MODIFY("maincpu")
19081954   MDRV_CPU_PROGRAM_MAP(darthvdr_map)
r6740r6741
28092855GAME( 1980, lupin3a,  lupin3,   lupin3a,  lupin3a,  0, ROT270, "Taito", "Lupin III (set 2)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
28102856GAME( 1980, polaris,  0,        polaris,  polaris,  0, ROT270, "Taito", "Polaris (set 1)", GAME_SUPPORTS_SAVE )
28112857GAME( 1980, polarisa, polaris,  polaris,  polaris,  0, ROT270, "Taito", "Polaris (set 2)", GAME_SUPPORTS_SAVE )
2812GAME( 1980, ballbomb, 0,        ballbomb, ballbomb, 0, ROT270, "Taito", "Balloon Bomber", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )    /* missing clouds */
2858GAME( 1980, ballbomb, 0,        ballbomb, ballbomb, 0, ROT270, "Taito", "Balloon Bomber", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )   /* missing clouds */
28132859GAME( 1980, indianbt, 0,        indianbt, indianbt, 0, ROT270, "Taito", "Indian Battle", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
28142860GAME( 1980, steelwkr, 0,        steelwkr, steelwkr, 0, ROT0  , "Taito", "Steel Worker", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
28152861
src/mame/drivers/othunder.c
r6740r6741
232232
233233#include "driver.h"
234234#include "cpu/z80/z80.h"
235#include "taitoipt.h"
235#include "includes/taitoipt.h"
236236#include "cpu/m68000/m68000.h"
237237#include "machine/eeprom.h"
238238#include "video/taitoic.h"
src/mame/drivers/quasar.c
r6740r6741
5858************************************************************************/
5959
6060#include "driver.h"
61#include "cvs.h"
6261#include "cpu/s2650/s2650.h"
6362#include "cpu/mcs48/mcs48.h"
6463#include "sound/dac.h"
6564#include "video/s2636.h"
65#include "includes/cvs.h"
6666
67
68PALETTE_INIT( quasar );
69VIDEO_UPDATE( quasar );
70VIDEO_START( quasar );
71
72
73extern UINT8 *quasar_effectram;
74extern UINT8 quasar_effectcontrol;
75
76static UINT8 page = 0;
77static UINT8 IOpage;
78
79
8067/************************************************************************
8168
8269  Quasar memory layout
r6740r6741
8976
9077static WRITE8_HANDLER( video_page_select_w )
9178{
92   page = offset & 0x03;
79    cvs_state *state = (cvs_state *)space->machine->driver_data;
80   state->page = offset & 0x03;
9381}
9482
9583static WRITE8_HANDLER( io_page_select_w )
9684{
97   IOpage = offset & 0x03;
85    cvs_state *state = (cvs_state *)space->machine->driver_data;
86   state->io_page = offset & 0x03;
9887}
9988
10089static WRITE8_HANDLER( quasar_video_w )
10190{
102   switch (page)
91    cvs_state *state = (cvs_state *)space->machine->driver_data;
92
93   switch (state->page)
10394   {
104   case 0:  cvs_video_ram[offset] = data; break;
105   case 1:  cvs_color_ram[offset] = data & 7; break;   // 3 bits of ram only - 3 x 2102
106   case 2:  quasar_effectram[offset] = data; break;
107   case 3:  quasar_effectcontrol = data; break;
95   case 0:  state->video_ram[offset] = data; break;
96   case 1:  state->color_ram[offset] = data & 7; break;   // 3 bits of ram only - 3 x 2102
97   case 2:  state->effectram[offset] = data; break;
98   case 3:  state->effectcontrol = data; break;
10899   }
109100}
110101
111102static READ8_HANDLER( quasar_IO_r )
112103{
104    cvs_state *state = (cvs_state *)space->machine->driver_data;
113105   UINT8 ans = 0;
114106
115   if (IOpage == 0) ans = input_port_read(space->machine, "IN0");
116   if (IOpage == 1) ans = input_port_read(space->machine, "IN1");
117   if (IOpage == 2) ans = input_port_read(space->machine, "DSW0");
118   if (IOpage == 3) ans = input_port_read(space->machine, "DSW1");
107   switch (state->io_page)
108   {
109   case 0:  ans = input_port_read(space->machine, "IN0"); break;
110   case 1:  ans = input_port_read(space->machine, "IN1"); break;
111   case 2:  ans = input_port_read(space->machine, "DSW0"); break;
112   case 3:  ans = input_port_read(space->machine, "DSW1"); break;
113   }
119114
120115   return ans;
121116}
122117
123118static WRITE8_HANDLER( quasar_bullet_w )
124119{
125   cvs_bullet_ram[offset] = (data ^ 0xff);
120    cvs_state *state = (cvs_state *)space->machine->driver_data;
121   state->bullet_ram[offset] = (data ^ 0xff);
126122}
127123
128//static int sh_page=0;
129
130124static WRITE8_HANDLER( quasar_sh_command_w )
131125{
132126   // bit 4 = Sound Invader : Linked to an NE555V circuit
r6740r6741
152146
153147static ADDRESS_MAP_START( quasar, ADDRESS_SPACE_PROGRAM, 8 )
154148   AM_RANGE(0x0000, 0x13ff) AM_ROM
155   AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_READWRITE(cvs_bullet_ram_or_palette_r, quasar_bullet_w) AM_BASE(&cvs_bullet_ram)
149   AM_RANGE(0x1400, 0x14ff) AM_MIRROR(0x6000) AM_READWRITE(cvs_bullet_ram_or_palette_r, quasar_bullet_w) AM_BASE_MEMBER(cvs_state, bullet_ram)
156150   AM_RANGE(0x1500, 0x15ff) AM_MIRROR(0x6000) AM_READWRITE(cvs_s2636_0_or_character_ram_r, cvs_s2636_0_or_character_ram_w)
157151   AM_RANGE(0x1600, 0x16ff) AM_MIRROR(0x6000) AM_READWRITE(cvs_s2636_1_or_character_ram_r, cvs_s2636_1_or_character_ram_w)
158152   AM_RANGE(0x1700, 0x17ff) AM_MIRROR(0x6000) AM_READWRITE(cvs_s2636_2_or_character_ram_r, cvs_s2636_2_or_character_ram_w)
159   AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_READWRITE(cvs_video_or_color_ram_r, quasar_video_w) AM_BASE(&cvs_video_ram)
153   AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0x6000) AM_READWRITE(cvs_video_or_color_ram_r, quasar_video_w) AM_BASE_MEMBER(cvs_state, video_ram)
160154   AM_RANGE(0x1c00, 0x1fff) AM_MIRROR(0x6000) AM_RAM
161155   AM_RANGE(0x2000, 0x33ff) AM_ROM
162156   AM_RANGE(0x4000, 0x53ff) AM_ROM
r6740r6741
169163   AM_RANGE(S2650_DATA_PORT,  S2650_DATA_PORT) AM_READWRITE(cvs_collision_clear, quasar_sh_command_w)
170164   AM_RANGE(S2650_CTRL_PORT,  S2650_CTRL_PORT) AM_READ(cvs_collision_r) AM_WRITENOP
171165   AM_RANGE(S2650_SENSE_PORT, S2650_SENSE_PORT) AM_READ_PORT("SENSE")
172   AM_RANGE(S2650_FO_PORT, S2650_FO_PORT) AM_RAM AM_BASE(&cvs_fo_state)
166   AM_RANGE(S2650_FO_PORT, S2650_FO_PORT) AM_RAM AM_BASE_MEMBER(cvs_state, fo_state)
173167ADDRESS_MAP_END
174168
175169/*************************************
r6740r6741
196190************************************************************************/
197191
198192static INPUT_PORTS_START( quasar )
199   PORT_START("IN0")   /* Controls 0 */
193   PORT_START("IN0")
200194   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
201195   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
202196   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN2 )
r6740r6741
206200   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_TILT )
207201   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON3 )         /* switch collaudo */
208202
209   PORT_START("IN1")   /* Controls 1 */
203   PORT_START("IN1")
210204   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON4 )         /* tavalino */
211205   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_COCKTAIL
212206   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )
r6740r6741
216210   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 )
217211   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START3 )            /* count enable */
218212
219   PORT_START("DSW0")   /* DSW0 */
213   PORT_START("DSW0")
220214   PORT_DIPNAME( 0x0c, 0x04, DEF_STR( Coin_A ) )         /* confirmed */
221215   PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
222216   PORT_DIPSETTING(    0x04, DEF_STR( 1C_1C ) )
r6740r6741
239233   PORT_DIPSETTING(    0x00, "Collisions excluded" )
240234   PORT_DIPSETTING(    0x80, "Collisions included" )
241235
242   PORT_START("DSW1")   /* DSW1 */
236   PORT_START("DSW1")
243237   PORT_DIPNAME( 0x07, 0x01, "High Score" )
244238   PORT_DIPSETTING(    0x00, "No H.S." ) // this option only wants bit 0 OFF
245239   PORT_DIPSETTING(    0x01, "Normal H.S." )
r6740r6741
260254   PORT_DIPSETTING(    0x80, "Stop at edge" )
261255   PORT_DIPSETTING(    0x00, "Wrap Around" )
262256
263   PORT_START("SENSE")   /* SENSE */
257   PORT_START("SENSE")
264258   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )
265259
266   PORT_START("DSW2")   /* Sound DIP switch */
260   PORT_START("DSW2")
267261#if 0
268262   PORT_DIPNAME( 0x0f, 0x00, "Noise to play" )
269263   PORT_DIPSETTING(    0x00, "00" )
r6740r6741
311305
312306static INTERRUPT_GEN( quasar_interrupt )
313307{
314   generic_pulse_irq_line_and_vector(device,0,0x03);
308   generic_pulse_irq_line_and_vector(device, 0, 0x03);
315309}
316310
317311static const s2636_interface s2636_0_config =
318312{
319313   "screen",
320   0xff,
314   0x100,
321315   CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET
322316};
323317
324318static const s2636_interface s2636_1_config =
325319{
326320   "screen",
327   0xff,
321   0x100,
328322   CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET
329323};
330324
331325static const s2636_interface s2636_2_config =
332326{
333327   "screen",
334   0xff,
328   0x100,
335329   CVS_S2636_Y_OFFSET, CVS_S2636_X_OFFSET
336330};
337331
r6740r6741
339333// Quasar S2650 Main CPU, I8035 sound board
340334// ****************************************
341335
336MACHINE_START( quasar )
337{
338   cvs_state *state = (cvs_state *)machine->driver_data;
339
340   MACHINE_START_CALL(cvs);
341
342   /* register state save */
343   state_save_register_global(machine, state->effectcontrol);
344   state_save_register_global(machine, state->page);
345   state_save_register_global(machine, state->io_page);
346}
347
348static MACHINE_RESET( quasar )
349{
350   cvs_state *state = (cvs_state *)machine->driver_data;
351
352   MACHINE_RESET_CALL(cvs);
353
354   state->effectcontrol = 0;
355   state->page = 0;
356   state->io_page = 8;
357}
358
342359static MACHINE_DRIVER_START( quasar )
343360
361   /* driver data */
362   MDRV_DRIVER_DATA(cvs_state)
363
364   /* basic machine hardware */
344365   MDRV_CPU_ADD("maincpu", S2650, 14318000/4)   /* 14 mhz crystal divide by 4 on board */
345366   MDRV_CPU_PROGRAM_MAP(quasar)
346367   MDRV_CPU_IO_MAP(quasar_io)
r6740r6741
350371   MDRV_CPU_PROGRAM_MAP(sound_map)
351372   MDRV_CPU_IO_MAP(sound_portmap)
352373
353   MDRV_MACHINE_START( cvs )
374   MDRV_MACHINE_START(quasar)
375   MDRV_MACHINE_RESET(quasar)
354376
355377   MDRV_QUANTUM_TIME(HZ(6000))
356378
r6740r6741
440462   ROM_LOAD( "12m_q.bin",    0x0000, 0x0200, CRC(1ab8633d) SHA1(3aed29f2326676a8d8a5de6f6bb923b6510896d8) )
441463ROM_END
442464
443static DRIVER_INIT( quasar )
444{
445   page = 0;
446   IOpage = 8;
447}
448465
449GAME( 1980, quasar,        0, quasar,   quasar,   quasar, ROT90, "Zelco / Zaccaria", "Quasar",             GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
450GAME( 1980, quasara,  quasar, quasar,   quasar,   quasar, ROT90, "Zelco / Zaccaria", "Quasar (Alternate)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
466GAME( 1980, quasar,        0, quasar,   quasar,   0, ROT90, "Zelco / Zaccaria", "Quasar",             GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
467GAME( 1980, quasara,  quasar, quasar,   quasar,   0, ROT90, "Zelco / Zaccaria", "Quasar (Alternate)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
src/mame/drivers/1943.c
r6740r6741
1414
1515/*
1616
17    SERVICE TEST INFORMATION:
18
19    - To access the unreachable tests (#4-7) in the Service Test, when starting
20    up the machine after it has been set into Test Mode, hold down the left
21    coin switch.
22
23
1724    TODO:
1825
1926    - use priority PROM for drawing sprites
r6740r6741
2431#include "deprecat.h"
2532#include "cpu/z80/z80.h"
2633#include "sound/2203intf.h"
27#include "1943.h"
34#include "includes/1943.h"
2835
2936
3037/* Read/Write Handlers */
src/mame/drivers/psikyo4.c
r6740r6741
132132#include "machine/eeprom.h"
133133#include "sound/ymf278b.h"
134134#include "rendlay.h"
135#include "includes/psikyo4.h"
135136
136137#define ROMTEST 1 /* Does necessary stuff to perform rom test, uses RAM as it doesn't dispose of GFX after decoding */
137138
138UINT32 *psikyo4_vidregs;
139static UINT32 *ps4_ram, *ps4_io_select;
140static UINT32 *bgpen_1, *bgpen_2;
141139
142#define MASTER_CLOCK 57272700   // main oscillator frequency
143
144/* defined in video/psikyo4.c */
145VIDEO_START( psikyo4 );
146VIDEO_UPDATE( psikyo4 );
147
148140static const gfx_layout layout_16x16x8 =
149141{
150142   16,16,
r6740r6741
235227
236228static CUSTOM_INPUT( mahjong_ctrl_r ) /* used by hotgmck/hgkairak */
237229{
230   psikyo4_state *state = (psikyo4_state *)field->port->machine->driver_data;
238231   int player = (FPTR)param;
239   int sel = (ps4_io_select[0] & 0x0000ff00) >> 8;
232   int sel = (state->io_select[0] & 0x0000ff00) >> 8;
240233   int ret = 0xff;
241234
242235   if (sel & 1) ret &= input_port_read(field->port->machine, player ? "KEY4" : "KEY0" );
r6740r6741
249242
250243static WRITE32_HANDLER( ps4_paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w )
251244{
252   int r,g,b;
253   COMBINE_DATA(&space->machine->generic.paletteram.u32[offset]);
245   psikyo4_state *state = (psikyo4_state *)space->machine->driver_data;
246   int r, g, b;
247   COMBINE_DATA(&state->paletteram[offset]);
254248
255   b = ((space->machine->generic.paletteram.u32[offset] & 0x0000ff00) >>8);
256   g = ((space->machine->generic.paletteram.u32[offset] & 0x00ff0000) >>16);
257   r = ((space->machine->generic.paletteram.u32[offset] & 0xff000000) >>24);
249   b = ((state->paletteram[offset] & 0x0000ff00) >> 8);
250   g = ((state->paletteram[offset] & 0x00ff0000) >> 16);
251   r = ((state->paletteram[offset] & 0xff000000) >> 24);
258252
259   palette_set_color(space->machine,offset,MAKE_RGB(r,g,b));
260   palette_set_color(space->machine,offset+0x800,MAKE_RGB(r,g,b)); // For screen 2
253   palette_set_color(space->machine, offset, MAKE_RGB(r, g, b));
254   palette_set_color(space->machine, offset + 0x800, MAKE_RGB(r, g, b)); // For screen 2
261255}
262256
263257static WRITE32_HANDLER( ps4_bgpen_1_dword_w )
264258{
265   int r,g,b;
266   COMBINE_DATA(&bgpen_1[0]);
259   psikyo4_state *state = (psikyo4_state *)space->machine->driver_data;
260   int r, g, b;
261   COMBINE_DATA(&state->bgpen_1[0]);
267262
268   b = ((bgpen_1[0] & 0x0000ff00) >>8);
269   g = ((bgpen_1[0] & 0x00ff0000) >>16);
270   r = ((bgpen_1[0] & 0xff000000) >>24);
263   b = ((state->bgpen_1[0] & 0x0000ff00) >>8);
264   g = ((state->bgpen_1[0] & 0x00ff0000) >>16);
265   r = ((state->bgpen_1[0] & 0xff000000) >>24);
271266
272   palette_set_color(space->machine,0x1000,MAKE_RGB(r,g,b)); // Clear colour for screen 1
267   palette_set_color(space->machine, 0x1000, MAKE_RGB(r, g, b)); // Clear colour for screen 1
273268}
274269
275270static WRITE32_HANDLER( ps4_bgpen_2_dword_w )
276271{
277   int r,g,b;
278   COMBINE_DATA(&bgpen_2[0]);
272   psikyo4_state *state = (psikyo4_state *)space->machine->driver_data;
273   int r, g, b;
274   COMBINE_DATA(&state->bgpen_2[0]);
279275
280   b = ((bgpen_2[0] & 0x0000ff00) >>8);
281   g = ((bgpen_2[0] & 0x00ff0000) >>16);
282   r = ((bgpen_2[0] & 0xff000000) >>24);
276   b = ((state->bgpen_2[0] & 0x0000ff00) >>8);
277   g = ((state->bgpen_2[0] & 0x00ff0000) >>16);
278   r = ((state->bgpen_2[0] & 0xff000000) >>24);
283279
284   palette_set_color(space->machine,0x1001,MAKE_RGB(r,g,b)); // Clear colour for screen 2
280   palette_set_color(space->machine, 0x1001, MAKE_RGB(r, g, b)); // Clear colour for screen 2
285281}
286282
287283static WRITE32_HANDLER( ps4_screen1_brt_w )
288284{
289   if(ACCESSING_BITS_0_7) {
285   psikyo4_state *state = (psikyo4_state *)space->machine->driver_data;
286
287   if (ACCESSING_BITS_0_7)
288   {
290289      /* Need seperate brightness for both screens if displaying together */
291290      double brt1 = data & 0xff;
292      static double oldbrt1;
293291
294      if (brt1>0x7f) brt1 = 0x7f; /* I reckon values must be clamped to 0x7f */
292      if (brt1 > 0x7f)
293         brt1 = 0x7f; /* I reckon values must be clamped to 0x7f */
295294
296295      brt1 = (0x7f - brt1) / 127.0;
297      if (oldbrt1 != brt1)
296      if (state->oldbrt1 != brt1)
298297      {
299298         int i;
300299
301300         for (i = 0; i < 0x800; i++)
302            palette_set_pen_contrast(space->machine,i,brt1);
301            palette_set_pen_contrast(space->machine, i, brt1);
303302
304         oldbrt1 = brt1;
303         state->oldbrt1 = brt1;
305304      }
306   } else {
305   }
306   else
307   {
307308      /* I believe this to be seperate rgb brightness due to strings in hotdebut, unused in 4 dumped games */
308309      if((data & mem_mask) != 0)
309310         logerror("Unk Scr 1 rgb? brt write %08x mask %08x\n", data, mem_mask);
r6740r6741
312313
313314static WRITE32_HANDLER( ps4_screen2_brt_w )
314315{
315   if(ACCESSING_BITS_0_7) {
316   psikyo4_state *state = (psikyo4_state *)space->machine->driver_data;
317
318   if (ACCESSING_BITS_0_7)
319   {
316320      /* Need seperate brightness for both screens if displaying together */
317321      double brt2 = data & 0xff;
318      static double oldbrt2;
319322
320      if (brt2>0x7f) brt2 = 0x7f; /* I reckon values must be clamped to 0x7f */
323      if (brt2 > 0x7f)
324         brt2 = 0x7f; /* I reckon values must be clamped to 0x7f */
321325
322326      brt2 = (0x7f - brt2) / 127.0;
323327
324      if (oldbrt2 != brt2)
328      if (state->oldbrt2 != brt2)
325329      {
326330         int i;
327331
328332         for (i = 0x800; i < 0x1000; i++)
329            palette_set_pen_contrast(space->machine,i,brt2);
333            palette_set_pen_contrast(space->machine, i, brt2);
330334
331         oldbrt2 = brt2;
335         state->oldbrt2 = brt2;
332336      }
333   } else {
337   }
338   else
339   {
334340      /* I believe this to be seperate rgb brightness due to strings in hotdebut, unused in 4 dumped games */
335341      if((data & mem_mask) != 0)
336342         logerror("Unk Scr 2 rgb? brt write %08x mask %08x\n", data, mem_mask);
r6740r6741
339345
340346static WRITE32_HANDLER( ps4_vidregs_w )
341347{
342   COMBINE_DATA(&psikyo4_vidregs[offset]);
348   psikyo4_state *state = (psikyo4_state *)space->machine->driver_data;
349   COMBINE_DATA(&state->vidregs[offset]);
343350
344351#if ROMTEST
345   if(offset==2) /* Configure bank for gfx test */
352   if (offset == 2) /* Configure bank for gfx test */
346353   {
347354      if (ACCESSING_BITS_0_15)   // Bank
348355      {
349         UINT8 *ROM = memory_region(space->machine, "gfx1");
350         memory_set_bankptr(space->machine, "bank2",&ROM[0x2000 * (psikyo4_vidregs[offset]&0x1fff)]); /* Bank comes from vidregs */
351      }
356//          memory_set_bank(space->machine, "bank2", state->vidregs[offset] & 0x1fff);  /* Bank comes from vidregs */
357         memory_set_bankptr(space->machine, "bank2", memory_region(space->machine, "gfx1") + 0x2000 * (state->vidregs[offset] & 0x1fff)); /* Bank comes from vidregs */      }
352358   }
353359#endif
354360}
355361
356362#if ROMTEST
357static UINT32 sample_offs = 0;
358
359363static READ32_HANDLER( ps4_sample_r ) /* Send sample data for test */
360364{
365   psikyo4_state *state = (psikyo4_state *)space->machine->driver_data;
361366   UINT8 *ROM = memory_region(space->machine, "ymf");
362   return ROM[sample_offs++]<<16;
367   return ROM[state->sample_offs++] << 16;
363368}
364369#endif
365370
366#define PCM_BANK_NO(n)   ((ps4_io_select[0] >> (n * 4 + 24)) & 0x07)
371#define PCM_BANK_NO(n)   ((state->io_select[0] >> (n * 4 + 24)) & 0x07)
367372
368static void set_hotgmck_pcm_bank(running_machine *machine, int n)
373static void set_hotgmck_pcm_bank( running_machine *machine, int n )
369374{
375   psikyo4_state *state = (psikyo4_state *)machine->driver_data;
370376   UINT8 *ymf_pcmbank = memory_region(machine, "ymf") + 0x200000;
371377   UINT8 *pcm_rom = memory_region(machine, "ymfsource");
372378
r6740r6741
375381
376382static WRITE32_HANDLER( hotgmck_pcm_bank_w )
377383{
384   psikyo4_state *state = (psikyo4_state *)space->machine->driver_data;
378385   int old_bank0 = PCM_BANK_NO(0);
379386   int old_bank1 = PCM_BANK_NO(1);
380387   int new_bank0, new_bank1;
381388
382   COMBINE_DATA(&ps4_io_select[0]);
389   COMBINE_DATA(&state->io_select[0]);
383390
384391   new_bank0 = PCM_BANK_NO(0);
385392   new_bank1 = PCM_BANK_NO(1);
r6740r6741
394401static ADDRESS_MAP_START( ps4_map, ADDRESS_SPACE_PROGRAM, 32 )
395402   AM_RANGE(0x00000000, 0x000fffff) AM_ROM      // program ROM (1 meg)
396403   AM_RANGE(0x02000000, 0x021fffff) AM_ROMBANK("bank1") // data ROM
397   AM_RANGE(0x03000000, 0x030037ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
404   AM_RANGE(0x03000000, 0x030037ff) AM_RAM AM_BASE_SIZE_MEMBER(psikyo4_state, spriteram, spriteram_size)
398405   AM_RANGE(0x03003fe0, 0x03003fe3) AM_READWRITE(ps4_eeprom_r,ps4_eeprom_w)
399406   AM_RANGE(0x03003fe4, 0x03003fe7) AM_READNOP // also writes to this address - might be vblank?
400407//  AM_RANGE(0x03003fe4, 0x03003fe7) AM_WRITENOP // might be vblank?
401   AM_RANGE(0x03003fe4, 0x03003fef) AM_RAM_WRITE(ps4_vidregs_w) AM_BASE(&psikyo4_vidregs) // vid regs?
408   AM_RANGE(0x03003fe4, 0x03003fef) AM_RAM_WRITE(ps4_vidregs_w) AM_BASE_MEMBER(psikyo4_state, vidregs) // vid regs?
402409   AM_RANGE(0x03003ff0, 0x03003ff3) AM_WRITE(ps4_screen1_brt_w) // screen 1 brightness
403   AM_RANGE(0x03003ff4, 0x03003ff7) AM_WRITE(ps4_bgpen_1_dword_w) AM_BASE(&bgpen_1) // screen 1 clear colour
410   AM_RANGE(0x03003ff4, 0x03003ff7) AM_WRITE(ps4_bgpen_1_dword_w) AM_BASE_MEMBER(psikyo4_state, bgpen_1) // screen 1 clear colour
404411   AM_RANGE(0x03003ff8, 0x03003ffb) AM_WRITE(ps4_screen2_brt_w) // screen 2 brightness
405   AM_RANGE(0x03003ffc, 0x03003fff) AM_WRITE(ps4_bgpen_2_dword_w) AM_BASE(&bgpen_2) // screen 2 clear colour
406   AM_RANGE(0x03004000, 0x03005fff) AM_RAM_WRITE(ps4_paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w) AM_BASE_GENERIC(paletteram) // palette
412   AM_RANGE(0x03003ffc, 0x03003fff) AM_WRITE(ps4_bgpen_2_dword_w) AM_BASE_MEMBER(psikyo4_state, bgpen_2) // screen 2 clear colour
413   AM_RANGE(0x03004000, 0x03005fff) AM_RAM_WRITE(ps4_paletteram32_RRRRRRRRGGGGGGGGBBBBBBBBxxxxxxxx_dword_w) AM_BASE_MEMBER(psikyo4_state, paletteram) // palette
407414   AM_RANGE(0x05000000, 0x05000003) AM_DEVREAD8("ymf", ymf278b_r, 0xffffffff) // read YMF status
408415   AM_RANGE(0x05000000, 0x05000007) AM_DEVWRITE8("ymf", ymf278b_w, 0xffffffff)
409416   AM_RANGE(0x05800000, 0x05800003) AM_READ_PORT("P1_P2")
410417   AM_RANGE(0x05800004, 0x05800007) AM_READ_PORT("P3_P4")
411   AM_RANGE(0x05800008, 0x0580000b) AM_WRITEONLY AM_BASE(&ps4_io_select) // Used by Mahjong games to choose input (also maps normal loderndf inputs to offsets)
418   AM_RANGE(0x05800008, 0x0580000b) AM_WRITEONLY AM_BASE_MEMBER(psikyo4_state, io_select) // Used by Mahjong games to choose input (also maps normal loderndf inputs to offsets)
412419
413   AM_RANGE(0x06000000, 0x060fffff) AM_RAM   AM_BASE(&ps4_ram) // main RAM (1 meg)
420   AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_BASE_MEMBER(psikyo4_state, ram) // main RAM (1 meg)
414421
415422#if ROMTEST
416423   AM_RANGE(0x05000004, 0x05000007) AM_READ(ps4_sample_r) // data for rom tests (Used to verify Sample rom)
r6740r6741
418425#endif
419426ADDRESS_MAP_END
420427
421static void irqhandler(const device_config *device, int linestate)
422{
423   if (linestate)
424      cputag_set_input_line(device->machine, "maincpu", 12, ASSERT_LINE);
425   else
426      cputag_set_input_line(device->machine, "maincpu", 12, CLEAR_LINE);
427}
428428
429static const ymf278b_interface ymf278b_config =
430{
431   irqhandler
432};
433
434static MACHINE_DRIVER_START( ps4big )
435   /* basic machine hardware */
436   MDRV_CPU_ADD("maincpu", SH2, MASTER_CLOCK/2)
437   MDRV_CPU_PROGRAM_MAP(ps4_map)
438   MDRV_CPU_VBLANK_INT("lscreen", psikyosh_interrupt)
439
440   MDRV_NVRAM_HANDLER(93C56)
441
442   /* video hardware */
443   MDRV_GFXDECODE(ps4)
444   MDRV_PALETTE_LENGTH((0x2000/4)*2 + 2) /* 0x2000/4 for each screen. 1 for each screen clear colour */
445   MDRV_DEFAULT_LAYOUT(layout_dualhsxs)
446
447   MDRV_SCREEN_ADD("lscreen", RASTER)
448   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
449   MDRV_SCREEN_REFRESH_RATE(60)
450   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
451   MDRV_SCREEN_SIZE(40*8, 32*8)
452   MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 28*8-1)
453
454   MDRV_SCREEN_ADD("rscreen", RASTER)
455   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
456   MDRV_SCREEN_REFRESH_RATE(60)
457   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
458   MDRV_SCREEN_SIZE(40*8, 32*8)
459   MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 28*8-1)
460
461   MDRV_VIDEO_START(psikyo4)
462   MDRV_VIDEO_UPDATE(psikyo4)
463
464   /* sound hardware */
465   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
466
467   MDRV_SOUND_ADD("ymf", YMF278B, MASTER_CLOCK/2)
468   MDRV_SOUND_CONFIG(ymf278b_config)
469   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0)
470   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0)
471MACHINE_DRIVER_END
472
473static MACHINE_DRIVER_START( ps4small )
474   /* basic machine hardware */
475   MDRV_IMPORT_FROM(ps4big)
476
477   MDRV_SCREEN_MODIFY("lscreen")
478   MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 30*8-1)
479
480   MDRV_SCREEN_MODIFY("rscreen")
481   MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 30*8-1)
482MACHINE_DRIVER_END
483
484
485429static INPUT_PORTS_START( hotgmck )
486430   PORT_START("P1_P2")
487431   PORT_BIT( 0x000000ff, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_CUSTOM(system_port_r, NULL)
r6740r6741
764708   PORT_BIT( 0x00100000, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)
765709INPUT_PORTS_END
766710
711
712static void irqhandler( const device_config *device, int linestate )
713{
714   psikyo4_state *state = (psikyo4_state *)device->machine->driver_data;
715   cpu_set_input_line(state->maincpu, 12, linestate ? ASSERT_LINE : CLEAR_LINE);
716}
717
718static const ymf278b_interface ymf278b_config =
719{
720   irqhandler
721};
722
723
724static MACHINE_START( psikyo4 )
725{
726   psikyo4_state *state = (psikyo4_state *)machine->driver_data;
727
728   state->maincpu = devtag_get_device(machine, "maincpu");
729
730#if ROMTEST
731//  FIXME: Too many banks! it cannot be handled in this way, currently
732//  memory_configure_bank(machine, "bank2", 0, 0x2000, memory_region(machine, "gfx1"), 0x2000);
733
734   state->sample_offs = 0;
735   state_save_register_global(machine, state->sample_offs);
736#endif
737
738   state_save_register_global(machine, state->oldbrt1);
739   state_save_register_global(machine, state->oldbrt2);
740}
741
742static MACHINE_RESET( psikyo4 )
743{
744   psikyo4_state *state = (psikyo4_state *)machine->driver_data;
745
746   state->oldbrt1 = -1;
747   state->oldbrt2 = -1;
748}
749
750static MACHINE_DRIVER_START( ps4big )
751
752   /* driver data */
753   MDRV_DRIVER_DATA(psikyo4_state)
754
755   /* basic machine hardware */
756   MDRV_CPU_ADD("maincpu", SH2, MASTER_CLOCK/2)
757   MDRV_CPU_PROGRAM_MAP(ps4_map)
758   MDRV_CPU_VBLANK_INT("lscreen", psikyosh_interrupt)
759
760   MDRV_MACHINE_START(psikyo4)
761   MDRV_MACHINE_RESET(psikyo4)
762
763   MDRV_NVRAM_HANDLER(93C56)
764
765   /* video hardware */
766   MDRV_GFXDECODE(ps4)
767   MDRV_PALETTE_LENGTH((0x2000/4)*2 + 2) /* 0x2000/4 for each screen. 1 for each screen clear colour */
768   MDRV_DEFAULT_LAYOUT(layout_dualhsxs)
769
770   MDRV_SCREEN_ADD("lscreen", RASTER)
771   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
772   MDRV_SCREEN_REFRESH_RATE(60)
773   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
774   MDRV_SCREEN_SIZE(40*8, 32*8)
775   MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 28*8-1)
776
777   MDRV_SCREEN_ADD("rscreen", RASTER)
778   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
779   MDRV_SCREEN_REFRESH_RATE(60)
780   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
781   MDRV_SCREEN_SIZE(40*8, 32*8)
782   MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 28*8-1)
783
784   MDRV_VIDEO_START(psikyo4)
785   MDRV_VIDEO_UPDATE(psikyo4)
786
787   /* sound hardware */
788   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
789
790   MDRV_SOUND_ADD("ymf", YMF278B, MASTER_CLOCK/2)
791   MDRV_SOUND_CONFIG(ymf278b_config)
792   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0)
793   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0)
794MACHINE_DRIVER_END
795
796static MACHINE_DRIVER_START( ps4small )
797   /* basic machine hardware */
798   MDRV_IMPORT_FROM(ps4big)
799
800   MDRV_SCREEN_MODIFY("lscreen")
801   MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 30*8-1)
802
803   MDRV_SCREEN_MODIFY("rscreen")
804   MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 30*8-1)
805MACHINE_DRIVER_END
806
807
808
767809ROM_START( hotgmck )
768810   /* main program */
769811   ROM_REGION( 0x300000, "maincpu", 0)
r6740r6741
852894   ROM_REGION( 0x500000, "maincpu", 0)
853895   ROM_LOAD32_WORD_SWAP( "2.u22",   0x000000, 0x080000, CRC(3334c21e) SHA1(8d825448e40bc50d670ab8587a40df6b27ac918e) )
854896   ROM_LOAD32_WORD_SWAP( "1.u23",   0x000002, 0x080000, CRC(b1a1c643) SHA1(1912a2d231e97ffbe9b668ca7f25cf406664f3ba) )
855    ROM_LOAD16_WORD_SWAP( "prog.u1", 0x100000, 0x400000, CRC(ad556d8e) SHA1(d3dc3c5cbe939b6fc28f861e4132c5485ba89f50) ) // no test
897   ROM_LOAD16_WORD_SWAP( "prog.u1", 0x100000, 0x400000, CRC(ad556d8e) SHA1(d3dc3c5cbe939b6fc28f861e4132c5485ba89f50) ) // no test
856898
857899   ROM_REGION( 0x8000000, "gfx1", 0 )   /* Sprites */
858    ROM_LOAD32_WORD( "0l.u2",  0x0000000, 0x400000, CRC(f65986f7) SHA1(3824a7ea7f14ef3f319b07bd1224847131f6cac0) ) // ok
900   ROM_LOAD32_WORD( "0l.u2",  0x0000000, 0x400000, CRC(f65986f7) SHA1(3824a7ea7f14ef3f319b07bd1224847131f6cac0) ) // ok
859901   ROM_LOAD32_WORD( "0h.u11", 0x0000002, 0x400000, CRC(51fd07a9) SHA1(527097a376fc0ecb23aa8707eb5e029ec1126873) ) // ok
860    ROM_LOAD32_WORD( "1l.u3",  0x0800000, 0x400000, CRC(f59d21d7) SHA1(05a1b93f2926b419ff5e031a25fd227706d66050) ) // ok
861    ROM_LOAD32_WORD( "1h.u12", 0x0800002, 0x400000, CRC(60ea4797) SHA1(5da4a26496ac986ba0bdefde63040634775132dc) ) // ok
862    ROM_LOAD32_WORD( "2l.u4",  0x1000000, 0x400000, CRC(fbaf05e3) SHA1(ce929f1e87b05324e5e863bdb8baafef3d73f781) ) // ok
863    ROM_LOAD32_WORD( "2h.u13", 0x1000002, 0x400000, CRC(61281612) SHA1(88af33aa9348044c3620dd7a89e992f3812f45a8) ) // ok
864    ROM_LOAD32_WORD( "3l.u5",  0x1800000, 0x400000, CRC(e2e1bd9f) SHA1(8078bbffd6bf3abae6a3b36ae26628eb53ee5dc2) ) // ok
865    ROM_LOAD32_WORD( "3h.u14", 0x1800002, 0x400000, CRC(c4426542) SHA1(660e0fc3f641034cc0b2a8398951de0579b35d77) ) // ok
866    ROM_LOAD32_WORD( "4l.u6",  0x2000000, 0x400000, CRC(7298a242) SHA1(f1987a466bc1cb569d1b5f918ef6690b24479b3b) ) // ok
867    ROM_LOAD32_WORD( "4h.u15", 0x2000002, 0x400000, CRC(fe91b459) SHA1(18d0dc1c9f9103d505110dbc1a44f805597037d9) ) // ok
868    ROM_LOAD32_WORD( "5l.u7",  0x2800000, 0x400000, CRC(cc714a7d) SHA1(933c08fb34b138279d5ee7783d1b4865b2d4520a) ) // ok
869    ROM_LOAD32_WORD( "5h.u16", 0x2800002, 0x400000, CRC(2f149cf9) SHA1(598c3e606e3cd87938ccfc3c5e08d88c6044b393) ) // ok
870    ROM_LOAD32_WORD( "6l.u8",  0x3000000, 0x400000, CRC(bfe97dfe) SHA1(f249258a620188d0d7c3858cfb36af5d67ba94b2) ) // ok
871    ROM_LOAD32_WORD( "6h.u17", 0x3000002, 0x400000, CRC(3473052a) SHA1(897987422885a19a53a02257a9dde6348ec42f9f) ) // ok
872    ROM_LOAD32_WORD( "7l.u9",  0x3800000, 0x400000, CRC(022a8a31) SHA1(a21dbf36f56e144f9817c7255866546367dda2f6) ) // ok
873    ROM_LOAD32_WORD( "7h.u18", 0x3800002, 0x400000, CRC(77e47409) SHA1(0e1deb01dd1250c90fc3eed776becd51899f0b5f) ) // ok
902   ROM_LOAD32_WORD( "1l.u3",  0x0800000, 0x400000, CRC(f59d21d7) SHA1(05a1b93f2926b419ff5e031a25fd227706d66050) ) // ok
903   ROM_LOAD32_WORD( "1h.u12", 0x0800002, 0x400000, CRC(60ea4797) SHA1(5da4a26496ac986ba0bdefde63040634775132dc) ) // ok
904   ROM_LOAD32_WORD( "2l.u4",  0x1000000, 0x400000, CRC(fbaf05e3) SHA1(ce929f1e87b05324e5e863bdb8baafef3d73f781) ) // ok
905   ROM_LOAD32_WORD( "2h.u13", 0x1000002, 0x400000, CRC(61281612) SHA1(88af33aa9348044c3620dd7a89e992f3812f45a8) ) // ok
906   ROM_LOAD32_WORD( "3l.u5",  0x1800000, 0x400000, CRC(e2e1bd9f) SHA1(8078bbffd6bf3abae6a3b36ae26628eb53ee5dc2) ) // ok
907   ROM_LOAD32_WORD( "3h.u14", 0x1800002, 0x400000, CRC(c4426542) SHA1(660e0fc3f641034cc0b2a8398951de0579b35d77) ) // ok
908   ROM_LOAD32_WORD( "4l.u6",  0x2000000, 0x400000, CRC(7298a242) SHA1(f1987a466bc1cb569d1b5f918ef6690b24479b3b) ) // ok
909   ROM_LOAD32_WORD( "4h.u15", 0x2000002, 0x400000, CRC(fe91b459) SHA1(18d0dc1c9f9103d505110dbc1a44f805597037d9) ) // ok
910   ROM_LOAD32_WORD( "5l.u7",  0x2800000, 0x400000, CRC(cc714a7d) SHA1(933c08fb34b138279d5ee7783d1b4865b2d4520a) ) // ok
911   ROM_LOAD32_WORD( "5h.u16", 0x2800002, 0x400000, CRC(2f149cf9) SHA1(598c3e606e3cd87938ccfc3c5e08d88c6044b393) ) // ok
912   ROM_LOAD32_WORD( "6l.u8",  0x3000000, 0x400000, CRC(bfe97dfe) SHA1(f249258a620188d0d7c3858cfb36af5d67ba94b2) ) // ok
913   ROM_LOAD32_WORD( "6h.u17", 0x3000002, 0x400000, CRC(3473052a) SHA1(897987422885a19a53a02257a9dde6348ec42f9f) ) // ok
914   ROM_LOAD32_WORD( "7l.u9",  0x3800000, 0x400000, CRC(022a8a31) SHA1(a21dbf36f56e144f9817c7255866546367dda2f6) ) // ok
915   ROM_LOAD32_WORD( "7h.u18", 0x3800002, 0x400000, CRC(77e47409) SHA1(0e1deb01dd1250c90fc3eed776becd51899f0b5f) ) // ok
874916
875917   ROM_REGION( 0x400000, "ymf", ROMREGION_ERASE00 )
876918
877919   ROM_REGION( 0x800000, "ymfsource", 0 )
878    ROM_LOAD( "snd0.u10", 0x000000, 0x400000, CRC(051e2fed) SHA1(ee8073332801982549b3c142fba114e27733a756) ) // ok
879    ROM_LOAD( "snd1.u19", 0x400000, 0x400000, CRC(0de0232d) SHA1(c600fe1d3c6c05e451ae7ef249bb92e8fc9cec3a) ) // ok (but fails rom test due to banking error in emulation)
920   ROM_LOAD( "snd0.u10", 0x000000, 0x400000, CRC(051e2fed) SHA1(ee8073332801982549b3c142fba114e27733a756) ) // ok
921   ROM_LOAD( "snd1.u19", 0x400000, 0x400000, CRC(0de0232d) SHA1(c600fe1d3c6c05e451ae7ef249bb92e8fc9cec3a) ) // ok (but fails rom test due to banking error in emulation)
880922ROM_END
881923
882924ROM_START( hotgmcki )
883925   ROM_REGION( 0x500000, "maincpu", 0)
884926   ROM_LOAD32_WORD_SWAP( "2.u22",   0x000000, 0x080000, CRC(abc192dd) SHA1(674c2b8814319605c1b6221bbe18588a98dda093) )
885927   ROM_LOAD32_WORD_SWAP( "1.u23",   0x000002, 0x080000, CRC(8be896d0) SHA1(5d677dede4ec18cbfc54acae95fe0f10bfc4d566) )
886    ROM_LOAD16_WORD_SWAP( "prog.u1", 0x100000, 0x200000, CRC(9017ae8e) SHA1(0879198606095a2d209df059538ce1c73460b30e) ) // no test
928   ROM_LOAD16_WORD_SWAP( "prog.u1", 0x100000, 0x200000, CRC(9017ae8e) SHA1(0879198606095a2d209df059538ce1c73460b30e) ) // no test
887929   ROM_RELOAD(0x300000,0x200000)
888930
889931   /* Roms have to be mirrored with ROM_RELOAD for rom tests to pass */
r6740r6741
894936   ROM_RELOAD(                0x0400002, 0x200000 )
895937   ROM_LOAD32_WORD( "1l.u3",  0x0800000, 0x200000, CRC(27576360) SHA1(ed9d6f5b9934e8ddae3f3ca146e99f42dbd495de) ) // ok
896938   ROM_RELOAD(                0x0c00000, 0x200000 )
897    ROM_LOAD32_WORD( "1h.u12", 0x0800002, 0x200000, CRC(7439a63f) SHA1(c9a74e5e81a2c94ce7a9b3b487f54ac5b3635744) ) // ok
939   ROM_LOAD32_WORD( "1h.u12", 0x0800002, 0x200000, CRC(7439a63f) SHA1(c9a74e5e81a2c94ce7a9b3b487f54ac5b3635744) ) // ok
898940   ROM_RELOAD(                0x0c00002, 0x200000 )
899941   ROM_LOAD32_WORD( "2l.u4",  0x1000000, 0x200000, CRC(fda64e24) SHA1(e8788b5f0e8b0f90c9942f9f4cbcee02be8afd09) ) // ok
900942   ROM_RELOAD(                0x1400000, 0x200000 )
r6740r6741
9921034PC  :00001B46: TST     R2,R2
9931035PC  :00001B48: BT      $00001B3C
9941036*/
1037   psikyo4_state *state = (psikyo4_state *)space->machine->driver_data;
9951038
996   if (cpu_get_pc(space->cpu)==0x00001B3E) cpu_spinuntil_int(space->cpu);
997   return ps4_ram[0x000020/4];
1039   if (cpu_get_pc(space->cpu) == 0x00001b3e)
1040      cpu_spinuntil_int(space->cpu);
1041
1042   return state->ram[0x000020 / 4];
9981043}
9991044
10001045static READ32_HANDLER( loderdfa_speedup_r )
r6740r6741
10081053PC  :00001B52: TST     R2,R2
10091054PC  :00001B54: BT      $00001B48
10101055*/
1056   psikyo4_state *state = (psikyo4_state *)space->machine->driver_data;
10111057
1012   if (cpu_get_pc(space->cpu)==0x00001B4A) cpu_spinuntil_int(space->cpu);
1013   return ps4_ram[0x000020/4];
1058   if (cpu_get_pc(space->cpu) == 0x00001b4a)
1059      cpu_spinuntil_int(space->cpu);
1060
1061   return state->ram[0x000020 / 4];
10141062}
10151063
10161064static READ32_HANDLER( hotdebut_speedup_r )
r6740r6741
10241072PC  :000029F6: TST     R3,R3
10251073PC  :000029F8: BT      $000029EC
10261074*/
1075   psikyo4_state *state = (psikyo4_state *)space->machine->driver_data;
10271076
1028   if (cpu_get_pc(space->cpu)==0x000029EE) cpu_spinuntil_int(space->cpu);
1029   return ps4_ram[0x00001c/4];
1077   if (cpu_get_pc(space->cpu) == 0x000029ee)
1078      cpu_spinuntil_int(space->cpu);
1079
1080   return state->ram[0x00001c / 4];
10301081}
10311082
10321083static STATE_POSTLOAD( hotgmck_pcm_bank_postload )
r6740r6741
10361087
10371088static void install_hotgmck_pcm_bank(running_machine *machine)
10381089{
1090   psikyo4_state *state = (psikyo4_state *)machine->driver_data;
10391091   UINT8 *ymf_pcm = memory_region(machine, "ymf");
10401092   UINT8 *pcm_rom = memory_region(machine, "ymfsource");
10411093
10421094   memcpy(ymf_pcm, pcm_rom, 0x200000);
10431095
1044   ps4_io_select[0] = (ps4_io_select[0] & 0x00ffffff) | 0x32000000;
1096   state->io_select[0] = (state->io_select[0] & 0x00ffffff) | 0x32000000;
10451097   set_hotgmck_pcm_bank(machine, 0);
10461098   set_hotgmck_pcm_bank(machine, 1);
10471099
src/mame/drivers/rollrace.c
r6740r6741
1313#include "sound/ay8910.h"
1414
1515
16extern UINT8 *rollrace_videoram;
17extern UINT8 *rollrace_colorram;
1618VIDEO_UPDATE( rollrace );
1719PALETTE_INIT( wiz );
1820
r6740r6741
4042   AM_RANGE(0xc000, 0xcfff) AM_RAM
4143   AM_RANGE(0xd806, 0xd806) AM_READNOP /* looks like a watchdog, bit4 checked*/
4244   AM_RANGE(0xd900, 0xd900) AM_READWRITE(ra_fake_d800_r,ra_fake_d800_w) /* protection ??*/
43   AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
44   AM_RANGE(0xe400, 0xe47f) AM_RAM AM_BASE_GENERIC(colorram)
45   AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_BASE(&rollrace_videoram)
46   AM_RANGE(0xe400, 0xe47f) AM_RAM AM_BASE(&rollrace_colorram)
4547   AM_RANGE(0xe800, 0xe800) AM_WRITE(soundlatch_w)
4648   AM_RANGE(0xec00, 0xec0f) AM_NOP /* Analog sound effects ?? ec00 sound enable ?*/
4749   AM_RANGE(0xf000, 0xf0ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
src/mame/drivers/mirage.c
r6740r6741
3434
3535#include "driver.h"
3636#include "cpu/m68000/m68000.h"
37#include "decocrpt.h"
38#include "decoprot.h"
39#include "deco16ic.h"
37#include "includes/decocrpt.h"
38#include "includes/decoprot.h"
39#include "includes/deco16ic.h"
4040#include "sound/okim6295.h"
4141
42#include "deco16ic.h"
43
4442static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect, int pri)
4543{
4644   UINT16 *spriteram16 = machine->generic.spriteram.u16;
src/mame/drivers/popper.c
r6740r6741
8585#include "cpu/z80/z80.h"
8686#include "deprecat.h"
8787#include "sound/ay8910.h"
88#include "popper.h"
88#include "includes/popper.h"
8989
9090
9191/*************************************
src/mame/drivers/djboy.c
r6740r6741
11/*
2DJ Boy (c)1989 Kanako
2DJ Boy (c)1989 Kaneko
33
44Hardware has many similarities to Airbusters.
55
r6740r6741
159159#include "sound/2203intf.h"
160160#include "sound/okim6295.h"
161161#include "video/kan_pand.h"
162#include "includes/djboy.h"
162163
163/* public functions from video/djboy.h */
164extern void djboy_set_videoreg( UINT8 data );
165extern WRITE8_HANDLER( djboy_scrollx_w );
166extern WRITE8_HANDLER( djboy_scrolly_w );
167extern WRITE8_HANDLER( djboy_videoram_w );
168extern WRITE8_HANDLER( djboy_paletteram_w );
169extern VIDEO_START( djboy );
170extern VIDEO_UPDATE( djboy );
171extern VIDEO_EOF( djboy );
172164
173/******************************************************************************/
174
175165/* KANEKO BEAST state */
176166
177#define PROT_OUTPUT_BUFFER_SIZE 8
178
179static int prot_busy_count;
180static UINT8 prot_output_buffer[PROT_OUTPUT_BUFFER_SIZE];
181static int prot_available_data_count;
182static int prot_offs; /* internal state */
183static UINT8 prot_ram[0x80]; /* internal RAM */
184static UINT8 prot_param[8];
185
186static int coin;
187static int complete;
188static int lives[2];
189static int addr;
190static int bankxor;
191
192static enum
167static void ProtectionOut( running_machine *machine, int i, UINT8 data )
193168{
194   eDJBOY_ATTRACT_HIGHSCORE,
195   eDJBOY_ATTRACT_TITLE,
196   eDJBOY_ATTRACT_GAMEPLAY,
197   eDJBOY_PRESS_P1_START,
198   eDJBOY_PRESS_P1_OR_P2_START,
199   eDJBOY_ACTIVE_GAMEPLAY
200} mDjBoyState;
169   djboy_state *state = (djboy_state *)machine->driver_data;
201170
202static enum
203{
204   ePROT_NORMAL,
205   ePROT_WRITE_BYTES,
206   ePROT_WRITE_BYTE,
207   ePROT_READ_BYTES,
208   ePROT_WAIT_DSW1_WRITEBACK,
209   ePROT_WAIT_DSW2_WRITEBACK,
210   ePROT_STORE_PARAM
211} prot_mode;
212
213static void
214ProtectionOut( int i, UINT8 data )
215{
216   if( prot_available_data_count == i )
217   {
218      prot_output_buffer[prot_available_data_count++] = data;
219   }
171   if (state->prot_available_data_count == i)
172      state->prot_output_buffer[state->prot_available_data_count++] = data;
220173   else
221174   {
222      logerror( "prot_output_buffer overflow!\n" );
175      logerror("prot_output_buffer overflow!\n");
223176      exit(1);
224177   }
225178} /* ProtectionOut */
226179
227static int
228GetLives( running_machine *machine )
180static int GetLives( running_machine *machine )
229181{
230182   int dsw = input_port_read(machine, "DSW2");
231   switch( dsw&0x30 )
183   switch (dsw & 0x30)
232184   {
233185   case 0x10: return 3;
234186   case 0x00: return 5;
r6740r6741
238190   return 0;
239191} /* GetLives */
240192
193
241194static WRITE8_HANDLER( coinplus_w )
242195{
196   djboy_state *state = (djboy_state *)space->machine->driver_data;
197
243198   int dsw = input_port_read(space->machine, "DSW1");
244   coin_counter_w( space->machine, 0, data&1 );
245   coin_counter_w( space->machine, 1, data&2 );
246   if( data&1 )
199   coin_counter_w(space->machine, 0, data & 1);
200   coin_counter_w(space->machine, 1, data & 2);
201
202   if (data & 1)
247203   { /* TODO: coinage adjustments */
248      logerror( "COIN A+\n" );
249      switch( (dsw&0x30)>>4 )
204      logerror("COIN A+\n");
205      switch ((dsw & 0x30) >> 4)
250206      {
251      case 0: coin += 4; break; /* 1 coin, 1 credit */
252      case 1: coin += 8; break; /* 1 coin, 2 credits */
253      case 2: coin += 2; break; /* 2 coins, 1 credit */
254      case 3: coin += 6; break; /* 2 coins, 3 credits */
207      case 0: state->coin += 4; break; /* 1 coin, 1 credit */
208      case 1: state->coin += 8; break; /* 1 coin, 2 credits */
209      case 2: state->coin += 2; break; /* 2 coins, 1 credit */
210      case 3: state->coin += 6; break; /* 2 coins, 3 credits */
255211      }
256212   }
257   if( data&2 )
213   if (data & 2)
258214   {
259      logerror( "COIN B+\n" );
260      switch( (dsw&0xc0)>>6 )
215      logerror("COIN B+\n");
216      switch ((dsw & 0xc0) >> 6)
261217      {
262      case 0: coin += 4; break; /* 1 coin, 1 credit */
263      case 1: coin += 8; break; /* 1 coin, 2 credits */
264      case 2: coin += 2; break; /* 2 coins, 1 credit */
265      case 3: coin += 6; break; /* 2 coins, 3 credits */
218      case 0: state->coin += 4; break; /* 1 coin, 1 credit */
219      case 1: state->coin += 8; break; /* 1 coin, 2 credits */
220      case 2: state->coin += 2; break; /* 2 coins, 1 credit */
221      case 3: state->coin += 6; break; /* 2 coins, 3 credits */
266222      }
267223   }
268224} /* coinplus_w */
269225
270static void
271OutputProtectionState( running_machine *machine, int i, int type )
226static void OutputProtectionState( running_machine *machine, int i, int type )
272227{
228   djboy_state *state = (djboy_state *)machine->driver_data;
273229   int io = ~input_port_read(machine, "IN0");
274230   int dat = 0x00;
275231
276   switch( mDjBoyState )
232   switch (state->mDjBoyState)
277233   {
278234   case eDJBOY_ATTRACT_HIGHSCORE:
279      if( coin>=4 )
235      if (state->coin >= 4)
280236      {
281237         dat = 0x01;
282         mDjBoyState = eDJBOY_PRESS_P1_START;
283         logerror( "COIN UP\n" );
238         state->mDjBoyState = eDJBOY_PRESS_P1_START;
239         logerror("COIN UP\n");
284240      }
285      else if( complete )
241      else if (state->complete)
286242      {
287243         dat = 0x06;
288         mDjBoyState = eDJBOY_ATTRACT_TITLE;
244         state->mDjBoyState = eDJBOY_ATTRACT_TITLE;
289245      }
290246      break;
291247
292248   case eDJBOY_ATTRACT_TITLE:
293      if( coin>=4 )
249      if (state->coin >= 4)
294250      {
295251         dat = 0x01;
296         mDjBoyState = eDJBOY_PRESS_P1_START;
297         logerror( "COIN UP\n" );
252         state->mDjBoyState = eDJBOY_PRESS_P1_START;
253         logerror("COIN UP\n");
298254      }
299      else if( complete )
255      else if (state->complete)
300256      {
301257         dat = 0x15;
302         mDjBoyState = eDJBOY_ATTRACT_GAMEPLAY;
258         state->mDjBoyState = eDJBOY_ATTRACT_GAMEPLAY;
303259      }
304260      break;
305261
306262   case eDJBOY_ATTRACT_GAMEPLAY:
307      if( coin>=4 )
263      if (state->coin>=4)
308264      {
309265         dat = 0x01;
310         mDjBoyState = eDJBOY_PRESS_P1_START;
311         logerror( "COIN UP\n" );
266         state->mDjBoyState = eDJBOY_PRESS_P1_START;
267         logerror("COIN UP\n");
312268      }
313      else if( complete )
269      else if (state->complete)
314270      {
315271         dat = 0x0b;
316         mDjBoyState = eDJBOY_ATTRACT_HIGHSCORE;
272         state->mDjBoyState = eDJBOY_ATTRACT_HIGHSCORE;
317273      }
318274      break;
319275
320276   case eDJBOY_PRESS_P1_START:
321      if( io&1 )
322      { /* p1 start */
277      if (io & 1) /* p1 start */
278      {
323279         dat = 0x16;
324         mDjBoyState = eDJBOY_ACTIVE_GAMEPLAY;
325         logerror( "P1 START\n" );
280         state->mDjBoyState = eDJBOY_ACTIVE_GAMEPLAY;
281         logerror("P1 START\n");
326282      }
327      else if( coin>=8 )
283      else if (state->coin >= 8)
328284      {
329285         dat = 0x05;
330         mDjBoyState = eDJBOY_PRESS_P1_OR_P2_START;
331         logerror( "COIN2 UP\n" );
286         state->mDjBoyState = eDJBOY_PRESS_P1_OR_P2_START;
287         logerror("COIN2 UP\n");
332288      }
333289      break;
334290
335291   case eDJBOY_PRESS_P1_OR_P2_START:
336      if( io&1 )
337      { /* p1 start */
292      if (io & 1) /* p1 start */
293      {
338294         dat = 0x16;
339         mDjBoyState = eDJBOY_ACTIVE_GAMEPLAY;
340         lives[0] = GetLives(machine);
341         logerror( "P1 START!\n" );
342         coin-=4;
295         state->mDjBoyState = eDJBOY_ACTIVE_GAMEPLAY;
296         state->lives[0] = GetLives(machine);
297         logerror("P1 START!\n");
298         state->coin -= 4;
343299      }
344      else if( io&2 )
345      { /* p2 start */
300      else if (io & 2) /* p2 start */
301      {
346302         dat = 0x0a;
347         mDjBoyState = eDJBOY_ACTIVE_GAMEPLAY;
348         lives[0] = GetLives(machine);
349         lives[1] = GetLives(machine);
350         logerror( "P2 START!\n" );
351         coin-=8;
303         state->mDjBoyState = eDJBOY_ACTIVE_GAMEPLAY;
304         state->lives[0] = GetLives(machine);
305         state->lives[1] = GetLives(machine);
306         logerror("P2 START!\n");
307         state->coin -= 8;
352308      }
353309      break;
354310
355311   case eDJBOY_ACTIVE_GAMEPLAY:
356      if( lives[0]==0 && lives[1]==0 && complete )
357      { /* continue countdown complete */
312      if (state->lives[0] == 0 && state->lives[1] == 0 && state->complete) /* continue countdown complete */
313      {
358314         dat = 0x0f;
359         logerror( "countdown complete!\n" );
360         mDjBoyState = eDJBOY_ATTRACT_HIGHSCORE;
315         logerror("countdown complete!\n");
316         state->mDjBoyState = eDJBOY_ATTRACT_HIGHSCORE;
361317      }
362      else if( coin>=4 )
318      else if (state->coin >= 4)
363319      {
364         if( (io&1) && lives[0]==0 )
320         if ((io & 1) && state->lives[0] == 0)
365321         {
366322            dat = 0x12; /* continue (P1) */
367            lives[0] = GetLives(machine);
368            mDjBoyState = eDJBOY_ACTIVE_GAMEPLAY;
369            coin-=4;
370            logerror( "P1 CONTINUE!\n" );
323            state->lives[0] = GetLives(machine);
324            state->mDjBoyState = eDJBOY_ACTIVE_GAMEPLAY;
325            state->coin -= 4;
326            logerror("P1 CONTINUE!\n");
371327         }
372         else if( (io&2) && lives[1]==0 )
328         else if ((io & 2) && state->lives[1] == 0)
373329         {
374330            dat = 0x08; /* continue (P2) */
375            lives[1] = GetLives(machine);
376            mDjBoyState = eDJBOY_ACTIVE_GAMEPLAY;
377            coin-=4;
378            logerror( "P2 CONTINUE!\n" );
331            state->lives[1] = GetLives(machine);
332            state->mDjBoyState = eDJBOY_ACTIVE_GAMEPLAY;
333            state->coin -= 4;
334            logerror("P2 CONTINUE!\n");
379335         }
380336      }
381337      break;
382338   }
383   complete = 0;
384   ProtectionOut( i, dat );
339   state->complete = 0;
340   ProtectionOut(machine, i, dat);
385341} /* OutputProtectionState */
386342
387static void
388CommonProt( running_machine *machine, int i, int type )
343static void CommonProt( running_machine *machine, int i, int type )
389344{
390   int displayedCredits = coin/4;
391   if( displayedCredits>9 )
392   {
345   djboy_state *state = (djboy_state *)machine->driver_data;
346   int displayedCredits = state->coin / 4;
347   if (displayedCredits > 9)
393348      displayedCredits = 9;
394   }
395   ProtectionOut( i++, displayedCredits );
396   ProtectionOut( i++, input_port_read(machine, "IN0") ); /* COIN/START */
397   OutputProtectionState( machine, i, type );
349
350   ProtectionOut(machine, i++, displayedCredits);
351   ProtectionOut(machine, i++, input_port_read(machine, "IN0")); /* COIN/START */
352   OutputProtectionState(machine, i, type);
398353} /* CommonProt */
399354
400355static WRITE8_HANDLER( beast_data_w )
401356{
402   prot_busy_count = 1;
357   djboy_state *state = (djboy_state *)space->machine->driver_data;
403358
404   logerror( "0x%04x: prot_w(0x%02x)\n", cpu_get_pc(space->cpu), data );
359   state->prot_busy_count = 1;
405360
406   watchdog_reset_w(space,0,0);
361   logerror("0x%04x: prot_w(0x%02x)\n", cpu_get_pc(space->cpu), data);
407362
408   if( prot_mode == ePROT_WAIT_DSW1_WRITEBACK )
363   watchdog_reset_w(space, 0, 0);
364
365   if (state->prot_mode == ePROT_WAIT_DSW1_WRITEBACK)
409366   {
410      logerror( "[DSW1_WRITEBACK]\n" );
411      ProtectionOut( 0, input_port_read(space->machine, "DSW2") ); /* DSW2 */
412      prot_mode = ePROT_WAIT_DSW2_WRITEBACK;
367      logerror("[DSW1_WRITEBACK]\n");
368      ProtectionOut(space->machine, 0, input_port_read(space->machine, "DSW2")); /* DSW2 */
369      state->prot_mode = ePROT_WAIT_DSW2_WRITEBACK;
413370   }
414   else if( prot_mode == ePROT_WAIT_DSW2_WRITEBACK )
371   else if (state->prot_mode == ePROT_WAIT_DSW2_WRITEBACK)
415372   {
416      logerror( "[DSW2_WRITEBACK]\n" );
417      prot_mode = ePROT_STORE_PARAM;
418      prot_offs = 0;
373      logerror("[DSW2_WRITEBACK]\n");
374      state->prot_mode = ePROT_STORE_PARAM;
375      state->prot_offs = 0;
419376   }
420   else if( prot_mode == ePROT_STORE_PARAM )
377   else if (state->prot_mode == ePROT_STORE_PARAM)
421378   {
422      logerror( "prot param[%d]: 0x%02x\n", prot_offs, data );
423      if( prot_offs<8 )
424      {
425         prot_param[prot_offs++] = data;
426      }
427      if( prot_offs == 8 )
428      {
429         prot_mode = ePROT_NORMAL;
430      }
379      logerror("prot param[%d]: 0x%02x\n", state->prot_offs, data);
380      if (state->prot_offs < 8)
381         state->prot_param[state->prot_offs++] = data;
382
383      if(state->prot_offs == 8)
384         state->prot_mode = ePROT_NORMAL;
431385   }
432   else if( prot_mode == ePROT_WRITE_BYTE )
386   else if (state->prot_mode == ePROT_WRITE_BYTE)
433387   { /* pc == 0x79cd */
434      prot_ram[(prot_offs++)&0x7f] = data;
435      prot_mode = ePROT_WRITE_BYTES;
388      state->prot_ram[(state->prot_offs++) & 0x7f] = data;
389      state->prot_mode = ePROT_WRITE_BYTES;
436390   }
437391   else
438392   {
439      switch( data )
393      switch (data)
440394      {
441395      case 0x00:
442         if( prot_mode == ePROT_WRITE_BYTES )
396         if (state->prot_mode == ePROT_WRITE_BYTES)
443397         { /* next byte is data to write to internal prot RAM */
444            prot_mode = ePROT_WRITE_BYTE;
398            state->prot_mode = ePROT_WRITE_BYTE;
445399         }
446         else if( prot_mode == ePROT_READ_BYTES )
400         else if (state->prot_mode == ePROT_READ_BYTES)
447401         { /* request next byte of internal prot RAM */
448            ProtectionOut( 0, prot_ram[(prot_offs++)&0x7f] );
402            ProtectionOut(space->machine, 0, state->prot_ram[(state->prot_offs++) & 0x7f]);
449403         }
450404         else
451         {
452            logerror( "UNEXPECTED PREFIX!\n" );
453         }
405            logerror("UNEXPECTED PREFIX!\n");
454406         break;
455407
456408      case 0x01: // pc=7389
457         OutputProtectionState( space->machine, 0, 0x01 );
409         OutputProtectionState(space->machine, 0, 0x01);
458410         break;
459411
460412      case 0x02:
461         CommonProt( space->machine,0,0x02 );
413         CommonProt(space->machine, 0, 0x02);
462414         break;
463415
464416      case 0x03: /* prepare for memory write to protection device ram (pc == 0x7987) */ // -> 0x02
465         logerror( "[WRITE BYTES]\n" );
466         prot_mode = ePROT_WRITE_BYTES;
467         prot_offs = 0;
417         logerror("[WRITE BYTES]\n");
418         state->prot_mode = ePROT_WRITE_BYTES;
419         state->prot_offs = 0;
468420         break;
469421
470422      case 0x04:
471         ProtectionOut( 0,0 ); // ?
472         ProtectionOut( 1,0 ); // ?
473         ProtectionOut( 2,0 ); // ?
474         ProtectionOut( 3,0 ); // ?
475         CommonProt(    space->machine, 4,0x04 );
423         ProtectionOut(space->machine, 0, 0); // ?
424         ProtectionOut(space->machine, 1, 0); // ?
425         ProtectionOut(space->machine, 2, 0); // ?
426         ProtectionOut(space->machine, 3, 0); // ?
427         CommonProt(space->machine, 4, 0x04);
476428         break;
477429
478430      case 0x05: /* 0x71f4 */
479         ProtectionOut( 0,input_port_read(space->machine, "IN1") ); // to $42
480         ProtectionOut( 1,0 ); // ?
481         ProtectionOut( 2,input_port_read(space->machine, "IN2") ); // to $43
482         ProtectionOut( 3,0 ); // ?
483         ProtectionOut( 4,0 ); // ?
484         CommonProt(    space->machine, 5,0x05 );
431         ProtectionOut(space->machine, 0, input_port_read(space->machine, "IN1")); // to $42
432         ProtectionOut(space->machine, 1, 0); // ?
433         ProtectionOut(space->machine, 2, input_port_read(space->machine, "IN2")); // to $43
434         ProtectionOut(space->machine, 3, 0); // ?
435         ProtectionOut(space->machine, 4, 0); // ?
436         CommonProt(space->machine, 5, 0x05);
485437         break;
486438
487439      case 0x07:
488         CommonProt( space->machine, 0,0x07 );
440         CommonProt(space->machine, 0, 0x07);
489441         break;
490442
491443      case 0x08: /* pc == 0x727a */
492         ProtectionOut( 0,input_port_read(space->machine, "IN0") ); /* COIN/START */
493         ProtectionOut( 1,input_port_read(space->machine, "IN1") ); /* JOY1 */
494         ProtectionOut( 2,input_port_read(space->machine, "IN2") ); /* JOY2 */
495         ProtectionOut( 3,input_port_read(space->machine, "DSW1") ); /* DSW1 */
496         ProtectionOut( 4,input_port_read(space->machine, "DSW2") ); /* DSW2 */
497         CommonProt(    space->machine, 5, 0x08 );
444         ProtectionOut(space->machine, 0, input_port_read(space->machine, "IN0")); /* COIN/START */
445         ProtectionOut(space->machine, 1, input_port_read(space->machine, "IN1")); /* JOY1 */
446         ProtectionOut(space->machine, 2, input_port_read(space->machine, "IN2")); /* JOY2 */
447         ProtectionOut(space->machine, 3, input_port_read(space->machine, "DSW1")); /* DSW1 */
448         ProtectionOut(space->machine, 4, input_port_read(space->machine, "DSW2")); /* DSW2 */
449         CommonProt(space->machine, 5, 0x08);
498450         break;
499451
500452      case 0x09:
501         ProtectionOut( 0,0 ); // ?
502         ProtectionOut( 1,0 ); // ?
503         ProtectionOut( 2,0 ); // ?
504         CommonProt(    space->machine, 3, 0x09 );
453         ProtectionOut(space->machine, 0, 0); // ?
454         ProtectionOut(space->machine, 1, 0); // ?
455         ProtectionOut(space->machine, 2, 0); // ?
456         CommonProt(space->machine, 3, 0x09);
505457         break;
506458
507459      case 0x0a:
508         CommonProt( space->machine,0,0x0a );
460         CommonProt(space->machine, 0, 0x0a);
509461         break;
510462
511463      case 0x0c:
512         CommonProt( space->machine,1,0x0c );
464         CommonProt(space->machine, 1, 0x0c);
513465         break;
514466
515467      case 0x0d:
516         CommonProt( space->machine,2,0x0d );
468         CommonProt(space->machine, 2, 0x0d);
517469         break;
518470
519471      case 0xfe: /* prepare for memory read from protection device ram (pc == 0x79ee, 0x7a3f) */
520         if( prot_mode == ePROT_WRITE_BYTES )
472         if (state->prot_mode == ePROT_WRITE_BYTES)
521473         {
522            prot_mode = ePROT_READ_BYTES;
523            logerror( "[READ BYTES]\n" );
474            state->prot_mode = ePROT_READ_BYTES;
475            logerror("[READ BYTES]\n");
524476         }
525477         else
526478         {
527            prot_mode = ePROT_WRITE_BYTES;
528            logerror( "[WRITE BYTES*]\n" );
479            state->prot_mode = ePROT_WRITE_BYTES;
480            logerror("[WRITE BYTES*]\n");
529481         }
530         prot_offs = 0;
482         state->prot_offs = 0;
531483         break;
532484
533485      case 0xff: /* read DSW (pc == 0x714d) */
534         ProtectionOut( 0,input_port_read(space->machine, "DSW1") ); /* DSW1 */
535         prot_mode = ePROT_WAIT_DSW1_WRITEBACK;
486         ProtectionOut(space->machine, 0, input_port_read(space->machine, "DSW1")); /* DSW1 */
487         state->prot_mode = ePROT_WAIT_DSW1_WRITEBACK;
536488         break;
537489
538490      case 0xa9: /* 1-player game: P1 dies
539491                         2-player game: P2 dies */
540         if( lives[0]>0 && lives[1]>0 )
492         if (state->lives[0] > 0 && state->lives[1] > 0 )
541493         {
542            lives[1]--;
543            logerror( "%02x P2 DIE(%d)\n", data, lives[1] );
494            state->lives[1]--;
495            logerror("%02x P2 DIE(%d)\n", data, state->lives[1]);
544496         }
545         else if( lives[0]>0 )
497         else if (state->lives[0] > 0)
546498         {
547            lives[0]--;
548            logerror( "%02x P1 DIE(%d)\n", data, lives[0] );
499            state->lives[0]--;
500            logerror("%02x P1 DIE(%d)\n", data, state->lives[0]);
549501         }
550502         else
551503         {
552            logerror( "%02x COMPLETE.\n", data );
553            complete = 0xa9;
504            logerror("%02x COMPLETE.\n", data);
505            state->complete = 0xa9;
554506         }
555507         break;
556508
557509      case 0x92: /* p2 lost life; in 2-p game, P1 died */
558         if( lives[0]>0 && lives[1]>0 )
510         if (state->lives[0] > 0 && state->lives[1] > 0 )
559511         {
560            lives[0]--;
561            logerror( "%02x P1 DIE(%d)\n", data, lives[0] );
512            state->lives[0]--;
513            logerror("%02x P1 DIE(%d)\n", data, state->lives[0]);
562514         }
563         else if( lives[1]>0 )
515         else if (state->lives[1] > 0)
564516         {
565            lives[1]--;
566            logerror( "%02x P2 DIE (%d)\n", data, lives[1] );
517            state->lives[1]--;
518            logerror("%02x P2 DIE (%d)\n", data, state->lives[1]);
567519         }
568520         else
569521         {
570            logerror( "%02x COMPLETE.\n", data );
571            complete = 0x92;
522            logerror("%02x COMPLETE.\n", data);
523            state->complete = 0x92;
572524         }
573525         break;
574526
575527      case 0xa3: /* p2 bonus life */
576         lives[1]++;
577         logerror( "%02x P2 BONUS(%d)\n", data, lives[1] );
528         state->lives[1]++;
529         logerror("%02x P2 BONUS(%d)\n", data, state->lives[1]);
578530         break;
579531
580532      case 0xa5: /* p1 bonus life */
581         lives[0]++;
582         logerror( "%02x P1 BONUS(%d)\n", data, lives[0] );
533         state->lives[0]++;
534         logerror("%02x P1 BONUS(%d)\n", data, state->lives[0]);
583535         break;
584536
585537      case 0xad: /* 1p game start ack */
586         logerror( "%02x 1P GAME START\n", data );
538         logerror("%02x 1P GAME START\n", data);
587539         break;
588540
589541      case 0xb0: /* 1p+2p game start ack */
590         logerror( "%02x 1P+2P GAME START\n", data );
542         logerror("%02x 1P+2P GAME START\n", data);
591543         break;
592544
593545      case 0xb3: /* 1p continue ack */
594         logerror( "%02x 1P CONTINUE\n", data );
546         logerror("%02x 1P CONTINUE\n", data);
595547         break;
596548
597549      case 0xb7: /* 2p continue ack */
598         logerror( "%02x 2P CONTINUE\n", data );
550         logerror("%02x 2P CONTINUE\n", data);
599551         break;
600552
601553      default:
602554      case 0x97:
603555      case 0x9a:
604         logerror( "!!0x%04x: prot_w(0x%02x)\n", cpu_get_pc(space->cpu), data );
556         logerror("!!0x%04x: prot_w(0x%02x)\n", cpu_get_pc(space->cpu), data);
605557         break;
606558      }
607559   }
r6740r6741
609561
610562static READ8_HANDLER( beast_data_r )
611563{ /* port#4 */
564   djboy_state *state = (djboy_state *)space->machine->driver_data;
612565   UINT8 data = 0x00;
613   if( prot_available_data_count )
566   if (state->prot_available_data_count)
614567   {
615568      int i;
616      data = prot_output_buffer[0];
617      prot_available_data_count--;
618      for( i=0; i<prot_available_data_count; i++ )
619      {
620         prot_output_buffer[i] = prot_output_buffer[i+1];
621      }
569      data = state->prot_output_buffer[0];
570      state->prot_available_data_count--;
571      for (i = 0; i < state->prot_available_data_count; i++)
572         state->prot_output_buffer[i] = state->prot_output_buffer[i + 1];
622573   }
623574   else
624575   {
625      logerror( "prot_r: data expected!\n" );
576      logerror("prot_r: data expected!\n");
626577   }
627   logerror( "0x%04x: prot_r() == 0x%02x\n", cpu_get_pc(space->cpu), data );
578   logerror("0x%04x: prot_r() == 0x%02x\n", cpu_get_pc(space->cpu), data);
628579   return data;
629580} /* beast_data_r */
630581
631582static READ8_HANDLER( beast_status_r )
632583{ /* port 0xc */
584   djboy_state *state = (djboy_state *)space->machine->driver_data;
633585   UINT8 result = 0;
634   if( prot_busy_count )
586
587   if (state->prot_busy_count)
635588   {
636      prot_busy_count--;
637      result |= 1<<3;
589      state->prot_busy_count--;
590      result |= 1 << 3;
638591   }
639   if( !prot_available_data_count )
592   if (!state->prot_available_data_count)
640593   {
641      result |= 1<<2;
594      result |= 1 << 2;
642595   }
643596   return result;
644597} /* beast_status_r */
645598
646599/******************************************************************************/
647static DRIVER_INIT( djboy )
648{
649   coin = 0;
650   complete = 0;
651   memset(lives, 0, sizeof(lives));
652   addr = 0xff;
653   bankxor = 0x00;
654}
655600
656static DRIVER_INIT( djboyj )
657{
658   DRIVER_INIT_CALL( djboy );
659   bankxor = 0x1f;
660}
661
662601static WRITE8_HANDLER( trigger_nmi_on_cpu0 )
663602{
664   cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
603   djboy_state *state = (djboy_state *)space->machine->driver_data;
604   cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, PULSE_LINE);
665605}
666606
667607static WRITE8_HANDLER( cpu0_bankswitch_w )
668608{
669   unsigned char *RAM = memory_region(space->machine, "maincpu");
670   data ^= bankxor;
671   memory_set_bankptr(space->machine, "bank4",&RAM[0x10000]); /* unsure if/how this area is banked */
672   if( data < 4 )
673   {
674      RAM = &RAM[0x2000 * data];
675   }
676   else
677   {
678      RAM = &RAM[0x10000 + 0x2000 * (data-4)];
679   }
680   memory_set_bankptr(space->machine, "bank1",RAM);
609   djboy_state *state = (djboy_state *)space->machine->driver_data;
610
611   data ^= state->bankxor;
612   memory_set_bank(space->machine, "bank1", data);
613   memory_set_bank(space->machine, "bank4", 0); /* unsure if/how this area is banked */
681614}
682615
683616/******************************************************************************/
r6740r6741
690623 */
691624static WRITE8_HANDLER( cpu1_bankswitch_w )
692625{
693   UINT8 *RAM = memory_region(space->machine, "cpu1");
694   djboy_set_videoreg( data );
695   switch( data&0xf )
626   djboy_state *state = (djboy_state *)space->machine->driver_data;
627   state->videoreg = data;
628
629   switch (data & 0xf)
696630   {
697631   /* bs65.5y */
698   case 0x00: memory_set_bankptr(space->machine, "bank2",&RAM[0x00000]); break;
699   case 0x01: memory_set_bankptr(space->machine, "bank2",&RAM[0x04000]); break;
700   case 0x02: memory_set_bankptr(space->machine, "bank2",&RAM[0x10000]); break;
701   case 0x03: memory_set_bankptr(space->machine, "bank2",&RAM[0x14000]); break;
632   case 0x00:
633   case 0x01:
634   case 0x02:
635   case 0x03:
636      memory_set_bank(space->machine, "bank2", (data & 0xf));
637      break;
702638
703639   /* bs101.6w */
704   case 0x08: memory_set_bankptr(space->machine, "bank2",&RAM[0x18000]); break;
705   case 0x09: memory_set_bankptr(space->machine, "bank2",&RAM[0x1c000]); break;
706   case 0x0a: memory_set_bankptr(space->machine, "bank2",&RAM[0x20000]); break;
707   case 0x0b: memory_set_bankptr(space->machine, "bank2",&RAM[0x24000]); break;
708   case 0x0c: memory_set_bankptr(space->machine, "bank2",&RAM[0x28000]); break;
709   case 0x0d: memory_set_bankptr(space->machine, "bank2",&RAM[0x2c000]); break;
710   case 0x0e: memory_set_bankptr(space->machine, "bank2",&RAM[0x30000]); break;
711   case 0x0f: memory_set_bankptr(space->machine, "bank2",&RAM[0x34000]); break;
640   case 0x08:
641   case 0x09:
642   case 0x0a:
643   case 0x0b:
644   case 0x0c:
645   case 0x0d:
646   case 0x0e:
647   case 0x0f:
648      memory_set_bank(space->machine, "bank2", (data & 0xf) - 4);
649      break;
712650
713651   default:
714652      break;
r6740r6741
719657
720658static WRITE8_HANDLER( trigger_nmi_on_sound_cpu2 )
721659{
660   djboy_state *state = (djboy_state *)space->machine->driver_data;
722661   soundlatch_w(space, 0, data);
723   cputag_set_input_line(space->machine, "cpu2", INPUT_LINE_NMI, PULSE_LINE);
662   cpu_set_input_line(state->cpu2, INPUT_LINE_NMI, PULSE_LINE);
724663} /* trigger_nmi_on_sound_cpu2 */
725664
726665static WRITE8_HANDLER( cpu2_bankswitch_w )
727666{
728   UINT8 *RAM = memory_region(space->machine, "cpu2");
729
730   if( data < 3 )
731   {
732      RAM = &RAM[0x04000 * data];
733   }
734   else
735   {
736      RAM = &RAM[0x10000 + 0x4000 * (data - 3)];
737   }
738   memory_set_bankptr(space->machine, "bank3", RAM);
667   memory_set_bank(space->machine, "bank3", data);   // shall we check data<0x07?
739668}
740669
741670/******************************************************************************/
r6740r6741
760689static ADDRESS_MAP_START( cpu1_am, ADDRESS_SPACE_PROGRAM, 8 )
761690   AM_RANGE(0x0000, 0x7fff) AM_ROM
762691   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank2")
763   AM_RANGE(0xc000, 0xcfff) AM_RAM_WRITE(djboy_videoram_w) AM_BASE_GENERIC(videoram)
764   AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(djboy_paletteram_w) AM_BASE_GENERIC(paletteram)
692   AM_RANGE(0xc000, 0xcfff) AM_RAM_WRITE(djboy_videoram_w) AM_BASE_MEMBER(djboy_state, videoram)
693   AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(djboy_paletteram_w) AM_BASE_MEMBER(djboy_state, paletteram)
765694   AM_RANGE(0xd400, 0xd8ff) AM_RAM
766695   AM_RANGE(0xe000, 0xffff) AM_RAM AM_SHARE("share1")
767696ADDRESS_MAP_END
r6740r6741
903832
904833static INTERRUPT_GEN( djboy_interrupt )
905834{ /* CPU1 uses interrupt mode 2. For now, just alternate the two interrupts. */
906   addr ^= 0x02;
907   cpu_set_input_line_and_vector(device, 0, HOLD_LINE, addr);
835   djboy_state *state = (djboy_state *)device->machine->driver_data;
836   state->addr ^= 0x02;
837   cpu_set_input_line_and_vector(device, 0, HOLD_LINE, state->addr);
908838}
909839
910840static const kaneko_pandora_interface djboy_pandora_config =
r6740r6741
914844   0, 0   /* x_offs, y_offs */
915845};
916846
847
848static MACHINE_START( djboy )
849{
850   djboy_state *state = (djboy_state *)machine->driver_data;
851   UINT8 *MAIN = memory_region(machine, "maincpu");
852   UINT8 *CPU1 = memory_region(machine, "cpu1");
853   UINT8 *CPU2 = memory_region(machine, "cpu2");
854
855   memory_configure_bank(machine, "bank1", 0, 4,  &MAIN[0x00000], 0x2000);
856   memory_configure_bank(machine, "bank1", 4, 28, &MAIN[0x10000], 0x2000);
857   memory_configure_bank(machine, "bank2", 0, 2,  &CPU1[0x00000], 0x4000);
858   memory_configure_bank(machine, "bank2", 2, 10, &CPU1[0x10000], 0x4000);
859   memory_configure_bank(machine, "bank3", 0, 3,  &CPU2[0x00000], 0x4000);
860   memory_configure_bank(machine, "bank3", 3, 5,  &CPU2[0x10000], 0x4000);
861   memory_configure_bank(machine, "bank4", 0, 1,  &MAIN[0x10000], 0x3000); /* unsure if/how this area is banked */
862
863   state->maincpu = devtag_get_device(machine, "maincpu");
864   state->cpu1 = devtag_get_device(machine, "cpu1");
865   state->cpu2 = devtag_get_device(machine, "cpu2");
866   state->pandora = devtag_get_device(machine, "pandora");
867
868   state_save_register_global(machine, state->videoreg);
869   state_save_register_global(machine, state->scrollx);
870   state_save_register_global(machine, state->scrolly);
871
872   /* Kaneko BEAST */
873   state_save_register_global(machine, state->coin);
874   state_save_register_global(machine, state->complete);
875   state_save_register_global(machine, state->addr);
876   state_save_register_global_array(machine, state->lives);
877
878   state_save_register_global(machine, state->mDjBoyState );
879   state_save_register_global(machine, state->prot_mode);
880   state_save_register_global(machine, state->prot_busy_count);
881   state_save_register_global(machine, state->prot_available_data_count);
882   state_save_register_global(machine, state->prot_offs);
883   state_save_register_global_array(machine, state->prot_output_buffer);
884   state_save_register_global_array(machine, state->prot_ram);
885   state_save_register_global_array(machine, state->prot_param);
886}
887
888static MACHINE_RESET( djboy )
889{
890   djboy_state *state = (djboy_state *)machine->driver_data;
891
892   state->videoreg = 0;
893   state->scrollx = 0;
894   state->scrolly = 0;
895
896   /* Kaneko BEAST */
897   state->coin = 0;
898   state->complete = 0;
899   state->addr = 0xff;
900   state->lives[0] = 0;
901   state->lives[1] = 0;
902
903   state->prot_busy_count = 0;
904   state->prot_available_data_count = 0;
905   state->prot_offs = 0;
906
907   memset(state->prot_output_buffer, 0, PROT_OUTPUT_BUFFER_SIZE);
908   memset(state->prot_ram, 0, 0x80);
909   memset(state->prot_param, 0, 8);
910
911   state->mDjBoyState = eDJBOY_ATTRACT_HIGHSCORE;
912   state->prot_mode = ePROT_NORMAL;
913}
914
917915static MACHINE_DRIVER_START( djboy )
916   MDRV_DRIVER_DATA(djboy_state)
917
918918   MDRV_CPU_ADD("maincpu", Z80,6000000)
919919   MDRV_CPU_PROGRAM_MAP(cpu0_am)
920920   MDRV_CPU_IO_MAP(cpu0_port_am)
r6740r6741
932932
933933   MDRV_QUANTUM_TIME(HZ(6000))
934934
935   MDRV_MACHINE_START(djboy)
936   MDRV_MACHINE_RESET(djboy)
937
935938   MDRV_SCREEN_ADD("screen", RASTER)
936939   MDRV_SCREEN_REFRESH_RATE(60)
937940   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
r6740r6741
10721075ROM_END
10731076
10741077
1078static DRIVER_INIT( djboy )
1079{
1080   djboy_state *state = (djboy_state *)machine->driver_data;
1081   state->bankxor = 0x00;
1082}
10751083
1084static DRIVER_INIT( djboyj )
1085{
1086   djboy_state *state = (djboy_state *)machine->driver_data;
1087   state->bankxor = 0x1f;
1088}
1089
10761090/*     YEAR, NAME,  PARENT, MACHINE, INPUT, INIT, MNTR,  COMPANY, FULLNAME, FLAGS */
1077GAME( 1989, djboy,  0,      djboy,   djboy, djboy,    ROT0, "Kaneko (American Sammy license)", "DJ Boy (set 1)", 0) // Sammy & Williams logos in FG ROM
1078GAME( 1989, djboya, djboy,  djboy,   djboy, djboy,    ROT0, "Kaneko (American Sammy license)", "DJ Boy (set 2)", 0) // Sammy & Williams logos in FG ROM
1079GAME( 1989, djboyj, djboy,  djboy,   djboy, djboyj,   ROT0, "Kaneko (Sega license)", "DJ Boy (Japan)", 0 ) // Sega logo in FG ROM
1091GAME( 1989, djboy,  0,      djboy,   djboy, djboy,    ROT0, "Kaneko (American Sammy license)", "DJ Boy (set 1)", GAME_SUPPORTS_SAVE) // Sammy & Williams logos in FG ROM
1092GAME( 1989, djboya, djboy,  djboy,   djboy, djboy,    ROT0, "Kaneko (American Sammy license)", "DJ Boy (set 2)", GAME_SUPPORTS_SAVE) // Sammy & Williams logos in FG ROM
1093GAME( 1989, djboyj, djboy,  djboy,   djboy, djboyj,   ROT0, "Kaneko (Sega license)", "DJ Boy (Japan)", GAME_SUPPORTS_SAVE ) // Sega logo in FG ROM
src/mame/drivers/sidearms.c
r6740r6741
4040#include "sound/2203intf.h"
4141#include "sound/2151intf.h"
4242
43extern UINT8 *sidearms_videoram;
44extern UINT8 *sidearms_colorram;
4345extern UINT8 *sidearms_bg_scrollx;
4446extern UINT8 *sidearms_bg_scrolly;
4547
r6740r6741
99101   AM_RANGE(0xc808, 0xc809) AM_WRITEONLY AM_BASE(&sidearms_bg_scrollx)
100102   AM_RANGE(0xc80a, 0xc80b) AM_WRITEONLY AM_BASE(&sidearms_bg_scrolly)
101103   AM_RANGE(0xc80c, 0xc80c) AM_WRITE(sidearms_gfxctrl_w)   /* background and sprite enable */
102   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(sidearms_videoram_w) AM_BASE_GENERIC(videoram)
103   AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(sidearms_colorram_w) AM_BASE_GENERIC(colorram)
104   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(sidearms_videoram_w) AM_BASE(&sidearms_videoram)
105   AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(sidearms_colorram_w) AM_BASE(&sidearms_colorram)
104106   AM_RANGE(0xe000, 0xefff) AM_RAM
105107   AM_RANGE(0xf000, 0xffff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
106108ADDRESS_MAP_END
r6740r6741
122124   AM_RANGE(0xe808, 0xe809) AM_WRITEONLY AM_BASE(&sidearms_bg_scrollx)
123125   AM_RANGE(0xe80a, 0xe80b) AM_WRITEONLY AM_BASE(&sidearms_bg_scrolly)
124126   AM_RANGE(0xe80c, 0xe80c) AM_WRITE(sidearms_gfxctrl_w)   /* background and sprite enable */
125   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(sidearms_videoram_w) AM_BASE_GENERIC(videoram)
126   AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(sidearms_colorram_w) AM_BASE_GENERIC(colorram)
127   AM_RANGE(0xf000, 0xf7ff) AM_RAM_WRITE(sidearms_videoram_w) AM_BASE(&sidearms_videoram)
128   AM_RANGE(0xf800, 0xffff) AM_RAM_WRITE(sidearms_colorram_w) AM_BASE(&sidearms_colorram)
127129ADDRESS_MAP_END
128130
129131static ADDRESS_MAP_START( sidearms_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
r6740r6741
172174   AM_RANGE(0xe805, 0xe805) AM_WRITE(sidearms_star_scrollx_w)
173175   AM_RANGE(0xe806, 0xe806) AM_WRITE(sidearms_star_scrolly_w)
174176   AM_RANGE(0xc80c, 0xc80c) AM_WRITE(sidearms_gfxctrl_w)
175   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(sidearms_videoram_w) AM_BASE_GENERIC(videoram)
176   AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(sidearms_colorram_w) AM_BASE_GENERIC(colorram)
177   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(sidearms_videoram_w) AM_BASE(&sidearms_videoram)
178   AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(sidearms_colorram_w) AM_BASE(&sidearms_colorram)
177179   AM_RANGE(0xe000, 0xefff) AM_RAM
178180   AM_RANGE(0xf000, 0xffff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
179181ADDRESS_MAP_END
src/mame/drivers/taito_x.c
r6740r6741
313313#include "driver.h"
314314#include "cpu/z80/z80.h"
315315#include "cpu/m68000/m68000.h"
316#include "taitoipt.h"
316#include "includes/taitoipt.h"
317317#include "audio/taitosnd.h"
318#include "seta.h"
318#include "includes/seta.h"
319319#include "sound/2610intf.h"
320320#include "sound/2151intf.h"
321321#include "includes/cchip.h"
src/mame/drivers/tumblep.c
r6740r6741
4242#include "driver.h"
4343#include "cpu/m68000/m68000.h"
4444#include "cpu/h6280/h6280.h"
45#include "decocrpt.h"
45#include "includes/decocrpt.h"
4646#include "sound/2151intf.h"
4747#include "sound/3812intf.h"
4848#include "sound/okim6295.h"
49#include "deco16ic.h"
49#include "includes/deco16ic.h"
5050
5151#define TUMBLEP_HACK   0
5252
src/mame/drivers/dietgo.c
r6740r6741
99#include "cpu/h6280/h6280.h"
1010#include "sound/2151intf.h"
1111#include "sound/okim6295.h"
12#include "decocrpt.h"
13#include "decoprot.h"
14#include "deco16ic.h"
12#include "includes/decocrpt.h"
13#include "includes/decoprot.h"
14#include "includes/deco16ic.h"
1515
1616VIDEO_UPDATE( dietgo );
1717VIDEO_START( dietgo );
src/mame/drivers/esripsys.c
r6740r6741
3131#include "machine/6840ptm.h"
3232#include "sound/dac.h"
3333#include "sound/tms5220.h"
34#include "esripsys.h"
34#include "includes/esripsys.h"
3535
3636
3737/*************************************
src/mame/drivers/blockout.c
r6740r6741
7070#include "cpu/z80/z80.h"
7171#include "sound/2151intf.h"
7272#include "sound/okim6295.h"
73#include "blockout.h"
73#include "includes/blockout.h"
7474
7575
7676static INTERRUPT_GEN( blockout_interrupt )
src/mame/drivers/tsamurai.c
r6740r6741
4747#include "sound/ay8910.h"
4848#include "sound/dac.h"
4949
50extern UINT8 *tsamurai_videoram;
51extern UINT8 *tsamurai_colorram;
52extern UINT8 *tsamurai_bg_videoram;
53
5054WRITE8_HANDLER( vsgongf_color_w );
5155
5256WRITE8_HANDLER( tsamurai_bgcolor_w );
r6740r6741
6064WRITE8_HANDLER( tsamurai_fg_videoram_w );
6165WRITE8_HANDLER( tsamurai_fg_colorram_w );
6266extern VIDEO_START( tsamurai );
63extern UINT8 *tsamurai_videoram;
6467
6568extern VIDEO_START( vsgongf );
6669extern VIDEO_UPDATE( vsgongf );
r6740r6741
142145   AM_RANGE(0xd900, 0xd900) AM_READ(unknown_d900_r)
143146   AM_RANGE(0xd938, 0xd938) AM_READ(unknown_d938_r)
144147
145   AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(tsamurai_fg_videoram_w) AM_BASE_GENERIC(videoram)
146   AM_RANGE(0xe400, 0xe43f) AM_RAM_WRITE(tsamurai_fg_colorram_w) AM_BASE_GENERIC(colorram)
148   AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(tsamurai_fg_videoram_w) AM_BASE(&tsamurai_videoram)
149   AM_RANGE(0xe400, 0xe43f) AM_RAM_WRITE(tsamurai_fg_colorram_w) AM_BASE(&tsamurai_colorram)
147150   AM_RANGE(0xe440, 0xe7ff) AM_RAM
148   AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(tsamurai_bg_videoram_w) AM_BASE(&tsamurai_videoram)
151   AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(tsamurai_bg_videoram_w) AM_BASE(&tsamurai_bg_videoram)
149152   AM_RANGE(0xf000, 0xf3ff) AM_RAM AM_BASE_GENERIC(spriteram)
150153
151154   AM_RANGE(0xf400, 0xf400) AM_WRITENOP
r6740r6741
175178   AM_RANGE(0xd900, 0xd900) AM_READ(unknown_d900_r)
176179   AM_RANGE(0xd938, 0xd938) AM_READ(unknown_d938_r)
177180
178   AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(tsamurai_fg_videoram_w) AM_BASE_GENERIC(videoram)
179   AM_RANGE(0xe400, 0xe43f) AM_RAM_WRITE(tsamurai_fg_colorram_w) AM_BASE_GENERIC(colorram)
181   AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(tsamurai_fg_videoram_w) AM_BASE(&tsamurai_videoram)
182   AM_RANGE(0xe400, 0xe43f) AM_RAM_WRITE(tsamurai_fg_colorram_w) AM_BASE(&tsamurai_colorram)
180183   AM_RANGE(0xe440, 0xe7ff) AM_RAM
181   AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(tsamurai_bg_videoram_w) AM_BASE(&tsamurai_videoram)
184   AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(tsamurai_bg_videoram_w) AM_BASE(&tsamurai_bg_videoram)
182185   AM_RANGE(0xf000, 0xf3ff) AM_RAM AM_BASE_GENERIC(spriteram)
183186
184187   AM_RANGE(0xf400, 0xf400) AM_WRITENOP/* This is always written with F401, F402 & F403 data */
r6740r6741
335338   AM_RANGE(0xa006, 0xa006) AM_READ(vsgongf_a006_r) /* protection */
336339   AM_RANGE(0xa100, 0xa100) AM_READ(vsgongf_a100_r) /* protection */
337340   AM_RANGE(0xc000, 0xc7ff) AM_RAM                /* work ram */
338   AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(tsamurai_fg_videoram_w) AM_BASE_GENERIC(videoram)
341   AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(tsamurai_fg_videoram_w) AM_BASE(&tsamurai_videoram)
339342   AM_RANGE(0xe400, 0xe43f) AM_RAM AM_BASE_GENERIC(spriteram)
340343   AM_RANGE(0xe440, 0xe47b) AM_RAM
341344   AM_RANGE(0xe800, 0xe800) AM_WRITE(vsgongf_sound_command_w)
src/mame/drivers/f1gp.c
r6740r6741
11/***************************************************************************
22
3F-1 Grand Prix       (c) 1991 Video System Co.
3    F-1 Grand Prix       (c) 1991 Video System Co.
44
5driver by Nicola Salmoria
5    driver by Nicola Salmoria
66
7Notes:
8- The ROZ layer generator is a Konami 053936.
9- f1gp2's hardware is very similar to Lethal Crash Race, main difference
10  being an extra 68000.
7    Notes:
8    - The ROZ layer generator is a Konami 053936.
9    - f1gp2's hardware is very similar to Lethal Crash Race, main difference
10      being an extra 68000.
1111
12TODO:
13f1gp:
14- gfxctrl register not understood - handling of fg/sprite priority to fix
15  "continue" screen is just a kludge.
16f1gp2:
17- sprite lag noticeable in the animation at the end of a race (the wheels
18  of the car are sprites while the car is the fg tilemap)
12    TODO:
13    f1gp:
14    - gfxctrl register not understood - handling of fg/sprite priority to fix
15      "continue" screen is just a kludge.
16    f1gp2:
17    - sprite lag noticeable in the animation at the end of a race (the wheels
18      of the car are sprites while the car is the fg tilemap)
1919
2020***************************************************************************/
2121
2222#include "driver.h"
2323#include "cpu/z80/z80.h"
2424#include "cpu/m68000/m68000.h"
25#include "video/konamiic.h"
26#include "f1gp.h"
25#include "video/konicdev.h"
2726#include "sound/2610intf.h"
2827#include "sound/okim6295.h"
28#include "includes/f1gp.h"
2929
3030
31static UINT16 *sharedram;
32
3331static READ16_HANDLER( sharedram_r )
3432{
35   return sharedram[offset];
33   f1gp_state *state = (f1gp_state *)space->machine->driver_data;
34   return state->sharedram[offset];
3635}
3736
3837static WRITE16_HANDLER( sharedram_w )
3938{
40   COMBINE_DATA(&sharedram[offset]);
39   f1gp_state *state = (f1gp_state *)space->machine->driver_data;
40   COMBINE_DATA(&state->sharedram[offset]);
4141}
4242
4343static READ16_HANDLER( extrarom_r )
r6740r6741
4646
4747   offset *= 2;
4848
49   return rom[offset] | (rom[offset+1] << 8);
49   return rom[offset] | (rom[offset + 1] << 8);
5050}
5151
5252static READ16_HANDLER( extrarom2_r )
r6740r6741
5555
5656   offset *= 2;
5757
58   return rom[offset] | (rom[offset+1] << 8);
58   return rom[offset] | (rom[offset + 1] << 8);
5959}
6060
6161static WRITE8_HANDLER( f1gp_sh_bankswitch_w )
6262{
63   UINT8 *rom = memory_region(space->machine, "audiocpu") + 0x10000;
64
65   memory_set_bankptr(space->machine, "bank1",rom + (data & 0x01) * 0x8000);
63   memory_set_bank(space->machine, "bank1", data & 0x01);
6664}
6765
6866
69static int pending_command;
70
7167static WRITE16_HANDLER( sound_command_w )
7268{
69   f1gp_state *state = (f1gp_state *)space->machine->driver_data;
70
7371   if (ACCESSING_BITS_0_7)
7472   {
75      pending_command = 1;
73      state->pending_command = 1;
7674      soundlatch_w(space, offset, data & 0xff);
77      cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
75      cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
7876   }
7977}
8078
8179static READ16_HANDLER( command_pending_r )
8280{
83   return (pending_command ? 0xff : 0);
81   f1gp_state *state = (f1gp_state *)space->machine->driver_data;
82   return (state->pending_command ? 0xff : 0);
8483}
8584
8685static WRITE8_HANDLER( pending_command_clear_w )
8786{
88   pending_command = 0;
87   f1gp_state *state = (f1gp_state *)space->machine->driver_data;
88   state->pending_command = 0;
8989}
9090
9191
92
9392static ADDRESS_MAP_START( f1gp_cpu1_map, ADDRESS_SPACE_PROGRAM, 16 )
9493   AM_RANGE(0x000000, 0x03ffff) AM_ROM
9594   AM_RANGE(0x100000, 0x2fffff) AM_READ(extrarom_r)
9695   AM_RANGE(0xa00000, 0xbfffff) AM_READ(extrarom2_r)
9796   AM_RANGE(0xc00000, 0xc3ffff) AM_READWRITE(f1gp_zoomdata_r, f1gp_zoomdata_w)
98   AM_RANGE(0xd00000, 0xd01fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE(&f1gp_rozvideoram)
99   AM_RANGE(0xd02000, 0xd03fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE(&f1gp_rozvideoram) /* mirror */
100   AM_RANGE(0xd04000, 0xd05fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE(&f1gp_rozvideoram) /* mirror */
101   AM_RANGE(0xd06000, 0xd07fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE(&f1gp_rozvideoram) /* mirror */
102   AM_RANGE(0xe00000, 0xe03fff) AM_RAM AM_BASE(&f1gp_spr1cgram) AM_SIZE(&f1gp_spr1cgram_size)            // SPR-1 CG RAM
103   AM_RANGE(0xe04000, 0xe07fff) AM_RAM AM_BASE(&f1gp_spr2cgram) AM_SIZE(&f1gp_spr2cgram_size)            // SPR-2 CG RAM
104   AM_RANGE(0xf00000, 0xf003ff) AM_RAM AM_BASE(&f1gp_spr1vram)                                    // SPR-1 VRAM
105   AM_RANGE(0xf10000, 0xf103ff) AM_RAM AM_BASE(&f1gp_spr2vram)                                    // SPR-2 VRAM
106   AM_RANGE(0xff8000, 0xffbfff) AM_RAM                                                      // WORK RAM-1
107   AM_RANGE(0xffc000, 0xffcfff) AM_READWRITE(sharedram_r, sharedram_w) AM_BASE(&sharedram)               // DUAL RAM
108   AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(f1gp_fgvideoram_w) AM_BASE(&f1gp_fgvideoram)               // CHARACTER
97   AM_RANGE(0xd00000, 0xd01fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE_MEMBER(f1gp_state, rozvideoram)
98   AM_RANGE(0xd02000, 0xd03fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w)                       /* mirror */
99   AM_RANGE(0xd04000, 0xd05fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w)                       /* mirror */
100   AM_RANGE(0xd06000, 0xd07fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w)                       /* mirror */
101   AM_RANGE(0xe00000, 0xe03fff) AM_RAM AM_BASE_SIZE_MEMBER(f1gp_state, spr1cgram, spr1cgram_size)            // SPR-1 CG RAM
102   AM_RANGE(0xe04000, 0xe07fff) AM_RAM AM_BASE_SIZE_MEMBER(f1gp_state, spr2cgram, spr2cgram_size)            // SPR-2 CG RAM
103   AM_RANGE(0xf00000, 0xf003ff) AM_RAM AM_BASE_MEMBER(f1gp_state, spr1vram)                        // SPR-1 VRAM
104   AM_RANGE(0xf10000, 0xf103ff) AM_RAM AM_BASE_MEMBER(f1gp_state, spr2vram)                        // SPR-2 VRAM
105   AM_RANGE(0xff8000, 0xffbfff) AM_RAM                                             // WORK RAM-1
106   AM_RANGE(0xffc000, 0xffcfff) AM_READWRITE(sharedram_r, sharedram_w) AM_BASE_MEMBER(f1gp_state, sharedram)      // DUAL RAM
107   AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(f1gp_fgvideoram_w) AM_BASE_MEMBER(f1gp_state, fgvideoram)         // CHARACTER
109108   AM_RANGE(0xffe000, 0xffefff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)   // PALETTE
110109   AM_RANGE(0xfff000, 0xfff001) AM_READ_PORT("INPUTS")
111110   AM_RANGE(0xfff000, 0xfff001) AM_WRITE(f1gp_gfxctrl_w)
r6740r6741
115114   AM_RANGE(0xfff006, 0xfff007) AM_READ_PORT("DSW2")
116115   AM_RANGE(0xfff008, 0xfff009) AM_READ(command_pending_r)
117116   AM_RANGE(0xfff008, 0xfff009) AM_WRITE(sound_command_w)
118   AM_RANGE(0xfff040, 0xfff05f) AM_WRITEONLY AM_BASE(&K053936_0_ctrl)
117   AM_RANGE(0xfff040, 0xfff05f) AM_DEVWRITE("k053936", k053936_ctrl_w)
119118   AM_RANGE(0xfff050, 0xfff051) AM_READ_PORT("DSW3")
120119ADDRESS_MAP_END
121120
122121static ADDRESS_MAP_START( f1gp2_cpu1_map, ADDRESS_SPACE_PROGRAM, 16 )
123122   AM_RANGE(0x000000, 0x03ffff) AM_ROM
124123   AM_RANGE(0x100000, 0x2fffff) AM_READ(extrarom_r)
125   AM_RANGE(0xa00000, 0xa07fff) AM_RAM AM_BASE(&f1gp2_sprcgram)                                       // SPR-1 CG RAM + SPR-2 CG RAM
126   AM_RANGE(0xd00000, 0xd01fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE(&f1gp_rozvideoram)   // BACK VRAM
127   AM_RANGE(0xe00000, 0xe00fff) AM_RAM AM_BASE(&f1gp2_spritelist)                                       // not checked + SPR-1 VRAM + SPR-2 VRAM
128   AM_RANGE(0xff8000, 0xffbfff) AM_RAM                                                            // WORK RAM-1
129   AM_RANGE(0xffc000, 0xffcfff) AM_READWRITE(sharedram_r, sharedram_w) AM_BASE(&sharedram)                     // DUAL RAM
130   AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(f1gp_fgvideoram_w) AM_BASE(&f1gp_fgvideoram)                     // CHARACTER
124   AM_RANGE(0xa00000, 0xa07fff) AM_RAM AM_BASE_MEMBER(f1gp_state, sprcgram)                           // SPR-1 CG RAM + SPR-2 CG RAM
125   AM_RANGE(0xd00000, 0xd01fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE_MEMBER(f1gp_state, rozvideoram)   // BACK VRAM
126   AM_RANGE(0xe00000, 0xe00fff) AM_RAM AM_BASE_MEMBER(f1gp_state, spritelist)                     // not checked + SPR-1 VRAM + SPR-2 VRAM
127   AM_RANGE(0xff8000, 0xffbfff) AM_RAM                                                // WORK RAM-1
128   AM_RANGE(0xffc000, 0xffcfff) AM_READWRITE(sharedram_r, sharedram_w) AM_BASE_MEMBER(f1gp_state, sharedram)         // DUAL RAM
129   AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(f1gp_fgvideoram_w) AM_BASE_MEMBER(f1gp_state, fgvideoram)            // CHARACTER
131130   AM_RANGE(0xffe000, 0xffefff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)         // PALETTE
132131   AM_RANGE(0xfff000, 0xfff001) AM_READ_PORT("INPUTS") AM_WRITE(f1gp2_gfxctrl_w)
133132//  AM_RANGE(0xfff002, 0xfff003)    analog wheel?
r6740r6741
135134   AM_RANGE(0xfff006, 0xfff007) AM_READ_PORT("DSW2")
136135   AM_RANGE(0xfff008, 0xfff009) AM_READWRITE(command_pending_r, sound_command_w)
137136   AM_RANGE(0xfff00a, 0xfff00b) AM_READ_PORT("DSW3")
138   AM_RANGE(0xfff020, 0xfff02f) AM_WRITEONLY AM_BASE(&K053936_0_ctrl)
137   AM_RANGE(0xfff020, 0xfff03f) AM_DEVWRITE("k053936", k053936_ctrl_w)
139138   AM_RANGE(0xfff044, 0xfff047) AM_WRITE(f1gp_fgscroll_w)
140139ADDRESS_MAP_END
141140
r6740r6741
188187   AM_RANGE(0x000000, 0x03ffff) AM_ROM
189188   AM_RANGE(0x100000, 0x2fffff) AM_READ(extrarom_r)
190189   AM_RANGE(0xa00000, 0xbfffff) AM_READ(extrarom2_r)
191   AM_RANGE(0x800000, 0x801fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
190   AM_RANGE(0x800000, 0x801fff) AM_RAM AM_BASE_SIZE_MEMBER(f1gp_state, spriteram, spriteram_size)
192191   AM_RANGE(0xc00000, 0xc3ffff) AM_READWRITE(f1gp_zoomdata_r, f1gp_zoomdata_w)
193   AM_RANGE(0xd00000, 0xd01fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE(&f1gp_rozvideoram)
192   AM_RANGE(0xd00000, 0xd01fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w) AM_BASE_MEMBER(f1gp_state, rozvideoram)
194193   AM_RANGE(0xd02000, 0xd03fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w)   /* mirror */
195194   AM_RANGE(0xd04000, 0xd05fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w)   /* mirror */
196195   AM_RANGE(0xd06000, 0xd07fff) AM_READWRITE(f1gp_rozvideoram_r, f1gp_rozvideoram_w)   /* mirror */
r6740r6741
199198   AM_RANGE(0xf00000, 0xf003ff) AM_RAM //unused
200199   AM_RANGE(0xf10000, 0xf103ff) AM_RAM //unused
201200   AM_RANGE(0xff8000, 0xffbfff) AM_RAM
202   AM_RANGE(0xffc000, 0xffcfff) AM_READWRITE(sharedram_r, sharedram_w) AM_BASE(&sharedram)
203   AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(f1gp_fgvideoram_w) AM_BASE(&f1gp_fgvideoram)
201   AM_RANGE(0xffc000, 0xffcfff) AM_READWRITE(sharedram_r, sharedram_w) AM_BASE_MEMBER(f1gp_state, sharedram)
202   AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(f1gp_fgvideoram_w) AM_BASE_MEMBER(f1gp_state, fgvideoram)
204203   AM_RANGE(0xffe000, 0xffefff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
205204   AM_RANGE(0xfff000, 0xfff001) AM_READ_PORT("INPUTS")
206205   AM_RANGE(0xfff004, 0xfff005) AM_READ_PORT("DSW1")
207206   AM_RANGE(0xfff006, 0xfff007) AM_READ_PORT("DSW2")
208207   AM_RANGE(0xfff008, 0xfff009) AM_READNOP //?
209208   AM_RANGE(0xfff006, 0xfff007) AM_WRITENOP
210   AM_RANGE(0xfff00a, 0xfff00b) AM_RAM AM_BASE(&f1gpb_fgregs)
209   AM_RANGE(0xfff00a, 0xfff00b) AM_RAM AM_BASE_MEMBER(f1gp_state, fgregs)
211210   AM_RANGE(0xfff00e, 0xfff00f) AM_DEVREADWRITE8("oki", okim6295_r, okim6295_w, 0x00ff)
212211   AM_RANGE(0xfff00c, 0xfff00d) AM_WRITE(f1gpb_misc_w)
213212   AM_RANGE(0xfff010, 0xfff011) AM_WRITENOP
214213   AM_RANGE(0xfff020, 0xfff023) AM_RAM //?
215214   AM_RANGE(0xfff050, 0xfff051) AM_READ_PORT("DSW3")
216   AM_RANGE(0xfff800, 0xfff809) AM_RAM AM_BASE(&f1gpb_rozregs)
215   AM_RANGE(0xfff800, 0xfff809) AM_RAM AM_BASE_MEMBER(f1gp_state, rozregs)
217216ADDRESS_MAP_END
218217
219218static ADDRESS_MAP_START( f1gpb_cpu2_map, ADDRESS_SPACE_PROGRAM, 16 )
r6740r6741
410409
411410
412411
413static void irqhandler(const device_config *device, int irq)
412static void irqhandler( const device_config *device, int irq )
414413{
415   cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE);
414   f1gp_state *state = (f1gp_state *)device->machine->driver_data;
415   cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE);
416416}
417417
418418static const ym2610_interface ym2610_config =
r6740r6741
420420   irqhandler
421421};
422422
423static const k053936_interface f1gp_k053936_intf =
424{
425   1, -58, -2   /* wrap, xoff, yoff */
426};
423427
428static const k053936_interface f1gp2_k053936_intf =
429{
430   1, -48, -21   /* wrap, xoff, yoff */
431};
424432
433
434static MACHINE_START( f1gpb )
435{
436   f1gp_state *state = (f1gp_state *)machine->driver_data;
437
438   state_save_register_global(machine, state->pending_command);
439   state_save_register_global(machine, state->roz_bank);
440   state_save_register_global(machine, state->flipscreen);
441   state_save_register_global(machine, state->gfxctrl);
442   state_save_register_global_array(machine, state->scroll);
443}
444
445static MACHINE_START( f1gp )
446{
447   f1gp_state *state = (f1gp_state *)machine->driver_data;
448   UINT8 *ROM = memory_region(machine, "audiocpu");
449
450   memory_configure_bank(machine, "bank1", 0, 2, &ROM[0x10000], 0x8000);
451
452   state->audiocpu = devtag_get_device(machine, "audiocpu");
453   state->k053936 = devtag_get_device(machine, "k053936");
454
455   MACHINE_START_CALL(f1gpb);
456}
457
458static MACHINE_RESET( f1gp )
459{
460   f1gp_state *state = (f1gp_state *)machine->driver_data;
461
462   state->pending_command = 0;
463   state->roz_bank = 0;
464   state->flipscreen = 0;
465   state->gfxctrl = 0;
466   state->scroll[0] = 0;
467   state->scroll[1] = 0;
468}
469
425470static MACHINE_DRIVER_START( f1gp )
426471
472   /* driver data */
473   MDRV_DRIVER_DATA(f1gp_state)
474
427475   /* basic machine hardware */
428476   MDRV_CPU_ADD("maincpu",M68000,XTAL_20MHz/2)   /* verified on pcb */
429477   MDRV_CPU_PROGRAM_MAP(f1gp_cpu1_map)
r6740r6741
439487
440488   MDRV_QUANTUM_TIME(HZ(6000)) /* 100 CPU slices per frame */
441489
490   MDRV_MACHINE_START(f1gp)
491   MDRV_MACHINE_RESET(f1gp)
492
442493   /* video hardware */
443494   MDRV_SCREEN_ADD("screen", RASTER)
444495   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
452503   MDRV_VIDEO_START(f1gp)
453504   MDRV_VIDEO_UPDATE(f1gp)
454505
506   MDRV_K053936_ADD("k053936", f1gp_k053936_intf)
507
455508   /* sound hardware */
456509   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
457510
r6740r6741
466519
467520static MACHINE_DRIVER_START( f1gpb )
468521
522   /* driver data */
523   MDRV_DRIVER_DATA(f1gp_state)
524
469525   /* basic machine hardware */
470526   MDRV_CPU_ADD("maincpu",M68000,10000000)   /* 10 MHz ??? */
471527   MDRV_CPU_PROGRAM_MAP(f1gpb_cpu1_map)
r6740r6741
478534   /* NO sound CPU */
479535   MDRV_QUANTUM_TIME(HZ(6000)) /* 100 CPU slices per frame */
480536
537   MDRV_MACHINE_START(f1gpb)
538   MDRV_MACHINE_RESET(f1gp)
539
481540   /* video hardware */
482541   MDRV_SCREEN_ADD("screen", RASTER)
483542   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
513572   MDRV_SCREEN_MODIFY("screen")
514573   MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 0*8, 28*8-1)
515574
575   MDRV_DEVICE_REMOVE("k053936")
576   MDRV_K053936_ADD("k053936", f1gp2_k053936_intf)
577
516578   MDRV_VIDEO_START(f1gp2)
517579   MDRV_VIDEO_UPDATE(f1gp2)
518580MACHINE_DRIVER_END
r6740r6741
664726ROM_END
665727
666728
667GAME( 1991, f1gp,  0,    f1gp,  f1gp,  0, ROT90, "Video System Co.", "F-1 Grand Prix",         GAME_NO_COCKTAIL )
668GAME( 1991, f1gpb, f1gp, f1gpb, f1gp,  0, ROT90, "[Video System Co.] (Playmark bootleg)", "F-1 Grand Prix (Playmark bootleg)", GAME_NOT_WORKING ) // PCB marked 'Super Formula II', manufactured by Playmark.
729GAME( 1991, f1gp,  0,    f1gp,  f1gp,  0, ROT90, "Video System Co.", "F-1 Grand Prix", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
730GAME( 1991, f1gpb, f1gp, f1gpb, f1gp,  0, ROT90, "[Video System Co.] (Playmark bootleg)", "F-1 Grand Prix (Playmark bootleg)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) // PCB marked 'Super Formula II', manufactured by Playmark.
669731
670GAME( 1992, f1gp2, 0,    f1gp2, f1gp2, 0, ROT90, "Video System Co.", "F-1 Grand Prix Part II", GAME_NO_COCKTAIL )
671
732GAME( 1992, f1gp2, 0,    f1gp2, f1gp2, 0, ROT90, "Video System Co.", "F-1 Grand Prix Part II", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
src/mame/drivers/lvcards.c
r6740r6741
7777#include "cpu/z80/z80.h"
7878#include "sound/ay8910.h"
7979
80extern UINT8 *lvcards_videoram;
81extern UINT8 *lvcards_colorram;
8082extern WRITE8_HANDLER( lvcards_videoram_w );
8183extern WRITE8_HANDLER( lvcards_colorram_w );
8284
r6740r6741
157159static ADDRESS_MAP_START( ponttehk_map, ADDRESS_SPACE_PROGRAM, 8 )
158160   AM_RANGE(0x0000, 0x5fff) AM_ROM
159161   AM_RANGE(0x6000, 0x67ff) AM_RAM AM_BASE_SIZE_GENERIC(nvram)
160   AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(lvcards_videoram_w) AM_BASE_GENERIC(videoram)
161   AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(lvcards_colorram_w) AM_BASE_GENERIC(colorram)
162   AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(lvcards_videoram_w) AM_BASE(&lvcards_videoram)
163   AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(lvcards_colorram_w) AM_BASE(&lvcards_colorram)
162164   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")
163165   AM_RANGE(0xa001, 0xa001) AM_READ_PORT("IN1") AM_WRITENOP // lamps
164166   AM_RANGE(0xa002, 0xa002) AM_READ(payout_r) AM_WRITE(control_port_2a_w)//AM_WRITENOP // ???
r6740r6741
167169static ADDRESS_MAP_START( lvcards_map, ADDRESS_SPACE_PROGRAM, 8  )
168170   AM_RANGE(0x0000, 0x5fff) AM_ROM
169171   AM_RANGE(0x6000, 0x67ff) AM_RAM AM_BASE_SIZE_GENERIC(nvram)
170   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(lvcards_videoram_w) AM_BASE_GENERIC(videoram)
171   AM_RANGE(0x9400, 0x97ff) AM_RAM_WRITE(lvcards_colorram_w) AM_BASE_GENERIC(colorram)
172   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(lvcards_videoram_w) AM_BASE(&lvcards_videoram)
173   AM_RANGE(0x9400, 0x97ff) AM_RAM_WRITE(lvcards_colorram_w) AM_BASE(&lvcards_colorram)
172174   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")
173175   AM_RANGE(0xa001, 0xa001) AM_READ_PORT("IN1") AM_WRITENOP
174176   AM_RANGE(0xa002, 0xa002) AM_READ_PORT("IN2") AM_WRITENOP
r6740r6741
184186static ADDRESS_MAP_START( lvpoker_map, ADDRESS_SPACE_PROGRAM, 8  )
185187   AM_RANGE(0x0000, 0x5fff) AM_ROM
186188   AM_RANGE(0x6000, 0x67ff) AM_RAM AM_BASE_SIZE_GENERIC(nvram)
187   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(lvcards_videoram_w) AM_BASE_GENERIC(videoram)
188   AM_RANGE(0x9400, 0x97ff) AM_RAM_WRITE(lvcards_colorram_w) AM_BASE_GENERIC(colorram)
189   AM_RANGE(0x9000, 0x93ff) AM_RAM_WRITE(lvcards_videoram_w) AM_BASE(&lvcards_videoram)
190   AM_RANGE(0x9400, 0x97ff) AM_RAM_WRITE(lvcards_colorram_w) AM_BASE(&lvcards_colorram)
189191   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")
190192   AM_RANGE(0xa001, 0xa001) AM_READ_PORT("IN1") AM_WRITENOP // lamps
191193   AM_RANGE(0xa002, 0xa002) AM_READ(payout_r) AM_WRITE(control_port_2_w)
src/mame/drivers/namcos2.c
r6740r6741
446446#include "cpu/m68000/m68000.h"
447447#include "cpu/m6805/m6805.h"
448448#include "deprecat.h"
449#include "namcos2.h"
449#include "includes/namcos2.h"
450450#include "cpu/m6809/m6809.h"
451#include "namcoic.h"
451#include "includes/namcoic.h"
452452#include "sound/2151intf.h"
453453#include "sound/c140.h"
454454
src/mame/drivers/exzisus.c
r6740r6741
3434
3535#include "driver.h"
3636#include "cpu/z80/z80.h"
37#include "taitoipt.h"
37#include "includes/taitoipt.h"
3838#include "audio/taitosnd.h"
3939#include "sound/2151intf.h"
4040
src/mame/drivers/tx1.c
r6740r6741
4444#include "machine/8255ppi.h"
4545#include "sound/ay8910.h"
4646#include "rendlay.h"
47#include "tx1.h"
47#include "includes/tx1.h"
4848
4949#include "tx1.lh"
5050#include "buggyboy.lh"
src/mame/drivers/merit.c
r6740r6741
12931293   ROM_LOAD( "chr7.u40",   0x0000, 0x2000, CRC(52298162) SHA1(79aa6c4ab6bec6450d882615e64f61cfef934153) )
12941294ROM_END
12951295
1296ROM_START( pitbossa ) /* Program roms were hand labeled */
1296ROM_START( pitbossa )
12971297   ROM_REGION( 0x10000, "maincpu", 0 )
1298   ROM_LOAD( "pbhd.u5", 0x0000, 0x2000, CRC(97f870bd) SHA1(b1b01abff0385e3b0585e49f78b93bcf56e434ef) ) /* Games included in this set are: */
1299   ROM_LOAD( "pbhd.u6", 0x2000, 0x2000, CRC(086e699b) SHA1(a1d1eafaac9262f924f175961aa52c6d8e779bf0) ) /* Joker Poker, Blackjack, Foto Finish & The Dice Game */
1300   ROM_LOAD( "pbhd.u7", 0x4000, 0x2000, CRC(023e8cb8) SHA1(cdb180a94d801137466c13ddfaf65918cb608c5a) )
1298   ROM_LOAD( "2214-03.u5-0c", 0x0000, 0x2000, CRC(97f870bd) SHA1(b1b01abff0385e3b0585e49f78b93bcf56e434ef) ) /* Games included in this set are: */
1299   ROM_LOAD( "2214-03.u6-0",  0x2000, 0x2000, CRC(086e699b) SHA1(a1d1eafaac9262f924f175961aa52c6d8e779bf0) ) /* Joker Poker, Blackjack, Foto Finish & The Dice Game */
1300   ROM_LOAD( "2214-03.u7-0",  0x4000, 0x2000, CRC(023e8cb8) SHA1(cdb180a94d801137466c13ddfaf65918cb608c5a) ) /* Roms also found labeled simply as "PBHD" U5 through U7 */
13011301
13021302   ROM_REGION( 0x6000, "gfx1", 0 )
13031303   ROM_LOAD( "chr7.u39",   0x0000, 0x2000, CRC(6662f607) SHA1(6b423f8de011d196700839af0be37effbf87383f) ) /* Shows: */
r6740r6741
13411341
13421342ROM_START( casino5 )
13431343   ROM_REGION( 0x10000, "maincpu", 0 )
1344   ROM_LOAD( "u5",           0x0000, 0x2000, CRC(abe240d8) SHA1(296eb3251dd51147d6984a8c08c3be22e5ed8e86) )
1345   ROM_LOAD( "u6",           0x2000, 0x4000, CRC(4d9f0c57) SHA1(d19b4b4f42d329ea35907d17c15a55b954b07295) )
1346   ROM_LOAD( "u7",           0x6000, 0x4000, CRC(d3bc510d) SHA1(6222badabf629dd6334591867596f811883aed52) )
1344   ROM_LOAD( "u5", 0x0000, 0x2000, CRC(abe240d8) SHA1(296eb3251dd51147d6984a8c08c3be22e5ed8e86) )
1345   ROM_LOAD( "u6", 0x2000, 0x4000, CRC(4d9f0c57) SHA1(d19b4b4f42d329ea35907d17c15a55b954b07295) )
1346   ROM_LOAD( "u7", 0x6000, 0x4000, CRC(d3bc510d) SHA1(6222badabf629dd6334591867596f811883aed52) )
13471347
13481348   ROM_REGION( 0x6000, "gfx1", 0 )
1349   ROM_LOAD( "u39",          0x0000, 0x2000, CRC(6662f607) SHA1(6b423f8de011d196700839af0be37effbf87383f) )
1350   ROM_LOAD( "u38",          0x2000, 0x2000, CRC(a014b44f) SHA1(906d426b1de75f26030c19dcd599b6570909f510) )
1351   ROM_LOAD( "u37",          0x4000, 0x2000, CRC(cb12e139) SHA1(06fe91281faae5d0c0ae4b3cd8ad103bd3995c38) )
1349   ROM_LOAD( "chr7.u39",   0x0000, 0x2000, CRC(6662f607) SHA1(6b423f8de011d196700839af0be37effbf87383f) )
1350   ROM_LOAD( "chr7.u38",   0x2000, 0x2000, CRC(a014b44f) SHA1(906d426b1de75f26030c19dcd599b6570909f510) )
1351   ROM_LOAD( "chr7.u37",   0x4000, 0x2000, CRC(cb12e139) SHA1(06fe91281faae5d0c0ae4b3cd8ad103bd3995c38) )
13521352
13531353   ROM_REGION( 0x2000, "gfx2", 0 )
1354   ROM_LOAD( "u40",          0x0000, 0x2000, CRC(b13a3fb1) SHA1(25760aa27c88b8be248a87df724bf8797d179e7a) )
1354   ROM_LOAD( "u40", 0x0000, 0x2000, CRC(b13a3fb1) SHA1(25760aa27c88b8be248a87df724bf8797d179e7a) )
13551355ROM_END
13561356
13571357ROM_START( bigappg )
13581358   ROM_REGION( 0x10000, "maincpu", 0 )
1359   ROM_LOAD( "merit.u5",    0x0000, 0x8000, CRC(47bad6fd) SHA1(87f6c603b52e184f82179869d7b58453cbd34814) )
1359   ROM_LOAD( "2131-13_u5-0.u5", 0x0000, 0x8000, CRC(47bad6fd) SHA1(87f6c603b52e184f82179869d7b58453cbd34814) )
13601360
13611361   ROM_REGION( 0x6000, "gfx1", 0 )
1362   ROM_LOAD( "merit.u39",    0x0000, 0x2000, CRC(506e20b4) SHA1(cd28d4f56f83ed3f7cfa44280975c0a6af474707) )
1363   ROM_LOAD( "merit.u38",    0x2000, 0x2000, CRC(1924feeb) SHA1(c4656a04e2284a265554ea9774d0201c44864809) )
1364   ROM_LOAD( "merit.u37",    0x4000, 0x2000, CRC(12a04867) SHA1(8e3a6050d854ccc906ae473a104a16d610e4f1da) )
1362   ROM_LOAD( "haip_u39.u39", 0x0000, 0x2000, CRC(506e20b4) SHA1(cd28d4f56f83ed3f7cfa44280975c0a6af474707) )
1363   ROM_LOAD( "haip_u38.u38", 0x2000, 0x2000, CRC(1924feeb) SHA1(c4656a04e2284a265554ea9774d0201c44864809) )
1364   ROM_LOAD( "haip_u37.u37", 0x4000, 0x2000, CRC(12a04867) SHA1(8e3a6050d854ccc906ae473a104a16d610e4f1da) )
13651365
13661366   ROM_REGION( 0x2000, "gfx2", 0 )
1367   ROM_LOAD( "merit.u40",    0x0000, 0x2000, CRC(ac4983b8) SHA1(a552a15f813c331de67eaae2ed42cc037b26c5bd) )
1367   ROM_LOAD( "haip_u40.u40", 0x0000, 0x2000, CRC(ac4983b8) SHA1(a552a15f813c331de67eaae2ed42cc037b26c5bd) )
13681368ROM_END
13691369
13701370ROM_START( trvwzh )
r6740r6741
13781378   ROM_LOAD( "triv_1_u37.u37", 0x4000, 0x2000, CRC(f739b5dc) SHA1(fbf469b7f4cab50e06ec2def9344e3b9801a275e) )
13791379
13801380   ROM_REGION( 0x2000, "gfx2", 0 )
1381   ROM_LOAD( "triv_1_u40.u40",   0x0000, 0x2000, CRC(cea7319f) SHA1(663cd18a4699dfd5ad1d3357094eff247e9b4a47) )
1381   ROM_LOAD( "triv_1_u40.u40", 0x0000, 0x2000, CRC(cea7319f) SHA1(663cd18a4699dfd5ad1d3357094eff247e9b4a47) )
13821382
13831383   ROM_REGION( 0xa0000, "user1", ROMREGION_ERASEFF ) /* questions */
1384   ROM_LOAD( "ent-001_01a",  0x08000, 0x8000, CRC(ff45d92b) SHA1(10356bc6a04b2c53ecaf76cb0cba3ec70b4ba612) )
1384   ROM_LOAD( "ent-001_01a",  0x08000, 0x8000, CRC(ff45d92b) SHA1(10356bc6a04b2c53ecaf76cb0cba3ec70b4ba612) ) /* This set verified as all found on the same question board */
13851385   ROM_LOAD( "ent-001_02a",  0x18000, 0x8000, CRC(902e26f7) SHA1(f13b816bfc507fb429fb3f44531de346a82c780d) )
13861386   ROM_LOAD( "gen-001_01a",  0x28000, 0x8000, CRC(1d8d353f) SHA1(6bd0cc5c67da81a48737f32bc49cbf235648c4c6) )
13871387   ROM_LOAD( "gen-001_02a",  0x3c000, 0x4000, CRC(2000e3c3) SHA1(21737fde3d1a1b22da4590476e4e52ee1bab026f) ) /* 27128 eprom, others are 27256 */
1388   ROM_LOAD( "sex-001_01a",  0x48000, 0x8000, CRC(32519098) SHA1(d070e02bb10e04964893903599a69a8943f9ac8a) )
1389   ROM_LOAD( "sex-001_02a",  0x58000, 0x8000, CRC(0be4ef9a) SHA1(c80080f1c853e1043bf7e47bea322540a8ac9195) )
1388   ROM_LOAD( "spo-001_01a",  0x48000, 0x8000, CRC(ae111429) SHA1(ff551d7ac7ad367338e908805aeb78c59a747919) )
1389   ROM_LOAD( "spo-001_02a",  0x58000, 0x8000, CRC(ee9263b3) SHA1(1644ab01f17e3af1e193e509d64dcbb243d3eb80) )
1390   ROM_LOAD( "spo-001_03a",  0x68000, 0x8000, CRC(64181d34) SHA1(f84e28fc589b86ca6a596815871ed26602bcc095) )
1391   ROM_LOAD( "sex-001_01a",  0x78000, 0x8000, CRC(32519098) SHA1(d070e02bb10e04964893903599a69a8943f9ac8a) )
1392   ROM_LOAD( "sex-001_02a",  0x88000, 0x8000, CRC(0be4ef9a) SHA1(c80080f1c853e1043bf7e47bea322540a8ac9195) )
13901393ROM_END
13911394
13921395ROM_START( trvwzha )
r6740r6741
14001403   ROM_LOAD( "triv_1_u37.u37", 0x4000, 0x2000, CRC(f739b5dc) SHA1(fbf469b7f4cab50e06ec2def9344e3b9801a275e) )
14011404
14021405   ROM_REGION( 0x2000, "gfx2", 0 )
1403   ROM_LOAD( "triv_1_u40.u40",   0x0000, 0x2000, CRC(cea7319f) SHA1(663cd18a4699dfd5ad1d3357094eff247e9b4a47) )
1406   ROM_LOAD( "triv_1_u40.u40", 0x0000, 0x2000, CRC(cea7319f) SHA1(663cd18a4699dfd5ad1d3357094eff247e9b4a47) )
14041407
14051408   ROM_REGION( 0xa0000, "user1", ROMREGION_ERASEFF ) /* questions */
14061409   ROM_LOAD( "spo-001_01a",  0x08000, 0x8000, CRC(ae111429) SHA1(ff551d7ac7ad367338e908805aeb78c59a747919) )
r6740r6741
14081411   ROM_LOAD( "spo-001_03a",  0x28000, 0x8000, CRC(64181d34) SHA1(f84e28fc589b86ca6a596815871ed26602bcc095) )
14091412ROM_END
14101413
1411/* question board only - this contained a variety of roms from the 'trvwzh' and 'trvwzha' sets
1412  as well as 2 unique general knowledge ones */
1414/* question board only - this contained a variety of roms from the 'trvwzh' and 'trvwzha' sets as well as 2 unique general knowledge ones */
14131415ROM_START( trvwzhb )
14141416   ROM_REGION( 0x10000, "maincpu", 0 )
14151417   ROM_LOAD( "trivia.u5",    0x0000, 0x2000, CRC(731fd5b1) SHA1(1074780321029446da0e6765b9e036b06b067a48) )
r6740r6741
14301432
14311433ROM_START( trvwzv )
14321434   ROM_REGION( 0x10000, "maincpu", 0 )
1433   ROM_LOAD( "u5.bin",       0x0000, 0x2000, CRC(fd3531ac) SHA1(d11573df65676e704b28cc2d99fb004b48a358a4) )
1434   ROM_LOAD( "u6.bin",       0x2000, 0x2000, CRC(29e43d0e) SHA1(ad610748fe37436880648078f5d1a305cb147c5d) )
1435   ROM_LOAD( "u5.bin", 0x0000, 0x2000, CRC(fd3531ac) SHA1(d11573df65676e704b28cc2d99fb004b48a358a4) )
1436   ROM_LOAD( "u6.bin", 0x2000, 0x2000, CRC(29e43d0e) SHA1(ad610748fe37436880648078f5d1a305cb147c5d) )
14351437
14361438   ROM_REGION( 0x6000, "gfx1", 0 )
1437   ROM_LOAD( "u39",          0x0000, 0x2000, CRC(b9d9a80e) SHA1(55b6a0d09f8619df93ba936e083835c859a557df) )
1438   ROM_LOAD( "u38",          0x2000, 0x2000, CRC(8348083e) SHA1(260a4c1ae043e7ceac65a8818c23940d32275879) )
1439   ROM_LOAD( "u37",          0x4000, 0x2000, CRC(b4d3c9f4) SHA1(dda99549306519c147d275d8c6af672e80a96b67) )
1439   ROM_LOAD( "trvs_u39.u39", 0x0000, 0x2000, CRC(b9d9a80e) SHA1(55b6a0d09f8619df93ba936e083835c859a557df) )
1440   ROM_LOAD( "trvs_u38.u38", 0x2000, 0x2000, CRC(8348083e) SHA1(260a4c1ae043e7ceac65a8818c23940d32275879) )
1441   ROM_LOAD( "trvs_u37.u37", 0x4000, 0x2000, CRC(b4d3c9f4) SHA1(dda99549306519c147d275d8c6af672e80a96b67) )
14401442
14411443   ROM_REGION( 0x2000, "gfx2", 0 )
1442   ROM_LOAD( "u40.bin",      0x0000, 0x2000, CRC(1f0ff6e0) SHA1(5a31afde34aeb6f851389d093bb426e5cfdedbf2) )
1444   ROM_LOAD( "trvs_u40.u40", 0x0000, 0x2000, CRC(1f0ff6e0) SHA1(5a31afde34aeb6f851389d093bb426e5cfdedbf2) )
14431445
14441446   ROM_REGION( 0xa0000, "user1", ROMREGION_ERASEFF ) /* questions */
1445   ROM_LOAD( "ent_001_01.bin", 0x08000, 0x8000, CRC(c68ce954) SHA1(bf70fe64f095d5cfcf5347d83651b78c6c8bf05f) )
1446   ROM_LOAD( "ent_001_02.bin", 0x18000, 0x8000, CRC(aac4ff63) SHA1(d68c4408b4dad976e317a33f2a4eaee39d90dbed) )
1447   ROM_LOAD( "gen_001_01.bin", 0x28000, 0x8000, CRC(5deb1900) SHA1(b7e9407c37481ef8953e8283d45949d951302e92) )
1448   ROM_LOAD( "gen_001_02.bin", 0x3c000, 0x4000, CRC(d2b53b6a) SHA1(f75334e47885086e277682daf018818a02ce1026) ) /* 27128 eprom, others are 27256 */
1449   ROM_LOAD( "sex_001_01a",    0x48000, 0x8000, CRC(32519098) SHA1(d070e02bb10e04964893903599a69a8943f9ac8a) )
1450   ROM_LOAD( "sex_001_02a",    0x58000, 0x8000, CRC(0be4ef9a) SHA1(c80080f1c853e1043bf7e47bea322540a8ac9195) )
1447   ROM_LOAD( "ent-001_01",  0x08000, 0x8000, CRC(c68ce954) SHA1(bf70fe64f095d5cfcf5347d83651b78c6c8bf05f) )
1448   ROM_LOAD( "ent-001_02",  0x18000, 0x8000, CRC(aac4ff63) SHA1(d68c4408b4dad976e317a33f2a4eaee39d90dbed) )
1449   ROM_LOAD( "gen-001_01",  0x28000, 0x8000, CRC(5deb1900) SHA1(b7e9407c37481ef8953e8283d45949d951302e92) )
1450   ROM_LOAD( "gen-001_02",  0x3c000, 0x4000, CRC(d2b53b6a) SHA1(f75334e47885086e277682daf018818a02ce1026) ) /* 27128 eprom, others are 27256 */
1451   ROM_LOAD( "sex-001_01a", 0x48000, 0x8000, CRC(32519098) SHA1(d070e02bb10e04964893903599a69a8943f9ac8a) )
1452   ROM_LOAD( "sex-001_02a", 0x58000, 0x8000, CRC(0be4ef9a) SHA1(c80080f1c853e1043bf7e47bea322540a8ac9195) )
14511453ROM_END
14521454
14531455ROM_START( trvwzva )
14541456   ROM_REGION( 0x10000, "maincpu", 0 )
1455   ROM_LOAD( "u5.bin",       0x0000, 0x2000, CRC(fd3531ac) SHA1(d11573df65676e704b28cc2d99fb004b48a358a4) )
1456   ROM_LOAD( "u6.bin",       0x2000, 0x2000, CRC(29e43d0e) SHA1(ad610748fe37436880648078f5d1a305cb147c5d) )
1457   ROM_LOAD( "u5.bin", 0x0000, 0x2000, CRC(fd3531ac) SHA1(d11573df65676e704b28cc2d99fb004b48a358a4) )
1458   ROM_LOAD( "u6.bin", 0x2000, 0x2000, CRC(29e43d0e) SHA1(ad610748fe37436880648078f5d1a305cb147c5d) )
14571459
14581460   ROM_REGION( 0x6000, "gfx1", 0 )
1459   ROM_LOAD( "u39",          0x0000, 0x2000, CRC(b9d9a80e) SHA1(55b6a0d09f8619df93ba936e083835c859a557df) )
1460   ROM_LOAD( "u38",          0x2000, 0x2000, CRC(8348083e) SHA1(260a4c1ae043e7ceac65a8818c23940d32275879) )
1461   ROM_LOAD( "u37",          0x4000, 0x2000, CRC(b4d3c9f4) SHA1(dda99549306519c147d275d8c6af672e80a96b67) )
1461   ROM_LOAD( "trvs_u39.u39", 0x0000, 0x2000, CRC(b9d9a80e) SHA1(55b6a0d09f8619df93ba936e083835c859a557df) )
1462   ROM_LOAD( "trvs_u38.u38", 0x2000, 0x2000, CRC(8348083e) SHA1(260a4c1ae043e7ceac65a8818c23940d32275879) )
1463   ROM_LOAD( "trvs_u37.u37", 0x4000, 0x2000, CRC(b4d3c9f4) SHA1(dda99549306519c147d275d8c6af672e80a96b67) )
14621464
14631465   ROM_REGION( 0x2000, "gfx2", 0 )
1464   ROM_LOAD( "u40.bin",      0x0000, 0x2000, CRC(1f0ff6e0) SHA1(5a31afde34aeb6f851389d093bb426e5cfdedbf2) )
1466   ROM_LOAD( "trvs_u40.u40", 0x0000, 0x2000, CRC(1f0ff6e0) SHA1(5a31afde34aeb6f851389d093bb426e5cfdedbf2) )
14651467
14661468   ROM_REGION( 0xa0000, "user1", ROMREGION_ERASEFF ) /* questions */
1467   ROM_LOAD( "spo_001_01.bin", 0x08000, 0x8000, CRC(7b56315d) SHA1(4c8c63b80176bfac9594958a7043627012baada3) )
1468   ROM_LOAD( "spo_001_02.bin", 0x18000, 0x8000, CRC(148b63ee) SHA1(9f3b222d979f23b313f379cbc06cc00d88d08c56) )
1469   ROM_LOAD( "spo_001_03.bin", 0x28000, 0x8000, CRC(a6af8e41) SHA1(64f672bfa5fb2c0575103614986e53e238c5984f) )
1469   ROM_LOAD( "spo-001_01", 0x08000, 0x8000, CRC(7b56315d) SHA1(4c8c63b80176bfac9594958a7043627012baada3) )
1470   ROM_LOAD( "spo-001_02", 0x18000, 0x8000, CRC(148b63ee) SHA1(9f3b222d979f23b313f379cbc06cc00d88d08c56) )
1471   ROM_LOAD( "spo-001_03", 0x28000, 0x8000, CRC(a6af8e41) SHA1(64f672bfa5fb2c0575103614986e53e238c5984f) )
14701472ROM_END
14711473
14721474ROM_START( trvwz2 )
14731475   ROM_REGION( 0x10000, "maincpu", 0 )
1474   ROM_LOAD( "u5_0e",        0x0000, 0x2000, CRC(97b8d320) SHA1(573945531113d8aae9418ba1e9a2063052227029) )
1475   ROM_LOAD( "u6_0e",        0x2000, 0x2000, CRC(2e86288d) SHA1(62c7024d8dfebed9bb05ea91302efe5d18cb7d2a) )
1476   ROM_LOAD( "6221-05_u5-0e.u5", 0x0000, 0x2000, CRC(97b8d320) SHA1(573945531113d8aae9418ba1e9a2063052227029) )
1477   ROM_LOAD( "6221-05_u6-0e.u6", 0x2000, 0x2000, CRC(2e86288d) SHA1(62c7024d8dfebed9bb05ea91302efe5d18cb7d2a) )
14761478
14771479   ROM_REGION( 0x6000, "gfx1", 0 )
1478   ROM_LOAD( "u39",          0x0000, 0x2000, CRC(b9d9a80e) SHA1(55b6a0d09f8619df93ba936e083835c859a557df) )
1479   ROM_LOAD( "u38",          0x2000, 0x2000, CRC(8348083e) SHA1(260a4c1ae043e7ceac65a8818c23940d32275879) )
1480   ROM_LOAD( "u37",          0x4000, 0x2000, CRC(b4d3c9f4) SHA1(dda99549306519c147d275d8c6af672e80a96b67) )
1480   ROM_LOAD( "trvs_u39.u39", 0x0000, 0x2000, CRC(b9d9a80e) SHA1(55b6a0d09f8619df93ba936e083835c859a557df) )
1481   ROM_LOAD( "trvs_u38.u38", 0x2000, 0x2000, CRC(8348083e) SHA1(260a4c1ae043e7ceac65a8818c23940d32275879) )
1482   ROM_LOAD( "trvs_u37.u37", 0x4000, 0x2000, CRC(b4d3c9f4) SHA1(dda99549306519c147d275d8c6af672e80a96b67) )
14811483
14821484   ROM_REGION( 0x2000, "gfx2", 0 )
1483   ROM_LOAD( "u40a",        0x0000, 0x2000, CRC(fbfae092) SHA1(b8569819952a5c805f11b6854d64b3ae9c857f97) )
1485   ROM_LOAD( "trvs_u40a.u40", 0x0000, 0x2000, CRC(fbfae092) SHA1(b8569819952a5c805f11b6854d64b3ae9c857f97) )
14841486
14851487   ROM_REGION( 0xa0000, "user1", ROMREGION_ERASEFF ) /* questions */
1486   ROM_LOAD( "ent_101.01a",  0x08000, 0x8000, CRC(3825ac47) SHA1(d0da047c4d30a26f496b3663cfda77c229279be8) )
1487   ROM_LOAD( "ent_101.02a",  0x18000, 0x8000, CRC(a0153407) SHA1(e669957a5d4775bfa2c16960a2a909a3505c078b) )
1488   ROM_LOAD( "ent_101.03a",  0x28000, 0x8000, CRC(755b16ab) SHA1(277ea4110479ecdb2c772299ea04f4918cf7f561) )
1489   ROM_LOAD( "gen_101.01a",  0x38000, 0x8000, CRC(74d14039) SHA1(54b85581d60fb535d37a051f375e687a933600ea) )
1490   ROM_LOAD( "gen_101.02a",  0x48000, 0x8000, CRC(b1b930d8) SHA1(57be3ee1c0adcb549088818dc7efda64508b5647) )
1491   ROM_LOAD( "spo_101.01a",  0x58000, 0x8000, CRC(9dc4ba98) SHA1(4ce2bbbd7436a0ba8140879d5d8614bddbd5a8ec) )
1492   ROM_LOAD( "spo_101.02a",  0x68000, 0x8000, CRC(9c106ad9) SHA1(1d1a5c91152283e3937a2df17cd57b8fe04072b7) )
1493   ROM_LOAD( "spo_101.03a",  0x78000, 0x8000, CRC(3d69c3a3) SHA1(9f16d45660f3cb15e44e9fc0d940a7b2b12819e8) )
1488   ROM_LOAD( "ent-101.01a",  0x08000, 0x8000, CRC(3825ac47) SHA1(d0da047c4d30a26f496b3663cfda77c229279be8) ) /* This set verified as all found on the same question board */
1489   ROM_LOAD( "ent-101.02a",  0x18000, 0x8000, CRC(a0153407) SHA1(e669957a5d4775bfa2c16960a2a909a3505c078b) )
1490   ROM_LOAD( "ent-101.03a",  0x28000, 0x8000, CRC(755b16ab) SHA1(277ea4110479ecdb2c772299ea04f4918cf7f561) )
1491   ROM_LOAD( "gen-101.01a",  0x38000, 0x8000, CRC(74d14039) SHA1(54b85581d60fb535d37a051f375e687a933600ea) )
1492   ROM_LOAD( "gen-101.02a",  0x48000, 0x8000, CRC(b1b930d8) SHA1(57be3ee1c0adcb549088818dc7efda64508b5647) ) /* These question roms have been found with the "trvwz3ha"    */
1493   ROM_LOAD( "spo-101.01a",  0x58000, 0x8000, CRC(9dc4ba98) SHA1(4ce2bbbd7436a0ba8140879d5d8614bddbd5a8ec) ) /* program & CHAR roms and might actually be an Edition 3 set */
1494   ROM_LOAD( "spo-101.02a",  0x68000, 0x8000, CRC(9c106ad9) SHA1(1d1a5c91152283e3937a2df17cd57b8fe04072b7) )
1495   ROM_LOAD( "spo-101.03a",  0x78000, 0x8000, CRC(3d69c3a3) SHA1(9f16d45660f3cb15e44e9fc0d940a7b2b12819e8) )
14941496   ROM_LOAD( "sex-101.01a",  0x88000, 0x8000, CRC(301d65c2) SHA1(48d260077e9c9ed82f6dfa176b1103723dc9e19a) )
14951497   ROM_LOAD( "sex-101.02a",  0x98000, 0x8000, CRC(2596091b) SHA1(7fbb9c2c3f74e12714513928c8cf3769bf29fc8b) )
1498
1499   ROM_REGION( 0x0100, "prom", 0 )
1500   ROM_LOAD( "sc-002", 0x00000, 0x0100, CRC(94a8da8a) SHA1(8bdaee436481418425c36de24477c96ec0787916) ) /* N82S129N BPROM found on question board, unknown use */
14961501ROM_END
14971502
1498/* questions only - this dump contained a variety of questions from the 'trvwz2' ones above,
1499 and 2 unique roms, which are Sex Trivia */
1503/* questions only - this dump contained a variety of questions from the 'trvwz2' ones above, and 2 unique roms, which are Sex Trivia */
15001504ROM_START( trvwz2a )
15011505   ROM_REGION( 0x10000, "maincpu", 0 )
1502   ROM_LOAD( "u5_0e",        0x0000, 0x2000, CRC(97b8d320) SHA1(573945531113d8aae9418ba1e9a2063052227029) )
1503   ROM_LOAD( "u6_0e",        0x2000, 0x2000, CRC(2e86288d) SHA1(62c7024d8dfebed9bb05ea91302efe5d18cb7d2a) )
1506   ROM_LOAD( "6221-05_u5-0e.u5", 0x0000, 0x2000, CRC(97b8d320) SHA1(573945531113d8aae9418ba1e9a2063052227029) )
1507   ROM_LOAD( "6221-05_u6-0e.u6", 0x2000, 0x2000, CRC(2e86288d) SHA1(62c7024d8dfebed9bb05ea91302efe5d18cb7d2a) )
15041508
15051509   ROM_REGION( 0x6000, "gfx1", 0 )
1506   ROM_LOAD( "u39",          0x0000, 0x2000, CRC(b9d9a80e) SHA1(55b6a0d09f8619df93ba936e083835c859a557df) )
1507   ROM_LOAD( "u38",          0x2000, 0x2000, CRC(8348083e) SHA1(260a4c1ae043e7ceac65a8818c23940d32275879) )
1508   ROM_LOAD( "u37",          0x4000, 0x2000, CRC(b4d3c9f4) SHA1(dda99549306519c147d275d8c6af672e80a96b67) )
1510   ROM_LOAD( "trvs_u39.u39", 0x0000, 0x2000, CRC(b9d9a80e) SHA1(55b6a0d09f8619df93ba936e083835c859a557df) )
1511   ROM_LOAD( "trvs_u38.u38", 0x2000, 0x2000, CRC(8348083e) SHA1(260a4c1ae043e7ceac65a8818c23940d32275879) )
1512   ROM_LOAD( "trvs_u37.u37", 0x4000, 0x2000, CRC(b4d3c9f4) SHA1(dda99549306519c147d275d8c6af672e80a96b67) )
15091513
15101514   ROM_REGION( 0x2000, "gfx2", 0 )
1511   ROM_LOAD( "u40a",        0x0000, 0x2000, CRC(fbfae092) SHA1(b8569819952a5c805f11b6854d64b3ae9c857f97) )
1515   ROM_LOAD( "trvs_u40a.u40", 0x0000, 0x2000, CRC(fbfae092) SHA1(b8569819952a5c805f11b6854d64b3ae9c857f97) )
15121516
15131517   ROM_REGION( 0xa0000, "user1", ROMREGION_ERASEFF ) /* questions */
15141518   ROM_LOAD( "merit2_4.0",  0x08000, 0x8000, CRC(069b59a3) SHA1(e3d75edd3a9271df73bf51f409f066547025abbe) ) // Sex Trivia
r6740r6741
15171521
15181522ROM_START( trvwz3h )
15191523   ROM_REGION( 0x10000, "maincpu", 0 )
1520   ROM_LOAD( "u5",           0x0000, 0x2000, CRC(ad4ab519) SHA1(80e99f4e5542115e34074b41bbc69906e01a408f) )
1521   ROM_LOAD( "u6",           0x2000, 0x2000, CRC(21a44014) SHA1(331f8b4fa3f837de070b68b959c818122aedc68a) )
1524   ROM_LOAD( "u5", 0x0000, 0x2000, CRC(ad4ab519) SHA1(80e99f4e5542115e34074b41bbc69906e01a408f) )
1525   ROM_LOAD( "u6", 0x2000, 0x2000, CRC(21a44014) SHA1(331f8b4fa3f837de070b68b959c818122aedc68a) )
15221526
15231527   ROM_REGION( 0x6000, "gfx1", 0 )
15241528   ROM_LOAD( "triv_1_u39.u39", 0x0000, 0x2000, CRC(f8a5f5fb) SHA1(a511e1a2b5e887ef00dc919e9e664ccec2d36cfa) )
r6740r6741
15261530   ROM_LOAD( "triv_1_u37.u37", 0x4000, 0x2000, CRC(f739b5dc) SHA1(fbf469b7f4cab50e06ec2def9344e3b9801a275e) )
15271531
15281532   ROM_REGION( 0x2000, "gfx2", 0 )
1529   ROM_LOAD( "u40",          0x0000, 0x2000, CRC(e829473f) SHA1(ba754d9377d955b409970494e1a14dbe1d359ee5) )
1533   ROM_LOAD( "triv_1_u40b.u40", 0x0000, 0x2000, CRC(e829473f) SHA1(ba754d9377d955b409970494e1a14dbe1d359ee5) )
15301534
15311535   ROM_REGION( 0xa0000, "user1", ROMREGION_ERASEFF ) /* questions */
1532   ROM_LOAD( "7",            0x08000, 0x8000, CRC(974dca96) SHA1(eb4a745c84307a1bbb220659877f97c28cd515ac) )
1533   ROM_LOAD( "8",            0x18000, 0x8000, CRC(e15ef8d0) SHA1(51c946311ffe507aa9031044bc34e5ae8d3473ab) )
1534   ROM_LOAD( "9",            0x28000, 0x8000, CRC(503115a1) SHA1(5e6630191465b3d2a590fab08b4f47f7408ecc44) )
1535   ROM_LOAD( "10",           0x38000, 0x8000, CRC(0e4fe73d) SHA1(9aee22a5837637ec5e360b72e71555942df1d26f) )
1536   ROM_LOAD( "11",           0x48000, 0x8000, CRC(f56c0935) SHA1(8e16133ad90829bbc0e0f2e9ee9c26e9d0c5057e) )
1537   ROM_LOAD( "12",           0x58000, 0x8000, CRC(057f6676) SHA1(a93a7a76fc8b8263568a50b00a57f3abe76c9aa3) )
1538   ROM_LOAD( "13",           0x68000, 0x8000, CRC(1fa46b86) SHA1(16d54d0932fe342399faf303eafa3c0b7ba2e202) )
1539   ROM_LOAD( "14",           0x78000, 0x8000, CRC(b395cd97) SHA1(a42c7c1687eaba64a725888cd6413568cc90b010) )
1540   ROM_LOAD( "sex-001_02",   0x88000, 0x8000, CRC(b064876b) SHA1(588300fb6603f334de41a9685b1fcf8c642b5c16) )
1536   ROM_LOAD( "spo-002_01", 0x08000, 0x8000, CRC(974dca96) SHA1(eb4a745c84307a1bbb220659877f97c28cd515ac) )
1537   ROM_LOAD( "spo-002_02", 0x18000, 0x8000, CRC(e15ef8d0) SHA1(51c946311ffe507aa9031044bc34e5ae8d3473ab) )
1538   ROM_LOAD( "spo-002_03", 0x28000, 0x8000, CRC(503115a1) SHA1(5e6630191465b3d2a590fab08b4f47f7408ecc44) )
1539   ROM_LOAD( "ent-002_01", 0x38000, 0x8000, CRC(0e4fe73d) SHA1(9aee22a5837637ec5e360b72e71555942df1d26f) )
1540   ROM_LOAD( "ent-002_02", 0x48000, 0x8000, CRC(f56c0935) SHA1(8e16133ad90829bbc0e0f2e9ee9c26e9d0c5057e) )
1541   ROM_LOAD( "ent-002_03", 0x58000, 0x8000, CRC(057f6676) SHA1(a93a7a76fc8b8263568a50b00a57f3abe76c9aa3) )
1542   ROM_LOAD( "gen-002_02", 0x68000, 0x8000, CRC(1fa46b86) SHA1(16d54d0932fe342399faf303eafa3c0b7ba2e202) )
1543   ROM_LOAD( "gen-002_02", 0x78000, 0x8000, CRC(b395cd97) SHA1(a42c7c1687eaba64a725888cd6413568cc90b010) )
1544   ROM_LOAD( "sex-001_02", 0x88000, 0x8000, CRC(b064876b) SHA1(588300fb6603f334de41a9685b1fcf8c642b5c16) ) /* Does this one actually belong here? */
1545
1546   ROM_REGION( 0x0100, "prom", 0 )
1547   ROM_LOAD( "sc-002", 0x00000, 0x0100, CRC(94a8da8a) SHA1(8bdaee436481418425c36de24477c96ec0787916) ) /* N82S129N BPROM found on question board, unknown use */
1548
1549   ROM_REGION( 0x8000, "misc", 0 )
1550   ROM_LOAD( "dec002.u13", 0x00000, 0x01f3, CRC(686d2ad0) SHA1(7aad0a1ed09942528eceaf4d7a5e1fd7601aeac7) ) /* PAL10L8CN */
1551   ROM_LOAD( "sex-001_01", 0x00000, 0x8000, CRC(77a2a734) SHA1(7ba662d275b7914c9dcc9532116086e091e6cf88) ) /* These seem to be misplaced? Verfied good dumps, not */
1552   ROM_LOAD( "sex-001_02", 0x00000, 0x8000, CRC(b064876b) SHA1(588300fb6603f334de41a9685b1fcf8c642b5c16) ) /* sure which set they actually belong to, maybe trvwzv */
15411553ROM_END
15421554
15431555ROM_START( trvwz3v )
15441556   ROM_REGION( 0x10000, "maincpu", 0 )
1545   ROM_LOAD( "u5",    0x0000, 0x2000, CRC(97b8d320) SHA1(573945531113d8aae9418ba1e9a2063052227029) )
1546   ROM_LOAD( "u6",    0x2000, 0x2000, CRC(2e86288d) SHA1(62c7024d8dfebed9bb05ea91302efe5d18cb7d2a) )
1557   ROM_LOAD( "6221-05_u5-0e.u5", 0x0000, 0x2000, CRC(97b8d320) SHA1(573945531113d8aae9418ba1e9a2063052227029) )
1558   ROM_LOAD( "6221-05_u6-0e.u6", 0x2000, 0x2000, CRC(2e86288d) SHA1(62c7024d8dfebed9bb05ea91302efe5d18cb7d2a) )
15471559
15481560   ROM_REGION( 0x6000, "gfx1", 0 )
1549   ROM_LOAD( "u39",   0x0000, 0x2000, CRC(b9d9a80e) SHA1(55b6a0d09f8619df93ba936e083835c859a557df) )
1550   ROM_LOAD( "u38",   0x2000, 0x2000, CRC(8348083e) SHA1(260a4c1ae043e7ceac65a8818c23940d32275879) )
1551   ROM_LOAD( "u37",   0x4000, 0x2000, CRC(b4d3c9f4) SHA1(dda99549306519c147d275d8c6af672e80a96b67) )
1561   ROM_LOAD( "trvs_u39.u39", 0x0000, 0x2000, CRC(b9d9a80e) SHA1(55b6a0d09f8619df93ba936e083835c859a557df) )
1562   ROM_LOAD( "trvs_u38.u38", 0x2000, 0x2000, CRC(8348083e) SHA1(260a4c1ae043e7ceac65a8818c23940d32275879) )
1563   ROM_LOAD( "trvs_u37.u37", 0x4000, 0x2000, CRC(b4d3c9f4) SHA1(dda99549306519c147d275d8c6af672e80a96b67) )
15521564
15531565   ROM_REGION( 0x2000, "gfx2", 0 )
1554   ROM_LOAD( "u40",  0x0000, 0x2000, CRC(fbfae092) SHA1(b8569819952a5c805f11b6854d64b3ae9c857f97) )
1566   ROM_LOAD( "trvs_u40a.u40", 0x0000, 0x2000, CRC(fbfae092) SHA1(b8569819952a5c805f11b6854d64b3ae9c857f97) )
15551567
15561568   ROM_REGION( 0xa0000, "user1", ROMREGION_ERASEFF ) /* questions */
1557   ROM_LOAD( "10",    0x08000, 0x8000, CRC(15d16703) SHA1(9184f63669e9ec93e88276777e1b7f209543c3e3) )
1558   ROM_LOAD( "8",     0x18000, 0x8000, CRC(647f3394) SHA1(636647ae620fd2f985b82e3516451e3bffd44040) )
1559   ROM_LOAD( "7",     0x28000, 0x8000, CRC(974dca96) SHA1(eb4a745c84307a1bbb220659877f97c28cd515ac) )
1560   ROM_LOAD( "6",     0x38000, 0x8000, CRC(e15ef8d0) SHA1(51c946311ffe507aa9031044bc34e5ae8d3473ab) )
1561   ROM_LOAD( "5",     0x48000, 0x8000, CRC(503115a1) SHA1(5e6630191465b3d2a590fab08b4f47f7408ecc44) )
1562   ROM_LOAD( "4",     0x58000, 0x8000, CRC(0e4fe73d) SHA1(9aee22a5837637ec5e360b72e71555942df1d26f) )
1563   ROM_LOAD( "3",     0x68000, 0x8000, CRC(f56c0935) SHA1(8e16133ad90829bbc0e0f2e9ee9c26e9d0c5057e) )
1564   ROM_LOAD( "2",     0x78000, 0x8000, CRC(057f6676) SHA1(a93a7a76fc8b8263568a50b00a57f3abe76c9aa3) )
1565   ROM_LOAD( "1",     0x88000, 0x8000, CRC(1fa46b86) SHA1(16d54d0932fe342399faf303eafa3c0b7ba2e202) )
1566   ROM_LOAD( "0",     0x98000, 0x8000, CRC(b395cd97) SHA1(a42c7c1687eaba64a725888cd6413568cc90b010) )
1569   ROM_LOAD( "10",         0x08000, 0x8000, CRC(15d16703) SHA1(9184f63669e9ec93e88276777e1b7f209543c3e3) ) /* Actual label unknown */
1570   ROM_LOAD( "8",          0x18000, 0x8000, CRC(647f3394) SHA1(636647ae620fd2f985b82e3516451e3bffd44040) ) /* Actual label unknown */
1571   ROM_LOAD( "spo-002_01", 0x28000, 0x8000, CRC(974dca96) SHA1(eb4a745c84307a1bbb220659877f97c28cd515ac) )
1572   ROM_LOAD( "spo-002_02", 0x38000, 0x8000, CRC(e15ef8d0) SHA1(51c946311ffe507aa9031044bc34e5ae8d3473ab) )
1573   ROM_LOAD( "spo-002_03", 0x48000, 0x8000, CRC(503115a1) SHA1(5e6630191465b3d2a590fab08b4f47f7408ecc44) )
1574   ROM_LOAD( "ent-002_01", 0x58000, 0x8000, CRC(0e4fe73d) SHA1(9aee22a5837637ec5e360b72e71555942df1d26f) )
1575   ROM_LOAD( "ent-002_02", 0x68000, 0x8000, CRC(f56c0935) SHA1(8e16133ad90829bbc0e0f2e9ee9c26e9d0c5057e) )
1576   ROM_LOAD( "ent-002_03", 0x78000, 0x8000, CRC(057f6676) SHA1(a93a7a76fc8b8263568a50b00a57f3abe76c9aa3) )
1577   ROM_LOAD( "gen-002_02", 0x88000, 0x8000, CRC(1fa46b86) SHA1(16d54d0932fe342399faf303eafa3c0b7ba2e202) )
1578   ROM_LOAD( "gen-002_02", 0x98000, 0x8000, CRC(b395cd97) SHA1(a42c7c1687eaba64a725888cd6413568cc90b010) )
1579
1580   ROM_REGION( 0x0100, "prom", 0 )
1581   ROM_LOAD( "sc-002", 0x00000, 0x0100, CRC(94a8da8a) SHA1(8bdaee436481418425c36de24477c96ec0787916) ) /* N82S129N BPROM found on question board, unknown use */
15671582ROM_END
15681583
15691584ROM_START( trvwz3ha )
15701585   ROM_REGION( 0x10000, "maincpu", 0 )
1571   ROM_LOAD( "6221-04_u5-0c", 0x0000, 0x2000, CRC(e0a07f06) SHA1(02cde0fc4a62d108ecd3e2f7704b9166c31707f2) )
1572   ROM_LOAD( "6221-04_u6-0c", 0x2000, 0x2000, CRC(223482d6) SHA1(4d9dbce7505b98ccd8e2b55f6f86a59b213d72a1) )
1586   ROM_LOAD( "6221-04_u5-0c", 0x0000, 0x2000, CRC(e0a07f06) SHA1(02cde0fc4a62d108ecd3e2f7704b9166c31707f2) ) /* Also found labeled as "6221-04 U5-0D" */
1587   ROM_LOAD( "6221-04_u6-0c", 0x2000, 0x2000, CRC(223482d6) SHA1(4d9dbce7505b98ccd8e2b55f6f86a59b213d72a1) ) /* Also found labeled as "6221-04 U6-0D" */
15731588
15741589   ROM_REGION( 0x6000, "gfx1", 0 )
15751590   ROM_LOAD( "triv_1_u39.u39", 0x0000, 0x2000, CRC(f8a5f5fb) SHA1(a511e1a2b5e887ef00dc919e9e664ccec2d36cfa) )
r6740r6741
15771592   ROM_LOAD( "triv_1_u37.u37", 0x4000, 0x2000, CRC(f739b5dc) SHA1(fbf469b7f4cab50e06ec2def9344e3b9801a275e) )
15781593
15791594   ROM_REGION( 0x2000, "gfx2", 0 )
1580   ROM_LOAD( "merit6.u40",          0x0000, 0x2000, CRC(e829473f) SHA1(ba754d9377d955b409970494e1a14dbe1d359ee5) )
1595   ROM_LOAD( "triv_1_u40b.u40", 0x0000, 0x2000, CRC(e829473f) SHA1(ba754d9377d955b409970494e1a14dbe1d359ee5) )
15811596
15821597   ROM_REGION( 0xa0000, "user1", ROMREGION_ERASEFF ) /* questions */
1583   ROM_LOAD( "merit6.9",   0x08000, 0x8000, CRC(974dca96) SHA1(eb4a745c84307a1bbb220659877f97c28cd515ac) )
1584   ROM_LOAD( "merit6.8",   0x18000, 0x8000, CRC(503115a1) SHA1(5e6630191465b3d2a590fab08b4f47f7408ecc44) )
1585   ROM_LOAD( "merit6.6",   0x28000, 0x8000, CRC(0e4fe73d) SHA1(9aee22a5837637ec5e360b72e71555942df1d26f) )
1586   ROM_LOAD( "merit6.5",   0x38000, 0x8000, CRC(f56c0935) SHA1(8e16133ad90829bbc0e0f2e9ee9c26e9d0c5057e) )
1587   ROM_LOAD( "merit6.7",   0x48000, 0x8000, CRC(057f6676) SHA1(a93a7a76fc8b8263568a50b00a57f3abe76c9aa3) )
1588   ROM_LOAD( "merit6.0",   0x58000, 0x8000, CRC(1fa46b86) SHA1(16d54d0932fe342399faf303eafa3c0b7ba2e202) )
1589   ROM_LOAD( "merit6.3",   0x68000, 0x8000, CRC(b395cd97) SHA1(a42c7c1687eaba64a725888cd6413568cc90b010) )
1590   ROM_LOAD( "sex-001_02", 0x78000, 0x8000, CRC(b064876b) SHA1(588300fb6603f334de41a9685b1fcf8c642b5c16) )
1598   ROM_LOAD( "spo-002_01", 0x08000, 0x8000, CRC(974dca96) SHA1(eb4a745c84307a1bbb220659877f97c28cd515ac) ) /* This set verified as all found on the same question board */
1599   ROM_LOAD( "spo-002_02", 0x18000, 0x8000, CRC(e15ef8d0) SHA1(51c946311ffe507aa9031044bc34e5ae8d3473ab) )
1600   ROM_LOAD( "spo-002_03", 0x28000, 0x8000, CRC(503115a1) SHA1(5e6630191465b3d2a590fab08b4f47f7408ecc44) )
1601   ROM_LOAD( "ent-002_01", 0x38000, 0x8000, CRC(0e4fe73d) SHA1(9aee22a5837637ec5e360b72e71555942df1d26f) )
1602   ROM_LOAD( "ent-002_02", 0x48000, 0x8000, CRC(f56c0935) SHA1(8e16133ad90829bbc0e0f2e9ee9c26e9d0c5057e) )
1603   ROM_LOAD( "ent-002_03", 0x58000, 0x8000, CRC(057f6676) SHA1(a93a7a76fc8b8263568a50b00a57f3abe76c9aa3) )
1604   ROM_LOAD( "gen-002_01", 0x68000, 0x8000, CRC(1fa46b86) SHA1(16d54d0932fe342399faf303eafa3c0b7ba2e202) )
1605   ROM_LOAD( "gen-002_02", 0x78000, 0x8000, CRC(b395cd97) SHA1(a42c7c1687eaba64a725888cd6413568cc90b010) )
1606   ROM_LOAD( "sex-002_03", 0x88000, 0x8000, CRC(2f37dcb0) SHA1(e96eeabfa62c0a56c2f888cf1abdfdcb059572c6) )
1607   ROM_LOAD( "sex-002_04", 0x98000, 0x8000, CRC(20bf245e) SHA1(1286fd2eb51c6125a7560da3e2390ec51b64fb43) )
15911608
1592   ROM_REGION( 0x8000, "misc", 0 )
1593   ROM_LOAD( "merit6.u13",         0x00000, 0x1f3, CRC(686d2ad0) SHA1(7aad0a1ed09942528eceaf4d7a5e1fd7601aeac7) )
1594   ROM_LOAD( "sex-001_01",         0x00000, 0x8000, CRC(77a2a734) SHA1(7ba662d275b7914c9dcc9532116086e091e6cf88) ) // should be a question rom, but doesn't work, bad, or from a different game?
1609   ROM_REGION( 0x0100, "prom", 0 )
1610   ROM_LOAD( "sc-002", 0x00000, 0x0100, CRC(94a8da8a) SHA1(8bdaee436481418425c36de24477c96ec0787916) ) /* N82S129N BPROM found on question board, unknown use */
1611
1612   ROM_REGION( 0x200, "misc", 0 )
1613   ROM_LOAD( "dec002.u13", 0x00000, 0x01f3, CRC(686d2ad0) SHA1(7aad0a1ed09942528eceaf4d7a5e1fd7601aeac7) )
15951614ROM_END
15961615
15971616ROM_START( trvwz4 )
15981617   ROM_REGION( 0x10000, "maincpu", 0 )
1599   ROM_LOAD( "u5.bin",       0x0000, 0x8000, CRC(bc23a1ab) SHA1(b9601f316e373c568c5b208de417617094046559) )
1618   ROM_LOAD( "u5.bin", 0x0000, 0x8000, CRC(bc23a1ab) SHA1(b9601f316e373c568c5b208de417617094046559) )
16001619
16011620   ROM_REGION( 0x6000, "gfx1", 0 )
1602   ROM_LOAD( "u39.bin",      0x0000, 0x2000, CRC(b9d9a80e) SHA1(55b6a0d09f8619df93ba936e083835c859a557df) )
1603   ROM_LOAD( "u38.bin",      0x2000, 0x2000, CRC(8348083e) SHA1(260a4c1ae043e7ceac65a8818c23940d32275879) )
1604   ROM_LOAD( "u37.bin",      0x4000, 0x2000, CRC(b4d3c9f4) SHA1(dda99549306519c147d275d8c6af672e80a96b67) )
1621   ROM_LOAD( "trvs_u39.u39", 0x0000, 0x2000, CRC(b9d9a80e) SHA1(55b6a0d09f8619df93ba936e083835c859a557df) )
1622   ROM_LOAD( "trvs_u38.u38", 0x2000, 0x2000, CRC(8348083e) SHA1(260a4c1ae043e7ceac65a8818c23940d32275879) )
1623   ROM_LOAD( "trvs_u37.u37", 0x4000, 0x2000, CRC(b4d3c9f4) SHA1(dda99549306519c147d275d8c6af672e80a96b67) )
16051624
16061625   ROM_REGION( 0x2000, "gfx2", 0 )
1607   ROM_LOAD( "u40.bin",      0x0000, 0x2000, CRC(fbfae092) SHA1(b8569819952a5c805f11b6854d64b3ae9c857f97) )
1626   ROM_LOAD( "trvs_u40a.u40", 0x0000, 0x2000, CRC(fbfae092) SHA1(b8569819952a5c805f11b6854d64b3ae9c857f97) )
16081627
16091628   ROM_REGION( 0xa0000, "user1", ROMREGION_ERASEFF ) /* questions */
16101629   ROM_LOAD( "ent_4_1.bin",  0x08000, 0x8000, CRC(1b317149) SHA1(94e882e9cc041ac8f292136c1ce2d21340ac5e7f) )
16111630   ROM_LOAD( "ent_4_2.bin",  0x18000, 0x8000, CRC(43d51697) SHA1(7af3f16f9519184ae63d8818bbc52a2ba897f275) )
1612   ROM_LOAD( "rnp_4_1.bin",  0x28000, 0x8000, CRC(e54fc4bc) SHA1(4607974ed2bf83c475396fc1cbb1e09ad084ace8) )
1613   ROM_LOAD( "rnp_4_2.bin",  0x38000, 0x8000, CRC(fee2d0b0) SHA1(9c9abec4ce693fc2d3976f3d499213c2ce67c197) )
1631   ROM_LOAD( "tw4-05_rnp-1", 0x28000, 0x8000, CRC(fee2d0b0) SHA1(9c9abec4ce693fc2d3976f3d499213c2ce67c197) )
1632   ROM_LOAD( "tw4-05_rnp-2", 0x38000, 0x8000, CRC(e54fc4bc) SHA1(4607974ed2bf83c475396fc1cbb1e09ad084ace8) )
16141633   ROM_LOAD( "sbt_4_1.bin",  0x48000, 0x8000, CRC(f1560804) SHA1(2ef0d587fbedfc342a12e913fa3c94eb8d67e2c5) )
16151634   ROM_LOAD( "sbt_4_2.bin",  0x58000, 0x8000, CRC(b0d6f6b2) SHA1(b08622d3775d1bb40c3b07ef932f3db4166ee284) )
16161635   ROM_LOAD( "sex_4_1.bin",  0x68000, 0x8000, CRC(976352b0) SHA1(5f89caca410704ba8a90da3167ba18e45fb21d43) )
16171636   ROM_LOAD( "sex_4_2.bin",  0x78000, 0x8000, CRC(5f148bc9) SHA1(2fd2cf819c2f395dcffad59857b3533fe3cce60b) )
1618   ROM_LOAD( "spo_4_1.bin",  0x88000, 0x8000, CRC(5fe0c6a3) SHA1(17bdb5262ce4edf5f022f075537f6161e1397b46) )
1619   ROM_LOAD( "spo_4_2.bin",  0x98000, 0x8000, CRC(3f3390e0) SHA1(50bd7b79268438584bb0f497ab0055b4d4864590) )
1637   ROM_LOAD( "tw4-05_spo-1", 0x88000, 0x8000, CRC(5fe0c6a3) SHA1(17bdb5262ce4edf5f022f075537f6161e1397b46) )
1638   ROM_LOAD( "tw4-05_spo-2", 0x98000, 0x8000, CRC(3f3390e0) SHA1(50bd7b79268438584bb0f497ab0055b4d4864590) )
16201639ROM_END
16211640
16221641/* only the question board was dumped, but it contained a selection
r6740r6741
16241643*/
16251644ROM_START( trvwz4a )
16261645   ROM_REGION( 0x10000, "maincpu", 0 )
1627   ROM_LOAD( "u5.bin",       0x0000, 0x8000, CRC(bc23a1ab) SHA1(b9601f316e373c568c5b208de417617094046559) )
1646   ROM_LOAD( "u5.bin", 0x0000, 0x8000, CRC(bc23a1ab) SHA1(b9601f316e373c568c5b208de417617094046559) )
16281647
16291648   ROM_REGION( 0x6000, "gfx1", 0 )
1630   ROM_LOAD( "u39.bin",      0x0000, 0x2000, CRC(b9d9a80e) SHA1(55b6a0d09f8619df93ba936e083835c859a557df) )
1631   ROM_LOAD( "u38.bin",      0x2000, 0x2000, CRC(8348083e) SHA1(260a4c1ae043e7ceac65a8818c23940d32275879) )
1632   ROM_LOAD( "u37.bin",      0x4000, 0x2000, CRC(b4d3c9f4) SHA1(dda99549306519c147d275d8c6af672e80a96b67) )
1649   ROM_LOAD( "trvs_u39.u39", 0x0000, 0x2000, CRC(b9d9a80e) SHA1(55b6a0d09f8619df93ba936e083835c859a557df) )
1650   ROM_LOAD( "trvs_u38.u38", 0x2000, 0x2000, CRC(8348083e) SHA1(260a4c1ae043e7ceac65a8818c23940d32275879) )
1651   ROM_LOAD( "trvs_u37.u37", 0x4000, 0x2000, CRC(b4d3c9f4) SHA1(dda99549306519c147d275d8c6af672e80a96b67) )
16331652
16341653   ROM_REGION( 0x2000, "gfx2", 0 )
1635   ROM_LOAD( "u40.bin",      0x0000, 0x2000, CRC(fbfae092) SHA1(b8569819952a5c805f11b6854d64b3ae9c857f97) )
1654   ROM_LOAD( "trvs_u40a.u40", 0x0000, 0x2000, CRC(fbfae092) SHA1(b8569819952a5c805f11b6854d64b3ae9c857f97) )
16361655
16371656   ROM_REGION( 0xa0000, "user1", ROMREGION_ERASEFF ) /* questions */
16381657   ROM_LOAD( "merit2_5.0",  0x08000, 0x8000, CRC(e07d139f) SHA1(e364dcc628719c1bcdc119bdb2f3c98b5538c411) ) // sex trivia III
r6740r6741
16921711
16931712   // probably over-dumped, 1st and 2nd half identical
16941713   ROM_REGION( 0x18000, "gfx1", 0 )
1695   ROM_LOAD( "phrz.7",       0x00000, 0x8000, CRC(237e221a) SHA1(7aa69375c2b9a9e73e0e4ed207bf595368b2deb2) )
1696   ROM_LOAD( "phrz.10",      0x08000, 0x8000, CRC(bfa78b67) SHA1(1b51c0e00240f798fe717624e706cb15700bc2f9) )
1697   ROM_LOAD( "phrz.8",       0x10000, 0x8000, CRC(9ce22cb3) SHA1(b653afb8f13decd993e434aaad69a6e09ab65f83) )
1714   ROM_LOAD( "phrz_u37.u37", 0x00000, 0x8000, CRC(237e221a) SHA1(7aa69375c2b9a9e73e0e4ed207bf595368b2deb2) )
1715   ROM_LOAD( "phrz_u38.u38", 0x08000, 0x8000, CRC(bfa78b67) SHA1(1b51c0e00240f798fe717624e706cb15700bc2f9) )
1716   ROM_LOAD( "phrz_u39.u39", 0x10000, 0x8000, CRC(9ce22cb3) SHA1(b653afb8f13decd993e434aaad69a6e09ab65f83) )
16981717
16991718   // probably over-dumped
17001719   ROM_REGION( 0x08000, "gfx2", 0 )
1701   ROM_LOAD( "phrz.9",       0x00000, 0x8000, CRC(17dcddd4) SHA1(51682bdbfb67cd0ccf20b97e8fa12d72f0fe82ed) )
1720   ROM_LOAD( "phrz_u40.u40",0x00000, 0x8000, CRC(17dcddd4) SHA1(51682bdbfb67cd0ccf20b97e8fa12d72f0fe82ed) )
17021721
17031722   ROM_REGION( 0xa0000, "user1", ROMREGION_ERASEFF ) // questions
1704   ROM_LOAD( "phrz.1",       0x00000, 0x8000, CRC(0a016c5e) SHA1(1a24ecd7fe59b08c75a1b4575c7fe467cc7f0cf8) )
1705   ROM_LOAD( "phrz.2",       0x10000, 0x8000, CRC(e67dc49e) SHA1(5265af228531dc16db7f7ee78da6e51ef9a1d772) )
1706   ROM_LOAD( "phrz.3",       0x20000, 0x8000, CRC(5c79a653) SHA1(85a904465b347564e937074e2b18159604c83e51) )
1707   ROM_LOAD( "phrz.4",       0x30000, 0x8000, CRC(9837f757) SHA1(01106114b6997fe6432e519101f95c83a1f7cc1e) )
1708   ROM_LOAD( "phrz.5",       0x40000, 0x8000, CRC(dc9d8682) SHA1(46973da4298d0ed149c651498527c91b8ba57e0a) )
1709   ROM_LOAD( "phrz.6",       0x50000, 0x8000, CRC(48e24f17) SHA1(f50c85505f6ab2360f0885494001f174224f8575) )
1723   ROM_LOAD( "std1.bin",     0x00000, 0x8000, CRC(0a016c5e) SHA1(1a24ecd7fe59b08c75a1b4575c7fe467cc7f0cf8) )
1724   ROM_LOAD( "std2.bin",     0x10000, 0x8000, CRC(e67dc49e) SHA1(5265af228531dc16db7f7ee78da6e51ef9a1d772) )
1725   ROM_LOAD( "std3.bin",     0x20000, 0x8000, CRC(5c79a653) SHA1(85a904465b347564e937074e2b18159604c83e51) )
1726   ROM_LOAD( "std4.bin",     0x30000, 0x8000, CRC(9837f757) SHA1(01106114b6997fe6432e519101f95c83a1f7cc1e) )
1727   ROM_LOAD( "std5.bin",     0x40000, 0x8000, CRC(dc9d8682) SHA1(46973da4298d0ed149c651498527c91b8ba57e0a) )
1728   ROM_LOAD( "std6.bin",     0x50000, 0x8000, CRC(48e24f17) SHA1(f50c85505f6ab2360f0885494001f174224f8575) )
17101729ROM_END
17111730
17121731ROM_START( phrcrazea )
17131732   ROM_REGION( 0x10000, "maincpu", 0 )
1714   ROM_LOAD( "merit5.u5",      0x00000, 0x8000, CRC(d04c7657) SHA1(0b59fbf553eb5b68544ee2f94cf8106ab30ff1ed) )
1733   ROM_LOAD( "5281-40_u5-3a.u5",0x00000, 0x8000, CRC(d04c7657) SHA1(0b59fbf553eb5b68544ee2f94cf8106ab30ff1ed) )
17151734
17161735   ROM_REGION( 0x18000, "gfx1", 0 )
1717   ROM_LOAD( "merit5.u37",       0x00000, 0x8000, CRC(237e221a) SHA1(7aa69375c2b9a9e73e0e4ed207bf595368b2deb2) )
1718   ROM_LOAD( "merit5.u38",       0x08000, 0x8000, CRC(bfa78b67) SHA1(1b51c0e00240f798fe717624e706cb15700bc2f9) )
1719   ROM_LOAD( "merit5.u39",       0x10000, 0x8000, CRC(9ce22cb3) SHA1(b653afb8f13decd993e434aaad69a6e09ab65f83) )
1736   ROM_LOAD( "phrz_u27.u37", 0x00000, 0x8000, CRC(237e221a) SHA1(7aa69375c2b9a9e73e0e4ed207bf595368b2deb2) )
1737   ROM_LOAD( "phrz_u38.u38", 0x08000, 0x8000, CRC(bfa78b67) SHA1(1b51c0e00240f798fe717624e706cb15700bc2f9) )
1738   ROM_LOAD( "phrz_u39.u39", 0x10000, 0x8000, CRC(9ce22cb3) SHA1(b653afb8f13decd993e434aaad69a6e09ab65f83) )
17201739
17211740   ROM_REGION( 0x08000, "gfx2", 0 )
1722   ROM_LOAD( "merit5.u40",       0x00000, 0x8000, CRC(17dcddd4) SHA1(51682bdbfb67cd0ccf20b97e8fa12d72f0fe82ed) )
1741   ROM_LOAD( "phrz_u40.u40",0x00000, 0x8000, CRC(17dcddd4) SHA1(51682bdbfb67cd0ccf20b97e8fa12d72f0fe82ed) )
17231742
17241743   ROM_REGION( 0xa0000, "user1", ROMREGION_ERASEFF ) /* questions */
1725   ROM_LOAD( "merit2_0.0",     0x00000, 0x8000, CRC(7ef3bca7) SHA1(f25cd01f996882a500e1a800d924759cd1de255d) )
1726   ROM_LOAD( "merit2_0.1",     0x10000, 0x8000, CRC(ed7604b8) SHA1(b1e841b50b8ef6ae95fafac1c34b6d0337a05d18) )
1727   ROM_LOAD( "merit2_0.2",     0x20000, 0x8000, CRC(423eecd6) SHA1(ca8d181ccba05acba8ebc57f20e0542eda00c917) )
1728   ROM_LOAD( "merit2_0.3",     0x30000, 0x8000, CRC(05dd3900) SHA1(bb13a3c5f84771c450fa88560cc74c5a1be1b876) )
1729   ROM_LOAD( "merit2_0.4",     0x40000, 0x8000, CRC(c5980f24) SHA1(a3b665c74aaa704ffa382f95adac70c7c46fb446) )
1730   ROM_LOAD( "merit2_0.5",     0x50000, 0x8000, CRC(7cb395a9) SHA1(48b3ac524e6ae23f885b9b767e77930a89a81f5f) )
1731   ROM_LOAD( "merit2_0.6",     0x60000, 0x8000, CRC(effc811b) SHA1(2479539965ed541be417bbe48a5e66a58a6294aa) )
1732   ROM_LOAD( "merit2_0.7",     0x70000, 0x8000, CRC(c4c7dcee) SHA1(81d879df3da0fbe1cf2247d92b3853104a99689d) )
1733   ROM_LOAD( "merit2_0.8",     0x80000, 0x8000, CRC(527b3025) SHA1(36dc129d2276909643e90ae3810c8341076fd88c) )
1734   ROM_LOAD( "merit2_0.9",     0x90000, 0x8000, CRC(367f1dfa) SHA1(01d69004c365acefb0e52ac12593a3874c16ab9d) )
1744   ROM_LOAD( "phrz1-07_sex-2a", 0x00000, 0x8000, CRC(7ef3bca7) SHA1(f25cd01f996882a500e1a800d924759cd1de255d) )
1745   ROM_LOAD( "phrz1-07_sex-1a", 0x10000, 0x8000, CRC(ed7604b8) SHA1(b1e841b50b8ef6ae95fafac1c34b6d0337a05d18) )
1746   ROM_LOAD( "phrz1-07_std-8a", 0x20000, 0x8000, CRC(423eecd6) SHA1(ca8d181ccba05acba8ebc57f20e0542eda00c917) )
1747   ROM_LOAD( "phrz1-07_std-7a", 0x30000, 0x8000, CRC(05dd3900) SHA1(bb13a3c5f84771c450fa88560cc74c5a1be1b876) )
1748   ROM_LOAD( "phrz1-07_std-6a", 0x40000, 0x8000, CRC(c5980f24) SHA1(a3b665c74aaa704ffa382f95adac70c7c46fb446) )
1749   ROM_LOAD( "phrz1-07_std-5a", 0x50000, 0x8000, CRC(7cb395a9) SHA1(48b3ac524e6ae23f885b9b767e77930a89a81f5f) )
1750   ROM_LOAD( "phrz1-07_std-4a", 0x60000, 0x8000, CRC(effc811b) SHA1(2479539965ed541be417bbe48a5e66a58a6294aa) )
1751   ROM_LOAD( "phrz1-07_std-3a", 0x70000, 0x8000, CRC(c4c7dcee) SHA1(81d879df3da0fbe1cf2247d92b3853104a99689d) )
1752   ROM_LOAD( "phrz1-07_std-2a", 0x80000, 0x8000, CRC(527b3025) SHA1(36dc129d2276909643e90ae3810c8341076fd88c) )
1753   ROM_LOAD( "phrz1-07_std-1a", 0x90000, 0x8000, CRC(367f1dfa) SHA1(01d69004c365acefb0e52ac12593a3874c16ab9d) )
17351754ROM_END
17361755
17371756ROM_START( phrcrazes )
r6740r6741
17551774   ROM_LOAD( "std6.bin",     0x50000, 0x8000, CRC(48e24f17) SHA1(f50c85505f6ab2360f0885494001f174224f8575) )
17561775   /* empty space as per instructions for other "sex" category roms */
17571776   /* "Sex" questions revision A */
1758   ROM_LOAD( "sex1_2a.bin",  0x80000, 0x8000, CRC(7ef3bca7) SHA1(f25cd01f996882a500e1a800d924759cd1de255d) )
1759   ROM_LOAD( "sex1_1a.bin",  0x90000, 0x8000, CRC(ed7604b8) SHA1(b1e841b50b8ef6ae95fafac1c34b6d0337a05d18) )
1777   ROM_LOAD( "phrz1-07_sex-2a", 0x80000, 0x8000, CRC(7ef3bca7) SHA1(f25cd01f996882a500e1a800d924759cd1de255d) )
1778   ROM_LOAD( "phrz1-07_sex-1a", 0x90000, 0x8000, CRC(ed7604b8) SHA1(b1e841b50b8ef6ae95fafac1c34b6d0337a05d18) )
17601779ROM_END
17611780
17621781ROM_START( dodge )
src/mame/drivers/pingpong.c
r6740r6741
99#include "deprecat.h"
1010#include "sound/sn76496.h"
1111
12extern UINT8 *pingpong_videoram;
13extern UINT8 *pingpong_colorram;
14
1215extern WRITE8_HANDLER( pingpong_videoram_w );
1316extern WRITE8_HANDLER( pingpong_colorram_w );
1417
r6740r6741
9497
9598static ADDRESS_MAP_START( pingpong_map, ADDRESS_SPACE_PROGRAM, 8 )
9699   AM_RANGE(0x0000, 0x7fff) AM_ROM
97   AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(pingpong_colorram_w) AM_BASE_GENERIC(colorram)
98   AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(pingpong_videoram_w) AM_BASE_GENERIC(videoram)
100   AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(pingpong_colorram_w) AM_BASE(&pingpong_colorram)
101   AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(pingpong_videoram_w) AM_BASE(&pingpong_videoram)
99102   AM_RANGE(0x9000, 0x9002) AM_RAM
100103   AM_RANGE(0x9003, 0x9052) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
101104   AM_RANGE(0x9053, 0x97ff) AM_RAM
r6740r6741
115118   AM_RANGE(0x5400, 0x57ff) AM_RAM
116119   AM_RANGE(0x6000, 0x6007) AM_WRITENOP /* solenoid writes */
117120   AM_RANGE(0x7000, 0x7000) AM_READ_PORT("IN4")
118   AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(pingpong_colorram_w) AM_BASE_GENERIC(colorram)
119   AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(pingpong_videoram_w) AM_BASE_GENERIC(videoram)
121   AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(pingpong_colorram_w) AM_BASE(&pingpong_colorram)
122   AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(pingpong_videoram_w) AM_BASE(&pingpong_videoram)
120123   AM_RANGE(0x9000, 0x9002) AM_RAM
121124   AM_RANGE(0x9003, 0x9052) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
122125   AM_RANGE(0x9053, 0x97ff) AM_RAM
src/mame/drivers/blstroid.c
r6740r6741
2121#include "cpu/m68000/m68000.h"
2222#include "machine/atarigen.h"
2323#include "audio/atarijsa.h"
24#include "blstroid.h"
24#include "includes/blstroid.h"
2525
2626
2727
r6740r6741
4646}
4747
4848
49static MACHINE_START( blstroid )
50{
51   atarigen_init(machine);
52}
53
54
4955static MACHINE_RESET( blstroid )
5056{
5157   blstroid_state *state = (blstroid_state *)machine->driver_data;
r6740r6741
202208   MDRV_CPU_PROGRAM_MAP(main_map)
203209   MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen)
204210
211   MDRV_MACHINE_START(blstroid)
205212   MDRV_MACHINE_RESET(blstroid)
206213   MDRV_NVRAM_HANDLER(atarigen)
207214
src/mame/drivers/aztarac.c
r6740r6741
1717#include "cpu/z80/z80.h"
1818#include "cpu/m68000/m68000.h"
1919#include "video/vector.h"
20#include "aztarac.h"
20#include "includes/aztarac.h"
2121#include "sound/ay8910.h"
2222
2323
src/mame/drivers/meadows.c
r6740r6741
118118
119119#include "driver.h"
120120#include "cpu/s2650/s2650.h"
121#include "meadows.h"
121#include "includes/meadows.h"
122122#include "sound/dac.h"
123123#include "sound/samples.h"
124124
src/mame/drivers/sms.c
r6740r6741
516516static MACHINE_START( sms )
517517{
518518   memory_configure_bank(machine, "bank1", 0, 16, memory_region(machine, "questions"), 0x4000);
519
520   state_save_register_global(machine, communication_port_status);
521   state_save_register_global_array(machine, communication_port);
519522}
520523
521524static MACHINE_START( sureshot )
522525{
526   state_save_register_global(machine, communication_port_status);
527   state_save_register_global_array(machine, communication_port);
523528}
524529
525530static MACHINE_RESET( sms )
526531{
527532   communication_port_status = 0;
528
529   state_save_register_global(machine, communication_port_status);
530   state_save_register_global_array(machine, communication_port);
531533}
532534
533535static MACHINE_DRIVER_START( sms )
src/mame/drivers/harddriv.c
r6740r6741
172172PCB Layouts
173173-----------
174174
175
175176Driver Sound
176177A046491
177178|------------------------------------------------------------------------------------------------------|
r6740r6741
187188|               |  8  |   6264                   CY7C168                         SOCKET     136052-1124.55A
188189|      16MHz    |  0  |                                        |---|                                   |
189190|               |  0  |   136077-1032-70N        CY7C168       |TMS|             SOCKET     136052-1123.65A
190|               |  0  |                                        |   |                                   |
191|      LED      |  0  |                                        |   |                                   |
191192|               |     |   6264                   CY7C168       |320|
192193|               |     |                                        |C10|                                   |
193|               |     |                                   20MHz|   |                                   |
194|               |     |            LED                    20MHz|   |                                   |
194195|               |-----|                                        |   |            95C           95A      |
195196|                                                              |---|          GAL16V8       GAL16V8    |
196197|                                                                           (136052-1140) (136052-1139)|
197198|                                                                                                      |
198199|                                                                                                      |
199|                                                                                                      |
200|        LED                                                                                           |
200201|  J2                                  J5                  TL084     TL084     TL084                   |
201202|------------------------------------------------------------------------------------------------------|
203Notes:
204      68000 clock input - 8.000MHz [16/2]
202205
206
207DSK
208A047724-01
209|-----------------------------------------------|
210|  (SLAPSTICK?)       |---------------------|   |
211|  DIP20_SOCKET       |---------------------|   |
212|                                            LED|
213|                     40B            60B        |
214|                  GAL20V8A       GAL20V8A      |
215|                136077-1025     136077-1026    |
216|MK48Z02B.10C  MK48Z02B.30C                     |
217|                                               |
218|                                               |
219|62256       62256                      62256   |
220|                                               |
221|                                               |
222|136078-1031.10E         |-----------|  62256   |
223|         136078-1030.30E|           |          |
224|                        |137661-100 |          |
225|SOCKET      SOCKET      |           |  62256   |
226|                        |           |          |
227|          |-------|     |           |          |
228|          |137665-|     |-----------|  62256   |
229|          |1020   |                            |
230|          |LC9040 |        40MHz               |
231|          |-------|                            |
232|  LED        20MHz                             |
233|-----------------------------------------------|
234
235
236
237ADSP II
238A047046-01
239|------------------------------------------------------------------------------------------------------|
240|                     |---------------------|                                                          |
241|CY7C168   CY7C168    |---------------------|                  CY7C168           6264       6264       |
242|                                                                                                      |
243|CY7C168   CY7C168        LED                                  CY7C168                                 |
244|                                                                                                      |
245|CY7C168   CY7C168                                             CY7C168                                 |
246|                                                                                                      |
247|                                                              CY7C168                                 |
248|                                    32MHz                                                             |
249|CY7C168   CY7C168                  |-------|                  CY7C168                                 |
250|                                   | ADSP  |                                                          |
251|CY7C168   CY7C168                  | 2100  |                  CY7C168                                 |
252|                                   |       |                                                          |
253|CY7C168   CY7C168                  |-------|                  CY7C168                                 |
254|                                                                                                      |
255|                                                              CY7C168                                 |
256|136077-2022.10H                                                                 6264       6264       |
257|      136077-2021.9/10H                                                                               |
258|                 SOCKET                                                                               |
259|136077-2024.10K                                                                                       |
260|      136077-2023.9/10K                                                                               |
261|                 SOCKET                                                                               |
262|                                          LED  LED                                                    |
263|------------------------------------------------------------------------------------------------------|
264
265
266
267MULTISYNC
268A046901
269|------------------------------------------------------------------------------------------------------|
270|                     |---------------------|     136078-4001.210R           136078-4009.210V          |
271|                     |---------------------|        136078-4003.210S           136078-1011.210W       |
272|                                                      136078-4005.210T           136078-1013.210X     |
273| 68681       6264  6264  MK48Z02B.210E                  136078-4007.210U           136078-4015.210Y   |
274|  3.6864MHz                        (SLAPSTICK)                                                        |
275|                                   (DIP20)       136078-4002.200R           136078-4010.200V          |
276|J2                                 137412-117       136078-4004.200S           136078-1012.200W       |
277|             6264  6264  MK48T02B.200E                136078-4006.200T           136078-1014.200X     |
278|                                                        136078-4008.200U           136078-4016.200Y   |
279|J3                                                                                                    |
280|                                                                      136068-1168.195U                |
281|                                                                        (82S123 PROM)                 |
282|                  |----------------------------|                                           J13        |
283|                  |                            |                                                      |
284|J6                |           68010            |                                                      |
285|                  |                            |                                                      |
286|                  |----------------------------|                                                      |
287|                                                                     |-------|                  32MHZ |
288|J5                            32MHz                                  |TMS    |                        |
289|                                                              48MHz  |34010  |                        |
290|                                                                     |       |                   LED  |
291|                                                                     |-------|                        |
292|                                                                                                      |
293|                                                                                                      |
294|J4          DSW(8)                                                   |-------|                        |
295|                                                                     |SCX    |                        |
296|      LED LED                                                        |6218UTP|                        |
297|                                                                     |       |                        |
298|                                   |-------|                         |-------|                        |
299|J15                                |       |                                                          |
300|                                   |       |                                                          |
301|               J12  LED            |       |             42C4064  42C4064  42C4064  42C4064           |
302|                                   |-------|                                                          |
303|J14                            (EMPTY PLCC68 SOCKET)     42C4064  42C4064  42C4064  42C4064           |
304|                                                                                                      |
305|                                                         42C4064  42C4064  42C4064  42C4064           |
306|       ADC0809                 |--EMPTY_SOCKETS--|                                                    |
307|J9                             DIP20        DIP20        42C4064  42C4064  42C4064  42C4064           |
308|               J1                                                                                     |
309|                               DIP20        DIP20                  CY2149   CY2149   CY2149           |
310|      LED                                                                                             |
311|                               DIP20        DIP20                  CY2149   CY2149   CY2149           |
312|J8               LED  LED                                                                             |
313|                 LED  LED      DIP20        DIP20                                  J10                |
314|------------------------------------------------------------------------------------------------------|
315Notes:
316      68010 clock input - 8.000MHz [32/4]
317      34010 clock input - 48.000MHz
318
203319****************************************************************************/
204320
205321
r6740r6741
212328#include "machine/atarigen.h"
213329#include "machine/asic65.h"
214330#include "audio/atarijsa.h"
215#include "harddriv.h"
331#include "includes/harddriv.h"
216332#include "sound/dac.h"
217333
218334/* from slapstic.c */
r6740r6741
10221138   MDRV_MACHINE_RESET(harddriv)
10231139   MDRV_NVRAM_HANDLER(atarigen)
10241140
1141   MDRV_TIMER_ADD("duart_timer", hd68k_duart_callback)
1142
10251143   /* video hardware */
10261144   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
10271145   MDRV_PALETTE_LENGTH(1024)
src/mame/drivers/madalien.c
r6740r6741
1010#include "cpu/m6502/m6502.h"
1111#include "sound/ay8910.h"
1212#include "video/mc6845.h"
13#include "madalien.h"
13#include "includes/madalien.h"
1414
1515
1616#define SOUND_CLOCK XTAL_4MHz
src/mame/drivers/aeroboto.c
r6740r6741
2525#include "driver.h"
2626#include "cpu/m6809/m6809.h"
2727#include "sound/ay8910.h"
28#include "aeroboto.h"
28#include "includes/aeroboto.h"
2929
3030
3131static READ8_HANDLER( aeroboto_201_r )
src/mame/drivers/konamigv.c
r6740r6741
317317   psx_dma_install_write_handler(5, scsi_dma_write);
318318}
319319
320static MACHINE_RESET( konamigv )
320static MACHINE_START( konamigv )
321321{
322   psx_machine_init(machine);
323
324   /* also hook up CDDA audio to the CD-ROM drive */
325   cdda_set_cdrom(devtag_get_device(machine, "cdda"), am53cf96_get_device(SCSI_ID_4));
326
327322   state_save_register_global_array(machine, sector_buffer);
328323   state_save_register_global(machine, flash_address);
329324   state_save_register_global_array(machine, trackball_prev);
r6740r6741
332327   state_save_register_global_array(machine, btc_trackball_data);
333328}
334329
330static MACHINE_RESET( konamigv )
331{
332   psx_machine_init(machine);
333
334   /* also hook up CDDA audio to the CD-ROM drive */
335   cdda_set_cdrom(devtag_get_device(machine, "cdda"), am53cf96_get_device(SCSI_ID_4));
336}
337
335338static void spu_irq(const device_config *device, UINT32 data)
336339{
337340   psx_irq_set(device->machine, data);
r6740r6741
351354   MDRV_CPU_PROGRAM_MAP( konamigv_map)
352355   MDRV_CPU_VBLANK_INT("screen", psx_vblank)
353356
357   MDRV_MACHINE_START( konamigv )
354358   MDRV_MACHINE_RESET( konamigv )
355359   MDRV_NVRAM_HANDLER(konamigv_93C46)
356360
src/mame/drivers/firetrap.c
r6740r6741
6262#include "cpu/m6502/m6502.h"
6363#include "sound/3526intf.h"
6464#include "sound/msm5205.h"
65#include "firetrap.h"
65#include "includes/firetrap.h"
6666
6767
6868static WRITE8_HANDLER( firetrap_nmi_disable_w )
src/mame/drivers/thedeep.c
r6740r6741
2828#include "cpu/z80/z80.h"
2929#include "cpu/m6502/m6502.h"
3030#include "deprecat.h"
31#include "thedeep.h"
31#include "includes/thedeep.h"
3232#include "sound/2203intf.h"
3333
3434/***************************************************************************
src/mame/drivers/zr107.c
r6740r6741
169169#include "cpu/sharc/sharc.h"
170170#include "sound/k054539.h"
171171#include "machine/konppc.h"
172#include "machine/konamiic.h"
173172#include "machine/adc083x.h"
174173#include "machine/eepromdev.h"
175#include "video/konamiic.h"
174#include "video/konicdev.h"
176175#include "video/gticlub.h"
176#include "sound/k056800.h"
177177
178
179178static UINT8 led_reg0, led_reg1;
180179
181180
r6740r6741
237236
238237#define NUM_LAYERS   2
239238
240static void game_tile_callback(int layer, int *code, int *color, int *flags)
239static void game_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags)
241240{
242241   *color += layer * 0x40;
243242}
244243
245244static VIDEO_START( zr107 )
246245{
247   static int scrolld[NUM_LAYERS][4][2] = {
248       {{ 0, 0}, {0, 0}, {0, 0}, {0, 0}},
249       {{ 0, 0}, {0, 0}, {0, 0}, {0, 0}}
250   };
246   const device_config *k056832 = devtag_get_device(machine, "k056832");
251247
252   K056832_vh_start(machine, "gfx2", K056832_BPP_8, 1, scrolld, game_tile_callback, 0);
248   k056832_set_layer_offs(k056832, 0, -29, -27);
249   k056832_set_layer_offs(k056832, 1, -29, -27);
250   k056832_set_layer_offs(k056832, 2, -29, -27);
251   k056832_set_layer_offs(k056832, 3, -29, -27);
252   k056832_set_layer_offs(k056832, 4, -29, -27);
253   k056832_set_layer_offs(k056832, 5, -29, -27);
254   k056832_set_layer_offs(k056832, 6, -29, -27);
255   k056832_set_layer_offs(k056832, 7, -29, -27);
256
253257   K001006_init(machine);
254258   K001005_init(machine);
255259}
256260
257261static VIDEO_UPDATE( zr107 )
258262{
263   const device_config *k056832 = devtag_get_device(screen->machine, "k056832");
259264   bitmap_fill(bitmap, cliprect, screen->machine->pens[0]);
260265
261   K056832_set_LayerOffset(0, -29, -27);
262   K056832_set_LayerOffset(1, -29, -27);
263   K056832_set_LayerOffset(2, -29, -27);
264   K056832_set_LayerOffset(3, -29, -27);
265   K056832_set_LayerOffset(4, -29, -27);
266   K056832_set_LayerOffset(5, -29, -27);
267   K056832_set_LayerOffset(6, -29, -27);
268   K056832_set_LayerOffset(7, -29, -27);
269
270   K056832_tilemap_draw(screen->machine, bitmap, cliprect, 1, 0, 0);
266   k056832_tilemap_draw(k056832, bitmap, cliprect, 1, 0, 0);
271267   K001005_draw(bitmap, cliprect);
272   K056832_tilemap_draw(screen->machine, bitmap, cliprect, 0, 0, 0);
268   k056832_tilemap_draw(k056832, bitmap, cliprect, 0, 0, 0);
273269
274270   draw_7segment_led(bitmap, 3, 3, led_reg0);
275271   draw_7segment_led(bitmap, 9, 3, led_reg1);
r6740r6741
410406
411407static ADDRESS_MAP_START( zr107_map, ADDRESS_SPACE_PROGRAM, 32 )
412408   AM_RANGE(0x00000000, 0x000fffff) AM_RAM   AM_BASE(&workram)   /* Work RAM */
413   AM_RANGE(0x74000000, 0x74003fff) AM_READWRITE(K056832_ram_long_r, K056832_ram_long_w)
414   AM_RANGE(0x74020000, 0x7402003f) AM_READWRITE(K056832_long_r, K056832_long_w)
409   AM_RANGE(0x74000000, 0x74003fff) AM_DEVREADWRITE("k056832", k056832_ram_long_r, k056832_ram_long_w)
410   AM_RANGE(0x74020000, 0x7402003f) AM_DEVREADWRITE("k056832", k056832_long_r, k056832_long_w)
415411   AM_RANGE(0x74060000, 0x7406003f) AM_READWRITE(ccu_r, ccu_w)
416412   AM_RANGE(0x74080000, 0x74081fff) AM_RAM_WRITE(paletteram32_w) AM_BASE_GENERIC(paletteram)
417   AM_RANGE(0x740a0000, 0x740a3fff) AM_READ(K056832_rom_long_r)
413   AM_RANGE(0x740a0000, 0x740a3fff) AM_DEVREAD("k056832", k056832_rom_long_r)
418414   AM_RANGE(0x78000000, 0x7800ffff) AM_READWRITE(cgboard_dsp_shared_r_ppc, cgboard_dsp_shared_w_ppc)      /* 21N 21K 23N 23K */
419415   AM_RANGE(0x78010000, 0x7801ffff) AM_WRITE(cgboard_dsp_shared_w_ppc)
420416   AM_RANGE(0x78040000, 0x7804000f) AM_READWRITE(K001006_0_r, K001006_0_w)
r6740r6741
422418   AM_RANGE(0x7e000000, 0x7e003fff) AM_READWRITE8(sysreg_r, sysreg_w, 0xffffffff)
423419   AM_RANGE(0x7e008000, 0x7e009fff) AM_READWRITE8(K056230_r, K056230_w, 0xffffffff)            /* LANC registers */
424420   AM_RANGE(0x7e00a000, 0x7e00bfff) AM_READWRITE(lanc_ram_r, lanc_ram_w) AM_BASE(&lanc_ram)      /* LANC Buffer RAM (27E) */
425   AM_RANGE(0x7e00c000, 0x7e00c007) AM_WRITE(K056800_host_w)
426   AM_RANGE(0x7e00c008, 0x7e00c00f) AM_READ(K056800_host_r)
421   AM_RANGE(0x7e00c000, 0x7e00c007) AM_DEVWRITE("k056800", k056800_host_w)
422   AM_RANGE(0x7e00c008, 0x7e00c00f) AM_DEVREAD("k056800", k056800_host_r)
427423   AM_RANGE(0x7f800000, 0x7f9fffff) AM_ROM AM_SHARE("share2")
428424   AM_RANGE(0x7fe00000, 0x7fffffff) AM_ROM AM_REGION("user1", 0) AM_SHARE("share2")   /* Program ROM */
429425ADDRESS_MAP_END
r6740r6741
450446   AM_RANGE(0x7e000000, 0x7e003fff) AM_MIRROR(0x80000000) AM_READWRITE8(sysreg_r, sysreg_w, 0xffffffff)
451447   AM_RANGE(0x7e008000, 0x7e009fff) AM_MIRROR(0x80000000) AM_READWRITE8(K056230_r, K056230_w, 0xffffffff)            /* LANC registers */
452448   AM_RANGE(0x7e00a000, 0x7e00bfff) AM_MIRROR(0x80000000) AM_READWRITE(lanc_ram_r, lanc_ram_w)    AM_BASE(&lanc_ram)   /* LANC Buffer RAM (27E) */
453   AM_RANGE(0x7e00c000, 0x7e00c007) AM_MIRROR(0x80000000) AM_WRITE(K056800_host_w)
454   AM_RANGE(0x7e00c008, 0x7e00c00f) AM_MIRROR(0x80000000) AM_READ(K056800_host_r)
449   AM_RANGE(0x7e00c000, 0x7e00c007) AM_MIRROR(0x80000000) AM_DEVWRITE("k056800", k056800_host_w)
450   AM_RANGE(0x7e00c008, 0x7e00c00f) AM_MIRROR(0x80000000) AM_DEVREAD("k056800", k056800_host_r)
455451   AM_RANGE(0x7f000000, 0x7f3fffff) AM_MIRROR(0x80000000) AM_ROM AM_REGION("user2", 0)
456452   AM_RANGE(0x7f800000, 0x7f9fffff) AM_MIRROR(0x80000000) AM_ROM AM_SHARE("share2")
457453   AM_RANGE(0x7fe00000, 0x7fffffff) AM_MIRROR(0x80000000) AM_ROM AM_REGION("user1", 0) AM_SHARE("share2")   /* Program ROM */
r6740r6741
485481   AM_RANGE(0x000000, 0x01ffff) AM_ROM
486482   AM_RANGE(0x100000, 0x103fff) AM_RAM      /* Work RAM */
487483   AM_RANGE(0x200000, 0x2004ff) AM_READWRITE(dual539_r, dual539_w)
488   AM_RANGE(0x400000, 0x40000f) AM_WRITE(K056800_sound_w)
489   AM_RANGE(0x400010, 0x40001f) AM_READ(K056800_sound_r)
484   AM_RANGE(0x400000, 0x40000f) AM_DEVWRITE("k056800", k056800_sound_w)
485   AM_RANGE(0x400010, 0x40001f) AM_DEVREAD("k056800", k056800_sound_r)
490486   AM_RANGE(0x580000, 0x580001) AM_WRITENOP
491487ADDRESS_MAP_END
492488
r6740r6741
682678};
683679
684680
681static TIMER_CALLBACK( irq_off )
682{
683   cputag_set_input_line(machine, "audiocpu", param, CLEAR_LINE);
684}
685
686static void sound_irq_callback( running_machine *machine, int irq )
687{
688   int line = (irq == 0) ? INPUT_LINE_IRQ1 : INPUT_LINE_IRQ2;
689
690   cputag_set_input_line(machine, "audiocpu", line, ASSERT_LINE);
691   timer_set(machine, ATTOTIME_IN_USEC(1), NULL, line, irq_off);
692}
693
694static const k056800_interface zr107_k056800_interface =
695{
696   sound_irq_callback
697};
698
699static const k056832_interface zr107_k056832_intf =
700{
701   "gfx2", 1,
702   K056832_BPP_8,
703   1, 0,
704   KONAMI_ROM_DEINTERLEAVE_NONE,
705   game_tile_callback, "none"
706};
707
685708/* PowerPC interrupts
686709
687710    IRQ0:  Vblank
r6740r6741
693716{
694717   cpu_set_input_line(device, INPUT_LINE_IRQ0, ASSERT_LINE);
695718}
719
696720static MACHINE_RESET( zr107 )
697721{
698722   cputag_set_input_line(machine, "dsp", INPUT_LINE_RESET, ASSERT_LINE);
r6740r6741
730754   MDRV_VIDEO_START(zr107)
731755   MDRV_VIDEO_UPDATE(zr107)
732756
757   MDRV_K056832_ADD("k056832", zr107_k056832_intf)
758
759   MDRV_K056800_ADD("k056800", zr107_k056800_interface)
760
733761   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
734762
735763   MDRV_SOUND_ADD("konami1", K054539, 48000)
r6740r6741
777805   MDRV_VIDEO_START(jetwave)
778806   MDRV_VIDEO_UPDATE(jetwave)
779807
808   MDRV_K056800_ADD("k056800", zr107_k056800_interface)
809
780810   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
781811
782812   MDRV_SOUND_ADD("konami1", K054539, 48000)
r6740r6741
794824
795825/*****************************************************************************/
796826
797static TIMER_CALLBACK( irq_off )
798{
799   cputag_set_input_line(machine, "audiocpu", param, CLEAR_LINE);
800}
801
802static void sound_irq_callback(running_machine *machine, int irq)
803{
804   int line = (irq == 0) ? INPUT_LINE_IRQ1 : INPUT_LINE_IRQ2;
805   cputag_set_input_line(machine, "audiocpu", line, ASSERT_LINE);
806   timer_set(machine, ATTOTIME_IN_USEC(1), NULL, line, irq_off);
807}
808
809827static void init_zr107(running_machine *machine)
810828{
811829   sharc_dataram = auto_alloc_array(machine, UINT32, 0x100000/4);
r6740r6741
813831   ccu_vcth = ccu_vctl = 0;
814832
815833   K001005_preprocess_texture_data(memory_region(machine, "gfx1"), memory_region_length(machine, "gfx1"), 0);
816
817   K056800_init(machine, sound_irq_callback);
818834}
819835
820836static DRIVER_INIT(zr107)
src/mame/drivers/bladestl.c
r6740r6741
11/***************************************************************************
22
3Blades of Steel(GX797) (c) 1987 Konami
3    Blades of Steel (GX797) (c) 1987 Konami
44
5Driver by Manuel Abadia <manu@teleline.es>
5    Driver by Manuel Abadia <manu@teleline.es>
66
7Interrupts:
7    Interrupts:
88
9    CPU #0 (6309):
10    --------------
11    * IRQ: not used.
12    * FIRQ: generated by VBLANK.
13    * NMI: writes the sound command to the 6809.
9        CPU #0 (6309):
10        --------------
11        * IRQ: not used.
12        * FIRQ: generated by VBLANK.
13        * NMI: writes the sound command to the 6809.
1414
15    CPU #1 (6809):
16    --------------
17    * IRQ: triggered by the 6309 when a sound command is written.
18    * FIRQ: not used.
19    * NMI: not used.
15        CPU #1 (6809):
16        --------------
17        * IRQ: triggered by the 6309 when a sound command is written.
18        * FIRQ: not used.
19        * NMI: not used.
2020
21Notes:
22    * The protection is not fully understood(Konami 051733). The
23    game is playable, but is not 100% accurate.
24    * Missing samples.
21    Notes:
22        * The protection is not fully understood(Konami 051733). The
23        game is playable, but is not 100% accurate.
24        * Missing samples.
2525
2626***************************************************************************/
2727
r6740r6741
2929#include "deprecat.h"
3030#include "cpu/m6809/m6809.h"
3131#include "cpu/hd6309/hd6309.h"
32#include "video/konamiic.h"
3332#include "sound/2203intf.h"
3433#include "sound/upd7759.h"
35#include "konamipt.h"
34#include "video/konicdev.h"
35#include "includes/konamipt.h"
36#include "includes/bladestl.h"
3637
37/* from video */
38int bladestl_spritebank;
39PALETTE_INIT( bladestl );
40VIDEO_START( bladestl );
41VIDEO_UPDATE( bladestl );
4238
4339static INTERRUPT_GEN( bladestl_interrupt )
4440{
45   if (cpu_getiloops(device) == 0){
46      if (K007342_is_INT_enabled())
41   bladestl_state *state = (bladestl_state *)device->machine->driver_data;
42
43   if (cpu_getiloops(device) == 0)
44   {
45      if (k007342_is_int_enabled(state->k007342))
4746         cpu_set_input_line(device, HD6309_FIRQ_LINE, HOLD_LINE);
4847   }
49   else if (cpu_getiloops(device) % 2){
48   else if (cpu_getiloops(device) % 2)
49   {
5050      cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
5151   }
5252}
5353
54/*************************************
55 *
56 *  Memory handlers
57 *
58 *************************************/
59
5460static READ8_HANDLER( trackball_r )
5561{
56   static int last[4];
57   int curr,delta;
62   bladestl_state *state = (bladestl_state *)space->machine->driver_data;
5863   static const char *const port[] = { "TRACKBALL_P1_1", "TRACKBALL_P1_2", "TRACKBALL_P2_1", "TRACKBALL_P1_2" };
64   int curr, delta;
5965
6066   curr = input_port_read(space->machine, port[offset]);
61   delta = (curr - last[offset]) & 0xff;
62   last[offset] = curr;
67   delta = (curr - state->last_track[offset]) & 0xff;
68   state->last_track[offset] = curr;
69
6370   return (delta & 0x80) | (curr >> 1);
6471}
6572
6673static WRITE8_HANDLER( bladestl_bankswitch_w )
6774{
68   UINT8 *RAM = memory_region(space->machine, "maincpu");
69   int bankaddress;
75   bladestl_state *state = (bladestl_state *)space->machine->driver_data;
7076
7177   /* bits 0 & 1 = coin counters */
7278   coin_counter_w(space->machine, 0,data & 0x01);
r6740r6741
7985   /* bit 4 = relay (???) */
8086
8187   /* bits 5-6 = bank number */
82   bankaddress = 0x10000 + ((data & 0x60) >> 5) * 0x2000;
83   memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]);
88   memory_set_bank(space->machine, "bank1", (data & 0x60) >> 5);
8489
8590   /* bit 7 = select sprite bank */
86   bladestl_spritebank = (data & 0x80) << 3;
91   state->spritebank = (data & 0x80) << 3;
8792
8893}
8994
9095static WRITE8_HANDLER( bladestl_sh_irqtrigger_w )
9196{
97   bladestl_state *state = (bladestl_state *)space->machine->driver_data;
98
9299   soundlatch_w(space, offset, data);
93   cputag_set_input_line(space->machine, "audiocpu", M6809_IRQ_LINE, HOLD_LINE);
100   cpu_set_input_line(state->audiocpu, M6809_IRQ_LINE, HOLD_LINE);
94101   //logerror("(sound) write %02x\n", data);
95102}
96103
97static WRITE8_DEVICE_HANDLER( bladestl_port_B_w ){
104static WRITE8_DEVICE_HANDLER( bladestl_port_B_w )
105{
98106   /* bit 1, 2 unknown */
99   upd7759_set_bank_base(device, ((data & 0x38) >> 3)*0x20000);
107   upd7759_set_bank_base(device, ((data & 0x38) >> 3) * 0x20000);
100108}
101109
102static READ8_DEVICE_HANDLER( bladestl_speech_busy_r ){
110static READ8_DEVICE_HANDLER( bladestl_speech_busy_r )
111{
103112   return upd7759_busy_r(device) ? 1 : 0;
104113}
105114
106static WRITE8_DEVICE_HANDLER( bladestl_speech_ctrl_w ){
115static WRITE8_DEVICE_HANDLER( bladestl_speech_ctrl_w )
116{
107117   upd7759_reset_w(device, data & 1);
108118   upd7759_start_w(device, data & 2);
109119}
110120
121/*************************************
122 *
123 *  Address maps
124 *
125 *************************************/
126
111127static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
112   AM_RANGE(0x0000, 0x1fff) AM_READWRITE(K007342_r, K007342_w)   /* Color RAM + Video RAM */
113   AM_RANGE(0x2000, 0x21ff) AM_READWRITE(K007420_r, K007420_w)   /* Sprite RAM */
114   AM_RANGE(0x2200, 0x23ff) AM_READWRITE(K007342_scroll_r, K007342_scroll_w)   /* Scroll RAM */
115   AM_RANGE(0x2400, 0x245f) AM_RAM AM_BASE_GENERIC(paletteram)      /* palette */
116   AM_RANGE(0x2600, 0x2607) AM_WRITE(K007342_vreg_w)         /* Video Registers */
128   AM_RANGE(0x0000, 0x1fff) AM_DEVREADWRITE("k007342", k007342_r, k007342_w)   /* Color RAM + Video RAM */
129   AM_RANGE(0x2000, 0x21ff) AM_DEVREADWRITE("k007420", k007420_r, k007420_w)   /* Sprite RAM */
130   AM_RANGE(0x2200, 0x23ff) AM_DEVREADWRITE("k007342", k007342_scroll_r, k007342_scroll_w)   /* Scroll RAM */
131   AM_RANGE(0x2400, 0x245f) AM_RAM AM_BASE_MEMBER(bladestl_state, paletteram)      /* palette */
132   AM_RANGE(0x2600, 0x2607) AM_DEVWRITE("k007342", k007342_vreg_w)         /* Video Registers */
117133   AM_RANGE(0x2e00, 0x2e00) AM_READ_PORT("COINSW")            /* DIPSW #3, coinsw, startsw */
118134   AM_RANGE(0x2e01, 0x2e01) AM_READ_PORT("P1")               /* 1P controls */
119135   AM_RANGE(0x2e02, 0x2e02) AM_READ_PORT("P2")               /* 2P controls */
r6740r6741
123139   AM_RANGE(0x2ec0, 0x2ec0) AM_WRITE(watchdog_reset_w)         /* watchdog reset */
124140   AM_RANGE(0x2f00, 0x2f03) AM_READ(trackball_r)            /* Trackballs */
125141   AM_RANGE(0x2f40, 0x2f40) AM_WRITE(bladestl_bankswitch_w)   /* bankswitch control */
126   AM_RANGE(0x2f80, 0x2f9f) AM_READWRITE(K051733_r, K051733_w)   /* Protection: 051733 */
142   AM_RANGE(0x2f80, 0x2f9f) AM_DEVREADWRITE("k051733", k051733_r, k051733_w)   /* Protection: 051733 */
127143   AM_RANGE(0x2fc0, 0x2fc0) AM_WRITENOP                  /* ??? */
128144   AM_RANGE(0x4000, 0x5fff) AM_RAM                        /* Work RAM */
129145   AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank1")                  /* banked ROM */
r6740r6741
140156   AM_RANGE(0x8000, 0xffff) AM_ROM
141157ADDRESS_MAP_END
142158
143/***************************************************************************
144159
145    Input Ports
160/*************************************
161 *
162 *  Input ports
163 *
164 *************************************/
146165
147***************************************************************************/
148
149166static INPUT_PORTS_START( bladestl )
150167   PORT_START("DSW1")
151168   KONAMI_COINAGE_ALT_LOC(SW1)
r6740r6741
223240
224241
225242
243/*************************************
244 *
245 *  Graphics definitions
246 *
247 *************************************/
248
226249static const gfx_layout charlayout =
227250{
228251   8,8,         /* 8 x 8 characters */
r6740r6741
250273   GFXDECODE_ENTRY( "gfx1", 0x040000, spritelayout,   32,   16 )   /* colors 32..47 but using lookup table */
251274GFXDECODE_END
252275
253/***************************************************************************
254276
255    Machine Driver
277/*************************************
278 *
279 *  Machine driver
280 *
281 *************************************/
256282
257***************************************************************************/
258
259283static const ym2203_interface ym2203_config =
260284{
261285   {
r6740r6741
269293   NULL
270294};
271295
296static const k007342_interface bladestl_k007342_intf =
297{
298   0,   bladestl_tile_callback   /* gfx_num (for tile creation), callback */
299};
300
301static const k007420_interface bladestl_k007420_intf =
302{
303   0x3ff,    bladestl_sprite_callback   /* banklimit, callback */
304};
305
306
307static MACHINE_START( bladestl )
308{
309   bladestl_state *state = (bladestl_state *)machine->driver_data;
310   UINT8 *ROM = memory_region(machine, "maincpu");
311
312   memory_configure_bank(machine, "bank1", 0, 4, &ROM[0x10000], 0x2000);
313
314   state->audiocpu = devtag_get_device(machine, "audiocpu");
315   state->k007342 = devtag_get_device(machine, "k007342");
316   state->k007420 = devtag_get_device(machine, "k007420");
317
318   state_save_register_global(machine, state->spritebank);
319   state_save_register_global_array(machine, state->layer_colorbase);
320   state_save_register_global_array(machine, state->last_track);
321}
322
323static MACHINE_RESET( bladestl )
324{
325   bladestl_state *state = (bladestl_state *)machine->driver_data;
326   int i;
327
328   state->layer_colorbase[0] = 0;
329   state->layer_colorbase[1] = 1;
330   state->spritebank = 0;
331
332   for (i = 0; i < 4 ; i++)
333      state->last_track[i] = 0;
334}
335
272336static MACHINE_DRIVER_START( bladestl )
273337
338   /* driver data */
339   MDRV_DRIVER_DATA(bladestl_state)
340
274341   /* basic machine hardware */
275342   MDRV_CPU_ADD("maincpu", HD6309, 24000000/2)      /* 24MHz/2 (?) */
276343   MDRV_CPU_PROGRAM_MAP(main_map)
r6740r6741
281348
282349   MDRV_QUANTUM_TIME(HZ(600))
283350
351   MDRV_MACHINE_START(bladestl)
352   MDRV_MACHINE_RESET(bladestl)
353
284354   /* video hardware */
285355   MDRV_SCREEN_ADD("screen", RASTER)
286356   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
293363   MDRV_PALETTE_INIT(bladestl)
294364   MDRV_PALETTE_LENGTH(32 + 16*16)
295365
296   MDRV_VIDEO_START(bladestl)
297366   MDRV_VIDEO_UPDATE(bladestl)
298367
368   MDRV_K007342_ADD("k007342", bladestl_k007342_intf)
369   MDRV_K007420_ADD("k007420", bladestl_k007420_intf)
370   MDRV_K051733_ADD("k051733")
371
299372   /* sound hardware */
300373   /* the initialization order is important, the port callbacks being
301374       called at initialization time */
r6740r6741
309382   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.45)
310383MACHINE_DRIVER_END
311384
312/***************************************************************************
313385
314  Game ROMs
386/*************************************
387 *
388 *  ROM definition(s)
389 *
390 *************************************/
315391
316***************************************************************************/
317
318392ROM_START( bladestl )
319393   ROM_REGION( 0x18000, "maincpu", 0 ) /* code + banked roms */
320394   ROM_LOAD( "797t01.bin", 0x10000, 0x08000, CRC(89d7185d) SHA1(0d2f346d9515cab0389106c0e227fb0bd84a2c9c) )   /* fixed ROM */
r6740r6741
356430ROM_END
357431
358432
359GAME( 1987, bladestl, 0,        bladestl, bladestl, 0, ROT90, "Konami", "Blades of Steel (version T)", 0 )
360GAME( 1987, bladestle,bladestl, bladestl, bladstle, 0, ROT90, "Konami", "Blades of Steel (version E)", 0 )
433/*************************************
434 *
435 *  Game driver(s)
436 *
437 *************************************/
438
439GAME( 1987, bladestl,  0,        bladestl, bladestl, 0, ROT90, "Konami", "Blades of Steel (version T)", GAME_SUPPORTS_SAVE )
440GAME( 1987, bladestle, bladestl, bladestl, bladstle, 0, ROT90, "Konami", "Blades of Steel (version E)", GAME_SUPPORTS_SAVE )
src/mame/drivers/mcr68.c
r6740r6741
5757#include "cpu/m68000/m68000.h"
5858#include "audio/mcr.h"
5959#include "audio/williams.h"
60#include "mcr.h"
60#include "includes/mcr.h"
6161
6262
6363
src/mame/drivers/pbaction.c
r6740r6741
7070#include "machine/segacrpt.h"
7171
7272
73extern UINT8 *pbaction_videoram,*pbaction_colorram;
7374extern UINT8 *pbaction_videoram2,*pbaction_colorram2;
7475
7576extern WRITE8_HANDLER( pbaction_videoram_w );
r6740r6741
99100   AM_RANGE(0xc000, 0xcfff) AM_RAM AM_BASE(&work_ram)
100101   AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(pbaction_videoram2_w) AM_BASE(&pbaction_videoram2)
101102   AM_RANGE(0xd400, 0xd7ff) AM_RAM_WRITE(pbaction_colorram2_w) AM_BASE(&pbaction_colorram2)
102   AM_RANGE(0xd800, 0xdbff) AM_RAM_WRITE(pbaction_videoram_w) AM_BASE_GENERIC(videoram)
103   AM_RANGE(0xdc00, 0xdfff) AM_RAM_WRITE(pbaction_colorram_w) AM_BASE_GENERIC(colorram)
103   AM_RANGE(0xd800, 0xdbff) AM_RAM_WRITE(pbaction_videoram_w) AM_BASE(&pbaction_videoram)
104   AM_RANGE(0xdc00, 0xdfff) AM_RAM_WRITE(pbaction_colorram_w) AM_BASE(&pbaction_colorram)
104105   AM_RANGE(0xe000, 0xe07f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
105106   AM_RANGE(0xe400, 0xe5ff) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_le_w) AM_BASE_GENERIC(paletteram)
106107   AM_RANGE(0xe600, 0xe600) AM_READ_PORT("P1") AM_WRITE(interrupt_enable_w)
src/mame/drivers/funworld.c
r6740r6741
10601060#include "funworld.lh"
10611061
10621062/* from video */
1063extern UINT8* funworld_videoram;
1064extern UINT8* funworld_colorram;
1065
10631066WRITE8_HANDLER( funworld_videoram_w );
10641067WRITE8_HANDLER( funworld_colorram_w );
10651068PALETTE_INIT( funworld );
r6740r6741
11131116   AM_RANGE(0x0c00, 0x0c01) AM_DEVWRITE("ay8910", ay8910_address_data_w)
11141117   AM_RANGE(0x0e00, 0x0e00) AM_DEVWRITE("crtc", mc6845_address_w)
11151118   AM_RANGE(0x0e01, 0x0e01) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
1116   AM_RANGE(0x2000, 0x2fff) AM_RAM_WRITE(funworld_videoram_w) AM_BASE_GENERIC(videoram)
1117   AM_RANGE(0x3000, 0x3fff) AM_RAM_WRITE(funworld_colorram_w) AM_BASE_GENERIC(colorram)
1119   AM_RANGE(0x2000, 0x2fff) AM_RAM_WRITE(funworld_videoram_w) AM_BASE(&funworld_videoram)
1120   AM_RANGE(0x3000, 0x3fff) AM_RAM_WRITE(funworld_colorram_w) AM_BASE(&funworld_colorram)
11181121   AM_RANGE(0x4000, 0x4000) AM_READNOP
11191122   AM_RANGE(0x8000, 0xbfff) AM_ROM
11201123   AM_RANGE(0xc000, 0xffff) AM_ROM
r6740r6741
11311134   AM_RANGE(0x2c00, 0x2cff) AM_RAM   /* range for protection */
11321135   AM_RANGE(0x3600, 0x36ff) AM_RAM   /* some games use $3603-05 range for protection */
11331136   AM_RANGE(0x3c00, 0x3cff) AM_RAM   /* range for protection */
1134   AM_RANGE(0x4000, 0x4fff) AM_RAM_WRITE(funworld_videoram_w) AM_BASE_GENERIC(videoram)
1135   AM_RANGE(0x5000, 0x5fff) AM_RAM_WRITE(funworld_colorram_w) AM_BASE_GENERIC(colorram)
1137   AM_RANGE(0x4000, 0x4fff) AM_RAM_WRITE(funworld_videoram_w) AM_BASE(&funworld_videoram)
1138   AM_RANGE(0x5000, 0x5fff) AM_RAM_WRITE(funworld_colorram_w) AM_BASE(&funworld_colorram)
11361139   AM_RANGE(0x6000, 0xffff) AM_ROM
11371140ADDRESS_MAP_END
11381141
r6740r6741
11461149   AM_RANGE(0x0e01, 0x0e01) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
11471150   AM_RANGE(0x2000, 0x2000) AM_READNOP   /* some unknown reads */
11481151   AM_RANGE(0x3e00, 0x3fff) AM_RAM   /* some games use $3e03-05 range for protection */
1149   AM_RANGE(0x6000, 0x6fff) AM_RAM_WRITE(funworld_videoram_w) AM_BASE_GENERIC(videoram)
1150   AM_RANGE(0x7000, 0x7fff) AM_RAM_WRITE(funworld_colorram_w) AM_BASE_GENERIC(colorram)
1152   AM_RANGE(0x6000, 0x6fff) AM_RAM_WRITE(funworld_videoram_w) AM_BASE(&funworld_videoram)
1153   AM_RANGE(0x7000, 0x7fff) AM_RAM_WRITE(funworld_colorram_w) AM_BASE(&funworld_colorram)
11511154   AM_RANGE(0x8000, 0xffff) AM_ROM
11521155ADDRESS_MAP_END
11531156
r6740r6741
11591162   AM_RANGE(0x2c00, 0x2c01) AM_DEVWRITE("ay8910", ay8910_address_data_w)
11601163   AM_RANGE(0x2e00, 0x2e00) AM_DEVWRITE("crtc", mc6845_address_w)
11611164   AM_RANGE(0x2e01, 0x2e01) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
1162   AM_RANGE(0x4000, 0x4fff) AM_RAM_WRITE(funworld_videoram_w) AM_BASE_GENERIC(videoram)
1163   AM_RANGE(0x5000, 0x5fff) AM_RAM_WRITE(funworld_colorram_w) AM_BASE_GENERIC(colorram)
1165   AM_RANGE(0x4000, 0x4fff) AM_RAM_WRITE(funworld_videoram_w) AM_BASE(&funworld_videoram)
1166   AM_RANGE(0x5000, 0x5fff) AM_RAM_WRITE(funworld_colorram_w) AM_BASE(&funworld_colorram)
11641167   AM_RANGE(0x6000, 0xffff) AM_ROM
11651168ADDRESS_MAP_END
11661169
r6740r6741
11741177   AM_RANGE(0x1800, 0x1800) AM_DEVREAD("ay8910", ay8910_r)
11751178   AM_RANGE(0x1800, 0x1801) AM_DEVWRITE("ay8910", ay8910_address_data_w)
11761179//  AM_RANGE(0x2000, 0x2000) AM_READNOP /* some unknown reads... maybe a DSW */
1177   AM_RANGE(0x6000, 0x6fff) AM_RAM_WRITE(funworld_videoram_w) AM_BASE_GENERIC(videoram)
1178   AM_RANGE(0x7000, 0x7fff) AM_RAM_WRITE(funworld_colorram_w) AM_BASE_GENERIC(colorram)
1180   AM_RANGE(0x6000, 0x6fff) AM_RAM_WRITE(funworld_videoram_w) AM_BASE(&funworld_videoram)
1181   AM_RANGE(0x7000, 0x7fff) AM_RAM_WRITE(funworld_colorram_w) AM_BASE(&funworld_colorram)
11791182   AM_RANGE(0x8000, 0xffff) AM_ROM
11801183ADDRESS_MAP_END
11811184
src/mame/drivers/overdriv.c
r6740r6741
2121#include "driver.h"
2222#include "cpu/m68000/m68000.h"
2323#include "deprecat.h"
24#include "video/konamiic.h"
25#include "machine/eeprom.h"
24#include "video/konicdev.h"
25#include "machine/eepromdev.h"
2626#include "cpu/m6809/m6809.h"
2727#include "sound/2151intf.h"
2828#include "sound/k053260.h"
r6740r6741
3131VIDEO_START( overdriv );
3232VIDEO_UPDATE( overdriv );
3333
34extern void overdriv_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask);
35extern void overdriv_zoom_callback_0(running_machine *machine, int *code,int *color,int *flags);
36extern void overdriv_zoom_callback_1(running_machine *machine, int *code,int *color,int *flags);
3437
35static READ16_HANDLER( K051316_0_msb_r )
36{
37   return K051316_0_r(space,offset) << 8;
38}
39
40static READ16_HANDLER( K051316_1_msb_r )
41{
42   return K051316_1_r(space,offset) << 8;
43}
44
45static READ16_HANDLER( K051316_rom_0_msb_r )
46{
47   return K051316_rom_0_r(space,offset) << 8;
48}
49
50static READ16_HANDLER( K051316_rom_1_msb_r )
51{
52   return K051316_rom_1_r(space,offset) << 8;
53}
54
55static WRITE16_HANDLER( K051316_0_msb_w )
56{
57   if (ACCESSING_BITS_8_15)
58      K051316_0_w(space,offset,data >> 8);
59}
60
61static WRITE16_HANDLER( K051316_1_msb_w )
62{
63   if (ACCESSING_BITS_8_15)
64      K051316_1_w(space,offset,data >> 8);
65}
66
67static WRITE16_HANDLER( K051316_ctrl_0_msb_w )
68{
69   if (ACCESSING_BITS_8_15)
70      K051316_ctrl_0_w(space,offset,data >> 8);
71}
72
73static WRITE16_HANDLER( K051316_ctrl_1_msb_w )
74{
75   if (ACCESSING_BITS_8_15)
76      K051316_ctrl_1_w(space,offset,data >> 8);
77}
78
79
8038/***************************************************************************
8139
8240  EEPROM
8341
8442***************************************************************************/
8543
86static const UINT8 default_eeprom[128] =
44static const UINT8 overdriv_default_eeprom[128] =
8745{
8846   0x77,0x58,0xFF,0xFF,0x00,0x78,0x90,0x00,0x00,0x78,0x70,0x00,0x00,0x78,0x50,0x00,
8947   0x54,0x41,0x4B,0x51,0x31,0x36,0x46,0x55,0x4A,0xFF,0x03,0x00,0x02,0x70,0x02,0x50,
r6740r6741
10765   "010011000000"   /* unlock command */
10866};
10967
110static NVRAM_HANDLER( overdriv )
111{
112   if (read_or_write)
113      eeprom_save(file);
114   else
115   {
116      eeprom_init(machine, &eeprom_intf);
117
118      if (file)
119         eeprom_load(file);
120      else
121         eeprom_set_data(default_eeprom,sizeof(default_eeprom));
122   }
123}
124
12568static WRITE16_HANDLER( eeprom_w )
12669{
12770//logerror("%06x: write %04x to eeprom_w\n",cpu_get_pc(space->cpu),data);
r6740r6741
13073      /* bit 0 is data */
13174      /* bit 1 is clock (active high) */
13275      /* bit 2 is cs (active low) */
133      eeprom_write_bit(data & 0x01);
134      eeprom_set_cs_line((data & 0x04) ? CLEAR_LINE : ASSERT_LINE);
135      eeprom_set_clock_line((data & 0x02) ? ASSERT_LINE : CLEAR_LINE);
76      input_port_write(space->machine, "EEPROMOUT", data, 0xff);
13677   }
13778}
13879
13980
140
141
142
14381static INTERRUPT_GEN( cpuA_interrupt )
14482{
145   if (cpu_getiloops(device)) cpu_set_input_line(device, 5, HOLD_LINE);
146   else cpu_set_input_line(device, 4, HOLD_LINE);
83   if (cpu_getiloops(device))
84      cpu_set_input_line(device, 5, HOLD_LINE);
85   else
86      cpu_set_input_line(device, 4, HOLD_LINE);
14787}
14888
14989static INTERRUPT_GEN( cpuB_interrupt )
15090{
151   if (K053246_is_IRQ_enabled()) cpu_set_input_line(device, 4, HOLD_LINE);
91   const device_config *k053246 = devtag_get_device(device->machine, "k053246");
92
93   if (k053246_is_irq_enabled(k053246))
94      cpu_set_input_line(device, 4, HOLD_LINE);
15295}
15396
15497
r6740r6741
185128
186129static WRITE16_HANDLER( cpuB_ctrl_w )
187130{
131   const device_config *k053246 = devtag_get_device(space->machine, "k053246");
188132   COMBINE_DATA(&cpuB_ctrl);
189133
190134   if (ACCESSING_BITS_0_7)
191135   {
192136      /* bit 0 = enable sprite ROM reading */
193      K053246_set_OBJCHA_line((data & 0x01) ? ASSERT_LINE : CLEAR_LINE);
137      k053246_set_objcha_line(k053246, (data & 0x01) ? ASSERT_LINE : CLEAR_LINE);
194138
195139      /* bit 1 used but unknown (irq enable?) */
196140
r6740r6741
201145
202146static READ8_DEVICE_HANDLER( overdriv_sound_r )
203147{
204   return k053260_r(device,2 + offset);
148   return k053260_r(device, 2 + offset);
205149}
206150
207151static WRITE16_HANDLER( overdriv_soundirq_w )
r6740r6741
232176   AM_RANGE(0x100000, 0x10001f) AM_WRITENOP         /* 053252? (LSB) */
233177   AM_RANGE(0x140000, 0x140001) AM_WRITE(watchdog_reset16_w)
234178   AM_RANGE(0x180000, 0x180001) AM_READ_PORT("PADDLE")
235   AM_RANGE(0x1c0000, 0x1c001f) AM_WRITE(K051316_ctrl_0_msb_w)
236   AM_RANGE(0x1c8000, 0x1c801f) AM_WRITE(K051316_ctrl_1_msb_w)
237   AM_RANGE(0x1d0000, 0x1d001f) AM_WRITE(K053251_msb_w)
179   AM_RANGE(0x1c0000, 0x1c001f) AM_DEVWRITE8("k051316_1", k051316_ctrl_w, 0xff00)
180   AM_RANGE(0x1c8000, 0x1c801f) AM_DEVWRITE8("k051316_2", k051316_ctrl_w, 0xff00)
181   AM_RANGE(0x1d0000, 0x1d001f) AM_DEVWRITE("k053251", k053251_msb_w)
238182   AM_RANGE(0x1d8000, 0x1d8003) AM_DEVREADWRITE8("konami1", overdriv_sound_r, k053260_w, 0x00ff)   /* K053260 */
239183   AM_RANGE(0x1e0000, 0x1e0003) AM_DEVREADWRITE8("konami2", overdriv_sound_r, k053260_w, 0x00ff)   /* K053260 */
240184   AM_RANGE(0x1e8000, 0x1e8001) AM_WRITE(overdriv_soundirq_w)
241185   AM_RANGE(0x1f0000, 0x1f0001) AM_WRITE(cpuA_ctrl_w)   /* halt cpu B, coin counter, start lamp, other? */
242186   AM_RANGE(0x1f8000, 0x1f8001) AM_WRITE(eeprom_w)
243187   AM_RANGE(0x200000, 0x203fff) AM_RAM AM_SHARE("share1")
244   AM_RANGE(0x210000, 0x210fff) AM_READWRITE(K051316_0_msb_r,K051316_0_msb_w)
245   AM_RANGE(0x218000, 0x218fff) AM_READWRITE(K051316_1_msb_r,K051316_1_msb_w)
246   AM_RANGE(0x220000, 0x220fff) AM_READ(K051316_rom_0_msb_r)
247   AM_RANGE(0x228000, 0x228fff) AM_READ(K051316_rom_1_msb_r)
188   AM_RANGE(0x210000, 0x210fff) AM_DEVREADWRITE8("k051316_1", k051316_r, k051316_w, 0xff00)
189   AM_RANGE(0x218000, 0x218fff) AM_DEVREADWRITE8("k051316_2", k051316_r, k051316_w, 0xff00)
190   AM_RANGE(0x220000, 0x220fff) AM_DEVREAD8("k051316_1", k051316_rom_r, 0xff00)
191   AM_RANGE(0x228000, 0x228fff) AM_DEVREAD8("k051316_2", k051316_rom_r, 0xff00)
248192   AM_RANGE(0x230000, 0x230001) AM_WRITE(overdriv_cpuB_irq6_w)
249193   AM_RANGE(0x238000, 0x238001) AM_WRITE(overdriv_cpuB_irq5_w)
250194ADDRESS_MAP_END
r6740r6741
255199   AM_RANGE(0x0c0000, 0x0c1fff) AM_RAM
256200   AM_RANGE(0x100000, 0x10000f) AM_NOP   // K053250 #0
257201   AM_RANGE(0x108000, 0x10800f) AM_NOP   // K053250 #1
258   AM_RANGE(0x118000, 0x118fff) AM_READWRITE(K053247_word_r,K053247_word_w)
259   AM_RANGE(0x120000, 0x120001) AM_READ(K053246_word_r)
202   AM_RANGE(0x118000, 0x118fff) AM_DEVREADWRITE("k053246", k053247_word_r, k053247_word_w)
203   AM_RANGE(0x120000, 0x120001) AM_DEVREAD("k053246", k053246_word_r)
260204   AM_RANGE(0x128000, 0x128001) AM_READWRITE(cpuB_ctrl_r,cpuB_ctrl_w)    /* enable K053247 ROM reading, plus something else */
261   AM_RANGE(0x130000, 0x130007) AM_WRITE(K053246_word_w)
205   AM_RANGE(0x130000, 0x130007) AM_DEVWRITE("k053246", k053246_word_w)
262206   AM_RANGE(0x200000, 0x203fff) AM_RAM AM_SHARE("share1")
263207   AM_RANGE(0x208000, 0x20bfff) AM_RAM
264208   AM_RANGE(0x218000, 0x219fff) AM_READNOP   // K053250 #0 gfx ROM read (LSB)
r6740r6741
286230   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
287231   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )
288232   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
289   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
233   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
290234   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
291235
292236   PORT_START("SYSTEM")
r6740r6741
301245
302246   PORT_START("PADDLE")
303247   PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_SENSITIVITY(100) PORT_KEYDELTA(50)
248
249   PORT_START( "EEPROMOUT" )
250   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
251   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
252   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
304253INPUT_PORTS_END
305254
306255
307
256#if 0
308257static const gfx_layout charlayout =
309258{
310259   8,8,
r6740r6741
320269   GFXDECODE_ENTRY( "gfx4", 0, charlayout, 0, 0x80 )
321270   GFXDECODE_ENTRY( "gfx5", 0, charlayout, 0, 0x80 )
322271GFXDECODE_END
272#endif
323273
324274
325
326275static const k053260_interface k053260_config =
327276{
328277   "shared"
329278};
330279
280static const k053247_interface overdriv_k053246_intf =
281{
282   "screen",
283   "gfx1", 0,
284   NORMAL_PLANE_ORDER,
285   77, 22,
286   KONAMI_ROM_DEINTERLEAVE_4,
287   overdriv_sprite_callback
288};
331289
290static const k051316_interface overdriv_k051316_intf_1 =
291{
292   "gfx2", 1,
293   4, TRUE, 0,
294   1, 14, -1,
295   overdriv_zoom_callback_0
296};
332297
298static const k051316_interface overdriv_k051316_intf_2 =
299{
300   "gfx3", 2,
301   4, FALSE, 0,
302   0, 15, 1,
303   overdriv_zoom_callback_1
304};
305
306
333307static MACHINE_DRIVER_START( overdriv )
334308
335309   /* basic machine hardware */
r6740r6741
350324   MDRV_QUANTUM_TIME(HZ(12000))
351325
352326   MDRV_MACHINE_RESET(overdriv)
353   MDRV_NVRAM_HANDLER(overdriv)
354327
328   MDRV_EEPROM_ADD("eeprom", eeprom_intf, 128, overdriv_default_eeprom)
329
355330   /* video hardware */
356331   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS)
357332
r6740r6741
362337   MDRV_SCREEN_SIZE(64*8, 32*8)
363338   MDRV_SCREEN_VISIBLE_AREA(13*8, (64-13)*8-1, 0*8, 32*8-1 )
364339
365   MDRV_GFXDECODE(overdriv)
340//  MDRV_GFXDECODE(overdriv)
366341   MDRV_PALETTE_LENGTH(2048)
367342
368343   MDRV_VIDEO_START(overdriv)
369344   MDRV_VIDEO_UPDATE(overdriv)
370345
346   MDRV_K053246_ADD("k053246", overdriv_k053246_intf)
347   MDRV_K051316_ADD("k051316_1", overdriv_k051316_intf_1)
348   MDRV_K051316_ADD("k051316_2", overdriv_k051316_intf_2)
349   MDRV_K053251_ADD("k053251")
350
371351   /* sound hardware */
372352   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
373353
r6740r6741
433413ROM_END
434414
435415
436static DRIVER_INIT( overdriv )
437{
438   konami_rom_deinterleave_4(machine, "gfx1");
439}
440
441
442GAMEL( 1990, overdriv, 0, overdriv, overdriv, overdriv, ROT90, "Konami", "Over Drive", GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING, layout_overdriv )
416GAMEL( 1990, overdriv, 0, overdriv, overdriv, 0, ROT90, "Konami", "Over Drive", GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING, layout_overdriv )
src/mame/drivers/spcforce.c
r6740r6741
3737#include "sound/sn76496.h"
3838
3939
40extern UINT8 *spcforce_videoram;
41extern UINT8 *spcforce_colorram;
4042extern UINT8 *spcforce_scrollram;
4143
4244WRITE8_HANDLER( spcforce_flip_screen_w );
r6740r6741
9193   AM_RANGE(0x700b, 0x700b) AM_WRITE(spcforce_flip_screen_w)
9294   AM_RANGE(0x700e, 0x700e) AM_WRITE(interrupt_enable_w)
9395   AM_RANGE(0x700f, 0x700f) AM_WRITENOP
94   AM_RANGE(0x8000, 0x83ff) AM_RAM AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
95   AM_RANGE(0x9000, 0x93ff) AM_RAM AM_BASE_GENERIC(colorram)
96   AM_RANGE(0x8000, 0x83ff) AM_RAM AM_BASE(&spcforce_videoram)
97   AM_RANGE(0x9000, 0x93ff) AM_RAM AM_BASE(&spcforce_colorram)
9698   AM_RANGE(0xa000, 0xa3ff) AM_RAM AM_BASE(&spcforce_scrollram)
9799ADDRESS_MAP_END
98100
src/mame/drivers/xmen.c
r6740r6741
1616#include "driver.h"
1717#include "cpu/m68000/m68000.h"
1818#include "deprecat.h"
19#include "video/konamiic.h"
20#include "machine/eeprom.h"
19#include "video/konicdev.h"
20#include "machine/eepromdev.h"
2121#include "cpu/z80/z80.h"
2222#include "sound/2151intf.h"
2323#include "sound/k054539.h"
2424#include "rendlay.h"
2525#include "includes/xmen.h"
26#include "konamipt.h"
26#include "includes/konamipt.h"
2727
2828UINT16 xmen_current_frame;
2929
r6740r6741
3939
4040***************************************************************************/
4141
42static int init_eeprom_count;
43
44
4542static const eeprom_interface eeprom_intf =
4643{
4744   7,            /* address bits */
r6740r6741
5350   "0100110000000" /* unlock command */
5451};
5552
56static NVRAM_HANDLER( xmen )
53static WRITE16_HANDLER( eeprom_w )
5754{
58   if (read_or_write)
59      eeprom_save(file);
60   else
61   {
62      eeprom_init(machine, &eeprom_intf);
55   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
56   const device_config *k053246 = devtag_get_device(space->machine, "k053246");
6357
64      if (file)
65      {
66         init_eeprom_count = 0;
67         eeprom_load(file);
68      }
69      else
70         init_eeprom_count = 10;
71   }
72}
73
74static READ16_HANDLER( eeprom_r )
75{
76   int res;
77
78logerror("%06x eeprom_r\n",cpu_get_pc(space->cpu));
79   /* bit 6 is EEPROM data */
80   /* bit 7 is EEPROM ready */
81   /* bit 14 is service button */
82   res = input_port_read(space->machine, "EEPROM");
83   if (init_eeprom_count)
84   {
85      init_eeprom_count--;
86      res &= 0xbfff;
87   }
88   return res;
89}
90
91
92static WRITE16_HANDLER( eeprom_w )
93{
94logerror("%06x: write %04x to 108000\n",cpu_get_pc(space->cpu),data);
58   logerror("%06x: write %04x to 108000\n",cpu_get_pc(space->cpu),data);
9559   if (ACCESSING_BITS_0_7)
9660   {
9761      /* bit 0 = coin counter */
r6740r6741
10064      /* bit 2 is data */
10165      /* bit 3 is clock (active high) */
10266      /* bit 4 is cs (active low) */
103      eeprom_write_bit(data & 0x04);
104      eeprom_set_cs_line((data & 0x10) ? CLEAR_LINE : ASSERT_LINE);
105      eeprom_set_clock_line((data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
67      input_port_write(space->machine, "EEPROMOUT", data, 0xff);
10668   }
10769   if (ACCESSING_BITS_8_15)
10870   {
10971      /* bit 8 = enable sprite ROM reading */
110      K053246_set_OBJCHA_line((data & 0x0100) ? ASSERT_LINE : CLEAR_LINE);
72      k053246_set_objcha_line(k053246, (data & 0x0100) ? ASSERT_LINE : CLEAR_LINE);
11173      /* bit 9 = enable char ROM reading through the video RAM */
112      K052109_set_RMRD_line((data & 0x0200) ? ASSERT_LINE : CLEAR_LINE);
74      k052109_set_rmrd_line(k052109, (data & 0x0200) ? ASSERT_LINE : CLEAR_LINE);
11375   }
11476}
11577
r6740r6741
161123static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 )
162124   AM_RANGE(0x000000, 0x03ffff) AM_ROM
163125   AM_RANGE(0x080000, 0x0fffff) AM_ROM
164   AM_RANGE(0x100000, 0x100fff) AM_READWRITE(K053247_word_r, K053247_word_w)
126   AM_RANGE(0x100000, 0x100fff) AM_DEVREADWRITE("k053246", k053247_word_r, k053247_word_w)
165127   AM_RANGE(0x101000, 0x101fff) AM_RAM
166128   AM_RANGE(0x104000, 0x104fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
167129   AM_RANGE(0x108000, 0x108001) AM_WRITE(eeprom_w)
168   AM_RANGE(0x108020, 0x108027) AM_WRITE(K053246_word_w)
130   AM_RANGE(0x108020, 0x108027) AM_DEVWRITE("k053246", k053246_word_w)
169131   AM_RANGE(0x10804c, 0x10804d) AM_WRITE(sound_cmd_w)
170132   AM_RANGE(0x10804e, 0x10804f) AM_WRITE(sound_irq_w)
171133   AM_RANGE(0x108054, 0x108055) AM_READ(sound_status_r)
172   AM_RANGE(0x108060, 0x10807f) AM_WRITE(K053251_lsb_w)
134   AM_RANGE(0x108060, 0x10807f) AM_DEVWRITE("k053251", k053251_lsb_w)
173135   AM_RANGE(0x10a000, 0x10a001) AM_READ_PORT("P2_P4") AM_WRITE(watchdog_reset16_w)
174136   AM_RANGE(0x10a002, 0x10a003) AM_READ_PORT("P1_P3")
175   AM_RANGE(0x10a004, 0x10a005) AM_READ(eeprom_r)
176   AM_RANGE(0x10a00c, 0x10a00d) AM_READ(K053246_word_r)
137   AM_RANGE(0x10a004, 0x10a005) AM_READ_PORT("EEPROM")
138   AM_RANGE(0x10a00c, 0x10a00d) AM_DEVREAD("k053246", k053246_word_r)
177139   AM_RANGE(0x110000, 0x113fff) AM_RAM      /* main RAM */
178140   AM_RANGE(0x18fa00, 0x18fa01) AM_WRITE(xmen_18fa00_w)
179   AM_RANGE(0x18c000, 0x197fff) AM_READWRITE(K052109_lsb_r, K052109_lsb_w)
141   AM_RANGE(0x18c000, 0x197fff) AM_DEVREADWRITE("k052109", k052109_lsb_r, k052109_lsb_w)
180142ADDRESS_MAP_END
181143
182144static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
r6740r6741
200162   AM_RANGE(0x103000, 0x103fff) AM_RAM      /* 6p - a buffer? */
201163   AM_RANGE(0x104000, 0x104fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
202164   AM_RANGE(0x108000, 0x108001) AM_WRITE(eeprom_w)
203   AM_RANGE(0x108020, 0x108027) AM_WRITE(K053246_word_w) /* sprites */
165   AM_RANGE(0x108020, 0x108027) AM_DEVWRITE("k053246", k053246_word_w) /* sprites */
204166   AM_RANGE(0x10804c, 0x10804d) AM_WRITE(sound_cmd_w)
205167   AM_RANGE(0x10804e, 0x10804f) AM_WRITE(sound_irq_w)
206168   AM_RANGE(0x108054, 0x108055) AM_READ(sound_status_r)
207   AM_RANGE(0x108060, 0x10807f) AM_WRITE(K053251_lsb_w)
169   AM_RANGE(0x108060, 0x10807f) AM_DEVWRITE("k053251", k053251_lsb_w)
208170   AM_RANGE(0x10a000, 0x10a001) AM_READ_PORT("P2_P4") AM_WRITE(watchdog_reset16_w)
209171   AM_RANGE(0x10a002, 0x10a003) AM_READ_PORT("P1_P3")
210   AM_RANGE(0x10a004, 0x10a005) AM_READ(eeprom_r)
172   AM_RANGE(0x10a004, 0x10a005) AM_READ_PORT("EEPROM")
211173   AM_RANGE(0x10a006, 0x10a007) AM_READ_PORT("P5_P6")
212   AM_RANGE(0x10a00c, 0x10a00d) AM_READ(K053246_word_r) /* sprites */
174   AM_RANGE(0x10a00c, 0x10a00d) AM_DEVREAD("k053246", k053246_word_r) /* sprites */
213175   AM_RANGE(0x110000, 0x113fff) AM_RAM      /* main RAM */
214176   AM_RANGE(0x18fa00, 0x18fa01) AM_WRITE(xmen_18fa00_w)
215/*  AM_RANGE(0x18c000, 0x197fff) AM_WRITE(K052109_lsb_w) AM_BASE(&xmen6p_tilemapleft) */
177/*  AM_RANGE(0x18c000, 0x197fff) AM_DEVWRITE("k052109", k052109_lsb_w) AM_BASE(&xmen6p_tilemapleft) */
216178   AM_RANGE(0x18c000, 0x197fff) AM_RAM AM_BASE(&xmen6p_tilemapleft) /* left tilemap (p1,p2,p3 counters) */
217179/*
218180    AM_RANGE(0x1ac000, 0x1af7ff) AM_READONLY
r6740r6741
260222
261223   PORT_START("EEPROM")
262224   PORT_BIT( 0x003f, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
263   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
225   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
264226   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* EEPROM status - always 1 */
265227   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_START1 )
266228   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_START2 )
r6740r6741
269231   PORT_BIT( 0x3000, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
270232   PORT_SERVICE_NO_TOGGLE( 0x4000, IP_ACTIVE_LOW )
271233   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
234
235   PORT_START( "EEPROMOUT" )
236   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
237   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
238   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
272239INPUT_PORTS_END
273240
274241static INPUT_PORTS_START( xmen2p )
r6740r6741
284251   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_SERVICE1 )
285252   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_SERVICE2 )
286253   PORT_BIT( 0x003c, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
287   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
254   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
288255   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* EEPROM status - always 1 */
289256   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_START1 )
290257   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_START2 )
r6740r6741
293260   PORT_BIT( 0x3000, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
294261   PORT_SERVICE_NO_TOGGLE( 0x4000, IP_ACTIVE_LOW )
295262   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
263
264   PORT_START( "EEPROMOUT" )
265   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
266   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
267   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
296268INPUT_PORTS_END
297269
298270static CUSTOM_INPUT( xmen_frame_r )
r6740r6741
315287
316288   PORT_START("EEPROM")
317289   PORT_BIT( 0x003f, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* unused? */
318   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
290   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
319291   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* EEPROM status - always 1 */
320292   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_START1 )
321293   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_START2 )
r6740r6741
325297   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_START6 ) /* not verified */
326298   PORT_SERVICE_NO_TOGGLE( 0x4000, IP_ACTIVE_LOW )
327299   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(xmen_frame_r, NULL)   /* screen indicator? */
300
301   PORT_START( "EEPROMOUT" )
302   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
303   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
304   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
328305INPUT_PORTS_END
329306
330307
r6740r6741
346323   state_save_register_postload(machine, xmen_postload, NULL);
347324}
348325
326
327static const k052109_interface xmen_k052109_intf =
328{
329   "gfx1", 0,
330   NORMAL_PLANE_ORDER,
331   KONAMI_ROM_DEINTERLEAVE_2,
332   xmen_tile_callback
333};
334
335static const k053247_interface xmen_k053246_intf =
336{
337   "screen",
338   "gfx2", 1,
339   NORMAL_PLANE_ORDER,
340   53, -2,
341   KONAMI_ROM_DEINTERLEAVE_4,
342   xmen_sprite_callback
343};
344
349345static MACHINE_DRIVER_START( xmen )
350346
351347   /* basic machine hardware */
r6740r6741
358354
359355   MDRV_MACHINE_START(xmen)
360356
361   MDRV_NVRAM_HANDLER(xmen)
357   MDRV_EEPROM_NODEFAULT_ADD("eeprom", eeprom_intf)
362358
363359   /* video hardware */
364360   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS)
r6740r6741
371367   MDRV_SCREEN_VISIBLE_AREA(13*8, (64-13)*8-1, 2*8, 30*8-1 )   /* correct, same issue of TMNT2 */
372368   MDRV_PALETTE_LENGTH(2048)
373369
374   MDRV_VIDEO_START(xmen)
375370   MDRV_VIDEO_UPDATE(xmen)
376371
372   MDRV_K052109_ADD("k052109", xmen_k052109_intf)
373   MDRV_K053246_ADD("k053246", xmen_k053246_intf)
374   MDRV_K053251_ADD("k053251")
375
377376   /* sound hardware */
378377   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
379378
r6740r6741
402401   }
403402   else
404403   {
405//      if (xmen_irqenabled&0x04)
404//      if (xmen_irqenabled & 0x04)
406405//      {
407406         irq3_line_hold(device);
408407//          xmen_current_frame = 0x00;
r6740r6741
411410   }
412411}
413412
413static const k053247_interface xmen6p_k053246_intf =
414{
415   "lscreen",   /* is this correct? */
416   "gfx2", 1,
417   NORMAL_PLANE_ORDER,
418   53, -2,
419   KONAMI_ROM_DEINTERLEAVE_4,
420   xmen_sprite_callback
421};
422
414423static MACHINE_DRIVER_START( xmen6p )
415424
416425   /* basic machine hardware */
r6740r6741
421430   MDRV_CPU_ADD("audiocpu", Z80,8000000)   /* verified with M1, guessed but accurate */
422431   MDRV_CPU_PROGRAM_MAP(sound_map)
423432
433   MDRV_MACHINE_RESET(xmen6p)
424434
425   MDRV_NVRAM_HANDLER(xmen)
435   MDRV_EEPROM_NODEFAULT_ADD("eeprom", eeprom_intf)
426436
427   MDRV_MACHINE_RESET(xmen6p)
428
429437   /* video hardware */
430438   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS)
431439   MDRV_PALETTE_LENGTH(2048)
r6740r6741
445453   MDRV_SCREEN_SIZE(64*8, 32*8)
446454   MDRV_SCREEN_VISIBLE_AREA(16*8, 52*8-1, 2*8, 30*8-1)
447455
448
449456   MDRV_VIDEO_START(xmen6p)
450457   MDRV_VIDEO_UPDATE(xmen6p)
451458   MDRV_VIDEO_EOF(xmen6p)
452459
460   MDRV_K052109_ADD("k052109", xmen_k052109_intf)
461   MDRV_K053246_ADD("k053246", xmen6p_k053246_intf)
462   MDRV_K053251_ADD("k053251")
463
453464   /* sound hardware */
454465   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
455466
r6740r6741
774785   ROM_LOAD( "065-a06.1d",  0x000000, 0x200000, CRC(5adbcee0) SHA1(435feda697193bc51db80eba46be474cbbc1de4b) )
775786ROM_END
776787
788GAME( 1992, xmen,    0,    xmen, xmen,    0,   ROT0, "Konami", "X-Men (4 Players ver UBB)", 0 ) /* Second "version" letter denotes players, A=2 players, B=4 players, C=6 players ??? */
789GAME( 1992, xmenj,   xmen, xmen, xmen,    0,   ROT0, "Konami", "X-Men (4 Players ver JBA)", 0 )
790GAME( 1992, xmene,   xmen, xmen, xmen,    0,   ROT0, "Konami", "X-Men (4 Players ver EBA)", 0 )
791GAME( 1992, xmen2pe, xmen, xmen, xmen2p,  0,   ROT0, "Konami", "X-Men (2 Players ver EAA)", 0 )
792GAME( 1992, xmen2pa, xmen, xmen, xmen2p,  0,   ROT0, "Konami", "X-Men (2 Players ver AAA)", 0 )
793GAME( 1992, xmen2pj, xmen, xmen, xmen2p,  0,   ROT0, "Konami", "X-Men (2 Players ver JAA)", 0 )
777794
778
779
780static DRIVER_INIT( xmen )
781{
782   konami_rom_deinterleave_2(machine, "gfx1");
783   konami_rom_deinterleave_4(machine, "gfx2");
784}
785
786GAME( 1992, xmen,    0,    xmen, xmen,   xmen,   ROT0, "Konami", "X-Men (4 Players ver UBB)", 0 ) /* Second "version" letter denotes players, A=2 players, B=4 players, C=6 players ??? */
787GAME( 1992, xmenj,   xmen, xmen, xmen,   xmen,   ROT0, "Konami", "X-Men (4 Players ver JBA)", 0 )
788GAME( 1992, xmene,   xmen, xmen, xmen,   xmen,   ROT0, "Konami", "X-Men (4 Players ver EBA)", 0 )
789GAME( 1992, xmen2pe, xmen, xmen, xmen2p, xmen,   ROT0, "Konami", "X-Men (2 Players ver EAA)", 0 )
790GAME( 1992, xmen2pa, xmen, xmen, xmen2p, xmen,   ROT0, "Konami", "X-Men (2 Players ver AAA)", 0 )
791GAME( 1992, xmen2pj, xmen, xmen, xmen2p, xmen,   ROT0, "Konami", "X-Men (2 Players ver JAA)", 0 )
792
793GAME( 1992, xmen6p,  xmen, xmen6p,xmen6p,   xmen, ROT0, "Konami", "X-Men (6 Players ver ECB)", GAME_IMPERFECT_GRAPHICS )
794GAME( 1992, xmen6pu, xmen, xmen6p,xmen6p,   xmen, ROT0, "Konami", "X-Men (6 Players ver UCB)", GAME_IMPERFECT_GRAPHICS )
795GAME( 1992, xmen6p,  xmen, xmen6p,xmen6p, 0,   ROT0, "Konami", "X-Men (6 Players ver ECB)", GAME_IMPERFECT_GRAPHICS )
796GAME( 1992, xmen6pu, xmen, xmen6p,xmen6p, 0,   ROT0, "Konami", "X-Men (6 Players ver UCB)", GAME_IMPERFECT_GRAPHICS )
src/mame/drivers/mario.c
r6740r6741
9393#include "cpu/z80/z80.h"
9494#include "machine/z80dma.h"
9595
96#include "mario.h"
96#include "includes/mario.h"
9797
9898/*************************************
9999 *
src/mame/drivers/nbmj8900.c
r6740r6741
2424******************************************************************************/
2525
2626#include "driver.h"
27#include "nb1413m3.h"
27#include "includes/nb1413m3.h"
2828#include "cpu/z80/z80.h"
2929#include "sound/dac.h"
3030#include "sound/ay8910.h"
src/mame/drivers/atarifb.c
r6740r6741
105105#include "driver.h"
106106#include "cpu/m6502/m6502.h"
107107#include "deprecat.h"
108#include "atarifb.h"
108#include "includes/atarifb.h"
109109#include "sound/discrete.h"
110110
111111#include "atarifb.lh"
src/mame/drivers/lethal.c
r6740r6741
165165***************************************************************************/
166166
167167#include "driver.h"
168#include "video/konamiic.h"
168#include "video/konicdev.h"
169169#include "cpu/m6809/m6809.h"
170170#include "cpu/hd6309/hd6309.h"
171171#include "cpu/z80/z80.h"
172#include "machine/eeprom.h"
172#include "machine/eepromdev.h"
173173#include "sound/k054539.h"
174174
175175#define MAIN_CLOCK      XTAL_24MHz
r6740r6741
186186VIDEO_UPDATE(lethalen);
187187WRITE8_HANDLER(lethalen_palette_control);
188188
189static int init_eeprom_count;
189extern void lethalen_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask);
190extern void lethalen_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags);
191
190192static UINT8 cur_control2;
191193
192194/* Default Eeprom for the parent.. otherwise it will always complain first boot */
r6740r6741
208210   "0100110000000"    /* unlock command */
209211};
210212
211static NVRAM_HANDLER( lethalen )
212{
213   if (read_or_write)
214      eeprom_save(file);
215   else
216   {
217      eeprom_init(machine, &eeprom_intf);
218
219      if (file)
220      {
221         init_eeprom_count = 0;
222         eeprom_load(file);
223      }
224      else
225      {
226         init_eeprom_count = 10;
227         eeprom_set_data(lethalen_default_eeprom,48);
228
229      }
230   }
231}
232
233213static WRITE8_HANDLER( control2_w )
234214{
235215   /* bit 0 is data */
r6740r6741
242222
243223   cur_control2 = data;
244224
245   eeprom_write_bit(cur_control2 & 0x01);
246   eeprom_set_cs_line((cur_control2 & 0x02) ? CLEAR_LINE : ASSERT_LINE);
247   eeprom_set_clock_line((cur_control2 & 0x04) ? ASSERT_LINE : CLEAR_LINE);
225   input_port_write(space->machine, "EEPROMOUT", cur_control2, 0xff);
248226}
249227
250228static INTERRUPT_GEN(lethalen_interrupt)
251229{
252   if (K056832_is_IRQ_enabled(0)) cpu_set_input_line(device, HD6309_IRQ_LINE, HOLD_LINE);
230   const device_config *k056832 = devtag_get_device(device->machine, "k056832");
231
232   if (k056832_is_irq_enabled(k056832, 0))
233      cpu_set_input_line(device, HD6309_IRQ_LINE, HOLD_LINE);
253234}
254235
255236static WRITE8_HANDLER( sound_cmd_w )
r6740r6741
281262
282263static READ8_HANDLER( le_4800_r )
283264{
265   const device_config *k056832 = devtag_get_device(space->machine, "k056832");
266   const device_config *k053244 = devtag_get_device(space->machine, "k053244");
267   const device_config *k054000 = devtag_get_device(space->machine, "k054000");
268
284269   if (cur_control2 & 0x10)   // RAM enable
285270   {
286271      return space->machine->generic.paletteram.u8[offset];
r6740r6741
298283            case 0x44:
299284            case 0x45:
300285            case 0x46:
301               return K053244_r(space,offset-0x40);
286               return k053244_r(k053244, offset - 0x40);
302287
303288            case 0x80:
304289            case 0x81:
r6740r6741
332317            case 0x9d:
333318            case 0x9e:
334319            case 0x9f:
335               return K054000_r(space,offset-0x80);
320               return k054000_r(k054000, offset - 0x80);
336321
337322            case 0xca:
338               return sound_status_r(space,0);
323               return sound_status_r(space, 0);
339324         }
340325      }
341326      else if (offset < 0x1800)
342         return K053245_r(space,(offset - 0x0800) & 0x07ff);
327         return k053245_r(k053244, (offset - 0x0800) & 0x07ff);
343328      else if (offset < 0x2000)
344         return K056832_ram_code_lo_r(space,offset - 0x1800);
329         return k056832_ram_code_lo_r(k056832, offset - 0x1800);
345330      else if (offset < 0x2800)
346         return K056832_ram_code_hi_r(space,offset - 0x2000);
331         return k056832_ram_code_hi_r(k056832, offset - 0x2000);
347332      else if (offset < 0x3000)
348         return K056832_ram_attr_lo_r(space,offset - 0x2800);
333         return k056832_ram_attr_lo_r(k056832, offset - 0x2800);
349334      else // (offset < 0x3800)
350         return K056832_ram_attr_hi_r(space,offset - 0x3000);
335         return k056832_ram_attr_hi_r(k056832, offset - 0x3000);
351336   }
352337
353338   return 0;
r6740r6741
355340
356341static WRITE8_HANDLER( le_4800_w )
357342{
343   const device_config *k056832 = devtag_get_device(space->machine, "k056832");
344   const device_config *k053244 = devtag_get_device(space->machine, "k053244");
345   const device_config *k054000 = devtag_get_device(space->machine, "k054000");
346
358347   if (cur_control2 & 0x10)   // RAM enable
359348   {
360349      paletteram_xBBBBBGGGGGRRRRR_be_w(space,offset,data);
r6740r6741
380369            case 0x44:
381370            case 0x45:
382371            case 0x46:
383               K053244_w(space, offset-0x40, data);
372               k053244_w(k053244, offset - 0x40, data);
384373               break;
385374
386375            case 0x80:
r6740r6741
415404            case 0x9d:
416405            case 0x9e:
417406            case 0x9f:
418               K054000_w(space, offset-0x80, data);
407               k054000_w(k054000, offset - 0x80, data);
419408               break;
420409
421410            default:
r6740r6741
424413         }
425414      }
426415      else if (offset < 0x1800)
427      {
428         K053245_w(space, (offset - 0x0800) & 0x07ff, data);
429
430      }
416         k053245_w(k053244, (offset - 0x0800) & 0x07ff, data);
431417      else if (offset < 0x2000)
432         K056832_ram_code_lo_w(space, offset - 0x1800, data);
418         k056832_ram_code_lo_w(k056832, offset - 0x1800, data);
433419      else if (offset < 0x2800)
434         K056832_ram_code_hi_w(space, offset - 0x2000, data);
420         k056832_ram_code_hi_w(k056832, offset - 0x2000, data);
435421      else if (offset < 0x3000)
436         K056832_ram_attr_lo_w(space, offset - 0x2800, data);
422         k056832_ram_attr_lo_w(k056832, offset - 0x2800, data);
437423      else // (offset < 0x3800)
438         K056832_ram_attr_hi_w(space, offset - 0x3000, data);
424         k056832_ram_attr_hi_w(k056832, offset - 0x3000, data);
439425   }
440426}
441427
r6740r6741
450436   switch (offset)
451437   {
452438      case 0:
453         return GUNX(1)>>1;
439         return GUNX(1) >> 1;
454440      case 1:
455         if ((240-GUNY(1)) == 7)
441         if ((240 - GUNY(1)) == 7)
456442            return 0;
457443         else
458            return (240-GUNY(1));
444            return (240 - GUNY(1));
459445         break;
460446      case 2:
461         return GUNX(2)>>1;
447         return GUNX(2) >> 1;
462448      case 3:
463         if ((240-GUNY(2)) == 7)
449         if ((240 - GUNY(2)) == 7)
464450            return 0;
465451         else
466            return (240-GUNY(2));
452            return (240 - GUNY(2));
467453         break;
468454   }
469455
r6740r6741
483469static ADDRESS_MAP_START( le_main, ADDRESS_SPACE_PROGRAM, 8 )
484470   AM_RANGE(0x0000, 0x1fff) AM_ROMBANK("bank1")
485471   AM_RANGE(0x2000, 0x3fff) AM_RAM            // work RAM
486   AM_RANGE(0x4000, 0x403f) AM_WRITE(K056832_w)
487   AM_RANGE(0x4040, 0x404f) AM_WRITE(K056832_b_w)
472   AM_RANGE(0x4000, 0x403f) AM_DEVWRITE("k056832", k056832_w)
473   AM_RANGE(0x4040, 0x404f) AM_DEVWRITE("k056832", k056832_b_w)
488474   AM_RANGE(0x4080, 0x4080) AM_READNOP      // watchdog
489475   AM_RANGE(0x4090, 0x4090) AM_READNOP
490476   AM_RANGE(0x40a0, 0x40a0) AM_READNOP
r6740r6741
509495   AM_RANGE(0xfc03, 0xfc03) AM_READNOP
510496ADDRESS_MAP_END
511497
512/* sound */
513
514498static INPUT_PORTS_START( lethalen )
515499   PORT_START("INPUTS")
516500   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
r6740r6741
523507   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
524508
525509   PORT_START("DSW")
526   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)
510   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
527511   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* it must be 1 ? */
528512   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
529513   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
r6740r6741
540524   PORT_DIPSETTING(      0x0000, DEF_STR( Mono ) )
541525   PORT_DIPSETTING(      0x0080, DEF_STR( Stereo ) )
542526
527   PORT_START( "EEPROMOUT" )
528   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
529   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
530   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
531
543532   PORT_START("LIGHT0_X")
544533   PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X ) PORT_CROSSHAIR(X, 1.0, 0.0, 0) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(1)
545534
r6740r6741
569558   PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR(Y, -1.0, 0.0, 0) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(2) PORT_REVERSE
570559INPUT_PORTS_END
571560
561
562static const gfx_layout lethal_6bpp =
563{
564   16,16,
565   RGN_FRAC(1,2),
566   6,
567   { RGN_FRAC(1,2)+8,RGN_FRAC(1,2)+0, 8, 0, 24, 16 },
568   { 0, 1, 2, 3, 4, 5, 6, 7,
569   8*32+0, 8*32+1, 8*32+2, 8*32+3, 8*32+4, 8*32+5, 8*32+6, 8*32+7 },
570   { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
571      16*32, 17*32, 18*32, 19*32, 20*32, 21*32, 22*32, 23*32 },
572   128*8
573};
574
575/* we use this decode instead of the one done by the sprite video start due to it being 6bpp */
576static GFXDECODE_START( lethal )
577   GFXDECODE_ENTRY( "gfx2", 0, lethal_6bpp,   0x000/*0x400*/, 256  ) /* sprites tiles */
578GFXDECODE_END
579
580
581/* sound */
582
572583static const k054539_interface k054539_config =
573584{
574585   NULL,
r6740r6741
591602   device_reset(cputag_get_cpu(machine, "maincpu"));
592603}
593604
594static const gfx_layout lethal_6bpp =
605static const k056832_interface lethalen_k056832_intf =
595606{
596   16,16,
597   RGN_FRAC(1,2),
598   6,
599   { RGN_FRAC(1,2)+8,RGN_FRAC(1,2)+0, 8, 0, 24, 16 },
600   { 0, 1, 2, 3, 4, 5, 6, 7,
601   8*32+0, 8*32+1, 8*32+2, 8*32+3, 8*32+4, 8*32+5, 8*32+6, 8*32+7 },
602   { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
603      16*32, 17*32, 18*32, 19*32, 20*32, 21*32, 22*32, 23*32 },
604   128*8
607   "gfx1", 1,
608   K056832_BPP_8LE,
609   1, 0,
610   KONAMI_ROM_DEINTERLEAVE_NONE,
611   lethalen_tile_callback, "none"
605612};
606613
607/* we use this decode instead of the one done by the sprite video start due to it being 6bpp */
608static GFXDECODE_START( lethal )
609   GFXDECODE_ENTRY( "gfx2", 0, lethal_6bpp,   0x000/*0x400*/, 256  ) /* sprites tiles */
610GFXDECODE_END
614static const k05324x_interface lethalen_k05324x_intf =
615{
616   "gfx3", 2,
617   NORMAL_PLANE_ORDER,
618   95, 0,
619   KONAMI_ROM_DEINTERLEAVE_2,
620   lethalen_sprite_callback
621};
611622
623static const k05324x_interface lethalej_k05324x_intf =
624{
625   "gfx3", 2,
626   NORMAL_PLANE_ORDER,
627   -105, 0,
628   KONAMI_ROM_DEINTERLEAVE_2,
629   lethalen_sprite_callback
630};
631
612632static MACHINE_DRIVER_START( lethalen )
613633   /* basic machine hardware */
614634   MDRV_CPU_ADD("maincpu", HD6309, MAIN_CLOCK/2)   // ???
r6740r6741
621641   MDRV_MACHINE_START(lethalen)
622642   MDRV_MACHINE_RESET(lethalen)
623643
624   MDRV_NVRAM_HANDLER(lethalen)
644   MDRV_EEPROM_ADD("eeprom", eeprom_intf, 48, lethalen_default_eeprom)
625645
626646   MDRV_GFXDECODE(lethal)
627647
r6740r6741
640660   MDRV_VIDEO_START(lethalen)
641661   MDRV_VIDEO_UPDATE(lethalen)
642662
663   MDRV_K056832_ADD("k056832", lethalen_k056832_intf)
664   MDRV_K053244_ADD("k053244", lethalen_k05324x_intf)
665   MDRV_K054000_ADD("k054000")
666
643667   /* sound hardware */
644668   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
645669
r6740r6741
654678
655679   MDRV_SCREEN_MODIFY("screen")
656680   MDRV_SCREEN_VISIBLE_AREA(224, 512-1, 16, 240-1)
681
682   MDRV_DEVICE_REMOVE("k053244")
683   MDRV_K053244_ADD("k053244", lethalej_k05324x_intf)
657684MACHINE_DRIVER_END
658685
659686ROM_START( lethalen )   // US version UAE
r6740r6741
864891
865892static DRIVER_INIT( lethalen )
866893{
867   konami_rom_deinterleave_2_half(machine, "gfx2");
868   konami_rom_deinterleave_2(machine, "gfx3");
869   konami_rom_deinterleave_2(machine, "gfx4");
894   konamid_rom_deinterleave_2_half(machine, "gfx2");
895   konamid_rom_deinterleave_2(machine, "gfx4");
870896}
871897
872898GAME( 1992, lethalen,   0,        lethalen, lethalen, lethalen, ORIENTATION_FLIP_Y, "Konami", "Lethal Enforcers (ver UAE, 11/19/92 15:04)", GAME_IMPERFECT_GRAPHICS) // writes UE to eeprom
src/mame/drivers/exprraid.c
r6740r6741
210210#include "cpu/m6809/m6809.h"
211211#include "sound/2203intf.h"
212212#include "sound/3526intf.h"
213#include "exprraid.h"
213#include "includes/exprraid.h"
214214
215215
216216/*****************************************************************************************/
src/mame/drivers/gunbustr.c
r6740r6741
302302                 MACHINE DRIVERS
303303***********************************************************/
304304
305static MACHINE_RESET( gunbustr )
306{
307   taito_f3_soundsystem_reset(machine);
308
309   f3_68681_reset(machine);
310}
311
312
313305static const UINT8 default_eeprom[128]={
314306   0x00,0x01,0x00,0x85,0x00,0xfd,0x00,0xff,0x00,0x67,0x00,0x02,0x00,0x00,0x00,0x7b,
315307   0x00,0xff,0x00,0xff,0x00,0x78,0x00,0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
r6740r6741
352344   MDRV_CPU_PROGRAM_MAP(gunbustr_map)
353345   MDRV_CPU_VBLANK_INT("screen", gunbustr_interrupt) /* VBL */
354346
355   TAITO_F3_SOUND_SYSTEM_CPU(16000000)
356
357   MDRV_MACHINE_RESET(gunbustr)
358347   MDRV_NVRAM_HANDLER(gunbustr)
359348
360349   /* video hardware */
r6740r6741
372361   MDRV_VIDEO_UPDATE(gunbustr)
373362
374363   /* sound hardware */
375   TAITO_F3_SOUND_SYSTEM_ES5505(30476100/2)
364   MDRV_IMPORT_FROM(taito_f3_sound)
376365MACHINE_DRIVER_END
377366
378367/***************************************************************************/
src/mame/drivers/scotrsht.c
r6740r6741
3636#include "cpu/z80/z80.h"
3737#include "cpu/m6809/m6809.h"
3838#include "sound/2203intf.h"
39#include "konamipt.h"
39#include "includes/konamipt.h"
4040
41extern UINT8 *scotrsht_videoram;
42extern UINT8 *scotrsht_colorram;
4143extern UINT8 *scotrsht_scroll;
4244
4345extern WRITE8_HANDLER( scotrsht_videoram_w );
r6740r6741
7072}
7173
7274static ADDRESS_MAP_START( scotrsht_map, ADDRESS_SPACE_PROGRAM, 8 )
73   AM_RANGE(0x0000, 0x07ff) AM_RAM_WRITE(scotrsht_colorram_w) AM_BASE_GENERIC(colorram)
74    AM_RANGE(0x0800, 0x0fff) AM_RAM_WRITE(scotrsht_videoram_w) AM_BASE_GENERIC(videoram)
75   AM_RANGE(0x0000, 0x07ff) AM_RAM_WRITE(scotrsht_colorram_w) AM_BASE(&scotrsht_colorram)
76    AM_RANGE(0x0800, 0x0fff) AM_RAM_WRITE(scotrsht_videoram_w) AM_BASE(&scotrsht_videoram)
7577    AM_RANGE(0x1000, 0x10bf) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* sprites */
7678   AM_RANGE(0x10c0, 0x1fff) AM_RAM /* work ram */
7779    AM_RANGE(0x2000, 0x201f) AM_RAM AM_BASE(&scotrsht_scroll) /* scroll registers */
src/mame/drivers/taito_z.c
r6740r6741
877877
878878#include "driver.h"
879879#include "cpu/z80/z80.h"
880#include "taitoipt.h"
880#include "includes/taitoipt.h"
881881#include "cpu/m68000/m68000.h"
882882#include "machine/eepromdev.h"
883883#include "video/taitoic.h"
src/mame/drivers/cojag.c
r6740r6741
294294#include "cpu/jaguar/jaguar.h"
295295#include "machine/idectrl.h"
296296#include "sound/dac.h"
297#include "jaguar.h"
297#include "includes/jaguar.h"
298298
299299
300300#define JAGUAR_CLOCK      XTAL_52MHz
r6740r6741
371371   /* halt the CPUs */
372372   jaguargpu_ctrl_w(cputag_get_cpu(machine, "gpu"), G_CTRL, 0, 0xffffffff);
373373   jaguardsp_ctrl_w(cputag_get_cpu(machine, "audiocpu"), D_CTRL, 0, 0xffffffff);
374
375   /* init the sound system */
376   cojag_sound_reset(machine);
377
378   /* reset the IDE controller */
379   devtag_reset(machine, "ide");
380374}
381375
382376
r6740r6741
11231117
11241118   MDRV_IDE_CONTROLLER_ADD("ide", jaguar_external_int)
11251119
1120   MDRV_TIMER_ADD("serial_timer", jaguar_serial_callback)
1121
11261122   /* video hardware */
11271123   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
11281124
src/mame/drivers/rastan.c
r6740r6741
159159#include "driver.h"
160160#include "cpu/z80/z80.h"
161161#include "cpu/m68000/m68000.h"
162#include "taitoipt.h"
162#include "includes/taitoipt.h"
163163#include "video/taitoic.h"
164164#include "audio/taitosnd.h"
165165#include "sound/2151intf.h"
src/mame/drivers/darkhors.c
r6740r6741
6060#include "machine/eeprom.h"
6161#include "sound/okim6295.h"
6262#include "sound/st0016.h"
63#include "st0016.h"
63#include "includes/st0016.h"
6464#include "cpu/z80/z80.h"
6565
6666#define DARKHORS_DEBUG   0
src/mame/drivers/bishjan.c
r6740r6741
4242                              Tilemaps Access
4343***************************************************************************/
4444
45static UINT8   *bishjan_colorram;
4546static UINT8   *bishjan_videoram_1_lo,   *bishjan_videoram_1_hi;
4647static UINT8   *bishjan_videoram_2_lo,   *bishjan_videoram_2_hi;
4748
r6740r6741
227228
228229   bishjan_videoram_2_hi = auto_alloc_array(machine, UINT8, 0x80 * 0x40);
229230
230   machine->generic.colorram.u8 = auto_alloc_array(machine, UINT8, 256*3);
231   bishjan_colorram = auto_alloc_array(machine, UINT8, 256*3);
231232}
232233
233234static VIDEO_UPDATE( bishjan )
r6740r6741
282283         break;
283284
284285      case 1:
285         space->machine->generic.colorram.u8[colordac_offs] = data;
286         bishjan_colorram[colordac_offs] = data;
286287         palette_set_color_rgb(space->machine, colordac_offs/3,
287            pal6bit(space->machine->generic.colorram.u8[(colordac_offs/3)*3+0]),
288            pal6bit(space->machine->generic.colorram.u8[(colordac_offs/3)*3+1]),
289            pal6bit(space->machine->generic.colorram.u8[(colordac_offs/3)*3+2])
288            pal6bit(bishjan_colorram[(colordac_offs/3)*3+0]),
289            pal6bit(bishjan_colorram[(colordac_offs/3)*3+1]),
290            pal6bit(bishjan_colorram[(colordac_offs/3)*3+2])
290291         );
291292         colordac_offs = (colordac_offs+1) % (256*3);
292293         break;
src/mame/drivers/equites.c
r6740r6741
372372#include "sound/msm5232.h"
373373#include "sound/dac.h"
374374#include "sound/samples.h"
375#include "equites.h"
375#include "includes/equites.h"
376376
377377#define HVOLTAGE_DEBUG   0
378378#define EASY_TEST_MODE   0
src/mame/drivers/mirax.c
r6740r6741
7575
7676static UINT8 nAyCtrl, nAyData;
7777static UINT8 nmi_mask;
78static UINT8 *videoram;
79static UINT8 *colorram;
7880
7981static VIDEO_START(mirax)
8082{
r6740r6741
117119   {
118120      for (x=0;x<32;x++)
119121      {
120         int tile = screen->machine->generic.videoram.u8[count];
121         int color = (screen->machine->generic.colorram.u8[x*2]<<8) | (screen->machine->generic.colorram.u8[(x*2)+1]);
122         int tile = videoram[count];
123         int color = (colorram[x*2]<<8) | (colorram[(x*2)+1]);
122124         int x_scroll = (color & 0xff00)>>8;
123125         tile |= ((color & 0xe0)<<3);
124126
r6740r6741
139141   {
140142      for (x=0;x<32;x++)
141143      {
142         int tile = screen->machine->generic.videoram.u8[count];
143         int color = (screen->machine->generic.colorram.u8[x*2]<<8) | (screen->machine->generic.colorram.u8[(x*2)+1]);
144         int tile = videoram[count];
145         int color = (colorram[x*2]<<8) | (colorram[(x*2)+1]);
144146         int x_scroll = (color & 0xff00)>>8;
145147         tile |= ((color & 0xe0)<<3);
146148
r6740r6741
204206static ADDRESS_MAP_START( mirax_main_map, ADDRESS_SPACE_PROGRAM, 8 )
205207   AM_RANGE(0x0000, 0xbfff) AM_ROM
206208   AM_RANGE(0xc800, 0xd7ff) AM_RAM
207   AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_BASE_GENERIC(videoram)
209   AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_BASE(&videoram)
208210   AM_RANGE(0xe800, 0xe9ff) AM_RAM AM_BASE_GENERIC(spriteram)
209   AM_RANGE(0xea00, 0xea3f) AM_RAM AM_BASE_GENERIC(colorram) //per-column color + bank bits for the videoram
211   AM_RANGE(0xea00, 0xea3f) AM_RAM AM_BASE(&colorram) //per-column color + bank bits for the videoram
210212   AM_RANGE(0xf000, 0xf000) AM_READ_PORT("P1")
211213   AM_RANGE(0xf100, 0xf100) AM_READ_PORT("P2")
212214   AM_RANGE(0xf200, 0xf200) AM_READ_PORT("DSW1")
src/mame/drivers/gradius3.c
r6740r6741
2020
2121#include "driver.h"
2222#include "deprecat.h"
23#include "video/konamiic.h"
23#include "video/konicdev.h"
2424#include "cpu/m68000/m68000.h"
2525#include "cpu/z80/z80.h"
2626#include "sound/2151intf.h"
2727#include "sound/k007232.h"
28#include "konamipt.h"
28#include "includes/konamipt.h"
2929
3030extern UINT16 *gradius3_gfxram;
3131extern int gradius3_priority;
r6740r6741
3434WRITE16_HANDLER( gradius3_gfxram_w );
3535VIDEO_UPDATE( gradius3 );
3636
37extern void gradius3_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask,int *shadow);
38extern void gradius3_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
3739
3840
3941static READ16_HANDLER( K052109_halfword_r )
4042{
41   return K052109_r(space,offset);
43   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
44   return k052109_r(k052109, offset);
4245}
4346
4447static WRITE16_HANDLER( K052109_halfword_w )
4548{
49   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
4650   if (ACCESSING_BITS_0_7)
47      K052109_w(space,offset,data & 0xff);
51      k052109_w(k052109, offset, data & 0xff);
4852
4953   /* is this a bug in the game or something else? */
5054   if (!ACCESSING_BITS_0_7)
51      K052109_w(space,offset,(data >> 8) & 0xff);
55      k052109_w(k052109, offset, (data >> 8) & 0xff);
5256//      logerror("%06x half %04x = %04x\n",cpu_get_pc(space->cpu),offset,data);
5357}
5458
5559static READ16_HANDLER( K051937_halfword_r )
5660{
57   return K051937_r(space,offset);
61   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
62   return k051937_r(k051960, offset);
5863}
5964
6065static WRITE16_HANDLER( K051937_halfword_w )
6166{
67   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
68
6269   if (ACCESSING_BITS_0_7)
63      K051937_w(space,offset,data & 0xff);
70      k051937_w(k051960, offset, data & 0xff);
6471}
6572
6673static READ16_HANDLER( K051960_halfword_r )
6774{
68   return K051960_r(space,offset);
75   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
76   return k051960_r(k051960, offset);
6977}
7078
7179static WRITE16_HANDLER( K051960_halfword_w )
7280{
81   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
7382   if (ACCESSING_BITS_0_7)
74      K051960_w(space,offset,data & 0xff);
83      k051960_w(k051960, offset, data & 0xff);
7584}
7685
7786
r6740r6741
287296
288297
289298
299static const k052109_interface gradius3_k052109_intf =
300{
301   "gfx1", 0,
302   GRADIUS3_PLANE_ORDER,
303   KONAMI_ROM_DEINTERLEAVE_NONE,
304   gradius3_tile_callback
305};
306
307static const k051960_interface gradius3_k051960_intf =
308{
309   "gfx2", 1,
310   GRADIUS3_PLANE_ORDER,
311   KONAMI_ROM_DEINTERLEAVE_2,
312   gradius3_sprite_callback
313};
314
290315static MACHINE_DRIVER_START( gradius3 )
291316
292317   /* basic machine hardware */
r6740r6741
321346   MDRV_VIDEO_START(gradius3)
322347   MDRV_VIDEO_UPDATE(gradius3)
323348
349   MDRV_K052109_ADD("k052109", gradius3_k052109_intf)
350   MDRV_K051960_ADD("k051960", gradius3_k051960_intf)
351
324352   /* sound hardware */
325353   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
326354
r6740r6741
471499ROM_END
472500
473501
474static DRIVER_INIT( gradius3 )
475{
476   konami_rom_deinterleave_2(machine, "gfx2");
477}
478502
479
480
481GAME( 1989, gradius3, 0,        gradius3, gradius3, gradius3, ROT0, "Konami", "Gradius III (Japan)", 0 )
482GAME( 1989, gradius3a, gradius3, gradius3, gradius3, gradius3, ROT0, "Konami", "Gradius III (Asia)", 0 )
483GAME( 1989, gradius3e, gradius3, gradius3, gradius3, gradius3, ROT0, "Konami", "Gradius III (World ?)", 0 )
503GAME( 1989, gradius3, 0,        gradius3, gradius3, 0, ROT0, "Konami", "Gradius III (Japan)", 0 )
504GAME( 1989, gradius3a, gradius3, gradius3, gradius3, 0, ROT0, "Konami", "Gradius III (Asia)", 0 )
505GAME( 1989, gradius3e, gradius3, gradius3, gradius3, 0, ROT0, "Konami", "Gradius III (World ?)", 0 )
src/mame/drivers/cardline.c
r6740r6741
2323#include "cardline.lh"
2424
2525static int cardline_video;
26static UINT8 *videoram;
27static UINT8 *colorram;
2628
2729#define DRAW_TILE(machine, offset, transparency) drawgfx_transpen(bitmap, cliprect, machine->gfx[0],\
28               (machine->generic.videoram.u8[index+offset] | (machine->generic.colorram.u8[index+offset]<<8))&0x3fff,\
29               (machine->generic.colorram.u8[index+offset]&0x80)>>7,\
30               (videoram[index+offset] | (colorram[index+offset]<<8))&0x3fff,\
31               (colorram[index+offset]&0x80)>>7,\
3032               0,0,\
3133               x<<3, y<<3,\
3234               transparency?transparency:-1);
r6740r6741
5961static WRITE8_HANDLER(vram_w)
6062{
6163   offset+=0x1000*((cardline_video&2)>>1);
62   space->machine->generic.videoram.u8[offset]=data;
64   videoram[offset]=data;
6365}
6466
6567static WRITE8_HANDLER(attr_w)
6668{
6769   offset+=0x1000*((cardline_video&2)>>1);
68   space->machine->generic.colorram.u8[offset]=data;
70   colorram[offset]=data;
6971}
7072
7173static WRITE8_HANDLER(video_w)
r6740r6741
111113   AM_RANGE(0x2840, 0x2840) AM_NOP
112114   AM_RANGE(0x2880, 0x2880) AM_NOP
113115   AM_RANGE(0x3003, 0x3003) AM_NOP
114   AM_RANGE(0xc000, 0xdfff) AM_WRITE(vram_w) AM_BASE_GENERIC(videoram)
115   AM_RANGE(0xe000, 0xffff) AM_WRITE(attr_w) AM_BASE_GENERIC(colorram)
116   AM_RANGE(0xc000, 0xdfff) AM_WRITE(vram_w) AM_BASE(&videoram)
117   AM_RANGE(0xe000, 0xffff) AM_WRITE(attr_w) AM_BASE(&colorram)
116118   /* Ports */
117119   AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_READWRITE(unk_r, video_w)
118120ADDRESS_MAP_END
src/mame/drivers/mystwarr.c
r6740r6741
2525#include "deprecat.h"
2626
2727#include "video/konamiic.h"
28#include "konamigx.h"
28#include "includes/konamigx.h"
2929#include "cpu/m68000/m68000.h"
3030#include "cpu/z80/z80.h"
31#include "machine/eeprom.h"
31#include "machine/eepromdev.h"
3232#include "sound/k054539.h"
33#include "konamipt.h"
33#include "includes/konamipt.h"
3434
3535VIDEO_START(gaiapols);
3636VIDEO_START(dadandrn);
r6740r6741
5353
5454static UINT16 *gx_workram;
5555
56static INT32 init_eeprom_count;
5756static UINT8 mw_irq_control;
5857
5958static const eeprom_interface eeprom_intf =
r6740r6741
6968
7069/* Gaiapolis and Polygonet Commanders use the ER5911,
7170   but the command formats are slightly different.  Why? */
72static const eeprom_interface eeprom_intf_gaia =
71static const eeprom_interface gaia_eeprom_intf =
7372{
7473   7,         /* address bits */
7574   8,         /* data bits */
r6740r6741
8079   "0100110000000" /* unlock command */
8180};
8281
83static NVRAM_HANDLER(mystwarr)
82static READ16_HANDLER( eeprom_r )
8483{
85   if (read_or_write)
86      eeprom_save(file);
87   else
88   {
89      eeprom_init(machine, &eeprom_intf);
90
91      if (file)
92      {
93         init_eeprom_count = 0;
94         eeprom_load(file);
95      }
96      else
97         init_eeprom_count = 10;
98   }
99}
100
101static NVRAM_HANDLER(gaiapols)
102{
103   if (read_or_write)
104      eeprom_save(file);
105   else
106   {
107      eeprom_init(machine, &eeprom_intf_gaia);
108
109      if (file)
110      {
111         init_eeprom_count = 0;
112         eeprom_load(file);
113      }
114      else
115         init_eeprom_count = 10;
116   }
117}
118
119static READ16_HANDLER( mweeprom_r )
120{
12184   if (ACCESSING_BITS_0_7)
12285   {
123      int res = input_port_read(space->machine, "IN1");
124
125      if (init_eeprom_count)
126      {
127         init_eeprom_count--;
128         res &= ~0x04;
129      }
130
131      return res;
86      return input_port_read(space->machine, "IN1");
13287   }
13388
13489//  logerror("msb access to eeprom port\n");
r6740r6741
13691   return 0;
13792}
13893
139static READ16_HANDLER( vseeprom_r )
140{
141   if (ACCESSING_BITS_0_7)
142   {
143      int res = input_port_read(space->machine, "IN1");
144
145      if (init_eeprom_count)
146      {
147         init_eeprom_count--;
148         res &= ~0x08;
149      }
150
151      return res;
152   }
153
154//  logerror("msb access to eeprom port\n");
155
156   return 0;
157}
158
15994static WRITE16_HANDLER( mweeprom_w )
16095{
16196   if (ACCESSING_BITS_8_15)
16297   {
163      eeprom_write_bit((data&0x0100) ? 1 : 0);
164      eeprom_set_cs_line((data&0x0200) ? CLEAR_LINE : ASSERT_LINE);
165      eeprom_set_clock_line((data&0x0400) ? ASSERT_LINE : CLEAR_LINE);
166      return;
98      input_port_write(space->machine, "EEPROMOUT", data, 0xffff);
16799   }
168100
169101//  logerror("unknown LSB write %x to eeprom\n", data);
r6740r6741
184116{
185117   if (ACCESSING_BITS_0_7)
186118   {
187      eeprom_write_bit((data&0x01) ? 1 : 0);
188      eeprom_set_cs_line((data&0x02) ? CLEAR_LINE : ASSERT_LINE);
189      eeprom_set_clock_line((data&0x04) ? ASSERT_LINE : CLEAR_LINE);
190      return;
119      input_port_write(space->machine, "EEPROMOUT", data, 0xff);
191120   }
192121}
193122
r6740r6741
315244   }
316245}
317246
318static READ16_HANDLER( mmcoins_r )
319{
320   int res = input_port_read(space->machine, "IN0");
321
322   if (init_eeprom_count)
323   {
324      init_eeprom_count--;
325      res &= ~0x10;
326   }
327
328   return res;
329}
330
331static READ16_HANDLER( dddcoins_r )
332{
333   int res = (input_port_read(space->machine, "IN0")<<8) | input_port_read(space->machine, "P1");
334
335   if (init_eeprom_count)
336   {
337      init_eeprom_count--;
338      res &= ~0x0800;
339   }
340
341   return res;
342}
343
344247/* the interface with the 053247 is weird. The chip can address only 0x1000 bytes */
345248/* of RAM, but they put 0x10000 there. The CPU can access them all. */
346249static READ16_HANDLER( K053247_scattered_word_r )
r6740r6741
385288   AM_RANGE(0x492000, 0x492001) AM_WRITENOP   // watchdog
386289   AM_RANGE(0x494000, 0x494001) AM_READ_PORT("P1_P2")
387290   AM_RANGE(0x494002, 0x494003) AM_READ_PORT("P3_P4")
388   AM_RANGE(0x496000, 0x496001) AM_READ(mmcoins_r)
389   AM_RANGE(0x496002, 0x496003) AM_READ(mweeprom_r)
291   AM_RANGE(0x496000, 0x496001) AM_READ_PORT("IN0")
292   AM_RANGE(0x496002, 0x496003) AM_READ(eeprom_r)
390293   AM_RANGE(0x49800c, 0x49800d) AM_WRITE(sound_cmd1_w)
391294   AM_RANGE(0x49800e, 0x49800f) AM_WRITE(sound_cmd2_w)
392295   AM_RANGE(0x498014, 0x498015) AM_READ(sound_status_r)
r6740r6741
431334   AM_RANGE(0x270000, 0x27003f) AM_WRITE(K056832_word_w)
432335   AM_RANGE(0x274000, 0x274001) AM_READ_PORT("P1_P3")
433336   AM_RANGE(0x274002, 0x274003) AM_READ_PORT("P2_P4")
434   AM_RANGE(0x278000, 0x278001) AM_READ(mmcoins_r)
435   AM_RANGE(0x278002, 0x278003) AM_READ(vseeprom_r)
337   AM_RANGE(0x278000, 0x278001) AM_READ_PORT("IN0")
338   AM_RANGE(0x278002, 0x278003) AM_READ(eeprom_r)
436339   AM_RANGE(0x27c000, 0x27c001) AM_READNOP   // watchdog lives here
437340   AM_RANGE(0x27c000, 0x27c001) AM_WRITE(mmeeprom_w)
438341   AM_RANGE(0x300000, 0x301fff) AM_READWRITE(K056832_ram_word_r,K056832_ram_word_w)
r6740r6741
475378   AM_RANGE(0x270000, 0x27003f) AM_WRITE(K056832_word_w)
476379   AM_RANGE(0x274000, 0x274001) AM_READ_PORT("P1_P3")
477380   AM_RANGE(0x274002, 0x274003) AM_READ_PORT("P2_P4")
478   AM_RANGE(0x278000, 0x278001) AM_READ(mmcoins_r)
479   AM_RANGE(0x278002, 0x278003) AM_READ(vseeprom_r)
381   AM_RANGE(0x278000, 0x278001) AM_READ_PORT("IN0")
382   AM_RANGE(0x278002, 0x278003) AM_READ(eeprom_r)
480383   AM_RANGE(0x27c000, 0x27c001) AM_READNOP      // watchdog lives here
481384   AM_RANGE(0x27c000, 0x27c001) AM_WRITE(mmeeprom_w)
482385   AM_RANGE(0x300000, 0x301fff) AM_READWRITE(K056832_ram_word_r,K056832_ram_word_w)
r6740r6741
561464   AM_RANGE(0x412000, 0x412001) AM_READWRITE(mccontrol_r,mccontrol_w)
562465   AM_RANGE(0x414000, 0x414001) AM_READ_PORT("P1_P2")
563466   AM_RANGE(0x414002, 0x414003) AM_READ_PORT("P3_P4")
564   AM_RANGE(0x416000, 0x416001) AM_READ(mmcoins_r)                  // coin
565   AM_RANGE(0x416002, 0x416003) AM_READ(mweeprom_r)               // eeprom read
467   AM_RANGE(0x416000, 0x416001) AM_READ_PORT("IN0")
468   AM_RANGE(0x416002, 0x416003) AM_READ(eeprom_r)               // eeprom read
566469   AM_RANGE(0x418014, 0x418015) AM_READ(sound_status_r)            // z80 status
567470   AM_RANGE(0x41800c, 0x41800d) AM_WRITE(sound_cmd1_w)
568471   AM_RANGE(0x41800e, 0x41800f) AM_WRITE(sound_cmd2_w)
r6740r6741
609512   AM_RANGE(0x48a014, 0x48a015) AM_READ(sound_status_msb_r)
610513   AM_RANGE(0x48a000, 0x48a01f) AM_RAM               // sound regs fall-through
611514   AM_RANGE(0x48c000, 0x48c01f) AM_WRITE(K054338_word_w)
612   AM_RANGE(0x48e000, 0x48e001) AM_READ(dddcoins_r)   // bit 3 (0x8) is test switch
515   AM_RANGE(0x48e000, 0x48e001) AM_READ_PORT("IN0_P1")   // bit 3 (0x8) is test switch
613516   AM_RANGE(0x48e020, 0x48e021) AM_READ(dddeeprom_r)
614517   AM_RANGE(0x600000, 0x60ffff) AM_RAM AM_BASE(&gx_workram)
615518   AM_RANGE(0x680000, 0x68003f) AM_READWRITE(K055550_word_r,K055550_word_w)
r6740r6741
657560   AM_RANGE(0x48a014, 0x48a015) AM_READ(sound_status_msb_r)
658561   AM_RANGE(0x48a000, 0x48a01f) AM_RAM                        // sound regs fall-through
659562   AM_RANGE(0x48c000, 0x48c01f) AM_WRITE(K054338_word_w)
660   AM_RANGE(0x48e000, 0x48e001) AM_READ(dddcoins_r)            // bit 3 (0x8) is test switch
563   AM_RANGE(0x48e000, 0x48e001) AM_READ_PORT("IN0_P1")            // bit 3 (0x8) is test switch
661564   AM_RANGE(0x48e020, 0x48e021) AM_READ(dddeeprom_r)
662565   AM_RANGE(0x600000, 0x60ffff) AM_RAM AM_BASE(&gx_workram)
663566   AM_RANGE(0x660000, 0x6600ff) AM_READWRITE(K054000_lsb_r,K054000_lsb_w)
r6740r6741
726629
727630/**********************************************************************************/
728631
632static INPUT_PORTS_START( mystwarr )
633   PORT_START("IN0")
634   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
635   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
636   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
637   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN4 )
638   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
639   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
640   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
641   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
642
643   PORT_START("IN1")
644   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
645   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM ready (always 1) */
646   PORT_SERVICE_NO_TOGGLE( 0x04, IP_ACTIVE_LOW )
647   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SPECIAL )   /* game loops if this is set */
648   PORT_DIPNAME( 0x10, 0x00, "Sound Output" )
649   PORT_DIPSETTING(    0x10, DEF_STR( Mono ) )
650   PORT_DIPSETTING(    0x00, DEF_STR( Stereo ) )
651   PORT_DIPNAME( 0x20, 0x20, "Coin Mechanism" )
652   PORT_DIPSETTING(    0x20, "Common" )
653   PORT_DIPSETTING(    0x00, "Independant" )
654   PORT_DIPNAME( 0x40, 0x40, "Number of Players" )
655   PORT_DIPSETTING(    0x00, "4" )
656   PORT_DIPSETTING(    0x40, "2" )
657   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
658
659   PORT_START("P1_P2")
660   KONAMI16_LSB(1, IPT_BUTTON3, IPT_START1 )
661   KONAMI16_MSB(2, IPT_BUTTON3, IPT_START2 )
662
663   PORT_START("P3_P4")
664   KONAMI16_LSB(3, IPT_BUTTON3, IPT_START3 )
665   KONAMI16_MSB(4, IPT_BUTTON3, IPT_START4 )
666
667   PORT_START( "EEPROMOUT" )
668   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
669   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
670   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
671INPUT_PORTS_END
672
673static INPUT_PORTS_START( metamrph )
674   PORT_START("IN0")
675   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
676   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
677   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
678   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
679   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE1 )
680   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE2 )
681   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
682   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
683
684   PORT_START("IN1")
685   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
686   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM ready (always 1) */
687   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL )
688   PORT_SERVICE_NO_TOGGLE( 0x08, IP_ACTIVE_LOW )
689   PORT_DIPNAME( 0x10, 0x00, "Sound Output" )
690   PORT_DIPSETTING(    0x10, DEF_STR( Mono ) )
691   PORT_DIPSETTING(    0x00, DEF_STR( Stereo ) )
692   PORT_DIPNAME( 0x20, 0x20, "Coin Mechanism" )
693   PORT_DIPSETTING(    0x20, "Common" )
694   PORT_DIPSETTING(    0x00, "Independant" )
695   PORT_DIPNAME( 0x40, 0x40, "Number of Players" )
696   PORT_DIPSETTING(    0x00, "4" )
697   PORT_DIPSETTING(    0x40, "2" )
698   PORT_DIPNAME( 0x80, 0x80, "Continuous Energy Increment" )
699   PORT_DIPSETTING(    0x80, DEF_STR( No ) )
700   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
701
702   PORT_START("P1_P3")
703   KONAMI16_LSB(1, IPT_BUTTON3, IPT_START1 )
704   KONAMI16_MSB(3, IPT_BUTTON3, IPT_START3 )
705
706   PORT_START("P2_P4")
707   KONAMI16_LSB(2, IPT_BUTTON3, IPT_START2 )
708   KONAMI16_MSB(4, IPT_BUTTON3, IPT_START4 )
709
710   PORT_START( "EEPROMOUT" )
711   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
712   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
713   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
714INPUT_PORTS_END
715
716static INPUT_PORTS_START( viostorm )
717   PORT_START("IN0")
718   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
719   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
720   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
721   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
722   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE1 )
723   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE2 )
724   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
725   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
726
727   PORT_START("IN1")
728   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
729   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM ready (always 1) */
730   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL )
731   PORT_SERVICE_NO_TOGGLE( 0x08, IP_ACTIVE_LOW )
732   PORT_DIPNAME( 0x10, 0x00, "Sound Output" )
733   PORT_DIPSETTING(    0x10, DEF_STR( Mono ) )
734   PORT_DIPSETTING(    0x00, DEF_STR( Stereo ) )
735   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Flip_Screen ) )
736   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
737   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
738   PORT_DIPNAME( 0x40, 0x40, "Coin Mechanism" )
739   PORT_DIPSETTING(    0x40, "Common" )
740   PORT_DIPSETTING(    0x00, "Independant" )
741   PORT_DIPNAME( 0x80, 0x80, "Number of Players" )
742   PORT_DIPSETTING(    0x00, "3" )
743   PORT_DIPSETTING(    0x80, "2" )
744
745   PORT_START("P1_P3")
746   KONAMI16_LSB(1, IPT_BUTTON3, IPT_START1 )
747   KONAMI16_MSB(3, IPT_BUTTON3, IPT_START3 )
748
749   PORT_START("P2_P4")
750   KONAMI16_LSB(2, IPT_BUTTON3, IPT_START2 )
751   KONAMI16_MSB(4, IPT_BUTTON3, IPT_START4 )
752
753   PORT_START( "EEPROMOUT" )
754   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
755   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
756   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
757INPUT_PORTS_END
758
759static INPUT_PORTS_START( dadandrn )
760   PORT_START("IN0_P1")
761   KONAMI8_B123_START(1)
762   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_COIN1 )
763   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_COIN2 )
764   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN )
765   PORT_SERVICE_NO_TOGGLE( 0x0800, IP_ACTIVE_LOW )
766   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_SERVICE1 )
767   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_SERVICE2 )
768   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
769   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
770
771   PORT_START("IN1")
772   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
773   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM ready (always 1) */
774   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL )
775   PORT_SERVICE_NO_TOGGLE( 0x08, IP_ACTIVE_LOW )
776   PORT_DIPNAME( 0x10, 0x00, "Sound Output" )
777   PORT_DIPSETTING(    0x10, DEF_STR( Mono ) )
778   PORT_DIPSETTING(    0x00, DEF_STR( Stereo ) )
779   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Flip_Screen ) )
780   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
781   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
782   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
783   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
784
785   PORT_START("P2")
786   KONAMI8_B123_START(2)
787
788   PORT_START("P3")
789   KONAMI8_B123_START(3)
790
791   PORT_START("P4")
792   KONAMI8_B123_START(4)
793
794   PORT_START( "EEPROMOUT" )
795   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
796   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
797   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
798INPUT_PORTS_END
799
800static INPUT_PORTS_START( martchmp )
801   PORT_START("IN0")
802   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
803   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
804   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
805   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
806   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE1 )
807   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE2 )
808   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
809   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
810
811   PORT_START("IN1")
812   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
813   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM ready (always 1) */
814   PORT_SERVICE_NO_TOGGLE( 0x04, IP_ACTIVE_LOW )
815   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SPECIAL )   /* game loops if this is set */
816   PORT_DIPNAME( 0x10, 0x00, "Sound Output" )
817   PORT_DIPSETTING(    0x10, DEF_STR( Mono ) )
818   PORT_DIPSETTING(    0x00, DEF_STR( Stereo ) )
819   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Flip_Screen ) )
820   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
821   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
822   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
823   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
824
825   PORT_START("P1_P2")
826   KONAMI16_LSB(1, IPT_BUTTON3, IPT_START1 )
827   KONAMI16_MSB(2, IPT_BUTTON3, IPT_START2 )
828
829   PORT_START("P3_P4")
830   KONAMI16_LSB(3, IPT_BUTTON3, IPT_START3 )
831   KONAMI16_MSB(4, IPT_BUTTON3, IPT_START4 )
832
833   PORT_START( "EEPROMOUT" )
834   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
835   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
836   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
837INPUT_PORTS_END
838
839/**********************************************************************************/
840
729841static const gfx_layout bglayout_4bpp =
730842{
731843   16,16,
r6740r6741
858970
859971   MDRV_QUANTUM_TIME(HZ(1920))
860972
861   MDRV_NVRAM_HANDLER(mystwarr)
973   MDRV_EEPROM_NODEFAULT_ADD("eeprom", eeprom_intf)
974
862975   MDRV_MACHINE_START(mystwarr)
863976   MDRV_MACHINE_RESET(mystwarr)
864977
r6740r6741
9661079
9671080   MDRV_GFXDECODE(gaiapols)
9681081
969   MDRV_NVRAM_HANDLER(gaiapols)
1082   MDRV_DEVICE_REMOVE("eeprom")
1083   MDRV_EEPROM_NODEFAULT_ADD("eeprom", gaia_eeprom_intf)
9701084
9711085   /* video hardware */
9721086   MDRV_VIDEO_START(gaiapols)
r6740r6741
10031117
10041118/**********************************************************************************/
10051119
1006static INPUT_PORTS_START( mystwarr )
1007   PORT_START("IN0")
1008   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
1009   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
1010   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
1011   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN4 )
1012   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
1013   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
1014   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1015   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
1016
1017   PORT_START("IN1")
1018   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
1019   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM ready (always 1) */
1020   PORT_SERVICE_NO_TOGGLE( 0x04, IP_ACTIVE_LOW )
1021   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SPECIAL )   /* game loops if this is set */
1022   PORT_DIPNAME( 0x10, 0x00, "Sound Output" )
1023   PORT_DIPSETTING(    0x10, DEF_STR( Mono ) )
1024   PORT_DIPSETTING(    0x00, DEF_STR( Stereo ) )
1025   PORT_DIPNAME( 0x20, 0x20, "Coin Mechanism" )
1026   PORT_DIPSETTING(    0x20, "Common" )
1027   PORT_DIPSETTING(    0x00, "Independant" )
1028   PORT_DIPNAME( 0x40, 0x40, "Number of Players" )
1029   PORT_DIPSETTING(    0x00, "4" )
1030   PORT_DIPSETTING(    0x40, "2" )
1031   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
1032
1033   PORT_START("P1_P2")
1034   KONAMI16_LSB(1, IPT_BUTTON3, IPT_START1 )
1035   KONAMI16_MSB(2, IPT_BUTTON3, IPT_START2 )
1036
1037   PORT_START("P3_P4")
1038   KONAMI16_LSB(3, IPT_BUTTON3, IPT_START3 )
1039   KONAMI16_MSB(4, IPT_BUTTON3, IPT_START4 )
1040INPUT_PORTS_END
1041
1042static INPUT_PORTS_START( metamrph )
1043   PORT_START("IN0")
1044   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
1045   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
1046   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1047   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1048   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE1 )
1049   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE2 )
1050   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1051   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
1052
1053   PORT_START("IN1")
1054   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
1055   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM ready (always 1) */
1056   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL )
1057   PORT_SERVICE_NO_TOGGLE( 0x08, IP_ACTIVE_LOW )
1058   PORT_DIPNAME( 0x10, 0x00, "Sound Output" )
1059   PORT_DIPSETTING(    0x10, DEF_STR( Mono ) )
1060   PORT_DIPSETTING(    0x00, DEF_STR( Stereo ) )
1061   PORT_DIPNAME( 0x20, 0x20, "Coin Mechanism" )
1062   PORT_DIPSETTING(    0x20, "Common" )
1063   PORT_DIPSETTING(    0x00, "Independant" )
1064   PORT_DIPNAME( 0x40, 0x40, "Number of Players" )
1065   PORT_DIPSETTING(    0x00, "4" )
1066   PORT_DIPSETTING(    0x40, "2" )
1067   PORT_DIPNAME( 0x80, 0x80, "Continuous Energy Increment" )
1068   PORT_DIPSETTING(    0x80, DEF_STR( No ) )
1069   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
1070
1071   PORT_START("P1_P3")
1072   KONAMI16_LSB(1, IPT_BUTTON3, IPT_START1 )
1073   KONAMI16_MSB(3, IPT_BUTTON3, IPT_START3 )
1074
1075   PORT_START("P2_P4")
1076   KONAMI16_LSB(2, IPT_BUTTON3, IPT_START2 )
1077   KONAMI16_MSB(4, IPT_BUTTON3, IPT_START4 )
1078INPUT_PORTS_END
1079
1080static INPUT_PORTS_START( viostorm )
1081   PORT_START("IN0")
1082   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
1083   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
1084   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1085   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1086   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE1 )
1087   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE2 )
1088   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1089   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
1090
1091   PORT_START("IN1")
1092   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
1093   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM ready (always 1) */
1094   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL )
1095   PORT_SERVICE_NO_TOGGLE( 0x08, IP_ACTIVE_LOW )
1096   PORT_DIPNAME( 0x10, 0x00, "Sound Output" )
1097   PORT_DIPSETTING(    0x10, DEF_STR( Mono ) )
1098   PORT_DIPSETTING(    0x00, DEF_STR( Stereo ) )
1099   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Flip_Screen ) )
1100   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1101   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1102   PORT_DIPNAME( 0x40, 0x40, "Coin Mechanism" )
1103   PORT_DIPSETTING(    0x40, "Common" )
1104   PORT_DIPSETTING(    0x00, "Independant" )
1105   PORT_DIPNAME( 0x80, 0x80, "Number of Players" )
1106   PORT_DIPSETTING(    0x00, "3" )
1107   PORT_DIPSETTING(    0x80, "2" )
1108
1109   PORT_START("P1_P3")
1110   KONAMI16_LSB(1, IPT_BUTTON3, IPT_START1 )
1111   KONAMI16_MSB(3, IPT_BUTTON3, IPT_START3 )
1112
1113   PORT_START("P2_P4")
1114   KONAMI16_LSB(2, IPT_BUTTON3, IPT_START2 )
1115   KONAMI16_MSB(4, IPT_BUTTON3, IPT_START4 )
1116INPUT_PORTS_END
1117
1118static INPUT_PORTS_START( dadandrn )
1119   PORT_START("IN0")
1120   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
1121   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
1122   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1123   PORT_SERVICE_NO_TOGGLE( 0x08, IP_ACTIVE_LOW )
1124   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE1 )
1125   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE2 )
1126   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1127   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
1128
1129   PORT_START("IN1")
1130   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
1131   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM ready (always 1) */
1132   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL )
1133   PORT_SERVICE_NO_TOGGLE( 0x08, IP_ACTIVE_LOW )
1134   PORT_DIPNAME( 0x10, 0x00, "Sound Output" )
1135   PORT_DIPSETTING(    0x10, DEF_STR( Mono ) )
1136   PORT_DIPSETTING(    0x00, DEF_STR( Stereo ) )
1137   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Flip_Screen ) )
1138   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1139   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1140   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1141   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
1142
1143   PORT_START("P1")
1144   KONAMI8_B123_START(1)
1145
1146   PORT_START("P2")
1147   KONAMI8_B123_START(2)
1148
1149   PORT_START("P3")
1150   KONAMI8_B123_START(3)
1151
1152   PORT_START("P4")
1153   KONAMI8_B123_START(4)
1154INPUT_PORTS_END
1155
1156static INPUT_PORTS_START( martchmp )
1157   PORT_START("IN0")
1158   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
1159   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
1160   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
1161   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1162   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE1 )
1163   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE2 )
1164   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1165   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
1166
1167   PORT_START("IN1")
1168   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
1169   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SPECIAL )   /* EEPROM ready (always 1) */
1170   PORT_SERVICE_NO_TOGGLE( 0x04, IP_ACTIVE_LOW )
1171   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SPECIAL )   /* game loops if this is set */
1172   PORT_DIPNAME( 0x10, 0x00, "Sound Output" )
1173   PORT_DIPSETTING(    0x10, DEF_STR( Mono ) )
1174   PORT_DIPSETTING(    0x00, DEF_STR( Stereo ) )
1175   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Flip_Screen ) )
1176   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1177   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1178   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
1179   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
1180
1181   PORT_START("P1_P2")
1182   KONAMI16_LSB(1, IPT_BUTTON3, IPT_START1 )
1183   KONAMI16_MSB(2, IPT_BUTTON3, IPT_START2 )
1184
1185   PORT_START("P3_P4")
1186   KONAMI16_LSB(3, IPT_BUTTON3, IPT_START3 )
1187   KONAMI16_MSB(4, IPT_BUTTON3, IPT_START4 )
1188INPUT_PORTS_END
1189
1190/**********************************************************************************/
1191
11921120#define ROM_LOADTILE_WORD(name,offset,length,crc) ROMX_LOAD(name, offset, length, crc, ROM_GROUPWORD | ROM_SKIP(3) | ROM_REVERSE)
11931121#define ROM_LOADTILE_BYTE(name,offset,length,crc) ROMX_LOAD(name, offset, length, crc, ROM_GROUPBYTE | ROM_SKIP(4))
11941122
src/mame/drivers/irobot.c
r6740r6741
7777#include "driver.h"
7878#include "cpu/m6809/m6809.h"
7979#include "sound/pokey.h"
80#include "irobot.h"
80#include "includes/irobot.h"
8181
8282
8383
r6740r6741
306306   MDRV_VIDEO_START(irobot)
307307   MDRV_VIDEO_UPDATE(irobot)
308308
309   MDRV_TIMER_ADD("irvg_timer", irobot_irvg_done_callback)
310   MDRV_TIMER_ADD("irmb_timer", irobot_irmb_done_callback)
311
309312   /* sound hardware */
310313   MDRV_SPEAKER_STANDARD_MONO("mono")
311314
src/mame/drivers/klax.c
r6740r6741
1919
2020#include "driver.h"
2121#include "cpu/m68000/m68000.h"
22#include "klax.h"
22#include "includes/klax.h"
2323#include "sound/okim6295.h"
2424
2525
r6740r6741
5959 *
6060 *************************************/
6161
62static MACHINE_START( klax )
63{
64   atarigen_init(machine);
65}
66
67
6268static MACHINE_RESET( klax )
6369{
6470   klax_state *state = (klax_state *)machine->driver_data;
r6740r6741
94100ADDRESS_MAP_END
95101
96102
103
97104/*************************************
98105 *
99106 *  Port definitions
r6740r6741
165172   MDRV_CPU_PROGRAM_MAP(klax_map)
166173   MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen)
167174
175   MDRV_MACHINE_START(klax)
168176   MDRV_MACHINE_RESET(klax)
169177   MDRV_NVRAM_HANDLER(atarigen)
170178
src/mame/drivers/gomoku.c
r6740r6741
7979   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN2 )
8080
8181   PORT_START("DSW")
82   PORT_SERVICE( 0x01, IP_ACTIVE_HIGH )
83   PORT_DIPNAME( 0x06, 0x00, DEF_STR( Lives ))
82   PORT_SERVICE( 0x01, IP_ACTIVE_HIGH )  PORT_DIPLOCATION("SW1:1")
83   PORT_DIPNAME( 0x06, 0x00, DEF_STR( Lives ))  PORT_DIPLOCATION("SW1:2,3")
8484   PORT_DIPSETTING(    0x00, "2" )
85   PORT_DIPSETTING(    0x04, "3" )
8586   PORT_DIPSETTING(    0x02, "4" )
86   PORT_DIPSETTING(    0x04, "3" )
8787   PORT_DIPSETTING(    0x06, "5" )
88   PORT_DIPNAME( 0x08, 0x00, "Time" )
88   PORT_DIPNAME( 0x08, 0x00, "Time" )  PORT_DIPLOCATION("SW1:4")
8989   PORT_DIPSETTING(    0x00, "60" )
9090   PORT_DIPSETTING(    0x08, "80" )
91   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
91   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )  PORT_DIPLOCATION("SW1:5,6")
9292   PORT_DIPSETTING(    0x10, DEF_STR( 3C_1C ) )
9393   PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) )
9494   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
9595   PORT_DIPSETTING(    0x30, DEF_STR( Free_Play ) )
96   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
96   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )  PORT_DIPLOCATION("SW1:7,8")
9797   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
9898   PORT_DIPSETTING(    0x80, DEF_STR( 1C_2C ) )
9999   PORT_DIPSETTING(    0x40, DEF_STR( 1C_3C ) )
r6740r6741
119119
120120static MACHINE_DRIVER_START( gomoku )
121121   /* basic machine hardware */
122   MDRV_CPU_ADD("maincpu", Z80, 18432000/12)       /* 1.536 MHz ? */
122   MDRV_CPU_ADD("maincpu", Z80, XTAL_18_432MHz/12)       /* 1.536 MHz ? */
123123   MDRV_CPU_PROGRAM_MAP(gomoku_map)
124124   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
125125
src/mame/drivers/firetrk.c
r6740r6741
77
88#include "driver.h"
99#include "cpu/m6800/m6800.h"
10#include "firetrk.h"
10#include "includes/firetrk.h"
1111#include "sound/discrete.h"
1212
1313#define MASTER_CLOCK (XTAL_12_096MHz)
src/mame/drivers/m57.c
r6740r6741
4949
5050#include "driver.h"
5151#include "cpu/z80/z80.h"
52#include "iremipt.h"
52#include "includes/iremipt.h"
5353#include "includes/iremz80.h"
5454
5555
src/mame/drivers/segas24.c
r6740r6741
790790static UINT8  irq_timerb;
791791static UINT8  irq_allow0, irq_allow1;
792792static int    irq_timer_pend0, irq_timer_pend1, irq_yms, irq_vblank, irq_sprite;
793static emu_timer *irq_timer, *irq_timer_clear;
793static const device_config *irq_timer, *irq_timer_clear;
794794
795static TIMER_CALLBACK( irq_timer_cb )
795static TIMER_DEVICE_CALLBACK( irq_timer_cb )
796796{
797797   irq_timer_pend0 = irq_timer_pend1 = 1;
798798   if(irq_allow0 & (1 << IRQ_TIMER))
799      cputag_set_input_line(machine, "maincpu", IRQ_TIMER+1, ASSERT_LINE);
799      cputag_set_input_line(timer->machine, "maincpu", IRQ_TIMER+1, ASSERT_LINE);
800800   if(irq_allow1 & (1 << IRQ_TIMER))
801      cputag_set_input_line(machine, "sub", IRQ_TIMER+1, ASSERT_LINE);
801      cputag_set_input_line(timer->machine, "sub", IRQ_TIMER+1, ASSERT_LINE);
802802}
803803
804static TIMER_CALLBACK( irq_timer_clear_cb )
804static TIMER_DEVICE_CALLBACK( irq_timer_clear_cb )
805805{
806806   irq_sprite = irq_vblank = 0;
807   cputag_set_input_line(machine, "maincpu", IRQ_VBLANK+1, CLEAR_LINE);
808   cputag_set_input_line(machine, "maincpu", IRQ_SPRITE+1, CLEAR_LINE);
809   cputag_set_input_line(machine, "sub", IRQ_VBLANK+1, CLEAR_LINE);
810   cputag_set_input_line(machine, "sub", IRQ_SPRITE+1, CLEAR_LINE);
807   cputag_set_input_line(timer->machine, "maincpu", IRQ_VBLANK+1, CLEAR_LINE);
808   cputag_set_input_line(timer->machine, "maincpu", IRQ_SPRITE+1, CLEAR_LINE);
809   cputag_set_input_line(timer->machine, "sub", IRQ_VBLANK+1, CLEAR_LINE);
810   cputag_set_input_line(timer->machine, "sub", IRQ_SPRITE+1, CLEAR_LINE);
811811}
812812
813813static void irq_init(running_machine *machine)
r6740r6741
820820   irq_timer_pend1 = 0;
821821   irq_vblank = 0;
822822   irq_sprite = 0;
823   irq_timer = timer_alloc(machine, irq_timer_cb, NULL);
824   irq_timer_clear = timer_alloc(machine, irq_timer_clear_cb, NULL);
823   irq_timer = devtag_get_device(machine, "irq_timer");
824   irq_timer_clear = devtag_get_device(machine, "irq_timer_clear");
825825}
826826
827827static void irq_timer_reset(void)
r6740r6741
829829   int freq = (irq_timerb << 12) | irq_timera;
830830   freq &= 0x1fff;
831831
832   timer_adjust_periodic(irq_timer, ATTOTIME_IN_HZ(freq), 0, ATTOTIME_IN_HZ(freq));
832   timer_device_adjust_periodic(irq_timer, ATTOTIME_IN_HZ(freq), 0, ATTOTIME_IN_HZ(freq));
833833   logerror("New timer frequency: %0d [%02x %04x]\n", freq, irq_timerb, irq_timera);
834834}
835835
r6740r6741
916916      irq_vblank = 1;
917917   }
918918
919   timer_adjust_oneshot(irq_timer_clear, ATTOTIME_IN_HZ(VIDEO_CLOCK/2/656.0), 0);
919   timer_device_adjust_oneshot(irq_timer_clear, ATTOTIME_IN_HZ(VIDEO_CLOCK/2/656.0), 0);
920920
921921   mask = 1 << irq;
922922
r6740r6741
17871787   MDRV_MACHINE_START(system24)
17881788   MDRV_MACHINE_RESET(system24)
17891789
1790   MDRV_TIMER_ADD("irq_timer", irq_timer_cb)
1791   MDRV_TIMER_ADD("irq_timer_clear", irq_timer_clear_cb)
1792
17901793   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK)
17911794
17921795   MDRV_SCREEN_ADD("screen", RASTER)
src/mame/drivers/konamigx.c
r6740r6741
101101#include "cpu/m68000/m68000.h"
102102#include "cpu/z80/z80.h"
103103#include "cpu/tms57002/tms57002.h"
104#include "machine/eeprom.h"
104#include "machine/eepromdev.h"
105105#include "sound/k054539.h"
106#include "konamigx.h"
106#include "includes/konamigx.h"
107107#include "machine/adc083x.h"
108108#include "rendlay.h"
109109
r6740r6741
440440}
441441
442442/**********************************************************************************/
443/* NVRAM and EEPROM handlers */
443/* EEPROM handlers */
444444
445static int init_eeprom_count;
446
447static NVRAM_HANDLER(konamigx_93C46)
448{
449   if (read_or_write)
450      eeprom_save(file);
451   else
452   {
453      eeprom_init(machine, &eeprom_interface_93C46);
454
455      if (file)
456      {
457         init_eeprom_count = 0;
458         eeprom_load(file);
459      }
460      else
461         init_eeprom_count = 10;
462   }
463}
464
465445static CUSTOM_INPUT( gx_rdport1_3_r )
466446{
467447   return (gx_rdport1_3 >> 1);
r6740r6741
485465          bit 0: eeprom data
486466        */
487467
488      eeprom_write_bit((odata&0x01) ? 1 : 0);
489      eeprom_set_cs_line((odata&0x02) ? CLEAR_LINE : ASSERT_LINE);
490      eeprom_set_clock_line((odata&0x04) ? ASSERT_LINE : CLEAR_LINE);
468      input_port_write(space->machine, "EEPROMOUT", odata, 0xff);
491469
492470      konamigx_wrport1_0 = odata;
493471   }
r6740r6741
912890   return (p1y<<16)|p2y;
913891}
914892
915static READ32_HANDLER( service_r )
916{
917   int res = input_port_read(space->machine, "SERVICE");
918
919   if (init_eeprom_count)
920   {
921      init_eeprom_count--;
922      res &= ~0x08000000;
923   }
924
925   return res;
926}
927
928
929893/**********************************************************************************/
930894/* system or game dependent handlers */
931895
r6740r6741
11821146   AM_RANGE(0xd58000, 0xd58003) AM_WRITE(control_w)
11831147   AM_RANGE(0xd5a000, 0xd5a003) AM_READ_PORT("SYSTEM_DSW")
11841148   AM_RANGE(0xd5c000, 0xd5c003) AM_READ_PORT("INPUTS")
1185   AM_RANGE(0xd5e000, 0xd5e003) AM_READ(service_r)
1149   AM_RANGE(0xd5e000, 0xd5e003) AM_READ_PORT("SERVICE")
11861150   AM_RANGE(0xd80000, 0xd8001f) AM_WRITE(K054338_long_w)
11871151   AM_RANGE(0xda0000, 0xda1fff) AM_READWRITE(K056832_ram_long_r, K056832_ram_long_w)
11881152   AM_RANGE(0xda2000, 0xda3fff) AM_READWRITE(K056832_ram_long_r, K056832_ram_long_w)
r6740r6741
13371301
13381302
13391303/**********************************************************************************/
1340/* hardware definitions */
1341
1342/* i think we could reduce the number of machine drivers with different visible areas by adjusting the sprite
1343   positioning on a per game basis too */
1344
1345static const gfx_layout bglayout_8bpp =
1346{
1347   16,16,
1348   RGN_FRAC(1,1),
1349   8,
1350   { 0, 1, 2, 3, 4, 5, 6, 7 },
1351   { 0*128, 1*128, 2*128, 3*128, 4*128, 5*128, 6*128, 7*128, 8*128, 9*128, 10*128, 11*128, 12*128, 13*128, 14*128, 15*128 },
1352    { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
1353    16*128
1354};
1355
1356// for scanrows on tilemap
1357#if 0
1358static const gfx_layout t1_charlayout6 =
1359{
1360   16, 16,
1361   RGN_FRAC(1,1),
1362   6,
1363   { 20, 16, 12, 8, 4, 0 },
1364   { 3, 2, 1, 0, 27, 26, 25, 24, 51, 50, 49, 48, 75, 74, 73, 72 },
1365   { 0, 12*8, 12*8*2, 12*8*3, 12*8*4, 12*8*5, 12*8*6, 12*8*7,
1366     12*8*8, 12*8*9, 12*8*10, 12*8*11, 12*8*12, 12*8*13, 12*8*14, 12*8*15 },
1367   16*16*6
1368};
1369
1370static const gfx_layout t1_charlayout8 =
1371{
1372   16, 16,
1373   RGN_FRAC(1,1),
1374   8,
1375   { 28, 24, 20, 16, 12, 8, 4, 0 },
1376   { 3, 2, 1, 0, 35, 34, 33, 32, 67, 66, 65, 64, 99, 98, 97, 96 },
1377   { 0, 16*8, 16*8*2, 16*8*3, 16*8*4, 16*8*5, 16*8*6, 16*8*7,
1378     16*8*8, 16*8*9, 16*8*10, 16*8*11, 16*8*12, 16*8*13, 16*8*14, 16*8*15 },
1379   16*16*8
1380};
1381#endif
1382
1383// for scancols on tilemap
1384static const gfx_layout t1_charlayout6 =
1385{
1386   16, 16,
1387   RGN_FRAC(1,1),
1388   6,
1389   { 20, 16, 12, 8, 4, 0 },
1390   { 0, 12*8, 12*8*2, 12*8*3, 12*8*4, 12*8*5, 12*8*6, 12*8*7,
1391     12*8*8, 12*8*9, 12*8*10, 12*8*11, 12*8*12, 12*8*13, 12*8*14, 12*8*15 },
1392   { 3, 2, 1, 0, 27, 26, 25, 24, 51, 50, 49, 48, 75, 74, 73, 72 },
1393  16*16*6
1394};
1395
1396static const gfx_layout t1_charlayout8 =
1397{
1398   16, 16,
1399   RGN_FRAC(1,1),
1400   8,
1401   { 28, 24, 20, 16, 12, 8, 4, 0 },
1402   { 0, 16*8, 16*8*2, 16*8*3, 16*8*4, 16*8*5, 16*8*6, 16*8*7,
1403     16*8*8, 16*8*9, 16*8*10, 16*8*11, 16*8*12, 16*8*13, 16*8*14, 16*8*15 },
1404   { 3, 2, 1, 0, 35, 34, 33, 32, 67, 66, 65, 64, 99, 98, 97, 96 },
1405  16*16*8
1406};
1407
1408/* type 1 (opengolf + racinfrc) use 6 and 8 bpp planar layouts for the 53936 */
1409static GFXDECODE_START( opengolf )
1410   GFXDECODE_ENTRY( "gfx3", 0, t1_charlayout8, 0x0000, 8 )
1411   GFXDECODE_ENTRY( "gfx4", 0, t1_charlayout6, 0x0000, 8 )
1412GFXDECODE_END
1413
1414static GFXDECODE_START( racinfrc )
1415   GFXDECODE_ENTRY( "gfx3", 0, t1_charlayout6, 0x0000, 8 )
1416   GFXDECODE_ENTRY( "gfx4", 0, t1_charlayout6, 0x0000, 8 )
1417GFXDECODE_END
1418
1419/* type 3 & 4 games use a simple 8bpp decode for the 53936 */
1420static GFXDECODE_START( type34 )
1421   GFXDECODE_ENTRY( "gfx3", 0, bglayout_8bpp, 0x1000, 8 )
1422GFXDECODE_END
1423
1424static GFXDECODE_START( type4 )
1425   GFXDECODE_ENTRY( "gfx3", 0, bglayout_8bpp, 0x1800, 8 )
1426GFXDECODE_END
1427
1428static MACHINE_DRIVER_START( konamigx )
1429   /* basic machine hardware */
1430   MDRV_CPU_ADD("maincpu", M68EC020, 24000000)
1431   MDRV_CPU_PROGRAM_MAP(gx_type2_map)
1432   MDRV_CPU_VBLANK_INT("screen", konamigx_vbinterrupt)
1433
1434   MDRV_CPU_ADD("soundcpu", M68000, 8000000)
1435   MDRV_CPU_PROGRAM_MAP(gxsndmap)
1436   MDRV_CPU_PERIODIC_INT(irq2_line_hold, 480)
1437
1438   MDRV_CPU_ADD("dasp", TMS57002, 12500000)
1439   MDRV_CPU_DATA_MAP(gxtmsmap)
1440   MDRV_CPU_PERIODIC_INT(tms_sync, 48000)
1441
1442   MDRV_QUANTUM_TIME(HZ(1920))
1443
1444   MDRV_MACHINE_START(konamigx)
1445   MDRV_MACHINE_RESET(konamigx)
1446   MDRV_NVRAM_HANDLER(konamigx_93C46)
1447
1448   /* video hardware */
1449   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_AFTER_VBLANK)
1450
1451   MDRV_SCREEN_ADD("screen", RASTER)
1452   MDRV_SCREEN_RAW_PARAMS(6000000, 288+16+32+48, 0, 287, 224+16+8+16, 0, 223)
1453   /* These parameters are actual value written to the CCU.
1454    tbyahhoo attract mode desync is caused by another matter. */
1455
1456//  MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(600))
1457   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
1458   MDRV_SCREEN_SIZE(64*8, 32*8)
1459   MDRV_SCREEN_VISIBLE_AREA(24, 24+288-1, 16, 16+224-1)
1460
1461   MDRV_PALETTE_LENGTH(8192)
1462
1463   MDRV_VIDEO_START(konamigx_5bpp)
1464   MDRV_VIDEO_UPDATE(konamigx)
1465
1466   /* sound hardware */
1467   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
1468
1469   MDRV_SOUND_ADD("konami1", K054539, 48000)
1470   MDRV_SOUND_CONFIG(k054539_config)
1471   MDRV_SOUND_ROUTE(0, "lspeaker", 1.0)
1472   MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)
1473
1474   MDRV_SOUND_ADD("konami2", K054539, 48000)
1475   MDRV_SOUND_CONFIG(k054539_config)
1476   MDRV_SOUND_ROUTE(0, "lspeaker", 1.0)
1477   MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)
1478MACHINE_DRIVER_END
1479
1480static MACHINE_DRIVER_START( dragoonj )
1481   MDRV_IMPORT_FROM(konamigx)
1482   MDRV_CPU_REPLACE("maincpu", M68EC020, 26400000) // needs higher clock to stop sprite flickerings
1483   MDRV_SCREEN_MODIFY("screen")
1484   MDRV_SCREEN_VISIBLE_AREA(40, 40+384-1, 16, 16+224-1)
1485   MDRV_VIDEO_START(dragoonj)
1486MACHINE_DRIVER_END
1487
1488static MACHINE_DRIVER_START( le2 )
1489   MDRV_IMPORT_FROM(konamigx)
1490   MDRV_VIDEO_START(le2)
1491MACHINE_DRIVER_END
1492
1493static MACHINE_DRIVER_START( konamigx_6bpp )
1494   MDRV_IMPORT_FROM(konamigx)
1495   MDRV_VIDEO_START(konamigx_6bpp)
1496MACHINE_DRIVER_END
1497
1498static MACHINE_DRIVER_START( konamigx_6bpp_2 )
1499   MDRV_IMPORT_FROM(konamigx)
1500   MDRV_VIDEO_START(konamigx_6bpp_2)
1501MACHINE_DRIVER_END
1502
1503static MACHINE_DRIVER_START( opengolf )
1504   MDRV_IMPORT_FROM(konamigx)
1505   MDRV_SCREEN_MODIFY("screen")
1506   MDRV_SCREEN_RAW_PARAMS(8000000, 384+24+64+40, 0, 383, 224+16+8+16, 0, 223)
1507   MDRV_SCREEN_VISIBLE_AREA(40, 40+384-1, 16, 16+224-1)
1508   MDRV_GFXDECODE(opengolf)
1509   MDRV_VIDEO_START(opengolf)
1510
1511   MDRV_CPU_MODIFY("maincpu")
1512   MDRV_CPU_PROGRAM_MAP(gx_type1_map)
1513
1514   MDRV_ADC0834_ADD( "adc0834", konamigx_adc_interface )
1515MACHINE_DRIVER_END
1516
1517static MACHINE_DRIVER_START( racinfrc )
1518   MDRV_IMPORT_FROM(konamigx)
1519   MDRV_SCREEN_MODIFY("screen")
1520   MDRV_SCREEN_RAW_PARAMS(8000000, 384+24+64+40, 0, 383, 224+16+8+16, 0, 223)
1521   MDRV_SCREEN_VISIBLE_AREA(32, 32+384-1, 16, 16+224-1)
1522   MDRV_GFXDECODE(racinfrc)
1523   MDRV_VIDEO_START(racinfrc)
1524
1525   MDRV_CPU_MODIFY("maincpu")
1526   MDRV_CPU_PROGRAM_MAP(gx_type1_map)
1527
1528   MDRV_ADC0834_ADD( "adc0834", konamigx_adc_interface )
1529MACHINE_DRIVER_END
1530
1531static MACHINE_DRIVER_START( gxtype3 )
1532   MDRV_IMPORT_FROM(konamigx)
1533
1534   MDRV_CPU_MODIFY("maincpu")
1535   MDRV_CPU_PROGRAM_MAP(gx_type3_map)
1536   MDRV_CPU_VBLANK_INT_HACK(konamigx_hbinterrupt, 262)
1537
1538   MDRV_DEFAULT_LAYOUT(layout_dualhsxs)
1539   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_AFTER_VBLANK | VIDEO_ALWAYS_UPDATE)
1540
1541   MDRV_VIDEO_START(konamigx_type3)
1542   MDRV_PALETTE_LENGTH(16384)
1543   MDRV_SCREEN_MODIFY("screen")
1544   MDRV_SCREEN_SIZE(576, 32*8)
1545   MDRV_SCREEN_VISIBLE_AREA(0, 576-1, 16, 32*8-1-16)
1546
1547   MDRV_SCREEN_ADD("screen2", RASTER)
1548   MDRV_SCREEN_RAW_PARAMS(6000000, 288+16+32+48, 0, 287, 224+16+8+16, 0, 223)
1549   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
1550   MDRV_SCREEN_SIZE(576, 32*8)
1551   MDRV_SCREEN_VISIBLE_AREA(0, 576-1, 16, 32*8-1-16)
1552
1553
1554   MDRV_GFXDECODE(type34)
1555MACHINE_DRIVER_END
1556
1557static MACHINE_DRIVER_START( gxtype4 )
1558   MDRV_IMPORT_FROM(konamigx)
1559
1560   MDRV_CPU_MODIFY("maincpu")
1561   MDRV_CPU_PROGRAM_MAP(gx_type4_map)
1562   MDRV_CPU_VBLANK_INT_HACK(konamigx_hbinterrupt, 262)
1563
1564   MDRV_DEFAULT_LAYOUT(layout_dualhsxs)
1565   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_AFTER_VBLANK | VIDEO_ALWAYS_UPDATE)
1566
1567   MDRV_SCREEN_MODIFY("screen")
1568   MDRV_SCREEN_SIZE(128*8, 32*8)
1569   MDRV_SCREEN_VISIBLE_AREA(0, 384-1, 16, 32*8-1-16)
1570
1571   MDRV_SCREEN_ADD("screen2", RASTER)
1572   MDRV_SCREEN_RAW_PARAMS(6000000, 288+16+32+48, 0, 287, 224+16+8+16, 0, 223)
1573   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
1574   MDRV_SCREEN_SIZE(128*8, 32*8)
1575   MDRV_SCREEN_VISIBLE_AREA(0, 384-1, 16, 32*8-1-16)
1576
1577
1578   MDRV_PALETTE_LENGTH(8192)
1579   MDRV_GFXDECODE(type4)
1580   MDRV_VIDEO_START(konamigx_type4)
1581MACHINE_DRIVER_END
1582
1583static MACHINE_DRIVER_START( gxtype4vsnet )
1584   MDRV_IMPORT_FROM(gxtype4)
1585
1586   MDRV_DEFAULT_LAYOUT(layout_dualhsxs)
1587
1588   MDRV_SCREEN_MODIFY("screen")
1589   MDRV_SCREEN_SIZE(128*8, 32*8)
1590   MDRV_SCREEN_VISIBLE_AREA(0, 576-1, 16, 32*8-1-16)
1591
1592   MDRV_SCREEN_MODIFY("screen2")
1593   MDRV_SCREEN_SIZE(128*8, 32*8)
1594   MDRV_SCREEN_VISIBLE_AREA(0, 576-1, 16, 32*8-1-16)
1595MACHINE_DRIVER_END
1596
1597static MACHINE_DRIVER_START( gxtype4sd2 )
1598   MDRV_IMPORT_FROM(gxtype4)
1599
1600   MDRV_VIDEO_START(konamigx_type4_sd2)
1601MACHINE_DRIVER_END
1602
1603
1604static MACHINE_DRIVER_START( winspike )
1605   MDRV_IMPORT_FROM(konamigx)
1606
1607   MDRV_SCREEN_MODIFY("screen")
1608   MDRV_SCREEN_VISIBLE_AREA(38, 38+384-1, 16, 16+224-1)
1609   MDRV_VIDEO_START(winspike)
1610MACHINE_DRIVER_END
1611
1612/**********************************************************************************/
16131304/* port maps */
16141305
16151306/* here we collect players' inputs: they are shared among all the ports */
r6740r6741
16671358   //      excpuint stat, objdma stat, eeprom do
16681359
16691360   // note: racin' force expects bit 1 of the eeprom port to toggle
1670   PORT_BIT( 0x00000001, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(eeprom_bit_r, NULL)
1361   PORT_BIT( 0x00000001, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
16711362   PORT_BIT( 0x000000fe, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(gx_rdport1_3_r, NULL)
16721363   PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_COIN1 )
16731364   PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_COIN2 )
r6740r6741
16781369   PORT_BIT( 0x00004000, IP_ACTIVE_LOW, IPT_UNKNOWN )
16791370   PORT_BIT( 0x00008000, IP_ACTIVE_LOW, IPT_UNKNOWN )
16801371   PORT_BIT( 0xffff0000, IP_ACTIVE_LOW, IPT_UNUSED )   /* DIP#1 & DIP#2 */
1372
1373   PORT_START( "EEPROMOUT" )
1374   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
1375   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
1376   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
16811377INPUT_PORTS_END
16821378
16831379
r6740r6741
19561652
19571653
19581654/**********************************************************************************/
1655/* hardware definitions */
1656
1657/* i think we could reduce the number of machine drivers with different visible areas by adjusting the sprite
1658   positioning on a per game basis too */
1659
1660static const gfx_layout bglayout_8bpp =
1661{
1662   16,16,
1663   RGN_FRAC(1,1),
1664   8,
1665   { 0, 1, 2, 3, 4, 5, 6, 7 },
1666   { 0*128, 1*128, 2*128, 3*128, 4*128, 5*128, 6*128, 7*128, 8*128, 9*128, 10*128, 11*128, 12*128, 13*128, 14*128, 15*128 },
1667    { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
1668    16*128
1669};
1670
1671// for scanrows on tilemap
1672#if 0
1673static const gfx_layout t1_charlayout6 =
1674{
1675   16, 16,
1676   RGN_FRAC(1,1),
1677   6,
1678   { 20, 16, 12, 8, 4, 0 },
1679   { 3, 2, 1, 0, 27, 26, 25, 24, 51, 50, 49, 48, 75, 74, 73, 72 },
1680   { 0, 12*8, 12*8*2, 12*8*3, 12*8*4, 12*8*5, 12*8*6, 12*8*7,
1681     12*8*8, 12*8*9, 12*8*10, 12*8*11, 12*8*12, 12*8*13, 12*8*14, 12*8*15 },
1682   16*16*6
1683};
1684
1685static const gfx_layout t1_charlayout8 =
1686{
1687   16, 16,
1688   RGN_FRAC(1,1),
1689   8,
1690   { 28, 24, 20, 16, 12, 8, 4, 0 },
1691   { 3, 2, 1, 0, 35, 34, 33, 32, 67, 66, 65, 64, 99, 98, 97, 96 },
1692   { 0, 16*8, 16*8*2, 16*8*3, 16*8*4, 16*8*5, 16*8*6, 16*8*7,
1693     16*8*8, 16*8*9, 16*8*10, 16*8*11, 16*8*12, 16*8*13, 16*8*14, 16*8*15 },
1694   16*16*8
1695};
1696#endif
1697
1698// for scancols on tilemap
1699static const gfx_layout t1_charlayout6 =
1700{
1701   16, 16,
1702   RGN_FRAC(1,1),
1703   6,
1704   { 20, 16, 12, 8, 4, 0 },
1705   { 0, 12*8, 12*8*2, 12*8*3, 12*8*4, 12*8*5, 12*8*6, 12*8*7,
1706     12*8*8, 12*8*9, 12*8*10, 12*8*11, 12*8*12, 12*8*13, 12*8*14, 12*8*15 },
1707   { 3, 2, 1, 0, 27, 26, 25, 24, 51, 50, 49, 48, 75, 74, 73, 72 },
1708  16*16*6
1709};
1710
1711static const gfx_layout t1_charlayout8 =
1712{
1713   16, 16,
1714   RGN_FRAC(1,1),
1715   8,
1716   { 28, 24, 20, 16, 12, 8, 4, 0 },
1717   { 0, 16*8, 16*8*2, 16*8*3, 16*8*4, 16*8*5, 16*8*6, 16*8*7,
1718     16*8*8, 16*8*9, 16*8*10, 16*8*11, 16*8*12, 16*8*13, 16*8*14, 16*8*15 },
1719   { 3, 2, 1, 0, 35, 34, 33, 32, 67, 66, 65, 64, 99, 98, 97, 96 },
1720  16*16*8
1721};
1722
1723/* type 1 (opengolf + racinfrc) use 6 and 8 bpp planar layouts for the 53936 */
1724static GFXDECODE_START( opengolf )
1725   GFXDECODE_ENTRY( "gfx3", 0, t1_charlayout8, 0x0000, 8 )
1726   GFXDECODE_ENTRY( "gfx4", 0, t1_charlayout6, 0x0000, 8 )
1727GFXDECODE_END
1728
1729static GFXDECODE_START( racinfrc )
1730   GFXDECODE_ENTRY( "gfx3", 0, t1_charlayout6, 0x0000, 8 )
1731   GFXDECODE_ENTRY( "gfx4", 0, t1_charlayout6, 0x0000, 8 )
1732GFXDECODE_END
1733
1734/* type 3 & 4 games use a simple 8bpp decode for the 53936 */
1735static GFXDECODE_START( type34 )
1736   GFXDECODE_ENTRY( "gfx3", 0, bglayout_8bpp, 0x1000, 8 )
1737GFXDECODE_END
1738
1739static GFXDECODE_START( type4 )
1740   GFXDECODE_ENTRY( "gfx3", 0, bglayout_8bpp, 0x1800, 8 )
1741GFXDECODE_END
1742
1743static MACHINE_DRIVER_START( konamigx )
1744   /* basic machine hardware */
1745   MDRV_CPU_ADD("maincpu", M68EC020, 24000000)
1746   MDRV_CPU_PROGRAM_MAP(gx_type2_map)
1747   MDRV_CPU_VBLANK_INT("screen", konamigx_vbinterrupt)
1748
1749   MDRV_CPU_ADD("soundcpu", M68000, 8000000)
1750   MDRV_CPU_PROGRAM_MAP(gxsndmap)
1751   MDRV_CPU_PERIODIC_INT(irq2_line_hold, 480)
1752
1753   MDRV_CPU_ADD("dasp", TMS57002, 12500000)
1754   MDRV_CPU_DATA_MAP(gxtmsmap)
1755   MDRV_CPU_PERIODIC_INT(tms_sync, 48000)
1756
1757   MDRV_QUANTUM_TIME(HZ(1920))
1758
1759   MDRV_MACHINE_START(konamigx)
1760   MDRV_MACHINE_RESET(konamigx)
1761
1762   MDRV_EEPROM_93C46_NODEFAULT_ADD("eeprom")
1763
1764   /* video hardware */
1765   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_AFTER_VBLANK)
1766
1767   MDRV_SCREEN_ADD("screen", RASTER)
1768   MDRV_SCREEN_RAW_PARAMS(6000000, 288+16+32+48, 0, 287, 224+16+8+16, 0, 223)
1769   /* These parameters are actual value written to the CCU.
1770    tbyahhoo attract mode desync is caused by another matter. */
1771
1772//  MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(600))
1773   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
1774   MDRV_SCREEN_SIZE(64*8, 32*8)
1775   MDRV_SCREEN_VISIBLE_AREA(24, 24+288-1, 16, 16+224-1)
1776
1777   MDRV_PALETTE_LENGTH(8192)
1778
1779   MDRV_VIDEO_START(konamigx_5bpp)
1780   MDRV_VIDEO_UPDATE(konamigx)
1781
1782   /* sound hardware */
1783   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
1784
1785   MDRV_SOUND_ADD("konami1", K054539, 48000)
1786   MDRV_SOUND_CONFIG(k054539_config)
1787   MDRV_SOUND_ROUTE(0, "lspeaker", 1.0)
1788   MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)
1789
1790   MDRV_SOUND_ADD("konami2", K054539, 48000)
1791   MDRV_SOUND_CONFIG(k054539_config)
1792   MDRV_SOUND_ROUTE(0, "lspeaker", 1.0)
1793   MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)
1794MACHINE_DRIVER_END
1795
1796static MACHINE_DRIVER_START( dragoonj )
1797   MDRV_IMPORT_FROM(konamigx)
1798   MDRV_CPU_REPLACE("maincpu", M68EC020, 26400000) // needs higher clock to stop sprite flickerings
1799   MDRV_SCREEN_MODIFY("screen")
1800   MDRV_SCREEN_VISIBLE_AREA(40, 40+384-1, 16, 16+224-1)
1801   MDRV_VIDEO_START(dragoonj)
1802MACHINE_DRIVER_END
1803
1804static MACHINE_DRIVER_START( le2 )
1805   MDRV_IMPORT_FROM(konamigx)
1806   MDRV_VIDEO_START(le2)
1807MACHINE_DRIVER_END
1808
1809static MACHINE_DRIVER_START( konamigx_6bpp )
1810   MDRV_IMPORT_FROM(konamigx)
1811   MDRV_VIDEO_START(konamigx_6bpp)
1812MACHINE_DRIVER_END
1813
1814static MACHINE_DRIVER_START( konamigx_6bpp_2 )
1815   MDRV_IMPORT_FROM(konamigx)
1816   MDRV_VIDEO_START(konamigx_6bpp_2)
1817MACHINE_DRIVER_END
1818
1819static MACHINE_DRIVER_START( opengolf )
1820   MDRV_IMPORT_FROM(konamigx)
1821   MDRV_SCREEN_MODIFY("screen")
1822   MDRV_SCREEN_RAW_PARAMS(8000000, 384+24+64+40, 0, 383, 224+16+8+16, 0, 223)
1823   MDRV_SCREEN_VISIBLE_AREA(40, 40+384-1, 16, 16+224-1)
1824   MDRV_GFXDECODE(opengolf)
1825   MDRV_VIDEO_START(opengolf)
1826
1827   MDRV_CPU_MODIFY("maincpu")
1828   MDRV_CPU_PROGRAM_MAP(gx_type1_map)
1829
1830   MDRV_ADC0834_ADD( "adc0834", konamigx_adc_interface )
1831MACHINE_DRIVER_END
1832
1833static MACHINE_DRIVER_START( racinfrc )
1834   MDRV_IMPORT_FROM(konamigx)
1835   MDRV_SCREEN_MODIFY("screen")
1836   MDRV_SCREEN_RAW_PARAMS(8000000, 384+24+64+40, 0, 383, 224+16+8+16, 0, 223)
1837   MDRV_SCREEN_VISIBLE_AREA(32, 32+384-1, 16, 16+224-1)
1838   MDRV_GFXDECODE(racinfrc)
1839   MDRV_VIDEO_START(racinfrc)
1840
1841   MDRV_CPU_MODIFY("maincpu")
1842   MDRV_CPU_PROGRAM_MAP(gx_type1_map)
1843
1844   MDRV_ADC0834_ADD( "adc0834", konamigx_adc_interface )
1845MACHINE_DRIVER_END
1846
1847static MACHINE_DRIVER_START( gxtype3 )
1848   MDRV_IMPORT_FROM(konamigx)
1849
1850   MDRV_CPU_MODIFY("maincpu")
1851   MDRV_CPU_PROGRAM_MAP(gx_type3_map)
1852   MDRV_CPU_VBLANK_INT_HACK(konamigx_hbinterrupt, 262)
1853
1854   MDRV_DEFAULT_LAYOUT(layout_dualhsxs)
1855   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_AFTER_VBLANK | VIDEO_ALWAYS_UPDATE)
1856
1857   MDRV_VIDEO_START(konamigx_type3)
1858   MDRV_PALETTE_LENGTH(16384)
1859   MDRV_SCREEN_MODIFY("screen")
1860   MDRV_SCREEN_SIZE(576, 32*8)
1861   MDRV_SCREEN_VISIBLE_AREA(0, 576-1, 16, 32*8-1-16)
1862
1863   MDRV_SCREEN_ADD("screen2", RASTER)
1864   MDRV_SCREEN_RAW_PARAMS(6000000, 288+16+32+48, 0, 287, 224+16+8+16, 0, 223)
1865   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
1866   MDRV_SCREEN_SIZE(576, 32*8)
1867   MDRV_SCREEN_VISIBLE_AREA(0, 576-1, 16, 32*8-1-16)
1868
1869
1870   MDRV_GFXDECODE(type34)
1871MACHINE_DRIVER_END
1872
1873static MACHINE_DRIVER_START( gxtype4 )
1874   MDRV_IMPORT_FROM(konamigx)
1875
1876   MDRV_CPU_MODIFY("maincpu")
1877   MDRV_CPU_PROGRAM_MAP(gx_type4_map)
1878   MDRV_CPU_VBLANK_INT_HACK(konamigx_hbinterrupt, 262)
1879
1880   MDRV_DEFAULT_LAYOUT(layout_dualhsxs)
1881   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_AFTER_VBLANK | VIDEO_ALWAYS_UPDATE)
1882
1883   MDRV_SCREEN_MODIFY("screen")
1884   MDRV_SCREEN_SIZE(128*8, 32*8)
1885   MDRV_SCREEN_VISIBLE_AREA(0, 384-1, 16, 32*8-1-16)
1886
1887   MDRV_SCREEN_ADD("screen2", RASTER)
1888   MDRV_SCREEN_RAW_PARAMS(6000000, 288+16+32+48, 0, 287, 224+16+8+16, 0, 223)
1889   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
1890   MDRV_SCREEN_SIZE(128*8, 32*8)
1891   MDRV_SCREEN_VISIBLE_AREA(0, 384-1, 16, 32*8-1-16)
1892
1893
1894   MDRV_PALETTE_LENGTH(8192)
1895   MDRV_GFXDECODE(type4)
1896   MDRV_VIDEO_START(konamigx_type4)
1897MACHINE_DRIVER_END
1898
1899static MACHINE_DRIVER_START( gxtype4vsnet )
1900   MDRV_IMPORT_FROM(gxtype4)
1901
1902   MDRV_DEFAULT_LAYOUT(layout_dualhsxs)
1903
1904   MDRV_SCREEN_MODIFY("screen")
1905   MDRV_SCREEN_SIZE(128*8, 32*8)
1906   MDRV_SCREEN_VISIBLE_AREA(0, 576-1, 16, 32*8-1-16)
1907
1908   MDRV_SCREEN_MODIFY("screen2")
1909   MDRV_SCREEN_SIZE(128*8, 32*8)
1910   MDRV_SCREEN_VISIBLE_AREA(0, 576-1, 16, 32*8-1-16)
1911MACHINE_DRIVER_END
1912
1913static MACHINE_DRIVER_START( gxtype4sd2 )
1914   MDRV_IMPORT_FROM(gxtype4)
1915
1916   MDRV_VIDEO_START(konamigx_type4_sd2)
1917MACHINE_DRIVER_END
1918
1919
1920static MACHINE_DRIVER_START( winspike )
1921   MDRV_IMPORT_FROM(konamigx)
1922
1923   MDRV_SCREEN_MODIFY("screen")
1924   MDRV_SCREEN_VISIBLE_AREA(38, 38+384-1, 16, 16+224-1)
1925   MDRV_VIDEO_START(winspike)
1926MACHINE_DRIVER_END
1927
1928
1929/**********************************************************************************/
19591930/* BIOS and ROM maps */
19601931
19611932#define GX_BIOS ROM_LOAD("300a01.34k", 0x000000, 128*1024, CRC(d5fa95f5) SHA1(c483aa98ff8ef40cdac359c19ad23fea5ecc1906) )
src/mame/drivers/triforce.c
r6740r6741
399399#include "driver.h"
400400#include "cpu/powerpc/ppc.h"
401401#include "video/generic.h"
402#include "naomibd.h"
402#include "includes/naomibd.h"
403403
404404static ADDRESS_MAP_START( gc_map, ADDRESS_SPACE_PROGRAM, 32 )
405405   AM_RANGE(0x7fe00000, 0x7fffffff) AM_ROM AM_REGION("maincpu", 0) AM_SHARE("share2")   /* Program ROM */
src/mame/drivers/thunderj.c
r6740r6741
2121#include "cpu/m68000/m68000.h"
2222#include "machine/atarigen.h"
2323#include "audio/atarijsa.h"
24#include "thunderj.h"
24#include "includes/thunderj.h"
2525
2626
2727
r6740r6741
4040}
4141
4242
43static MACHINE_START( thunderj )
44{
45   thunderj_state *state = (thunderj_state *)machine->driver_data;
46   atarigen_init(machine);
47
48   state_save_register_global(machine, state->alpha_tile_bank);
49}
50
51
4352static MACHINE_RESET( thunderj )
4453{
4554   thunderj_state *state = (thunderj_state *)machine->driver_data;
r6740r6741
284293   MDRV_CPU_ADD("extra", M68000, ATARI_CLOCK_14MHz/2)
285294   MDRV_CPU_PROGRAM_MAP(extra_map)
286295
296   MDRV_MACHINE_START(thunderj)
287297   MDRV_MACHINE_RESET(thunderj)
288298   MDRV_NVRAM_HANDLER(atarigen)
289299
src/mame/drivers/parodius.c
r6740r6741
99#include "driver.h"
1010#include "cpu/z80/z80.h"
1111#include "cpu/konami/konami.h" /* for the callback and the firq irq definition */
12#include "video/konamiic.h"
12#include "video/konicdev.h"
1313#include "sound/2151intf.h"
1414#include "sound/k053260.h"
15#include "konamipt.h"
15#include "includes/konamipt.h"
1616
1717/* prototypes */
1818static MACHINE_RESET( parodius );
1919static KONAMI_SETLINES_CALLBACK( parodius_banking );
20VIDEO_START( parodius );
2120VIDEO_UPDATE( parodius );
2221
22extern void parodius_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
23extern void parodius_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask);
24
2325static int videobank;
2426static UINT8 *ram;
2527
2628static INTERRUPT_GEN( parodius_interrupt )
2729{
28   if (K052109_is_IRQ_enabled()) cpu_set_input_line(device, 0, HOLD_LINE);
30   const device_config *k052109 = devtag_get_device(device->machine, "k052109");
31   if (k052109_is_irq_enabled(k052109))
32      cpu_set_input_line(device, 0, HOLD_LINE);
2933}
3034
3135static READ8_HANDLER( bankedram_r )
r6740r6741
5660
5761static READ8_HANDLER( parodius_052109_053245_r )
5862{
63   const device_config *k053245 = devtag_get_device(space->machine, "k053245");
64   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
65
5966   if (videobank & 0x02)
60      return K053245_r(space,offset);
67      return k053245_r(k053245, offset);
6168   else
62      return K052109_r(space,offset);
69      return k052109_r(k052109, offset);
6370}
6471
6572static WRITE8_HANDLER( parodius_052109_053245_w )
6673{
74   const device_config *k053245 = devtag_get_device(space->machine, "k053245");
75   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
76
6777   if (videobank & 0x02)
68      K053245_w(space,offset,data);
78      k053245_w(k053245, offset, data);
6979   else
70      K052109_w(space,offset,data);
80      k052109_w(k052109, offset, data);
7181}
7282
7383static WRITE8_HANDLER( parodius_videobank_w )
r6740r6741
8292
8393static WRITE8_HANDLER( parodius_3fc0_w )
8494{
95   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
96
8597   if ((data & 0xf4) != 0x10) logerror("%04x: 3fc0 = %02x\n",cpu_get_pc(space->cpu),data);
8698
8799   /* bit 0/1 = coin counters */
r6740r6741
89101   coin_counter_w(space->machine, 1,data & 0x02);
90102
91103   /* bit 3 = enable char ROM reading through the video RAM */
92   K052109_set_RMRD_line( ( data & 0x08 ) ? ASSERT_LINE : CLEAR_LINE );
104   k052109_set_rmrd_line(k052109, (data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
93105
94106   /* other bits unknown */
95107}
r6740r6741
137149   AM_RANGE(0x3f8e, 0x3f8e) AM_READ_PORT("DSW3")
138150   AM_RANGE(0x3f8f, 0x3f8f) AM_READ_PORT("DSW1")
139151   AM_RANGE(0x3f90, 0x3f90) AM_READ_PORT("DSW2")
140   AM_RANGE(0x3fa0, 0x3faf) AM_READWRITE(K053244_r,K053244_w)
141   AM_RANGE(0x3fb0, 0x3fbf) AM_WRITE(K053251_w)
152   AM_RANGE(0x3fa0, 0x3faf) AM_DEVREADWRITE("k053245", k053244_r, k053244_w)
153   AM_RANGE(0x3fb0, 0x3fbf) AM_DEVWRITE("k053251", k053251_w)
142154   AM_RANGE(0x3fc0, 0x3fc0) AM_READWRITE(watchdog_reset_r,parodius_3fc0_w)
143155   AM_RANGE(0x3fc4, 0x3fc4) AM_WRITE(parodius_videobank_w)
144156   AM_RANGE(0x3fc8, 0x3fc8) AM_WRITE(parodius_sh_irqtrigger_w)
145157   AM_RANGE(0x3fcc, 0x3fcd) AM_DEVREADWRITE("konami", parodius_sound_r,k053260_w)   /* K053260 */
146158   AM_RANGE(0x2000, 0x27ff) AM_READWRITE(parodius_052109_053245_r,parodius_052109_053245_w)
147   AM_RANGE(0x2000, 0x5fff) AM_READWRITE(K052109_r,K052109_w)
159   AM_RANGE(0x2000, 0x5fff) AM_DEVREADWRITE("k052109", k052109_r, k052109_w)
148160   AM_RANGE(0x6000, 0x9fff) AM_ROMBANK("bank1")         /* banked ROM */
149161   AM_RANGE(0xa000, 0xffff) AM_ROM               /* ROM */
150162ADDRESS_MAP_END
r6740r6741
223235
224236***************************************************************************/
225237
238static const k052109_interface parodius_k052109_intf =
239{
240   "gfx1", 0,
241   NORMAL_PLANE_ORDER,
242   KONAMI_ROM_DEINTERLEAVE_2,
243   parodius_tile_callback
244};
245
246static const k05324x_interface parodius_k05324x_intf =
247{
248   "gfx2", 1,
249   NORMAL_PLANE_ORDER,
250   0, 0,
251   KONAMI_ROM_DEINTERLEAVE_2,
252   parodius_sprite_callback
253};
254
226255static MACHINE_DRIVER_START( parodius )
227256
228257   /* basic machine hardware */
r6740r6741
248277
249278   MDRV_PALETTE_LENGTH(2048)
250279
251   MDRV_VIDEO_START(parodius)
252280   MDRV_VIDEO_UPDATE(parodius)
253281
282   MDRV_K052109_ADD("k052109", parodius_k052109_intf)
283   MDRV_K053245_ADD("k053245", parodius_k05324x_intf)
284   MDRV_K053251_ADD("k053251")
285
254286   /* sound hardware */
255287   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
256288
r6740r6741
344376}
345377
346378
347static DRIVER_INIT( parodius )
348{
349   konami_rom_deinterleave_2(machine, "gfx1");
350   konami_rom_deinterleave_2(machine, "gfx2");
351}
352
353
354GAME( 1990, parodius, 0,        parodius, parodius, parodius, ROT0, "Konami", "Parodius DA! (World)", 0 )
355GAME( 1990, parodiusj,parodius, parodius, parodius, parodius, ROT0, "Konami", "Parodius DA! (Japan)", 0 )
379GAME( 1990, parodius, 0,        parodius, parodius, 0, ROT0, "Konami", "Parodius DA! (World)", 0 )
380GAME( 1990, parodiusj,parodius, parodius, parodius, 0, ROT0, "Konami", "Parodius DA! (Japan)", 0 )
src/mame/drivers/combatsc.c
r6740r6741
33"Combat School" (also known as "Boot Camp") - (Konami GX611)
44
55TODO:
6- in combasc (and more generally the 007121) the number of sprites can be
6- in combatsc (and more generally the 007121) the number of sprites can be
77  increased from 0x40 to 0x80. There is a hack in konamiic.c to handle that,
88  but it is wrong. If you don't pass the Iron Man stage, a few sprites are
99  left dangling on the screen.(*not a bug, 64 sprites are the maximum)
1010- it seems that to get correct target colors in firing range III we have to
1111  use the WRONG lookup table (the one for tiles instead of the one for
1212  sprites).
13- in combascb, wrong sprite/char priority (see cpu head at beginning of arm
13- in combatscb, wrong sprite/char priority (see cpu head at beginning of arm
1414  wrestling, and heads in intermission after firing range III)
1515- hook up sound in bootleg (the current sound is a hack, making use of the
1616  Konami ROMset)
r6740r6741
126126#include "cpu/z80/z80.h"
127127#include "sound/2203intf.h"
128128#include "sound/upd7759.h"
129#include "video/konicdev.h"
130#include "includes/combatsc.h"
129131
130/* from video/combasc.c */
131PALETTE_INIT( combasc );
132PALETTE_INIT( combascb );
133READ8_HANDLER( combasc_video_r );
134WRITE8_HANDLER( combasc_video_w );
135VIDEO_START( combasc );
136VIDEO_START( combascb );
137132
138WRITE8_HANDLER( combascb_bankselect_w );
139WRITE8_HANDLER( combasc_bankselect_w );
140MACHINE_RESET( combasc );
141WRITE8_HANDLER( combasc_pf_control_w );
142READ8_HANDLER( combasc_scrollram_r );
143WRITE8_HANDLER( combasc_scrollram_w );
133/*************************************
134 *
135 *  Memory handlers
136 *
137 *************************************/
144138
145VIDEO_UPDATE( combascb );
146VIDEO_UPDATE( combasc );
147WRITE8_HANDLER( combasc_vreg_w );
139static WRITE8_HANDLER( combatsc_vreg_w )
140{
141   combatsc_state *state = (combatsc_state *)space->machine->driver_data;
142   if (data != state->vreg)
143   {
144      tilemap_mark_all_tiles_dirty(state->textlayer);
145      if ((data & 0x0f) != (state->vreg & 0x0f))
146         tilemap_mark_all_tiles_dirty(state->bg_tilemap[0]);
147      if ((data >> 4) != (state->vreg >> 4))
148         tilemap_mark_all_tiles_dirty(state->bg_tilemap[1]);
149      state->vreg = data;
150   }
151}
148152
153static WRITE8_HANDLER( combatscb_sh_irqtrigger_w )
154{
155   combatsc_state *state = (combatsc_state *)space->machine->driver_data;
156   soundlatch_w(space, offset, data);
157   cpu_set_input_line_and_vector(state->audiocpu, 0, HOLD_LINE, 0xff);
158}
149159
160static READ8_HANDLER( combatscb_io_r )
161{
162   static const char *const portnames[] = { "IN0", "IN1", "DSW1", "DSW2" };
150163
164   return input_port_read(space->machine, portnames[offset]);
165}
151166
152static WRITE8_HANDLER( combasc_coin_counter_w )
167static WRITE8_HANDLER( combatscb_priority_w )
153168{
169   combatsc_state *state = (combatsc_state *)space->machine->driver_data;
170   state->priority = data & 0x20;
171}
172
173static WRITE8_HANDLER( combatsc_bankselect_w )
174{
175   combatsc_state *state = (combatsc_state *)space->machine->driver_data;
176
177   if (data & 0x40)
178   {
179      state->video_circuit = 1;
180      state->videoram = state->page[1];
181      state->scrollram = state->scrollram1;
182   }
183   else
184   {
185      state->video_circuit = 0;
186      state->videoram = state->page[0];
187      state->scrollram = state->scrollram0;
188   }
189
190   state->priority = data & 0x20;
191
192   if (data & 0x10)
193      memory_set_bank(space->machine, "bank1", (data & 0x0e) >> 1);
194   else
195      memory_set_bank(space->machine, "bank1", 8 + (data & 1));
196}
197
198static WRITE8_HANDLER( combatscb_io_w )
199{
200   combatsc_state *state = (combatsc_state *)space->machine->driver_data;
201
202   switch (offset)
203   {
204      case 0x400: combatscb_priority_w(space, 0, data); break;
205      case 0x800: combatscb_sh_irqtrigger_w(space, 0, data); break;
206      case 0xc00:   combatsc_vreg_w(space, 0, data); break;
207      default: state->io_ram[offset] = data; break;
208   }
209}
210
211static WRITE8_HANDLER( combatscb_bankselect_w )
212{
213   combatsc_state *state = (combatsc_state *)space->machine->driver_data;
214
215   if (data & 0x40)
216   {
217      state->video_circuit = 1;
218      state->videoram = state->page[1];
219   }
220   else
221   {
222      state->video_circuit = 0;
223      state->videoram = state->page[0];
224   }
225
226   data = data & 0x1f;
227
228   if (data != state->bank_select)
229   {
230      state->bank_select = data;
231
232      if (data & 0x10)
233         memory_set_bank(space->machine, "bank1", (data & 0x0e) >> 1);
234      else
235         memory_set_bank(space->machine, "bank1", 8 + (data & 1));
236
237      if (data == 0x1f)
238      {
239         memory_set_bank(space->machine, "bank1", 8 + (data & 1));
240         memory_install_write8_handler(space, 0x4000, 0x7fff, 0, 0, combatscb_io_w);
241         memory_install_read8_handler(space, 0x4400, 0x4403, 0, 0, combatscb_io_r);/* IO RAM & Video Registers */
242      }
243      else
244      {
245         memory_install_read_bank(space, 0x4000, 0x7fff, 0, 0, "bank1");   /* banked ROM */
246         memory_unmap_write(space, 0x4000, 0x7fff, 0, 0);   /* banked ROM */
247      }
248   }
249}
250
251/****************************************************************************/
252
253static WRITE8_HANDLER( combatsc_coin_counter_w )
254{
154255   /* b7-b3: unused? */
155256   /* b1: coin counter 2 */
156257   /* b0: coin counter 1 */
157258
158   coin_counter_w(space->machine, 0,data & 0x01);
159   coin_counter_w(space->machine, 1,data & 0x02);
259   coin_counter_w(space->machine, 0, data & 0x01);
260   coin_counter_w(space->machine, 1, data & 0x02);
160261}
161262
162263static READ8_HANDLER( trackball_r )
163264{
164   static UINT8 pos[4],sign[4];
265   combatsc_state *state = (combatsc_state *)space->machine->driver_data;
165266
166267   if (offset == 0)
167268   {
168      int i,dir[4];
269      int i, dir[4];
169270      static const char *const tracknames[] = { "TRACK0_Y", "TRACK0_X", "TRACK1_Y", "TRACK1_X" };
170271
171272      for (i = 0; i < 4; i++)
r6740r6741
174275
175276         curr = input_port_read_safe(space->machine, tracknames[i], 0xff);
176277
177         dir[i] = curr - pos[i];
178         sign[i] = dir[i] & 0x80;
179         pos[i] = curr;
278         dir[i] = curr - state->pos[i];
279         state->sign[i] = dir[i] & 0x80;
280         state->pos[i] = curr;
180281      }
181282
182283      /* fix sign for orthogonal movements */
183284      if (dir[0] || dir[1])
184285      {
185         if (!dir[0]) sign[0] = sign[1] ^ 0x80;
186         if (!dir[1]) sign[1] = sign[0];
286         if (!dir[0]) state->sign[0] = state->sign[1] ^ 0x80;
287         if (!dir[1]) state->sign[1] = state->sign[0];
187288      }
188289      if (dir[2] || dir[3])
189290      {
190         if (!dir[2]) sign[2] = sign[3] ^ 0x80;
191         if (!dir[3]) sign[3] = sign[2];
291         if (!dir[2]) state->sign[2] = state->sign[3] ^ 0x80;
292         if (!dir[3]) state->sign[3] = state->sign[2];
192293      }
193294   }
194295
195   return sign[offset] | (pos[offset] & 0x7f);
296   return state->sign[offset] | (state->pos[offset] & 0x7f);
196297}
197298
198299
199300/* the protection is a simple multiply */
200static int prot[2];
201
202301static WRITE8_HANDLER( protection_w )
203302{
204   prot[offset] = data;
303   combatsc_state *state = (combatsc_state *)space->machine->driver_data;
304   state->prot[offset] = data;
205305}
206306static READ8_HANDLER( protection_r )
207307{
208   return ((prot[0] * prot[1]) >> (offset * 8)) & 0xff;
308   combatsc_state *state = (combatsc_state *)space->machine->driver_data;
309   return ((state->prot[0] * state->prot[1]) >> (offset * 8)) & 0xff;
209310}
210311static WRITE8_HANDLER( protection_clock_w )
211312{
r6740r6741
215316
216317/****************************************************************************/
217318
218static WRITE8_HANDLER( combasc_sh_irqtrigger_w )
319static WRITE8_HANDLER( combatsc_sh_irqtrigger_w )
219320{
220   cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff);
321   combatsc_state *state = (combatsc_state *)space->machine->driver_data;
322   cpu_set_input_line_and_vector(state->audiocpu, 0, HOLD_LINE, 0xff);
221323}
222324
223static READ8_DEVICE_HANDLER( combasc_busy_r )
325static READ8_DEVICE_HANDLER( combatsc_busy_r )
224326{
225327   return upd7759_busy_r(device) ? 1 : 0;
226328}
227329
228static WRITE8_DEVICE_HANDLER( combasc_play_w )
330static WRITE8_DEVICE_HANDLER( combatsc_play_w )
229331{
230332   upd7759_start_w(device, data & 2);
231333}
232334
233static WRITE8_DEVICE_HANDLER( combasc_voice_reset_w )
335static WRITE8_DEVICE_HANDLER( combatsc_voice_reset_w )
234336{
235    upd7759_reset_w(device,data & 1);
337   upd7759_reset_w(device,data & 1);
236338}
237339
238static WRITE8_DEVICE_HANDLER( combasc_portA_w )
340static WRITE8_DEVICE_HANDLER( combatsc_portA_w )
239341{
240342   /* unknown. always write 0 */
241343}
242344
243static int boost;
244static emu_timer *combasc_interleave_timer;
245
246static READ8_DEVICE_HANDLER ( combasc_ym2203_r )
345static READ8_DEVICE_HANDLER ( combatsc_ym2203_r )
247346{
347   combatsc_state *state = (combatsc_state *)device->machine->driver_data;
248348   int status = ym2203_r(device,offset);
249349
250   if (cpu_get_pc(cputag_get_cpu(device->machine, "audiocpu")) == 0x334)
350   if (cpu_get_pc(state->audiocpu) == 0x334)
251351   {
252      if (boost)
352      if (state->boost)
253353      {
254         boost = 0;
255         timer_adjust_periodic(combasc_interleave_timer, attotime_zero, 0, cputag_clocks_to_attotime(device->machine, "audiocpu", 80));
354         state->boost = 0;
355         timer_adjust_periodic(state->interleave_timer, attotime_zero, 0, cpu_clocks_to_attotime(state->audiocpu, 80));
256356      }
257357      else if (status & 2)
258358      {
259         boost = 1;
260         timer_adjust_oneshot(combasc_interleave_timer, attotime_zero, 0);
359         state->boost = 1;
360         timer_adjust_oneshot(state->interleave_timer, attotime_zero, 0);
261361      }
262362   }
263363
264   return(status);
364   return status;
265365}
266366
267/****************************************************************************/
367/*************************************
368 *
369 *  Address maps
370 *
371 *************************************/
268372
269static ADDRESS_MAP_START( combasc_map, ADDRESS_SPACE_PROGRAM, 8 )
270   AM_RANGE(0x0000, 0x0007) AM_WRITE(combasc_pf_control_w)
271   AM_RANGE(0x0020, 0x005f) AM_READWRITE(combasc_scrollram_r, combasc_scrollram_w)
373static ADDRESS_MAP_START( combatsc_map, ADDRESS_SPACE_PROGRAM, 8 )
374   AM_RANGE(0x0000, 0x0007) AM_WRITE(combatsc_pf_control_w)
375   AM_RANGE(0x0020, 0x005f) AM_READWRITE(combatsc_scrollram_r, combatsc_scrollram_w)
272376//  AM_RANGE(0x0060, 0x00ff) AM_WRITEONLY                 /* RAM */
273377
274378   AM_RANGE(0x0200, 0x0201) AM_READWRITE(protection_r, protection_w)
r6740r6741
279383   AM_RANGE(0x0402, 0x0402) AM_READ_PORT("DSW1")         /* DSW #1 */
280384   AM_RANGE(0x0403, 0x0403) AM_READ_PORT("DSW2")         /* DSW #2 */
281385   AM_RANGE(0x0404, 0x0407) AM_READ(trackball_r)         /* 1P & 2P controls / trackball */
282   AM_RANGE(0x0408, 0x0408) AM_WRITE(combasc_coin_counter_w)   /* coin counters */
283   AM_RANGE(0x040c, 0x040c) AM_WRITE(combasc_vreg_w)
284   AM_RANGE(0x0410, 0x0410) AM_WRITE(combasc_bankselect_w)
386   AM_RANGE(0x0408, 0x0408) AM_WRITE(combatsc_coin_counter_w)   /* coin counters */
387   AM_RANGE(0x040c, 0x040c) AM_WRITE(combatsc_vreg_w)
388   AM_RANGE(0x0410, 0x0410) AM_WRITE(combatsc_bankselect_w)
285389   AM_RANGE(0x0414, 0x0414) AM_WRITE(soundlatch_w)
286   AM_RANGE(0x0418, 0x0418) AM_WRITE(combasc_sh_irqtrigger_w)
390   AM_RANGE(0x0418, 0x0418) AM_WRITE(combatsc_sh_irqtrigger_w)
287391   AM_RANGE(0x041c, 0x041c) AM_WRITE(watchdog_reset_w)         /* watchdog reset? */
288392
289   AM_RANGE(0x0600, 0x06ff) AM_RAM AM_BASE_GENERIC(paletteram)      /* palette */
393   AM_RANGE(0x0600, 0x06ff) AM_RAM AM_BASE_MEMBER(combatsc_state, paletteram)      /* palette */
290394   AM_RANGE(0x0800, 0x1fff) AM_RAM                        /* RAM */
291   AM_RANGE(0x2000, 0x3fff) AM_READWRITE(combasc_video_r, combasc_video_w)
395   AM_RANGE(0x2000, 0x3fff) AM_READWRITE(combatsc_video_r, combatsc_video_w)
292396   AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1")                  /* banked ROM area */
293397   AM_RANGE(0x8000, 0xffff) AM_ROM                        /* ROM */
294398ADDRESS_MAP_END
295399
296static ADDRESS_MAP_START( combascb_map, ADDRESS_SPACE_PROGRAM, 8 )
400static ADDRESS_MAP_START( combatscb_map, ADDRESS_SPACE_PROGRAM, 8 )
297401   AM_RANGE(0x0000, 0x04ff) AM_RAM
298   AM_RANGE(0x0500, 0x0500) AM_WRITE(combascb_bankselect_w)
299   AM_RANGE(0x0600, 0x06ff) AM_RAM AM_BASE_GENERIC(paletteram)      /* palette */
402   AM_RANGE(0x0500, 0x0500) AM_WRITE(combatscb_bankselect_w)
403   AM_RANGE(0x0600, 0x06ff) AM_RAM AM_BASE_MEMBER(combatsc_state, paletteram)      /* palette */
300404   AM_RANGE(0x0800, 0x1fff) AM_RAM
301   AM_RANGE(0x2000, 0x3fff) AM_READWRITE(combasc_video_r, combasc_video_w)
405   AM_RANGE(0x2000, 0x3fff) AM_READWRITE(combatsc_video_r, combatsc_video_w)
302406   AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1")                  /* banked ROM/RAM area */
303407   AM_RANGE(0x8000, 0xffff) AM_ROM                        /* ROM */
304408ADDRESS_MAP_END
r6740r6741
316420ADDRESS_MAP_END
317421#endif
318422
319static ADDRESS_MAP_START( combasc_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
423static ADDRESS_MAP_START( combatsc_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
320424   AM_RANGE(0x0000, 0x7fff) AM_ROM                                    /* ROM */
321425   AM_RANGE(0x8000, 0x87ff) AM_RAM                                    /* RAM */
322426
323   AM_RANGE(0x9000, 0x9000) AM_DEVWRITE("upd", combasc_play_w)               /* upd7759 play voice */
427   AM_RANGE(0x9000, 0x9000) AM_DEVWRITE("upd", combatsc_play_w)               /* upd7759 play voice */
324428   AM_RANGE(0xa000, 0xa000) AM_DEVWRITE("upd", upd7759_port_w)               /* upd7759 voice select */
325   AM_RANGE(0xb000, 0xb000) AM_DEVREAD("upd", combasc_busy_r)               /* upd7759 busy? */
326   AM_RANGE(0xc000, 0xc000) AM_DEVWRITE("upd", combasc_voice_reset_w)         /* upd7759 reset? */
429   AM_RANGE(0xb000, 0xb000) AM_DEVREAD("upd", combatsc_busy_r)               /* upd7759 busy? */
430   AM_RANGE(0xc000, 0xc000) AM_DEVWRITE("upd", combatsc_voice_reset_w)         /* upd7759 reset? */
327431
328432   AM_RANGE(0xd000, 0xd000) AM_READ(soundlatch_r)                        /* soundlatch_r? */
329   AM_RANGE(0xe000, 0xe001) AM_DEVREADWRITE("ymsnd", combasc_ym2203_r, ym2203_w)   /* YM 2203 intercepted */
433   AM_RANGE(0xe000, 0xe001) AM_DEVREADWRITE("ymsnd", combatsc_ym2203_r, ym2203_w)   /* YM 2203 intercepted */
330434ADDRESS_MAP_END
331435
332436
437/*************************************
438 *
439 *  Input ports
440 *
441 *************************************/
442
333443static INPUT_PORTS_START( common_inputs )
334444   PORT_START("IN0")
335445   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
r6740r6741
410520   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
411521INPUT_PORTS_END
412522
413static INPUT_PORTS_START( combasc )
523static INPUT_PORTS_START( combatsc )
414524   PORT_INCLUDE( dips )
415525
416526   PORT_INCLUDE( common_inputs )
r6740r6741
426536   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
427537INPUT_PORTS_END
428538
429static INPUT_PORTS_START( combasct )
539static INPUT_PORTS_START( combatsct )
430540   PORT_INCLUDE( dips )
431541
432542   PORT_INCLUDE( common_inputs )
r6740r6741
446556   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(10) PORT_KEYDELTA(10) PORT_PLAYER(2)
447557INPUT_PORTS_END
448558
449static INPUT_PORTS_START( combascb )
559static INPUT_PORTS_START( combatscb )
450560   PORT_INCLUDE( dips )
451561
452562   PORT_MODIFY("DSW2")
r6740r6741
478588
479589
480590
591/*************************************
592 *
593 *  Graphics definitions
594 *
595 *************************************/
596
481597static const gfx_layout gfxlayout =
482598{
483599   8,8,
r6740r6741
517633   8*8*4
518634};
519635
520static GFXDECODE_START( combasc )
636static GFXDECODE_START( combatsc )
521637   GFXDECODE_ENTRY( "gfx1", 0x00000, gfxlayout, 0, 8*16 )
522638   GFXDECODE_ENTRY( "gfx2", 0x00000, gfxlayout, 0, 8*16 )
523639GFXDECODE_END
524640
525static GFXDECODE_START( combascb )
641static GFXDECODE_START( combatscb )
526642   GFXDECODE_ENTRY( "gfx1", 0x00000, tile_layout,   0, 8*16 )
527643   GFXDECODE_ENTRY( "gfx1", 0x40000, tile_layout,   0, 8*16 )
528644   GFXDECODE_ENTRY( "gfx2", 0x00000, sprite_layout, 0, 8*16 )
529645   GFXDECODE_ENTRY( "gfx2", 0x40000, sprite_layout, 0, 8*16 )
530646GFXDECODE_END
531647
648
649/*************************************
650 *
651 *  Machine driver
652 *
653 *************************************/
654
532655static const ym2203_interface ym2203_config =
533656{
534657   {
r6740r6741
536659      AY8910_DEFAULT_LOADS,
537660      DEVCB_NULL,
538661      DEVCB_NULL,
539      DEVCB_HANDLER(combasc_portA_w),
662      DEVCB_HANDLER(combatsc_portA_w),
540663      DEVCB_NULL
541664   },
542665   NULL
543666};
544667
545668
669static MACHINE_START( combatsc )
670{
671   combatsc_state *state = (combatsc_state *)machine->driver_data;
672   UINT8 *MEM = memory_region(machine, "maincpu") + 0x38000;
673
674   state->io_ram  = MEM + 0x0000;
675   state->page[0] = MEM + 0x4000;
676   state->page[1] = MEM + 0x6000;
677
678   state->interleave_timer = timer_alloc(machine, NULL, NULL);
679
680   state->audiocpu = devtag_get_device(machine, "audiocpu");
681   state->k007121_1 = devtag_get_device(machine, "k007121_1");
682   state->k007121_2 = devtag_get_device(machine, "k007121_2");
683
684   memory_configure_bank(machine, "bank1", 0, 10, memory_region(machine, "maincpu") + 0x10000, 0x4000);
685
686   state_save_register_global(machine, state->priority);
687   state_save_register_global(machine, state->vreg);
688   state_save_register_global(machine, state->bank_select);
689   state_save_register_global(machine, state->video_circuit);
690   state_save_register_global(machine, state->boost);
691   state_save_register_global_array(machine, state->prot);
692   state_save_register_global_array(machine, state->pos);
693   state_save_register_global_array(machine, state->sign);
694}
695
696
697static MACHINE_RESET( combatsc )
698{
699   combatsc_state *state = (combatsc_state *)machine->driver_data;
700   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
701   int i;
702
703   memset(state->io_ram,  0x00, 0x4000);
704   memset(state->page[0], 0x00, 0x2000);
705   memset(state->page[1], 0x00, 0x2000);
706
707   state->vreg = -1;
708   state->boost = 1;
709   state->bank_select = -1;
710   state->prot[0] = 0;
711   state->prot[1] = 0;
712
713   for (i = 0; i < 4; i++)
714   {
715      state->pos[i] = 0;
716      state->sign[i] = 0;
717   }
718
719   combatsc_bankselect_w(space, 0, 0);
720}
721
546722/* combat school (original) */
547static MACHINE_DRIVER_START( combasc )
723static MACHINE_DRIVER_START( combatsc )
548724
725   /* driver data */
726   MDRV_DRIVER_DATA(combatsc_state)
727
549728   /* basic machine hardware */
550729   MDRV_CPU_ADD("maincpu", HD6309, 3000000*4)   /* 3 MHz? */
551   MDRV_CPU_PROGRAM_MAP(combasc_map)
730   MDRV_CPU_PROGRAM_MAP(combatsc_map)
552731   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
553732
554733   MDRV_CPU_ADD("audiocpu", Z80,3579545)   /* 3.579545 MHz */
555   MDRV_CPU_PROGRAM_MAP(combasc_sound_map)
734   MDRV_CPU_PROGRAM_MAP(combatsc_sound_map)
556735
557736   MDRV_QUANTUM_TIME(HZ(1200))
558737
559   MDRV_MACHINE_RESET(combasc)
738   MDRV_MACHINE_START(combatsc)
739   MDRV_MACHINE_RESET(combatsc)
560740
561741   /* video hardware */
562742   MDRV_SCREEN_ADD("screen", RASTER)
r6740r6741
566746   MDRV_SCREEN_SIZE(32*8, 32*8)
567747   MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
568748
569   MDRV_GFXDECODE(combasc)
749   MDRV_GFXDECODE(combatsc)
570750   MDRV_PALETTE_LENGTH(8*16*16)
571751
572   MDRV_PALETTE_INIT(combasc)
573   MDRV_VIDEO_START(combasc)
574   MDRV_VIDEO_UPDATE(combasc)
752   MDRV_PALETTE_INIT(combatsc)
753   MDRV_VIDEO_START(combatsc)
754   MDRV_VIDEO_UPDATE(combatsc)
575755
756   MDRV_K007121_ADD("k007121_1")
757   MDRV_K007121_ADD("k007121_2")
758
576759   /* sound hardware */
577760   MDRV_SPEAKER_STANDARD_MONO("mono")
578761
r6740r6741
585768MACHINE_DRIVER_END
586769
587770/* combat school (bootleg on different hardware) */
588static MACHINE_DRIVER_START( combascb )
771static MACHINE_DRIVER_START( combatscb )
589772
773   /* driver data */
774   MDRV_DRIVER_DATA(combatsc_state)
775
590776   /* basic machine hardware */
591777   MDRV_CPU_ADD("maincpu", HD6309, 3000000*4)   /* 3 MHz? */
592   MDRV_CPU_PROGRAM_MAP(combascb_map)
778   MDRV_CPU_PROGRAM_MAP(combatscb_map)
593779   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
594780
595781   MDRV_CPU_ADD("audiocpu", Z80,3579545)   /* 3.579545 MHz */
596   MDRV_CPU_PROGRAM_MAP(combasc_sound_map) /* FAKE */
782   MDRV_CPU_PROGRAM_MAP(combatsc_sound_map) /* FAKE */
597783
598784   MDRV_QUANTUM_TIME(HZ(1200))
599785
600   MDRV_MACHINE_RESET(combasc)
786   MDRV_MACHINE_START(combatsc)
787   MDRV_MACHINE_RESET(combatsc)
601788
602789   /* video hardware */
603790   MDRV_SCREEN_ADD("screen", RASTER)
r6740r6741
607794   MDRV_SCREEN_SIZE(32*8, 32*8)
608795   MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
609796
610   MDRV_GFXDECODE(combascb)
797   MDRV_GFXDECODE(combatscb)
611798   MDRV_PALETTE_LENGTH(8*16*16)
612799
613   MDRV_PALETTE_INIT(combascb)
614   MDRV_VIDEO_START(combascb)
615   MDRV_VIDEO_UPDATE(combascb)
800   MDRV_PALETTE_INIT(combatscb)
801   MDRV_VIDEO_START(combatscb)
802   MDRV_VIDEO_UPDATE(combatscb)
616803
617804   /* We are using the original sound subsystem */
618805   MDRV_SPEAKER_STANDARD_MONO("mono")
r6740r6741
627814
628815
629816
630ROM_START( combasc )
817/*************************************
818 *
819 *  ROM definition(s)
820 *
821 *************************************/
822
823ROM_START( combatsc )
631824   ROM_REGION( 0x40000, "maincpu", 0 ) /* 6309 code */
632825   ROM_LOAD( "611g01.rom", 0x30000, 0x08000, CRC(857ffffe) SHA1(de7566d58314df4b7fdc07eb31a3f9bdd12d1a73) )
633826   ROM_CONTINUE(           0x08000, 0x08000 )
r6740r6741
660853   ROM_LOAD( "pal20l8.8h",   0x0400, 0x0144, NO_DUMP ) /* PAL is read protected */
661854ROM_END
662855
663ROM_START( combasct )
856ROM_START( combatsct )
664857   ROM_REGION( 0x40000, "maincpu", 0 ) /* 6309 code */
665858   ROM_LOAD( "g01.rom",     0x30000, 0x08000, CRC(489c132f) SHA1(c717195f89add4be4a21ecc1ddd58361b0ab4a74) )
666859   ROM_CONTINUE(            0x08000, 0x08000 )
r6740r6741
688881   ROM_LOAD( "611g04.rom",  0x00000, 0x20000, CRC(2987e158) SHA1(87c5129161d3be29a339083349807e60b625c3f7) )
689882ROM_END
690883
691ROM_START( combascj )
884ROM_START( combatscj )
692885   ROM_REGION( 0x40000, "maincpu", 0 ) /* 6309 code */
693886   ROM_LOAD( "611p01.a14",  0x30000, 0x08000, CRC(d748268e) SHA1(91588b6a0d3af47065204b980a56544a9f29b6d9) )
694887   ROM_CONTINUE(            0x08000, 0x08000 )
r6740r6741
744937   ROM_LOAD( "611g04.rom",  0x00000, 0x20000, CRC(2987e158) SHA1(87c5129161d3be29a339083349807e60b625c3f7) )
745938ROM_END
746939
747ROM_START( combascb )
940ROM_START( combatscb )
748941   ROM_REGION( 0x40000, "maincpu", 0 ) /* 6809 code */
749942   ROM_LOAD( "combat.002",    0x30000, 0x08000, CRC(0996755d) SHA1(bb6bbbf7ab3b5fab5e1c6cebc7b3f0d720493c3b) )
750943   ROM_CONTINUE(            0x08000, 0x08000 )
r6740r6741
785978ROM_END
786979
787980
981/*************************************
982 *
983 *  Driver initialization
984 *
985 *************************************/
788986
789static void combasc_init_common(running_machine *machine)
987static DRIVER_INIT( combatsc )
790988{
791   boost = 1;
792   combasc_interleave_timer = timer_alloc(machine, NULL, NULL);
793}
794
795static DRIVER_INIT( combasct )
796{
797   combasc_init_common(machine);
798}
799
800static DRIVER_INIT( combasc )
801{
802989   /* joystick instead of trackball */
803990   memory_install_read_port(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0404, 0x0404, 0, 0, "IN1");
804
805   combasc_init_common(machine);
806991}
807992
808static DRIVER_INIT( combascb )
809{
810   combasc_init_common(machine);
811}
812993
994/*************************************
995 *
996 *  Game driver(s)
997 *
998 *************************************/
813999
814
815GAME( 1988, combasc,  0,       combasc,  combasc,  combasc,  ROT0, "Konami", "Combat School (joystick)", 0 )
816GAME( 1987, combasct, combasc, combasc,  combasct, combasct, ROT0, "Konami", "Combat School (trackball)", 0 )
817GAME( 1987, combascj, combasc, combasc,  combasct, combasct, ROT0, "Konami", "Combat School (Japan trackball)", 0 )
818GAME( 1987, bootcamp, combasc, combasc,  combasct, combasct, ROT0, "Konami", "Boot Camp", 0 )
819GAME( 1988, combascb, combasc, combascb, combascb, combascb, ROT0, "bootleg", "Combat School (bootleg)", GAME_IMPERFECT_COLORS )
1000GAME( 1988, combatsc,  0,        combatsc,  combatsc,  combatsc,  ROT0, "Konami",  "Combat School (joystick)", 0 )
1001GAME( 1987, combatsct, combatsc, combatsc,  combatsct, 0,         ROT0, "Konami",  "Combat School (trackball)", 0 )
1002GAME( 1987, combatscj, combatsc, combatsc,  combatsct, 0,         ROT0, "Konami",  "Combat School (Japan trackball)", 0 )
1003GAME( 1987, bootcamp,  combatsc, combatsc,  combatsct, 0,         ROT0, "Konami",  "Boot Camp", 0 )
1004GAME( 1988, combatscb, combatsc, combatscb, combatscb, 0,         ROT0, "bootleg", "Combat School (bootleg)", GAME_IMPERFECT_COLORS )
src/mame/drivers/rockrage.c
r6740r6741
5050#include "driver.h"
5151#include "cpu/m6809/m6809.h"
5252#include "cpu/hd6309/hd6309.h"
53#include "video/konamiic.h"
5453#include "sound/2151intf.h"
5554#include "sound/vlm5030.h"
55#include "video/konicdev.h"
56#include "includes/rockrage.h"
5657
57/* from video */
58VIDEO_START( rockrage );
59VIDEO_UPDATE( rockrage );
60WRITE8_HANDLER( rockrage_vreg_w );
61PALETTE_INIT( rockrage );
6258
6359static INTERRUPT_GEN( rockrage_interrupt )
6460{
65   if (K007342_is_INT_enabled())
66        cpu_set_input_line(device, HD6309_IRQ_LINE, HOLD_LINE);
61   rockrage_state *state = (rockrage_state *)device->machine->driver_data;
62   if (k007342_is_int_enabled(state->k007342))
63      cpu_set_input_line(device, HD6309_IRQ_LINE, HOLD_LINE);
6764}
6865
6966static WRITE8_HANDLER( rockrage_bankswitch_w )
7067{
71   int bankaddress;
72   UINT8 *RAM = memory_region(space->machine, "maincpu");
73
7468   /* bits 4-6 = bank number */
75   bankaddress = 0x10000 + ((data & 0x70) >> 4) * 0x2000;
76   memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]);
69   memory_set_bank(space->machine, "bank1", (data & 0x70) >> 4);
7770
7871   /* bits 0 & 1 = coin counters */
7972   coin_counter_w(space->machine, 0,data & 0x01);
r6740r6741
8477
8578static WRITE8_HANDLER( rockrage_sh_irqtrigger_w )
8679{
80   rockrage_state *state = (rockrage_state *)space->machine->driver_data;
8781   soundlatch_w(space, offset, data);
88   cputag_set_input_line(space->machine, "audiocpu", M6809_IRQ_LINE, HOLD_LINE);
82   cpu_set_input_line(state->audiocpu, M6809_IRQ_LINE, HOLD_LINE);
8983}
9084
9185static READ8_DEVICE_HANDLER( rockrage_VLM5030_busy_r )
9286{
93   return ( vlm5030_bsy(device) ? 1 : 0 );
87   return (vlm5030_bsy(device) ? 1 : 0);
9488}
9589
9690static WRITE8_DEVICE_HANDLER( rockrage_speech_w )
9791{
9892   /* bit2 = data bus enable */
99   vlm5030_rst( device, ( data >> 1 ) & 0x01 );
100   vlm5030_st( device, ( data >> 0 ) & 0x01 );
93   vlm5030_rst(device, (data >> 1) & 0x01);
94   vlm5030_st(device, (data >> 0) & 0x01);
10195}
10296
10397static ADDRESS_MAP_START( rockrage_map, ADDRESS_SPACE_PROGRAM, 8 )
104   AM_RANGE(0x0000, 0x1fff) AM_READWRITE(K007342_r,K007342_w)               /* Color RAM + Video RAM */
105   AM_RANGE(0x2000, 0x21ff) AM_READWRITE(K007420_r,K007420_w)               /* Sprite RAM */
106   AM_RANGE(0x2200, 0x23ff) AM_READWRITE(K007342_scroll_r,K007342_scroll_w)   /* Scroll RAM */
107   AM_RANGE(0x2400, 0x247f) AM_RAM AM_BASE_GENERIC(paletteram)                  /* Palette */
108   AM_RANGE(0x2600, 0x2607) AM_WRITE(K007342_vreg_w)                     /* Video Registers */
98   AM_RANGE(0x0000, 0x1fff) AM_DEVREADWRITE("k007342", k007342_r, k007342_w)               /* Color RAM + Video RAM */
99   AM_RANGE(0x2000, 0x21ff) AM_DEVREADWRITE("k007420", k007420_r, k007420_w)               /* Sprite RAM */
100   AM_RANGE(0x2200, 0x23ff) AM_DEVREADWRITE("k007342", k007342_scroll_r, k007342_scroll_w)   /* Scroll RAM */
101   AM_RANGE(0x2400, 0x247f) AM_RAM AM_BASE_MEMBER(rockrage_state, paletteram)                  /* Palette */
102   AM_RANGE(0x2600, 0x2607) AM_DEVWRITE("k007342", k007342_vreg_w)                     /* Video Registers */
109103   AM_RANGE(0x2e00, 0x2e00) AM_READ_PORT("SYSTEM")
110104   AM_RANGE(0x2e01, 0x2e01) AM_READ_PORT("P1")
111105   AM_RANGE(0x2e02, 0x2e02) AM_READ_PORT("P2")
r6740r6741
266260
267261***************************************************************************/
268262
263static const k007342_interface rockrage_k007342_intf =
264{
265   0,   rockrage_tile_callback
266};
267
268static const k007420_interface rockrage_k007420_intf =
269{
270   0x3ff, rockrage_sprite_callback
271};
272
273
274static MACHINE_START( rockrage )
275{
276   rockrage_state *state = (rockrage_state *)machine->driver_data;
277   UINT8 *ROM = memory_region(machine, "maincpu");
278
279   memory_configure_bank(machine, "bank1", 0, 8, &ROM[0x10000], 0x2000);
280
281   state->audiocpu = devtag_get_device(machine, "audiocpu");
282   state->k007342 = devtag_get_device(machine, "k007342");
283   state->k007420 = devtag_get_device(machine, "k007420");
284
285   state_save_register_global(machine, state->vreg);
286   state_save_register_global_array(machine, state->layer_colorbase);
287}
288
289static MACHINE_RESET( rockrage )
290{
291   rockrage_state *state = (rockrage_state *)machine->driver_data;
292
293   state->vreg = 0;
294   state->layer_colorbase[0] = 0x00;
295   state->layer_colorbase[1] = 0x10;
296}
297
269298static MACHINE_DRIVER_START( rockrage )
270299
300   /* driver data */
301   MDRV_DRIVER_DATA(rockrage_state)
302
271303   /* basic machine hardware */
272304   MDRV_CPU_ADD("maincpu", HD6309, 3000000*4)      /* 24MHz/8 */
273305   MDRV_CPU_PROGRAM_MAP(rockrage_map)
r6740r6741
276308   MDRV_CPU_ADD("audiocpu", M6809, 1500000)      /* 24MHz/16 */
277309   MDRV_CPU_PROGRAM_MAP(rockrage_sound_map)
278310
311   MDRV_MACHINE_START(rockrage)
312   MDRV_MACHINE_RESET(rockrage)
313
279314   /* video hardware */
280315   MDRV_SCREEN_ADD("screen", RASTER)
281316   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
284319   MDRV_SCREEN_SIZE(32*8, 32*8)
285320   MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
286321
322   MDRV_K007342_ADD("k007342", rockrage_k007342_intf)
323   MDRV_K007420_ADD("k007420", rockrage_k007420_intf)
324
287325   MDRV_GFXDECODE(rockrage)
288326   MDRV_PALETTE_LENGTH(64 + 2*16*16)
289327
290328   MDRV_PALETTE_INIT(rockrage)
291   MDRV_VIDEO_START(rockrage)
292329   MDRV_VIDEO_UPDATE(rockrage)
293330
294331   /* sound hardware */
r6740r6741
394431
395432***************************************************************************/
396433
397GAME( 1986, rockrage, 0,        rockrage, rockrage, 0, ROT0, "Konami", "Rock'n Rage (World)", 0 )
398GAME( 1986, rockragea,rockrage, rockrage, rockrage, 0, ROT0, "Konami", "Rock'n Rage (Prototype?)", 0 )
399GAME( 1986, rockragej,rockrage, rockrage, rockrage, 0, ROT0, "Konami", "Koi no Hotrock (Japan)", 0 )
434GAME( 1986, rockrage, 0,        rockrage, rockrage, 0, ROT0, "Konami", "Rock'n Rage (World)", GAME_SUPPORTS_SAVE )
435GAME( 1986, rockragea,rockrage, rockrage, rockrage, 0, ROT0, "Konami", "Rock'n Rage (Prototype?)", GAME_SUPPORTS_SAVE )
436GAME( 1986, rockragej,rockrage, rockrage, rockrage, 0, ROT0, "Konami", "Koi no Hotrock (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/midxunit.c
r6740r6741
8383#include "cpu/tms34010/tms34010.h"
8484#include "cpu/adsp2100/adsp2100.h"
8585#include "audio/dcs.h"
86#include "midwunit.h"
86#include "includes/midwunit.h"
8787
8888
8989#define PIXEL_CLOCK      (8000000)
src/mame/drivers/segac2.c
r6740r6741
13701370   MDRV_MACHINE_RESET(segac2)
13711371   MDRV_NVRAM_HANDLER(generic_randfill)
13721372
1373   MDRV_IMPORT_FROM(megadriv_timers)
1374
13731375   /* video hardware */
13741376   //MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS)
13751377
src/mame/drivers/tubep.c
r6740r6741
105105#include "sound/ay8910.h"
106106#include "sound/msm5205.h"
107107
108#include "tubep.h"
108#include "includes/tubep.h"
109109
110110/* Global variables */
111111static UINT8 sound_latch;
src/mame/drivers/homedata.c
r6740r6741
219219#include "cpu/z80/z80.h"
220220#include "cpu/m6809/m6809.h"
221221#include "cpu/upd7810/upd7810.h"
222#include "homedata.h"
222#include "includes/homedata.h"
223223#include "sound/dac.h"
224224#include "sound/2203intf.h"
225225#include "sound/sn76496.h"
src/mame/drivers/exidy.c
r6740r6741
128128#include "driver.h"
129129#include "cpu/m6502/m6502.h"
130130#include "deprecat.h"
131#include "exidy.h"
132#include "targ.h"
131#include "includes/exidy.h"
132#include "includes/targ.h"
133133#include "machine/6821pia.h"
134134
135135
src/mame/drivers/jokrwild.c
r6740r6741
100100*     Video Hardware     *
101101*************************/
102102
103static UINT8 *videoram;
104static UINT8 *colorram;
103105static tilemap *bg_tilemap;
104106
105107
106108static WRITE8_HANDLER( jokrwild_videoram_w )
107109{
108   space->machine->generic.videoram.u8[offset] = data;
110   videoram[offset] = data;
109111   tilemap_mark_tile_dirty(bg_tilemap, offset);
110112}
111113
112114
113115static WRITE8_HANDLER( jokrwild_colorram_w )
114116{
115   space->machine->generic.colorram.u8[offset] = data;
117   colorram[offset] = data;
116118   tilemap_mark_tile_dirty(bg_tilemap, offset);
117119}
118120
r6740r6741
124126    xx-- ----   bank select.
125127    ---- xxxx   color code.
126128*/
127     int attr = machine->generic.colorram.u8[tile_index];
128   int code = machine->generic.videoram.u8[tile_index] | ((attr & 0xc0) << 2);
129     int attr = colorram[tile_index];
130   int code = videoram[tile_index] | ((attr & 0xc0) << 2);
129131   int color = (attr & 0x0f);
130132
131133   SET_TILE_INFO( 0, code , color , 0);
r6740r6741
176178*************************/
177179
178180static ADDRESS_MAP_START( jokrwild_map, ADDRESS_SPACE_PROGRAM, 8 )
179   AM_RANGE(0x0000, 0x03ff) AM_RAM_WRITE(jokrwild_videoram_w) AM_BASE_GENERIC(videoram)
181   AM_RANGE(0x0000, 0x03ff) AM_RAM_WRITE(jokrwild_videoram_w) AM_BASE(&videoram)
180182   AM_RANGE(0x0400, 0x07ff) AM_RAM //FIXME: backup RAM
181   AM_RANGE(0x2000, 0x23ff) AM_RAM_WRITE(jokrwild_colorram_w) AM_BASE_GENERIC(colorram)
183   AM_RANGE(0x2000, 0x23ff) AM_RAM_WRITE(jokrwild_colorram_w) AM_BASE(&colorram)
182184   AM_RANGE(0x2400, 0x27ff) AM_RAM //stack RAM
183185    AM_RANGE(0x4004, 0x4007) AM_DEVREADWRITE("pia0", pia6821_r, pia6821_w)
184186   AM_RANGE(0x4008, 0x400b) AM_DEVREADWRITE("pia1", pia6821_r, pia6821_w) //optical sensor is here
src/mame/drivers/hng64.c
r6740r6741
452452#include "cpu/nec/nec.h"
453453#include "deprecat.h"
454454#include "cpu/mips/mips3.h"
455#include "hng64.h"
455#include "includes/hng64.h"
456456
457457int hng64_mcu_type = 0;
458458static UINT32 fake_mcu_time;
r6740r6741
472472extern UINT32 *hng64_tcram;
473473extern UINT32 *hng64_3dregs;
474474
475extern UINT32 hng64_dls[2][0x81];
475extern void hng64_command3d(running_machine* machine, const UINT16* packet);
476476
477477extern UINT8 hng64_screen_dis;
478478
r6740r6741
621621/* preliminary dma code, dma is used to copy program code -> ram */
622622static INT32 hng_dma_start,hng_dma_dst,hng_dma_len;
623623
624static void hng64_do_dma (const address_space *space)
624static void hng64_do_dma(const address_space *space)
625625{
626   printf("Performing DMA Start %08x Len %08x Dst %08x\n",hng_dma_start, hng_dma_len, hng_dma_dst);
626   //printf("Performing DMA Start %08x Len %08x Dst %08x\n",hng_dma_start, hng_dma_len, hng_dma_dst);
627627
628628   while (hng_dma_len>=0)
629629   {
r6740r6741
659659
660660   switch(offset*4)
661661   {
662      //case 0x100c: Extremely likely to be involved with the ROZ groundplane.
663      //             Probably tells the groundplane which scanline to start drawing at.
664
662665      case 0x1084: //MIPS->MCU latch port
663666         hng_mcu_en = (data & 0xff); //command-based, i.e. doesn't control halt line and such?
664667         //printf("HNG64 writing to SYSTEM Registers 0x%08x == 0x%08x. (PC=%08x)\n", offset*4, hng64_sysregs[offset], cpu_get_pc(space->cpu));
r6740r6741
869872
870873
871874
872// The 3d 'display list'
873// is it a fifo?
875// The 3d 'display list' - is it a fifo?
874876// sams64 / sams64_2 access it in a very different way to fatal fury...
875877static WRITE32_HANDLER( dl_w )
876878{
877   COMBINE_DATA (&hng64_dl[offset]);
879   int i;
880   UINT16 packet3d[16];
881
882   COMBINE_DATA(&hng64_dl[offset]);
883
884   if (offset == 0x08 || offset == 0x7f ||   // Special buggers.
885      offset == 0x10 || offset == 0x18 ||
886      offset == 0x20 || offset == 0x28 ||
887      offset == 0x30 || offset == 0x38 ||
888      offset == 0x40 || offset == 0x48 ||
889      offset == 0x50 || offset == 0x58 ||
890      offset == 0x60 || offset == 0x68 ||
891      offset == 0x70 || offset == 0x78)
892   {
893      // Create a 3d packet
894      UINT16 packetStart = offset - 0x08;
895      if (offset == 0x7f) packetStart += 1;
896
897      for (i = 0; i < 0x08; i++)
898      {
899         packet3d[i*2+0] = (hng64_dl[packetStart+i] & 0xffff0000) >> 16;
900         packet3d[i*2+1] = (hng64_dl[packetStart+i] & 0x0000ffff);
901      }
902
903      // Send it off to the 3d subsystem.
904      hng64_command3d(space->machine, packet3d);
905   }
878906}
879907
880908#if 0
881909static READ32_HANDLER( dl_r )
882910{
883
884
885911//  mame_printf_debug("dl R (%08x) : %x %x\n", cpu_get_pc(space->cpu), offset, hng64_dl[offset]);
886912//  usrintf_showmessage("dl R (%08x) : %x %x", cpu_get_pc(space->cpu), offset, hng64_dl[offset]);
887913   return hng64_dl[offset];
r6740r6741
894920// Some kind of buffering of the display lists, or 'render current buffer' write?
895921static WRITE32_HANDLER( dl_control_w )
896922{
897   if (activeBuffer==0 || activeBuffer==1)
898      memcpy(&hng64_dls[activeBuffer][0],&hng64_dl[0],0x200);
923   //printf("\n");   // Debug - ajg
924   // TODO: put this back in.
925   /*
926    if (activeBuffer==0 || activeBuffer==1)
927        memcpy(&hng64_dls[activeBuffer][0],&hng64_dl[0],0x200);
899928
900   // Only if it's VALID (hack)
901   if (data & 1)
902      activeBuffer = 0;
903   if (data & 2)
904      activeBuffer = 1;
929    // Only if it's VALID (hack)
930    if (data & 1)
931        activeBuffer = 0;
932    if (data & 2)
933        activeBuffer = 1;
934    */
905935}
906936
907937#ifdef UNUSED_FUNCTION
r6740r6741
10701100   AM_RANGE(0x2000d800, 0x2000e3ff) AM_WRITE(hng64_sprite_clear_even_w)
10711101   AM_RANGE(0x2000e400, 0x2000efff) AM_WRITE(hng64_sprite_clear_odd_w)
10721102   AM_RANGE(0x20010000, 0x20010013) AM_RAM AM_BASE(&hng64_spriteregs)
1073   AM_RANGE(0x20100000, 0x2017ffff) AM_RAM_WRITE(hng64_videoram_w) AM_BASE(&hng64_videoram)// Tilemap
1103   AM_RANGE(0x20100000, 0x2017ffff) AM_RAM_WRITE(hng64_videoram_w) AM_BASE(&hng64_videoram)   // Tilemap
10741104   AM_RANGE(0x20190000, 0x20190037) AM_RAM AM_BASE(&hng64_videoregs)
10751105   AM_RANGE(0x20200000, 0x20203fff) AM_RAM_WRITE(hng64_pal_w) AM_BASE_GENERIC(paletteram)
10761106   AM_RANGE(0x20208000, 0x2020805f) AM_READWRITE(tcram_r, tcram_w) AM_BASE(&hng64_tcram)   // Transition Control
1077   AM_RANGE(0x20300000, 0x203001ff) AM_RAM_WRITE(dl_w) AM_BASE(&hng64_dl)      // 3d Display List
1107   AM_RANGE(0x20300000, 0x203001ff) AM_RAM_WRITE(dl_w) AM_BASE(&hng64_dl)   // 3d Display List
1108//  AM_RANGE(0x20300200, 0x20300213) AM_RAM_WRITE(xxxx) AM_BASE(&xxxxxxxx)  // 3d Display List Upload?
10781109   AM_RANGE(0x20300214, 0x20300217) AM_WRITE(dl_control_w)
10791110   AM_RANGE(0x20300218, 0x2030021b) AM_READ(unk_vreg_r)
10801111
r6740r6741
16981729//  hng64_patch_bios_region(machine, 4); // 'Others'
16991730#endif
17001731
1732   /* 1 meg of virtual address space for the com cpu */
1733   hng64_com_virtual_mem = auto_alloc_array(machine, UINT8, 0x100000);
1734   hng64_com_op_base     = auto_alloc_array(machine, UINT8, 0x10000);
1735
17011736   hng64_soundram=auto_alloc_array(machine, UINT16, 0x200000/2);
17021737   DRIVER_INIT_CALL(hng64_reorder_gfx);
17031738}
r6740r6741
17101745
17111746static DRIVER_INIT( fatfurwa )
17121747{
1748   /* FILE* fp = fopen("/tmp/test.bin", "wb"); fwrite(memory_region(machine, "verts"), 1, 0x0c00000*2, fp); fclose(fp); */
17131749   DRIVER_INIT_CALL(hng64_fght);
17141750   hng64_mcu_type = FIGHT_MCU;
17151751}
r6740r6741
18031839   /* Comm CPU */
18041840   KL5C80_init();
18051841
1806   /* 1 meg of virtual address space for the com cpu */
1807   hng64_com_virtual_mem = auto_alloc_array(machine, UINT8, 0x100000);
1808   hng64_com_op_base     = auto_alloc_array(machine, UINT8, 0x10000);
1809
18101842   /* Fill up virtual memory with ROM */
18111843   for (i = 0x0; i < 0x100000; i++)
18121844      hng64_com_virtual_mem[i] = rom[i];
r6740r6741
18611893
18621894
18631895ROM_START( hng64 )
1896   /* BIOS */
18641897   ROM_REGION32_BE( 0x0100000, "user1", 0 ) /* 512k for R4300 BIOS code */
18651898   ROM_LOAD ( "brom1.bin", 0x000000, 0x080000,  CRC(a30dd3de) SHA1(3e2fd0a56214e6f5dcb93687e409af13d065ea30) )
18661899   ROM_REGION( 0x0100000, "user2", 0 ) /* KL5C80 BIOS and unknown ROM */
r6740r6741
18761909   ROM_REGION( 0x1000000, "samples", ROMREGION_ERASEFF ) /* Sound Samples? */
18771910ROM_END
18781911
1912
18791913/* roads edge might need a different bios (driving board bios?) */
18801914ROM_START( roadedge )
1881
18821915   /* BIOS */
18831916   ROM_REGION32_BE( 0x0100000, "user1", 0 ) /* 512k for R4300 BIOS code */
18841917   ROM_LOAD ( "brom1.bin", 0x000000, 0x080000,  CRC(a30dd3de) SHA1(3e2fd0a56214e6f5dcb93687e409af13d065ea30) )
r6740r6741
19371970ROM_END
19381971
19391972
1940
19411973ROM_START( sams64 )
19421974   /* BIOS */
19431975   ROM_REGION32_BE( 0x0100000, "user1", 0 ) /* 512k for R4300 BIOS code */
r6740r6741
19832015   ROM_LOAD( "002-tx03a.15", 0x0800000, 0x400000, CRC(68c313f7) SHA1(90ce8d0d19a994647c7167e3b256ff31647e575a) )
19842016   ROM_LOAD( "002-tx04a.16", 0x0c00000, 0x400000, CRC(f7dac24f) SHA1(1215354f28cbeb9fc38f6a7acae450ad5f34bb6a) )
19852017
1986
19872018   /* X,Y,Z Vertex ROMs */
19882019   ROM_REGION( 0x1800000, "verts", 0 )
19892020   ROMX_LOAD( "002-vt01a.17", 0x0000000, 0x400000, CRC(403fd7fd) SHA1(9bdadbeb4cd13c4c4e89a1c233af9eaaa46f8fdf), ROM_GROUPWORD | ROM_SKIP(4) )
r6740r6741
21812212
21822213
21832214ROM_START( fatfurwa )
2184
21852215   /* BIOS */
21862216   ROM_REGION32_BE( 0x0100000, "user1", 0 ) /* 512k for R4300 BIOS code */
21872217   ROM_LOAD ( "brom1.bin", 0x000000, 0x080000,  CRC(a30dd3de) SHA1(3e2fd0a56214e6f5dcb93687e409af13d065ea30) )
r6740r6741
22392269   ROM_LOAD( "006tx04a.16",0x0c00000, 0x400000, CRC(82d61652) SHA1(28303ae9e2545a4cb0b5843f9e73407754f41e9e) )
22402270
22412271   /* X,Y,Z Vertex ROMs */
2242   ROM_REGION16_BE( 0x0c00000, "verts", 0 )
2272   ROM_REGION( 0x0c00000, "verts", 0 )
22432273   ROMX_LOAD( "006vt01a.17", 0x0000000, 0x400000, CRC(5c20ed4c) SHA1(df679f518292d70b9f23d2bddabf975d56b96910), ROM_GROUPWORD | ROM_SKIP(4) )
22442274   ROMX_LOAD( "006vt02a.18", 0x0000002, 0x400000, CRC(150eb717) SHA1(9acb067346eb386256047c0f1d24dc8fcc2118ca), ROM_GROUPWORD | ROM_SKIP(4) )
22452275   ROMX_LOAD( "006vt03a.19", 0x0000004, 0x400000, CRC(021cfcaf) SHA1(fb8b5f50d3490b31f0a4c3e6d3ae1b98bae41c97), ROM_GROUPWORD | ROM_SKIP(4) )
r6740r6741
23112341   ROM_LOAD( "007tx04a.16",0x0c00000, 0x400000, CRC(02aa3f46) SHA1(1fca89c70586f8ebcdf669ecac121afa5cdf623f) )
23122342
23132343   /* X,Y,Z Vertex ROMs */
2314   ROM_REGION16_BE( 0x0c00000, "verts", 0 )
2344   ROM_REGION( 0x0c00000, "verts", 0 )
23152345   ROMX_LOAD( "007vt01a.17", 0x0000000, 0x400000, CRC(f78a0376) SHA1(fde4ddd4bf326ae5f1ed10311c237b13b62e060c), ROM_GROUPWORD | ROM_SKIP(4) )
23162346   ROMX_LOAD( "007vt02a.18", 0x0000002, 0x400000, CRC(f365f608) SHA1(035fd9b829b7720c4aee6fdf204c080e6157994f), ROM_GROUPWORD | ROM_SKIP(4) )
23172347   ROMX_LOAD( "007vt03a.19", 0x0000004, 0x400000, CRC(ba05654d) SHA1(b7fe532732c0af7860c8eded3c5abd304d74e08e), ROM_GROUPWORD | ROM_SKIP(4) )
src/mame/drivers/solomon.c
r6740r6741
1010#include "cpu/z80/z80.h"
1111#include "sound/ay8910.h"
1212
13extern UINT8 *solomon_videoram;
14extern UINT8 *solomon_colorram;
1315extern UINT8 *solomon_videoram2;
1416extern UINT8 *solomon_colorram2;
1517
r6740r6741
5355static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
5456   AM_RANGE(0x0000, 0xbfff) AM_ROM
5557   AM_RANGE(0xc000, 0xcfff) AM_RAM
56   AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(solomon_colorram_w) AM_BASE_GENERIC(colorram)
57   AM_RANGE(0xd400, 0xd7ff) AM_RAM_WRITE(solomon_videoram_w) AM_BASE_GENERIC(videoram)
58   AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(solomon_colorram_w) AM_BASE(&solomon_colorram)
59   AM_RANGE(0xd400, 0xd7ff) AM_RAM_WRITE(solomon_videoram_w) AM_BASE(&solomon_videoram)
5860   AM_RANGE(0xd800, 0xdbff) AM_RAM_WRITE(solomon_colorram2_w) AM_BASE(&solomon_colorram2)
5961   AM_RANGE(0xdc00, 0xdfff) AM_RAM_WRITE(solomon_videoram2_w) AM_BASE(&solomon_videoram2)
6062   AM_RANGE(0xe000, 0xe07f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
src/mame/drivers/fastlane.c
r6740r6741
11/***************************************************************************
22
3Fast Lane(GX752) (c) 1987 Konami
3    Fast Lane (GX752) (c) 1987 Konami
44
5Driver by Manuel Abadia <manu@teleline.es>
5    Driver by Manuel Abadia <manu@teleline.es>
66
7TODO:
8- colors don't seem 100% accurate.
9- verify that sound is correct (volume and bank switching)
7    TODO:
8        - colors don't seem 100% accurate.
9        - verify that sound is correct (volume and bank switching)
1010
1111***************************************************************************/
1212
1313#include "driver.h"
1414#include "deprecat.h"
1515#include "cpu/hd6309/hd6309.h"
16#include "video/konamiic.h"
1716#include "sound/k007232.h"
18#include "konamipt.h"
17#include "video/konicdev.h"
18#include "includes/konamipt.h"
19#include "includes/fastlane.h"
1920
20/* from video/fastlane.c */
21extern UINT8 *fastlane_k007121_regs,*fastlane_videoram1,*fastlane_videoram2;
22WRITE8_HANDLER( fastlane_vram1_w );
23WRITE8_HANDLER( fastlane_vram2_w );
24PALETTE_INIT( fastlane );
25VIDEO_START( fastlane );
26VIDEO_UPDATE( fastlane );
27
2821static INTERRUPT_GEN( fastlane_interrupt )
2922{
23   fastlane_state *state = (fastlane_state *)device->machine->driver_data;
24
3025   if (cpu_getiloops(device) == 0)
3126   {
32      if (K007121_ctrlram[0][0x07] & 0x02)
27      if (k007121_ctrlram_r(state->k007121, 7) & 0x02)
3328         cpu_set_input_line(device, HD6309_IRQ_LINE, HOLD_LINE);
3429   }
3530   else if (cpu_getiloops(device) % 2)
3631   {
37      if (K007121_ctrlram[0][0x07] & 0x01)
32      if (k007121_ctrlram_r(state->k007121, 7) & 0x01)
3833         cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
3934   }
4035}
4136
4237static WRITE8_HANDLER( k007121_registers_w )
4338{
39   fastlane_state *state = (fastlane_state *)space->machine->driver_data;
40
4441   if (offset < 8)
45      K007121_ctrl_0_w(space,offset,data);
42      k007121_ctrl_w(state->k007121, offset, data);
4643   else   /* scroll registers */
47      fastlane_k007121_regs[offset] = data;
44      state->k007121_regs[offset] = data;
4845}
4946
5047static WRITE8_HANDLER( fastlane_bankswitch_w )
5148{
52   int bankaddress;
53   UINT8 *RAM = memory_region(space->machine, "maincpu");
49   fastlane_state *state = (fastlane_state *)space->machine->driver_data;
5450
5551   /* bits 0 & 1 coin counters */
5652   coin_counter_w(space->machine, 0,data & 0x01);
5753   coin_counter_w(space->machine, 1,data & 0x02);
5854
5955   /* bits 2 & 3 = bank number */
60   bankaddress = 0x10000 + ((data & 0x0c) >> 2) * 0x4000;
61   memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]);
56   memory_set_bank(space->machine, "bank1", (data & 0x0c) >> 2);
6257
6358   /* bit 4: bank # for the 007232 (chip 2) */
64   k007232_set_bank(devtag_get_device(space->machine, "konami2"),0 + ((data & 0x10) >> 4),2 + ((data & 0x10) >> 4));
59   k007232_set_bank(state->konami2, 0 + ((data & 0x10) >> 4), 2 + ((data & 0x10) >> 4));
6560
6661   /* other bits seems to be unused */
6762}
r6740r6741
7368{
7469   return k007232_r(device, offset ^ 1);
7570}
71
7672static WRITE8_DEVICE_HANDLER( fastlane_k007232_w )
7773{
7874   k007232_w(device, offset ^ 1, data);
7975}
8076
8177
82
8378static ADDRESS_MAP_START( fastlane_map, ADDRESS_SPACE_PROGRAM, 8 )
84   AM_RANGE(0x0000, 0x005f) AM_RAM_WRITE(k007121_registers_w) AM_BASE(&fastlane_k007121_regs)   /* 007121 registers */
79   AM_RANGE(0x0000, 0x005f) AM_RAM_WRITE(k007121_registers_w) AM_BASE_MEMBER(fastlane_state, k007121_regs)   /* 007121 registers */
8580   AM_RANGE(0x0800, 0x0800) AM_READ_PORT("DSW3")
8681   AM_RANGE(0x0801, 0x0801) AM_READ_PORT("P2")
8782   AM_RANGE(0x0802, 0x0802) AM_READ_PORT("P1")
r6740r6741
9287   AM_RANGE(0x0c00, 0x0c00) AM_WRITE(fastlane_bankswitch_w)                           /* bankswitch control */
9388   AM_RANGE(0x0d00, 0x0d0d) AM_DEVREADWRITE("konami1", fastlane_k007232_r, fastlane_k007232_w)   /* 007232 registers (chip 1) */
9489   AM_RANGE(0x0e00, 0x0e0d) AM_DEVREADWRITE("konami2", fastlane_k007232_r, fastlane_k007232_w)   /* 007232 registers (chip 2) */
95   AM_RANGE(0x0f00, 0x0f1f) AM_READWRITE(K051733_r, K051733_w)                           /* 051733 (protection) */
96   AM_RANGE(0x1000, 0x17ff) AM_RAM AM_BASE_GENERIC(paletteram)                              /* Palette RAM */
90   AM_RANGE(0x0f00, 0x0f1f) AM_DEVREADWRITE("k051733", k051733_r, k051733_w)                           /* 051733 (protection) */
91   AM_RANGE(0x1000, 0x17ff) AM_RAM AM_BASE_MEMBER(fastlane_state, paletteram)                              /* Palette RAM */
9792   AM_RANGE(0x1800, 0x1fff) AM_RAM                                                /* Work RAM */
98   AM_RANGE(0x2000, 0x27ff) AM_RAM_WRITE(fastlane_vram1_w) AM_BASE(&fastlane_videoram1)       /* Video RAM (chip 1) */
99   AM_RANGE(0x2800, 0x2fff) AM_RAM_WRITE(fastlane_vram2_w) AM_BASE(&fastlane_videoram2)       /* Video RAM (chip 2) */
100   AM_RANGE(0x3000, 0x3fff) AM_RAM AM_BASE_GENERIC(spriteram)                                 /* Sprite RAM */
93   AM_RANGE(0x2000, 0x27ff) AM_RAM_WRITE(fastlane_vram1_w) AM_BASE_MEMBER(fastlane_state, videoram1)       /* Video RAM (chip 1) */
94   AM_RANGE(0x2800, 0x2fff) AM_RAM_WRITE(fastlane_vram2_w) AM_BASE_MEMBER(fastlane_state, videoram2)       /* Video RAM (chip 2) */
95   AM_RANGE(0x3000, 0x3fff) AM_RAM AM_BASE_MEMBER(fastlane_state, spriteram)                                 /* Sprite RAM */
10196   AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1")                                          /* banked ROM */
10297   AM_RANGE(0x8000, 0xffff) AM_ROM                                                /* ROM */
10398ADDRESS_MAP_END
r6740r6741
183178
184179static void volume_callback0(const device_config *device, int v)
185180{
186   k007232_set_volume(device,0,(v >> 4) * 0x11,0);
187   k007232_set_volume(device,1,0,(v & 0x0f) * 0x11);
181   k007232_set_volume(device, 0, (v >> 4) * 0x11, 0);
182   k007232_set_volume(device, 1, 0, (v & 0x0f) * 0x11);
188183}
189184
190185static void volume_callback1(const device_config *device, int v)
191186{
192   k007232_set_volume(device,0,(v >> 4) * 0x11,0);
193   k007232_set_volume(device,1,0,(v & 0x0f) * 0x11);
187   k007232_set_volume(device, 0, (v >> 4) * 0x11, 0);
188   k007232_set_volume(device, 1, 0, (v & 0x0f) * 0x11);
194189}
195190
196191static const k007232_interface k007232_interface_1 =
r6740r6741
203198   volume_callback1
204199};
205200
201static MACHINE_START( fastlane )
202{
203   fastlane_state *state = (fastlane_state *)machine->driver_data;
204   UINT8 *ROM = memory_region(machine, "maincpu");
205
206   memory_configure_bank(machine, "bank1", 0, 4, &ROM[0x10000], 0x4000);
207
208   state->konami2 = devtag_get_device(machine, "konami2");
209   state->k007121 = devtag_get_device(machine, "k007121");
210}
211
206212static MACHINE_DRIVER_START( fastlane )
207213
214   /* driver data */
215   MDRV_DRIVER_DATA(fastlane_state)
216
208217   /* basic machine hardware */
209218   MDRV_CPU_ADD("maincpu", HD6309, 3000000*4)      /* 24MHz/8? */
210219   MDRV_CPU_PROGRAM_MAP(fastlane_map)
211220   MDRV_CPU_VBLANK_INT_HACK(fastlane_interrupt,16)   /* 1 IRQ + ??? NMI (generated by the 007121) */
212221
222   MDRV_MACHINE_START(fastlane)
223
213224   /* video hardware */
214225   MDRV_SCREEN_ADD("screen", RASTER)
215226   MDRV_SCREEN_REFRESH_RATE(60)
r6740r6741
225236   MDRV_VIDEO_START(fastlane)
226237   MDRV_VIDEO_UPDATE(fastlane)
227238
239   MDRV_K007121_ADD("k007121")
240   MDRV_K051733_ADD("k051733")
241
228242   /* sound hardware */
229243   MDRV_SPEAKER_STANDARD_MONO("mono")
230244
r6740r6741
265279ROM_END
266280
267281
268GAME( 1987, fastlane, 0, fastlane, fastlane, 0, ROT90, "Konami", "Fast Lane", GAME_IMPERFECT_COLORS )
282GAME( 1987, fastlane, 0, fastlane, fastlane, 0, ROT90, "Konami", "Fast Lane", GAME_IMPERFECT_COLORS | GAME_SUPPORTS_SAVE )
src/mame/drivers/cidelsa.c
r6740r6741
44#include "sound/cdp1869.h"
55#include "sound/ay8910.h"
66#include "machine/cdp1852.h"
7#include "cidelsa.h"
7#include "includes/cidelsa.h"
88
99/* CDP1802 Interface */
1010
src/mame/drivers/vendetta.c
r6740r6741
8888
8989#include "driver.h"
9090#include "cpu/z80/z80.h"
91#include "video/konamiic.h"
91#include "video/konicdev.h"
9292#include "cpu/konami/konami.h" /* for the callback and the firq irq definition */
93#include "machine/eeprom.h"
93#include "machine/eepromdev.h"
9494#include "sound/2151intf.h"
9595#include "sound/k053260.h"
96#include "konamipt.h"
96#include "includes/konamipt.h"
9797
9898/* prototypes */
9999static MACHINE_RESET( vendetta );
100100static KONAMI_SETLINES_CALLBACK( vendetta_banking );
101101static void vendetta_video_banking( running_machine *machine, int select );
102102
103VIDEO_START( vendetta );
104VIDEO_START( esckids );
105103VIDEO_UPDATE( vendetta );
106104
105extern void vendetta_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
106extern void esckids_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
107extern void vendetta_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask);
107108
109
108110/***************************************************************************
109111
110112  EEPROM
111113
112114***************************************************************************/
113115
114static int init_eeprom_count;
115
116
117116static const eeprom_interface eeprom_intf =
118117{
119118   7,            /* address bits */
r6740r6741
125124   "0100110000000" /* unlock command */
126125};
127126
128static NVRAM_HANDLER( vendetta )
129{
130   if (read_or_write)
131      eeprom_save(file);
132   else
133   {
134      eeprom_init(machine, &eeprom_intf);
135127
136      if (file)
137      {
138         init_eeprom_count = 0;
139         eeprom_load(file);
140      }
141      else
142         init_eeprom_count = 1000;
143   }
144}
145
146static READ8_HANDLER( vendetta_eeprom_r )
147{
148   int res = 0;
149
150   res |= 0x02;   //konami_eeprom_ack() << 5;     /* add the ack */
151
152   res |= input_port_read(space->machine, "EEPROM") & 0x0d;   /* test switch */
153
154   if (init_eeprom_count)
155   {
156      init_eeprom_count--;
157      res &= 0xfb;
158   }
159   return res;
160}
161
162128static int irq_enabled;
163129
164130static WRITE8_HANDLER( vendetta_eeprom_w )
r6740r6741
176142      return;
177143
178144   /* EEPROM */
179   eeprom_write_bit(data & 0x20);
180   eeprom_set_clock_line((data & 0x10) ? ASSERT_LINE : CLEAR_LINE);
181   eeprom_set_cs_line((data & 0x08) ? CLEAR_LINE : ASSERT_LINE);
145   input_port_write(space->machine, "EEPROMOUT", data, 0xff);
182146
183147   irq_enabled = ( data >> 6 ) & 1;
184148
r6740r6741
189153
190154static READ8_HANDLER( vendetta_K052109_r )
191155{
192   return K052109_r( space, offset + 0x2000 );
156   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
157   return k052109_r(k052109, offset + 0x2000);
193158}
194//static WRITE8_HANDLER( vendetta_K052109_w ) { K052109_w( machine, offset + 0x2000, data ); }
159
195160static WRITE8_HANDLER( vendetta_K052109_w )
196161{
162   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
163
197164   // *************************************************************************************
198165   // *  Escape Kids uses 052109's mirrored Tilemap ROM bank selector, but only during    *
199166   // *  Tilemap MASK-ROM Test       (0x1d80<->0x3d80, 0x1e00<->0x3e00, 0x1f00<->0x3f00)  *
200167   // *************************************************************************************
201168   if ( ( offset == 0x1d80 ) || ( offset == 0x1e00 ) || ( offset == 0x1f00 ) )
202      K052109_w( space, offset, data );
203   K052109_w( space, offset + 0x2000, data );
169      k052109_w(k052109, offset, data);
170   k052109_w(k052109, offset + 0x2000, data);
204171}
205172
206173static offs_t video_banking_base;
207174
208175static void vendetta_video_banking( running_machine *machine, int select )
209176{
177   const device_config *k052109 = devtag_get_device(machine, "k052109");
178   const device_config *k053246 = devtag_get_device(machine, "k053246");
179   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
180
210181   if ( select & 1 )
211182   {
212      memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), video_banking_base + 0x2000, video_banking_base + 0x2fff, 0, 0, "bank4" );
213      memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), video_banking_base + 0x2000, video_banking_base + 0x2fff, 0, 0, paletteram_xBBBBBGGGGGRRRRR_be_w );
214      memory_install_readwrite8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), video_banking_base + 0x0000, video_banking_base + 0x0fff, 0, 0, K053247_r, K053247_w );
183      memory_install_read_bank(space, video_banking_base + 0x2000, video_banking_base + 0x2fff, 0, 0, "bank4" );
184      memory_install_write8_handler(space, video_banking_base + 0x2000, video_banking_base + 0x2fff, 0, 0, paletteram_xBBBBBGGGGGRRRRR_be_w );
185      memory_install_readwrite8_device_handler(space, k053246, video_banking_base + 0x0000, video_banking_base + 0x0fff, 0, 0, k053247_r, k053247_w );
215186      memory_set_bankptr(machine, "bank4", machine->generic.paletteram.v);
216187   }
217188   else
218189   {
219      memory_install_readwrite8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), video_banking_base + 0x2000, video_banking_base + 0x2fff, 0, 0, vendetta_K052109_r, vendetta_K052109_w );
220      memory_install_readwrite8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), video_banking_base + 0x0000, video_banking_base + 0x0fff, 0, 0, K052109_r, K052109_w );
190      memory_install_readwrite8_handler(space, video_banking_base + 0x2000, video_banking_base + 0x2fff, 0, 0, vendetta_K052109_r, vendetta_K052109_w );
191      memory_install_readwrite8_device_handler(space, k052109, video_banking_base + 0x0000, video_banking_base + 0x0fff, 0, 0, k052109_r, k052109_w );
221192   }
222193}
223194
224195static WRITE8_HANDLER( vendetta_5fe0_w )
225196{
197   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
198   const device_config *k053246 = devtag_get_device(space->machine, "k053246");
199
226200   /* bit 0,1 coin counters */
227   coin_counter_w(space->machine, 0,data & 0x01);
228   coin_counter_w(space->machine, 1,data & 0x02);
201   coin_counter_w(space->machine, 0, data & 0x01);
202   coin_counter_w(space->machine, 1, data & 0x02);
229203
230204   /* bit 2 = BRAMBK ?? */
231205
232206   /* bit 3 = enable char ROM reading through the video RAM */
233   K052109_set_RMRD_line((data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
207   k052109_set_rmrd_line(k052109, (data & 0x08) ? ASSERT_LINE : CLEAR_LINE);
234208
235209   /* bit 4 = INIT ?? */
236210
237211   /* bit 5 = enable sprite ROM reading */
238   K053246_set_OBJCHA_line((data & 0x20) ? ASSERT_LINE : CLEAR_LINE);
212   k053246_set_objcha_line(k053246, (data & 0x20) ? ASSERT_LINE : CLEAR_LINE);
239213}
240214
241215static TIMER_CALLBACK( z80_nmi_callback )
r6740r6741
247221{
248222   cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, CLEAR_LINE );
249223
250   timer_set( space->machine, ATTOTIME_IN_USEC( 25 ), NULL, 0, z80_nmi_callback );
224   timer_set(space->machine, ATTOTIME_IN_USEC(25), NULL, 0, z80_nmi_callback);
251225}
252226
253227static WRITE8_HANDLER( z80_irq_w )
r6740r6741
271245static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
272246   AM_RANGE(0x0000, 0x1fff) AM_ROMBANK("bank1")
273247   AM_RANGE(0x2000, 0x3fff) AM_RAM
274   AM_RANGE(0x5f80, 0x5f9f) AM_READWRITE(K054000_r, K054000_w)
275   AM_RANGE(0x5fa0, 0x5faf) AM_WRITE(K053251_w)
276   AM_RANGE(0x5fb0, 0x5fb7) AM_WRITE(K053246_w)
248   AM_RANGE(0x5f80, 0x5f9f) AM_DEVREADWRITE("k054000", k054000_r, k054000_w)
249   AM_RANGE(0x5fa0, 0x5faf) AM_DEVWRITE("k053251", k053251_w)
250   AM_RANGE(0x5fb0, 0x5fb7) AM_DEVWRITE("k053246", k053246_w)
277251   AM_RANGE(0x5fc0, 0x5fc0) AM_READ_PORT("P1")
278252   AM_RANGE(0x5fc1, 0x5fc1) AM_READ_PORT("P2")
279253   AM_RANGE(0x5fc2, 0x5fc2) AM_READ_PORT("P3")
280254   AM_RANGE(0x5fc3, 0x5fc3) AM_READ_PORT("P4")
281   AM_RANGE(0x5fd0, 0x5fd0) AM_READ(vendetta_eeprom_r) /* vblank, service */
255   AM_RANGE(0x5fd0, 0x5fd0) AM_READ_PORT("EEPROM")
282256   AM_RANGE(0x5fd1, 0x5fd1) AM_READ_PORT("SERVICE")
283257   AM_RANGE(0x5fe0, 0x5fe0) AM_WRITE(vendetta_5fe0_w)
284258   AM_RANGE(0x5fe2, 0x5fe2) AM_WRITE(vendetta_eeprom_w)
285259   AM_RANGE(0x5fe4, 0x5fe4) AM_READWRITE(vendetta_sound_interrupt_r, z80_irq_w)
286260   AM_RANGE(0x5fe6, 0x5fe7) AM_DEVREADWRITE("konami", vendetta_sound_r, k053260_w)
287   AM_RANGE(0x5fe8, 0x5fe9) AM_READ(K053246_r)
261   AM_RANGE(0x5fe8, 0x5fe9) AM_DEVREAD("k053246", k053246_r)
288262   AM_RANGE(0x5fea, 0x5fea) AM_READ(watchdog_reset_r)
289263   /* what is the desired effect of overlapping these memory regions anyway? */
290264   AM_RANGE(0x4000, 0x4fff) AM_RAMBANK("bank3")
291265   AM_RANGE(0x6000, 0x6fff) AM_RAMBANK("bank2")
292   AM_RANGE(0x4000, 0x7fff) AM_READWRITE(K052109_r, K052109_w)
266   AM_RANGE(0x4000, 0x7fff) AM_DEVREADWRITE("k052109", k052109_r, k052109_w)
293267   AM_RANGE(0x8000, 0xffff) AM_ROM
294268ADDRESS_MAP_END
295269
r6740r6741
299273   AM_RANGE(0x3f81, 0x3f81) AM_READ_PORT("P2")
300274   AM_RANGE(0x3f82, 0x3f82) AM_READ_PORT("P3")            // ???  (But not used)
301275   AM_RANGE(0x3f83, 0x3f83) AM_READ_PORT("P4")            // ???  (But not used)
302   AM_RANGE(0x3f92, 0x3f92) AM_READ(vendetta_eeprom_r)      // vblank, TEST SW on PCB
276   AM_RANGE(0x3f92, 0x3f92) AM_READ_PORT("EEPROM")
303277   AM_RANGE(0x3f93, 0x3f93) AM_READ_PORT("SERVICE")
304   AM_RANGE(0x3fa0, 0x3fa7) AM_WRITE(K053246_w)         // 053246 (Sprite)
305   AM_RANGE(0x3fb0, 0x3fbf) AM_WRITE(K053251_w)         // 053251 (Priority Encoder)
278   AM_RANGE(0x3fa0, 0x3fa7) AM_DEVWRITE("k053246", k053246_w)         // 053246 (Sprite)
279   AM_RANGE(0x3fb0, 0x3fbf) AM_DEVWRITE("k053251", k053251_w)         // 053251 (Priority Encoder)
306280   AM_RANGE(0x3fc0, 0x3fcf) AM_WRITENOP            // Not Emulated (053252 ???)
307281   AM_RANGE(0x3fd0, 0x3fd0) AM_WRITE(vendetta_5fe0_w)      // Coin Counter, 052109 RMRD, 053246 OBJCHA
308282   AM_RANGE(0x3fd2, 0x3fd2) AM_WRITE(vendetta_eeprom_w)   // EEPROM, Video banking
309283   AM_RANGE(0x3fd4, 0x3fd4) AM_READWRITE(vendetta_sound_interrupt_r, z80_irq_w)         // Sound
310284   AM_RANGE(0x3fd6, 0x3fd7) AM_DEVREADWRITE("konami", vendetta_sound_r, k053260_w)      // Sound
311   AM_RANGE(0x3fd8, 0x3fd9) AM_READ(K053246_r)            // 053246 (Sprite)
285   AM_RANGE(0x3fd8, 0x3fd9) AM_DEVREAD("k053246", k053246_r)            // 053246 (Sprite)
312286   AM_RANGE(0x3fda, 0x3fda) AM_WRITENOP            // Not Emulated (Watchdog ???)
313287   /* what is the desired effect of overlapping these memory regions anyway? */
314288   AM_RANGE(0x2000, 0x2fff) AM_RAMBANK("bank3")               // 052109 (Tilemap) 0x0000-0x0fff
315289   AM_RANGE(0x4000, 0x4fff) AM_RAMBANK("bank2")               // 052109 (Tilemap) 0x2000-0x3fff, Tilemap MASK-ROM bank selector (MASK-ROM Test)
316   AM_RANGE(0x2000, 0x5fff) AM_READWRITE(K052109_r, K052109_w)         // 052109 (Tilemap)
290   AM_RANGE(0x2000, 0x5fff) AM_DEVREADWRITE("k052109", k052109_r, k052109_w)         // 052109 (Tilemap)
317291   AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank1")               // 053248 '975r01' 1M ROM (Banked)
318292   AM_RANGE(0x8000, 0xffff) AM_ROM                     // 053248 '975r01' 1M ROM (0x18000-0x1ffff)
319293ADDRESS_MAP_END
r6740r6741
358332   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
359333
360334   PORT_START("EEPROM")
361   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
335   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
362336   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* EEPROM ready */
363337   PORT_SERVICE_NO_TOGGLE(0x04, IP_ACTIVE_LOW)
364338   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK ) /* not really vblank, object related. Its timed, otherwise sprites flicker */
365339   PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
340
341   PORT_START( "EEPROMOUT" )
342   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
343   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
344   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
366345INPUT_PORTS_END
367346
368347static INPUT_PORTS_START( vendetta )
r6740r6741
409388   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
410389
411390   PORT_START("EEPROM")
412   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_CUSTOM(eeprom_bit_r, NULL)   /* EEPROM data */
391   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_READ_LINE_DEVICE("eeprom", eepromdev_read_bit)
413392   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )   /* EEPROM ready */
414393   PORT_SERVICE_NO_TOGGLE(0x04, IP_ACTIVE_LOW)
415394   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK ) /* not really vblank, object related. Its timed, otherwise sprites flicker */
416395   PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
396
397   PORT_START( "EEPROMOUT" )
398   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_cs_line)
399   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_set_clock_line)
400   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE("eeprom", eepromdev_write_bit)
417401INPUT_PORTS_END
418402
419403static INPUT_PORTS_START( esckidsj )
r6740r6741
438422      cpu_set_input_line(device, KONAMI_IRQ_LINE, HOLD_LINE);
439423}
440424
425static const k052109_interface vendetta_k052109_intf =
426{
427   "gfx1", 0,
428   NORMAL_PLANE_ORDER,
429   KONAMI_ROM_DEINTERLEAVE_2,
430   vendetta_tile_callback
431};
432
433static const k052109_interface esckids_k052109_intf =
434{
435   "gfx1", 0,
436   NORMAL_PLANE_ORDER,
437   KONAMI_ROM_DEINTERLEAVE_2,
438   esckids_tile_callback
439};
440
441static const k053247_interface vendetta_k053246_intf =
442{
443   "screen",
444   "gfx2", 1,
445   NORMAL_PLANE_ORDER,
446   53, 6,
447   KONAMI_ROM_DEINTERLEAVE_4,
448   vendetta_sprite_callback
449};
450
451static const k053247_interface esckids_k053246_intf =
452{
453   "screen",
454   "gfx2", 1,
455   NORMAL_PLANE_ORDER,
456   101, 6,
457   KONAMI_ROM_DEINTERLEAVE_4,
458   vendetta_sprite_callback
459};
460
441461static MACHINE_DRIVER_START( vendetta )
442462
443463   /* basic machine hardware */
r6740r6741
451471                            /* interrupts are triggered by the main CPU */
452472
453473   MDRV_MACHINE_RESET(vendetta)
454   MDRV_NVRAM_HANDLER(vendetta)
455474
475   MDRV_EEPROM_NODEFAULT_ADD("eeprom", eeprom_intf)
476
456477   /* video hardware */
457478   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS)
458479
r6740r6741
465486
466487   MDRV_PALETTE_LENGTH(2048)
467488
468   MDRV_VIDEO_START(vendetta)
469489   MDRV_VIDEO_UPDATE(vendetta)
470490
491   MDRV_K052109_ADD("k052109", vendetta_k052109_intf)
492   MDRV_K053246_ADD("k053246", vendetta_k053246_intf)
493   MDRV_K053251_ADD("k053251")
494   MDRV_K054000_ADD("k054000")
495
471496   /* sound hardware */
472497   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
473498
r6740r6741
492517//MDRV_SCREEN_VISIBLE_AREA(13*8, (64-13)*8-1, 2*8, 30*8-1 )    /* black areas on the edges */
493518   MDRV_SCREEN_VISIBLE_AREA(14*8, (64-14)*8-1, 2*8, 30*8-1 )
494519
495   MDRV_VIDEO_START(esckids)
496
520   MDRV_DEVICE_REMOVE("k054000")
521   MDRV_DEVICE_REMOVE("k052109")
522   MDRV_K052109_ADD("k052109", esckids_k052109_intf)
523   MDRV_DEVICE_REMOVE("k053246")
524   MDRV_K053246_ADD("k053246", esckids_k053246_intf)
497525MACHINE_DRIVER_END
498526
499527
r6740r6741
716744static DRIVER_INIT( vendetta )
717745{
718746   video_banking_base = 0x4000;
719   konami_rom_deinterleave_2(machine, "gfx1");
720   konami_rom_deinterleave_4(machine, "gfx2");
721747}
722748
723749static DRIVER_INIT( esckids )
724750{
725751   video_banking_base = 0x2000;
726   konami_rom_deinterleave_2(machine, "gfx1");
727   konami_rom_deinterleave_4(machine, "gfx2");
728752}
729753
730754
src/mame/drivers/segas16b.c
r6740r6741
871871#include "cpu/z80/z80.h"
872872#include "cpu/m68000/m68000.h"
873873#include "cpu/mcs51/mcs51.h"
874#include "system16.h"
874#include "includes/system16.h"
875875#include "machine/segaic16.h"
876876#include "machine/fd1089.h"
877877#include "machine/fd1094.h"
r6740r6741
909909static UINT16 *workram;
910910
911911static UINT8 rom_board;
912static int atomicp_sound_rate;
912static UINT8 atomicp_sound_divisor;
913static UINT8 atomicp_sound_count;
913914
914915static UINT8 has_sound_cpu;
915916
r6740r6741
11121113}
11131114
11141115
1115static TIMER_CALLBACK( atomicp_sound_irq )
1116static TIMER_DEVICE_CALLBACK( atomicp_sound_irq )
11161117{
1117   cputag_set_input_line(machine, "maincpu", 2, HOLD_LINE);
1118   if (++atomicp_sound_count >= atomicp_sound_divisor)
1119   {
1120      cputag_set_input_line(timer->machine, "maincpu", 2, HOLD_LINE);
1121      atomicp_sound_count = 0;
1122   }
11181123}
11191124
11201125
1121static MACHINE_RESET( atomicp )
1122{
1123   MACHINE_RESET_CALL(system16b);
1124   timer_pulse(machine, ATTOTIME_IN_HZ(atomicp_sound_rate), NULL, 0, atomicp_sound_irq);
1125}
11261126
1127
1128
11291127/*************************************
11301128 *
11311129 *  I/O space
r6740r6741
15561554 *
15571555 *************************************/
15581556
1557static MACHINE_START( atomicp )
1558{
1559   state_save_register_global(machine, atomicp_sound_count);
1560}
1561
1562
15591563static WRITE16_HANDLER( atomicp_sound_w )
15601564{
15611565   ym2413_w(devtag_get_device(space->machine, "ymsnd"), offset, data >> 8);
r6740r6741
32963300
32973301   /* basic machine hardware */
32983302   MDRV_DEVICE_REMOVE("soundcpu")
3299   MDRV_MACHINE_RESET(atomicp)
33003303
3304   MDRV_MACHINE_START(atomicp)
3305   MDRV_TIMER_ADD_PERIODIC("atomicp_timer", atomicp_sound_irq, HZ(10000))
3306
33013307   /* sound hardware */
33023308   MDRV_SOUND_REPLACE("ymsnd", YM2413, XTAL_20MHz/4) /* 20MHz OSC divided by 4 (verified) */
33033309   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
r6740r6741
63566362   system16b_generic_init(machine, ROM_BOARD_ATOMICP);
63576363   disable_screen_blanking = 1;
63586364   segaic16_display_enable = 1;
6359   atomicp_sound_rate = 10000;
6365   atomicp_sound_divisor = 1;
63606366}
63616367
63626368
r6740r6741
63656371   system16b_generic_init(machine, ROM_BOARD_ATOMICP);
63666372   disable_screen_blanking = 1;
63676373   segaic16_display_enable = 1;
6368   atomicp_sound_rate = 2500;
6374   atomicp_sound_divisor = 4;
63696375}
63706376
63716377
src/mame/drivers/pktgaldx.c
r6740r6741
5454
5555#include "driver.h"
5656#include "cpu/m68000/m68000.h"
57#include "decocrpt.h"
58#include "decoprot.h"
59#include "deco16ic.h"
57#include "includes/decocrpt.h"
58#include "includes/decoprot.h"
59#include "includes/deco16ic.h"
6060#include "sound/okim6295.h"
6161
6262VIDEO_START(pktgaldx);
src/mame/drivers/atarigx2.c
r6740r6741
2323#include "cpu/m68000/m68000.h"
2424#include "audio/atarijsa.h"
2525#include "video/atarirle.h"
26#include "atarigx2.h"
26#include "includes/atarigx2.h"
2727
2828
2929
r6740r6741
4141}
4242
4343
44static MACHINE_START( atarigx2 )
45{
46   atarigen_init(machine);
47}
48
49
4450static MACHINE_RESET( atarigx2 )
4551{
4652   atarigx2_state *state = (atarigx2_state *)machine->driver_data;
r6740r6741
13921398   MDRV_CPU_PROGRAM_MAP(main_map)
13931399   MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen)
13941400
1401   MDRV_MACHINE_START(atarigx2)
13951402   MDRV_MACHINE_RESET(atarigx2)
13961403   MDRV_NVRAM_HANDLER(atarigen)
13971404
src/mame/drivers/nwk-tr.c
r6740r6741
217217#include "cpu/powerpc/ppc.h"
218218#include "cpu/sharc/sharc.h"
219219#include "machine/konppc.h"
220#include "machine/konamiic.h"
221220#include "machine/adc1213x.h"
222221#include "sound/rf5c400.h"
223222#include "video/voodoo.h"
224223#include "machine/timekpr.h"
224#include "sound/k056800.h"
225225
226226static UINT8 led_reg0, led_reg1;
227227
r6740r6741
894894   AM_RANGE(0x7d000000, 0x7d00ffff) AM_READ(sysreg_r)
895895   AM_RANGE(0x7d010000, 0x7d01ffff) AM_WRITE(sysreg_w)
896896   AM_RANGE(0x7d020000, 0x7d021fff) AM_DEVREADWRITE8("m48t58", timekeeper_r, timekeeper_w, 0xffffffff)   /* M48T58Y RTC/NVRAM */
897   AM_RANGE(0x7d030000, 0x7d030007) AM_READ(K056800_host_r)
898   AM_RANGE(0x7d030000, 0x7d030007) AM_WRITE(K056800_host_w)
899   AM_RANGE(0x7d030008, 0x7d03000f) AM_WRITE(K056800_host_w)
897   AM_RANGE(0x7d030000, 0x7d030007) AM_DEVREAD("k056800", k056800_host_r)
898   AM_RANGE(0x7d030000, 0x7d030007) AM_DEVWRITE("k056800", k056800_host_w)
899   AM_RANGE(0x7d030008, 0x7d03000f) AM_DEVWRITE("k056800", k056800_host_w)
900900   AM_RANGE(0x7d040000, 0x7d04ffff) AM_READWRITE(lanc1_r, lanc1_w)
901901   AM_RANGE(0x7d050000, 0x7d05ffff) AM_READWRITE(lanc2_r, lanc2_w)
902902   AM_RANGE(0x7e000000, 0x7e7fffff) AM_ROM AM_REGION("user2", 0)   /* Data ROM */
r6740r6741
910910   AM_RANGE(0x000000, 0x07ffff) AM_ROM
911911   AM_RANGE(0x100000, 0x10ffff) AM_RAM      /* Work RAM */
912912   AM_RANGE(0x200000, 0x200fff) AM_DEVREADWRITE("rfsnd", rf5c400_r, rf5c400_w)      /* Ricoh RF5C400 */
913   AM_RANGE(0x300000, 0x30000f) AM_READWRITE(K056800_sound_r, K056800_sound_w)
913   AM_RANGE(0x300000, 0x30000f) AM_DEVREADWRITE("k056800", k056800_sound_r, k056800_sound_w)
914914   AM_RANGE(0x600000, 0x600001) AM_NOP
915915ADDRESS_MAP_END
916916
r6740r6741
10291029   adc12138_input_callback
10301030};
10311031
1032static void sound_irq_callback(running_machine *machine, int irq)
1033{
1034   if (irq == 0)
1035      generic_pulse_irq_line(cputag_get_cpu(machine, "audiocpu"), INPUT_LINE_IRQ1);
1036   else
1037      generic_pulse_irq_line(cputag_get_cpu(machine, "audiocpu"), INPUT_LINE_IRQ2);
1038}
10321039
1040static const k056800_interface nwktr_k056800_interface =
1041{
1042   sound_irq_callback
1043};
1044
10331045static MACHINE_RESET( nwktr )
10341046{
10351047   cputag_set_input_line(machine, "dsp", INPUT_LINE_RESET, ASSERT_LINE);
r6740r6741
10711083   MDRV_VIDEO_START(nwktr)
10721084   MDRV_VIDEO_UPDATE(nwktr)
10731085
1086   MDRV_K056800_ADD("k056800", nwktr_k056800_interface)
1087
10741088   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
10751089
10761090   MDRV_SOUND_ADD("rfsnd", RF5C400, 16934400)   // as per Guru readme above
r6740r6741
10841098
10851099/*****************************************************************************/
10861100
1087static void sound_irq_callback(running_machine *machine, int irq)
1088{
1089   if (irq == 0)
1090      generic_pulse_irq_line(cputag_get_cpu(machine, "audiocpu"), INPUT_LINE_IRQ1);
1091   else
1092      generic_pulse_irq_line(cputag_get_cpu(machine, "audiocpu"), INPUT_LINE_IRQ2);
1093}
1094
10951101static DRIVER_INIT(nwktr)
10961102{
10971103   init_konami_cgboard(machine, 1, CGBOARD_TYPE_NWKTR);
r6740r6741
11001106   sharc_dataram = auto_alloc_array(machine, UINT32, 0x100000/4);
11011107   led_reg0 = led_reg1 = 0x7f;
11021108
1103   K056800_init(machine, sound_irq_callback);
11041109   K033906_init(machine);
11051110
11061111   lanc2_init(machine);
src/mame/drivers/circus.c
r6740r6741
3737#include "cpu/m6502/m6502.h"
3838#include "deprecat.h"
3939#include "sound/samples.h"
40#include "circus.h"
40#include "includes/circus.h"
4141
4242#include "circus.lh"
4343#include "crash.lh"
src/mame/drivers/relief.c
r6740r6741
2020#include "driver.h"
2121#include "cpu/m68000/m68000.h"
2222#include "machine/atarigen.h"
23#include "relief.h"
23#include "includes/relief.h"
2424#include "sound/okim6295.h"
2525#include "sound/2413intf.h"
2626
r6740r6741
6464 *
6565 *************************************/
6666
67static MACHINE_START( relief )
68{
69   atarigen_init(machine);
70}
71
72
6773static MACHINE_RESET( relief )
6874{
6975   relief_state *state = (relief_state *)machine->driver_data;
r6740r6741
293299   MDRV_CPU_ADD("maincpu", M68000, ATARI_CLOCK_14MHz/2)
294300   MDRV_CPU_PROGRAM_MAP(main_map)
295301
302   MDRV_MACHINE_START(relief)
296303   MDRV_MACHINE_RESET(relief)
297304   MDRV_NVRAM_HANDLER(atarigen)
298305
src/mame/drivers/taito_f3.c
r6740r6741
3838#include "driver.h"
3939#include "cpu/m68000/m68000.h"
4040#include "machine/eepromdev.h"
41#include "taito_f3.h"
41#include "includes/taito_f3.h"
4242#include "sound/es5506.h"
4343#include "audio/taito_en.h"
4444#include "sound/okim6295.h"
r6740r6741
369369
370370static MACHINE_RESET( f3 )
371371{
372   taito_f3_soundsystem_reset(machine);
373372   cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, ASSERT_LINE);
374
375   f3_68681_reset(machine);
376373}
377374
378375
r6740r6741
399396   MDRV_CPU_PROGRAM_MAP(f3_map)
400397   MDRV_CPU_VBLANK_INT("screen", f3_interrupt2)
401398
402   TAITO_F3_SOUND_SYSTEM_CPU(16000000)
403
404399   MDRV_MACHINE_START(f3)
405400   MDRV_MACHINE_RESET(f3)
406401
r6740r6741
422417   MDRV_VIDEO_UPDATE(f3)
423418
424419   /* sound hardware */
425   TAITO_F3_SOUND_SYSTEM_ES5505(30476100/2)
420   MDRV_IMPORT_FROM(taito_f3_sound)
426421MACHINE_DRIVER_END
427422
428423/* These games reprogram the video output registers to display different scanlines,
src/mame/drivers/champbas.c
r6740r6741
8585#include "cpu/alph8201/alph8201.h"
8686#include "sound/ay8910.h"
8787#include "sound/dac.h"
88#include "champbas.h"
88#include "includes/champbas.h"
8989
9090
9191/*************************************
src/mame/drivers/ssozumo.c
r6740r6741
1313#include "sound/ay8910.h"
1414#include "sound/dac.h"
1515
16extern UINT8 *ssozumo_videoram;
17extern UINT8 *ssozumo_colorram;
1618extern UINT8 *ssozumo_videoram2;
1719extern UINT8 *ssozumo_colorram2;
1820
r6740r6741
4042   AM_RANGE(0x0780, 0x07ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
4143   AM_RANGE(0x2000, 0x23ff) AM_RAM_WRITE(ssozumo_videoram2_w) AM_BASE(&ssozumo_videoram2)
4244   AM_RANGE(0x2400, 0x27ff) AM_RAM_WRITE(ssozumo_colorram2_w) AM_BASE(&ssozumo_colorram2)
43   AM_RANGE(0x3000, 0x31ff) AM_RAM_WRITE(ssozumo_videoram_w) AM_BASE_GENERIC(videoram)
44   AM_RANGE(0x3200, 0x33ff) AM_RAM_WRITE(ssozumo_colorram_w) AM_BASE_GENERIC(colorram)
45   AM_RANGE(0x3000, 0x31ff) AM_RAM_WRITE(ssozumo_videoram_w) AM_BASE(&ssozumo_videoram)
46   AM_RANGE(0x3200, 0x33ff) AM_RAM_WRITE(ssozumo_colorram_w) AM_BASE(&ssozumo_colorram)
4547   AM_RANGE(0x3400, 0x35ff) AM_RAM
4648   AM_RANGE(0x3600, 0x37ff) AM_RAM
4749   AM_RANGE(0x4000, 0x4000) AM_READ_PORT("P1") AM_WRITE(ssozumo_flipscreen_w)
src/mame/drivers/m107.c
r6740r6741
2525
2626#include "driver.h"
2727#include "cpu/nec/nec.h"
28#include "m107.h"
29#include "iremipt.h"
28#include "includes/m107.h"
29#include "includes/iremipt.h"
3030#include "machine/irem_cpu.h"
3131#include "sound/2151intf.h"
3232#include "sound/iremga20.h"
src/mame/drivers/ninjaw.c
r6740r6741
312312
313313#include "driver.h"
314314#include "cpu/z80/z80.h"
315#include "taitoipt.h"
315#include "includes/taitoipt.h"
316316#include "cpu/m68000/m68000.h"
317317#include "video/taitoic.h"
318318#include "audio/taitosnd.h"
src/mame/drivers/arkanoid.c
r6740r6741
505505
506506#include "driver.h"
507507#include "cpu/z80/z80.h"
508#include "arkanoid.h"
508#include "includes/arkanoid.h"
509509#include "sound/ay8910.h"
510510#include "cpu/m6805/m6805.h"
511511
r6740r6741
13061306
13071307   memcpy(srcgfx, buffer, 0x18000);
13081308
1309   free(buffer);
1310
13091311   state->bootleg_id = BLOCK2;
13101312   arkanoid_bootleg_init(machine);
13111313}
src/mame/drivers/twin16.c
r6740r6741
5050#include "sound/k007232.h"
5151#include "sound/upd7759.h"
5252#include "includes/twin16.h"
53#include "konamipt.h"
53#include "includes/konamipt.h"
5454
5555UINT16 twin16_custom_video;
5656UINT16 *twin16_gfx_rom;
src/mame/drivers/megasys1.c
r6740r6741
123123#include "cpu/z80/z80.h"
124124#include "cpu/m68000/m68000.h"
125125#include "deprecat.h"
126#include "megasys1.h"
126#include "includes/megasys1.h"
127127#include "sound/2203intf.h"
128128#include "sound/2151intf.h"
129129#include "sound/okim6295.h"
src/mame/drivers/crshrace.c
r6740r6741
129129#include "driver.h"
130130#include "cpu/z80/z80.h"
131131#include "cpu/m68000/m68000.h"
132#include "video/konamiic.h"
133132#include "sound/2610intf.h"
134#include "crshrace.h"
133#include "video/konicdev.h"
134#include "includes/crshrace.h"
135135
136136
137137#define CRSHRACE_3P_HACK   0
r6740r6741
143143
144144   offset *= 2;
145145
146   return rom[offset] | (rom[offset+1] << 8);
146   return rom[offset] | (rom[offset + 1] << 8);
147147}
148148
149149static READ16_HANDLER( extrarom2_r )
r6740r6741
152152
153153   offset *= 2;
154154
155   return rom[offset] | (rom[offset+1] << 8);
155   return rom[offset] | (rom[offset + 1] << 8);
156156}
157157
158158static WRITE8_HANDLER( crshrace_sh_bankswitch_w )
r6740r6741
163163}
164164
165165
166static int pending_command;
167
168166static WRITE16_HANDLER( sound_command_w )
169167{
168   crshrace_state *state = (crshrace_state *)space->machine->driver_data;
169
170170   if (ACCESSING_BITS_0_7)
171171   {
172      pending_command = 1;
173      soundlatch_w(space,offset,data & 0xff);
174      cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
172      state->pending_command = 1;
173      soundlatch_w(space, offset, data & 0xff);
174      cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
175175   }
176176}
177177
178178static CUSTOM_INPUT( country_sndpending_r )
179179{
180   return pending_command;
180   crshrace_state *state = (crshrace_state *)field->port->machine->driver_data;
181   return state->pending_command;
181182}
182183
183184static WRITE8_HANDLER( pending_command_clear_w )
184185{
185   pending_command = 0;
186   crshrace_state *state = (crshrace_state *)space->machine->driver_data;
187   state->pending_command = 0;
186188}
187189
188190
r6740r6741
193195   AM_RANGE(0x400000, 0x4fffff) AM_READ(extrarom2_r)
194196   AM_RANGE(0x500000, 0x5fffff) AM_READ(extrarom2_r)   /* mirror */
195197   AM_RANGE(0xa00000, 0xa0ffff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram2)
196   AM_RANGE(0xd00000, 0xd01fff) AM_RAM_WRITE(crshrace_videoram1_w) AM_BASE(&crshrace_videoram1)
198   AM_RANGE(0xd00000, 0xd01fff) AM_RAM_WRITE(crshrace_videoram1_w) AM_BASE_MEMBER(crshrace_state, videoram1)
197199   AM_RANGE(0xe00000, 0xe01fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
198200   AM_RANGE(0xfe0000, 0xfeffff) AM_RAM
199201   AM_RANGE(0xffc000, 0xffc001) AM_WRITE(crshrace_roz_bank_w)
200   AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(crshrace_videoram2_w) AM_BASE(&crshrace_videoram2)
202   AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(crshrace_videoram2_w) AM_BASE_MEMBER(crshrace_state, videoram2)
201203   AM_RANGE(0xffe000, 0xffefff) AM_RAM_WRITE(paletteram16_xGGGGGBBBBBRRRRR_word_w) AM_BASE_GENERIC(paletteram)
202204   AM_RANGE(0xfff000, 0xfff001) AM_READ_PORT("P1") AM_WRITE(crshrace_gfxctrl_w)
203205   AM_RANGE(0xfff002, 0xfff003) AM_READ_PORT("P2")
r6740r6741
206208   AM_RANGE(0xfff008, 0xfff009) AM_WRITE(sound_command_w)
207209   AM_RANGE(0xfff00a, 0xfff00b) AM_READ_PORT("DSW1")
208210   AM_RANGE(0xfff00e, 0xfff00f) AM_READ_PORT("P3")
209   AM_RANGE(0xfff020, 0xfff03f) AM_WRITEONLY AM_BASE(&K053936_0_ctrl)
211   AM_RANGE(0xfff020, 0xfff03f) AM_DEVWRITE("k053936", k053936_ctrl_w)
210212   AM_RANGE(0xfff044, 0xfff047) AM_WRITEONLY   // ??? moves during race
211213ADDRESS_MAP_END
212214
r6740r6741
426428
427429
428430
429static void irqhandler(const device_config *device, int irq)
431static void irqhandler( const device_config *device, int irq )
430432{
431   cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE);
433   crshrace_state *state = (crshrace_state *)device->machine->driver_data;
434   cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE);
432435}
433436
434437static const ym2610_interface ym2610_config =
r6740r6741
436439   irqhandler
437440};
438441
442static const k053936_interface crshrace_k053936_intf =
443{
444   1, -48, -21   /* wrap, xoff, yoff */
445};
439446
440447
448static MACHINE_START( crshrace )
449{
450   crshrace_state *state = (crshrace_state *)machine->driver_data;
451
452   state->audiocpu = devtag_get_device(machine, "audiocpu");
453   state->k053936 = devtag_get_device(machine, "k053936");
454
455   state_save_register_global(machine, state->roz_bank);
456   state_save_register_global(machine, state->gfxctrl);
457   state_save_register_global(machine, state->flipscreen);
458   state_save_register_global(machine, state->pending_command);
459}
460
461static MACHINE_RESET( crshrace )
462{
463   crshrace_state *state = (crshrace_state *)machine->driver_data;
464
465   state->roz_bank = 0;
466   state->gfxctrl = 0;
467   state->flipscreen = 0;
468   state->pending_command = 0;
469}
470
441471static MACHINE_DRIVER_START( crshrace )
442472
473   /* driver data */
474   MDRV_DRIVER_DATA(crshrace_state)
475
443476   /* basic machine hardware */
444477   MDRV_CPU_ADD("maincpu", M68000,16000000)   /* 16 MHz ??? */
445478   MDRV_CPU_PROGRAM_MAP(crshrace_map)
r6740r6741
449482   MDRV_CPU_PROGRAM_MAP(sound_map)
450483   MDRV_CPU_IO_MAP(sound_io_map)
451484
485   MDRV_MACHINE_START(crshrace)
486   MDRV_MACHINE_RESET(crshrace)
487
452488   /* video hardware */
453489   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
454490
r6740r6741
461497   MDRV_GFXDECODE(crshrace)
462498   MDRV_PALETTE_LENGTH(2048)
463499
500   MDRV_K053936_ADD("k053936", crshrace_k053936_intf)
501
464502   MDRV_VIDEO_START(crshrace)
465503   MDRV_VIDEO_EOF(crshrace)
466504   MDRV_VIDEO_UPDATE(crshrace)
r6740r6741
547585
548586
549587#ifdef UNUSED_FUNCTION
550void crshrace_patch_code(UINT16 offset)
588void crshrace_patch_code( UINT16 offset )
551589{
552590   /* A hack which shows 3 player mode in code which is disabled */
553591   UINT16 *RAM = (UINT16 *)memory_region(machine, "maincpu");
r6740r6741
573611}
574612
575613
576GAME( 1993, crshrace, 0,        crshrace, crshrace, crshrace, ROT270, "Video System Co.", "Lethal Crash Race (set 1)", GAME_NO_COCKTAIL )
577GAME( 1993, crshrace2,crshrace, crshrace, crshrac2, crshrac2, ROT270, "Video System Co.", "Lethal Crash Race (set 2)", GAME_NO_COCKTAIL )
578
614GAME( 1993, crshrace, 0,        crshrace, crshrace, crshrace, ROT270, "Video System Co.", "Lethal Crash Race (set 1)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
615GAME( 1993, crshrace2,crshrace, crshrace, crshrac2, crshrac2, ROT270, "Video System Co.", "Lethal Crash Race (set 2)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
src/mame/drivers/airbustr.c
r6740r6741
223223#include "sound/2203intf.h"
224224#include "sound/okim6295.h"
225225#include "video/kan_pand.h"
226#include "includes/airbustr.h"
226227
227static UINT8 *devram;
228static int soundlatch_status, soundlatch2_status;
229static int master_addr;
230static int slave_addr;
231
232extern UINT8 *airbustr_videoram2, *airbustr_colorram2;
233
234extern WRITE8_HANDLER( airbustr_videoram_w );
235extern WRITE8_HANDLER( airbustr_colorram_w );
236extern WRITE8_HANDLER( airbustr_videoram2_w );
237extern WRITE8_HANDLER( airbustr_colorram2_w );
238extern WRITE8_HANDLER( airbustr_scrollregs_w );
239extern VIDEO_START( airbustr );
240extern VIDEO_UPDATE( airbustr );
241extern VIDEO_EOF( airbustr );
242
243228/* Read/Write Handlers */
244
245229static READ8_HANDLER( devram_r )
246230{
231   airbustr_state *state = (airbustr_state *)space->machine->driver_data;
232
247233   // There's an MCU here, possibly
248
249234   switch (offset)
250235   {
251236      /* Reading efe0 probably resets a watchdog mechanism
252237           that would reset the main cpu. We avoid this and patch
253238           the rom instead (main cpu has to be reset once at startup) */
254239      case 0xfe0:
255         return watchdog_reset_r(space,0);
240         return watchdog_reset_r(space, 0);
256241
257242      /* Reading a word at eff2 probably yelds the product
258243           of the words written to eff0 and eff2 */
259244      case 0xff2:
260245      case 0xff3:
261246      {
262         int   x = (devram[0xff0] + devram[0xff1] * 256) *
263               (devram[0xff2] + devram[0xff3] * 256);
264         if (offset == 0xff2)   return (x & 0x00FF) >> 0;
265         else            return (x & 0xFF00) >> 8;
247         int   x = (state->devram[0xff0] + state->devram[0xff1] * 256) * (state->devram[0xff2] + state->devram[0xff3] * 256);
248         if (offset == 0xff2)
249            return (x & 0x00ff) >> 0;
250         else
251            return (x & 0xff00) >> 8;
266252      }   break;
267253
268254      /* Reading eff4, F0 times must yield at most 80-1 consecutive
r6740r6741
271257         return mame_rand(space->machine);
272258
273259      default:
274         return devram[offset];
260         return state->devram[offset];
275261   }
276262}
277263
278264static WRITE8_HANDLER( master_nmi_trigger_w )
279265{
280   cputag_set_input_line(space->machine, "slave", INPUT_LINE_NMI, PULSE_LINE);
266   airbustr_state *state = (airbustr_state *)space->machine->driver_data;
267   cpu_set_input_line(state->slave, INPUT_LINE_NMI, PULSE_LINE);
281268}
282269
283static void airbustr_bankswitch(running_machine *machine, const char *cpu, const char *bank, int data)
284{
285   UINT8 *ROM = memory_region(machine, cpu);
286
287   if ((data & 0x07) <  3)
288      ROM = &ROM[0x4000 * (data & 0x07)];
289   else
290      ROM = &ROM[0x10000 + 0x4000 * ((data & 0x07) - 3)];
291
292   memory_set_bankptr(machine, bank, ROM);
293}
294
295270static WRITE8_HANDLER( master_bankswitch_w )
296271{
297   airbustr_bankswitch(space->machine, "master", "bank1", data);
272   memory_set_bank(space->machine, "bank1", data & 0x07);
298273}
299274
300275static WRITE8_HANDLER( slave_bankswitch_w )
301276{
302   const device_config *pandora = devtag_get_device(space->machine, "pandora");
303   airbustr_bankswitch(space->machine, "slave", "bank2", data);
277   airbustr_state *state = (airbustr_state *)space->machine->driver_data;
304278
279   memory_set_bank(space->machine, "bank2", data & 0x07);
280
305281   flip_screen_set(space->machine, data & 0x10);
306282
307283   // used at the end of levels, after defeating the boss, to leave trails
308   pandora_set_clear_bitmap(pandora, data&0x20);
284   pandora_set_clear_bitmap(state->pandora, data & 0x20);
309285}
310286
311287static WRITE8_HANDLER( sound_bankswitch_w )
312288{
313   airbustr_bankswitch(space->machine, "audiocpu", "bank3", data);
289   memory_set_bank(space->machine, "bank3", data & 0x07);
314290}
315291
316292static READ8_HANDLER( soundcommand_status_r )
317293{
294   airbustr_state *state = (airbustr_state *)space->machine->driver_data;
295
318296   // bits: 2 <-> ?    1 <-> soundlatch full   0 <-> soundlatch2 empty
319   return 4 + soundlatch_status * 2 + (1 - soundlatch2_status);
297   return 4 + state->soundlatch_status * 2 + (1 - state->soundlatch2_status);
320298}
321299
322300static READ8_HANDLER( soundcommand_r )
323301{
324   soundlatch_status = 0;   // soundlatch has been read
325   return soundlatch_r(space,0);
302   airbustr_state *state = (airbustr_state *)space->machine->driver_data;
303   state->soundlatch_status = 0;   // soundlatch has been read
304   return soundlatch_r(space, 0);
326305}
327306
328307static READ8_HANDLER( soundcommand2_r )
329308{
330   soundlatch2_status = 0;   // soundlatch2 has been read
331   return soundlatch2_r(space,0);
309   airbustr_state *state = (airbustr_state *)space->machine->driver_data;
310   state->soundlatch2_status = 0;   // soundlatch2 has been read
311   return soundlatch2_r(space, 0);
332312}
333313
334314static WRITE8_HANDLER( soundcommand_w )
335315{
316   airbustr_state *state = (airbustr_state *)space->machine->driver_data;
336317   soundlatch_w(space, 0, data);
337   soundlatch_status = 1;   // soundlatch has been written
338   cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);   // cause a nmi to sub cpu
318   state->soundlatch_status = 1;   // soundlatch has been written
319   cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);   // cause a nmi to sub cpu
339320}
340321
341322static WRITE8_HANDLER( soundcommand2_w )
342323{
324   airbustr_state *state = (airbustr_state *)space->machine->driver_data;
343325   soundlatch2_w(space, 0, data);
344   soundlatch2_status = 1;   // soundlatch2 has been written
326   state->soundlatch2_status = 1;   // soundlatch2 has been written
345327}
346328
347329static WRITE8_HANDLER( airbustr_paletteram_w )
348330{
331   airbustr_state *state = (airbustr_state *)space->machine->driver_data;
349332   int val;
350333
351334   /*  ! byte 1 ! ! byte 0 !   */
352335   /*  xGGG GGRR   RRRB BBBB   */
353336   /*  x432 1043   2104 3210   */
354337
355   space->machine->generic.paletteram.u8[offset] = data;
356   val = (space->machine->generic.paletteram.u8[offset | 1] << 8) | space->machine->generic.paletteram.u8[offset & ~1];
338   state->paletteram[offset] = data;
339   val = (state->paletteram[offset | 1] << 8) | state->paletteram[offset & ~1];
357340
358   palette_set_color_rgb(space->machine, offset/2, pal5bit(val >> 5), pal5bit(val >> 10), pal5bit(val >> 0));
341   palette_set_color_rgb(space->machine, offset / 2, pal5bit(val >> 5), pal5bit(val >> 10), pal5bit(val >> 0));
359342}
360343
361344static WRITE8_HANDLER( airbustr_coin_counter_w )
r6740r6741
367350}
368351
369352/* Memory Maps */
370
371353static ADDRESS_MAP_START( master_map, ADDRESS_SPACE_PROGRAM, 8 )
372354   AM_RANGE(0x0000, 0x7fff) AM_ROM
373355   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
374356   AM_RANGE(0xc000, 0xcfff) AM_DEVREADWRITE("pandora", pandora_spriteram_r, pandora_spriteram_w)
375357   AM_RANGE(0xd000, 0xdfff) AM_RAM
376   AM_RANGE(0xe000, 0xefff) AM_RAM AM_BASE(&devram) // shared with protection device
358   AM_RANGE(0xe000, 0xefff) AM_RAM AM_BASE_MEMBER(airbustr_state, devram) // shared with protection device
377359   AM_RANGE(0xf000, 0xffff) AM_RAM AM_SHARE("share1")
378360ADDRESS_MAP_END
379361
r6740r6741
387369static ADDRESS_MAP_START( slave_map, ADDRESS_SPACE_PROGRAM, 8 )
388370   AM_RANGE(0x0000, 0x7fff) AM_ROM
389371   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank2")
390   AM_RANGE(0xc000, 0xc3ff) AM_RAM_WRITE(airbustr_videoram2_w) AM_BASE(&airbustr_videoram2)
391   AM_RANGE(0xc400, 0xc7ff) AM_RAM_WRITE(airbustr_colorram2_w) AM_BASE(&airbustr_colorram2)
392   AM_RANGE(0xc800, 0xcbff) AM_RAM_WRITE(airbustr_videoram_w) AM_BASE_GENERIC(videoram)
393   AM_RANGE(0xcc00, 0xcfff) AM_RAM_WRITE(airbustr_colorram_w) AM_BASE_GENERIC(colorram)
394   AM_RANGE(0xd000, 0xd5ff) AM_RAM_WRITE(airbustr_paletteram_w) AM_BASE_GENERIC(paletteram)
372   AM_RANGE(0xc000, 0xc3ff) AM_RAM_WRITE(airbustr_videoram2_w) AM_BASE_MEMBER(airbustr_state, videoram2)
373   AM_RANGE(0xc400, 0xc7ff) AM_RAM_WRITE(airbustr_colorram2_w) AM_BASE_MEMBER(airbustr_state, colorram2)
374   AM_RANGE(0xc800, 0xcbff) AM_RAM_WRITE(airbustr_videoram_w) AM_BASE_MEMBER(airbustr_state, videoram)
375   AM_RANGE(0xcc00, 0xcfff) AM_RAM_WRITE(airbustr_colorram_w) AM_BASE_MEMBER(airbustr_state, colorram)
376   AM_RANGE(0xd000, 0xd5ff) AM_RAM_WRITE(airbustr_paletteram_w) AM_BASE_MEMBER(airbustr_state, paletteram)
395377   AM_RANGE(0xd600, 0xdfff) AM_RAM
396378   AM_RANGE(0xe000, 0xefff) AM_RAM
397379   AM_RANGE(0xf000, 0xffff) AM_RAM AM_SHARE("share1")
r6740r6741
577559
578560static INTERRUPT_GEN( master_interrupt )
579561{
580   master_addr ^= 0x02;
581   cpu_set_input_line_and_vector(device, 0, HOLD_LINE, master_addr);
562   airbustr_state *state = (airbustr_state *)device->machine->driver_data;
563   state->master_addr ^= 0x02;
564   cpu_set_input_line_and_vector(device, 0, HOLD_LINE, state->master_addr);
582565}
583566
584567static INTERRUPT_GEN( slave_interrupt )
585568{
586   slave_addr ^= 0x02;
587   cpu_set_input_line_and_vector(device, 0, HOLD_LINE, slave_addr);
569   airbustr_state *state = (airbustr_state *)device->machine->driver_data;
570   state->slave_addr ^= 0x02;
571   cpu_set_input_line_and_vector(device, 0, HOLD_LINE, state->slave_addr);
588572}
589573
590574/* Machine Initialization */
591575
592576static MACHINE_START( airbustr )
593577{
594    state_save_register_global(machine, soundlatch_status);
595    state_save_register_global(machine, soundlatch2_status);
596    state_save_register_global(machine, master_addr);
597    state_save_register_global(machine, slave_addr);
578   airbustr_state *state = (airbustr_state *)machine->driver_data;
579   UINT8 *MASTER = memory_region(machine, "master");
580   UINT8 *SLAVE = memory_region(machine, "slave");
581   UINT8 *AUDIO = memory_region(machine, "audiocpu");
582
583   memory_configure_bank(machine, "bank1", 0, 3, &MASTER[0x00000], 0x4000);
584   memory_configure_bank(machine, "bank1", 3, 5, &MASTER[0x10000], 0x4000);
585   memory_configure_bank(machine, "bank2", 0, 3, &SLAVE[0x00000], 0x4000);
586   memory_configure_bank(machine, "bank2", 3, 5, &SLAVE[0x10000], 0x4000);
587   memory_configure_bank(machine, "bank3", 0, 3, &AUDIO[0x00000], 0x4000);
588   memory_configure_bank(machine, "bank3", 3, 5, &AUDIO[0x10000], 0x4000);
589
590   state->master = devtag_get_device(machine, "master");
591   state->slave = devtag_get_device(machine, "slave");
592   state->audiocpu = devtag_get_device(machine, "audiocpu");
593   state->pandora = devtag_get_device(machine, "pandora");
594
595   state_save_register_global(machine, state->soundlatch_status);
596   state_save_register_global(machine, state->soundlatch2_status);
597   state_save_register_global(machine, state->master_addr);
598   state_save_register_global(machine, state->slave_addr);
599   state_save_register_global(machine, state->bg_scrollx);
600   state_save_register_global(machine, state->bg_scrolly);
601   state_save_register_global(machine, state->fg_scrollx);
602   state_save_register_global(machine, state->fg_scrolly);
603   state_save_register_global(machine, state->highbits);
598604}
599605
600606static MACHINE_RESET( airbustr )
601607{
602   const address_space *space = cputag_get_address_space(machine, "master", ADDRESS_SPACE_PROGRAM);
603   soundlatch_status = soundlatch2_status = 0;
604   master_addr = 0xff;
605   slave_addr = 0xfd;
606   master_bankswitch_w(space, 0, 0x02);
607   slave_bankswitch_w(space, 0, 0x02);
608   sound_bankswitch_w(space, 0, 0x02);
608   airbustr_state *state = (airbustr_state *)machine->driver_data;
609
610   state->soundlatch_status = state->soundlatch2_status = 0;
611   state->master_addr = 0xff;
612   state->slave_addr = 0xfd;
613   state->bg_scrollx = 0;
614   state->bg_scrolly = 0;
615   state->fg_scrollx = 0;
616   state->fg_scrolly = 0;
617   state->highbits = 0;
618
619   memory_set_bank(machine, "bank1", 0x02);
620   memory_set_bank(machine, "bank2", 0x02);
621   memory_set_bank(machine, "bank3", 0x02);
609622}
610623
611624/* Machine Driver */
r6740r6741
618631};
619632
620633static MACHINE_DRIVER_START( airbustr )
621   // basic machine hardware
634
635   /* driver data */
636   MDRV_DRIVER_DATA(airbustr_state)
637
638   /* basic machine hardware */
622639   MDRV_CPU_ADD("master", Z80, 6000000)   // ???
623640   MDRV_CPU_PROGRAM_MAP(master_map)
624641   MDRV_CPU_IO_MAP(master_io_map)
r6740r6741
640657   MDRV_MACHINE_RESET(airbustr)
641658   MDRV_WATCHDOG_TIME_INIT(SEC(3))   /* a guess, and certainly wrong */
642659
643   // video hardware
660   /* video hardware */
644661   MDRV_SCREEN_ADD("screen", RASTER)
645662   MDRV_SCREEN_REFRESH_RATE(60)
646663   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
r6740r6741
656673   MDRV_VIDEO_UPDATE(airbustr)
657674   MDRV_VIDEO_EOF(airbustr)
658675
659   // sound hardware
676   /* sound hardware */
660677   MDRV_SPEAKER_STANDARD_MONO("mono")
661678
662679   MDRV_SOUND_ADD("ymsnd", YM2203, 3000000)
src/mame/drivers/pacman.c
r6740r6741
339339#include "driver.h"
340340#include "cpu/z80/z80.h"
341341#include "deprecat.h"
342#include "pacman.h"
342#include "includes/pacman.h"
343343#include "cpu/s2650/s2650.h"
344344#include "sound/namco.h"
345345#include "sound/ay8910.h"
r6740r6741
892892static ADDRESS_MAP_START( pacman_map, ADDRESS_SPACE_PROGRAM, 8 )
893893   //A lot of games don't have an a15 at the cpu.  Generally only games with a cpu daughter board can access the full 32k of romspace.
894894   AM_RANGE(0x0000, 0x3fff) AM_MIRROR(0x8000) AM_ROM
895   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
896   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_GENERIC(colorram)
895   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram)
896   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram)
897897   AM_RANGE(0x4800, 0x4bff) AM_MIRROR(0xa000) AM_READ(pacman_read_nop) AM_WRITENOP
898898   AM_RANGE(0x4c00, 0x4fef) AM_MIRROR(0xa000) AM_RAM
899899   AM_RANGE(0x4ff0, 0x4fff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
r6740r6741
919919
920920
921921static ADDRESS_MAP_START( mspacman_map, ADDRESS_SPACE_PROGRAM, 8 )
922   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
923   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_GENERIC(colorram)
922   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram)
923   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram)
924924   AM_RANGE(0x4800, 0x4bff) AM_MIRROR(0xa000) AM_READ(pacman_read_nop) AM_WRITENOP
925925   AM_RANGE(0x4c00, 0x4fef) AM_MIRROR(0xa000) AM_RAM
926926   AM_RANGE(0x4ff0, 0x4fff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
r6740r6741
959959
960960static ADDRESS_MAP_START( woodpek_map, ADDRESS_SPACE_PROGRAM, 8 )
961961   AM_RANGE(0x0000, 0x3fff) AM_ROM
962   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
963   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_GENERIC(colorram)
962   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram)
963   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram)
964964   AM_RANGE(0x4800, 0x4bff) AM_MIRROR(0xa000) AM_READ(pacman_read_nop) AM_WRITENOP
965965   AM_RANGE(0x4c00, 0x4fef) AM_MIRROR(0xa000) AM_RAM
966966   AM_RANGE(0x4ff0, 0x4fff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
r6740r6741
986986
987987static ADDRESS_MAP_START( alibaba_map, ADDRESS_SPACE_PROGRAM, 8 )
988988   AM_RANGE(0x0000, 0x3fff) AM_ROM
989   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
990   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_GENERIC(colorram)
989   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram)
990   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram)
991991   AM_RANGE(0x4800, 0x4bff) AM_MIRROR(0xa000) AM_READ(pacman_read_nop) AM_WRITENOP
992992   AM_RANGE(0x4c00, 0x4eef) AM_MIRROR(0xa000) AM_RAM
993993   AM_RANGE(0x4ef0, 0x4eff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
r6740r6741
10181018
10191019static ADDRESS_MAP_START( dremshpr_map, ADDRESS_SPACE_PROGRAM, 8 )
10201020   AM_RANGE(0x0000, 0x3fff) AM_ROM
1021   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
1022   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_GENERIC(colorram)
1021   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram)
1022   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram)
10231023   AM_RANGE(0x4800, 0x4fef) AM_MIRROR(0xa000) AM_RAM
10241024   AM_RANGE(0x4ff0, 0x4fff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
10251025   AM_RANGE(0x5000, 0x5000) AM_MIRROR(0xaf38) AM_WRITE(interrupt_enable_w)
r6740r6741
10441044
10451045static ADDRESS_MAP_START( epos_map, ADDRESS_SPACE_PROGRAM, 8 )
10461046   AM_RANGE(0x0000, 0x3fff) AM_MIRROR(0x8000) AM_ROMBANK("bank1")
1047   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
1048   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_GENERIC(colorram)
1047   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram)
1048   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram)
10491049   AM_RANGE(0x4800, 0x4bff) AM_MIRROR(0xa000) AM_READ(pacman_read_nop) AM_WRITENOP
10501050   AM_RANGE(0x4c00, 0x4fef) AM_MIRROR(0xa000) AM_RAM
10511051   AM_RANGE(0x4ff0, 0x4fff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
r6740r6741
10701070
10711071static ADDRESS_MAP_START( vanvan_map, ADDRESS_SPACE_PROGRAM, 8 )
10721072   AM_RANGE(0x0000, 0x3fff) AM_ROM
1073   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
1074   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_GENERIC(colorram)
1073   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram)
1074   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram)
10751075   AM_RANGE(0x4800, 0x4fef) AM_MIRROR(0xa000) AM_RAM
10761076   AM_RANGE(0x4ff0, 0x4fff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
10771077   AM_RANGE(0x5000, 0x5000) AM_MIRROR(0xaf38) AM_WRITE(interrupt_enable_w)
r6740r6741
10991099
11001100static ADDRESS_MAP_START( s2650games_map, ADDRESS_SPACE_PROGRAM, 8 )
11011101   AM_RANGE(0x0000, 0x0fff) AM_MIRROR(0x8000) AM_ROMBANK("bank1")
1102   AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0xe000) AM_WRITE(s2650games_colorram_w) AM_BASE_GENERIC(colorram)
1102   AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0xe000) AM_WRITE(s2650games_colorram_w) AM_BASE(&pacman_colorram)
11031103   AM_RANGE(0x1400, 0x141f) AM_MIRROR(0xe000) AM_WRITE(s2650games_scroll_w)
11041104   AM_RANGE(0x1420, 0x148f) AM_MIRROR(0xe000) AM_WRITEONLY
11051105   AM_RANGE(0x1490, 0x149f) AM_MIRROR(0xe000) AM_WRITEONLY AM_BASE(&s2650games_spriteram)
r6740r6741
11181118   AM_RANGE(0x1500, 0x1500) AM_MIRROR(0xe000) AM_READ_PORT("IN0")
11191119   AM_RANGE(0x1540, 0x1540) AM_MIRROR(0xe000) AM_READ_PORT("IN1")
11201120   AM_RANGE(0x1580, 0x1580) AM_MIRROR(0xe000) AM_READ_PORT("DSW0")
1121   AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0xe000) AM_WRITE(s2650games_videoram_w) AM_BASE_GENERIC(videoram)
1121   AM_RANGE(0x1800, 0x1bff) AM_MIRROR(0xe000) AM_WRITE(s2650games_videoram_w) AM_BASE(&pacman_videoram)
11221122   AM_RANGE(0x1c00, 0x1fef) AM_MIRROR(0xe000) AM_RAM
11231123   AM_RANGE(0x1ff0, 0x1fff) AM_MIRROR(0xe000) AM_WRITEONLY AM_BASE_SIZE_GENERIC(spriteram)
11241124   AM_RANGE(0x2000, 0x2fff) AM_MIRROR(0x8000) AM_ROMBANK("bank2")
r6740r6741
11291129
11301130static ADDRESS_MAP_START( rocktrv2_map, ADDRESS_SPACE_PROGRAM, 8 )
11311131   AM_RANGE(0x0000, 0x3fff) AM_ROM
1132   AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
1133   AM_RANGE(0x4400, 0x47ff) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_GENERIC(colorram)
1132   AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram)
1133   AM_RANGE(0x4400, 0x47ff) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram)
11341134   AM_RANGE(0x4c00, 0x4fff) AM_RAM
11351135   AM_RANGE(0x5000, 0x5000) AM_WRITE(interrupt_enable_w)
11361136   AM_RANGE(0x5001, 0x5001) AM_DEVWRITE("namco", pacman_sound_enable_w)
r6740r6741
11561156
11571157static ADDRESS_MAP_START( bigbucks_map, ADDRESS_SPACE_PROGRAM, 8 )
11581158   AM_RANGE(0x0000, 0x3fff) AM_ROM
1159   AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
1160   AM_RANGE(0x4400, 0x47ff) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_GENERIC(colorram)
1159   AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram)
1160   AM_RANGE(0x4400, 0x47ff) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram)
11611161   AM_RANGE(0x4c00, 0x4fff) AM_RAM
11621162   AM_RANGE(0x5000, 0x5000) AM_WRITE(interrupt_enable_w)
11631163   AM_RANGE(0x5001, 0x5001) AM_DEVWRITE("namco", pacman_sound_enable_w)
r6740r6741
11771177
11781178static ADDRESS_MAP_START( mschamp_map, ADDRESS_SPACE_PROGRAM, 8 )
11791179   AM_RANGE(0x0000, 0x3fff) AM_ROMBANK("bank1")
1180   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
1181   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_GENERIC(colorram)
1180   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram)
1181   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram)
11821182   AM_RANGE(0x4800, 0x4bff) AM_MIRROR(0xa000) AM_READ(pacman_read_nop) AM_WRITENOP
11831183   AM_RANGE(0x4c00, 0x4fef) AM_MIRROR(0xa000) AM_RAM
11841184   AM_RANGE(0x4ff0, 0x4fff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
r6740r6741
12041204static ADDRESS_MAP_START( crushs_map, ADDRESS_SPACE_PROGRAM, 8 )
12051205   //A lot of games don't have an a15 at the cpu.  Generally only games with a cpu daughter board can access the full 32k of romspace.
12061206   AM_RANGE(0x0000, 0x3fff) AM_MIRROR(0x8000) AM_ROM
1207   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
1208   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE_GENERIC(colorram)
1207   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_videoram_w) AM_BASE(&pacman_videoram)
1208   AM_RANGE(0x4400, 0x47ff) AM_MIRROR(0xa000) AM_RAM_WRITE(pacman_colorram_w) AM_BASE(&pacman_colorram)
12091209   AM_RANGE(0x4800, 0x4bff) AM_MIRROR(0xa000) AM_READ(pacman_read_nop) AM_WRITENOP
12101210   AM_RANGE(0x4c00, 0x4fef) AM_MIRROR(0xa000) AM_RAM
12111211   AM_RANGE(0x4ff0, 0x4fff) AM_MIRROR(0xa000) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
r6740r6741
32773277   MDRV_CPU_PROGRAM_MAP(epos_map)
32783278   MDRV_CPU_IO_MAP(theglobp_portmap)
32793279
3280   MDRV_MACHINE_START(theglobp)
32803281   MDRV_MACHINE_RESET(theglobp)
32813282MACHINE_DRIVER_END
32823283
r6740r6741
32903291   MDRV_CPU_PROGRAM_MAP(epos_map)
32913292   MDRV_CPU_IO_MAP(acitya_portmap)
32923293
3294   MDRV_MACHINE_START(acitya)
32933295   MDRV_MACHINE_RESET(acitya)
32943296MACHINE_DRIVER_END
32953297
src/mame/drivers/bwing.c
r6740r6741
2828#include "cpu/m6502/m6502.h"
2929#include "sound/ay8910.h"
3030#include "sound/dac.h"
31#include "bwing.h"
31#include "includes/bwing.h"
3232
3333
3434//****************************************************************************
src/mame/drivers/sf.c
r6740r6741
11/***************************************************************************
22
3  Street Fighter
3    Street Fighter
44
5  driver by Olivier Galibert
5    driver by Olivier Galibert
66
7TODO:
8- is there a third coin input?
7    TODO:
8    - is there a third coin input?
99
1010***************************************************************************/
1111
r6740r6741
1414#include "cpu/m68000/m68000.h"
1515#include "sound/2151intf.h"
1616#include "sound/msm5205.h"
17#include "includes/sf.h"
1718
18
19extern UINT16 *sf_objectram,*sf_videoram;
20
21WRITE16_HANDLER( sf_bg_scroll_w );
22WRITE16_HANDLER( sf_fg_scroll_w );
23WRITE16_HANDLER( sf_videoram_w );
24WRITE16_HANDLER( sf_gfxctrl_w );
25VIDEO_START( sf );
26VIDEO_UPDATE( sf );
27
28
2919static READ16_HANDLER( dummy_r )
3020{
3121   return 0xffff;
r6740r6741
3626{
3727   if (ACCESSING_BITS_0_7)
3828   {
39      coin_counter_w(space->machine, 0,data & 0x01);
40      coin_counter_w(space->machine, 1,data & 0x02);
41      coin_lockout_w(space->machine, 0,~data & 0x10);
42      coin_lockout_w(space->machine, 1,~data & 0x20);
43      coin_lockout_w(space->machine, 2,~data & 0x40);   /* is there a third coin input? */
29      coin_counter_w(space->machine, 0, data & 0x01);
30      coin_counter_w(space->machine, 1,  data & 0x02);
31      coin_lockout_w(space->machine, 0, ~data & 0x10);
32      coin_lockout_w(space->machine, 1, ~data & 0x20);
33      coin_lockout_w(space->machine, 2, ~data & 0x40);   /* is there a third coin input? */
4434   }
4535}
4636
4737
4838static WRITE16_HANDLER( soundcmd_w )
4939{
40   sf_state *state = (sf_state *)space->machine->driver_data;
41
5042   if (ACCESSING_BITS_0_7)
5143   {
5244      soundlatch_w(space, offset, data & 0xff);
53      cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
45      cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
5446   }
5547}
5648
r6740r6741
5850/* The protection of the japanese version */
5951/* I'd love to see someone dump the 68705 rom */
6052
61static void write_dword(const address_space *space,offs_t offset,UINT32 data)
53static void write_dword( const address_space *space, offs_t offset, UINT32 data )
6254{
63   memory_write_word(space, offset,data >> 16);
64   memory_write_word(space, offset+2,data);
55   memory_write_word(space, offset, data >> 16);
56   memory_write_word(space, offset + 2, data);
6557}
6658
6759static WRITE16_HANDLER( protection_w )
r6740r6741
7668
7769   map = maplist
7870      [memory_read_byte(space, 0xffc006)]
79      [(memory_read_byte(space, 0xffc003)<<1) + (memory_read_word(space, 0xffc004)>>8)];
71      [(memory_read_byte(space, 0xffc003) << 1) + (memory_read_word(space, 0xffc004) >> 8)];
8072
81   switch(memory_read_byte(space, 0xffc684)) {
73   switch (memory_read_byte(space, 0xffc684))
74   {
8275   case 1:
8376      {
8477         int base;
8578
86         base = 0x1b6e8+0x300e*map;
79         base = 0x1b6e8 + 0x300e * map;
8780
88         write_dword(space, 0xffc01c, 0x16bfc+0x270*map);
89         write_dword(space, 0xffc020, base+0x80);
81         write_dword(space, 0xffc01c, 0x16bfc + 0x270 * map);
82         write_dword(space, 0xffc020, base + 0x80);
9083         write_dword(space, 0xffc024, base);
91         write_dword(space, 0xffc028, base+0x86);
92         write_dword(space, 0xffc02c, base+0x8e);
93         write_dword(space, 0xffc030, base+0x20e);
94         write_dword(space, 0xffc034, base+0x30e);
95         write_dword(space, 0xffc038, base+0x38e);
96         write_dword(space, 0xffc03c, base+0x40e);
97         write_dword(space, 0xffc040, base+0x80e);
98         write_dword(space, 0xffc044, base+0xc0e);
99         write_dword(space, 0xffc048, base+0x180e);
100         write_dword(space, 0xffc04c, base+0x240e);
101         write_dword(space, 0xffc050, 0x19548+0x60*map);
102         write_dword(space, 0xffc054, 0x19578+0x60*map);
84         write_dword(space, 0xffc028, base + 0x86);
85         write_dword(space, 0xffc02c, base + 0x8e);
86         write_dword(space, 0xffc030, base + 0x20e);
87         write_dword(space, 0xffc034, base + 0x30e);
88         write_dword(space, 0xffc038, base + 0x38e);
89         write_dword(space, 0xffc03c, base + 0x40e);
90         write_dword(space, 0xffc040, base + 0x80e);
91         write_dword(space, 0xffc044, base + 0xc0e);
92         write_dword(space, 0xffc048, base + 0x180e);
93         write_dword(space, 0xffc04c, base + 0x240e);
94         write_dword(space, 0xffc050, 0x19548 + 0x60 * map);
95         write_dword(space, 0xffc054, 0x19578 + 0x60 * map);
10396         break;
10497      }
10598   case 2:
r6740r6741
126119   case 4:
127120      {
128121         int pos = memory_read_byte(space, 0xffc010);
129         pos = (pos+1) & 3;
122         pos = (pos + 1) & 3;
130123         memory_write_byte(space, 0xffc010, pos);
131         if(!pos) {
124         if(!pos)
125         {
132126            int d1 = memory_read_word(space, 0xffc682);
133127            int off = memory_read_word(space, 0xffc00e);
134            if(off!=512) {
128            if (off!=512)
129            {
135130               off++;
136131               d1++;
137            } else {
132            }
133            else
134            {
138135               off = 0;
139136               d1 -= 512;
140137            }
r6740r6741
146143      }
147144   default:
148145      {
149         logerror("Write protection at %06x (%04x)\n", cpu_get_pc(space->cpu), data&0xffff);
146         logerror("Write protection at %06x (%04x)\n", cpu_get_pc(space->cpu), data & 0xffff);
150147         logerror("*** Unknown protection %d\n", memory_read_byte(space, 0xffc684));
151148         break;
152149      }
r6740r6741
162159
163160static READ16_HANDLER( button1_r )
164161{
165   return (scale[input_port_read(space->machine, "IN3")]<<8) | scale[input_port_read(space->machine, "IN1")];
162   return (scale[input_port_read(space->machine, "IN3")] << 8) | scale[input_port_read(space->machine, "IN1")];
166163}
167164
168165static READ16_HANDLER( button2_r )
169166{
170   return (scale[input_port_read(space->machine, "IN4")]<<8) | scale[input_port_read(space->machine, "IN2")];
167   return (scale[input_port_read(space->machine, "IN4")] << 8) | scale[input_port_read(space->machine, "IN2")];
171168}
172169
173170
174171static WRITE8_HANDLER( sound2_bank_w )
175172{
176   memory_set_bankptr(space->machine, "bank1",memory_region(space->machine, "audio2")+0x8000*(data+1));
173   memory_set_bankptr(space->machine, "bank1", memory_region(space->machine, "audio2") + 0x8000 * (data + 1));
177174}
178175
179176
180177static WRITE8_DEVICE_HANDLER( msm5205_w )
181178{
182   msm5205_reset_w(device,(data>>7)&1);
179   msm5205_reset_w(device, (data >> 7) & 1);
183180   /* ?? bit 6?? */
184   msm5205_data_w(device,data);
185   msm5205_vclk_w(device,1);
186   msm5205_vclk_w(device,0);
181   msm5205_data_w(device, data);
182   msm5205_vclk_w(device, 1);
183   msm5205_vclk_w(device, 0);
187184}
188185
189186
190187
191188static ADDRESS_MAP_START( sf_map, ADDRESS_SPACE_PROGRAM, 16 )
192189   AM_RANGE(0x000000, 0x04ffff) AM_ROM
193   AM_RANGE(0x800000, 0x800fff) AM_RAM_WRITE(sf_videoram_w) AM_BASE(&sf_videoram) AM_SIZE_GENERIC(videoram)
190   AM_RANGE(0x800000, 0x800fff) AM_RAM_WRITE(sf_videoram_w) AM_BASE_SIZE_MEMBER(sf_state, videoram, videoram_size)
194191   AM_RANGE(0xb00000, 0xb007ff) AM_RAM_WRITE(paletteram16_xxxxRRRRGGGGBBBB_word_w) AM_BASE_GENERIC(paletteram)
195192   AM_RANGE(0xc00000, 0xc00001) AM_READ_PORT("COINS")
196193   AM_RANGE(0xc00002, 0xc00003) AM_READ_PORT("IN0")
r6740r6741
207204   AM_RANGE(0xc0001c, 0xc0001d) AM_WRITE(soundcmd_w)
208205   AM_RANGE(0xc0001e, 0xc0001f) AM_WRITE(protection_w)
209206   AM_RANGE(0xff8000, 0xffdfff) AM_RAM
210   AM_RANGE(0xffe000, 0xffffff) AM_RAM AM_BASE(&sf_objectram)
207   AM_RANGE(0xffe000, 0xffffff) AM_RAM AM_BASE_MEMBER(sf_state, objectram)
211208ADDRESS_MAP_END
212209
213210static ADDRESS_MAP_START( sfus_map, ADDRESS_SPACE_PROGRAM, 16 )
214211   AM_RANGE(0x000000, 0x04ffff) AM_ROM
215   AM_RANGE(0x800000, 0x800fff) AM_RAM_WRITE(sf_videoram_w) AM_BASE(&sf_videoram) AM_SIZE_GENERIC(videoram)
212   AM_RANGE(0x800000, 0x800fff) AM_RAM_WRITE(sf_videoram_w) AM_BASE_SIZE_MEMBER(sf_state, videoram, videoram_size)
216213   AM_RANGE(0xb00000, 0xb007ff) AM_RAM_WRITE(paletteram16_xxxxRRRRGGGGBBBB_word_w) AM_BASE_GENERIC(paletteram)
217214   AM_RANGE(0xc00000, 0xc00001) AM_READ_PORT("IN0")
218215   AM_RANGE(0xc00002, 0xc00003) AM_READ_PORT("IN1")
r6740r6741
229226   AM_RANGE(0xc0001c, 0xc0001d) AM_WRITE(soundcmd_w)
230227   AM_RANGE(0xc0001e, 0xc0001f) AM_WRITE(protection_w)
231228   AM_RANGE(0xff8000, 0xffdfff) AM_RAM
232   AM_RANGE(0xffe000, 0xffffff) AM_RAM AM_BASE(&sf_objectram)
229   AM_RANGE(0xffe000, 0xffffff) AM_RAM AM_BASE_MEMBER(sf_state, objectram)
233230ADDRESS_MAP_END
234231
235232static ADDRESS_MAP_START( sfjp_map, ADDRESS_SPACE_PROGRAM, 16 )
236233   AM_RANGE(0x000000, 0x04ffff) AM_ROM
237   AM_RANGE(0x800000, 0x800fff) AM_RAM_WRITE(sf_videoram_w) AM_BASE(&sf_videoram) AM_SIZE_GENERIC(videoram)
234   AM_RANGE(0x800000, 0x800fff) AM_RAM_WRITE(sf_videoram_w) AM_BASE_SIZE_MEMBER(sf_state, videoram, videoram_size)
238235   AM_RANGE(0xb00000, 0xb007ff) AM_RAM_WRITE(paletteram16_xxxxRRRRGGGGBBBB_word_w) AM_BASE_GENERIC(paletteram)
239236   AM_RANGE(0xc00000, 0xc00001) AM_READ_PORT("COINS")
240237   AM_RANGE(0xc00002, 0xc00003) AM_READ_PORT("P1")
r6740r6741
251248   AM_RANGE(0xc0001c, 0xc0001d) AM_WRITE(soundcmd_w)
252249   AM_RANGE(0xc0001e, 0xc0001f) AM_WRITE(protection_w)
253250   AM_RANGE(0xff8000, 0xffdfff) AM_RAM
254   AM_RANGE(0xffe000, 0xffffff) AM_RAM AM_BASE(&sf_objectram)
251   AM_RANGE(0xffe000, 0xffffff) AM_RAM AM_BASE_MEMBER(sf_state, objectram)
255252ADDRESS_MAP_END
256253
257254static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
r6740r6741
786783
787784
788785
789static void irq_handler(const device_config *device, int irq)
786static void irq_handler( const device_config *device, int irq )
790787{
791   cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE);
788   sf_state *state = (sf_state *)device->machine->driver_data;
789   cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE);
792790}
793791
794792static const ym2151_interface ym2151_config =
r6740r6741
802800   MSM5205_SEX_4B   /* 8KHz playback ?    */
803801};
804802
803static MACHINE_START( sf )
804{
805   sf_state *state = (sf_state *)machine->driver_data;
806
807   /* devices */
808   state->maincpu = devtag_get_device(machine, "maincpu");
809   state->audiocpu = devtag_get_device(machine, "audiocpu");
810
811   state_save_register_global(machine, state->sf_active);
812   state_save_register_global(machine, state->bgscroll);
813   state_save_register_global(machine, state->fgscroll);
814}
815
816static MACHINE_RESET( sf )
817{
818   sf_state *state = (sf_state *)machine->driver_data;
819
820   state->sf_active = 0;
821   state->bgscroll = 0;
822   state->fgscroll = 0;
823}
824
805825static MACHINE_DRIVER_START( sf )
806826
827   /* driver data */
828   MDRV_DRIVER_DATA(sf_state)
829
807830   /* basic machine hardware */
808831   MDRV_CPU_ADD("maincpu", M68000, 8000000)   /* 8 MHz ? (xtal is 16MHz) */
809832   MDRV_CPU_PROGRAM_MAP(sf_map)
r6740r6741
813836   MDRV_CPU_PROGRAM_MAP(sound_map)
814837                        /* NMIs are caused by the main CPU */
815838
839   MDRV_MACHINE_START(sf)
840   MDRV_MACHINE_RESET(sf)
841
816842   MDRV_CPU_ADD("audio2", Z80, 3579545)   /* ? xtal is 3.579545MHz */
817843   MDRV_CPU_PROGRAM_MAP(sound2_map)
818844   MDRV_CPU_IO_MAP(sound2_io_map)
r6740r6741
11331159
11341160
11351161
1136GAME( 1987, sf,   0,  sf,   sf,   0, ROT0, "Capcom", "Street Fighter (World)", 0 )
1137GAME( 1987, sfus, sf, sfus, sfus, 0, ROT0, "Capcom", "Street Fighter (US)", 0 )
1138GAME( 1987, sfj, sf, sfjp, sfjp, 0, ROT0, "Capcom", "Street Fighter (Japan)", 0 )
1139GAME( 1987, sfp,  sf, sfp,  sf,   0, ROT0, "Capcom", "Street Fighter (prototype)", 0 )
1162GAME( 1987, sf,   0,  sf,   sf,   0, ROT0, "Capcom", "Street Fighter (World)", GAME_SUPPORTS_SAVE )
1163GAME( 1987, sfus, sf, sfus, sfus, 0, ROT0, "Capcom", "Street Fighter (US)", GAME_SUPPORTS_SAVE )
1164GAME( 1987, sfj,  sf, sfjp, sfjp, 0, ROT0, "Capcom", "Street Fighter (Japan)", GAME_SUPPORTS_SAVE )
1165GAME( 1987, sfp,  sf, sfp,  sf,   0, ROT0, "Capcom", "Street Fighter (prototype)", GAME_SUPPORTS_SAVE )
src/mame/drivers/cave.c
r6740r6741
7373#include "machine/eeprom.h"
7474#include "machine/nmk112.h"
7575#include "cpu/z80/z80.h"
76#include "cave.h"
76#include "includes/cave.h"
7777#include "sound/2203intf.h"
7878#include "sound/2151intf.h"
7979#include "sound/okim6295.h"
src/mame/drivers/williams.c
r6740r6741
497497#include "sound/dac.h"
498498#include "sound/hc55516.h"
499499#include "machine/6821pia.h"
500#include "machine/ticket.h"
500501#include "audio/williams.h"
501#include "williams.h"
502#include "includes/williams.h"
502503
503504
504505#define MASTER_CLOCK      (12000000)
505506#define SOUND_CLOCK         (3579000)
506507
508
509
507510/*************************************
508511 *
509512 *  Defender memory handlers
r6740r6741
12371240   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT )
12381241   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START1 )
12391242   PORT_BIT( 0x60, IP_ACTIVE_HIGH, IPT_UNKNOWN )
1240   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* Used by ticket dispenser */
1243   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE("ticket", ticket_dispenser_line_r)
12411244
12421245   PORT_START("IN1")
12431246   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNKNOWN )
r6740r6741
14321435   MDRV_CPU_ADD("soundcpu", M6808, SOUND_CLOCK)
14331436   MDRV_CPU_PROGRAM_MAP(defender_sound_map)
14341437
1438   MDRV_MACHINE_START(defender)
14351439   MDRV_MACHINE_RESET(defender)
14361440   MDRV_NVRAM_HANDLER(generic_0fill)
14371441
1442   MDRV_TIMER_ADD("scan_timer", williams_va11_callback)
1443   MDRV_TIMER_ADD("240_timer", williams_count240_callback)
1444
14381445   /* video hardware */
14391446   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_SCANLINE)
14401447
r6740r6741
14771484   MDRV_CPU_MODIFY("soundcpu")
14781485   MDRV_CPU_PROGRAM_MAP(sound_map)
14791486
1487   MDRV_MACHINE_START(williams)
14801488   MDRV_MACHINE_RESET(williams)
14811489   MDRV_SCREEN_MODIFY("screen")
14821490   MDRV_SCREEN_VISIBLE_AREA(6, 298-1, 7, 247-1)
r6740r6741
15201528
15211529   /* pia */
15221530   MDRV_PIA6821_MODIFY("pia_0", lottofun_pia_0_intf)
1531   MDRV_TICKET_DISPENSER_ADD("ticket", 70, TICKET_MOTOR_ACTIVE_LOW, TICKET_STATUS_ACTIVE_HIGH)
15231532MACHINE_DRIVER_END
15241533
15251534
r6740r6741
15311540   MDRV_CPU_MODIFY("maincpu")
15321541   MDRV_CPU_PROGRAM_MAP(williams_map)
15331542
1543   MDRV_MACHINE_START(williams)
15341544   MDRV_MACHINE_RESET(williams)
15351545   MDRV_SCREEN_MODIFY("screen")
15361546   MDRV_SCREEN_VISIBLE_AREA(6, 298-1, 7, 247-1)
r6740r6741
15821592   MDRV_CPU_MODIFY("maincpu")
15831593   MDRV_CPU_PROGRAM_MAP(blaster_map)
15841594
1595   MDRV_MACHINE_START(blaster)
15851596   MDRV_MACHINE_RESET(blaster)
15861597
15871598   /* video hardware */
r6740r6741
16121623   MDRV_CPU_ADD("soundcpu", M6808, MASTER_CLOCK/3)   /* yes, this is different from the older games */
16131624   MDRV_CPU_PROGRAM_MAP(williams2_sound_map)
16141625
1626   MDRV_MACHINE_START(williams2)
16151627   MDRV_MACHINE_RESET(williams2)
16161628   MDRV_NVRAM_HANDLER(generic_0fill)
16171629
1630   MDRV_TIMER_ADD("scan_timer", williams2_va11_callback)
1631   MDRV_TIMER_ADD("254_timer", williams2_endscreen_callback)
1632
16181633   /* video hardware */
16191634   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_SCANLINE)
16201635   MDRV_PALETTE_LENGTH(1024)
src/mame/drivers/fuukifg3.c
r6740r6741
152152#include "cpu/z80/z80.h"
153153#include "cpu/m68000/m68000.h"
154154#include "sound/ymf278b.h"
155#include "fuukifg3.h"
155#include "includes/fuukifg3.h"
156156
157157
158158static WRITE32_HANDLER( paletteram32_xRRRRRGGGGGBBBBB_dword_w )
src/mame/drivers/battlane.c
r6740r6741
1212#include "driver.h"
1313#include "cpu/m6809/m6809.h"
1414#include "sound/3526intf.h"
15#include "battlane.h"
15#include "includes/battlane.h"
1616
1717/*************************************
1818 *
src/mame/drivers/atarigt.c
r6740r6741
2323#include "video/atarirle.h"
2424#include "cpu/m68000/m68000.h"
2525#include "audio/cage.h"
26#include "atarigt.h"
26#include "includes/atarigt.h"
2727
2828
2929#define LOG_PROTECTION      (0)
r6740r6741
5656}
5757
5858
59static MACHINE_START( atarigt )
60{
61   atarigen_init(machine);
62}
63
64
5965static MACHINE_RESET( atarigt )
6066{
6167   atarigt_state *state = (atarigt_state *)machine->driver_data;
r6740r6741
793799   MDRV_CPU_VBLANK_INT("screen", atarigen_video_int_gen)
794800   MDRV_CPU_PERIODIC_INT(atarigen_scanline_int_gen, 250)
795801
802   MDRV_MACHINE_START(atarigt)
796803   MDRV_MACHINE_RESET(atarigt)
797804   MDRV_NVRAM_HANDLER(atarigen)
798805
src/mame/drivers/crimfght.c
r6740r6741
1414#include "driver.h"
1515#include "cpu/z80/z80.h"
1616#include "cpu/konami/konami.h" /* for the callback and the firq irq definition */
17#include "video/konamiic.h"
17#include "video/konicdev.h"
1818#include "sound/2151intf.h"
1919#include "sound/k007232.h"
20#include "konamipt.h"
20#include "includes/konamipt.h"
2121
2222/* prototypes */
2323static MACHINE_RESET( crimfght );
2424static KONAMI_SETLINES_CALLBACK( crimfght_banking );
2525
26extern void crimfght_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
27extern void crimfght_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow);
28
2629VIDEO_START( crimfght );
2730VIDEO_UPDATE( crimfght );
2831
r6740r6741
4952   k007232_set_bank( devtag_get_device(device->machine, "konami"), bank_A, bank_B );
5053}
5154
55static READ8_HANDLER( k052109_051960_r )
56{
57   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
58   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
5259
60   if (k052109_get_rmrd_line(k052109) == CLEAR_LINE)
61   {
62      if (offset >= 0x3800 && offset < 0x3808)
63         return k051937_r(k051960, offset - 0x3800);
64      else if (offset < 0x3c00)
65         return k052109_r(k052109, offset);
66      else
67         return k051960_r(k051960, offset - 0x3c00);
68   }
69   else
70      return k052109_r(k052109, offset);
71}
72
73static WRITE8_HANDLER( k052109_051960_w )
74{
75   const device_config *k052109 = devtag_get_device(space->machine, "k052109");
76   const device_config *k051960 = devtag_get_device(space->machine, "k051960");
77
78   if (offset >= 0x3800 && offset < 0x3808)
79      k051937_w(k051960, offset - 0x3800, data);
80   else if (offset < 0x3c00)
81      k052109_w(k052109, offset, data);
82   else
83      k051960_w(k051960, offset - 0x3c00, data);
84}
85
5386/********************************************/
5487
5588static ADDRESS_MAP_START( crimfght_map, ADDRESS_SPACE_PROGRAM, 8 )
r6740r6741
6598   AM_RANGE(0x3f87, 0x3f87) AM_READ_PORT("DSW1")
6699   AM_RANGE(0x3f88, 0x3f88) AM_READWRITE(watchdog_reset_r, crimfght_coin_w)   /* watchdog reset */
67100   AM_RANGE(0x3f8c, 0x3f8c) AM_WRITE(crimfght_sh_irqtrigger_w)   /* cause interrupt on audio CPU? */
68   AM_RANGE(0x2000, 0x5fff) AM_READWRITE(K052109_051960_r, K052109_051960_w)   /* video RAM + sprite RAM */
101   AM_RANGE(0x2000, 0x5fff) AM_READWRITE(k052109_051960_r, k052109_051960_w)   /* video RAM + sprite RAM */
69102   AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank2")                  /* banked ROM */
70103   AM_RANGE(0x8000, 0xffff) AM_ROM                                    /* ROM */
71104ADDRESS_MAP_END
r6740r6741
212245
213246
214247
248static const k052109_interface crimfght_k052109_intf =
249{
250   "gfx1", 0,
251   NORMAL_PLANE_ORDER,
252   KONAMI_ROM_DEINTERLEAVE_2,
253   crimfght_tile_callback
254};
255
256static const k051960_interface crimfght_k051960_intf =
257{
258   "gfx2", 1,
259   NORMAL_PLANE_ORDER,
260   KONAMI_ROM_DEINTERLEAVE_2,
261   crimfght_sprite_callback
262};
263
215264static MACHINE_DRIVER_START( crimfght )
216265
217266   /* basic machine hardware */
r6740r6741
239288   MDRV_VIDEO_START(crimfght)
240289   MDRV_VIDEO_UPDATE(crimfght)
241290
291   MDRV_K052109_ADD("k052109", crimfght_k052109_intf)
292   MDRV_K051960_ADD("k051960", crimfght_k051960_intf)
293
242294   /* sound hardware */
243295   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
244296
r6740r6741
338390
339391static KONAMI_SETLINES_CALLBACK( crimfght_banking )
340392{
393   const device_config *k052109 = devtag_get_device(device->machine, "k052109");
341394   UINT8 *RAM = memory_region(device->machine, "maincpu");
342395   int offs = 0;
343396
r6740r6741
352405      memory_install_readwrite_bank(cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM), 0x0000, 0x03ff, 0, 0, "bank1");                        /* RAM */
353406
354407   /* bit 6 = enable char ROM reading through the video RAM */
355   K052109_set_RMRD_line((lines & 0x40) ? ASSERT_LINE : CLEAR_LINE);
408   k052109_set_rmrd_line(k052109, (lines & 0x40) ? ASSERT_LINE : CLEAR_LINE);
356409
357410   offs = 0x10000 + ((lines & 0x0f) * 0x2000);
358411   memory_set_bankptr(device->machine, "bank2", &RAM[offs]);
r6740r6741
368421   memory_set_bankptr(machine,  "bank2", &RAM[0x10000] );
369422}
370423
371static DRIVER_INIT( crimfght )
372{
373   konami_rom_deinterleave_2(machine, "gfx1");
374   konami_rom_deinterleave_2(machine, "gfx2");
375}
376
377
378
379GAME( 1989, crimfght, 0,        crimfght, crimfght, crimfght, ROT0, "Konami", "Crime Fighters (US 4 players)", 0 )
380GAME( 1989, crimfght2,crimfght, crimfght, crimfgtj, crimfght, ROT0, "Konami", "Crime Fighters (World 2 Players)", 0 )
381GAME( 1989, crimfghtj,crimfght, crimfght, crimfgtj, crimfght, ROT0, "Konami", "Crime Fighters (Japan 2 Players)", 0 )
424GAME( 1989, crimfght, 0,        crimfght, crimfght, 0, ROT0, "Konami", "Crime Fighters (US 4 players)", 0 )
425GAME( 1989, crimfght2,crimfght, crimfght, crimfgtj, 0, ROT0, "Konami", "Crime Fighters (World 2 Players)", 0 )
426GAME( 1989, crimfghtj,crimfght, crimfght, crimfgtj, 0, ROT0, "Konami", "Crime Fighters (Japan 2 Players)", 0 )
src/mame/drivers/triplhnt.c
r6740r6741
1212
1313#include "driver.h"
1414#include "cpu/m6800/m6800.h"
15#include "triplhnt.h"
15#include "includes/triplhnt.h"
1616
1717static UINT8 triplhnt_cmos[16];
1818static UINT8 triplhnt_da_latch;
src/mame/drivers/asuka.c
r6740r6741
215215#include "driver.h"
216216#include "cpu/z80/z80.h"
217217#include "cpu/m68000/m68000.h"
218#include "taitoipt.h"
218#include "includes/taitoipt.h"
219219#include "video/taitoic.h"
220220#include "audio/taitosnd.h"
221221#include "sound/2610intf.h"
src/mame/drivers/rollerg.c
r6740r6741
1212
1313#include "driver.h"
1414#include "cpu/z80/z80.h"
15#include "video/konamiic.h"
15#include "video/konicdev.h"
1616#include "cpu/konami/konami.h" /* for the callback and the firq irq definition */
17#include "machine/eeprom.h"
1817#include "sound/3812intf.h"
1918#include "sound/k053260.h"
2019
r6740r6741
2524VIDEO_START( rollerg );
2625VIDEO_UPDATE( rollerg );
2726
27extern void rollerg_sprite_callback(running_machine *machine, int *code,int *color,int *priority_mask);
28extern void rollerg_zoom_callback(running_machine *machine, int *code,int *color,int *flags);
2829
29
3030static int readzoomroms;
3131
3232static WRITE8_HANDLER( rollerg_0010_w )
3333{
34logerror("%04x: write %02x to 0010\n",cpu_get_pc(space->cpu),data);
34   const device_config *k051316 = devtag_get_device(space->machine, "k051316");
35   logerror("%04x: write %02x to 0010\n",cpu_get_pc(space->cpu),data);
3536
3637   /* bits 0/1 are coin counters */
3738   coin_counter_w(space->machine, 0,data & 0x01);
r6740r6741
4142   readzoomroms = data & 0x04;
4243
4344   /* bit 5 enables 051316 wraparound */
44   K051316_wraparound_enable(0, data & 0x20);
45   k051316_wraparound_enable(k051316, data & 0x20);
4546
4647   /* other bits unknown */
4748}
4849
4950static READ8_HANDLER( rollerg_K051316_r )
5051{
51   if (readzoomroms) return K051316_rom_0_r(space, offset);
52   else return K051316_0_r(space, offset);
52   const device_config *k051316 = devtag_get_device(space->machine, "k051316");
53   if (readzoomroms)
54      return k051316_rom_r(k051316, offset);
55   else
56      return k051316_r(k051316, offset);
5357}
5458
5559static READ8_DEVICE_HANDLER( rollerg_sound_r )
r6740r6741
9296   AM_RANGE(0x0060, 0x0060) AM_READ_PORT("DSW2")
9397   AM_RANGE(0x0061, 0x0061) AM_READ(pip_r)            /* ????? */
9498   AM_RANGE(0x0100, 0x010f) AM_WRITENOP   /* 053252? */
95   AM_RANGE(0x0200, 0x020f) AM_WRITE(K051316_ctrl_0_w)
96   AM_RANGE(0x0300, 0x030f) AM_READWRITE(K053244_r,K053244_w)
97   AM_RANGE(0x0800, 0x0fff) AM_READWRITE(rollerg_K051316_r,K051316_0_w)
98   AM_RANGE(0x1000, 0x17ff) AM_READWRITE(K053245_r,K053245_w)
99   AM_RANGE(0x0200, 0x020f) AM_DEVWRITE("k051316", k051316_ctrl_w)
100   AM_RANGE(0x0300, 0x030f) AM_DEVREADWRITE("k053244", k053244_r, k053244_w)
101   AM_RANGE(0x0800, 0x0fff) AM_READ(rollerg_K051316_r) AM_DEVWRITE("k051316", k051316_w)
102   AM_RANGE(0x1000, 0x17ff) AM_DEVREADWRITE("k053244", k053245_r, k053245_w)
99103   AM_RANGE(0x1800, 0x1fff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_be_w) AM_BASE_GENERIC(paletteram)
100104   AM_RANGE(0x2000, 0x3aff) AM_RAM
101105   AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1")
r6740r6741
217221
218222***************************************************************************/
219223
224static const k05324x_interface rollerg_k05324x_intf =
225{
226   "gfx1", 0,
227   NORMAL_PLANE_ORDER,
228   -3, -1,
229   KONAMI_ROM_DEINTERLEAVE_2,
230   rollerg_sprite_callback
231};
232
233static const k051316_interface rollerg_k051316_intf =
234{
235   "gfx2", 1,
236   4, FALSE, 0,
237   0, 22, 1,
238   rollerg_zoom_callback
239};
240
220241static MACHINE_DRIVER_START( rollerg )
221242
222243   /* basic machine hardware */
r6740r6741
244265   MDRV_VIDEO_START(rollerg)
245266   MDRV_VIDEO_UPDATE(rollerg)
246267
268   MDRV_K053244_ADD("k053244", rollerg_k05324x_intf)
269   MDRV_K051316_ADD("k051316", rollerg_k051316_intf)
270
247271   /* sound hardware */
248272   MDRV_SPEAKER_STANDARD_MONO("mono")
249273
r6740r6741
328352   readzoomroms = 0;
329353}
330354
331static DRIVER_INIT( rollerg )
332{
333   konami_rom_deinterleave_2(machine, "gfx1");
334}
335355
336
337
338GAME( 1991, rollerg,  0,       rollerg, rollerg, rollerg, ROT0, "Konami", "Rollergames (US)", 0 )
339GAME( 1991, rollergj, rollerg, rollerg, rollerg, rollerg, ROT0, "Konami", "Rollergames (Japan)", 0 )
356GAME( 1991, rollerg,  0,       rollerg, rollerg, 0, ROT0, "Konami", "Rollergames (US)", 0 )
357GAME( 1991, rollergj, rollerg, rollerg, rollerg, 0, ROT0, "Konami", "Rollergames (Japan)", 0 )
src/mame/drivers/hvyunit.c
r6740r6741
6060#include "sound/2203intf.h"
6161#include "video/kan_pand.h"
6262
63static UINT8 *videoram;
64static UINT8 *colorram;
6365static tilemap *bg_tilemap;
6466static UINT16 hu_scrollx, hu_scrolly;
6567static UINT16 port0_data;
r6740r6741
276278
277279static TILE_GET_INFO( get_bg_tile_info )
278280{
279   int attr = machine->generic.colorram.u8[tile_index];
280   int code = machine->generic.videoram.u8[tile_index] + ((attr & 0x0f) << 8);
281   int attr = colorram[tile_index];
282   int code = videoram[tile_index] + ((attr & 0x0f) << 8);
281283   int color = (attr >> 4);
282284
283285   SET_TILE_INFO(1, code, color, 0);
r6740r6741
336338
337339static WRITE8_HANDLER( hu_videoram_w )
338340{
339   space->machine->generic.videoram.u8[offset] = data;
341   videoram[offset] = data;
340342   tilemap_mark_tile_dirty(bg_tilemap, offset);
341343}
342344
343345static WRITE8_HANDLER( hu_colorram_w )
344346{
345   space->machine->generic.colorram.u8[offset] = data;
347   colorram[offset] = data;
346348   tilemap_mark_tile_dirty(bg_tilemap, offset);
347349}
348350
r6740r6741
385387static ADDRESS_MAP_START( slave_memory, ADDRESS_SPACE_PROGRAM, 8 )
386388   AM_RANGE(0x0000, 0x7fff) AM_ROM
387389   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank2")
388   AM_RANGE(0xc000, 0xc3ff) AM_RAM_WRITE(hu_videoram_w) AM_BASE_GENERIC(videoram)
389   AM_RANGE(0xc400, 0xc7ff) AM_RAM_WRITE(hu_colorram_w) AM_BASE_GENERIC(colorram)
390   AM_RANGE(0xc000, 0xc3ff) AM_RAM_WRITE(hu_videoram_w) AM_BASE(&videoram)
391   AM_RANGE(0xc400, 0xc7ff) AM_RAM_WRITE(hu_colorram_w) AM_BASE(&colorram)
390392   AM_RANGE(0xd000, 0xd1ff) AM_RAM_WRITE(paletteram_xxxxRRRRGGGGBBBB_split2_w) AM_BASE_GENERIC(paletteram2)
391393   AM_RANGE(0xd800, 0xd9ff) AM_RAM_WRITE(paletteram_xxxxRRRRGGGGBBBB_split1_w) AM_BASE_GENERIC(paletteram)
392394   AM_RANGE(0xd000, 0xdfff) AM_RAM
src/mame/drivers/pirates.c
r6740r6741
146146static CUSTOM_INPUT( prot_r )
147147{
148148//  static int prot = 0xa3;
149//  offs_t pc;
149150   int bit;
150151
151152//  logerror("%s: IN1_r\n",cpuexec_describe_context(field->port->machine));
r6740r6741
155156       602e and 62a6 */
156157   /* For Genix, see 6576 for setting values and 67c2,d3b4 and dbc2 for tests. */
157158
158   if (cpu_get_pc(cputag_get_cpu(field->port->machine, "main")) == 0x6134)
159   pc = cpu_get_pc(cputag_get_cpu(field->port->machine, "main"));
160   if (pc == 0x6134)
159161   {
160162      bit = prot & 1;
161163      prot = (prot >> 1) | (bit << 7);
162164   }
163   else if (cputag_get_cpu(field->port->machine, "main")) == 0x6020)
165   else if (pc == 0x6020)
164166      bit = 0;
165   else if (cputag_get_cpu(field->port->machine, "main")) == 0x6168)
167   else if (pc == 0x6168)
166168      bit = 0;
167   else if (cputag_get_cpu(field->port->machine, "main")) == 0x61cc)
169   else if (pc == 0x61cc)
168170      bit = 1;
169171   else
170172#endif
src/mame/drivers/subs.c
r6740r6741
2020#include "driver.h"
2121#include "cpu/m6502/m6502.h"
2222#include "deprecat.h"
23#include "subs.h"
23#include "includes/subs.h"
2424#include "sound/discrete.h"
2525#include "rendlay.h"
2626
src/mame/drivers/crospang.c
r6740r6741
3333#include "cpu/m68000/m68000.h"
3434#include "sound/okim6295.h"
3535#include "sound/3812intf.h"
36#include "crospang.h"
36#include "includes/crospang.h"
3737
3838
3939static WRITE16_HANDLER ( crospang_soundlatch_w )
src/mame/drivers/ajax.c
r6740r6741
1414#include "cpu/z80/z80.h"
1515#include "cpu/m6809/m6809.h"
1616#include "cpu/konami/konami.h"
17#include "video/konamiic.h"
17#include "video/konicdev.h"
1818#include "sound/2151intf.h"
1919#include "sound/k007232.h"
2020#include "includes/ajax.h"
21#include "konamipt.h"
21#include "includes/konamipt.h"
2222
2323static WRITE8_DEVICE_HANDLER( k007232_extvol_w );
2424static WRITE8_HANDLER( sound_bank_w );
2525
26extern void ajax_tile_callback(running_machine *machine, int layer,int bank,int *code,int *color,int *flags,int *priority);
27extern void ajax_sprite_callback(running_machine *machine, int *code,int *color,int *priority,int *shadow);
28extern void ajax_zoom_callback(running_machine *machine, int *code,int *color,int *flags);
29
30
2631/****************************************************************************/
2732
2833static ADDRESS_MAP_START( ajax_main_map, ADDRESS_SPACE_PROGRAM, 8 )
2934   AM_RANGE(0x0000, 0x01c0) AM_READWRITE(ajax_ls138_f10_r, ajax_ls138_f10_w)   /* bankswitch + sound command + FIRQ command */
30   AM_RANGE(0x0800, 0x0807) AM_READWRITE(K051937_r, K051937_w)               /* sprite control registers */
31   AM_RANGE(0x0c00, 0x0fff) AM_READWRITE(K051960_r, K051960_w)               /* sprite RAM 2128SL at J7 */
35   AM_RANGE(0x0800, 0x0807) AM_DEVREADWRITE("k051960", k051937_r, k051937_w)               /* sprite control registers */
36   AM_RANGE(0x0c00, 0x0fff) AM_DEVREADWRITE("k051960", k051960_r, k051960_w)               /* sprite RAM 2128SL at J7 */
3237   AM_RANGE(0x1000, 0x1fff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_be_w) AM_BASE_GENERIC(paletteram)/* palette */
3338   AM_RANGE(0x2000, 0x3fff) AM_RAM AM_SHARE("share1")                           /* shared RAM with the 6809 */
3439   AM_RANGE(0x4000, 0x5fff) AM_RAM                                    /* RAM 6264L at K10 */
r6740r6741
3742ADDRESS_MAP_END
3843
3944static ADDRESS_MAP_START( ajax_sub_map, ADDRESS_SPACE_PROGRAM, 8 )
40   AM_RANGE(0x0000, 0x07ff) AM_READWRITE(K051316_0_r, K051316_0_w)   /* 051316 zoom/rotation layer */
41   AM_RANGE(0x0800, 0x080f) AM_WRITE(K051316_ctrl_0_w)            /* 051316 control registers */
42   AM_RANGE(0x1000, 0x17ff) AM_READ(K051316_rom_0_r)            /* 051316 (ROM test) */
45   AM_RANGE(0x0000, 0x07ff) AM_DEVREADWRITE("k051316", k051316_r, k051316_w)   /* 051316 zoom/rotation layer */
46   AM_RANGE(0x0800, 0x080f) AM_DEVWRITE("k051316", k051316_ctrl_w)            /* 051316 control registers */
47   AM_RANGE(0x1000, 0x17ff) AM_DEVREAD("k051316", k051316_rom_r)            /* 051316 (ROM test) */
4348   AM_RANGE(0x1800, 0x1800) AM_WRITE(ajax_bankswitch_2_w)         /* bankswitch control */
4449   AM_RANGE(0x2000, 0x3fff) AM_RAM AM_SHARE("share1")                  /* shared RAM with the 052001 */
45   AM_RANGE(0x4000, 0x7fff) AM_READWRITE(K052109_r, K052109_w)      /* video RAM + color RAM + video registers */
50   AM_RANGE(0x4000, 0x7fff) AM_DEVREADWRITE("k052109", k052109_r, k052109_w)      /* video RAM + color RAM + video registers */
4651   AM_RANGE(0x8000, 0x9fff) AM_ROMBANK("bank1")                     /* banked ROM */
4752   AM_RANGE(0xa000, 0xffff) AM_ROM                           /* ROM I16 */
4853ADDRESS_MAP_END
r6740r6741
180185
181186
182187
188static const k052109_interface ajax_k052109_intf =
189{
190   "gfx1", 0,
191   NORMAL_PLANE_ORDER,
192   KONAMI_ROM_DEINTERLEAVE_2,
193   ajax_tile_callback
194};
195
196static const k051960_interface ajax_k051960_intf =
197{
198   "gfx2", 1,
199   NORMAL_PLANE_ORDER,
200   KONAMI_ROM_DEINTERLEAVE_2,
201   ajax_sprite_callback
202};
203
204static const k051316_interface ajax_k051316_intf =
205{
206   "gfx3", 2,
207   7, FALSE, 0,
208   0, 0, 0,
209   ajax_zoom_callback
210};
211
183212static MACHINE_DRIVER_START( ajax )
184213
185214   /* basic machine hardware */
r6740r6741
196225   MDRV_QUANTUM_TIME(HZ(600))
197226
198227   MDRV_MACHINE_RESET(ajax)
199    MDRV_MACHINE_START(ajax)
228   MDRV_MACHINE_START(ajax)
200229
201230   /* video hardware */
202231   MDRV_VIDEO_ATTRIBUTES(VIDEO_HAS_SHADOWS)
r6740r6741
212241   MDRV_VIDEO_START(ajax)
213242   MDRV_VIDEO_UPDATE(ajax)
214243
244   MDRV_K052109_ADD("k052109", ajax_k052109_intf)
245   MDRV_K051960_ADD("k051960", ajax_k051960_intf)
246   MDRV_K051316_ADD("k051316", ajax_k051316_intf)
247
215248   /* sound hardware */
216249   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
217250
r6740r6741
383416ROM_END
384417
385418
386static DRIVER_INIT( ajax )
387{
388   konami_rom_deinterleave_2(machine, "gfx1");
389   konami_rom_deinterleave_2(machine, "gfx2");
390}
391
392
393GAME( 1987, ajax,    0,    ajax, ajax, ajax, ROT90, "Konami", "Ajax", GAME_SUPPORTS_SAVE )
394GAME( 1987, typhoon, ajax, ajax, ajax, ajax, ROT90, "Konami", "Typhoon", GAME_SUPPORTS_SAVE )
395GAME( 1987, ajaxj,   ajax, ajax, ajax, ajax, ROT90, "Konami", "Ajax (Japan)", GAME_SUPPORTS_SAVE )
419GAME( 1987, ajax,    0,    ajax, ajax, 0, ROT90, "Konami", "Ajax", GAME_SUPPORTS_SAVE )
420GAME( 1987, typhoon, ajax, ajax, ajax, 0, ROT90, "Konami", "Typhoon", GAME_SUPPORTS_SAVE )
421GAME( 1987, ajaxj,   ajax, ajax, ajax, 0, ROT90, "Konami", "Ajax (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/funybubl.c
r6740r6741
5151#include "driver.h"
5252#include "cpu/z80/z80.h"
5353#include "sound/okim6295.h"
54#include "funybubl.h"
54#include "includes/funybubl.h"
5555
5656
5757static WRITE8_HANDLER ( funybubl_vidram_bank_w )
src/mame/drivers/shisen.c
r6740r6741
229229   MDRV_CPU_VBLANK_INT_HACK(nmi_line_pulse,128)   /* clocked by V1? (Vigilante) */
230230                        /* IRQs are generated by main Z80 and YM2151 */
231231
232   MDRV_MACHINE_RESET(m72_sound)
232   MDRV_SOUND_START(m72)
233   MDRV_SOUND_RESET(m72)
233234
234235   /* video hardware */
235236   MDRV_SCREEN_ADD("screen", RASTER)
src/mame/drivers/miniboy7.c
r6740r6741
132132*     Video Hardware     *
133133*************************/
134134
135static UINT8 *videoram;
136static UINT8 *colorram;
135137static tilemap *bg_tilemap;
136138
137139static WRITE8_HANDLER( miniboy7_videoram_w )
138140{
139   space->machine->generic.videoram.u8[offset] = data;
141   videoram[offset] = data;
140142   tilemap_mark_tile_dirty(bg_tilemap, offset);
141143}
142144
143145static WRITE8_HANDLER( miniboy7_colorram_w )
144146{
145   space->machine->generic.colorram.u8[offset] = data;
147   colorram[offset] = data;
146148   tilemap_mark_tile_dirty(bg_tilemap, offset);
147149}
148150
r6740r6741
154156    ---- --x-   tiles bank.
155157    xx-- ---x   seems unused. */
156158
157   int attr = machine->generic.colorram.u8[tile_index];
158   int code = machine->generic.videoram.u8[tile_index];
159   int attr = colorram[tile_index];
160   int code = videoram[tile_index];
159161   int bank = (attr & 0x02) >> 1;   /* bit 1 switch the gfx banks */
160162   int color = (attr & 0x3c);   /* bits 2-3-4-5 for color? */
161163
r6740r6741
183185
184186static ADDRESS_MAP_START( miniboy7_map, ADDRESS_SPACE_PROGRAM, 8 )
185187   AM_RANGE(0x0000, 0x07ff) AM_RAM   /* battery backed RAM? */
186   AM_RANGE(0x0800, 0x0fff) AM_RAM_WRITE(miniboy7_videoram_w) AM_BASE_GENERIC(videoram)
187   AM_RANGE(0x1000, 0x17ff) AM_RAM_WRITE(miniboy7_colorram_w) AM_BASE_GENERIC(colorram)
188   AM_RANGE(0x0800, 0x0fff) AM_RAM_WRITE(miniboy7_videoram_w) AM_BASE(&videoram)
189   AM_RANGE(0x1000, 0x17ff) AM_RAM_WRITE(miniboy7_colorram_w) AM_BASE(&colorram)
188190   AM_RANGE(0x1800, 0x25ff) AM_RAM   /* looks like videoram */
189191   AM_RANGE(0x2600, 0x27ff) AM_RAM
190192   AM_RANGE(0x2800, 0x2800) AM_DEVWRITE("crtc", mc6845_address_w)
src/mame/drivers/m10.c
r6740r6741
115115#include "machine/rescap.h"
116116#include "sound/samples.h"
117117#include "machine/74123.h"
118#include "m10.h"
118#include "includes/m10.h"
119119
120120
121121/*************************************
src/tools/src2html.c
r6740r6741
590590      int quotes_are_linked = FALSE;
591591      char in_quotes = 0;
592592      int curcol = 0;
593      int escape = 0;
593594
594595      /* start with the line number */
595596      dstptr += sprintf(dstptr, "<span class=\"linenum\">%5d</span>&nbsp;&nbsp;", linenum++);
r6740r6741
704705            }
705706
706707            /* track closing quotes */
707            else if (!in_comment && !in_inline_comment && in_quotes && ch == in_quotes && (type != FILE_TYPE_C || srcptr[-2] != '\\' || srcptr[-3] == '\\'))
708            else if (!in_comment && !in_inline_comment && in_quotes && ch == in_quotes && !escape)
708709            {
709710               if (quotes_are_linked)
710711                  dstptr += sprintf(dstptr, "</a>");
r6740r6741
727728               *dstptr++ = ch;
728729            curcol++;
729730         }
731
732         /* Update escape state */
733         if (in_quotes)
734            escape = (ch == '\\' && type == FILE_TYPE_C) ? !escape : 0;
730735      }
731736
732737      /* finish inline comments */
src/tools/unidasm.c
r6740r6741
166166CPU_DISASSEMBLE( tx0_64kw );
167167CPU_DISASSEMBLE( tx0_8kw );
168168CPU_DISASSEMBLE( pic16c5x );
169CPU_DISASSEMBLE( pic16c62x );
169170CPU_DISASSEMBLE( powerpc );
170171CPU_DISASSEMBLE( rsp );
171172CPU_DISASSEMBLE( s2650 );
r6740r6741
291292   { "tx0_64kw",   _32be, -2, CPU_DISASSEMBLE_NAME(tx0_64kw) },
292293   { "tx0_8kw",    _32be, -2, CPU_DISASSEMBLE_NAME(tx0_8kw) },
293294   { "pic16c5x",   _16le, -1, CPU_DISASSEMBLE_NAME(pic16c5x) },
295   { "pic16c62x",  _16le, -1, CPU_DISASSEMBLE_NAME(pic16c62x) },
294296   { "powerpc",    _32be,  0, CPU_DISASSEMBLE_NAME(powerpc) },
295297   { "rsp",        _32le,  0, CPU_DISASSEMBLE_NAME(rsp) },
296298   { "s2650",      _8bit,  0, CPU_DISASSEMBLE_NAME(s2650) },
src/tools/srcclean.c
r6740r6741
128128
129129         if (!in_c_string && !in_cpp_comment)
130130         {
131            int consume = TRUE;
132
131133            /* track whether or not we are within a C-style comment */
132134            if (!in_c_comment && ch == '/' && original[src] == '*')
133135               in_c_comment = TRUE;
r6740r6741
135137               in_c_comment = FALSE;
136138
137139            /* track whether or not we are within a C++-style comment */
138            if (!in_c_comment && ch == '/' && original[src] == '/')
140            else if (!in_c_comment && ch == '/' && original[src] == '/')
139141               in_cpp_comment = TRUE;
142            else
143               consume = FALSE;
144
145            if (consume)
146            {
147               modified[dst++] = ch;
148               col++;
149               ch = original[src++];
150            }
140151         }
141152      }
142153
src/osd/windows/winwork.c
r6740r6741
174174   volatile INT32      done;         // is the item done?
175175};
176176
177//============================================================
178//  GLOBAL VARIABLES
179//============================================================
177180
181int osd_num_processors = 0;
178182
179183//============================================================
180184//  FUNCTION PROTOTYPES
r6740r6741
677681
678682static int effective_num_processors(void)
679683{
680   TCHAR *procsoverride;
681684   SYSTEM_INFO info;
682   int numprocs = 0;
685   // fetch the info from the system
686   GetSystemInfo(&info);
683687
684   // if the OSDPROCESSORS environment variable is set, use that value if valid
685   procsoverride = _tgetenv(_T("OSDPROCESSORS"));
686   if (procsoverride != NULL && _stscanf(procsoverride, _T("%d"), &numprocs) == 1 && numprocs > 0)
687      return numprocs;
688   if (osd_num_processors > 0)
689   {
690      return MIN(info.dwNumberOfProcessors * 4, osd_num_processors);
691   }
692   else
693   {
694      TCHAR *procsoverride;
695      int numprocs = 0;
688696
689   // otherwise, fetch the info from the system
690   GetSystemInfo(&info);
697      // if the OSDPROCESSORS environment variable is set, use that value if valid
698      procsoverride = _tgetenv(_T("OSDPROCESSORS"));
699      if (procsoverride != NULL && _stscanf(procsoverride, _T("%d"), &numprocs) == 1 && numprocs > 0)
700         // Be well behaved ...
701         return MIN(info.dwNumberOfProcessors * 4, numprocs);
691702
692   // max out at 4 for now since scaling above that seems to do poorly
693   return MIN(info.dwNumberOfProcessors, 4);
703      // max out at 4 for now since scaling above that seems to do poorly
704      return MIN(info.dwNumberOfProcessors, 4);
705   }
694706}
695707
696708
src/osd/windows/winmain.c
r6740r6741
165165   { NULL,                       NULL,       OPTION_HEADER,     "WINDOWS PERFORMANCE OPTIONS" },
166166   { "priority(-15-1)",          "0",        0,                 "thread priority for the main game thread; range from -15 to 1" },
167167   { "multithreading;mt",        "0",        OPTION_BOOLEAN,    "enable multithreading; this enables rendering and blitting on a separate thread" },
168   { "numprocessors;np",         "auto",     0,             "number of processors; this overrides the number the system reports" },
168169
169170   // video options
170171   { NULL,                       NULL,       OPTION_HEADER,     "WINDOWS VIDEO OPTIONS" },
r6740r6741
309310void osd_init(running_machine *machine)
310311{
311312   int watchdog = options_get_int(mame_options(), WINOPTION_WATCHDOG);
313   const char *stemp;
312314
313315   // thread priority
314316   if (!options_get_bool(mame_options(), OPTION_DEBUG))
r6740r6741
317319   // ensure we get called on the way out
318320   add_exit_callback(machine, osd_exit);
319321
322   // get number of processors
323   stemp = options_get_string(mame_options(), WINOPTION_NUMPROCESSORS);
324
325   osd_num_processors = 0;
326
327   if (strcmp(stemp, "auto") != 0)
328   {
329      osd_num_processors = atoi(stemp);
330      if (osd_num_processors < 1)
331      {
332         mame_printf_warning("Warning: numprocessors < 1 doesn't make much sense. Assuming auto ...\n");
333         osd_num_processors = 0;
334      }
335   }
336
320337   // initialize the subsystems
321338   winvideo_init(machine);
322339   winsound_init(machine);
r6740r6741
669686         }
670687
671688   fclose(map);
672   return 0;
689   return result;
673690}
674691
675692
src/osd/windows/winmain.h
r6740r6741
5353// performance options
5454#define WINOPTION_PRIORITY            "priority"
5555#define WINOPTION_MULTITHREADING      "multithreading"
56#define WINOPTION_NUMPROCESSORS         "numprocessors"
5657
5758// video options
5859#define WINOPTION_VIDEO               "video"
r6740r6741
131132
132133extern const options_entry mame_win_options[];
133134
135// defined in winwork.c
136extern int osd_num_processors;
134137
135138
136139//============================================================
src/emu/debug/debugvw.c
r6740r6741
166166typedef struct _debug_view_memory debug_view_memory;
167167struct _debug_view_memory
168168{
169   const memory_subview_item *subviewlist;      /* linked list of memory subviews */
169170   const memory_subview_item *desc;         /* description of our current subview */
170171   debug_view_expression expression;         /* expression describing the start address */
171172   UINT32            chunks_per_row;         /* number of chunks displayed per line */
r6740r6741
207208   debug_view *      viewlist;            /* list of views */
208209   const registers_subview_item *registers_subviews;/* linked list of registers subviews */
209210   const disasm_subview_item *disasm_subviews;   /* linked list of disassembly subviews */
210   const memory_subview_item *memory_subviews;   /* linked list of memory subviews */
211211};
212212
213213
r6740r6741
350350   /* build a list of disassembly and memory subviews */
351351   global->registers_subviews = registers_view_enumerate_subviews(machine);
352352   global->disasm_subviews = disasm_view_enumerate_subviews(machine);
353   global->memory_subviews = memory_view_enumerate_subviews(machine);
354353}
355354
356355
r6740r6741
24122411               astring_printf(tempstring, "CPU '%s' (%s) %s memory", device->tag, device_get_name(device), space->name);
24132412            else
24142413               astring_printf(tempstring, "%s '%s' space #%d memory", device_get_name(device), device->tag, spacenum);
2415            subview = (memory_subview_item *)auto_alloc_array_clear(machine, UINT8, sizeof(*subview) + astring_len(tempstring));
2414            subview = (memory_subview_item *)alloc_array_clear_or_die(UINT8, sizeof(*subview) + astring_len(tempstring));
24162415
24172416            /* populate the subview */
24182417            subview->next = NULL;
r6740r6741
24412440
24422441         /* determine the string and allocate a subview large enough */
24432442         astring_printf(tempstring, "Region '%s'", rgntag);
2444         subview = (memory_subview_item *)auto_alloc_array_clear(machine, UINT8, sizeof(*subview) + astring_len(tempstring));
2443         subview = (memory_subview_item *)alloc_array_clear_or_die(UINT8, sizeof(*subview) + astring_len(tempstring));
24452444
24462445         /* populate the subview */
24472446         subview->next = NULL;
r6740r6741
24722471         break;
24732472
24742473      /* if this is a single-entry global, add it */
2475      if (valcount > 1 && strstr(name, "/globals/"))
2474      if (valcount > 1 && strstr(name, "globals/"))
24762475      {
24772476         memory_subview_item *subview;
24782477
24792478         /* determine the string and allocate a subview large enough */
24802479         astring_printf(tempstring, "%s", strrchr(name, '/') + 1);
2481         subview = (memory_subview_item *)auto_alloc_array_clear(machine, UINT8, sizeof(*subview) + astring_len(tempstring));
2480         subview = (memory_subview_item *)alloc_array_clear_or_die(UINT8, sizeof(*subview) + astring_len(tempstring));
24822481
24832482         /* populate the subview */
24842483         subview->next = NULL;
r6740r6741
25092508
25102509static int memory_view_alloc(debug_view *view)
25112510{
2511   const memory_subview_item *subviews = memory_view_enumerate_subviews(view->machine);
25122512   debug_view_memory *memdata;
25132513
2514   /* fail if no available subviews */
2515   if (view->machine->debugvw_data->memory_subviews == NULL)
2514   /* if no subviews, fail */
2515   if (subviews == NULL)
25162516      return FALSE;
25172517
25182518   /* allocate memory */
2519   memdata = (debug_view_memory *)malloc(sizeof(*memdata));
2520   if (memdata == NULL)
2521      return FALSE;
2522   memset(memdata, 0, sizeof(*memdata));
2519   memdata = alloc_clear_or_die(debug_view_memory);
2520   memdata->subviewlist = subviews;
25232521
25242522   /* allocate the expression data */
25252523   debug_view_expression_alloc(&memdata->expression);
r6740r6741
25312529   view->supports_cursor = TRUE;
25322530
25332531   /* default to the first subview */
2534   memdata->desc = view->machine->debugvw_data->memory_subviews;
2532   memdata->desc = memdata->subviewlist;
25352533
25362534   /* start out with 16 bytes in a single column and ASCII displayed */
25372535   memdata->bytes_per_chunk = memdata->desc->prefsize;
r6740r6741
25552553   /* free any memory we allocated */
25562554   if (memdata != NULL)
25572555   {
2556      while (memdata->subviewlist != NULL)
2557      {
2558         memory_subview_item *item = (memory_subview_item *)memdata->subviewlist;
2559         memdata->subviewlist = item->next;
2560         free(item);
2561      }
25582562      debug_view_expression_free(&memdata->expression);
25592563      free(memdata);
25602564   }
r6740r6741
30993103
31003104const memory_subview_item *memory_view_get_subview_list(debug_view *view)
31013105{
3106   debug_view_memory *memdata = (debug_view_memory *)view->extra_data;
31023107   assert(view->type == DVT_MEMORY);
3103   return view->machine->debugvw_data->memory_subviews;
3108   return memdata->subviewlist;
31043109}
31053110
31063111
r6740r6741
32203225
32213226void memory_view_set_subview(debug_view *view, int index)
32223227{
3223   const memory_subview_item *subview = memory_view_get_subview_by_index(view->machine->debugvw_data->memory_subviews, index);
32243228   debug_view_memory *memdata = (debug_view_memory *)view->extra_data;
3229   const memory_subview_item *subview;
32253230
32263231   assert(view->type == DVT_MEMORY);
3227   assert(subview != NULL);
3232
3233   /* pick the requested view */
3234   subview = memory_view_get_subview_by_index(memdata->subviewlist, index);
32283235   if (subview == NULL)
32293236      return;
32303237
src/emu/cpu/pic16c62x/pic16c62x.c
r0r6741
1 /**************************************************************************\
2 *                  Microchip PIC16C62X Emulator                            *
3 *                                                                          *
4 *                          Based On                                        *
5 *                  Microchip PIC16C5X Emulator                             *
6 *                    Copyright Tony La Porta                               *
7 *                 Originally written for the MAME project.                 *
8 *                                                                          *
9 *                                                                          *
10 *      Addressing architecture is based on the Harvard addressing scheme.  *
11 *                                                                          *
12 *                                                                          *
13 *  **** Change Log ****                                                    *
14 *  SZ (22-Oct-2009)                                                        *
15 *   - Improvements and tests                                               *
16 *  SZ (2-Oct-2009)                                                         *
17 *   - Internal ram and registers                                           *
18 *  SZ (12-Sep-2009)                                                        *
19 *   - Started working on it.                                               *
20 *                                                                          *
21 *                                                                          *
22 *  **** TODO ****                                                          *
23 *   - Finish checking opcodes/instructions                                 *
24 *   - Internal devices                                                     *
25 *   - Interrupts                                                           *
26 *   - Everything !                                                         *
27 *                                                                          *
28 *  **** DONE ****                                                          *
29 *   - I/O ports                                                            *
30 *   - Savestates                                                           *
31 *   - Internal memory                                                      *
32 *   - New opcodes                                                          *
33 *   - Opcode disassembly                                                   *
34 *                                                                          *
35 *  **** Notes (from PIC16C5X): ****                                        *
36 *  PIC WatchDog Timer has a seperate internal clock. For the moment, we're *
37 *     basing the count on a 4MHz input clock, since 4MHz is the typical    *
38 *     input frequency (but by no means always).                            *
39 *  A single scaler is available for the Counter/Timer or WatchDog Timer.   *
40 *     When connected to the Counter/Timer, it functions as a Prescaler,    *
41 *     hence prescale overflows, tick the Counter/Timer.                    *
42 *     When connected to the WatchDog Timer, it functions as a Postscaler   *
43 *     hence WatchDog Timer overflows, tick the Postscaler. This scenario   *
44 *     means that the WatchDog timeout occurs when the Postscaler has       *
45 *     reached the scaler rate value, not when the WatchDog reaches zero.   *
46 *  CLRWDT should prevent the WatchDog Timer from timing out and generating *
47 *     a device reset, but how is not known. The manual also mentions that  *
48 *     the WatchDog Timer can only be disabled during ROM programming, and  *
49 *     no other means seem to exist???                                      *
50 *                                                                          *
51 \**************************************************************************/
52
53#include "debugger.h"
54#include "pic16c62x.h"
55
56
57
58
59typedef struct _pic16c62x_state pic16c62x_state;
60struct _pic16c62x_state
61{
62   /******************** CPU Internal Registers *******************/
63   UINT16   PC;
64   UINT16   PREVPC;      /* previous program counter */
65   UINT8   W;
66   UINT8   PCLATH;      /* 0a,8a */
67   UINT8   OPTION;      /* 81 */
68   UINT16   CONFIG;
69   UINT8   ALU;
70   UINT16   WDT;
71   UINT8   TRISA;      /* 85 */
72   UINT8   TRISB;      /* 86 */
73   UINT16   STACK[8];
74   UINT16   prescaler;   /* Note: this is really an 8-bit register */
75   PAIR   opcode;
76   UINT8   *internalram;
77
78   int      icount;
79   int      reset_vector;
80   int      picmodel;
81   int      delay_timer;
82   UINT16   temp_config;
83   UINT8   old_T0;
84   INT8   old_data;
85   UINT8   picRAMmask;
86   int      inst_cycles;
87
88
89   const   device_config *device;
90   const   address_space *program;
91   const   address_space *data;
92   const   address_space *io;
93};
94
95INLINE pic16c62x_state *get_safe_token(const device_config *device)
96{
97   assert(device != NULL);
98   assert(device->token != NULL);
99   assert(device->type == CPU);
100   assert(cpu_get_type(device) == CPU_PIC16C620 ||
101         cpu_get_type(device) == CPU_PIC16C620A ||
102//         cpu_get_type(device) == CPU_PIC16CR620A ||
103         cpu_get_type(device) == CPU_PIC16C621 ||
104         cpu_get_type(device) == CPU_PIC16C621A ||
105         cpu_get_type(device) == CPU_PIC16C622 ||
106         cpu_get_type(device) == CPU_PIC16C622A);
107   return (pic16c62x_state *)device->token;
108}
109
110
111/* opcode table entry */
112typedef struct _pic16c62x_opcode pic16c62x_opcode;
113struct _pic16c62x_opcode
114{
115   UINT8   cycles;
116   void    (*function)(pic16c62x_state *);
117};
118/* instruction list entry */
119typedef struct _pic16c62x_instruction pic16c62x_instruction;
120struct _pic16c62x_instruction
121{
122   char   *format;
123   void    (*function)(pic16c62x_state *);
124   UINT8   cycles;
125};
126
127
128INLINE void update_internalram_ptr(pic16c62x_state *cpustate)
129{
130   cpustate->internalram = (UINT8 *)memory_get_write_ptr(cpustate->data, 0x00);
131}
132
133#define PIC16C62x_RDOP(A)         (memory_decrypted_read_word(cpustate->program, (A)<<1))
134#define PIC16C62x_RAM_RDMEM(A)    ((UINT8)memory_read_byte_8le(cpustate->data, A))
135#define PIC16C62x_RAM_WRMEM(A,V)  (memory_write_byte_8le(cpustate->data, A,V))
136#define PIC16C62x_In(Port)        ((UINT8)memory_read_byte_8le(cpustate->io, (Port)))
137#define PIC16C62x_Out(Port,Value) (memory_write_byte_8le(cpustate->io, (Port),Value))
138/************  Read the state of the T0 Clock input signal  ************/
139#define PIC16C62x_T0_In           (memory_read_byte_8le(cpustate->io, PIC16C62x_T0) >> 4)
140
141#define M_RDRAM(A)      (((A) == 0) ? cpustate->internalram[0] : PIC16C62x_RAM_RDMEM(A))
142#define M_WRTRAM(A,V)   do { if ((A) == 0) cpustate->internalram[0] = (V); else PIC16C62x_RAM_WRMEM(A,V); } while (0)
143#define M_RDOP(A)      PIC16C62x_RDOP(A)
144#define P_IN(A)         PIC16C62x_In(A)
145#define P_OUT(A,V)      PIC16C62x_Out(A,V)
146#define S_T0_IN         PIC16C62x_T0_In
147#define ADDR_MASK      0x1fff
148
149
150
151#define TMR0   internalram[1]
152#define PCL      internalram[2]
153#define STATUS   internalram[3]
154#define FSR      internalram[4]
155#define PORTA   internalram[5]
156#define PORTB   internalram[6]
157#define INDF   M_RDRAM(cpustate->FSR)
158
159#define  RISING_EDGE_T0  (( (int)(T0_in - cpustate->old_T0) > 0) ? 1 : 0)
160#define FALLING_EDGE_T0  (( (int)(T0_in - cpustate->old_T0) < 0) ? 1 : 0)
161
162
163/********  The following is the Status Flag register definition.  *********/
164         /* | 7 | 6 | 5 |  4 |  3 | 2 |  1 | 0 | */
165         /* |IRP|RP1|RP0| TO | PD | Z | DC | C | */
166#define IRP_FLAG   0x80   /* IRP  Register Bank Select bit (used for indirect addressing) */
167#define RP1_FLAG   0x40   /* RP1  Register Bank Select bits (used for direct addressing) */
168#define RP0_FLAG   0x20   /* RP0  Register Bank Select bits (used for direct addressing) */
169#define TO_FLAG      0x10   /* TO   Time Out flag (WatchDog) */
170#define PD_FLAG      0x08   /* PD   Power Down flag */
171#define Z_FLAG      0x04   /* Z    Zero Flag */
172#define DC_FLAG      0x02   /* DC   Digit Carry/Borrow flag (Nibble) */
173#define C_FLAG      0x01   /* C    Carry/Borrow Flag (Byte) */
174
175#define IRP      (cpustate->STATUS & IRP_FLAG)
176#define RP1      (cpustate->STATUS & RP1_FLAG)
177#define RP0      (cpustate->STATUS & RP0_FLAG)
178#define TO      (cpustate->STATUS & TO_FLAG)
179#define PD      (cpustate->STATUS & PD_FLAG)
180#define ZERO   (cpustate->STATUS & Z_FLAG)
181#define DC      (cpustate->STATUS & DC_FLAG)
182#define CARRY   (cpustate->STATUS & C_FLAG)
183
184#define ADDR   ((cpustate->opcode.b.l & 0x7f) | (RP0 << 2))
185
186/********  The following is the Option Flag register definition.  *********/
187         /* |   7  |   6    |   5  |   4  |  3  | 2 | 1 | 0 | */
188         /* | RBPU | INTEDG | TOCS | TOSE | PSA |    PS     | */
189#define RBPU_FLAG   0x80   /* RBPU     Pull-up Enable */
190#define INTEDG_FLAG   0x40   /* INTEDG   Interrupt Edge Select */
191#define T0CS_FLAG   0x20   /* TOCS     Timer 0 clock source select */
192#define T0SE_FLAG   0x10   /* TOSE     Timer 0 clock source edge select */
193#define PSA_FLAG   0x08   /* PSA      Prescaler Assignment bit */
194#define PS_REG      0x07   /* PS       Prescaler Rate select */
195
196#define T0CS   (cpustate->OPTION & T0CS_FLAG)
197#define T0SE   (cpustate->OPTION & T0SE_FLAG)
198#define PSA      (cpustate->OPTION & PSA_FLAG)
199#define PS      (cpustate->OPTION & PS_REG)
200
201/********  The following is the Config Flag register definition.  *********/
202   /* | 13 | 12 | 11 | 10 | 9 | 8 | 7 |   6   | 5 | 4 |   3   |   2  | 1 | 0 | */
203   /* |           CP              |   | BODEN |  CP   | PWRTE | WDTE |  FOSC | */
204   /* CP       Code Protect (ROM read protect) */
205#define BODEN_FLAG   0x40   /* BODEN    Brown-out Reset Enable */
206#define PWRTE_FLAG   0x08   /* PWRTE    Power-up Timer Enable */
207#define WDTE_FLAG   0x04   /* WDTE     WatchDog Timer enable */
208#define FOSC_FLAG   0x03   /* FOSC     Oscillator source select */
209
210#define WDTE   (cpustate->CONFIG & WDTE_FLAG)
211#define FOSC   (cpustate->CONFIG & FOSC_FLAG)
212
213
214/************************************************************************
215 *  Shortcuts
216 ************************************************************************/
217
218#define CLR(flagreg, flag) ( flagreg &= (UINT8)(~flag) )
219#define SET(flagreg, flag) ( flagreg |=  flag )
220
221
222/* Easy bit position selectors */
223#define POS    ((cpustate->opcode.w.l >> 7) & 7)
224static const unsigned int bit_clr[8] = { 0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f };
225static const unsigned int bit_set[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
226
227
228
229INLINE void CALCULATE_Z_FLAG(pic16c62x_state *cpustate)
230{
231   if (cpustate->ALU == 0) SET(cpustate->STATUS, Z_FLAG);
232   else CLR(cpustate->STATUS, Z_FLAG);
233}
234
235INLINE void CALCULATE_ADD_CARRY(pic16c62x_state *cpustate)
236{
237   if ((UINT8)(cpustate->old_data) > (UINT8)(cpustate->ALU)) {
238      SET(cpustate->STATUS, C_FLAG);
239   }
240   else {
241      CLR(cpustate->STATUS, C_FLAG);
242   }
243}
244
245INLINE void CALCULATE_ADD_DIGITCARRY(pic16c62x_state *cpustate)
246{
247   if (((UINT8)(cpustate->old_data) & 0x0f) > ((UINT8)(cpustate->ALU) & 0x0f)) {
248      SET(cpustate->STATUS, DC_FLAG);
249   }
250   else {
251      CLR(cpustate->STATUS, DC_FLAG);
252   }
253}
254
255INLINE void CALCULATE_SUB_CARRY(pic16c62x_state *cpustate)
256{
257   if ((UINT8)(cpustate->old_data) < (UINT8)(cpustate->ALU)) {
258      CLR(cpustate->STATUS, C_FLAG);
259   }
260   else {
261      SET(cpustate->STATUS, C_FLAG);
262   }
263}
264
265INLINE void CALCULATE_SUB_DIGITCARRY(pic16c62x_state *cpustate)
266{
267   if (((UINT8)(cpustate->old_data) & 0x0f) < ((UINT8)(cpustate->ALU) & 0x0f)) {
268      CLR(cpustate->STATUS, DC_FLAG);
269   }
270   else {
271      SET(cpustate->STATUS, DC_FLAG);
272   }
273}
274
275
276
277INLINE UINT16 POP_STACK(pic16c62x_state *cpustate)
278{
279   UINT16 data = cpustate->STACK[7];
280   cpustate->STACK[7] = cpustate->STACK[6];
281   cpustate->STACK[6] = cpustate->STACK[5];
282   cpustate->STACK[5] = cpustate->STACK[4];
283   cpustate->STACK[4] = cpustate->STACK[3];
284   cpustate->STACK[3] = cpustate->STACK[2];
285   cpustate->STACK[2] = cpustate->STACK[1];
286   cpustate->STACK[1] = cpustate->STACK[0];
287   return (data & ADDR_MASK);
288}
289INLINE void PUSH_STACK(pic16c62x_state *cpustate, UINT16 data)
290{
291   cpustate->STACK[0] = cpustate->STACK[1];
292   cpustate->STACK[1] = cpustate->STACK[2];
293   cpustate->STACK[2] = cpustate->STACK[3];
294   cpustate->STACK[3] = cpustate->STACK[4];
295   cpustate->STACK[4] = cpustate->STACK[5];
296   cpustate->STACK[5] = cpustate->STACK[6];
297   cpustate->STACK[6] = cpustate->STACK[7];
298   cpustate->STACK[7] = (data & ADDR_MASK);
299}
300
301
302
303INLINE UINT8 GET_REGFILE(pic16c62x_state *cpustate, offs_t addr)   /* Read from internal memory */
304{
305   UINT8 data;
306
307   if (addr == 0) {                  /* Indirect addressing  */
308      addr = (cpustate->FSR & cpustate->picRAMmask);
309   }
310
311   switch(addr)
312   {
313      case 0x00:   /* Not an actual register, so return 0 */
314      case 0x80:
315               data = 0;
316               break;
317      case 0x02:
318      case 0x03:
319      case 0x0b:
320      case 0x82:
321      case 0x83:
322      case 0x8b:
323               data = M_RDRAM(addr & 0x7f);
324               break;
325      case 0x84:
326      case 0x04:   data = (cpustate->FSR | (UINT8)(~cpustate->picRAMmask));
327               break;
328      case 0x05:   data = P_IN(0);
329               data &= cpustate->TRISA;
330               data |= ((UINT8)(~cpustate->TRISA) & cpustate->PORTA);
331               data &= 0x1f;      /* 5-bit port (only lower 5 bits used) */
332               break;
333      case 0x06:   data = P_IN(1);
334               data &= cpustate->TRISB;
335               data |= ((UINT8)(~cpustate->TRISB) & cpustate->PORTB);
336               break;
337      case 0x8a:
338      case 0x0a:   data = cpustate->PCLATH;
339               break;
340      case 0x81:   data = cpustate->OPTION;
341               break;
342      case 0x85:   data = cpustate->TRISA;
343               break;
344      case 0x86:   data = cpustate->TRISB;
345               break;
346      default:   data = M_RDRAM(addr);
347               break;
348   }
349   return data;
350}
351
352INLINE void STORE_REGFILE(pic16c62x_state *cpustate, offs_t addr, UINT8 data)   /* Write to internal memory */
353{
354   if (addr == 0) {                  /* Indirect addressing  */
355      addr = (cpustate->FSR & cpustate->picRAMmask);
356   }
357
358   switch(addr)
359   {
360      case 0x80:
361      case 0x00:   /* Not an actual register, nothing to save */
362               break;
363      case 0x01:   cpustate->delay_timer = 2;      /* Timer starts after next two instructions */
364               if (PSA == 0) cpustate->prescaler = 0;   /* Must clear the Prescaler */
365               cpustate->TMR0 = data;
366               break;
367      case 0x82:
368      case 0x02:   cpustate->PCL = data;
369               cpustate->PC = (cpustate->PCLATH << 8) | data;
370               break;
371      case 0x83:
372      case 0x03:   cpustate->STATUS &= (UINT8)(~(IRP_FLAG|RP1_FLAG|RP0_FLAG)); cpustate->STATUS |= (data & (IRP_FLAG|RP1_FLAG|RP0_FLAG));
373               break;
374      case 0x84:
375      case 0x04:   cpustate->FSR = (data | (UINT8)(~cpustate->picRAMmask));
376               break;
377      case 0x05:   data &= 0x1f;      /* 5-bit port (only lower 5 bits used) */
378               P_OUT(0,data & (UINT8)(~cpustate->TRISA)); cpustate->PORTA = data;
379               break;
380      case 0x06:   P_OUT(1,data & (UINT8)(~cpustate->TRISB)); cpustate->PORTB = data;
381               break;
382      case 0x8a:
383      case 0x0a:
384               cpustate->PCLATH = data & 0x1f;
385               M_WRTRAM(0x0a, cpustate->PCLATH);
386               break;
387      case 0x8b:
388      case 0x0b:   M_WRTRAM(0x0b, data);
389               break;
390      case 0x81:   cpustate->OPTION = data;
391               M_WRTRAM(0x81, data);
392               break;
393      case 0x85:   if   (cpustate->TRISA != data)
394               {
395                  cpustate->TRISA = data | 0xf0;
396                  P_OUT(2,cpustate->TRISA);
397                  P_OUT(0,cpustate->PORTA & (UINT8)(~cpustate->TRISA) & 0x0f);
398                  M_WRTRAM(addr, data);
399               }
400               break;
401      case 0x86:   if   (cpustate->TRISB != data)
402               {
403                  cpustate->TRISB = data;
404                  P_OUT(3,cpustate->TRISB);
405                  P_OUT(1,cpustate->PORTB & (UINT8)(~cpustate->TRISB));
406                  M_WRTRAM(addr, data);
407               }
408               break;
409      default:   M_WRTRAM(addr, data);
410               break;
411   }
412}
413
414
415INLINE void STORE_RESULT(pic16c62x_state *cpustate, offs_t addr, UINT8 data)
416{
417   if (cpustate->opcode.b.l & 0x80)
418   {
419      STORE_REGFILE(cpustate, addr, data);
420   }
421   else
422   {
423      cpustate->W = data;
424   }
425}
426
427
428/************************************************************************
429 *  Emulate the Instructions
430 ************************************************************************/
431
432/* This following function is here to fill in the void for */
433/* the opcode call function. This function is never called. */
434
435
436static void illegal(pic16c62x_state *cpustate)
437{
438   logerror("PIC16C62x:  PC=%03x,  Illegal opcode = %04x\n", (cpustate->PC-1), cpustate->opcode.w.l);
439}
440
441
442static void addwf(pic16c62x_state *cpustate)
443{
444   cpustate->old_data = GET_REGFILE(cpustate, ADDR);
445   cpustate->ALU = cpustate->old_data + cpustate->W;
446   STORE_RESULT(cpustate, ADDR, cpustate->ALU);
447   CALCULATE_Z_FLAG(cpustate);
448   CALCULATE_ADD_CARRY(cpustate);
449   CALCULATE_ADD_DIGITCARRY(cpustate);
450}
451
452static void addlw(pic16c62x_state *cpustate)
453{
454   cpustate->ALU = (cpustate->opcode.b.l & 0xff) + cpustate->W;
455   cpustate->W = cpustate->ALU;
456   CALCULATE_Z_FLAG(cpustate);
457   CALCULATE_ADD_CARRY(cpustate);
458   CALCULATE_ADD_DIGITCARRY(cpustate);
459}
460
461static void andwf(pic16c62x_state *cpustate)
462{
463   cpustate->ALU = GET_REGFILE(cpustate, ADDR) & cpustate->W;
464   STORE_RESULT(cpustate, ADDR, cpustate->ALU);
465   CALCULATE_Z_FLAG(cpustate);
466}
467
468static void andlw(pic16c62x_state *cpustate)
469{
470   cpustate->ALU = cpustate->opcode.b.l & cpustate->W;
471   cpustate->W = cpustate->ALU;
472   CALCULATE_Z_FLAG(cpustate);
473}
474
475static void bcf(pic16c62x_state *cpustate)
476{
477   cpustate->ALU = GET_REGFILE(cpustate, ADDR);
478   cpustate->ALU &= bit_clr[POS];
479   STORE_REGFILE(cpustate, ADDR, cpustate->ALU);
480}
481
482static void bsf(pic16c62x_state *cpustate)
483{
484   cpustate->ALU = GET_REGFILE(cpustate, ADDR);
485   cpustate->ALU |= bit_set[POS];
486   STORE_REGFILE(cpustate, ADDR, cpustate->ALU);
487}
488
489static void btfss(pic16c62x_state *cpustate)
490{
491   if ((GET_REGFILE(cpustate, ADDR) & bit_set[POS]) == bit_set[POS])
492   {
493      cpustate->PC++ ;
494      cpustate->PCL = cpustate->PC & 0xff;
495      cpustate->inst_cycles += 1;      /* Add NOP cycles */
496   }
497}
498
499static void btfsc(pic16c62x_state *cpustate)
500{
501   if ((GET_REGFILE(cpustate, ADDR) & bit_set[POS]) == 0)
502   {
503      cpustate->PC++ ;
504      cpustate->PCL = cpustate->PC & 0xff;
505      cpustate->inst_cycles += 1;      /* Add NOP cycles */
506   }
507}
508
509static void call(pic16c62x_state *cpustate)
510{
511   PUSH_STACK(cpustate, cpustate->PC);
512   cpustate->PC = ((cpustate->PCLATH & 0x18) << 8) | (cpustate->opcode.w.l & 0x7ff);
513   cpustate->PC &= ADDR_MASK;
514   cpustate->PCL = cpustate->PC & 0xff;
515}
516
517static void clrw(pic16c62x_state *cpustate)
518{
519   cpustate->W = 0;
520   SET(cpustate->STATUS, Z_FLAG);
521}
522
523static void clrf(pic16c62x_state *cpustate)
524{
525   STORE_REGFILE(cpustate, ADDR, 0);
526   SET(cpustate->STATUS, Z_FLAG);
527}
528
529static void clrwdt(pic16c62x_state *cpustate)
530{
531   cpustate->WDT = 0;
532   if (PSA) cpustate->prescaler = 0;
533   SET(cpustate->STATUS, TO_FLAG);
534   SET(cpustate->STATUS, PD_FLAG);
535}
536
537static void comf(pic16c62x_state *cpustate)
538{
539   cpustate->ALU = (UINT8)(~(GET_REGFILE(cpustate, ADDR)));
540   STORE_RESULT(cpustate, ADDR, cpustate->ALU);
541   CALCULATE_Z_FLAG(cpustate);
542}
543
544static void decf(pic16c62x_state *cpustate)
545{
546   cpustate->ALU = GET_REGFILE(cpustate, ADDR) - 1;
547   STORE_RESULT(cpustate, ADDR, cpustate->ALU);
548   CALCULATE_Z_FLAG(cpustate);
549}
550
551static void decfsz(pic16c62x_state *cpustate)
552{
553   cpustate->ALU = GET_REGFILE(cpustate, ADDR) - 1;
554   STORE_RESULT(cpustate, ADDR, cpustate->ALU);
555   if (cpustate->ALU == 0)
556   {
557      cpustate->PC++ ;
558      cpustate->PCL = cpustate->PC & 0xff;
559      cpustate->inst_cycles += 1;      /* Add NOP cycles */
560   }
561}
562
563static void goto_op(pic16c62x_state *cpustate)
564{
565   cpustate->PC = ((cpustate->PCLATH & 0x18) << 8) | (cpustate->opcode.w.l & 0x7ff);
566   cpustate->PC &= ADDR_MASK;
567   cpustate->PCL = cpustate->PC & 0xff;
568}
569
570static void incf(pic16c62x_state *cpustate)
571{
572   cpustate->ALU = GET_REGFILE(cpustate, ADDR) + 1;
573   STORE_RESULT(cpustate, ADDR, cpustate->ALU);
574   CALCULATE_Z_FLAG(cpustate);
575}
576
577static void incfsz(pic16c62x_state *cpustate)
578{
579   cpustate->ALU = GET_REGFILE(cpustate, ADDR) + 1;
580   STORE_RESULT(cpustate, ADDR, cpustate->ALU);
581   if (cpustate->ALU == 0)
582   {
583      cpustate->PC++ ;
584      cpustate->PCL = cpustate->PC & 0xff;
585      cpustate->inst_cycles += 1;      /* Add NOP cycles */
586   }
587}
588
589static void iorlw(pic16c62x_state *cpustate)
590{
591   cpustate->ALU = cpustate->opcode.b.l | cpustate->W;
592   cpustate->W = cpustate->ALU;
593   CALCULATE_Z_FLAG(cpustate);
594}
595
596static void iorwf(pic16c62x_state *cpustate)
597{
598   cpustate->ALU = GET_REGFILE(cpustate, ADDR) | cpustate->W;
599   STORE_RESULT(cpustate, ADDR, cpustate->ALU);
600   CALCULATE_Z_FLAG(cpustate);
601}
602
603static void movf(pic16c62x_state *cpustate)
604{
605   cpustate->ALU = GET_REGFILE(cpustate, ADDR);
606   STORE_RESULT(cpustate, ADDR, cpustate->ALU);
607   CALCULATE_Z_FLAG(cpustate);
608}
609
610static void movlw(pic16c62x_state *cpustate)
611{
612   cpustate->W = cpustate->opcode.b.l;
613}
614
615static void movwf(pic16c62x_state *cpustate)
616{
617   STORE_REGFILE(cpustate, ADDR, cpustate->W);
618}
619
620static void nop(pic16c62x_state *cpustate)
621{
622   /* Do nothing */
623}
624
625static void option(pic16c62x_state *cpustate)
626{
627   cpustate->OPTION = cpustate->W;
628}
629
630static void retlw(pic16c62x_state *cpustate)
631{
632   cpustate->W = cpustate->opcode.b.l;
633   cpustate->PC = POP_STACK(cpustate);
634   cpustate->PCL = cpustate->PC & 0xff;
635}
636
637static void returns(pic16c62x_state *cpustate)
638{
639   cpustate->PC = POP_STACK(cpustate);
640   cpustate->PCL = cpustate->PC & 0xff;
641}
642
643static void retfie(pic16c62x_state *cpustate)
644{
645   cpustate->PC = POP_STACK(cpustate);
646   cpustate->PCL = cpustate->PC & 0xff;
647   //INTCON(7)=1;
648}
649
650static void rlf(pic16c62x_state *cpustate)
651{
652   cpustate->ALU = GET_REGFILE(cpustate, ADDR);
653   cpustate->ALU <<= 1;
654   if (cpustate->STATUS & C_FLAG) cpustate->ALU |= 1;
655   if (GET_REGFILE(cpustate, ADDR) & 0x80) SET(cpustate->STATUS, C_FLAG);
656   else CLR(cpustate->STATUS, C_FLAG);
657   STORE_RESULT(cpustate, ADDR, cpustate->ALU);
658}
659
660static void rrf(pic16c62x_state *cpustate)
661{
662   cpustate->ALU = GET_REGFILE(cpustate, ADDR);
663   cpustate->ALU >>= 1;
664   if (cpustate->STATUS & C_FLAG) cpustate->ALU |= 0x80;
665   if (GET_REGFILE(cpustate, ADDR) & 1) SET(cpustate->STATUS, C_FLAG);
666   else CLR(cpustate->STATUS, C_FLAG);
667   STORE_RESULT(cpustate, ADDR, cpustate->ALU);
668}
669
670static void sleepic(pic16c62x_state *cpustate)
671{
672   if (WDTE) cpustate->WDT = 0;
673   if (PSA) cpustate->prescaler = 0;
674   SET(cpustate->STATUS, TO_FLAG);
675   CLR(cpustate->STATUS, PD_FLAG);
676}
677
678static void subwf(pic16c62x_state *cpustate)
679{
680   cpustate->old_data = GET_REGFILE(cpustate, ADDR);
681   cpustate->ALU = cpustate->old_data - cpustate->W;
682   STORE_RESULT(cpustate, ADDR, cpustate->ALU);
683   CALCULATE_Z_FLAG(cpustate);
684   CALCULATE_SUB_CARRY(cpustate);
685   CALCULATE_SUB_DIGITCARRY(cpustate);
686}
687
688static void sublw(pic16c62x_state *cpustate)
689{
690   cpustate->ALU = (cpustate->opcode.b.l & 0xff) - cpustate->W;
691   cpustate->W = cpustate->ALU;
692   CALCULATE_Z_FLAG(cpustate);
693   CALCULATE_SUB_CARRY(cpustate);
694   CALCULATE_SUB_DIGITCARRY(cpustate);
695}
696
697static void swapf(pic16c62x_state *cpustate)
698{
699   cpustate->ALU  = ((GET_REGFILE(cpustate, ADDR) << 4) & 0xf0);
700   cpustate->ALU |= ((GET_REGFILE(cpustate, ADDR) >> 4) & 0x0f);
701   STORE_RESULT(cpustate, ADDR, cpustate->ALU);
702}
703
704static void tris(pic16c62x_state *cpustate)
705{
706
707   switch(cpustate->opcode.b.l & 0x7)
708   {
709      case 05:   STORE_REGFILE(cpustate, 0x85, cpustate->W); break;
710      case 06:   STORE_REGFILE(cpustate, 0x86, cpustate->W); break;
711      default:   illegal(cpustate); break;
712   }
713}
714
715static void xorlw(pic16c62x_state *cpustate)
716{
717   cpustate->ALU = cpustate->W ^ cpustate->opcode.b.l;
718   cpustate->W = cpustate->ALU;
719   CALCULATE_Z_FLAG(cpustate);
720}
721
722static void xorwf(pic16c62x_state *cpustate)
723{
724   cpustate->ALU = GET_REGFILE(cpustate, ADDR) ^ cpustate->W;
725   STORE_RESULT(cpustate, ADDR, cpustate->ALU);
726   CALCULATE_Z_FLAG(cpustate);
727}
728
729
730/***********************************************************************
731 *  Instruction Table (Format, Instruction, Cycles)
732 ***********************************************************************/
733
734static const pic16c62x_instruction instructiontable[]=
735{
736   {(char *)"000111dfffffff", addwf, 1},
737   {(char *)"000101dfffffff", andwf, 1},
738   {(char *)"0000011fffffff", clrf, 1},
739   {(char *)"00000100000011", clrw, 1},
740   {(char *)"001001dfffffff", comf, 1},
741   {(char *)"000011dfffffff", decf, 1},
742   {(char *)"001011dfffffff", decfsz, 1},
743   {(char *)"001010dfffffff", incf, 1},
744   {(char *)"001111dfffffff", incfsz, 1},
745   {(char *)"000100dfffffff", iorwf, 1},
746   {(char *)"001000dfffffff", movf, 1},
747   {(char *)"0000001fffffff", movwf, 1},
748   {(char *)"0000000xx00000", nop, 1},
749   {(char *)"001101dfffffff", rlf, 1},
750   {(char *)"001100dfffffff", rrf, 1},
751   {(char *)"000010dfffffff", subwf, 1},
752   {(char *)"001110dfffffff", swapf, 1},
753   {(char *)"000110dfffffff", xorwf, 1},
754   {(char *)"0100bbbfffffff", bcf, 1},
755   {(char *)"0101bbbfffffff", bsf, 1},
756   {(char *)"0110bbbfffffff", btfsc, 1},
757   {(char *)"0111bbbfffffff", btfss, 1},
758   {(char *)"11111xkkkkkkkk", addlw, 1},
759   {(char *)"111001kkkkkkkk", andlw, 1},
760   {(char *)"100aaaaaaaaaaa", call, 2},
761   {(char *)"101aaaaaaaaaaa", goto_op, 2},
762   {(char *)"111000kkkkkkkk", iorlw, 1},
763   {(char *)"1100xxkkkkkkkk", movlw, 1},
764   {(char *)"00000000001001", retfie, 2},
765   {(char *)"1101xxkkkkkkkk", retlw, 2},
766   {(char *)"00000000001000", returns, 2},
767   {(char *)"00000001100011", sleepic, 1},
768   {(char *)"11110xkkkkkkkk", sublw, 1},
769   {(char *)"111010kkkkkkkk", xorlw, 1},
770   {(char *)"00000001100100", clrwdt, 1},
771   {(char *)"00000001100010", option, 1},      // deprecated
772   {(char *)"00000001100fff", tris, 1},      // deprecated
773   {NULL, NULL, 0}
774};
775
776/***********************************************************************
777 *  Opcode Table (Cycles, Instruction)
778 ***********************************************************************/
779
780static pic16c62x_opcode opcode_table[16384];
781
782/***********************************************************************
783 *  Opcode Table build function
784 ***********************************************************************/
785
786static void build_opcode_table(void)
787{
788int instr,mask,bits;
789int a;
790
791   // defaults
792   for ( a = 0; a < 16384; a++)
793   {
794      opcode_table[a].cycles = 0;
795      opcode_table[a].function = illegal;
796   }
797   // build table
798   for( instr = 0; instructiontable[instr].cycles != 0; instr++)
799   {
800      bits=0;
801      mask=0;
802      for ( a = 0; a < 14; a++)
803      {
804         switch (instructiontable[instr].format[a])
805         {
806            case '0':
807               bits = bits << 1;
808               mask = (mask << 1) | 1;
809               break;
810            case '1':
811               bits = (bits << 1) | 1;
812               mask = (mask << 1) | 1;
813               break;
814            default:
815               bits = bits << 1;
816               mask = mask << 1;
817               break;
818         }
819      }
820      for ( a = 0; a < 16384; a++)
821      {
822         if (((a & mask) == bits) && (opcode_table[a].cycles == 0))
823         {
824            opcode_table[a].cycles = instructiontable[instr].cycles;
825            opcode_table[a].function = instructiontable[instr].function;
826         }
827      }
828   }
829}
830
831/****************************************************************************
832 *  Inits CPU emulation
833 ****************************************************************************/
834
835static CPU_INIT( pic16c62x )
836{
837   pic16c62x_state *cpustate = get_safe_token(device);
838
839   cpustate->device = device;
840   cpustate->program = memory_find_address_space(device, ADDRESS_SPACE_PROGRAM);
841   cpustate->data = memory_find_address_space(device, ADDRESS_SPACE_DATA);
842   cpustate->io = memory_find_address_space(device, ADDRESS_SPACE_IO);
843
844   cpustate->CONFIG = 0x3fff;
845
846   /* ensure the internal ram pointers are set before get_info is called */
847   update_internalram_ptr(cpustate);
848
849   build_opcode_table();
850
851   state_save_register_device_item(device, 0, cpustate->W);
852   state_save_register_device_item(device, 0, cpustate->ALU);
853   state_save_register_device_item(device, 0, cpustate->OPTION);
854   state_save_register_device_item(device, 0, cpustate->PCLATH);
855   state_save_register_device_item(device, 0, cpustate->TMR0);
856   state_save_register_device_item(device, 0, cpustate->PCL);
857   state_save_register_device_item(device, 0, cpustate->STATUS);
858   state_save_register_device_item(device, 0, cpustate->FSR);
859   state_save_register_device_item(device, 0, cpustate->PORTA);
860   state_save_register_device_item(device, 0, cpustate->PORTB);
861   state_save_register_device_item(device, 0, cpustate->TRISA);
862   state_save_register_device_item(device, 0, cpustate->TRISB);
863   state_save_register_device_item(device, 0, cpustate->old_T0);
864   state_save_register_device_item(device, 0, cpustate->old_data);
865   state_save_register_device_item(device, 0, cpustate->picRAMmask);
866   state_save_register_device_item(device, 0, cpustate->WDT);
867   state_save_register_device_item(device, 0, cpustate->prescaler);
868   state_save_register_device_item(device, 0, cpustate->STACK[0]);
869   state_save_register_device_item(device, 0, cpustate->STACK[1]);
870   state_save_register_device_item(device, 0, cpustate->STACK[2]);
871   state_save_register_device_item(device, 0, cpustate->STACK[3]);
872   state_save_register_device_item(device, 0, cpustate->STACK[4]);
873   state_save_register_device_item(device, 0, cpustate->STACK[5]);
874   state_save_register_device_item(device, 0, cpustate->STACK[6]);
875   state_save_register_device_item(device, 0, cpustate->STACK[7]);
876   state_save_register_device_item(device, 0, cpustate->PC);
877   state_save_register_device_item(device, 0, cpustate->PREVPC);
878   state_save_register_device_item(device, 0, cpustate->CONFIG);
879   state_save_register_device_item(device, 0, cpustate->opcode.d);
880   state_save_register_device_item(device, 0, cpustate->delay_timer);
881   state_save_register_device_item(device, 0, cpustate->picmodel);
882   state_save_register_device_item(device, 0, cpustate->reset_vector);
883
884   state_save_register_device_item(device, 0, cpustate->icount);
885   state_save_register_device_item(device, 0, cpustate->temp_config);
886   state_save_register_device_item(device, 0, cpustate->inst_cycles);
887}
888
889
890/****************************************************************************
891 *  Reset registers to their initial values
892 ****************************************************************************/
893
894static void pic16c62x_reset_regs(pic16c62x_state *cpustate)
895{
896   cpustate->PC     = cpustate->reset_vector;
897   cpustate->TRISA  = 0x1f;
898   cpustate->TRISB  = 0xff;
899   cpustate->OPTION = 0xff;
900   cpustate->STATUS = 0x18;
901   cpustate->PCL    = 0;
902   cpustate->FSR   |= (UINT8)(~cpustate->picRAMmask);
903   cpustate->PORTA  = 0;
904   cpustate->prescaler = 0;
905   cpustate->delay_timer = 0;
906   cpustate->old_T0 = 0;
907   cpustate->inst_cycles = 0;
908   PIC16C62x_RAM_WRMEM(0x85,cpustate->TRISA);
909   PIC16C62x_RAM_WRMEM(0x86,cpustate->TRISB);
910   PIC16C62x_RAM_WRMEM(0x81,cpustate->OPTION);
911}
912
913static void pic16c62x_soft_reset(pic16c62x_state *cpustate)
914{
915   SET(cpustate->STATUS, (TO_FLAG | PD_FLAG | Z_FLAG | DC_FLAG | C_FLAG));
916   pic16c62x_reset_regs(cpustate);
917}
918
919void pic16c62x_set_config(const device_config *cpu, int data)
920{
921   pic16c62x_state *cpustate = get_safe_token(cpu);
922
923   logerror("Writing %04x to the PIC16C62x configuration bits\n",data);
924   cpustate->CONFIG = (data & 0x3fff);
925}
926
927
928/****************************************************************************
929 *  Shut down CPU emulation
930 ****************************************************************************/
931
932static CPU_EXIT( pic16c62x )
933{
934   /* nothing to do */
935}
936
937
938/****************************************************************************
939 *  WatchDog
940 ****************************************************************************/
941
942static void pic16c62x_update_watchdog(pic16c62x_state *cpustate, int counts)
943{
944   /* TODO: needs updating */
945   /* WatchDog is set up to count 18,000 (0x464f hex) ticks to provide */
946   /* the timeout period of 0.018ms based on a 4MHz input clock. */
947   /* Note: the 4MHz clock should be divided by the PIC16C5x_CLOCK_DIVIDER */
948   /* which effectively makes the PIC run at 1MHz internally. */
949
950   /* If the current instruction is CLRWDT or SLEEP, don't update the WDT */
951
952   if ((cpustate->opcode.w.l != 0x64) && (cpustate->opcode.w.l != 0x63))
953   {
954      UINT16 old_WDT = cpustate->WDT;
955
956      cpustate->WDT -= counts;
957
958      if (cpustate->WDT > 0x464f) {
959         cpustate->WDT = 0x464f - (0xffff - cpustate->WDT);
960      }
961
962      if (((old_WDT != 0) && (old_WDT < cpustate->WDT)) || (cpustate->WDT == 0))
963      {
964         if (PSA) {
965            cpustate->prescaler++;
966            if (cpustate->prescaler >= (1 << PS)) {   /* Prescale values from 1 to 128 */
967               cpustate->prescaler = 0;
968               CLR(cpustate->STATUS, TO_FLAG);
969               pic16c62x_soft_reset(cpustate);
970            }
971         }
972         else {
973            CLR(cpustate->STATUS, TO_FLAG);
974            pic16c62x_soft_reset(cpustate);
975         }
976      }
977   }
978}
979
980
981/****************************************************************************
982 *  Update Timer
983 ****************************************************************************/
984
985static void pic16c62x_update_timer(pic16c62x_state *cpustate, int counts)
986{
987   if (PSA == 0) {
988      cpustate->prescaler += counts;
989      if (cpustate->prescaler >= (2 << PS)) {   /* Prescale values from 2 to 256 */
990         cpustate->TMR0 += (cpustate->prescaler / (2 << PS));
991         cpustate->prescaler %= (2 << PS);   /* Overflow prescaler */
992      }
993   }
994   else {
995      cpustate->TMR0 += counts;
996   }
997}
998
999
1000/****************************************************************************
1001 *  Execute IPeriod. Return 0 if emulation should be stopped
1002 ****************************************************************************/
1003
1004static CPU_EXECUTE( pic16c62x )
1005{
1006   pic16c62x_state *cpustate = get_safe_token(device);
1007   UINT8 T0_in;
1008
1009   update_internalram_ptr(cpustate);
1010
1011   cpustate->icount = cycles;
1012
1013   do
1014   {
1015      if (PD == 0)                  /* Sleep Mode */
1016      {
1017         cpustate->inst_cycles = 1;
1018         debugger_instruction_hook(device, cpustate->PC);
1019         if (WDTE) {
1020            pic16c62x_update_watchdog(cpustate, 1);
1021         }
1022      }
1023      else
1024      {
1025         cpustate->PREVPC = cpustate->PC;
1026
1027         debugger_instruction_hook(device, cpustate->PC);
1028
1029         cpustate->opcode.d = M_RDOP(cpustate->PC);
1030         cpustate->PC++;
1031         cpustate->PCL++;
1032
1033         cpustate->inst_cycles = opcode_table[cpustate->opcode.w.l & 16383].cycles;
1034         (*opcode_table[cpustate->opcode.w.l & 16383].function)(cpustate);
1035
1036         if (T0CS) {                  /* Count mode */
1037            T0_in = S_T0_IN;
1038            if (T0_in) T0_in = 1;
1039            if (T0SE) {               /* Count falling edge T0 input */
1040               if (FALLING_EDGE_T0) {
1041                  pic16c62x_update_timer(cpustate, 1);
1042               }
1043            }
1044            else {                  /* Count rising edge T0 input */
1045               if (RISING_EDGE_T0) {
1046                  pic16c62x_update_timer(cpustate, 1);
1047               }
1048            }
1049            cpustate->old_T0 = T0_in;
1050         }
1051         else {                     /* Timer mode */
1052            if (cpustate->delay_timer) {
1053               cpustate->delay_timer--;
1054            }
1055            else {
1056               pic16c62x_update_timer(cpustate, cpustate->inst_cycles);
1057            }
1058         }
1059         if (WDTE) {
1060            pic16c62x_update_watchdog(cpustate, cpustate->inst_cycles);
1061         }
1062      }
1063
1064      cpustate->icount -= cpustate->inst_cycles;
1065
1066   } while (cpustate->icount > 0);
1067
1068   return cycles - cpustate->icount;
1069}
1070
1071
1072
1073/**************************************************************************
1074 *  Generic set_info
1075 **************************************************************************/
1076
1077static CPU_SET_INFO( pic16c62x )
1078{
1079   pic16c62x_state *cpustate = get_safe_token(device);
1080
1081   switch (state)
1082   {
1083      /* --- the following bits of info are set as 64-bit signed integers --- */
1084      case CPUINFO_INT_PC:
1085      case CPUINFO_INT_REGISTER + PIC16C62x_PC:      cpustate->PC = info->i; cpustate->PCL = info->i & 0xff ;break;
1086      /* This is actually not a stack pointer, but the stack contents */
1087      /* Stack is a 8 level First In Last Out stack */
1088      case CPUINFO_INT_SP:
1089      case CPUINFO_INT_REGISTER + PIC16C62x_STK7:      cpustate->STACK[7] = info->i;               break;
1090      case CPUINFO_INT_REGISTER + PIC16C62x_STK6:      cpustate->STACK[6] = info->i;               break;
1091      case CPUINFO_INT_REGISTER + PIC16C62x_STK5:      cpustate->STACK[5] = info->i;               break;
1092      case CPUINFO_INT_REGISTER + PIC16C62x_STK4:      cpustate->STACK[4] = info->i;               break;
1093      case CPUINFO_INT_REGISTER + PIC16C62x_STK3:      cpustate->STACK[3] = info->i;               break;
1094      case CPUINFO_INT_REGISTER + PIC16C62x_STK2:      cpustate->STACK[2] = info->i;               break;
1095      case CPUINFO_INT_REGISTER + PIC16C62x_STK1:      cpustate->STACK[1] = info->i;               break;
1096      case CPUINFO_INT_REGISTER + PIC16C62x_STK0:      cpustate->STACK[0] = info->i;               break;
1097      case CPUINFO_INT_REGISTER + PIC16C62x_W:      cpustate->W      = info->i;                  break;
1098      case CPUINFO_INT_REGISTER + PIC16C62x_ALU:      cpustate->ALU    = info->i;                  break;
1099      case CPUINFO_INT_REGISTER + PIC16C62x_OPT:      cpustate->OPTION = info->i & (RBPU_FLAG | INTEDG_FLAG | T0CS_FLAG | T0SE_FLAG | PSA_FLAG | PS_REG);   break;
1100      case CPUINFO_INT_REGISTER + PIC16C62x_TMR0:      cpustate->TMR0   = info->i;                  break;
1101      case CPUINFO_INT_REGISTER + PIC16C62x_WDT:      cpustate->WDT    = info->i;                  break;
1102      case CPUINFO_INT_REGISTER + PIC16C62x_PSCL:      cpustate->prescaler = info->i;               break;
1103      case CPUINFO_INT_REGISTER + PIC16C62x_PRTA:      cpustate->PORTA  = info->i & 0x1f;            break;
1104      case CPUINFO_INT_REGISTER + PIC16C62x_PRTB:      cpustate->PORTB  = info->i;                  break;
1105      case CPUINFO_INT_REGISTER + PIC16C62x_FSR:      cpustate->FSR    = ((info->i & cpustate->picRAMmask) | (UINT8)(~cpustate->picRAMmask));   break;
1106   }
1107}
1108
1109
1110
1111/**************************************************************************
1112 *  Generic get_info
1113 **************************************************************************/
1114
1115static CPU_GET_INFO( pic16c62x )
1116{
1117   pic16c62x_state *cpustate = (device != NULL && device->token != NULL) ? get_safe_token(device) : NULL;
1118
1119   switch (state)
1120   {
1121      /* --- the following bits of info are returned as 64-bit signed integers --- */
1122      case CPUINFO_INT_CONTEXT_SIZE:               info->i = sizeof(pic16c62x_state);   break;
1123      case CPUINFO_INT_INPUT_LINES:               info->i = 1;                  break;
1124      case CPUINFO_INT_DEFAULT_IRQ_VECTOR:         info->i = 0;                  break;
1125      case DEVINFO_INT_ENDIANNESS:               info->i = ENDIANNESS_LITTLE;      break;
1126      case CPUINFO_INT_CLOCK_MULTIPLIER:            info->i = 1;                  break;
1127      case CPUINFO_INT_CLOCK_DIVIDER:               info->i = 4;                  break;
1128      case CPUINFO_INT_MIN_INSTRUCTION_BYTES:         info->i = 2;                  break;
1129      case CPUINFO_INT_MAX_INSTRUCTION_BYTES:         info->i = 2;                  break;
1130      case CPUINFO_INT_MIN_CYCLES:               info->i = 1;                  break;
1131      case CPUINFO_INT_MAX_CYCLES:               info->i = 2;                  break;
1132
1133      case CPUINFO_INT_DATABUS_WIDTH_PROGRAM:         info->i = 16;                  break;
1134      case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM:         info->i = 12;                  break;
1135      case CPUINFO_INT_ADDRBUS_SHIFT_PROGRAM:         info->i = -1;                  break;
1136      case CPUINFO_INT_DATABUS_WIDTH_DATA:         info->i = 8;                  break;
1137      case CPUINFO_INT_ADDRBUS_WIDTH_DATA:         info->i = 8;                  break;
1138      case CPUINFO_INT_ADDRBUS_SHIFT_DATA:         info->i = 0;                  break;
1139      case CPUINFO_INT_DATABUS_WIDTH_IO:            info->i = 8;                  break;
1140      case CPUINFO_INT_ADDRBUS_WIDTH_IO:            info->i = 5;                  break;
1141      case CPUINFO_INT_ADDRBUS_SHIFT_IO:            info->i = 0;                  break;
1142
1143      case CPUINFO_INT_PREVIOUSPC:               info->i = cpustate->PREVPC;                  break;
1144
1145      case CPUINFO_INT_PC:
1146      case CPUINFO_INT_REGISTER + PIC16C62x_PC:      info->i = cpustate->PC;                     break;
1147      /* This is actually not a stack pointer, but the stack contents */
1148      case CPUINFO_INT_SP:
1149      case CPUINFO_INT_REGISTER + PIC16C62x_STK7:      info->i = cpustate->STACK[7];               break;
1150      case CPUINFO_INT_REGISTER + PIC16C62x_STK6:      info->i = cpustate->STACK[6];               break;
1151      case CPUINFO_INT_REGISTER + PIC16C62x_STK5:      info->i = cpustate->STACK[5];               break;
1152      case CPUINFO_INT_REGISTER + PIC16C62x_STK4:      info->i = cpustate->STACK[4];               break;
1153      case CPUINFO_INT_REGISTER + PIC16C62x_STK3:      info->i = cpustate->STACK[3];               break;
1154      case CPUINFO_INT_REGISTER + PIC16C62x_STK2:      info->i = cpustate->STACK[2];               break;
1155      case CPUINFO_INT_REGISTER + PIC16C62x_STK1:      info->i = cpustate->STACK[1];               break;
1156      case CPUINFO_INT_REGISTER + PIC16C62x_STK0:      info->i = cpustate->STACK[0];               break;
1157      case CPUINFO_INT_REGISTER + PIC16C62x_W:         info->i = cpustate->W;                     break;
1158      case CPUINFO_INT_REGISTER + PIC16C62x_ALU:      info->i = cpustate->ALU;                  break;
1159      case CPUINFO_INT_REGISTER + PIC16C62x_STR:      info->i = cpustate->STATUS;                  break;
1160      case CPUINFO_INT_REGISTER + PIC16C62x_OPT:      info->i = cpustate->OPTION;                  break;
1161      case CPUINFO_INT_REGISTER + PIC16C62x_TMR0:      info->i = cpustate->TMR0;                  break;
1162      case CPUINFO_INT_REGISTER + PIC16C62x_WDT:      info->i = cpustate->WDT;                  break;
1163      case CPUINFO_INT_REGISTER + PIC16C62x_PSCL:      info->i = cpustate->prescaler;               break;
1164      case CPUINFO_INT_REGISTER + PIC16C62x_PRTA:      info->i = cpustate->PORTA;                  break;
1165      case CPUINFO_INT_REGISTER + PIC16C62x_PRTB:      info->i = cpustate->PORTB;                  break;
1166      case CPUINFO_INT_REGISTER + PIC16C62x_FSR:      info->i = ((cpustate->FSR & cpustate->picRAMmask) | (UINT8)(~cpustate->picRAMmask));   break;
1167
1168      /* --- the following bits of info are returned as pointers to data or functions --- */
1169      case CPUINFO_FCT_SET_INFO:                  info->setinfo = CPU_SET_INFO_NAME(pic16c62x);   break;
1170      case CPUINFO_FCT_INIT:                     info->init = CPU_INIT_NAME(pic16c62x);         break;
1171      case CPUINFO_FCT_RESET:                     /* set per-CPU */                        break;
1172      case CPUINFO_FCT_EXIT:                     info->exit = CPU_EXIT_NAME(pic16c62x);         break;
1173      case CPUINFO_FCT_EXECUTE:                  info->execute = CPU_EXECUTE_NAME(pic16c62x);      break;
1174      case CPUINFO_FCT_BURN:                     info->burn = NULL;                        break;
1175      case CPUINFO_FCT_DISASSEMBLE:               info->disassemble = CPU_DISASSEMBLE_NAME(pic16c62x);   break;
1176      case CPUINFO_PTR_INSTRUCTION_COUNTER:         info->icount = &cpustate->icount;            break;
1177
1178      /* --- the following bits of info are returned as NULL-terminated strings --- */
1179      case DEVINFO_STR_NAME:                     strcpy(info->s, "PIC16C62x");               break;
1180      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Microchip");               break;
1181      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
1182      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                  break;
1183      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright Tony La Porta");      break;
1184
1185      case CPUINFO_STR_FLAGS:
1186         sprintf(info->s, "%01x%c%c%c%c%c %c%c%c%03x",
1187            (cpustate->STATUS & 0xe0) >> 5,         /* Register bank */
1188            cpustate->STATUS & 0x10 ? '.':'O',      /* WDT Overflow */
1189            cpustate->STATUS & 0x08 ? 'P':'D',      /* Power/Down */
1190            cpustate->STATUS & 0x04 ? 'Z':'.',      /* Zero */
1191            cpustate->STATUS & 0x02 ? 'c':'b',      /* Nibble Carry/Borrow */
1192            cpustate->STATUS & 0x01 ? 'C':'B',      /* Carry/Borrow */
1193
1194            cpustate->OPTION & 0x20 ? 'C':'T',      /* Counter/Timer */
1195            cpustate->OPTION & 0x10 ? 'N':'P',      /* Negative/Positive */
1196            cpustate->OPTION & 0x08 ? 'W':'T',      /* WatchDog/Timer */
1197            cpustate->OPTION & 0x08 ? (1<<(cpustate->OPTION&7)) : (2<<(cpustate->OPTION&7)) );
1198         break;
1199
1200      case CPUINFO_STR_REGISTER + PIC16C62x_PC:      sprintf(info->s, "PC:%03X",   cpustate->PC);            break;
1201      case CPUINFO_STR_REGISTER + PIC16C62x_W:         sprintf(info->s, "W:%02X",    cpustate->W);               break;
1202      case CPUINFO_STR_REGISTER + PIC16C62x_ALU:      sprintf(info->s, "ALU:%02X",  cpustate->ALU);            break;
1203      case CPUINFO_STR_REGISTER + PIC16C62x_STR:      sprintf(info->s, "STR:%02X",  cpustate->STATUS);         break;
1204      case CPUINFO_STR_REGISTER + PIC16C62x_TMR0:      sprintf(info->s, "TMR:%02X",  cpustate->TMR0);            break;
1205      case CPUINFO_STR_REGISTER + PIC16C62x_WDT:      sprintf(info->s, "WDT:%04X",  cpustate->WDT);            break;
1206      case CPUINFO_STR_REGISTER + PIC16C62x_OPT:      sprintf(info->s, "OPT:%02X",  cpustate->OPTION);         break;
1207      case CPUINFO_STR_REGISTER + PIC16C62x_STK0:      sprintf(info->s, "STK0:%03X", cpustate->STACK[0]);         break;
1208      case CPUINFO_STR_REGISTER + PIC16C62x_STK1:      sprintf(info->s, "STK1:%03X", cpustate->STACK[1]);         break;
1209      case CPUINFO_STR_REGISTER + PIC16C62x_STK2:      sprintf(info->s, "STK2:%03X", cpustate->STACK[2]);         break;
1210      case CPUINFO_STR_REGISTER + PIC16C62x_STK3:      sprintf(info->s, "STK3:%03X", cpustate->STACK[3]);         break;
1211      case CPUINFO_STR_REGISTER + PIC16C62x_STK4:      sprintf(info->s, "STK4:%03X", cpustate->STACK[4]);         break;
1212      case CPUINFO_STR_REGISTER + PIC16C62x_STK5:      sprintf(info->s, "STK5:%03X", cpustate->STACK[5]);         break;
1213      case CPUINFO_STR_REGISTER + PIC16C62x_STK6:      sprintf(info->s, "STK6:%03X", cpustate->STACK[6]);         break;
1214      case CPUINFO_STR_REGISTER + PIC16C62x_STK7:      sprintf(info->s, "STK7:%03X", cpustate->STACK[7]);         break;
1215      case CPUINFO_STR_REGISTER + PIC16C62x_PRTA:      sprintf(info->s, "PRTA:%01X", ((cpustate->PORTA) & 0x1f));   break;
1216      case CPUINFO_STR_REGISTER + PIC16C62x_PRTB:      sprintf(info->s, "PRTB:%02X", cpustate->PORTB);            break;
1217      case CPUINFO_STR_REGISTER + PIC16C62x_TRSA:      sprintf(info->s, "TRSA:%01X", ((cpustate->TRISA) & 0x1f));   break;
1218      case CPUINFO_STR_REGISTER + PIC16C62x_TRSB:      sprintf(info->s, "TRSB:%02X", cpustate->TRISB);            break;
1219      case CPUINFO_STR_REGISTER + PIC16C62x_FSR:      sprintf(info->s, "FSR:%02X",  ((cpustate->FSR) & cpustate->picRAMmask) | (UINT8)(~cpustate->picRAMmask));   break;
1220      case CPUINFO_STR_REGISTER + PIC16C62x_PSCL:      sprintf(info->s, "PSCL:%c%02X", ((cpustate->OPTION & 0x08) ? 'W':'T'), cpustate->prescaler);   break;
1221   }
1222}
1223
1224
1225/****************************************************************************
1226 *  PIC16C620
1227 ****************************************************************************/
1228/****************************************************************************
1229 *  Internal Memory Map
1230 ****************************************************************************/
1231
1232static ADDRESS_MAP_START( pic16c620_rom, ADDRESS_SPACE_PROGRAM, 16 )
1233   AM_RANGE(0x000, 0x1ff) AM_ROM
1234ADDRESS_MAP_END
1235
1236static ADDRESS_MAP_START( pic16c620_ram, ADDRESS_SPACE_DATA, 8 )
1237   AM_RANGE(0x00, 0x06) AM_RAM
1238   AM_RANGE(0x0a, 0x0c) AM_RAM
1239   AM_RANGE(0x1f, 0x6f) AM_RAM
1240   AM_RANGE(0x80, 0x86) AM_RAM
1241   AM_RANGE(0x8a, 0x8e) AM_RAM
1242   AM_RANGE(0x9f, 0x9f) AM_RAM
1243ADDRESS_MAP_END
1244
1245
1246/****************************************************************************
1247 *  PIC16C620 Reset
1248 ****************************************************************************/
1249
1250static CPU_RESET( pic16c620 )
1251{
1252   pic16c62x_state *cpustate = get_safe_token(device);
1253
1254   update_internalram_ptr(cpustate);
1255
1256   cpustate->picmodel = 0x16C620;
1257   cpustate->picRAMmask = 0xff;
1258   cpustate->reset_vector = 0x0;
1259   pic16c62x_reset_regs(cpustate);
1260   SET(cpustate->STATUS, (TO_FLAG | PD_FLAG));
1261}
1262
1263
1264/**************************************************************************
1265 *  CPU-specific get_info
1266 **************************************************************************/
1267
1268CPU_GET_INFO( pic16c620 )
1269{
1270   switch (state)
1271   {
1272      case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM:         info->i = 9;                     break;
1273      case CPUINFO_INT_ADDRBUS_WIDTH_DATA:         info->i = 8;                     break;
1274
1275      /* --- the following bits of info are returned as pointers to data or functions --- */
1276      case CPUINFO_FCT_RESET:                     info->reset = CPU_RESET_NAME(pic16c620);               break;
1277      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM:   info->internal_map16 = ADDRESS_MAP_NAME(pic16c620_rom);   break;
1278      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA:      info->internal_map8 = ADDRESS_MAP_NAME(pic16c620_ram);   break;
1279
1280      /* --- the following bits of info are returned as NULL-terminated strings --- */
1281      case DEVINFO_STR_NAME:                     strcpy(info->s, "PIC16C620");         break;
1282
1283      default:                              CPU_GET_INFO_CALL(pic16c62x);         break;
1284   }
1285}
1286
1287
1288/****************************************************************************
1289 *  PIC16C621
1290 ****************************************************************************/
1291/****************************************************************************
1292 *  Internal Memory Map
1293 ****************************************************************************/
1294
1295static ADDRESS_MAP_START( pic16c621_rom, ADDRESS_SPACE_PROGRAM, 16 )
1296   AM_RANGE(0x000, 0x3ff) AM_ROM
1297ADDRESS_MAP_END
1298
1299static ADDRESS_MAP_START( pic16c621_ram, ADDRESS_SPACE_DATA, 8 )
1300   AM_RANGE(0x00, 0x06) AM_RAM
1301   AM_RANGE(0x0a, 0x0c) AM_RAM
1302   AM_RANGE(0x1f, 0x6f) AM_RAM
1303   AM_RANGE(0x80, 0x86) AM_RAM
1304   AM_RANGE(0x8a, 0x8e) AM_RAM
1305   AM_RANGE(0x9f, 0x9f) AM_RAM
1306ADDRESS_MAP_END
1307
1308
1309/****************************************************************************
1310 *  PIC16C621 Reset
1311 ****************************************************************************/
1312
1313static CPU_RESET( pic16c621 )
1314{
1315   pic16c62x_state *cpustate = get_safe_token(device);
1316
1317   update_internalram_ptr(cpustate);
1318
1319   cpustate->picmodel = 0x16C621;
1320   cpustate->picRAMmask = 0xff;
1321   cpustate->reset_vector = 0x0;
1322   pic16c62x_reset_regs(cpustate);
1323   SET(cpustate->STATUS, (TO_FLAG | PD_FLAG));
1324}
1325
1326
1327/**************************************************************************
1328 *  CPU-specific get_info
1329 **************************************************************************/
1330
1331CPU_GET_INFO( pic16c621 )
1332{
1333   switch (state)
1334   {
1335      case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM:         info->i = 10;                     break;
1336      case CPUINFO_INT_ADDRBUS_WIDTH_DATA:         info->i = 8;                     break;
1337
1338      /* --- the following bits of info are returned as pointers to data or functions --- */
1339      case CPUINFO_FCT_RESET:                     info->reset = CPU_RESET_NAME(pic16c621);               break;
1340      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM:   info->internal_map16 = ADDRESS_MAP_NAME(pic16c621_rom);   break;
1341      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA:      info->internal_map8 = ADDRESS_MAP_NAME(pic16c621_ram);   break;
1342
1343      /* --- the following bits of info are returned as NULL-terminated strings --- */
1344      case DEVINFO_STR_NAME:                     strcpy(info->s, "PIC16C621");         break;
1345
1346      default:                              CPU_GET_INFO_CALL(pic16c62x);         break;
1347   }
1348}
1349
1350
1351/****************************************************************************
1352 *  PIC16C622
1353 ****************************************************************************/
1354/****************************************************************************
1355 *  Internal Memory Map
1356 ****************************************************************************/
1357
1358static ADDRESS_MAP_START( pic16c622_rom, ADDRESS_SPACE_PROGRAM, 16 )
1359   AM_RANGE(0x000, 0x7ff) AM_ROM
1360ADDRESS_MAP_END
1361
1362static ADDRESS_MAP_START( pic16c622_ram, ADDRESS_SPACE_DATA, 8 )
1363   AM_RANGE(0x00, 0x06) AM_RAM
1364   AM_RANGE(0x0a, 0x0c) AM_RAM
1365   AM_RANGE(0x1f, 0x7f) AM_RAM
1366   AM_RANGE(0x80, 0x86) AM_RAM
1367   AM_RANGE(0x8a, 0x8e) AM_RAM
1368   AM_RANGE(0x9f, 0xbf) AM_RAM
1369ADDRESS_MAP_END
1370
1371
1372/****************************************************************************
1373 *  PIC16C622 Reset
1374 ****************************************************************************/
1375
1376static CPU_RESET( pic16c622 )
1377{
1378   pic16c62x_state *cpustate = get_safe_token(device);
1379
1380   update_internalram_ptr(cpustate);
1381
1382   cpustate->picmodel = 0x16C622;
1383   cpustate->picRAMmask = 0xff;
1384   cpustate->reset_vector = 0x0;
1385   pic16c62x_reset_regs(cpustate);
1386   SET(cpustate->STATUS, (TO_FLAG | PD_FLAG));
1387}
1388
1389
1390/**************************************************************************
1391 *  CPU-specific get_info
1392 **************************************************************************/
1393
1394CPU_GET_INFO( pic16c622 )
1395{
1396   switch (state)
1397   {
1398      case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM:         info->i = 11;                     break;
1399      case CPUINFO_INT_ADDRBUS_WIDTH_DATA:         info->i = 8;                     break;
1400
1401      /* --- the following bits of info are returned as pointers to data or functions --- */
1402      case CPUINFO_FCT_RESET:                     info->reset = CPU_RESET_NAME(pic16c622);               break;
1403      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM:   info->internal_map16 = ADDRESS_MAP_NAME(pic16c622_rom);   break;
1404      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA:      info->internal_map8 = ADDRESS_MAP_NAME(pic16c622_ram);   break;
1405
1406      /* --- the following bits of info are returned as NULL-terminated strings --- */
1407      case DEVINFO_STR_NAME:                     strcpy(info->s, "PIC16C622");         break;
1408
1409      default:                              CPU_GET_INFO_CALL(pic16c62x);         break;
1410   }
1411}
1412
1413
1414/****************************************************************************
1415 *  PIC16C620A
1416 ****************************************************************************/
1417/****************************************************************************
1418 *  Internal Memory Map
1419 ****************************************************************************/
1420
1421static ADDRESS_MAP_START( pic16c620a_rom, ADDRESS_SPACE_PROGRAM, 16 )
1422   AM_RANGE(0x000, 0x1ff) AM_ROM
1423ADDRESS_MAP_END
1424
1425static ADDRESS_MAP_START( pic16c620a_ram, ADDRESS_SPACE_DATA, 8 )
1426   AM_RANGE(0x00, 0x06) AM_RAM
1427   AM_RANGE(0x0a, 0x0c) AM_RAM
1428   AM_RANGE(0x1f, 0x6f) AM_RAM
1429   AM_RANGE(0x70, 0x7f) AM_RAM AM_SHARE(0)
1430   AM_RANGE(0x80, 0x86) AM_RAM
1431   AM_RANGE(0x8a, 0x8e) AM_RAM
1432   AM_RANGE(0x9f, 0x9f) AM_RAM
1433   AM_RANGE(0xf0, 0xff) AM_RAM AM_SHARE(0)
1434ADDRESS_MAP_END
1435
1436
1437/****************************************************************************
1438 *  PIC16C620A Reset
1439 ****************************************************************************/
1440
1441static CPU_RESET( pic16c620a )
1442{
1443   pic16c62x_state *cpustate = get_safe_token(device);
1444
1445   update_internalram_ptr(cpustate);
1446
1447   cpustate->picmodel = 0x16C620A;
1448   cpustate->picRAMmask = 0xff;
1449   cpustate->reset_vector = 0x0;
1450   pic16c62x_reset_regs(cpustate);
1451   SET(cpustate->STATUS, (TO_FLAG | PD_FLAG));
1452}
1453
1454
1455/**************************************************************************
1456 *  CPU-specific get_info
1457 **************************************************************************/
1458
1459CPU_GET_INFO( pic16c620a )
1460{
1461   switch (state)
1462   {
1463      case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM:         info->i = 9;                     break;
1464      case CPUINFO_INT_ADDRBUS_WIDTH_DATA:         info->i = 8;                     break;
1465
1466      /* --- the following bits of info are returned as pointers to data or functions --- */
1467      case CPUINFO_FCT_RESET:                     info->reset = CPU_RESET_NAME(pic16c620a);               break;
1468      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM:   info->internal_map16 = ADDRESS_MAP_NAME(pic16c620a_rom);   break;
1469      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA:      info->internal_map8 = ADDRESS_MAP_NAME(pic16c620a_ram);   break;
1470
1471      /* --- the following bits of info are returned as NULL-terminated strings --- */
1472      case DEVINFO_STR_NAME:                     strcpy(info->s, "PIC16C620A");         break;
1473
1474      default:                              CPU_GET_INFO_CALL(pic16c62x);         break;
1475   }
1476}
1477
1478
1479/****************************************************************************
1480 *  PIC16C621A
1481 ****************************************************************************/
1482/****************************************************************************
1483 *  Internal Memory Map
1484 ****************************************************************************/
1485
1486static ADDRESS_MAP_START( pic16c621a_rom, ADDRESS_SPACE_PROGRAM, 16 )
1487   AM_RANGE(0x000, 0x3ff) AM_ROM
1488ADDRESS_MAP_END
1489
1490static ADDRESS_MAP_START( pic16c621a_ram, ADDRESS_SPACE_DATA, 8 )
1491   AM_RANGE(0x00, 0x06) AM_RAM
1492   AM_RANGE(0x0a, 0x0c) AM_RAM
1493   AM_RANGE(0x1f, 0x6f) AM_RAM
1494   AM_RANGE(0x70, 0x7f) AM_RAM AM_SHARE(0)
1495   AM_RANGE(0x80, 0x86) AM_RAM
1496   AM_RANGE(0x8a, 0x8e) AM_RAM
1497   AM_RANGE(0x9f, 0x9f) AM_RAM
1498   AM_RANGE(0xf0, 0xff) AM_RAM AM_SHARE(0)
1499ADDRESS_MAP_END
1500
1501
1502/****************************************************************************
1503 *  PIC16C621A Reset
1504 ****************************************************************************/
1505
1506static CPU_RESET( pic16c621a )
1507{
1508   pic16c62x_state *cpustate = get_safe_token(device);
1509
1510   update_internalram_ptr(cpustate);
1511
1512   cpustate->picmodel = 0x16C621A;
1513   cpustate->picRAMmask = 0xff;
1514   cpustate->reset_vector = 0x0;
1515   pic16c62x_reset_regs(cpustate);
1516   SET(cpustate->STATUS, (TO_FLAG | PD_FLAG));
1517}
1518
1519
1520/**************************************************************************
1521 *  CPU-specific get_info
1522 **************************************************************************/
1523
1524CPU_GET_INFO( pic16c621a )
1525{
1526   switch (state)
1527   {
1528      case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM:         info->i = 10;                     break;
1529      case CPUINFO_INT_ADDRBUS_WIDTH_DATA:         info->i = 8;                     break;
1530
1531      /* --- the following bits of info are returned as pointers to data or functions --- */
1532      case CPUINFO_FCT_RESET:                     info->reset = CPU_RESET_NAME(pic16c621a);               break;
1533      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM:   info->internal_map16 = ADDRESS_MAP_NAME(pic16c621a_rom);   break;
1534      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA:      info->internal_map8 = ADDRESS_MAP_NAME(pic16c621a_ram);   break;
1535
1536      /* --- the following bits of info are returned as NULL-terminated strings --- */
1537      case DEVINFO_STR_NAME:                     strcpy(info->s, "PIC16C621A");         break;
1538
1539      default:                              CPU_GET_INFO_CALL(pic16c62x);         break;
1540   }
1541}
1542
1543
1544/****************************************************************************
1545 *  PIC16C622A
1546 ****************************************************************************/
1547/****************************************************************************
1548 *  Internal Memory Map
1549 ****************************************************************************/
1550
1551static ADDRESS_MAP_START( pic16c622a_rom, ADDRESS_SPACE_PROGRAM, 16 )
1552   AM_RANGE(0x000, 0x7ff) AM_ROM
1553ADDRESS_MAP_END
1554
1555static ADDRESS_MAP_START( pic16c622a_ram, ADDRESS_SPACE_DATA, 8 )
1556   AM_RANGE(0x00, 0x06) AM_RAM
1557   AM_RANGE(0x0a, 0x0c) AM_RAM
1558   AM_RANGE(0x1f, 0x6f) AM_RAM
1559   AM_RANGE(0x70, 0x7f) AM_RAM AM_SHARE(0)
1560   AM_RANGE(0x80, 0x86) AM_RAM
1561   AM_RANGE(0x8a, 0x8e) AM_RAM
1562   AM_RANGE(0x9f, 0xbf) AM_RAM
1563   AM_RANGE(0xf0, 0xff) AM_RAM AM_SHARE(0)
1564ADDRESS_MAP_END
1565
1566
1567/****************************************************************************
1568 *  PIC16C622A Reset
1569 ****************************************************************************/
1570
1571static CPU_RESET( pic16c622a )
1572{
1573   pic16c62x_state *cpustate = get_safe_token(device);
1574
1575   update_internalram_ptr(cpustate);
1576
1577   cpustate->picmodel = 0x16C622A;
1578   cpustate->picRAMmask = 0xff;
1579   cpustate->reset_vector = 0x0;
1580   pic16c62x_reset_regs(cpustate);
1581   SET(cpustate->STATUS, (TO_FLAG | PD_FLAG));
1582}
1583
1584
1585/**************************************************************************
1586 *  CPU-specific get_info
1587 **************************************************************************/
1588
1589CPU_GET_INFO( pic16c622a )
1590{
1591   switch (state)
1592   {
1593      case CPUINFO_INT_ADDRBUS_WIDTH_PROGRAM:         info->i = 11;                     break;
1594      case CPUINFO_INT_ADDRBUS_WIDTH_DATA:         info->i = 8;                     break;
1595
1596      /* --- the following bits of info are returned as pointers to data or functions --- */
1597      case CPUINFO_FCT_RESET:                     info->reset = CPU_RESET_NAME(pic16c622a);               break;
1598      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM:   info->internal_map16 = ADDRESS_MAP_NAME(pic16c622a_rom);   break;
1599      case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA:      info->internal_map8 = ADDRESS_MAP_NAME(pic16c622a_ram);   break;
1600
1601      /* --- the following bits of info are returned as NULL-terminated strings --- */
1602      case DEVINFO_STR_NAME:                     strcpy(info->s, "PIC16C622A");         break;
1603
1604      default:                              CPU_GET_INFO_CALL(pic16c62x);         break;
1605   }
1606}
1607
src/emu/cpu/pic16c62x/dis16c62x.c
r0r6741
1 /**************************************************************************\
2 *                  Microchip PIC16C62X Emulator                            *
3 *                                                                          *
4 *                          Based On                                        *
5 *                  Microchip PIC16C5X Emulator                             *
6 *                    Copyright Tony La Porta                               *
7 *                 Originally written for the MAME project.                 *
8 *                                                                          *
9 *                                                                          *
10 *      Notes : Data is expected to be read from source file as LSB first.  *
11 *                                                                          *
12 \**************************************************************************/
13
14#include <stdio.h>
15#include <string.h>
16
17#include "16c62xdsm.c"
18
19
20unsigned char *Buffer;
21
22
23int main(int argc,char *argv[])
24{
25   int  length=0, length_to_dump=0, offset=0, disasm_words=0;
26   int  filelength=0, bytes_read;
27   int  Counter=0;
28
29   FILE *F;
30   char *String_Output;
31
32   if(argc<2)
33   {
34      printf("\n");
35      printf("PIC16C5x Disassembler 1.0 by Tony La Porta (C)2003+\n\n");
36      printf("Usage: dis16c5x <input-file> [ <start-addr> [ <num-of-addr> ] ]\n");
37      printf("                <input-file>  source file data must be MSB first\n");
38      printf("                <start-addr>  starting address to disassemble from (decimal)\n");
39      printf("                <num-of-addr> number of addresses to disassemble (decimal)\n");
40      printf("                              Preceed values with 0x if HEX values preffered\n");
41      exit(1);
42   }
43
44   if(!(F=fopen(argv[1],"rb")))
45   {
46      printf("\n%s: Can't open file %s\n",argv[0],argv[1]);
47      exit(2);
48   }
49   argv++; argc--;
50   if (argv[1])
51   {
52      offset = strtol(argv[1],NULL,0);
53      argv++; argc--;
54   }
55   if (argv[1])
56   {
57      length = strtol(argv[1],NULL,0);
58      argv++; argc--;
59   }
60
61   fseek(F,0, SEEK_END);
62   filelength = ftell(F);
63
64   length *= 2;
65
66   if ((length > (filelength - (offset*2))) || (length == 0)) length = filelength - (offset*2);
67   printf("Length=%04Xh(words)  Offset=$%04Xh  filelength=%04Xh(words) %04Xh(bytes)\n",length/2,offset,filelength/2,filelength);
68   length_to_dump = length;
69   printf("Starting from %d, dumping %d opcodes (word size)\n",offset,length/2);
70   Buffer = calloc((filelength+1),sizeof(char));
71   if (Buffer==NULL)
72   {
73      printf("Out of Memory !!!");
74      fclose(F);
75      exit(3);
76   }
77   String_Output = calloc(80,sizeof(char));
78   if (String_Output==NULL)
79   {
80      printf("Out of Memory !!!");
81      free(Buffer);
82      fclose(F);
83      exit(4);
84   }
85
86   if (fseek(F,0,SEEK_SET) != 0)
87   {
88      printf("Error seeking to beginning of file\n");
89      free(String_Output);
90      free(Buffer);
91      fclose(F);
92      exit(5);
93   }
94
95   Counter = offset;
96   bytes_read = fread(Buffer,sizeof(char),filelength,F);
97   if (bytes_read >= length)
98   {
99      for (; length > 0; length -= (disasm_words*2))
100      {
101         int ii;
102         disasm_words = Dasm16C5x(String_Output,Counter);
103         printf("$%03X: ",Counter);
104         for (ii = 0; ii < disasm_words; ii++)
105         {
106            if (((Counter*2) + ii) > filelength)   /* Past end of length to dump ? */
107            {
108               sprintf(String_Output,"???? dw %02.2X%02.2Xh (Past end of disassembly !)",Buffer[((Counter-1)*2)+1],Buffer[((Counter-1)*2)]);
109            }
110            else
111            {
112               printf("%02.2x%02.2x ",Buffer[(Counter*2)+1],Buffer[(Counter*2)]);
113            }
114            Counter++ ;
115         }
116         for (; ii < 4; ii++)
117         {
118            printf(" ");
119         }
120         printf("\t%s\n",String_Output);
121      }
122   }
123   else
124   {
125      printf("ERROR length to dump was %d ", length_to_dump/2);
126      printf(", but bytes read from file were %d\n", bytes_read/2);
127      free(String_Output);
128      free(Buffer);
129      fclose(F);
130      exit(7);
131   }
132   free(String_Output);
133   free(Buffer);
134   fclose(F);
135   return(0);
136}
src/emu/cpu/pic16c62x/pic16c62x.h
r0r6741
1 /**************************************************************************\
2 *                  Microchip PIC16C62X Emulator                            *
3 *                                                                          *
4 *                          Based On                                        *
5 *                  Microchip PIC16C5X Emulator                             *
6 *                    Copyright Tony La Porta                               *
7 *                 Originally written for the MAME project.                 *
8 *                                                                          *
9 *                                                                          *
10 *      Addressing architecture is based on the Harvard addressing scheme.  *
11 *                                                                          *
12 \**************************************************************************/
13
14#pragma once
15
16#ifndef __PIC16C62X_H__
17#define __PIC16C62X_H__
18
19
20#include "cpuintrf.h"
21
22
23/**************************************************************************
24 *  Internal Clock divisor
25 *
26 *  External Clock is divided internally by 4 for the instruction cycle
27 *  times. (Each instruction cycle passes through 4 machine states). This
28 *  is handled by the cpu execution engine.
29 */
30
31enum
32{
33   PIC16C62x_PC=1, PIC16C62x_STK0, PIC16C62x_STK1, PIC16C62x_STK2,
34   PIC16C62x_STK3, PIC16C62x_STK4, PIC16C62x_STK5, PIC16C62x_STK6,
35   PIC16C62x_STK7, PIC16C62x_FSR,   PIC16C62x_W,    PIC16C62x_ALU,
36   PIC16C62x_STR,  PIC16C62x_OPT,   PIC16C62x_TMR0, PIC16C62x_PRTA,
37   PIC16C62x_PRTB, PIC16C62x_WDT,  PIC16C62x_TRSA, PIC16C62x_TRSB,
38   PIC16C62x_PSCL
39};
40
41#define PIC16C62x_T0      0
42
43
44/****************************************************************************
45 *  Function to configure the CONFIG register. This is actually hard-wired
46 *  during ROM programming, so should be called in the driver INIT, with
47 *  the value if known (available in HEX dumps of the ROM).
48 */
49
50void pic16c62x_set_config(const device_config *cpu, int data);
51
52
53
54CPU_GET_INFO( pic16c620 );
55#define CPU_PIC16C620 CPU_GET_INFO_NAME( pic16c620 )
56
57
58CPU_GET_INFO( pic16c620a );
59#define CPU_PIC16C620A CPU_GET_INFO_NAME( pic16c620a )
60
61
62//CPU_GET_INFO( pic16cr620a );
63//#define CPU_PIC16CR620A CPU_GET_INFO_NAME( pic16cr620a )
64
65
66CPU_GET_INFO( pic16c621 );
67#define CPU_PIC16C621 CPU_GET_INFO_NAME( pic16c621 )
68
69
70CPU_GET_INFO( pic16c621a );
71#define CPU_PIC16C621A CPU_GET_INFO_NAME( pic16c621a )
72
73CPU_GET_INFO( pic16c622 );
74#define CPU_PIC16C622 CPU_GET_INFO_NAME( pic16c622 )
75
76
77CPU_GET_INFO( pic16c622a );
78#define CPU_PIC16C622A CPU_GET_INFO_NAME( pic16c622a )
79
80
81CPU_DISASSEMBLE( pic16c62x );
82
83
84#endif   /* __PIC16C62X_H__ */
src/emu/cpu/pic16c62x/16c62xdsm.c
r0r6741
1 /**************************************************************************\
2 *                  Microchip PIC16C62X Emulator                            *
3 *                                                                          *
4 *                          Based On                                        *
5 *                  Microchip PIC16C5X Emulator                             *
6 *                    Copyright Tony La Porta                               *
7 *                 Originally written for the MAME project.                 *
8 *                                                                          *
9 *                                                                          *
10 *      Addressing architecture is based on the Harvard addressing scheme.  *
11 *                                                                          *
12 *         Many thanks to those involved in the i8039 Disassembler          *
13 *                        as this was based on it.                          *
14 *                                                                          *
15 *                                                                          *
16 *                                                                          *
17 * A Address to jump to.                                                    *
18 * B Bit address within an 8-bit file register.                             *
19 * D Destination select (0 = store result in W (accumulator))               *
20 *                      (1 = store result in file register)                 *
21 * F Register file address (00-1F).                                         *
22 * K Literal field, constant data.                                          *
23 * X Not used                                                               *
24 *                                                                          *
25 \**************************************************************************/
26
27#include <stdio.h>
28#include <stdlib.h>
29#include <string.h>
30#include <ctype.h>
31
32#include "cpuintrf.h"
33#include "mame.h"
34static const UINT8 *rombase;
35static const UINT8 *rambase;
36static offs_t pcbase;
37#define READOP16(A)  (rombase[(A) - pcbase] | (rombase[(A) + 1 - pcbase] << 8))
38#define READARG16(A) (rambase[(A) - pcbase] | (rambase[(A) + 1 - pcbase] << 8))
39
40
41
42typedef unsigned char byte;
43typedef unsigned short int word;
44
45#define FMT(a,b) a, b
46#define PTRS_PER_FORMAT 2
47
48/* Registers bank 0/1 */
49static const char *const regfile[32] = { "Reg$00 (INDF)",    "Reg$01 (TMR0/OPTION)",    "Reg$02 (PCL)",  "Reg$03 (STATUS)", "Reg$04 (FSR)", "Reg$05 (PORTA/TRISA)", "Reg$06 (PORTB/TRISB)", "Reg$07",
50                         "Reg$08", "Reg$09", "Reg$0A (PCLATH)", "Reg$0B (INTCON)", "Reg$0C (PIR1/PIE1)", "Reg$0D", "Reg$0E (none/PCON)", "Reg$0F",
51                         "Reg$10", "Reg$11", "Reg$12", "Reg$13", "Reg$14", "Reg$15", "Reg$16", "Reg$17",
52                         "Reg$18", "Reg$19", "Reg$1A", "Reg$1B", "Reg$1C", "Reg$1D", "Reg$1E", "Reg$1F (CMCON/VRCON)" };
53/* Registers bank 1 */
54/*static const char *const regfile1[32] = { "Reg$00 (INDF)",    "Reg$01 (OPTION)",    "Reg$02 (PCL)",  "Reg$03 (STATUS)", "Reg$04 (FSR)", "Reg$05 (TRISA)", "Reg$06 (TRISB)", "Reg$07",
55                                 "Reg$08", "Reg$09", "Reg$0A (PCLATH)", "Reg$0B (INTCON)", "Reg$0C (PIE1)", "Reg$0D", "Reg$0E (PCON)", "Reg$0F",
56                                 "Reg$10", "Reg$11", "Reg$12", "Reg$13", "Reg$14", "Reg$15", "Reg$16", "Reg$17",
57                                 "Reg$18", "Reg$19", "Reg$1A", "Reg$1B", "Reg$1C", "Reg$1D", "Reg$1E", "Reg$1F (VRCON)" };
58static const char **regfile[2] = { regfile0, regfile1 };*/
59
60static const char *const dest[2] = { "W", "Reg" };
61
62static const char *const PIC16C62xFormats[] = {
63   FMT("0000000xx00000", "nop"),
64   FMT("00000000001000", "return"),
65   FMT("00000000001001", "retfie"),
66   FMT("00000001100011", "sleep"),
67   FMT("00000001100100", "clrwdt"),
68   FMT("0000001fffffff", "movwf  %F"),
69   FMT("00000100000011", "clrw"),
70   FMT("0000011fffffff", "clrf   %F"),
71   FMT("000010dfffffff", "subwf  %F,%D"),
72   FMT("000011dfffffff", "decf   %F,%D"),
73   FMT("000100dfffffff", "iorwf  %F,%D"),
74   FMT("000101dfffffff", "andwf  %F,%D"),
75   FMT("000110dfffffff", "xorwf  %F,%D"),
76   FMT("000111dfffffff", "addwf  %F,%D"),
77   FMT("001000dfffffff", "movf   %F,%D"),
78   FMT("001001dfffffff", "comf   %F,%D"),
79   FMT("001010dfffffff", "incf   %F,%D"),
80   FMT("001011dfffffff", "decfsz %F,%D"),
81   FMT("001100dfffffff", "rrf    %F,%D"),
82   FMT("001101dfffffff", "rlf    %F,%D"),
83   FMT("001110dfffffff", "swapf  %F,%D"),
84   FMT("001111dfffffff", "incfsz %F,%D"),
85   FMT("0100bbbfffffff", "bcf    %F,%B"),
86   FMT("0101bbbfffffff", "bsf    %F,%B"),
87   FMT("0110bbbfffffff", "btfsc  %F,%B"),
88   FMT("0111bbbfffffff", "btfss  %F,%B"),
89   FMT("1101xxkkkkkkkk", "retlw  %K"),
90   FMT("100aaaaaaaaaaa", "call   %A"),
91   FMT("101aaaaaaaaaaa", "goto   %A"),
92   FMT("1100xxkkkkkkkk", "movlw  %K"),
93   FMT("111000kkkkkkkk", "iorlw  %K"),
94   FMT("111001kkkkkkkk", "andlw  %K"),
95   FMT("111010kkkkkkkk", "xorlw  %K"),
96   FMT("11110xkkkkkkkk", "sublw  %K"),
97   FMT("11111xkkkkkkkk", "addlw  %K"),
98   NULL
99};
100
101#define MAX_OPS (((sizeof(PIC16C62xFormats) / sizeof(PIC16C62xFormats[0])) - 1) / PTRS_PER_FORMAT)
102
103typedef struct opcode {
104   word mask;         /* instruction mask */
105   word bits;         /* constant bits */
106   word extcode;      /* value that gets extension code */
107   const char *parse;   /* how to parse bits */
108   const char *fmt;   /* instruction format */
109} PIC16C62xOpcode;
110
111static PIC16C62xOpcode Op[MAX_OPS+1];
112static int OpInizialized = 0;
113
114static void InitDasm16C5x(void)
115{
116   const char *p;
117   const char *const *ops;
118   word mask, bits;
119   int bit;
120   int i;
121
122   ops = PIC16C62xFormats; i = 0;
123   while (*ops)
124   {
125      p = *ops;
126      mask = 0; bits = 0; bit = 13;
127      while (*p && bit >= 0)
128      {
129         switch (*p++)
130         {
131            case '1': mask |= 1<<bit; bits |= 1<<bit; bit--; break;
132            case '0': mask |= 1<<bit; bit--; break;
133            case ' ': break;
134            case 'a':
135            case 'b':
136            case 'd':
137            case 'f':
138            case 'k':
139            case 'x':
140               bit --;
141               break;
142            default: fatalerror("Invalid instruction encoding '%s %s'",
143               ops[0],ops[1]);
144         }
145      }
146      if (bit != -1 )
147      {
148         fatalerror("not enough bits in encoding '%s %s' %d",
149            ops[0],ops[1],bit);
150      }
151      while (isspace((UINT8)*p)) p++;
152      if (*p) Op[i].extcode = *p;
153      Op[i].bits = bits;
154      Op[i].mask = mask;
155      Op[i].fmt = ops[1];
156      Op[i].parse = ops[0];
157
158      ops += PTRS_PER_FORMAT;
159      i++;
160   }
161
162   OpInizialized = 1;
163}
164
165CPU_DISASSEMBLE( pic16c62x )
166{
167   int a, b, d, f, k;   /* these can all be filled in by parsing an instruction */
168   int i;
169   int op;
170   int cnt = 1;
171   int code;
172   int bit;
173   char *buffertmp;
174   const char *cp;            /* character pointer in OpFormats */
175   UINT32 flags = 0;
176
177   rombase = oprom;
178   rambase = opram;
179   pcbase = 2*pc;
180
181   if (!OpInizialized) InitDasm16C5x();
182
183   op = -1;            /* no matching opcode */
184   code = READOP16(2*pc);
185   for ( i = 0; i < MAX_OPS; i++)
186   {
187      if ((code & Op[i].mask) == Op[i].bits)
188      {
189         if (op != -1)
190         {
191            mame_printf_debug("Error: opcode %04Xh matches %d (%s) and %d (%s)\n",
192               code,i,Op[i].fmt,op,Op[op].fmt);
193         }
194         op = i;
195      }
196   }
197   if (op == -1)
198   {
199      sprintf(buffer,"???? dw %04Xh",code);
200      return cnt;
201   }
202   buffertmp = buffer;
203   if (Op[op].extcode)      /* Actually, theres no double length opcodes */
204   {
205      bit = 29;
206      code <<= 16;
207      code |= READARG16(2*(pc+cnt));
208      cnt++;
209   }
210   else
211   {
212      bit = 13;
213   }
214
215   /* shift out operands */
216   cp = Op[op].parse;
217   a = b = d = f = k = 0;
218
219   while (bit >= 0)
220   {
221      /* mame_printf_debug("{%c/%d}",*cp,bit); */
222      switch(*cp)
223      {
224         case 'a': a <<=1; a |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
225         case 'b': b <<=1; b |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
226         case 'd': d <<=1; d |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
227         case 'f': f <<=1; f |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
228         case 'k': k <<=1; k |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
229         case ' ': break;
230         case '1': case '0': case 'x':  bit--; break;
231         case '\0': fatalerror("premature end of parse string, opcode %x, bit = %d",code,bit);
232      }
233      cp++;
234   }
235
236   /* now traverse format string */
237   cp = Op[op].fmt;
238   if (!strncmp(cp, "call", 4))
239      flags = DASMFLAG_STEP_OVER;
240   else if (!strncmp(cp, "ret", 3))
241      flags = DASMFLAG_STEP_OUT;
242
243   while (*cp)
244   {
245      if (*cp == '%')
246      {
247         char num[30], *q;
248         cp++;
249         switch (*cp++)
250         {
251            case 'A': sprintf(num,"$%03X",a); break;
252            case 'B': sprintf(num,"%d",b); break;
253            case 'D': sprintf(num,"%s",dest[d]); break;
254            case 'F': if (f < 0x20) sprintf(num,"%s",regfile[f]); else sprintf(num,"Reg$%02X",f); break;
255            case 'K': sprintf(num,"%02Xh",k); break;
256            default:
257               fatalerror("illegal escape character in format '%s'",Op[op].fmt);
258         }
259         q = num; while (*q) *buffer++ = *q++;
260         *buffer = '\0';
261      }
262      else
263      {
264         *buffer++ = *cp++;
265         *buffer = '\0';
266      }
267   }
268   return cnt | flags | DASMFLAG_SUPPORTED;
269}
src/emu/cpu/cpu.mak
r6740r6741
789789
790790
791791#-------------------------------------------------
792# Microchip PIC16C62x
793#-------------------------------------------------
794
795ifneq ($(filter PIC16C62X,$(CPUS)),)
796OBJDIRS += $(CPUOBJ)/pic16c62x
797CPUOBJS += $(CPUOBJ)/pic16c62x/pic16c62x.o
798DASMOBJS += $(CPUOBJ)/pic16c62x/16c62xdsm.o
799endif
800
801$(CPUOBJ)/pic16c62x/pic16c62x.o:   $(CPUSRC)/pic16c62x/pic16c62x.c \
802                        $(CPUSRC)/pic16c62x/pic16c62x.h
803
804
805
806#-------------------------------------------------
792807# MIPS R3000 (MIPS I/II) series
793808# MIPS R4000 (MIPS III/IV) series
794809# Sony PlayStation CPU (R3000-based + GTE)
src/emu/cpu/z180/z180.c
r6740r6741
20192019      cpustate->daisy = z80daisy_init(device, (const z80_daisy_chain *)device->static_config);
20202020   cpustate->irq_callback = irqcallback;
20212021
2022   SZHVC_add = auto_alloc_array(device->machine, UINT8, 2*256*256);
2023   SZHVC_sub = auto_alloc_array(device->machine, UINT8, 2*256*256);
2024
20222025   /* set up the state table */
20232026   cpustate->state = state_table_template;
20242027   cpustate->state.baseptr = cpustate;
r6740r6741
20642067   int oldval, newval, val;
20652068   UINT8 *padd, *padc, *psub, *psbc;
20662069   /* allocate big flag arrays once */
2067   SZHVC_add = auto_alloc_array(device->machine, UINT8, 2*256*256);
2068   SZHVC_sub = auto_alloc_array(device->machine, UINT8, 2*256*256);
20692070   padd = &SZHVC_add[   0*256];
20702071   padc = &SZHVC_add[256*256];
20712072   psub = &SZHVC_sub[   0*256];
src/emu/cpu/drcuml.c
r6740r6741
100100#define PTYPES_CFUNC   (PTYPES_MEM | 0x4000)
101101#define PTYPES_HAND      (PTYPES_MEM | 0x5000)
102102#define PTYPES_SIZE      (PTYPES_IMM | 0x8000)
103#define PTYPES_SPACE   (PTYPES_IMM | 0x9000)
104#define PTYPES_SPSZ      (PTYPES_IMM | 0xa000)
105#define PTYPES_FMOD      (PTYPES_IMM | 0xb000)
106#define PTYPES_LAB      (PTYPES_IMM | 0xc000)
103#define PTYPES_SCSZ      (PTYPES_IMM | 0x9000)
104#define PTYPES_SPACE   (PTYPES_IMM | 0xa000)
105#define PTYPES_SPSZ      (PTYPES_IMM | 0xb000)
106#define PTYPES_FMOD      (PTYPES_IMM | 0xc000)
107#define PTYPES_LAB      (PTYPES_IMM | 0xd000)
107108
108109/* combinations of types */
109110#define PTYPES_IRM      (PTYPES_IREG | PTYPES_MEM)
r6740r6741
227228   OPINFO1(RESTORE, "restore",  4,   FALSE, NONE, ALL,  ALL,  PINFO(IN, OP, STATE))
228229
229230   /* Integer Operations */
230   OPINFO4(LOAD,    "!load",    4|8, FALSE, NONE, NONE, ALL,  PINFO(OUT, OP, IRM), PINFO(IN, OP, PTR), PINFO(IN, 4, IANY), PINFO(IN, OP, SIZE))
231   OPINFO4(LOADS,   "!loads",   4|8, FALSE, NONE, NONE, ALL,  PINFO(OUT, OP, IRM), PINFO(IN, OP, PTR), PINFO(IN, 4, IANY), PINFO(IN, OP, SIZE))
232   OPINFO4(STORE,   "!store",   4|8, FALSE, NONE, NONE, ALL,  PINFO(IN, OP, PTR), PINFO(IN, 4, IANY), PINFO(IN, OP, IANY), PINFO(IN, OP, SIZE))
231   OPINFO4(LOAD,    "!load",    4|8, FALSE, NONE, NONE, ALL,  PINFO(OUT, OP, IRM), PINFO(IN, OP, PTR), PINFO(IN, 4, IANY), PINFO(IN, OP, SCSZ))
232   OPINFO4(LOADS,   "!loads",   4|8, FALSE, NONE, NONE, ALL,  PINFO(OUT, OP, IRM), PINFO(IN, OP, PTR), PINFO(IN, 4, IANY), PINFO(IN, OP, SCSZ))
233   OPINFO4(STORE,   "!store",   4|8, FALSE, NONE, NONE, ALL,  PINFO(IN, OP, PTR), PINFO(IN, 4, IANY), PINFO(IN, OP, IANY), PINFO(IN, OP, SCSZ))
233234   OPINFO3(READ,    "!read",    4|8, FALSE, NONE, NONE, ALL,  PINFO(OUT, OP, IRM), PINFO(IN, 4, IANY), PINFO(IN, OP, SPSZ))
234235   OPINFO4(READM,   "!readm",   4|8, FALSE, NONE, NONE, ALL,  PINFO(OUT, OP, IRM), PINFO(IN, 4, IANY), PINFO(IN, OP, IANY), PINFO(IN, OP, SPSZ))
235236   OPINFO3(WRITE,   "!write",   4|8, FALSE, NONE, NONE, ALL,  PINFO(IN, 4, IANY), PINFO(IN, OP, IANY), PINFO(IN, OP, SPSZ))
r6740r6741
11931194            else if (typemask == PTYPES_SPSZ)
11941195               dest += sprintf(dest, "%s_%s", address_space_names[param->value / 16], sizes[param->value % 16]);
11951196
1197            /* size + scale immediate */
1198            else if (typemask == PTYPES_SCSZ)
1199            {
1200               int scale = param->value / 16;
1201               int size  = param->value % 16;
1202               if (scale == size)
1203                  dest += sprintf(dest, "%s", sizes[size]);
1204               else
1205                  dest += sprintf(dest, "%s_x%d", sizes[size], 1 << scale);
1206            }
1207
11961208            /* fmod immediate */
11971209            else if (typemask == PTYPES_FMOD)
11981210               dest += sprintf(dest, "%s", fmods[param->value]);
src/emu/cpu/drcuml.h
r6740r6741
163163};
164164
165165
166/* scale/space combinations */
167enum
168{
169   DRCUML_SCSIZE_BYTE     =  (0 * 16) + DRCUML_SIZE_BYTE,
170   DRCUML_SCSIZE_BYTE_x2  =  (1 * 16) + DRCUML_SIZE_BYTE,
171   DRCUML_SCSIZE_BYTE_x4  =  (2 * 16) + DRCUML_SIZE_BYTE,
172   DRCUML_SCSIZE_BYTE_x8  =  (3 * 16) + DRCUML_SIZE_BYTE,
173   DRCUML_SCSIZE_WORD_x1  =  (0 * 16) + DRCUML_SIZE_WORD,
174   DRCUML_SCSIZE_WORD     =  (1 * 16) + DRCUML_SIZE_WORD,
175   DRCUML_SCSIZE_WORD_x4  =  (2 * 16) + DRCUML_SIZE_WORD,
176   DRCUML_SCSIZE_WORD_x8  =  (3 * 16) + DRCUML_SIZE_WORD,
177   DRCUML_SCSIZE_DWORD_x1 =  (0 * 16) + DRCUML_SIZE_DWORD,
178   DRCUML_SCSIZE_DWORD_x2 =  (1 * 16) + DRCUML_SIZE_DWORD,
179   DRCUML_SCSIZE_DWORD    =  (2 * 16) + DRCUML_SIZE_DWORD,
180   DRCUML_SCSIZE_DWORD_x8 =  (3 * 16) + DRCUML_SIZE_DWORD,
181   DRCUML_SCSIZE_QWORD_x1 =  (0 * 16) + DRCUML_SIZE_QWORD,
182   DRCUML_SCSIZE_QWORD_x2 =  (1 * 16) + DRCUML_SIZE_QWORD,
183   DRCUML_SCSIZE_QWORD_x4 =  (2 * 16) + DRCUML_SIZE_QWORD,
184   DRCUML_SCSIZE_QWORD    =  (3 * 16) + DRCUML_SIZE_QWORD
185};
186
187
166188/* size/space combinations */
167189enum
168190{
src/emu/cpu/i386/i386op16.c
r6740r6741
31103110   UINT8 modrm = FETCH(cpustate);
31113111   UINT32 limit;
31123112   I386_SREG seg;
3113   
3113
31143114   if(PROTECTED_MODE)
31153115   {
31163116      memset(&seg, 0, sizeof(seg));
src/emu/cpu/drcbex64.c
r6740r6741
1818
1919    * Identify common pairs and optimize output
2020
21    * Convert AND 0xff/0xffff to movzx
22
2321    * Convert SUB a,0,b to NEG
2422
2523    * Optimize, e.g., and [r5],i0,$FF to use rbx as temporary register
r6740r6741
38083806
38093807static x86code *op_load(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
38103808{
3811   drcuml_parameter dstp, basep, indp, sizep;
3812   int basereg, dstreg;
3809   drcuml_parameter dstp, basep, indp, scalesizep;
3810   int basereg, dstreg, scale, size;
38133811   INT32 baseoffs;
38143812
38153813   /* validate instruction */
r6740r6741
38183816   assert_no_flags(inst);
38193817
38203818   /* normalize parameters */
3821   param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &basep, PTYPE_M, &indp, PTYPE_MRI, &sizep, PTYPE_I);
3819   param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &basep, PTYPE_M, &indp, PTYPE_MRI, &scalesizep, PTYPE_I);
3820   scale = 1 << (scalesizep.value / 16);
3821   size = scalesizep.value % 16;
38223822
38233823   /* determine the pointer base */
38243824   basereg = get_base_register_and_offset(drcbe, &dst, basep.value, REG_RDX, &baseoffs);
r6740r6741
38293829   /* immediate index */
38303830   if (indp.type == DRCUML_PTYPE_IMMEDIATE)
38313831   {
3832      if (sizep.value == DRCUML_SIZE_BYTE)
3833         emit_movzx_r32_m8(&dst, dstreg, MBD(basereg, baseoffs + 1*indp.value));      // movzx dstreg,[basep + 1*indp]
3834      else if (sizep.value == DRCUML_SIZE_WORD)
3835         emit_movzx_r32_m16(&dst, dstreg, MBD(basereg, baseoffs + 2*indp.value));   // movzx dstreg,[basep + 2*indp]
3836      else if (sizep.value == DRCUML_SIZE_DWORD)
3837         emit_mov_r32_m32(&dst, dstreg, MBD(basereg, baseoffs + 4*indp.value));      // mov   dstreg,[basep + 4*indp]
3838      else if (sizep.value == DRCUML_SIZE_QWORD)
3839         emit_mov_r64_m64(&dst, dstreg, MBD(basereg, baseoffs + 8*indp.value));      // mov   dstreg,[basep + 8*indp]
3832      if (size == DRCUML_SIZE_BYTE)
3833         emit_movzx_r32_m8(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value));   // movzx dstreg,[basep + scale*indp]
3834      else if (size == DRCUML_SIZE_WORD)
3835         emit_movzx_r32_m16(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value));// movzx dstreg,[basep + scale*indp]
3836      else if (size == DRCUML_SIZE_DWORD)
3837         emit_mov_r32_m32(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value));   // mov   dstreg,[basep + scale*indp]
3838      else if (size == DRCUML_SIZE_QWORD)
3839         emit_mov_r64_m64(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value));   // mov   dstreg,[basep + scale*indp]
38403840   }
38413841
38423842   /* other index */
r6740r6741
38443844   {
38453845      int indreg = param_select_register(REG_ECX, &indp, NULL);
38463846      emit_mov_r32_p32(drcbe, &dst, indreg, &indp);
3847      if (sizep.value == DRCUML_SIZE_BYTE)
3848         emit_movzx_r32_m8(&dst, dstreg, MBISD(basereg, indreg, 1, baseoffs));      // movzx dstreg,[basep + 1*indp]
3849      else if (sizep.value == DRCUML_SIZE_WORD)
3850         emit_movzx_r32_m16(&dst, dstreg, MBISD(basereg, indreg, 2, baseoffs));      // movzx dstreg,[basep + 2*indp]
3851      else if (sizep.value == DRCUML_SIZE_DWORD)
3852         emit_mov_r32_m32(&dst, dstreg, MBISD(basereg, indreg, 4, baseoffs));      // mov   dstreg,[basep + 4*indp]
3853      else if (sizep.value == DRCUML_SIZE_QWORD)
3854         emit_mov_r64_m64(&dst, dstreg, MBISD(basereg, indreg, 8, baseoffs));      // mov   dstreg,[basep + 8*indp]
3847      if (size == DRCUML_SIZE_BYTE)
3848         emit_movzx_r32_m8(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs));   // movzx dstreg,[basep + scale*indp]
3849      else if (size == DRCUML_SIZE_WORD)
3850         emit_movzx_r32_m16(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs));   // movzx dstreg,[basep + scale*indp]
3851      else if (size == DRCUML_SIZE_DWORD)
3852         emit_mov_r32_m32(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs));   // mov   dstreg,[basep + scale*indp]
3853      else if (size == DRCUML_SIZE_QWORD)
3854         emit_mov_r64_m64(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs));   // mov   dstreg,[basep + scale*indp]
38553855   }
38563856
38573857   /* store result */
r6740r6741
38703870
38713871static x86code *op_loads(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
38723872{
3873   drcuml_parameter dstp, basep, indp, sizep;
3874   int basereg, dstreg;
3873   drcuml_parameter dstp, basep, indp, scalesizep;
3874   int basereg, dstreg, scale, size;
38753875   INT32 baseoffs;
38763876
38773877   /* validate instruction */
r6740r6741
38803880   assert_no_flags(inst);
38813881
38823882   /* normalize parameters */
3883   param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &basep, PTYPE_M, &indp, PTYPE_MRI, &sizep, PTYPE_I);
3883   param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &basep, PTYPE_M, &indp, PTYPE_MRI, &scalesizep, PTYPE_I);
3884   scale = 1 << (scalesizep.value / 16);
3885   size = scalesizep.value % 16;
38843886
38853887   /* determine the pointer base */
38863888   basereg = get_base_register_and_offset(drcbe, &dst, basep.value, REG_RDX, &baseoffs);
r6740r6741
38933895   {
38943896      if (inst->size == 4)
38953897      {
3896         if (sizep.value == DRCUML_SIZE_BYTE)
3897            emit_movsx_r32_m8(&dst, dstreg, MBD(basereg, baseoffs + 1*indp.value));   // movsx dstreg,[basep + 1*indp]
3898         else if (sizep.value == DRCUML_SIZE_WORD)
3899            emit_movsx_r32_m16(&dst, dstreg, MBD(basereg, baseoffs + 2*indp.value));// movsx dstreg,[basep + 2*indp]
3900         else if (sizep.value == DRCUML_SIZE_DWORD)
3901            emit_mov_r32_m32(&dst, dstreg, MBD(basereg, baseoffs + 4*indp.value));   // mov   dstreg,[basep + 4*indp]
3898         if (size == DRCUML_SIZE_BYTE)
3899            emit_movsx_r32_m8(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value));   // movsx dstreg,[basep + scale*indp]
3900         else if (size == DRCUML_SIZE_WORD)
3901            emit_movsx_r32_m16(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value));// movsx dstreg,[basep + scale*indp]
3902         else if (size == DRCUML_SIZE_DWORD)
3903            emit_mov_r32_m32(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value));   // mov   dstreg,[basep + scale*indp]
39023904      }
39033905      else if (inst->size == 8)
39043906      {
3905         if (sizep.value == DRCUML_SIZE_BYTE)
3906            emit_movsx_r64_m8(&dst, dstreg, MBD(basereg, baseoffs + 1*indp.value));   // movzx dstreg,[basep + 1*indp]
3907         else if (sizep.value == DRCUML_SIZE_WORD)
3908            emit_movsx_r64_m16(&dst, dstreg, MBD(basereg, baseoffs + 2*indp.value));// movzx dstreg,[basep + 2*indp]
3909         else if (sizep.value == DRCUML_SIZE_DWORD)
3910            emit_movsxd_r64_m32(&dst, dstreg, MBD(basereg, baseoffs + 4*indp.value));// movsxd dstreg,[basep + 4*indp]
3911         else if (sizep.value == DRCUML_SIZE_QWORD)
3912            emit_mov_r64_m64(&dst, dstreg, MBD(basereg, baseoffs + 8*indp.value));   // mov   dstreg,[basep + 8*indp]
3907         if (size == DRCUML_SIZE_BYTE)
3908            emit_movsx_r64_m8(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value));   // movzx dstreg,[basep + scale*indp]
3909         else if (size == DRCUML_SIZE_WORD)
3910            emit_movsx_r64_m16(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value));// movzx dstreg,[basep + scale*indp]
3911         else if (size == DRCUML_SIZE_DWORD)
3912            emit_movsxd_r64_m32(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value));// movsxd dstreg,[basep + scale*indp]
3913         else if (size == DRCUML_SIZE_QWORD)
3914            emit_mov_r64_m64(&dst, dstreg, MBD(basereg, baseoffs + scale*indp.value));   // mov   dstreg,[basep + scale*indp]
39133915      }
39143916   }
39153917
r6740r6741
39203922      emit_mov_r32_p32(drcbe, &dst, indreg, &indp);
39213923      if (inst->size == 4)
39223924      {
3923         if (sizep.value == DRCUML_SIZE_BYTE)
3924            emit_movsx_r32_m8(&dst, dstreg, MBISD(basereg, indreg, 1, baseoffs));   // movsx dstreg,[basep + 1*indp]
3925         else if (sizep.value == DRCUML_SIZE_WORD)
3926            emit_movsx_r32_m16(&dst, dstreg, MBISD(basereg, indreg, 2, baseoffs));   // movsx dstreg,[basep + 2*indp]
3927         else if (sizep.value == DRCUML_SIZE_DWORD)
3928            emit_mov_r32_m32(&dst, dstreg, MBISD(basereg, indreg, 4, baseoffs));   // mov   dstreg,[basep + 4*indp]
3925         if (size == DRCUML_SIZE_BYTE)
3926            emit_movsx_r32_m8(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs));   // movsx dstreg,[basep + scale*indp]
3927         else if (size == DRCUML_SIZE_WORD)
3928            emit_movsx_r32_m16(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs));   // movsx dstreg,[basep + scale*indp]
3929         else if (size == DRCUML_SIZE_DWORD)
3930            emit_mov_r32_m32(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs));   // mov   dstreg,[basep + scale*indp]
39293931      }
39303932      else if (inst->size == 8)
39313933      {
3932         if (sizep.value == DRCUML_SIZE_BYTE)
3933            emit_movsx_r64_m8(&dst, dstreg, MBISD(basereg, indreg, 1, baseoffs));   // movsx dstreg,[basep + 1*indp]
3934         else if (sizep.value == DRCUML_SIZE_WORD)
3935            emit_movsx_r64_m16(&dst, dstreg, MBISD(basereg, indreg, 2, baseoffs));   // movsx dstreg,[basep + 2*indp]
3936         else if (sizep.value == DRCUML_SIZE_DWORD)
3937            emit_movsxd_r64_m32(&dst, dstreg, MBISD(basereg, indreg, 4, baseoffs));   // movsxd dstreg,[basep + 4*indp]
3938         else if (sizep.value == DRCUML_SIZE_QWORD)
3939            emit_mov_r64_m64(&dst, dstreg, MBISD(basereg, indreg, 8, baseoffs));   // mov   dstreg,[basep + 8*indp]
3934         if (size == DRCUML_SIZE_BYTE)
3935            emit_movsx_r64_m8(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs));   // movsx dstreg,[basep + scale*indp]
3936         else if (size == DRCUML_SIZE_WORD)
3937            emit_movsx_r64_m16(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs));   // movsx dstreg,[basep + scale*indp]
3938         else if (size == DRCUML_SIZE_DWORD)
3939            emit_movsxd_r64_m32(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs));   // movsxd dstreg,[basep + scale*indp]
3940         else if (size == DRCUML_SIZE_QWORD)
3941            emit_mov_r64_m64(&dst, dstreg, MBISD(basereg, indreg, scale, baseoffs));   // mov   dstreg,[basep + scale*indp]
39403942      }
39413943   }
39423944
r6740r6741
39563958
39573959static x86code *op_store(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
39583960{
3959   drcuml_parameter srcp, basep, indp, sizep;
3960   int srcreg, basereg;
3961   drcuml_parameter srcp, basep, indp, scalesizep;
3962   int srcreg, basereg, scale, size;
39613963   INT32 baseoffs;
39623964
39633965   /* validate instruction */
r6740r6741
39663968   assert_no_flags(inst);
39673969
39683970   /* normalize parameters */
3969   param_normalize_4(drcbe, inst, &basep, PTYPE_M, &indp, PTYPE_MRI, &srcp, PTYPE_MRI, &sizep, PTYPE_I);
3971   param_normalize_4(drcbe, inst, &basep, PTYPE_M, &indp, PTYPE_MRI, &srcp, PTYPE_MRI, &scalesizep, PTYPE_I);
3972   scale = 1 << (scalesizep.value / 16);
3973   size = scalesizep.value % 16;
39703974
39713975   /* determine the pointer base */
39723976   basereg = get_base_register_and_offset(drcbe, &dst, basep.value, REG_RDX, &baseoffs);
r6740r6741
39803984      /* immediate source */
39813985      if (srcp.type == DRCUML_PTYPE_IMMEDIATE)
39823986      {
3983         if (sizep.value == DRCUML_SIZE_BYTE)
3984            emit_mov_m8_imm(&dst, MBD(basereg, baseoffs + 1*indp.value), srcp.value);   // mov   [basep + 1*indp],srcp
3985         else if (sizep.value == DRCUML_SIZE_WORD)
3986            emit_mov_m16_imm(&dst, MBD(basereg, baseoffs + 2*indp.value), srcp.value);   // mov   [basep + 2*indp],srcp
3987         else if (sizep.value == DRCUML_SIZE_DWORD)
3988            emit_mov_m32_imm(&dst, MBD(basereg, baseoffs + 4*indp.value), srcp.value);   // mov   [basep + 4*indp],srcp
3989         else if (sizep.value == DRCUML_SIZE_QWORD)
3987         if (size == DRCUML_SIZE_BYTE)
3988            emit_mov_m8_imm(&dst, MBD(basereg, baseoffs + scale*indp.value), srcp.value);   // mov   [basep + scale*indp],srcp
3989         else if (size == DRCUML_SIZE_WORD)
3990            emit_mov_m16_imm(&dst, MBD(basereg, baseoffs + scale*indp.value), srcp.value);   // mov   [basep + scale*indp],srcp
3991         else if (size == DRCUML_SIZE_DWORD)
3992            emit_mov_m32_imm(&dst, MBD(basereg, baseoffs + scale*indp.value), srcp.value);   // mov   [basep + scale*indp],srcp
3993         else if (size == DRCUML_SIZE_QWORD)
39903994         {
39913995            if (short_immediate(srcp.value))
3992               emit_mov_m64_imm(&dst, MBD(basereg, baseoffs + 8*indp.value), srcp.value);// mov   [basep + 8*indp],srcp
3996               emit_mov_m64_imm(&dst, MBD(basereg, baseoffs + scale*indp.value), srcp.value);// mov   [basep + scale*indp],srcp
39933997            else
39943998            {
3995               emit_mov_m32_imm(&dst, MBD(basereg, baseoffs + 8*indp.value), srcp.value);// mov   [basep + 8*indp],srcp
3996               emit_mov_m32_imm(&dst, MBD(basereg, baseoffs + 8*indp.value + 4), srcp.value >> 32);
3997                                                                  // mov   [basep + 8*indp + 4],srcp >> 32
3999               emit_mov_m32_imm(&dst, MBD(basereg, baseoffs + scale*indp.value), srcp.value);// mov   [basep + scale*indp],srcp
4000               emit_mov_m32_imm(&dst, MBD(basereg, baseoffs + scale*indp.value + 4), srcp.value >> 32);
4001                                                                  // mov   [basep + scale*indp + 4],srcp >> 32
39984002            }
39994003         }
40004004      }
r6740r6741
40024006      /* variable source */
40034007      else
40044008      {
4005         if (sizep.value != DRCUML_SIZE_QWORD)
4009         if (size != DRCUML_SIZE_QWORD)
40064010            emit_mov_r32_p32(drcbe, &dst, srcreg, &srcp);                     // mov   srcreg,srcp
40074011         else
40084012            emit_mov_r64_p64(drcbe, &dst, srcreg, &srcp);                     // mov   srcreg,srcp
4009         if (sizep.value == DRCUML_SIZE_BYTE)
4010            emit_mov_m8_r8(&dst, MBD(basereg, baseoffs + 1*indp.value), srcreg);   // mov   [basep + 1*indp],srcreg
4011         else if (sizep.value == DRCUML_SIZE_WORD)
4012            emit_mov_m16_r16(&dst, MBD(basereg, baseoffs + 2*indp.value), srcreg);   // mov   [basep + 2*indp],srcreg
4013         else if (sizep.value == DRCUML_SIZE_DWORD)
4014            emit_mov_m32_r32(&dst, MBD(basereg, baseoffs + 4*indp.value), srcreg);   // mov   [basep + 4*indp],srcreg
4015         else if (sizep.value == DRCUML_SIZE_QWORD)
4016            emit_mov_m64_r64(&dst, MBD(basereg, baseoffs + 8*indp.value), srcreg);   // mov   [basep + 8*indp],srcreg
4013         if (size == DRCUML_SIZE_BYTE)
4014            emit_mov_m8_r8(&dst, MBD(basereg, baseoffs + scale*indp.value), srcreg);   // mov   [basep + scale*indp],srcreg
4015         else if (size == DRCUML_SIZE_WORD)
4016            emit_mov_m16_r16(&dst, MBD(basereg, baseoffs + scale*indp.value), srcreg);   // mov   [basep + scale*indp],srcreg
4017         else if (size == DRCUML_SIZE_DWORD)
4018            emit_mov_m32_r32(&dst, MBD(basereg, baseoffs + scale*indp.value), srcreg);   // mov   [basep + scale*indp],srcreg
4019         else if (size == DRCUML_SIZE_QWORD)
4020            emit_mov_m64_r64(&dst, MBD(basereg, baseoffs + scale*indp.value), srcreg);   // mov   [basep + scale*indp],srcreg
40174021      }
40184022   }
40194023
r6740r6741
40264030      /* immediate source */
40274031      if (srcp.type == DRCUML_PTYPE_IMMEDIATE)
40284032      {
4029         if (sizep.value == DRCUML_SIZE_BYTE)
4030            emit_mov_m8_imm(&dst, MBISD(basereg, indreg, 1, baseoffs), srcp.value);   // mov   [basep + 1*ecx],srcp
4031         else if (sizep.value == DRCUML_SIZE_WORD)
4032            emit_mov_m16_imm(&dst, MBISD(basereg, indreg, 2, baseoffs), srcp.value);// mov   [basep + 2*ecx],srcp
4033         else if (sizep.value == DRCUML_SIZE_DWORD)
4034            emit_mov_m32_imm(&dst, MBISD(basereg, indreg, 4, baseoffs), srcp.value);// mov   [basep + 4*ecx],srcp
4035         else if (sizep.value == DRCUML_SIZE_QWORD)
4033         if (size == DRCUML_SIZE_BYTE)
4034            emit_mov_m8_imm(&dst, MBISD(basereg, indreg, scale, baseoffs), srcp.value);   // mov   [basep + scale*ecx],srcp
4035         else if (size == DRCUML_SIZE_WORD)
4036            emit_mov_m16_imm(&dst, MBISD(basereg, indreg, scale, baseoffs), srcp.value);// mov   [basep + scale*ecx],srcp
4037         else if (size == DRCUML_SIZE_DWORD)
4038            emit_mov_m32_imm(&dst, MBISD(basereg, indreg, scale, baseoffs), srcp.value);// mov   [basep + scale*ecx],srcp
4039         else if (size == DRCUML_SIZE_QWORD)
40364040         {
40374041            if (short_immediate(srcp.value))
4038               emit_mov_m64_imm(&dst, MBISD(basereg, indreg, 8, baseoffs), srcp.value);// mov   [basep + 8*indp],srcp
4042               emit_mov_m64_imm(&dst, MBISD(basereg, indreg, scale, baseoffs), srcp.value);// mov   [basep + scale*indp],srcp
40394043            else
40404044            {
4041               emit_mov_m32_imm(&dst, MBISD(basereg, indreg, 8, baseoffs), srcp.value);// mov   [basep + 8*ecx],srcp
4042               emit_mov_m32_imm(&dst, MBISD(basereg, indreg, 8, baseoffs + 4), srcp.value >> 32);
4043                                                                  // mov   [basep + 8*ecx + 4],srcp >> 32
4045               emit_mov_m32_imm(&dst, MBISD(basereg, indreg, scale, baseoffs), srcp.value);// mov   [basep + scale*ecx],srcp
4046               emit_mov_m32_imm(&dst, MBISD(basereg, indreg, scale, baseoffs + 4), srcp.value >> 32);
4047                                                                  // mov   [basep + scale*ecx + 4],srcp >> 32
40444048            }
40454049         }
40464050      }
r6740r6741
40484052      /* variable source */
40494053      else
40504054      {
4051         if (sizep.value != DRCUML_SIZE_QWORD)
4055         if (size != DRCUML_SIZE_QWORD)
40524056            emit_mov_r32_p32(drcbe, &dst, srcreg, &srcp);                     // mov   srcreg,srcp
40534057         else
40544058            emit_mov_r64_p64(drcbe, &dst, srcreg, &srcp);                     // mov   edx:srcreg,srcp
4055         if (sizep.value == DRCUML_SIZE_BYTE)
4056            emit_mov_m8_r8(&dst, MBISD(basereg, indreg, 1, baseoffs), srcreg);      // mov   [basep + 1*ecx],srcreg
4057         else if (sizep.value == DRCUML_SIZE_WORD)
4058            emit_mov_m16_r16(&dst, MBISD(basereg, indreg, 2, baseoffs), srcreg);   // mov   [basep + 2*ecx],srcreg
4059         else if (sizep.value == DRCUML_SIZE_DWORD)
4060            emit_mov_m32_r32(&dst, MBISD(basereg, indreg, 4, baseoffs), srcreg);   // mov   [basep + 4*ecx],srcreg
4061         else if (sizep.value == DRCUML_SIZE_QWORD)
4062            emit_mov_m64_r64(&dst, MBISD(basereg, indreg, 8, baseoffs), srcreg);   // mov   [basep + 8*ecx],srcreg
4059         if (size == DRCUML_SIZE_BYTE)
4060            emit_mov_m8_r8(&dst, MBISD(basereg, indreg, scale, baseoffs), srcreg);   // mov   [basep + scale*ecx],srcreg
4061         else if (size == DRCUML_SIZE_WORD)
4062            emit_mov_m16_r16(&dst, MBISD(basereg, indreg, scale, baseoffs), srcreg);// mov   [basep + scale*ecx],srcreg
4063         else if (size == DRCUML_SIZE_DWORD)
4064            emit_mov_m32_r32(&dst, MBISD(basereg, indreg, scale, baseoffs), srcreg);// mov   [basep + scale*ecx],srcreg
4065         else if (size == DRCUML_SIZE_QWORD)
4066            emit_mov_m64_r64(&dst, MBISD(basereg, indreg, scale, baseoffs), srcreg);// mov   [basep + scale*ecx],srcreg
40634067      }
40644068   }
40654069   return dst;
r6740r6741
54405444      if (src1p.type == dstp.type && src1p.value == dstp.value && dstp.type == DRCUML_PTYPE_MEMORY)
54415445         emit_and_m32_p32(drcbe, &dst, MABS(drcbe, dstp.value), &src2p, inst);      // and   [dstp],src2p
54425446
5447      /* AND with immediate 0xff */
5448      else if (src2p.type == DRCUML_PTYPE_IMMEDIATE && src2p.value == 0xff && inst->flags == 0)
5449      {
5450         if (src1p.type == DRCUML_PTYPE_INT_REGISTER)
5451            emit_movzx_r32_r8(&dst, dstreg, src1p.value);                     // movzx dstreg,src1p
5452         else if (src1p.type == DRCUML_PTYPE_MEMORY)
5453            emit_movzx_r32_m8(&dst, dstreg, MABS(drcbe, src1p.value));            // movzx dstreg,[src1p]
5454         emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg);                        // mov   dstp,dstreg
5455      }
5456
5457      /* AND with immediate 0xffff */
5458      else if (src2p.type == DRCUML_PTYPE_IMMEDIATE && src2p.value == 0xffff && inst->flags == 0)
5459      {
5460         if (src1p.type == DRCUML_PTYPE_INT_REGISTER)
5461            emit_movzx_r32_r16(&dst, dstreg, src1p.value);                     // movzx dstreg,src1p
5462         else if (src1p.type == DRCUML_PTYPE_MEMORY)
5463            emit_movzx_r32_m16(&dst, dstreg, MABS(drcbe, src1p.value));            // movzx dstreg,[src1p]
5464         emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg);                        // mov   dstp,dstreg
5465      }
5466
54435467      /* general case */
54445468      else
54455469      {
r6740r6741
54565480      if (src1p.type == dstp.type && src1p.value == dstp.value && dstp.type == DRCUML_PTYPE_MEMORY)
54575481         emit_and_m64_p64(drcbe, &dst, MABS(drcbe, dstp.value), &src2p, inst);      // and   [dstp],src2p
54585482
5483      /* AND with immediate 0xff */
5484      else if (src2p.type == DRCUML_PTYPE_IMMEDIATE && src2p.value == 0xff && inst->flags == 0)
5485      {
5486         if (src1p.type == DRCUML_PTYPE_INT_REGISTER)
5487            emit_movzx_r32_r8(&dst, dstreg, src1p.value);                     // movzx dstreg,src1p
5488         else if (src1p.type == DRCUML_PTYPE_MEMORY)
5489            emit_movzx_r32_m8(&dst, dstreg, MABS(drcbe, src1p.value));            // movzx dstreg,[src1p]
5490         emit_mov_p64_r64(drcbe, &dst, &dstp, dstreg);                        // mov   dstp,dstreg
5491      }
5492
5493      /* AND with immediate 0xffff */
5494      else if (src2p.type == DRCUML_PTYPE_IMMEDIATE && src2p.value == 0xffff && inst->flags == 0)
5495      {
5496         if (src1p.type == DRCUML_PTYPE_INT_REGISTER)
5497            emit_movzx_r32_r16(&dst, dstreg, src1p.value);                     // movzx dstreg,src1p
5498         else if (src1p.type == DRCUML_PTYPE_MEMORY)
5499            emit_movzx_r32_m16(&dst, dstreg, MABS(drcbe, src1p.value));            // movzx dstreg,[src1p]
5500         emit_mov_p64_r64(drcbe, &dst, &dstp, dstreg);                        // mov   dstp,dstreg
5501      }
5502
5503      /* AND with immediate 0xffffffff */
5504      else if (src2p.type == DRCUML_PTYPE_IMMEDIATE && src2p.value == 0xffffffff && inst->flags == 0)
5505      {
5506         if (src1p.type == dstp.type && src1p.value == dstp.value && dstp.type == DRCUML_PTYPE_INT_REGISTER)
5507            emit_mov_r32_r32(&dst, dstreg, dstreg);                           // mov   dstreg,dstreg
5508         else
5509         {
5510            emit_mov_r32_p32(drcbe, &dst, dstreg, &src1p);                     // mov   dstreg,src1p
5511            emit_mov_p64_r64(drcbe, &dst, &dstp, dstreg);                     // mov   dstp,dstreg
5512         }
5513      }
5514
54595515      /* general case */
54605516      else
54615517      {
src/emu/cpu/drcbec.c
r6740r6741
4949enum
5050{
5151   DRCUML_OP_LOAD1 = DRCUML_OP_MAX,
52   DRCUML_OP_LOAD1x2,
53   DRCUML_OP_LOAD1x4,
54   DRCUML_OP_LOAD1x8,
55   DRCUML_OP_LOAD2x1,
5256   DRCUML_OP_LOAD2,
57   DRCUML_OP_LOAD2x4,
58   DRCUML_OP_LOAD2x8,
59   DRCUML_OP_LOAD4x1,
60   DRCUML_OP_LOAD4x2,
5361   DRCUML_OP_LOAD4,
62   DRCUML_OP_LOAD4x8,
63   DRCUML_OP_LOAD8x1,
64   DRCUML_OP_LOAD8x2,
65   DRCUML_OP_LOAD8x4,
5466   DRCUML_OP_LOAD8,
5567   DRCUML_OP_LOADS1,
68   DRCUML_OP_LOADS1x2,
69   DRCUML_OP_LOADS1x4,
70   DRCUML_OP_LOADS1x8,
71   DRCUML_OP_LOADS2x1,
5672   DRCUML_OP_LOADS2,
73   DRCUML_OP_LOADS2x4,
74   DRCUML_OP_LOADS2x8,
75   DRCUML_OP_LOADS4x1,
76   DRCUML_OP_LOADS4x2,
5777   DRCUML_OP_LOADS4,
78   DRCUML_OP_LOADS4x8,
79   DRCUML_OP_LOADS8x1,
80   DRCUML_OP_LOADS8x2,
81   DRCUML_OP_LOADS8x4,
5882   DRCUML_OP_LOADS8,
5983   DRCUML_OP_STORE1,
84   DRCUML_OP_STORE1x2,
85   DRCUML_OP_STORE1x4,
86   DRCUML_OP_STORE1x8,
87   DRCUML_OP_STORE2x1,
6088   DRCUML_OP_STORE2,
89   DRCUML_OP_STORE2x4,
90   DRCUML_OP_STORE2x8,
91   DRCUML_OP_STORE4x1,
92   DRCUML_OP_STORE4x2,
6193   DRCUML_OP_STORE4,
94   DRCUML_OP_STORE4x8,
95   DRCUML_OP_STORE8x1,
96   DRCUML_OP_STORE8x2,
97   DRCUML_OP_STORE8x4,
6298   DRCUML_OP_STORE8,
6399   DRCUML_OP_READ1,
64100   DRCUML_OP_READ2,
r6740r6741
473509            if (opcode == DRCUML_OP_FFRINT || opcode == DRCUML_OP_FFRFLT)
474510               psize[1] = 1 << inst->param[2].value;
475511
476            /* pre-expand opcodes that encode size in them */
512            /* pre-expand opcodes that encode size/scale in them */
477513            if (opcode == DRCUML_OP_LOAD)
478               opcode = (drcuml_opcode)(DRCUML_OP_LOAD1 + (inst->param[3].value & 3));
514               opcode = (drcuml_opcode)(DRCUML_OP_LOAD1 + (inst->param[3].value & 3) * 4 + ((inst->param[3].value >> 4) & 3));
479515            if (opcode == DRCUML_OP_LOADS)
480               opcode = (drcuml_opcode)(DRCUML_OP_LOADS1 + (inst->param[3].value & 3));
516               opcode = (drcuml_opcode)(DRCUML_OP_LOADS1 + (inst->param[3].value & 3) * 4 + ((inst->param[3].value >> 4) & 3));
481517            if (opcode == DRCUML_OP_STORE)
482               opcode = (drcuml_opcode)(DRCUML_OP_STORE1 + (inst->param[3].value & 3));
518               opcode = (drcuml_opcode)(DRCUML_OP_STORE1 + (inst->param[3].value & 3) * 4 + ((inst->param[3].value >> 4) & 3));
483519            if (opcode == DRCUML_OP_READ)
484520               opcode = (drcuml_opcode)(DRCUML_OP_READ1 + (inst->param[2].value & 3));
485521            if (opcode == DRCUML_OP_READM)
r6740r6741
728764            PARAM0 = inst[1].puint8[PARAM2];
729765            break;
730766
767         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD1x2, 4, 0):   /* LOAD    dst,base,index,BYTE_x2 */
768            PARAM0 = *(UINT8 *)&inst[1].puint16[PARAM2];
769            break;
770
771         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD1x4, 4, 0):   /* LOAD    dst,base,index,BYTE_x4 */
772            PARAM0 = *(UINT8 *)&inst[1].puint32[PARAM2];
773            break;
774
775         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD1x8, 4, 0):   /* LOAD    dst,base,index,BYTE_x8 */
776            PARAM0 = *(UINT8 *)&inst[1].puint64[PARAM2];
777            break;
778
779         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2x1, 4, 0):   /* LOAD    dst,base,index,WORD_x1 */
780            PARAM0 = *(UINT16 *)&inst[1].puint8[PARAM2];
781            break;
782
731783         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2, 4, 0):      /* LOAD    dst,base,index,WORD    */
732784            PARAM0 = inst[1].puint16[PARAM2];
733785            break;
734786
787         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2x4, 4, 0):   /* LOAD    dst,base,index,WORD_x4 */
788            PARAM0 = *(UINT16 *)&inst[1].puint32[PARAM2];
789            break;
790
791         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2x8, 4, 0):   /* LOAD    dst,base,index,WORD_x8 */
792            PARAM0 = *(UINT16 *)&inst[1].puint64[PARAM2];
793            break;
794
795         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4x1, 4, 0):   /* LOAD    dst,base,index,DWORD_x1 */
796            PARAM0 = *(UINT32 *)&inst[1].puint8[PARAM2];
797            break;
798
799         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4x2, 4, 0):   /* LOAD    dst,base,index,DWORD_x2 */
800            PARAM0 = *(UINT32 *)&inst[1].puint16[PARAM2];
801            break;
802
735803         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4, 4, 0):      /* LOAD    dst,base,index,DWORD   */
736804            PARAM0 = inst[1].puint32[PARAM2];
737805            break;
738806
807         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4x8, 4, 0):   /* LOAD    dst,base,index,DWORD_x8 */
808            PARAM0 = *(UINT32 *)&inst[1].puint64[PARAM2];
809            break;
810
739811         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS1, 4, 0):      /* LOADS   dst,base,index,BYTE    */
740812            PARAM0 = inst[1].pint8[PARAM2];
741813            break;
742814
815         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS1x2, 4, 0):   /* LOADS   dst,base,index,BYTE_x2 */
816            PARAM0 = *(INT8 *)&inst[1].pint16[PARAM2];
817            break;
818
819         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS1x4, 4, 0):   /* LOADS   dst,base,index,BYTE_x4 */
820            PARAM0 = *(INT8 *)&inst[1].pint32[PARAM2];
821            break;
822
823         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS1x8, 4, 0):   /* LOADS   dst,base,index,BYTE_x8 */
824            PARAM0 = *(INT8 *)&inst[1].pint64[PARAM2];
825            break;
826
827         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2x1, 4, 0):   /* LOADS   dst,base,index,WORD_x1 */
828            PARAM0 = *(INT16 *)&inst[1].pint8[PARAM2];
829            break;
830
743831         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2, 4, 0):      /* LOADS   dst,base,index,WORD    */
744832            PARAM0 = inst[1].pint16[PARAM2];
745833            break;
746834
835         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2x4, 4, 0):   /* LOADS   dst,base,index,WORD_x4 */
836            PARAM0 = *(INT16 *)&inst[1].pint32[PARAM2];
837            break;
838
839         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2x8, 4, 0):   /* LOADS   dst,base,index,WORD_x8 */
840            PARAM0 = *(INT16 *)&inst[1].pint64[PARAM2];
841            break;
842
843         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4x1, 4, 0):   /* LOADS   dst,base,index,DWORD_x1 */
844            PARAM0 = *(INT32 *)&inst[1].pint8[PARAM2];
845            break;
846
847         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4x2, 4, 0):   /* LOADS   dst,base,index,DWORD_x2 */
848            PARAM0 = *(INT32 *)&inst[1].pint16[PARAM2];
849            break;
850
747851         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4, 4, 0):      /* LOADS   dst,base,index,DWORD   */
748852            PARAM0 = inst[1].pint32[PARAM2];
749853            break;
750854
855         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4x8, 4, 0):   /* LOADS   dst,base,index,DWORD_x8 */
856            PARAM0 = *(INT32 *)&inst[1].pint64[PARAM2];
857            break;
858
751859         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1, 4, 0):      /* STORE   dst,base,index,BYTE    */
752860            inst[0].puint8[PARAM1] = PARAM2;
753861            break;
754862
863         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1x2, 4, 0):   /* STORE   dst,base,index,BYTE_x2 */
864            *(UINT8 *)&inst[0].puint16[PARAM1] = PARAM2;
865            break;
866
867         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1x4, 4, 0):   /* STORE   dst,base,index,BYTE_x4 */
868            *(UINT8 *)&inst[0].puint32[PARAM1] = PARAM2;
869            break;
870
871         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1x8, 4, 0):   /* STORE   dst,base,index,BYTE_x8 */
872            *(UINT8 *)&inst[0].puint64[PARAM1] = PARAM2;
873            break;
874
875         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2x1, 4, 0):   /* STORE   dst,base,index,WORD_x1 */
876            *(UINT16 *)&inst[0].puint8[PARAM1] = PARAM2;
877            break;
878
755879         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2, 4, 0):      /* STORE   dst,base,index,WORD    */
756880            inst[0].puint16[PARAM1] = PARAM2;
757881            break;
758882
883         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2x4, 4, 0):   /* STORE   dst,base,index,WORD_x4 */
884            *(UINT16 *)&inst[0].puint32[PARAM1] = PARAM2;
885            break;
886
887         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2x8, 4, 0):   /* STORE   dst,base,index,WORD_x8 */
888            *(UINT16 *)&inst[0].puint64[PARAM1] = PARAM2;
889            break;
890
891         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4x1, 4, 0):   /* STORE   dst,base,index,DWORD_x1 */
892            *(UINT32 *)&inst[0].puint8[PARAM1] = PARAM2;
893            break;
894
895         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4x2, 4, 0):   /* STORE   dst,base,index,DWORD_x2 */
896            *(UINT32 *)&inst[0].puint16[PARAM1] = PARAM2;
897            break;
898
759899         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4, 4, 0):      /* STORE   dst,base,index,DWORD   */
760900            inst[0].puint32[PARAM1] = PARAM2;
761901            break;
762902
903         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4x8, 4, 0):   /* STORE   dst,base,index,DWORD_x8 */
904            *(UINT32 *)&inst[0].puint64[PARAM1] = PARAM2;
905            break;
906
763907         case MAKE_OPCODE_SHORT(DRCUML_OP_READ1, 4, 0):      /* READ    dst,src1,space_BYTE    */
764908            PARAM0 = memory_read_byte(drcbe->space[PARAM2 / 16], PARAM1);
765909            break;
r6740r6741
11511295            DPARAM0 = inst[1].puint8[PARAM2];
11521296            break;
11531297
1298         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD1x2, 8, 0):   /* DLOAD   dst,base,index,BYTE_x2 */
1299            DPARAM0 = *(UINT8 *)&inst[1].puint16[PARAM2];
1300            break;
1301
1302         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD1x4, 8, 0):   /* DLOAD   dst,base,index,BYTE_x4 */
1303            DPARAM0 = *(UINT8 *)&inst[1].puint32[PARAM2];
1304            break;
1305
1306         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD1x8, 8, 0):   /* DLOAD   dst,base,index,BYTE_x8 */
1307            DPARAM0 = *(UINT8 *)&inst[1].puint64[PARAM2];
1308            break;
1309
1310         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2x1, 8, 0):   /* DLOAD   dst,base,index,WORD_x1 */
1311            DPARAM0 = *(UINT16 *)&inst[1].puint8[PARAM2];
1312            break;
1313
11541314         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2, 8, 0):      /* DLOAD   dst,base,index,WORD    */
11551315            DPARAM0 = inst[1].puint16[PARAM2];
11561316            break;
11571317
1318         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2x4, 8, 0):   /* DLOAD   dst,base,index,WORD_x4 */
1319            DPARAM0 = *(UINT16 *)&inst[1].puint32[PARAM2];
1320            break;
1321
1322         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD2x8, 8, 0):   /* DLOAD   dst,base,index,WORD_x8 */
1323            DPARAM0 = *(UINT16 *)&inst[1].puint64[PARAM2];
1324            break;
1325
1326         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4x1, 8, 0):   /* DLOAD   dst,base,index,DWORD_x1 */
1327            DPARAM0 = *(UINT32 *)&inst[1].puint8[PARAM2];
1328            break;
1329
1330         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4x2, 8, 0):   /* DLOAD   dst,base,index,DWORD_x2 */
1331            DPARAM0 = *(UINT32 *)&inst[1].puint16[PARAM2];
1332            break;
1333
11581334         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4, 8, 0):      /* DLOAD   dst,base,index,DWORD   */
11591335            DPARAM0 = inst[1].puint32[PARAM2];
11601336            break;
11611337
1162         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD8, 8, 0):      /* DLOAD   dst,base,index,QWORD   */
1338         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD4x8, 8, 0):   /* DLOAD   dst,base,index,DWORD_x8 */
1339            DPARAM0 = *(UINT32 *)&inst[1].puint64[PARAM2];
1340            break;
1341
1342         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD8x1, 8, 0):   /* DLOAD   dst,base,index,QWORD_x1 */
1343            DPARAM0 = *(UINT64 *)&inst[1].puint8[PARAM2];
1344            break;
1345
1346         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD8x2, 8, 0):   /* DLOAD   dst,base,index,QWORD_x2 */
1347            DPARAM0 = *(UINT64 *)&inst[1].puint16[PARAM2];
1348            break;
1349
1350         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD8x4, 8, 0):   /* DLOAD   dst,base,index,QWORD_x4 */
1351            DPARAM0 = *(UINT64 *)&inst[1].puint32[PARAM2];
1352            break;
1353
1354         case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD8, 8, 0):      /* DLOAD   dst,base,index,QWORD */
11631355            DPARAM0 = inst[1].puint64[PARAM2];
11641356            break;
11651357
r6740r6741
11671359            DPARAM0 = inst[1].pint8[PARAM2];
11681360            break;
11691361
1362         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS1x2, 8, 0):   /* DLOADS  dst,base,index,BYTE_x2 */
1363            DPARAM0 = *(INT8 *)&inst[1].pint16[PARAM2];
1364            break;
1365
1366         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS1x4, 8, 0):   /* DLOADS  dst,base,index,BYTE_x4 */
1367            DPARAM0 = *(INT8 *)&inst[1].pint32[PARAM2];
1368            break;
1369
1370         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS1x8, 8, 0):   /* DLOADS  dst,base,index,BYTE_x8 */
1371            DPARAM0 = *(INT8 *)&inst[1].pint64[PARAM2];
1372            break;
1373
1374         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2x1, 8, 0):   /* DLOADS  dst,base,index,WORD_x1 */
1375            DPARAM0 = *(INT16 *)&inst[1].pint8[PARAM2];
1376            break;
1377
11701378         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2, 8, 0):      /* DLOADS  dst,base,index,WORD    */
11711379            DPARAM0 = inst[1].pint16[PARAM2];
11721380            break;
11731381
1382         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2x4, 8, 0):   /* DLOADS  dst,base,index,WORD_x4 */
1383            DPARAM0 = *(INT16 *)&inst[1].pint32[PARAM2];
1384            break;
1385
1386         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS2x8, 8, 0):   /* DLOADS  dst,base,index,WORD_x8 */
1387            DPARAM0 = *(INT16 *)&inst[1].pint64[PARAM2];
1388            break;
1389
1390         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4x1, 8, 0):   /* DLOADS  dst,base,index,DWORD_x1 */
1391            DPARAM0 = *(INT32 *)&inst[1].pint8[PARAM2];
1392            break;
1393
1394         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4x2, 8, 0):   /* DLOADS  dst,base,index,DWORD_x2 */
1395            DPARAM0 = *(INT32 *)&inst[1].pint16[PARAM2];
1396            break;
1397
11741398         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4, 8, 0):      /* DLOADS  dst,base,index,DWORD   */
11751399            DPARAM0 = inst[1].pint32[PARAM2];
11761400            break;
11771401
1402         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS4x8, 8, 0):   /* DLOADS  dst,base,index,DWORD_x8 */
1403            DPARAM0 = *(INT32 *)&inst[1].pint64[PARAM2];
1404            break;
1405
1406         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS8x1, 8, 0):   /* DLOADS  dst,base,index,QWORD_x1 */
1407            DPARAM0 = *(INT64 *)&inst[1].pint8[PARAM2];
1408            break;
1409
1410         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS8x2, 8, 0):   /* DLOADS  dst,base,index,QWORD_x2 */
1411            DPARAM0 = *(INT64 *)&inst[1].pint16[PARAM2];
1412            break;
1413
1414         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS8x4, 8, 0):   /* DLOADS  dst,base,index,QWORD_x4 */
1415            DPARAM0 = *(INT64 *)&inst[1].pint32[PARAM2];
1416            break;
1417
1418         case MAKE_OPCODE_SHORT(DRCUML_OP_LOADS8, 8, 0):      /* DLOADS  dst,base,index,QWORD   */
1419            DPARAM0 = inst[1].pint64[PARAM2];
1420            break;
1421
11781422         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1, 8, 0):      /* DSTORE  dst,base,index,BYTE    */
11791423            inst[0].puint8[PARAM1] = DPARAM2;
11801424            break;
11811425
1426         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1x2, 8, 0):   /* DSTORE  dst,base,index,BYTE_x2 */
1427            *(UINT8 *)&inst[0].puint16[PARAM1] = DPARAM2;
1428            break;
1429
1430         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1x4, 8, 0):   /* DSTORE  dst,base,index,BYTE_x4 */
1431            *(UINT8 *)&inst[0].puint32[PARAM1] = DPARAM2;
1432            break;
1433
1434         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE1x8, 8, 0):   /* DSTORE  dst,base,index,BYTE_x8 */
1435            *(UINT8 *)&inst[0].puint64[PARAM1] = DPARAM2;
1436            break;
1437
1438         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2x1, 8, 0):   /* DSTORE  dst,base,index,WORD_x1 */
1439            *(UINT16 *)&inst[0].puint8[PARAM1] = DPARAM2;
1440            break;
1441
11821442         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2, 8, 0):      /* DSTORE  dst,base,index,WORD    */
11831443            inst[0].puint16[PARAM1] = DPARAM2;
11841444            break;
11851445
1446         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2x4, 8, 0):   /* DSTORE  dst,base,index,WORD_x4 */
1447            *(UINT16 *)&inst[0].puint32[PARAM1] = DPARAM2;
1448            break;
1449
1450         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE2x8, 8, 0):   /* DSTORE  dst,base,index,WORD_x8 */
1451            *(UINT16 *)&inst[0].puint64[PARAM1] = DPARAM2;
1452            break;
1453
1454         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4x1, 8, 0):   /* DSTORE  dst,base,index,DWORD_x1 */
1455            *(UINT32 *)&inst[0].puint8[PARAM1] = DPARAM2;
1456            break;
1457
1458         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4x2, 8, 0):   /* DSTORE  dst,base,index,DWORD_x2 */
1459            *(UINT32 *)&inst[0].puint16[PARAM1] = DPARAM2;
1460            break;
1461
11861462         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4, 8, 0):      /* DSTORE  dst,base,index,DWORD   */
11871463            inst[0].puint32[PARAM1] = DPARAM2;
11881464            break;
11891465
1190         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE8, 8, 0):      /* DSTORE  dst,base,index,QWORD   */
1466         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE4x8, 8, 0):   /* DSTORE  dst,base,index,DWORD_x8 */
1467            *(UINT32 *)&inst[0].puint64[PARAM1] = DPARAM2;
1468            break;
1469
1470         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE8x1, 8, 0):   /* DSTORE  dst,base,index,QWORD_x1 */
1471            *(UINT64 *)&inst[0].puint8[PARAM1] = DPARAM2;
1472            break;
1473
1474         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE8x2, 8, 0):   /* DSTORE  dst,base,index,QWORD_x2 */
1475            *(UINT64 *)&inst[0].puint16[PARAM1] = DPARAM2;
1476            break;
1477
1478         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE8x4, 8, 0):   /* DSTORE  dst,base,index,QWORD_x4 */
1479            *(UINT64 *)&inst[0].puint32[PARAM1] = DPARAM2;
1480            break;
1481
1482         case MAKE_OPCODE_SHORT(DRCUML_OP_STORE8, 8, 0):      /* DSTORE  dst,base,index,QWORD    */
11911483            inst[0].puint64[PARAM1] = DPARAM2;
11921484            break;
11931485
src/emu/cpu/rsp/rspfe.c
r6740r6741
6363
6464      case 0x02:   /* J */
6565         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
66         desc->targetpc = LIMMVAL << 2;
66         desc->targetpc = ((LIMMVAL << 2) & 0x00000fff) | 0x1000;
6767         desc->delayslots = 1;
6868         return TRUE;
6969
7070      case 0x03:   /* JAL */
7171         desc->regout[0] |= REGFLAG_R(31);
7272         desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE;
73         desc->targetpc = LIMMVAL << 2;
73         desc->targetpc = ((LIMMVAL << 2) & 0x00000fff) | 0x1000;
7474         desc->delayslots = 1;
7575         return TRUE;
7676
r6740r6741
8383            desc->regin[0] |= REGFLAG_R(RSREG) | REGFLAG_R(RTREG);
8484            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
8585         }
86         desc->targetpc = (desc->pc + 4 + (SIMMVAL << 2)) | 0x04001000;
86         desc->targetpc = ((desc->pc + 4 + (SIMMVAL << 2)) & 0x00000fff) | 0x1000;
8787         desc->delayslots = 1;
8888         desc->skipslots = (opswitch & 0x10) ? 1 : 0;
8989         return TRUE;
r6740r6741
9797            desc->regin[0] |= REGFLAG_R(RSREG);
9898            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
9999         }
100         desc->targetpc = (desc->pc + 4 + (SIMMVAL << 2)) | 0x04001000;
100         desc->targetpc = ((desc->pc + 4 + (SIMMVAL << 2)) & 0x00000fff) | 0x1000;
101101         desc->delayslots = 1;
102102         desc->skipslots = (opswitch & 0x10) ? 1 : 0;
103103         return TRUE;
r6740r6741
236236            desc->regin[0] |= REGFLAG_R(RSREG);
237237            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
238238         }
239         desc->targetpc = (desc->pc + 4 + (SIMMVAL << 2)) | 0x04001000;
239         desc->targetpc = ((desc->pc + 4 + (SIMMVAL << 2)) & 0x00000fff) | 0x1000;
240240         desc->delayslots = 1;
241241         desc->skipslots = (RTREG & 0x02) ? 1 : 0;
242242         return TRUE;
r6740r6741
251251            desc->flags |= OPFLAG_IS_CONDITIONAL_BRANCH;
252252         }
253253         desc->regout[0] |= REGFLAG_R(31);
254         desc->targetpc = (desc->pc + 4 + (SIMMVAL << 2)) | 0x04001000;
254         desc->targetpc = ((desc->pc + 4 + (SIMMVAL << 2)) & 0x00000fff) | 0x1000;
255255         desc->delayslots = 1;
256256         desc->skipslots = (RTREG & 0x02) ? 1 : 0;
257257         return TRUE;
src/emu/cpu/rsp/rspdrc.c
r6740r6741
22
33    rspdrc.c
44
5   Universal machine language-based Nintendo/SGI RSP emulator.
6   Written by Harmony of the MESS team.
5    Universal machine language-based Nintendo/SGI RSP emulator.
6    Written by Harmony of the MESS team.
77
88    Copyright the MESS team.
99    Released for general non-commercial use under the MAME license
r6740r6741
2020
2121#include "cpuintrf.h"
2222#include "debugger.h"
23#include "profiler.h"
2324#include "rsp.h"
2425#include "rspfe.h"
2526#include "cpu/drcfe.h"
r6740r6741
172173static int generate_cop0(rsp_state *rsp, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc);
173174static int generate_cop2(rsp_state *rsp, drcuml_block *block, compiler_state *compiler, const opcode_desc *desc);
174175
176static void log_add_disasm_comment(rsp_state *rsp, drcuml_block *block, UINT32 pc, UINT32 op);
177
175178/***************************************************************************
176179    HELPFUL DEFINES
177180***************************************************************************/
r6740r6741
415418    debugging
416419-------------------------------------------------*/
417420
421#ifndef LSB_FIRST
418422static void cfunc_printf_debug(void *param)
419423{
420424   rsp_state *rsp = (rsp_state *)param;
421425   printf(rsp->impstate->format, rsp->impstate->arg0, rsp->impstate->arg1);
422426   logerror(rsp->impstate->format, rsp->impstate->arg0, rsp->impstate->arg1);
423427}
428#endif
424429
425430
426431static void cfunc_get_cop0_reg(void *param)
r6740r6741
879884
880885         for (i=(16 - index); i < end; i++)
881886         {
887            //printf("%d",i);
882888            W_VREG_B(dest, i & 0xf, READ8(rsp, ea));
883889            ea += 4;
884890         }
891         //printf("\n");
885892         break;
886893      }
887894      case 0x0b:      /* LTV */
r6740r6741
12131220   }
12141221}
12151222
1216INLINE UINT16 SATURATE_ACCUM(rsp_state *rsp, int accum, int slice, UINT16 negative, UINT16 positive)
1223INLINE UINT16 SATURATE_ACCUM_SIGNED(rsp_state *rsp, int accum, int slice)
12171224{
12181225   if (ACCUM(accum).h.high < 0)
12191226   {
12201227      if ((UINT16)ACCUM(accum).h.high != 0xffff)
12211228      {
1222         return negative;
1229         return 0x8000;
12231230      }
12241231      else
12251232      {
12261233         if (ACCUM(accum).h.mid >= 0)
12271234         {
1228            return negative;
1235            return 0x8000;
12291236         }
12301237         else
12311238         {
r6740r6741
12441251   {
12451252      if ((UINT16)ACCUM(accum).h.high != 0)
12461253      {
1247         return positive;
1254         return 0x7fff;
12481255      }
12491256      else
12501257      {
12511258         if (ACCUM(accum).h.mid < 0)
12521259         {
1253            return positive;
1260            return 0x7fff;
12541261         }
12551262         else
12561263         {
r6740r6741
12691276   return 0;
12701277}
12711278
1279INLINE UINT16 SATURATE_ACCUM_UNSIGNED(rsp_state *rsp, int accum, int slice)
1280{
1281   if (ACCUM(accum).h.high < 0)
1282   {
1283      if ((UINT16)ACCUM(accum).h.high != 0xffff)
1284      {
1285         return 0;
1286      }
1287      else
1288      {
1289         if (ACCUM(accum).h.mid >= 0)
1290         {
1291            return 0;
1292         }
1293         else
1294         {
1295            if (slice == 0)
1296            {
1297               return ACCUM(accum).h.low;
1298            }
1299            else if (slice == 1)
1300            {
1301               return ACCUM(accum).h.mid;
1302            }
1303         }
1304      }
1305   }
1306   else
1307   {
1308      if ((UINT16)ACCUM(accum).h.high != 0)
1309      {
1310         return 0xffff;
1311      }
1312      else
1313      {
1314         if (ACCUM(accum).h.mid < 0)
1315         {
1316            return 0xffff;
1317         }
1318         else
1319         {
1320            if (slice == 0)
1321            {
1322               return ACCUM(accum).h.low;
1323            }
1324            else
1325            {
1326               return ACCUM(accum).h.mid;
1327            }
1328         }
1329      }
1330   }
1331
1332   return 0;
1333}
1334
12721335#define WRITEBACK_RESULT()                \
12731336   do {                           \
12741337      W_VREG_S(VDREG, 0, vres[0]);         \
r6740r6741
15171580
15181581      ACCUM(del).l += (INT64)(r) << 17;
15191582      //ACCUM(del) += (INT64)(r) << 17;
1520      res = SATURATE_ACCUM(rsp, del, 1, 0x8000, 0x7fff);
1583      res = SATURATE_ACCUM_SIGNED(rsp, del, 1);
15211584
15221585      vres[del] = res;
15231586   }
r6740r6741
16041667      W_ACCUM_M(del, (UINT16)(r3));
16051668      W_ACCUM_H(del, ACCUM(del).h.high + (INT16)(r3 >> 16));
16061669
1607      res = SATURATE_ACCUM(rsp, del, 0, 0x0000, 0xffff);
1670      res = SATURATE_ACCUM_UNSIGNED(rsp, del, 0);
16081671
16091672      vres[del] = res;
16101673   }
r6740r6741
16401703      if ((INT32)(r1) < 0)
16411704         W_ACCUM_H(del, (UINT16)ACCUM(del).h.high - 1);
16421705
1643      res = SATURATE_ACCUM(rsp, del, 1, 0x8000, 0x7fff);
1706      res = SATURATE_ACCUM_SIGNED(rsp, del, 1);
16441707
16451708      vres[del] = res;
16461709   }
r6740r6741
16751738      if ((INT32)(r1) < 0)
16761739         W_ACCUM_H(del, (UINT16)ACCUM(del).h.high - 1);
16771740
1678      vres[del] = SATURATE_ACCUM(rsp, del, 0, 0x0000, 0xffff);
1741      vres[del] = SATURATE_ACCUM_UNSIGNED(rsp, del, 0);
16791742   }
16801743   WRITEBACK_RESULT();
16811744}
r6740r6741
17031766
17041767      ACCUM(del).l += (INT64)(r) << 32;
17051768
1706      res = SATURATE_ACCUM(rsp, del, 1, 0x8000, 0x7fff);
1769      res = SATURATE_ACCUM_SIGNED(rsp, del, 1);
17071770
17081771      vres[del] = res;
17091772   }
r6740r6741
23312394   WRITEBACK_RESULT();
23322395}
23332396
2334//   switch(EL)
2335//   {
2336//      case 0: /* 0, 1, 2, 3, 4, 5, 6, 7 - none */      /* 0, 1, 2, 3, 4, 5, 6, 7 - none */
2337//         break;
2338//      case 1: /* 0, 1, 2, 3, 4, 5, 6, 7 - ???  */      /* 0, 1, 2, 3, 4, 5, 6, 7 - ???  */
2339//         break;
2340//      case 2: /* 1, 3, 5, 7, 0, 2, 4, 6 - 0q   */      /* 0, 0, 2, 2, 4, 4, 6, 6 - 0q   */
2341//         break;
2342//      case 3: /* 0, 2, 4, 6, 1, 3, 5, 7 - 1q   */      /* 1, 1, 3, 3, 5, 5, 7, 7 - 1q   */
2343//         break;
2344//      case 4: /* 1, 2, 3, 5, 6, 7, 0, 4 - 0h   */      /* 0, 0, 0, 0, 4, 4, 4, 4 - 0h   */
2345//         break;
2346//      case 5: /* 0, 2, 3, 4, 6, 7, 1, 5 - 1h   */      /* 1, 1, 1, 1, 5, 5, 5, 5 - 1h   */
2347//         break;
2348//      case 6: /* 0, 1, 3, 4, 5, 7, 2, 6 - 2h   */      /* 2, 2, 2, 2, 6, 6, 6, 6 - 2h   */
2349//         break;
2350//      case 7: /* 0, 1, 2, 4, 5, 6, 3, 7 - 3h   */      /* 3, 3, 3, 3, 7, 7, 7, 7 - 3h   */
2351//         break;
2352//      case 8: /* 1, 2, 3, 4, 5, 6, 7, 0 - 0    */      /*  0, 0, 0, 0, 0, 0, 0, 0 - 0    */
2353//         break;
2354//      case 9: /* 0, 2, 3, 4, 5, 6, 7, 1 - 1    */      /*  1, 1, 1, 1, 1, 1, 1, 1 - 0    */
2355//         break;
2356//      case 10:/* 0, 1, 3, 4, 5, 6, 7, 2 - 2    */      /*  2, 2, 2, 2, 2, 2, 2, 2 - 0    */
2357//         break;
2358//      case 11:/* 0, 1, 2, 4, 5, 6, 7, 3 - 3    */      /*  3, 3, 3, 3, 3, 3, 3, 3 - 0    */
2359//         break;
2360//      case 12:/* 0, 1, 2, 3, 5, 6, 7, 4 - 4    */      /*  4, 4, 4, 4, 4, 4, 4, 4 - 0    */
2361//         break;
2362//      case 13:/* 0, 1, 2, 3, 4, 6, 7, 5 - 5    */      /*  5, 5, 5, 5, 5, 5, 5, 5 - 0    */
2363//         break;
2364//      case 14:/* 0, 1, 2, 3, 4, 5, 7, 6 - 6    */      /*  6, 6, 6, 6, 6, 6, 6, 6 - 0    */
2365//         break;
2366//      case 15:/* 0, 1, 2, 3, 4, 5, 6, 7 - 7    */      /*  7, 7, 7, 7, 7, 7, 7, 7 - 0    */
2367//         break;
2368//   }
2397//  switch(EL)
2398//  {
2399//      case 0: /* 0, 1, 2, 3, 4, 5, 6, 7 - none */     /* 0, 1, 2, 3, 4, 5, 6, 7 - none */
2400//          break;
2401//      case 1: /* 0, 1, 2, 3, 4, 5, 6, 7 - ???  */     /* 0, 1, 2, 3, 4, 5, 6, 7 - ???  */
2402//          break;
2403//      case 2: /* 1, 3, 5, 7, 0, 2, 4, 6 - 0q   */     /* 0, 0, 2, 2, 4, 4, 6, 6 - 0q   */
2404//          break;
2405//      case 3: /* 0, 2, 4, 6, 1, 3, 5, 7 - 1q   */     /* 1, 1, 3, 3, 5, 5, 7, 7 - 1q   */
2406//          break;
2407//      case 4: /* 1, 2, 3, 5, 6, 7, 0, 4 - 0h   */     /* 0, 0, 0, 0, 4, 4, 4, 4 - 0h   */
2408//          break;
2409//      case 5: /* 0, 2, 3, 4, 6, 7, 1, 5 - 1h   */     /* 1, 1, 1, 1, 5, 5, 5, 5 - 1h   */
2410//          break;
2411//      case 6: /* 0, 1, 3, 4, 5, 7, 2, 6 - 2h   */     /* 2, 2, 2, 2, 6, 6, 6, 6 - 2h   */
2412//          break;
2413//      case 7: /* 0, 1, 2, 4, 5, 6, 3, 7 - 3h   */     /* 3, 3, 3, 3, 7, 7, 7, 7 - 3h   */
2414//          break;
2415//      case 8: /* 1, 2, 3, 4, 5, 6, 7, 0 - 0    */     /*  0, 0, 0, 0, 0, 0, 0, 0 - 0    */
2416//          break;
2417//      case 9: /* 0, 2, 3, 4, 5, 6, 7, 1 - 1    */     /*  1, 1, 1, 1, 1, 1, 1, 1 - 0    */
2418//          break;
2419//      case 10:/* 0, 1, 3, 4, 5, 6, 7, 2 - 2    */     /*  2, 2, 2, 2, 2, 2, 2, 2 - 0    */
2420//          break;
2421//      case 11:/* 0, 1, 2, 4, 5, 6, 7, 3 - 3    */     /*  3, 3, 3, 3, 3, 3, 3, 3 - 0    */
2422//          break;
2423//      case 12:/* 0, 1, 2, 3, 5, 6, 7, 4 - 4    */     /*  4, 4, 4, 4, 4, 4, 4, 4 - 0    */
2424//          break;
2425//      case 13:/* 0, 1, 2, 3, 4, 6, 7, 5 - 5    */     /*  5, 5, 5, 5, 5, 5, 5, 5 - 0    */
2426//          break;
2427//      case 14:/* 0, 1, 2, 3, 4, 5, 7, 6 - 6    */     /*  6, 6, 6, 6, 6, 6, 6, 6 - 0    */
2428//          break;
2429//      case 15:/* 0, 1, 2, 3, 4, 5, 6, 7 - 7    */     /*  7, 7, 7, 7, 7, 7, 7, 7 - 0    */
2430//          break;
2431//  }
23692432
23702433#define RSP_VMRG(E10, E11, E12, E13, E14, E15, E16, E17, E20, E21, E22, E23, E24, E25, E26, E27) \
23712434   if (COMPARE_FLAG(E10))               \
r6740r6741
24652528           RSP_VMRG(0, 2, 4, 6, 1, 3, 5, 7, 1, 1, 3, 3, 5, 5, 7, 7);
24662529           break;
24672530        case 4: /* 1, 2, 3, 5, 6, 7, 0, 4 - 0h   */      /* 0, 0, 0, 0, 4, 4, 4, 4 - 0h   */
2468           RSP_VMRG(1, 3, 5, 6, 7, 0, 4, 6, 0, 0, 0, 0, 4, 4, 4, 4);
2531           RSP_VMRG(1, 2, 3, 5, 6, 7, 0, 4, 0, 0, 0, 0, 4, 4, 4, 4);
24692532           break;
24702533        case 5: /* 0, 2, 3, 4, 6, 7, 1, 5 - 1h   */      /* 1, 1, 1, 1, 5, 5, 5, 5 - 1h   */
24712534           RSP_VMRG(0, 2, 3, 4, 6, 7, 1, 5, 1, 1, 1, 1, 5, 5, 5, 5);
r6740r6741
25462609           RSP_VAND(0, 2, 4, 6, 1, 3, 5, 7, 1, 1, 3, 3, 5, 5, 7, 7);
25472610           break;
25482611        case 4: /* 1, 2, 3, 5, 6, 7, 0, 4 - 0h   */      /* 0, 0, 0, 0, 4, 4, 4, 4 - 0h   */
2549           RSP_VAND(1, 3, 5, 6, 7, 0, 4, 6, 0, 0, 0, 0, 4, 4, 4, 4);
2612           RSP_VAND(1, 2, 3, 5, 6, 7, 0, 4, 0, 0, 0, 0, 4, 4, 4, 4);
25502613           break;
25512614        case 5: /* 0, 2, 3, 4, 6, 7, 1, 5 - 1h   */      /* 1, 1, 1, 1, 5, 5, 5, 5 - 1h   */
25522615           RSP_VAND(0, 2, 3, 4, 6, 7, 1, 5, 1, 1, 1, 1, 5, 5, 5, 5);
r6740r6741
26272690           RSP_VNAND(0, 2, 4, 6, 1, 3, 5, 7, 1, 1, 3, 3, 5, 5, 7, 7);
26282691           break;
26292692        case 4: /* 1, 2, 3, 5, 6, 7, 0, 4 - 0h   */      /* 0, 0, 0, 0, 4, 4, 4, 4 - 0h   */
2630           RSP_VNAND(1, 3, 5, 6, 7, 0, 4, 6, 0, 0, 0, 0, 4, 4, 4, 4);
2693           RSP_VNAND(1, 2, 3, 5, 6, 7, 0, 4, 0, 0, 0, 0, 4, 4, 4, 4);
26312694           break;
26322695        case 5: /* 0, 2, 3, 4, 6, 7, 1, 5 - 1h   */      /* 1, 1, 1, 1, 5, 5, 5, 5 - 1h   */
26332696           RSP_VNAND(0, 2, 3, 4, 6, 7, 1, 5, 1, 1, 1, 1, 5, 5, 5, 5);
r6740r6741
27082771           RSP_VOR(0, 2, 4, 6, 1, 3, 5, 7, 1, 1, 3, 3, 5, 5, 7, 7);
27092772           break;
27102773        case 4: /* 1, 2, 3, 5, 6, 7, 0, 4 - 0h   */      /* 0, 0, 0, 0, 4, 4, 4, 4 - 0h   */
2711           RSP_VOR(1, 3, 5, 6, 7, 0, 4, 6, 0, 0, 0, 0, 4, 4, 4, 4);
2774           RSP_VOR(1, 2, 3, 5, 6, 7, 0, 4, 0, 0, 0, 0, 4, 4, 4, 4);
27122775           break;
27132776        case 5: /* 0, 2, 3, 4, 6, 7, 1, 5 - 1h   */      /* 1, 1, 1, 1, 5, 5, 5, 5 - 1h   */
27142777           RSP_VOR(0, 2, 3, 4, 6, 7, 1, 5, 1, 1, 1, 1, 5, 5, 5, 5);
r6740r6741
27892852           RSP_VNOR(0, 2, 4, 6, 1, 3, 5, 7, 1, 1, 3, 3, 5, 5, 7, 7);
27902853           break;
27912854        case 4: /* 1, 2, 3, 5, 6, 7, 0, 4 - 0h   */      /* 0, 0, 0, 0, 4, 4, 4, 4 - 0h   */
2792           RSP_VNOR(1, 3, 5, 6, 7, 0, 4, 6, 0, 0, 0, 0, 4, 4, 4, 4);
2855           RSP_VNOR(1, 2, 3, 5, 6, 7, 0, 4, 0, 0, 0, 0, 4, 4, 4, 4);
27932856           break;
27942857        case 5: /* 0, 2, 3, 4, 6, 7, 1, 5 - 1h   */      /* 1, 1, 1, 1, 5, 5, 5, 5 - 1h   */
27952858           RSP_VNOR(0, 2, 3, 4, 6, 7, 1, 5, 1, 1, 1, 1, 5, 5, 5, 5);
r6740r6741
28702933           RSP_VXOR(0, 2, 4, 6, 1, 3, 5, 7, 1, 1, 3, 3, 5, 5, 7, 7);
28712934           break;
28722935        case 4: /* 1, 2, 3, 5, 6, 7, 0, 4 - 0h   */      /* 0, 0, 0, 0, 4, 4, 4, 4 - 0h   */
2873           RSP_VXOR(1, 3, 5, 6, 7, 0, 4, 6, 0, 0, 0, 0, 4, 4, 4, 4);
2936           RSP_VXOR(1, 2, 3, 5, 6, 7, 0, 4, 0, 0, 0, 0, 4, 4, 4, 4);
28742937           break;
28752938        case 5: /* 0, 2, 3, 4, 6, 7, 1, 5 - 1h   */      /* 1, 1, 1, 1, 5, 5, 5, 5 - 1h   */
28762939           RSP_VXOR(0, 2, 3, 4, 6, 7, 1, 5, 1, 1, 1, 1, 5, 5, 5, 5);
r6740r6741
29513014           RSP_VNXOR(0, 2, 4, 6, 1, 3, 5, 7, 1, 1, 3, 3, 5, 5, 7, 7);
29523015           break;
29533016        case 4: /* 1, 2, 3, 5, 6, 7, 0, 4 - 0h   */      /* 0, 0, 0, 0, 4, 4, 4, 4 - 0h   */
2954           RSP_VNXOR(1, 3, 5, 6, 7, 0, 4, 6, 0, 0, 0, 0, 4, 4, 4, 4);
3017           RSP_VNXOR(1, 2, 3, 5, 6, 7, 0, 4, 0, 0, 0, 0, 4, 4, 4, 4);
29553018           break;
29563019        case 5: /* 0, 2, 3, 4, 6, 7, 1, 5 - 1h   */      /* 1, 1, 1, 1, 5, 5, 5, 5 - 1h   */
29573020           RSP_VNXOR(0, 2, 3, 4, 6, 7, 1, 5, 1, 1, 1, 1, 5, 5, 5, 5);
r6740r6741
35603623   drcuml_block *block;
35613624   jmp_buf errorbuf;
35623625
3626   profiler_mark_start(PROFILER_DRC_COMPILE);
3627
35633628   /* get a description of this sequence */
35643629   desclist = drcfe_describe_code(rsp->impstate->drcfe, pc);
35653630
r6740r6741
36393704
36403705   /* end the sequence */
36413706   drcuml_block_end(block);
3707   profiler_mark_end();
36423708}
36433709
36443710/***************************************************************************
r6740r6741
36623728    cfunc_fatalerror - a generic fatalerror call
36633729-------------------------------------------------*/
36643730
3731#ifndef LSB_FIRST
36653732static void cfunc_fatalerror(void *param)
36663733{
36673734   //fatalerror("fatalerror");
36683735}
3736#endif
36693737
36703738
36713739/***************************************************************************
r6740r6741
37813849   drcuml_state *drcuml = rsp->impstate->drcuml;
37823850   drcuml_block *block;
37833851   jmp_buf errorbuf;
3784   int label = 1;
3785   UINT32 unaligned_w2 = label++;
3786   UINT32 aligned_w2 = label++;
3787   UINT32 unaligned_w4 = label++;
3788   UINT32 unaligned_r2 = label++;
3789   UINT32 unaligned_r4 = label++;
3852   int unaligned_case = 1;
37903853
37913854   /* if we get an error back, we're screwed */
37923855   if (setjmp(errorbuf) != 0)
r6740r6741
38013864   alloc_handle(drcuml, handleptr, name);
38023865   UML_HANDLE(block, *handleptr);                                       // handle  *handleptr
38033866
3804   UML_AND(block, IREG(0), IREG(0), IMM(0x00000fff));
38053867
38063868   // write:
38073869   if (iswrite)
38083870   {
38093871      if (size == 1)
38103872      {
3811         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));         // xor     i0,i0,bytexor
3812         UML_STORE(block, rsp->impstate->dmem, IREG(0), IREG(1), BYTE);   // store   dmem,i0,i1,byte
3873#ifdef LSB_FIRST
3874         UML_XOR(block, IREG(0), IREG(0), IMM(3));                           // xor     i0,i0,3
3875#endif
3876         UML_AND(block, IREG(0), IREG(0), IMM(0x00000fff));                     // and     i0,i0,0xfff
3877         UML_STORE(block, rsp->impstate->dmem, IREG(0), IREG(1), BYTE);            // store   dmem,i0,i1,byte
38133878      }
38143879      else if (size == 2)
38153880      {
3816         static const char text[] = "%08x: Unaligned word write to %08x\n";
3881#ifdef LSB_FIRST
38173882         UML_TEST(block, IREG(0), IMM(1));                                 // test    i0,1
3818         UML_JMPc(block, IF_NZ, unaligned_w2);                              // jnz     <unaligned_w2>
3819         UML_JMP(block, aligned_w2);                                       // jmp     <aligned_w2>
3820
3821         UML_LABEL(block, unaligned_w2);                                    // <unaligned_w2>:
3822         UML_MOV(block, MEM(&rsp->impstate->format), IMM((FPTR)text));            // mov     [format],text
3823         UML_MOV(block, MEM(&rsp->impstate->arg0), IMM(rsp->pc));               // mov     [arg0],rsp->pc
3824         UML_MOV(block, MEM(&rsp->impstate->arg1), IREG(0));                     // mov     [arg1],i0
3825         UML_CALLC(block, cfunc_printf_debug, rsp);                           // callc   printf_debug
3826         UML_CALLC(block, cfunc_fatalerror, rsp);
3827
3828         UML_LABEL(block, aligned_w2);                                    // <aligned_w2>:
3829         UML_SHR(block, IREG(0), IREG(0), IMM(1));                           // shr     i0,i0,1
3830         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE_XOR_BE(0)));                  // xor     i0,i0,bytexor
3831         UML_STORE(block, rsp->impstate->dmem, IREG(0), IREG(1), WORD);            // store   dmem,i0,i1,word
3883         UML_JMPc(block, IF_NZ, unaligned_case);                              // jnz     <unaligned_case>
3884         UML_XOR(block, IREG(0), IREG(0), IMM(2));                           // xor     i0,i0,2
3885#endif
3886         UML_AND(block, IREG(0), IREG(0), IMM(0x00000fff));                     // and     i0,i0,0xfff
3887         UML_STORE(block, rsp->impstate->dmem, IREG(0), IREG(1), WORD_x1);         // store   dmem,i0,i1,word_x1
3888         UML_RET(block);
3889#ifdef LSB_FIRST
3890         UML_LABEL(block, unaligned_case);                              // unaligned_case:
3891         UML_ROLAND(block, IREG(2), IREG(0), IMM(3), IMM(0x18));                  // roland  i2,i0,3,0x18
3892         UML_AND(block, IREG(0), IREG(0), IMM(0xffc));                        // and     i0,i0,0xffc
3893         UML_DLOAD(block, IREG(3), rsp->impstate->dmem, IREG(0), QWORD_x1);          // dload   i3,dmem,i0,qword_x1
3894         UML_DROL(block, IREG(3), IREG(3), IREG(2));                           // drol    i3,i3,i2
3895         UML_DAND(block, IREG(1), IREG(1), IMM(0xffff));                        // dand    i1,i1,0xffff
3896         UML_DAND(block, IREG(3), IREG(3), IMM(U64(0xffffffffffff0000)));         // dand    i3,i3,~0xffff
3897         UML_DOR(block, IREG(1), IREG(1), IREG(3));                           // dor     i1,i1,i3
3898         UML_DROR(block, IREG(1), IREG(1), IREG(2));                           // dror    i1,i1,i2
3899         UML_DSTORE(block, rsp->impstate->dmem, IREG(0), IREG(1), QWORD_x1);       // dstore  dmem,i0,i1,qword_x1
3900#endif
38323901      }
38333902      else if (size == 4)
38343903      {
3904#ifdef LSB_FIRST
38353905         UML_TEST(block, IREG(0), IMM(3));                                 // test    i0,3
3836         UML_JMPc(block, IF_NZ, unaligned_w4);                              // jnz     <unaligned_w4>
3837
3838         UML_SHR(block, IREG(0), IREG(0), IMM(2));                           // shr     i0,i0,2
3839         UML_STORE(block, rsp->impstate->dmem, IREG(0), IREG(1), DWORD);            // store   dmem,i0,i1,dword
3906         UML_JMPc(block, IF_NZ, unaligned_case);                              // jnz     <unaligned_case>
3907#endif
3908         UML_AND(block, IREG(0), IREG(0), IMM(0x00000fff));                     // and     i0,i0,0xfff
3909         UML_STORE(block, rsp->impstate->dmem, IREG(0), IREG(1), DWORD_x1);         // store   dmem,i0,i1,dword_x1
38403910         UML_RET(block);
3841
3842         UML_LABEL(block, unaligned_w4);
3843         UML_ADD(block, IREG(0), IREG(0), IMM(3));
3844
3845         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3846         UML_STORE(block, rsp->impstate->dmem, IREG(0), IREG(1), BYTE);
3847
3848         UML_SHR(block, IREG(1), IREG(1), IMM(8));
3849         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3850         UML_SUB(block, IREG(0), IREG(0), IMM(1));
3851         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3852         UML_STORE(block, rsp->impstate->dmem, IREG(0), IREG(1), BYTE);
3853
3854         UML_SHR(block, IREG(1), IREG(1), IMM(8));
3855         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3856         UML_SUB(block, IREG(0), IREG(0), IMM(1));
3857         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3858         UML_STORE(block, rsp->impstate->dmem, IREG(0), IREG(1), BYTE);
3859
3860         UML_SHR(block, IREG(1), IREG(1), IMM(8));
3861         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3862         UML_SUB(block, IREG(0), IREG(0), IMM(1));
3863         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3864         UML_STORE(block, rsp->impstate->dmem, IREG(0), IREG(1), BYTE);
3911#ifdef LSB_FIRST
3912         UML_LABEL(block, unaligned_case);                              // unaligned_case:
3913         UML_ROLAND(block, IREG(2), IREG(0), IMM(3), IMM(0x18));                  // roland  i2,i0,3,0x18
3914         UML_AND(block, IREG(0), IREG(0), IMM(0xffc));                        // and     i0,i0,0xffc
3915         UML_DLOAD(block, IREG(3), rsp->impstate->dmem, IREG(0), QWORD_x1);          // dload   i3,dmem,i0,qword_x1
3916         UML_DROL(block, IREG(3), IREG(3), IREG(2));                           // drol    i3,i3,i2
3917         UML_DAND(block, IREG(1), IREG(1), IMM(0xffffffff));                     // dand    i1,i1,0xffffffff
3918         UML_DAND(block, IREG(3), IREG(3), IMM(U64(0xffffffff00000000)));         // dand    i3,i3,~0xffffffff
3919         UML_DOR(block, IREG(1), IREG(1), IREG(3));                           // dor     i1,i1,i3
3920         UML_DROR(block, IREG(1), IREG(1), IREG(2));                           // dror    i1,i1,i2
3921         UML_DSTORE(block, rsp->impstate->dmem, IREG(0), IREG(1), QWORD_x1);       // dstore  dmem,i0,i1,qword_x1
3922#endif
38653923      }
38663924   }
38673925   else
38683926   {
38693927      if (size == 1)
38703928      {
3871         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));                  // xor     i0,i0,bytexor
3929#ifdef LSB_FIRST
3930         UML_XOR(block, IREG(0), IREG(0), IMM(3));                           // xor     i0,i0,3
3931#endif
3932         UML_AND(block, IREG(0), IREG(0), IMM(0x00000fff));                     // and     i0,i0,0xfff
38723933         UML_LOAD(block, IREG(0), rsp->impstate->dmem, IREG(0), BYTE);            // load    i0,dmem,i0,byte
38733934      }
38743935      else if (size == 2)
38753936      {
3876         UML_TEST(block, IREG(0), IMM(1));                                 // test    i0,3
3877         UML_JMPc(block, IF_NZ, unaligned_r2);                              // jnz     <unaligned_r2>
3878
3879         UML_SHR(block, IREG(0), IREG(0), IMM(1));                           // shr     i0,i0,1
3880         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE_XOR_BE(0)));                  // xor     i0,i0,bytexor
3881         UML_LOAD(block, IREG(0), rsp->impstate->dmem, IREG(0), WORD);            // load    i0,dmem,i0,word
3937#ifdef LSB_FIRST
3938         UML_TEST(block, IREG(0), IMM(1));                                 // test    i0,1
3939         UML_JMPc(block, IF_NZ, unaligned_case);                              // jnz     <unaligned_case>
3940         UML_XOR(block, IREG(0), IREG(0), IMM(2));                           // xor     i0,i0,2
3941#endif
3942         UML_AND(block, IREG(0), IREG(0), IMM(0x00000fff));                     // and     i0,i0,0xfff
3943         UML_LOAD(block, IREG(0), rsp->impstate->dmem, IREG(0), WORD_x1);         // load    i0,dmem,i0,word_x1
38823944         UML_RET(block);
3883
3884         UML_LABEL(block, unaligned_r2);
3885         UML_MOV(block, IREG(2), IMM(0));
3886         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3887
3888         UML_LOAD(block, IREG(3), rsp->impstate->dmem, IREG(0), BYTE);
3889         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3890         UML_ADD(block, IREG(0), IREG(0), IMM(1));
3891         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3892         UML_OR(block, IREG(2), IREG(2), IREG(3));
3893
3894         UML_LOAD(block, IREG(3), rsp->impstate->dmem, IREG(0), BYTE);
3895         UML_ADD(block, IREG(0), IREG(0), IMM(1));
3896         UML_SHL(block, IREG(2), IREG(2), IMM(8));
3897         UML_OR(block, IREG(2), IREG(2), IREG(3));
3898
3899         UML_MOV(block, IREG(0), IREG(2));
3945#ifdef LSB_FIRST
3946         UML_LABEL(block, unaligned_case);                              // unaligned_case:
3947         UML_ROLAND(block, IREG(1), IREG(0), IMM(3), IMM(0x18));                  // roland  i1,i0,3,0x18
3948         UML_AND(block, IREG(0), IREG(0), IMM(0xffc));                        // and     i0,i0,0xffc
3949         UML_DLOAD(block, IREG(0), rsp->impstate->dmem, IREG(0), QWORD_x1);          // dload   i0,dmem,i0,qword_x1
3950         UML_DROL(block, IREG(0), IREG(0), IREG(1));                           // drol    i0,i0,i1
3951         UML_AND(block, IREG(0), IREG(0), IMM(0xffff));                        // and     i0,i0,0xffff
3952#endif
39003953      }
39013954      else if (size == 4)
39023955      {
3956#ifdef LSB_FIRST
39033957         UML_TEST(block, IREG(0), IMM(3));                                 // test    i0,3
3904         UML_JMPc(block, IF_NZ, unaligned_r4);                              // jnz     <unaligned_r4>
3905
3906         UML_SHR(block, IREG(0), IREG(0), IMM(2));                           // shr     i0,i0,2
3907         UML_LOAD(block, IREG(0), rsp->impstate->dmem, IREG(0), DWORD);            // load    i0,dmem,i0,dword
3958         UML_JMPc(block, IF_NZ, unaligned_case);                              // jnz     <unaligned_case>
3959#endif
3960         UML_AND(block, IREG(0), IREG(0), IMM(0x00000fff));                     // and     i0,i0,0xfff
3961         UML_LOAD(block, IREG(0), rsp->impstate->dmem, IREG(0), DWORD_x1);         // load    i0,dmem,i0,dword_x1
39083962         UML_RET(block);
3909
3910         UML_LABEL(block, unaligned_r4);
3911         UML_MOV(block, IREG(2), IMM(0));
3912         UML_MOV(block, IREG(3), IMM(0));
3913
3914         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3915         UML_LOAD(block, IREG(3), rsp->impstate->dmem, IREG(0), BYTE);
3916         UML_SHL(block, IREG(3), IREG(3), IMM(24));
3917         UML_OR(block, IREG(2), IREG(2), IREG(3));
3918
3919         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3920         UML_ADD(block, IREG(0), IREG(0), IMM(1));
3921         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3922         UML_LOAD(block, IREG(3), rsp->impstate->dmem, IREG(0), BYTE);
3923         UML_SHL(block, IREG(3), IREG(3), IMM(16));
3924         UML_OR(block, IREG(2), IREG(2), IREG(3));
3925
3926         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3927         UML_ADD(block, IREG(0), IREG(0), IMM(1));
3928         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3929         UML_LOAD(block, IREG(3), rsp->impstate->dmem, IREG(0), BYTE);
3930         UML_SHL(block, IREG(3), IREG(3), IMM(8));
3931         UML_OR(block, IREG(2), IREG(2), IREG(3));
3932
3933         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3934         UML_ADD(block, IREG(0), IREG(0), IMM(1));
3935         UML_XOR(block, IREG(0), IREG(0), IMM(BYTE4_XOR_BE(0)));
3936         UML_LOAD(block, IREG(3), rsp->impstate->dmem, IREG(0), BYTE);
3937         UML_OR(block, IREG(2), IREG(2), IREG(3));
3938
3939         UML_MOV(block, IREG(0), IREG(2));
3963#ifdef LSB_FIRST
3964         UML_LABEL(block, unaligned_case);                              // unaligned_case:
3965         UML_ROLAND(block, IREG(1), IREG(0), IMM(3), IMM(0x18));                  // roland  i1,i0,3,0x18
3966         UML_AND(block, IREG(0), IREG(0), IMM(0xffc));                        // and     i0,i0,0xffc
3967         UML_DLOAD(block, IREG(0), rsp->impstate->dmem, IREG(0), QWORD_x1);          // dload   i0,dmem,i0,qword_x1
3968         UML_DROL(block, IREG(0), IREG(0), IREG(1));                           // drol    i0,i0,i1
3969#endif
39403970      }
39413971   }
39423972   UML_RET(block);
r6740r6741
40214051{
40224052   offs_t expc;
40234053
4054   /* add an entry for the log */
4055   if (LOG_UML && !(desc->flags & OPFLAG_VIRTUAL_NOOP))
4056      log_add_disasm_comment(rsp, block, desc->pc, desc->opptr.l[0]);
4057
40244058   /* set the PC map variable */
40254059   expc = (desc->flags & OPFLAG_IN_DELAY_SLOT) ? desc->pc - 3 : desc->pc;
40264060   UML_MAPVAR(block, MAPVAR_PC, expc);                                    // mapvar  PC,expc
r6740r6741
40424076   /* if we hit an unmapped address, fatal error */
40434077   //if (desc->flags & OPFLAG_COMPILER_UNMAPPED)
40444078   //{
4045   //   UML_MOV(block, MEM(&rsp->pc), IMM(desc->pc));                        // mov     [pc],desc->pc
4046   //   save_fast_iregs(rsp, block);
4047   //   UML_EXIT(block, IMM(EXECUTE_UNMAPPED_CODE));                        // exit    EXECUTE_UNMAPPED_CODE
4079   //  UML_MOV(block, MEM(&rsp->pc), IMM(desc->pc));                               // mov     [pc],desc->pc
4080   //  save_fast_iregs(rsp, block);
4081   //  UML_EXIT(block, IMM(EXECUTE_UNMAPPED_CODE));                                // exit    EXECUTE_UNMAPPED_CODE
40484082   //}
40494083
40504084   /* otherwise, unless this is a virtual no-op, it's a regular instruction */
r6740r6741
40744108   if (desc->targetpc == BRANCH_TARGET_DYNAMIC)
40754109   {
40764110      UML_MOV(block, MEM(&rsp->impstate->jmpdest), R32(RSREG));               // mov     [jmpdest],<rsreg>
4111      UML_AND(block, MEM(&rsp->impstate->jmpdest), R32(RSREG), IMM(0x00000fff));
4112      UML_OR(block, MEM(&rsp->impstate->jmpdest), MEM(&rsp->impstate->jmpdest), IMM(0x1000));
40774113   }
40784114
40794115   /* set the link if needed -- before the delay slot */
r6740r6741
41944230      case 0x09:   /* ADDIU - MIPS I */
41954231         if (RTREG != 0)
41964232         {
4197            UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));               // add     i0,<rsreg>,SIMMVAL,V
4198            UML_SEXT(block, R32(RTREG), IREG(0), DWORD);                  // dsext   <rtreg>,i0,dword
4233            UML_ADD(block, R32(RTREG), R32(RSREG), IMM(SIMMVAL));         // add     i0,<rsreg>,SIMMVAL,V
41994234         }
42004235         return TRUE;
42014236
r6740r6741
42554290         UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL));                  // add     i0,<rsreg>,SIMMVAL
42564291         UML_CALLH(block, rsp->impstate->read32);                        // callh   read32
42574292         if (RTREG != 0)
4258            UML_SEXT(block, R32(RTREG), IREG(0), DWORD);                  // dsext   <rtreg>,i0
4293            UML_MOV(block, R32(RTREG), IREG(0));                     // mov   <rtreg>,i0
42594294         if (!in_delay_slot)
42604295            generate_update_cycles(rsp, block, compiler, IMM(desc->pc + 4), TRUE);
42614296         return TRUE;
r6740r6741
42824317         UML_MOV(block, MEM(&rsp->impstate->arg0), IMM(desc->opptr.l[0]));      // mov     [arg0],desc->opptr.l
42834318         UML_CALLC(block, cfunc_lwc2, rsp);                              // callc   cfunc_mfc2
42844319         return TRUE;
4320         //return generate_lwc2(rsp, block, compiler, desc);
42854321
42864322
42874323      /* ----- memory store operations ----- */
r6740r6741
43534389      case 0x00:   /* SLL - MIPS I */
43544390         if (RDREG != 0)
43554391         {
4356            UML_SHL(block, IREG(0), R32(RTREG), IMM(SHIFT));               // shl     i0,<rtreg>,<shift>
4357            UML_SEXT(block, R32(RDREG), IREG(0), DWORD);                  // dsext   <rdreg>,i0,dword
4392            UML_SHL(block, R32(RDREG), R32(RTREG), IMM(SHIFT));               // shl     i0,<rtreg>,<shift>
43584393         }
43594394         return TRUE;
43604395
43614396      case 0x02:   /* SRL - MIPS I */
43624397         if (RDREG != 0)
43634398         {
4364            UML_SHR(block, IREG(0), R32(RTREG), IMM(SHIFT));               // shr     i0,<rtreg>,<shift>
4365            UML_SEXT(block, R32(RDREG), IREG(0), DWORD);                  // dsext   <rdreg>,i0,dword
4399            UML_SHR(block, R32(RDREG), R32(RTREG), IMM(SHIFT));               // shr     i0,<rtreg>,<shift>
43664400         }
43674401         return TRUE;
43684402
43694403      case 0x03:   /* SRA - MIPS I */
43704404         if (RDREG != 0)
43714405         {
4372            UML_SAR(block, IREG(0), R32(RTREG), IMM(SHIFT));               // sar     i0,<rtreg>,<shift>
4373            UML_SEXT(block, R32(RDREG), IREG(0), DWORD);                  // dsext   <rdreg>,i0,dword
4406            UML_SAR(block, R32(RDREG), R32(RTREG), IMM(SHIFT));               // sar     i0,<rtreg>,<shift>
43744407         }
43754408         return TRUE;
43764409
43774410      case 0x04:   /* SLLV - MIPS I */
43784411         if (RDREG != 0)
43794412         {
4380            UML_SHL(block, IREG(0), R32(RTREG), R32(RSREG));               // shl     i0,<rtreg>,<rsreg>
4381            UML_SEXT(block, R32(RDREG), IREG(0), DWORD);                  // dsext   <rdreg>,i0,dword
4413            UML_SHL(block, R32(RDREG), R32(RTREG), R32(RSREG));               // shl     i0,<rtreg>,<rsreg>
43824414         }
43834415         return TRUE;
43844416
43854417      case 0x06:   /* SRLV - MIPS I */
43864418         if (RDREG != 0)
43874419         {
4388            UML_SHR(block, IREG(0), R32(RTREG), R32(RSREG));               // shr     i0,<rtreg>,<rsreg>
4389            UML_SEXT(block, R32(RDREG), IREG(0), DWORD);                  // dsext   <rdreg>,i0,dword
4420            UML_SHR(block, R32(RDREG), R32(RTREG), R32(RSREG));               // shr     i0,<rtreg>,<rsreg>
43904421         }
43914422         return TRUE;
43924423
43934424      case 0x07:   /* SRAV - MIPS I */
43944425         if (RDREG != 0)
43954426         {
4396            UML_SAR(block, IREG(0), R32(RTREG), R32(RSREG));               // sar     i0,<rtreg>,<rsreg>
4397            UML_SEXT(block, R32(RDREG), IREG(0), DWORD);                  // dsext   <rdreg>,i0,dword
4427            UML_SAR(block, R32(RDREG), R32(RTREG), R32(RSREG));               // sar     i0,<rtreg>,<rsreg>
43984428         }
43994429         return TRUE;
44004430
r6740r6741
44034433      case 0x20:   /* ADD - MIPS I */
44044434         if (RDREG != 0)
44054435         {
4406            UML_ADD(block, IREG(0), R32(RSREG), R32(RTREG));               // add     i0,<rsreg>,<rtreg>
4407            UML_SEXT(block, R32(RDREG), IREG(0), DWORD);                  // dsext   <rdreg>,i0,dword
4436            UML_ADD(block, R32(RDREG), R32(RSREG), R32(RTREG));               // add     i0,<rsreg>,<rtreg>
44084437         }
44094438         return TRUE;
44104439
44114440      case 0x21:   /* ADDU - MIPS I */
44124441         if (RDREG != 0)
44134442         {
4414            UML_ADD(block, IREG(0), R32(RSREG), R32(RTREG));               // add     i0,<rsreg>,<rtreg>
4415            UML_SEXT(block, R32(RDREG), IREG(0), DWORD);                  // dsext   <rdreg>,i0,dword
4443            UML_ADD(block, R32(RDREG), R32(RSREG), R32(RTREG));               // add     i0,<rsreg>,<rtreg>
44164444         }
44174445         return TRUE;
44184446
44194447      case 0x22:   /* SUB - MIPS I */
44204448         if (RDREG != 0)
44214449         {
4422            UML_SUB(block, IREG(0), R32(RSREG), R32(RTREG));               // sub     i0,<rsreg>,<rtreg>
4423            UML_SEXT(block, R32(RDREG), IREG(0), DWORD);                  // dsext   <rdreg>,i0,dword
4450            UML_SUB(block, R32(RDREG), R32(RSREG), R32(RTREG));               // sub     i0,<rsreg>,<rtreg>
44244451         }
44254452         return TRUE;
44264453
44274454      case 0x23:   /* SUBU - MIPS I */
44284455         if (RDREG != 0)
44294456         {
4430            UML_SUB(block, IREG(0), R32(RSREG), R32(RTREG));               // sub     i0,<rsreg>,<rtreg>
4431            UML_SEXT(block, R32(RDREG), IREG(0), DWORD);                  // dsext   <rdreg>,i0,dword
4457            UML_SUB(block, R32(RDREG), R32(RSREG), R32(RTREG));               // sub     i0,<rsreg>,<rtreg>
44324458         }
44334459         return TRUE;
44344460
r6740r6741
45014527   return FALSE;
45024528}
45034529
4504
4505
45064530/*-------------------------------------------------
45074531    generate_regimm - compile opcodes in the
45084532    'REGIMM' group
r6740r6741
45634587         {
45644588            UML_MOV(block, MEM(&rsp->impstate->arg0), IMM(desc->opptr.l[0]));   // mov     [arg0],desc->opptr.l
45654589            UML_CALLC(block, cfunc_mfc2, rsp);                           // callc   cfunc_mfc2
4566            //UML_SEXT(block, R32(RTREG), IREG(0), DWORD);                  // dsext   <rtreg>,i0,dword
4590            //UML_SEXT(block, R32(RTREG), IREG(0), DWORD);                      // dsext   <rtreg>,i0,dword
45674591         }
45684592         return TRUE;
45694593
r6740r6741
45724596         {
45734597            UML_MOV(block, MEM(&rsp->impstate->arg0), IMM(desc->opptr.l[0]));   // mov     [arg0],desc->opptr.l
45744598            UML_CALLC(block, cfunc_cfc2, rsp);                           // callc   cfunc_cfc2
4575            //UML_SEXT(block, R32(RTREG), IREG(0), DWORD);                  // dsext   <rtreg>,i0,dword
4599            //UML_SEXT(block, R32(RTREG), IREG(0), DWORD);                      // dsext   <rtreg>,i0,dword
45764600         }
45774601         return TRUE;
45784602
r6740r6741
46094633      case 0x00:   /* MFCz */
46104634         if (RTREG != 0)
46114635         {
4612            UML_SEXT(block, MEM(&rsp->impstate->arg0), IMM(RDREG), DWORD);      // mov     [arg0],<rtreg>,dword
4613            UML_SEXT(block, MEM(&rsp->impstate->arg1), IMM(RTREG), DWORD);      // mov     [arg1],<rdval>,dword
4636            UML_MOV(block, MEM(&rsp->impstate->arg0), IMM(RDREG));            // mov     [arg0],<rtreg>,dword
4637            UML_MOV(block, MEM(&rsp->impstate->arg1), IMM(RTREG));            // mov     [arg1],<rdval>,dword
46144638            UML_CALLC(block, cfunc_get_cop0_reg, rsp);                     // callc   cfunc_get_cop0_reg
46154639         }
46164640         return TRUE;
46174641
46184642      case 0x04:   /* MTCz */
4619         UML_SEXT(block, MEM(&rsp->impstate->arg0), IMM(RDREG), DWORD);         // mov     [arg0],<rtreg>,dword
4620         UML_SEXT(block, MEM(&rsp->impstate->arg1), R32(RTREG), DWORD);         // mov     [arg1],<rdval>,dword
4643         UML_MOV(block, MEM(&rsp->impstate->arg0), IMM(RDREG));               // mov     [arg0],<rtreg>,dword
4644         UML_MOV(block, MEM(&rsp->impstate->arg1), R32(RTREG));               // mov     [arg1],<rdval>,dword
46214645         UML_CALLC(block, cfunc_set_cop0_reg, rsp);                        // callc   cfunc_set_cop0_reg
46224646         return TRUE;
46234647   }
r6740r6741
46704694   rsp->flag[RDREG] = RTVAL & 0xffff;
46714695}
46724696
4697/***************************************************************************
4698    CODE LOGGING HELPERS
4699***************************************************************************/
4700
4701/*-------------------------------------------------
4702    log_add_disasm_comment - add a comment
4703    including disassembly of a RSP instruction
4704-------------------------------------------------*/
4705
4706static void log_add_disasm_comment(rsp_state *rsp, drcuml_block *block, UINT32 pc, UINT32 op)
4707{
4708#if (LOG_UML)
4709   char buffer[100];
4710   rsp_dasm_one(buffer, pc, op);
4711   UML_COMMENT(block, "%08X: %s", pc, buffer);                              // comment
4712#endif
4713}
4714
4715
46734716static CPU_SET_INFO( rsp )
46744717{
46754718   rsp_state *rsp = get_safe_token(device);
src/emu/cpu/powerpc/ppcdrc.c
r6740r6741
1919#include <stddef.h>
2020#include "cpuintrf.h"
2121#include "debugger.h"
22#include "profiler.h"
2223#include "ppccom.h"
2324#include "ppcfe.h"
2425#include "cpu/drcfe.h"
r6740r6741
953954   drcuml_block *block;
954955   jmp_buf errorbuf;
955956
957   profiler_mark_start(PROFILER_DRC_COMPILE);
958
956959   /* get a description of this sequence */
957960   desclist = drcfe_describe_code(ppc->impstate->drcfe, pc);
958961   if (LOG_UML || LOG_NATIVE)
r6740r6741
10341037
10351038   /* end the sequence */
10361039   drcuml_block_end(block);
1040   profiler_mark_end();
10371041}
10381042
10391043
r6740r6741
15681572            {
15691573               if (size == 1)
15701574               {
1571                  UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 0));               // xor     i0,i0,fastxor >>
1575                  UML_XOR(block, IREG(0), IREG(0), IMM(fastxor & 7));                  // xor     i0,i0,fastxor & 7
15721576                  UML_LOAD(block, IREG(0), fastbase, IREG(0), BYTE);                  // load    i0,fastbase,i0,byte
15731577               }
15741578               else if (size == 2)
15751579               {
1576                  UML_SHR(block, IREG(0), IREG(0), IMM(1));                        // shr     i0,i0,1
1577                  UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 1));               // xor     i0,i0,fastxor >> 1
1578                  UML_LOAD(block, IREG(0), fastbase, IREG(0), WORD);                  // load    i0,fastbase,i0,word
1580                  UML_XOR(block, IREG(0), IREG(0), IMM(fastxor & 6));                  // xor     i0,i0,fastxor & 6
1581                  UML_LOAD(block, IREG(0), fastbase, IREG(0), WORD_x1);               // load    i0,fastbase,i0,word_x1
15791582               }
15801583               else if (size == 4)
15811584               {
1582                  UML_SHR(block, IREG(0), IREG(0), IMM(2));                        // shr     i0,i0,2
1583                  UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 2));               // xor     i0,i0,fastxor >> 2
1584                  UML_LOAD(block, IREG(0), fastbase, IREG(0), DWORD);                  // load    i0,fastbase,i0,dword
1585                  UML_XOR(block, IREG(0), IREG(0), IMM(fastxor & 4));                  // xor     i0,i0,fastxor & 4
1586                  UML_LOAD(block, IREG(0), fastbase, IREG(0), DWORD_x1);               // load    i0,fastbase,i0,dword_x1
15851587               }
15861588               else if (size == 8)
15871589               {
1588                  UML_SHR(block, IREG(0), IREG(0), IMM(3));                        // shr     i0,i0,3
1589                  UML_DLOAD(block, IREG(0), fastbase, IREG(0), QWORD);               // dload   i0,fastbase,i0,qword
1590                  UML_DLOAD(block, IREG(0), fastbase, IREG(0), QWORD_x1);               // dload   i0,fastbase,i0,qword
15901591               }
15911592               UML_RET(block);                                                // ret
15921593            }
r6740r6741
15941595            {
15951596               if (size == 1)
15961597               {
1597                  UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 0));               // xor     i0,i0,fastxor >>
1598                  UML_XOR(block, IREG(0), IREG(0), IMM(fastxor & 7));                  // xor     i0,i0,fastxor & 7
15981599                  UML_STORE(block, fastbase, IREG(0), IREG(1), BYTE);                  // store   fastbase,i0,i1,byte
15991600               }
16001601               else if (size == 2)
16011602               {
1602                  UML_SHR(block, IREG(0), IREG(0), IMM(1));                        // shr     i0,i0,1
1603                  UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 1));               // xor     i0,i0,fastxor >> 1
1604                  UML_STORE(block, fastbase, IREG(0), IREG(1), WORD);                  // store   fastbase,i0,i1,word
1603                  UML_XOR(block, IREG(0), IREG(0), IMM(fastxor & 6));                  // xor     i0,i0,fastxor & 6
1604                  UML_STORE(block, fastbase, IREG(0), IREG(1), WORD_x1);               // store   fastbase,i0,i1,word_x1
16051605               }
16061606               else if (size == 4)
16071607               {
1608                  UML_SHR(block, IREG(0), IREG(0), IMM(2));                        // shr     i0,i0,2
1609                  UML_XOR(block, IREG(0), IREG(0), IMM(fastxor >> 2));               // xor     i0,i0,fastxor >> 2
1608                  UML_XOR(block, IREG(0), IREG(0), IMM(fastxor & 4));                  // xor     i0,i0,fastxor & 4
16101609                  if (ismasked)
16111610                  {
1612                     UML_LOAD(block, IREG(3), fastbase, IREG(0), DWORD);               // load    i3,fastbase,i0,dword
1611                     UML_LOAD(block, IREG(3), fastbase, IREG(0), DWORD_x1);            // load    i3,fastbase,i0,dword_x1
16131612                     UML_AND(block, IREG(1), IREG(1), IREG(2));                     // and     i1,i1,i2
16141613                     UML_XOR(block, IREG(2), IREG(2), IMM(0xffffffff));               // xor     i2,i2,0xfffffffff
16151614                     UML_AND(block, IREG(3), IREG(3), IREG(2));                     // and     i3,i3,i2
16161615                     UML_OR(block, IREG(1), IREG(1), IREG(3));                     // or      i1,i1,i3
16171616                  }
1618                  UML_STORE(block, fastbase, IREG(0), IREG(1), DWORD);               // store   fastbase,i0,i1,dword
1617                  UML_STORE(block, fastbase, IREG(0), IREG(1), DWORD_x1);               // store   fastbase,i0,i1,dword_x1
16191618               }
16201619               else if (size == 8)
16211620               {
1622                  UML_SHR(block, IREG(0), IREG(0), IMM(3));                        // shr     i0,i0,3
16231621                  if (ismasked)
16241622                  {
1625                     UML_DLOAD(block, IREG(3), fastbase, IREG(0), QWORD);            // dload   i3,fastbase,i0,qword
1623                     UML_DLOAD(block, IREG(3), fastbase, IREG(0), QWORD_x1);            // dload   i3,fastbase,i0,qword_x1
16261624                     UML_DAND(block, IREG(1), IREG(1), IREG(2));                     // dand    i1,i1,i2
16271625                     UML_DXOR(block, IREG(2), IREG(2), IMM(U64(0xffffffffffffffff)));   // dxor    i2,i2,0xfffffffffffffffff
16281626                     UML_DAND(block, IREG(3), IREG(3), IREG(2));                     // dand    i3,i3,i2
16291627                     UML_DOR(block, IREG(1), IREG(1), IREG(3));                     // dor     i1,i1,i3
16301628                  }
1631                  UML_DSTORE(block, fastbase, IREG(0), IREG(1), QWORD);               // dstore  fastbase,i0,i1,qword
1629                  UML_DSTORE(block, fastbase, IREG(0), IREG(1), QWORD_x1);            // dstore  fastbase,i0,i1,qword_x1
16321630               }
16331631               UML_RET(block);                                                // ret
16341632            }
src/emu/cpu/sh2/sh2drc.c
r6740r6741
1919#include "sh2.h"
2020#include "sh2comn.h"
2121#include "eminline.h"
22#include "profiler.h"
2223
2324CPU_DISASSEMBLE( sh2 );
2425
r6740r6741
930931   drcuml_block *block;
931932   jmp_buf errorbuf;
932933
934   profiler_mark_start(PROFILER_DRC_COMPILE);
935
933936   /* get a description of this sequence */
934937   desclist = drcfe_describe_code(sh2->drcfe, pc);
935938   if (LOG_UML || LOG_NATIVE)
r6740r6741
10191022
10201023   /* end the sequence */
10211024   drcuml_block_end(block);
1025   profiler_mark_end();
10221026}
10231027
10241028/*-------------------------------------------------
src/emu/cpu/drcumlsh.h
r6740r6741
106106
107107
108108/* ----- 32-Bit Integer Operations ----- */
109#define UML_LOAD(block, dst, base, index, size)            do { drcuml_block_append_4(block, DRCUML_OP_LOAD,    4, IF_ALWAYS,  dst, MEM(base), index, IMM(DRCUML_SIZE_##size)); } while (0)
110#define UML_LOADS(block, dst, base, index, size)         do { drcuml_block_append_4(block, DRCUML_OP_LOADS,   4, IF_ALWAYS,  dst, MEM(base), index, IMM(DRCUML_SIZE_##size)); } while (0)
111#define UML_STORE(block, base, index, src1, size)         do { drcuml_block_append_4(block, DRCUML_OP_STORE,   4, IF_ALWAYS,  MEM(base), index, src1, IMM(DRCUML_SIZE_##size)); } while (0)
109#define UML_LOAD(block, dst, base, index, size)            do { drcuml_block_append_4(block, DRCUML_OP_LOAD,    4, IF_ALWAYS,  dst, MEM(base), index, IMM(DRCUML_SCSIZE_##size)); } while (0)
110#define UML_LOADS(block, dst, base, index, size)         do { drcuml_block_append_4(block, DRCUML_OP_LOADS,   4, IF_ALWAYS,  dst, MEM(base), index, IMM(DRCUML_SCSIZE_##size)); } while (0)
111#define UML_STORE(block, base, index, src1, size)         do { drcuml_block_append_4(block, DRCUML_OP_STORE,   4, IF_ALWAYS,  MEM(base), index, src1, IMM(DRCUML_SCSIZE_##size)); } while (0)
112112#define UML_READ(block, dst, src1, spsize)               do { drcuml_block_append_3(block, DRCUML_OP_READ,    4, IF_ALWAYS,  dst, src1, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
113113#define UML_READM(block, dst, src1, mask, spsize)         do { drcuml_block_append_4(block, DRCUML_OP_READM,   4, IF_ALWAYS,  dst, src1, mask, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
114114#define UML_WRITE(block, dst, src1, spsize)               do { drcuml_block_append_3(block, DRCUML_OP_WRITE,   4, IF_ALWAYS,  dst, src1, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
r6740r6741
145145
146146
147147/* ----- 64-Bit Integer Operations ----- */
148#define UML_DLOAD(block, dst, base, index, size)         do { drcuml_block_append_4(block, DRCUML_OP_LOAD,    8, IF_ALWAYS,  dst, MEM(base), index, IMM(DRCUML_SIZE_##size)); } while (0)
149#define UML_DLOADS(block, dst, base, index, size)         do { drcuml_block_append_4(block, DRCUML_OP_LOADS,   8, IF_ALWAYS,  dst, MEM(base), index, IMM(DRCUML_SIZE_##size)); } while (0)
150#define UML_DSTORE(block, base, index, src1, size)         do { drcuml_block_append_4(block, DRCUML_OP_STORE,   8, IF_ALWAYS,  MEM(base), index, src1, IMM(DRCUML_SIZE_##size)); } while (0)
148#define UML_DLOAD(block, dst, base, index, size)         do { drcuml_block_append_4(block, DRCUML_OP_LOAD,    8, IF_ALWAYS,  dst, MEM(base), index, IMM(DRCUML_SCSIZE_##size)); } while (0)
149#define UML_DLOADS(block, dst, base, index, size)         do { drcuml_block_append_4(block, DRCUML_OP_LOADS,   8, IF_ALWAYS,  dst, MEM(base), index, IMM(DRCUML_SCSIZE_##size)); } while (0)
150#define UML_DSTORE(block, base, index, src1, size)         do { drcuml_block_append_4(block, DRCUML_OP_STORE,   8, IF_ALWAYS,  MEM(base), index, src1, IMM(DRCUML_SCSIZE_##size)); } while (0)
151151#define UML_DREAD(block, dst, src1, spsize)               do { drcuml_block_append_3(block, DRCUML_OP_READ,    8, IF_ALWAYS,  dst, src1, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
152152#define UML_DREADM(block, dst, src1, mask, spsize)         do { drcuml_block_append_4(block, DRCUML_OP_READM,   8, IF_ALWAYS,  dst, src1, mask, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
153153#define UML_DWRITE(block, dst, src1, spsize)            do { drcuml_block_append_3(block, DRCUML_OP_WRITE,   8, IF_ALWAYS,  dst, src1, IMM(DRCUML_SPSIZE_##spsize)); } while (0)
src/emu/cpu/mips/mips3drc.c
r6740r6741
2828#include <stddef.h>
2929#include "cpuintrf.h"
3030#include "debugger.h"
31#include "profiler.h"
3132#include "cpuexec.h"
3233#include "mips3com.h"
3334#include "mips3fe.h"
r6740r6741
749750   drcuml_block *block;
750751   jmp_buf errorbuf;
751752
753   profiler_mark_start(PROFILER_DRC_COMPILE);
754
752755   /* get a description of this sequence */
753756   desclist = drcfe_describe_code(mips3->impstate->drcfe, pc);
754757   if (LOG_UML || LOG_NATIVE)
r6740r6741
832835
833836   /* end the sequence */
834837   drcuml_block_end(block);
838   profiler_mark_end();
835839}
836840
837841
r6740r6741
13011305               }
13021306               else if (size == 2)
13031307               {
1304                  UML_SHR(block, IREG(0), IREG(0), IMM(1));                  // shr     i0,i0,1
1305                  UML_XOR(block, IREG(0), IREG(0), IMM(mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0)));
1306                                                                  // xor     i0,i0,bytexor
1307                  UML_LOAD(block, IREG(0), fastbase, IREG(0), WORD);            // load    i0,fastbase,i0,word
1308                  UML_XOR(block, IREG(0), IREG(0), IMM(mips3->bigendian ? WORD_XOR_BE(0) : WORD_XOR_LE(0)));
1309                                                                  // xor     i0,i0,wordxor
1310                  UML_LOAD(block, IREG(0), fastbase, IREG(0), WORD_x1);         // load    i0,fastbase,i0,word_x1
13081311               }
13091312               else if (size == 4)
13101313               {
1311                  UML_SHR(block, IREG(0), IREG(0), IMM(2));                  // shr     i0,i0,2
1312                  UML_LOAD(block, IREG(0), fastbase, IREG(0), DWORD);            // load    i0,fastbase,i0,dword
1314                  UML_LOAD(block, IREG(0), fastbase, IREG(0), DWORD_x1);         // load    i0,fastbase,i0,dword_x1
13131315               }
13141316               else if (size == 8)
13151317               {
1316                  UML_SHR(block, IREG(0), IREG(0), IMM(3));                  // shr     i0,i0,3
1317                  UML_DLOAD(block, IREG(0), fastbase, IREG(0), QWORD);         // dload   i0,fastbase,i0,qword
1318                  UML_DLOAD(block, IREG(0), fastbase, IREG(0), QWORD_x1);         // dload   i0,fastbase,i0,qword_x1
13181319                  UML_DROR(block, IREG(0), IREG(0), IMM(32 * (mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0))));
13191320                                                                  // dror    i0,i0,32*bytexor
13201321               }
r6740r6741
13301331               }
13311332               else if (size == 2)
13321333               {
1333                  UML_SHR(block, IREG(0), IREG(0), IMM(1));                  // shr     i0,i0,1
1334                  UML_XOR(block, IREG(0), IREG(0), IMM(mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0)));
1335                                                                  // xor     i0,i0,bytexor
1336                  UML_STORE(block, fastbase, IREG(0), IREG(1), WORD);            // store   fastbase,i0,i1,word
1334                  UML_XOR(block, IREG(0), IREG(0), IMM(mips3->bigendian ? WORD_XOR_BE(0) : WORD_XOR_LE(0)));
1335                                                                  // xor     i0,i0,wordxor
1336                  UML_STORE(block, fastbase, IREG(0), IREG(1), WORD_x1);         // store   fastbase,i0,i1,word_x1
13371337               }
13381338               else if (size == 4)
13391339               {
1340                  UML_SHR(block, IREG(0), IREG(0), IMM(2));                  // shr     i0,i0,2
13411340                  if (ismasked)
13421341                  {
1343                     UML_LOAD(block, IREG(3), fastbase, IREG(0), DWORD);         // load    i3,fastbase,i0,dword
1342                     UML_LOAD(block, IREG(3), fastbase, IREG(0), DWORD_x1);      // load    i3,fastbase,i0,dword_x1
13441343                     UML_ROLINS(block, IREG(3), IREG(1), IMM(0), IREG(2));      // rolins  i3,i1,0,i2
1345                     UML_STORE(block, fastbase, IREG(0), IREG(3), DWORD);      // store   fastbase,i0,i3,dword
1344                     UML_STORE(block, fastbase, IREG(0), IREG(3), DWORD_x1);      // store   fastbase,i0,i3,dword_x1
13461345                  }
13471346                  else
1348                     UML_STORE(block, fastbase, IREG(0), IREG(1), DWORD);      // store   fastbase,i0,i1,dword
1347                     UML_STORE(block, fastbase, IREG(0), IREG(1), DWORD_x1);      // store   fastbase,i0,i1,dword_x1
13491348               }
13501349               else if (size == 8)
13511350               {
1352                  UML_SHR(block, IREG(0), IREG(0), IMM(3));                  // shr     i0,i0,3
13531351                  UML_DROR(block, IREG(1), IREG(1), IMM(32 * (mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0))));
13541352                                                                  // dror    i1,i1,32*bytexor
13551353                  if (ismasked)
13561354                  {
13571355                     UML_DROR(block, IREG(2), IREG(2), IMM(32 * (mips3->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0))));
13581356                                                                  // dror    i2,i2,32*bytexor
1359                     UML_DLOAD(block, IREG(3), fastbase, IREG(0), QWORD);      // dload   i3,fastbase,i0,qword
1357                     UML_DLOAD(block, IREG(3), fastbase, IREG(0), QWORD_x1);      // dload   i3,fastbase,i0,qword_x1
13601358                     UML_DROLINS(block, IREG(3), IREG(1), IMM(0), IREG(2));      // drolins i3,i1,0,i2
1361                     UML_DSTORE(block, fastbase, IREG(0), IREG(3), QWORD);      // dstore  fastbase,i0,i3,qword
1359                     UML_DSTORE(block, fastbase, IREG(0), IREG(3), QWORD_x1);   // dstore  fastbase,i0,i3,qword_x1
13621360                  }
13631361                  else
1364                     UML_DSTORE(block, fastbase, IREG(0), IREG(1), QWORD);      // dstore  fastbase,i0,i1,qword
1362                     UML_DSTORE(block, fastbase, IREG(0), IREG(1), QWORD_x1);   // dstore  fastbase,i0,i1,qword_x1
13651363               }
13661364               UML_RET(block);                                          // ret
13671365            }
src/emu/cpu/x86emit.h
r6740r6741
19001900INLINE void emit_movsx_r32_m8(x86code **emitptr, UINT8 dreg, DECLARE_MEMPARAMS)               { emit_op_modrm_mem(emitptr, OP_MOVSX_Gv_Eb, OP_32BIT, dreg, MEMPARAMS); }
19011901INLINE void emit_movsx_r32_r16(x86code **emitptr, UINT8 dreg, UINT8 sreg)                  { emit_op_modrm_reg(emitptr, OP_MOVSX_Gv_Ew, OP_32BIT, dreg, sreg); }
19021902INLINE void emit_movsx_r32_m16(x86code **emitptr, UINT8 dreg, DECLARE_MEMPARAMS)            { emit_op_modrm_mem(emitptr, OP_MOVSX_Gv_Ew, OP_32BIT, dreg, MEMPARAMS); }
1903INLINE void emit_movzx_r32_r8(x86code **emitptr, UINT8 dreg, UINT8 sreg)                  { emit_op_modrm_reg(emitptr, OP_MOVZX_Gv_Eb, OP_32BIT, dreg, sreg); }
1903INLINE void emit_movzx_r32_r8(x86code **emitptr, UINT8 dreg, UINT8 sreg)
1904{
1905#ifndef PTR64
1906   if (sreg >= 4)
1907   {
1908      emit_op_modrm_reg(emitptr, OP_MOV_Gv_Ev, OP_32BIT, dreg, sreg);                     // mov dreg,sreg
1909       emit_op_modrm_reg_imm832(emitptr, OP_G1_Ev_Ib, OP_G1_Ev_Iz, OP_32BIT, 4, dreg, 0xff);    // and dreg,0xff
1910   }
1911   else
1912#endif
1913   emit_op_modrm_reg(emitptr, OP_MOVZX_Gv_Eb, OP_32BIT, dreg, sreg);
1914}
19041915INLINE void emit_movzx_r32_m8(x86code **emitptr, UINT8 dreg, DECLARE_MEMPARAMS)               { emit_op_modrm_mem(emitptr, OP_MOVZX_Gv_Eb, OP_32BIT, dreg, MEMPARAMS); }
19051916INLINE void emit_movzx_r32_r16(x86code **emitptr, UINT8 dreg, UINT8 sreg)                  { emit_op_modrm_reg(emitptr, OP_MOVZX_Gv_Ew, OP_32BIT, dreg, sreg); }
19061917INLINE void emit_movzx_r32_m16(x86code **emitptr, UINT8 dreg, DECLARE_MEMPARAMS)            { emit_op_modrm_mem(emitptr, OP_MOVZX_Gv_Ew, OP_32BIT, dreg, MEMPARAMS); }
src/emu/cpu/v810/v810.c
r6740r6741
140140#define D16(x) (((x)&0xffff)|(((x)&0x8000)?0xffff0000:0))
141141#define D26(x,y) ((y)|((x&0x3ff)<<16 )|((x&0x200)?0xfc000000:0))
142142#define D9(x) ((x&0x1ff)|((x&0x100)?0xfffffe00:0))
143#define SO(opcode) ((opcode)&0xfc00)>>10)
143#define SO(opcode) (((opcode)&0xfc00)>>10)
144144
145145#define CHECK_CY(x)   cpustate->PSW=(cpustate->PSW & ~8)|(((x) & (((UINT64)1) << 32)) ? 8 : 0)
146146#define CHECK_OVADD(x,y,z)   cpustate->PSW=(cpustate->PSW & ~0x00000004) |(( ((x) ^ (z)) & ((y) ^ (z)) & 0x80000000) ? 4: 0)
src/emu/cpu/drcbex86.c
r6740r6741
1818
1919    * Identify common pairs and optimize output
2020
21    * Convert AND 0xff/0xffff to movzx
22
2321    * Convert SUB a,0,b to NEG
2422
2523    * Optimize, e.g., and [r5],i0,$FF to use ebx as temporary register
r6740r6741
174172
175173   UINT32 *            reglo[REG_MAX];         /* pointer to low part of data for each register */
176174   UINT32 *            reghi[REG_MAX];         /* pointer to high part of data for each register */
175   UINT8               last_lower_reg;         /* last register we stored a lower from */
176   x86code *            last_lower_pc;         /* PC after instruction where we last stored a lower register */
177   UINT32 *            last_lower_addr;      /* address where we last stored an lower register */
178   UINT8               last_upper_reg;         /* last register we stored an upper from */
179   x86code *            last_upper_pc;         /* PC after instruction where we last stored an upper register */
180   UINT32 *            last_upper_addr;      /* address where we last stored an upper register */
177181   double               fptemp;               /* temporary storage for floating point */
178182
179183   const address_space *   space[ADDRESS_SPACES];   /* address spaces */
r6740r6741
523527}
524528
525529
530/*-------------------------------------------------
531    reset_last_upper_lower_reg - reset the last
532    upper/lower register state
533-------------------------------------------------*/
526534
535INLINE void reset_last_upper_lower_reg(drcbe_state *drcbe)
536{
537   drcbe->last_lower_reg = REG_NONE;
538   drcbe->last_upper_reg = REG_NONE;
539}
540
541
542/*-------------------------------------------------
543    set_last_lower_reg - note that we have just
544    loaded a lower register
545-------------------------------------------------*/
546
547INLINE void set_last_lower_reg(drcbe_state *drcbe, x86code *dst, const drcuml_parameter *param, UINT8 reglo)
548{
549   if (param->type == DRCUML_PTYPE_MEMORY)
550   {
551      drcbe->last_lower_reg = reglo;
552      drcbe->last_lower_addr = (UINT32 *)((FPTR)param->value);
553      drcbe->last_lower_pc = dst;
554   }
555}
556
557
558/*-------------------------------------------------
559    set_last_upper_reg - note that we have just
560    loaded an upper register
561-------------------------------------------------*/
562
563INLINE void set_last_upper_reg(drcbe_state *drcbe, x86code *dst, const drcuml_parameter *param, UINT8 reghi)
564{
565   drcbe->last_upper_reg = reghi;
566   drcbe->last_upper_addr = (param->type == DRCUML_PTYPE_INT_REGISTER) ? drcbe->reghi[param->value] : (UINT32 *)((FPTR)param->value + 4);
567   drcbe->last_upper_pc = dst;
568}
569
570
571/*-------------------------------------------------
572    can_skip_lower_load - return TRUE if we can
573    skip re-loading a lower half of a register
574-------------------------------------------------*/
575
576INLINE int can_skip_lower_load(drcbe_state *drcbe, x86code *dst, UINT32 *memptr, UINT8 reglo)
577{
578//  return FALSE;
579   return (dst == drcbe->last_lower_pc && memptr == drcbe->last_lower_addr && reglo == drcbe->last_lower_reg);
580}
581
582
583/*-------------------------------------------------
584    can_skip_upper_load - return TRUE if we can
585    skip re-loading an upper half of a register
586-------------------------------------------------*/
587
588INLINE int can_skip_upper_load(drcbe_state *drcbe, x86code *dst, UINT32 *memptr, UINT8 reghi)
589{
590//  return FALSE;
591   return (dst == drcbe->last_upper_pc && memptr == drcbe->last_upper_addr && reghi == drcbe->last_upper_reg);
592}
593
594
595/*-------------------------------------------------
596    track_resolve_link - wrapper for resolve_link
597    that resets all register tracking info
598-------------------------------------------------*/
599
600INLINE void track_resolve_link(drcbe_state *drcbe, x86code **destptr, const emit_link *linkinfo)
601{
602   reset_last_upper_lower_reg(drcbe);
603   resolve_link(destptr, linkinfo);
604}
605
606#define resolve_link INVALID
607
608
609
527610/***************************************************************************
528611    BACKEND CALLBACKS
529612***************************************************************************/
r6740r6741
11431226   if (param->type == DRCUML_PTYPE_IMMEDIATE)
11441227      emit_mov_r32_imm(dst, reg, param->value);                              // mov   reg,param
11451228   else if (param->type == DRCUML_PTYPE_MEMORY)
1146      emit_mov_r32_m32(dst, reg, MABS(param->value));                           // mov   reg,[param]
1229   {
1230      if (!can_skip_lower_load(drcbe, *dst, (UINT32 *)((FPTR)param->value), reg))
1231         emit_mov_r32_m32(dst, reg, MABS(param->value));                        // mov   reg,[param]
1232   }
11471233   else if (param->type == DRCUML_PTYPE_INT_REGISTER)
11481234   {
11491235      if (reg != param->value)
r6740r6741
11631249      emit_mov_m32_imm(dst, MEMPARAMS, param->value);                           // mov   [mem],param
11641250   else if (param->type == DRCUML_PTYPE_MEMORY)
11651251   {
1166      emit_mov_r32_m32(dst, REG_EAX, MABS(param->value));                        // mov   eax,[param]
1252      if (!can_skip_lower_load(drcbe, *dst, (UINT32 *)((FPTR)param->value), REG_EAX))
1253         emit_mov_r32_m32(dst, REG_EAX, MABS(param->value));                     // mov   eax,[param]
11671254      emit_mov_m32_r32(dst, MEMPARAMS, REG_EAX);                              // mov   [mem],eax
11681255   }
11691256   else if (param->type == DRCUML_PTYPE_INT_REGISTER)
r6740r6741
11801267{
11811268   assert(param->type != DRCUML_PTYPE_IMMEDIATE);
11821269   if (param->type == DRCUML_PTYPE_MEMORY)
1270   {
11831271      emit_mov_m32_r32(dst, MABS(param->value), reg);                           // mov   [param],reg
1272      set_last_lower_reg(drcbe, *dst, param, reg);
1273   }
11841274   else if (param->type == DRCUML_PTYPE_INT_REGISTER)
11851275   {
11861276      if (reg != param->value)
r6740r6741
18721962{
18731963   if (param->type == DRCUML_PTYPE_IMMEDIATE)
18741964   {
1875      if ((UINT32)param->value == 0)
1965      if (reglo == REG_NONE)
1966         ;
1967      else if ((UINT32)param->value == 0)
18761968         emit_xor_r32_r32(dst, reglo, reglo);                              // xor   reglo,reglo
18771969      else
18781970         emit_mov_r32_imm(dst, reglo, param->value);                           // mov   reglo,param
1879      if ((UINT32)(param->value >> 32) == 0)
1971      if (reghi == REG_NONE)
1972         ;
1973      else if ((UINT32)(param->value >> 32) == 0)
18801974         emit_xor_r32_r32(dst, reghi, reghi);                              // xor   reghi,reghi
18811975      else
18821976         emit_mov_r32_imm(dst, reghi, param->value >> 32);                     // mov   reghi,param >> 32
18831977   }
18841978   else if (param->type == DRCUML_PTYPE_MEMORY)
18851979   {
1886      emit_mov_r32_m32(dst, reglo, MABS(param->value));                        // mov   reglo,[param]
1887      emit_mov_r32_m32(dst, reghi, MABS(param->value + 4));                     // mov   reghi,[param+4]
1980      int skip_lower = can_skip_lower_load(drcbe, *dst, (UINT32 *)((FPTR)param->value), reglo);
1981      int skip_upper = can_skip_upper_load(drcbe, *dst, (UINT32 *)((FPTR)param->value + 4), reghi);
1982      if (reglo != REG_NONE && !skip_lower)
1983         emit_mov_r32_m32(dst, reglo, MABS(param->value));                     // mov   reglo,[param]
1984      if (reghi != REG_NONE && !skip_upper)
1985         emit_mov_r32_m32(dst, reghi, MABS(param->value + 4));                  // mov   reghi,[param+4]
18881986   }
18891987   else if (param->type == DRCUML_PTYPE_INT_REGISTER)
18901988   {
1891      if (reglo != param->value)
1989      int skip_upper = can_skip_upper_load(drcbe, *dst, drcbe->reghi[param->value], reghi);
1990      if (reglo != REG_NONE && reglo != param->value)
18921991         emit_mov_r32_r32(dst, reglo, param->value);                           // mov   reglo,param
1893      emit_mov_r32_m32(dst, reghi, MABS(drcbe->reghi[param->value]));               // mov   reghi,reghi[param]
1992      if (reghi != REG_NONE && !skip_upper)
1993         emit_mov_r32_m32(dst, reghi, MABS(drcbe->reghi[param->value]));            // mov   reghi,reghi[param]
18941994   }
18951995}
18961996
r6740r6741
19052005{
19062006   if (param->type == DRCUML_PTYPE_IMMEDIATE)
19072007   {
1908      emit_mov_r32_imm(dst, reglo, param->value);                              // mov   reglo,param
1909      emit_mov_r32_imm(dst, reghi, param->value >> 32);                        // mov   reghi,param >> 32
2008      if (reglo != REG_NONE)
2009         emit_mov_r32_imm(dst, reglo, param->value);                           // mov   reglo,param
2010      if (reghi != REG_NONE)
2011         emit_mov_r32_imm(dst, reghi, param->value >> 32);                     // mov   reghi,param >> 32
19102012   }
19112013   else if (param->type == DRCUML_PTYPE_MEMORY)
19122014   {
1913      emit_mov_r32_m32(dst, reglo, MABS(param->value));                        // mov   reglo,[param]
1914      emit_mov_r32_m32(dst, reghi, MABS(param->value + 4));                     // mov   reghi,[param+4]
2015      int skip_lower = can_skip_lower_load(drcbe, *dst, (UINT32 *)((FPTR)param->value), reglo);
2016      int skip_upper = can_skip_upper_load(drcbe, *dst, (UINT32 *)((FPTR)param->value + 4), reghi);
2017      if (reglo != REG_NONE && !skip_lower)
2018         emit_mov_r32_m32(dst, reglo, MABS(param->value));                     // mov   reglo,[param]
2019      if (reghi != REG_NONE && !skip_upper)
2020         emit_mov_r32_m32(dst, reghi, MABS(param->value + 4));                  // mov   reghi,[param+4]
19152021   }
19162022   else if (param->type == DRCUML_PTYPE_INT_REGISTER)
19172023   {
1918      if (reglo != param->value)
2024      int skip_upper = can_skip_upper_load(drcbe, *dst, drcbe->reghi[param->value], reghi);
2025      if (reglo != REG_NONE && reglo != param->value)
19192026         emit_mov_r32_r32(dst, reglo, param->value);                           // mov   reglo,param
1920      emit_mov_r32_m32(dst, reghi, MABS(drcbe->reghi[param->value]));               // mov   reghi,reghi[param]
2027      if (reghi != REG_NONE && !skip_upper)
2028         emit_mov_r32_m32(dst, reghi, MABS(drcbe->reghi[param->value]));            // mov   reghi,reghi[param]
19212029   }
19222030}
19232031
r6740r6741
19362044   }
19372045   else if (param->type == DRCUML_PTYPE_MEMORY)
19382046   {
1939      emit_mov_r32_m32(dst, REG_EAX, MABS(param->value));                        // mov   eax,[param]
2047      int skip_lower = can_skip_lower_load(drcbe, *dst, (UINT32 *)((FPTR)param->value), REG_EAX);
2048      if (!skip_lower)
2049         emit_mov_r32_m32(dst, REG_EAX, MABS(param->value));                     // mov   eax,[param]
19402050      emit_mov_m32_r32(dst, MEMPARAMS + 0, REG_EAX);                           // mov   [mem],eax
19412051      emit_mov_r32_m32(dst, REG_EAX, MABS(param->value + 4));                     // mov   eax,[param+4]
19422052      emit_mov_m32_r32(dst, MEMPARAMS + 4, REG_EAX);                           // mov   [mem+4],eax
r6740r6741
19692079         emit_mov_r32_r32(dst, param->value, reglo);                           // mov   param,reglo
19702080      emit_mov_m32_r32(dst, MABS(drcbe->reghi[param->value]), reghi);               // mov   reghi[param],reghi
19712081   }
2082   set_last_lower_reg(drcbe, *dst, param, reglo);
2083   set_last_upper_reg(drcbe, *dst, param, reghi);
19722084}
19732085
19742086
r6740r6741
25832695         emit_sub_r32_imm(dst, REG_ECX, 31);                                 // sub   ecx,31
25842696         emit_shld_r32_r32_imm(dst, reghi, reglo, 31);                        // shld  reghi,reglo,31
25852697         emit_shl_r32_imm(dst, reglo, 31);                                 // shl   reglo,31
2586         resolve_link(dst, &skip2);                                    // skip2:
2698         track_resolve_link(drcbe, dst, &skip2);                           // skip2:
25872699      }
25882700      else
25892701      {
25902702         emit_mov_r32_r32(dst, reghi, reglo);                              // mov   reghi,reglo
25912703         emit_xor_r32_r32(dst, reglo, reglo);                              // xor   reglo,reglo
25922704      }
2593      resolve_link(dst, &skip1);                                       // skip1:
2705      track_resolve_link(drcbe, dst, &skip1);                              // skip1:
25942706      emit_shld_r32_r32_cl(dst, reghi, reglo);                              // shld  reghi,reglo,cl
25952707      if (saveflags) emit_pushf(dst);                                       // pushf
25962708      emit_shl_r32_cl(dst, reglo);                                       // shl   reglo,cl
r6740r6741
26542766         emit_sub_r32_imm(dst, REG_ECX, 31);                                 // sub   ecx,31
26552767         emit_shrd_r32_r32_imm(dst, reglo, reghi, 31);                        // shrd  reglo,reghi,31
26562768         emit_shr_r32_imm(dst, reghi, 31);                                 // shr   reghi,31
2657         resolve_link(dst, &skip2);                                    // skip2:
2769         track_resolve_link(drcbe, dst, &skip2);                           // skip2:
26582770      }
26592771      else
26602772      {
26612773         emit_mov_r32_r32(dst, reglo, reghi);                              // mov   reglo,reghi
26622774         emit_xor_r32_r32(dst, reghi, reghi);                              // xor   reghi,reghi
26632775      }
2664      resolve_link(dst, &skip1);                                       // skip1:
2776      track_resolve_link(drcbe, dst, &skip1);                              // skip1:
26652777      emit_shrd_r32_r32_cl(dst, reglo, reghi);                              // shrd  reglo,reghi,cl
26662778      if (saveflags) emit_pushf(dst);                                       // pushf
26672779      emit_shr_r32_cl(dst, reghi);                                       // shr   reghi,cl
r6740r6741
27252837         emit_sub_r32_imm(dst, REG_ECX, 31);                                 // sub   ecx,31
27262838         emit_shrd_r32_r32_imm(dst, reglo, reghi, 31);                        // shrd  reglo,reghi,31
27272839         emit_sar_r32_imm(dst, reghi, 31);                                 // sar   reghi,31
2728         resolve_link(dst, &skip2);                                    // skip2:
2840         track_resolve_link(drcbe, dst, &skip2);                           // skip2:
27292841      }
27302842      else
27312843      {
27322844         emit_mov_r32_r32(dst, reglo, reghi);                              // mov   reglo,reghi
27332845         emit_sar_r32_imm(dst, reghi, 31);                                 // sar   reghi,31
27342846      }
2735      resolve_link(dst, &skip1);                                       // skip1:
2847      track_resolve_link(drcbe, dst, &skip1);                              // skip1:
27362848      emit_shrd_r32_r32_cl(dst, reglo, reghi);                              // shrd  reglo,reghi,cl
27372849      if (saveflags) emit_pushf(dst);                                       // pushf
27382850      emit_sar_r32_cl(dst, reghi);                                       // sar   reghi,cl
r6740r6741
28002912         emit_mov_r32_r32(dst, REG_EBX, reglo);                              // mov   ebx,reglo
28012913         emit_shld_r32_r32_imm(dst, reglo, reghi, 31);                        // shld  reglo,reghi,31
28022914         emit_shld_r32_r32_imm(dst, reghi, REG_EBX, 31);                        // shld  reghi,ebx,31
2803         resolve_link(dst, &skip2);                                    // skip2:
2915         track_resolve_link(drcbe, dst, &skip2);                           // skip2:
28042916      }
28052917      else
28062918         emit_xchg_r32_r32(dst, reghi, reglo);                              // xchg  reghi,reglo
2807      resolve_link(dst, &skip1);                                       // skip1:
2919      track_resolve_link(drcbe, dst, &skip1);                              // skip1:
28082920      emit_mov_r32_r32(dst, REG_EBX, reglo);                                 // mov   ebx,reglo
28092921      emit_shld_r32_r32_cl(dst, reglo, reghi);                              // shld  reglo,reghi,cl
28102922      if (saveflags) emit_pushf(dst);                                       // pushf
r6740r6741
28742986         emit_mov_r32_r32(dst, REG_EBX, reglo);                              // mov   ebx,reglo
28752987         emit_shrd_r32_r32_imm(dst, reglo, reghi, 31);                        // shrd  reglo,reghi,31
28762988         emit_shrd_r32_r32_imm(dst, reghi, REG_EBX, 31);                        // shrd  reghi,ebx,31
2877         resolve_link(dst, &skip2);                                    // skip2:
2989         track_resolve_link(drcbe, dst, &skip2);                           // skip2:
28782990      }
28792991      else
28802992         emit_xchg_r32_r32(dst, reghi, reglo);                              // xchg  reghi,reglo
2881      resolve_link(dst, &skip1);                                       // skip1:
2993      track_resolve_link(drcbe, dst, &skip1);                              // skip1:
28822994      emit_mov_r32_r32(dst, REG_EBX, reglo);                                 // mov   ebx,reglo
28832995      emit_shrd_r32_r32_cl(dst, reglo, reghi);                              // shrd  reglo,reghi,cl
28842996      if (saveflags) emit_pushf(dst);                                       // pushf
r6740r6741
29103022      emit_rcl_r32_imm(dst, reglo, 1);                                    // rcl   reglo,1
29113023      emit_rcl_r32_imm(dst, reghi, 1);                                    // rcl   reghi,1
29123024      emit_jmp(dst, loop);                                             // jmp   loop
2913      resolve_link(dst, &skipall);                                    // skipall:
3025      track_resolve_link(drcbe, dst, &skipall);                           // skipall:
29143026   }
29153027   else
29163028   {
r6740r6741
29223034      emit_rcl_r32_imm(dst, reglo, 1);                                    // rcl   reglo,1
29233035      emit_rcl_r32_imm(dst, reghi, 1);                                    // rcl   reghi,1
29243036      emit_jmp(dst, loop);                                             // jmp   loop
2925      resolve_link(dst, &skiploop);                                    // skiploop:
3037      track_resolve_link(drcbe, dst, &skiploop);                           // skiploop:
29263038      emit_rcl_r32_imm(dst, reglo, 1);                                    // rcl   reglo,1
29273039      emit_pushf(dst);                                                // pushf
29283040      emit_rcl_r32_imm(dst, reghi, 1);                                    // rcl   reghi,1
2929      resolve_link(dst, &skipall);                                    // skipall:
3041      track_resolve_link(drcbe, dst, &skipall);                           // skipall:
29303042      emit_combine_z_flags(dst);
29313043   }
29323044}
r6740r6741
29523064      emit_rcr_r32_imm(dst, reghi, 1);                                    // rcr   reghi,1
29533065      emit_rcr_r32_imm(dst, reglo, 1);                                    // rcr   reglo,1
29543066      emit_jmp(dst, loop);                                             // jmp   loop
2955      resolve_link(dst, &skipall);                                    // skipall:
3067      track_resolve_link(drcbe, dst, &skipall);                           // skipall:
29563068   }
29573069   else
29583070   {
r6740r6741
29643076      emit_rcr_r32_imm(dst, reghi, 1);                                    // rcr   reghi,1
29653077      emit_rcr_r32_imm(dst, reglo, 1);                                    // rcr   reglo,1
29663078      emit_jmp(dst, loop);                                             // jmp   loop
2967      resolve_link(dst, &skiploop);                                    // skiploop:
3079      track_resolve_link(drcbe, dst, &skiploop);                           // skiploop:
29683080      emit_rcr_r32_imm(dst, reghi, 1);                                    // rcr   reghi,1
29693081      emit_pushf(dst);                                                // pushf
29703082      emit_rcr_r32_imm(dst, reglo, 1);                                    // rcr   reglo,1
2971      resolve_link(dst, &skipall);                                    // skipall:
3083      track_resolve_link(drcbe, dst, &skipall);                           // skipall:
29723084      emit_combine_z_shl_flags(dst);
29733085   }
29743086}
r6740r6741
31173229   assert(inst->numparams == 1);
31183230   assert(inst->param[0].type == DRCUML_PTYPE_MEMORY);
31193231
3232   reset_last_upper_lower_reg(drcbe);
3233
31203234   /* emit a jump around the stack adjust in case code falls through here */
31213235   emit_jmp_short_link(&dst, &skip);                                       // jmp   skip
31223236
r6740r6741
31253239
31263240   /* by default, the handle points to prolog code that moves the stack pointer */
31273241   emit_lea_r32_m32(&dst, REG_ESP, MBD(REG_ESP, -28));                           // lea   rsp,[rsp-28]
3128   resolve_link(&dst, &skip);                                          // skip:
3242   track_resolve_link(drcbe, &dst, &skip);                                 // skip:
31293243   return dst;
31303244}
31313245
r6740r6741
31443258
31453259   /* register the current pointer for the mode/PC */
31463260   drchash_set_codeptr(drcbe->hash, inst->param[0].value, inst->param[1].value, dst);
3261   reset_last_upper_lower_reg(drcbe);
31473262   return dst;
31483263}
31493264
r6740r6741
31613276
31623277   /* register the current pointer for the label */
31633278   drclabel_set_codeptr(drcbe->labels, inst->param[0].value, dst);
3279   reset_last_upper_lower_reg(drcbe);
31643280   return dst;
31653281}
31663282
r6740r6741
32443360      emit_mov_m32_imm(&dst, MBD(REG_ESP, 0), (FPTR)drcbe->device);               // mov   [esp],device
32453361      emit_call(&dst, (x86code *)debug_cpu_instruction_hook);                     // call  debug_cpu_instruction_hook
32463362
3247      resolve_link(&dst, &skip);                                       // skip:
3363      track_resolve_link(drcbe, &dst, &skip);                              // skip:
32483364   }
32493365
32503366   return dst;
r6740r6741
34653581
34663582   /* resolve the conditional link */
34673583   if (inst->condition != DRCUML_COND_ALWAYS)
3468      resolve_link(&dst, &skip);                                       // skip:
3584      track_resolve_link(drcbe, &dst, &skip);                              // skip:
34693585   return dst;
34703586}
34713587
r6740r6741
34943610
34953611   /* resolve the conditional link */
34963612   if (inst->condition != DRCUML_COND_ALWAYS)
3497      resolve_link(&dst, &skip);                                       // skip:
3613      track_resolve_link(drcbe, &dst, &skip);                              // skip:
34983614   return dst;
34993615}
35003616
r6740r6741
35263642
35273643   /* resolve the conditional link */
35283644   if (inst->condition != DRCUML_COND_ALWAYS)
3529      resolve_link(&dst, &skip);                                       // skip:
3645      track_resolve_link(drcbe, &dst, &skip);                              // skip:
35303646   return dst;
35313647}
35323648
r6740r6741
38563972
38573973static x86code *op_load(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
38583974{
3859   drcuml_parameter dstp, basep, indp, sizep;
3860   int dstreg;
3975   drcuml_parameter dstp, basep, indp, scalesizep;
3976   int dstreg, scale, size;
38613977
38623978   /* validate instruction */
38633979   assert(inst->size == 4 || inst->size == 8);
r6740r6741
38653981   assert_no_flags(inst);
38663982
38673983   /* normalize parameters */
3868   param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &basep, PTYPE_M, &indp, PTYPE_MRI, &sizep, PTYPE_I);
3984   param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &basep, PTYPE_M, &indp, PTYPE_MRI, &scalesizep, PTYPE_I);
3985   scale = 1 << (scalesizep.value / 16);
3986   size = scalesizep.value % 16;
38693987
38703988   /* pick a target register for the general case */
38713989   dstreg = param_select_register(REG_EAX, &dstp, NULL);
r6740r6741
38733991   /* immediate index */
38743992   if (indp.type == DRCUML_PTYPE_IMMEDIATE)
38753993   {
3876      if (sizep.value == DRCUML_SIZE_BYTE)
3877         emit_movzx_r32_m8(&dst, dstreg, MABS(basep.value + 1*indp.value));         // movzx dstreg,[basep + 1*indp]
3878      else if (sizep.value == DRCUML_SIZE_WORD)
3879         emit_movzx_r32_m16(&dst, dstreg, MABS(basep.value + 2*indp.value));         // movzx dstreg,[basep + 2*indp]
3880      else if (sizep.value == DRCUML_SIZE_DWORD)
3881         emit_mov_r32_m32(&dst, dstreg, MABS(basep.value + 4*indp.value));         // mov   dstreg,[basep + 4*indp]
3882      else if (sizep.value == DRCUML_SIZE_QWORD)
3994      if (size == DRCUML_SIZE_BYTE)
3995         emit_movzx_r32_m8(&dst, dstreg, MABS(basep.value + scale*indp.value));      // movzx dstreg,[basep + scale*indp]
3996      else if (size == DRCUML_SIZE_WORD)
3997         emit_movzx_r32_m16(&dst, dstreg, MABS(basep.value + scale*indp.value));      // movzx dstreg,[basep + scale*indp]
3998      else if (size == DRCUML_SIZE_DWORD)
3999         emit_mov_r32_m32(&dst, dstreg, MABS(basep.value + scale*indp.value));      // mov   dstreg,[basep + scale*indp]
4000      else if (size == DRCUML_SIZE_QWORD)
38834001      {
3884         emit_mov_r32_m32(&dst, REG_EDX, MABS(basep.value + 8*indp.value + 4));      // mov   edx,[basep + 8*indp + 4]
3885         emit_mov_r32_m32(&dst, dstreg, MABS(basep.value + 8*indp.value));         // mov   dstreg,[basep + 8*indp]
4002         emit_mov_r32_m32(&dst, REG_EDX, MABS(basep.value + scale*indp.value + 4));   // mov   edx,[basep + scale*indp + 4]
4003         emit_mov_r32_m32(&dst, dstreg, MABS(basep.value + scale*indp.value));      // mov   dstreg,[basep + scale*indp]
38864004      }
38874005   }
38884006
r6740r6741
38914009   {
38924010      int indreg = param_select_register(REG_ECX, &indp, NULL);
38934011      emit_mov_r32_p32(drcbe, &dst, indreg, &indp);
3894      if (sizep.value == DRCUML_SIZE_BYTE)
3895         emit_movzx_r32_m8(&dst, dstreg, MISD(indreg, 1, basep.value));            // movzx dstreg,[basep + 1*indp]
3896      else if (sizep.value == DRCUML_SIZE_WORD)
3897         emit_movzx_r32_m16(&dst, dstreg, MISD(indreg, 2, basep.value));            // movzx dstreg,[basep + 2*indp]
3898      else if (sizep.value == DRCUML_SIZE_DWORD)
3899         emit_mov_r32_m32(&dst, dstreg, MISD(indreg, 4, basep.value));            // mov   dstreg,[basep + 4*indp]
3900      else if (sizep.value == DRCUML_SIZE_QWORD)
4012      if (size == DRCUML_SIZE_BYTE)
4013         emit_movzx_r32_m8(&dst, dstreg, MISD(indreg, scale, basep.value));         // movzx dstreg,[basep + scale*indp]
4014      else if (size == DRCUML_SIZE_WORD)
4015         emit_movzx_r32_m16(&dst, dstreg, MISD(indreg, scale, basep.value));         // movzx dstreg,[basep + scale*indp]
4016      else if (size == DRCUML_SIZE_DWORD)
4017         emit_mov_r32_m32(&dst, dstreg, MISD(indreg, scale, basep.value));         // mov   dstreg,[basep + scale*indp]
4018      else if (size == DRCUML_SIZE_QWORD)
39014019      {
3902         emit_mov_r32_m32(&dst, REG_EDX, MISD(indreg, 8, basep.value + 4));         // mov   edx,[basep + 8*indp + 4]
3903         emit_mov_r32_m32(&dst, dstreg, MISD(indreg, 8, basep.value));            // mov   dstreg,[basep + 8*indp]
4020         emit_mov_r32_m32(&dst, REG_EDX, MISD(indreg, scale, basep.value + 4));      // mov   edx,[basep + scale*indp + 4]
4021         emit_mov_r32_m32(&dst, dstreg, MISD(indreg, scale, basep.value));         // mov   dstreg,[basep + scale*indp]
39044022      }
39054023   }
39064024
r6740r6741
39114029   if (inst->size == 8)
39124030   {
39134031      /* 1, 2, or 4-byte case */
3914      if (sizep.value != DRCUML_SIZE_QWORD)
4032      if (size != DRCUML_SIZE_QWORD)
39154033      {
39164034         if (dstp.type == DRCUML_PTYPE_MEMORY)
39174035            emit_mov_m32_imm(&dst, MABS(dstp.value + 4), 0);                  // mov   [dstp+4],0
r6740r6741
39264044            emit_mov_m32_r32(&dst, MABS(dstp.value + 4), REG_EDX);               // mov   [dstp+4],edx
39274045         else if (dstp.type == DRCUML_PTYPE_INT_REGISTER)
39284046            emit_mov_m32_r32(&dst, MABS(drcbe->reghi[dstp.value]), REG_EDX);      // mov   [reghi],edx
4047         set_last_upper_reg(drcbe, dst, &dstp, REG_EDX);
39294048      }
39304049   }
4050   set_last_lower_reg(drcbe, dst, &dstp, dstreg);
39314051   return dst;
39324052}
39334053
r6740r6741
39384058
39394059static x86code *op_loads(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
39404060{
3941   drcuml_parameter dstp, basep, indp, sizep;
3942   int dstreg;
4061   drcuml_parameter dstp, basep, indp, scalesizep;
4062   int dstreg, scale, size;
39434063
39444064   /* validate instruction */
39454065   assert(inst->size == 4 || inst->size == 8);
r6740r6741
39474067   assert_no_flags(inst);
39484068
39494069   /* normalize parameters */
3950   param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &basep, PTYPE_M, &indp, PTYPE_MRI, &sizep, PTYPE_I);
4070   param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &basep, PTYPE_M, &indp, PTYPE_MRI, &scalesizep, PTYPE_I);
4071   scale = 1 << (scalesizep.value / 16);
4072   size = scalesizep.value % 16;
39514073
39524074   /* pick a target register for the general case */
39534075   dstreg = param_select_register(REG_EAX, &dstp, NULL);
r6740r6741
39554077   /* immediate index */
39564078   if (indp.type == DRCUML_PTYPE_IMMEDIATE)
39574079   {
3958      if (sizep.value == DRCUML_SIZE_BYTE)
3959         emit_movsx_r32_m8(&dst, dstreg, MABS(basep.value + 1*indp.value));         // movsx dstreg,[basep + 1*indp]
3960      else if (sizep.value == DRCUML_SIZE_WORD)
3961         emit_movsx_r32_m16(&dst, dstreg, MABS(basep.value + 2*indp.value));         // movsx dstreg,[basep + 2*indp]
3962      else if (sizep.value == DRCUML_SIZE_DWORD)
3963         emit_mov_r32_m32(&dst, dstreg, MABS(basep.value + 4*indp.value));         // mov   dstreg,[basep + 4*indp]
3964      else if (sizep.value == DRCUML_SIZE_QWORD)
4080      if (size == DRCUML_SIZE_BYTE)
4081         emit_movsx_r32_m8(&dst, dstreg, MABS(basep.value + scale*indp.value));      // movsx dstreg,[basep + scale*indp]
4082      else if (size == DRCUML_SIZE_WORD)
4083         emit_movsx_r32_m16(&dst, dstreg, MABS(basep.value + scale*indp.value));      // movsx dstreg,[basep + scale*indp]
4084      else if (size == DRCUML_SIZE_DWORD)
4085         emit_mov_r32_m32(&dst, dstreg, MABS(basep.value + scale*indp.value));      // mov   dstreg,[basep + scale*indp]
4086      else if (size == DRCUML_SIZE_QWORD)
39654087      {
3966         emit_mov_r32_m32(&dst, REG_EDX, MABS(basep.value + 8*indp.value + 4));      // mov   edx,[basep + 8*indp + 4]
3967         emit_mov_r32_m32(&dst, dstreg, MABS(basep.value + 8*indp.value));         // mov   dstreg,[basep + 8*indp]
4088         emit_mov_r32_m32(&dst, REG_EDX, MABS(basep.value + scale*indp.value + 4));   // mov   edx,[basep + scale*indp + 4]
4089         emit_mov_r32_m32(&dst, dstreg, MABS(basep.value + scale*indp.value));      // mov   dstreg,[basep + scale*indp]
39684090      }
39694091   }
39704092
r6740r6741
39734095   {
39744096      int indreg = param_select_register(REG_ECX, &indp, NULL);
39754097      emit_mov_r32_p32(drcbe, &dst, indreg, &indp);
3976      if (sizep.value == DRCUML_SIZE_BYTE)
3977         emit_movsx_r32_m8(&dst, dstreg, MISD(indreg, 1, basep.value));            // movsx dstreg,[basep + 1*indp]
3978      else if (sizep.value == DRCUML_SIZE_WORD)
3979         emit_movsx_r32_m16(&dst, dstreg, MISD(indreg, 2, basep.value));            // movsx dstreg,[basep + 2*indp]
3980      else if (sizep.value == DRCUML_SIZE_DWORD)
3981         emit_mov_r32_m32(&dst, dstreg, MISD(indreg, 4, basep.value));            // mov   dstreg,[basep + 4*indp]
3982      else if (sizep.value == DRCUML_SIZE_QWORD)
4098      if (size == DRCUML_SIZE_BYTE)
4099         emit_movsx_r32_m8(&dst, dstreg, MISD(indreg, scale, basep.value));         // movsx dstreg,[basep + scale*indp]
4100      else if (size == DRCUML_SIZE_WORD)
4101         emit_movsx_r32_m16(&dst, dstreg, MISD(indreg, scale, basep.value));         // movsx dstreg,[basep + scale*indp]
4102      else if (size == DRCUML_SIZE_DWORD)
4103         emit_mov_r32_m32(&dst, dstreg, MISD(indreg, scale, basep.value));         // mov   dstreg,[basep + scale*indp]
4104      else if (size == DRCUML_SIZE_QWORD)
39834105      {
3984         emit_mov_r32_m32(&dst, REG_EDX, MISD(indreg, 8, basep.value + 4));         // mov   edx,[basep + 8*indp + 4]
3985         emit_mov_r32_m32(&dst, dstreg, MISD(indreg, 8, basep.value));            // mov   dstreg,[basep + 8*indp]
4106         emit_mov_r32_m32(&dst, REG_EDX, MISD(indreg, scale, basep.value + 4));      // mov   edx,[basep + scale*indp + 4]
4107         emit_mov_r32_m32(&dst, dstreg, MISD(indreg, scale, basep.value));         // mov   dstreg,[basep + scale*indp]
39864108      }
39874109   }
39884110
r6740r6741
39974119         emit_mov_m32_r32(&dst, MABS(dstp.value + 4), REG_EDX);                  // mov   [dstp+4],edx
39984120      else if (dstp.type == DRCUML_PTYPE_INT_REGISTER)
39994121         emit_mov_m32_r32(&dst, MABS(drcbe->reghi[dstp.value]), REG_EDX);         // mov   [reghi],edx
4122      set_last_upper_reg(drcbe, dst, &dstp, REG_EDX);
40004123   }
4124   set_last_lower_reg(drcbe, dst, &dstp, dstreg);
40014125   return dst;
40024126}
40034127
r6740r6741
40084132
40094133static x86code *op_store(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst)
40104134{
4011   drcuml_parameter srcp, basep, indp, sizep;
4012   int srcreg;
4135   drcuml_parameter srcp, basep, indp, scalesizep;
4136   int srcreg, scale, size;
40134137
40144138   /* validate instruction */
40154139   assert(inst->size == 4 || inst->size == 8);
r6740r6741
40174141   assert_no_flags(inst);
40184142
40194143   /* normalize parameters */
4020   param_normalize_4(drcbe, inst, &basep, PTYPE_M, &indp, PTYPE_MRI, &srcp, PTYPE_MRI, &sizep, PTYPE_I);
4144   param_normalize_4(drcbe, inst, &basep, PTYPE_M, &indp, PTYPE_MRI, &srcp, PTYPE_MRI, &scalesizep, PTYPE_I);
4145   scale = 1 << (scalesizep.value / 16);
4146   size = scalesizep.value % 16;
40214147
40224148   /* pick a source register for the general case */
40234149   srcreg = param_select_register(REG_EAX, &srcp, NULL);
4024   if (sizep.value == DRCUML_SIZE_BYTE && (srcreg & 4))
4150   if (size == DRCUML_SIZE_BYTE && (srcreg & 4))
40254151      srcreg = REG_EAX;
40264152
40274153   /* degenerate case: constant index */
r6740r6741
40304156      /* immediate source */
40314157      if (srcp.type == DRCUML_PTYPE_IMMEDIATE)
40324158      {
4033         if (sizep.value == DRCUML_SIZE_BYTE)
4034            emit_mov_m8_imm(&dst, MABS(basep.value + 1*indp.value), srcp.value);   // mov   [basep + 1*indp],srcp
4035         else if (sizep.value == DRCUML_SIZE_WORD)
4036            emit_mov_m16_imm(&dst, MABS(basep.value + 2*indp.value), srcp.value);   // mov   [basep + 2*indp],srcp
4037         else if (sizep.value == DRCUML_SIZE_DWORD)
4038            emit_mov_m32_imm(&dst, MABS(basep.value + 4*indp.value), srcp.value);   // mov   [basep + 4*indp],srcp
4039         else if (sizep.value == DRCUML_SIZE_QWORD)
4159         if (size == DRCUML_SIZE_BYTE)
4160            emit_mov_m8_imm(&dst, MABS(basep.value + scale*indp.value), srcp.value);   // mov   [basep + scale*indp],srcp
4161         else if (size == DRCUML_SIZE_WORD)
4162            emit_mov_m16_imm(&dst, MABS(basep.value + scale*indp.value), srcp.value);   // mov   [basep + scale*indp],srcp
4163         else if (size == DRCUML_SIZE_DWORD)
4164            emit_mov_m32_imm(&dst, MABS(basep.value + scale*indp.value), srcp.value);   // mov   [basep + scale*indp],srcp
4165         else if (size == DRCUML_SIZE_QWORD)
40404166         {
4041            emit_mov_m32_imm(&dst, MABS(basep.value + 8*indp.value), srcp.value);   // mov   [basep + 8*indp],srcp
4042            emit_mov_m32_imm(&dst, MABS(basep.value + 8*indp.value + 4), srcp.value >> 32);
4043                                                                  // mov   [basep + 8*indp + 4],srcp >> 32
4167            emit_mov_m32_imm(&dst, MABS(basep.value + scale*indp.value), srcp.value);   // mov   [basep + scale*indp],srcp
4168            emit_mov_m32_imm(&dst, MABS(basep.value + scale*indp.value + 4), srcp.value >> 32);
4169                                                                  // mov   [basep + scale*indp + 4],srcp >> 32
40444170         }
40454171      }
40464172
40474173      /* variable source */
40484174      else
40494175      {
4050         if (sizep.value != DRCUML_SIZE_QWORD)
4176         if (size != DRCUML_SIZE_QWORD)
40514177            emit_mov_r32_p32(drcbe, &dst, srcreg, &srcp);                     // mov   srcreg,srcp
40524178         else
40534179            emit_mov_r64_p64(drcbe, &dst, srcreg, REG_EDX, &srcp);               // mov   edx:srcreg,srcp
4054         if (sizep.value == DRCUML_SIZE_BYTE)
4055            emit_mov_m8_r8(&dst, MABS(basep.value + 1*indp.value), srcreg);         // mov   [basep + 1*indp],srcreg
4056         else if (sizep.value == DRCUML_SIZE_WORD)
4057            emit_mov_m16_r16(&dst, MABS(basep.value + 2*indp.value), srcreg);      // mov   [basep + 2*indp],srcreg
4058         else if (sizep.value == DRCUML_SIZE_DWORD)
4059            emit_mov_m32_r32(&dst, MABS(basep.value + 4*indp.value), srcreg);      // mov   [basep + 4*indp],srcreg
4060         else if (sizep.value == DRCUML_SIZE_QWORD)
4180         if (size == DRCUML_SIZE_BYTE)
4181            emit_mov_m8_r8(&dst, MABS(basep.value + scale*indp.value), srcreg);      // mov   [basep + scale*indp],srcreg
4182         else if (size == DRCUML_SIZE_WORD)
4183            emit_mov_m16_r16(&dst, MABS(basep.value + scale*indp.value), srcreg);   // mov   [basep + scale*indp],srcreg
4184         else if (size == DRCUML_SIZE_DWORD)
4185            emit_mov_m32_r32(&dst, MABS(basep.value + scale*indp.value), srcreg);   // mov   [basep + scale*indp],srcreg
4186         else if (size == DRCUML_SIZE_QWORD)
40614187         {
4062            emit_mov_m32_r32(&dst, MABS(basep.value + 8*indp.value), srcreg);      // mov   [basep + 8*indp],srcreg
4063            emit_mov_m32_r32(&dst, MABS(basep.value + 8*indp.value + 4), REG_EDX);   // mov   [basep + 8*indp + 4],edx
4188            emit_mov_m32_r32(&dst, MABS(basep.value + scale*indp.value), srcreg);   // mov   [basep + scale*indp],srcreg
4189            emit_mov_m32_r32(&dst, MABS(basep.value + scale*indp.value + 4), REG_EDX);   // mov   [basep + scale*indp + 4],edx
40644190         }
40654191      }
40664192   }
r6740r6741
40744200      /* immediate source */
40754201      if (srcp.type == DRCUML_PTYPE_IMMEDIATE)
40764202      {
4077         if (sizep.value == DRCUML_SIZE_BYTE)
4078            emit_mov_m8_imm(&dst, MISD(indreg, 1, basep.value), srcp.value);      // mov   [basep + 1*ecx],srcp
4079         else if (sizep.value == DRCUML_SIZE_WORD)
4080            emit_mov_m16_imm(&dst, MISD(indreg, 2, basep.value), srcp.value);      // mov   [basep + 2*ecx],srcp
4081         else if (sizep.value == DRCUML_SIZE_DWORD)
4082            emit_mov_m32_imm(&dst, MISD(indreg, 4, basep.value), srcp.value);      // mov   [basep + 4*ecx],srcp
4083         else if (sizep.value == DRCUML_SIZE_QWORD)
4203         if (size == DRCUML_SIZE_BYTE)
4204            emit_mov_m8_imm(&dst, MISD(indreg, scale, basep.value), srcp.value);   // mov   [basep + 1*ecx],srcp
4205         else if (size == DRCUML_SIZE_WORD)
4206            emit_mov_m16_imm(&dst, MISD(indreg, scale, basep.value), srcp.value);   // mov   [basep + 2*ecx],srcp
4207         else if (size == DRCUML_SIZE_DWORD)
4208            emit_mov_m32_imm(&dst, MISD(indreg, scale, basep.value), srcp.value);   // mov   [basep + 4*ecx],srcp
4209         else if (size == DRCUML_SIZE_QWORD)
40844210         {
4085            emit_mov_m32_imm(&dst, MISD(indreg, 8, basep.value), srcp.value);      // mov   [basep + 8*ecx],srcp
4086            emit_mov_m32_imm(&dst, MISD(indreg, 8, basep.value + 4), srcp.value >> 32);
4211            emit_mov_m32_imm(&dst, MISD(indreg, scale, basep.value), srcp.value);   // mov   [basep + 8*ecx],srcp
4212            emit_mov_m32_imm(&dst, MISD(indreg, scale, basep.value + 4), srcp.value >> 32);
40874213                                                                  // mov   [basep + 8*ecx + 4],srcp >> 32
40884214         }
40894215      }
r6740r6741
40914217      /* variable source */
40924218      else
40934219      {
4094         if (sizep.value != DRCUML_SIZE_QWORD)
4220         if (size != DRCUML_SIZE_QWORD)
40954221            emit_mov_r32_p32(drcbe, &dst, srcreg, &srcp);                     // mov   srcreg,srcp
40964222         else
40974223            emit_mov_r64_p64(drcbe, &dst, srcreg, REG_EDX, &srcp);               // mov   edx:srcreg,srcp
4098         if (sizep.value == DRCUML_SIZE_BYTE)
4099            emit_mov_m8_r8(&dst, MISD(indreg, 1, basep.value), srcreg);            // mov   [basep + 1*ecx],srcreg
4100         else if (sizep.value == DRCUML_SIZE_WORD)
4101            emit_mov_m16_r16(&dst, MISD(indreg, 2, basep.value), srcreg);         // mov   [basep + 2*ecx],srcreg
4102         else if (sizep.value == DRCUML_SIZE_DWORD)
4103            emit_mov_m32_r32(&dst, MISD(indreg, 4, basep.value), srcreg);         // mov   [basep + 4*ecx],srcreg
4104         else if (sizep.value == DRCUML_SIZE_QWORD)
4224         if (size == DRCUML_SIZE_BYTE)
4225            emit_mov_m8_r8(&dst, MISD(indreg, scale, basep.value), srcreg);         // mov   [basep + 1*ecx],srcreg
4226         else if (size == DRCUML_SIZE_WORD)
4227            emit_mov_m16_r16(&dst, MISD(indreg, scale, basep.value), srcreg);      // mov   [basep + 2*ecx],srcreg
4228         else if (size == DRCUML_SIZE_DWORD)
4229            emit_mov_m32_r32(&dst, MISD(indreg, scale, basep.value), srcreg);      // mov   [basep + 4*ecx],srcreg
4230         else if (size == DRCUML_SIZE_QWORD)
41054231         {
4106            emit_mov_m32_r32(&dst, MISD(indreg, 8, basep.value), srcreg);         // mov   [basep + 8*ecx],srcreg
4107            emit_mov_m32_r32(&dst, MISD(indreg, 8, basep.value + 4), REG_EDX);      // mov   [basep + 8*ecx],edx
4232            emit_mov_m32_r32(&dst, MISD(indreg, scale, basep.value), srcreg);      // mov   [basep + 8*ecx],srcreg
4233            emit_mov_m32_r32(&dst, MISD(indreg, scale, basep.value + 4), REG_EDX);   // mov   [basep + 8*ecx],edx
41084234         }
41094235      }
41104236   }
r6740r6741
45604686
45614687   /* resolve the jump */
45624688   if (skip.target != NULL)
4563      resolve_link(&dst, &skip);
4689      track_resolve_link(drcbe, &dst, &skip);
45644690   return dst;
45654691}
45664692
r6740r6741
53275453         emit_mov_p32_r32(drcbe, &dst, &edstp, REG_EDX);                        // mov   edstp,edx
53285454      if (inst->flags != 0)
53295455         emit_test_r32_r32(&dst, REG_EAX, REG_EAX);                           // test  eax,eax
5330      resolve_link(&dst, &skip);                                       // skip:
5456      track_resolve_link(drcbe, &dst, &skip);                              // skip:
53315457   }
53325458
53335459   /* 64-bit form */
r6740r6741
53985524         emit_mov_p32_r32(drcbe, &dst, &edstp, REG_EDX);                        // mov   edstp,edx
53995525      if (inst->flags != 0)
54005526         emit_test_r32_r32(&dst, REG_EAX, REG_EAX);                           // test  eax,eax
5401      resolve_link(&dst, &skip);                                       // skip:
5527      track_resolve_link(drcbe, &dst, &skip);                              // skip:
54025528   }
54035529
54045530   /* 64-bit form */
r6740r6741
54585584      if (src1p.type == dstp.type && src1p.value == dstp.value && dstp.type == DRCUML_PTYPE_MEMORY)
54595585         emit_and_m32_p32(drcbe, &dst, MABS(dstp.value), &src2p, inst);            // and   [dstp],src2p
54605586
5587      /* AND with immediate 0xff */
5588      else if (src2p.type == DRCUML_PTYPE_IMMEDIATE && src2p.value == 0xff && inst->flags == 0)
5589      {
5590         if (src1p.type == DRCUML_PTYPE_INT_REGISTER)
5591            emit_movzx_r32_r8(&dst, dstreg, src1p.value);                     // movzx dstreg,src1p
5592         else if (src1p.type == DRCUML_PTYPE_MEMORY)
5593            emit_movzx_r32_m8(&dst, dstreg, MABS(src1p.value));                  // movzx dstreg,[src1p]
5594         emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg);                        // mov   dstp,dstreg
5595      }
5596
5597      /* AND with immediate 0xffff */
5598      else if (src2p.type == DRCUML_PTYPE_IMMEDIATE && src2p.value == 0xffff && inst->flags == 0)
5599      {
5600         if (src1p.type == DRCUML_PTYPE_INT_REGISTER)
5601            emit_movzx_r32_r16(&dst, dstreg, src1p.value);                     // movzx dstreg,src1p
5602         else if (src1p.type == DRCUML_PTYPE_MEMORY)
5603            emit_movzx_r32_m16(&dst, dstreg, MABS(src1p.value));               // movzx dstreg,[src1p]
5604         emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg);                        // mov   dstp,dstreg
5605      }
5606
54615607      /* general case */
54625608      else
54635609      {
r6740r6741
54745620      if (src1p.type == dstp.type && src1p.value == dstp.value && dstp.type == DRCUML_PTYPE_MEMORY)
54755621         emit_and_m64_p64(drcbe, &dst, MABS(dstp.value), &src2p, inst);            // and   [dstp],src2p
54765622
5623      /* AND with immediate 0xff */
5624      else if (src2p.type == DRCUML_PTYPE_IMMEDIATE && src2p.value == 0xff && inst->flags == 0)
5625      {
5626         if (src1p.type == DRCUML_PTYPE_INT_REGISTER)
5627            emit_movzx_r32_r8(&dst, dstreg, src1p.value);                     // movzx dstreg,src1p
5628         else if (src1p.type == DRCUML_PTYPE_MEMORY)
5629            emit_movzx_r32_m8(&dst, dstreg, MABS(src1p.value));                  // movzx dstreg,[src1p]
5630         emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg);                        // mov   dstp,dstreg
5631         if (dstp.type == DRCUML_PTYPE_INT_REGISTER)
5632            emit_mov_m32_imm(&dst, MABS(drcbe->reghi[dstp.value]), 0);            // mov   dsthi,0
5633         else if (dstp.type == DRCUML_PTYPE_MEMORY)
5634            emit_mov_m32_imm(&dst, MABS(dstp.value + 4), 0);                  // mov   dsthi,0
5635      }
5636
5637      /* AND with immediate 0xffff */
5638      else if (src2p.type == DRCUML_PTYPE_IMMEDIATE && src2p.value == 0xffff && inst->flags == 0)
5639      {
5640         if (src1p.type == DRCUML_PTYPE_INT_REGISTER)
5641            emit_movzx_r32_r16(&dst, dstreg, src1p.value);                     // movzx dstreg,src1p
5642         else if (src1p.type == DRCUML_PTYPE_MEMORY)
5643            emit_movzx_r32_m16(&dst, dstreg, MABS(src1p.value));               // movzx dstreg,[src1p]
5644         emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg);                        // mov   dstp,dstreg
5645         if (dstp.type == DRCUML_PTYPE_INT_REGISTER)
5646            emit_mov_m32_imm(&dst, MABS(drcbe->reghi[dstp.value]), 0);            // mov   dsthi,0
5647         else if (dstp.type == DRCUML_PTYPE_MEMORY)
5648            emit_mov_m32_imm(&dst, MABS(dstp.value + 4), 0);                  // mov   dsthi,0
5649      }
5650
5651      /* AND with immediate 0xffffffff */
5652      else if (src2p.type == DRCUML_PTYPE_IMMEDIATE && src2p.value == 0xffffffff && inst->flags == 0)
5653      {
5654         emit_mov_r32_p32(drcbe, &dst, dstreg, &src1p);                        // mov   dstreg,src1p
5655         emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg);                        // mov   dstp,dstreg
5656         if (dstp.type == DRCUML_PTYPE_INT_REGISTER)
5657            emit_mov_m32_imm(&dst, MABS(drcbe->reghi[dstp.value]), 0);            // mov   dsthi,0
5658         else if (dstp.type == DRCUML_PTYPE_MEMORY)
5659            emit_mov_m32_imm(&dst, MABS(dstp.value + 4), 0);                  // mov   dsthi,0
5660      }
5661
5662      /* AND with immediate 0xffffffff00000000 */
5663      else if (src2p.type == DRCUML_PTYPE_IMMEDIATE && src2p.value == U64(0xffffffff00000000) && inst->flags == 0)
5664      {
5665         if (src1p.type != dstp.type || src1p.value != dstp.value)
5666         {
5667            emit_mov_r64_p64(drcbe, &dst, REG_NONE, REG_EDX, &src1p);            // mov   dstreg,src1p
5668            emit_mov_p64_r64(drcbe, &dst, &dstp, REG_NONE, REG_EDX);            // mov   dstp,dstreg
5669         }
5670         if (dstp.type == DRCUML_PTYPE_INT_REGISTER)
5671            emit_xor_r32_r32(&dst, dstp.value, dstp.value);                     // xor   dstlo,dstlo
5672         else if (dstp.type == DRCUML_PTYPE_MEMORY)
5673            emit_mov_m32_imm(&dst, MABS(dstp.value), 0);                     // mov   dstlo,0
5674      }
5675
5676      /* AND with immediate <= 0xffffffff */
5677      else if (src2p.type == DRCUML_PTYPE_IMMEDIATE && src2p.value <= 0xffffffff && inst->flags == 0)
5678      {
5679         emit_mov_r32_p32(drcbe, &dst, dstreg, &src1p);                        // mov   dstreg,src1p
5680         emit_and_r32_p32(drcbe, &dst, dstreg, &src2p, inst);                  // and   dstreg,src2p
5681         emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg);                        // mov   dstp,dstreg
5682         if (dstp.type == DRCUML_PTYPE_INT_REGISTER)
5683            emit_mov_m32_imm(&dst, MABS(drcbe->reghi[dstp.value]), 0);            // mov   dsthi,0
5684         else if (dstp.type == DRCUML_PTYPE_MEMORY)
5685            emit_mov_m32_imm(&dst, MABS(dstp.value + 4), 0);                  // mov   dsthi,0
5686      }
5687
54775688      /* general case */
54785689      else
54795690      {
r6740r6741
56925903      emit_bsr_r32_r32(&dst, dstreg, REG_EDX);                              // bsr   dstreg,edx
56935904      emit_cmovcc_r32_r32(&dst, COND_Z, dstreg, REG_ECX);                        // cmovz dstreg,ecx
56945905      emit_add_r32_imm(&dst, REG_ECX, 32);                                 // add   ecx,32
5695      resolve_link(&dst, &skip);                                       // skip:
5906      track_resolve_link(drcbe, &dst, &skip);                              // skip:
56965907      emit_xor_r32_r32(&dst, REG_EDX, REG_EDX);                              // xor   edx,edx
56975908      emit_xor_r32_imm(&dst, dstreg, 31);                                    // xor   dstreg,31
56985909      emit_mov_p64_r64(drcbe, &dst, &dstp, dstreg, REG_EDX);                     // mov   dstp,edx:dstreg
r6740r6741
62776488
62786489   /* resolve the jump */
62796490   if (skip.target != NULL)
6280      resolve_link(&dst, &skip);                                       // skip:
6491      track_resolve_link(drcbe, &dst, &skip);                              // skip:
62816492   return dst;
62826493}
62836494
src/emu/video/generic.c
r6740r6741
255255   machine->generic.tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
256256
257257   /* ensure the contents of the bitmap are saved */
258   state_save_register_bitmap(machine, "video", NULL, 0, "tmpbitmap", machine->generic.tmpbitmap);
258   state_save_register_global_bitmap(machine, machine->generic.tmpbitmap);
259259}
260260
261261
src/emu/video/mc6845.c
r6740r6741
845845      /* call the tear down function if any */
846846      if (mc6845->intf->end_update != NULL)
847847         mc6845->intf->end_update(device, bitmap, cliprect, param);
848
849      popmessage(NULL);
848850   }
849851   else
850852      popmessage("Invalid MC6845 screen parameters - display disabled!!!");
src/emu/video/v9938.c
r6740r6741
16071607#define pre_loop \
16081608    while ((cnt-=delta) > 0) {
16091609
1610#define post_loop \
1611    }
16101612
16111613/* Loop over DX, DY */
16121614#define post__x_y(MX) \
r6740r6741
16181620        ANX=NX; \
16191621      } \
16201622    } \
1621  }
1623  post_loop
16221624
16231625/* Loop over DX, SY, DY */
16241626#define post__xyy(MX) \
r6740r6741
16281630      else \
16291631        ADX=DX; \
16301632    } \
1631  }
1633  post_loop
16321634
16331635/* Loop over SX, DX, SY, DY */
16341636#define post_xxyy(MX) \
r6740r6741
16411643        ANX=NX; \
16421644      } \
16431645    } \
1644  }
1646  post_loop
16451647
16461648/*************************************************************/
16471649/** Function prototypes                                     **/
r6740r6741
18941896      VDPStatus[2]&=0xEF; /* Border not detected */ \
18951897      break; \
18961898    } \
1897  }
1899  post_loop
18981900
18991901  switch (ScrMode) {
19001902    default:
r6740r6741
19521954      ASX&=1023; /* Mask to 10 bits range */ \
19531955      if (ADX++==NX || (DX&MX)) \
19541956        break; \
1955    }
1957    post_loop
1958
19561959#define post_lineymaj(MX) \
19571960      DY+=TY; \
19581961      if ((ASX-=NY)<0) { \
r6740r6741
19621965      ASX&=1023; /* Mask to 10 bits range */ \
19631966      if (ADX++==NX || (DX&MX)) \
19641967        break; \
1965    }
1968    post_loop
19661969
19671970  if ((VDP[45]&0x01)==0)
19681971    /* X-Axis is major direction */
src/emu/video/saa5050.c
r6740r6741
99    -  Implement BOX and dirtybuffer
1010    -  Add support for non-English version (SAA505x), possibly merging
1111       src/mess/video/saa505x.c unsed by bbc.c in MESS
12    -  Investigate why supporting code 0 behavior breaks p2000t vscroll
12    -  Investigate why supporting code 0 behavior breaks p2000t vscroll
1313       in MESS (but not supporting breaks malzak title background)
1414    -  x,y sizes should probably be calculated from the screen parameters
1515       rather than passed in the device interface
r6740r6741
4040   int         size;
4141   int         rev;
4242
43   UINT8 *     videoram;
43   UINT8 *     videoram;
4444   UINT16      flags;
4545   UINT8         forecol;
4646   UINT8         backcol;
r6740r6741
159159
160160   for ( i = 0; i < 8; i++ )
161161   {
162      r = saa5050_colors[i * 3];
163      g = saa5050_colors[i * 3 + 1];
162      r = saa5050_colors[i * 3];
163      g = saa5050_colors[i * 3 + 1];
164164      b = saa5050_colors[i * 3 + 2];
165165      colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b));
166166   }
r6740r6741
195195 *************************************/
196196
197197
198/* this should probably be put at the end of saa5050 update,
199but p2000t in MESS does not seem to currently support it.
198/* this should probably be put at the end of saa5050 update,
199but p2000t in MESS does not seem to currently support it.
200200Hence, we leave it independent for the moment */
201201void saa5050_frame_advance( const device_config *device )
202202{
r6740r6741
231231         code = saa5050->videoram[ssy * saa5050->size + sx];
232232         if (code < 32)
233233         {
234            switch (code)
234            switch (code)
235235            {
236236            case 0x00:
237237#ifndef MESS
src/emu/video/s2636.c
r6740r6741
317317{
318318   s2636_state *s2636 = get_safe_token(device);
319319
320   assert(offset < 8);
320   assert(offset < s2636->work_ram_size);
321321
322322   s2636->work_ram[offset] = data;
323323}
src/emu/tilemap.c
r6740r6741
297297
298298   if (screen_width != 0 && screen_height != 0)
299299   {
300      machine->tilemap_data = auto_alloc_clear(machine, tilemap_private);
301      machine->tilemap_data->tailptr = &machine->tilemap_data->list;
302
303300      machine->priority_bitmap = auto_bitmap_alloc(machine, screen_width, screen_height, BITMAP_FORMAT_INDEXED8);
304301      add_exit_callback(machine, tilemap_exit);
305302   }
r6740r6741
340337static tilemap *tilemap_create_common(running_machine *machine, void *get_info_object, tile_get_info_func tile_get_info, tilemap_mapper_func mapper, int tilewidth, int tileheight, int cols, int rows)
341338{
342339   tilemap *tmap;
343   int tilemap_instance = machine->tilemap_data->instance;
340   int tilemap_instance;
344341   int group;
345342
343   /* if no tilemap private data yet, allocate it */
344   if (machine->tilemap_data == NULL)
345   {
346      machine->tilemap_data = auto_alloc_clear(machine, tilemap_private);
347      machine->tilemap_data->tailptr = &machine->tilemap_data->list;
348   }
349   tilemap_instance = machine->tilemap_data->instance;
350
346351   /* allocate the tilemap itself */
347352   tmap = alloc_clear_or_die(tilemap);
348353
r6740r6741
471476void tilemap_set_flip_all(running_machine *machine, UINT32 attributes)
472477{
473478   tilemap *tmap;
479
480   if (machine->tilemap_data == NULL)
481      return;
482
474483   for (tmap = machine->tilemap_data->list; tmap != NULL; tmap = tmap->next)
475484      tilemap_set_flip(tmap, attributes);
476485}
r6740r6741
971980   tilemap *tmap;
972981   int count = 0;
973982
983   if (machine->tilemap_data == NULL)
984      return 0;
985
974986   /* find by the tilemap index */
975987   for (tmap = machine->tilemap_data->list; tmap != NULL; tmap = tmap->next)
976988      count++;
r6740r6741
11031115   tilemap_private *tilemap_data = machine->tilemap_data;
11041116
11051117   /* free all the tilemaps in the list */
1106   while (tilemap_data->list != NULL)
1107   {
1108      tilemap *next = tilemap_data->list->next;
1109      tilemap_dispose(tilemap_data->list);
1110      tilemap_data->list = next;
1111   }
1112   tilemap_data->tailptr = &tilemap_data->list;
1118   if (tilemap_data != NULL)
1119      while (tilemap_data->list != NULL)
1120      {
1121         tilemap *next = tilemap_data->list->next;
1122         tilemap_dispose(tilemap_data->list);
1123         tilemap_data->list = next;
1124      }
11131125}
11141126
11151127
src/emu/deprecat.h
r6740r6741
6666 *
6767 *************************************/
6868
69/* decode a series of tiles from a particular gfx_element */
70void decodegfx(gfx_element *gfx, UINT32 first, UINT32 count);
71
7269void decodechar(const gfx_element *gfx, UINT32 code, const UINT8 *src);
7370
7471
src/emu/tilemap.h
r6740r6741
354354
355355/* function definition for a get info callback */
356356#define TILE_GET_INFO(_name)         void _name(running_machine *machine, tile_data *tileinfo, tilemap_memory_index tile_index, void *param)
357#define TILE_GET_INFO_DEVICE(_name)      void _name(const device_config *device, tile_data *tileinfo, tilemap_memory_index tile_index, void *param)
357358
358359/* function definition for a logical-to-memory mapper */
359360#define TILEMAP_MAPPER(_name)         tilemap_memory_index _name(UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows)
360361
361362/* useful macro inside of a TILE_GET_INFO callback to set tile information  */
362#define SET_TILE_INFO(GFX,CODE,COLOR,FLAGS) tileinfo_set(machine, tileinfo, GFX, CODE, COLOR, FLAGS)
363#define SET_TILE_INFO(GFX,CODE,COLOR,FLAGS)         tileinfo_set(machine, tileinfo, GFX, CODE, COLOR, FLAGS)
364#define SET_TILE_INFO_DEVICE(GFX,CODE,COLOR,FLAGS)  tileinfo_set(device->machine, tileinfo, GFX, CODE, COLOR, FLAGS)
363365
364366/* Macros for setting tile attributes in the TILE_GET_INFO callback: */
365367/*   TILE_FLIP_YX assumes that flipy is in bit 1 and flipx is in bit 0 */
src/emu/video.c
r6740r6741
174174static void video_exit(running_machine *machine);
175175static void init_buffered_spriteram(running_machine *machine);
176176
177/* graphics decoding */
178static void allocate_graphics(running_machine *machine, const gfx_decode_entry *gfxdecodeinfo);
179
180177static void realloc_screen_bitmaps(const device_config *screen);
181178static STATE_POSTLOAD( video_screen_postload );
182179
r6740r6741
334331   if (machine->config->video_attributes & VIDEO_BUFFERS_SPRITERAM)
335332      init_buffered_spriteram(machine);
336333
337   /* convert the gfx ROMs into character sets. This is done BEFORE calling the driver's */
338   /* palette_init() routine because it might need to check the machine->gfx[] data */
339   if (machine->config->gfxdecodeinfo != NULL)
340      allocate_graphics(machine, machine->config->gfxdecodeinfo);
341
342334   /* call the PALETTE_INIT function */
343335   if (machine->config->init_palette != NULL)
344336      (*machine->config->init_palette)(machine, memory_region(machine, "proms"));
r6740r6741
452444
453445
454446/***************************************************************************
455    GRAPHICS DECODING
456***************************************************************************/
457
458/*-------------------------------------------------
459    allocate_graphics - allocate memory for the
460    graphics
461-------------------------------------------------*/
462
463static void allocate_graphics(running_machine *machine, const gfx_decode_entry *gfxdecodeinfo)
464{
465   int curgfx;
466
467   /* loop over all elements */
468   for (curgfx = 0; curgfx < MAX_GFX_ELEMENTS && gfxdecodeinfo[curgfx].gfxlayout != NULL; curgfx++)
469   {
470      const gfx_decode_entry *gfxdecode = &gfxdecodeinfo[curgfx];
471      UINT32 region_length = 8 * memory_region_length(machine, gfxdecode->memory_region);
472      const UINT8 *region_base = memory_region(machine, gfxdecode->memory_region);
473      UINT32 xscale = (gfxdecode->xscale == 0) ? 1 : gfxdecode->xscale;
474      UINT32 yscale = (gfxdecode->yscale == 0) ? 1 : gfxdecode->yscale;
475      UINT32 *extpoffs, extxoffs[MAX_ABS_GFX_SIZE], extyoffs[MAX_ABS_GFX_SIZE];
476      const gfx_layout *gl = gfxdecode->gfxlayout;
477      int israw = (gl->planeoffset[0] == GFX_RAW);
478      int planes = gl->planes;
479      UINT32 width = gl->width;
480      UINT32 height = gl->height;
481      UINT32 total = gl->total;
482      UINT32 charincrement = gl->charincrement;
483      gfx_layout glcopy;
484      int j;
485
486      /* make a copy of the layout */
487      glcopy = *gfxdecode->gfxlayout;
488
489      /* copy the X and Y offsets into temporary arrays */
490      memcpy(extxoffs, glcopy.xoffset, sizeof(glcopy.xoffset));
491      memcpy(extyoffs, glcopy.yoffset, sizeof(glcopy.yoffset));
492
493      /* if there are extended offsets, copy them over top */
494      if (glcopy.extxoffs != NULL)
495         memcpy(extxoffs, glcopy.extxoffs, glcopy.width * sizeof(extxoffs[0]));
496      if (glcopy.extyoffs != NULL)
497         memcpy(extyoffs, glcopy.extyoffs, glcopy.height * sizeof(extyoffs[0]));
498
499      /* always use the extended offsets here */
500      glcopy.extxoffs = extxoffs;
501      glcopy.extyoffs = extyoffs;
502
503      extpoffs = glcopy.planeoffset;
504
505      /* expand X and Y by the scale factors */
506      if (xscale > 1)
507      {
508         width *= xscale;
509         for (j = width - 1; j >= 0; j--)
510            extxoffs[j] = extxoffs[j / xscale];
511      }
512      if (yscale > 1)
513      {
514         height *= yscale;
515         for (j = height - 1; j >= 0; j--)
516            extyoffs[j] = extyoffs[j / yscale];
517      }
518
519      /* if the character count is a region fraction, compute the effective total */
520      if (IS_FRAC(total))
521      {
522         assert(region_length != 0);
523         total = region_length / charincrement * FRAC_NUM(total) / FRAC_DEN(total);
524      }
525
526      /* for non-raw graphics, decode the X and Y offsets */
527      if (!israw)
528      {
529         /* loop over all the planes, converting fractions */
530         for (j = 0; j < planes; j++)
531         {
532            UINT32 value = extpoffs[j];
533            if (IS_FRAC(value))
534            {
535               assert(region_length != 0);
536               extpoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value);
537            }
538         }
539
540         /* loop over all the X/Y offsets, converting fractions */
541         for (j = 0; j < width; j++)
542         {
543            UINT32 value = extxoffs[j];
544            if (IS_FRAC(value))
545            {
546               assert(region_length != 0);
547               extxoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value);
548            }
549         }
550
551         for (j = 0; j < height; j++)
552         {
553            UINT32 value = extyoffs[j];
554            if (IS_FRAC(value))
555            {
556               assert(region_length != 0);
557               extyoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value);
558            }
559         }
560      }
561
562      /* otherwise, just use the line modulo */
563      else
564      {
565         int base = gfxdecode->start;
566         int end = region_length/8;
567         int linemod = gl->yoffset[0];
568         while (total > 0)
569         {
570            int elementbase = base + (total - 1) * charincrement / 8;
571            int lastpixelbase = elementbase + height * linemod / 8 - 1;
572            if (lastpixelbase < end)
573               break;
574            total--;
575         }
576      }
577
578      /* update glcopy */
579      glcopy.width = width;
580      glcopy.height = height;
581      glcopy.total = total;
582
583      /* allocate the graphics */
584      machine->gfx[curgfx] = gfx_element_alloc(machine, &glcopy, (region_base != NULL) ? region_base + gfxdecode->start : NULL, gfxdecode->total_color_codes, gfxdecode->color_codes_start);
585   }
586}
587
588
589
590/***************************************************************************
591447    SCREEN MANAGEMENT
592448***************************************************************************/
593449
src/emu/memory.c
r6740r6741
34433443      char name[256];
34443444
34453445      sprintf(name, "%08x-%08x", bytestart, byteend);
3446      state_save_register_memory(space->machine, "memory", space->cpu->tag, space->spacenum, name, memory, bytes_per_element, (UINT32)(byteend - bytestart + 1) / bytes_per_element);
3446      state_save_register_memory(space->machine, "memory", space->cpu->tag, space->spacenum, name, memory, bytes_per_element, (UINT32)(byteend - bytestart + 1) / bytes_per_element, __FILE__, __LINE__);
34473447   }
34483448
34493449   /* fill in the tracking block */
src/emu/emu.mak
r6740r6741
146146   $(EMUMACHINE)/ldpr8210.o \
147147   $(EMUMACHINE)/ldv1000.o \
148148   $(EMUMACHINE)/ldvp931.o \
149   $(EMUMACHINE)/mb14241.o \
149150   $(EMUMACHINE)/mb3773.o \
150151   $(EMUMACHINE)/mb87078.o \
151152   $(EMUMACHINE)/mc146818.o \
src/emu/restrack.c
r6740r6741
1313#include "pool.h"
1414#include "timer.h"
1515#include "state.h"
16#include "mame.h"
1617
1718
1819
r6740r6741
143144   pool_type_register(new_pool, OBJTYPE_ASTRING, "String", astring_destructor);
144145   pool_type_register(new_pool, OBJTYPE_BITMAP, "Bitmap", bitmap_destructor);
145146   pool_type_register(new_pool, OBJTYPE_TIMER, "Timer", timer_destructor);
146   pool_type_register(new_pool, OBJTYPE_STATEREG, "Save State Registration", state_destructor);
147147
148148   /* increment the tag counter */
149149   resource_tracking_tag++;
r6740r6741
188188
189189void *restrack_register_object(object_type type, void *ptr, size_t size, const char *file, int line)
190190{
191if (resource_tracking_tag == 2) mame_printf_warning("restrack_register_object(%p,%ld) called within reset scope by %s, line %d\n", ptr, (long) size, file, line);
191192   return pool_object_add_file_line(current_pool(), type, ptr, size, file, line);
192193}
193194
r6740r6741
200201void *auto_malloc_file_line(running_machine *machine, size_t size, const char *file, int line)
201202{
202203   void *result = pool_malloc_file_line(current_pool(), size, file, line);
204if (resource_tracking_tag == 2) mame_printf_warning("auto_malloc(%ld) called within reset scope by %s, line %d\n", (long) size, file, line);
203205#ifdef MAME_DEBUG
204206   rand_memory(result, size);
205207#endif
r6740r6741
226228      }
227229      assert_always(tag > 0, "Failed to find alloc in pool");
228230   }
231else if (resource_tracking_tag == 2) mame_printf_warning("auto_realloc(%p, %ld) called within reset scope by %s, line %d\n", ptr, (long) size, file, line);
229232
230233   return pool_realloc_file_line(pool, ptr, size, file, line);
231234}
r6740r6741
238241
239242char *auto_strdup_file_line(running_machine *machine, const char *str, const char *file, int line)
240243{
244if (resource_tracking_tag == 2) mame_printf_warning("auto_strdup() called within reset scope by %s, line %d\n", file, line);
241245   return pool_strdup_file_line(current_pool(), str, file, line);
242246}
243247
r6740r6741
249253
250254char *auto_strdup_allow_null_file_line(running_machine *machine, const char *str, const char *file, int line)
251255{
256if (resource_tracking_tag == 2) mame_printf_warning("auto_strdup_allow_null() called within reset scope by %s, line %d\n", file, line);
252257   return (str != NULL) ? auto_strdup_file_line(machine, str, file, line) : NULL;
253258}
254259
r6740r6741
260265
261266astring *auto_astring_alloc_file_line(running_machine *machine, const char *file, int line)
262267{
268if (resource_tracking_tag == 2) mame_printf_warning("auto_astring_alloc() called within reset scope by %s, line %d\n", file, line);
263269   return (astring *)restrack_register_object(OBJTYPE_ASTRING, astring_alloc(), 0, file, line);
264270}
265271
r6740r6741
271277
272278bitmap_t *auto_bitmap_alloc_file_line(running_machine *machine, int width, int height, bitmap_format format, const char *file, int line)
273279{
280if (resource_tracking_tag == 2) mame_printf_warning("auto_bitmap_alloc(%d,%d) called within reset scope by %s, line %d\n", width, height, file, line);
274281   return (bitmap_t *)restrack_register_object(OBJTYPE_BITMAP, bitmap_alloc(width, height, format), width * height, file, line);
275282}
276283
src/emu/inptport.c
r6740r6741
771771
772772
773773/*-------------------------------------------------
774    input_port_by_index - return a pointer to the
775    port_config associated with the given port
776    index
777-------------------------------------------------*/
778
779const input_port_config *input_port_by_index(const input_port_list *portlist, int index)
780{
781   const input_port_config *port;
782
783   /* loop over ports until we hit the index or run out */
784   for (port = portlist->head; port != NULL; port = port->next)
785      if (index-- == 0)
786         return port;
787
788   return NULL;
789}
790
791
792/*-------------------------------------------------
793774    input_field_by_tag_and_mask - return a pointer
794775    to the first field that intersects the given
795776    mask on the tagged port
src/emu/mame.c
r6740r6741
15301530   cpuexec_init(machine);
15311531   watchdog_init(machine);
15321532
1533   /* allocate the gfx elements prior to device initialization */
1534   gfx_init(machine);
1535
15331536#ifdef MESS
15341537   /* first MESS initialization */
15351538   mess_predevice_init(machine);
r6740r6741
15731576   saveload_init(machine);
15741577   if (options_get_bool(mame_options(), OPTION_CHEAT))
15751578      cheat_init(machine);
1579
1580   /* disallow save state registrations starting here */
1581   state_save_allow_registration(machine, FALSE);
15761582}
15771583
15781584
r6740r6741
15961602   end_resource_tracking();
15971603   begin_resource_tracking();
15981604
1599   /* allow save state registrations during the reset */
1600   state_save_allow_registration(machine, TRUE);
1601
16021605   /* call all registered reset callbacks */
16031606   for (cb = machine->mame_data->reset_callback_list; cb; cb = cb->next)
16041607      (*cb->func.reset)(machine);
r6740r6741
16111614   if (machine->config->video_reset != NULL)
16121615      (*machine->config->video_reset)(machine);
16131616
1614   /* disallow save state registrations starting here */
1615   state_save_allow_registration(machine, FALSE);
1616
16171617   /* now we're running */
16181618   mame->current_phase = MAME_PHASE_RUNNING;
16191619
src/emu/restrack.h
r6740r6741
2424#define OBJTYPE_ASTRING               OBJECT_TYPE('a','s','t','r')
2525#define OBJTYPE_BITMAP               OBJECT_TYPE('b','i','t','m')
2626#define OBJTYPE_TIMER               OBJECT_TYPE('t','i','m','r')
27#define OBJTYPE_STATEREG            OBJECT_TYPE('s','t','a','t')
2827
2928
3029
src/emu/machine/rtc65271.h
r6740r6741
22    rtc65271.h: include file for rtc65271.c
33*/
44
5extern int rtc65271_file_load(running_machine *machine, mame_file *file);
6extern int rtc65271_file_save(mame_file *file);
7extern void rtc65271_init(running_machine *machine, UINT8 *xram, void (*interrupt_callback)(running_machine *machine, int state));
8extern UINT8 rtc65271_r(int xramsel, offs_t offset);
9extern void rtc65271_w(int xramsel, offs_t offset, UINT8 data);
10extern READ8_HANDLER( rtc65271_rtc_r );
11extern READ8_HANDLER( rtc65271_xram_r );
12extern WRITE8_HANDLER( rtc65271_rtc_w );
13extern WRITE8_HANDLER( rtc65271_xram_w );
5typedef struct _rtc65271_config rtc65271_config;
6struct _rtc65271_config
7{
8   void (*interrupt_callback)(const device_config *device, int state);
9};
10
11
12#define MDRV_RTC65271_ADD(_tag, _callback) \
13   MDRV_DEVICE_ADD(_tag, RTC65271, 0) \
14   MDRV_DEVICE_CONFIG_DATAPTR(rtc65271_config, interrupt_callback, _callback)
15
16
17UINT8 rtc65271_r(const device_config *device, int xramsel, offs_t offset);
18void rtc65271_w(const device_config *device, int xramsel, offs_t offset, UINT8 data);
19
20READ8_DEVICE_HANDLER( rtc65271_rtc_r );
21READ8_DEVICE_HANDLER( rtc65271_xram_r );
22WRITE8_DEVICE_HANDLER( rtc65271_rtc_w );
23WRITE8_DEVICE_HANDLER( rtc65271_xram_w );
24
25
26/* device get info callback */
27#define RTC65271 DEVICE_GET_INFO_NAME(rtc65271)
28DEVICE_GET_INFO( rtc65271 );
src/emu/machine/74148.c
r6740r6741
4242#include "machine/74148.h"
4343
4444
45#define MAX_TTL74148 4
46
47struct TTL74148
45typedef struct _ttl74148_state ttl74148_state;
46struct _ttl74148_state
4847{
4948   /* callback */
50   void (*output_cb)(running_machine *machine);
49   void (*output_cb)(const device_config *device);
5150
5251   /* inputs */
5352   int input_lines[8];   /* pins 1-4,10-13 */
r6740r6741
6463   int last_enable_output;
6564};
6665
67static struct TTL74148 chips[MAX_TTL74148];
6866
67INLINE ttl74148_state *get_safe_token(const device_config *device)
68{
69   assert(device != NULL);
70   assert(device->token != NULL);
71   assert(device->type == TTL74148);
6972
70void TTL74148_update(running_machine *machine, int which)
73   return (ttl74148_state *)device->token;
74}
75
76void ttl74148_update(const device_config *device)
7177{
72   if (chips[which].enable_input)
78   ttl74148_state *state = get_safe_token(device);
79
80   if (state->enable_input)
7381   {
7482      // row 1 in truth table
75      chips[which].output = 0x07;
76      chips[which].output_valid = 1;
77      chips[which].enable_output = 1;
83      state->output = 0x07;
84      state->output_valid = 1;
85      state->enable_output = 1;
7886   }
7987   else
8088   {
8189      int bit0, bit1, bit2;
8290
8391      /* this comes straight off the data sheet schematics */
84      bit0 = !(((!chips[which].input_lines[1]) &
85                 chips[which].input_lines[2] &
86                 chips[which].input_lines[4] &
87                 chips[which].input_lines[6])  |
88               ((!chips[which].input_lines[3]) &
89                 chips[which].input_lines[4] &
90                 chips[which].input_lines[6])  |
91               ((!chips[which].input_lines[5]) &
92                 chips[which].input_lines[6])  |
93               (!chips[which].input_lines[7]));
92      bit0 = !(((!state->input_lines[1]) &
93                 state->input_lines[2] &
94                 state->input_lines[4] &
95                 state->input_lines[6])  |
96               ((!state->input_lines[3]) &
97                 state->input_lines[4] &
98                 state->input_lines[6])  |
99               ((!state->input_lines[5]) &
100                 state->input_lines[6])  |
101               (!state->input_lines[7]));
94102
95      bit1 = !(((!chips[which].input_lines[2]) &
96                 chips[which].input_lines[4] &
97                 chips[which].input_lines[5])  |
98               ((!chips[which].input_lines[3]) &
99                 chips[which].input_lines[4] &
100                 chips[which].input_lines[5])  |
101               (!chips[which].input_lines[6])  |
102               (!chips[which].input_lines[7]));
103      bit1 = !(((!state->input_lines[2]) &
104                 state->input_lines[4] &
105                 state->input_lines[5])  |
106               ((!state->input_lines[3]) &
107                 state->input_lines[4] &
108                 state->input_lines[5])  |
109               (!state->input_lines[6])  |
110               (!state->input_lines[7]));
103111
104      bit2 = !((!chips[which].input_lines[4])  |
105               (!chips[which].input_lines[5])  |
106               (!chips[which].input_lines[6])  |
107               (!chips[which].input_lines[7]));
112      bit2 = !((!state->input_lines[4])  |
113               (!state->input_lines[5])  |
114               (!state->input_lines[6])  |
115               (!state->input_lines[7]));
108116
109      chips[which].output = (bit2 << 2) | (bit1 << 1) | bit0;
117      state->output = (bit2 << 2) | (bit1 << 1) | bit0;
110118
111      chips[which].output_valid = (chips[which].input_lines[0] &
112                            chips[which].input_lines[1] &
113                            chips[which].input_lines[2] &
114                            chips[which].input_lines[3] &
115                            chips[which].input_lines[4] &
116                            chips[which].input_lines[5] &
117                            chips[which].input_lines[6] &
118                            chips[which].input_lines[7]);
119      state->output_valid = (state->input_lines[0] &
120                            state->input_lines[1] &
121                            state->input_lines[2] &
122                            state->input_lines[3] &
123                            state->input_lines[4] &
124                            state->input_lines[5] &
125                            state->input_lines[6] &
126                            state->input_lines[7]);
119127
120      chips[which].enable_output = !chips[which].output_valid;
128      state->enable_output = !state->output_valid;
121129   }
122130
123131
124132   /* call callback if any of the outputs changed */
125   if (  chips[which].output_cb &&
126      ((chips[which].output        != chips[which].last_output) ||
127        (chips[which].output_valid  != chips[which].last_output_valid) ||
128        (chips[which].enable_output != chips[which].last_enable_output)))
133   if (  state->output_cb &&
134      ((state->output        != state->last_output) ||
135        (state->output_valid  != state->last_output_valid) ||
136        (state->enable_output != state->last_enable_output)))
129137   {
130      chips[which].last_output = chips[which].output;
131      chips[which].last_output_valid = chips[which].output_valid;
132      chips[which].last_enable_output = chips[which].enable_output;
138      state->last_output = state->output;
139      state->last_output_valid = state->output_valid;
140      state->last_enable_output = state->enable_output;
133141
134      chips[which].output_cb(machine);
142      state->output_cb(device);
135143   }
136144}
137145
138146
139void TTL74148_input_line_w(int which, int input_line, int data)
147void ttl74148_input_line_w(const device_config *device, int input_line, int data)
140148{
141   chips[which].input_lines[input_line] = data ? 1 : 0;
149   ttl74148_state *state = get_safe_token(device);
150   state->input_lines[input_line] = data ? 1 : 0;
142151}
143152
144153
145void TTL74148_enable_input_w(int which, int data)
154void ttl74148_enable_input_w(const device_config *device, int data)
146155{
147   chips[which].enable_input = data ? 1 : 0;
156   ttl74148_state *state = get_safe_token(device);
157   state->enable_input = data ? 1 : 0;
148158}
149159
150160
151int TTL74148_output_r(int which)
161int ttl74148_output_r(const device_config *device)
152162{
153   return chips[which].output;
163   ttl74148_state *state = get_safe_token(device);
164   return state->output;
154165}
155166
156167
157int TTL74148_output_valid_r(int which)
168int ttl74148_output_valid_r(const device_config *device)
158169{
159   return chips[which].output_valid;
170   ttl74148_state *state = get_safe_token(device);
171   return state->output_valid;
160172}
161173
162174
163int TTL74148_enable_output_r(int which)
175int ttl74148_enable_output_r(const device_config *device)
164176{
165   return chips[which].enable_output;
177   ttl74148_state *state = get_safe_token(device);
178   return state->enable_output;
166179}
167180
168181
182static DEVICE_START( ttl74148 )
183{
184   ttl74148_config *config = (ttl74148_config *)device->inline_config;
185   ttl74148_state *state = get_safe_token(device);
186    state->output_cb = config->output_cb;
169187
170void TTL74148_config(running_machine *machine, int which, const struct TTL74148_interface *intf)
188    state_save_register_device_item_array(device, 0, state->input_lines);
189    state_save_register_device_item(device, 0, state->enable_input);
190    state_save_register_device_item(device, 0, state->output);
191    state_save_register_device_item(device, 0, state->output_valid);
192    state_save_register_device_item(device, 0, state->enable_output);
193    state_save_register_device_item(device, 0, state->last_output);
194    state_save_register_device_item(device, 0, state->last_output_valid);
195    state_save_register_device_item(device, 0, state->last_enable_output);
196}
197
198
199static DEVICE_RESET( ttl74148 )
171200{
172   if (which >= MAX_TTL74148)
173   {
174      logerror("Only %d 74148's are supported at this time.\n", MAX_TTL74148);
175      return;
176   }
201   ttl74148_state *state = get_safe_token(device);
177202
203    state->enable_input = 1;
204    state->input_lines[0] = 1;
205    state->input_lines[1] = 1;
206    state->input_lines[2] = 1;
207    state->input_lines[3] = 1;
208    state->input_lines[4] = 1;
209    state->input_lines[5] = 1;
210    state->input_lines[6] = 1;
211    state->input_lines[7] = 1;
178212
179    chips[which].output_cb = (intf ? intf->output_cb : 0);
180    chips[which].enable_input = 1;
181    chips[which].input_lines[0] = 1;
182    chips[which].input_lines[1] = 1;
183    chips[which].input_lines[2] = 1;
184    chips[which].input_lines[3] = 1;
185    chips[which].input_lines[4] = 1;
186    chips[which].input_lines[5] = 1;
187    chips[which].input_lines[6] = 1;
188    chips[which].input_lines[7] = 1;
213    state->last_output = -1;
214    state->last_output_valid = -1;
215    state->last_enable_output = -1;
216}
189217
190    chips[which].last_output = -1;
191    chips[which].last_output_valid = -1;
192    chips[which].last_enable_output = -1;
193218
194    state_save_register_item_array(machine, "ttl74148", NULL, which, chips[which].input_lines);
195    state_save_register_item(machine, "ttl74148", NULL, which, chips[which].enable_input);
196    state_save_register_item(machine, "ttl74148", NULL, which, chips[which].output);
197    state_save_register_item(machine, "ttl74148", NULL, which, chips[which].output_valid);
198    state_save_register_item(machine, "ttl74148", NULL, which, chips[which].enable_output);
199    state_save_register_item(machine, "ttl74148", NULL, which, chips[which].last_output);
200    state_save_register_item(machine, "ttl74148", NULL, which, chips[which].last_output_valid);
201    state_save_register_item(machine, "ttl74148", NULL, which, chips[which].last_enable_output);
202}
219static const char DEVTEMPLATE_SOURCE[] = __FILE__;
220
221#define DEVTEMPLATE_ID(p,s)      p##ttl74148##s
222#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET | DT_HAS_INLINE_CONFIG
223#define DEVTEMPLATE_NAME      "74148"
224#define DEVTEMPLATE_FAMILY      "TTL"
225#include "devtempl.h"
src/emu/machine/68681.c
r6740r6741
691691   assert(device != NULL);
692692   assert(device->tag != NULL);
693693
694   duart68681->duart_config = (const duart68681_config *)device->static_config;
695   duart68681->device = device;
696
697   duart68681->channel[0].tx_timer = timer_alloc(device->machine, tx_timer_callback, (void*)device);
698   duart68681->channel[1].tx_timer = timer_alloc(device->machine, tx_timer_callback, (void*)device);
699   duart68681->duart_timer = timer_alloc(device->machine, duart_timer_callback, (void*)device);
700
694701   state_save_register_device_item(device, 0, duart68681->ACR);
695702   state_save_register_device_item(device, 0, duart68681->IMR);
696703   state_save_register_device_item(device, 0, duart68681->ISR);
r6740r6741
739746static DEVICE_RESET(duart68681)
740747{
741748   duart68681_state *duart68681 = get_safe_token(device);
749   emu_timer *save0, *save1;
742750
743   memset(duart68681, 0, sizeof(duart68681_state));
744   duart68681->duart_config = (const duart68681_config *)device->static_config;
745   duart68681->device = device;
751   duart68681->ACR = 0;  /* Interrupt Vector Register */
746752   duart68681->IVR = 0x0f;  /* Interrupt Vector Register */
747   // "reset clears internal registers (SRA, SRB, IMR, ISR, OPR, OPCR) puts OP0-7 in the high state, stops the counter/timer, and puts channels a/b in the inactive state"
748   duart68681->channel[0].SR = 0;
749   duart68681->channel[1].SR = 0;
750753   duart68681->IMR = 0;  /* Interrupt Mask Register */
751754   duart68681->ISR = 0;  /* Interrupt Status Register */
752755   duart68681->OPCR = 0; /* Output Port Conf. Register */
753756   duart68681->OPR = 0;  /* Output Port Register */
757   duart68681->CTR.d = 0;  /* Counter/Timer Preset Value */
758   duart68681->IP_last_state = 0;  /* last state of IP bits */
759   // "reset clears internal registers (SRA, SRB, IMR, ISR, OPR, OPCR) puts OP0-7 in the high state, stops the counter/timer, and puts channels a/b in the inactive state"
760   save0 = duart68681->channel[0].tx_timer;
761   save1 = duart68681->channel[1].tx_timer;
762   memset(duart68681->channel, 0, sizeof(duart68681->channel));
763   duart68681->channel[0].tx_timer = save0;
764   duart68681->channel[1].tx_timer = save1;
765
754766   if (duart68681->duart_config->output_port_write)
755   duart68681->duart_config->output_port_write(duart68681->device, duart68681->OPR ^ 0xff);
767      duart68681->duart_config->output_port_write(duart68681->device, duart68681->OPR ^ 0xff);
756768
757   // allocate timers
758   duart68681->channel[0].tx_timer = timer_alloc(device->machine, tx_timer_callback, (void*)device);
769   // reset timers
759770   timer_adjust_oneshot(duart68681->channel[0].tx_timer, attotime_never, 0);
760
761   duart68681->channel[1].tx_timer = timer_alloc(device->machine, tx_timer_callback, (void*)device);
762771   timer_adjust_oneshot(duart68681->channel[1].tx_timer, attotime_never, 1);
763
764   duart68681->duart_timer = timer_alloc(device->machine, duart_timer_callback, (void*)device);
765772}
766773
767774/*-------------------------------------------------
src/emu/machine/74148.h
r6740r6741
4242#define TTL74148_H
4343
4444
45/* The interface structure */
46struct TTL74148_interface
45typedef struct _ttl74148_config ttl74148_config;
46struct _ttl74148_config
4747{
48   void (*output_cb)(running_machine *machine);
48   void (*output_cb)(const device_config *device);
4949};
5050
5151
52void TTL74148_config(running_machine *machine, int which, const struct TTL74148_interface *intf);
52#define MDRV_74148_ADD(_tag, _output_cb) \
53   MDRV_DEVICE_ADD(_tag, TTL74148, 0) \
54   MDRV_DEVICE_CONFIG_DATAPTR(ttl74148_config, output_cb, _output_cb)
5355
54/* must call TTL74148_update() after setting the inputs */
55void TTL74148_update(running_machine *machine, int which);
5656
57void TTL74148_input_line_w(int which, int input_line, int data);
58void TTL74148_enable_input_w(int which, int data);
59int  TTL74148_output_r(int which);
60int  TTL74148_output_valid_r(int which);
61int  TTL74148_enable_output_r(int which);
57/* must call ttl74148_update() after setting the inputs */
58void ttl74148_update(const device_config *device);
6259
60void ttl74148_input_line_w(const device_config *device, int input_line, int data);
61void ttl74148_enable_input_w(const device_config *device, int data);
62int  ttl74148_output_r(const device_config *device);
63int  ttl74148_output_valid_r(const device_config *device);
64int  ttl74148_enable_output_r(const device_config *device);
65
66/* device get info callback */
67#define TTL74148 DEVICE_GET_INFO_NAME(ttl74148)
68DEVICE_GET_INFO( ttl74148 );
69
6370#endif
src/emu/machine/7474.c
r6740r6741
4141#include "7474.h"
4242
4343
44#define MAX_TTL7474  12
45
46struct TTL7474
44typedef struct _ttl7474_state ttl7474_state;
45struct _ttl7474_state
4746{
4847   /* callback */
49   void (*output_cb)(running_machine *);
48   void (*output_cb)(const device_config *);
5049
5150   /* inputs */
5251   UINT8 clear;         /* pin 1/13 */
r6740r6741
6463   UINT8 last_output_comp;
6564};
6665
67static struct TTL7474 chips[MAX_TTL7474];
66INLINE ttl7474_state *get_safe_token(const device_config *device)
67{
68   assert(device != NULL);
69   assert(device->token != NULL);
70   assert(device->type == TTL7474);
6871
72   return (ttl7474_state *)device->token;
73}
6974
70void TTL7474_update(running_machine *machine, int which)
75
76void ttl7474_update(const device_config *device)
7177{
72   if (!chips[which].preset && chips[which].clear)           /* line 1 in truth table */
78   ttl7474_state *state = get_safe_token(device);
79
80   if (!state->preset && state->clear)           /* line 1 in truth table */
7381   {
74      chips[which].output     = 1;
75      chips[which].output_comp = 0;
82      state->output     = 1;
83      state->output_comp = 0;
7684   }
77   else if (chips[which].preset && !chips[which].clear)     /* line 2 in truth table */
85   else if (state->preset && !state->clear)     /* line 2 in truth table */
7886   {
79      chips[which].output     = 0;
80      chips[which].output_comp = 1;
87      state->output     = 0;
88      state->output_comp = 1;
8189   }
82   else if (!chips[which].preset && !chips[which].clear)     /* line 3 in truth table */
90   else if (!state->preset && !state->clear)     /* line 3 in truth table */
8391   {
84      chips[which].output     = 1;
85      chips[which].output_comp = 1;
92      state->output     = 1;
93      state->output_comp = 1;
8694   }
87   else if (!chips[which].last_clock && chips[which].clock)  /* line 4 in truth table */
95   else if (!state->last_clock && state->clock)  /* line 4 in truth table */
8896   {
89      chips[which].output     =  chips[which].d;
90      chips[which].output_comp = !chips[which].d;
97      state->output     =  state->d;
98      state->output_comp = !state->d;
9199   }
92100
93   chips[which].last_clock = chips[which].clock;
101   state->last_clock = state->clock;
94102
95103
96104   /* call callback if any of the outputs changed */
97   if (  chips[which].output_cb &&
98       ((chips[which].output      != chips[which].last_output) ||
99        (chips[which].output_comp != chips[which].last_output_comp)))
105   if (  state->output_cb &&
106       ((state->output      != state->last_output) ||
107        (state->output_comp != state->last_output_comp)))
100108   {
101      chips[which].last_output = chips[which].output;
102      chips[which].last_output_comp = chips[which].output_comp;
109      state->last_output = state->output;
110      state->last_output_comp = state->output_comp;
103111
104      chips[which].output_cb(machine);
112      state->output_cb(device);
105113   }
106114}
107115
108116
109void TTL7474_clear_w(int which, int data)
117void ttl7474_clear_w(const device_config *device, int data)
110118{
111   chips[which].clear = data ? 1 : 0;
119   ttl7474_state *state = get_safe_token(device);
120   state->clear = data ? 1 : 0;
112121}
113122
114void TTL7474_preset_w(int which, int data)
123void ttl7474_preset_w(const device_config *device, int data)
115124{
116   chips[which].preset = data ? 1 : 0;
125   ttl7474_state *state = get_safe_token(device);
126   state->preset = data ? 1 : 0;
117127}
118128
119void TTL7474_clock_w(int which, int data)
129void ttl7474_clock_w(const device_config *device, int data)
120130{
121   chips[which].clock = data ? 1 : 0;
131   ttl7474_state *state = get_safe_token(device);
132   state->clock = data ? 1 : 0;
122133}
123134
124void TTL7474_d_w(int which, int data)
135void ttl7474_d_w(const device_config *device, int data)
125136{
126   chips[which].d = data ? 1 : 0;
137   ttl7474_state *state = get_safe_token(device);
138   state->d = data ? 1 : 0;
127139}
128140
129141
130int TTL7474_output_r(int which)
142int ttl7474_output_r(const device_config *device)
131143{
132   return chips[which].output;
144   ttl7474_state *state = get_safe_token(device);
145   return state->output;
133146}
134147
135int TTL7474_output_comp_r(int which)
148int ttl7474_output_comp_r(const device_config *device)
136149{
137   return chips[which].output_comp;
150   ttl7474_state *state = get_safe_token(device);
151   return state->output_comp;
138152}
139153
140154
141void TTL7474_config(running_machine *machine, int which, const struct TTL7474_interface *intf)
155static DEVICE_START( ttl7474 )
142156{
143   if (which >= MAX_TTL7474)
144   {
145      logerror("Only %d 7474's are supported at this time.\n", MAX_TTL7474);
146      return;
147   }
157   ttl7474_config *config = (ttl7474_config *)device->inline_config;
158   ttl7474_state *state = get_safe_token(device);
159    state->output_cb = config->output_cb;
148160
161    state_save_register_device_item(device, 0, state->clear);
162    state_save_register_device_item(device, 0, state->preset);
163    state_save_register_device_item(device, 0, state->clock);
164    state_save_register_device_item(device, 0, state->d);
165    state_save_register_device_item(device, 0, state->output);
166    state_save_register_device_item(device, 0, state->output_comp);
167    state_save_register_device_item(device, 0, state->last_clock);
168    state_save_register_device_item(device, 0, state->last_output);
169    state_save_register_device_item(device, 0, state->last_output_comp);
170}
149171
150    chips[which].output_cb = (intf ? intf->output_cb : 0);
151172
173static DEVICE_RESET( ttl7474 )
174{
175   ttl7474_state *state = get_safe_token(device);
176
152177   /* all inputs are open first */
153    chips[which].clear = 1;
154    chips[which].preset = 1;
155    chips[which].clock = 1;
156    chips[which].d = 1;
178    state->clear = 1;
179    state->preset = 1;
180    state->clock = 1;
181    state->d = 1;
157182
158    chips[which].last_clock = 1;
159    chips[which].last_output = -1;
160    chips[which].last_output_comp = -1;
183    state->last_clock = 1;
184    state->last_output = -1;
185    state->last_output_comp = -1;
186}
161187
162    state_save_register_item(machine, "ttl7474", NULL, which, chips[which].clear);
163    state_save_register_item(machine, "ttl7474", NULL, which, chips[which].preset);
164    state_save_register_item(machine, "ttl7474", NULL, which, chips[which].clock);
165    state_save_register_item(machine, "ttl7474", NULL, which, chips[which].d);
166    state_save_register_item(machine, "ttl7474", NULL, which, chips[which].output);
167    state_save_register_item(machine, "ttl7474", NULL, which, chips[which].output_comp);
168    state_save_register_item(machine, "ttl7474", NULL, which, chips[which].last_clock);
169    state_save_register_item(machine, "ttl7474", NULL, which, chips[which].last_output);
170    state_save_register_item(machine, "ttl7474", NULL, which, chips[which].last_output_comp);
171}
188
189static const char DEVTEMPLATE_SOURCE[] = __FILE__;
190
191#define DEVTEMPLATE_ID(p,s)      p##ttl7474##s
192#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET | DT_HAS_INLINE_CONFIG
193#define DEVTEMPLATE_NAME      "7474"
194#define DEVTEMPLATE_FAMILY      "TTL"
195#include "devtempl.h"
src/emu/machine/7474.h
r6740r6741
2525    H   L   X   X | L   H
2626    L   L   X   X | H   H  (Note 1)
2727    H   H  _-   X | D  /D
28    H   H   L   X | Q0 /Q0
28    H   H   L   X | Q0 /Q01
2929    --------------+-------
3030    L   = lo (0)
3131    H   = hi (1)
r6740r6741
4141#define TTL7474_H
4242
4343
44/* The interface structure */
45struct TTL7474_interface
44typedef struct _ttl7474_config ttl7474_config;
45struct _ttl7474_config
4646{
47   void (*output_cb)(running_machine *machine);
47   void (*output_cb)(const device_config *device);
4848};
4949
5050
51void TTL7474_config(running_machine *machine, int which, const struct TTL7474_interface *intf);
51#define MDRV_7474_ADD(_tag, _output_cb) \
52   MDRV_DEVICE_ADD(_tag, TTL7474, 0) \
53   MDRV_DEVICE_CONFIG_DATAPTR(ttl7474_config, output_cb, _output_cb)
5254
55
56
5357/* must call TTL7474_update() after setting the inputs */
54void TTL7474_update(running_machine *machine, int which);
58void ttl7474_update(const device_config *device);
5559
56void TTL7474_clear_w(int which, int data);
57void TTL7474_preset_w(int which, int data);
58void TTL7474_clock_w(int which, int data);
59void TTL7474_d_w(int which, int data);
60int  TTL7474_output_r(int which);
61int  TTL7474_output_comp_r(int which);   /* NOT strictly the same as !TTL7474_output_r() */
60void ttl7474_clear_w(const device_config *device, int data);
61void ttl7474_preset_w(const device_config *device, int data);
62void ttl7474_clock_w(const device_config *device, int data);
63void ttl7474_d_w(const device_config *device, int data);
64int  ttl7474_output_r(const device_config *device);
65int  ttl7474_output_comp_r(const device_config *device);   /* NOT strictly the same as !ttl7474_output_r() */
6266
67/* device get info callback */
68#define TTL7474 DEVICE_GET_INFO_NAME(ttl7474)
69DEVICE_GET_INFO( ttl7474 );
70
6371#endif
src/emu/machine/74153.c
r6740r6741
3737#include "machine/74153.h"
3838
3939
40#define MAX_TTL74153 9
41
42struct TTL74153
40typedef struct _ttl74153_state ttl74153_state;
41struct _ttl74153_state
4342{
44   running_machine *machine;
45
4643   /* callback */
47   void (*output_cb)(running_machine *machine);
44   void (*output_cb)(const device_config *device);
4845
4946   /* inputs */
5047   int a;               /* pin 14 */
r6740r6741
5956   int last_output[2];
6057};
6158
62static struct TTL74153 chips[MAX_TTL74153];
59INLINE ttl74153_state *get_safe_token(const device_config *device)
60{
61   assert(device != NULL);
62   assert(device->token != NULL);
63   assert(device->type == TTL74153);
6364
65   return (ttl74153_state *)device->token;
66}
6467
65void TTL74153_update(int which)
68
69
70void ttl74153_update(const device_config *device)
6671{
72   ttl74153_state *state = get_safe_token(device);
6773   int sel;
6874   int section;
6975
7076
71   sel = (chips[which].b << 1) | chips[which].a;
77   sel = (state->b << 1) | state->a;
7278
7379
7480   /* process both sections */
7581   for (section = 0; section < 2; section++)
7682   {
77      if (chips[which].enable[section])
78         chips[which].output[section] = 0;   // row 1 in truth table
83      if (state->enable[section])
84         state->output[section] = 0;   // row 1 in truth table
7985      else
80         chips[which].output[section] = chips[which].input_lines[section][sel];
86         state->output[section] = state->input_lines[section][sel];
8187   }
8288
8389
8490   /* call callback if either of the outputs changed */
85   if (  chips[which].output_cb &&
86      ((chips[which].output[0] != chips[which].last_output[0]) ||
87       (chips[which].output[1] != chips[which].last_output[1])))
91   if (  state->output_cb &&
92      ((state->output[0] != state->last_output[0]) ||
93       (state->output[1] != state->last_output[1])))
8894   {
89      chips[which].last_output[0] = chips[which].output[0];
90      chips[which].last_output[1] = chips[which].output[1];
95      state->last_output[0] = state->output[0];
96      state->last_output[1] = state->output[1];
9197
92      chips[which].output_cb(chips[which].machine);
98      state->output_cb(device);
9399   }
94100}
95101
96102
97void TTL74153_a_w(int which, int data)
103void ttl74153_a_w(const device_config *device, int data)
98104{
99   chips[which].a = data ? 1 : 0;
105   ttl74153_state *state = get_safe_token(device);
106   state->a = data ? 1 : 0;
100107}
101108
102109
103void TTL74153_b_w(int which, int data)
110void ttl74153_b_w(const device_config *device, int data)
104111{
105   chips[which].b = data ? 1 : 0;
112   ttl74153_state *state = get_safe_token(device);
113   state->b = data ? 1 : 0;
106114}
107115
108116
109void TTL74153_input_line_w(int which, int section, int input_line, int data)
117void ttl74153_input_line_w(const device_config *device, int section, int input_line, int data)
110118{
111   chips[which].input_lines[section][input_line] = data ? 1 : 0;
119   ttl74153_state *state = get_safe_token(device);
120   state->input_lines[section][input_line] = data ? 1 : 0;
112121}
113122
114123
115void TTL74153_enable_w(int which, int section, int data)
124void ttl74153_enable_w(const device_config *device, int section, int data)
116125{
117   chips[which].enable[section] = data ? 1 : 0;
126   ttl74153_state *state = get_safe_token(device);
127   state->enable[section] = data ? 1 : 0;
118128}
119129
120130
121int TTL74153_output_r(int which, int section)
131int ttl74153_output_r(const device_config *device, int section)
122132{
123   return chips[which].output[section];
133   ttl74153_state *state = get_safe_token(device);
134   return state->output[section];
124135}
125136
126137
138static DEVICE_START( ttl74153 )
139{
140   ttl74153_config *config = (ttl74153_config *)device->inline_config;
141   ttl74153_state *state = get_safe_token(device);
142    state->output_cb = config->output_cb;
127143
128void TTL74153_config(running_machine *machine, int which, const struct TTL74153_interface *intf)
144    state_save_register_device_item_array(device, 0, state->enable);
145    state_save_register_device_item_array(device, 0, state->last_output);
146    state_save_register_device_item(device, 0, state->input_lines[0][0]);
147    state_save_register_device_item(device, 0, state->input_lines[0][1]);
148    state_save_register_device_item(device, 0, state->input_lines[0][2]);
149    state_save_register_device_item(device, 0, state->input_lines[0][3]);
150    state_save_register_device_item(device, 0, state->input_lines[1][0]);
151    state_save_register_device_item(device, 0, state->input_lines[1][1]);
152    state_save_register_device_item(device, 0, state->input_lines[1][2]);
153    state_save_register_device_item(device, 0, state->input_lines[1][3]);
154    state_save_register_device_item(device, 0, state->a);
155    state_save_register_device_item(device, 0, state->b);
156}
157
158
159static DEVICE_RESET( ttl74153 )
129160{
130   if (which >= MAX_TTL74153)
131   {
132      logerror("Only %d 74153's are supported at this time.\n", MAX_TTL74153);
133      return;
134   }
161   ttl74153_state *state = get_safe_token(device);
135162
163    state->a = 1;
164    state->b = 1;
165    state->enable[0] = 1;
166    state->enable[1] = 1;
167    state->input_lines[0][0] = 1;
168    state->input_lines[0][1] = 1;
169    state->input_lines[0][2] = 1;
170    state->input_lines[0][3] = 1;
171    state->input_lines[1][0] = 1;
172    state->input_lines[1][1] = 1;
173    state->input_lines[1][2] = 1;
174    state->input_lines[1][3] = 1;
136175
137    chips[which].machine = machine;
138    chips[which].output_cb = (intf ? intf->output_cb : 0);
139    chips[which].a = 1;
140    chips[which].b = 1;
141    chips[which].enable[0] = 1;
142    chips[which].enable[1] = 1;
143    chips[which].input_lines[0][0] = 1;
144    chips[which].input_lines[0][1] = 1;
145    chips[which].input_lines[0][2] = 1;
146    chips[which].input_lines[0][3] = 1;
147    chips[which].input_lines[1][0] = 1;
148    chips[which].input_lines[1][1] = 1;
149    chips[which].input_lines[1][2] = 1;
150    chips[which].input_lines[1][3] = 1;
176    state->last_output[0] = -1;
177    state->last_output[1] = -1;
178}
151179
152    chips[which].last_output[0] = -1;
153    chips[which].last_output[1] = -1;
154180
155    state_save_register_item_array(machine, "ttl74153", NULL, which, chips[which].enable);
156    state_save_register_item_array(machine, "ttl74153", NULL, which, chips[which].last_output);
157    state_save_register_item(machine, "ttl74153", NULL, which, chips[which].input_lines[0][0]);
158    state_save_register_item(machine, "ttl74153", NULL, which, chips[which].input_lines[0][1]);
159    state_save_register_item(machine, "ttl74153", NULL, which, chips[which].input_lines[0][2]);
160    state_save_register_item(machine, "ttl74153", NULL, which, chips[which].input_lines[0][3]);
161    state_save_register_item(machine, "ttl74153", NULL, which, chips[which].input_lines[1][0]);
162    state_save_register_item(machine, "ttl74153", NULL, which, chips[which].input_lines[1][1]);
163    state_save_register_item(machine, "ttl74153", NULL, which, chips[which].input_lines[1][2]);
164    state_save_register_item(machine, "ttl74153", NULL, which, chips[which].input_lines[1][3]);
165    state_save_register_item(machine, "ttl74153", NULL, which, chips[which].a);
166    state_save_register_item(machine, "ttl74153", NULL, which, chips[which].b);
167}
181static const char DEVTEMPLATE_SOURCE[] = __FILE__;
182
183#define DEVTEMPLATE_ID(p,s)      p##ttl74153##s
184#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET | DT_HAS_INLINE_CONFIG
185#define DEVTEMPLATE_NAME      "74153"
186#define DEVTEMPLATE_FAMILY      "TTL"
187#include "devtempl.h"
src/emu/machine/74153.h
r6740r6741
3737#define TTL74153_H
3838
3939
40/* The interface structure */
41struct TTL74153_interface
40typedef struct _ttl74153_config ttl74153_config;
41struct _ttl74153_config
4242{
43   void (*output_cb)(running_machine *machine);
43   void (*output_cb)(const device_config *device);
4444};
4545
4646
47void TTL74153_config(running_machine *machine, int which, const struct TTL74153_interface *intf);
47#define MDRV_74153_ADD(_tag, _output_cb) \
48   MDRV_DEVICE_ADD(_tag, TTL74153, 0) \
49   MDRV_DEVICE_CONFIG_DATAPTR(ttl74153_config, output_cb, _output_cb)
4850
51
52
4953/* must call TTL74153_update() after setting the inputs */
50void TTL74153_update(int which);
54void ttl74153_update(const device_config *device);
5155
52void TTL74153_a_w(int which, int data);
53void TTL74153_b_w(int which, int data);
54void TTL74153_input_line_w(int which, int section, int input_line, int data);
55void TTL74153_enable_w(int which, int section, int data);
56int TTL74153_output_r(int which, int section);
56void ttl74153_a_w(const device_config *device, int data);
57void ttl74153_b_w(const device_config *device, int data);
58void ttl74153_input_line_w(const device_config *device, int section, int input_line, int data);
59void ttl74153_enable_w(const device_config *device, int section, int data);
60int ttl74153_output_r(const device_config *device, int section);
5761
62/* device get info callback */
63#define TTL74153 DEVICE_GET_INFO_NAME(ttl74153)
64DEVICE_GET_INFO( ttl74153 );
65
5866#endif
src/emu/machine/tmp68301.c
r6740r6741
106106   }
107107}
108108
109MACHINE_RESET( tmp68301 )
109MACHINE_START( tmp68301 )
110110{
111111   int i;
112112   for (i = 0; i < 3; i++)
113113      tmp68301_timer[i] = timer_alloc(machine, tmp68301_timer_callback, NULL);
114}
114115
116MACHINE_RESET( tmp68301 )
117{
118   int i;
119
115120   for (i = 0; i < 3; i++)
116121      tmp68301_IE[i] = 0;
117122
src/emu/machine/tmp68301.h
r6740r6741
22#define TMP68301_H
33
44// Machine init
5MACHINE_START( tmp68301 );
56MACHINE_RESET( tmp68301 );
67
78// Hardware Registers
src/emu/machine/eepromdev.c
r6740r6741
2121   const eeprom_interface *intf;
2222   int serial_count;
2323   UINT8 serial_buffer[SERIAL_BUFFER_LENGTH];
24   UINT8 eeprom_data[MEMORY_SIZE];
25   int eeprom_data_bits;
26   int eeprom_read_address;
27   int eeprom_clock_count;
24   UINT8 data[MEMORY_SIZE];
25   int data_bits;
26   int read_address;
27   int clock_count;
2828   int latch,reset_line,clock_line,sending;
2929   int locked;
3030   int reset_delay;
r6740r6741
130130//  "*10010xxxxxx", /* erase all */
131131};
132132
133static void eeprom_write(eeprom_state *c, int bit)
133static void eeprom_write(eeprom_state *eestate, int bit)
134134{
135135   LOG(("EEPROM write bit %d\n",bit));
136136
137   if (c->serial_count >= SERIAL_BUFFER_LENGTH-1)
137   if (eestate->serial_count >= SERIAL_BUFFER_LENGTH-1)
138138   {
139139      logerror("error: EEPROM serial buffer overflow\n");
140140      return;
141141   }
142142
143   c->serial_buffer[c->serial_count++] = (bit ? '1' : '0');
144   c->serial_buffer[c->serial_count] = 0;   /* nul terminate so we can treat it as a string */
143   eestate->serial_buffer[eestate->serial_count++] = (bit ? '1' : '0');
144   eestate->serial_buffer[eestate->serial_count] = 0;   /* nul terminate so we can treat it as a string */
145145
146   if ( (c->serial_count > c->intf->address_bits) &&
147         eeprom_command_match((char*)(c->serial_buffer),c->intf->cmd_read,strlen((char*)(c->serial_buffer))-c->intf->address_bits) )
146   if ( (eestate->serial_count > eestate->intf->address_bits) &&
147         eeprom_command_match((char*)(eestate->serial_buffer),eestate->intf->cmd_read,strlen((char*)(eestate->serial_buffer))-eestate->intf->address_bits) )
148148   {
149149      int i,address;
150150
151151      address = 0;
152      for (i = c->serial_count-c->intf->address_bits;i < c->serial_count;i++)
152      for (i = eestate->serial_count-eestate->intf->address_bits;i < eestate->serial_count;i++)
153153      {
154154         address <<= 1;
155         if (c->serial_buffer[i] == '1') address |= 1;
155         if (eestate->serial_buffer[i] == '1') address |= 1;
156156      }
157      if (c->intf->data_bits == 16)
158         c->eeprom_data_bits = (c->eeprom_data[2*address+0] << 8) + c->eeprom_data[2*address+1];
157      if (eestate->intf->data_bits == 16)
158         eestate->data_bits = (eestate->data[2*address+0] << 8) + eestate->data[2*address+1];
159159      else
160         c->eeprom_data_bits = c->eeprom_data[address];
161      c->eeprom_read_address = address;
162      c->eeprom_clock_count = 0;
163      c->sending = 1;
164      c->serial_count = 0;
165logerror("EEPROM read %04x from address %02x\n",c->eeprom_data_bits,address);
160         eestate->data_bits = eestate->data[address];
161      eestate->read_address = address;
162      eestate->clock_count = 0;
163      eestate->sending = 1;
164      eestate->serial_count = 0;
165logerror("EEPROM read %04x from address %02x\n",eestate->data_bits,address);
166166   }
167   else if ( (c->serial_count > c->intf->address_bits) &&
168              eeprom_command_match((char*)(c->serial_buffer),c->intf->cmd_erase,strlen((char*)(c->serial_buffer))-c->intf->address_bits) )
167   else if ( (eestate->serial_count > eestate->intf->address_bits) &&
168              eeprom_command_match((char*)(eestate->serial_buffer),eestate->intf->cmd_erase,strlen((char*)(eestate->serial_buffer))-eestate->intf->address_bits) )
169169   {
170170      int i,address;
171171
172172      address = 0;
173      for (i = c->serial_count-c->intf->address_bits;i < c->serial_count;i++)
173      for (i = eestate->serial_count-eestate->intf->address_bits;i < eestate->serial_count;i++)
174174      {
175175         address <<= 1;
176         if (c->serial_buffer[i] == '1') address |= 1;
176         if (eestate->serial_buffer[i] == '1') address |= 1;
177177      }
178178logerror("EEPROM erase address %02x\n",address);
179      if (c->locked == 0)
179      if (eestate->locked == 0)
180180      {
181         if (c->intf->data_bits == 16)
181         if (eestate->intf->data_bits == 16)
182182         {
183            c->eeprom_data[2*address+0] = 0x00;
184            c->eeprom_data[2*address+1] = 0x00;
183            eestate->data[2*address+0] = 0x00;
184            eestate->data[2*address+1] = 0x00;
185185         }
186186         else
187            c->eeprom_data[address] = 0x00;
187            eestate->data[address] = 0x00;
188188      }
189189      else
190190logerror("Error: EEPROM is locked\n");
191      c->serial_count = 0;
191      eestate->serial_count = 0;
192192   }
193   else if ( (c->serial_count > (c->intf->address_bits + c->intf->data_bits)) &&
194              eeprom_command_match((char*)(c->serial_buffer),c->intf->cmd_write,strlen((char*)(c->serial_buffer))-(c->intf->address_bits + c->intf->data_bits)) )
193   else if ( (eestate->serial_count > (eestate->intf->address_bits + eestate->intf->data_bits)) &&
194              eeprom_command_match((char*)(eestate->serial_buffer),eestate->intf->cmd_write,strlen((char*)(eestate->serial_buffer))-(eestate->intf->address_bits + eestate->intf->data_bits)) )
195195   {
196196      int i,address,data;
197197
198198      address = 0;
199      for (i = c->serial_count-c->intf->data_bits-c->intf->address_bits;i < (c->serial_count-c->intf->data_bits);i++)
199      for (i = eestate->serial_count-eestate->intf->data_bits-eestate->intf->address_bits;i < (eestate->serial_count-eestate->intf->data_bits);i++)
200200      {
201201         address <<= 1;
202         if (c->serial_buffer[i] == '1') address |= 1;
202         if (eestate->serial_buffer[i] == '1') address |= 1;
203203      }
204204      data = 0;
205      for (i = c->serial_count-c->intf->data_bits;i < c->serial_count;i++)
205      for (i = eestate->serial_count-eestate->intf->data_bits;i < eestate->serial_count;i++)
206206      {
207207         data <<= 1;
208         if (c->serial_buffer[i] == '1') data |= 1;
208         if (eestate->serial_buffer[i] == '1') data |= 1;
209209      }
210210logerror("EEPROM write %04x to address %02x\n",data,address);
211      if (c->locked == 0)
211      if (eestate->locked == 0)
212212      {
213         if (c->intf->data_bits == 16)
213         if (eestate->intf->data_bits == 16)
214214         {
215            c->eeprom_data[2*address+0] = data >> 8;
216            c->eeprom_data[2*address+1] = data & 0xff;
215            eestate->data[2*address+0] = data >> 8;
216            eestate->data[2*address+1] = data & 0xff;
217217         }
218218         else
219            c->eeprom_data[address] = data;
219            eestate->data[address] = data;
220220      }
221221      else
222222logerror("Error: EEPROM is locked\n");
223      c->serial_count = 0;
223      eestate->serial_count = 0;
224224   }
225   else if ( eeprom_command_match((char*)(c->serial_buffer),c->intf->cmd_lock,strlen((char*)(c->serial_buffer))) )
225   else if ( eeprom_command_match((char*)(eestate->serial_buffer),eestate->intf->cmd_lock,strlen((char*)(eestate->serial_buffer))) )
226226   {
227227logerror("EEPROM lock\n");
228      c->locked = 1;
229      c->serial_count = 0;
228      eestate->locked = 1;
229      eestate->serial_count = 0;
230230   }
231   else if ( eeprom_command_match((char*)(c->serial_buffer),c->intf->cmd_unlock,strlen((char*)(c->serial_buffer))) )
231   else if ( eeprom_command_match((char*)(eestate->serial_buffer),eestate->intf->cmd_unlock,strlen((char*)(eestate->serial_buffer))) )
232232   {
233233logerror("EEPROM unlock\n");
234      c->locked = 0;
235      c->serial_count = 0;
234      eestate->locked = 0;
235      eestate->serial_count = 0;
236236   }
237237}
238238
239static void eeprom_reset(eeprom_state *c)
239static void eeprom_reset(eeprom_state *eestate)
240240{
241   if (c->serial_count)
242      logerror("EEPROM reset, buffer = %s\n",c->serial_buffer);
241   if (eestate->serial_count)
242      logerror("EEPROM reset, buffer = %s\n",eestate->serial_buffer);
243243
244   c->serial_count = 0;
245   c->sending = 0;
246   c->reset_delay = c->intf->reset_delay;   /* delay a little before returning setting data to 1 (needed by wbeachvl) */
244   eestate->serial_count = 0;
245   eestate->sending = 0;
246   eestate->reset_delay = eestate->intf->reset_delay;   /* delay a little before returning setting data to 1 (needed by wbeachvl) */
247247}
248248
249249
250250WRITE_LINE_DEVICE_HANDLER( eepromdev_write_bit )
251251{
252   eeprom_state *c = get_safe_token(device);
252   eeprom_state *eestate = get_safe_token(device);
253253
254254   LOG(("write bit %d\n",state));
255   c->latch = state;
255   eestate->latch = state;
256256}
257257
258258READ_LINE_DEVICE_HANDLER( eepromdev_read_bit )
259259{
260   eeprom_state *c = get_safe_token(device);
260   eeprom_state *eestate = get_safe_token(device);
261261   int res;
262262
263   if (c->sending)
264      res = (c->eeprom_data_bits >> c->intf->data_bits) & 1;
263   if (eestate->sending)
264      res = (eestate->data_bits >> eestate->intf->data_bits) & 1;
265265   else
266266   {
267      if (c->reset_delay > 0)
267      if (eestate->reset_delay > 0)
268268      {
269269         /* this is needed by wbeachvl */
270         c->reset_delay--;
270         eestate->reset_delay--;
271271         res = 0;
272272      }
273273      else
r6740r6741
281281
282282WRITE_LINE_DEVICE_HANDLER( eepromdev_set_cs_line )
283283{
284   eeprom_state *c = get_safe_token(device);
284   eeprom_state *eestate = get_safe_token(device);
285285
286286   LOG(("set reset line %d\n",state));
287   c->reset_line = state;
287   eestate->reset_line = state;
288288
289   if (c->reset_line != CLEAR_LINE)
290      eeprom_reset(c);
289   if (eestate->reset_line != CLEAR_LINE)
290      eeprom_reset(eestate);
291291}
292292
293293WRITE_LINE_DEVICE_HANDLER( eepromdev_set_clock_line )
294294{
295   eeprom_state *c = get_safe_token(device);
295   eeprom_state *eestate = get_safe_token(device);
296296
297297   LOG(("set clock line %d\n",state));
298   if (state == PULSE_LINE || (c->clock_line == CLEAR_LINE && state != CLEAR_LINE))
298   if (state == PULSE_LINE || (eestate->clock_line == CLEAR_LINE && state != CLEAR_LINE))
299299   {
300      if (c->reset_line == CLEAR_LINE)
300      if (eestate->reset_line == CLEAR_LINE)
301301      {
302         if (c->sending)
302         if (eestate->sending)
303303         {
304            if (c->eeprom_clock_count == c->intf->data_bits && c->intf->enable_multi_read)
304            if (eestate->clock_count == eestate->intf->data_bits && eestate->intf->enable_multi_read)
305305            {
306               c->eeprom_read_address = (c->eeprom_read_address + 1) & ((1 << c->intf->address_bits) - 1);
307               if (c->intf->data_bits == 16)
308                  c->eeprom_data_bits = (c->eeprom_data[2*c->eeprom_read_address+0] << 8) + c->eeprom_data[2*c->eeprom_read_address+1];
306               eestate->read_address = (eestate->read_address + 1) & ((1 << eestate->intf->address_bits) - 1);
307               if (eestate->intf->data_bits == 16)
308                  eestate->data_bits = (eestate->data[2*eestate->read_address+0] << 8) + eestate->data[2*eestate->read_address+1];
309309               else
310                  c->eeprom_data_bits = c->eeprom_data[c->eeprom_read_address];
311               c->eeprom_clock_count = 0;
312logerror("EEPROM read %04x from address %02x\n",c->eeprom_data_bits,c->eeprom_read_address);
310                  eestate->data_bits = eestate->data[eestate->read_address];
311               eestate->clock_count = 0;
312logerror("EEPROM read %04x from address %02x\n",eestate->data_bits,eestate->read_address);
313313            }
314            c->eeprom_data_bits = (c->eeprom_data_bits << 1) | 1;
315            c->eeprom_clock_count++;
314            eestate->data_bits = (eestate->data_bits << 1) | 1;
315            eestate->clock_count++;
316316         }
317317         else
318            eeprom_write(c,c->latch);
318            eeprom_write(eestate,eestate->latch);
319319      }
320320   }
321321
322   c->clock_line = state;
322   eestate->clock_line = state;
323323}
324324
325325
326326static void eepromdev_load(const device_config *device, mame_file *f)
327327{
328   eeprom_state *c = get_safe_token(device);
328   eeprom_state *eestate = get_safe_token(device);
329329
330   mame_fread(f, c->eeprom_data, (1 << c->intf->address_bits) * c->intf->data_bits / 8);
330   mame_fread(f, eestate->data, (1 << eestate->intf->address_bits) * eestate->intf->data_bits / 8);
331331}
332332
333333static void eepromdev_save(const device_config *device, mame_file *f)
334334{
335   eeprom_state *c = get_safe_token(device);
335   eeprom_state *eestate = get_safe_token(device);
336336
337   mame_fwrite(f, c->eeprom_data, (1 << c->intf->address_bits) * c->intf->data_bits / 8);
337   mame_fwrite(f, eestate->data, (1 << eestate->intf->address_bits) * eestate->intf->data_bits / 8);
338338}
339339
340340void eepromdev_set_data(const device_config *device, const UINT8 *data, int length)
341341{
342   eeprom_state *c = get_safe_token(device);
342   eeprom_state *eestate = get_safe_token(device);
343343
344   assert(length <= ((1 << c->intf->address_bits) * c->intf->data_bits / 8));
345   memcpy(c->eeprom_data, data, length);
344   assert(length <= ((1 << eestate->intf->address_bits) * eestate->intf->data_bits / 8));
345   memcpy(eestate->data, data, length);
346/* temporary: write data to eeprom.bin when this happens so we capture it
347   for adding to a region */
348{
349   FILE *f = fopen("eeprom.bin", "wb");
350   fwrite(eestate->data, 1, (1 << eestate->intf->address_bits) * eestate->intf->data_bits / 8, f);
351   fclose(f);
346352}
353}
347354
348355void *eepromdev_get_data_pointer(const device_config *device, UINT32 *length, UINT32 *size)
349356{
350   eeprom_state *c = get_safe_token(device);
357   eeprom_state *eestate = get_safe_token(device);
351358
352   if (length != NULL && c->intf != NULL)
353      *length = 1 << c->intf->address_bits;
354   if (size != NULL && c->intf != NULL)
355      *size = c->intf->data_bits / 8;
359   if (length != NULL && eestate->intf != NULL)
360      *length = 1 << eestate->intf->address_bits;
361   if (size != NULL && eestate->intf != NULL)
362      *size = eestate->intf->data_bits / 8;
356363
357   return c->eeprom_data;
364   return eestate->data;
358365}
359366
360367static DEVICE_NVRAM( eeprom )
r6740r6741
373380
374381static DEVICE_START(eeprom)
375382{
376   eeprom_state *c = get_safe_token(device);
383   eeprom_state *eestate = get_safe_token(device);
377384   const eeprom_config *config;
385   UINT8 *region_base;
378386
379387   /* validate some basic stuff */
380388   assert(device != NULL);
r6740r6741
384392
385393   config = (const eeprom_config *)device->inline_config;
386394
387   c->intf = config->pinterface;
395   eestate->intf = config->pinterface;
388396
389   if ((1 << c->intf->address_bits) * c->intf->data_bits / 8 > MEMORY_SIZE)
397   if ((1 << eestate->intf->address_bits) * eestate->intf->data_bits / 8 > MEMORY_SIZE)
390398   {
391399      fatalerror("EEPROM larger than eepromdev.c allows");
392400   }
393401
394   memset(c->eeprom_data, 0xff, (1 << c->intf->address_bits) * c->intf->data_bits / 8);
402   memset(eestate->data, 0xff, (1 << eestate->intf->address_bits) * eestate->intf->data_bits / 8);
395403   if ((config->default_data != NULL) && (config->default_data_size != 0))
396404      eepromdev_set_data(device, config->default_data, config->default_data_size);
397   c->serial_count = 0;
398   c->latch = 0;
399   c->reset_line = ASSERT_LINE;
400   c->clock_line = ASSERT_LINE;
401   c->eeprom_read_address = 0;
402   c->sending = 0;
403   if (c->intf->cmd_unlock) c->locked = 1;
404   else c->locked = 0;
405405
406   state_save_register_device_item_pointer( device, 0, c->eeprom_data, MEMORY_SIZE);
407   state_save_register_device_item_pointer( device, 0, c->serial_buffer, SERIAL_BUFFER_LENGTH);
408   state_save_register_device_item( device, 0, c->clock_line);
409   state_save_register_device_item( device, 0, c->reset_line);
410   state_save_register_device_item( device, 0, c->locked);
411   state_save_register_device_item( device, 0, c->serial_count);
412   state_save_register_device_item( device, 0, c->latch);
413   state_save_register_device_item( device, 0, c->reset_delay);
414   state_save_register_device_item( device, 0, c->eeprom_clock_count);
415   state_save_register_device_item( device, 0, c->eeprom_data_bits);
416   state_save_register_device_item( device, 0, c->eeprom_read_address);
406   region_base = memory_region(device->machine, device->tag);
407   if (region_base != NULL)
408   {
409      UINT32 region_length = memory_region_length(device->machine, device->tag);
410      UINT32 region_flags = memory_region_flags(device->machine, device->tag);
411
412      if (region_length != (1 << eestate->intf->address_bits) * eestate->intf->data_bits / 8)
413         fatalerror("eeprom region '%s' wrong size (expected size = 0x%X)", device->tag, (1 << eestate->intf->address_bits) * eestate->intf->data_bits / 8);
414      if (eestate->intf->data_bits == 8 && (region_flags & ROMREGION_WIDTHMASK) != ROMREGION_8BIT)
415         fatalerror("eeprom region '%s' needs to be an 8-bit region", device->tag);
416      if (eestate->intf->data_bits == 16 && ((region_flags & ROMREGION_WIDTHMASK) != ROMREGION_16BIT || (region_flags & ROMREGION_ENDIANMASK) != ROMREGION_BE))
417         fatalerror("eeprom region '%s' needs to be a 16-bit big-endian region (flags=%08x)", device->tag, region_flags);
418      memcpy(eestate->data, region_base, region_length);
419   }
420
421   eestate->serial_count = 0;
422   eestate->latch = 0;
423   eestate->reset_line = ASSERT_LINE;
424   eestate->clock_line = ASSERT_LINE;
425   eestate->read_address = 0;
426   eestate->sending = 0;
427   if (eestate->intf->cmd_unlock) eestate->locked = 1;
428   else eestate->locked = 0;
429
430   state_save_register_device_item_pointer( device, 0, eestate->data, MEMORY_SIZE);
431   state_save_register_device_item_pointer( device, 0, eestate->serial_buffer, SERIAL_BUFFER_LENGTH);
432   state_save_register_device_item( device, 0, eestate->clock_line);
433   state_save_register_device_item( device, 0, eestate->reset_line);
434   state_save_register_device_item( device, 0, eestate->locked);
435   state_save_register_device_item( device, 0, eestate->serial_count);
436   state_save_register_device_item( device, 0, eestate->latch);
437   state_save_register_device_item( device, 0, eestate->reset_delay);
438   state_save_register_device_item( device, 0, eestate->clock_count);
439   state_save_register_device_item( device, 0, eestate->data_bits);
440   state_save_register_device_item( device, 0, eestate->read_address);
417441}
418442
419443static DEVICE_RESET(eeprom)
420444{
421445}
422446
423DEVICE_GET_INFO(eeprom)
424{
425   switch (state)
426   {
427      /* --- the following bits of info are returned as 64-bit signed integers --- */
428      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(eeprom_state); break;
429      case DEVINFO_INT_INLINE_CONFIG_BYTES:   info->i = sizeof(eeprom_config); break;
430      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_PERIPHERAL; break;
431447
432      /* --- the following bits of info are returned as pointers to data or functions --- */
433      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(eeprom); break;
434      case DEVINFO_FCT_STOP:               /* nothing */ break;
435      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(eeprom); break;
436      case DEVINFO_FCT_NVRAM:               info->nvram = DEVICE_NVRAM_NAME(eeprom); break;
448static const char DEVTEMPLATE_SOURCE[] = __FILE__;
437449
438      /* --- the following bits of info are returned as NULL-terminated strings --- */
439      case DEVINFO_STR_NAME:               strcpy(info->s, "EEPROM"); break;
440      case DEVINFO_STR_FAMILY:            strcpy(info->s, "EEPROM"); break;
441      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0"); break;
442      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__); break;
443      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
444   }
445}
450#define DEVTEMPLATE_ID(p,s)      p##eeprom##s
451#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET | DT_HAS_NVRAM | DT_HAS_INLINE_CONFIG
452#define DEVTEMPLATE_NAME      "EEPROM"
453#define DEVTEMPLATE_FAMILY      "EEPROM"
454#include "devtempl.h"
src/emu/machine/intelfsh.c
r6740r6741
151151   state_save_register_item( machine, "intelfsh", NULL, chip, c->status );
152152   state_save_register_item( machine, "intelfsh", NULL, chip, c->flash_mode );
153153   state_save_register_item( machine, "intelfsh", NULL, chip, c->flash_master_lock );
154   state_save_register_memory( machine, "intelfsh", NULL, chip, "flash_memory", c->flash_memory, c->bits/8, c->size / (c->bits/8) );
154   state_save_register_memory( machine, "intelfsh", NULL, chip, "flash_memory", c->flash_memory, c->bits/8, c->size / (c->bits/8), __FILE__, __LINE__ );
155155}
156156
157157UINT32 intelflash_read(int chip, UINT32 address)
src/emu/machine/8237dma.c
r6740r6741
641641      devcb_resolve_write8(&i8237->chan[i].out_iow_func, &intf->out_iow_func[i], device);
642642      devcb_resolve_write_line(&i8237->chan[i].out_dack_func, &intf->out_dack_func[i], device);
643643   }
644
645   i8237->timer = timer_alloc(device->machine, dma8237_timerproc, (void *)device);
644646}
645647
646648
r6740r6741
648650   i8237_t   *i8237 = get_safe_token(device);
649651
650652   i8237->status = 0x0F;
651   i8237->timer = timer_alloc(device->machine, dma8237_timerproc, (void *)device);
652653   i8237->eop = 1;
653654   i8237->state = DMA8237_SI;
654655   i8237->last_service_channel = 3;
src/emu/machine/mb14241.c
r0r6741
1/***************************************************************************
2
3    Midway 8080-based black and white hardware
4
5****************************************************************************/
6
7#include "driver.h"
8#include "machine/mb14241.h"
9
10typedef struct _mb14241_state  mb14241_state;
11struct _mb14241_state
12{
13   UINT16 shift_data;   /* 15 bits only */
14   UINT8 shift_count;   /* 3 bits */
15};
16
17/*****************************************************************************
18    INLINE FUNCTIONS
19*****************************************************************************/
20
21INLINE mb14241_state *get_safe_token( const device_config *device )
22{
23   assert(device != NULL);
24   assert(device->token != NULL);
25   assert(device->type == MB14241);
26
27   return (mb14241_state *)device->token;
28}
29
30/*****************************************************************************
31    IMPLEMENTATION
32*****************************************************************************/
33
34WRITE8_DEVICE_HANDLER( mb14241_shift_count_w )
35{
36   mb14241_state *mb14241 = get_safe_token(device);
37   mb14241->shift_count = ~data & 0x07;
38}
39
40WRITE8_DEVICE_HANDLER( mb14241_shift_data_w )
41{
42   mb14241_state *mb14241 = get_safe_token(device);
43   mb14241->shift_data = (mb14241->shift_data >> 8) | ((UINT16)data << 7);
44}
45
46READ8_DEVICE_HANDLER( mb14241_shift_result_r )
47{
48   mb14241_state *mb14241 = get_safe_token(device);
49   return mb14241->shift_data >> mb14241->shift_count;
50}
51
52/*****************************************************************************
53    DEVICE INTERFACE
54*****************************************************************************/
55
56static DEVICE_START( mb14241 )
57{
58   mb14241_state *mb14241 = get_safe_token(device);
59
60   state_save_register_device_item(device, 0, mb14241->shift_data);
61   state_save_register_device_item(device, 0, mb14241->shift_count);
62}
63
64static DEVICE_RESET( mb14241 )
65{
66   mb14241_state *mb14241 = get_safe_token(device);
67
68   mb14241->shift_data = 0;
69   mb14241->shift_count = 0;
70}
71
72static const char DEVTEMPLATE_SOURCE[] = __FILE__;
73
74#define DEVTEMPLATE_ID( p, s )   p##mb14241##s
75#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET
76#define DEVTEMPLATE_NAME      "MB14241"
77#define DEVTEMPLATE_FAMILY      "MB14241 Shifter IC"
78#define DEVTEMPLATE_CLASS      DEVICE_CLASS_VIDEO
79#include "devtempl.h"
src/emu/machine/mb14241.h
r0r6741
1/*****************************************************************************
2
3    MB14241 shifter IC emulation
4
5 *****************************************************************************/
6
7#ifndef __MB14241_H__
8#define __MB14241_H__
9
10#include "devcb.h"
11
12/***************************************************************************
13    FUNCTION PROTOTYPES
14***************************************************************************/
15
16DEVICE_GET_INFO( mb14241 );
17
18
19/***************************************************************************
20    DEVICE CONFIGURATION MACROS
21***************************************************************************/
22
23#define MB14241 DEVICE_GET_INFO_NAME( mb14241 )
24
25#define MDRV_MB14241_ADD(_tag) \
26   MDRV_DEVICE_ADD(_tag, MB14241, 0)
27
28
29/***************************************************************************
30    DEVICE I/O FUNCTIONS
31***************************************************************************/
32
33WRITE8_DEVICE_HANDLER ( mb14241_shift_count_w );
34WRITE8_DEVICE_HANDLER ( mb14241_shift_data_w );
35READ8_DEVICE_HANDLER( mb14241_shift_result_r );
36
37
38#endif /* __MB14241_H__ */
src/emu/machine/ds2404.c
r6740r6741
1717   DS2404_STATE_COPY_SCRATCHPAD      /* Copy Scratchpad command active */
1818} DS2404_STATE;
1919
20typedef struct {
20typedef struct _ds2404_state ds2404_state;
21struct _ds2404_state {
2122   UINT16 address;
2223   UINT16 offset;
2324   UINT16 end_offset;
r6740r6741
2728   UINT8 rtc[5];      /* 40-bit RTC counter */
2829   DS2404_STATE state[8];
2930   int state_ptr;
30} DS2404;
31};
3132
32static DS2404 ds2404;
33INLINE ds2404_state *get_safe_token(const device_config *device)
34{
35   assert(device != NULL);
36   assert(device->token != NULL);
37   assert(device->type == DS2404);
3338
34static void ds2404_rom_cmd(UINT8 cmd)
39   return (ds2404_state *)device->token;
40}
41
42
43static void ds2404_rom_cmd(ds2404_state *state, UINT8 cmd)
3544{
3645   switch(cmd)
3746   {
3847      case 0xcc:      /* Skip ROM */
39         ds2404.state[0] = DS2404_STATE_COMMAND;
40         ds2404.state_ptr = 0;
48         state->state[0] = DS2404_STATE_COMMAND;
49         state->state_ptr = 0;
4150         break;
4251
4352      default:
r6740r6741
4655   }
4756}
4857
49static void ds2404_cmd(UINT8 cmd)
58static void ds2404_cmd(ds2404_state *state, UINT8 cmd)
5059{
5160   switch(cmd)
5261   {
5362      case 0x0f:      /* Write scratchpad */
54         ds2404.state[0] = DS2404_STATE_ADDRESS1;
55         ds2404.state[1] = DS2404_STATE_ADDRESS2;
56         ds2404.state[2] = DS2404_STATE_INIT_COMMAND;
57         ds2404.state[3] = DS2404_STATE_WRITE_SCRATCHPAD;
58         ds2404.state_ptr = 0;
63         state->state[0] = DS2404_STATE_ADDRESS1;
64         state->state[1] = DS2404_STATE_ADDRESS2;
65         state->state[2] = DS2404_STATE_INIT_COMMAND;
66         state->state[3] = DS2404_STATE_WRITE_SCRATCHPAD;
67         state->state_ptr = 0;
5968         break;
6069
6170      case 0x55:      /* Copy scratchpad */
62         ds2404.state[0] = DS2404_STATE_ADDRESS1;
63         ds2404.state[1] = DS2404_STATE_ADDRESS2;
64         ds2404.state[2] = DS2404_STATE_OFFSET;
65         ds2404.state[3] = DS2404_STATE_INIT_COMMAND;
66         ds2404.state[4] = DS2404_STATE_COPY_SCRATCHPAD;
67         ds2404.state_ptr = 0;
71         state->state[0] = DS2404_STATE_ADDRESS1;
72         state->state[1] = DS2404_STATE_ADDRESS2;
73         state->state[2] = DS2404_STATE_OFFSET;
74         state->state[3] = DS2404_STATE_INIT_COMMAND;
75         state->state[4] = DS2404_STATE_COPY_SCRATCHPAD;
76         state->state_ptr = 0;
6877         break;
6978
7079      case 0xf0:      /* Read memory */
71         ds2404.state[0] = DS2404_STATE_ADDRESS1;
72         ds2404.state[1] = DS2404_STATE_ADDRESS2;
73         ds2404.state[2] = DS2404_STATE_INIT_COMMAND;
74         ds2404.state[3] = DS2404_STATE_READ_MEMORY;
75         ds2404.state_ptr = 0;
80         state->state[0] = DS2404_STATE_ADDRESS1;
81         state->state[1] = DS2404_STATE_ADDRESS2;
82         state->state[2] = DS2404_STATE_INIT_COMMAND;
83         state->state[3] = DS2404_STATE_READ_MEMORY;
84         state->state_ptr = 0;
7685         break;
7786
7887      default:
r6740r6741
8190   }
8291}
8392
84static UINT8 ds2404_readmem(void)
93static UINT8 ds2404_readmem(ds2404_state *state)
8594{
86   if( ds2404.address < 0x200 )
95   if( state->address < 0x200 )
8796   {
88      return ds2404.sram[ ds2404.address ];
97      return state->sram[ state->address ];
8998   }
90   else if( ds2404.address >= 0x202 && ds2404.address <= 0x206 )
99   else if( state->address >= 0x202 && state->address <= 0x206 )
91100   {
92      return ds2404.rtc[ ds2404.address - 0x202 ];
101      return state->rtc[ state->address - 0x202 ];
93102   }
94103   return 0;
95104}
96105
97static void ds2404_writemem(UINT8 value)
106static void ds2404_writemem(ds2404_state *state, UINT8 value)
98107{
99   if( ds2404.address < 0x200 )
108   if( state->address < 0x200 )
100109   {
101      ds2404.sram[ ds2404.address ] = value;
110      state->sram[ state->address ] = value;
102111   }
103   else if( ds2404.address >= 0x202 && ds2404.address <= 0x206 )
112   else if( state->address >= 0x202 && state->address <= 0x206 )
104113   {
105      ds2404.rtc[ ds2404.address - 0x202 ] = value;
114      state->rtc[ state->address - 0x202 ] = value;
106115   }
107116}
108117
109WRITE8_HANDLER( DS2404_1W_reset_w )
118WRITE8_DEVICE_HANDLER( ds2404_1w_reset_w )
110119{
111   ds2404.state[0] = DS2404_STATE_IDLE;
112   ds2404.state_ptr = 0;
120   ds2404_state *state = get_safe_token(device);
121   state->state[0] = DS2404_STATE_IDLE;
122   state->state_ptr = 0;
113123}
114124
115WRITE8_HANDLER( DS2404_3W_reset_w )
125WRITE8_DEVICE_HANDLER( ds2404_3w_reset_w )
116126{
117   ds2404.state[0] = DS2404_STATE_COMMAND;
118   ds2404.state_ptr = 0;
127   ds2404_state *state = get_safe_token(device);
128   state->state[0] = DS2404_STATE_COMMAND;
129   state->state_ptr = 0;
119130}
120131
121READ8_HANDLER( DS2404_data_r )
132READ8_DEVICE_HANDLER( ds2404_data_r )
122133{
134   ds2404_state *state = get_safe_token(device);
123135   UINT8 value;
124   switch( ds2404.state[ds2404.state_ptr] )
136   switch( state->state[state->state_ptr] )
125137   {
126138      case DS2404_STATE_IDLE:
127139      case DS2404_STATE_COMMAND:
r6740r6741
132144         break;
133145
134146      case DS2404_STATE_READ_MEMORY:
135         value = ds2404_readmem();
147         value = ds2404_readmem(state);
136148         return value;
137149
138150      case DS2404_STATE_READ_SCRATCHPAD:
139         if( ds2404.offset < 0x20 ) {
140            value = ds2404.ram[ds2404.offset];
141            ds2404.offset++;
151         if( state->offset < 0x20 ) {
152            value = state->ram[state->offset];
153            state->offset++;
142154            return value;
143155         }
144156         break;
r6740r6741
152164   return 0;
153165}
154166
155WRITE8_HANDLER( DS2404_data_w )
167WRITE8_DEVICE_HANDLER( ds2404_data_w )
156168{
169   ds2404_state *state = get_safe_token(device);
157170   int i;
158171
159   switch( ds2404.state[ds2404.state_ptr] )
172   switch( state->state[state->state_ptr] )
160173   {
161174      case DS2404_STATE_IDLE:
162         ds2404_rom_cmd(data & 0xff);
175         ds2404_rom_cmd(state, data & 0xff);
163176         break;
164177
165178      case DS2404_STATE_COMMAND:
166         ds2404_cmd(data & 0xff);
179         ds2404_cmd(state, data & 0xff);
167180         break;
168181
169182      case DS2404_STATE_ADDRESS1:
170         ds2404.a1 = data & 0xff;
171         ds2404.state_ptr++;
183         state->a1 = data & 0xff;
184         state->state_ptr++;
172185         break;
173186
174187      case DS2404_STATE_ADDRESS2:
175         ds2404.a2 = data & 0xff;
176         ds2404.state_ptr++;
188         state->a2 = data & 0xff;
189         state->state_ptr++;
177190         break;
178191
179192      case DS2404_STATE_OFFSET:
180         ds2404.end_offset = data & 0xff;
181         ds2404.state_ptr++;
193         state->end_offset = data & 0xff;
194         state->state_ptr++;
182195         break;
183196
184197      case DS2404_STATE_INIT_COMMAND:
r6740r6741
191204         break;
192205
193206      case DS2404_STATE_WRITE_SCRATCHPAD:
194         if( ds2404.offset < 0x20 ) {
195            ds2404.ram[ds2404.offset] = data & 0xff;
196            ds2404.offset++;
207         if( state->offset < 0x20 ) {
208            state->ram[state->offset] = data & 0xff;
209            state->offset++;
197210         } else {
198211            /* Set OF flag */
199212         }
r6740r6741
203216         break;
204217   }
205218
206   if( ds2404.state[ds2404.state_ptr] == DS2404_STATE_INIT_COMMAND ) {
207      switch( ds2404.state[ds2404.state_ptr+1] )
219   if( state->state[state->state_ptr] == DS2404_STATE_INIT_COMMAND ) {
220      switch( state->state[state->state_ptr+1] )
208221      {
209222         case DS2404_STATE_IDLE:
210223         case DS2404_STATE_COMMAND:
r6740r6741
215228            break;
216229
217230         case DS2404_STATE_READ_MEMORY:
218            ds2404.address = (ds2404.a2 << 8) | ds2404.a1;
219            ds2404.address -= 1;
231            state->address = (state->a2 << 8) | state->a1;
232            state->address -= 1;
220233            break;
221234
222235         case DS2404_STATE_WRITE_SCRATCHPAD:
223            ds2404.address = (ds2404.a2 << 8) | ds2404.a1;
224            ds2404.offset = ds2404.address & 0x1f;
236            state->address = (state->a2 << 8) | state->a1;
237            state->offset = state->address & 0x1f;
225238            break;
226239
227240         case DS2404_STATE_READ_SCRATCHPAD:
228            ds2404.address = (ds2404.a2 << 8) | ds2404.a1;
229            ds2404.offset = ds2404.address & 0x1f;
241            state->address = (state->a2 << 8) | state->a1;
242            state->offset = state->address & 0x1f;
230243            break;
231244
232245         case DS2404_STATE_COPY_SCRATCHPAD:
233            ds2404.address = (ds2404.a2 << 8) | ds2404.a1;
246            state->address = (state->a2 << 8) | state->a1;
234247
235            for( i=0; i <= ds2404.end_offset; i++ ) {
236               ds2404_writemem( ds2404.ram[i] );
237               ds2404.address++;
248            for( i=0; i <= state->end_offset; i++ ) {
249               ds2404_writemem( state, state->ram[i] );
250               state->address++;
238251            }
239252            break;
240253      }
241      ds2404.state_ptr++;
254      state->state_ptr++;
242255   }
243256}
244257
245WRITE8_HANDLER( DS2404_clk_w )
258WRITE8_DEVICE_HANDLER( ds2404_clk_w )
246259{
247   switch( ds2404.state[ds2404.state_ptr] )
260   ds2404_state *state = get_safe_token(device);
261   switch( state->state[state->state_ptr] )
248262   {
249263      case DS2404_STATE_IDLE:
250264      case DS2404_STATE_COMMAND:
r6740r6741
255269         break;
256270
257271      case DS2404_STATE_READ_MEMORY:
258         ds2404.address++;
272         state->address++;
259273         break;
260274
261275      case DS2404_STATE_READ_SCRATCHPAD:
r6740r6741
269283   }
270284}
271285
272static TIMER_CALLBACK( DS2404_tick )
286static TIMER_CALLBACK( ds2404_tick )
273287{
288   ds2404_state *state = get_safe_token(ptr);
274289   int i;
275290   for( i = 0; i < 5; i++ )
276291   {
277      ds2404.rtc[ i ]++;
278      if( ds2404.rtc[ i ] != 0 )
292      state->rtc[ i ]++;
293      if( state->rtc[ i ] != 0 )
279294      {
280295         break;
281296      }
282297   }
283298}
284299
285void DS2404_init(running_machine *machine, int ref_year, int ref_month, int ref_day)
300
301static DEVICE_START( ds2404 )
286302{
303   ds2404_config *config = (ds2404_config *)device->inline_config;
304   ds2404_state *state = get_safe_token(device);
305
287306   struct tm ref_tm;
288307   time_t ref_time;
289308   time_t current_time;
290309   emu_timer *timer;
291310
292311   memset( &ref_tm, 0, sizeof( ref_tm ) );
293   ref_tm.tm_year = ref_year - 1900;
294   ref_tm.tm_mon = ref_month - 1;
295   ref_tm.tm_mday = ref_day;
312   ref_tm.tm_year = config->ref_year - 1900;
313   ref_tm.tm_mon = config->ref_month - 1;
314   ref_tm.tm_mday = config->ref_day;
296315
297316   ref_time = mktime( &ref_tm );
298317
299318   time( &current_time );
300319   current_time -= ref_time;
301320
302   ds2404.rtc[ 0 ] = 0x0;
303   ds2404.rtc[ 1 ] = ( current_time >> 0 ) & 0xff;
304   ds2404.rtc[ 2 ] = ( current_time >> 8 ) & 0xff;
305   ds2404.rtc[ 3 ] = ( current_time >> 16 ) & 0xff;
306   ds2404.rtc[ 4 ] = ( current_time >> 24 ) & 0xff;
321   state->rtc[ 0 ] = 0x0;
322   state->rtc[ 1 ] = ( current_time >> 0 ) & 0xff;
323   state->rtc[ 2 ] = ( current_time >> 8 ) & 0xff;
324   state->rtc[ 3 ] = ( current_time >> 16 ) & 0xff;
325   state->rtc[ 4 ] = ( current_time >> 24 ) & 0xff;
307326
308   timer = timer_alloc( machine, DS2404_tick , NULL);
327   timer = timer_alloc( device->machine, ds2404_tick , (void *)device);
309328   timer_adjust_periodic( timer, ATTOTIME_IN_HZ( 256 ), 0, ATTOTIME_IN_HZ( 256 ) );
310329}
311330
312void DS2404_load(mame_file *file)
331
332static DEVICE_RESET( ds2404 )
313333{
314   mame_fread(file, ds2404.sram, 512);
315334}
316335
317void DS2404_save(mame_file *file)
336
337static DEVICE_NVRAM( ds2404 )
318338{
319   mame_fwrite(file, ds2404.sram, 512);
339   ds2404_state *state = get_safe_token(device);
340
341   if (read_or_write)
342      mame_fwrite(file, state->sram, sizeof(state->sram));
343   else if (file)
344      mame_fread(file, state->sram, sizeof(state->sram));
345   else
346      memset(state->sram, 0, sizeof(state->sram));
320347}
348
349
350static const char DEVTEMPLATE_SOURCE[] = __FILE__;
351
352#define DEVTEMPLATE_ID(p,s)      p##ds2404##s
353#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET | DT_HAS_NVRAM | DT_HAS_INLINE_CONFIG
354#define DEVTEMPLATE_NAME      "DS2404"
355#define DEVTEMPLATE_FAMILY      "NVRAM"
356#include "devtempl.h"
src/emu/machine/ds2404.h
r6740r6741
11#ifndef DS2404_H
22#define DS2404_H
33
4void DS2404_init(running_machine *machine, int ref_year, int ref_month, int ref_day);
5void DS2404_load(mame_file *file);
6void DS2404_save(mame_file *file);
4typedef struct _ds2404_config ds2404_config;
5struct _ds2404_config
6{
7   UINT32   ref_year;
8   UINT8   ref_month;
9   UINT8   ref_day;
10};
711
12
13#define MDRV_DS2404_ADD(_tag, _ref_year, _ref_month, _ref_day) \
14   MDRV_DEVICE_ADD(_tag, DS2404, 0) \
15   MDRV_DEVICE_CONFIG_DATA32(ds2404_config, ref_year, _ref_year) \
16   MDRV_DEVICE_CONFIG_DATA32(ds2404_config, ref_month, _ref_month) \
17   MDRV_DEVICE_CONFIG_DATA32(ds2404_config, ref_day, _ref_day)
18
19
820/* 1-wire interface reset */
9WRITE8_HANDLER( DS2404_1W_reset_w );
21WRITE8_DEVICE_HANDLER( ds2404_1w_reset_w );
1022
1123/* 3-wire interface reset  */
12WRITE8_HANDLER( DS2404_3W_reset_w );
24WRITE8_DEVICE_HANDLER( ds2404_3w_reset_w );
1325
14READ8_HANDLER( DS2404_data_r );
15WRITE8_HANDLER( DS2404_data_w );
16WRITE8_HANDLER( DS2404_clk_w );
26READ8_DEVICE_HANDLER( ds2404_data_r );
27WRITE8_DEVICE_HANDLER( ds2404_data_w );
28WRITE8_DEVICE_HANDLER( ds2404_clk_w );
1729
30/* device get info callback */
31#define DS2404 DEVICE_GET_INFO_NAME(ds2404)
32DEVICE_GET_INFO( ds2404 );
33
1834#endif
src/emu/machine/rtc65271.c
r6740r6741
1818#include "driver.h"
1919#include "rtc65271.h"
2020
21static void field_interrupts(void);
21static void field_interrupts(const device_config *device);
2222static TIMER_CALLBACK( rtc_SQW_callback );
2323static TIMER_CALLBACK( rtc_begin_update_callback );
2424static TIMER_CALLBACK( rtc_end_update_callback );
r6740r6741
3030cycle */
3131/*#define UPDATE_CYCLE_DELAY ATTOTIME_IN_USEC(244)*/
3232
33static struct
33typedef struct _rtc65271_state rtc65271_state;
34struct _rtc65271_state
3435{
35   running_machine *machine;
36
3736   /* 64 8-bit registers (10 clock registers, 4 control/status registers, and
3837    50 bytes of user RAM) */
3938   UINT8 regs[64];
40   int cur_reg;
39   UINT8 cur_reg;
4140
4241   /* extended RAM: 4kbytes of battery-backed RAM (in pages of 32 bytes) */
43   UINT8 *xram;
44   int cur_xram_page;
42   UINT8 xram[4096];
43   UINT8 cur_xram_page;
4544
4645   /* update timer: called every second */
4746   emu_timer *update_timer;
4847
4948   /* SQW timer: called every periodic clock half-period */
5049   emu_timer *SQW_timer;
51   int SQW_internal_state;
50   UINT8 SQW_internal_state;
5251
5352   /* callback called when interrupt pin state changes (may be NULL) */
54   void (*interrupt_callback)(running_machine *machine, int state);
55} rtc;
53   void (*interrupt_callback)(const device_config *device, int state);
54};
5655
56INLINE rtc65271_state *get_safe_token(const device_config *device)
57{
58   assert(device != NULL);
59   assert(device->token != NULL);
60   assert(device->type == RTC65271);
61
62   return (rtc65271_state *)device->token;
63}
64
65
5766enum
5867{
5968   reg_second = 0,
r6740r6741
185194/*
186195    load the SRAM and register contents from file
187196*/
188int rtc65271_file_load(running_machine *machine, mame_file *file)
197static int rtc65271_file_load(const device_config *device, mame_file *file)
189198{
199   rtc65271_state *state = get_safe_token(device);
190200   UINT8 buf;
191201
192202
r6740r6741
199209   /* control registers */
200210   if (mame_fread(file, &buf, 1) != 1)
201211      return 1;
202   rtc.regs[reg_A] = buf & (reg_A_DV /*| reg_A_RS*/);
212   state->regs[reg_A] = buf & (reg_A_DV /*| reg_A_RS*/);
203213   if (mame_fread(file, &buf, 1) != 1)
204214      return 1;
205   rtc.regs[reg_B] = buf & (reg_B_SET | reg_B_DM | reg_B_24h | reg_B_DSE);
215   state->regs[reg_B] = buf & (reg_B_SET | reg_B_DM | reg_B_24h | reg_B_DSE);
206216
207217   /* alarm registers */
208   if (mame_fread(file, &rtc.regs[reg_alarm_second], 1) != 1)
218   if (mame_fread(file, &state->regs[reg_alarm_second], 1) != 1)
209219      return 1;
210   if (mame_fread(file, &rtc.regs[reg_alarm_minute], 1) != 1)
220   if (mame_fread(file, &state->regs[reg_alarm_minute], 1) != 1)
211221      return 1;
212   if (mame_fread(file, &rtc.regs[reg_alarm_hour], 1) != 1)
222   if (mame_fread(file, &state->regs[reg_alarm_hour], 1) != 1)
213223      return 1;
214224
215225   /* user RAM */
216   if (mame_fread(file, rtc.regs+14, 50) != 50)
226   if (mame_fread(file, state->regs+14, 50) != 50)
217227      return 1;
218228
219229   /* extended RAM */
220   if (mame_fread(file, rtc.xram, 4096) != 4096)
230   if (mame_fread(file, state->xram, 4096) != 4096)
221231      return 1;
222232
223   rtc.regs[reg_D] |= reg_D_VRT;   /* the data was backed up successfully */
224   /*rtc.dirty = FALSE;*/
233   state->regs[reg_D] |= reg_D_VRT;   /* the data was backed up successfully */
234   /*state->dirty = FALSE;*/
225235
226236   {
227237      mame_system_time systime;
228238
229239      /* get the current date/time from the core */
230      mame_get_current_datetime(machine, &systime);
240      mame_get_current_datetime(device->machine, &systime);
231241
232242      /* set clock registers */
233      rtc.regs[reg_second] = systime.local_time.second;
234      rtc.regs[reg_minute] = systime.local_time.minute;
235      if (rtc.regs[reg_B] & reg_B_24h)
243      state->regs[reg_second] = systime.local_time.second;
244      state->regs[reg_minute] = systime.local_time.minute;
245      if (state->regs[reg_B] & reg_B_24h)
236246         /* 24-hour mode */
237         rtc.regs[reg_hour] = systime.local_time.hour;
247         state->regs[reg_hour] = systime.local_time.hour;
238248      else
239249      {   /* 12-hour mode */
240250         if (systime.local_time.hour >= 12)
241251         {
242            rtc.regs[reg_hour] = 0x80;
252            state->regs[reg_hour] = 0x80;
243253            systime.local_time.hour -= 12;
244254         }
245255         else
246            rtc.regs[reg_hour] = 0;
247         rtc.regs[reg_hour] |= systime.local_time.hour ? systime.local_time.hour : 12;
256            state->regs[reg_hour] = 0;
257         state->regs[reg_hour] |= systime.local_time.hour ? systime.local_time.hour : 12;
248258      }
249      rtc.regs[reg_weekday] = systime.local_time.weekday + 1;
250      rtc.regs[reg_monthday] = systime.local_time.mday;
251      rtc.regs[reg_month] = systime.local_time.month + 1;
252      rtc.regs[reg_year] = systime.local_time.year % 100;
253      if (! (rtc.regs[reg_B] & reg_B_DM))
259      state->regs[reg_weekday] = systime.local_time.weekday + 1;
260      state->regs[reg_monthday] = systime.local_time.mday;
261      state->regs[reg_month] = systime.local_time.month + 1;
262      state->regs[reg_year] = systime.local_time.year % 100;
263      if (! (state->regs[reg_B] & reg_B_DM))
254264      {   /* BCD mode */
255         rtc.regs[reg_second] = binary_to_BCD(rtc.regs[reg_second]);
256         rtc.regs[reg_minute] = binary_to_BCD(rtc.regs[reg_minute]);
257         rtc.regs[reg_hour] = (rtc.regs[reg_hour] & 0x80) | binary_to_BCD(rtc.regs[reg_hour] & 0x7f);
258         /*rtc.regs[reg_weekday] = binary_to_BCD(rtc.regs[reg_weekday]);*/
259         rtc.regs[reg_monthday] = binary_to_BCD(rtc.regs[reg_monthday]);
260         rtc.regs[reg_month] = binary_to_BCD(rtc.regs[reg_month]);
261         rtc.regs[reg_year] = binary_to_BCD(rtc.regs[reg_year]);
265         state->regs[reg_second] = binary_to_BCD(state->regs[reg_second]);
266         state->regs[reg_minute] = binary_to_BCD(state->regs[reg_minute]);
267         state->regs[reg_hour] = (state->regs[reg_hour] & 0x80) | binary_to_BCD(state->regs[reg_hour] & 0x7f);
268         /*state->regs[reg_weekday] = binary_to_BCD(state->regs[reg_weekday]);*/
269         state->regs[reg_monthday] = binary_to_BCD(state->regs[reg_monthday]);
270         state->regs[reg_month] = binary_to_BCD(state->regs[reg_month]);
271         state->regs[reg_year] = binary_to_BCD(state->regs[reg_year]);
262272      }
263273   }
264274
r6740r6741
268278/*
269279    save the SRAM and register contents to file
270280*/
271int rtc65271_file_save(mame_file *file)
281static int rtc65271_file_save(const device_config *device, mame_file *file)
272282{
283   rtc65271_state *state = get_safe_token(device);
273284   UINT8 buf;
274285
275286
r6740r6741
279290      return 1;
280291
281292   /* control registers */
282   buf = rtc.regs[reg_A] & (reg_A_DV | reg_A_RS);
293   buf = state->regs[reg_A] & (reg_A_DV | reg_A_RS);
283294   if (mame_fwrite(file, &buf, 1) != 1)
284295      return 1;
285   buf = rtc.regs[reg_B] & (reg_B_SET | reg_B_DM | reg_B_24h | reg_B_DSE);
296   buf = state->regs[reg_B] & (reg_B_SET | reg_B_DM | reg_B_24h | reg_B_DSE);
286297   if (mame_fwrite(file, &buf, 1) != 1)
287298      return 1;
288299
289300   /* alarm registers */
290   if (mame_fwrite(file, &rtc.regs[reg_alarm_second], 1) != 1)
301   if (mame_fwrite(file, &state->regs[reg_alarm_second], 1) != 1)
291302      return 1;
292   if (mame_fwrite(file, &rtc.regs[reg_alarm_minute], 1) != 1)
303   if (mame_fwrite(file, &state->regs[reg_alarm_minute], 1) != 1)
293304      return 1;
294   if (mame_fwrite(file, &rtc.regs[reg_alarm_hour], 1) != 1)
305   if (mame_fwrite(file, &state->regs[reg_alarm_hour], 1) != 1)
295306      return 1;
296307
297308   /* user RAM */
298   if (mame_fwrite(file, rtc.regs+14, 50) != 50)
309   if (mame_fwrite(file, state->regs+14, 50) != 50)
299310      return 1;
300311
301312   /* extended RAM */
302   if (mame_fwrite(file, rtc.xram, 4096) != 4096)
313   if (mame_fwrite(file, state->xram, 4096) != 4096)
303314      return 1;
304315
305316   return 0;
306317}
307318
308319/*
309    Initialize clock
310
311    xram: pointer to 4kb RAM area
312    interrupt_callback: callback called when interrupt pin state changes (may
313        be NULL)
314*/
315void rtc65271_init(running_machine *machine, UINT8 *xram, void (*interrupt_callback)(running_machine *machine, int state))
316{
317   memset(&rtc, 0, sizeof(rtc));
318
319   rtc.machine = machine;
320   rtc.xram = xram;
321
322   rtc.update_timer = timer_alloc(machine, rtc_begin_update_callback, NULL);
323   timer_adjust_periodic(rtc.update_timer, ATTOTIME_IN_SEC(1), 0, ATTOTIME_IN_SEC(1));
324   rtc.SQW_timer = timer_alloc(machine, rtc_SQW_callback, NULL);
325   rtc.interrupt_callback = interrupt_callback;
326}
327
328/*
329320    Read a byte from clock
330321
331322    xramsel: select RTC register if 0, XRAM if 1
332323    offset: address (A0-A5 pins)
333324*/
334UINT8 rtc65271_r(int xramsel, offs_t offset)
325UINT8 rtc65271_r(const device_config *device, int xramsel, offs_t offset)
335326{
327   rtc65271_state *state = get_safe_token(device);
336328   int reply;
337329
338330   if (xramsel)
339331   {
340332      if (offset & 0x20)
341333         /* XRAM page register */
342         reply = rtc.cur_xram_page;
334         reply = state->cur_xram_page;
343335      else
344336         /* XRAM data */
345         reply = rtc.xram[(offset & 0x1f) + 0x0020*rtc.cur_xram_page];
337         reply = state->xram[(offset & 0x1f) + 0x0020*state->cur_xram_page];
346338   }
347339   else
348340   {
349341      if (offset & 0x01)
350342         /* data register */
351         switch (rtc.cur_reg)
343         switch (state->cur_reg)
352344         {
353345         case reg_C:
354            reply = rtc.regs[rtc.cur_reg];
355            rtc.regs[rtc.cur_reg] = 0;
356            field_interrupts();
346            reply = state->regs[state->cur_reg];
347            state->regs[state->cur_reg] = 0;
348            field_interrupts(device);
357349            break;
358350         case reg_D:
359            reply = rtc.regs[rtc.cur_reg];
360            rtc.regs[rtc.cur_reg] = /*0*/reg_D_VRT;   /* set VRT flag so that the computer does not complain that the battery is low */
351            reply = state->regs[state->cur_reg];
352            state->regs[state->cur_reg] = /*0*/reg_D_VRT;   /* set VRT flag so that the computer does not complain that the battery is low */
361353            break;
362354
363355         default:
364            reply = rtc.regs[rtc.cur_reg];
356            reply = state->regs[state->cur_reg];
365357            break;
366358         }
367359      else
368360         /* indirect address register */
369         reply = rtc.cur_reg;
361         reply = state->cur_reg;
370362   }
371363
372364   return reply;
373365}
374366
375READ8_HANDLER( rtc65271_rtc_r )
367READ8_DEVICE_HANDLER( rtc65271_rtc_r )
376368{
377   return rtc65271_r( 0, offset );
369   return rtc65271_r( device, 0, offset );
378370}
379371
380READ8_HANDLER( rtc65271_xram_r )
372READ8_DEVICE_HANDLER( rtc65271_xram_r )
381373{
382   return rtc65271_r( 1, offset );
374   return rtc65271_r( device, 1, offset );
383375}
384376
385377/*
r6740r6741
388380    xramsel: select RTC register if 0, XRAM if 1
389381    offset: address (A0-A5 pins)
390382*/
391void rtc65271_w(int xramsel, offs_t offset, UINT8 data)
383void rtc65271_w(const device_config *device, int xramsel, offs_t offset, UINT8 data)
392384{
385   rtc65271_state *state = get_safe_token(device);
393386   if (xramsel)
394387   {
395388      if (offset & 0x20)
396389         /* XRAM page register */
397         rtc.cur_xram_page = data & 0x7f;
390         state->cur_xram_page = data & 0x7f;
398391      else
399392         /* XRAM data */
400         rtc.xram[(offset & 0x1f) + 0x0020*rtc.cur_xram_page] = data;
393         state->xram[(offset & 0x1f) + 0x0020*state->cur_xram_page] = data;
401394   }
402395   else
403396   {
404397      if (offset & 0x01)
405398         /* data register */
406         switch (rtc.cur_reg)
399         switch (state->cur_reg)
407400         {
408401         case reg_second:
409402            /* the data sheet says bit 7 is read-only.  (I have no idea of
410403                the reason why it is.) */
411            rtc.regs[reg_second] = data & 0x7f;
404            state->regs[reg_second] = data & 0x7f;
412405            break;
413406
414407         case reg_A:
415            if ((data & reg_A_RS) != (rtc.regs[rtc.cur_reg] & reg_A_RS))
408            if ((data & reg_A_RS) != (state->regs[state->cur_reg] & reg_A_RS))
416409            {
417410               if (data & reg_A_RS)
418411               {
419412                  attotime period = ATTOTIME_IN_HZ(SQW_freq_table[data & reg_A_RS]);
420413                  attotime half_period = attotime_div(period, 2);
421                  attotime elapsed = timer_timeelapsed(rtc.update_timer);
414                  attotime elapsed = timer_timeelapsed(state->update_timer);
422415
423416                  if (attotime_compare(half_period, elapsed) > 0)
424                     timer_adjust_oneshot(rtc.SQW_timer, attotime_sub(half_period, elapsed), 0);
417                     timer_adjust_oneshot(state->SQW_timer, attotime_sub(half_period, elapsed), 0);
425418                  else
426                     timer_adjust_oneshot(rtc.SQW_timer, half_period, 0);
419                     timer_adjust_oneshot(state->SQW_timer, half_period, 0);
427420               }
428421               else
429422               {
430                  rtc.SQW_internal_state = 0;   /* right??? */
423                  state->SQW_internal_state = 0;   /* right??? */
431424
432425                  /* Stop the divider used for SQW and periodic interrupts. */
433                  timer_adjust_oneshot(rtc.SQW_timer, attotime_never, 0);
426                  timer_adjust_oneshot(state->SQW_timer, attotime_never, 0);
434427               }
435428            }
436429            /* The UIP bit is read-only */
437            rtc.regs[reg_A] = (data & ~reg_A_UIP) | (rtc.regs[reg_A] & reg_A_UIP);
430            state->regs[reg_A] = (data & ~reg_A_UIP) | (state->regs[reg_A] & reg_A_UIP);
438431            break;
439432
440433         case reg_B:
441            rtc.regs[rtc.cur_reg] = data;
434            state->regs[state->cur_reg] = data;
442435            if (data & reg_B_SET)
443436            {
444437               /* if we are in SET mode, clear update cycle */
445               rtc.regs[reg_A] &= ~reg_A_UIP;
446               rtc.regs[reg_B] &= ~reg_B_UIE;   /* the data sheet tells this, but I wonder how much sense it makes */
447               field_interrupts();
438               state->regs[reg_A] &= ~reg_A_UIP;
439               state->regs[reg_B] &= ~reg_B_UIE;   /* the data sheet tells this, but I wonder how much sense it makes */
440               field_interrupts(device);
448441            }
449442            break;
450443
r6740r6741
453446            break;
454447
455448         default:
456            rtc.regs[rtc.cur_reg] = data;
449            state->regs[state->cur_reg] = data;
457450            break;
458451         }
459452      else
460453         /* indirect address register */
461         rtc.cur_reg = data & 0x3f;
454         state->cur_reg = data & 0x3f;
462455   }
463456}
464457
465WRITE8_HANDLER( rtc65271_rtc_w )
458WRITE8_DEVICE_HANDLER( rtc65271_rtc_w )
466459{
467   rtc65271_w( 0, offset, data );
460   rtc65271_w( device, 0, offset, data );
468461}
469462
470WRITE8_HANDLER( rtc65271_xram_w )
463WRITE8_DEVICE_HANDLER( rtc65271_xram_w )
471464{
472   rtc65271_w( 1, offset, data );
465   rtc65271_w( device, 1, offset, data );
473466}
474467
475static void field_interrupts(void)
468static void field_interrupts(const device_config *device)
476469{
477   if (rtc.regs[reg_C] & rtc.regs[reg_B] & (reg_C_PF | reg_C_AF | reg_C_UF))
470   rtc65271_state *state = get_safe_token(device);
471
472   if (state->regs[reg_C] & state->regs[reg_B] & (reg_C_PF | reg_C_AF | reg_C_UF))
478473   {
479      rtc.regs[reg_C] |= reg_C_IRQF;
480      if (rtc.interrupt_callback)
481         rtc.interrupt_callback(rtc.machine, 1);
474      state->regs[reg_C] |= reg_C_IRQF;
475      if (state->interrupt_callback)
476         state->interrupt_callback(device, 1);
482477   }
483478   else
484479   {
485      rtc.regs[reg_C] &= ~reg_C_IRQF;
486      if (rtc.interrupt_callback)
487         rtc.interrupt_callback(rtc.machine, 0);
480      state->regs[reg_C] &= ~reg_C_IRQF;
481      if (state->interrupt_callback)
482         state->interrupt_callback(device, 0);
488483   }
489484}
490485
r6740r6741
499494*/
500495static TIMER_CALLBACK( rtc_SQW_callback )
501496{
497   const device_config *device = (const device_config *)ptr;
498   rtc65271_state *state = get_safe_token(device);
502499   attotime half_period;
503500
504   rtc.SQW_internal_state = ! rtc.SQW_internal_state;
505   if (! rtc.SQW_internal_state)
501   state->SQW_internal_state = ! state->SQW_internal_state;
502   if (! state->SQW_internal_state)
506503   {
507504      /* high-to-low??? transition -> interrupt (or should it be low-to-high?) */
508      rtc.regs[reg_C] |= reg_C_PF;
509      field_interrupts();
505      state->regs[reg_C] |= reg_C_PF;
506      field_interrupts(device);
510507   }
511508
512   half_period = attotime_div(ATTOTIME_IN_HZ(SQW_freq_table[rtc.regs[reg_A] & reg_A_RS]), 2);
513   timer_adjust_oneshot(rtc.SQW_timer, half_period, 0);
509   half_period = attotime_div(ATTOTIME_IN_HZ(SQW_freq_table[state->regs[reg_A] & reg_A_RS]), 2);
510   timer_adjust_oneshot(state->SQW_timer, half_period, 0);
514511}
515512
516513/*
r6740r6741
518515*/
519516static TIMER_CALLBACK( rtc_begin_update_callback )
520517{
521   if (((rtc.regs[reg_A] & reg_A_DV) == 0x20) && ! (rtc.regs[reg_B] & reg_B_SET))
518   const device_config *device = (const device_config *)ptr;
519   rtc65271_state *state = get_safe_token(device);
520
521   if (((state->regs[reg_A] & reg_A_DV) == 0x20) && ! (state->regs[reg_B] & reg_B_SET))
522522   {
523      rtc.regs[reg_A] |= reg_A_UIP;
523      state->regs[reg_A] |= reg_A_UIP;
524524
525525      /* schedule end of update cycle */
526      timer_set(machine, UPDATE_CYCLE_TIME, NULL, 0, rtc_end_update_callback);
526      timer_set(device->machine, UPDATE_CYCLE_TIME, (void *)device, 0, rtc_end_update_callback);
527527   }
528528}
529529
r6740r6741
538538      31,28,31, 30,31,30,
539539      31,31,30, 31,30,31
540540   };
541   const device_config *device = (const device_config *)ptr;
542   rtc65271_state *state = get_safe_token(device);
541543   UINT8 (*increment)(UINT8 data);
542544   int c59, c23, c12, c11, c29;
543545
544   if (! (rtc.regs[reg_A] & reg_A_UIP))
546   if (! (state->regs[reg_A] & reg_A_UIP))
545547      /* abort if update cycle has been canceled */
546548      return;
547549
548   if (rtc.regs[reg_B] & reg_B_DM)
550   if (state->regs[reg_B] & reg_B_DM)
549551   {
550552      /* binary mode */
551553      increment = increment_binary;
r6740r6741
567569   }
568570
569571   /* increment second */
570   if (rtc.regs[reg_second] < c59)
571      rtc.regs[reg_second] = (*increment)(rtc.regs[reg_second]);
572   if (state->regs[reg_second] < c59)
573      state->regs[reg_second] = (*increment)(state->regs[reg_second]);
572574   else
573575   {
574      rtc.regs[reg_second] = 0;
576      state->regs[reg_second] = 0;
575577
576578      /* increment minute */
577      if (rtc.regs[reg_minute] < c59)
578         rtc.regs[reg_minute] = (*increment)(rtc.regs[reg_minute]);
579      if (state->regs[reg_minute] < c59)
580         state->regs[reg_minute] = (*increment)(state->regs[reg_minute]);
579581      else
580582      {
581         rtc.regs[reg_minute] = 0;
583         state->regs[reg_minute] = 0;
582584
583585         /* increment hour */
584         if (rtc.regs[reg_B] & reg_B_24h)
586         if (state->regs[reg_B] & reg_B_24h)
585587         {
586588            /* 24 hour mode */
587            if (rtc.regs[reg_hour] < c23)
588               rtc.regs[reg_hour] = (*increment)(rtc.regs[reg_hour]);
589            if (state->regs[reg_hour] < c23)
590               state->regs[reg_hour] = (*increment)(state->regs[reg_hour]);
589591            else
590               rtc.regs[reg_hour] = 0;
592               state->regs[reg_hour] = 0;
591593         }
592594         else
593595         {
594596            /* 12 hour mode */
595            if (rtc.regs[reg_hour] < c12)
597            if (state->regs[reg_hour] < c12)
596598            {
597               if ((rtc.regs[reg_hour] & 0x7f) == c11)
598                  rtc.regs[reg_hour] ^= 0x80;
599               rtc.regs[reg_hour] = ((*increment)(rtc.regs[reg_hour] & 0x7f) & 0x7f)
600                                 | (rtc.regs[reg_hour] & 0x80);
599               if ((state->regs[reg_hour] & 0x7f) == c11)
600                  state->regs[reg_hour] ^= 0x80;
601               state->regs[reg_hour] = ((*increment)(state->regs[reg_hour] & 0x7f) & 0x7f)
602                                 | (state->regs[reg_hour] & 0x80);
601603            }
602604            else
603               rtc.regs[reg_hour] = 1 | (rtc.regs[reg_hour] & 0x80);
605               state->regs[reg_hour] = 1 | (state->regs[reg_hour] & 0x80);
604606         }
605607
606608         /* increment day if needed */
607         if (rtc.regs[reg_hour] == ((rtc.regs[reg_B] & reg_B_24h) ? 0 : c12))
609         if (state->regs[reg_hour] == ((state->regs[reg_B] & reg_B_24h) ? 0 : c12))
608610         {
609611            /* increment day */
610612            int days_in_month;
611613
612            if (rtc.regs[reg_weekday] < 7)
613               rtc.regs[reg_weekday]++;
614            if (state->regs[reg_weekday] < 7)
615               state->regs[reg_weekday]++;
614616            else
615               rtc.regs[reg_weekday] = 1;
617               state->regs[reg_weekday] = 1;
616618
617            if ((rtc.regs[reg_month] != 2) || (rtc.regs[reg_year] & 0x03))
619            if ((state->regs[reg_month] != 2) || (state->regs[reg_year] & 0x03))
618620            {
619               if (rtc.regs[reg_B] & reg_B_DM)
621               if (state->regs[reg_B] & reg_B_DM)
620622               {
621623                  /* binary mode */
622                  days_in_month = days_in_month_table[rtc.regs[reg_month] - 1];
624                  days_in_month = days_in_month_table[state->regs[reg_month] - 1];
623625               }
624626               else
625627               {
626628                  /* BCD mode */
627                  days_in_month = binary_to_BCD(days_in_month_table[BCD_to_binary(rtc.regs[reg_month]) - 1]);
629                  days_in_month = binary_to_BCD(days_in_month_table[BCD_to_binary(state->regs[reg_month]) - 1]);
628630               }
629631            }
630632            else
631633               days_in_month = c29;
632634
633            if (rtc.regs[reg_monthday] < days_in_month)
634               rtc.regs[reg_monthday] = (*increment)(rtc.regs[reg_monthday]);
635            if (state->regs[reg_monthday] < days_in_month)
636               state->regs[reg_monthday] = (*increment)(state->regs[reg_monthday]);
635637            else
636638            {
637639               /* increment month */
638               rtc.regs[reg_monthday] = 1;
640               state->regs[reg_monthday] = 1;
639641
640               if (rtc.regs[reg_month] < c12)
641                  rtc.regs[reg_month] = (*increment)(rtc.regs[reg_month]);
642               if (state->regs[reg_month] < c12)
643                  state->regs[reg_month] = (*increment)(state->regs[reg_month]);
642644               else
643645               {
644646                  /* increment year */
645                  rtc.regs[reg_month] = 1;
647                  state->regs[reg_month] = 1;
646648
647                  if (rtc.regs[reg_B] & reg_B_DM)
649                  if (state->regs[reg_B] & reg_B_DM)
648650                  {
649651                     /* binary mode */
650                     if (rtc.regs[reg_year] < 99)
651                        rtc.regs[reg_year]++;
652                     if (state->regs[reg_year] < 99)
653                        state->regs[reg_year]++;
652654                     else
653                        rtc.regs[reg_year] = 0;
655                        state->regs[reg_year] = 0;
654656                  }
655657                  else
656658                  {
657659                     /* BCD mode */
658                     rtc.regs[reg_year] = increment_BCD(rtc.regs[reg_year]);
660                     state->regs[reg_year] = increment_BCD(state->regs[reg_year]);
659661                  }
660662               }
661663            }
r6740r6741
663665      }
664666   }
665667
666   rtc.regs[reg_A] &= ~reg_A_UIP;
667   rtc.regs[reg_C] |= reg_C_UF;
668   state->regs[reg_A] &= ~reg_A_UIP;
669   state->regs[reg_C] |= reg_C_UF;
668670
669671   /* test for alarm (values in range 0xc0-0xff mean "don't care") */
670   if ((((rtc.regs[reg_alarm_second] & 0xc0) == 0xc0) || (rtc.regs[reg_alarm_second] == rtc.regs[reg_second]))
671         && (((rtc.regs[reg_alarm_minute] & 0xc0) == 0xc0) || (rtc.regs[reg_alarm_minute] == rtc.regs[reg_minute]))
672         && (((rtc.regs[reg_alarm_hour] & 0xc0) == 0xc0) || (rtc.regs[reg_alarm_hour] == rtc.regs[reg_hour])))
673      rtc.regs[reg_C] |= reg_C_AF;
672   if ((((state->regs[reg_alarm_second] & 0xc0) == 0xc0) || (state->regs[reg_alarm_second] == state->regs[reg_second]))
673         && (((state->regs[reg_alarm_minute] & 0xc0) == 0xc0) || (state->regs[reg_alarm_minute] == state->regs[reg_minute]))
674         && (((state->regs[reg_alarm_hour] & 0xc0) == 0xc0) || (state->regs[reg_alarm_hour] == state->regs[reg_hour])))
675      state->regs[reg_C] |= reg_C_AF;
674676
675   field_interrupts();
677   field_interrupts(device);
676678}
679
680/*
681    Initialize clock
682
683    interrupt_callback: callback called when interrupt pin state changes (may
684        be NULL)
685*/
686
687static DEVICE_START( rtc65271 )
688{
689   rtc65271_config *config = (rtc65271_config *)device->inline_config;
690   rtc65271_state *state = get_safe_token(device);
691
692   state->update_timer = timer_alloc(device->machine, rtc_begin_update_callback, (void *)device);
693   timer_adjust_periodic(state->update_timer, ATTOTIME_IN_SEC(1), 0, ATTOTIME_IN_SEC(1));
694   state->SQW_timer = timer_alloc(device->machine, rtc_SQW_callback, (void *)device);
695   state->interrupt_callback = config->interrupt_callback;
696
697   state_save_register_device_item_array(device, 0, state->regs);
698   state_save_register_device_item(device, 0, state->cur_reg);
699   state_save_register_device_item_array(device, 0, state->xram);
700   state_save_register_device_item(device, 0, state->cur_xram_page);
701   state_save_register_device_item(device, 0, state->SQW_internal_state);
702}
703
704
705static DEVICE_NVRAM( rtc65271 )
706{
707   if (read_or_write)
708      rtc65271_file_save(device, file);
709   else if (file)
710      rtc65271_file_load(device, file);
711}
712
713
714static const char DEVTEMPLATE_SOURCE[] = __FILE__;
715
716#define DEVTEMPLATE_ID(p,s)      p##rtc65271##s
717#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_NVRAM | DT_HAS_INLINE_CONFIG
718#define DEVTEMPLATE_NAME      "RTC65271"
719#define DEVTEMPLATE_FAMILY      "RTC"
720#include "devtempl.h"
src/emu/inptport.h
r6740r6741
10411041/* return the config that matches the given tag */
10421042const input_port_config *input_port_by_tag_slow(const input_port_list *portlist, const char *tag);
10431043
1044/* return the config that matches the given tag */
1045const input_port_config *input_port_by_index(const input_port_list *portlist, int index);
1046
10471044/* return the field that matches the given tag and mask */
10481045const input_field_config *input_field_by_tag_and_mask(const input_port_list *portlist, const char *tag, input_port_value mask);
10491046
src/emu/mame.h
r6740r6741
165165   UINT32               nvram_size;
166166   generic_ptr            videoram;         /* videoram */
167167   UINT32               videoram_size;
168   generic_ptr            colorram;         /* color ram */
169   UINT32               colorram_size;
170168   generic_ptr            spriteram;         /* spriteram */
171169   UINT32               spriteram_size;
172170   generic_ptr            spriteram2;         /* secondary spriteram */
src/emu/sound/tms5110.c
r6740r6741
175175   INT32 speech_rom_bitnum;
176176
177177   emu_timer *romclk_timer;
178   UINT8 romclk_timer_started;
178179   UINT8 romclk_state;
179180};
180181
r6740r6741
206207static void tms5110_process(tms5110_state *tms, INT16 *buffer, unsigned int size);
207208static void parse_frame(tms5110_state *tms);
208209static STREAM_UPDATE( tms5110_update );
210static TIMER_CALLBACK( romclk_timer_cb );
209211
210212
211213#define DEBUG_5110   0
r6740r6741
964966   }
965967
966968   tms->state = CTL_STATE_INPUT; /* most probably not defined */
969      tms->romclk_timer = timer_alloc(device->machine, romclk_timer_cb, (void *) device);
967970
968971   register_for_save_states(tms);
969972}
r6740r6741
11391142    stream_update(tms->stream);
11401143
11411144    /* create and start timer if necessary */
1142    if (tms->romclk_timer == NULL)
1145    if (!tms->romclk_timer_started)
11431146    {
1144       tms->romclk_timer = timer_alloc(device->machine, romclk_timer_cb, (void *) device);
1145       timer_adjust_periodic(tms->romclk_timer, ATTOTIME_IN_HZ(device->clock / 40), 0, ATTOTIME_IN_HZ(device->clock / 40));
1146    }
1147       tms->romclk_timer_started = TRUE;
1148         timer_adjust_periodic(tms->romclk_timer, ATTOTIME_IN_HZ(device->clock / 40), 0, ATTOTIME_IN_HZ(device->clock / 40));
1149   }
11471150    return tms->romclk_state;
11481151}
11491152
src/emu/sound/fm2612.c
r6740r6741
17771777         for (i=0; i<13; i++)
17781778            logerror(", [%02i] %4x", i*2, tl_tab[ x*2 /*+1*/ + i*2*TL_RES_LEN ]);
17791779         logerror("\n");
1780      }
17811780   #endif
17821781   }
17831782   /*logerror("FM.C: TL_TAB_LEN = %i elements (%i bytes)\n",TL_TAB_LEN, (int)sizeof(tl_tab));*/
src/emu/sound/disc_inp.c
r6740r6741
174174
175175   double min, max;
176176
177   if (node->custom)
178   {
179      context->port = input_port_by_tag(&node->info->device->machine->portlist, (const char *)node->custom);
180      if (context->port == NULL)
181         fatalerror("DISCRETE_ADJUSTMENT_TAG - NODE_%d has invalid tag", NODE_BLOCKINDEX(node));
182   }
183   else
184      context->port = input_port_by_index(&node->info->device->machine->portlist, DSS_ADJUSTMENT__PORT);
177   context->port = input_port_by_tag(&node->info->device->machine->portlist, (const char *)node->custom);
178   if (context->port == NULL)
179      fatalerror("DISCRETE_ADJUSTMENT - NODE_%d has invalid tag", NODE_BLOCKINDEX(node));
185180
186181   context->lastpval = 0x7fffffff;
187182   context->pmin     = DSS_ADJUSTMENT__PMIN;
src/emu/sound/k056800.c
r0r6741
1/***********************************************************************
2
3    Konami K056800 (MIRAC)
4    Sound interface
5
6
7***********************************************************************/
8
9#include "driver.h"
10#include "sound/k056800.h"
11
12typedef struct _k056800_state k056800_state;
13struct _k056800_state
14{
15   UINT8                host_reg[8];
16   UINT8                sound_reg[8];
17
18   emu_timer            *sound_cpu_timer;
19   UINT8                sound_cpu_irq1_enable;
20   k056800_irq_cb       irq_cb;
21};
22
23/*****************************************************************************
24    INLINE FUNCTIONS
25*****************************************************************************/
26
27INLINE k056800_state *k056800_get_safe_token( const device_config *device )
28{
29   assert(device != NULL);
30   assert(device->token != NULL);
31   assert(device->type == K056800);
32
33   return (k056800_state *)device->token;
34}
35
36INLINE const k056800_interface *k056800_get_interface( const device_config *device )
37{
38   assert(device != NULL);
39   assert((device->type == K056800));
40   return (const k056800_interface *) device->static_config;
41}
42
43/*****************************************************************************
44    DEVICE HANDLERS
45*****************************************************************************/
46
47
48static UINT8 k056800_host_reg_r( const device_config *device, int reg )
49{
50   k056800_state *k056800 = k056800_get_safe_token(device);
51   UINT8 value = k056800->host_reg[reg];
52   if (reg == 2)
53      value &= ~3; // suppress VOLWR busy flags
54
55   return value;
56}
57
58static void k056800_host_reg_w( const device_config *device, int reg, UINT8 data )
59{
60   k056800_state *k056800 = k056800_get_safe_token(device);
61
62   k056800->sound_reg[reg] = data;
63
64   if (reg == 7)
65      k056800->irq_cb(device->machine, 1);
66}
67
68static UINT8 k056800_sound_reg_r( const device_config *device, int reg )
69{
70   k056800_state *k056800 = k056800_get_safe_token(device);
71   return k056800->sound_reg[reg];
72}
73
74static void k056800_sound_reg_w( const device_config *device, int reg, UINT8 data )
75{
76   k056800_state *k056800 = k056800_get_safe_token(device);
77
78   if (reg == 4)
79      k056800->sound_cpu_irq1_enable = data & 0x01;
80
81   k056800->host_reg[reg] = data;
82}
83
84static TIMER_CALLBACK( k056800_sound_cpu_timer_tick )
85{
86   k056800_state *k056800 = (k056800_state *)ptr;
87
88   if (k056800->sound_cpu_irq1_enable)
89      k056800->irq_cb(machine, 0);
90}
91
92READ32_DEVICE_HANDLER( k056800_host_r )
93{
94   UINT32 r = 0;
95
96   if (ACCESSING_BITS_24_31)
97      r |= k056800_host_reg_r(device, (offset * 4) + 0) << 24;
98
99   if (ACCESSING_BITS_16_23)
100      r |= k056800_host_reg_r(device, (offset * 4) + 1) << 16;
101
102   if (ACCESSING_BITS_8_15)
103      r |= k056800_host_reg_r(device, (offset * 4) + 2) << 8;
104
105   if (ACCESSING_BITS_0_7)
106      r |= k056800_host_reg_r(device, (offset * 4) + 3) << 0;
107
108
109   return r;
110}
111
112WRITE32_DEVICE_HANDLER( k056800_host_w )
113{
114   if (ACCESSING_BITS_24_31)
115      k056800_host_reg_w(device, (offset * 4) + 0, (data >> 24) & 0xff);
116
117   if (ACCESSING_BITS_16_23)
118      k056800_host_reg_w(device, (offset * 4) + 1, (data >> 16) & 0xff);
119
120   if (ACCESSING_BITS_8_15)
121      k056800_host_reg_w(device, (offset * 4) + 2, (data >> 8) & 0xff);
122
123   if (ACCESSING_BITS_0_7)
124      k056800_host_reg_w(device, (offset * 4) + 3, (data >> 0) & 0xff);
125
126}
127
128READ16_DEVICE_HANDLER( k056800_sound_r )
129{
130   return k056800_sound_reg_r(device, offset);
131}
132
133WRITE16_DEVICE_HANDLER( k056800_sound_w )
134{
135   k056800_sound_reg_w(device, offset, data);
136}
137
138/*****************************************************************************
139    DEVICE INTERFACE
140*****************************************************************************/
141
142static DEVICE_START( k056800 )
143{
144   k056800_state *k056800 = k056800_get_safe_token(device);
145   const k056800_interface *intf = k056800_get_interface(device);
146   attotime timer_period = attotime_mul(ATTOTIME_IN_HZ(44100), 128);   // roughly 2.9us
147
148   k056800->irq_cb = intf->irq_cb;
149
150   k056800->sound_cpu_timer = timer_alloc(device->machine, k056800_sound_cpu_timer_tick, k056800);
151   timer_adjust_periodic(k056800->sound_cpu_timer, timer_period, 0, timer_period);
152
153   state_save_register_device_item_array(device, 0, k056800->host_reg);
154   state_save_register_device_item_array(device, 0, k056800->sound_reg);
155   state_save_register_device_item(device, 0, k056800->sound_cpu_irq1_enable);
156}
157
158static DEVICE_RESET( k056800 )
159{
160   k056800_state *k056800 = k056800_get_safe_token(device);
161
162   memset(k056800->host_reg, 0, sizeof(k056800->host_reg));
163   memset(k056800->sound_reg, 0, sizeof(k056800->sound_reg));
164
165   k056800->sound_cpu_irq1_enable = 0;
166}
167
168
169static const char DEVTEMPLATE_SOURCE[] = __FILE__;
170
171#define DEVTEMPLATE_ID( p, s )   p##k056800##s
172#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET
173#define DEVTEMPLATE_NAME      "Konami 056800 MIRAC"
174#define DEVTEMPLATE_FAMILY      "Konami custom"
175#include "devtempl.h"
src/emu/sound/k056800.h
r0r6741
1/*********************************************************
2
3    Konami 056800 MIRAC sound interface
4
5*********************************************************/
6
7#ifndef __K056800_H__
8#define __K056800_H__
9
10#include "devcb.h"
11
12
13/***************************************************************************
14    TYPE DEFINITIONS
15***************************************************************************/
16
17typedef void (*k056800_irq_cb)(running_machine *, int);
18
19
20typedef struct _k056800_interface k056800_interface;
21struct _k056800_interface
22{
23   k056800_irq_cb       irq_cb;
24};
25
26
27/***************************************************************************
28    FUNCTION PROTOTYPES
29***************************************************************************/
30
31DEVICE_GET_INFO( k056800 );
32
33
34/***************************************************************************
35    DEVICE CONFIGURATION MACROS
36***************************************************************************/
37
38#define K056800 DEVICE_GET_INFO_NAME( k056800 )
39
40#define MDRV_K056800_ADD(_tag, _interface) \
41   MDRV_DEVICE_ADD(_tag, K056800, 0) \
42   MDRV_DEVICE_CONFIG(_interface)
43
44
45/***************************************************************************
46    DEVICE I/O FUNCTIONS
47***************************************************************************/
48
49READ32_DEVICE_HANDLER( k056800_host_r );
50WRITE32_DEVICE_HANDLER( k056800_host_w );
51READ16_DEVICE_HANDLER( k056800_sound_r );
52WRITE16_DEVICE_HANDLER( k056800_sound_w );
53
54
55#endif /* __K056800_H__ */
56
57
src/emu/sound/discrete.h
r6740r6741
187187 * DISCRETE_SOUND_START(STRUCTURENAME)
188188 * DISCRETE_SOUND_END
189189 *
190 * DISCRETE_ADJUSTMENT(NODE,MIN,MAX,LOGLIN,PORT)
191 * DISCRETE_ADJUSTMENT_TAG(NODE,MIN,MAX,LOGLIN,TAG)
192 * DISCRETE_ADJUSTMENTX(NODE,MIN,MAX,LOGLIN,PORT,PMIN,PMAX)
190 * DISCRETE_ADJUSTMENT(NODE,MIN,MAX,LOGLIN,TAG)
191 * DISCRETE_ADJUSTMENTX(NODE,MIN,MAX,LOGLIN,TAG,PMIN,PMAX)
193192 * DISCRETE_CONSTANT(NODE,CONST0)
194193 * DISCRETE_INPUT_DATA(NODE)
195194 * DISCRETE_INPUTX_DATA(NODE,GAIN,OFFSET,INIT)
r6740r6741
336335 ***********************************************************************
337336 *
338337 * DISCRETE_ADJUSTMENT     - Adjustable constant set by the UI [~] menu.
339 * DISCRETE_ADJUSTMENT_TAG - Same as above but referenced by a tag.
340338 *
341 * Note: DISCRETE_ADJUSTMENT_TAG is prefered over DISCRETE_ADJUSTMENT.
342 *
343339 *                        .----------.
344340 *                        |          |
345341 *                        | ADJUST.. |-------->   Netlist node
r6740r6741
351347 *                         static minimum value the node can take,
352348 *                         static maximum value the node can take,
353349 *                         log/linear scale 0=Linear !0=Logarithmic,
354 *                         input port number of the adjuster)
350 *                         port tag name of the adjuster)
355351 *
356 *     DISCRETE_ADJUSTMENT_TAG(name of node,
357 *                             static minimum value the node can take,
358 *                             static maximum value the node can take,
359 *                             log/linear scale 0=Linear !0=Logarithmic,
360 *                             port tag name of the adjuster)
361 *
362352 *  Note: When using DISC_LOGADJ, the min/max values must be > 0.
363353 *        If they are <=0, they will be forced to 1.
364354 *        Min can be a higher value then max.
r6740r6741
366356 *
367357 *  Example config line
368358 *
369 *     DISCRETE_ADJUSTMENT(NODE_01,0.0,5.0,DISC_LINADJ,0,5)
359 *     DISCRETE_ADJUSTMENT(NODE_01,0.0,5.0,DISC_LINADJ,0,"pot")
370360 *
371361 *  Define an adjustment slider that takes a 0-100 input from input
372 *  port #5, scaling between 0.0 and 5.0. Adjustment scaling is Linear.
362 *  port "pot", scaling between 0.0 and 5.0. Adjustment scaling is Linear.
373363 *
374364 *      DISC_LOGADJ 1.0
375365 *      DISC_LINADJ 0.0
r6740r6741
43854375#define DISCRETE_SOUND_END                                              { NODE_00, DSS_NULL     , 0, { NODE_NC }, { 0 } ,NULL  ,"DISCRETE_SOUND_END" }  };
43864376
43874377/* from disc_inp.c */
4388#define DISCRETE_ADJUSTMENT(NODE,MIN,MAX,LOGLIN,PORT)                   { NODE, DSS_ADJUSTMENT  , 7, { NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { MIN,MAX,LOGLIN,PORT,0   ,100  }, NULL  , "DISCRETE_ADJUSTMENT"  },
4389#define DISCRETE_ADJUSTMENT_TAG(NODE,MIN,MAX,LOGLIN,TAG)                { NODE, DSS_ADJUSTMENT  , 7, { NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { MIN,MAX,LOGLIN,0   ,0   ,100  }, TAG   , "DISCRETE_ADJUSTMENT_TAG" },
4390#define DISCRETE_ADJUSTMENTX(NODE,MIN,MAX,LOGLIN,PORT,PMIN,PMAX)        { NODE, DSS_ADJUSTMENT  , 7, { NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { MIN,MAX,LOGLIN,PORT,PMIN,PMAX }, NULL  , "DISCRETE_ADJUSTMENTX"  },
4378#define DISCRETE_ADJUSTMENT(NODE,MIN,MAX,LOGLIN,TAG)                   { NODE, DSS_ADJUSTMENT  , 7, { NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { MIN,MAX,LOGLIN,0   ,0   ,100  }, TAG   , "DISCRETE_ADJUSTMENT" },
4379#define DISCRETE_ADJUSTMENTX(NODE,MIN,MAX,LOGLIN,TAG,PMIN,PMAX)         { NODE, DSS_ADJUSTMENT  , 7, { NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { MIN,MAX,LOGLIN,0   ,PMIN,PMAX }, TAG   , "DISCRETE_ADJUSTMENTX"  },
43914380#define DISCRETE_CONSTANT(NODE,CONST)                                   { NODE, DSS_CONSTANT    , 1, { NODE_NC }, { CONST } ,NULL  ,"DISCRETE_CONSTANT" },
43924381#define DISCRETE_INPUT_DATA(NODE)                                       { NODE, DSS_INPUT_DATA  , 3, { NODE_NC,NODE_NC,NODE_NC }, { 1,0,0 }, NULL, "DISCRETE_INPUT_DATA" },
43934382#define DISCRETE_INPUTX_DATA(NODE,GAIN,OFFSET,INIT)                     { NODE, DSS_INPUT_DATA  , 3, { NODE_NC,NODE_NC,NODE_NC }, { GAIN,OFFSET,INIT }, NULL, "DISCRETE_INPUTX_DATA" },
src/emu/sound/ics2115.c
r6740r6741
8080static void recalc_irq(ics2115_state *chip)
8181{
8282   int i;
83    int irq = 0;
84   if(chip->irq_en & chip->irq_pend)
83   int irq = 0;
84   if (chip->irq_en & chip->irq_pend)
8585      irq = 1;
86   for(i=0; !irq && i<32; i++)
87      if(chip->voice[i].state & V_DONE)
86   for (i = 0; !irq && i<32; i++)
87      if (chip->voice[i].state & V_DONE)
8888         irq = 1;
89   if(irq != chip->irq_on) {
89   if (irq != chip->irq_on)
90   {
9091      chip->irq_on = irq;
91      if(chip->intf->irq_cb)
92      if (chip->intf->irq_cb)
9293         chip->intf->irq_cb(chip->device, irq ? ASSERT_LINE : CLEAR_LINE);
9394   }
9495}
r6740r6741
103104   memset(outputs[0], 0, samples*sizeof(*outputs[0]));
104105   memset(outputs[1], 0, samples*sizeof(*outputs[0]));
105106
106   for(osc = 0; osc < 32; osc++)
107      if(chip->voice[osc].state & V_ON) {
107   for (osc = 0; osc < 32; osc++)
108      if (chip->voice[osc].state & V_ON)
109      {
108110         UINT32 adr = (chip->voice[osc].addrh << 16) | chip->voice[osc].addrl;
109111         UINT32 end = (chip->voice[osc].endh << 16) | (chip->voice[osc].endl << 8);
110112         UINT32 loop = (chip->voice[osc].strth << 16) | (chip->voice[osc].strtl << 8);
r6740r6741
117119         if (ICS2115LOGERROR) logerror("ICS2115: KEYRUN %02d adr=%08x end=%08x delta=%08x\n",
118120                osc, adr, end, delta);
119121
120         for(i=0; i<samples; i++) {
122         for (i = 0; i < samples; i++)
123         {
121124            INT32 v = chip->rom[badr|(adr >> 12)];
122            if(conf & 1)
125            if (conf & 1)
123126               v = chip->ulaw[v];
124127            else
125128               v = ((INT8)v) << 6;
r6740r6741
128131            outputs[0][i] += v;
129132            outputs[1][i] += v;
130133            adr += delta;
131            if(adr >= end) {
134            if (adr >= end)
135            {
132136               if (ICS2115LOGERROR) logerror("ICS2115: KEYDONE %2d\n", osc);
133137               adr -= (end-loop);
134138               chip->voice[osc].state &= ~V_ON;
r6740r6741
140144         chip->voice[osc].addrh = adr >> 16;
141145         chip->voice[osc].addrl = adr;
142146      }
143   if(rec_irq)
147   if (rec_irq)
144148      recalc_irq(chip);
145149}
146150
147151static void keyon(ics2115_state *chip, int osc)
148152{
149153   if (ICS2115LOGERROR) logerror("ICS2115: KEYON %2d conf:%02x vctl:%02x a:%07x.%03x l:%05x.%x e:%05x.%x v:%03x f:%d\n",
150          osc,
151          chip->voice[chip->osc].conf,
152          chip->voice[chip->osc].vctl,
153          (chip->voice[osc].saddr << 20)|(chip->voice[osc].addrh << 4)|(chip->voice[osc].addrl >> 12),
154          (chip->voice[osc].addrl >> 3) & 0x1ff,
155          (chip->voice[osc].strth << 4)|(chip->voice[osc].strtl >> 4),
156          chip->voice[osc].strtl & 0xf,
157          (chip->voice[osc].endh << 4)|(chip->voice[osc].endl >> 4),
158          chip->voice[osc].endl & 0xf,
159          chip->voice[osc].volacc>>4,
160          (chip->voice[chip->osc].fc*33075+512)/1024);
154         osc,
155         chip->voice[chip->osc].conf,
156         chip->voice[chip->osc].vctl,
157         (chip->voice[osc].saddr << 20)|(chip->voice[osc].addrh << 4)|(chip->voice[osc].addrl >> 12),
158         (chip->voice[osc].addrl >> 3) & 0x1ff,
159         (chip->voice[osc].strth << 4)|(chip->voice[osc].strtl >> 4),
160         chip->voice[osc].strtl & 0xf,
161         (chip->voice[osc].endh << 4)|(chip->voice[osc].endl >> 4),
162         chip->voice[osc].endl & 0xf,
163         chip->voice[osc].volacc>>4,
164         (chip->voice[chip->osc].fc*33075+512)/1024);
161165   chip->voice[osc].state |= V_ON;
162166}
163167
r6740r6741
179183static void recalc_timer(ics2115_state *chip, int timer)
180184{
181185   UINT64 period = 1000000000 * chip->timer[timer].scale*chip->timer[timer].preset / 33868800;
182   if(period)
186   if (period)
183187      period = 1000000000/62.8206;
184   if(period)
188
189   if (period)
185190   {
186191      if (ICS2115LOGERROR) logerror("ICS2115: timer %d freq=%fHz\n", timer, 1.0/(period / 1000000000.0));
187192   }
r6740r6741
190195      if (ICS2115LOGERROR) logerror("ICS2115: timer %d off\n", timer);
191196   }
192197
193   if(chip->timer[timer].period != period) {
198   if (chip->timer[timer].period != period)
199   {
194200      chip->timer[timer].period = period;
195      if(period)
201      if (period)
196202         timer_adjust_periodic(chip->timer[timer].timer, ATTOTIME_IN_NSEC(period), 0, ATTOTIME_IN_NSEC(period));
197203      else
198204         timer_adjust_oneshot(chip->timer[timer].timer, attotime_never, 0);
r6740r6741
204210{
205211   running_machine *machine = chip->device->machine;
206212
207   switch(reg) {
213   switch (reg)
214   {
208215   case 0x00: // [osc] Oscillator Configuration
209      if(msb) {
216      if (msb)
217      {
210218         chip->voice[chip->osc].conf = data;
211219         if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: conf = %02x\n", cpuexec_describe_context(machine), chip->osc,
212220                chip->voice[chip->osc].conf);
r6740r6741
215223
216224   case 0x01: // [osc] Wavesample frequency
217225      // freq = fc*33075/1024 in 32 voices mode, fc*44100/1024 in 24 voices mode
218      if(msb)
226      if (msb)
219227         chip->voice[chip->osc].fc = (chip->voice[chip->osc].fc & 0xff)|(data << 8);
220228      else
221229         chip->voice[chip->osc].fc = (chip->voice[chip->osc].fc & 0xff00)|data;
r6740r6741
224232      break;
225233
226234   case 0x02: // [osc] Wavesample loop start address 19-4
227      if(msb)
235      if (msb)
228236         chip->voice[chip->osc].strth = (chip->voice[chip->osc].strth & 0xff)|(data << 8);
229237      else
230238         chip->voice[chip->osc].strth = (chip->voice[chip->osc].strth & 0xff00)|data;
r6740r6741
233241      break;
234242
235243   case 0x03: // [osc] Wavesample loop start address 3-0.3-0
236      if(msb) {
244      if (msb)
245      {
237246         chip->voice[chip->osc].strtl = data;
238247         if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: strtl = %02x\n", cpuexec_describe_context(machine), chip->osc,
239248                chip->voice[chip->osc].strtl);
r6740r6741
241250      break;
242251
243252   case 0x04: // [osc] Wavesample loop end address 19-4
244      if(msb)
253      if (msb)
245254         chip->voice[chip->osc].endh = (chip->voice[chip->osc].endh & 0xff)|(data << 8);
246255      else
247256         chip->voice[chip->osc].endh = (chip->voice[chip->osc].endh & 0xff00)|data;
r6740r6741
250259      break;
251260
252261   case 0x05: // [osc] Wavesample loop end address 3-0.3-0
253      if(msb) {
262      if (msb)
263      {
254264         chip->voice[chip->osc].endl = data;
255265         if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: endl = %02x\n", cpuexec_describe_context(machine), chip->osc,
256266                chip->voice[chip->osc].endl);
r6740r6741
258268      break;
259269
260270   case 0x07: // [osc] Volume Start
261      if(msb) {
271      if (msb)
272      {
262273         chip->voice[chip->osc].vstart = data;
263274         if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: vstart = %02x\n", cpuexec_describe_context(machine), chip->osc,
264275                chip->voice[chip->osc].vstart);
r6740r6741
266277      break;
267278
268279   case 0x08: // [osc] Volume End
269      if(msb) {
280      if (msb)
281      {
270282         chip->voice[chip->osc].vend = data;
271283         if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: vend = %02x\n", cpuexec_describe_context(machine), chip->osc,
272284                chip->voice[chip->osc].vend);
r6740r6741
274286      break;
275287
276288   case 0x09: // [osc] Volume accumulator
277      if(msb)
289      if (msb)
278290         chip->voice[chip->osc].volacc = (chip->voice[chip->osc].volacc & 0xff)|(data << 8);
279291      else
280292         chip->voice[chip->osc].volacc = (chip->voice[chip->osc].volacc & 0xff00)|data;
r6740r6741
283295      break;
284296
285297   case 0x0a: // [osc] Wavesample address 19-4
286      if(msb)
298      if (msb)
287299         chip->voice[chip->osc].addrh = (chip->voice[chip->osc].addrh & 0xff)|(data << 8);
288300      else
289301         chip->voice[chip->osc].addrh = (chip->voice[chip->osc].addrh & 0xff00)|data;
r6740r6741
292304      break;
293305
294306   case 0x0b: // [osc] Wavesample address 3-0.8-0
295      if(msb)
307      if (msb)
296308         chip->voice[chip->osc].addrl = (chip->voice[chip->osc].addrl & 0xff)|(data << 8);
297309      else
298310         chip->voice[chip->osc].addrl = (chip->voice[chip->osc].addrl & 0xff00)|data;
r6740r6741
302314
303315
304316   case 0x0c: // [osc] Pan
305      if(msb) {
317      if (msb)
318      {
306319         chip->voice[chip->osc].pan = data;
307320         if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: pan = %02x\n", cpuexec_describe_context(machine), chip->osc,
308321                chip->voice[chip->osc].pan);
r6740r6741
310323      break;
311324
312325   case 0x0d: // [osc] Volume Enveloppe Control
313      if(msb) {
326      if (msb)
327      {
314328         chip->voice[chip->osc].vctl = data;
315329         if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: vctl = %02x\n", cpuexec_describe_context(machine), chip->osc,
316330                chip->voice[chip->osc].vctl);
r6740r6741
318332      break;
319333
320334   case 0x10: // [osc] Oscillator Control
321      if(msb) {
335      if (msb)
336      {
322337         chip->voice[chip->osc].ctl = data;
323338         if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: ctl = %02x\n", cpuexec_describe_context(machine), chip->osc,
324339                chip->voice[chip->osc].ctl);
325         if(data == 0)
340         if (data == 0)
326341            keyon(chip, chip->osc);
327342      }
328343      break;
329344
330345   case 0x11: // [osc] Wavesample static address 27-20
331      if(msb) {
346      if (msb)
347      {
332348         chip->voice[chip->osc].saddr = data;
333349         if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: saddr = %02x\n", cpuexec_describe_context(machine), chip->osc,
334350                chip->voice[chip->osc].saddr);
r6740r6741
336352      break;
337353
338354   case 0x40: // Timer 1 Preset
339      if(!msb) {
355      if (!msb)
356      {
340357         chip->timer[0].preset = data;
341358         if (ICS2115LOGERROR) logerror("%s:ICS2115: t1preset = %d\n", cpuexec_describe_context(machine), chip->timer[0].preset);
342359         recalc_timer(chip, 0);
r6740r6741
344361      break;
345362
346363   case 0x41: // Timer 2 Preset
347      if(!msb) {
364      if (!msb)
365      {
348366         chip->timer[1].preset = data;
349367         if (ICS2115LOGERROR) logerror("%s:ICS2115: t2preset = %d\n", cpuexec_describe_context(machine), chip->timer[1].preset);
350368         recalc_timer(chip, 1);
r6740r6741
352370      break;
353371
354372   case 0x42: // Timer 1 Prescaler
355      if(!msb) {
373      if (!msb)
374      {
356375         chip->timer[0].scale = data;
357376         if (ICS2115LOGERROR) logerror("%s:ICS2115: t1scale = %d\n", cpuexec_describe_context(machine), chip->timer[0].scale);
358377         recalc_timer(chip, 0);
r6740r6741
360379      break;
361380
362381   case 0x43: // Timer 2 Prescaler
363      if(!msb) {
382      if (!msb)
383      {
364384         chip->timer[1].scale = data;
365385         if (ICS2115LOGERROR) logerror("%s:ICS2115: t2scale = %d\n", cpuexec_describe_context(machine), chip->timer[1].scale);
366386         recalc_timer(chip, 1);
r6740r6741
368388      break;
369389
370390   case 0x4a: // IRQ Enable
371      if(!msb) {
391      if (!msb)
392      {
372393         chip->irq_en = data;
373394         if (ICS2115LOGERROR) logerror("%s:ICS2115: irq_en = %02x\n", cpuexec_describe_context(machine), chip->irq_en);
374395         recalc_irq(chip);
r6740r6741
376397      break;
377398
378399   case 0x4f: // Oscillator Address being Programmed
379      if(!msb) {
400      if (!msb)
401      {
380402         chip->osc = data & 31;
381403         if (ICS2115LOGERROR) logerror("%s:ICS2115: oscnumber = %d\n", cpuexec_describe_context(machine), chip->osc);
382404      }
r6740r6741
391413{
392414   running_machine *machine = chip->device->machine;
393415
394   switch(reg) {
416   switch (reg)
417   {
395418   case 0x0d: // [osc] Volume Enveloppe Control
396419      if (ICS2115LOGERROR) logerror("%s:ICS2115: %2d: read vctl\n", cpuexec_describe_context(machine), chip->osc);
397420      //      res = chip->voice[chip->osc].vctl << 8;
r6740r6741
402425   case 0x0f:{// [osc] Interrupt source/oscillator
403426      int osc;
404427      UINT8 res = 0xff;
405      for(osc = 0; osc < 32; osc++)
406         if(chip->voice[osc].state & V_DONE) {
428      for (osc = 0; osc < 32; osc++)
429         if (chip->voice[osc].state & V_DONE)
430         {
407431            chip->voice[osc].state &= ~V_DONE;
408432            if (ICS2115LOGERROR) logerror("ICS2115: KEYOFF %2d\n", osc);
409433            recalc_irq(chip);
r6740r6741
452476static DEVICE_START( ics2115 )
453477{
454478   ics2115_state *chip = get_safe_token(device);
455   int i;
479   int i, vv;
456480
457481   chip->device = device;
458482   chip->intf = (const ics2115_interface *)device->static_config;
r6740r6741
462486   chip->ulaw = auto_alloc_array(device->machine, INT16, 256);
463487   chip->stream = stream_create(device, 0, 2, 33075, chip, update);
464488
465   for(i=0; i<256; i++) {
489   for (i = 0; i < 256; i++)
490   {
466491      UINT8 c = ~i;
467492      int v;
468493      v = ((c & 15) << 1) + 33;
469494      v <<= ((c & 0x70) >> 4);
470      if(c & 0x80)
471         v = 33-v;
495      if (c & 0x80)
496         v = 33 - v;
472497      else
473         v = v-33;
498         v = v - 33;
474499      chip->ulaw[i] = v;
475500   }
501
502   state_save_register_device_item(device, 0, chip->timer[0].period);
503   state_save_register_device_item(device, 0, chip->timer[0].scale);
504   state_save_register_device_item(device, 0, chip->timer[0].preset);
505   state_save_register_device_item(device, 0, chip->timer[1].period);
506   state_save_register_device_item(device, 0, chip->timer[1].scale);
507   state_save_register_device_item(device, 0, chip->reg);
508   state_save_register_device_item(device, 0, chip->osc);
509   state_save_register_device_item(device, 0, chip->irq_en);
510   state_save_register_device_item(device, 0, chip->irq_pend);
511   state_save_register_device_item(device, 0, chip->irq_on);
512
513   for (vv = 0; vv < 32; vv++)
514   {
515      state_save_register_device_item(device, vv, chip->voice[vv].fc);
516      state_save_register_device_item(device, vv, chip->voice[vv].addrh);
517      state_save_register_device_item(device, vv, chip->voice[vv].addrl);
518      state_save_register_device_item(device, vv, chip->voice[vv].strth);
519      state_save_register_device_item(device, vv, chip->voice[vv].endh);
520      state_save_register_device_item(device, vv, chip->voice[vv].volacc);
521      state_save_register_device_item(device, vv, chip->voice[vv].strtl);
522      state_save_register_device_item(device, vv, chip->voice[vv].endl);
523      state_save_register_device_item(device, vv, chip->voice[vv].saddr);
524      state_save_register_device_item(device, vv, chip->voice[vv].pan);
525      state_save_register_device_item(device, vv, chip->voice[vv].conf);
526      state_save_register_device_item(device, vv, chip->voice[vv].ctl);
527      state_save_register_device_item(device, vv, chip->voice[vv].vstart);
528      state_save_register_device_item(device, vv, chip->voice[vv].vend);
529      state_save_register_device_item(device, vv, chip->voice[vv].vctl);
530      state_save_register_device_item(device, vv, chip->voice[vv].state);
531   }
476532}
477533
478534READ8_DEVICE_HANDLER( ics2115_r )
479535{
480536   ics2115_state *chip = get_safe_token(device);
481   switch(offset) {
482   case 0: {
537   switch (offset)
538   {
539   case 0:
540      {
483541      UINT8 res = 0;
484      if(chip->irq_on) {
542      if (chip->irq_on)
543      {
485544         int i;
486545         res |= 0x80;
487         if(chip->irq_en & chip->irq_pend & 3)
546         if (chip->irq_en & chip->irq_pend & 3)
488547            res |= 1; // Timer irq
489         for(i=0; i<32; i++)
490            if(chip->voice[i].state & V_DONE) {
548         for (i = 0; i < 32; i++)
549            if (chip->voice[i].state & V_DONE)
550            {
491551               res |= 2;
492552               break;
493553            }
r6740r6741
497557      return res;
498558   }
499559   case 1:
500       return chip->reg;
560      return chip->reg;
501561   case 2:
502562      return ics2115_reg_r(chip, chip->reg);
503563   case 3:
r6740r6741
509569WRITE8_DEVICE_HANDLER( ics2115_w )
510570{
511571   ics2115_state *chip = get_safe_token(device);
512   switch(offset) {
572   switch (offset)
573   {
513574   case 1:
514575      chip->reg = data;
515576      break;
r6740r6741
537598}
538599
539600
540
541
542601/**************************************************************************
543602 * Generic get_info
544603 **************************************************************************/
src/emu/sound/fm.c
r6740r6741
15671567         for (i=0; i<13; i++)
15681568            logerror(", [%02i] %4x", i*2, tl_tab[ x*2 /*+1*/ + i*2*TL_RES_LEN ]);
15691569         logerror("\n");
1570      }
15711570   #endif
15721571   }
15731572   /*logerror("FM.C: TL_TAB_LEN = %i elements (%i bytes)\n",TL_TAB_LEN, (int)sizeof(tl_tab));*/
src/emu/sound/cdp1864.c
r6740r6741
468468   state_save_register_device_item(device, 0, cdp1864->signal);
469469   state_save_register_device_item(device, 0, cdp1864->incr);
470470
471   state_save_register_bitmap(device->machine, "cdp1864", device->tag, 0, "cdp1864->bitmap", cdp1864->bitmap);
471   state_save_register_device_item_bitmap(device, 0, cdp1864->bitmap);
472472}
473473
474474/*-------------------------------------------------
src/emu/sound/sound.mak
r6740r6741
298298SOUNDDEFS += -DHAS_K051649=$(if $(filter K051649,$(SOUNDS)),1,0)
299299SOUNDDEFS += -DHAS_K053260=$(if $(filter K053260,$(SOUNDS)),1,0)
300300SOUNDDEFS += -DHAS_K054539=$(if $(filter K054539,$(SOUNDS)),1,0)
301SOUNDDEFS += -DHAS_K056800=$(if $(filter K056800,$(SOUNDS)),1,0)
301302
302303ifneq ($(filter K005289,$(SOUNDS)),)
303304SOUNDOBJS += $(SOUNDOBJ)/k005289.o
r6740r6741
319320SOUNDOBJS += $(SOUNDOBJ)/k054539.o
320321endif
321322
323ifneq ($(filter K056800,$(SOUNDS)),)
324SOUNDOBJS += $(SOUNDOBJ)/k056800.o
325endif
322326
323327
324328#-------------------------------------------------
src/emu/profiler.c
r6740r6741
115115{
116116   static const profile_string names[] =
117117   {
118      { PROFILER_DRC_COMPILE,      "DRC Compilation" },
118119      { PROFILER_MEMREAD,          "Memory Read" },
119120      { PROFILER_MEMWRITE,         "Memory Write" },
120121      { PROFILER_VIDEO,            "Video Update" },
src/emu/profiler.h
r6740r6741
3636{
3737   PROFILER_CPU_FIRST = 0,
3838   PROFILER_CPU_MAX = PROFILER_CPU_FIRST + 32,
39   PROFILER_DRC_COMPILE,
3940   PROFILER_MEMREAD,
4041   PROFILER_MEMWRITE,
4142   PROFILER_VIDEO,
src/emu/drawgfx.c
r6740r6741
7575***************************************************************************/
7676
7777/*-------------------------------------------------
78    gfx_init - allocate memory for the graphics
79    elements referenced by a machine
80-------------------------------------------------*/
81
82void gfx_init(running_machine *machine)
83{
84   const gfx_decode_entry *gfxdecodeinfo = machine->config->gfxdecodeinfo;
85   int curgfx;
86
87   /* skip if nothing to do */
88   if (gfxdecodeinfo == NULL)
89      return;
90
91   /* loop over all elements */
92   for (curgfx = 0; curgfx < MAX_GFX_ELEMENTS && gfxdecodeinfo[curgfx].gfxlayout != NULL; curgfx++)
93   {
94      const gfx_decode_entry *gfxdecode = &gfxdecodeinfo[curgfx];
95      UINT32 region_length = 8 * memory_region_length(machine, gfxdecode->memory_region);
96      const UINT8 *region_base = memory_region(machine, gfxdecode->memory_region);
97      UINT32 xscale = (gfxdecode->xscale == 0) ? 1 : gfxdecode->xscale;
98      UINT32 yscale = (gfxdecode->yscale == 0) ? 1 : gfxdecode->yscale;
99      UINT32 *extpoffs, extxoffs[MAX_ABS_GFX_SIZE], extyoffs[MAX_ABS_GFX_SIZE];
100      const gfx_layout *gl = gfxdecode->gfxlayout;
101      int israw = (gl->planeoffset[0] == GFX_RAW);
102      int planes = gl->planes;
103      UINT32 width = gl->width;
104      UINT32 height = gl->height;
105      UINT32 total = gl->total;
106      UINT32 charincrement = gl->charincrement;
107      gfx_layout glcopy;
108      int j;
109
110      /* make a copy of the layout */
111      glcopy = *gfxdecode->gfxlayout;
112
113      /* copy the X and Y offsets into temporary arrays */
114      memcpy(extxoffs, glcopy.xoffset, sizeof(glcopy.xoffset));
115      memcpy(extyoffs, glcopy.yoffset, sizeof(glcopy.yoffset));
116
117      /* if there are extended offsets, copy them over top */
118      if (glcopy.extxoffs != NULL)
119         memcpy(extxoffs, glcopy.extxoffs, glcopy.width * sizeof(extxoffs[0]));
120      if (glcopy.extyoffs != NULL)
121         memcpy(extyoffs, glcopy.extyoffs, glcopy.height * sizeof(extyoffs[0]));
122
123      /* always use the extended offsets here */
124      glcopy.extxoffs = extxoffs;
125      glcopy.extyoffs = extyoffs;
126
127      extpoffs = glcopy.planeoffset;
128
129      /* expand X and Y by the scale factors */
130      if (xscale > 1)
131      {
132         width *= xscale;
133         for (j = width - 1; j >= 0; j--)
134            extxoffs[j] = extxoffs[j / xscale];
135      }
136      if (yscale > 1)
137      {
138         height *= yscale;
139         for (j = height - 1; j >= 0; j--)
140            extyoffs[j] = extyoffs[j / yscale];
141      }
142
143      /* if the character count is a region fraction, compute the effective total */
144      if (IS_FRAC(total))
145      {
146         assert(region_length != 0);
147         total = region_length / charincrement * FRAC_NUM(total) / FRAC_DEN(total);
148      }
149
150      /* for non-raw graphics, decode the X and Y offsets */
151      if (!israw)
152      {
153         /* loop over all the planes, converting fractions */
154         for (j = 0; j < planes; j++)
155         {
156            UINT32 value = extpoffs[j];
157            if (IS_FRAC(value))
158            {
159               assert(region_length != 0);
160               extpoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value);
161            }
162         }
163
164         /* loop over all the X/Y offsets, converting fractions */
165         for (j = 0; j < width; j++)
166         {
167            UINT32 value = extxoffs[j];
168            if (IS_FRAC(value))
169            {
170               assert(region_length != 0);
171               extxoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value);
172            }
173         }
174
175         for (j = 0; j < height; j++)
176         {
177            UINT32 value = extyoffs[j];
178            if (IS_FRAC(value))
179            {
180               assert(region_length != 0);
181               extyoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value);
182            }
183         }
184      }
185
186      /* otherwise, just use the line modulo */
187      else
188      {
189         int base = gfxdecode->start;
190         int end = region_length/8;
191         int linemod = gl->yoffset[0];
192         while (total > 0)
193         {
194            int elementbase = base + (total - 1) * charincrement / 8;
195            int lastpixelbase = elementbase + height * linemod / 8 - 1;
196            if (lastpixelbase < end)
197               break;
198            total--;
199         }
200      }
201
202      /* update glcopy */
203      glcopy.width = width;
204      glcopy.height = height;
205      glcopy.total = total;
206
207      /* allocate the graphics */
208      machine->gfx[curgfx] = gfx_element_alloc(machine, &glcopy, (region_base != NULL) ? region_base + gfxdecode->start : NULL, gfxdecode->total_color_codes, gfxdecode->color_codes_start);
209   }
210}
211
212
213
214/*-------------------------------------------------
78215    gfx_element_alloc - allocate a gfx_element structure
79216    based on a given layout
80217-------------------------------------------------*/
r6740r6741
362499}
363500
364501
365/*-------------------------------------------------
366    decodegfx - decode a series of tiles from
367    a particular gfx_element
368-------------------------------------------------*/
369
370void decodegfx(gfx_element *gfx, UINT32 first, UINT32 count)
371{
372   int last = first + count - 1;
373   int c;
374
375   assert(gfx != NULL);
376   assert(gfx->srcdata != NULL);
377   assert(first < gfx->total_elements);
378   assert(last < gfx->total_elements);
379
380   /* if this is raw graphics data, just set the pointer and compute pen usage */
381   if (gfx->flags & GFX_ELEMENT_DONT_FREE)
382   {
383      /* if we got a pointer, set it */
384      gfx->gfxdata = (UINT8 *)gfx->srcdata;
385
386      /* compute pen usage for everything */
387      for (c = first; c <= last; c++)
388         calc_penusage(gfx, c);
389   }
390
391   /* otherwise, we get to manually decode */
392   else
393      for (c = first; c <= last; c++)
394         decodechar(gfx, c, gfx->srcdata);
395}
396
397
398
399502/***************************************************************************
400503    DRAWGFX IMPLEMENTATIONS
401504***************************************************************************/
src/emu/drawgfx.h
r6740r6741
168168
169169/* ----- graphics elements ----- */
170170
171/* allocate memory for the graphics elements referenced by a machine */
172void gfx_init(running_machine *machine);
173
171174/* allocate a gfx_element structure based on a given layout */
172175gfx_element *gfx_element_alloc(running_machine *machine, const gfx_layout *gl, const UINT8 *srcdata, UINT32 total_colors, UINT32 color_base);
173176
src/emu/clifront.c
r6740r6741
9393   { "verifyroms",               "0",        OPTION_COMMAND,    "report romsets that have problems" },
9494   { "verifysamples",            "0",        OPTION_COMMAND,    "report samplesets that have problems" },
9595   { "romident",                 "0",        OPTION_COMMAND,    "compare files with known MAME roms" },
96#ifdef MESS
97   { "listdevices",              "0",        OPTION_COMMAND,    "list available devices" },
98#endif
96   { "listdevices;ld",           "0",        OPTION_COMMAND,    "list available devices" },
9997
10098   { NULL }
10199};
r6740r6741
243241      { CLIOPTION_LISTCLONES,      cli_info_listclones },
244242      { CLIOPTION_LISTBROTHERS,   cli_info_listbrothers },
245243      { CLIOPTION_LISTCRC,      cli_info_listcrc },
246#ifdef MESS
247      { CLIOPTION_LISTDEVICES,   info_listdevices },
248#endif
244      { CLIOPTION_LISTDEVICES,   cli_info_listdevices },
249245      { CLIOPTION_LISTROMS,      cli_info_listroms },
250246      { CLIOPTION_LISTSAMPLES,   cli_info_listsamples },
251247      { CLIOPTION_VERIFYROMS,      info_verifyroms },
r6740r6741
639635
640636
641637/*-------------------------------------------------
638    cli_info_listdevices - output the list of
639    devices referenced by a given game or set of
640    games
641-------------------------------------------------*/
642
643int cli_info_listdevices(core_options *options, const char *gamename)
644{
645   int count = 0;
646   int drvindex;
647
648   /* since we expand the machine driver, we need to set things up */
649   init_resource_tracking();
650
651   /* iterate over drivers */
652   for (drvindex = 0; drivers[drvindex] != NULL; drvindex++)
653      if (mame_strwildcmp(gamename, drivers[drvindex]->name) == 0)
654      {
655         machine_config *config = machine_config_alloc(drivers[drvindex]->machine_config);
656         const device_config *device;
657
658         if (count != 0)
659            printf("\n");
660         printf("Driver %s (%s):\n", drivers[drvindex]->name, drivers[drvindex]->description);
661
662         /* iterate through devices */
663         for (device = config->devicelist.head; device != NULL; device = device->next)
664         {
665            switch (device->devclass)
666            {
667               case DEVICE_CLASS_AUDIO:      printf("  Audio: ");   break;
668               case DEVICE_CLASS_VIDEO:      printf("  Video: ");   break;
669               case DEVICE_CLASS_CPU_CHIP:      printf("    CPU: ");   break;
670               case DEVICE_CLASS_SOUND_CHIP:   printf("  Sound: ");   break;
671               case DEVICE_CLASS_TIMER:      printf("  Timer: ");   break;
672               default:                  printf("  Other: ");   break;
673            }
674            printf("%s ('%s')", device_get_name(device), device->tag);
675            if (device->clock >= 1000000000)
676               printf(" @ %d.%02d GHz\n", device->clock / 1000000000, (device->clock / 10000000) % 100);
677            else if (device->clock >= 1000000)
678               printf(" @ %d.%02d MHz\n", device->clock / 1000000, (device->clock / 10000) % 100);
679            else if (device->clock >= 1000)
680               printf(" @ %d.%02d kHz\n", device->clock / 1000, (device->clock / 10) % 100);
681            else if (device->clock > 0)
682               printf(" @ %d Hz\n", device->clock);
683            else
684               printf("\n");
685         }
686
687         count++;
688         machine_config_free(config);
689      }
690
691   /* clean up our tracked resources */
692   exit_resource_tracking();
693
694   return (count > 0) ? MAMERR_NONE : MAMERR_NO_SUCH_GAME;
695}
696
697
698/*-------------------------------------------------
642699    info_verifyroms - verify the ROM sets of
643700    one or more games
644701-------------------------------------------------*/
src/emu/state.c
r6740r6741
223223    array of data in memory
224224-------------------------------------------------*/
225225
226void state_save_register_memory(running_machine *machine, const char *module, const char *tag, UINT32 index, const char *name, void *val, UINT32 valsize, UINT32 valcount)
226void state_save_register_memory(running_machine *machine, const char *module, const char *tag, UINT32 index, const char *name, void *val, UINT32 valsize, UINT32 valcount, const char *file, int line)
227227{
228228   state_private *global = machine->state_data;
229229   state_entry **entryptr, *next;
r6740r6741
234234   /* check for invalid timing */
235235   if (!global->reg_allowed)
236236   {
237      logerror("Attempt to register save state entry after state registration is closed! module %s tag %s name %s\n",module, tag, name);
237      logerror("Attempt to register save state entry after state registration is closed!\nFile: %s, line %d, module %s tag %s name %s\n", file, line, module, tag, name);
238238      if (machine->gamedrv->flags & GAME_SUPPORTS_SAVE)
239         fatalerror("Attempt to register save state entry after state registration is closed! module %s tag %s name %s\n", module, tag, name);
239         fatalerror("Attempt to register save state entry after state registration is closed!\nFile: %s, line %d, module %s tag %s name %s\n", file, line, module, tag, name);
240240      global->illegal_regs++;
241241      return;
242242   }
243243
244244   /* create the full name */
245   totalname = astring_alloc();
245   totalname = auto_astring_alloc(machine);
246246   if (tag != NULL)
247247      astring_printf(totalname, "%s/%s/%X/%s", module, tag, index, name);
248248   else
r6740r6741
263263
264264   /* didn't find one; allocate a new one */
265265   next = *entryptr;
266   *entryptr = alloc_clear_or_die(state_entry);
266   *entryptr = auto_alloc_clear(machine, state_entry);
267267
268268   /* fill in the rest */
269269   (*entryptr)->next      = next;
r6740r6741
272272   (*entryptr)->name      = totalname;
273273   (*entryptr)->typesize  = valsize;
274274   (*entryptr)->typecount = valcount;
275   restrack_register_object(OBJTYPE_STATEREG, *entryptr, 0, __FILE__, __LINE__);
276275}
277276
278277
r6740r6741
281280    bitmap to be saved
282281-------------------------------------------------*/
283282
284void state_save_register_bitmap(running_machine *machine, const char *module, const char *tag, UINT32 index, const char *name, bitmap_t *val)
283void state_save_register_bitmap(running_machine *machine, const char *module, const char *tag, UINT32 index, const char *name, bitmap_t *val, const char *file, int line)
285284{
286   state_save_register_memory(machine, module, tag, index, name, val->base, val->bpp / 8, val->rowpixels * val->height);
285   state_save_register_memory(machine, module, tag, index, name, val->base, val->bpp / 8, val->rowpixels * val->height, file, line);
287286}
288287
289288
r6740r6741
312311         fatalerror("Duplicate save state function (%p, %p)", param, func);
313312
314313   /* allocate a new entry */
315   *cbptr = alloc_or_die(state_callback);
314   *cbptr = auto_alloc(machine, state_callback);
316315
317316   /* fill it in */
318317   (*cbptr)->next         = NULL;
319318   (*cbptr)->machine      = machine;
320319   (*cbptr)->func.presave = func;
321320   (*cbptr)->param        = param;
322   restrack_register_object(OBJTYPE_STATEREG, *cbptr, 1, __FILE__, __LINE__);
323321}
324322
325323
r6740r6741
343341         fatalerror("Duplicate save state function (%p, %p)", param, func);
344342
345343   /* allocate a new entry */
346   *cbptr = alloc_or_die(state_callback);
344   *cbptr = auto_alloc(machine, state_callback);
347345
348346   /* fill it in */
349347   (*cbptr)->next          = NULL;
350348   (*cbptr)->machine       = machine;
351349   (*cbptr)->func.postload = func;
352350   (*cbptr)->param         = param;
353   restrack_register_object(OBJTYPE_STATEREG, *cbptr, 2, __FILE__, __LINE__);
354351}
355352
356353
357354
358355/***************************************************************************
359    REGISTRATION FREEING
360***************************************************************************/
361
362/*-------------------------------------------------
363    func_free - free registered functions attached
364    to the current resource tag
365-------------------------------------------------*/
366
367static void func_free(state_callback **rootptr, void *ptr)
368{
369   state_callback **cbptr;
370
371   /* iterate over the function list */
372   for (cbptr = rootptr; *cbptr != NULL; cbptr = &(*cbptr)->next)
373      if (*cbptr == ptr)
374      {
375         state_callback *cb = *cbptr;
376
377         /* de-link us from the list and free our memory */
378         *cbptr = (*cbptr)->next;
379         free(cb);
380         break;
381      }
382}
383
384
385/*-------------------------------------------------
386    state_save_free - free all registrations that
387    have been tagged with the current resource
388    tag
389-------------------------------------------------*/
390
391void state_destructor(void *ptr, size_t size)
392{
393   state_private *global = NULL;
394
395   /* size of 0 means an entry */
396   if (size == 0)
397   {
398      state_entry **entryptr;
399
400      /* iterate over entries */
401      global = ((state_entry *)ptr)->machine->state_data;
402      for (entryptr = &global->entrylist; *entryptr != NULL; entryptr = &(*entryptr)->next)
403         if (*entryptr == ptr)
404         {
405            state_entry *entry = *entryptr;
406
407            /* de-link us from the list and free our memory */
408            *entryptr = (*entryptr)->next;
409            astring_free(entry->name);
410            free(entry);
411            break;
412         }
413   }
414
415   /* size of 1 means a pre function */
416   else if (size == 1)
417   {
418      global = ((state_callback *)ptr)->machine->state_data;
419      func_free(&global->prefunclist, ptr);
420   }
421
422   /* size of 2 means a post function */
423   else if (size == 2)
424   {
425      global = ((state_callback *)ptr)->machine->state_data;
426      func_free(&global->postfunclist, ptr);
427   }
428
429   /* if we're clear of all registrations, reset the invalid counter */
430   if (global != NULL && global->entrylist == NULL && global->prefunclist == NULL && global->postfunclist == NULL)
431      global->illegal_regs = 0;
432}
433
434
435
436/***************************************************************************
437356    PROCESSING HELPERS
438357***************************************************************************/
439358
src/emu/timer.c
r6740r6741
644644   /* if we're not temporary, register ourselves with the save state system */
645645   if (!temp)
646646   {
647      if (!state_save_registration_allowed(machine))
648         fatalerror("timer_alloc() called after save state registration closed! (file %s, line %d)\n", file, line);
647649      timer_register_save(timer);
648650      restrack_register_object(OBJTYPE_TIMER, timer, 0, file, line);
649651   }
src/emu/clifront.h
r6740r6741
5454int cli_info_listcrc(core_options *options, const char *gamename);
5555int cli_info_listroms(core_options *options, const char *gamename);
5656int cli_info_listsamples(core_options *options, const char *gamename);
57int cli_info_listdevices(core_options *options, const char *gamename);
5758
5859#endif   /* __CLIFRONT_H__ */
src/emu/state.h
r6740r6741
6767#define state_save_register_generic(_mach, _mod, _tag, _index, _name, _val, _valsize, _count)       \
6868do {                                                                        \
6969   assert_always(IS_VALID_SAVE_TYPE(_valsize), "Invalid data type supplied for state saving.");   \
70   state_save_register_memory(_mach, _mod, _tag, _index, _name, _val, sizeof(_valsize), _count);   \
70   state_save_register_memory(_mach, _mod, _tag, _index, _name, _val, sizeof(_valsize), _count, __FILE__, __LINE__);   \
7171} while (0)
7272
7373
r6740r6741
8585   state_save_register_item_pointer(_mach, _mod, _tag, _index, _val[0], sizeof(_val)/sizeof(_val[0][0]))
8686
8787#define state_save_register_item_bitmap(_mach, _mod, _tag, _index, _val)   \
88   state_save_register_bitmap(_mach, _mod, _tag, _index, #_val, _val)
88   state_save_register_bitmap(_mach, _mod, _tag, _index, #_val, _val, __FILE__, __LINE__)
8989
9090
9191
r6740r6741
103103   state_save_register_item_pointer((_dev)->machine, device_get_name(_dev), (_dev)->tag, _index, _val[0], sizeof(_val)/sizeof(_val[0][0]))
104104
105105#define state_save_register_device_item_bitmap(_dev, _index, _val)   \
106   state_save_register_bitmap((_dev)->machine, device_get_name(_dev), (_dev)->tag, _index, #_val, _val)
106   state_save_register_bitmap((_dev)->machine, device_get_name(_dev), (_dev)->tag, _index, #_val, _val, __FILE__, __LINE__)
107107
108108
109109
r6740r6741
121121   state_save_register_item_2d_array(_mach, "globals", NULL, 0, _val)
122122
123123#define state_save_register_global_bitmap(_mach, _val) \
124   state_save_register_bitmap(_mach, "globals", NULL, 0, #_val, _val)
124   state_save_register_bitmap(_mach, "globals", NULL, 0, #_val, _val, __FILE__, __LINE__)
125125
126126
127127
r6740r6741
149149int state_save_registration_allowed(running_machine *machine);
150150
151151/* register an array of data in memory */
152void state_save_register_memory(running_machine *machine, const char *module, const char *tag, UINT32 index, const char *name, void *val, UINT32 valsize, UINT32 valcount);
152void state_save_register_memory(running_machine *machine, const char *module, const char *tag, UINT32 index, const char *name, void *val, UINT32 valsize, UINT32 valcount, const char *file, int line);
153153
154154/* register a bitmap to be saved */
155void state_save_register_bitmap(running_machine *machine, const char *module, const char *tag, UINT32 index, const char *name, bitmap_t *val);
155void state_save_register_bitmap(running_machine *machine, const char *module, const char *tag, UINT32 index, const char *name, bitmap_t *val, const char *file, int line);
156156
157157
158158
r6740r6741
166166
167167
168168
169/* ----- registration freeing ----- */
170
171/* free all registrations that have been tagged with the current resource tag */
172void state_destructor(void *ptr, size_t size);
173
174
175
176169/* ----- save state file processing ----- */
177170
178171/* check if a file is a valid save state */
src/emu/romload.c
r6740r6741
12421242static UINT32 normalize_flags_for_cpu(running_machine *machine, UINT32 startflags, const char *rgntag)
12431243{
12441244   const device_config *device = cputag_get_cpu(machine, rgntag);
1245   if (device != NULL)
1245   if (device != NULL && cpu_get_databus_width(device, ADDRESS_SPACE_PROGRAM) != 0)
12461246   {
12471247      int buswidth;
12481248
src/lib/util/pool.c
r6740r6741
138138
139139
140140/*-------------------------------------------------
141    hash_object - compute the hash for a given
142    object
141    get_object_type - return the type entry for
142    a given object type
143143-------------------------------------------------*/
144144
145145INLINE objtype_entry *get_object_type(object_pool *pool, object_type type)
src/mess/video/mbee.c
r6740r6741
4545static UINT8 mbee_pcg_color_latch = 0;
4646
4747UINT8 *mbee_pcgram;
48
48static UINT8 *colorram;
4949static UINT8 mc6845_cursor[16];            // cursor shape
5050static void mc6845_cursor_configure(void);
5151static void mc6845_screen_configure(running_machine *machine);
r6740r6741
7979   if( (m6545_video_bank & 0x01) || (mbee_pcg_color_latch & 0x40) == 0 )
8080      mbee_pcgram[0x0800 | offset] = data;
8181   else
82      space->machine->generic.colorram.u8[offset] = data;
82      colorram[offset] = data;
8383}
8484
8585static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" };
r6740r6741
467467{
468468   UINT8 *ram = memory_region(machine, "maincpu");
469469   machine->generic.videoram.u8 = ram+0x15000;
470   machine->generic.colorram.u8 = ram+0x15800;
470   colorram = ram+0x15800;
471471   mbee_pcgram = ram+0x11000;
472472}
473473
r6740r6741
541541            UINT8 inv=0;
542542            mem = (x + screen_home) & 0x7ff;
543543            chr = screen->machine->generic.videoram.u8[mem];
544            col = screen->machine->generic.colorram.u8[mem] | colourm;               // read a byte of colour
544            col = colorram[mem] | colourm;               // read a byte of colour
545545            if ((x & 15) == 0) keyboard_matrix_r(screen->machine, x);   // actually happens for every scanline of every character, but imposes too much unnecessary overhead */
546546
547547            /* process cursor */
src/mess/video/mz700.c
r6740r6741
4949VIDEO_UPDATE( mz700 )
5050{
5151   int offs;
52   mz_state *mz = screen->machine->driver_data;
5253
5354   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
5455
r6740r6741
5960      sy = (offs / 40) * 8;
6061      sx = (offs % 40) * 8;
6162
62      color = screen->machine->generic.colorram.u8[offs];
63      color = mz->colorram[offs];
6364      code = screen->machine->generic.videoram.u8[offs] | (color & 0x80) << 1;
6465
6566      drawgfx_opaque(bitmap, cliprect, screen->machine->gfx[0], code, color, 0, 0, sx, sy);
src/mess/video/cgenie.c
r6740r6741
283283
284284            /* translate defined character sets */
285285            code += cgenie_font_offset[(code >> 6) & 3];
286            drawgfx_opaque(bitmap, &r, machine->gfx[0], code, machine->generic.colorram.u8[i&0x3ff],
286            drawgfx_opaque(bitmap, &r, machine->gfx[0], code, cgenie_colorram[i&0x3ff],
287287               0, 0, r.min_x, r.min_y);
288288         }
289289
r6740r6741
312312            rc.max_x = r.max_x;
313313            rc.min_y = r.min_y + (crt.cursor_top & 15);
314314            rc.max_y = r.min_y + (crt.cursor_bottom & 15);
315            drawgfx_opaque(bitmap, &rc, machine->gfx[0], 0x7f, machine->generic.colorram.u8[i&0x3ff],
315            drawgfx_opaque(bitmap, &rc, machine->gfx[0], 0x7f, cgenie_colorram[i&0x3ff],
316316               0, 0, rc.min_x, rc.min_y);
317317         }
318318      }
r6740r6741
364364
365365            /* translate defined character sets */
366366            code += cgenie_font_offset[(code >> 6) & 3];
367            drawgfx_opaque(machine->generic.tmpbitmap, &r, machine->gfx[0], code, machine->generic.colorram.u8[i&0x3ff] + 16,
367            drawgfx_opaque(machine->generic.tmpbitmap, &r, machine->gfx[0], code, cgenie_colorram[i&0x3ff] + 16,
368368               0, 0, r.min_x, r.min_y);
369            drawgfx_opaque(dlybitmap, &r, machine->gfx[0], code, machine->generic.colorram.u8[i&0x3ff] + 32,
369            drawgfx_opaque(dlybitmap, &r, machine->gfx[0], code, cgenie_colorram[i&0x3ff] + 32,
370370               0, 0, r.min_x, r.min_y);
371371         }
372372
r6740r6741
396396            rc.min_y = r.min_y + (crt.cursor_top & 15);
397397            rc.max_y = r.min_y + (crt.cursor_bottom & 15);
398398
399            drawgfx_opaque(machine->generic.tmpbitmap, &rc, machine->gfx[0], 0x7f, machine->generic.colorram.u8[i&0x3ff] + 16,
399            drawgfx_opaque(machine->generic.tmpbitmap, &rc, machine->gfx[0], 0x7f, cgenie_colorram[i&0x3ff] + 16,
400400               0, 0, rc.min_x, rc.min_y);
401            drawgfx_opaque(dlybitmap, &rc, machine->gfx[0], 0x7f, machine->generic.colorram.u8[i&0x3ff] + 32,
401            drawgfx_opaque(dlybitmap, &rc, machine->gfx[0], 0x7f, cgenie_colorram[i&0x3ff] + 32,
402402               0, 0, rc.min_x, rc.min_y);
403403         }
404404      }
src/mess/video/aquarius.c
r6740r6741
1111
1212static tilemap *aquarius_tilemap;
1313
14UINT8 *aquarius_colorram;
15
1416static const rgb_t aquarius_colors[] =
1517{
1618   RGB_BLACK,               /* Black */
r6740r6741
7274
7375WRITE8_HANDLER( aquarius_colorram_w )
7476{
75   space->machine->generic.colorram.u8[offset] = data;
77   aquarius_colorram[offset] = data;
7678   tilemap_mark_tile_dirty(aquarius_tilemap, offset);
7779}
7880
r6740r6741
8082{
8183   int bank = 0;
8284   int code = machine->generic.videoram.u8[tile_index];
83   int color = machine->generic.colorram.u8[tile_index];
85   int color = aquarius_colorram[tile_index];
8486   int flags = 0;
8587
8688   SET_TILE_INFO(bank, code, color, flags);
src/mess/video/super80.c
r6740r6741
1919static UINT8 chr,col,gfx,fg,bg;
2020static UINT16 mem,x;
2121static UINT8 options;
22extern UINT8 *super80_colorram;
2223
23
2424/**************************** PALETTES for super80m and super80v ******************************************/
2525
2626static const UINT8 super80_rgb_palette[16*3] =
r6740r6741
307307   if (super80_shared & 4)
308308      return space->machine->generic.videoram.u8[offset];
309309   else
310      return space->machine->generic.colorram.u8[offset];
310      return super80_colorram[offset];
311311}
312312
313313WRITE8_HANDLER( super80v_low_w )
r6740r6741
315315   if (super80_shared & 4)
316316      space->machine->generic.videoram.u8[offset] = data;
317317   else
318      space->machine->generic.colorram.u8[offset] = data;
318      super80_colorram[offset] = data;
319319}
320320
321321READ8_HANDLER( super80v_high_r )
322322{
323323   if (~super80_shared & 4)
324      return space->machine->generic.colorram.u8[0x800+offset];
324      return super80_colorram[0x800+offset];
325325
326326   if (super80_shared & 0x10)
327327      return super80_pcgram[0x800+offset];
r6740r6741
332332WRITE8_HANDLER( super80v_high_w )
333333{
334334   if (~super80_shared & 4)
335      space->machine->generic.colorram.u8[offset+0x800] = data;
335      super80_colorram[offset+0x800] = data;
336336   else
337337   {
338338      space->machine->generic.videoram.u8[offset+0x800] = data;
r6740r6741
429429
430430      if (~options & 0x40)
431431      {
432          col = device->machine->generic.colorram.u8[mem];               /* byte of colour to display */
432          col = super80_colorram[mem];               /* byte of colour to display */
433433         fg = col & 0x0f;
434434         bg = (col & 0xf0) >> 4;
435435      }
src/mess/includes/mz700.h
r6740r6741
4242
4343   int hires_mode;         /* 1 if in 640x200 mode */
4444   int screen;          /* screen designation */
45   UINT8 *colorram;
4546};
4647
4748
src/mess/includes/cgenie.h
r6740r6741
1515WRITE8_DEVICE_HANDLER( cgenie_sh_control_port_w );
1616
1717extern UINT8 *cgenie_fontram;
18extern UINT8 *cgenie_colorram;
1819extern const wd17xx_interface cgenie_wd17xx_interface;
1920
2021extern int cgenie_tv_mode;
src/mess/includes/aquarius.h
r6740r6741
99
1010/*----------- defined in video/aquarius.c -----------*/
1111
12extern UINT8 *aquarius_colorram;
1213WRITE8_HANDLER( aquarius_videoram_w );
1314WRITE8_HANDLER( aquarius_colorram_w );
1415
src/mess/includes/geneve.h
r6740r6741
4343WRITE8_HANDLER ( geneve_peb_mode_cru_w );
4444
4545extern const tms9901_interface tms9901reset_param_ti99;
46void ti99_clk_interrupt_callback(const device_config *device, int state);
4647
4748#endif /* GENEVE_H_ */
src/mess/machine/mz700.c
r6740r6741
8989
9090   machine->generic.videoram_size = 0x800;
9191   machine->generic.videoram.u8 = auto_alloc_array(machine, UINT8, machine->generic.videoram_size);
92   machine->generic.colorram.u8 = auto_alloc_array(machine, UINT8, 0x800);
92   mz->colorram = auto_alloc_array(machine, UINT8, 0x800);
9393}
9494
9595DRIVER_INIT( mz800 )
r6740r6741
101101   /* video ram */
102102   machine->generic.videoram_size = 0x4000;
103103   machine->generic.videoram.u8 = auto_alloc_array(machine, UINT8, machine->generic.videoram_size);
104   machine->generic.colorram.u8 = machine->generic.videoram.u8 + 0x800;
104   mz->colorram = machine->generic.videoram.u8 + 0x800;
105105
106106   /* character generator ram */
107107   mz->cgram = auto_alloc_array(machine, UINT8, 0x1000);
r6740r6741
274274
275275         /* switch in colorram */
276276         memory_install_readwrite_bank(spc, 0xd800, 0xdfff, 0, 0, "bank9");
277         memory_set_bankptr(space->machine, "bank9", space->machine->generic.colorram.u8);
277         memory_set_bankptr(space->machine, "bank9", mz->colorram);
278278
279279         mz->mz700_ram_vram = TRUE;
280280
src/mess/machine/cgenie.c
r6740r6741
2525#define TAPE_HEADER "Colour Genie - Virtual Tape File"
2626
2727UINT8 *cgenie_fontram;
28UINT8 *cgenie_colorram;
2829
2930
3031int cgenie_tv_mode = -1;
r6740r6741
531532
532533 READ8_HANDLER( cgenie_colorram_r )
533534{
534   return space->machine->generic.colorram.u8[offset] | 0xf0;
535   return cgenie_colorram[offset] | 0xf0;
535536}
536537
537538WRITE8_HANDLER( cgenie_colorram_w )
r6740r6741
539540   /* only bits 0 to 3 */
540541   data &= 15;
541542   /* nothing changed ? */
542   if( data == space->machine->generic.colorram.u8[offset] )
543   if( data == cgenie_colorram[offset] )
543544      return;
544545
545546   /* set new value */
546   space->machine->generic.colorram.u8[offset] = data;
547   cgenie_colorram[offset] = data;
547548   /* make offset relative to video frame buffer offset */
548549   offset = (offset + (cgenie_get_register(12) << 8) + cgenie_get_register(13)) & 0x3ff;
549550}
src/mess/machine/super80.c
r6740r6741
1515    d2 super80 screen off (=2mhz) or on (bursts of 2mhz at 50hz = 1mhz) */
1616
1717UINT8 super80_shared=0xff;
18
18UINT8 *super80_colorram;
1919static const device_config *super80_z80pio;
2020static const device_config *super80_speaker;
2121static const device_config *super80_cassette;
r6740r6741
273273{
274274   super80_pcgram = memory_region(machine, "maincpu")+0xf000;
275275   machine->generic.videoram.u8 = memory_region(machine, "maincpu")+0x18000;
276   machine->generic.colorram.u8 = memory_region(machine, "maincpu")+0x1C000;
276   super80_colorram = memory_region(machine, "maincpu")+0x1C000;
277277   driver_init_common(machine);
278278}
279279
src/mess/machine/geneve.c
r6740r6741
8484static int KeyAutoRepeatKey;
8585static int KeyAutoRepeatTimer;
8686
87static void machine_stop_geneve(running_machine *machine);
88
8987/*
9088    GROM support.
9189
r6740r6741
161159   ti99_floppy_controllers_init_all(machine);
162160   ti99_ide_init(machine);
163161   ti99_usbsm_init(machine);
164   add_exit_callback(machine, machine_stop_geneve);
165162
166163   /* set up RAM pointers */
167164   ROM_ptr = memory_region(machine, "maincpu") + offset_rom_geneve;
r6740r6741
239236   if (has_ide)
240237   {
241238      ti99_ide_reset(machine, TRUE);
242      ti99_ide_load_memcard(machine);
243239   }
244240
245241   if (has_usb_sm)
r6740r6741
249245   cputag_reset(machine, "maincpu");
250246}
251247
252static void machine_stop_geneve(running_machine *machine)
253{
254   if (has_ide)
255      ti99_ide_save_memcard();
256}
257
258
259248/*
260249    video initialization.
261250*/
src/mess/machine/99_ide.c
r6740r6741
8787
8888    clock interrupt callback
8989*/
90static void clk_interrupt_callback(running_machine *machine, int state)
90void ti99_clk_interrupt_callback(const device_config *device, int state)
9191{
9292   clk_irq = state;
93   ti99_peb_set_ila_bit(machine, inta_ide_clk_bit, state);
93   ti99_peb_set_ila_bit(device->machine, inta_ide_clk_bit, state);
9494}
9595
9696/*
r6740r6741
9898*/
9999void ti99_ide_init(running_machine *machine)
100100{
101   rtc65271_init(machine, memory_region(machine, region_dsr) + offset_ide_ram2, clk_interrupt_callback);
101//   rtc65271_init(machine, memory_region(machine, region_dsr) + offset_ide_ram2, clk_interrupt_callback);
102102   ti99_ide_RAM = memory_region(machine, region_dsr) + offset_ide_ram;
103103}
104104
r6740r6741
116116   tms9995_mode = in_tms9995_mode;
117117}
118118
119int ti99_ide_load_memcard(running_machine *machine)
120{
121   file_error filerr;
122   mame_file *file;
123
124   filerr = mame_fopen(SEARCHPATH_MEMCARD, "ide.nv", OPEN_FLAG_READ, &file);
125   if (filerr != FILERR_NONE)
126      return /*1*/0;
127   if (rtc65271_file_load(machine, file))
128   {
129      mame_fclose(file);
130      return 1;
131   }
132
133   mame_fclose(file);
134   return 0;
135}
136
137int ti99_ide_save_memcard(void)
138{
139   file_error filerr;
140   mame_file *file;
141
142   /*if (ti99_ide_get_dirty_flag())*/
143   {
144      filerr = mame_fopen(SEARCHPATH_MEMCARD, "ide.nv", OPEN_FLAG_WRITE, &file);
145      if (filerr != FILERR_NONE)
146         return 1;
147      if (rtc65271_file_save(file))
148      {
149         mame_fclose(file);
150         return 1;
151      }
152
153      mame_fclose(file);
154   }
155
156   return 0;
157}
158
159119/*
160120    Read ide CRU interface
161121*/
r6740r6741
224184static READ8_HANDLER(ide_mem_r)
225185{
226186   int reply = 0;
187   const device_config *ide_rtc = devtag_get_device(space->machine, "ide_rtc");
227188
228
229189   if ((offset <= 0xff) && (sram_enable == sram_enable_dip))
230190   {   /* registers */
231191      switch ((offset >> 5) & 0x3)
r6740r6741
233193      case 0:      /* RTC RAM */
234194         if (offset & 0x80)
235195            /* RTC RAM page register */
236            reply = rtc65271_r(1, (offset & 0x1f) | 0x20);
196            reply = rtc65271_xram_r(ide_rtc, (offset & 0x1f) | 0x20);
237197         else
238198            /* RTC RAM read */
239            reply = rtc65271_r(1, offset);
199            reply = rtc65271_xram_r(ide_rtc, offset);
240200         break;
241201      case 1:      /* RTC registers */
242202         if (offset & 0x10)
243203            /* register data */
244            reply = rtc65271_r(0, 1);
204            reply = rtc65271_rtc_r(ide_rtc, 1);
245205         else
246206            /* register select */
247            reply = rtc65271_r(0, 0);
207            reply = rtc65271_rtc_r(ide_rtc, 0);
248208         break;
249209      case 2:      /* IDE registers set 1 (CS1Fx) */
250210         if (tms9995_mode ? (!(offset & 1)) : (offset & 1))
r6740r6741
288248*/
289249static WRITE8_HANDLER(ide_mem_w)
290250{
251   const device_config *ide_rtc = devtag_get_device(space->machine, "ide_rtc");
252
291253   if (cru_register & cru_reg_page_switching)
292254   {
293255      cur_page = (offset >> 1) & page_mask;
r6740r6741
300262      case 0:      /* RTC RAM */
301263         if (offset & 0x80)
302264            /* RTC RAM page register */
303            rtc65271_w(1, (offset & 0x1f) | 0x20, data);
265            rtc65271_xram_w(ide_rtc,(offset & 0x1f) | 0x20, data);
304266         else
305267            /* RTC RAM write */
306            rtc65271_w(1, offset, data);
268            rtc65271_xram_w(ide_rtc,offset, data);
307269         break;
308270      case 1:      /* RTC registers */
309271         if (offset & 0x10)
310272            /* register data */
311            rtc65271_w(0, 1, data);
273            rtc65271_rtc_w(ide_rtc, 1, data);
312274         else
313275            /* register select */
314            rtc65271_w(0, 0, data);
276            rtc65271_rtc_w(ide_rtc, 0, data);
315277         break;
316278      case 2:      /* IDE registers set 1 (CS1Fx) */
317279#if 0
src/mess/machine/ti99_4x.c
r6740r6741
596596
597597   if (has_ide) {
598598      ti99_ide_reset(machine, ti99_model == model_99_8);
599      ti99_ide_load_memcard(machine);
600599   }
601600
602601   if (has_hsgpl)   {
r6740r6741
625624#ifdef UNUSED_FUNCTION
626625void machine_stop_ti99(void)
627626{
628   if (has_ide)
629      ti99_ide_save_memcard();
630
631627   if (has_hsgpl)
632628      ti99_hsgpl_save_memcard();
633629
src/mess/machine/ti99_4x.h
r6740r6741
198198extern const tms9901_interface tms9901reset_param_ti99_4x;
199199extern const tms9901_interface tms9901reset_param_ti99_8;
200200
201void ti99_clk_interrupt_callback(const device_config *device, int state);
src/mess/mess.mak
r6740r6741
8484CPUS += SH4
8585CPUS += DSP32C
8686CPUS += PIC16C5X
87CPUS += PIC16C62X
8788CPUS += G65816
8889CPUS += SPC700
8990CPUS += E1
r6740r6741
188189SOUNDS += K051649
189190#SOUNDS += K053260
190191#SOUNDS += K054539
192#SOUNDS += K056800
191193#SOUNDS += SEGAPCM
192194#SOUNDS += MULTIPCM
193195SOUNDS += SCSP
src/mess/drivers/jaguar.c
r6740r6741
161161   jaguargpu_ctrl_w(cputag_get_cpu(machine, "gpu"), G_CTRL, 0, 0xffffffff);
162162   jaguardsp_ctrl_w(cputag_get_cpu(machine, "audiocpu"), D_CTRL, 0, 0xffffffff);
163163
164   /* init the sound system */
165   cojag_sound_reset(machine);
166
167164   joystick_data = 0xffffffff;
168165   eeprom_bit_count = 0;
169166}
src/mess/drivers/ti99_8.c
r6740r6741
181181#include "machine/smc92x4.h"
182182#include "machine/mm58274c.h"
183183#include "devices/ti99cart.h"
184#include "machine/rtc65271.h"
184185
185186/*
186187    Memory map - see description above
r6740r6741
472473   MDRV_IMPORT_FROM( smc92x4_hd )
473474
474475   MDRV_IDE_HARDDISK_ADD( "ide_harddisk" )
476   MDRV_RTC65271_ADD("ide_rtc", ti99_clk_interrupt_callback)
475477
476478   MDRV_CASSETTE_ADD( "cassette", default_cassette_config )
477479
r6740r6741
525527   MDRV_IMPORT_FROM( smc92x4_hd )
526528
527529   MDRV_IDE_HARDDISK_ADD( "ide_harddisk" )
530   MDRV_RTC65271_ADD("ide_rtc", ti99_clk_interrupt_callback)
528531
529532   MDRV_CASSETTE_ADD( "cassette", default_cassette_config )
530533
src/mess/drivers/x1.c
r6740r6741
228228
229229static DEVICE_START(x1_daisy){}
230230
231static UINT8 *x1_colorram;
231232/*************************************
232233 *
233234 *  Video Functions
r6740r6741
236237
237238static VIDEO_START( x1 )
238239{
239   machine->generic.colorram.u8 = auto_alloc_array(machine, UINT8, 0x1000);
240   x1_colorram = auto_alloc_array(machine, UINT8, 0x1000);
240241   machine->generic.videoram.u8 = auto_alloc_array(machine, UINT8, 0x1000);
241242   gfx_bitmap_ram = auto_alloc_array(machine, UINT8, 0xc000*2);
242243}
r6740r6741
253254      for (x=0;x<40*w;x++)
254255      {
255256         int tile = machine->generic.videoram.u8[(x+(y*40*w)+crtc_start_addr) & screen_mask];
256         int color = machine->generic.colorram.u8[(x+(y*40*w)+crtc_start_addr) & screen_mask] & 0x1f;
257         int width = (machine->generic.colorram.u8[(x+(y*40*w)+crtc_start_addr) & screen_mask] & 0x80)>>7;
258         int height = (machine->generic.colorram.u8[(x+(y*40*w)+crtc_start_addr) & screen_mask] & 0x40)>>6;
259         int pcg_bank = (machine->generic.colorram.u8[(x+(y*40*w)+crtc_start_addr) & screen_mask] & 0x20)>>5;
257         int color = x1_colorram[(x+(y*40*w)+crtc_start_addr) & screen_mask] & 0x1f;
258         int width = (x1_colorram[(x+(y*40*w)+crtc_start_addr) & screen_mask] & 0x80)>>7;
259         int height = (x1_colorram[(x+(y*40*w)+crtc_start_addr) & screen_mask] & 0x40)>>6;
260         int pcg_bank = (x1_colorram[(x+(y*40*w)+crtc_start_addr) & screen_mask] & 0x20)>>5;
260261         UINT8 *gfx_data = pcg_bank ? memory_region(machine, "pcg") : memory_region(machine, "cgrom");
261262
262263         /* skip draw if the x/y values are odd and the width/height is active, */
r6740r6741
984985
985986static UINT16 check_pcg_addr(running_machine *machine)
986987{
987   if(machine->generic.colorram.u8[0x7ff] & 0x20) return 0x7ff;
988   if(machine->generic.colorram.u8[0x3ff] & 0x20) return 0x3ff;
989   if(machine->generic.colorram.u8[0x5ff] & 0x20) return 0x5ff;
990   if(machine->generic.colorram.u8[0x1ff] & 0x20) return 0x1ff;
988   if(x1_colorram[0x7ff] & 0x20) return 0x7ff;
989   if(x1_colorram[0x3ff] & 0x20) return 0x3ff;
990   if(x1_colorram[0x5ff] & 0x20) return 0x5ff;
991   if(x1_colorram[0x1ff] & 0x20) return 0x1ff;
991992
992993   return 0x3ff;
993994}
994995
995996static UINT16 check_chr_addr(running_machine *machine)
996997{
997   if(!(machine->generic.colorram.u8[0x7ff] & 0x20)) return 0x7ff;
998   if(!(machine->generic.colorram.u8[0x3ff] & 0x20)) return 0x3ff;
999   if(!(machine->generic.colorram.u8[0x5ff] & 0x20)) return 0x5ff;
1000   if(!(machine->generic.colorram.u8[0x1ff] & 0x20)) return 0x1ff;
998   if(!(x1_colorram[0x7ff] & 0x20)) return 0x7ff;
999   if(!(x1_colorram[0x3ff] & 0x20)) return 0x3ff;
1000   if(!(x1_colorram[0x5ff] & 0x20)) return 0x5ff;
1001   if(!(x1_colorram[0x1ff] & 0x20)) return 0x1ff;
10011002
10021003   return 0x3ff;
10031004}
r6740r6741
13191320   else if(offset >= 0x1fa8 && offset <= 0x1fab)   { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x1fa8); }
13201321//  else if(offset >= 0x1fd0 && offset <= 0x1fdf)   { return x1_scrn_r(space,offset-0x1fd0); }
13211322//  else if(offset == 0x1fe0)                       { return x1_blackclip_r(space,0); }
1322   else if(offset >= 0x2000 && offset <= 0x2fff)   { return space->machine->generic.colorram.u8[offset-0x2000]; }
1323   else if(offset >= 0x2000 && offset <= 0x2fff)   { return x1_colorram[offset-0x2000]; }
13231324   else if(offset >= 0x3000 && offset <= 0x3fff)   { return space->machine->generic.videoram.u8[offset-0x3000]; }
13241325   else if(offset >= 0x4000 && offset <= 0xffff)   { return gfx_bitmap_ram[offset-0x4000+(scrn_reg.gfx_bank*0xc000)]; }
13251326   else
r6740r6741
13601361//  else if(offset == 0x1fc5)                       { x1turbo_gfxpal_w(space,0,data); }
13611362   else if(offset >= 0x1fd0 && offset <= 0x1fdf)   { x1_scrn_w(space,0,data); }
13621363//  else if(offset == 0x1fe0)                       { x1_blackclip_w(space,0,data); }
1363   else if(offset >= 0x2000 && offset <= 0x2fff)   { space->machine->generic.colorram.u8[offset-0x2000] = data; }
1364   else if(offset >= 0x2000 && offset <= 0x2fff)   { x1_colorram[offset-0x2000] = data; }
13641365   else if(offset >= 0x3000 && offset <= 0x3fff)   { space->machine->generic.videoram.u8[offset-0x3000] = pcg_write_addr = data; }
13651366   else if(offset >= 0x4000 && offset <= 0xffff)   { gfx_bitmap_ram[offset-0x4000+(scrn_reg.gfx_bank*0xc000)] = data; }
13661367   else
r6740r6741
13931394   else if(offset == 0x1fc5)                  { return x1turbo_gfxpal_r(space,0); }
13941395//  else if(offset >= 0x1fd0 && offset <= 0x1fdf)   { return x1_scrn_r(space,offset-0x1fd0); }
13951396   else if(offset == 0x1fe0)                  { return x1_blackclip_r(space,0); }
1396   else if(offset >= 0x2000 && offset <= 0x2fff)   { return space->machine->generic.colorram.u8[offset-0x2000]; }
1397   else if(offset >= 0x2000 && offset <= 0x2fff)   { return x1_colorram[offset-0x2000]; }
13971398   else if(offset >= 0x3000 && offset <= 0x3fff)   { return space->machine->generic.videoram.u8[offset-0x3000]; }
13981399   else if(offset >= 0x4000 && offset <= 0xffff)   { return gfx_bitmap_ram[offset-0x4000+(scrn_reg.gfx_bank*0xc000)]; }
13991400   else
r6740r6741
14371438   else if(offset == 0x1fc5)                  { x1turbo_gfxpal_w(space,0,data); }
14381439   else if(offset >= 0x1fd0 && offset <= 0x1fdf)   { x1_scrn_w(space,0,data); }
14391440   else if(offset == 0x1fe0)                  { x1_blackclip_w(space,0,data); }
1440   else if(offset >= 0x2000 && offset <= 0x2fff)   { space->machine->generic.colorram.u8[offset-0x2000] = data; }
1441   else if(offset >= 0x2000 && offset <= 0x2fff)   { x1_colorram[offset-0x2000] = data; }
14411442   else if(offset >= 0x3000 && offset <= 0x3fff)   { space->machine->generic.videoram.u8[offset-0x3000] = pcg_write_addr = data; }
14421443   else if(offset >= 0x4000 && offset <= 0xffff)   { gfx_bitmap_ram[offset-0x4000+(scrn_reg.gfx_bank*0xc000)] = data; }
14431444   else
src/mess/drivers/ng_aes.c
r6740r6741
114114}
115115
116116
117void neogeo_set_display_position_interrupt_control(UINT16 data)
117void neogeo_set_display_position_interrupt_control(running_machine *machine,UINT16 data)
118118{
119119   display_position_interrupt_control = data;
120120}
r6740r6741
764764      case 0x01: set_main_cpu_vector_table_source(space->machine, bit);
765765               set_audio_cpu_rom_source(space, bit); /* this is a guess */
766766               break;
767      case 0x05: neogeo_set_fixed_layer_source(bit); break;
767      case 0x05: neogeo_set_fixed_layer_source(space->machine,bit); break;
768768      case 0x06: set_save_ram_unlock(bit); break;
769769      case 0x07: neogeo_set_palette_bank(space->machine, bit); break;
770770
r6740r6741
855855      system_control_w(space, offs, 0, 0x00ff);
856856   device_reset(cputag_get_cpu(machine, "maincpu"));
857857
858   neogeo_reset_rng();
858   neogeo_reset_rng(machine);
859859
860860   start_interrupt_timers(machine);
861861
r6740r6741
863863   update_interrupts(machine);
864864
865865   /* AES apparently always uses the cartridge's fixed bank mode */
866   neogeo_set_fixed_layer_source(1);
866   neogeo_set_fixed_layer_source(machine,1);
867867}
868868
869869
src/mess/drivers/cgenie.c
r6740r6741
4343//  AM_RANGE(0x4000, 0xbfff) AM_RAM // set up in MACHINE_START
4444//  AM_RANGE(0xc000, 0xdfff) AM_ROM // installed in cgenie_init_machine
4545//  AM_RANGE(0xe000, 0xefff) AM_ROM // installed in cgenie_init_machine
46   AM_RANGE(0xf000, 0xf3ff) AM_READWRITE( cgenie_colorram_r, cgenie_colorram_w ) AM_BASE_GENERIC( colorram )
46   AM_RANGE(0xf000, 0xf3ff) AM_READWRITE( cgenie_colorram_r, cgenie_colorram_w ) AM_BASE( &cgenie_colorram )
4747   AM_RANGE(0xf400, 0xf7ff) AM_READWRITE( cgenie_fontram_r, cgenie_fontram_w) AM_BASE( &cgenie_fontram )
4848   AM_RANGE(0xf800, 0xf8ff) AM_READ( cgenie_keyboard_r )
4949   AM_RANGE(0xf900, 0xffdf) AM_NOP
src/mess/drivers/aquarius.c
r6740r6741
232232static ADDRESS_MAP_START( aquarius_mem, ADDRESS_SPACE_PROGRAM, 8 )
233233   AM_RANGE(0x0000, 0x1fff) AM_ROM
234234   AM_RANGE(0x3000, 0x33ff) AM_RAM_WRITE(aquarius_videoram_w) AM_BASE_SIZE_GENERIC(videoram)
235   AM_RANGE(0x3400, 0x37ff) AM_RAM_WRITE(aquarius_colorram_w) AM_BASE_GENERIC(colorram)
235   AM_RANGE(0x3400, 0x37ff) AM_RAM_WRITE(aquarius_colorram_w) AM_BASE(&aquarius_colorram)
236236   AM_RANGE(0x3800, 0x3fff) AM_RAM
237237   AM_RANGE(0x4000, 0xbfff) AM_NOP /* expansion ram */
238238   AM_RANGE(0xc000, 0xffff) AM_READ(cartridge_r)
src/mess/drivers/geneve.c
r6740r6741
218218#include "machine/idectrl.h"
219219#include "machine/smc92x4.h"
220220#include "machine/mm58274c.h"
221#include "machine/rtc65271.h"
221222
222
223223/*
224224    memory map
225225*/
r6740r6741
510510   MDRV_IMPORT_FROM( smc92x4_hd )
511511
512512   MDRV_IDE_HARDDISK_ADD( "ide_harddisk" )
513   MDRV_RTC65271_ADD("ide_rtc", ti99_clk_interrupt_callback)
513514
514515   /* rtc */
515516   MDRV_MM58274C_ADD("mm58274c", geneve_mm58274c_interface)
src/mess/drivers/ti99_4p.c
r6740r6741
5858#include "devices/harddriv.h"
5959#include "machine/idectrl.h"
6060#include "machine/smc92x4.h"
61#include "machine/rtc65271.h"
6162
6263static ADDRESS_MAP_START(memmap, ADDRESS_SPACE_PROGRAM, 16)
6364   AM_RANGE(0x0000, 0x1fff) AM_ROMBANK("bank1")                        /*system ROM*/
r6740r6741
297298   MDRV_IMPORT_FROM( smc92x4_hd )
298299
299300   MDRV_IDE_HARDDISK_ADD( "ide_harddisk" )
301   MDRV_RTC65271_ADD("ide_rtc", ti99_clk_interrupt_callback)
300302
301303   /* MDRV_CASSETTE_ADD( "cassette", default_cassette_config ) */
302304
src/mess/drivers/ti99_4x.c
r6740r6741
4141#include "machine/idectrl.h"
4242#include "machine/smc92x4.h"
4343#include "machine/mm58274c.h"
44
44#include "machine/rtc65271.h"
4545#include "devices/ti99cart.h"
4646
4747/*
r6740r6741
561561
562562   MDRV_IMPORT_FROM( smc92x4_hd )
563563
564   MDRV_IDE_HARDDISK_ADD( "ide_harddisk" )
564   MDRV_IDE_HARDDISK_ADD( "ide_harddisk" )   
565   MDRV_RTC65271_ADD("ide_rtc", ti99_clk_interrupt_callback)
565566
566567   MDRV_CASSETTE_ADD( "cassette1", default_cassette_config )
567568   MDRV_CASSETTE_ADD( "cassette2", default_cassette_config )
r6740r6741
615616   MDRV_IMPORT_FROM( smc92x4_hd )
616617
617618   MDRV_IDE_HARDDISK_ADD( "ide_harddisk" )
619   MDRV_RTC65271_ADD("ide_rtc", ti99_clk_interrupt_callback)
618620
619621   MDRV_CASSETTE_ADD( "cassette1", default_cassette_config )
620622   MDRV_CASSETTE_ADD( "cassette2", default_cassette_config )
r6740r6741
667669   MDRV_IMPORT_FROM( smc92x4_hd )
668670
669671   MDRV_IDE_HARDDISK_ADD( "ide_harddisk" )
672   MDRV_RTC65271_ADD("ide_rtc", ti99_clk_interrupt_callback)
670673
671674   MDRV_CASSETTE_ADD( "cassette1", default_cassette_config )
672675   MDRV_CASSETTE_ADD( "cassette2", default_cassette_config )
r6740r6741
721724   MDRV_IMPORT_FROM( smc92x4_hd )
722725
723726   MDRV_IDE_HARDDISK_ADD( "ide_harddisk" )
727   MDRV_RTC65271_ADD("ide_rtc", ti99_clk_interrupt_callback)
724728
725729   MDRV_CASSETTE_ADD( "cassette1", default_cassette_config )
726730   MDRV_CASSETTE_ADD( "cassette2", default_cassette_config )
r6740r6741
782786   MDRV_IMPORT_FROM( smc92x4_hd )
783787
784788   MDRV_IDE_HARDDISK_ADD( "ide_harddisk" )
789   MDRV_RTC65271_ADD("ide_rtc", ti99_clk_interrupt_callback)
785790
786791   MDRV_CASSETTE_ADD( "cassette1", default_cassette_config )
787792   MDRV_CASSETTE_ADD( "cassette2", default_cassette_config )
docs/messnew.txt
r6740r6741
127127
128128Source Changes:
129129----------------
130- The core is based on MAME 0.135u3.  This incorporates all features of the
130- The core is based on MAME 0.135u4.  This incorporates all features of the
131131  update to this core.  [MAME team]
132132
133133- Cleanups (static qualifiers, headers, renames, reduced global symbols, dead
makefile
r6740r6741
365365# add core include paths
366366CCOMFLAGS += \
367367   -I$(SRC)/$(TARGET) \
368   -I$(SRC)/$(TARGET)/includes \
369368   -I$(OBJ)/$(TARGET)/layout \
370369   -I$(SRC)/emu \
371370   -I$(OBJ)/emu \

Previous 15994 Revisions Next


© 1998-2018 The MESS Team